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

HLSL: way to treat discard as OpDemoteToHelperInvocation without requiring SPIR-V 1.6/Vulkan 1.3 #3297

Closed
danginsburg opened this issue Oct 27, 2023 · 4 comments · Fixed by #4254
Assignees
Labels
goal:client support Feature or fix needed for a current slang user. priority:medium nice to have in next milestone

Comments

@danginsburg
Copy link

In DXC, there is an option to treat discard as OpDemoteToHelperInvocation -fspv-extension=SPV_EXT_demote_to_helper_invocation. This is needed because OpKill can lead to undefined behavior in derivatives following the kill if it's executed outside of uniform flow control (OpKill is basically broken and has been deprecated). Could we get an option like -fspv-extension=SPV_EXT_demote_to_helper_invocation so that that even for example for SPIR-V 1.3 we use the extension, i.e.:

               OpExtension "SPV_EXT_demote_to_helper_invocation"

...
               %7118 = OpLabel
               OpDemoteToHelperInvocation
               OpBranch %19382

Also, I noticed that DXC treats clip(x) as OpKill even under this option. I'm not sure if that's a bug with DXC, but it seems like probably clip and discard should be treated the same?

Some background: microsoft/DirectXShaderCompiler#2823

@danginsburg
Copy link
Author

I also filed an issue on DXC for the clip question: microsoft/DirectXShaderCompiler#5937

@csyonghe csyonghe added the priority:medium nice to have in next milestone label Nov 28, 2023
@natduca natduca added this to the Q1 2024 (Winter) milestone Nov 30, 2023
@natduca
Copy link

natduca commented Nov 30, 2023

Putting q2 actually b/c we want to do it in Q1 but likely blocked on capability system...

@csyonghe
Copy link
Collaborator

Blocked by #3371

@swoods-nv swoods-nv added the goal:client support Feature or fix needed for a current slang user. label Feb 22, 2024
@csyonghe
Copy link
Collaborator

csyonghe commented Jun 1, 2024

This is now implemented. You can opt in to this behavior with
-profile spirv_1_4+SPV_EXT_demote_to_helper_invocation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:client support Feature or fix needed for a current slang user. priority:medium nice to have in next milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants