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

Make gl_HitT proper aliases of gl_RayTmax #2910

Merged
merged 1 commit into from May 24, 2024

Conversation

Max-Andersson
Copy link
Contributor

In #2759, a mechanism to better handle the aliased builtin variables gl_VertexID and gl_VertexIndex (and their Instance counterparts) was committed. There is a similar problem for gl_HitTEXT and gl_RayTmaxEXT (and their NV counterparts), where they end up handled as duplicated variables and SPIR-V generation ends up creating two OpVariables with the same builtin decoration.

This PR simply makes use of the RetargetVariable code from #2759, as well as remove some then redundant code for handling gl_HitT.

@CLAassistant
Copy link

CLAassistant commented Mar 22, 2022

CLA assistant check
All committers have signed the CLA.

@greg-lunarg greg-lunarg self-requested a review March 24, 2022 22:33
@greg-lunarg greg-lunarg added the kokoro:run Trigger Google bot runs label Mar 25, 2022
@kokoro-team kokoro-team removed the kokoro:run Trigger Google bot runs label Mar 25, 2022
@greg-lunarg
Copy link
Contributor

greg-lunarg commented Mar 25, 2022

By my reading, gl_HitTNV and gl_RayTmaxNV are not aliases in GL_NV_ray_tracing. Likewise HitTNV and RayTmaxNV are different things in SPV_NV_ray_tracing. So this should not cause changes for GL_NV_ray_tracing shaders targeting SPV_NV_ray_tracing. Right?

Yet I am seeing, for example, changes for spv.AnyHitShader.rahit test which is a GL_NV_ray_tracing shader targeting SPV_NV_ray_tracing.

Should this be changing? Or am I misunderstanding something here?

@Max-Andersson
Copy link
Contributor Author

I see, indeed the SPIR-V has two distinct decorations for the two in NV, unlike the EXT versions which only has RayTmaxKHR. I'll revert the changes to the NV variables, thanks for pointing it out!

@arcady-lunarg
Copy link
Contributor

@Max-Andersson do you plan to pick this back up at some point?

@arcady-lunarg
Copy link
Contributor

@greg-lunarg Looking at the GLSL_NV_ray_tracing spec, it does say "gl_HitTNV is available only in the any-hit and closest-hit shaders. This is an alias of gl_RayTmaxNV added to closest-hit and any-hit shaders for convenience." (line 657 here: https://github.com/KhronosGroup/GLSL/blob/master/extensions/nv/GLSL_NV_ray_tracing.txt). Seems like the specs are somewhat ambivalent on the issue.

@spencer-lunarg
Copy link
Contributor

Update - from https://gitlab.khronos.org/vulkan/vulkan/-/issues/3885 that these should be alias (for KHR version as well)

There is a upcoming spirv-val that will enforce this to be alias otherwise it will be invalid SPIR-V
KhronosGroup/SPIRV-Tools#5678

Changes the gl_HitT builtins properly alias
their gl_RayTmax. Previously they ended up as
duplicate variables, rather than aliased.
@arcady-lunarg
Copy link
Contributor

I've rebased the PR on top of main.

@arcady-lunarg arcady-lunarg added the kokoro:run Trigger Google bot runs label May 24, 2024
@kokoro-team kokoro-team removed the kokoro:run Trigger Google bot runs label May 24, 2024
@arcady-lunarg arcady-lunarg merged commit 1cad045 into KhronosGroup:main May 24, 2024
28 checks passed
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

Successfully merging this pull request may close these issues.

None yet

6 participants