-
Notifications
You must be signed in to change notification settings - Fork 858
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
HLSL: EvaluateAttributeAtSample gives error for valid HLSL code. #2584
Comments
The mechanism that maps members of PS_INPUT onto their true built-in identities somehow got missed. So i.vPositionOs was just looking like a function scope struct member rather than a texcoord input variable. |
There is a reason this doesn't currently work. There is a general mechanism that @loopdawg created to propagate built-in interpolants from their input structures into the texture operations that use them. It involves a wrapper function around main and inlining from spirv-opt. Unfortunately, this mechanism doesn't quite work for the There are two ways to solve this. One way is to get the SPIR-V WG to define new versions of The other solution is to try to come up with a new mechanism that somehow propagates pointers instead of values. This would be a very invasive change that would likely touch every texture operation. The idea of destabilizing the entire world to make a fairly marginal operation work seems to go against basic engineering principles. So I am thinking we talk to the SPIR-V workgroup about defining a new set of |
@greg-lunarg I don't know if I understand the specific issue here, but assuming DXC supports this as-is it seems unlikely we'd be able to convince the SPIR-V WG to create a new SPIR-V extension to make up for glslang internal architecture issues? I also don't know how useful that would be if it would require driver changes since we'd need this to work on today's drivers. I can respect it potentially not making sense to fix this in the HLSL frontend of glslang but unless I'm missing something I don't see how proposing a SPIR-V extension makes sense. |
OK, I think I have a good third solution. For HLSL, glslang will generate the This solution would use the existing glslang interpolant propagation mechanism, so no changes there. Since the fixup would happen as part of legalization, the "invalid" version would never see the light of day. I could probably also rig up some fairly simple code so that the new fixup pass would ONLY be run if I am fairly certain you will be ok with this approach and will pursue this solution unless you come up with a show-stopper issue. |
If people really had a problem with the "invalid" form of the I am fairly certain this will not be necessary, but we could use it as a fallback position in case there are objections or problems. I will probably bounce this design off the other spirv-opt folks and make sure they don't see any immediate problems. |
Generate load of interpolant for first operand to GLSLstd450 InterpolateAt* SPIR-V ops. This allows the interpolants to propagate from the input struct in the wrapper around main into the shader during HLSL legalization. A new pass has been added to legalization which will remove the load and replace with the pointer of the load to create valid external interpolate op. Fixes KhronosGroup#2584
Generate load of interpolant for first operand to GLSLstd450 InterpolateAt* SPIR-V ops. This allows the interpolants to propagate from the input struct in the wrapper around main into the shader during HLSL legalization. A new pass has been added to legalization which will remove the load and replace with the pointer of the load to create valid external interpolate op. Fixes KhronosGroup#2584
The following shader fails to compile with glslangValidator:
glslangValidator -D -V -S frag -E MainPs test.hlsl produces:
ERROR: test.hlsl:12: 'EvaluateAttributeAtSample' : first argument must be an interpolant, or interpolant-array element
ERROR: test.hlsl:12: 'for sub-statement' : Expected
test.hlsl(12): error at column 67, HLSL parsing failed.
ERROR: 3 compilation errors. No code generated.
Compiles correctly with fxc.exe /Tps_5_0 /EMainPs test.hlsl
The text was updated successfully, but these errors were encountered: