KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
2.95k stars 819 forks source link

SPIR-V module not valid: 2nd operand of TypePointer: operand 12 requires one of these extensions: SPV_KHR_storage_buffer_storage_class SPV_KHR_variable_pointers #1619

Closed hitok closed 5 years ago

hitok commented 5 years ago

Hi,

After I updated the vulkan sdk from 1.1.85.0 to 1.1.92.1, i got a debug report from validation layer:

SPIR-V module not valid: 2nd operand of TypePointer: operand 12 requires one of these extensions: SPV_KHR_storage_buffer_storage_class SPV_KHR_variable_pointers

A compute shader:

#version 450

layout (local_size_x = 32, local_size_y = 1, local_size_z = 1) in;

layout(std430, binding = 0) buffer activationsInBuff {
    float activationsIn[];
};

void main() {

}

A additional option "--target-env vulkan1.1" for the glslangValidator.

If to compare a human readable form of SPIR-V of this shader for 1.1.85.0 and 1.1.92.1 - we got differences:

Decorate 14(activationsInBuff) BufferBlock  -> Decorate 14(activationsInBuff) Block
TypePointer Uniform 14(activationsInBuff)   -> TypePointer StorageBuffer 14(activationsInBuff)
Variable Uniform                            -> Variable StorageBuffer

Has changed the storage class from Uniform to StorageBuffer.

From the SPIR-V specs: the StorageBuffer enabled by extensions SPV_KHR_storage_buffer_storage_class, SPV_KHR_variable_pointers. But a SPIR-V binary, generated from 1.1.92.1, does not have OpExtension instructions.

If I roughly commented - "if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3)" in the SPIRV/GlslangToSpv.cpp file:

void addPre13Extension(const char* ext) {
    //if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3)
    builder.addExtension(ext);
}

Thereafter the glslangValidator will be generating the SPIR-V binary with OpExtension instruction, no more messages from validation layer. I would like to know what the problem is? What am I doing wrong?

Best Regards.

johnkslang commented 5 years ago

StorageBuffer as a storage class became core SPIR-V as of SPIR-V 1.3, which is the version you should be getting generated in the SPIR-V output when you request vulkan1.1.

Things to check:

hitok commented 5 years ago

Hi johnkslang,

Thank you for your reply.

  1. The SPIR-V output version is 0x10300.
  2. I use the lunarg vulkan sdk 1.1.92.1 (latest).

I compiled latest vulkan tools manually. Now, there are no any warning messages.