Skip to content

Commit

Permalink
Declare SPV_KHR_storage_buffer_storage_class extension
Browse files Browse the repository at this point in the history
Do this so we can use StorageBuffer storage class

Fixes google#21
  • Loading branch information
dneto0 committed Aug 4, 2017
1 parent 099ce2a commit cf1a508
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/SPIRVProducerPass.cpp
Expand Up @@ -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<uint16_t>(1 + NameWordSize);
assert((NameWordSize + 1) < UINT16_MAX);
uint16_t WordCount = static_cast<uint16_t>(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) {
Expand Down
1 change: 1 addition & 0 deletions test/nop.cl
Expand Up @@ -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"
Expand Down

0 comments on commit cf1a508

Please sign in to comment.