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

Warn users when a derivative or quad op is used after a discard/terminateInvocation call #3818

Open
Tobski opened this issue Dec 18, 2024 · 0 comments

Comments

@Tobski
Copy link
Contributor

Tobski commented Dec 18, 2024

In HLSL, the discard keyword is specified to demote the invocation rather than terminating it, meaning that quad ops or derivatives remain well defined after a discard.

However, in GLSL, discard (or terminateInvocation) both cause the invocation to stop executing, resulting in undefined values or undefined behavior for subsequent quad or derivative operations if the entire quad (or primitive in some cases) was not discarded/terminated.

Detecting non uniformity conditions is beyond the scope of what glsl can provide currently, so an outright error isn't plausible as things currently stand, but it might be useful to emit a warning to at least give developers a heads up that this will happen. Actual validation errors will have to be handled via GPU AV in the Vulkan validation layers.

So I'd like to suggest we add a warning to glslang if there is a discard or terminateInvocation call, followed by any subgroupQuad* or implicit derivative texturing operation later in the shader in any fragment shader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant