summaryrefslogtreecommitdiff
path: root/thirdparty/glslang/SPIRV
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/glslang/SPIRV')
-rw-r--r--thirdparty/glslang/SPIRV/CInterface/spirv_c_interface.cpp110
-rw-r--r--thirdparty/glslang/SPIRV/GlslangToSpv.cpp219
-rw-r--r--thirdparty/glslang/SPIRV/SPVRemapper.cpp18
-rw-r--r--thirdparty/glslang/SPIRV/SpvBuilder.cpp31
-rw-r--r--thirdparty/glslang/SPIRV/SpvBuilder.h1
-rw-r--r--thirdparty/glslang/SPIRV/SpvPostProcess.cpp39
-rw-r--r--thirdparty/glslang/SPIRV/SpvTools.cpp2
-rw-r--r--thirdparty/glslang/SPIRV/disassemble.cpp47
-rw-r--r--thirdparty/glslang/SPIRV/doc.cpp6
-rw-r--r--thirdparty/glslang/SPIRV/spirv.hpp209
-rw-r--r--thirdparty/glslang/SPIRV/spvIR.h22
11 files changed, 454 insertions, 250 deletions
diff --git a/thirdparty/glslang/SPIRV/CInterface/spirv_c_interface.cpp b/thirdparty/glslang/SPIRV/CInterface/spirv_c_interface.cpp
deleted file mode 100644
index a0790f48f1..0000000000
--- a/thirdparty/glslang/SPIRV/CInterface/spirv_c_interface.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- This code is based on the glslang_c_interface implementation by Viktor Latypov
-**/
-
-/**
-BSD 2-Clause License
-
-Copyright (c) 2019, Viktor Latypov
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**/
-
-#include "glslang/Include/glslang_c_interface.h"
-
-#include "SPIRV/GlslangToSpv.h"
-#include "SPIRV/Logger.h"
-#include "SPIRV/SpvTools.h"
-
-typedef struct glslang_program_s {
- glslang::TProgram* program;
- std::vector<unsigned int> spirv;
- std::string loggerMessages;
-} glslang_program_t;
-
-static EShLanguage c_shader_stage(glslang_stage_t stage)
-{
- switch (stage) {
- case GLSLANG_STAGE_VERTEX:
- return EShLangVertex;
- case GLSLANG_STAGE_TESSCONTROL:
- return EShLangTessControl;
- case GLSLANG_STAGE_TESSEVALUATION:
- return EShLangTessEvaluation;
- case GLSLANG_STAGE_GEOMETRY:
- return EShLangGeometry;
- case GLSLANG_STAGE_FRAGMENT:
- return EShLangFragment;
- case GLSLANG_STAGE_COMPUTE:
- return EShLangCompute;
- case GLSLANG_STAGE_RAYGEN_NV:
- return EShLangRayGen;
- case GLSLANG_STAGE_INTERSECT_NV:
- return EShLangIntersect;
- case GLSLANG_STAGE_ANYHIT_NV:
- return EShLangAnyHit;
- case GLSLANG_STAGE_CLOSESTHIT_NV:
- return EShLangClosestHit;
- case GLSLANG_STAGE_MISS_NV:
- return EShLangMiss;
- case GLSLANG_STAGE_CALLABLE_NV:
- return EShLangCallable;
- case GLSLANG_STAGE_TASK_NV:
- return EShLangTaskNV;
- case GLSLANG_STAGE_MESH_NV:
- return EShLangMeshNV;
- default:
- break;
- }
- return EShLangCount;
-}
-
-GLSLANG_EXPORT void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage)
-{
- spv::SpvBuildLogger logger;
- glslang::SpvOptions spvOptions;
- spvOptions.validate = true;
-
- const glslang::TIntermediate* intermediate = program->program->getIntermediate(c_shader_stage(stage));
-
- glslang::GlslangToSpv(*intermediate, program->spirv, &logger, &spvOptions);
-
- program->loggerMessages = logger.getAllMessages();
-}
-
-GLSLANG_EXPORT size_t glslang_program_SPIRV_get_size(glslang_program_t* program) { return program->spirv.size(); }
-
-GLSLANG_EXPORT void glslang_program_SPIRV_get(glslang_program_t* program, unsigned int* out)
-{
- memcpy(out, program->spirv.data(), program->spirv.size() * sizeof(unsigned int));
-}
-
-GLSLANG_EXPORT unsigned int* glslang_program_SPIRV_get_ptr(glslang_program_t* program)
-{
- return program->spirv.data();
-}
-
-GLSLANG_EXPORT const char* glslang_program_SPIRV_get_messages(glslang_program_t* program)
-{
- return program->loggerMessages.empty() ? nullptr : program->loggerMessages.c_str();
-}
diff --git a/thirdparty/glslang/SPIRV/GlslangToSpv.cpp b/thirdparty/glslang/SPIRV/GlslangToSpv.cpp
index c323bcdb09..39941d3752 100644
--- a/thirdparty/glslang/SPIRV/GlslangToSpv.cpp
+++ b/thirdparty/glslang/SPIRV/GlslangToSpv.cpp
@@ -1256,8 +1256,10 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
if (type.getBasicType() == glslang::EbtRayQuery)
return spv::StorageClassPrivate;
#ifndef GLSLANG_WEB
- if (type.getQualifier().isSpirvByReference())
- return spv::StorageClassFunction;
+ if (type.getQualifier().isSpirvByReference()) {
+ if (type.getQualifier().isParamInput() || type.getQualifier().isParamOutput())
+ return spv::StorageClassFunction;
+ }
#endif
if (type.getQualifier().isPipeInput())
return spv::StorageClassInput;
@@ -1662,9 +1664,22 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
case EShLangCompute:
builder.addCapability(spv::CapabilityShader);
- builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSize(0),
- glslangIntermediate->getLocalSize(1),
- glslangIntermediate->getLocalSize(2));
+ if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_6) {
+ std::vector<spv::Id> dimConstId;
+ for (int dim = 0; dim < 3; ++dim) {
+ bool specConst = (glslangIntermediate->getLocalSizeSpecId(dim) != glslang::TQualifier::layoutNotSet);
+ dimConstId.push_back(builder.makeUintConstant(glslangIntermediate->getLocalSize(dim), specConst));
+ if (specConst) {
+ builder.addDecoration(dimConstId.back(), spv::DecorationSpecId,
+ glslangIntermediate->getLocalSizeSpecId(dim));
+ }
+ }
+ builder.addExecutionModeId(shaderEntry, spv::ExecutionModeLocalSizeId, dimConstId);
+ } else {
+ builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSize(0),
+ glslangIntermediate->getLocalSize(1),
+ glslangIntermediate->getLocalSize(2));
+ }
if (glslangIntermediate->getLayoutDerivativeModeNone() == glslang::LayoutDerivativeGroupQuads) {
builder.addCapability(spv::CapabilityComputeDerivativeGroupQuadsNV);
builder.addExecutionMode(shaderEntry, spv::ExecutionModeDerivativeGroupQuadsNV);
@@ -1768,9 +1783,22 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
case EShLangMeshNV:
builder.addCapability(spv::CapabilityMeshShadingNV);
builder.addExtension(spv::E_SPV_NV_mesh_shader);
- builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSize(0),
- glslangIntermediate->getLocalSize(1),
- glslangIntermediate->getLocalSize(2));
+ if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_6) {
+ std::vector<spv::Id> dimConstId;
+ for (int dim = 0; dim < 3; ++dim) {
+ bool specConst = (glslangIntermediate->getLocalSizeSpecId(dim) != glslang::TQualifier::layoutNotSet);
+ dimConstId.push_back(builder.makeUintConstant(glslangIntermediate->getLocalSize(dim), specConst));
+ if (specConst) {
+ builder.addDecoration(dimConstId.back(), spv::DecorationSpecId,
+ glslangIntermediate->getLocalSizeSpecId(dim));
+ }
+ }
+ builder.addExecutionModeId(shaderEntry, spv::ExecutionModeLocalSizeId, dimConstId);
+ } else {
+ builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSize(0),
+ glslangIntermediate->getLocalSize(1),
+ glslangIntermediate->getLocalSize(2));
+ }
if (glslangIntermediate->getStage() == EShLangMeshNV) {
builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices,
glslangIntermediate->getVertices());
@@ -1830,10 +1858,10 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
std::vector<spv::Id> operandIds;
assert(!modeId.second.empty());
for (auto extraOperand : modeId.second) {
- int nextConst = 0;
- spv::Id operandId = createSpvConstantFromConstUnionArray(
- extraOperand->getType(), extraOperand->getConstArray(), nextConst, false);
- operandIds.push_back(operandId);
+ if (extraOperand->getType().getQualifier().isSpecConstant())
+ operandIds.push_back(getSymbolId(extraOperand->getAsSymbolNode()));
+ else
+ operandIds.push_back(createSpvConstant(*extraOperand));
}
builder.addExecutionModeId(shaderEntry, static_cast<spv::ExecutionMode>(modeId.first), operandIds);
}
@@ -3384,7 +3412,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
const auto& spirvInst = node->getSpirvInstruction();
if (spirvInst.set == "") {
std::vector<spv::IdImmediate> idImmOps;
- for (int i = 0; i < glslangOperands.size(); ++i) {
+ for (unsigned int i = 0; i < glslangOperands.size(); ++i) {
if (glslangOperands[i]->getAsTyped()->getQualifier().isSpirvLiteral()) {
// Translate the constant to a literal value
std::vector<unsigned> literals;
@@ -3777,7 +3805,16 @@ bool TGlslangToSpvTraverser::visitBranch(glslang::TVisit /* visit */, glslang::T
switch (node->getFlowOp()) {
case glslang::EOpKill:
- builder.makeStatementTerminator(spv::OpKill, "post-discard");
+ if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_6) {
+ if (glslangIntermediate->getSource() == glslang::EShSourceHlsl) {
+ builder.addCapability(spv::CapabilityDemoteToHelperInvocation);
+ builder.createNoResultOp(spv::OpDemoteToHelperInvocationEXT);
+ } else {
+ builder.makeStatementTerminator(spv::OpTerminateInvocation, "post-terminate-invocation");
+ }
+ } else {
+ builder.makeStatementTerminator(spv::OpKill, "post-discard");
+ }
break;
case glslang::EOpTerminateInvocation:
builder.addExtension(spv::E_SPV_KHR_terminate_invocation);
@@ -3940,12 +3977,14 @@ spv::Id TGlslangToSpvTraverser::getSampledType(const glslang::TSampler& sampler)
builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float_fetch);
builder.addCapability(spv::CapabilityFloat16ImageAMD);
return builder.makeFloatType(16);
- case glslang::EbtInt64: return builder.makeIntType(64);
+ case glslang::EbtInt64:
builder.addExtension(spv::E_SPV_EXT_shader_image_int64);
- builder.addCapability(spv::CapabilityFloat16ImageAMD);
- case glslang::EbtUint64: return builder.makeUintType(64);
+ builder.addCapability(spv::CapabilityInt64ImageEXT);
+ return builder.makeIntType(64);
+ case glslang::EbtUint64:
builder.addExtension(spv::E_SPV_EXT_shader_image_int64);
- builder.addCapability(spv::CapabilityFloat16ImageAMD);
+ builder.addCapability(spv::CapabilityInt64ImageEXT);
+ return builder.makeUintType(64);
#endif
default:
assert(0);
@@ -4146,68 +4185,55 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
const auto& spirvType = type.getSpirvType();
const auto& spirvInst = spirvType.spirvInst;
- std::vector<spv::Id> operands;
+ std::vector<spv::IdImmediate> operands;
for (const auto& typeParam : spirvType.typeParams) {
- if (typeParam.isConstant) {
- // Constant expression
- if (typeParam.constant->isLiteral()) {
- if (typeParam.constant->getBasicType() == glslang::EbtFloat) {
- float floatValue = static_cast<float>(typeParam.constant->getConstArray()[0].getDConst());
- unsigned literal = *reinterpret_cast<unsigned*>(&floatValue);
- operands.push_back(literal);
- } else if (typeParam.constant->getBasicType() == glslang::EbtInt) {
- unsigned literal = typeParam.constant->getConstArray()[0].getIConst();
- operands.push_back(literal);
- } else if (typeParam.constant->getBasicType() == glslang::EbtUint) {
- unsigned literal = typeParam.constant->getConstArray()[0].getUConst();
- operands.push_back(literal);
- } else if (typeParam.constant->getBasicType() == glslang::EbtBool) {
- unsigned literal = typeParam.constant->getConstArray()[0].getBConst();
- operands.push_back(literal);
- } else if (typeParam.constant->getBasicType() == glslang::EbtString) {
- auto str = typeParam.constant->getConstArray()[0].getSConst()->c_str();
- unsigned literal = 0;
- char* literalPtr = reinterpret_cast<char*>(&literal);
- unsigned charCount = 0;
- char ch = 0;
- do {
- ch = *(str++);
- *(literalPtr++) = ch;
- ++charCount;
- if (charCount == 4) {
- operands.push_back(literal);
- literalPtr = reinterpret_cast<char*>(&literal);
- charCount = 0;
- }
- } while (ch != 0);
-
- // Partial literal is padded with 0
- if (charCount > 0) {
- for (; charCount < 4; ++charCount)
- *(literalPtr++) = 0;
- operands.push_back(literal);
+ // Constant expression
+ if (typeParam.constant->isLiteral()) {
+ if (typeParam.constant->getBasicType() == glslang::EbtFloat) {
+ float floatValue = static_cast<float>(typeParam.constant->getConstArray()[0].getDConst());
+ unsigned literal = *reinterpret_cast<unsigned*>(&floatValue);
+ operands.push_back({false, literal});
+ } else if (typeParam.constant->getBasicType() == glslang::EbtInt) {
+ unsigned literal = typeParam.constant->getConstArray()[0].getIConst();
+ operands.push_back({false, literal});
+ } else if (typeParam.constant->getBasicType() == glslang::EbtUint) {
+ unsigned literal = typeParam.constant->getConstArray()[0].getUConst();
+ operands.push_back({false, literal});
+ } else if (typeParam.constant->getBasicType() == glslang::EbtBool) {
+ unsigned literal = typeParam.constant->getConstArray()[0].getBConst();
+ operands.push_back({false, literal});
+ } else if (typeParam.constant->getBasicType() == glslang::EbtString) {
+ auto str = typeParam.constant->getConstArray()[0].getSConst()->c_str();
+ unsigned literal = 0;
+ char* literalPtr = reinterpret_cast<char*>(&literal);
+ unsigned charCount = 0;
+ char ch = 0;
+ do {
+ ch = *(str++);
+ *(literalPtr++) = ch;
+ ++charCount;
+ if (charCount == 4) {
+ operands.push_back({false, literal});
+ literalPtr = reinterpret_cast<char*>(&literal);
+ charCount = 0;
}
- } else
- assert(0); // Unexpected type
- } else {
- int nextConst = 0;
- spv::Id constant = createSpvConstantFromConstUnionArray(
- typeParam.constant->getType(), typeParam.constant->getConstArray(), nextConst, false);
- operands.push_back(constant);
- }
- } else {
- // Type specifier
- spv::Id typeId = convertGlslangToSpvType(*typeParam.type);
- operands.push_back(typeId);
- }
- }
+ } while (ch != 0);
- if (spirvInst.set == "")
- spvType = builder.createOp(static_cast<spv::Op>(spirvInst.id), spv::NoType, operands);
- else {
- spvType = builder.createBuiltinCall(
- spv::NoType, getExtBuiltins(spirvInst.set.c_str()), spirvInst.id, operands);
+ // Partial literal is padded with 0
+ if (charCount > 0) {
+ for (; charCount < 4; ++charCount)
+ *(literalPtr++) = 0;
+ operands.push_back({false, literal});
+ }
+ } else
+ assert(0); // Unexpected type
+ } else
+ operands.push_back({true, createSpvConstant(*typeParam.constant)});
}
+
+ assert(spirvInst.set == ""); // Currently, couldn't be extended instructions.
+ spvType = builder.makeGenericType(static_cast<spv::Op>(spirvInst.id), operands);
+
break;
}
#endif
@@ -7506,6 +7532,8 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
break;
case glslang::EOpReadFirstInvocation:
opCode = spv::OpSubgroupFirstInvocationKHR;
+ if (builder.isVectorType(typeId))
+ return CreateInvocationsVectorOperation(opCode, groupOperation, typeId, operands);
break;
case glslang::EOpBallot:
{
@@ -7630,7 +7658,7 @@ spv::Id TGlslangToSpvTraverser::CreateInvocationsVectorOperation(spv::Op op, spv
assert(op == spv::OpGroupFMin || op == spv::OpGroupUMin || op == spv::OpGroupSMin ||
op == spv::OpGroupFMax || op == spv::OpGroupUMax || op == spv::OpGroupSMax ||
op == spv::OpGroupFAdd || op == spv::OpGroupIAdd || op == spv::OpGroupBroadcast ||
- op == spv::OpSubgroupReadInvocationKHR ||
+ op == spv::OpSubgroupReadInvocationKHR || op == spv::OpSubgroupFirstInvocationKHR ||
op == spv::OpGroupFMinNonUniformAMD || op == spv::OpGroupUMinNonUniformAMD ||
op == spv::OpGroupSMinNonUniformAMD ||
op == spv::OpGroupFMaxNonUniformAMD || op == spv::OpGroupUMaxNonUniformAMD ||
@@ -7659,6 +7687,8 @@ spv::Id TGlslangToSpvTraverser::CreateInvocationsVectorOperation(spv::Op op, spv
spvGroupOperands.push_back(scalar);
spv::IdImmediate operand = { true, operands[1] };
spvGroupOperands.push_back(operand);
+ } else if (op == spv::OpSubgroupFirstInvocationKHR) {
+ spvGroupOperands.push_back(scalar);
} else if (op == spv::OpGroupBroadcast) {
spv::IdImmediate scope = { true, builder.makeUintConstant(spv::ScopeSubgroup) };
spvGroupOperands.push_back(scope);
@@ -8721,8 +8751,18 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
builder.addDecoration(id, spv::DecorationOffset, symbol->getQualifier().layoutOffset);
}
- if (symbol->getQualifier().hasLocation())
- builder.addDecoration(id, spv::DecorationLocation, symbol->getQualifier().layoutLocation);
+ if (symbol->getQualifier().hasLocation()) {
+ if (!(glslangIntermediate->isRayTracingStage() && glslangIntermediate->IsRequestedExtension(glslang::E_GL_EXT_ray_tracing)
+ && (builder.getStorageClass(id) == spv::StorageClassRayPayloadKHR ||
+ builder.getStorageClass(id) == spv::StorageClassIncomingRayPayloadKHR ||
+ builder.getStorageClass(id) == spv::StorageClassCallableDataKHR ||
+ builder.getStorageClass(id) == spv::StorageClassIncomingCallableDataKHR))) {
+ // Location values are used to link TraceRayKHR and ExecuteCallableKHR to corresponding variables
+ // but are not valid in SPIRV since they are supported only for Input/Output Storage classes.
+ builder.addDecoration(id, spv::DecorationLocation, symbol->getQualifier().layoutLocation);
+ }
+ }
+
builder.addDecoration(id, TranslateInvariantDecoration(symbol->getType().getQualifier()));
if (symbol->getQualifier().hasStream() && glslangIntermediate->isMultiStream()) {
builder.addCapability(spv::CapabilityGeometryStreams);
@@ -8756,7 +8796,16 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
// add built-in variable decoration
if (builtIn != spv::BuiltInMax) {
- builder.addDecoration(id, spv::DecorationBuiltIn, (int)builtIn);
+ // WorkgroupSize deprecated in spirv1.6
+ if (glslangIntermediate->getSpv().spv < glslang::EShTargetSpv_1_6 ||
+ builtIn != spv::BuiltInWorkgroupSize)
+ builder.addDecoration(id, spv::DecorationBuiltIn, (int)builtIn);
+ }
+
+ // Add volatile decoration to HelperInvocation for spirv1.6 and beyond
+ if (builtIn == spv::BuiltInHelperInvocation &&
+ glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_6) {
+ builder.addDecoration(id, spv::DecorationVolatile);
}
#ifndef GLSLANG_WEB
@@ -8841,12 +8890,12 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
std::vector<spv::Id> operandIds;
assert(!decorateId.second.empty());
for (auto extraOperand : decorateId.second) {
- int nextConst = 0;
- spv::Id operandId = createSpvConstantFromConstUnionArray(
- extraOperand->getType(), extraOperand->getConstArray(), nextConst, false);
- operandIds.push_back(operandId);
+ if (extraOperand->getQualifier().isSpecConstant())
+ operandIds.push_back(getSymbolId(extraOperand->getAsSymbolNode()));
+ else
+ operandIds.push_back(createSpvConstant(*extraOperand));
}
- builder.addDecoration(id, static_cast<spv::Decoration>(decorateId.first), operandIds);
+ builder.addDecorationId(id, static_cast<spv::Decoration>(decorateId.first), operandIds);
}
// Add spirv_decorate_string
diff --git a/thirdparty/glslang/SPIRV/SPVRemapper.cpp b/thirdparty/glslang/SPIRV/SPVRemapper.cpp
index 56d6d5d4a5..fdfbeb90cd 100644
--- a/thirdparty/glslang/SPIRV/SPVRemapper.cpp
+++ b/thirdparty/glslang/SPIRV/SPVRemapper.cpp
@@ -297,15 +297,21 @@ namespace spv {
std::string spirvbin_t::literalString(unsigned word) const
{
std::string literal;
+ const spirword_t * pos = spv.data() + word;
literal.reserve(16);
- const char* bytes = reinterpret_cast<const char*>(spv.data() + word);
-
- while (bytes && *bytes)
- literal += *bytes++;
-
- return literal;
+ do {
+ spirword_t word = *pos;
+ for (int i = 0; i < 4; i++) {
+ char c = word & 0xff;
+ if (c == '\0')
+ return literal;
+ literal += c;
+ word >>= 8;
+ }
+ pos++;
+ } while (true);
}
void spirvbin_t::applyMap()
diff --git a/thirdparty/glslang/SPIRV/SpvBuilder.cpp b/thirdparty/glslang/SPIRV/SpvBuilder.cpp
index e83306ebcb..36a3f09744 100644
--- a/thirdparty/glslang/SPIRV/SpvBuilder.cpp
+++ b/thirdparty/glslang/SPIRV/SpvBuilder.cpp
@@ -427,6 +427,37 @@ Id Builder::makeCooperativeMatrixType(Id component, Id scope, Id rows, Id cols)
return type->getResultId();
}
+Id Builder::makeGenericType(spv::Op opcode, std::vector<spv::IdImmediate>& operands)
+{
+ // try to find it
+ Instruction* type;
+ for (int t = 0; t < (int)groupedTypes[opcode].size(); ++t) {
+ type = groupedTypes[opcode][t];
+ if (static_cast<size_t>(type->getNumOperands()) != operands.size())
+ continue; // Number mismatch, find next
+
+ bool match = true;
+ for (int op = 0; match && op < (int)operands.size(); ++op) {
+ match = (operands[op].isId ? type->getIdOperand(op) : type->getImmediateOperand(op)) == operands[op].word;
+ }
+ if (match)
+ return type->getResultId();
+ }
+
+ // not found, make it
+ type = new Instruction(getUniqueId(), NoType, opcode);
+ for (size_t op = 0; op < operands.size(); ++op) {
+ if (operands[op].isId)
+ type->addIdOperand(operands[op].word);
+ else
+ type->addImmediateOperand(operands[op].word);
+ }
+ groupedTypes[opcode].push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
+ module.mapInstruction(type);
+
+ return type->getResultId();
+}
// TODO: performance: track arrays per stride
// If a stride is supplied (non-zero) make an array.
diff --git a/thirdparty/glslang/SPIRV/SpvBuilder.h b/thirdparty/glslang/SPIRV/SpvBuilder.h
index 251b9ee823..c72d9b287e 100644
--- a/thirdparty/glslang/SPIRV/SpvBuilder.h
+++ b/thirdparty/glslang/SPIRV/SpvBuilder.h
@@ -181,6 +181,7 @@ public:
Id makeSamplerType();
Id makeSampledImageType(Id imageType);
Id makeCooperativeMatrixType(Id component, Id scope, Id rows, Id cols);
+ Id makeGenericType(spv::Op opcode, std::vector<spv::IdImmediate>& operands);
// accelerationStructureNV type
Id makeAccelerationStructureType();
diff --git a/thirdparty/glslang/SPIRV/SpvPostProcess.cpp b/thirdparty/glslang/SPIRV/SpvPostProcess.cpp
index 23d7b5a461..dd6dabce0d 100644
--- a/thirdparty/glslang/SPIRV/SpvPostProcess.cpp
+++ b/thirdparty/glslang/SPIRV/SpvPostProcess.cpp
@@ -44,10 +44,8 @@
#include <algorithm>
#include "SpvBuilder.h"
-
#include "spirv.hpp"
-#include "GlslangToSpv.h"
-#include "SpvBuilder.h"
+
namespace spv {
#include "GLSL.std.450.h"
#include "GLSL.ext.KHR.h"
@@ -113,8 +111,6 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
}
}
break;
- case OpAccessChain:
- case OpPtrAccessChain:
case OpCopyObject:
break;
case OpFConvert:
@@ -161,26 +157,43 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
switch (inst.getImmediateOperand(1)) {
case GLSLstd450Frexp:
case GLSLstd450FrexpStruct:
- if (getSpvVersion() < glslang::EShTargetSpv_1_3 && containsType(typeId, OpTypeInt, 16))
+ if (getSpvVersion() < spv::Spv_1_3 && containsType(typeId, OpTypeInt, 16))
addExtension(spv::E_SPV_AMD_gpu_shader_int16);
break;
case GLSLstd450InterpolateAtCentroid:
case GLSLstd450InterpolateAtSample:
case GLSLstd450InterpolateAtOffset:
- if (getSpvVersion() < glslang::EShTargetSpv_1_3 && containsType(typeId, OpTypeFloat, 16))
+ if (getSpvVersion() < spv::Spv_1_3 && containsType(typeId, OpTypeFloat, 16))
addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
break;
default:
break;
}
break;
+ case OpAccessChain:
+ case OpPtrAccessChain:
+ if (isPointerType(typeId))
+ break;
+ if (basicTypeOp == OpTypeInt) {
+ if (width == 16)
+ addCapability(CapabilityInt16);
+ else if (width == 8)
+ addCapability(CapabilityInt8);
+ }
default:
- if (basicTypeOp == OpTypeFloat && width == 16)
- addCapability(CapabilityFloat16);
- if (basicTypeOp == OpTypeInt && width == 16)
- addCapability(CapabilityInt16);
- if (basicTypeOp == OpTypeInt && width == 8)
- addCapability(CapabilityInt8);
+ if (basicTypeOp == OpTypeInt) {
+ if (width == 16)
+ addCapability(CapabilityInt16);
+ else if (width == 8)
+ addCapability(CapabilityInt8);
+ else if (width == 64)
+ addCapability(CapabilityInt64);
+ } else if (basicTypeOp == OpTypeFloat) {
+ if (width == 16)
+ addCapability(CapabilityFloat16);
+ else if (width == 64)
+ addCapability(CapabilityFloat64);
+ }
break;
}
}
diff --git a/thirdparty/glslang/SPIRV/SpvTools.cpp b/thirdparty/glslang/SPIRV/SpvTools.cpp
index 8acf9b139a..e8f825119a 100644
--- a/thirdparty/glslang/SPIRV/SpvTools.cpp
+++ b/thirdparty/glslang/SPIRV/SpvTools.cpp
@@ -68,6 +68,8 @@ spv_target_env MapToSpirvToolsEnv(const SpvVersion& spvVersion, spv::SpvBuildLog
}
case glslang::EShTargetVulkan_1_2:
return spv_target_env::SPV_ENV_VULKAN_1_2;
+ case glslang::EShTargetVulkan_1_3:
+ return spv_target_env::SPV_ENV_VULKAN_1_3;
default:
break;
}
diff --git a/thirdparty/glslang/SPIRV/disassemble.cpp b/thirdparty/glslang/SPIRV/disassemble.cpp
index 73c988c5b3..74dd605409 100644
--- a/thirdparty/glslang/SPIRV/disassemble.cpp
+++ b/thirdparty/glslang/SPIRV/disassemble.cpp
@@ -43,6 +43,7 @@
#include <stack>
#include <sstream>
#include <cstring>
+#include <utility>
#include "disassemble.h"
#include "doc.h"
@@ -100,6 +101,7 @@ protected:
void outputMask(OperandClass operandClass, unsigned mask);
void disassembleImmediates(int numOperands);
void disassembleIds(int numOperands);
+ std::pair<int, std::string> decodeString();
int disassembleString();
void disassembleInstruction(Id resultId, Id typeId, Op opCode, int numOperands);
@@ -290,31 +292,44 @@ void SpirvStream::disassembleIds(int numOperands)
}
}
-// return the number of operands consumed by the string
-int SpirvStream::disassembleString()
+// decode string from words at current position (non-consuming)
+std::pair<int, std::string> SpirvStream::decodeString()
{
- int startWord = word;
-
- out << " \"";
-
- const char* wordString;
+ std::string res;
+ int wordPos = word;
+ char c;
bool done = false;
+
do {
- unsigned int content = stream[word];
- wordString = (const char*)&content;
+ unsigned int content = stream[wordPos];
for (int charCount = 0; charCount < 4; ++charCount) {
- if (*wordString == 0) {
+ c = content & 0xff;
+ content >>= 8;
+ if (c == '\0') {
done = true;
break;
}
- out << *(wordString++);
+ res += c;
}
- ++word;
- } while (! done);
+ ++wordPos;
+ } while(! done);
+
+ return std::make_pair(wordPos - word, res);
+}
+
+// return the number of operands consumed by the string
+int SpirvStream::disassembleString()
+{
+ out << " \"";
+ std::pair<int, std::string> decoderes = decodeString();
+
+ out << decoderes.second;
out << "\"";
- return word - startWord;
+ word += decoderes.first;
+
+ return decoderes.first;
}
void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, int numOperands)
@@ -331,7 +346,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
nextNestedControl = 0;
}
} else if (opCode == OpExtInstImport) {
- idDescriptor[resultId] = (const char*)(&stream[word]);
+ idDescriptor[resultId] = decodeString().second;
}
else {
if (resultId != 0 && idDescriptor[resultId].size() == 0) {
@@ -428,7 +443,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
--numOperands;
// Get names for printing "(XXX)" for readability, *after* this id
if (opCode == OpName)
- idDescriptor[stream[word - 1]] = (const char*)(&stream[word]);
+ idDescriptor[stream[word - 1]] = decodeString().second;
break;
case OperandVariableIds:
disassembleIds(numOperands);
diff --git a/thirdparty/glslang/SPIRV/doc.cpp b/thirdparty/glslang/SPIRV/doc.cpp
index dbdf7077a6..9a569e0d7f 100644
--- a/thirdparty/glslang/SPIRV/doc.cpp
+++ b/thirdparty/glslang/SPIRV/doc.cpp
@@ -900,6 +900,12 @@ const char* CapabilityString(int info)
case CapabilityDeviceGroup: return "DeviceGroup";
case CapabilityMultiView: return "MultiView";
+ case CapabilityDenormPreserve: return "DenormPreserve";
+ case CapabilityDenormFlushToZero: return "DenormFlushToZero";
+ case CapabilitySignedZeroInfNanPreserve: return "SignedZeroInfNanPreserve";
+ case CapabilityRoundingModeRTE: return "RoundingModeRTE";
+ case CapabilityRoundingModeRTZ: return "RoundingModeRTZ";
+
case CapabilityStencilExportEXT: return "StencilExportEXT";
case CapabilityFloat16ImageAMD: return "Float16ImageAMD";
diff --git a/thirdparty/glslang/SPIRV/spirv.hpp b/thirdparty/glslang/SPIRV/spirv.hpp
index e0fe24980d..3d500ebbd9 100644
--- a/thirdparty/glslang/SPIRV/spirv.hpp
+++ b/thirdparty/glslang/SPIRV/spirv.hpp
@@ -49,12 +49,12 @@ namespace spv {
typedef unsigned int Id;
-#define SPV_VERSION 0x10500
-#define SPV_REVISION 4
+#define SPV_VERSION 0x10600
+#define SPV_REVISION 1
static const unsigned int MagicNumber = 0x07230203;
-static const unsigned int Version = 0x00010500;
-static const unsigned int Revision = 4;
+static const unsigned int Version = 0x00010600;
+static const unsigned int Revision = 1;
static const unsigned int OpCodeMask = 0xffff;
static const unsigned int WordCountShift = 16;
@@ -65,6 +65,7 @@ enum SourceLanguage {
SourceLanguageOpenCL_C = 3,
SourceLanguageOpenCL_CPP = 4,
SourceLanguageHLSL = 5,
+ SourceLanguageCPP_for_OpenCL = 6,
SourceLanguageMax = 0x7fffffff,
};
@@ -352,6 +353,8 @@ enum ImageOperandsShift {
ImageOperandsVolatileTexelKHRShift = 11,
ImageOperandsSignExtendShift = 12,
ImageOperandsZeroExtendShift = 13,
+ ImageOperandsNontemporalShift = 14,
+ ImageOperandsOffsetsShift = 16,
ImageOperandsMax = 0x7fffffff,
};
@@ -375,6 +378,8 @@ enum ImageOperandsMask {
ImageOperandsVolatileTexelKHRMask = 0x00000800,
ImageOperandsSignExtendMask = 0x00001000,
ImageOperandsZeroExtendMask = 0x00002000,
+ ImageOperandsNontemporalMask = 0x00004000,
+ ImageOperandsOffsetsMask = 0x00010000,
};
enum FPFastMathModeShift {
@@ -491,6 +496,7 @@ enum Decoration {
DecorationPerPrimitiveNV = 5271,
DecorationPerViewNV = 5272,
DecorationPerTaskNV = 5273,
+ DecorationPerVertexKHR = 5285,
DecorationPerVertexNV = 5285,
DecorationNonUniform = 5300,
DecorationNonUniformEXT = 5300,
@@ -498,6 +504,10 @@ enum Decoration {
DecorationRestrictPointerEXT = 5355,
DecorationAliasedPointer = 5356,
DecorationAliasedPointerEXT = 5356,
+ DecorationBindlessSamplerNV = 5398,
+ DecorationBindlessImageNV = 5399,
+ DecorationBoundSamplerNV = 5400,
+ DecorationBoundImageNV = 5401,
DecorationSIMTCallINTEL = 5599,
DecorationReferencedIndirectlyINTEL = 5602,
DecorationClobberINTEL = 5607,
@@ -537,6 +547,7 @@ enum Decoration {
DecorationFunctionFloatingPointModeINTEL = 6080,
DecorationSingleElementVectorINTEL = 6085,
DecorationVectorComputeCallableFunctionINTEL = 6087,
+ DecorationMediaBlockIOINTEL = 6140,
DecorationMax = 0x7fffffff,
};
@@ -621,7 +632,9 @@ enum BuiltIn {
BuiltInLayerPerViewNV = 5279,
BuiltInMeshViewCountNV = 5280,
BuiltInMeshViewIndicesNV = 5281,
+ BuiltInBaryCoordKHR = 5286,
BuiltInBaryCoordNV = 5286,
+ BuiltInBaryCoordNoPerspKHR = 5287,
BuiltInBaryCoordNoPerspNV = 5287,
BuiltInFragSizeEXT = 5292,
BuiltInFragmentSizeNV = 5292,
@@ -722,6 +735,7 @@ enum FunctionControlShift {
FunctionControlDontInlineShift = 1,
FunctionControlPureShift = 2,
FunctionControlConstShift = 3,
+ FunctionControlOptNoneINTELShift = 16,
FunctionControlMax = 0x7fffffff,
};
@@ -731,6 +745,7 @@ enum FunctionControlMask {
FunctionControlDontInlineMask = 0x00000002,
FunctionControlPureMask = 0x00000004,
FunctionControlConstMask = 0x00000008,
+ FunctionControlOptNoneINTELMask = 0x00010000,
};
enum MemorySemanticsShift {
@@ -911,6 +926,7 @@ enum Capability {
CapabilityGroupNonUniformQuad = 68,
CapabilityShaderLayer = 69,
CapabilityShaderViewportIndex = 70,
+ CapabilityUniformDecoration = 71,
CapabilityFragmentShadingRateKHR = 4422,
CapabilitySubgroupBallotKHR = 4423,
CapabilityDrawParameters = 4427,
@@ -959,6 +975,7 @@ enum Capability {
CapabilityFragmentFullyCoveredEXT = 5265,
CapabilityMeshShadingNV = 5266,
CapabilityImageFootprintNV = 5282,
+ CapabilityFragmentBarycentricKHR = 5284,
CapabilityFragmentBarycentricNV = 5284,
CapabilityComputeDerivativeGroupQuadsNV = 5288,
CapabilityFragmentDensityEXT = 5291,
@@ -1003,7 +1020,9 @@ enum Capability {
CapabilityFragmentShaderShadingRateInterlockEXT = 5372,
CapabilityShaderSMBuiltinsNV = 5373,
CapabilityFragmentShaderPixelInterlockEXT = 5378,
+ CapabilityDemoteToHelperInvocation = 5379,
CapabilityDemoteToHelperInvocationEXT = 5379,
+ CapabilityBindlessTextureNV = 5390,
CapabilitySubgroupShuffleINTEL = 5568,
CapabilitySubgroupBufferBlockIOINTEL = 5569,
CapabilitySubgroupImageBlockIOINTEL = 5570,
@@ -1028,6 +1047,7 @@ enum Capability {
CapabilityFPGAMemoryAttributesINTEL = 5824,
CapabilityFPFastMathModeINTEL = 5837,
CapabilityArbitraryPrecisionIntegersINTEL = 5844,
+ CapabilityArbitraryPrecisionFloatingPointINTEL = 5845,
CapabilityUnstructuredLoopControlsINTEL = 5886,
CapabilityFPGALoopControlsINTEL = 5888,
CapabilityKernelAttributesINTEL = 5892,
@@ -1036,14 +1056,26 @@ enum Capability {
CapabilityFPGAClusterAttributesINTEL = 5904,
CapabilityLoopFuseINTEL = 5906,
CapabilityFPGABufferLocationINTEL = 5920,
+ CapabilityArbitraryPrecisionFixedPointINTEL = 5922,
CapabilityUSMStorageClassesINTEL = 5935,
CapabilityIOPipesINTEL = 5943,
CapabilityBlockingPipesINTEL = 5945,
CapabilityFPGARegINTEL = 5948,
+ CapabilityDotProductInputAll = 6016,
+ CapabilityDotProductInputAllKHR = 6016,
+ CapabilityDotProductInput4x8Bit = 6017,
+ CapabilityDotProductInput4x8BitKHR = 6017,
+ CapabilityDotProductInput4x8BitPacked = 6018,
+ CapabilityDotProductInput4x8BitPackedKHR = 6018,
+ CapabilityDotProduct = 6019,
+ CapabilityDotProductKHR = 6019,
+ CapabilityBitInstructions = 6025,
CapabilityAtomicFloat32AddEXT = 6033,
CapabilityAtomicFloat64AddEXT = 6034,
CapabilityLongConstantCompositeINTEL = 6089,
+ CapabilityOptNoneINTEL = 6094,
CapabilityAtomicFloat16AddEXT = 6095,
+ CapabilityDebugInfoModuleINTEL = 6114,
CapabilityMax = 0x7fffffff,
};
@@ -1122,6 +1154,32 @@ enum FPOperationMode {
FPOperationModeMax = 0x7fffffff,
};
+enum QuantizationModes {
+ QuantizationModesTRN = 0,
+ QuantizationModesTRN_ZERO = 1,
+ QuantizationModesRND = 2,
+ QuantizationModesRND_ZERO = 3,
+ QuantizationModesRND_INF = 4,
+ QuantizationModesRND_MIN_INF = 5,
+ QuantizationModesRND_CONV = 6,
+ QuantizationModesRND_CONV_ODD = 7,
+ QuantizationModesMax = 0x7fffffff,
+};
+
+enum OverflowModes {
+ OverflowModesWRAP = 0,
+ OverflowModesSAT = 1,
+ OverflowModesSAT_ZERO = 2,
+ OverflowModesSAT_SYM = 3,
+ OverflowModesMax = 0x7fffffff,
+};
+
+enum PackedVectorFormat {
+ PackedVectorFormatPackedVectorFormat4x8Bit = 0,
+ PackedVectorFormatPackedVectorFormat4x8BitKHR = 0,
+ PackedVectorFormatMax = 0x7fffffff,
+};
+
enum Op {
OpNop = 0,
OpUndef = 1,
@@ -1479,6 +1537,18 @@ enum Op {
OpConvertUToAccelerationStructureKHR = 4447,
OpIgnoreIntersectionKHR = 4448,
OpTerminateRayKHR = 4449,
+ OpSDot = 4450,
+ OpSDotKHR = 4450,
+ OpUDot = 4451,
+ OpUDotKHR = 4451,
+ OpSUDot = 4452,
+ OpSUDotKHR = 4452,
+ OpSDotAccSat = 4453,
+ OpSDotAccSatKHR = 4453,
+ OpUDotAccSat = 4454,
+ OpUDotAccSatKHR = 4454,
+ OpSUDotAccSat = 4455,
+ OpSUDotAccSatKHR = 4455,
OpTypeRayQueryKHR = 4472,
OpRayQueryInitializeKHR = 4473,
OpRayQueryTerminateKHR = 4474,
@@ -1517,8 +1587,16 @@ enum Op {
OpCooperativeMatrixLengthNV = 5362,
OpBeginInvocationInterlockEXT = 5364,
OpEndInvocationInterlockEXT = 5365,
+ OpDemoteToHelperInvocation = 5380,
OpDemoteToHelperInvocationEXT = 5380,
OpIsHelperInvocationEXT = 5381,
+ OpConvertUToImageNV = 5391,
+ OpConvertUToSamplerNV = 5392,
+ OpConvertImageToUNV = 5393,
+ OpConvertSamplerToUNV = 5394,
+ OpConvertUToSampledImageNV = 5395,
+ OpConvertSampledImageToUNV = 5396,
+ OpSamplerImageAddressingModeNV = 5397,
OpSubgroupShuffleINTEL = 5571,
OpSubgroupShuffleDownINTEL = 5572,
OpSubgroupShuffleUpINTEL = 5573,
@@ -1543,7 +1621,7 @@ enum Op {
OpUSubSatINTEL = 5596,
OpIMul32x16INTEL = 5597,
OpUMul32x16INTEL = 5598,
- OpConstFunctionPointerINTEL = 5600,
+ OpConstantFunctionPointerINTEL = 5600,
OpFunctionPointerCallINTEL = 5601,
OpAsmTargetINTEL = 5609,
OpAsmINTEL = 5610,
@@ -1677,7 +1755,59 @@ enum Op {
OpVariableLengthArrayINTEL = 5818,
OpSaveMemoryINTEL = 5819,
OpRestoreMemoryINTEL = 5820,
+ OpArbitraryFloatSinCosPiINTEL = 5840,
+ OpArbitraryFloatCastINTEL = 5841,
+ OpArbitraryFloatCastFromIntINTEL = 5842,
+ OpArbitraryFloatCastToIntINTEL = 5843,
+ OpArbitraryFloatAddINTEL = 5846,
+ OpArbitraryFloatSubINTEL = 5847,
+ OpArbitraryFloatMulINTEL = 5848,
+ OpArbitraryFloatDivINTEL = 5849,
+ OpArbitraryFloatGTINTEL = 5850,
+ OpArbitraryFloatGEINTEL = 5851,
+ OpArbitraryFloatLTINTEL = 5852,
+ OpArbitraryFloatLEINTEL = 5853,
+ OpArbitraryFloatEQINTEL = 5854,
+ OpArbitraryFloatRecipINTEL = 5855,
+ OpArbitraryFloatRSqrtINTEL = 5856,
+ OpArbitraryFloatCbrtINTEL = 5857,
+ OpArbitraryFloatHypotINTEL = 5858,
+ OpArbitraryFloatSqrtINTEL = 5859,
+ OpArbitraryFloatLogINTEL = 5860,
+ OpArbitraryFloatLog2INTEL = 5861,
+ OpArbitraryFloatLog10INTEL = 5862,
+ OpArbitraryFloatLog1pINTEL = 5863,
+ OpArbitraryFloatExpINTEL = 5864,
+ OpArbitraryFloatExp2INTEL = 5865,
+ OpArbitraryFloatExp10INTEL = 5866,
+ OpArbitraryFloatExpm1INTEL = 5867,
+ OpArbitraryFloatSinINTEL = 5868,
+ OpArbitraryFloatCosINTEL = 5869,
+ OpArbitraryFloatSinCosINTEL = 5870,
+ OpArbitraryFloatSinPiINTEL = 5871,
+ OpArbitraryFloatCosPiINTEL = 5872,
+ OpArbitraryFloatASinINTEL = 5873,
+ OpArbitraryFloatASinPiINTEL = 5874,
+ OpArbitraryFloatACosINTEL = 5875,
+ OpArbitraryFloatACosPiINTEL = 5876,
+ OpArbitraryFloatATanINTEL = 5877,
+ OpArbitraryFloatATanPiINTEL = 5878,
+ OpArbitraryFloatATan2INTEL = 5879,
+ OpArbitraryFloatPowINTEL = 5880,
+ OpArbitraryFloatPowRINTEL = 5881,
+ OpArbitraryFloatPowNINTEL = 5882,
OpLoopControlINTEL = 5887,
+ OpFixedSqrtINTEL = 5923,
+ OpFixedRecipINTEL = 5924,
+ OpFixedRsqrtINTEL = 5925,
+ OpFixedSinINTEL = 5926,
+ OpFixedCosINTEL = 5927,
+ OpFixedSinCosINTEL = 5928,
+ OpFixedSinPiINTEL = 5929,
+ OpFixedCosPiINTEL = 5930,
+ OpFixedSinCosPiINTEL = 5931,
+ OpFixedLogINTEL = 5932,
+ OpFixedExpINTEL = 5933,
OpPtrCastToCrossWorkgroupINTEL = 5934,
OpCrossWorkgroupCastToPtrINTEL = 5938,
OpReadPipeBlockingINTEL = 5946,
@@ -2069,6 +2199,12 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpConvertUToAccelerationStructureKHR: *hasResult = true; *hasResultType = true; break;
case OpIgnoreIntersectionKHR: *hasResult = false; *hasResultType = false; break;
case OpTerminateRayKHR: *hasResult = false; *hasResultType = false; break;
+ case OpSDot: *hasResult = true; *hasResultType = true; break;
+ case OpUDot: *hasResult = true; *hasResultType = true; break;
+ case OpSUDot: *hasResult = true; *hasResultType = true; break;
+ case OpSDotAccSat: *hasResult = true; *hasResultType = true; break;
+ case OpUDotAccSat: *hasResult = true; *hasResultType = true; break;
+ case OpSUDotAccSat: *hasResult = true; *hasResultType = true; break;
case OpTypeRayQueryKHR: *hasResult = true; *hasResultType = false; break;
case OpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break;
case OpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break;
@@ -2105,8 +2241,15 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break;
case OpBeginInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break;
case OpEndInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break;
- case OpDemoteToHelperInvocationEXT: *hasResult = false; *hasResultType = false; break;
+ case OpDemoteToHelperInvocation: *hasResult = false; *hasResultType = false; break;
case OpIsHelperInvocationEXT: *hasResult = true; *hasResultType = true; break;
+ case OpConvertUToImageNV: *hasResult = true; *hasResultType = true; break;
+ case OpConvertUToSamplerNV: *hasResult = true; *hasResultType = true; break;
+ case OpConvertImageToUNV: *hasResult = true; *hasResultType = true; break;
+ case OpConvertSamplerToUNV: *hasResult = true; *hasResultType = true; break;
+ case OpConvertUToSampledImageNV: *hasResult = true; *hasResultType = true; break;
+ case OpConvertSampledImageToUNV: *hasResult = true; *hasResultType = true; break;
+ case OpSamplerImageAddressingModeNV: *hasResult = false; *hasResultType = false; break;
case OpSubgroupShuffleINTEL: *hasResult = true; *hasResultType = true; break;
case OpSubgroupShuffleDownINTEL: *hasResult = true; *hasResultType = true; break;
case OpSubgroupShuffleUpINTEL: *hasResult = true; *hasResultType = true; break;
@@ -2131,7 +2274,7 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpUSubSatINTEL: *hasResult = true; *hasResultType = true; break;
case OpIMul32x16INTEL: *hasResult = true; *hasResultType = true; break;
case OpUMul32x16INTEL: *hasResult = true; *hasResultType = true; break;
- case OpConstFunctionPointerINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpConstantFunctionPointerINTEL: *hasResult = true; *hasResultType = true; break;
case OpFunctionPointerCallINTEL: *hasResult = true; *hasResultType = true; break;
case OpAsmTargetINTEL: *hasResult = true; *hasResultType = true; break;
case OpAsmINTEL: *hasResult = true; *hasResultType = true; break;
@@ -2263,7 +2406,59 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpVariableLengthArrayINTEL: *hasResult = true; *hasResultType = true; break;
case OpSaveMemoryINTEL: *hasResult = true; *hasResultType = true; break;
case OpRestoreMemoryINTEL: *hasResult = false; *hasResultType = false; break;
+ case OpArbitraryFloatSinCosPiINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatCastINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatCastFromIntINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatCastToIntINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatAddINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatSubINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatMulINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatDivINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatGTINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatGEINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatLTINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatLEINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatEQINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatRecipINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatRSqrtINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatCbrtINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatHypotINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatSqrtINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatLogINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatLog2INTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatLog10INTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatLog1pINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatExpINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatExp2INTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatExp10INTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatExpm1INTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatSinINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatCosINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatSinCosINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatSinPiINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatCosPiINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatASinINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatASinPiINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatACosINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatACosPiINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatATanINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatATanPiINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatATan2INTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatPowINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatPowRINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpArbitraryFloatPowNINTEL: *hasResult = true; *hasResultType = true; break;
case OpLoopControlINTEL: *hasResult = false; *hasResultType = false; break;
+ case OpFixedSqrtINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpFixedRecipINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpFixedRsqrtINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpFixedSinINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpFixedCosINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpFixedSinCosINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpFixedSinPiINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpFixedCosPiINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpFixedSinCosPiINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpFixedLogINTEL: *hasResult = true; *hasResultType = true; break;
+ case OpFixedExpINTEL: *hasResult = true; *hasResultType = true; break;
case OpPtrCastToCrossWorkgroupINTEL: *hasResult = true; *hasResultType = true; break;
case OpCrossWorkgroupCastToPtrINTEL: *hasResult = true; *hasResultType = true; break;
case OpReadPipeBlockingINTEL: *hasResult = true; *hasResultType = true; break;
diff --git a/thirdparty/glslang/SPIRV/spvIR.h b/thirdparty/glslang/SPIRV/spvIR.h
index 486e80d000..5249a5ba73 100644
--- a/thirdparty/glslang/SPIRV/spvIR.h
+++ b/thirdparty/glslang/SPIRV/spvIR.h
@@ -111,27 +111,23 @@ public:
void addStringOperand(const char* str)
{
- unsigned int word;
- char* wordString = (char*)&word;
- char* wordPtr = wordString;
- int charCount = 0;
+ unsigned int word = 0;
+ unsigned int shiftAmount = 0;
char c;
+
do {
c = *(str++);
- *(wordPtr++) = c;
- ++charCount;
- if (charCount == 4) {
+ word |= ((unsigned int)c) << shiftAmount;
+ shiftAmount += 8;
+ if (shiftAmount == 32) {
addImmediateOperand(word);
- wordPtr = wordString;
- charCount = 0;
+ word = 0;
+ shiftAmount = 0;
}
} while (c != 0);
// deal with partial last word
- if (charCount > 0) {
- // pad with 0s
- for (; charCount < 4; ++charCount)
- *(wordPtr++) = 0;
+ if (shiftAmount > 0) {
addImmediateOperand(word);
}
}