-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Frag depth #1263
base: master
Are you sure you want to change the base?
Frag depth #1263
Conversation
The PR needs several fixes. |
I quickly tested the changes with this : Also it would be nice to either forbid reading to fragDepth in the checker, since SV_Depth is write-only or create an intermediate value that can be read and rewritten multiple times that will write to fragDepth at the end of the shader. |
Sure thing, I'll go about fixing that. |
@TothBenoit I've added a reference for hasSideEffects and had to add a force inclusion in the linker for this to work. But I don't know if this would be the correct way. Also shader doesn't like when I assign a variable instead to fragDepth class CustomDepth extends hxsl.Shader { static var SRC = { function fragment() { var x = 0.5; fragDepth = x; } } } Crashes in compiler. I don't know how to proceed from here. |
Look at the way discard is implemented.
Le mar. 21 janv. 2025, 14:06, Rasmus Brinck ***@***.***> a
écrit :
… @TothBenoit <https://github.com/TothBenoit> I've added a reference for
hasSideEffects and had to add a force inclusion in the linker for this to
work. But I don't know if this would be the correct way. Also shader
doesn't like when I assign a variable instead to fragDepth
class CustomDepth extends hxsl.Shader { static var SRC = { function
fragment() { var x = 0.5; fragDepth = x; } } }
Crashes in compiler.
I don't know how to proceed from here.
—
Reply to this email directly, view it on GitHub
<#1263 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHZXQHSSMAHWW5DDKSS2Y32LZA5RAVCNFSM6AAAAABVL3U62KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMBUGY4DKNJUGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@ncannasse I did that and it seems to work fine other than it for some reason can't be assigned a variable. |
I have tried to add a readdependency but assigned variable still gets filtered out before (i think) dce. I'm trying to get a dependency going marking my variable "x" in testshader above as dependent but so far I have failed. Do you have any ideas on how to solve this? |
Ping @TothBenoit , do you have time to help me out here? Would be much appreciated! |
Hello,
This will force the DCE to keep expression e2. However, I just realised that we should only keep the last assignment to fragDepth.
This could be done by marking only the last assignment to fragDepth as having a side effect in the checker, and making sure that the fragDepth assignment has a side effect in the DCE. |
I have updated now ackording to the suggestions. To be able to distinguish between fragdepth writes I had to create a common variable id for it.
|
Just tested it, works fine with GL. However, it crashes on DirectX 11 and 12. SV_Depth is not a variable, it is a semantic name : You need to declare a new output for the fragment. See FragCoord in HlslOut.hx for a similar case. |
@TothBenoit Thank you for your reply. I have removed the Hlsl-lines due to no knowledge in DX and I have no stable environment to test this properly. Thank you for you invaluable knowledge. I'm letting the next person do the DX implementation of this. Are we fine to merge this @ncannasse ? |
GLSL Has a writeable global for writing directly to the depthbuffer.
SV_Depth seems to be the same in HLSL.