-
Notifications
You must be signed in to change notification settings - Fork 116
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
Fix OpRayQueryGenerateIntersectionKHR behavior #2702
Conversation
Problem: In our GPURT implementation, rayQuery.RayTCurrent is relative to rayQuery.RayTMin, so for OpRayQueryGetIntersectionTKHR, we return (RayTCurrent + RayTMin) = Hit T relative to ray origin. However, for OpRayQueryGenerateIntersectionKHR, we simply store the HitT value given by shader into rayQuery.RayTCurrent, and return it with RayTMin offset when OpRayQueryGetIntersectionTKHR is called again. Fix: For OpRayQueryGenerateIntersectionKHR, we store (HitT - rayQuery.RayTMin), so that rayQuery.RayTCurrent always represents offset to RayTMin.
Test summary for commit 7b25973CTS tests (Failed: 0/208496)
Rhel 9.0, Gfx10Ubuntu 22.04, Navi3xUbuntu 20.04, Navi2x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but a nit/suggestion inline.
@@ -864,7 +864,11 @@ template <> void SpirvLowerRayQuery::createRayQueryFunc<OpRayQueryGenerateInters | |||
storeAddr = m_builder->CreateGEP( | |||
rayQueryTy, rayQuery, | |||
{zero, m_builder->getInt32(RayQueryParams::Committed), m_builder->getInt32(RaySystemParams::RayTCurrent)}); | |||
m_builder->CreateStore(hitT, storeAddr); | |||
Value *rayTMinAddr = m_builder->CreateGEP(rayQueryTy, rayQuery, | |||
{m_builder->getInt32(0), m_builder->getInt32(RayQueryParams::RayTMin)}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use CreateConstGEP2_32 here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, and everywhere else that accesses ray query member. I will do that in another PR.
Test summary for commit 8deee69CTS tests (Failed: 0/208496)
Rhel 9.0, Gfx10Ubuntu 22.04, Navi3xUbuntu 20.04, Navi2x |
Problem:
In our GPURT implementation, rayQuery.RayTCurrent is relative to rayQuery.RayTMin, so for OpRayQueryGetIntersectionTKHR, we return (RayTCurrent + RayTMin) = Hit T relative to ray origin.
However, for OpRayQueryGenerateIntersectionKHR, we simply store the HitT value given by shader into rayQuery.RayTCurrent, and return it with RayTMin offset when OpRayQueryGetIntersectionTKHR is called again.
Fix:
For OpRayQueryGenerateIntersectionKHR, we store (HitT - rayQuery.RayTMin), so that rayQuery.RayTCurrent always represents offset to RayTMin.