Skip to content

SPIR-V validation fails for inconsistent SPIR-V generation of buffer reference #2470

@jasterplus

Description

@jasterplus

When I run the my Vulkan application with VkLayer_khronos_validation 1.2.154.1 layer, console outputs the error message:

Error: UNASSIGNED-CoreValidation-Shader-InconsistentSpirv
Validation Error: [ UNASSIGNED-CoreValidation-Shader-InconsistentSpirv ] Object 0: handle = 0x1f7f54f52c0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x6bbb14 | SPIR-V module not valid: ID 25[%_ptr_PhysicalStorageBuffer_Student] has not been defined
  %_runtimearr_25 = OpTypeRuntimeArray %_ptr_PhysicalStorageBuffer_Student

I'm not sure the problem is the generation order of SPIR-V instructions is incorrect or not, could you help check for this issue?

My glslangValidator.exe commit is 7f6559d
and the version message is:

Glslang Version: 10:11.0.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 11.0.0
GLSL Version: 4.60 glslang Khronos. 11.0.0
SPIR-V Version 0x00010500, Revision 3
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 10
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

Here is the compute shader source code:

#version 460
#extension GL_EXT_buffer_reference : enable

#define WG_THRDS 4

layout (local_size_x = WG_THRDS) in;

layout(binding = 0, set = 0) buffer DebugBuf
{
    uint value[];
} debug;

layout(buffer_reference, std430) buffer StudentData
{
    uint    instanceId;
    float   translation[3];
    float   scale[3];
};

layout(buffer_reference, std430) buffer Student
{
    StudentData data;
    float MVP[16];
};

layout(buffer_reference, std430) buffer SceneRef
{
    float MVP[16];
    Student instance[];
};

layout(buffer_reference, std430) buffer intRef
{
    int data[];
};
layout(buffer_reference, std430) buffer floatRef
{
    float data[];
};

layout(push_constant) uniform pushConstant {
    SceneRef    scene;
    floatRef    fTempBuffer;
    intRef      iTempBuffer;
    int         totalInstCount;
};

void setupScene() {
    debug.value[gl_LocalInvocationIndex] = scene.instance[gl_LocalInvocationIndex].data.instanceId;
}

void main() {
    setupScene();
}

The human readable form of partial SPIR-V:

21(pushConstant):             TypeStruct 18 19 20 13(int)
              22:             TypeFloat 32
              23:      8(int) Constant 16
              24:             TypeArray 22(float) 23
                              TypeForwardPointer 25 PhysicalStorageBufferEXT
              26:             TypeRuntimeArray 25
    27(SceneRef):             TypeStruct 24 26
                              TypeForwardPointer 28 PhysicalStorageBufferEXT
              29:             TypeArray 22(float) 23
     30(Student):             TypeStruct 28 29
              31:      8(int) Constant 3
              32:             TypeArray 22(float) 31
              33:             TypeArray 22(float) 31
 34(StudentData):             TypeStruct 8(int) 32 33
              28:             TypePointer PhysicalStorageBufferEXT 34(StudentData)
              25:             TypePointer PhysicalStorageBufferEXT 30(Student)
              35:             TypeRuntimeArray 25(ptr)
              18:             TypePointer PhysicalStorageBufferEXT 27(SceneRef)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions