-
Notifications
You must be signed in to change notification settings - Fork 569
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
WIP: Workaround AccessChain function arguments for DebugDeclare #5275
Conversation
Substitute variables for access chain function arguments. For each function argument that is an access chain, create a new variable, copy the access chain pointee into the variable before the function call, substitute the variable in the function call, and copy the variable back into the access chain pointee after the function call. This is a workaround for NonSemantic.Shader.DebugInfo.100. DebugDeclare expects the operand variable to be a result id of an OpVariable or OpFunctionParameter. However, function arguments may contain OpAccessChains during legalization which causes problems for DebugDeclare.
@s-perron I've been picking @greg-lunarg's brain for ideas to fix this bug and this is the approach we arrived at. Can you take a look and let us know what you think? |
Thanks for asking. I do not believe that this solution is correct. The problem is that passing in the address of a different variable and doing a copy-in/copy-out is different than passing in the address of a variable. You can see microsoft/DirectXShaderCompiler#5158 for a discussion on how this could make a difference. Could you use Indexes in the debug declare to represent the variable? If parameter is a series of OpAccessChains, then the debug declare that is generated should contains the base variable for the |
Here is a specific example. I may also show some other difficulties with your solution. If you change the parameter to be a pointer to a function scope variable, then the store to The other problem (potentially I did not read your code too carefully) is that the access chain in
|
Thanks @s-perron. I've taken a look at DXC #5158. I agree that fixing this issue at the root is a better solution. @llvm-beanz has begun this work on this branch. |
Hi, I'm one of the two people who have this issue in the AnyHit shader, trying to output variables to the ray payload when the ray is stopped (so the caller can do something with data stored in the payload). It looks like work on that branch stopped two months ago, was the actual fix implemented? It's unclear what the outcome of all this is at this point. Thanks |
@BattleAxeVR This would not have fixed your problem. This PR would have tried to fix the error caused by inlining. It would have created a new temporary variable, and it would have cause the payload to not be written to until we returned from the function. The solution for your problem will be the implementation of the c++ references. I'm not sure how far away that is. microsoft/DirectXShaderCompiler#5675 might be able to help you as well, but that will not be official, and not supported by the DXC maintainers. |
Fix DXC issue #5191.
Substitute variables for access chain function arguments. For each function argument that is an access chain, create a new variable, copy the access chain pointee into the variable before the function call, substitute the variable in the function call, and copy the variable back into the access chain pointee after the function call.
This is a workaround for NonSemantic.Shader.DebugInfo.100. DebugDeclare expects the operand variable to be a result id of an OpVariable or OpFunctionParameter. However, function arguments may contain OpAccessChains during legalization which causes problems for DebugDeclare.