Skip to content
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

[SPIR-V] Support EvaluateAttribute* intrinsics #3649

Closed
jaebaek opened this issue Mar 31, 2021 · 4 comments · Fixed by #6945
Closed

[SPIR-V] Support EvaluateAttribute* intrinsics #3649

jaebaek opened this issue Mar 31, 2021 · 4 comments · Fixed by #6945
Assignees
Labels
spirv Work related to SPIR-V

Comments

@jaebaek
Copy link
Collaborator

jaebaek commented Mar 31, 2021

Currently, SPIR-V backend does not support EvaluateAttribute* intrinsics.

According to the discussion in KhronosGroup/glslang#2584, OpInterpolate* needs a pointer operand rather than OpLoad. Based on the offline discussion with @greg-lunarg we need a spirv-opt pass to replace OpLoad operand of OpInterpolate* to the pointer loaded by the OpLoad.

When a spirv-opt pass is prepared, we can simply let DXC emit OpInterpolate* for EvaluateAttribute*. Since it will just follow typical code generation routine, it will use OpLoad for its operand. We can rely on the spirv-opt pass to make it correct (as a part of the legalization pass).

@jaebaek jaebaek added the spirv Work related to SPIR-V label Mar 31, 2021
@jaebaek jaebaek self-assigned this Mar 31, 2021
@jaebaek
Copy link
Collaborator Author

jaebaek commented Mar 31, 2021

KhronosGroup/SPIRV-Tools#4220 is the spirv-opt PR.

@jaebaek
Copy link
Collaborator Author

jaebaek commented Jul 13, 2021

We have two use three instructions InterpolateAtCentroid, InterpolateAtSample, and InterpolateAtOffset of GLSL.std.450 extended instruction set for corresponding EvaluateAttribute*.

@gjaegy
Copy link

gjaegy commented Jan 6, 2022

We are also relying on EvaluateAttributeAtSample() HLSL instruction in our code. This is now the only thing we haven't been able to port to Vulkan. Not dramatic, but our tree shadows looked better in D3D11, what is a bit frustrating.

Is there any update on that issue ?

Thanks a lot !

@pdoane
Copy link

pdoane commented Apr 6, 2022

I'm also interested in this. I tried using the SPIR-V intrinsics but not sure how to get the interpolant into the Input storage class. Here is what I tried:

[[vk::ext_capability(/* InterpolationFunction */ 52)]]
[[vk::ext_instruction(/* InterpolateAtSample */ 77, "GLSL.std.450")]]
float2 InterpolateAtSample([[vk::ext_reference]] float2 x, uint);

which outputs:

fatal error: generated SPIR-V is invalid: GLSL.std.450 InterpolateAtSample: expected Interpolant storage class to be Input
  %76 = OpExtInst %v2float %1 InterpolateAtSample %75 %70

@damyanp damyanp moved this to For Google in HLSL Triage Jul 10, 2024
@s-perron s-perron added this to the Next Release milestone Aug 22, 2024
@s-perron s-perron moved this from For Google to Triaged in HLSL Triage Aug 22, 2024
@s-perron s-perron moved this from New to In progress in HLSL Roadmap Sep 5, 2024
cassiebeckley added a commit to cassiebeckley/SPIRV-Tools that referenced this issue Sep 26, 2024
The GLSL 450 InterpolateAt* instructions should be treated as a load by
dead code elimination. This is part of
microsoft/DirectXShaderCompiler#3649.
cassiebeckley added a commit to KhronosGroup/SPIRV-Tools that referenced this issue Sep 26, 2024
The GLSL 450 InterpolateAt* instructions should be treated as a load by dead code elimination. This is part of microsoft/DirectXShaderCompiler#3649.
cassiebeckley added a commit to cassiebeckley/DirectXShaderCompiler that referenced this issue Oct 4, 2024
Emits SPIR-V InterpolateAt* instructions from the GLSL.std.450 extended
instruction set for EvaluateAttribute*. Relies on the optimizer's copy
propagate passes to ensure that these instructions are passed valid
pointers in the Input storage class after legalization.

Fixes microsoft#3649
cassiebeckley added a commit to cassiebeckley/DirectXShaderCompiler that referenced this issue Oct 4, 2024
Emits SPIR-V InterpolateAt* instructions from the GLSL.std.450 extended
instruction set for EvaluateAttribute*. Relies on the optimizer's copy
propagate passes to ensure that these instructions are passed valid
pointers in the Input storage class after legalization.

Fixes microsoft#3649
@github-project-automation github-project-automation bot moved this from In progress to Done in HLSL Roadmap Oct 8, 2024
Keenuts pushed a commit to Keenuts/SPIRV-Tools that referenced this issue Nov 12, 2024
The GLSL 450 InterpolateAt* instructions should be treated as a load by dead code elimination. This is part of microsoft/DirectXShaderCompiler#3649.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spirv Work related to SPIR-V
Projects
Status: Done
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants