Commit b40d6ac9 by John Kessenich

glslang AST -> SPIR-V: Move to new auto-generated official headers, and for the…

glslang AST -> SPIR-V: Move to new auto-generated official headers, and for the disassembler, mirror the split done between the auto-generation header database and the specification. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@30434 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent 1f77cacd
...@@ -124,7 +124,7 @@ enum Entrypoints { ...@@ -124,7 +124,7 @@ enum Entrypoints {
inline void GetDebugNames(const char** names) inline void GetDebugNames(const char** names)
{ {
for (int i = 0; i < Count; ++i) for (int i = 0; i < Count; ++i)
names[i] = "unknown"; names[i] = "Unknown";
names[Round] = "round"; names[Round] = "round";
names[RoundEven] = "roundEven"; names[RoundEven] = "roundEven";
......
...@@ -134,15 +134,15 @@ protected: ...@@ -134,15 +134,15 @@ protected:
spv::ExecutionModel TranslateExecutionModel(EShLanguage stage) spv::ExecutionModel TranslateExecutionModel(EShLanguage stage)
{ {
switch (stage) { switch (stage) {
case EShLangVertex: return spv::ModelVertex; case EShLangVertex: return spv::ExecutionModelVertex;
case EShLangTessControl: return spv::ModelTessellationControl; case EShLangTessControl: return spv::ExecutionModelTessellationControl;
case EShLangTessEvaluation: return spv::ModelTessellationEvaluation; case EShLangTessEvaluation: return spv::ExecutionModelTessellationEvaluation;
case EShLangGeometry: return spv::ModelGeometry; case EShLangGeometry: return spv::ExecutionModelGeometry;
case EShLangFragment: return spv::ModelFragment; case EShLangFragment: return spv::ExecutionModelFragment;
case EShLangCompute: return spv::ModelGLCompute; case EShLangCompute: return spv::ExecutionModelGLCompute;
default: default:
spv::MissingFunctionality("GLSL stage"); spv::MissingFunctionality("GLSL stage");
return spv::ModelFragment; return spv::ExecutionModelFragment;
} }
} }
...@@ -150,30 +150,30 @@ spv::ExecutionModel TranslateExecutionModel(EShLanguage stage) ...@@ -150,30 +150,30 @@ spv::ExecutionModel TranslateExecutionModel(EShLanguage stage)
spv::StorageClass TranslateStorageClass(const glslang::TType& type) spv::StorageClass TranslateStorageClass(const glslang::TType& type)
{ {
if (type.getQualifier().isPipeInput()) if (type.getQualifier().isPipeInput())
return spv::StorageInput; return spv::StorageClassInput;
else if (type.getQualifier().isPipeOutput()) else if (type.getQualifier().isPipeOutput())
return spv::StorageOutput; return spv::StorageClassOutput;
else if (type.getQualifier().isUniformOrBuffer()) { else if (type.getQualifier().isUniformOrBuffer()) {
if (type.getBasicType() == glslang::EbtBlock) if (type.getBasicType() == glslang::EbtBlock)
return spv::StorageUniform; return spv::StorageClassUniform;
else else
return spv::StorageConstantUniform; return spv::StorageClassUniformConstant;
// TODO: how are we distuingishing between default and non-default non-writable uniforms? Do default uniforms even exist? // TODO: how are we distuingishing between default and non-default non-writable uniforms? Do default uniforms even exist?
} else { } else {
switch (type.getQualifier().storage) { switch (type.getQualifier().storage) {
case glslang::EvqShared: return spv::StorageWorkgroupLocal; break; case glslang::EvqShared: return spv::StorageClassWorkgroupLocal; break;
case glslang::EvqGlobal: return spv::StoragePrivateGlobal; case glslang::EvqGlobal: return spv::StorageClassPrivateGlobal;
case glslang::EvqConstReadOnly: return spv::StorageFunction; case glslang::EvqConstReadOnly: return spv::StorageClassFunction;
case glslang::EvqTemporary: return spv::StorageFunction; case glslang::EvqTemporary: return spv::StorageClassFunction;
default: default:
spv::MissingFunctionality("unknown glslang storage class"); spv::MissingFunctionality("unknown glslang storage class");
return spv::StorageCount; return spv::StorageClassFunction;
} }
} }
} }
// Translate glslang sampler type to SPIR-V dimensionality. // Translate glslang sampler type to SPIR-V dimensionality.
spv::Dimensionality TranslateDimensionality(const glslang::TSampler& sampler) spv::Dim TranslateDimensionality(const glslang::TSampler& sampler)
{ {
switch (sampler.dim) { switch (sampler.dim) {
case glslang::Esd1D: return spv::Dim1D; case glslang::Esd1D: return spv::Dim1D;
...@@ -192,10 +192,11 @@ spv::Dimensionality TranslateDimensionality(const glslang::TSampler& sampler) ...@@ -192,10 +192,11 @@ spv::Dimensionality TranslateDimensionality(const glslang::TSampler& sampler)
spv::Decoration TranslatePrecisionDecoration(const glslang::TType& type) spv::Decoration TranslatePrecisionDecoration(const glslang::TType& type)
{ {
switch (type.getQualifier().precision) { switch (type.getQualifier().precision) {
case glslang::EpqLow: return spv::DecPrecisionLow; case glslang::EpqLow: return spv::DecorationPrecisionLow;
case glslang::EpqMedium: return spv::DecPrecisionMedium; case glslang::EpqMedium: return spv::DecorationPrecisionMedium;
case glslang::EpqHigh: return spv::DecPrecisionHigh; case glslang::EpqHigh: return spv::DecorationPrecisionHigh;
default: return spv::DecCount; default:
return spv::NoPrecision;
} }
} }
...@@ -204,17 +205,17 @@ spv::Decoration TranslateBlockDecoration(const glslang::TType& type) ...@@ -204,17 +205,17 @@ spv::Decoration TranslateBlockDecoration(const glslang::TType& type)
{ {
if (type.getBasicType() == glslang::EbtBlock) { if (type.getBasicType() == glslang::EbtBlock) {
switch (type.getQualifier().storage) { switch (type.getQualifier().storage) {
case glslang::EvqUniform: return spv::DecBlock; case glslang::EvqUniform: return spv::DecorationBlock;
case glslang::EvqBuffer: return spv::DecBufferBlock; case glslang::EvqBuffer: return spv::DecorationBufferBlock;
case glslang::EvqVaryingIn: return spv::DecBlock; case glslang::EvqVaryingIn: return spv::DecorationBlock;
case glslang::EvqVaryingOut: return spv::DecBlock; case glslang::EvqVaryingOut: return spv::DecorationBlock;
default: default:
spv::MissingFunctionality("kind of block"); spv::MissingFunctionality("kind of block");
break; break;
} }
} }
return spv::DecCount; return (spv::Decoration)spv::BadValue;
} }
// Translate glslang type to SPIR-V layout decorations. // Translate glslang type to SPIR-V layout decorations.
...@@ -223,36 +224,36 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type) ...@@ -223,36 +224,36 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type)
if (type.isMatrix()) { if (type.isMatrix()) {
switch (type.getQualifier().layoutMatrix) { switch (type.getQualifier().layoutMatrix) {
case glslang::ElmRowMajor: case glslang::ElmRowMajor:
return spv::DecRowMajor; return spv::DecorationRowMajor;
default: default:
return spv::DecColMajor; return spv::DecorationColMajor;
} }
} else { } else {
switch (type.getBasicType()) { switch (type.getBasicType()) {
default: default:
return spv::DecCount; return (spv::Decoration)spv::BadValue;
break; break;
case glslang::EbtBlock: case glslang::EbtBlock:
switch (type.getQualifier().storage) { switch (type.getQualifier().storage) {
case glslang::EvqUniform: case glslang::EvqUniform:
case glslang::EvqBuffer: case glslang::EvqBuffer:
switch (type.getQualifier().layoutPacking) { switch (type.getQualifier().layoutPacking) {
case glslang::ElpShared: return spv::DecGLSLShared; case glslang::ElpShared: return spv::DecorationGLSLShared;
case glslang::ElpStd140: return spv::DecGLSLStd140; case glslang::ElpStd140: return spv::DecorationGLSLStd140;
case glslang::ElpStd430: return spv::DecGLSLStd430; case glslang::ElpStd430: return spv::DecorationGLSLStd430;
case glslang::ElpPacked: return spv::DecGLSLPacked; case glslang::ElpPacked: return spv::DecorationGLSLPacked;
default: default:
spv::MissingFunctionality("uniform block layout"); spv::MissingFunctionality("uniform block layout");
return spv::DecGLSLShared; return spv::DecorationGLSLShared;
} }
case glslang::EvqVaryingIn: case glslang::EvqVaryingIn:
case glslang::EvqVaryingOut: case glslang::EvqVaryingOut:
if (type.getQualifier().layoutPacking != glslang::ElpNone) if (type.getQualifier().layoutPacking != glslang::ElpNone)
spv::MissingFunctionality("in/out block layout"); spv::MissingFunctionality("in/out block layout");
return spv::DecCount; return (spv::Decoration)spv::BadValue;
default: default:
spv::MissingFunctionality("block storage qualification"); spv::MissingFunctionality("block storage qualification");
return spv::DecCount; return (spv::Decoration)spv::BadValue;
} }
} }
} }
...@@ -262,28 +263,28 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type) ...@@ -262,28 +263,28 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type)
spv::Decoration TranslateInterpolationDecoration(const glslang::TType& type) spv::Decoration TranslateInterpolationDecoration(const glslang::TType& type)
{ {
if (type.getQualifier().smooth) if (type.getQualifier().smooth)
return spv::DecSmooth; return spv::DecorationSmooth;
if (type.getQualifier().nopersp) if (type.getQualifier().nopersp)
return spv::DecNoperspective; return spv::DecorationNoperspective;
else if (type.getQualifier().patch) else if (type.getQualifier().patch)
return spv::DecPatch; return spv::DecorationPatch;
else if (type.getQualifier().flat) else if (type.getQualifier().flat)
return spv::DecFlat; return spv::DecorationFlat;
else if (type.getQualifier().centroid) else if (type.getQualifier().centroid)
return spv::DecCentroid; return spv::DecorationCentroid;
else if (type.getQualifier().sample) else if (type.getQualifier().sample)
return spv::DecSample; return spv::DecorationSample;
else else
return spv::DecCount; return (spv::Decoration)spv::BadValue;
} }
// If glslang type is invaraiant, return SPIR-V invariant decoration. // If glslang type is invaraiant, return SPIR-V invariant decoration.
spv::Decoration TranslateInvariantDecoration(const glslang::TType& type) spv::Decoration TranslateInvariantDecoration(const glslang::TType& type)
{ {
if (type.getQualifier().invariant) if (type.getQualifier().invariant)
return spv::DecInvariant; return spv::DecorationInvariant;
else else
return spv::DecCount; return (spv::Decoration)spv::BadValue;
} }
// Identify what SPIR-V built-in variable a symbol is. // Identify what SPIR-V built-in variable a symbol is.
...@@ -312,7 +313,7 @@ spv::BuiltIn TranslateBuiltIn(const glslang::TIntermSymbol* node) ...@@ -312,7 +313,7 @@ spv::BuiltIn TranslateBuiltIn(const glslang::TIntermSymbol* node)
{ {
const glslang::TString& name = node->getName(); const glslang::TString& name = node->getName();
if (name.compare(0, 3, "gl_") != 0) if (name.compare(0, 3, "gl_") != 0)
return spv::BuiltInCount; return (spv::BuiltIn)spv::BadValue;
switch (node->getQualifier().storage) { switch (node->getQualifier().storage) {
case glslang::EvqPosition: return spv::BuiltInPosition; case glslang::EvqPosition: return spv::BuiltInPosition;
...@@ -325,7 +326,7 @@ spv::BuiltIn TranslateBuiltIn(const glslang::TIntermSymbol* node) ...@@ -325,7 +326,7 @@ spv::BuiltIn TranslateBuiltIn(const glslang::TIntermSymbol* node)
case glslang::EvqFace: return spv::BuiltInFrontFacing; case glslang::EvqFace: return spv::BuiltInFrontFacing;
case glslang::EvqFragColor: return spv::BuiltInFragColor; case glslang::EvqFragColor: return spv::BuiltInFragColor;
case glslang::EvqFragDepth: return spv::BuiltInFragDepth; case glslang::EvqFragDepth: return spv::BuiltInFragDepth;
default: return spv::BuiltInCount; default: return (spv::BuiltIn)spv::BadValue;
if (name == "gl_ClipDistance") if (name == "gl_ClipDistance")
return spv::BuiltInClipDistance; return spv::BuiltInClipDistance;
else if (name == "gl_PrimitiveID" || name == "gl_PrimitiveIDIn") else if (name == "gl_PrimitiveID" || name == "gl_PrimitiveIDIn")
...@@ -380,9 +381,9 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls ...@@ -380,9 +381,9 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
spv::ExecutionModel executionModel = TranslateExecutionModel(glslangIntermediate->getStage()); spv::ExecutionModel executionModel = TranslateExecutionModel(glslangIntermediate->getStage());
builder.clearAccessChain(); builder.clearAccessChain();
builder.setSource(spv::LangGLSL, glslangIntermediate->getVersion()); builder.setSource(spv::SourceLanguageGLSL, glslangIntermediate->getVersion());
stdBuiltins = builder.import("GLSL.std.450"); stdBuiltins = builder.import("GLSL.std.450");
builder.setMemoryModel(spv::AddressingLogical, spv::MemoryGLSL450); builder.setMemoryModel(spv::AddressingModelLogical, spv::MemoryModelGLSL450);
shaderEntry = builder.makeMain(); shaderEntry = builder.makeMain();
builder.addEntryPoint(executionModel, shaderEntry); builder.addEntryPoint(executionModel, shaderEntry);
...@@ -394,7 +395,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls ...@@ -394,7 +395,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
// Add the top-level modes for this shader. // Add the top-level modes for this shader.
if (glslangIntermediate->getXfbMode()) if (glslangIntermediate->getXfbMode())
builder.addExecutionMode(shaderEntry, spv::ExecutionXfb); builder.addExecutionMode(shaderEntry, spv::ExecutionModeXfb);
spv::ExecutionMode mode; spv::ExecutionMode mode;
switch (glslangIntermediate->getStage()) { switch (glslangIntermediate->getStage()) {
...@@ -402,17 +403,17 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls ...@@ -402,17 +403,17 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
break; break;
case EShLangTessControl: case EShLangTessControl:
builder.addExecutionMode(shaderEntry, spv::ExecutionOutputVertices, glslangIntermediate->getVertices()); builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVertices());
break; break;
case EShLangTessEvaluation: case EShLangTessEvaluation:
switch (glslangIntermediate->getInputPrimitive()) { switch (glslangIntermediate->getInputPrimitive()) {
case glslang::ElgTriangles: mode = spv::ExecutionInputTriangles; break; case glslang::ElgTriangles: mode = spv::ExecutionModeInputTriangles; break;
case glslang::ElgQuads: mode = spv::ExecutionInputQuads; break; case glslang::ElgQuads: mode = spv::ExecutionModeInputQuads; break;
case glslang::ElgIsolines: mode = spv::ExecutionInputIsolines; break; case glslang::ElgIsolines: mode = spv::ExecutionModeInputIsolines; break;
default: mode = spv::ExecutionModeCount; break; default: mode = (spv::ExecutionMode)spv::BadValue; break;
} }
if (mode != spv::ExecutionModeCount) if (mode != spv::BadValue)
builder.addExecutionMode(shaderEntry, mode); builder.addExecutionMode(shaderEntry, mode);
// TODO // TODO
...@@ -423,33 +424,33 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls ...@@ -423,33 +424,33 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
case EShLangGeometry: case EShLangGeometry:
switch (glslangIntermediate->getInputPrimitive()) { switch (glslangIntermediate->getInputPrimitive()) {
case glslang::ElgPoints: mode = spv::ExecutionInputPoints; break; case glslang::ElgPoints: mode = spv::ExecutionModeInputPoints; break;
case glslang::ElgLines: mode = spv::ExecutionInputLines; break; case glslang::ElgLines: mode = spv::ExecutionModeInputLines; break;
case glslang::ElgLinesAdjacency: mode = spv::ExecutionInputLinesAdjacency; break; case glslang::ElgLinesAdjacency: mode = spv::ExecutionModeInputLinesAdjacency; break;
case glslang::ElgTriangles: mode = spv::ExecutionInputTriangles; break; case glslang::ElgTriangles: mode = spv::ExecutionModeInputTriangles; break;
case glslang::ElgTrianglesAdjacency: mode = spv::ExecutionInputTrianglesAdjacency; break; case glslang::ElgTrianglesAdjacency: mode = spv::ExecutionModeInputTrianglesAdjacency; break;
default: mode = spv::ExecutionModeCount; break; default: mode = (spv::ExecutionMode)spv::BadValue; break;
} }
if (mode != spv::ExecutionModeCount) if (mode != spv::BadValue)
builder.addExecutionMode(shaderEntry, mode); builder.addExecutionMode(shaderEntry, mode);
builder.addExecutionMode(shaderEntry, spv::ExecutionInvocations, glslangIntermediate->getInvocations()); builder.addExecutionMode(shaderEntry, spv::ExecutionModeInvocations, glslangIntermediate->getInvocations());
switch (glslangIntermediate->getOutputPrimitive()) { switch (glslangIntermediate->getOutputPrimitive()) {
case glslang::ElgPoints: mode = spv::ExecutionOutputPoints; break; case glslang::ElgPoints: mode = spv::ExecutionModeOutputPoints; break;
case glslang::ElgLineStrip: mode = spv::ExecutionOutputLineStrip; break; case glslang::ElgLineStrip: mode = spv::ExecutionModeOutputLineStrip; break;
case glslang::ElgTriangleStrip: mode = spv::ExecutionOutputTriangleStrip; break; case glslang::ElgTriangleStrip: mode = spv::ExecutionModeOutputTriangleStrip; break;
default: mode = spv::ExecutionModeCount; break; default: mode = (spv::ExecutionMode)spv::BadValue; break;
} }
if (mode != spv::ExecutionModeCount) if (mode != spv::BadValue)
builder.addExecutionMode(shaderEntry, mode); builder.addExecutionMode(shaderEntry, mode);
builder.addExecutionMode(shaderEntry, spv::ExecutionOutputVertices, glslangIntermediate->getVertices()); builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVertices());
break; break;
case EShLangFragment: case EShLangFragment:
if (glslangIntermediate->getPixelCenterInteger()) if (glslangIntermediate->getPixelCenterInteger())
builder.addExecutionMode(shaderEntry, spv::ExecutionPixelCenterInteger); builder.addExecutionMode(shaderEntry, spv::ExecutionModePixelCenterInteger);
if (glslangIntermediate->getOriginUpperLeft()) if (glslangIntermediate->getOriginUpperLeft())
builder.addExecutionMode(shaderEntry, spv::ExecutionOriginUpperLeft); builder.addExecutionMode(shaderEntry, spv::ExecutionModeOriginUpperLeft);
break; break;
case EShLangCompute: case EShLangCompute:
...@@ -1075,14 +1076,14 @@ bool TGlslangToSpvTraverser::visitSelection(glslang::TVisit /* visit */, glslang ...@@ -1075,14 +1076,14 @@ bool TGlslangToSpvTraverser::visitSelection(glslang::TVisit /* visit */, glslang
if (node->getBasicType() != glslang::EbtVoid) { if (node->getBasicType() != glslang::EbtVoid) {
// don't handle this as just on-the-fly temporaries, because there will be two names // don't handle this as just on-the-fly temporaries, because there will be two names
// and better to leave SSA to later passes // and better to leave SSA to later passes
result = builder.createVariable(spv::StorageFunction, convertGlslangToSpvType(node->getType())); result = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(node->getType()));
} }
// emit the condition before doing anything with selection // emit the condition before doing anything with selection
node->getCondition()->traverse(this); node->getCondition()->traverse(this);
// make an "if" based on the value created by the condition // make an "if" based on the value created by the condition
spv::Builder::If ifBuilder(builder.accessChainLoad(spv::DecCount), builder); spv::Builder::If ifBuilder(builder.accessChainLoad(spv::NoPrecision), builder);
if (node->getTrueBlock()) { if (node->getTrueBlock()) {
// emit the "then" statement // emit the "then" statement
...@@ -1266,8 +1267,8 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol* ...@@ -1266,8 +1267,8 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol*
if (glslang::IsAnonymous(name)) if (glslang::IsAnonymous(name))
name = ""; name = "";
if (storageClass == spv::StorageCount) if (storageClass == spv::BadValue)
return builder.createVariable(spv::StorageFunction, spvType, name); return builder.createVariable(spv::StorageClassFunction, spvType, name);
else else
return builder.createVariable(storageClass, spvType, name); return builder.createVariable(storageClass, spvType, name);
} }
...@@ -1366,11 +1367,11 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty ...@@ -1366,11 +1367,11 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
addMemberDecoration(spvType, member, TranslateInterpolationDecoration(glslangType)); addMemberDecoration(spvType, member, TranslateInterpolationDecoration(glslangType));
addMemberDecoration(spvType, member, TranslateInvariantDecoration(glslangType)); addMemberDecoration(spvType, member, TranslateInvariantDecoration(glslangType));
if (glslangType.getQualifier().hasLocation()) if (glslangType.getQualifier().hasLocation())
builder.addMemberDecoration(spvType, member, spv::DecLocation, glslangType.getQualifier().layoutLocation); builder.addMemberDecoration(spvType, member, spv::DecorationLocation, glslangType.getQualifier().layoutLocation);
if (glslangType.getQualifier().hasComponent()) if (glslangType.getQualifier().hasComponent())
builder.addMemberDecoration(spvType, member, spv::DecComponent, glslangType.getQualifier().layoutComponent); builder.addMemberDecoration(spvType, member, spv::DecorationComponent, glslangType.getQualifier().layoutComponent);
if (glslangType.getQualifier().hasXfbOffset()) if (glslangType.getQualifier().hasXfbOffset())
builder.addMemberDecoration(spvType, member, spv::DecOffset, glslangType.getQualifier().layoutXfbOffset); builder.addMemberDecoration(spvType, member, spv::DecorationOffset, glslangType.getQualifier().layoutXfbOffset);
} }
} }
...@@ -1378,12 +1379,12 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty ...@@ -1378,12 +1379,12 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
addDecoration(spvType, TranslateLayoutDecoration(type)); addDecoration(spvType, TranslateLayoutDecoration(type));
addDecoration(spvType, TranslateBlockDecoration(type)); addDecoration(spvType, TranslateBlockDecoration(type));
if (type.getQualifier().hasStream()) if (type.getQualifier().hasStream())
builder.addDecoration(spvType, spv::DecStream, type.getQualifier().layoutStream); builder.addDecoration(spvType, spv::DecorationStream, type.getQualifier().layoutStream);
if (glslangIntermediate->getXfbMode()) { if (glslangIntermediate->getXfbMode()) {
if (type.getQualifier().hasXfbStride()) if (type.getQualifier().hasXfbStride())
builder.addDecoration(spvType, spv::DecStride, type.getQualifier().layoutXfbStride); builder.addDecoration(spvType, spv::DecorationStride, type.getQualifier().layoutXfbStride);
if (type.getQualifier().hasXfbBuffer()) if (type.getQualifier().hasXfbBuffer())
builder.addDecoration(spvType, spv::DecXfbBuffer, type.getQualifier().layoutXfbBuffer); builder.addDecoration(spvType, spv::DecorationXfbBuffer, type.getQualifier().layoutXfbBuffer);
} }
} }
break; break;
...@@ -1448,7 +1449,7 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF ...@@ -1448,7 +1449,7 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
const glslang::TType& paramType = parameters[p]->getAsTyped()->getType(); const glslang::TType& paramType = parameters[p]->getAsTyped()->getType();
spv::Id typeId = convertGlslangToSpvType(paramType); spv::Id typeId = convertGlslangToSpvType(paramType);
if (paramType.getQualifier().storage != glslang::EvqConstReadOnly) if (paramType.getQualifier().storage != glslang::EvqConstReadOnly)
typeId = builder.makePointer(spv::StorageFunction, typeId); typeId = builder.makePointer(spv::StorageClassFunction, typeId);
else else
constReadOnlyParameters.insert(parameters[p]->getAsSymbolNode()->getId()); constReadOnlyParameters.insert(parameters[p]->getAsSymbolNode()->getId());
paramTypes.push_back(typeId); paramTypes.push_back(typeId);
...@@ -1674,11 +1675,11 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg ...@@ -1674,11 +1675,11 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
if (qualifiers[a] != glslang::EvqConstReadOnly) { if (qualifiers[a] != glslang::EvqConstReadOnly) {
// need space to hold the copy // need space to hold the copy
const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType(); const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType();
arg = builder.createVariable(spv::StorageFunction, convertGlslangToSpvType(paramType), "param"); arg = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(paramType), "param");
if (qualifiers[a] == glslang::EvqIn || qualifiers[a] == glslang::EvqInOut) { if (qualifiers[a] == glslang::EvqIn || qualifiers[a] == glslang::EvqInOut) {
// need to copy the input into output space // need to copy the input into output space
builder.setAccessChain(lValues[lValueCount]); builder.setAccessChain(lValues[lValueCount]);
spv::Id copy = builder.accessChainLoad(spv::DecCount); // TODO: get precision spv::Id copy = builder.accessChainLoad(spv::NoPrecision); // TODO: get precision
builder.createStore(copy, arg); builder.createStore(copy, arg);
} }
++lValueCount; ++lValueCount;
...@@ -1715,7 +1716,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv ...@@ -1715,7 +1716,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
bool isUnsigned = typeProxy == glslang::EbtUint; bool isUnsigned = typeProxy == glslang::EbtUint;
bool isFloat = typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble; bool isFloat = typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble;
spv::OpCode binOp = spv::OpNop; spv::Op binOp = spv::OpNop;
bool needsPromotion = true; bool needsPromotion = true;
bool comparison = false; bool comparison = false;
...@@ -1943,7 +1944,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv ...@@ -1943,7 +1944,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, spv::Id operand, bool isFloat) spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, spv::Id operand, bool isFloat)
{ {
spv::OpCode unaryOp = spv::OpNop; spv::Op unaryOp = spv::OpNop;
int libCall = -1; int libCall = -1;
switch (op) { switch (op) {
...@@ -2158,7 +2159,7 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv: ...@@ -2158,7 +2159,7 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Decoration precision, spv::Id destType, spv::Id operand) spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Decoration precision, spv::Id destType, spv::Id operand)
{ {
spv::OpCode convOp = spv::OpNop; spv::Op convOp = spv::OpNop;
spv::Id zero; spv::Id zero;
spv::Id one; spv::Id one;
...@@ -2265,7 +2266,7 @@ spv::Id TGlslangToSpvTraverser::makeSmearedConstant(spv::Id constant, int vector ...@@ -2265,7 +2266,7 @@ spv::Id TGlslangToSpvTraverser::makeSmearedConstant(spv::Id constant, int vector
spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector<spv::Id>& operands, bool isUnsigned) spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector<spv::Id>& operands, bool isUnsigned)
{ {
spv::OpCode opCode = spv::OpNop; spv::Op opCode = spv::OpNop;
int libCall = -1; int libCall = -1;
switch (op) { switch (op) {
...@@ -2371,19 +2372,19 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op) ...@@ -2371,19 +2372,19 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op)
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsAllMemory); builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsAllMemory);
return 0; return 0;
case glslang::EOpMemoryBarrierAtomicCounter: case glslang::EOpMemoryBarrierAtomicCounter:
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsAtomicCounter); builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsAtomicCounterMemoryMask);
return 0; return 0;
case glslang::EOpMemoryBarrierBuffer: case glslang::EOpMemoryBarrierBuffer:
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsUniform); builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsUniformMemoryMask);
return 0; return 0;
case glslang::EOpMemoryBarrierImage: case glslang::EOpMemoryBarrierImage:
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsImage); builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsImageMemoryMask);
return 0; return 0;
case glslang::EOpMemoryBarrierShared: case glslang::EOpMemoryBarrierShared:
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsWorkgroupLocal); builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsWorkgroupLocalMemoryMask);
return 0; return 0;
case glslang::EOpGroupMemoryBarrier: case glslang::EOpGroupMemoryBarrier:
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsWorkgroupGlobal); builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsWorkgroupGlobalMemoryMask);
return 0; return 0;
default: default:
spv::MissingFunctionality("operation with no arguments"); spv::MissingFunctionality("operation with no arguments");
...@@ -2409,53 +2410,53 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol ...@@ -2409,53 +2410,53 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
addDecoration(id, TranslatePrecisionDecoration(symbol->getType())); addDecoration(id, TranslatePrecisionDecoration(symbol->getType()));
addDecoration(id, TranslateInterpolationDecoration(symbol->getType())); addDecoration(id, TranslateInterpolationDecoration(symbol->getType()));
if (symbol->getQualifier().hasLocation()) if (symbol->getQualifier().hasLocation())
builder.addDecoration(id, spv::DecLocation, symbol->getQualifier().layoutLocation); builder.addDecoration(id, spv::DecorationLocation, symbol->getQualifier().layoutLocation);
if (symbol->getQualifier().hasComponent()) if (symbol->getQualifier().hasComponent())
builder.addDecoration(id, spv::DecComponent, symbol->getQualifier().layoutComponent); builder.addDecoration(id, spv::DecorationComponent, symbol->getQualifier().layoutComponent);
if (glslangIntermediate->getXfbMode()) { if (glslangIntermediate->getXfbMode()) {
if (symbol->getQualifier().hasXfbStride()) if (symbol->getQualifier().hasXfbStride())
builder.addDecoration(id, spv::DecStride, symbol->getQualifier().layoutXfbStride); builder.addDecoration(id, spv::DecorationStride, symbol->getQualifier().layoutXfbStride);
if (symbol->getQualifier().hasXfbBuffer()) if (symbol->getQualifier().hasXfbBuffer())
builder.addDecoration(id, spv::DecXfbBuffer, symbol->getQualifier().layoutXfbBuffer); builder.addDecoration(id, spv::DecorationXfbBuffer, symbol->getQualifier().layoutXfbBuffer);
if (symbol->getQualifier().hasXfbOffset()) if (symbol->getQualifier().hasXfbOffset())
builder.addDecoration(id, spv::DecOffset, symbol->getQualifier().layoutXfbOffset); builder.addDecoration(id, spv::DecorationOffset, symbol->getQualifier().layoutXfbOffset);
} }
} }
addDecoration(id, TranslateInvariantDecoration(symbol->getType())); addDecoration(id, TranslateInvariantDecoration(symbol->getType()));
if (symbol->getQualifier().hasStream()) if (symbol->getQualifier().hasStream())
builder.addDecoration(id, spv::DecStream, symbol->getQualifier().layoutStream); builder.addDecoration(id, spv::DecorationStream, symbol->getQualifier().layoutStream);
if (symbol->getQualifier().hasSet()) if (symbol->getQualifier().hasSet())
builder.addDecoration(id, spv::DecDescriptorSet, symbol->getQualifier().layoutSet); builder.addDecoration(id, spv::DecorationDescriptorSet, symbol->getQualifier().layoutSet);
if (symbol->getQualifier().hasBinding()) if (symbol->getQualifier().hasBinding())
builder.addDecoration(id, spv::DecBinding, symbol->getQualifier().layoutBinding); builder.addDecoration(id, spv::DecorationBinding, symbol->getQualifier().layoutBinding);
if (glslangIntermediate->getXfbMode()) { if (glslangIntermediate->getXfbMode()) {
if (symbol->getQualifier().hasXfbStride()) if (symbol->getQualifier().hasXfbStride())
builder.addDecoration(id, spv::DecStride, symbol->getQualifier().layoutXfbStride); builder.addDecoration(id, spv::DecorationStride, symbol->getQualifier().layoutXfbStride);
if (symbol->getQualifier().hasXfbBuffer()) if (symbol->getQualifier().hasXfbBuffer())
builder.addDecoration(id, spv::DecXfbBuffer, symbol->getQualifier().layoutXfbBuffer); builder.addDecoration(id, spv::DecorationXfbBuffer, symbol->getQualifier().layoutXfbBuffer);
} }
// built-in variable decorations // built-in variable decorations
int num = TranslateBuiltInDecoration(*symbol); int num = TranslateBuiltInDecoration(*symbol);
if (num >= 0) if (num >= 0)
builder.addDecoration(id, spv::DecBuiltIn, num); builder.addDecoration(id, spv::DecorationBuiltIn, num);
if (linkageOnly) if (linkageOnly)
builder.addDecoration(id, spv::DecNoStaticUse); builder.addDecoration(id, spv::DecorationNoStaticUse);
return id; return id;
} }
void TGlslangToSpvTraverser::addDecoration(spv::Id id, spv::Decoration dec) void TGlslangToSpvTraverser::addDecoration(spv::Id id, spv::Decoration dec)
{ {
if (dec != spv::DecCount) if (dec != spv::BadValue)
builder.addDecoration(id, dec); builder.addDecoration(id, dec);
} }
void TGlslangToSpvTraverser::addMemberDecoration(spv::Id id, int member, spv::Decoration dec) void TGlslangToSpvTraverser::addMemberDecoration(spv::Id id, int member, spv::Decoration dec)
{ {
if (dec != spv::DecCount) if (dec != spv::BadValue)
builder.addMemberDecoration(id, (unsigned)member, dec); builder.addMemberDecoration(id, (unsigned)member, dec);
} }
......
...@@ -56,10 +56,10 @@ namespace spv { ...@@ -56,10 +56,10 @@ namespace spv {
const int SpvBuilderMagic = 0xBB; const int SpvBuilderMagic = 0xBB;
Builder::Builder(unsigned int userNumber) : Builder::Builder(unsigned int userNumber) :
source(LangUnknown), source(SourceLanguageUnknown),
sourceVersion(0), sourceVersion(0),
addressModel(AddressingLogical), addressModel(AddressingModelLogical),
memoryModel(MemoryGLSL450), memoryModel(MemoryModelGLSL450),
builderNumber(userNumber << 16 | SpvBuilderMagic), builderNumber(userNumber << 16 | SpvBuilderMagic),
buildPoint(0), buildPoint(0),
uniqueId(0), uniqueId(0),
...@@ -293,7 +293,7 @@ Id Builder::makeFunctionType(Id returnType, std::vector<Id>& paramTypes) ...@@ -293,7 +293,7 @@ Id Builder::makeFunctionType(Id returnType, std::vector<Id>& paramTypes)
return type->getResultId(); return type->getResultId();
} }
Id Builder::makeSampler(Id sampledType, Dimensionality dim, samplerContent content, bool arrayed, bool shadow, bool ms) Id Builder::makeSampler(Id sampledType, Dim dim, samplerContent content, bool arrayed, bool shadow, bool ms)
{ {
// try to find it // try to find it
Instruction* type; Instruction* type;
...@@ -332,11 +332,11 @@ Id Builder::getDerefTypeId(Id resultId) const ...@@ -332,11 +332,11 @@ Id Builder::getDerefTypeId(Id resultId) const
return module.getInstruction(typeId)->getImmediateOperand(1); return module.getInstruction(typeId)->getImmediateOperand(1);
} }
OpCode Builder::getMostBasicTypeClass(Id typeId) const Op Builder::getMostBasicTypeClass(Id typeId) const
{ {
Instruction* instr = module.getInstruction(typeId); Instruction* instr = module.getInstruction(typeId);
OpCode typeClass = instr->getOpCode(); Op typeClass = instr->getOpCode();
switch (typeClass) switch (typeClass)
{ {
case OpTypeVoid: case OpTypeVoid:
...@@ -384,7 +384,7 @@ Id Builder::getScalarTypeId(Id typeId) const ...@@ -384,7 +384,7 @@ Id Builder::getScalarTypeId(Id typeId) const
{ {
Instruction* instr = module.getInstruction(typeId); Instruction* instr = module.getInstruction(typeId);
OpCode typeClass = instr->getOpCode(); Op typeClass = instr->getOpCode();
switch (typeClass) switch (typeClass)
{ {
case OpTypeVoid: case OpTypeVoid:
...@@ -410,7 +410,7 @@ Id Builder::getContainedTypeId(Id typeId, int member) const ...@@ -410,7 +410,7 @@ Id Builder::getContainedTypeId(Id typeId, int member) const
{ {
Instruction* instr = module.getInstruction(typeId); Instruction* instr = module.getInstruction(typeId);
OpCode typeClass = instr->getOpCode(); Op typeClass = instr->getOpCode();
switch (typeClass) switch (typeClass)
{ {
case OpTypeVector: case OpTypeVector:
...@@ -436,7 +436,7 @@ Id Builder::getContainedTypeId(Id typeId) const ...@@ -436,7 +436,7 @@ Id Builder::getContainedTypeId(Id typeId) const
// See if a scalar constant of this type has already been created, so it // See if a scalar constant of this type has already been created, so it
// can be reused rather than duplicated. (Required by the specification). // can be reused rather than duplicated. (Required by the specification).
Id Builder::findScalarConstant(OpCode typeClass, Id typeId, unsigned value) const Id Builder::findScalarConstant(Op typeClass, Id typeId, unsigned value) const
{ {
Instruction* constant; Instruction* constant;
for (int i = 0; i < (int)groupedConstants[typeClass].size(); ++i) { for (int i = 0; i < (int)groupedConstants[typeClass].size(); ++i) {
...@@ -515,7 +515,7 @@ Id Builder::makeDoubleConstant(double d) ...@@ -515,7 +515,7 @@ Id Builder::makeDoubleConstant(double d)
return NoResult; return NoResult;
} }
Id Builder::findCompositeConstant(OpCode typeClass, std::vector<Id>& comps) const Id Builder::findCompositeConstant(Op typeClass, std::vector<Id>& comps) const
{ {
Instruction* constant; Instruction* constant;
bool found = false; bool found = false;
...@@ -547,7 +547,7 @@ Id Builder::findCompositeConstant(OpCode typeClass, std::vector<Id>& comps) cons ...@@ -547,7 +547,7 @@ Id Builder::findCompositeConstant(OpCode typeClass, std::vector<Id>& comps) cons
Id Builder::makeCompositeConstant(Id typeId, std::vector<Id>& members) Id Builder::makeCompositeConstant(Id typeId, std::vector<Id>& members)
{ {
assert(typeId); assert(typeId);
OpCode typeClass = getTypeClass(typeId); Op typeClass = getTypeClass(typeId);
switch (typeClass) { switch (typeClass) {
case OpTypeVector: case OpTypeVector:
...@@ -735,7 +735,7 @@ void Builder::leaveFunction(bool main) ...@@ -735,7 +735,7 @@ void Builder::leaveFunction(bool main)
if (function.getReturnType() == makeVoidType()) if (function.getReturnType() == makeVoidType())
makeReturn(true); makeReturn(true);
else { else {
Id retStorage = createVariable(StorageFunction, function.getReturnType(), "dummyReturn"); Id retStorage = createVariable(StorageClassFunction, function.getReturnType(), "dummyReturn");
Id retValue = createLoad(retStorage); Id retValue = createLoad(retStorage);
makeReturn(true, retValue); makeReturn(true, retValue);
} }
...@@ -761,18 +761,18 @@ Id Builder::createVariable(StorageClass storageClass, Id type, const char* name) ...@@ -761,18 +761,18 @@ Id Builder::createVariable(StorageClass storageClass, Id type, const char* name)
inst->addImmediateOperand(storageClass); inst->addImmediateOperand(storageClass);
switch (storageClass) { switch (storageClass) {
case StorageConstantUniform: case StorageClassUniformConstant:
case StorageUniform: case StorageClassUniform:
case StorageInput: case StorageClassInput:
case StorageOutput: case StorageClassOutput:
case StorageWorkgroupLocal: case StorageClassWorkgroupLocal:
case StoragePrivateGlobal: case StorageClassPrivateGlobal:
case StorageWorkgroupGlobal: case StorageClassWorkgroupGlobal:
constantsTypesGlobals.push_back(inst); constantsTypesGlobals.push_back(inst);
module.mapInstruction(inst); module.mapInstruction(inst);
break; break;
case StorageFunction: case StorageClassFunction:
// Validation rules require the declaration in the entry block // Validation rules require the declaration in the entry block
buildPoint->getParent().addLocalVariable(inst); buildPoint->getParent().addLocalVariable(inst);
break; break;
...@@ -878,14 +878,14 @@ Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, std::vecto ...@@ -878,14 +878,14 @@ Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, std::vecto
} }
// An opcode that has no operands, no result id, and no type // An opcode that has no operands, no result id, and no type
void Builder::createNoResultOp(OpCode opCode) void Builder::createNoResultOp(Op opCode)
{ {
Instruction* op = new Instruction(opCode); Instruction* op = new Instruction(opCode);
buildPoint->addInstruction(op); buildPoint->addInstruction(op);
} }
// An opcode that has one operand, no result id, and no type // An opcode that has one operand, no result id, and no type
void Builder::createNoResultOp(OpCode opCode, Id operand) void Builder::createNoResultOp(Op opCode, Id operand)
{ {
Instruction* op = new Instruction(opCode); Instruction* op = new Instruction(opCode);
op->addIdOperand(operand); op->addIdOperand(operand);
...@@ -908,7 +908,7 @@ void Builder::createMemoryBarrier(unsigned executionScope, unsigned memorySemant ...@@ -908,7 +908,7 @@ void Builder::createMemoryBarrier(unsigned executionScope, unsigned memorySemant
} }
// An opcode that has one operands, a result id, and a type // An opcode that has one operands, a result id, and a type
Id Builder::createUnaryOp(OpCode opCode, Id typeId, Id operand) Id Builder::createUnaryOp(Op opCode, Id typeId, Id operand)
{ {
Instruction* op = new Instruction(getUniqueId(), typeId, opCode); Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(operand); op->addIdOperand(operand);
...@@ -917,7 +917,7 @@ Id Builder::createUnaryOp(OpCode opCode, Id typeId, Id operand) ...@@ -917,7 +917,7 @@ Id Builder::createUnaryOp(OpCode opCode, Id typeId, Id operand)
return op->getResultId(); return op->getResultId();
} }
Id Builder::createBinOp(OpCode opCode, Id typeId, Id left, Id right) Id Builder::createBinOp(Op opCode, Id typeId, Id left, Id right)
{ {
Instruction* op = new Instruction(getUniqueId(), typeId, opCode); Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(left); op->addIdOperand(left);
...@@ -927,7 +927,7 @@ Id Builder::createBinOp(OpCode opCode, Id typeId, Id left, Id right) ...@@ -927,7 +927,7 @@ Id Builder::createBinOp(OpCode opCode, Id typeId, Id left, Id right)
return op->getResultId(); return op->getResultId();
} }
Id Builder::createTriOp(OpCode opCode, Id typeId, Id op1, Id op2, Id op3) Id Builder::createTriOp(Op opCode, Id typeId, Id op1, Id op2, Id op3)
{ {
Instruction* op = new Instruction(getUniqueId(), typeId, opCode); Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(op1); op->addIdOperand(op1);
...@@ -938,7 +938,7 @@ Id Builder::createTriOp(OpCode opCode, Id typeId, Id op1, Id op2, Id op3) ...@@ -938,7 +938,7 @@ Id Builder::createTriOp(OpCode opCode, Id typeId, Id op1, Id op2, Id op3)
return op->getResultId(); return op->getResultId();
} }
Id Builder::createTernaryOp(OpCode opCode, Id typeId, Id op1, Id op2, Id op3) Id Builder::createTernaryOp(Op opCode, Id typeId, Id op1, Id op2, Id op3)
{ {
Instruction* op = new Instruction(getUniqueId(), typeId, opCode); Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(op1); op->addIdOperand(op1);
...@@ -1080,7 +1080,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool proj, co ...@@ -1080,7 +1080,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool proj, co
// Set up the instruction // Set up the instruction
// //
OpCode opCode; Op opCode;
if (proj && parameters.gradX && parameters.offset) if (proj && parameters.gradX && parameters.offset)
opCode = OpTextureSampleProjGradOffset; opCode = OpTextureSampleProjGradOffset;
else if (proj && parameters.lod && parameters.offset) else if (proj && parameters.lod && parameters.offset)
...@@ -1118,7 +1118,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool proj, co ...@@ -1118,7 +1118,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool proj, co
} }
// Comments in header // Comments in header
Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& parameters) Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameters)
{ {
// Figure out the result type // Figure out the result type
Id resultType; Id resultType;
...@@ -1190,7 +1190,7 @@ Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& param ...@@ -1190,7 +1190,7 @@ Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& param
// Comments in header // Comments in header
//Id Builder::createBitFieldExtractCall(Decoration precision, Id id, Id offset, Id bits, bool isSigned) //Id Builder::createBitFieldExtractCall(Decoration precision, Id id, Id offset, Id bits, bool isSigned)
//{ //{
// OpCode opCode = isSigned ? sBitFieldExtract // Op opCode = isSigned ? sBitFieldExtract
// : uBitFieldExtract; // : uBitFieldExtract;
// //
// if (isScalar(offset) == false || isScalar(bits) == false) // if (isScalar(offset) == false || isScalar(bits) == false)
...@@ -1210,7 +1210,7 @@ Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& param ...@@ -1210,7 +1210,7 @@ Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& param
// Comments in header // Comments in header
//Id Builder::createBitFieldInsertCall(Decoration precision, Id base, Id insert, Id offset, Id bits) //Id Builder::createBitFieldInsertCall(Decoration precision, Id base, Id insert, Id offset, Id bits)
//{ //{
// OpCode opCode = bitFieldInsert; // Op opCode = bitFieldInsert;
// //
// if (isScalar(offset) == false || isScalar(bits) == false) // if (isScalar(offset) == false || isScalar(bits) == false)
// MissingFunctionality("bitFieldInsert operand types"); // MissingFunctionality("bitFieldInsert operand types");
...@@ -1230,7 +1230,7 @@ Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& param ...@@ -1230,7 +1230,7 @@ Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& param
Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal) Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal)
{ {
Instruction* compare = 0; Instruction* compare = 0;
spv::OpCode binOp = spv::OpNop; spv::Op binOp = spv::OpNop;
Id boolType = makeBoolType(); Id boolType = makeBoolType();
Id valueType = getTypeId(value1); Id valueType = getTypeId(value1);
...@@ -1242,7 +1242,7 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal ...@@ -1242,7 +1242,7 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal
if (isVectorType(valueType)) { if (isVectorType(valueType)) {
Id boolVectorType = makeVectorType(boolType, getNumTypeComponents(valueType)); Id boolVectorType = makeVectorType(boolType, getNumTypeComponents(valueType));
Id boolVector; Id boolVector;
OpCode op; Op op;
if (getMostBasicTypeClass(valueType) == OpTypeFloat) if (getMostBasicTypeClass(valueType) == OpTypeFloat)
op = equal ? OpFOrdEqual : OpFOrdNotEqual; op = equal ? OpFOrdEqual : OpFOrdNotEqual;
else else
...@@ -1307,9 +1307,9 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal ...@@ -1307,9 +1307,9 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal
} }
// Comments in header // Comments in header
//Id Builder::createOperation(Decoration precision, OpCode opCode, Id operand) //Id Builder::createOperation(Decoration precision, Op opCode, Id operand)
//{ //{
// OpCode* opCode = 0; // Op* opCode = 0;
// //
// // Handle special return types here. Things that don't have same result type as parameter // // Handle special return types here. Things that don't have same result type as parameter
// switch (opCode) { // switch (opCode) {
...@@ -1362,7 +1362,7 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal ...@@ -1362,7 +1362,7 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal
//} //}
// //
//// Comments in header //// Comments in header
//Id Builder::createOperation(Decoration precision, OpCode opCode, Id operand0, Id operand1) //Id Builder::createOperation(Decoration precision, Op opCode, Id operand0, Id operand1)
//{ //{
// Function* opCode = 0; // Function* opCode = 0;
// //
...@@ -1393,7 +1393,7 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal ...@@ -1393,7 +1393,7 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal
// return instr; // return instr;
//} //}
// //
//Id Builder::createOperation(Decoration precision, OpCode opCode, Id operand0, Id operand1, Id operand2) //Id Builder::createOperation(Decoration precision, Op opCode, Id operand0, Id operand1, Id operand2)
//{ //{
// Function* opCode; // Function* opCode;
// //
...@@ -1608,7 +1608,7 @@ void Builder::If::makeEndIf() ...@@ -1608,7 +1608,7 @@ void Builder::If::makeEndIf()
// Go back to the headerBlock and make the flow control split // Go back to the headerBlock and make the flow control split
builder.setBuildPoint(headerBlock); builder.setBuildPoint(headerBlock);
builder.createMerge(OpSelectionMerge, mergeBlock, SelectControlNone); builder.createMerge(OpSelectionMerge, mergeBlock, SelectionControlMaskNone);
if (elseBlock) if (elseBlock)
builder.createConditionalBranch(condition, thenBlock, elseBlock); builder.createConditionalBranch(condition, thenBlock, elseBlock);
else else
...@@ -1632,7 +1632,7 @@ void Builder::makeSwitch(Id selector, int numSegments, std::vector<int>& caseVal ...@@ -1632,7 +1632,7 @@ void Builder::makeSwitch(Id selector, int numSegments, std::vector<int>& caseVal
Block* mergeBlock = new Block(getUniqueId(), function); Block* mergeBlock = new Block(getUniqueId(), function);
// make and insert the switch's selection-merge instruction // make and insert the switch's selection-merge instruction
createMerge(OpSelectionMerge, mergeBlock, SelectControlNone); createMerge(OpSelectionMerge, mergeBlock, SelectionControlMaskNone);
// make the switch instruction // make the switch instruction
Instruction* switchInst = new Instruction(NoResult, NoType, OpSwitch); Instruction* switchInst = new Instruction(NoResult, NoType, OpSwitch);
...@@ -1706,7 +1706,7 @@ void Builder::createLoopHeaderBranch(Id condition) ...@@ -1706,7 +1706,7 @@ void Builder::createLoopHeaderBranch(Id condition)
Loop loop = loops.top(); Loop loop = loops.top();
Block* body = new Block(getUniqueId(), *loop.function); Block* body = new Block(getUniqueId(), *loop.function);
createMerge(OpLoopMerge, loop.merge, LoopControlNone); createMerge(OpLoopMerge, loop.merge, LoopControlMaskNone);
createConditionalBranch(condition, body, loop.merge); createConditionalBranch(condition, body, loop.merge);
loop.function->addBlock(body); loop.function->addBlock(body);
setBuildPoint(body); setBuildPoint(body);
...@@ -1831,7 +1831,7 @@ Id Builder::accessChainLoad(Decoration precision) ...@@ -1831,7 +1831,7 @@ Id Builder::accessChainLoad(Decoration precision)
id = createCompositeExtract(accessChain.base, accessChain.resultType, indexes); id = createCompositeExtract(accessChain.base, accessChain.resultType, indexes);
else { else {
// make a new function variable for this r-value // make a new function variable for this r-value
Id lValue = createVariable(StorageFunction, getTypeId(accessChain.base), "indexable"); Id lValue = createVariable(StorageClassUniform, getTypeId(accessChain.base), "indexable");
// store into it // store into it
createStore(accessChain.base, lValue); createStore(accessChain.base, lValue);
...@@ -1887,7 +1887,7 @@ void Builder::dump(std::vector<unsigned int>& out) const ...@@ -1887,7 +1887,7 @@ void Builder::dump(std::vector<unsigned int>& out) const
out.push_back(0); out.push_back(0);
// First instructions, some created on the spot here: // First instructions, some created on the spot here:
if (source != LangUnknown) { if (source != SourceLanguageUnknown) {
Instruction sourceInst(0, 0, OpSource); Instruction sourceInst(0, 0, OpSource);
sourceInst.addImmediateOperand(source); sourceInst.addImmediateOperand(source);
sourceInst.addImmediateOperand(sourceVersion); sourceInst.addImmediateOperand(sourceVersion);
...@@ -1979,7 +1979,7 @@ void Builder::createBranch(Block* block) ...@@ -1979,7 +1979,7 @@ void Builder::createBranch(Block* block)
block->addPredecessor(buildPoint); block->addPredecessor(buildPoint);
} }
void Builder::createMerge(OpCode mergeCode, Block* mergeBlock, unsigned int control) void Builder::createMerge(Op mergeCode, Block* mergeBlock, unsigned int control)
{ {
Instruction* merge = new Instruction(mergeCode); Instruction* merge = new Instruction(mergeCode);
merge->addIdOperand(mergeBlock->getId()); merge->addIdOperand(mergeBlock->getId());
......
...@@ -106,14 +106,14 @@ public: ...@@ -106,14 +106,14 @@ public:
samplerContentImage, samplerContentImage,
samplerContentTextureFilter samplerContentTextureFilter
}; };
Id makeSampler(Id sampledType, Dimensionality, samplerContent, bool arrayed, bool shadow, bool ms); Id makeSampler(Id sampledType, Dim, samplerContent, bool arrayed, bool shadow, bool ms);
// For querying about types. // For querying about types.
Id getTypeId(Id resultId) const { return module.getTypeId(resultId); } Id getTypeId(Id resultId) const { return module.getTypeId(resultId); }
Id getDerefTypeId(Id resultId) const; Id getDerefTypeId(Id resultId) const;
OpCode getOpCode(Id id) const { return module.getInstruction(id)->getOpCode(); } Op getOpCode(Id id) const { return module.getInstruction(id)->getOpCode(); }
OpCode getTypeClass(Id typeId) const { return getOpCode(typeId); } Op getTypeClass(Id typeId) const { return getOpCode(typeId); }
OpCode getMostBasicTypeClass(Id typeId) const; Op getMostBasicTypeClass(Id typeId) const;
int getNumComponents(Id resultId) const { return getNumTypeComponents(getTypeId(resultId)); } int getNumComponents(Id resultId) const { return getNumTypeComponents(getTypeId(resultId)); }
int getNumTypeComponents(Id typeId) const; int getNumTypeComponents(Id typeId) const;
Id getScalarTypeId(Id typeId) const; Id getScalarTypeId(Id typeId) const;
...@@ -151,10 +151,10 @@ public: ...@@ -151,10 +151,10 @@ public:
} }
int getNumRows(Id resultId) const { return getTypeNumRows(getTypeId(resultId)); } int getNumRows(Id resultId) const { return getTypeNumRows(getTypeId(resultId)); }
Dimensionality getDimensionality(Id resultId) const Dim getDimensionality(Id resultId) const
{ {
assert(isSamplerType(getTypeId(resultId))); assert(isSamplerType(getTypeId(resultId)));
return (Dimensionality)module.getInstruction(getTypeId(resultId))->getImmediateOperand(1); return (Dim)module.getInstruction(getTypeId(resultId))->getImmediateOperand(1);
} }
bool isArrayedSampler(Id resultId) const bool isArrayedSampler(Id resultId) const
{ {
...@@ -228,14 +228,14 @@ public: ...@@ -228,14 +228,14 @@ public:
Id createCompositeInsert(Id object, Id composite, Id typeId, unsigned index); Id createCompositeInsert(Id object, Id composite, Id typeId, unsigned index);
Id createCompositeInsert(Id object, Id composite, Id typeId, std::vector<unsigned>& indexes); Id createCompositeInsert(Id object, Id composite, Id typeId, std::vector<unsigned>& indexes);
void createNoResultOp(OpCode); void createNoResultOp(Op);
void createNoResultOp(OpCode, Id operand); void createNoResultOp(Op, Id operand);
void createControlBarrier(unsigned executionScope); void createControlBarrier(unsigned executionScope);
void createMemoryBarrier(unsigned executionScope, unsigned memorySemantics); void createMemoryBarrier(unsigned executionScope, unsigned memorySemantics);
Id createUnaryOp(OpCode, Id typeId, Id operand); Id createUnaryOp(Op, Id typeId, Id operand);
Id createBinOp(OpCode, Id typeId, Id operand1, Id operand2); Id createBinOp(Op, Id typeId, Id operand1, Id operand2);
Id createTriOp(OpCode, Id typeId, Id operand1, Id operand2, Id operand3); Id createTriOp(Op, Id typeId, Id operand1, Id operand2, Id operand3);
Id createTernaryOp(OpCode, Id typeId, Id operand1, Id operand2, Id operand3); Id createTernaryOp(Op, Id typeId, Id operand1, Id operand2, Id operand3);
Id createFunctionCall(spv::Function*, std::vector<spv::Id>&); Id createFunctionCall(spv::Function*, std::vector<spv::Id>&);
// Take an rvalue (source) and a set of channels to extract from it to // Take an rvalue (source) and a set of channels to extract from it to
...@@ -289,7 +289,7 @@ public: ...@@ -289,7 +289,7 @@ public:
// Emit the OpTextureQuery* instruction that was passed in. // Emit the OpTextureQuery* instruction that was passed in.
// Figure out the right return value and type, and return it. // Figure out the right return value and type, and return it.
Id createTextureQueryCall(OpCode, const TextureParameters&); Id createTextureQueryCall(Op, const TextureParameters&);
Id createSamplePositionCall(Decoration precision, Id, Id); Id createSamplePositionCall(Decoration precision, Id, Id);
...@@ -461,13 +461,13 @@ public: ...@@ -461,13 +461,13 @@ public:
void dump(std::vector<unsigned int>&) const; void dump(std::vector<unsigned int>&) const;
protected: protected:
Id findScalarConstant(OpCode typeClass, Id typeId, unsigned value) const; Id findScalarConstant(Op typeClass, Id typeId, unsigned value) const;
Id findCompositeConstant(OpCode typeClass, std::vector<Id>& comps) const; Id findCompositeConstant(Op typeClass, std::vector<Id>& comps) const;
Id collapseAccessChain(); Id collapseAccessChain();
void simplifyAccessChainSwizzle(); void simplifyAccessChainSwizzle();
void createAndSetNoPredecessorBlock(const char*); void createAndSetNoPredecessorBlock(const char*);
void createBranch(Block* block); void createBranch(Block* block);
void createMerge(OpCode, Block*, unsigned int control); void createMerge(Op, Block*, unsigned int control);
void createConditionalBranch(Id condition, Block* thenBlock, Block* elseBlock); void createConditionalBranch(Id condition, Block* thenBlock, Block* elseBlock);
void dumpInstructions(std::vector<unsigned int>&, const std::vector<Instruction*>&) const; void dumpInstructions(std::vector<unsigned int>&, const std::vector<Instruction*>&) const;
......
...@@ -40,10 +40,11 @@ ...@@ -40,10 +40,11 @@
// Disassembler for SPIR-V. // Disassembler for SPIR-V.
// //
#include <stdlib.h>
#include <assert.h>
#include <iomanip> #include <iomanip>
#include <stack> #include <stack>
#include <sstream> #include <sstream>
#include "stdlib.h"
#include "GLSL450Lib.h" #include "GLSL450Lib.h"
extern const char* GlslStd450DebugNames[GLSL_STD_450::Count]; extern const char* GlslStd450DebugNames[GLSL_STD_450::Count];
...@@ -69,7 +70,7 @@ public: ...@@ -69,7 +70,7 @@ public:
void processInstructions(); void processInstructions();
protected: protected:
OpCode getOpCode(int id) const { return idInstruction[id] ? (OpCode)(stream[idInstruction[id]] & OpCodeMask) : OpNop; } Op getOpCode(int id) const { return idInstruction[id] ? (Op)(stream[idInstruction[id]] & OpCodeMask) : OpNop; }
// Output methods // Output methods
void outputIndent(); void outputIndent();
...@@ -80,7 +81,7 @@ protected: ...@@ -80,7 +81,7 @@ protected:
void disassembleImmediates(int numOperands); void disassembleImmediates(int numOperands);
void disassembleIds(int numOperands); void disassembleIds(int numOperands);
void disassembleString(); void disassembleString();
void disassembleInstruction(Id resultId, Id typeId, OpCode opCode, int numOperands); void disassembleInstruction(Id resultId, Id typeId, Op opCode, int numOperands);
// Data // Data
std::ostream& out; // where to write the disassembly std::ostream& out; // where to write the disassembly
...@@ -144,7 +145,7 @@ void SpirvStream::processInstructions() ...@@ -144,7 +145,7 @@ void SpirvStream::processInstructions()
// Instruction wordCount and opcode // Instruction wordCount and opcode
unsigned int firstWord = stream[word]; unsigned int firstWord = stream[word];
unsigned wordCount = firstWord >> WordCountShift; unsigned wordCount = firstWord >> WordCountShift;
OpCode opCode = (OpCode)(firstWord & OpCodeMask); Op opCode = (Op)(firstWord & OpCodeMask);
int nextInst = word + wordCount; int nextInst = word + wordCount;
++word; ++word;
...@@ -176,7 +177,7 @@ void SpirvStream::processInstructions() ...@@ -176,7 +177,7 @@ void SpirvStream::processInstructions()
outputTypeId(typeId); outputTypeId(typeId);
outputIndent(); outputIndent();
// Hand off the OpCode and all its operands // Hand off the Op and all its operands
disassembleInstruction(resultId, typeId, opCode, numOperands); disassembleInstruction(resultId, typeId, opCode, numOperands);
if (word != nextInst) { if (word != nextInst) {
out << " ERROR, incorrect number of operands consumed. At " << word << " instead of " << nextInst << " instruction start was " << instructionStart; out << " ERROR, incorrect number of operands consumed. At " << word << " instead of " << nextInst << " instruction start was " << instructionStart;
...@@ -277,14 +278,11 @@ void SpirvStream::disassembleString() ...@@ -277,14 +278,11 @@ void SpirvStream::disassembleString()
out << "\""; out << "\"";
} }
void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode, int numOperands) void SpirvStream::disassembleInstruction(Id resultId, Id typeId, Op opCode, int numOperands)
{ {
// Process the opcode // Process the opcode
if (opCode < 0 || opCode >= OpCount) out << (OpcodeString(opCode) + 2); // leave out the "Op"
Kill(out, "Bad opcode");
else
out << InstructionDesc[opCode].opName + 2; // Skip the "Op"
if (opCode == OpLoopMerge || opCode == OpSelectionMerge) if (opCode == OpLoopMerge || opCode == OpSelectionMerge)
nextNestedControl = stream[word]; nextNestedControl = stream[word];
...@@ -339,7 +337,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode, ...@@ -339,7 +337,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode,
// Handle textures specially, so can put out helpful strings. // Handle textures specially, so can put out helpful strings.
if (opCode == OpTypeSampler) { if (opCode == OpTypeSampler) {
disassembleIds(1); disassembleIds(1);
out << " " << DimensionString((Dimensionality)stream[word++]); out << " " << DimensionString((Dim)stream[word++]);
switch (stream[word++]) { switch (stream[word++]) {
case 0: out << " texture"; break; case 0: out << " texture"; break;
case 1: out << " image"; break; case 1: out << " image"; break;
...@@ -354,7 +352,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode, ...@@ -354,7 +352,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode,
// Handle all the parameterized operands // Handle all the parameterized operands
for (int op = 0; op < InstructionDesc[opCode].operands.getNum(); ++op) { for (int op = 0; op < InstructionDesc[opCode].operands.getNum(); ++op) {
out << " "; out << " ";
switch (InstructionDesc[opCode].operands.getClass(op)) { OperandClass operandClass = InstructionDesc[opCode].operands.getClass(op);
switch (operandClass) {
case OperandId: case OperandId:
disassembleIds(1); disassembleIds(1);
// Get names for printing "(XXX)" for readability, *after* this id // Get names for printing "(XXX)" for readability, *after* this id
...@@ -366,7 +365,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode, ...@@ -366,7 +365,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode,
disassembleIds(numOperands); disassembleIds(numOperands);
return; return;
case OperandVariableLiterals: case OperandVariableLiterals:
if (opCode == OpDecorate && stream[word - 1] == DecBuiltIn) { if (opCode == OpDecorate && stream[word - 1] == DecorationBuiltIn) {
out << BuiltInString(stream[word++]); out << BuiltInString(stream[word++]);
--numOperands; --numOperands;
++op; ++op;
...@@ -376,8 +375,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode, ...@@ -376,8 +375,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode,
case OperandVariableLiteralId: case OperandVariableLiteralId:
while (numOperands > 0) { while (numOperands > 0) {
out << std::endl; out << std::endl;
outputResultId(NoResult); outputResultId(0);
outputTypeId(NoType); outputTypeId(0);
outputIndent(); outputIndent();
out << " case "; out << " case ";
disassembleImmediates(1); disassembleImmediates(1);
...@@ -397,76 +396,23 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode, ...@@ -397,76 +396,23 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode,
case OperandLiteralString: case OperandLiteralString:
disassembleString(); disassembleString();
return; return;
case OperandSource: default:
out << SourceString((SourceLanguage)stream[word++]); assert(operandClass >= OperandSource && operandClass < OperandOpcode);
break;
case OperandExecutionModel: if (OperandClassParams[operandClass].bitmask) {
out << ExecutionModelString((ExecutionModel)stream[word++]); unsigned int mask = stream[word++];
break; if (mask == 0)
case OperandAddressing: out << "None";
out << AddressingString((AddressingModel)stream[word++]);
break;
case OperandMemory:
out << MemoryString((MemoryModel)stream[word++]);
break;
case OperandExecutionMode:
out << ExecutionModeString((ExecutionMode)stream[word++]);
break;
case OperandStorage:
out << StorageClassString((StorageClass)stream[word++]);
break;
case OperandDimensionality:
out << DimensionString((Dimensionality)stream[word++]);
break;
case OperandDecoration:
out << DecorationString((Decoration)stream[word++]);
break;
case OperandBuiltIn:
out << BuiltInString((BuiltIn)stream[word++]);
break;
case OperandSelect:
out << SelectControlString((SelectControl)stream[word++]);
break;
case OperandLoop:
out << LoopControlString((LoopControl)stream[word++]);
break;
case OperandFunction:
{
unsigned int control = stream[word++];
if (control == 0)
out << FunctionControlString(control);
else { else {
for (int m = 0; m < FunctionControlCount; ++m) { for (int m = 0; m < OperandClassParams[operandClass].ceiling; ++m) {
if (control & (1 << m)) if (mask & (1 << m))
out << FunctionControlString(m); out << OperandClassParams[operandClass].getName(m) << " ";
}
} }
break;
}
case OperandMemorySemantics:
for (int shift = 0; shift < MemorySemanticsCount; ++shift) {
unsigned lit = (stream[word] & (1 << shift));
if (lit)
out << MemorySemanticsString(lit) << " ";
} }
word++;
break;
case OperandMemoryAccess:
out << MemoryAccessString(stream[word++]);
break; break;
case OperandExecutionScope: } else
out << ExecutionScopeString(stream[word++]); out << OperandClassParams[operandClass].getName(stream[word++]);
break;
case OperandGroupOperation:
out << GroupOperationString(stream[word++]);
break;
case OperandKernelEnqueueFlags:
out << KernelEnqueueFlagsString(stream[word++]);
break;
case OperandKernelProfilingInfo:
out << KernelProfilingInfoString(stream[word++]);
break;
default:
break; break;
} }
--numOperands; --numOperands;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -37,8 +37,7 @@ ...@@ -37,8 +37,7 @@
// //
// //
// Return English versions of instruction/operand information. // Parameterize the SPIR-V enumerants.
// This can be used for disassembly, printing documentation, etc.
// //
#include "spirv.h" #include "spirv.h"
...@@ -47,7 +46,7 @@ ...@@ -47,7 +46,7 @@
namespace spv { namespace spv {
// Fill in all the parameters of the instruction set // Fill in all the parameters
void Parameterize(); void Parameterize();
// Return the English names of all the enums. // Return the English names of all the enums.
...@@ -76,6 +75,35 @@ const char* ExecutionScopeString(int); ...@@ -76,6 +75,35 @@ const char* ExecutionScopeString(int);
const char* GroupOperationString(int); const char* GroupOperationString(int);
const char* KernelEnqueueFlagsString(int); const char* KernelEnqueueFlagsString(int);
const char* KernelProfilingInfoString(int); const char* KernelProfilingInfoString(int);
const char* OpcodeString(int);
// For grouping opcodes into subsections
enum OpcodeClass {
OpClassMisc, // default, until opcode is classified
OpClassDebug,
OpClassAnnotate,
OpClassExtension,
OpClassMode,
OpClassType,
OpClassConstant,
OpClassMemory,
OpClassFunction,
OpClassTexture,
OpClassConvert,
OpClassComposite,
OpClassArithmetic,
OpClassRelationalLogical,
OpClassDerivative,
OpClassFlowControl,
OpClassAtomic,
OpClassPrimitive,
OpClassBarrier,
OpClassGroup,
OpClassDeviceSideEnqueue,
OpClassPipe,
OpClassCount
};
// For parameterizing operands. // For parameterizing operands.
enum OperandClass { enum OperandClass {
...@@ -99,35 +127,85 @@ enum OperandClass { ...@@ -99,35 +127,85 @@ enum OperandClass {
OperandFPFastMath, OperandFPFastMath,
OperandFPRoundingMode, OperandFPRoundingMode,
OperandLinkageType, OperandLinkageType,
OperandAccessQualifier,
OperandFuncParamAttr, OperandFuncParamAttr,
OperandDecoration, OperandDecoration,
OperandBuiltIn, OperandBuiltIn,
OperandSelect, OperandSelect,
OperandLoop, OperandLoop,
OperandFunction, OperandFunction,
OperandAccessQualifier,
OperandMemorySemantics, OperandMemorySemantics,
OperandMemoryAccess, OperandMemoryAccess,
OperandExecutionScope, OperandExecutionScope,
OperandGroupOperation, OperandGroupOperation,
OperandKernelEnqueueFlags, OperandKernelEnqueueFlags,
OperandKernelProfilingInfo, OperandKernelProfilingInfo,
OperandOpcode,
OperandCount OperandCount
}; };
// Set of capabilities. Generally, something is assumed to be in core,
// if nothing else is said. So, these are used to identify when something
// requires a specific capability to be declared.
enum Capability {
CapMatrix,
CapShader,
CapGeom,
CapTess,
CapAddr,
CapLink,
CapKernel
};
// Any specific enum can have a set of capabilities that allow it:
typedef std::vector<Capability> EnumCaps;
// Parameterize a set of operands with their OperandClass(es) and descriptions. // Parameterize a set of operands with their OperandClass(es) and descriptions.
class OperandParameters { class OperandParameters {
public: public:
OperandParameters() { } OperandParameters() { }
void push(OperandClass oc) void push(OperandClass oc, const char* d)
{ {
opClass.push_back(oc); opClass.push_back(oc);
desc.push_back(d);
} }
OperandClass getClass(int op) const { return opClass[op]; } OperandClass getClass(int op) const { return opClass[op]; }
const char* getDesc(int op) const { return desc[op]; }
int getNum() const { return (int)opClass.size(); } int getNum() const { return (int)opClass.size(); }
protected: protected:
std::vector<OperandClass> opClass; std::vector<OperandClass> opClass;
std::vector<const char*> desc;
};
// Parameterize an enumerant
class EnumParameters {
public:
EnumParameters() : desc(0) { }
EnumCaps caps;
const char* desc;
};
// Parameterize a set of enumerants that form an enum
class EnumDefinition : public EnumParameters {
public:
EnumDefinition() :
ceiling(0), bitmask(false), getName(0), enumParams(0), operandParams(0) { }
void set(int ceil, const char* (*name)(int), EnumParameters* ep, bool mask = false)
{
ceiling = ceil;
getName = name;
bitmask = mask;
enumParams = ep;
}
void setOperands(OperandParameters* op) { operandParams = op; }
int ceiling; // ceiling of enumerants
bool bitmask; // true if these enumerants combine into a bitmask
const char* (*getName)(int); // a function that returns the name for each enumerant value (or shift)
EnumParameters* enumParams; // parameters for each individual enumerant
OperandParameters* operandParams; // sets of operands
}; };
// Parameterize an instruction's logical format, including its known set of operands, // Parameterize an instruction's logical format, including its known set of operands,
...@@ -137,7 +215,8 @@ public: ...@@ -137,7 +215,8 @@ public:
InstructionParameters() : InstructionParameters() :
typePresent(true), // most normal, only exceptions have to be spelled out typePresent(true), // most normal, only exceptions have to be spelled out
resultPresent(true), // most normal, only exceptions have to be spelled out resultPresent(true), // most normal, only exceptions have to be spelled out
opName(0) opDesc(0),
opClass(OpClassMisc)
{ } { }
void setResultAndType(bool r, bool t) void setResultAndType(bool r, bool t)
...@@ -149,7 +228,9 @@ public: ...@@ -149,7 +228,9 @@ public:
bool hasResult() const { return resultPresent != 0; } bool hasResult() const { return resultPresent != 0; }
bool hasType() const { return typePresent != 0; } bool hasType() const { return typePresent != 0; }
const char* opName; const char* opDesc;
EnumCaps capabilities;
OpcodeClass opClass;
OperandParameters operands; OperandParameters operands;
protected: protected:
...@@ -157,8 +238,19 @@ protected: ...@@ -157,8 +238,19 @@ protected:
int resultPresent : 1; int resultPresent : 1;
}; };
const int OpcodeCeiling = 267;
// The set of objects that hold all the instruction/operand // The set of objects that hold all the instruction/operand
// parameterization information. // parameterization information.
extern InstructionParameters InstructionDesc[spv::OpCount]; extern InstructionParameters InstructionDesc[];
// These hold definitions of the enumerants used for operands
extern EnumDefinition OperandClassParams[];
const char* GetOperandDesc(OperandClass operand);
void PrintImmediateRow(int imm, const char* name, const EnumParameters* enumParams, bool caps, bool hex = false);
const char* AccessQualifierString(int attr);
void PrintOperands(const OperandParameters& operands, int reservedOperands);
}; // end namespace spv }; // end namespace spv
...@@ -21,742 +21,1281 @@ ...@@ -21,742 +21,1281 @@
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/ */
// /*
// Enumeration tokens for SPIR V. ** This header is automatically generated by the same tool that creates
// ** the Binary Section of the SPIR-V specification.
*/
/*
** Specification revision 29.
** Enumeration tokens for SPIR-V, in three styles: C, C++, generic.
** - C++ will have the tokens in the "spv" name space, with no prefix.
** - C will have tokens with as "Spv" prefix.
**
** Some tokens act like mask values, which can be OR'd together,
** while others are mutually exclusive. The mask-like ones have
** "Mask" in their name, and a parallel enum that has the shift
** amount (1 << x) for each corresponding enumerant.
*/
#pragma once
#ifndef spirv_H #ifndef spirv_H
#define spirv_H #define spirv_H
#ifdef __cplusplus #ifdef __cplusplus
namespace spv{
#endif namespace spv {
const int MagicNumber = 0x07230203; const int MagicNumber = 0x07230203;
const int Version = 99; const int Version = 99;
typedef unsigned int Id; typedef unsigned int Id;
const Id NoResult = 0;
const Id NoType = 0;
const unsigned int OpCodeMask = 0xFFFF; const unsigned int OpCodeMask = 0xFFFF;
const unsigned int WordCountShift = 16; const unsigned int WordCountShift = 16;
// Set of capabilities. Generally, something is assumed to be in core,
// if nothing else is said. So, these are used to identify when something
// requires a specific capability to be declared.
enum Capability {
CapMatrix,
CapShader,
CapGeom,
CapTess,
CapAddr,
CapLink,
CapKernel
};
// What language is the source code in? Note the OpSource instruction has a separate
// operand for the version number, this is just the language name. The GLSL
// compatibility profile will be indicated by using an OpSourceExtension string.
enum SourceLanguage { enum SourceLanguage {
LangUnknown, SourceLanguageUnknown = 0,
LangESSL, SourceLanguageESSL = 1,
LangGLSL, SourceLanguageGLSL = 2,
LangOpenCL, SourceLanguageOpenCL = 3,
LangCount // guard for validation, "default:" statements, etc.
}; };
// Used per entry point to communicate the "stage" or other model of
// execution used by that entry point.
// See OpEntryPoint.
enum ExecutionModel { enum ExecutionModel {
ModelVertex, ExecutionModelVertex = 0,
ModelTessellationControl, ExecutionModelTessellationControl = 1,
ModelTessellationEvaluation, ExecutionModelTessellationEvaluation = 2,
ModelGeometry, ExecutionModelGeometry = 3,
ModelFragment, ExecutionModelFragment = 4,
ModelGLCompute, ExecutionModelGLCompute = 5,
ModelKernel, ExecutionModelKernel = 6,
ModelCount // guard for validation, "default:" statements, etc.
}; };
// Used as an argument to OpMemoryModel
enum AddressingModel { enum AddressingModel {
AddressingLogical, AddressingModelLogical = 0,
AddressingPhysical32, AddressingModelPhysical32 = 1,
AddressingPhysical64, AddressingModelPhysical64 = 2,
AddressingCount // guard for validation, "default:" statements, etc.
}; };
// Used as an argment to OpMemoryModel
enum MemoryModel { enum MemoryModel {
MemorySimple, MemoryModelSimple = 0,
MemoryGLSL450, MemoryModelGLSL450 = 1,
MemoryOCL12, MemoryModelOpenCL12 = 2,
MemoryOCL20, MemoryModelOpenCL20 = 3,
MemoryOCL21, MemoryModelOpenCL21 = 4,
MemoryCount // guard for validation, "default:" statements, etc.
}; };
// Used per entry point to communicate modes related to input, output, and execution.
// See OpExecutionMode.
enum ExecutionMode { enum ExecutionMode {
ExecutionInvocations, ExecutionModeInvocations = 0,
ExecutionSpacingEqual, ExecutionModeSpacingEqual = 1,
ExecutionSpacingFractionalEven, ExecutionModeSpacingFractionalEven = 2,
ExecutionSpacingFractionalOdd, ExecutionModeSpacingFractionalOdd = 3,
ExecutionVertexOrderCw, ExecutionModeVertexOrderCw = 4,
ExecutionVertexOrderCcw, ExecutionModeVertexOrderCcw = 5,
ExecutionPixelCenterInteger, ExecutionModePixelCenterInteger = 6,
ExecutionOriginUpperLeft, ExecutionModeOriginUpperLeft = 7,
ExecutionEarlyFragmentTests, ExecutionModeEarlyFragmentTests = 8,
ExecutionPointMode, ExecutionModePointMode = 9,
ExecutionXfb, ExecutionModeXfb = 10,
ExecutionDepthReplacing, ExecutionModeDepthReplacing = 11,
ExecutionDepthAny, ExecutionModeDepthAny = 12,
ExecutionDepthGreater, ExecutionModeDepthGreater = 13,
ExecutionDepthLess, ExecutionModeDepthLess = 14,
ExecutionDepthUnchanged, ExecutionModeDepthUnchanged = 15,
ExecutionLocalSize, ExecutionModeLocalSize = 16,
ExecutionLocalSizeHint, ExecutionModeLocalSizeHint = 17,
ExecutionModeInputPoints = 18,
ExecutionInputPoints, ExecutionModeInputLines = 19,
ExecutionInputLines, ExecutionModeInputLinesAdjacency = 20,
ExecutionInputLinesAdjacency, ExecutionModeInputTriangles = 21,
ExecutionInputTriangles, ExecutionModeInputTrianglesAdjacency = 22,
ExecutionInputTrianglesAdjacency, ExecutionModeInputQuads = 23,
ExecutionInputQuads, ExecutionModeInputIsolines = 24,
ExecutionInputIsolines, ExecutionModeOutputVertices = 25,
ExecutionModeOutputPoints = 26,
ExecutionOutputVertices, ExecutionModeOutputLineStrip = 27,
ExecutionOutputPoints, ExecutionModeOutputTriangleStrip = 28,
ExecutionOutputLineStrip, ExecutionModeVecTypeHint = 29,
ExecutionOutputTriangleStrip, ExecutionModeContractionOff = 30,
ExecutionVecTypeHint,
ExecutionContractionOff,
ExecutionModeCount // guard for validation, "default:" statements, etc.
}; };
enum StorageClass { enum StorageClass {
StorageConstantUniform, StorageClassUniformConstant = 0,
StorageInput, StorageClassInput = 1,
StorageUniform, StorageClassUniform = 2,
StorageOutput, StorageClassOutput = 3,
StorageWorkgroupLocal, StorageClassWorkgroupLocal = 4,
StorageWorkgroupGlobal, StorageClassWorkgroupGlobal = 5,
StoragePrivateGlobal, StorageClassPrivateGlobal = 6,
StorageFunction, StorageClassFunction = 7,
StorageGeneric, StorageClassGeneric = 8,
StoragePrivate, StorageClassPrivate = 9,
StorageAtomicCounter, StorageClassAtomicCounter = 10,
StorageCount // guard for validation, "default:" statements, etc. };
};
enum Dim {
// Dimensionalities currently used for sampling. Dim1D = 0,
// See TypeSampler in TypeClass. Dim2D = 1,
enum Dimensionality { Dim3D = 2,
Dim1D, DimCube = 3,
Dim2D, DimRect = 4,
Dim3D, DimBuffer = 5,
DimCube, };
DimRect,
DimBuffer,
DimCount // guard for validation, "default:" statements, etc.
};
// Sampler addressing mode.
enum SamplerAddressingMode { enum SamplerAddressingMode {
SamplerAddressingNone = 0, SamplerAddressingModeNone = 0,
SamplerAddressingClampToEdge = 2, SamplerAddressingModeClampToEdge = 2,
SamplerAddressingClamp = 4, SamplerAddressingModeClamp = 4,
SamplerAddressingRepeat = 6, SamplerAddressingModeRepeat = 6,
SamplerAddressingRepeatMirrored = 8, SamplerAddressingModeRepeatMirrored = 8,
SamplerAddressingModeLast,
}; };
// Sampler filter mode.
enum SamplerFilterMode { enum SamplerFilterMode {
SamplerFilterNearest = 0x10, SamplerFilterModeNearest = 16,
SamplerFilterLinear = 0x20, SamplerFilterModeLinear = 32,
SamplerFilterModeLast,
}; };
// FP Fast Math Mode. enum FPFastMathModeShift {
enum FPFastMath { FPFastMathModeNotNaNShift = 0,
FPFastMathNNan = 0, // assume parameters and result are not NaN. FPFastMathModeNotInfShift = 1,
FPFastMathNInf = 0x02, // assume parameters and result are not +/- Inf. FPFastMathModeNSZShift = 2,
FPFastMathNSZ = 0x04, // treat the sign of a zero parameter or result as insignificant. FPFastMathModeAllowRecipShift = 3,
FPFastMathARcp = 0x08, // allow the usage of reciprocal rather than perform a division. FPFastMathModeFastShift = 4,
FPFastMathFast = 0x10, // allow Algebraic transformations according to real number associative and distibutive algebra. This flag implies all the others. };
FPFastMathLast,
enum FPFastMathModeMask {
FPFastMathModeMaskNone = 0,
FPFastMathModeNotNaNMask = 0x00000001,
FPFastMathModeNotInfMask = 0x00000002,
FPFastMathModeNSZMask = 0x00000004,
FPFastMathModeAllowRecipMask = 0x00000008,
FPFastMathModeFastMask = 0x00000010,
}; };
// FP Fast Math Mode.
enum FPRoundingMode { enum FPRoundingMode {
FPRoundRTE, // round to nearest even. FPRoundingModeRTE = 0,
FPRoundRTZ, // round towards zero. FPRoundingModeRTZ = 1,
FPRoundRTP, // round towards positive infinity. FPRoundingModeRTP = 2,
FPRoundRTN, // round towards negative infinity. FPRoundingModeRTN = 3,
FPRoundLast,
}; };
// Global identifier linkage types (by default the linkage type of global identifiers is private. This means that they are only accessible to objects inside the module.)
enum LinkageType { enum LinkageType {
LinkageExport, // accessible by objects in other modules as well. LinkageTypeExport = 0,
LinkageImport, // a forward declaration to a global identifier that exists in another module. LinkageTypeImport = 1,
LinkageLast,
}; };
// Access Qualifiers for OpenCL pipes and images
enum AccessQualifier { enum AccessQualifier {
AccessQualReadOnly, AccessQualifierReadOnly = 0,
AccessQualWriteOnly, AccessQualifierWriteOnly = 1,
AccessQualReadWrite, AccessQualifierReadWrite = 2,
AccessQualLast,
}; };
// Function argument attributes
enum FunctionParameterAttribute { enum FunctionParameterAttribute {
FuncParamAttrZext, // value should be zero extended if needed FunctionParameterAttributeZext = 0,
FuncParamAttrSext, // value should be sign extended if needed FunctionParameterAttributeSext = 1,
FuncParamAttrByval, // only valid for pointer parameters (not for ret value), this indicates that the pointer parameter should really be passed by value to the function. FunctionParameterAttributeByVal = 2,
FuncParamAttrSret, // indicates that the pointer parameter specifies the address of a structure that is the return value of the function in the source program. only applicable to the first parameter FunctionParameterAttributeSret = 3,
FuncParamAttrNoAlias, FunctionParameterAttributeNoAlias = 4,
FuncParamAttrNoCapture, FunctionParameterAttributeNoCapture = 5,
FuncParamAttrSVM, FunctionParameterAttributeSVM = 6,
FuncParamAttrNoWrite, FunctionParameterAttributeNoWrite = 7,
FuncParamAttrNoReadWrite, FunctionParameterAttributeNoReadWrite = 8,
FuncParamAttrLast, // guard for validation, "default:" statements, etc.
}; };
// Extra forms of "qualification" to add as needed. See OpDecorate.
enum Decoration { enum Decoration {
// For legacy ES precision qualifiers; newer language DecorationPrecisionLow = 0,
// designs can use the "num-bits" feature in TypeClass. DecorationPrecisionMedium = 1,
// The precision qualifiers may be decorated on type <id>s or instruction <id>s. DecorationPrecisionHigh = 2,
DecPrecisionLow, DecorationBlock = 3,
DecPrecisionMedium, DecorationBufferBlock = 4,
DecPrecisionHigh, DecorationRowMajor = 5,
DecorationColMajor = 6,
DecBlock, // basic in/out/uniform block, applied only to types of TypeStruct DecorationGLSLShared = 7,
DecBufferBlock, // shader storage buffer block DecorationGLSLStd140 = 8,
DecRowMajor, DecorationGLSLStd430 = 9,
DecColMajor, DecorationGLSLPacked = 10,
DecGLSLShared, DecorationSmooth = 11,
DecGLSLStd140, DecorationNoperspective = 12,
DecGLSLStd430, DecorationFlat = 13,
DecGLSLPacked, DecorationPatch = 14,
DecSmooth, DecorationCentroid = 15,
DecNoperspective, DecorationSample = 16,
DecFlat, DecorationInvariant = 17,
DecPatch, DecorationRestrict = 18,
DecCentroid, DecorationAliased = 19,
DecSample, DecorationVolatile = 20,
DecInvariant, DecorationConstant = 21,
DecRestrict, DecorationCoherent = 22,
DecAliased, DecorationNonwritable = 23,
DecVolatile, DecorationNonreadable = 24,
DecConstant, DecorationUniform = 25,
DecCoherent, DecorationNoStaticUse = 26,
DecNonwritable, DecorationCPacked = 27,
DecNonreadable, DecorationSaturatedConversion = 28,
DecUniform, DecorationStream = 29,
DecNoStaticUse, DecorationLocation = 30,
DecorationComponent = 31,
DecCPacked, DecorationIndex = 32,
DecFPSaturatedConv, DecorationBinding = 33,
DecorationDescriptorSet = 34,
// these all take one additional operand DecorationOffset = 35,
DecStream, DecorationAlignment = 36,
DecLocation, DecorationXfbBuffer = 37,
DecComponent, DecorationStride = 38,
DecIndex, DecorationBuiltIn = 39,
DecBinding, DecorationFuncParamAttr = 40,
DecDescriptorSet, DecorationFPRoundingMode = 41,
DecOffset, DecorationFPFastMathMode = 42,
DecAlignment, DecorationLinkageAttributes = 43,
DecXfbBuffer, DecorationSpecId = 44,
DecStride,
DecBuiltIn,
DecFuncParamAttr,
DecFPRoundingMode,
DecFPFastMathMode,
DecLinkageType,
DecSpecId,
DecCount // guard for validation, "default:" statements, etc.
}; };
enum BuiltIn { enum BuiltIn {
BuiltInPosition, BuiltInPosition = 0,
BuiltInPointSize, BuiltInPointSize = 1,
BuiltInClipVertex, BuiltInClipVertex = 2,
BuiltInClipDistance, BuiltInClipDistance = 3,
BuiltInCullDistance, BuiltInCullDistance = 4,
BuiltInVertexId, BuiltInVertexId = 5,
BuiltInInstanceId, BuiltInInstanceId = 6,
BuiltInPrimitiveId, BuiltInPrimitiveId = 7,
BuiltInInvocationId, BuiltInInvocationId = 8,
BuiltInLayer, BuiltInLayer = 9,
BuiltInViewportIndex, BuiltInViewportIndex = 10,
BuiltInTessLevelOuter, BuiltInTessLevelOuter = 11,
BuiltInTessLevelInner, BuiltInTessLevelInner = 12,
BuiltInTessCoord, BuiltInTessCoord = 13,
BuiltInPatchVertices, BuiltInPatchVertices = 14,
BuiltInFragCoord, BuiltInFragCoord = 15,
BuiltInPointCoord, BuiltInPointCoord = 16,
BuiltInFrontFacing, BuiltInFrontFacing = 17,
BuiltInSampleId, BuiltInSampleId = 18,
BuiltInSamplePosition, BuiltInSamplePosition = 19,
BuiltInSampleMask, BuiltInSampleMask = 20,
BuiltInFragColor, BuiltInFragColor = 21,
BuiltInFragDepth, BuiltInFragDepth = 22,
BuiltInHelperInvocation, BuiltInHelperInvocation = 23,
BuiltInNumWorkgroups = 24,
// OpenGL compute stage, OpenCL work item built-ins BuiltInWorkgroupSize = 25,
BuiltInNumWorkgroups, // number of work-groups that will execute a kernel BuiltInWorkgroupId = 26,
BuiltInWorkgroupSize, // OpenCL number of local work-items BuiltInLocalInvocationId = 27,
BuiltInWorkgroupId, // OpenCL work group id BuiltInGlobalInvocationId = 28,
BuiltInLocalInvocationId, // OpenCL local work item id (decorates a vector3 i32/i64) BuiltInLocalInvocationIndex = 29,
BuiltInGlobalInvocationId, // OpenCL global work item id (decorates a vector3 i32/i64) BuiltInWorkDim = 30,
BuiltInLocalInvocationIndex, // not in use in OpenCL BuiltInGlobalSize = 31,
BuiltInWorkDim, // OpenCL number of dimensions in use (decorates a scalar i32/i64) BuiltInEnqueuedWorkgroupSize = 32,
BuiltInGlobalSize, // OpenCL number of global work items, per dimension (decorates a vector3 i32/i64) BuiltInGlobalOffset = 33,
BuiltInEnqueuedWorkgroupSize, // OpenCL 2.0 only, get local size BuiltInGlobalLinearId = 34,
BuiltInGlobalOffset, // OpenCL offset values specified global_work_offset BuiltInWorkgroupLinearId = 35,
BuiltInGlobalLinearId, // OpenCL 2.0 only, work items 1-dimensional global ID. BuiltInSubgroupSize = 36,
BuiltInWorkgroupLinearId, // OpenCL 2.0 only work items 1-dimensional local ID. BuiltInSubgroupMaxSize = 37,
BuiltInNumSubgroups = 38,
// OpenCL 2.0 subgroups BuiltInNumEnqueuedSubgroups = 39,
BuiltInSubgroupSize, // Returns the number of work-items in the subgroup BuiltInSubgroupId = 40,
BuiltInSubgroupMaxSize, // Returns the maximum size of a subgroup within the dispatch BuiltInSubgroupLocalInvocationId = 41,
BuiltInNumSubgroups, // Returns the maximum size of a subgroup within the dispatch };
BuiltInNumEnqueuedSubgroups, // Returns the maximum size of a subgroup within the dispatch
BuiltInSubgroupId, // enum SelectionControlShift {
BuiltInSubgroupLocalInvocationId, // Returns the unique work-item ID within the current subgroup SelectionControlFlattenShift = 0,
SelectionControlDontFlattenShift = 1,
BuiltInCount // guard for validation, "default:" statements, etc. };
};
enum SelectionControlMask {
enum SelectControl { SelectionControlMaskNone = 0,
SelectControlNone, SelectionControlFlattenMask = 0x00000001,
SelectControlFlatten, SelectionControlDontFlattenMask = 0x00000002,
SelectControlDontFlatten, };
SelectControlCount, // guard for validation, "default:" statements, etc. enum LoopControlShift {
}; LoopControlUnrollShift = 0,
LoopControlDontUnrollShift = 1,
enum LoopControl { };
LoopControlNone,
LoopControlUnroll, enum LoopControlMask {
LoopControlDontUnroll, LoopControlMaskNone = 0,
LoopControlUnrollMask = 0x00000001,
LoopControlCount, LoopControlDontUnrollMask = 0x00000002,
};
enum FunctionControlShift {
FunctionControlInlineShift = 0,
FunctionControlDontInlineShift = 1,
FunctionControlPureShift = 2,
FunctionControlConstShift = 3,
}; };
enum FunctionControlMask { enum FunctionControlMask {
FunctionControlNone = 0x0, FunctionControlMaskNone = 0,
FunctionControlInline = 0x1, FunctionControlInlineMask = 0x00000001,
FunctionControlDontInline = 0x2, FunctionControlDontInlineMask = 0x00000002,
FunctionControlPure = 0x4, FunctionControlPureMask = 0x00000004,
FunctionControlConst = 0x8, FunctionControlConstMask = 0x00000008,
};
FunctionControlCount = 4, enum MemorySemanticsShift {
MemorySemanticsRelaxedShift = 0,
MemorySemanticsSequentiallyConsistentShift = 1,
MemorySemanticsAcquireShift = 2,
MemorySemanticsReleaseShift = 3,
MemorySemanticsUniformMemoryShift = 4,
MemorySemanticsSubgroupMemoryShift = 5,
MemorySemanticsWorkgroupLocalMemoryShift = 6,
MemorySemanticsWorkgroupGlobalMemoryShift = 7,
MemorySemanticsAtomicCounterMemoryShift = 8,
MemorySemanticsImageMemoryShift = 9,
}; };
enum MemorySemanticsMask { enum MemorySemanticsMask {
MemorySemanticsRelaxed = 0x0001, MemorySemanticsMaskNone = 0,
MemorySemanticsSequentiallyConsistent = 0x0002, MemorySemanticsRelaxedMask = 0x00000001,
MemorySemanticsAcquire = 0x0004, MemorySemanticsSequentiallyConsistentMask = 0x00000002,
MemorySemanticsRelease = 0x0008, MemorySemanticsAcquireMask = 0x00000004,
MemorySemanticsReleaseMask = 0x00000008,
MemorySemanticsUniform = 0x0010, MemorySemanticsUniformMemoryMask = 0x00000010,
MemorySemanticsSubgroup = 0x0020, MemorySemanticsSubgroupMemoryMask = 0x00000020,
MemorySemanticsWorkgroupLocal = 0x0040, MemorySemanticsWorkgroupLocalMemoryMask = 0x00000040,
MemorySemanticsWorkgroupGlobal = 0x0080, MemorySemanticsWorkgroupGlobalMemoryMask = 0x00000080,
MemorySemanticsAtomicCounter = 0x0100, MemorySemanticsAtomicCounterMemoryMask = 0x00000100,
MemorySemanticsImage = 0x0200, MemorySemanticsImageMemoryMask = 0x00000200,
MemorySemanticsAllMemory = 0x03FF, };
MemorySemanticsCount = 10 enum MemoryAccessShift {
MemoryAccessVolatileShift = 0,
MemoryAccessAlignedShift = 1,
}; };
enum MemoryAccessMask { enum MemoryAccessMask {
MemoryAccessVolatile = 0x0001, MemoryAccessMaskNone = 0,
MemoryAccessAligned = 0x0002, MemoryAccessVolatileMask = 0x00000001,
MemoryAccessAlignedMask = 0x00000002,
MemoryAccessCount = 2
}; };
enum ExecutionScope { enum ExecutionScope {
ExecutionScopeCrossDevice, ExecutionScopeCrossDevice = 0,
ExecutionScopeDevice, ExecutionScopeDevice = 1,
ExecutionScopeWorkgroup, ExecutionScopeWorkgroup = 2,
ExecutionScopeSubgroup, ExecutionScopeSubgroup = 3,
ExecutionScopeCount // guard for validation, "default:" statements, etc.
}; };
enum GroupOperation { enum GroupOperation {
GroupOpReduce, GroupOperationReduce = 0,
GroupOpInclusiveScan, GroupOperationInclusiveScan = 1,
GroupOpExclusiveScan, GroupOperationExclusiveScan = 2,
GroupOpCount
}; };
enum KernelEnqueueFlags { enum KernelEnqueueFlags {
EnqFlagNoWait, KernelEnqueueFlagsNoWait = 0,
EnqFlagWaitKernel, KernelEnqueueFlagsWaitKernel = 1,
EnqFlagWaitWaitWorgGroup, KernelEnqueueFlagsWaitWorkGroup = 2,
};
EnqFlagCount
}; enum KernelProfilingInfoShift {
KernelProfilingInfoCmdExecTimeShift = 0,
enum KernelProfilingInfo { };
ProfInfoCmdExecTime = 0x01,
ProfilingInfoCount = 1 enum KernelProfilingInfoMask {
}; KernelProfilingInfoMaskNone = 0,
KernelProfilingInfoCmdExecTimeMask = 0x00000001,
enum OpCode { };
OpNop = 0, // Not used.
enum Op {
OpSource, OpNop = 0,
OpSourceExtension, OpSource = 1,
OpExtension, OpSourceExtension = 2,
OpExtInstImport, OpExtension = 3,
OpExtInstImport = 4,
OpMemoryModel, OpMemoryModel = 5,
OpEntryPoint, OpEntryPoint = 6,
OpExecutionMode, OpExecutionMode = 7,
OpTypeVoid = 8,
OpTypeVoid, OpTypeBool = 9,
OpTypeBool, OpTypeInt = 10,
OpTypeInt, OpTypeFloat = 11,
OpTypeFloat, OpTypeVector = 12,
OpTypeVector, OpTypeMatrix = 13,
OpTypeMatrix, OpTypeSampler = 14,
OpTypeSampler, OpTypeFilter = 15,
OpTypeFilter, OpTypeArray = 16,
OpTypeArray, OpTypeRuntimeArray = 17,
OpTypeRuntimeArray, OpTypeStruct = 18,
OpTypeStruct, OpTypeOpaque = 19,
OpTypeOpaque, OpTypePointer = 20,
OpTypePointer, OpTypeFunction = 21,
OpTypeFunction, OpTypeEvent = 22,
OpTypeEvent, OpTypeDeviceEvent = 23,
OpTypeDeviceEvent, OpTypeReserveId = 24,
OpTypeReserveId, OpTypeQueue = 25,
OpTypeQueue, OpTypePipe = 26,
OpTypePipe, OpConstantTrue = 27,
OpConstantFalse = 28,
OpConstantTrue, OpConstant = 29,
OpConstantFalse, OpConstantComposite = 30,
OpConstant, OpConstantSampler = 31,
OpConstantComposite, OpConstantNullPointer = 32,
OpConstantSampler, OpConstantNullObject = 33,
OpConstantNullPointer, OpSpecConstantTrue = 34,
OpConstantNullObject, OpSpecConstantFalse = 35,
OpSpecConstant = 36,
OpSpecConstantTrue, OpSpecConstantComposite = 37,
OpSpecConstantFalse, OpVariable = 38,
OpSpecConstant, OpVariableArray = 39,
OpSpecConstantComposite, OpFunction = 40,
OpFunctionParameter = 41,
OpVariable, OpFunctionEnd = 42,
OpVariableArray, OpFunctionCall = 43,
OpExtInst = 44,
OpFunction, OpUndef = 45,
OpFunctionParameter, OpLoad = 46,
OpFunctionEnd, OpStore = 47,
OpFunctionCall, OpPhi = 48,
OpDecorationGroup = 49,
OpExtInst, OpDecorate = 50,
OpMemberDecorate = 51,
OpUndef, OpGroupDecorate = 52,
OpGroupMemberDecorate = 53,
OpLoad, OpName = 54,
OpStore, OpMemberName = 55,
OpString = 56,
OpPhi, OpLine = 57,
OpVectorExtractDynamic = 58,
OpDecorationGroup, OpVectorInsertDynamic = 59,
OpDecorate, OpVectorShuffle = 60,
OpMemberDecorate, OpCompositeConstruct = 61,
OpGroupDecorate, OpCompositeExtract = 62,
OpGroupMemberDecorate, OpCompositeInsert = 63,
OpCopyObject = 64,
OpName, OpCopyMemory = 65,
OpMemberName, OpCopyMemorySized = 66,
OpString, OpSampler = 67,
OpLine, OpTextureSample = 68,
OpTextureSampleDref = 69,
OpVectorExtractDynamic, OpTextureSampleLod = 70,
OpVectorInsertDynamic, OpTextureSampleProj = 71,
OpVectorShuffle, OpTextureSampleGrad = 72,
OpTextureSampleOffset = 73,
OpCompositeConstruct, OpTextureSampleProjLod = 74,
OpCompositeExtract, OpTextureSampleProjGrad = 75,
OpCompositeInsert, OpTextureSampleLodOffset = 76,
OpTextureSampleProjOffset = 77,
OpCopyObject, OpTextureSampleGradOffset = 78,
OpCopyMemory, OpTextureSampleProjLodOffset = 79,
OpCopyMemorySized, OpTextureSampleProjGradOffset = 80,
OpTextureFetchTexelLod = 81,
OpSampler, OpTextureFetchTexelOffset = 82,
OpTextureFetchSample = 83,
OpTextureSample, OpTextureFetchTexel = 84,
OpTextureSampleDref, OpTextureGather = 85,
OpTextureSampleLod, OpTextureGatherOffset = 86,
OpTextureSampleProj, OpTextureGatherOffsets = 87,
OpTextureSampleGrad, OpTextureQuerySizeLod = 88,
OpTextureSampleOffset, OpTextureQuerySize = 89,
OpTextureSampleProjLod, OpTextureQueryLod = 90,
OpTextureSampleProjGrad, OpTextureQueryLevels = 91,
OpTextureSampleLodOffset, OpTextureQuerySamples = 92,
OpTextureSampleProjOffset, OpAccessChain = 93,
OpTextureSampleGradOffset, OpInBoundsAccessChain = 94,
OpTextureSampleProjLodOffset, OpSNegate = 95,
OpTextureSampleProjGradOffset, OpFNegate = 96,
OpNot = 97,
OpTextureFetchTexel, OpAny = 98,
OpTextureFetchTexelOffset, OpAll = 99,
OpTextureFetchSample, OpConvertFToU = 100,
OpTextureFetchBuffer, OpConvertFToS = 101,
OpTextureGather, OpConvertSToF = 102,
OpTextureGatherOffset, OpConvertUToF = 103,
OpTextureGatherOffsets, OpUConvert = 104,
OpSConvert = 105,
OpTextureQuerySizeLod, OpFConvert = 106,
OpTextureQuerySize, OpConvertPtrToU = 107,
OpTextureQueryLod, OpConvertUToPtr = 108,
OpTextureQueryLevels, OpPtrCastToGeneric = 109,
OpTextureQuerySamples, OpGenericCastToPtr = 110,
OpBitcast = 111,
OpAccessChain, OpTranspose = 112,
OpInBoundsAccessChain, OpIsNan = 113,
OpIsInf = 114,
OpSNegate, OpIsFinite = 115,
OpFNegate, OpIsNormal = 116,
OpSignBitSet = 117,
OpNot, OpLessOrGreater = 118,
OpOrdered = 119,
OpAny, OpUnordered = 120,
OpAll, OpArrayLength = 121,
OpIAdd = 122,
OpConvertFToU, OpFAdd = 123,
OpConvertFToS, OpISub = 124,
OpConvertSToF, OpFSub = 125,
OpConvertUToF, OpIMul = 126,
OpUConvert, OpFMul = 127,
OpSConvert, OpUDiv = 128,
OpFConvert, OpSDiv = 129,
OpConvertPtrToU, OpFDiv = 130,
OpConvertUToPtr, OpUMod = 131,
OpPtrCastToGeneric, // cast a pointer storage class to be in storage generic OpSRem = 132,
OpGenericCastToPtr, // cast a pointer in the generic storage class generic to another storage class OpSMod = 133,
OpBitcast, OpFRem = 134,
OpFMod = 135,
OpTranspose, OpVectorTimesScalar = 136,
OpMatrixTimesScalar = 137,
OpIsNan, OpVectorTimesMatrix = 138,
OpIsInf, OpMatrixTimesVector = 139,
OpIsFinite, OpMatrixTimesMatrix = 140,
OpIsNormal, OpOuterProduct = 141,
OpSignBitSet, OpDot = 142,
OpLessOrGreater, OpShiftRightLogical = 143,
OpOrdered, OpShiftRightArithmetic = 144,
OpUnordered, OpShiftLeftLogical = 145,
OpLogicalOr = 146,
OpArrayLength, OpLogicalXor = 147,
OpLogicalAnd = 148,
OpIAdd, OpBitwiseOr = 149,
OpFAdd, OpBitwiseXor = 150,
OpISub, OpBitwiseAnd = 151,
OpFSub, OpSelect = 152,
OpIMul, OpIEqual = 153,
OpFMul, OpFOrdEqual = 154,
OpUDiv, OpFUnordEqual = 155,
OpSDiv, OpINotEqual = 156,
OpFDiv, OpFOrdNotEqual = 157,
OpFUnordNotEqual = 158,
OpUMod, OpULessThan = 159,
OpSRem, OpSLessThan = 160,
OpSMod, OpFOrdLessThan = 161,
OpFRem, OpFUnordLessThan = 162,
OpFMod, OpUGreaterThan = 163,
OpSGreaterThan = 164,
OpVectorTimesScalar, OpFOrdGreaterThan = 165,
OpMatrixTimesScalar, OpFUnordGreaterThan = 166,
OpVectorTimesMatrix, OpULessThanEqual = 167,
OpMatrixTimesVector, OpSLessThanEqual = 168,
OpMatrixTimesMatrix, OpFOrdLessThanEqual = 169,
OpOuterProduct, OpFUnordLessThanEqual = 170,
OpUGreaterThanEqual = 171,
OpDot, OpSGreaterThanEqual = 172,
OpFOrdGreaterThanEqual = 173,
OpShiftRightLogical, OpFUnordGreaterThanEqual = 174,
OpShiftRightArithmetic, OpDPdx = 175,
OpShiftLeftLogical, OpDPdy = 176,
OpLogicalOr, OpFwidth = 177,
OpLogicalXor, OpDPdxFine = 178,
OpLogicalAnd, OpDPdyFine = 179,
OpFwidthFine = 180,
OpBitwiseOr, OpDPdxCoarse = 181,
OpBitwiseXor, OpDPdyCoarse = 182,
OpBitwiseAnd, OpFwidthCoarse = 183,
OpEmitVertex = 184,
OpSelect, OpEndPrimitive = 185,
OpEmitStreamVertex = 186,
OpIEqual, OpEndStreamPrimitive = 187,
OpFOrdEqual, OpControlBarrier = 188,
OpFUnordEqual, OpMemoryBarrier = 189,
OpImagePointer = 190,
OpINotEqual, OpAtomicInit = 191,
OpFOrdNotEqual, OpAtomicLoad = 192,
OpFUnordNotEqual, OpAtomicStore = 193,
OpAtomicExchange = 194,
OpULessThan, OpAtomicCompareExchange = 195,
OpSLessThan, OpAtomicCompareExchangeWeak = 196,
OpFOrdLessThan, OpAtomicIIncrement = 197,
OpFUnordLessThan, OpAtomicIDecrement = 198,
OpAtomicIAdd = 199,
OpUGreaterThan, OpAtomicISub = 200,
OpSGreaterThan, OpAtomicUMin = 201,
OpFOrdGreaterThan, OpAtomicUMax = 202,
OpFUnordGreaterThan, OpAtomicAnd = 203,
OpAtomicOr = 204,
OpULessThanEqual, OpAtomicXor = 205,
OpSLessThanEqual, OpLoopMerge = 206,
OpFOrdLessThanEqual, OpSelectionMerge = 207,
OpFUnordLessThanEqual, OpLabel = 208,
OpBranch = 209,
OpUGreaterThanEqual, OpBranchConditional = 210,
OpSGreaterThanEqual, OpSwitch = 211,
OpFOrdGreaterThanEqual, OpKill = 212,
OpFUnordGreaterThanEqual, OpReturn = 213,
OpReturnValue = 214,
OpDPdx, OpUnreachable = 215,
OpDPdy, OpLifetimeStart = 216,
OpFwidth, OpLifetimeStop = 217,
OpDPdxFine, OpCompileFlag = 218,
OpDPdyFine, OpAsyncGroupCopy = 219,
OpFwidthFine, OpWaitGroupEvents = 220,
OpDPdxCoarse, OpGroupAll = 221,
OpDPdyCoarse, OpGroupAny = 222,
OpFwidthCoarse, OpGroupBroadcast = 223,
OpGroupIAdd = 224,
OpEmitVertex, OpGroupFAdd = 225,
OpEndPrimitive, OpGroupFMin = 226,
OpEmitStreamVertex, OpGroupUMin = 227,
OpEndStreamPrimitive, OpGroupSMin = 228,
OpGroupFMax = 229,
OpControlBarrier, OpGroupUMax = 230,
OpMemoryBarrier, OpGroupSMax = 231,
OpGenericCastToPtrExplicit = 232,
OpImagePointer, OpGenericPtrMemSemantics = 233,
OpReadPipe = 234,
OpAtomicInit, OpWritePipe = 235,
OpAtomicLoad, OpReservedReadPipe = 236,
OpAtomicStore, OpReservedWritePipe = 237,
OpAtomicExchange, OpReserveReadPipePackets = 238,
OpAtomicCompareExchange, OpReserveWritePipePackets = 239,
OpAtomicCompareExchangeWeak, OpCommitReadPipe = 240,
OpAtomicIIncrement, OpCommitWritePipe = 241,
OpAtomicIDecrement, OpIsValidReserveId = 242,
OpAtomicIAdd, OpGetNumPipePackets = 243,
OpAtomicISub, OpGetMaxPipePackets = 244,
OpAtomicUMin, OpGroupReserveReadPipePackets = 245,
OpAtomicUMax, OpGroupReserveWritePipePackets = 246,
OpAtomicAnd, OpGroupCommitReadPipe = 247,
OpAtomicOr, OpGroupCommitWritePipe = 248,
OpAtomicXor, OpEnqueueMarker = 249,
OpEnqueueKernel = 250,
OpLoopMerge, OpGetKernelNDrangeSubGroupCount = 251,
OpSelectionMerge, OpGetKernelNDrangeMaxSubGroupSize = 252,
OpLabel, OpGetKernelWorkGroupSize = 253,
OpBranch, OpGetKernelPreferredWorkGroupSizeMultiple = 254,
OpBranchConditional, OpRetainEvent = 255,
OpSwitch, OpReleaseEvent = 256,
OpKill, OpCreateUserEvent = 257,
OpReturn, OpIsValidEvent = 258,
OpReturnValue, OpSetUserEventStatus = 259,
OpCaptureEventProfilingInfo = 260,
OpUnreachable, OpGetDefaultQueue = 261,
OpBuildNDRange = 262,
OpLifetimeStart, OpSatConvertSToU = 263,
OpLifetimeStop, OpSatConvertUToS = 264,
OpAtomicIMin = 265,
OpCompileFlag, OpAtomicIMax = 266,
OpAsyncGroupCopy,
OpWaitGroupEvents,
OpGroupAll,
OpGroupAny,
OpGroupBroadcast,
OpGroupIAdd,
OpGroupFAdd,
OpGroupFMin,
OpGroupUMin,
OpGroupSMin,
OpGroupFMax,
OpGroupUMax,
OpGroupSMax,
OpGenericCastToPtrExplicit,
OpGenericPtrMemSemantics,
OpReadPipe,
OpWritePipe,
OpReservedReadPipe,
OpReservedWritePipe,
OpReserveReadPipePackets,
OpReserveWritePipePackets,
OpCommitReadPipe,
OpCommitWritePipe,
OpIsValidReserveId,
OpGetNumPipePackets,
OpGetMaxPipePackets,
OpGroupReserveReadPipePackets,
OpGroupReserveWritePipePackets,
OpGroupCommitReadPipe,
OpGroupCommitWritePipe,
OpEnqueueMarker,
OpEnqueueKernel,
OpGetKernelNDrangeSubGroupCount,
OpGetKernelNDrangeMaxSubGroupSize,
OpGetKernelWorkGroupSize,
OpGetKernelPreferredWorkGroupSizeMultiple,
OpRetainEvent,
OpReleaseEvent,
OpCreateUserEvent,
OpIsValidEvent,
OpSetUserEventStatus,
OpCaptureEventProfilingInfo,
OpGetDefaultQueue,
OpBuildNDRange,
OpCount // guard for validation, "default:" statements, etc.
}; };
#ifdef __cplusplus
}; // end namespace spv }; // end namespace spv
#endif
#endif // spirv_H #endif // #ifdef __cplusplus
#ifndef __cplusplus
const int SpvMagicNumber = 0x07230203;
const int SpvVersion = 99;
typedef unsigned int SpvId;
const unsigned int SpvOpCodeMask = 0xFFFF;
const unsigned int SpvWordCountShift = 16;
typedef enum SpvSourceLanguage_ {
SpvSourceLanguageUnknown = 0,
SpvSourceLanguageESSL = 1,
SpvSourceLanguageGLSL = 2,
SpvSourceLanguageOpenCL = 3,
} SpvSourceLanguage;
typedef enum SpvExecutionModel_ {
SpvExecutionModelVertex = 0,
SpvExecutionModelTessellationControl = 1,
SpvExecutionModelTessellationEvaluation = 2,
SpvExecutionModelGeometry = 3,
SpvExecutionModelFragment = 4,
SpvExecutionModelGLCompute = 5,
SpvExecutionModelKernel = 6,
} SpvExecutionModel;
typedef enum SpvAddressingModel_ {
SpvAddressingModelLogical = 0,
SpvAddressingModelPhysical32 = 1,
SpvAddressingModelPhysical64 = 2,
} SpvAddressingModel;
typedef enum SpvMemoryModel_ {
SpvMemoryModelSimple = 0,
SpvMemoryModelGLSL450 = 1,
SpvMemoryModelOpenCL12 = 2,
SpvMemoryModelOpenCL20 = 3,
SpvMemoryModelOpenCL21 = 4,
} SpvMemoryModel;
typedef enum SpvExecutionMode_ {
SpvExecutionModeInvocations = 0,
SpvExecutionModeSpacingEqual = 1,
SpvExecutionModeSpacingFractionalEven = 2,
SpvExecutionModeSpacingFractionalOdd = 3,
SpvExecutionModeVertexOrderCw = 4,
SpvExecutionModeVertexOrderCcw = 5,
SpvExecutionModePixelCenterInteger = 6,
SpvExecutionModeOriginUpperLeft = 7,
SpvExecutionModeEarlyFragmentTests = 8,
SpvExecutionModePointMode = 9,
SpvExecutionModeXfb = 10,
SpvExecutionModeDepthReplacing = 11,
SpvExecutionModeDepthAny = 12,
SpvExecutionModeDepthGreater = 13,
SpvExecutionModeDepthLess = 14,
SpvExecutionModeDepthUnchanged = 15,
SpvExecutionModeLocalSize = 16,
SpvExecutionModeLocalSizeHint = 17,
SpvExecutionModeInputPoints = 18,
SpvExecutionModeInputLines = 19,
SpvExecutionModeInputLinesAdjacency = 20,
SpvExecutionModeInputTriangles = 21,
SpvExecutionModeInputTrianglesAdjacency = 22,
SpvExecutionModeInputQuads = 23,
SpvExecutionModeInputIsolines = 24,
SpvExecutionModeOutputVertices = 25,
SpvExecutionModeOutputPoints = 26,
SpvExecutionModeOutputLineStrip = 27,
SpvExecutionModeOutputTriangleStrip = 28,
SpvExecutionModeVecTypeHint = 29,
SpvExecutionModeContractionOff = 30,
} SpvExecutionMode;
typedef enum SpvStorageClass_ {
SpvStorageClassUniformConstant = 0,
SpvStorageClassInput = 1,
SpvStorageClassUniform = 2,
SpvStorageClassOutput = 3,
SpvStorageClassWorkgroupLocal = 4,
SpvStorageClassWorkgroupGlobal = 5,
SpvStorageClassPrivateGlobal = 6,
SpvStorageClassFunction = 7,
SpvStorageClassGeneric = 8,
SpvStorageClassPrivate = 9,
SpvStorageClassAtomicCounter = 10,
} SpvStorageClass;
typedef enum SpvDim_ {
SpvDim1D = 0,
SpvDim2D = 1,
SpvDim3D = 2,
SpvDimCube = 3,
SpvDimRect = 4,
SpvDimBuffer = 5,
} SpvDim;
typedef enum SpvSamplerAddressingMode_ {
SpvSamplerAddressingModeNone = 0,
SpvSamplerAddressingModeClampToEdge = 2,
SpvSamplerAddressingModeClamp = 4,
SpvSamplerAddressingModeRepeat = 6,
SpvSamplerAddressingModeRepeatMirrored = 8,
} SpvSamplerAddressingMode;
typedef enum SpvSamplerFilterMode_ {
SpvSamplerFilterModeNearest = 16,
SpvSamplerFilterModeLinear = 32,
} SpvSamplerFilterMode;
typedef enum SpvFPFastMathModeShift_ {
SpvFPFastMathModeNotNaNShift = 0,
SpvFPFastMathModeNotInfShift = 1,
SpvFPFastMathModeNSZShift = 2,
SpvFPFastMathModeAllowRecipShift = 3,
SpvFPFastMathModeFastShift = 4,
} SpvFPFastMathModeShift;
typedef enum SpvFPFastMathModeMask_ {
SpvFPFastMathModeMaskNone = 0,
SpvFPFastMathModeNotNaNMask = 0x00000001,
SpvFPFastMathModeNotInfMask = 0x00000002,
SpvFPFastMathModeNSZMask = 0x00000004,
SpvFPFastMathModeAllowRecipMask = 0x00000008,
SpvFPFastMathModeFastMask = 0x00000010,
} SpvFPFastMathModeMask;
typedef enum SpvFPRoundingMode_ {
SpvFPRoundingModeRTE = 0,
SpvFPRoundingModeRTZ = 1,
SpvFPRoundingModeRTP = 2,
SpvFPRoundingModeRTN = 3,
} SpvFPRoundingMode;
typedef enum SpvLinkageType_ {
SpvLinkageTypeExport = 0,
SpvLinkageTypeImport = 1,
} SpvLinkageType;
typedef enum SpvAccessQualifier_ {
SpvAccessQualifierReadOnly = 0,
SpvAccessQualifierWriteOnly = 1,
SpvAccessQualifierReadWrite = 2,
} SpvAccessQualifier;
typedef enum SpvFunctionParameterAttribute_ {
SpvFunctionParameterAttributeZext = 0,
SpvFunctionParameterAttributeSext = 1,
SpvFunctionParameterAttributeByVal = 2,
SpvFunctionParameterAttributeSret = 3,
SpvFunctionParameterAttributeNoAlias = 4,
SpvFunctionParameterAttributeNoCapture = 5,
SpvFunctionParameterAttributeSVM = 6,
SpvFunctionParameterAttributeNoWrite = 7,
SpvFunctionParameterAttributeNoReadWrite = 8,
} SpvFunctionParameterAttribute;
typedef enum SpvDecoration_ {
SpvDecorationPrecisionLow = 0,
SpvDecorationPrecisionMedium = 1,
SpvDecorationPrecisionHigh = 2,
SpvDecorationBlock = 3,
SpvDecorationBufferBlock = 4,
SpvDecorationRowMajor = 5,
SpvDecorationColMajor = 6,
SpvDecorationGLSLShared = 7,
SpvDecorationGLSLStd140 = 8,
SpvDecorationGLSLStd430 = 9,
SpvDecorationGLSLPacked = 10,
SpvDecorationSmooth = 11,
SpvDecorationNoperspective = 12,
SpvDecorationFlat = 13,
SpvDecorationPatch = 14,
SpvDecorationCentroid = 15,
SpvDecorationSample = 16,
SpvDecorationInvariant = 17,
SpvDecorationRestrict = 18,
SpvDecorationAliased = 19,
SpvDecorationVolatile = 20,
SpvDecorationConstant = 21,
SpvDecorationCoherent = 22,
SpvDecorationNonwritable = 23,
SpvDecorationNonreadable = 24,
SpvDecorationUniform = 25,
SpvDecorationNoStaticUse = 26,
SpvDecorationCPacked = 27,
SpvDecorationSaturatedConversion = 28,
SpvDecorationStream = 29,
SpvDecorationLocation = 30,
SpvDecorationComponent = 31,
SpvDecorationIndex = 32,
SpvDecorationBinding = 33,
SpvDecorationDescriptorSet = 34,
SpvDecorationOffset = 35,
SpvDecorationAlignment = 36,
SpvDecorationXfbBuffer = 37,
SpvDecorationStride = 38,
SpvDecorationBuiltIn = 39,
SpvDecorationFuncParamAttr = 40,
SpvDecorationFPRoundingMode = 41,
SpvDecorationFPFastMathMode = 42,
SpvDecorationLinkageAttributes = 43,
SpvDecorationSpecId = 44,
} SpvDecoration;
typedef enum SpvBuiltIn_ {
SpvBuiltInPosition = 0,
SpvBuiltInPointSize = 1,
SpvBuiltInClipVertex = 2,
SpvBuiltInClipDistance = 3,
SpvBuiltInCullDistance = 4,
SpvBuiltInVertexId = 5,
SpvBuiltInInstanceId = 6,
SpvBuiltInPrimitiveId = 7,
SpvBuiltInInvocationId = 8,
SpvBuiltInLayer = 9,
SpvBuiltInViewportIndex = 10,
SpvBuiltInTessLevelOuter = 11,
SpvBuiltInTessLevelInner = 12,
SpvBuiltInTessCoord = 13,
SpvBuiltInPatchVertices = 14,
SpvBuiltInFragCoord = 15,
SpvBuiltInPointCoord = 16,
SpvBuiltInFrontFacing = 17,
SpvBuiltInSampleId = 18,
SpvBuiltInSamplePosition = 19,
SpvBuiltInSampleMask = 20,
SpvBuiltInFragColor = 21,
SpvBuiltInFragDepth = 22,
SpvBuiltInHelperInvocation = 23,
SpvBuiltInNumWorkgroups = 24,
SpvBuiltInWorkgroupSize = 25,
SpvBuiltInWorkgroupId = 26,
SpvBuiltInLocalInvocationId = 27,
SpvBuiltInGlobalInvocationId = 28,
SpvBuiltInLocalInvocationIndex = 29,
SpvBuiltInWorkDim = 30,
SpvBuiltInGlobalSize = 31,
SpvBuiltInEnqueuedWorkgroupSize = 32,
SpvBuiltInGlobalOffset = 33,
SpvBuiltInGlobalLinearId = 34,
SpvBuiltInWorkgroupLinearId = 35,
SpvBuiltInSubgroupSize = 36,
SpvBuiltInSubgroupMaxSize = 37,
SpvBuiltInNumSubgroups = 38,
SpvBuiltInNumEnqueuedSubgroups = 39,
SpvBuiltInSubgroupId = 40,
SpvBuiltInSubgroupLocalInvocationId = 41,
} SpvBuiltIn;
typedef enum SpvSelectionControlShift_ {
SpvSelectionControlFlattenShift = 0,
SpvSelectionControlDontFlattenShift = 1,
} SpvSelectionControlShift;
typedef enum SpvSelectionControlMask_ {
SpvSelectionControlMaskNone = 0,
SpvSelectionControlFlattenMask = 0x00000001,
SpvSelectionControlDontFlattenMask = 0x00000002,
} SpvSelectionControlMask;
typedef enum SpvLoopControlShift_ {
SpvLoopControlUnrollShift = 0,
SpvLoopControlDontUnrollShift = 1,
} SpvLoopControlShift;
typedef enum SpvLoopControlMask_ {
SpvLoopControlMaskNone = 0,
SpvLoopControlUnrollMask = 0x00000001,
SpvLoopControlDontUnrollMask = 0x00000002,
} SpvLoopControlMask;
typedef enum SpvFunctionControlShift_ {
SpvFunctionControlInlineShift = 0,
SpvFunctionControlDontInlineShift = 1,
SpvFunctionControlPureShift = 2,
SpvFunctionControlConstShift = 3,
} SpvFunctionControlShift;
typedef enum SpvFunctionControlMask_ {
SpvFunctionControlMaskNone = 0,
SpvFunctionControlInlineMask = 0x00000001,
SpvFunctionControlDontInlineMask = 0x00000002,
SpvFunctionControlPureMask = 0x00000004,
SpvFunctionControlConstMask = 0x00000008,
} SpvFunctionControlMask;
typedef enum SpvMemorySemanticsShift_ {
SpvMemorySemanticsRelaxedShift = 0,
SpvMemorySemanticsSequentiallyConsistentShift = 1,
SpvMemorySemanticsAcquireShift = 2,
SpvMemorySemanticsReleaseShift = 3,
SpvMemorySemanticsUniformMemoryShift = 4,
SpvMemorySemanticsSubgroupMemoryShift = 5,
SpvMemorySemanticsWorkgroupLocalMemoryShift = 6,
SpvMemorySemanticsWorkgroupGlobalMemoryShift = 7,
SpvMemorySemanticsAtomicCounterMemoryShift = 8,
SpvMemorySemanticsImageMemoryShift = 9,
} SpvMemorySemanticsShift;
typedef enum SpvMemorySemanticsMask_ {
SpvMemorySemanticsMaskNone = 0,
SpvMemorySemanticsRelaxedMask = 0x00000001,
SpvMemorySemanticsSequentiallyConsistentMask = 0x00000002,
SpvMemorySemanticsAcquireMask = 0x00000004,
SpvMemorySemanticsReleaseMask = 0x00000008,
SpvMemorySemanticsUniformMemoryMask = 0x00000010,
SpvMemorySemanticsSubgroupMemoryMask = 0x00000020,
SpvMemorySemanticsWorkgroupLocalMemoryMask = 0x00000040,
SpvMemorySemanticsWorkgroupGlobalMemoryMask = 0x00000080,
SpvMemorySemanticsAtomicCounterMemoryMask = 0x00000100,
SpvMemorySemanticsImageMemoryMask = 0x00000200,
} SpvMemorySemanticsMask;
typedef enum SpvMemoryAccessShift_ {
SpvMemoryAccessVolatileShift = 0,
SpvMemoryAccessAlignedShift = 1,
} SpvMemoryAccessShift;
typedef enum SpvMemoryAccessMask_ {
SpvMemoryAccessMaskNone = 0,
SpvMemoryAccessVolatileMask = 0x00000001,
SpvMemoryAccessAlignedMask = 0x00000002,
} SpvMemoryAccessMask;
typedef enum SpvExecutionScope_ {
SpvExecutionScopeCrossDevice = 0,
SpvExecutionScopeDevice = 1,
SpvExecutionScopeWorkgroup = 2,
SpvExecutionScopeSubgroup = 3,
} SpvExecutionScope;
typedef enum SpvGroupOperation_ {
SpvGroupOperationReduce = 0,
SpvGroupOperationInclusiveScan = 1,
SpvGroupOperationExclusiveScan = 2,
} SpvGroupOperation;
typedef enum SpvKernelEnqueueFlags_ {
SpvKernelEnqueueFlagsNoWait = 0,
SpvKernelEnqueueFlagsWaitKernel = 1,
SpvKernelEnqueueFlagsWaitWorkGroup = 2,
} SpvKernelEnqueueFlags;
typedef enum SpvKernelProfilingInfoShift_ {
SpvKernelProfilingInfoCmdExecTimeShift = 0,
} SpvKernelProfilingInfoShift;
typedef enum SpvKernelProfilingInfoMask_ {
SpvKernelProfilingInfoMaskNone = 0,
SpvKernelProfilingInfoCmdExecTimeMask = 0x00000001,
} SpvKernelProfilingInfoMask;
typedef enum SpvOp_ {
SpvOpNop = 0,
SpvOpSource = 1,
SpvOpSourceExtension = 2,
SpvOpExtension = 3,
SpvOpExtInstImport = 4,
SpvOpMemoryModel = 5,
SpvOpEntryPoint = 6,
SpvOpExecutionMode = 7,
SpvOpTypeVoid = 8,
SpvOpTypeBool = 9,
SpvOpTypeInt = 10,
SpvOpTypeFloat = 11,
SpvOpTypeVector = 12,
SpvOpTypeMatrix = 13,
SpvOpTypeSampler = 14,
SpvOpTypeFilter = 15,
SpvOpTypeArray = 16,
SpvOpTypeRuntimeArray = 17,
SpvOpTypeStruct = 18,
SpvOpTypeOpaque = 19,
SpvOpTypePointer = 20,
SpvOpTypeFunction = 21,
SpvOpTypeEvent = 22,
SpvOpTypeDeviceEvent = 23,
SpvOpTypeReserveId = 24,
SpvOpTypeQueue = 25,
SpvOpTypePipe = 26,
SpvOpConstantTrue = 27,
SpvOpConstantFalse = 28,
SpvOpConstant = 29,
SpvOpConstantComposite = 30,
SpvOpConstantSampler = 31,
SpvOpConstantNullPointer = 32,
SpvOpConstantNullObject = 33,
SpvOpSpecConstantTrue = 34,
SpvOpSpecConstantFalse = 35,
SpvOpSpecConstant = 36,
SpvOpSpecConstantComposite = 37,
SpvOpVariable = 38,
SpvOpVariableArray = 39,
SpvOpFunction = 40,
SpvOpFunctionParameter = 41,
SpvOpFunctionEnd = 42,
SpvOpFunctionCall = 43,
SpvOpExtInst = 44,
SpvOpUndef = 45,
SpvOpLoad = 46,
SpvOpStore = 47,
SpvOpPhi = 48,
SpvOpDecorationGroup = 49,
SpvOpDecorate = 50,
SpvOpMemberDecorate = 51,
SpvOpGroupDecorate = 52,
SpvOpGroupMemberDecorate = 53,
SpvOpName = 54,
SpvOpMemberName = 55,
SpvOpString = 56,
SpvOpLine = 57,
SpvOpVectorExtractDynamic = 58,
SpvOpVectorInsertDynamic = 59,
SpvOpVectorShuffle = 60,
SpvOpCompositeConstruct = 61,
SpvOpCompositeExtract = 62,
SpvOpCompositeInsert = 63,
SpvOpCopyObject = 64,
SpvOpCopyMemory = 65,
SpvOpCopyMemorySized = 66,
SpvOpSampler = 67,
SpvOpTextureSample = 68,
SpvOpTextureSampleDref = 69,
SpvOpTextureSampleLod = 70,
SpvOpTextureSampleProj = 71,
SpvOpTextureSampleGrad = 72,
SpvOpTextureSampleOffset = 73,
SpvOpTextureSampleProjLod = 74,
SpvOpTextureSampleProjGrad = 75,
SpvOpTextureSampleLodOffset = 76,
SpvOpTextureSampleProjOffset = 77,
SpvOpTextureSampleGradOffset = 78,
SpvOpTextureSampleProjLodOffset = 79,
SpvOpTextureSampleProjGradOffset = 80,
SpvOpTextureFetchTexelLod = 81,
SpvOpTextureFetchTexelOffset = 82,
SpvOpTextureFetchSample = 83,
SpvOpTextureFetchTexel = 84,
SpvOpTextureGather = 85,
SpvOpTextureGatherOffset = 86,
SpvOpTextureGatherOffsets = 87,
SpvOpTextureQuerySizeLod = 88,
SpvOpTextureQuerySize = 89,
SpvOpTextureQueryLod = 90,
SpvOpTextureQueryLevels = 91,
SpvOpTextureQuerySamples = 92,
SpvOpAccessChain = 93,
SpvOpInBoundsAccessChain = 94,
SpvOpSNegate = 95,
SpvOpFNegate = 96,
SpvOpNot = 97,
SpvOpAny = 98,
SpvOpAll = 99,
SpvOpConvertFToU = 100,
SpvOpConvertFToS = 101,
SpvOpConvertSToF = 102,
SpvOpConvertUToF = 103,
SpvOpUConvert = 104,
SpvOpSConvert = 105,
SpvOpFConvert = 106,
SpvOpConvertPtrToU = 107,
SpvOpConvertUToPtr = 108,
SpvOpPtrCastToGeneric = 109,
SpvOpGenericCastToPtr = 110,
SpvOpBitcast = 111,
SpvOpTranspose = 112,
SpvOpIsNan = 113,
SpvOpIsInf = 114,
SpvOpIsFinite = 115,
SpvOpIsNormal = 116,
SpvOpSignBitSet = 117,
SpvOpLessOrGreater = 118,
SpvOpOrdered = 119,
SpvOpUnordered = 120,
SpvOpArrayLength = 121,
SpvOpIAdd = 122,
SpvOpFAdd = 123,
SpvOpISub = 124,
SpvOpFSub = 125,
SpvOpIMul = 126,
SpvOpFMul = 127,
SpvOpUDiv = 128,
SpvOpSDiv = 129,
SpvOpFDiv = 130,
SpvOpUMod = 131,
SpvOpSRem = 132,
SpvOpSMod = 133,
SpvOpFRem = 134,
SpvOpFMod = 135,
SpvOpVectorTimesScalar = 136,
SpvOpMatrixTimesScalar = 137,
SpvOpVectorTimesMatrix = 138,
SpvOpMatrixTimesVector = 139,
SpvOpMatrixTimesMatrix = 140,
SpvOpOuterProduct = 141,
SpvOpDot = 142,
SpvOpShiftRightLogical = 143,
SpvOpShiftRightArithmetic = 144,
SpvOpShiftLeftLogical = 145,
SpvOpLogicalOr = 146,
SpvOpLogicalXor = 147,
SpvOpLogicalAnd = 148,
SpvOpBitwiseOr = 149,
SpvOpBitwiseXor = 150,
SpvOpBitwiseAnd = 151,
SpvOpSelect = 152,
SpvOpIEqual = 153,
SpvOpFOrdEqual = 154,
SpvOpFUnordEqual = 155,
SpvOpINotEqual = 156,
SpvOpFOrdNotEqual = 157,
SpvOpFUnordNotEqual = 158,
SpvOpULessThan = 159,
SpvOpSLessThan = 160,
SpvOpFOrdLessThan = 161,
SpvOpFUnordLessThan = 162,
SpvOpUGreaterThan = 163,
SpvOpSGreaterThan = 164,
SpvOpFOrdGreaterThan = 165,
SpvOpFUnordGreaterThan = 166,
SpvOpULessThanEqual = 167,
SpvOpSLessThanEqual = 168,
SpvOpFOrdLessThanEqual = 169,
SpvOpFUnordLessThanEqual = 170,
SpvOpUGreaterThanEqual = 171,
SpvOpSGreaterThanEqual = 172,
SpvOpFOrdGreaterThanEqual = 173,
SpvOpFUnordGreaterThanEqual = 174,
SpvOpDPdx = 175,
SpvOpDPdy = 176,
SpvOpFwidth = 177,
SpvOpDPdxFine = 178,
SpvOpDPdyFine = 179,
SpvOpFwidthFine = 180,
SpvOpDPdxCoarse = 181,
SpvOpDPdyCoarse = 182,
SpvOpFwidthCoarse = 183,
SpvOpEmitVertex = 184,
SpvOpEndPrimitive = 185,
SpvOpEmitStreamVertex = 186,
SpvOpEndStreamPrimitive = 187,
SpvOpControlBarrier = 188,
SpvOpMemoryBarrier = 189,
SpvOpImagePointer = 190,
SpvOpAtomicInit = 191,
SpvOpAtomicLoad = 192,
SpvOpAtomicStore = 193,
SpvOpAtomicExchange = 194,
SpvOpAtomicCompareExchange = 195,
SpvOpAtomicCompareExchangeWeak = 196,
SpvOpAtomicIIncrement = 197,
SpvOpAtomicIDecrement = 198,
SpvOpAtomicIAdd = 199,
SpvOpAtomicISub = 200,
SpvOpAtomicUMin = 201,
SpvOpAtomicUMax = 202,
SpvOpAtomicAnd = 203,
SpvOpAtomicOr = 204,
SpvOpAtomicXor = 205,
SpvOpLoopMerge = 206,
SpvOpSelectionMerge = 207,
SpvOpLabel = 208,
SpvOpBranch = 209,
SpvOpBranchConditional = 210,
SpvOpSwitch = 211,
SpvOpKill = 212,
SpvOpReturn = 213,
SpvOpReturnValue = 214,
SpvOpUnreachable = 215,
SpvOpLifetimeStart = 216,
SpvOpLifetimeStop = 217,
SpvOpCompileFlag = 218,
SpvOpAsyncGroupCopy = 219,
SpvOpWaitGroupEvents = 220,
SpvOpGroupAll = 221,
SpvOpGroupAny = 222,
SpvOpGroupBroadcast = 223,
SpvOpGroupIAdd = 224,
SpvOpGroupFAdd = 225,
SpvOpGroupFMin = 226,
SpvOpGroupUMin = 227,
SpvOpGroupSMin = 228,
SpvOpGroupFMax = 229,
SpvOpGroupUMax = 230,
SpvOpGroupSMax = 231,
SpvOpGenericCastToPtrExplicit = 232,
SpvOpGenericPtrMemSemantics = 233,
SpvOpReadPipe = 234,
SpvOpWritePipe = 235,
SpvOpReservedReadPipe = 236,
SpvOpReservedWritePipe = 237,
SpvOpReserveReadPipePackets = 238,
SpvOpReserveWritePipePackets = 239,
SpvOpCommitReadPipe = 240,
SpvOpCommitWritePipe = 241,
SpvOpIsValidReserveId = 242,
SpvOpGetNumPipePackets = 243,
SpvOpGetMaxPipePackets = 244,
SpvOpGroupReserveReadPipePackets = 245,
SpvOpGroupReserveWritePipePackets = 246,
SpvOpGroupCommitReadPipe = 247,
SpvOpGroupCommitWritePipe = 248,
SpvOpEnqueueMarker = 249,
SpvOpEnqueueKernel = 250,
SpvOpGetKernelNDrangeSubGroupCount = 251,
SpvOpGetKernelNDrangeMaxSubGroupSize = 252,
SpvOpGetKernelWorkGroupSize = 253,
SpvOpGetKernelPreferredWorkGroupSizeMultiple = 254,
SpvOpRetainEvent = 255,
SpvOpReleaseEvent = 256,
SpvOpCreateUserEvent = 257,
SpvOpIsValidEvent = 258,
SpvOpSetUserEventStatus = 259,
SpvOpCaptureEventProfilingInfo = 260,
SpvOpGetDefaultQueue = 261,
SpvOpBuildNDRange = 262,
SpvOpSatConvertSToU = 263,
SpvOpSatConvertUToS = 264,
SpvOpAtomicIMin = 265,
SpvOpAtomicIMax = 266,
} SpvOp;
#endif // #ifndef __cplusplus
#endif // #ifndef spirv_H
...@@ -60,14 +60,21 @@ namespace spv { ...@@ -60,14 +60,21 @@ namespace spv {
class Function; class Function;
class Module; class Module;
const Id NoResult = 0;
const Id NoType = 0;
const unsigned int BadValue = 0xFFFFFFFF;
const Decoration NoPrecision = (Decoration)BadValue;
const MemorySemanticsMask MemorySemanticsAllMemory = (MemorySemanticsMask)0x3FF;
// //
// SPIR-V IR instruction. // SPIR-V IR instruction.
// //
class Instruction { class Instruction {
public: public:
Instruction(Id resultId, Id typeId, OpCode opCode) : resultId(resultId), typeId(typeId), opCode(opCode), string(0) { } Instruction(Id resultId, Id typeId, Op opCode) : resultId(resultId), typeId(typeId), opCode(opCode), string(0) { }
explicit Instruction(OpCode opCode) : resultId(NoResult), typeId(NoType), opCode(opCode), string(0) { } explicit Instruction(Op opCode) : resultId(NoResult), typeId(NoType), opCode(opCode), string(0) { }
virtual ~Instruction() virtual ~Instruction()
{ {
delete string; delete string;
...@@ -103,7 +110,7 @@ public: ...@@ -103,7 +110,7 @@ public:
originalString = str; originalString = str;
} }
OpCode getOpCode() const { return opCode; } Op getOpCode() const { return opCode; }
int getNumOperands() const { return operands.size(); } int getNumOperands() const { return operands.size(); }
Id getResultId() const { return resultId; } Id getResultId() const { return resultId; }
Id getTypeId() const { return typeId; } Id getTypeId() const { return typeId; }
...@@ -143,7 +150,7 @@ protected: ...@@ -143,7 +150,7 @@ protected:
Instruction(const Instruction&); Instruction(const Instruction&);
Id resultId; Id resultId;
Id typeId; Id typeId;
OpCode opCode; Op opCode;
std::vector<Id> operands; std::vector<Id> operands;
std::vector<unsigned int>* string; // usually non-existent std::vector<unsigned int>* string; // usually non-existent
std::string originalString; // could be optimized away; convenience for getting string operand std::string originalString; // could be optimized away; convenience for getting string operand
...@@ -310,7 +317,7 @@ __inline Function::Function(Id id, Id resultType, Id functionType, Id firstParam ...@@ -310,7 +317,7 @@ __inline Function::Function(Id id, Id resultType, Id functionType, Id firstParam
: parent(parent), functionInstruction(id, resultType, OpFunction) : parent(parent), functionInstruction(id, resultType, OpFunction)
{ {
// OpFunction // OpFunction
functionInstruction.addImmediateOperand(FunctionControlNone); functionInstruction.addImmediateOperand(FunctionControlMaskNone);
functionInstruction.addIdOperand(functionType); functionInstruction.addIdOperand(functionType);
parent.mapInstruction(&functionInstruction); parent.mapInstruction(&functionInstruction);
parent.addFunction(this); parent.addFunction(this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment