Skip to content

[SPIR-V] Generated "OpConstantNull %type_2d_image" when using with RayQuery #3267

Closed

Description

@Evil-Ryu

Hi, I'm compling HLSL to spirv using dxc, got this error:

fatal error: generated SPIR-V is invalid: OpConstantNull Result Type <id> '7[%type_2d_image]' cannot have a null value.
  %50 = OpConstantNull %type_2d_image

The command line to compile The Shader:
dxc.exe -Zpr -Od -T ps_6_5 -E main_00000000_00000000 -spirv -fvk-use-dx-position-w -fspv-reflect -fspv-target-env=vulkan1.2 test.hlsl

I used a struct which contains a texture, and declared the struct inside main function.
The error happens only when I also used RayQuery related stuff.

Activity

  1. changed the title [-]Generated "OpConstantNull %type_2d_image" when using with RayQuery[/-] [+][SPIR-V] Generated "OpConstantNull %type_2d_image" when using with RayQuery[/+] on Nov 18, 2020
  2. added
    spirv
    on Nov 18, 2020
  3. ehsannas commented on Nov 18, 2020

    @ehsannas
    Contributor

    Thanks for reporting Liming Xu (@Evil-Ryu).

  4. ehsannas commented on Dec 9, 2020

    @ehsannas
    Contributor

    For reference, this is the shader:

    struct A
    {
        Texture2D T;
    };
     
    RaytracingAccelerationStructure TLAS;
    Texture2D g_texture;
    SamplerState g_sampler;
     
    void main_00000000_00000000(out float4 OutColor : SV_Target0) {
        const uint InstanceInclusionMask = 1;
        A a;   // this caused the invalid spirv, but if you delete all rayquery stuff, it's fine
        RayDesc Ray;
        Ray.Origin = float3(0.F, 0.F, -1.F);
        Ray.Direction = float3(0., 0., 1.);
        Ray.TMin = 0.F;
        Ray.TMax = 1.0E+6F;
        RayQuery<RAY_FLAG_FORCE_OPAQUE  | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH> q;
        q.TraceRayInline(TLAS, RAY_FLAG_FORCE_OPAQUE  | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, InstanceInclusionMask, Ray);
        q.Proceed();
        if (q.CommittedStatus() == COMMITTED_TRIANGLE_HIT) {
            OutColor = g_texture.Sample(g_sampler, float2(0, 0));
            OutColor.r += q.CommittedRayT();
        }
        else {
            OutColor = float4(1.F, 0.F, 0.F, 1.F);
        }
    }
    
  5. sudonatalie commented on Mar 17, 2022

    @sudonatalie
    Collaborator

    No longer able to repro, it looks like this issue has since been fixed (could be the related to the recent ray tracing capability fixes or the struct buffer fixes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    spirv

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions