Fix #10092: empty ray payload struct generates invalid CUDA code#10100
Fix #10092: empty ray payload struct generates invalid CUDA code#10100szihs wants to merge 1 commit intoshader-slang:masterfrom
Conversation
…DA code Add non-template optixTrace/optixTraverse overloads for the empty payload case. When Slang's type legalization eliminates an empty payload struct, the generated CUDA code omits the payload argument, which failed to match any existing prelude wrapper.
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdded non-template overloads for OptiX tracing, traversal, and invoke functions in the CUDA prelude header to support empty payload scenarios. These wrappers enable code generated when payloads are eliminated by type legalization to compile without providing payload arguments. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Fixes CUDA/OptiX codegen for the case where Slang’s legalization removes an empty ray payload struct, causing generated CUDA to call optixTrace / optixTraverse without a payload argument that previously didn’t match any Slang-provided wrapper overload.
Changes:
- Added a non-template
optixTrace(...)overload that accepts no payload argument and forwards to the native OptiX intrinsic. - Added a non-template
optixTraverse(...)overload that accepts no payload argument (but keeps thehitObjparameter for signature compatibility) and forwards to the native OptiX intrinsic.
| // Non-template overload for empty payload case. | ||
| // When Slang's type legalization eliminates an empty payload struct, | ||
| // the generated code calls optixTrace without a payload argument. | ||
| __forceinline__ __device__ void optixTrace( | ||
| OptixTraversableHandle AccelerationStructure, | ||
| uint32_t RayFlags, | ||
| uint32_t InstanceInclusionMask, | ||
| uint32_t RayContributionToHitGroupIndex, | ||
| uint32_t MultiplierForGeometryContributionToHitGroupIndex, | ||
| uint32_t MissShaderIndex, | ||
| RayDesc Ray) | ||
| { | ||
| optixTrace( |
There was a problem hiding this comment.
Please add a regression test that exercises the empty ray payload case on the CUDA target (e.g., a [raypayload] struct with no fields used with TraceRay/HitObject::TraceRay) and filecheck that the generated CUDA calls the new no-payload optixTrace/optixTraverse overload(s). This change fixes a codegen mismatch, but without a test it’s easy for future prelude/codegen changes to reintroduce the invalid CUDA call signature from #10092.
Add non-template optixTrace/optixTraverse overloads for the empty payload case. When Slang's type legalization eliminates an empty payload struct, the generated CUDA code omits the payload argument, which failed to match any existing prelude wrapper.