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

fatal error : generated SPIR-V is invalid: OpAccessChain result type (OpTypeBool) does not match the type that results from indexing into the base <id> (OpTypeInt). 1> %99 = OpAccessChain %_ptr_Output_bool %10 %int_0 #4899

Open
sike2017 opened this issue Dec 22, 2022 · 2 comments
Labels
spirv Work related to SPIR-V

Comments

@sike2017
Copy link

HLSL code as below:

struct Meshlet
{
    uint indices[126 * 3];
    uint indexCount;
};

struct Payload
{
    Meshlet meshlet;
    float4x4 modelMatrix;
    int modelId;
};

//struct Vertex
//{
//    float3 Pos : POSITION0;
//    float2 UV : TEXCOORD0;
//    float4 Color : COLOR0;
//    float3 normal : NORMAL0;
//    int modelIndex : TEXCOORD1;
//};

//struct Primitive
//{
//    bool cullPrimitive : SV_CullPrimitive;
//};

//RWStructuredBuffer<Vertex> inVertices : register(u2);

//#define MAX_VERT 64
//#define MAX_PRIM 126
//#define Index uint

//[outputtopology("triangle")]
//[numthreads(1, 1, 1)]
//void main(
//    in payload Payload pld, 
//    out indices Index primitiveIndices[MAX_PRIM * 3], 
//    out vertices Vertex verts[MAX_VERT], 
//    out primitives Primitive prims[MAX_PRIM]
//    )
//{
//    int primitiveCount = pld.meshlet.indexCount / 3;
//    for (int n = 0; n < primitiveCount; n++)
//    {
//        verts[n * 3 + 0] = inVertices[pld.meshlet.indices[n * 3 + 0]];
//        verts[n * 3 + 1] = inVertices[pld.meshlet.indices[n * 3 + 1]];
//        verts[n * 3 + 2] = inVertices[pld.meshlet.indices[n * 3 + 2]];
//        primitiveIndices[n * 3 + 0] = n * 3 + 0;
//        primitiveIndices[n * 3 + 1] = n * 3 + 1;
//        primitiveIndices[n * 3 + 2] = n * 3 + 2;
//        prims[n].cullPrimitive = false;
        
//        verts[n * 3 + 0].Pos = mul(pld.modelMatrix, float4(verts[n * 3 + 0].Pos, 1.0)).xyz;
//        verts[n * 3 + 1].Pos = mul(pld.modelMatrix, float4(verts[n * 3 + 1].Pos, 1.0)).xyz;
//        verts[n * 3 + 2].Pos = mul(pld.modelMatrix, float4(verts[n * 3 + 2].Pos, 1.0)).xyz;
//    }
//    SetMeshOutputCounts(pld.meshlet.indexCount, primitiveCount);
//}

#define MAX_VERT 32
#define MAX_PRIM 16

struct MeshPerVertex
{
    float4 position : SV_Position;
    float4 color : COLOR0;
};

struct MeshPerPrimitive
{
    bool cullPrimitive : SV_CullPrimitive;
};

[numthreads(1, 1, 1)]
[outputtopology("triangle")]
void main(
    out indices uint3 primIndices[MAX_PRIM], 
    out vertices MeshPerVertex verts[MAX_VERT], 
    out primitives MeshPerPrimitive prims[MAX_PRIM],
    in payload Payload pld, 
    in uint tig : SV_GroupIndex 
)
{
    const float3 verticesData[3] =
    {
        float3(-0.5, 0.5, 0.0),
        float3(0.5, 0.5, 0.0),
        float3(0.0, -0.5, 0.0)
    };
    
    SetMeshOutputCounts(3, 1);
    verts[0].position = float4(-0.5, 0.5, 0.0, 1.0);
    verts[0].color = float4(1.0, 0.0, 0.0, 1.0);
    verts[1].position = float4(0.5, 0.5, 0.0, 1.0);
    verts[1].color = float4(0.0, 1.0, 0.0, 1.0);
    verts[2].position = float4(0.0, -0.5, 0.0, 1.0);
    verts[2].color = float4(0.0, 0.0, 1.0, 1.0);
    primIndices[0] = uint3(0, 1, 2);
    prims[0].cullPrimitive = false;
}
@Keenuts
Copy link
Collaborator

Keenuts commented Jan 3, 2023

Hi!

Thank you for the report!
Unfortunately, I am not able to reproduce your issue with the given information.
Could you provide me with:

  • commandline
  • operating system
  • version of the release, or commit if custom build.

Example of a report

Hi, I reached the following error message:

fatal error: this is some error message.

OS: linux
release: 1.7.22.12 (or commit: a0b6fc1)
command: dxc -HV2021 -sample-option my_shader.hlsl
shader to reproduce:

int my_shader() {
    bogus_line();
}

Thanks,

@Keenuts Keenuts added the needs repro steps Cannot reproduce or don't have repro informations label Jan 3, 2023
@tex3d tex3d added the spirv Work related to SPIR-V label Jan 3, 2023
@sudonatalie
Copy link
Collaborator

I was able to reproduce this issue with the following compile command:

dxc -spirv -T ms_6_5 -fspv-target-env=universal1.5 issue.hlsl 
fatal error: generated SPIR-V is invalid: OpAccessChain result type (OpTypeBool) does not match the type that results from indexing into the base <id> (OpTypeInt).
  %99 = OpAccessChain %_ptr_Output_bool %10 %int_0

note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible

@sudonatalie sudonatalie removed the needs repro steps Cannot reproduce or don't have repro informations label Aug 9, 2023
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

4 participants