Skip to content

spirv-val: throws validation error for GLSL buffer_refernece #4042

@jasterplus

Description

@jasterplus

I posted the issue here KhronosGroup/glslang#2470.
This issue contains a compute shader which declares the buffer_reference structure containing the runtime array pointer.

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

and the VulkanSDK\1.2.154.1\Bin\spirv-val.exe gives the result:

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

Here is the partial SPIR-V assembly:

                              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)

@johnkslang mentions that there are some exceptions allowing ID to be consumed before its declaration, like a structure containing a pointer.

My question is validation error for this SPIR-V generation is reasonable?

Metadata

Metadata

Assignees

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