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

terminateRayEXT & ignoreIntersectionEXT not recognized in GLSL compatibility mode #5946

Closed
juliusikkala opened this issue Dec 28, 2024 · 2 comments · Fixed by #5974
Closed

Comments

@juliusikkala
Copy link
Contributor

When attempting to compile the following any-hit shader in GLSL compatibility mode (e.g. slangc -allow-glsl -target spirv -entry main -O2 test.rahit -o test.spv), the terminateRayEXT and ignoreIntersectionEXT keywords are not recognized by slangc.

// test.rahit
#version 460
#extension GL_EXT_ray_tracing : require

void main()
{
    terminateRayEXT;
    ignoreIntersectionEXT;
}

Output:

test.rahit(7): error 30015: undefined identifier 'terminateRayEXT'.
    terminateRayEXT;
    ^~~~~~~~~~~~~~~
test.rahit(8): error 30015: undefined identifier 'ignoreIntersectionEXT'.
    ignoreIntersectionEXT;
    ^~~~~~~~~~~~~~~~~~~~~
@juliusikkala
Copy link
Contributor Author

juliusikkala commented Dec 29, 2024

These two are conspicuously missing from glsl.meta.slang, probably because they're statement keywords and not functions.

Based on a quick look at the internals, the options are:

  1. Add #define terminateRayEXT AcceptHitAndEndSearch() to glsl.meta.slang
  2. Expand parseSyntaxDecl to allow a new keyword to map to a function call, then add syntax terminateRayEXT = AcceptHitAndEndSearch; to glsl.meta.slang
  3. Add new AST nodes and parse in Parser::ParseStatement similar to discard

Considering terminateRayEXT and ignoreIntersectionEXT map directly to function calls (AcceptHitAndEndSearch() & IgnoreHit()) and this is just a compatibility feature, the third option seems a bit overkill. Option 1 is trivial to implement but would leak terminateRayEXT to all shader stages. To me, option 2 seems fairly clean and could be useful for other stuff as well.

I'm pretty confident I can fix this myself and submit a PR with any of the three options, but I'm not sure which one's the best from your POV.

@csyonghe
Copy link
Collaborator

I believe you should be able to (ab)use global property for this:

property int terminateRayEXT { [ForceInline] get { AcceptHitAndEndSearch(); return 0; } }

void test()
{
     terminateRayEXT;
}

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 a pull request may close this issue.

2 participants