mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Updated glslang.
This commit is contained in:
5
3rdparty/glslang/CHANGES.md
vendored
5
3rdparty/glslang/CHANGES.md
vendored
@@ -3,6 +3,11 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## 11.7.0 2021-11-11
|
||||
|
||||
### Other changes
|
||||
* Add support for targeting Vulkan 1.2 in the C API
|
||||
|
||||
## 11.6.0 2021-08-25
|
||||
|
||||
### Other changes
|
||||
|
||||
31
3rdparty/glslang/SPIRV/GlslangToSpv.cpp
vendored
31
3rdparty/glslang/SPIRV/GlslangToSpv.cpp
vendored
@@ -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;
|
||||
@@ -4148,23 +4150,23 @@ 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) {
|
||||
// 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);
|
||||
operands.push_back({false, literal});
|
||||
} else if (typeParam.constant->getBasicType() == glslang::EbtInt) {
|
||||
unsigned literal = typeParam.constant->getConstArray()[0].getIConst();
|
||||
operands.push_back(literal);
|
||||
operands.push_back({false, literal});
|
||||
} else if (typeParam.constant->getBasicType() == glslang::EbtUint) {
|
||||
unsigned literal = typeParam.constant->getConstArray()[0].getUConst();
|
||||
operands.push_back(literal);
|
||||
operands.push_back({false, literal});
|
||||
} else if (typeParam.constant->getBasicType() == glslang::EbtBool) {
|
||||
unsigned literal = typeParam.constant->getConstArray()[0].getBConst();
|
||||
operands.push_back(literal);
|
||||
operands.push_back({false, literal});
|
||||
} else if (typeParam.constant->getBasicType() == glslang::EbtString) {
|
||||
auto str = typeParam.constant->getConstArray()[0].getSConst()->c_str();
|
||||
unsigned literal = 0;
|
||||
@@ -4176,7 +4178,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
*(literalPtr++) = ch;
|
||||
++charCount;
|
||||
if (charCount == 4) {
|
||||
operands.push_back(literal);
|
||||
operands.push_back({false, literal});
|
||||
literalPtr = reinterpret_cast<char*>(&literal);
|
||||
charCount = 0;
|
||||
}
|
||||
@@ -4186,20 +4188,17 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
if (charCount > 0) {
|
||||
for (; charCount < 4; ++charCount)
|
||||
*(literalPtr++) = 0;
|
||||
operands.push_back(literal);
|
||||
operands.push_back({false, literal});
|
||||
}
|
||||
} else
|
||||
assert(0); // Unexpected type
|
||||
} else
|
||||
operands.push_back(createSpvConstant(*typeParam.constant));
|
||||
operands.push_back({true, createSpvConstant(*typeParam.constant)});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
assert(spirvInst.set == ""); // Currently, couldn't be extended instructions.
|
||||
spvType = builder.makeGenericType(static_cast<spv::Op>(spirvInst.id), operands);
|
||||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
31
3rdparty/glslang/SPIRV/SpvBuilder.cpp
vendored
31
3rdparty/glslang/SPIRV/SpvBuilder.cpp
vendored
@@ -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 (type->getNumOperands() != operands.size())
|
||||
continue; // Number mismatch, find next
|
||||
|
||||
bool match = true;
|
||||
for (int op = 0; match && op < 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 (int 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.
|
||||
|
||||
1
3rdparty/glslang/SPIRV/SpvBuilder.h
vendored
1
3rdparty/glslang/SPIRV/SpvBuilder.h
vendored
@@ -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();
|
||||
|
||||
6
3rdparty/glslang/SPIRV/doc.cpp
vendored
6
3rdparty/glslang/SPIRV/doc.cpp
vendored
@@ -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";
|
||||
|
||||
4
3rdparty/glslang/SPIRV/spirv.hpp
vendored
4
3rdparty/glslang/SPIRV/spirv.hpp
vendored
@@ -1543,7 +1543,7 @@ enum Op {
|
||||
OpUSubSatINTEL = 5596,
|
||||
OpIMul32x16INTEL = 5597,
|
||||
OpUMul32x16INTEL = 5598,
|
||||
OpConstFunctionPointerINTEL = 5600,
|
||||
OpConstantFunctionPointerINTEL = 5600,
|
||||
OpFunctionPointerCallINTEL = 5601,
|
||||
OpAsmTargetINTEL = 5609,
|
||||
OpAsmINTEL = 5610,
|
||||
@@ -2131,7 +2131,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;
|
||||
|
||||
8
3rdparty/glslang/StandAlone/StandAlone.cpp
vendored
8
3rdparty/glslang/StandAlone/StandAlone.cpp
vendored
@@ -177,6 +177,7 @@ const char* shaderStageName = nullptr;
|
||||
const char* variableName = nullptr;
|
||||
bool HlslEnable16BitTypes = false;
|
||||
bool HlslDX9compatible = false;
|
||||
bool HlslDxPositionW = false;
|
||||
bool DumpBuiltinSymbols = false;
|
||||
std::vector<std::string> IncludeDirectoryList;
|
||||
|
||||
@@ -662,6 +663,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
|
||||
HlslEnable16BitTypes = true;
|
||||
} else if (lowerword == "hlsl-dx9-compatible") {
|
||||
HlslDX9compatible = true;
|
||||
} else if (lowerword == "hlsl-dx-position-w") {
|
||||
HlslDxPositionW = true;
|
||||
} else if (lowerword == "auto-sampled-textures") {
|
||||
autoSampledTextures = true;
|
||||
} else if (lowerword == "invert-y" || // synonyms
|
||||
@@ -1284,6 +1287,9 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
|
||||
if (Options & EOptionInvertY)
|
||||
shader->setInvertY(true);
|
||||
|
||||
if (HlslDxPositionW)
|
||||
shader->setDxPositionW(true);
|
||||
|
||||
// Set up the environment, some subsettings take precedence over earlier
|
||||
// ways of setting things.
|
||||
if (Options & EOptionSpv) {
|
||||
@@ -1847,6 +1853,8 @@ void usage()
|
||||
" --hlsl-dx9-compatible interprets sampler declarations as a\n"
|
||||
" texture/sampler combo like DirectX9 would,\n"
|
||||
" and recognizes DirectX9-specific semantics\n"
|
||||
" --hlsl-dx-position-w W component of SV_Position in HLSL fragment\n"
|
||||
" shaders compatible with DirectX\n"
|
||||
" --invert-y | --iy invert position.Y output in vertex shader\n"
|
||||
" --keep-uncalled | --ku don't eliminate uncalled functions\n"
|
||||
" --nan-clamp favor non-NaN operand in min, max, and clamp\n"
|
||||
|
||||
2
3rdparty/glslang/build_info.h
vendored
2
3rdparty/glslang/build_info.h
vendored
@@ -35,7 +35,7 @@
|
||||
#define GLSLANG_BUILD_INFO
|
||||
|
||||
#define GLSLANG_VERSION_MAJOR 11
|
||||
#define GLSLANG_VERSION_MINOR 6
|
||||
#define GLSLANG_VERSION_MINOR 7
|
||||
#define GLSLANG_VERSION_PATCH 0
|
||||
#define GLSLANG_VERSION_FLAVOR ""
|
||||
|
||||
|
||||
@@ -269,6 +269,8 @@ static glslang::EShTargetClientVersion c_shader_client_version(glslang_target_cl
|
||||
switch (client_version) {
|
||||
case GLSLANG_TARGET_VULKAN_1_1:
|
||||
return glslang::EShTargetVulkan_1_1;
|
||||
case GLSLANG_TARGET_VULKAN_1_2:
|
||||
return glslang::EShTargetVulkan_1_2;
|
||||
case GLSLANG_TARGET_OPENGL_450:
|
||||
return glslang::EShTargetOpenGL_450;
|
||||
default:
|
||||
|
||||
@@ -36,19 +36,3 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#extension GL_EXT_spirv_intrinsics : enable
|
||||
#extension GL_ARB_gpu_shader_int64 : enable
|
||||
|
||||
uvec2 clockRealtime2x32EXT(void) {
|
||||
spirv_instruction (extensions = ["SPV_KHR_shader_clock"], capabilities = [5055], id = 5056)
|
||||
uvec2 clockRealtime2x32EXT_internal(uint scope);
|
||||
|
||||
return clockRealtime2x32EXT_internal(1 /*Device scope*/);
|
||||
}
|
||||
|
||||
uint64_t clockRealtimeEXT(void) {
|
||||
spirv_instruction (extensions = ["SPV_KHR_shader_clock"], capabilities = [5055], id = 5056)
|
||||
uint64_t clockRealtimeEXT_internal(uint scope);
|
||||
|
||||
return clockRealtimeEXT_internal(1 /*Device scope*/);
|
||||
}
|
||||
@@ -2167,8 +2167,21 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
|
||||
TIntermSymbol* arg = intermediate.addSymbol(*argVars.back());
|
||||
handleFunctionArgument(&callee, callingArgs, arg);
|
||||
if (param.type->getQualifier().isParamInput()) {
|
||||
intermediate.growAggregate(synthBody, handleAssign(loc, EOpAssign, arg,
|
||||
intermediate.addSymbol(**inputIt)));
|
||||
TIntermTyped* input = intermediate.addSymbol(**inputIt);
|
||||
if (input->getType().getQualifier().builtIn == EbvFragCoord && intermediate.getDxPositionW()) {
|
||||
// Replace FragCoord W with reciprocal
|
||||
auto pos_xyz = handleDotDereference(loc, input, "xyz");
|
||||
auto pos_w = handleDotDereference(loc, input, "w");
|
||||
auto one = intermediate.addConstantUnion(1.0, EbtFloat, loc);
|
||||
auto recip_w = intermediate.addBinaryMath(EOpDiv, one, pos_w, loc);
|
||||
TIntermAggregate* dst = new TIntermAggregate(EOpConstructVec4);
|
||||
dst->getSequence().push_back(pos_xyz);
|
||||
dst->getSequence().push_back(recip_w);
|
||||
dst->setType(TType(EbtFloat, EvqTemporary, 4));
|
||||
dst->setLoc(loc);
|
||||
input = dst;
|
||||
}
|
||||
intermediate.growAggregate(synthBody, handleAssign(loc, EOpAssign, arg, input));
|
||||
inputIt++;
|
||||
}
|
||||
if (param.type->getQualifier().storage == EvqUniform) {
|
||||
@@ -6935,6 +6948,9 @@ void HlslParseContext::shareStructBufferType(TType& type)
|
||||
if (lhs.isStruct() != rhs.isStruct())
|
||||
return false;
|
||||
|
||||
if (lhs.getQualifier().builtIn != rhs.getQualifier().builtIn)
|
||||
return false;
|
||||
|
||||
if (lhs.isStruct() && rhs.isStruct()) {
|
||||
if (lhs.getStruct()->size() != rhs.getStruct()->size())
|
||||
return false;
|
||||
|
||||
33
3rdparty/glslang/glslang/Include/Common.h
vendored
33
3rdparty/glslang/glslang/Include/Common.h
vendored
@@ -40,6 +40,11 @@
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#ifdef _MSC_VER
|
||||
#include <cfloat>
|
||||
#else
|
||||
#include <cmath>
|
||||
#endif
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <list>
|
||||
@@ -303,6 +308,34 @@ template <class T> int IntLog2(T n)
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool IsInfinity(double x) {
|
||||
#ifdef _MSC_VER
|
||||
switch (_fpclass(x)) {
|
||||
case _FPCLASS_NINF:
|
||||
case _FPCLASS_PINF:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return std::isinf(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool IsNan(double x) {
|
||||
#ifdef _MSC_VER
|
||||
switch (_fpclass(x)) {
|
||||
case _FPCLASS_SNAN:
|
||||
case _FPCLASS_QNAN:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return std::isnan(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
#endif // _COMMON_INCLUDED_
|
||||
|
||||
12
3rdparty/glslang/glslang/Include/Types.h
vendored
12
3rdparty/glslang/glslang/Include/Types.h
vendored
@@ -2469,6 +2469,14 @@ public:
|
||||
if (*(*structure)[li].type != *(*right.structure)[ri].type)
|
||||
return false;
|
||||
} else {
|
||||
// Skip hidden members
|
||||
if ((*structure)[li].type->hiddenMember()) {
|
||||
ri--;
|
||||
continue;
|
||||
} else if ((*right.structure)[ri].type->hiddenMember()) {
|
||||
li--;
|
||||
continue;
|
||||
}
|
||||
// If one of the members is something that's inconsistently declared, skip over it
|
||||
// for now.
|
||||
if (isGLPerVertex) {
|
||||
@@ -2485,10 +2493,10 @@ public:
|
||||
}
|
||||
// If we get here, then there should only be inconsistently declared members left
|
||||
} else if (li < structure->size()) {
|
||||
if (!isInconsistentGLPerVertexMember((*structure)[li].type->getFieldName()))
|
||||
if (!(*structure)[li].type->hiddenMember() && !isInconsistentGLPerVertexMember((*structure)[li].type->getFieldName()))
|
||||
return false;
|
||||
} else {
|
||||
if (!isInconsistentGLPerVertexMember((*right.structure)[ri].type->getFieldName()))
|
||||
if (!(*right.structure)[ri].type->hiddenMember() && !isInconsistentGLPerVertexMember((*right.structure)[ri].type->getFieldName()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,35 +46,6 @@ namespace {
|
||||
|
||||
using namespace glslang;
|
||||
|
||||
typedef union {
|
||||
double d;
|
||||
int i[2];
|
||||
} DoubleIntUnion;
|
||||
|
||||
// Some helper functions
|
||||
|
||||
bool isNan(double x)
|
||||
{
|
||||
DoubleIntUnion u;
|
||||
// tough to find a platform independent library function, do it directly
|
||||
u.d = x;
|
||||
int bitPatternL = u.i[0];
|
||||
int bitPatternH = u.i[1];
|
||||
return (bitPatternH & 0x7ff80000) == 0x7ff80000 &&
|
||||
((bitPatternH & 0xFFFFF) != 0 || bitPatternL != 0);
|
||||
}
|
||||
|
||||
bool isInf(double x)
|
||||
{
|
||||
DoubleIntUnion u;
|
||||
// tough to find a platform independent library function, do it directly
|
||||
u.d = x;
|
||||
int bitPatternL = u.i[0];
|
||||
int bitPatternH = u.i[1];
|
||||
return (bitPatternH & 0x7ff00000) == 0x7ff00000 &&
|
||||
(bitPatternH & 0xFFFFF) == 0 && bitPatternL == 0;
|
||||
}
|
||||
|
||||
const double pi = 3.1415926535897932384626433832795;
|
||||
|
||||
} // end anonymous namespace
|
||||
@@ -663,12 +634,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
|
||||
|
||||
case EOpIsNan:
|
||||
{
|
||||
newConstArray[i].setBConst(isNan(unionArray[i].getDConst()));
|
||||
newConstArray[i].setBConst(IsNan(unionArray[i].getDConst()));
|
||||
break;
|
||||
}
|
||||
case EOpIsInf:
|
||||
{
|
||||
newConstArray[i].setBConst(isInf(unionArray[i].getDConst()));
|
||||
newConstArray[i].setBConst(IsInfinity(unionArray[i].getDConst()));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -316,6 +316,7 @@ const CustomFunction CustomFunctions[] = {
|
||||
|
||||
{ EOpTextureQuerySize, "textureSize", nullptr },
|
||||
{ EOpTextureQueryLod, "textureQueryLod", nullptr },
|
||||
{ EOpTextureQueryLod, "textureQueryLOD", nullptr }, // extension GL_ARB_texture_query_lod
|
||||
{ EOpTextureQueryLevels, "textureQueryLevels", nullptr },
|
||||
{ EOpTextureQuerySamples, "textureSamples", nullptr },
|
||||
{ EOpTexture, "texture", nullptr },
|
||||
@@ -4553,11 +4554,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"\n");
|
||||
}
|
||||
|
||||
// GL_ARB_shader_clock
|
||||
// GL_ARB_shader_clock& GL_EXT_shader_realtime_clock
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
commonBuiltins.append(
|
||||
"uvec2 clock2x32ARB();"
|
||||
"uint64_t clockARB();"
|
||||
"uvec2 clockRealtime2x32EXT();"
|
||||
"uint64_t clockRealtimeEXT();"
|
||||
"\n");
|
||||
}
|
||||
|
||||
@@ -6245,38 +6248,44 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int
|
||||
//
|
||||
// textureQueryLod(), fragment stage only
|
||||
// Also enabled with extension GL_ARB_texture_query_lod
|
||||
// Extension GL_ARB_texture_query_lod says that textureQueryLOD() also exist at extension.
|
||||
|
||||
if (profile != EEsProfile && version >= 150 && sampler.isCombined() && sampler.dim != EsdRect &&
|
||||
! sampler.isMultiSample() && ! sampler.isBuffer()) {
|
||||
for (int f16TexAddr = 0; f16TexAddr < 2; ++f16TexAddr) {
|
||||
if (f16TexAddr && sampler.type != EbtFloat16)
|
||||
continue;
|
||||
stageBuiltins[EShLangFragment].append("vec2 textureQueryLod(");
|
||||
stageBuiltins[EShLangFragment].append(typeName);
|
||||
if (dimMap[sampler.dim] == 1)
|
||||
if (f16TexAddr)
|
||||
stageBuiltins[EShLangFragment].append(", float16_t");
|
||||
else
|
||||
stageBuiltins[EShLangFragment].append(", float");
|
||||
else {
|
||||
if (f16TexAddr)
|
||||
stageBuiltins[EShLangFragment].append(", f16vec");
|
||||
else
|
||||
stageBuiltins[EShLangFragment].append(", vec");
|
||||
stageBuiltins[EShLangFragment].append(postfixes[dimMap[sampler.dim]]);
|
||||
}
|
||||
stageBuiltins[EShLangFragment].append(");\n");
|
||||
}
|
||||
|
||||
stageBuiltins[EShLangCompute].append("vec2 textureQueryLod(");
|
||||
stageBuiltins[EShLangCompute].append(typeName);
|
||||
if (dimMap[sampler.dim] == 1)
|
||||
stageBuiltins[EShLangCompute].append(", float");
|
||||
else {
|
||||
stageBuiltins[EShLangCompute].append(", vec");
|
||||
stageBuiltins[EShLangCompute].append(postfixes[dimMap[sampler.dim]]);
|
||||
const TString funcName[2] = {"vec2 textureQueryLod(", "vec2 textureQueryLOD("};
|
||||
|
||||
for (int i = 0; i < 2; ++i){
|
||||
for (int f16TexAddr = 0; f16TexAddr < 2; ++f16TexAddr) {
|
||||
if (f16TexAddr && sampler.type != EbtFloat16)
|
||||
continue;
|
||||
stageBuiltins[EShLangFragment].append(funcName[i]);
|
||||
stageBuiltins[EShLangFragment].append(typeName);
|
||||
if (dimMap[sampler.dim] == 1)
|
||||
if (f16TexAddr)
|
||||
stageBuiltins[EShLangFragment].append(", float16_t");
|
||||
else
|
||||
stageBuiltins[EShLangFragment].append(", float");
|
||||
else {
|
||||
if (f16TexAddr)
|
||||
stageBuiltins[EShLangFragment].append(", f16vec");
|
||||
else
|
||||
stageBuiltins[EShLangFragment].append(", vec");
|
||||
stageBuiltins[EShLangFragment].append(postfixes[dimMap[sampler.dim]]);
|
||||
}
|
||||
stageBuiltins[EShLangFragment].append(");\n");
|
||||
}
|
||||
|
||||
stageBuiltins[EShLangCompute].append(funcName[i]);
|
||||
stageBuiltins[EShLangCompute].append(typeName);
|
||||
if (dimMap[sampler.dim] == 1)
|
||||
stageBuiltins[EShLangCompute].append(", float");
|
||||
else {
|
||||
stageBuiltins[EShLangCompute].append(", vec");
|
||||
stageBuiltins[EShLangCompute].append(postfixes[dimMap[sampler.dim]]);
|
||||
}
|
||||
stageBuiltins[EShLangCompute].append(");\n");
|
||||
}
|
||||
stageBuiltins[EShLangCompute].append(");\n");
|
||||
}
|
||||
|
||||
//
|
||||
@@ -8061,7 +8070,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version < 400) {
|
||||
symbolTable.setFunctionExtensions("textureQueryLod", 1, &E_GL_ARB_texture_query_lod);
|
||||
symbolTable.setFunctionExtensions("textureQueryLOD", 1, &E_GL_ARB_texture_query_lod);
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version >= 460) {
|
||||
@@ -8324,6 +8333,9 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
symbolTable.setFunctionExtensions("clockARB", 1, &E_GL_ARB_shader_clock);
|
||||
symbolTable.setFunctionExtensions("clock2x32ARB", 1, &E_GL_ARB_shader_clock);
|
||||
|
||||
symbolTable.setFunctionExtensions("clockRealtimeEXT", 1, &E_GL_EXT_shader_realtime_clock);
|
||||
symbolTable.setFunctionExtensions("clockRealtime2x32EXT", 1, &E_GL_EXT_shader_realtime_clock);
|
||||
|
||||
if (profile == EEsProfile && version < 320) {
|
||||
symbolTable.setVariableExtensions("gl_PrimitiveID", Num_AEP_geometry_shader, AEP_geometry_shader);
|
||||
symbolTable.setVariableExtensions("gl_Layer", Num_AEP_geometry_shader, AEP_geometry_shader);
|
||||
|
||||
@@ -3902,7 +3902,7 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
||||
case EbtFloat16: PROMOTE(setDConst, double, Get); break; \
|
||||
case EbtFloat: PROMOTE(setDConst, double, Get); break; \
|
||||
case EbtDouble: PROMOTE(setDConst, double, Get); break; \
|
||||
case EbtInt8: PROMOTE(setI8Const, char, Get); break; \
|
||||
case EbtInt8: PROMOTE(setI8Const, signed char, Get); break; \
|
||||
case EbtInt16: PROMOTE(setI16Const, short, Get); break; \
|
||||
case EbtInt: PROMOTE(setIConst, int, Get); break; \
|
||||
case EbtInt64: PROMOTE(setI64Const, long long, Get); break; \
|
||||
|
||||
@@ -6496,6 +6496,8 @@ void TParseContext::layoutQualifierCheck(const TSourceLoc& loc, const TQualifier
|
||||
error(loc, "can only be used with a uniform", "push_constant", "");
|
||||
if (qualifier.hasSet())
|
||||
error(loc, "cannot be used with push_constant", "set", "");
|
||||
if (qualifier.hasBinding())
|
||||
error(loc, "cannot be used with push_constant", "binding", "");
|
||||
}
|
||||
if (qualifier.hasBufferReference()) {
|
||||
if (qualifier.storage != EvqBuffer)
|
||||
@@ -6650,8 +6652,10 @@ const TFunction* TParseContext::findFunction(const TSourceLoc& loc, const TFunct
|
||||
: findFunctionExact(loc, call, builtIn));
|
||||
else if (version < 120)
|
||||
function = findFunctionExact(loc, call, builtIn);
|
||||
else if (version < 400)
|
||||
function = extensionTurnedOn(E_GL_ARB_gpu_shader_fp64) ? findFunction400(loc, call, builtIn) : findFunction120(loc, call, builtIn);
|
||||
else if (version < 400) {
|
||||
bool needfindFunction400 = extensionTurnedOn(E_GL_ARB_gpu_shader_fp64) || extensionTurnedOn(E_GL_ARB_gpu_shader5);
|
||||
function = needfindFunction400 ? findFunction400(loc, call, builtIn) : findFunction120(loc, call, builtIn);
|
||||
}
|
||||
else if (explicitTypesEnabled)
|
||||
function = findFunctionExplicitTypes(loc, call, builtIn);
|
||||
else
|
||||
|
||||
@@ -1343,7 +1343,6 @@ int ShInitialize()
|
||||
|
||||
glslang::GetGlobalLock();
|
||||
++NumberOfClients;
|
||||
glslang::ReleaseGlobalLock();
|
||||
|
||||
if (PerProcessGPA == nullptr)
|
||||
PerProcessGPA = new TPoolAllocator();
|
||||
@@ -1353,6 +1352,7 @@ int ShInitialize()
|
||||
glslang::HlslScanContext::fillInKeywordMap();
|
||||
#endif
|
||||
|
||||
glslang::ReleaseGlobalLock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1415,9 +1415,10 @@ int ShFinalize()
|
||||
--NumberOfClients;
|
||||
assert(NumberOfClients >= 0);
|
||||
bool finalize = NumberOfClients == 0;
|
||||
glslang::ReleaseGlobalLock();
|
||||
if (! finalize)
|
||||
if (! finalize) {
|
||||
glslang::ReleaseGlobalLock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int version = 0; version < VersionCount; ++version) {
|
||||
for (int spvVersion = 0; spvVersion < SpvVersionCount; ++spvVersion) {
|
||||
@@ -1455,6 +1456,7 @@ int ShFinalize()
|
||||
glslang::HlslScanContext::deleteKeywordMap();
|
||||
#endif
|
||||
|
||||
glslang::ReleaseGlobalLock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1827,6 +1829,7 @@ void TShader::setUniqueId(unsigned long long id)
|
||||
}
|
||||
|
||||
void TShader::setInvertY(bool invert) { intermediate->setInvertY(invert); }
|
||||
void TShader::setDxPositionW(bool invert) { intermediate->setDxPositionW(invert); }
|
||||
void TShader::setNanMinMaxClamp(bool useNonNan) { intermediate->setNanMinMaxClamp(useNonNan); }
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
|
||||
@@ -426,12 +426,7 @@ TSymbolTableLevel* TSymbolTableLevel::clone() const
|
||||
symTableLevel->thisLevel = thisLevel;
|
||||
symTableLevel->retargetedSymbols.clear();
|
||||
for (auto &s : retargetedSymbols) {
|
||||
// Extra constructions to make sure they use the correct allocator pool
|
||||
TString newFrom;
|
||||
newFrom = s.first;
|
||||
TString newTo;
|
||||
newTo = s.second;
|
||||
symTableLevel->retargetedSymbols.push_back({std::move(newFrom), std::move(newTo)});
|
||||
symTableLevel->retargetedSymbols.push_back({s.first, s.second});
|
||||
}
|
||||
std::vector<bool> containerCopied(anonId, false);
|
||||
tLevel::const_iterator iter;
|
||||
@@ -462,11 +457,7 @@ TSymbolTableLevel* TSymbolTableLevel::clone() const
|
||||
TSymbol* sym = symTableLevel->find(s.second);
|
||||
if (!sym)
|
||||
continue;
|
||||
|
||||
// Need to declare and assign so newS is using the correct pool allocator
|
||||
TString newS;
|
||||
newS = s.first;
|
||||
symTableLevel->insert(newS, sym);
|
||||
symTableLevel->insert(s.first, sym);
|
||||
}
|
||||
|
||||
return symTableLevel;
|
||||
|
||||
@@ -84,7 +84,7 @@ typedef TVector<const char*> TExtensionList;
|
||||
class TSymbol {
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||
explicit TSymbol(const TString *n) : name(n), extensions(0), writable(true) { }
|
||||
explicit TSymbol(const TString *n) : name(n), uniqueId(0), extensions(0), writable(true) { }
|
||||
virtual TSymbol* clone() const = 0;
|
||||
virtual ~TSymbol() { } // rely on all symbol owned memory coming from the pool
|
||||
|
||||
|
||||
@@ -225,6 +225,9 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
extensionBehavior[E_GL_ARB_shading_language_packing] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_texture_query_lod] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_vertex_attrib_64bit] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_draw_instanced] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_fragment_coord_conventions] = EBhDisable;
|
||||
|
||||
|
||||
extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable;
|
||||
extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable;
|
||||
@@ -465,6 +468,8 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
"#define GL_ARB_shader_storage_buffer_object 1\n"
|
||||
"#define GL_ARB_texture_query_lod 1\n"
|
||||
"#define GL_ARB_vertex_attrib_64bit 1\n"
|
||||
"#define GL_ARB_draw_instanced 1\n"
|
||||
"#define GL_ARB_fragment_coord_conventions 1\n"
|
||||
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
|
||||
"#define GL_EXT_shader_image_load_formatted 1\n"
|
||||
"#define GL_EXT_post_depth_coverage 1\n"
|
||||
|
||||
@@ -161,6 +161,8 @@ const char* const E_GL_ARB_shader_storage_buffer_object = "GL_ARB_shader_storage
|
||||
const char* const E_GL_ARB_shading_language_packing = "GL_ARB_shading_language_packing";
|
||||
const char* const E_GL_ARB_texture_query_lod = "GL_ARB_texture_query_lod";
|
||||
const char* const E_GL_ARB_vertex_attrib_64bit = "GL_ARB_vertex_attrib_64bit";
|
||||
const char* const E_GL_ARB_draw_instanced = "GL_ARB_draw_instanced";
|
||||
const char* const E_GL_ARB_fragment_coord_conventions = "GL_ARB_fragment_coord_conventions";
|
||||
|
||||
const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic";
|
||||
const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote";
|
||||
|
||||
@@ -48,37 +48,6 @@
|
||||
#endif
|
||||
#include <cstdint>
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsInfinity(double x) {
|
||||
#ifdef _MSC_VER
|
||||
switch (_fpclass(x)) {
|
||||
case _FPCLASS_NINF:
|
||||
case _FPCLASS_PINF:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return std::isinf(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsNan(double x) {
|
||||
#ifdef _MSC_VER
|
||||
switch (_fpclass(x)) {
|
||||
case _FPCLASS_SNAN:
|
||||
case _FPCLASS_QNAN:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return std::isnan(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace glslang {
|
||||
|
||||
|
||||
@@ -514,6 +514,24 @@ struct TSymbolValidater
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// Deal with input/output pairs where one is a block member but the other is loose,
|
||||
// e.g. with ARB_separate_shader_objects
|
||||
if (type1.getBasicType() == EbtBlock &&
|
||||
type1.isStruct() && !type2.isStruct()) {
|
||||
// Iterate through block members tracking layout
|
||||
glslang::TString name;
|
||||
type1.getStruct()->begin()->type->appendMangledName(name);
|
||||
if (name == mangleName2
|
||||
&& type1.getQualifier().layoutLocation == type2.getQualifier().layoutLocation) return;
|
||||
}
|
||||
if (type2.getBasicType() == EbtBlock &&
|
||||
type2.isStruct() && !type1.isStruct()) {
|
||||
// Iterate through block members tracking layout
|
||||
glslang::TString name;
|
||||
type2.getStruct()->begin()->type->appendMangledName(name);
|
||||
if (name == mangleName1
|
||||
&& type1.getQualifier().layoutLocation == type2.getQualifier().layoutLocation) return;
|
||||
}
|
||||
TString err = "Invalid In/Out variable type : " + entKey.first;
|
||||
infoSink.info.message(EPrefixInternalError, err.c_str());
|
||||
hadError = true;
|
||||
|
||||
@@ -312,6 +312,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
|
||||
MERGE_TRUE(autoMapBindings);
|
||||
MERGE_TRUE(autoMapLocations);
|
||||
MERGE_TRUE(invertY);
|
||||
MERGE_TRUE(dxPositionW);
|
||||
MERGE_TRUE(flattenUniformArrays);
|
||||
MERGE_TRUE(useUnknownFormat);
|
||||
MERGE_TRUE(hlslOffsets);
|
||||
@@ -759,7 +760,10 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin
|
||||
|
||||
auto checkName = [this, unitSymbol, &infoSink](const TString& name) {
|
||||
for (unsigned int i = 0; i < unitSymbol->getType().getStruct()->size(); ++i) {
|
||||
if (name == (*unitSymbol->getType().getStruct())[i].type->getFieldName()) {
|
||||
if (name == (*unitSymbol->getType().getStruct())[i].type->getFieldName()
|
||||
&& !((*unitSymbol->getType().getStruct())[i].type->getQualifier().hasLocation()
|
||||
|| unitSymbol->getType().getQualifier().hasLocation())
|
||||
) {
|
||||
error(infoSink, "Anonymous member name used for global variable or other anonymous member: ");
|
||||
infoSink.info << (*unitSymbol->getType().getStruct())[i].type->getCompleteString() << "\n";
|
||||
}
|
||||
@@ -858,9 +862,19 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
|
||||
if (symbol.getType().getBasicType() == EbtBlock && unitSymbol.getType().getBasicType() == EbtBlock &&
|
||||
symbol.getType().getStruct() && unitSymbol.getType().getStruct() &&
|
||||
symbol.getType().sameStructType(unitSymbol.getType())) {
|
||||
for (unsigned int i = 0; i < symbol.getType().getStruct()->size(); ++i) {
|
||||
const TQualifier& qualifier = (*symbol.getType().getStruct())[i].type->getQualifier();
|
||||
const TQualifier& unitQualifier = (*unitSymbol.getType().getStruct())[i].type->getQualifier();
|
||||
unsigned int li = 0;
|
||||
unsigned int ri = 0;
|
||||
while (li < symbol.getType().getStruct()->size() && ri < unitSymbol.getType().getStruct()->size()) {
|
||||
if ((*symbol.getType().getStruct())[li].type->hiddenMember()) {
|
||||
++li;
|
||||
continue;
|
||||
}
|
||||
if ((*unitSymbol.getType().getStruct())[ri].type->hiddenMember()) {
|
||||
++ri;
|
||||
continue;
|
||||
}
|
||||
const TQualifier& qualifier = (*symbol.getType().getStruct())[li].type->getQualifier();
|
||||
const TQualifier & unitQualifier = (*unitSymbol.getType().getStruct())[ri].type->getQualifier();
|
||||
if (qualifier.layoutMatrix != unitQualifier.layoutMatrix ||
|
||||
qualifier.layoutOffset != unitQualifier.layoutOffset ||
|
||||
qualifier.layoutAlign != unitQualifier.layoutAlign ||
|
||||
@@ -869,6 +883,8 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
|
||||
error(infoSink, "Interface block member layout qualifiers must match:");
|
||||
writeTypeComparison = true;
|
||||
}
|
||||
++li;
|
||||
++ri;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -290,6 +290,7 @@ public:
|
||||
resources(TBuiltInResource{}),
|
||||
numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
|
||||
invertY(false),
|
||||
dxPositionW(false),
|
||||
useStorageBuffer(false),
|
||||
invariantAll(false),
|
||||
nanMinMaxClamp(false),
|
||||
@@ -460,6 +461,14 @@ public:
|
||||
}
|
||||
bool getInvertY() const { return invertY; }
|
||||
|
||||
void setDxPositionW(bool dxPosW)
|
||||
{
|
||||
dxPositionW = dxPosW;
|
||||
if (dxPositionW)
|
||||
processes.addProcess("dx-position-w");
|
||||
}
|
||||
bool getDxPositionW() const { return dxPositionW; }
|
||||
|
||||
#ifdef ENABLE_HLSL
|
||||
void setSource(EShSource s) { source = s; }
|
||||
EShSource getSource() const { return source; }
|
||||
@@ -1070,6 +1079,7 @@ protected:
|
||||
int numPushConstants;
|
||||
bool recursive;
|
||||
bool invertY;
|
||||
bool dxPositionW;
|
||||
bool useStorageBuffer;
|
||||
bool invariantAll;
|
||||
bool nanMinMaxClamp; // true if desiring min/max/clamp to favor non-NaN over NaN
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace {
|
||||
pthread_mutex_t gMutex;
|
||||
}
|
||||
|
||||
void InitGlobalLock()
|
||||
static void InitMutex(void)
|
||||
{
|
||||
pthread_mutexattr_t mutexattr;
|
||||
pthread_mutexattr_init(&mutexattr);
|
||||
@@ -180,6 +180,12 @@ void InitGlobalLock()
|
||||
pthread_mutex_init(&gMutex, &mutexattr);
|
||||
}
|
||||
|
||||
void InitGlobalLock()
|
||||
{
|
||||
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||
pthread_once(&once, InitMutex);
|
||||
}
|
||||
|
||||
void GetGlobalLock()
|
||||
{
|
||||
pthread_mutex_lock(&gMutex);
|
||||
|
||||
1
3rdparty/glslang/glslang/Public/ShaderLang.h
vendored
1
3rdparty/glslang/glslang/Public/ShaderLang.h
vendored
@@ -485,6 +485,7 @@ public:
|
||||
GLSLANG_EXPORT void addUniformLocationOverride(const char* name, int loc);
|
||||
GLSLANG_EXPORT void setUniformLocationBase(int base);
|
||||
GLSLANG_EXPORT void setInvertY(bool invert);
|
||||
GLSLANG_EXPORT void setDxPositionW(bool dxPosW);
|
||||
#ifdef ENABLE_HLSL
|
||||
GLSLANG_EXPORT void setHlslIoMapping(bool hlslIoMap);
|
||||
GLSLANG_EXPORT void setFlattenUniformArrays(bool flatten);
|
||||
|
||||
Reference in New Issue
Block a user