Updated glslang.
This commit is contained in:
parent
d9a8a86d85
commit
dbc8a2c62a
16
3rdparty/glslang/SPIRV/SPVRemapper.cpp
vendored
16
3rdparty/glslang/SPIRV/SPVRemapper.cpp
vendored
@ -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++;
|
||||
|
||||
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()
|
||||
|
6
3rdparty/glslang/SPIRV/SpvBuilder.cpp
vendored
6
3rdparty/glslang/SPIRV/SpvBuilder.cpp
vendored
@ -433,11 +433,11 @@ Id Builder::makeGenericType(spv::Op opcode, std::vector<spv::IdImmediate>& opera
|
||||
Instruction* type;
|
||||
for (int t = 0; t < (int)groupedTypes[opcode].size(); ++t) {
|
||||
type = groupedTypes[opcode][t];
|
||||
if (type->getNumOperands() != operands.size())
|
||||
if (static_cast<size_t>(type->getNumOperands()) != operands.size())
|
||||
continue; // Number mismatch, find next
|
||||
|
||||
bool match = true;
|
||||
for (int op = 0; match && op < operands.size(); ++op) {
|
||||
for (size_t op = 0; match && op < operands.size(); ++op) {
|
||||
match = (operands[op].isId ? type->getIdOperand(op) : type->getImmediateOperand(op)) == operands[op].word;
|
||||
}
|
||||
if (match)
|
||||
@ -446,7 +446,7 @@ Id Builder::makeGenericType(spv::Op opcode, std::vector<spv::IdImmediate>& opera
|
||||
|
||||
// not found, make it
|
||||
type = new Instruction(getUniqueId(), NoType, opcode);
|
||||
for (int op = 0; op < operands.size(); ++op) {
|
||||
for (size_t op = 0; op < operands.size(); ++op) {
|
||||
if (operands[op].isId)
|
||||
type->addIdOperand(operands[op].word);
|
||||
else
|
||||
|
45
3rdparty/glslang/SPIRV/disassemble.cpp
vendored
45
3rdparty/glslang/SPIRV/disassemble.cpp
vendored
@ -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;
|
||||
++wordPos;
|
||||
} while(! done);
|
||||
|
||||
return std::make_pair(wordPos - word, res);
|
||||
}
|
||||
|
||||
// return the number of operands consumed by the string
|
||||
int SpirvStream::disassembleString()
|
||||
{
|
||||
out << " \"";
|
||||
|
||||
return word - startWord;
|
||||
std::pair<int, std::string> decoderes = decodeString();
|
||||
|
||||
out << decoderes.second;
|
||||
out << "\"";
|
||||
|
||||
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);
|
||||
|
22
3rdparty/glslang/SPIRV/spvIR.h
vendored
22
3rdparty/glslang/SPIRV/spvIR.h
vendored
@ -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);
|
||||
}
|
||||
}
|
||||
|
7
3rdparty/glslang/glslang/Include/Types.h
vendored
7
3rdparty/glslang/glslang/Include/Types.h
vendored
@ -2446,11 +2446,15 @@ public:
|
||||
//
|
||||
bool sameStructType(const TType& right) const
|
||||
{
|
||||
// TODO: Why return true when neither types are structures?
|
||||
// Most commonly, they are both nullptr, or the same pointer to the same actual structure
|
||||
if ((!isStruct() && !right.isStruct()) ||
|
||||
(isStruct() && right.isStruct() && structure == right.structure))
|
||||
return true;
|
||||
|
||||
if (!isStruct() || !right.isStruct())
|
||||
return false;
|
||||
|
||||
// Structure names have to match
|
||||
if (*typeName != *right.typeName)
|
||||
return false;
|
||||
@ -2460,8 +2464,7 @@ public:
|
||||
bool isGLPerVertex = *typeName == "gl_PerVertex";
|
||||
|
||||
// Both being nullptr was caught above, now they both have to be structures of the same number of elements
|
||||
if (!isStruct() || !right.isStruct() ||
|
||||
(structure->size() != right.structure->size() && !isGLPerVertex))
|
||||
if (structure->size() != right.structure->size() && !isGLPerVertex)
|
||||
return false;
|
||||
|
||||
// Compare the names and types of all the members, which have to match
|
||||
|
@ -8353,10 +8353,11 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version < 330 ) {
|
||||
symbolTable.setFunctionExtensions("floatBitsToInt", 1, &E_GL_ARB_shader_bit_encoding);
|
||||
symbolTable.setFunctionExtensions("floatBitsToUint", 1, &E_GL_ARB_shader_bit_encoding);
|
||||
symbolTable.setFunctionExtensions("intBitsToFloat", 1, &E_GL_ARB_shader_bit_encoding);
|
||||
symbolTable.setFunctionExtensions("uintBitsToFloat", 1, &E_GL_ARB_shader_bit_encoding);
|
||||
const char* bitsConvertExt[2] = {E_GL_ARB_shader_bit_encoding, E_GL_ARB_gpu_shader5};
|
||||
symbolTable.setFunctionExtensions("floatBitsToInt", 2, bitsConvertExt);
|
||||
symbolTable.setFunctionExtensions("floatBitsToUint", 2, bitsConvertExt);
|
||||
symbolTable.setFunctionExtensions("intBitsToFloat", 2, bitsConvertExt);
|
||||
symbolTable.setFunctionExtensions("uintBitsToFloat", 2, bitsConvertExt);
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version < 430 ) {
|
||||
|
@ -1321,7 +1321,7 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
|
||||
// Find it in the symbol table.
|
||||
//
|
||||
const TFunction* fnCandidate;
|
||||
bool builtIn;
|
||||
bool builtIn {false};
|
||||
fnCandidate = findFunction(loc, *function, builtIn);
|
||||
if (fnCandidate) {
|
||||
// This is a declared function that might map to
|
||||
@ -6210,11 +6210,13 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
if (qualifier.hasXfbOffset() && qualifier.hasXfbBuffer()) {
|
||||
if (type.isUnsizedArray()) {
|
||||
error(loc, "unsized array", "xfb_offset", "in buffer %d", qualifier.layoutXfbBuffer);
|
||||
} else {
|
||||
int repeated = intermediate.addXfbBufferOffset(type);
|
||||
if (repeated >= 0)
|
||||
error(loc, "overlapping offsets at", "xfb_offset", "offset %d in buffer %d", repeated, qualifier.layoutXfbBuffer);
|
||||
if (type.isUnsizedArray())
|
||||
error(loc, "unsized array", "xfb_offset", "in buffer %d", qualifier.layoutXfbBuffer);
|
||||
}
|
||||
|
||||
// "The offset must be a multiple of the size of the first component of the first
|
||||
// qualified variable or block member, or a compile-time error results. Further, if applied to an aggregate
|
||||
|
@ -1802,7 +1802,7 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
|
||||
return size;
|
||||
}
|
||||
|
||||
int numComponents;
|
||||
int numComponents {0};
|
||||
if (type.isScalar())
|
||||
numComponents = 1;
|
||||
else if (type.isVector())
|
||||
|
Loading…
x
Reference in New Issue
Block a user