diff --git a/lib/SPIRVProducerPass.cpp b/lib/SPIRVProducerPass.cpp index e4e284432c..0bda3191b6 100644 --- a/lib/SPIRVProducerPass.cpp +++ b/lib/SPIRVProducerPass.cpp @@ -2761,23 +2761,26 @@ void SPIRVProducerPass::GenerateModuleInfo() { // // Ops[0] = Name (Literal String) // - Ops.clear(); + for (auto extension : {"SPV_KHR_storage_buffer_storage_class", + "SPV_KHR_variable_pointers"}) { + Ops.clear(); - SPIRVOperand *Name = new SPIRVOperand(SPIRVOperandType::LITERAL_STRING, - "SPV_KHR_variable_pointers"); - Ops.push_back(Name); + SPIRVOperand *Name = + new SPIRVOperand(SPIRVOperandType::LITERAL_STRING, extension); + Ops.push_back(Name); - size_t NameWordSize = (Name->getLiteralStr().size() + 1) / 4; - if ((Name->getLiteralStr().size() + 1) % 4) { - NameWordSize += 1; - } + size_t NameWordSize = (Name->getLiteralStr().size() + 1) / 4; + if ((Name->getLiteralStr().size() + 1) % 4) { + NameWordSize += 1; + } - assert((NameWordSize + 1) < UINT16_MAX); - uint16_t WordCount = static_cast(1 + NameWordSize); + assert((NameWordSize + 1) < UINT16_MAX); + uint16_t WordCount = static_cast(1 + NameWordSize); - SPIRVInstruction *ExtensionInst = - new SPIRVInstruction(WordCount, spv::OpExtension, 0 /* No id */, Ops); - SPIRVInstList.insert(InsertPoint, ExtensionInst); + SPIRVInstruction *ExtensionInst = + new SPIRVInstruction(WordCount, spv::OpExtension, 0 /* No id */, Ops); + SPIRVInstList.insert(InsertPoint, ExtensionInst); + } } if (ExtInstImportID) { diff --git a/test/nop.cl b/test/nop.cl index 3f745c3a2b..b75a0e17ac 100644 --- a/test/nop.cl +++ b/test/nop.cl @@ -12,6 +12,7 @@ // CHECK: ; Schema: 0 // CHECK: OpCapability Shader // CHECK: OpCapability VariablePointers +// CHECK: OpExtension "SPV_KHR_storage_buffer_storage_class" // CHECK: OpExtension "SPV_KHR_variable_pointers" // CHECK: OpMemoryModel Logical GLSL450 // CHECK: OpEntryPoint GLCompute %[[FOO_ID:[a-zA-Z0-9_]*]] "foo"