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

[SPIRV] Inline ray tracing doesn't compile #3047

Closed
Jasper-Bekkers opened this issue Jul 22, 2020 · 6 comments
Closed

[SPIRV] Inline ray tracing doesn't compile #3047

Jasper-Bekkers opened this issue Jul 22, 2020 · 6 comments
Assignees
Labels
spirv Work related to SPIR-V

Comments

@Jasper-Bekkers
Copy link

RaytracingAccelerationStructure g_topLevel : register(t0, space0);
RWTexture2D<float4> g_output : register(u1, space0);

[numthreads(64, 1, 1)]
void main(uint2 launchIndex: SV_DispatchThreadID)
{
    float3 T = (float3)0;
    float sampleCount = 0;
    RayDesc ray;

    ray.Origin = float3(0, 0, 0);
    ray.Direction = float3(0, 1, 0);
    ray.TMin = 0.0;
    ray.TMax = 1000.0;

    RayQuery<RAY_FLAG_FORCE_OPAQUE> q;

    q.TraceRayInline(g_topLevel, 0, 0xff, ray);
    q.Proceed();

    if(q.CommittedStatus() == COMMITTED_TRIANGLE_HIT)
    {
        T += float3(1, 0, 1);
    }
    else 
    {
        T += float3(0, 1, 0);
    }

    g_output[launchIndex] += float4(T, 1);
}

Output with -spirv:

>dxc -spirv -Tcs_6_5 repro.hlsl /Zi -Qembed_debug
repro.hlsl:18:5: warning: SPV_KHR_ray_query is currently a provisional extension and mightchange in ways that are not backwards compatible
    q.TraceRayInline(g_topLevel, 0, 0xff, ray);
    ^
repro.cs.hlsl:19:5: warning: SPV_KHR_ray_query is currently a provisional extension and mightchange in ways that are not backwards compatible
    q.Proceed();
    ^
repro.hlsl:21:8: warning: SPV_KHR_ray_query is currently a provisional extension and mightchange in ways that are not backwards compatible
    if(q.CommittedStatus() == COMMITTED_TRIANGLE_HIT)
       ^
fatal error: found unregistered decl
note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible

Output when compiling normally:

>dxc -Tcs_6_5 repro.hlsl /Zi -Qembed_debug
;
; Note: shader requires additional functionality:
;       Typed UAV Load Additional Formats
;       Raytracing tier 1.1 features

...
@dgkoch
Copy link

dgkoch commented Jul 22, 2020

cc @jiaolu are you able to look at this? cc @Tobski

@jiaolu
Copy link
Contributor

jiaolu commented Jul 22, 2020

okay, i will take a look

@kuhar kuhar added the spirv Work related to SPIR-V label Jul 23, 2020
@alelenv
Copy link
Contributor

alelenv commented Jul 24, 2020

Is the issue enums like COMMITTED_TRIANGLE_HIT not being present in astDecls before use?
I think adding to getDeclEvalInfo is not correct and you should add them in doImplicitDecl similar to other enums for ray tracing

@ehsannas
Copy link
Contributor

yeah I agree. @jiaolu please consider and update your PR accordingly. Thanks!

@jiaolu
Copy link
Contributor

jiaolu commented Jul 24, 2020

doImplicitDecl

I did add them in the doImplicitDecl
I tried to remove spvContext.isLib() || spvContext.isRay(), but it would break the tests like WholeFileTest.PassThruPixelShader
in clang-spirv-tests.exe . the astcontext would add the dcl regardlessly for the all shader without raytracing shader guarding.

jiaolu added a commit to jiaolu/DirectXShaderCompiler that referenced this issue Jul 28, 2020
Fix [SPIRV] Inline ray tracing doesn't compile microsoft#3047
1)Trying to add astcontext decls to the astDecls tables if decl is not
inserted before
2) Add the unit test of previously failed cs shader.
@ehsannas ehsannas self-assigned this Jul 29, 2020
ehsannas added a commit that referenced this issue Jul 30, 2020
* Add astcontext const decls to the astDecl table if not inserted before

Fix [SPIRV] Inline ray tracing doesn't compile #3047
1)Trying to add astcontext decls to the astDecls tables if decl is not
inserted before
2) Add the unit test of previously failed cs shader.

* [spirv] Create implicit constant VarDecls lazily.

Co-authored-by: Ehsan Nasiri <[email protected]>
@ehsannas
Copy link
Contributor

Fixed via #3054

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spirv Work related to SPIR-V
Projects
None yet
Development

No branches or pull requests

6 participants