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

Fix OpRayQueryGenerateIntersectionKHR behavior #2702

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

LLJJDD
Copy link
Contributor

@LLJJDD LLJJDD commented Sep 14, 2023

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.

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.
@LLJJDD LLJJDD requested a review from a team as a code owner September 14, 2023 06:39
@amdvlk-admin
Copy link

Test summary for commit 7b25973

CTS tests (Failed: 0/208496)
  • Built with version 1.3.5.2
  • Rhel 9.0, Gfx10
    • Passed: 36978/69503 (53.2%)
    • Failed: 0/69503 (0.0%)
    • Not Supported: 32525/69503 (46.8%)
    • Warnings: 0/69503 (0.0%)
    Ubuntu 22.04, Navi3x
    • Passed: 41144/69503 (59.2%)
    • Failed: 0/69503 (0.0%)
    • Not Supported: 28359/69503 (40.8%)
    • Warnings: 0/69503 (0.0%)
    Ubuntu 20.04, Navi2x
    • Passed: 41178/69490 (59.3%)
    • Failed: 0/69490 (0.0%)
    • Not Supported: 28312/69490 (40.7%)
    • Warnings: 0/69490 (0.0%)

Copy link
Member

@nhaehnle nhaehnle left a 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)});
Copy link
Member

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.

Copy link
Contributor Author

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.

@amdvlk-admin
Copy link

Test summary for commit 8deee69

CTS tests (Failed: 0/208496)
  • Built with version 1.3.5.2
  • Rhel 9.0, Gfx10
    • Passed: 36978/69503 (53.2%)
    • Failed: 0/69503 (0.0%)
    • Not Supported: 32525/69503 (46.8%)
    • Warnings: 0/69503 (0.0%)
    Ubuntu 22.04, Navi3x
    • Passed: 41144/69503 (59.2%)
    • Failed: 0/69503 (0.0%)
    • Not Supported: 28359/69503 (40.8%)
    • Warnings: 0/69503 (0.0%)
    Ubuntu 20.04, Navi2x
    • Passed: 41178/69490 (59.3%)
    • Failed: 0/69490 (0.0%)
    • Not Supported: 28312/69490 (40.7%)
    • Warnings: 0/69490 (0.0%)

@LLJJDD LLJJDD merged commit 7aa4658 into GPUOpen-Drivers:dev Sep 19, 2023
@LLJJDD LLJJDD deleted the fix-generate-intersection branch September 19, 2023 02:55
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

3 participants