mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Update glslang
This commit is contained in:
@@ -36,6 +36,8 @@ static const char* const E_SPV_EXT_fragment_fully_covered = "SPV_EXT_fragment_fu
|
||||
static const char* const E_SPV_EXT_fragment_invocation_density = "SPV_EXT_fragment_invocation_density";
|
||||
static const char* const E_SPV_EXT_demote_to_helper_invocation = "SPV_EXT_demote_to_helper_invocation";
|
||||
static const char* const E_SPV_EXT_shader_atomic_float_add = "SPV_EXT_shader_atomic_float_add";
|
||||
static const char* const E_SPV_EXT_shader_atomic_float16_add = "SPV_EXT_shader_atomic_float16_add";
|
||||
static const char* const E_SPV_EXT_shader_atomic_float_min_max = "SPV_EXT_shader_atomic_float_min_max";
|
||||
static const char* const E_SPV_EXT_shader_image_int64 = "SPV_EXT_shader_image_int64";
|
||||
|
||||
#endif // #ifndef GLSLextEXT_H
|
||||
|
||||
@@ -51,5 +51,6 @@ static const char* const E_SPV_KHR_ray_query = "SPV_KHR_ray_q
|
||||
static const char* const E_SPV_KHR_fragment_shading_rate = "SPV_KHR_fragment_shading_rate";
|
||||
static const char* const E_SPV_KHR_terminate_invocation = "SPV_KHR_terminate_invocation";
|
||||
static const char* const E_SPV_KHR_workgroup_memory_explicit_layout = "SPV_KHR_workgroup_memory_explicit_layout";
|
||||
static const char* const E_SPV_KHR_subgroup_uniform_control_flow = "SPV_KHR_subgroup_uniform_control_flow";
|
||||
|
||||
#endif // #ifndef GLSLextKHR_H
|
||||
|
||||
@@ -69,6 +69,9 @@ const char* const E_SPV_NV_mesh_shader = "SPV_NV_mesh_shader";
|
||||
//SPV_NV_raytracing
|
||||
const char* const E_SPV_NV_ray_tracing = "SPV_NV_ray_tracing";
|
||||
|
||||
//SPV_NV_ray_tracing_motion_blur
|
||||
const char* const E_SPV_NV_ray_tracing_motion_blur = "SPV_NV_ray_tracing_motion_blur";
|
||||
|
||||
//SPV_NV_shading_rate
|
||||
const char* const E_SPV_NV_shading_rate = "SPV_NV_shading_rate";
|
||||
|
||||
|
||||
@@ -160,6 +160,7 @@ protected:
|
||||
spv::SelectionControlMask TranslateSwitchControl(const glslang::TIntermSwitch&) const;
|
||||
spv::LoopControlMask TranslateLoopControl(const glslang::TIntermLoop&, std::vector<unsigned int>& operands) const;
|
||||
spv::StorageClass TranslateStorageClass(const glslang::TType&);
|
||||
void TranslateLiterals(const glslang::TVector<const glslang::TIntermConstantUnion*>&, std::vector<unsigned>&) const;
|
||||
void addIndirectionIndexCapabilities(const glslang::TType& baseType, const glslang::TType& indexType);
|
||||
spv::Id createSpvVariable(const glslang::TIntermSymbol*, spv::Id forcedType);
|
||||
spv::Id getSampledType(const glslang::TSampler&);
|
||||
@@ -178,6 +179,7 @@ protected:
|
||||
spv::Id accessChainLoad(const glslang::TType& type);
|
||||
void accessChainStore(const glslang::TType& type, spv::Id rvalue);
|
||||
void multiTypeStore(const glslang::TType&, spv::Id rValue);
|
||||
spv::Id convertLoadedBoolInUniformToUint(const glslang::TType& type, spv::Id nominalTypeId, spv::Id loadedId);
|
||||
glslang::TLayoutPacking getExplicitLayout(const glslang::TType& type) const;
|
||||
int getArrayStride(const glslang::TType& arrayType, glslang::TLayoutPacking, glslang::TLayoutMatrix);
|
||||
int getMatrixStride(const glslang::TType& matrixType, glslang::TLayoutPacking, glslang::TLayoutMatrix);
|
||||
@@ -1031,6 +1033,10 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
|
||||
return spv::BuiltInIncomingRayFlagsKHR;
|
||||
case glslang::EbvGeometryIndex:
|
||||
return spv::BuiltInRayGeometryIndexKHR;
|
||||
case glslang::EbvCurrentRayTimeNV:
|
||||
builder.addExtension(spv::E_SPV_NV_ray_tracing_motion_blur);
|
||||
builder.addCapability(spv::CapabilityRayTracingMotionBlurNV);
|
||||
return spv::BuiltInCurrentRayTimeNV;
|
||||
|
||||
// barycentrics
|
||||
case glslang::EbvBaryCoordNV:
|
||||
@@ -1249,6 +1255,12 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
|
||||
{
|
||||
if (type.getBasicType() == glslang::EbtRayQuery)
|
||||
return spv::StorageClassPrivate;
|
||||
#ifndef GLSLANG_WEB
|
||||
if (type.getQualifier().isSpirvByReference()) {
|
||||
if (type.getQualifier().isParamInput() || type.getQualifier().isParamOutput())
|
||||
return spv::StorageClassFunction;
|
||||
}
|
||||
#endif
|
||||
if (type.getQualifier().isPipeInput())
|
||||
return spv::StorageClassInput;
|
||||
if (type.getQualifier().isPipeOutput())
|
||||
@@ -1297,6 +1309,7 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
|
||||
case glslang::EvqHitAttr: return spv::StorageClassHitAttributeKHR;
|
||||
case glslang::EvqCallableData: return spv::StorageClassCallableDataKHR;
|
||||
case glslang::EvqCallableDataIn: return spv::StorageClassIncomingCallableDataKHR;
|
||||
case glslang::EvqSpirvStorageClass: return static_cast<spv::StorageClass>(type.getQualifier().spirvStorageClass);
|
||||
#endif
|
||||
default:
|
||||
assert(0);
|
||||
@@ -1306,6 +1319,52 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
|
||||
return spv::StorageClassFunction;
|
||||
}
|
||||
|
||||
// Translate glslang constants to SPIR-V literals
|
||||
void TGlslangToSpvTraverser::TranslateLiterals(const glslang::TVector<const glslang::TIntermConstantUnion*>& constants,
|
||||
std::vector<unsigned>& literals) const
|
||||
{
|
||||
for (auto constant : constants) {
|
||||
if (constant->getBasicType() == glslang::EbtFloat) {
|
||||
float floatValue = static_cast<float>(constant->getConstArray()[0].getDConst());
|
||||
unsigned literal = *reinterpret_cast<unsigned*>(&floatValue);
|
||||
literals.push_back(literal);
|
||||
} else if (constant->getBasicType() == glslang::EbtInt) {
|
||||
unsigned literal = constant->getConstArray()[0].getIConst();
|
||||
literals.push_back(literal);
|
||||
} else if (constant->getBasicType() == glslang::EbtUint) {
|
||||
unsigned literal = constant->getConstArray()[0].getUConst();
|
||||
literals.push_back(literal);
|
||||
} else if (constant->getBasicType() == glslang::EbtBool) {
|
||||
unsigned literal = constant->getConstArray()[0].getBConst();
|
||||
literals.push_back(literal);
|
||||
} else if (constant->getBasicType() == glslang::EbtString) {
|
||||
auto str = 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) {
|
||||
literals.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;
|
||||
literals.push_back(literal);
|
||||
}
|
||||
} else
|
||||
assert(0); // Unexpected type
|
||||
}
|
||||
}
|
||||
|
||||
// Add capabilities pertaining to how an array is indexed.
|
||||
void TGlslangToSpvTraverser::addIndirectionIndexCapabilities(const glslang::TType& baseType,
|
||||
const glslang::TType& indexType)
|
||||
@@ -1526,6 +1585,13 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
||||
builder.addCapability(spv::CapabilityRayTraversalPrimitiveCullingKHR);
|
||||
}
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
if (glslangIntermediate->getSubgroupUniformControlFlow()) {
|
||||
builder.addExtension(spv::E_SPV_KHR_subgroup_uniform_control_flow);
|
||||
builder.addExecutionMode(shaderEntry, spv::ExecutionModeSubgroupUniformControlFlowKHR);
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int mode;
|
||||
switch (glslangIntermediate->getStage()) {
|
||||
case EShLangVertex:
|
||||
@@ -1598,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);
|
||||
@@ -1704,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());
|
||||
@@ -1728,6 +1820,53 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
//
|
||||
// Add SPIR-V requirements (GL_EXT_spirv_intrinsics)
|
||||
//
|
||||
if (glslangIntermediate->hasSpirvRequirement()) {
|
||||
const glslang::TSpirvRequirement& spirvRequirement = glslangIntermediate->getSpirvRequirement();
|
||||
|
||||
// Add SPIR-V extension requirement
|
||||
for (auto& extension : spirvRequirement.extensions)
|
||||
builder.addExtension(extension.c_str());
|
||||
|
||||
// Add SPIR-V capability requirement
|
||||
for (auto capability : spirvRequirement.capabilities)
|
||||
builder.addCapability(static_cast<spv::Capability>(capability));
|
||||
}
|
||||
|
||||
//
|
||||
// Add SPIR-V execution mode qualifiers (GL_EXT_spirv_intrinsics)
|
||||
//
|
||||
if (glslangIntermediate->hasSpirvExecutionMode()) {
|
||||
const glslang::TSpirvExecutionMode spirvExecutionMode = glslangIntermediate->getSpirvExecutionMode();
|
||||
|
||||
// Add spirv_execution_mode
|
||||
for (auto& mode : spirvExecutionMode.modes) {
|
||||
if (!mode.second.empty()) {
|
||||
std::vector<unsigned> literals;
|
||||
TranslateLiterals(mode.second, literals);
|
||||
builder.addExecutionMode(shaderEntry, static_cast<spv::ExecutionMode>(mode.first), literals);
|
||||
} else
|
||||
builder.addExecutionMode(shaderEntry, static_cast<spv::ExecutionMode>(mode.first));
|
||||
}
|
||||
|
||||
// Add spirv_execution_mode_id
|
||||
for (auto& modeId : spirvExecutionMode.modeIds) {
|
||||
std::vector<spv::Id> operandIds;
|
||||
assert(!modeId.second.empty());
|
||||
for (auto extraOperand : modeId.second) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Finish creating SPV, after the traversal is complete.
|
||||
@@ -2125,6 +2264,49 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
|
||||
}
|
||||
}
|
||||
|
||||
spv::Id TGlslangToSpvTraverser::convertLoadedBoolInUniformToUint(const glslang::TType& type,
|
||||
spv::Id nominalTypeId,
|
||||
spv::Id loadedId)
|
||||
{
|
||||
if (builder.isScalarType(nominalTypeId)) {
|
||||
// Conversion for bool
|
||||
spv::Id boolType = builder.makeBoolType();
|
||||
if (nominalTypeId != boolType)
|
||||
return builder.createBinOp(spv::OpINotEqual, boolType, loadedId, builder.makeUintConstant(0));
|
||||
} else if (builder.isVectorType(nominalTypeId)) {
|
||||
// Conversion for bvec
|
||||
int vecSize = builder.getNumTypeComponents(nominalTypeId);
|
||||
spv::Id bvecType = builder.makeVectorType(builder.makeBoolType(), vecSize);
|
||||
if (nominalTypeId != bvecType)
|
||||
loadedId = builder.createBinOp(spv::OpINotEqual, bvecType, loadedId,
|
||||
makeSmearedConstant(builder.makeUintConstant(0), vecSize));
|
||||
} else if (builder.isArrayType(nominalTypeId)) {
|
||||
// Conversion for bool array
|
||||
spv::Id boolArrayTypeId = convertGlslangToSpvType(type);
|
||||
if (nominalTypeId != boolArrayTypeId)
|
||||
{
|
||||
// Use OpCopyLogical from SPIR-V 1.4 if available.
|
||||
if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_4)
|
||||
return builder.createUnaryOp(spv::OpCopyLogical, boolArrayTypeId, loadedId);
|
||||
|
||||
glslang::TType glslangElementType(type, 0);
|
||||
spv::Id elementNominalTypeId = builder.getContainedTypeId(nominalTypeId);
|
||||
std::vector<spv::Id> constituents;
|
||||
for (int index = 0; index < type.getOuterArraySize(); ++index) {
|
||||
// get the element
|
||||
spv::Id elementValue = builder.createCompositeExtract(loadedId, elementNominalTypeId, index);
|
||||
|
||||
// recursively convert it
|
||||
spv::Id elementConvertedValue = convertLoadedBoolInUniformToUint(glslangElementType, elementNominalTypeId, elementValue);
|
||||
constituents.push_back(elementConvertedValue);
|
||||
}
|
||||
return builder.createCompositeConstruct(boolArrayTypeId, constituents);
|
||||
}
|
||||
}
|
||||
|
||||
return loadedId;
|
||||
}
|
||||
|
||||
// Figure out what, if any, type changes are needed when accessing a specific built-in.
|
||||
// Returns <the type SPIR-V requires for declarion, the type to translate to on use>.
|
||||
// Also see comment for 'forceType', regarding tracking SPIR-V-required types.
|
||||
@@ -2301,7 +2483,8 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
|
||||
if (node->getOp() == glslang::EOpAtomicCounterIncrement ||
|
||||
node->getOp() == glslang::EOpAtomicCounterDecrement ||
|
||||
node->getOp() == glslang::EOpAtomicCounter ||
|
||||
node->getOp() == glslang::EOpInterpolateAtCentroid ||
|
||||
(node->getOp() == glslang::EOpInterpolateAtCentroid &&
|
||||
glslangIntermediate->getSource() != glslang::EShSourceHlsl) ||
|
||||
node->getOp() == glslang::EOpRayQueryProceed ||
|
||||
node->getOp() == glslang::EOpRayQueryGetRayTMin ||
|
||||
node->getOp() == glslang::EOpRayQueryGetRayFlags ||
|
||||
@@ -2309,10 +2492,14 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
|
||||
node->getOp() == glslang::EOpRayQueryGetWorldRayDirection ||
|
||||
node->getOp() == glslang::EOpRayQueryGetIntersectionCandidateAABBOpaque ||
|
||||
node->getOp() == glslang::EOpRayQueryTerminate ||
|
||||
node->getOp() == glslang::EOpRayQueryConfirmIntersection) {
|
||||
node->getOp() == glslang::EOpRayQueryConfirmIntersection ||
|
||||
(node->getOp() == glslang::EOpSpirvInst && operandNode->getAsTyped()->getQualifier().isSpirvByReference())) {
|
||||
operand = builder.accessChainGetLValue(); // Special case l-value operands
|
||||
lvalueCoherentFlags = builder.getAccessChain().coherentFlags;
|
||||
lvalueCoherentFlags |= TranslateCoherent(operandNode->getAsTyped()->getType());
|
||||
} else if (operandNode->getAsTyped()->getQualifier().isSpirvLiteral()) {
|
||||
// Will be translated to a literal value, make a placeholder here
|
||||
operand = spv::NoResult;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -2333,6 +2520,38 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
|
||||
result = createUnaryOperation(node->getOp(), decorations, resultType(), operand,
|
||||
node->getOperand()->getBasicType(), lvalueCoherentFlags);
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// it could be attached to a SPIR-V intruction
|
||||
if (!result) {
|
||||
if (node->getOp() == glslang::EOpSpirvInst) {
|
||||
const auto& spirvInst = node->getSpirvInstruction();
|
||||
if (spirvInst.set == "") {
|
||||
spv::IdImmediate idImmOp = {true, operand};
|
||||
if (operandNode->getAsTyped()->getQualifier().isSpirvLiteral()) {
|
||||
// Translate the constant to a literal value
|
||||
std::vector<unsigned> literals;
|
||||
glslang::TVector<const glslang::TIntermConstantUnion*> constants;
|
||||
constants.push_back(operandNode->getAsConstantUnion());
|
||||
TranslateLiterals(constants, literals);
|
||||
idImmOp = {false, literals[0]};
|
||||
}
|
||||
|
||||
if (node->getBasicType() == glslang::EbtVoid)
|
||||
builder.createNoResultOp(static_cast<spv::Op>(spirvInst.id), {idImmOp});
|
||||
else
|
||||
result = builder.createOp(static_cast<spv::Op>(spirvInst.id), resultType(), {idImmOp});
|
||||
} else {
|
||||
result = builder.createBuiltinCall(
|
||||
resultType(), spirvInst.set == "GLSL.std.450" ? stdBuiltins : getExtBuiltins(spirvInst.set.c_str()),
|
||||
spirvInst.id, {operand});
|
||||
}
|
||||
|
||||
if (node->getBasicType() == glslang::EbtVoid)
|
||||
return false; // done with this node
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (result) {
|
||||
if (invertedType) {
|
||||
result = createInvertedSwizzle(decorations.precision, *node->getOperand(), result);
|
||||
@@ -2831,6 +3050,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
case glslang::EOpIgnoreIntersectionNV:
|
||||
case glslang::EOpTerminateRayNV:
|
||||
case glslang::EOpTraceNV:
|
||||
case glslang::EOpTraceRayMotionNV:
|
||||
case glslang::EOpTraceKHR:
|
||||
case glslang::EOpExecuteCallableNV:
|
||||
case glslang::EOpExecuteCallableKHR:
|
||||
@@ -2977,7 +3197,13 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
case glslang::EOpInterpolateAtOffset:
|
||||
case glslang::EOpInterpolateAtVertex:
|
||||
if (arg == 0) {
|
||||
lvalue = true;
|
||||
// If GLSL, use the address of the interpolant argument.
|
||||
// If HLSL, use an internal version of OpInterolates that takes
|
||||
// the rvalue of the interpolant. A fixup pass in spirv-opt
|
||||
// legalization will remove the OpLoad and convert to an lvalue.
|
||||
// Had to do this because legalization will only propagate a
|
||||
// builtin into an rvalue.
|
||||
lvalue = glslangIntermediate->getSource() != glslang::EShSourceHlsl;
|
||||
|
||||
// Does it need a swizzle inversion? If so, evaluation is inverted;
|
||||
// operate first on the swizzle base, then apply the swizzle.
|
||||
@@ -3023,6 +3249,10 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
if (arg == 1)
|
||||
lvalue = true;
|
||||
break;
|
||||
case glslang::EOpSpirvInst:
|
||||
if (glslangOperands[arg]->getAsTyped()->getQualifier().isSpirvByReference())
|
||||
lvalue = true;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
@@ -3120,15 +3350,22 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
bool cond = glslangOperands[arg]->getAsConstantUnion()->getConstArray()[0].getBConst();
|
||||
operands.push_back(builder.makeIntConstant(cond ? 1 : 0));
|
||||
} else if ((arg == 10 && glslangOp == glslang::EOpTraceKHR) ||
|
||||
(arg == 11 && glslangOp == glslang::EOpTraceRayMotionNV) ||
|
||||
(arg == 1 && glslangOp == glslang::EOpExecuteCallableKHR)) {
|
||||
const int opdNum = glslangOp == glslang::EOpTraceKHR ? 10 : 1;
|
||||
const int set = glslangOp == glslang::EOpTraceKHR ? 0 : 1;
|
||||
const int opdNum = glslangOp == glslang::EOpTraceKHR ? 10 : (glslangOp == glslang::EOpTraceRayMotionNV ? 11 : 1);
|
||||
const int set = glslangOp == glslang::EOpExecuteCallableKHR ? 1 : 0;
|
||||
|
||||
const int location = glslangOperands[opdNum]->getAsConstantUnion()->getConstArray()[0].getUConst();
|
||||
auto itNode = locationToSymbol[set].find(location);
|
||||
visitSymbol(itNode->second);
|
||||
spv::Id symId = getSymbolId(itNode->second);
|
||||
operands.push_back(symId);
|
||||
} else {
|
||||
#ifndef GLSLANG_WEB
|
||||
} else if (glslangOperands[arg]->getAsTyped()->getQualifier().isSpirvLiteral()) {
|
||||
// Will be translated to a literal value, make a placeholder here
|
||||
operands.push_back(spv::NoResult);
|
||||
#endif
|
||||
} else {
|
||||
operands.push_back(accessChainLoad(glslangOperands[arg]->getAsTyped()->getType()));
|
||||
}
|
||||
}
|
||||
@@ -3170,6 +3407,34 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
? node->getSequence()[0]->getAsTyped()->getBasicType() : node->getBasicType();
|
||||
result = createAtomicOperation(node->getOp(), precision, resultType(), operands, typeProxy,
|
||||
lvalueCoherentFlags);
|
||||
#ifndef GLSLANG_WEB
|
||||
} else if (node->getOp() == glslang::EOpSpirvInst) {
|
||||
const auto& spirvInst = node->getSpirvInstruction();
|
||||
if (spirvInst.set == "") {
|
||||
std::vector<spv::IdImmediate> idImmOps;
|
||||
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;
|
||||
glslang::TVector<const glslang::TIntermConstantUnion*> constants;
|
||||
constants.push_back(glslangOperands[i]->getAsConstantUnion());
|
||||
TranslateLiterals(constants, literals);
|
||||
idImmOps.push_back({false, literals[0]});
|
||||
} else
|
||||
idImmOps.push_back({true, operands[i]});
|
||||
}
|
||||
|
||||
if (node->getBasicType() == glslang::EbtVoid)
|
||||
builder.createNoResultOp(static_cast<spv::Op>(spirvInst.id), idImmOps);
|
||||
else
|
||||
result = builder.createOp(static_cast<spv::Op>(spirvInst.id), resultType(), idImmOps);
|
||||
} else {
|
||||
result = builder.createBuiltinCall(
|
||||
resultType(), spirvInst.set == "GLSL.std.450" ? stdBuiltins : getExtBuiltins(spirvInst.set.c_str()),
|
||||
spirvInst.id, operands);
|
||||
}
|
||||
noReturnValue = node->getBasicType() == glslang::EbtVoid;
|
||||
#endif
|
||||
} else if (node->getOp() == glslang::EOpDebugPrintf) {
|
||||
if (!nonSemanticDebugPrintf) {
|
||||
nonSemanticDebugPrintf = builder.import("NonSemantic.DebugPrintf");
|
||||
@@ -3450,6 +3715,11 @@ bool TGlslangToSpvTraverser::visitSwitch(glslang::TVisit /* visit */, glslang::T
|
||||
|
||||
void TGlslangToSpvTraverser::visitConstantUnion(glslang::TIntermConstantUnion* node)
|
||||
{
|
||||
#ifndef GLSLANG_WEB
|
||||
if (node->getQualifier().isSpirvLiteral())
|
||||
return; // Translated to a literal value, skip further processing
|
||||
#endif
|
||||
|
||||
int nextConst = 0;
|
||||
spv::Id constant = createSpvConstantFromConstUnionArray(node->getType(), node->getConstArray(), nextConst, false);
|
||||
|
||||
@@ -3535,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);
|
||||
@@ -3698,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);
|
||||
@@ -3898,6 +4179,64 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
case glslang::EbtString:
|
||||
// no type used for OpString
|
||||
return 0;
|
||||
#ifndef GLSLANG_WEB
|
||||
case glslang::EbtSpirvType: {
|
||||
// GL_EXT_spirv_intrinsics
|
||||
const auto& spirvType = type.getSpirvType();
|
||||
const auto& spirvInst = spirvType.spirvInst;
|
||||
|
||||
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({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;
|
||||
}
|
||||
} while (ch != 0);
|
||||
|
||||
// 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
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
@@ -4094,7 +4433,6 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
|
||||
{
|
||||
// Name and decorate the non-hidden members
|
||||
int offset = -1;
|
||||
int locationOffset = 0; // for use within the members of this struct
|
||||
bool memberLocationInvalid = type.isArrayOfArrays() ||
|
||||
(type.isArray() && (type.getQualifier().isArrayedIo(glslangIntermediate->getStage()) == false));
|
||||
for (int i = 0; i < (int)glslangMembers->size(); i++) {
|
||||
@@ -4152,10 +4490,6 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
|
||||
if (!memberLocationInvalid && memberQualifier.hasLocation())
|
||||
builder.addMemberDecoration(spvType, member, spv::DecorationLocation, memberQualifier.layoutLocation);
|
||||
|
||||
if (qualifier.hasLocation()) // track for upcoming inheritance
|
||||
locationOffset += glslangIntermediate->computeTypeLocationSize(
|
||||
glslangMember, glslangIntermediate->getStage());
|
||||
|
||||
// component, XFB, others
|
||||
if (glslangMember.getQualifier().hasComponent())
|
||||
builder.addMemberDecoration(spvType, member, spv::DecorationComponent,
|
||||
@@ -4211,6 +4545,38 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
|
||||
builder.addCapability(spv::CapabilityGeometryShaderPassthroughNV);
|
||||
builder.addExtension(spv::E_SPV_NV_geometry_shader_passthrough);
|
||||
}
|
||||
|
||||
//
|
||||
// Add SPIR-V decorations for members (GL_EXT_spirv_intrinsics)
|
||||
//
|
||||
if (glslangMember.getQualifier().hasSprivDecorate()) {
|
||||
const glslang::TSpirvDecorate& spirvDecorate = glslangMember.getQualifier().getSpirvDecorate();
|
||||
|
||||
// Add spirv_decorate
|
||||
for (auto& decorate : spirvDecorate.decorates) {
|
||||
if (!decorate.second.empty()) {
|
||||
std::vector<unsigned> literals;
|
||||
TranslateLiterals(decorate.second, literals);
|
||||
builder.addMemberDecoration(spvType, member, static_cast<spv::Decoration>(decorate.first), literals);
|
||||
}
|
||||
else
|
||||
builder.addMemberDecoration(spvType, member, static_cast<spv::Decoration>(decorate.first));
|
||||
}
|
||||
|
||||
// spirv_decorate_id not applied to members
|
||||
assert(spirvDecorate.decorateIds.empty());
|
||||
|
||||
// Add spirv_decorate_string
|
||||
for (auto& decorateString : spirvDecorate.decorateStrings) {
|
||||
std::vector<const char*> strings;
|
||||
assert(!decorateString.second.empty());
|
||||
for (auto extraOperand : decorateString.second) {
|
||||
const char* string = extraOperand->getConstArray()[0].getSConst()->c_str();
|
||||
strings.push_back(string);
|
||||
}
|
||||
builder.addDecoration(spvType, static_cast<spv::Decoration>(decorateString.first), strings);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -4229,6 +4595,8 @@ spv::Id TGlslangToSpvTraverser::makeArraySizeId(const glslang::TArraySizes& arra
|
||||
glslang::TIntermTyped* specNode = arraySizes.getDimNode(dim);
|
||||
if (specNode != nullptr) {
|
||||
builder.clearAccessChain();
|
||||
SpecConstantOpModeGuard spec_constant_op_mode_setter(&builder);
|
||||
spec_constant_op_mode_setter.turnOnSpecConstantOpMode();
|
||||
specNode->traverse(this);
|
||||
return accessChainLoad(specNode->getAsTyped()->getType());
|
||||
}
|
||||
@@ -4264,19 +4632,7 @@ spv::Id TGlslangToSpvTraverser::accessChainLoad(const glslang::TType& type)
|
||||
|
||||
// Need to convert to abstract types when necessary
|
||||
if (type.getBasicType() == glslang::EbtBool) {
|
||||
if (builder.isScalarType(nominalTypeId)) {
|
||||
// Conversion for bool
|
||||
spv::Id boolType = builder.makeBoolType();
|
||||
if (nominalTypeId != boolType)
|
||||
loadedId = builder.createBinOp(spv::OpINotEqual, boolType, loadedId, builder.makeUintConstant(0));
|
||||
} else if (builder.isVectorType(nominalTypeId)) {
|
||||
// Conversion for bvec
|
||||
int vecSize = builder.getNumTypeComponents(nominalTypeId);
|
||||
spv::Id bvecType = builder.makeVectorType(builder.makeBoolType(), vecSize);
|
||||
if (nominalTypeId != bvecType)
|
||||
loadedId = builder.createBinOp(spv::OpINotEqual, bvecType, loadedId,
|
||||
makeSmearedConstant(builder.makeUintConstant(0), vecSize));
|
||||
}
|
||||
loadedId = convertLoadedBoolInUniformToUint(type, nominalTypeId, loadedId);
|
||||
}
|
||||
|
||||
return loadedId;
|
||||
@@ -4598,6 +4954,9 @@ bool TGlslangToSpvTraverser::originalParam(glslang::TStorageQualifier qualifier,
|
||||
if (glslangIntermediate->getSource() == glslang::EShSourceHlsl)
|
||||
return paramType.getBasicType() == glslang::EbtBlock;
|
||||
return paramType.containsOpaque() || // sampler, etc.
|
||||
#ifndef GLSLANG_WEB
|
||||
paramType.getQualifier().isSpirvByReference() || // spirv_by_reference
|
||||
#endif
|
||||
(paramType.getBasicType() == glslang::EbtBlock && qualifier == glslang::EvqBuffer); // SSBO
|
||||
}
|
||||
|
||||
@@ -4991,7 +5350,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
||||
|
||||
int components = node->getType().getVectorSize();
|
||||
|
||||
if (node->getOp() == glslang::EOpTextureFetch) {
|
||||
if (node->getOp() == glslang::EOpImageLoad ||
|
||||
node->getOp() == glslang::EOpImageLoadLod ||
|
||||
node->getOp() == glslang::EOpTextureFetch ||
|
||||
node->getOp() == glslang::EOpTextureFetchOffset) {
|
||||
// These must produce 4 components, per SPIR-V spec. We'll add a conversion constructor if needed.
|
||||
// This will only happen through the HLSL path for operator[], so we do not have to handle e.g.
|
||||
// the EOpTexture/Proj/Lod/etc family. It would be harmless to do so, but would need more logic
|
||||
@@ -5553,7 +5915,7 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
|
||||
++lValueCount;
|
||||
} else {
|
||||
// process r-value, which involves a copy for a type mismatch
|
||||
if (function->getParamType(a) != convertGlslangToSpvType(*argTypes[a]) ||
|
||||
if (function->getParamType(a) != builder.getTypeId(rValues[rValueCount]) ||
|
||||
TranslatePrecisionDecoration(*argTypes[a]) != function->getParamPrecision(a))
|
||||
{
|
||||
spv::Id argCopy = builder.createVariable(function->getParamPrecision(a), spv::StorageClassFunction, function->getParamType(a), "arg");
|
||||
@@ -6884,13 +7246,17 @@ spv::Id TGlslangToSpvTraverser::createAtomicOperation(glslang::TOperator op, spv
|
||||
case glslang::EOpImageAtomicAdd:
|
||||
case glslang::EOpAtomicCounterAdd:
|
||||
opCode = spv::OpAtomicIAdd;
|
||||
if (typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble) {
|
||||
if (typeProxy == glslang::EbtFloat16 || typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble) {
|
||||
opCode = spv::OpAtomicFAddEXT;
|
||||
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float_add);
|
||||
if (typeProxy == glslang::EbtFloat)
|
||||
if (typeProxy == glslang::EbtFloat16) {
|
||||
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float16_add);
|
||||
builder.addCapability(spv::CapabilityAtomicFloat16AddEXT);
|
||||
} else if (typeProxy == glslang::EbtFloat) {
|
||||
builder.addCapability(spv::CapabilityAtomicFloat32AddEXT);
|
||||
else
|
||||
} else {
|
||||
builder.addCapability(spv::CapabilityAtomicFloat64AddEXT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case glslang::EOpAtomicSubtract:
|
||||
@@ -6900,14 +7266,38 @@ spv::Id TGlslangToSpvTraverser::createAtomicOperation(glslang::TOperator op, spv
|
||||
case glslang::EOpAtomicMin:
|
||||
case glslang::EOpImageAtomicMin:
|
||||
case glslang::EOpAtomicCounterMin:
|
||||
opCode = (typeProxy == glslang::EbtUint || typeProxy == glslang::EbtUint64) ?
|
||||
spv::OpAtomicUMin : spv::OpAtomicSMin;
|
||||
if (typeProxy == glslang::EbtFloat16 || typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble) {
|
||||
opCode = spv::OpAtomicFMinEXT;
|
||||
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float_min_max);
|
||||
if (typeProxy == glslang::EbtFloat16)
|
||||
builder.addCapability(spv::CapabilityAtomicFloat16MinMaxEXT);
|
||||
else if (typeProxy == glslang::EbtFloat)
|
||||
builder.addCapability(spv::CapabilityAtomicFloat32MinMaxEXT);
|
||||
else
|
||||
builder.addCapability(spv::CapabilityAtomicFloat64MinMaxEXT);
|
||||
} else if (typeProxy == glslang::EbtUint || typeProxy == glslang::EbtUint64) {
|
||||
opCode = spv::OpAtomicUMin;
|
||||
} else {
|
||||
opCode = spv::OpAtomicSMin;
|
||||
}
|
||||
break;
|
||||
case glslang::EOpAtomicMax:
|
||||
case glslang::EOpImageAtomicMax:
|
||||
case glslang::EOpAtomicCounterMax:
|
||||
opCode = (typeProxy == glslang::EbtUint || typeProxy == glslang::EbtUint64) ?
|
||||
spv::OpAtomicUMax : spv::OpAtomicSMax;
|
||||
if (typeProxy == glslang::EbtFloat16 || typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble) {
|
||||
opCode = spv::OpAtomicFMaxEXT;
|
||||
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float_min_max);
|
||||
if (typeProxy == glslang::EbtFloat16)
|
||||
builder.addCapability(spv::CapabilityAtomicFloat16MinMaxEXT);
|
||||
else if (typeProxy == glslang::EbtFloat)
|
||||
builder.addCapability(spv::CapabilityAtomicFloat32MinMaxEXT);
|
||||
else
|
||||
builder.addCapability(spv::CapabilityAtomicFloat64MinMaxEXT);
|
||||
} else if (typeProxy == glslang::EbtUint || typeProxy == glslang::EbtUint64) {
|
||||
opCode = spv::OpAtomicUMax;
|
||||
} else {
|
||||
opCode = spv::OpAtomicSMax;
|
||||
}
|
||||
break;
|
||||
case glslang::EOpAtomicAnd:
|
||||
case glslang::EOpImageAtomicAnd:
|
||||
@@ -7142,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:
|
||||
{
|
||||
@@ -7266,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 ||
|
||||
@@ -7295,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);
|
||||
@@ -7965,6 +8359,11 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
|
||||
case glslang::EOpTraceNV:
|
||||
builder.createNoResultOp(spv::OpTraceNV, operands);
|
||||
return 0;
|
||||
case glslang::EOpTraceRayMotionNV:
|
||||
builder.addExtension(spv::E_SPV_NV_ray_tracing_motion_blur);
|
||||
builder.addCapability(spv::CapabilityRayTracingMotionBlurNV);
|
||||
builder.createNoResultOp(spv::OpTraceRayMotionNV, operands);
|
||||
return 0;
|
||||
case glslang::EOpTraceKHR:
|
||||
builder.createNoResultOp(spv::OpTraceRayKHR, operands);
|
||||
return 0;
|
||||
@@ -8352,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);
|
||||
@@ -8387,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
|
||||
@@ -8449,6 +8867,48 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
|
||||
builder.addDecoration(id, symbol->getType().getQualifier().restrict ?
|
||||
spv::DecorationRestrictPointerEXT : spv::DecorationAliasedPointerEXT);
|
||||
}
|
||||
|
||||
//
|
||||
// Add SPIR-V decorations for structure (GL_EXT_spirv_intrinsics)
|
||||
//
|
||||
if (symbol->getType().getQualifier().hasSprivDecorate()) {
|
||||
const glslang::TSpirvDecorate& spirvDecorate = symbol->getType().getQualifier().getSpirvDecorate();
|
||||
|
||||
// Add spirv_decorate
|
||||
for (auto& decorate : spirvDecorate.decorates) {
|
||||
if (!decorate.second.empty()) {
|
||||
std::vector<unsigned> literals;
|
||||
TranslateLiterals(decorate.second, literals);
|
||||
builder.addDecoration(id, static_cast<spv::Decoration>(decorate.first), literals);
|
||||
}
|
||||
else
|
||||
builder.addDecoration(id, static_cast<spv::Decoration>(decorate.first));
|
||||
}
|
||||
|
||||
// Add spirv_decorate_id
|
||||
for (auto& decorateId : spirvDecorate.decorateIds) {
|
||||
std::vector<spv::Id> operandIds;
|
||||
assert(!decorateId.second.empty());
|
||||
for (auto extraOperand : decorateId.second) {
|
||||
if (extraOperand->getQualifier().isSpecConstant())
|
||||
operandIds.push_back(getSymbolId(extraOperand->getAsSymbolNode()));
|
||||
else
|
||||
operandIds.push_back(createSpvConstant(*extraOperand));
|
||||
}
|
||||
builder.addDecorationId(id, static_cast<spv::Decoration>(decorateId.first), operandIds);
|
||||
}
|
||||
|
||||
// Add spirv_decorate_string
|
||||
for (auto& decorateString : spirvDecorate.decorateStrings) {
|
||||
std::vector<const char*> strings;
|
||||
assert(!decorateString.second.empty());
|
||||
for (auto extraOperand : decorateString.second) {
|
||||
const char* string = extraOperand->getConstArray()[0].getSConst()->c_str();
|
||||
strings.push_back(string);
|
||||
}
|
||||
builder.addDecoration(id, static_cast<spv::Decoration>(decorateString.first), strings);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return id;
|
||||
|
||||
@@ -544,6 +544,9 @@ namespace spv {
|
||||
// Extended instructions: currently, assume everything is an ID.
|
||||
// TODO: add whatever data we need for exceptions to that
|
||||
if (opCode == spv::OpExtInst) {
|
||||
|
||||
idFn(asId(word)); // Instruction set is an ID that also needs to be mapped
|
||||
|
||||
word += 2; // instruction set, and instruction from set
|
||||
numOperands -= 2;
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -743,6 +774,26 @@ Id Builder::getContainedTypeId(Id typeId, int member) const
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out the final resulting type of the access chain.
|
||||
Id Builder::getResultingAccessChainType() const
|
||||
{
|
||||
assert(accessChain.base != NoResult);
|
||||
Id typeId = getTypeId(accessChain.base);
|
||||
|
||||
assert(isPointerType(typeId));
|
||||
typeId = getContainedTypeId(typeId);
|
||||
|
||||
for (int i = 0; i < (int)accessChain.indexChain.size(); ++i) {
|
||||
if (isStructType(typeId)) {
|
||||
assert(isConstantScalar(accessChain.indexChain[i]));
|
||||
typeId = getContainedTypeId(typeId, getConstantScalar(accessChain.indexChain[i]));
|
||||
} else
|
||||
typeId = getContainedTypeId(typeId, accessChain.indexChain[i]);
|
||||
}
|
||||
|
||||
return typeId;
|
||||
}
|
||||
|
||||
// Return the immediately contained type of a given composite type.
|
||||
Id Builder::getContainedTypeId(Id typeId) const
|
||||
{
|
||||
@@ -1585,16 +1636,7 @@ Id Builder::createLoad(Id lValue, spv::Decoration precision, spv::MemoryAccessMa
|
||||
Id Builder::createAccessChain(StorageClass storageClass, Id base, const std::vector<Id>& offsets)
|
||||
{
|
||||
// Figure out the final resulting type.
|
||||
spv::Id typeId = getTypeId(base);
|
||||
assert(isPointerType(typeId) && offsets.size() > 0);
|
||||
typeId = getContainedTypeId(typeId);
|
||||
for (int i = 0; i < (int)offsets.size(); ++i) {
|
||||
if (isStructType(typeId)) {
|
||||
assert(isConstantScalar(offsets[i]));
|
||||
typeId = getContainedTypeId(typeId, getConstantScalar(offsets[i]));
|
||||
} else
|
||||
typeId = getContainedTypeId(typeId, offsets[i]);
|
||||
}
|
||||
Id typeId = getResultingAccessChainType();
|
||||
typeId = makePointer(storageClass, typeId);
|
||||
|
||||
// Make the instruction
|
||||
@@ -2543,7 +2585,7 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
for (int arg = 0; arg < (int)sources.size(); ++arg) {
|
||||
for (int arg = 0; arg < (int)sources.size() && col < numCols; ++arg) {
|
||||
Id argComp = sources[arg];
|
||||
for (int comp = 0; comp < getNumComponents(sources[arg]); ++comp) {
|
||||
if (getNumComponents(sources[arg]) > 1) {
|
||||
@@ -2555,6 +2597,10 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
|
||||
row = 0;
|
||||
col++;
|
||||
}
|
||||
if (col == numCols) {
|
||||
// If more components are provided than fit the matrix, discard the rest.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2790,28 +2836,59 @@ void Builder::accessChainStore(Id rvalue, Decoration nonUniform, spv::MemoryAcce
|
||||
assert(accessChain.isRValue == false);
|
||||
|
||||
transferAccessChainSwizzle(true);
|
||||
Id base = collapseAccessChain();
|
||||
addDecoration(base, nonUniform);
|
||||
|
||||
Id source = rvalue;
|
||||
// If a swizzle exists and is not full and is not dynamic, then the swizzle will be broken into individual stores.
|
||||
if (accessChain.swizzle.size() > 0 &&
|
||||
getNumTypeComponents(getResultingAccessChainType()) != (int)accessChain.swizzle.size() &&
|
||||
accessChain.component == NoResult) {
|
||||
for (unsigned int i = 0; i < accessChain.swizzle.size(); ++i) {
|
||||
accessChain.indexChain.push_back(makeUintConstant(accessChain.swizzle[i]));
|
||||
accessChain.instr = NoResult;
|
||||
|
||||
// dynamic component should be gone
|
||||
assert(accessChain.component == NoResult);
|
||||
Id base = collapseAccessChain();
|
||||
addDecoration(base, nonUniform);
|
||||
|
||||
// If swizzle still exists, it is out-of-order or not full, we must load the target vector,
|
||||
// extract and insert elements to perform writeMask and/or swizzle.
|
||||
if (accessChain.swizzle.size() > 0) {
|
||||
Id tempBaseId = createLoad(base, spv::NoPrecision);
|
||||
source = createLvalueSwizzle(getTypeId(tempBaseId), tempBaseId, source, accessChain.swizzle);
|
||||
accessChain.indexChain.pop_back();
|
||||
accessChain.instr = NoResult;
|
||||
|
||||
// dynamic component should be gone
|
||||
assert(accessChain.component == NoResult);
|
||||
|
||||
Id source = createCompositeExtract(rvalue, getContainedTypeId(getTypeId(rvalue)), i);
|
||||
|
||||
// take LSB of alignment
|
||||
alignment = alignment & ~(alignment & (alignment-1));
|
||||
if (getStorageClass(base) == StorageClassPhysicalStorageBufferEXT) {
|
||||
memoryAccess = (spv::MemoryAccessMask)(memoryAccess | spv::MemoryAccessAlignedMask);
|
||||
}
|
||||
|
||||
createStore(source, base, memoryAccess, scope, alignment);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Id base = collapseAccessChain();
|
||||
addDecoration(base, nonUniform);
|
||||
|
||||
// take LSB of alignment
|
||||
alignment = alignment & ~(alignment & (alignment-1));
|
||||
if (getStorageClass(base) == StorageClassPhysicalStorageBufferEXT) {
|
||||
memoryAccess = (spv::MemoryAccessMask)(memoryAccess | spv::MemoryAccessAlignedMask);
|
||||
Id source = rvalue;
|
||||
|
||||
// dynamic component should be gone
|
||||
assert(accessChain.component == NoResult);
|
||||
|
||||
// If swizzle still exists, it may be out-of-order, we must load the target vector,
|
||||
// extract and insert elements to perform writeMask and/or swizzle.
|
||||
if (accessChain.swizzle.size() > 0) {
|
||||
Id tempBaseId = createLoad(base, spv::NoPrecision);
|
||||
source = createLvalueSwizzle(getTypeId(tempBaseId), tempBaseId, source, accessChain.swizzle);
|
||||
}
|
||||
|
||||
// take LSB of alignment
|
||||
alignment = alignment & ~(alignment & (alignment-1));
|
||||
if (getStorageClass(base) == StorageClassPhysicalStorageBufferEXT) {
|
||||
memoryAccess = (spv::MemoryAccessMask)(memoryAccess | spv::MemoryAccessAlignedMask);
|
||||
}
|
||||
|
||||
createStore(source, base, memoryAccess, scope, alignment);
|
||||
}
|
||||
|
||||
createStore(source, base, memoryAccess, scope, alignment);
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
|
||||
@@ -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();
|
||||
@@ -202,6 +203,7 @@ public:
|
||||
StorageClass getTypeStorageClass(Id typeId) const { return module.getStorageClass(typeId); }
|
||||
ImageFormat getImageTypeFormat(Id typeId) const
|
||||
{ return (ImageFormat)module.getInstruction(typeId)->getImmediateOperand(6); }
|
||||
Id getResultingAccessChainType() const;
|
||||
|
||||
bool isPointer(Id resultId) const { return isPointerType(getTypeId(resultId)); }
|
||||
bool isScalar(Id resultId) const { return isScalarType(getTypeId(resultId)); }
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,26 @@ 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::EShTargetUniversal:
|
||||
switch (spvVersion.spv) {
|
||||
case EShTargetSpv_1_0:
|
||||
return spv_target_env::SPV_ENV_UNIVERSAL_1_0;
|
||||
case EShTargetSpv_1_1:
|
||||
return spv_target_env::SPV_ENV_UNIVERSAL_1_1;
|
||||
case EShTargetSpv_1_2:
|
||||
return spv_target_env::SPV_ENV_UNIVERSAL_1_2;
|
||||
case EShTargetSpv_1_3:
|
||||
return spv_target_env::SPV_ENV_UNIVERSAL_1_3;
|
||||
case EShTargetSpv_1_4:
|
||||
return spv_target_env::SPV_ENV_UNIVERSAL_1_4;
|
||||
case EShTargetSpv_1_5:
|
||||
return spv_target_env::SPV_ENV_UNIVERSAL_1_5;
|
||||
case EShTargetSpv_1_6:
|
||||
return spv_target_env::SPV_ENV_UNIVERSAL_1_6;
|
||||
default:
|
||||
logger->missingFunctionality("Target version for SPIRV-Tools validator");
|
||||
return spv_target_env::SPV_ENV_UNIVERSAL_1_6;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -207,6 +227,7 @@ void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector
|
||||
optimizer.RegisterPass(spvtools::CreateAggressiveDCEPass());
|
||||
optimizer.RegisterPass(spvtools::CreateVectorDCEPass());
|
||||
optimizer.RegisterPass(spvtools::CreateDeadInsertElimPass());
|
||||
optimizer.RegisterPass(spvtools::CreateInterpolateFixupPass());
|
||||
if (options->optimizeSize) {
|
||||
optimizer.RegisterPass(spvtools::CreateRedundancyEliminationPass());
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@ const char* ExecutionModeString(int mode)
|
||||
case ExecutionModeRoundingModeRTE: return "RoundingModeRTE";
|
||||
case ExecutionModeRoundingModeRTZ: return "RoundingModeRTZ";
|
||||
case ExecutionModeStencilRefReplacingEXT: return "StencilRefReplacingEXT";
|
||||
case ExecutionModeSubgroupUniformControlFlowKHR: return "SubgroupUniformControlFlow";
|
||||
|
||||
case ExecutionModeOutputLinesNV: return "OutputLinesNV";
|
||||
case ExecutionModeOutputPrimitivesNV: return "OutputPrimitivesNV";
|
||||
@@ -425,6 +426,7 @@ const char* BuiltInString(int builtIn)
|
||||
case BuiltInSMCountNV: return "SMCountNV";
|
||||
case BuiltInWarpIDNV: return "WarpIDNV";
|
||||
case BuiltInSMIDNV: return "SMIDNV";
|
||||
case BuiltInCurrentRayTimeNV: return "CurrentRayTimeNV";
|
||||
|
||||
default: return "Bad";
|
||||
}
|
||||
@@ -898,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";
|
||||
@@ -915,6 +923,7 @@ const char* CapabilityString(int info)
|
||||
case CapabilityPerViewAttributesNV: return "PerViewAttributesNV";
|
||||
case CapabilityGroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV";
|
||||
case CapabilityRayTracingNV: return "RayTracingNV";
|
||||
case CapabilityRayTracingMotionBlurNV: return "RayTracingMotionBlurNV";
|
||||
case CapabilityRayTracingKHR: return "RayTracingKHR";
|
||||
case CapabilityRayQueryKHR: return "RayQueryKHR";
|
||||
case CapabilityRayTracingProvisionalKHR: return "RayTracingProvisionalKHR";
|
||||
@@ -965,8 +974,12 @@ const char* CapabilityString(int info)
|
||||
|
||||
case CapabilityIntegerFunctions2INTEL: return "CapabilityIntegerFunctions2INTEL";
|
||||
|
||||
case CapabilityAtomicFloat16AddEXT: return "AtomicFloat16AddEXT";
|
||||
case CapabilityAtomicFloat32AddEXT: return "AtomicFloat32AddEXT";
|
||||
case CapabilityAtomicFloat64AddEXT: return "AtomicFloat64AddEXT";
|
||||
case CapabilityAtomicFloat16MinMaxEXT: return "AtomicFloat16MinMaxEXT";
|
||||
case CapabilityAtomicFloat32MinMaxEXT: return "AtomicFloat32MinMaxEXT";
|
||||
case CapabilityAtomicFloat64MinMaxEXT: return "AtomicFloat64MinMaxEXT";
|
||||
|
||||
case CapabilityWorkgroupMemoryExplicitLayoutKHR: return "CapabilityWorkgroupMemoryExplicitLayoutKHR";
|
||||
case CapabilityWorkgroupMemoryExplicitLayout8BitAccessKHR: return "CapabilityWorkgroupMemoryExplicitLayout8BitAccessKHR";
|
||||
@@ -1351,6 +1364,8 @@ const char* OpcodeString(int op)
|
||||
case 4432: return "OpSubgroupReadInvocationKHR";
|
||||
|
||||
case OpAtomicFAddEXT: return "OpAtomicFAddEXT";
|
||||
case OpAtomicFMinEXT: return "OpAtomicFMinEXT";
|
||||
case OpAtomicFMaxEXT: return "OpAtomicFMaxEXT";
|
||||
|
||||
case 5000: return "OpGroupIAddNonUniformAMD";
|
||||
case 5001: return "OpGroupFAddNonUniformAMD";
|
||||
@@ -1375,6 +1390,7 @@ const char* OpcodeString(int op)
|
||||
case OpTerminateRayNV: return "OpTerminateRayNV";
|
||||
case OpTerminateRayKHR: return "OpTerminateRayKHR";
|
||||
case OpTraceNV: return "OpTraceNV";
|
||||
case OpTraceRayMotionNV: return "OpTraceRayMotionNV";
|
||||
case OpTraceRayKHR: return "OpTraceRayKHR";
|
||||
case OpTypeAccelerationStructureKHR: return "OpTypeAccelerationStructureKHR";
|
||||
case OpExecuteCallableNV: return "OpExecuteCallableNV";
|
||||
@@ -2341,6 +2357,16 @@ void Parameterize()
|
||||
InstructionDesc[OpAtomicSMax].operands.push(OperandMemorySemantics, "'Semantics'");
|
||||
InstructionDesc[OpAtomicSMax].operands.push(OperandId, "'Value'");
|
||||
|
||||
InstructionDesc[OpAtomicFMinEXT].operands.push(OperandId, "'Pointer'");
|
||||
InstructionDesc[OpAtomicFMinEXT].operands.push(OperandScope, "'Scope'");
|
||||
InstructionDesc[OpAtomicFMinEXT].operands.push(OperandMemorySemantics, "'Semantics'");
|
||||
InstructionDesc[OpAtomicFMinEXT].operands.push(OperandId, "'Value'");
|
||||
|
||||
InstructionDesc[OpAtomicFMaxEXT].operands.push(OperandId, "'Pointer'");
|
||||
InstructionDesc[OpAtomicFMaxEXT].operands.push(OperandScope, "'Scope'");
|
||||
InstructionDesc[OpAtomicFMaxEXT].operands.push(OperandMemorySemantics, "'Semantics'");
|
||||
InstructionDesc[OpAtomicFMaxEXT].operands.push(OperandId, "'Value'");
|
||||
|
||||
InstructionDesc[OpAtomicAnd].operands.push(OperandId, "'Pointer'");
|
||||
InstructionDesc[OpAtomicAnd].operands.push(OperandScope, "'Scope'");
|
||||
InstructionDesc[OpAtomicAnd].operands.push(OperandMemorySemantics, "'Semantics'");
|
||||
@@ -2795,6 +2821,20 @@ void Parameterize()
|
||||
InstructionDesc[OpTraceNV].operands.push(OperandId, "'Payload'");
|
||||
InstructionDesc[OpTraceNV].setResultAndType(false, false);
|
||||
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'Acceleration Structure'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'Ray Flags'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'Cull Mask'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'SBT Record Offset'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'SBT Record Stride'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'Miss Index'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'Ray Origin'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'TMin'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'Ray Direction'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'TMax'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'Time'");
|
||||
InstructionDesc[OpTraceRayMotionNV].operands.push(OperandId, "'Payload'");
|
||||
InstructionDesc[OpTraceRayMotionNV].setResultAndType(false, false);
|
||||
|
||||
InstructionDesc[OpTraceRayKHR].operands.push(OperandId, "'Acceleration Structure'");
|
||||
InstructionDesc[OpTraceRayKHR].operands.push(OperandId, "'Ray Flags'");
|
||||
InstructionDesc[OpTraceRayKHR].operands.push(OperandId, "'Cull Mask'");
|
||||
|
||||
+2314
-2293
File diff suppressed because it is too large
Load Diff
@@ -65,6 +65,10 @@ enum TBasicType {
|
||||
EbtAccStruct,
|
||||
EbtReference,
|
||||
EbtRayQuery,
|
||||
#ifndef GLSLANG_WEB
|
||||
// SPIR-V type defined by spirv_type
|
||||
EbtSpirvType,
|
||||
#endif
|
||||
|
||||
// HLSL types that live only temporarily.
|
||||
EbtString,
|
||||
@@ -91,6 +95,9 @@ enum TStorageQualifier {
|
||||
EvqUniform, // read only, shared with app
|
||||
EvqBuffer, // read/write, shared with app
|
||||
EvqShared, // compute shader's read/write 'shared' qualifier
|
||||
#ifndef GLSLANG_WEB
|
||||
EvqSpirvStorageClass, // spirv_storage_class
|
||||
#endif
|
||||
|
||||
EvqPayload,
|
||||
EvqPayloadIn,
|
||||
@@ -263,6 +270,7 @@ enum TBuiltInVariable {
|
||||
EbvWorldToObject,
|
||||
EbvWorldToObject3x4,
|
||||
EbvIncomingRayFlags,
|
||||
EbvCurrentRayTimeNV,
|
||||
// barycentrics
|
||||
EbvBaryCoordNV,
|
||||
EbvBaryCoordNoPerspNV,
|
||||
@@ -321,6 +329,9 @@ __inline const char* GetStorageQualifierString(TStorageQualifier q)
|
||||
case EvqGlobal: return "global"; break;
|
||||
case EvqConst: return "const"; break;
|
||||
case EvqConstReadOnly: return "const (read only)"; break;
|
||||
#ifndef GLSLANG_WEB
|
||||
case EvqSpirvStorageClass: return "spirv_storage_class"; break;
|
||||
#endif
|
||||
case EvqVaryingIn: return "in"; break;
|
||||
case EvqVaryingOut: return "out"; break;
|
||||
case EvqUniform: return "uniform"; break;
|
||||
@@ -465,6 +476,7 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
|
||||
case EbvIncomingRayFlags: return "IncomingRayFlagsNV";
|
||||
case EbvObjectToWorld: return "ObjectToWorldNV";
|
||||
case EbvWorldToObject: return "WorldToObjectNV";
|
||||
case EbvCurrentRayTimeNV: return "CurrentRayTimeNV";
|
||||
|
||||
case EbvBaryCoordNV: return "BaryCoordNV";
|
||||
case EbvBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
|
||||
|
||||
@@ -39,6 +39,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#ifdef _MSC_VER
|
||||
#include <cfloat>
|
||||
#else
|
||||
#include <cmath>
|
||||
#endif
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <list>
|
||||
@@ -61,7 +66,7 @@ std::string to_string(const T& val) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || defined MINGW_HAS_SECURE_API
|
||||
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || MINGW_HAS_SECURE_API
|
||||
#include <basetsd.h>
|
||||
#ifndef snprintf
|
||||
#define snprintf sprintf_s
|
||||
@@ -194,6 +199,10 @@ template <class K, class D, class HASH = std::hash<K>, class PRED = std::equal_t
|
||||
class TUnorderedMap : public std::unordered_map<K, D, HASH, PRED, pool_allocator<std::pair<K const, D> > > {
|
||||
};
|
||||
|
||||
template <class K, class CMP = std::less<K> >
|
||||
class TSet : public std::set<K, CMP, pool_allocator<K> > {
|
||||
};
|
||||
|
||||
//
|
||||
// Persistent string memory. Should only be used for strings that survive
|
||||
// across compiles/links.
|
||||
@@ -209,7 +218,7 @@ template <class T> T Max(const T a, const T b) { return a > b ? a : b; }
|
||||
//
|
||||
// Create a TString object from an integer.
|
||||
//
|
||||
#if defined _MSC_VER || defined MINGW_HAS_SECURE_API
|
||||
#if defined _MSC_VER || MINGW_HAS_SECURE_API
|
||||
inline const TString String(const int i, const int base = 10)
|
||||
{
|
||||
char text[16]; // 32 bit ints are at most 10 digits in base 10
|
||||
@@ -286,6 +295,46 @@ template <class T> bool IsMultipleOfPow2(T number, int powerOf2)
|
||||
return ! (number & (powerOf2 - 1));
|
||||
}
|
||||
|
||||
// Returns log2 of an integer power of 2.
|
||||
// T should be integral.
|
||||
template <class T> int IntLog2(T n)
|
||||
{
|
||||
assert(IsPow2(n));
|
||||
int result = 0;
|
||||
while ((T(1) << result) != n) {
|
||||
result++;
|
||||
}
|
||||
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_
|
||||
|
||||
@@ -306,6 +306,8 @@ public:
|
||||
|
||||
TPoolAllocator& getAllocator() const { return allocator; }
|
||||
|
||||
pool_allocator select_on_container_copy_construction() const { return pool_allocator{}; }
|
||||
|
||||
protected:
|
||||
pool_allocator& operator=(const pool_allocator&) { return *this; }
|
||||
TPoolAllocator& allocator;
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// Copyright(C) 2021 Advanced Micro Devices, Inc.
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// 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 HOLDERS 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.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
|
||||
//
|
||||
// GL_EXT_spirv_intrinsics
|
||||
//
|
||||
#include "Common.h"
|
||||
|
||||
namespace glslang {
|
||||
|
||||
class TIntermTyped;
|
||||
class TIntermConstantUnion;
|
||||
class TType;
|
||||
|
||||
// SPIR-V requirements
|
||||
struct TSpirvRequirement {
|
||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||
|
||||
// capability = [..]
|
||||
TSet<TString> extensions;
|
||||
// extension = [..]
|
||||
TSet<int> capabilities;
|
||||
};
|
||||
|
||||
// SPIR-V execution modes
|
||||
struct TSpirvExecutionMode {
|
||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||
|
||||
// spirv_execution_mode
|
||||
TMap<int, TVector<const TIntermConstantUnion*>> modes;
|
||||
// spirv_execution_mode_id
|
||||
TMap<int, TVector<const TIntermTyped*> > modeIds;
|
||||
};
|
||||
|
||||
// SPIR-V decorations
|
||||
struct TSpirvDecorate {
|
||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||
|
||||
// spirv_decorate
|
||||
TMap<int, TVector<const TIntermConstantUnion*> > decorates;
|
||||
// spirv_decorate_id
|
||||
TMap<int, TVector<const TIntermTyped*>> decorateIds;
|
||||
// spirv_decorate_string
|
||||
TMap<int, TVector<const TIntermConstantUnion*> > decorateStrings;
|
||||
};
|
||||
|
||||
// SPIR-V instruction
|
||||
struct TSpirvInstruction {
|
||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||
|
||||
TSpirvInstruction() { set = ""; id = -1; }
|
||||
|
||||
bool operator==(const TSpirvInstruction& rhs) const { return set == rhs.set && id == rhs.id; }
|
||||
bool operator!=(const TSpirvInstruction& rhs) const { return !operator==(rhs); }
|
||||
|
||||
// spirv_instruction
|
||||
TString set;
|
||||
int id;
|
||||
};
|
||||
|
||||
// SPIR-V type parameter
|
||||
struct TSpirvTypeParameter {
|
||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||
|
||||
TSpirvTypeParameter(const TIntermConstantUnion* arg) { constant = arg; }
|
||||
|
||||
bool operator==(const TSpirvTypeParameter& rhs) const { return constant == rhs.constant; }
|
||||
bool operator!=(const TSpirvTypeParameter& rhs) const { return !operator==(rhs); }
|
||||
|
||||
const TIntermConstantUnion* constant;
|
||||
};
|
||||
|
||||
typedef TVector<TSpirvTypeParameter> TSpirvTypeParameters;
|
||||
|
||||
// SPIR-V type
|
||||
struct TSpirvType {
|
||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||
|
||||
bool operator==(const TSpirvType& rhs) const
|
||||
{
|
||||
return spirvInst == rhs.spirvInst && typeParams == rhs.typeParams;
|
||||
}
|
||||
bool operator!=(const TSpirvType& rhs) const { return !operator==(rhs); }
|
||||
|
||||
// spirv_type
|
||||
TSpirvInstruction spirvInst;
|
||||
TSpirvTypeParameters typeParams;
|
||||
};
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
#endif // GLSLANG_WEB
|
||||
@@ -44,11 +44,14 @@
|
||||
#include "../Include/BaseTypes.h"
|
||||
#include "../Public/ShaderLang.h"
|
||||
#include "arrays.h"
|
||||
#include "SpirvIntrinsics.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace glslang {
|
||||
|
||||
class TIntermAggregate;
|
||||
|
||||
const int GlslangMaxTypeLength = 200; // TODO: need to print block/struct one member per line, so this can stay bounded
|
||||
|
||||
const char* const AnonymousPrefix = "anon@"; // for something like a block whose members can be directly accessed
|
||||
@@ -115,6 +118,7 @@ struct TSampler { // misnomer now; includes images, textures without sampler,
|
||||
#endif
|
||||
|
||||
bool is1D() const { return dim == Esd1D; }
|
||||
bool is2D() const { return dim == Esd2D; }
|
||||
bool isBuffer() const { return dim == EsdBuffer; }
|
||||
bool isRect() const { return dim == EsdRect; }
|
||||
bool isSubpass() const { return dim == EsdSubpass; }
|
||||
@@ -486,7 +490,6 @@ enum TShaderInterface
|
||||
EsiCount
|
||||
};
|
||||
|
||||
|
||||
class TQualifier {
|
||||
public:
|
||||
static const int layoutNotSet = -1;
|
||||
@@ -500,6 +503,8 @@ public:
|
||||
#ifndef GLSLANG_WEB
|
||||
noContraction = false;
|
||||
nullInit = false;
|
||||
spirvByReference = false;
|
||||
spirvLiteral = false;
|
||||
#endif
|
||||
defaultBlock = false;
|
||||
}
|
||||
@@ -517,6 +522,12 @@ public:
|
||||
nullInit = false;
|
||||
defaultBlock = false;
|
||||
clearLayout();
|
||||
#ifndef GLSLANG_WEB
|
||||
spirvStorageClass = -1;
|
||||
spirvDecorate = nullptr;
|
||||
spirvByReference = false;
|
||||
spirvLiteral = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void clearInterstage()
|
||||
@@ -595,6 +606,10 @@ public:
|
||||
bool isPervertexNV() const { return false; }
|
||||
void setNullInit() { }
|
||||
bool isNullInit() const { return false; }
|
||||
void setSpirvByReference() { }
|
||||
bool isSpirvByReference() { return false; }
|
||||
void setSpirvLiteral() { }
|
||||
bool isSpirvLiteral() { return false; }
|
||||
#else
|
||||
bool noContraction: 1; // prevent contraction and reassociation, e.g., for 'precise' keyword, and expressions it affects
|
||||
bool nopersp : 1;
|
||||
@@ -617,6 +632,8 @@ public:
|
||||
bool shadercallcoherent : 1;
|
||||
bool nonprivate : 1;
|
||||
bool nullInit : 1;
|
||||
bool spirvByReference : 1;
|
||||
bool spirvLiteral : 1;
|
||||
bool isWriteOnly() const { return writeonly; }
|
||||
bool isReadOnly() const { return readonly; }
|
||||
bool isRestrict() const { return restrict; }
|
||||
@@ -654,6 +671,10 @@ public:
|
||||
bool isPervertexNV() const { return pervertexNV; }
|
||||
void setNullInit() { nullInit = true; }
|
||||
bool isNullInit() const { return nullInit; }
|
||||
void setSpirvByReference() { spirvByReference = true; }
|
||||
bool isSpirvByReference() const { return spirvByReference; }
|
||||
void setSpirvLiteral() { spirvLiteral = true; }
|
||||
bool isSpirvLiteral() const { return spirvLiteral; }
|
||||
#endif
|
||||
|
||||
bool isPipeInput() const
|
||||
@@ -720,6 +741,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool isUniform() const
|
||||
{
|
||||
switch (storage) {
|
||||
case EvqUniform:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isIo() const
|
||||
{
|
||||
switch (storage) {
|
||||
@@ -947,6 +978,10 @@ public:
|
||||
bool layoutViewportRelative;
|
||||
int layoutSecondaryViewportRelativeOffset;
|
||||
bool layoutShaderRecord;
|
||||
|
||||
// GL_EXT_spirv_intrinsics
|
||||
int spirvStorageClass;
|
||||
TSpirvDecorate* spirvDecorate;
|
||||
#endif
|
||||
|
||||
bool hasUniformLayout() const
|
||||
@@ -1078,6 +1113,15 @@ public:
|
||||
{
|
||||
return nonUniform;
|
||||
}
|
||||
|
||||
// GL_EXT_spirv_intrinsics
|
||||
bool hasSprivDecorate() const { return spirvDecorate != nullptr; }
|
||||
void setSpirvDecorate(int decoration, const TIntermAggregate* args = nullptr);
|
||||
void setSpirvDecorateId(int decoration, const TIntermAggregate* args);
|
||||
void setSpirvDecorateString(int decoration, const TIntermAggregate* args);
|
||||
const TSpirvDecorate& getSpirvDecorate() const { assert(spirvDecorate); return *spirvDecorate; }
|
||||
TSpirvDecorate& getSpirvDecorate() { assert(spirvDecorate); return *spirvDecorate; }
|
||||
TString getSpirvDecorateQualifierString() const;
|
||||
#endif
|
||||
bool hasSpecConstantId() const
|
||||
{
|
||||
@@ -1422,6 +1466,10 @@ public:
|
||||
const TType* userDef;
|
||||
TSourceLoc loc;
|
||||
TArraySizes* typeParameters;
|
||||
#ifndef GLSLANG_WEB
|
||||
// SPIR-V type defined by spirv_type directive
|
||||
TSpirvType* spirvType;
|
||||
#endif
|
||||
|
||||
#ifdef GLSLANG_WEB
|
||||
bool isCoopmat() const { return false; }
|
||||
@@ -1440,6 +1488,9 @@ public:
|
||||
loc = l;
|
||||
typeParameters = nullptr;
|
||||
coopmat = false;
|
||||
#ifndef GLSLANG_WEB
|
||||
spirvType = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void initQualifiers(bool global = false)
|
||||
@@ -1476,6 +1527,11 @@ public:
|
||||
return matrixCols == 0 && vectorSize == 1 && arraySizes == nullptr && userDef == nullptr;
|
||||
}
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// GL_EXT_spirv_intrinsics
|
||||
void setSpirvType(const TSpirvInstruction& spirvInst, const TSpirvTypeParameters* typeParams = nullptr);
|
||||
#endif
|
||||
|
||||
// "Image" is a superset of "Subpass"
|
||||
bool isImage() const { return basicType == EbtSampler && sampler.isImage(); }
|
||||
bool isSubpass() const { return basicType == EbtSampler && sampler.isSubpass(); }
|
||||
@@ -1493,6 +1549,9 @@ public:
|
||||
bool isVector = false) :
|
||||
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1), coopmat(false),
|
||||
arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr), typeParameters(nullptr)
|
||||
#ifndef GLSLANG_WEB
|
||||
, spirvType(nullptr)
|
||||
#endif
|
||||
{
|
||||
sampler.clear();
|
||||
qualifier.clear();
|
||||
@@ -1504,6 +1563,9 @@ public:
|
||||
bool isVector = false) :
|
||||
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1), coopmat(false),
|
||||
arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr), typeParameters(nullptr)
|
||||
#ifndef GLSLANG_WEB
|
||||
, spirvType(nullptr)
|
||||
#endif
|
||||
{
|
||||
sampler.clear();
|
||||
qualifier.clear();
|
||||
@@ -1517,6 +1579,9 @@ public:
|
||||
basicType(p.basicType),
|
||||
vectorSize(p.vectorSize), matrixCols(p.matrixCols), matrixRows(p.matrixRows), vector1(false), coopmat(p.coopmat),
|
||||
arraySizes(p.arraySizes), structure(nullptr), fieldName(nullptr), typeName(nullptr), typeParameters(p.typeParameters)
|
||||
#ifndef GLSLANG_WEB
|
||||
, spirvType(p.spirvType)
|
||||
#endif
|
||||
{
|
||||
if (basicType == EbtSampler)
|
||||
sampler = p.sampler;
|
||||
@@ -1551,6 +1616,9 @@ public:
|
||||
basicType(EbtSampler), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false), coopmat(false),
|
||||
arraySizes(as), structure(nullptr), fieldName(nullptr), typeName(nullptr),
|
||||
sampler(sampler), typeParameters(nullptr)
|
||||
#ifndef GLSLANG_WEB
|
||||
, spirvType(nullptr)
|
||||
#endif
|
||||
{
|
||||
qualifier.clear();
|
||||
qualifier.storage = q;
|
||||
@@ -1601,6 +1669,9 @@ public:
|
||||
TType(TTypeList* userDef, const TString& n) :
|
||||
basicType(EbtStruct), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false), coopmat(false),
|
||||
arraySizes(nullptr), structure(userDef), fieldName(nullptr), typeParameters(nullptr)
|
||||
#ifndef GLSLANG_WEB
|
||||
, spirvType(nullptr)
|
||||
#endif
|
||||
{
|
||||
sampler.clear();
|
||||
qualifier.clear();
|
||||
@@ -1610,6 +1681,9 @@ public:
|
||||
TType(TTypeList* userDef, const TString& n, const TQualifier& q) :
|
||||
basicType(EbtBlock), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false), coopmat(false),
|
||||
qualifier(q), arraySizes(nullptr), structure(userDef), fieldName(nullptr), typeParameters(nullptr)
|
||||
#ifndef GLSLANG_WEB
|
||||
, spirvType(nullptr)
|
||||
#endif
|
||||
{
|
||||
sampler.clear();
|
||||
typeName = NewPoolTString(n.c_str());
|
||||
@@ -1618,6 +1692,9 @@ public:
|
||||
explicit TType(TBasicType t, const TType &p, const TString& n) :
|
||||
basicType(t), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false),
|
||||
arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr)
|
||||
#ifndef GLSLANG_WEB
|
||||
, spirvType(nullptr)
|
||||
#endif
|
||||
{
|
||||
assert(t == EbtReference);
|
||||
typeName = NewPoolTString(n.c_str());
|
||||
@@ -1648,6 +1725,9 @@ public:
|
||||
referentType = copyOf.referentType;
|
||||
}
|
||||
typeParameters = copyOf.typeParameters;
|
||||
#ifndef GLSLANG_WEB
|
||||
spirvType = copyOf.spirvType;
|
||||
#endif
|
||||
coopmat = copyOf.isCoopMat();
|
||||
}
|
||||
|
||||
@@ -1738,6 +1818,7 @@ public:
|
||||
|
||||
virtual bool isScalar() const { return ! isVector() && ! isMatrix() && ! isStruct() && ! isArray(); }
|
||||
virtual bool isScalarOrVec1() const { return isScalar() || vector1; }
|
||||
virtual bool isScalarOrVector() const { return !isMatrix() && !isStruct() && !isArray(); }
|
||||
virtual bool isVector() const { return vectorSize > 1 || vector1; }
|
||||
virtual bool isMatrix() const { return matrixCols ? true : false; }
|
||||
virtual bool isArray() const { return arraySizes != nullptr; }
|
||||
@@ -1768,7 +1849,7 @@ public:
|
||||
}
|
||||
virtual bool isOpaque() const { return basicType == EbtSampler
|
||||
#ifndef GLSLANG_WEB
|
||||
|| basicType == EbtAtomicUint || basicType == EbtAccStruct || basicType == EbtRayQuery
|
||||
|| basicType == EbtAtomicUint || basicType == EbtAccStruct || basicType == EbtRayQuery
|
||||
#endif
|
||||
; }
|
||||
virtual bool isBuiltIn() const { return getQualifier().builtIn != EbvNone; }
|
||||
@@ -1784,10 +1865,12 @@ public:
|
||||
bool isAtomic() const { return false; }
|
||||
bool isCoopMat() const { return false; }
|
||||
bool isReference() const { return false; }
|
||||
bool isSpirvType() const { return false; }
|
||||
#else
|
||||
bool isAtomic() const { return basicType == EbtAtomicUint; }
|
||||
bool isCoopMat() const { return coopmat; }
|
||||
bool isReference() const { return getBasicType() == EbtReference; }
|
||||
bool isSpirvType() const { return getBasicType() == EbtSpirvType; }
|
||||
#endif
|
||||
|
||||
// return true if this type contains any subtype which satisfies the given predicate.
|
||||
@@ -2016,8 +2099,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char* getBasicString() const
|
||||
{
|
||||
return TType::getBasicString(basicType);
|
||||
@@ -2048,6 +2129,7 @@ public:
|
||||
case EbtRayQuery: return "rayQueryEXT";
|
||||
case EbtReference: return "reference";
|
||||
case EbtString: return "string";
|
||||
case EbtSpirvType: return "spirv_type";
|
||||
#endif
|
||||
default: return "unknown type";
|
||||
}
|
||||
@@ -2068,6 +2150,9 @@ public:
|
||||
const auto appendUint = [&](unsigned int u) { typeString.append(std::to_string(u).c_str()); };
|
||||
const auto appendInt = [&](int i) { typeString.append(std::to_string(i).c_str()); };
|
||||
|
||||
if (qualifier.hasSprivDecorate())
|
||||
appendStr(qualifier.getSpirvDecorateQualifierString().c_str());
|
||||
|
||||
if (qualifier.hasLayout()) {
|
||||
// To reduce noise, skip this if the only layout is an xfb_buffer
|
||||
// with no triggering xfb_offset.
|
||||
@@ -2217,6 +2302,10 @@ public:
|
||||
appendStr(" nonuniform");
|
||||
if (qualifier.isNullInit())
|
||||
appendStr(" null-init");
|
||||
if (qualifier.isSpirvByReference())
|
||||
appendStr(" spirv_by_reference");
|
||||
if (qualifier.isSpirvLiteral())
|
||||
appendStr(" spirv_literal");
|
||||
appendStr(" ");
|
||||
appendStr(getStorageQualifierString());
|
||||
if (isArray()) {
|
||||
@@ -2382,6 +2471,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) {
|
||||
@@ -2398,10 +2495,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;
|
||||
}
|
||||
}
|
||||
@@ -2453,6 +2550,15 @@ public:
|
||||
(typeParameters != nullptr && right.typeParameters != nullptr && *typeParameters == *right.typeParameters));
|
||||
}
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// See if two type's SPIR-V type contents match
|
||||
bool sameSpirvType(const TType& right) const
|
||||
{
|
||||
return ((spirvType == nullptr && right.spirvType == nullptr) ||
|
||||
(spirvType != nullptr && right.spirvType != nullptr && *spirvType == *right.spirvType));
|
||||
}
|
||||
#endif
|
||||
|
||||
// See if two type's elements match in all ways except basic type
|
||||
bool sameElementShape(const TType& right) const
|
||||
{
|
||||
@@ -2491,7 +2597,11 @@ public:
|
||||
// See if two types match in all ways (just the actual type, not qualification)
|
||||
bool operator==(const TType& right) const
|
||||
{
|
||||
#ifndef GLSLANG_WEB
|
||||
return sameElementType(right) && sameArrayness(right) && sameTypeParameters(right) && sameSpirvType(right);
|
||||
#else
|
||||
return sameElementType(right) && sameArrayness(right) && sameTypeParameters(right);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool operator!=(const TType& right) const
|
||||
@@ -2510,6 +2620,10 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
const TSpirvType& getSpirvType() const { assert(spirvType); return *spirvType; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// Require consumer to pick between deep copy and shallow copy.
|
||||
TType(const TType& type);
|
||||
@@ -2522,6 +2636,19 @@ protected:
|
||||
{
|
||||
shallowCopy(copyOf);
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// GL_EXT_spirv_intrinsics
|
||||
if (copyOf.qualifier.spirvDecorate) {
|
||||
qualifier.spirvDecorate = new TSpirvDecorate;
|
||||
*qualifier.spirvDecorate = *copyOf.qualifier.spirvDecorate;
|
||||
}
|
||||
|
||||
if (copyOf.spirvType) {
|
||||
spirvType = new TSpirvType;
|
||||
*spirvType = *copyOf.spirvType;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (copyOf.arraySizes) {
|
||||
arraySizes = new TArraySizes;
|
||||
*arraySizes = *copyOf.arraySizes;
|
||||
@@ -2581,6 +2708,9 @@ protected:
|
||||
TString *typeName; // for structure type name
|
||||
TSampler sampler;
|
||||
TArraySizes* typeParameters;// nullptr unless a parameterized type; can be shared across types
|
||||
#ifndef GLSLANG_WEB
|
||||
TSpirvType* spirvType; // SPIR-V type defined by spirv_type directive
|
||||
#endif
|
||||
};
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
@@ -224,6 +224,9 @@ GLSLANG_EXPORT void glslang_finalize_process();
|
||||
|
||||
GLSLANG_EXPORT glslang_shader_t* glslang_shader_create(const glslang_input_t* input);
|
||||
GLSLANG_EXPORT void glslang_shader_delete(glslang_shader_t* shader);
|
||||
GLSLANG_EXPORT void glslang_shader_shift_binding(glslang_shader_t* shader, glslang_resource_type_t res, unsigned int base);
|
||||
GLSLANG_EXPORT void glslang_shader_shift_binding_for_set(glslang_shader_t* shader, glslang_resource_type_t res, unsigned int base, unsigned int set);
|
||||
GLSLANG_EXPORT void glslang_shader_set_options(glslang_shader_t* shader, int options); // glslang_shader_options_t
|
||||
GLSLANG_EXPORT int glslang_shader_preprocess(glslang_shader_t* shader, const glslang_input_t* input);
|
||||
GLSLANG_EXPORT int glslang_shader_parse(glslang_shader_t* shader, const glslang_input_t* input);
|
||||
GLSLANG_EXPORT const char* glslang_shader_get_preprocessed_code(glslang_shader_t* shader);
|
||||
@@ -234,6 +237,7 @@ GLSLANG_EXPORT glslang_program_t* glslang_program_create();
|
||||
GLSLANG_EXPORT void glslang_program_delete(glslang_program_t* program);
|
||||
GLSLANG_EXPORT void glslang_program_add_shader(glslang_program_t* program, glslang_shader_t* shader);
|
||||
GLSLANG_EXPORT int glslang_program_link(glslang_program_t* program, int messages); // glslang_messages_t
|
||||
GLSLANG_EXPORT int glslang_program_map_io(glslang_program_t* program);
|
||||
GLSLANG_EXPORT void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage);
|
||||
GLSLANG_EXPORT size_t glslang_program_SPIRV_get_size(glslang_program_t* program);
|
||||
GLSLANG_EXPORT void glslang_program_SPIRV_get(glslang_program_t* program, unsigned int*);
|
||||
|
||||
@@ -113,7 +113,8 @@ typedef enum {
|
||||
GLSLANG_TARGET_SPV_1_3 = (1 << 16) | (3 << 8),
|
||||
GLSLANG_TARGET_SPV_1_4 = (1 << 16) | (4 << 8),
|
||||
GLSLANG_TARGET_SPV_1_5 = (1 << 16) | (5 << 8),
|
||||
LAST_ELEMENT_MARKER(GLSLANG_TARGET_LANGUAGE_VERSION_COUNT = 6),
|
||||
GLSLANG_TARGET_SPV_1_6 = (1 << 16) | (6 << 8),
|
||||
LAST_ELEMENT_MARKER(GLSLANG_TARGET_LANGUAGE_VERSION_COUNT = 7),
|
||||
} glslang_target_language_version_t;
|
||||
|
||||
/* EShExecutable counterpart */
|
||||
@@ -181,6 +182,26 @@ typedef enum {
|
||||
LAST_ELEMENT_MARKER(GLSLANG_PROFILE_COUNT),
|
||||
} glslang_profile_t;
|
||||
|
||||
/* Shader options */
|
||||
typedef enum {
|
||||
GLSLANG_SHADER_DEFAULT_BIT = 0,
|
||||
GLSLANG_SHADER_AUTO_MAP_BINDINGS = (1 << 0),
|
||||
GLSLANG_SHADER_AUTO_MAP_LOCATIONS = (1 << 1),
|
||||
GLSLANG_SHADER_VULKAN_RULES_RELAXED = (1 << 2),
|
||||
LAST_ELEMENT_MARKER(GLSLANG_SHADER_COUNT),
|
||||
} glslang_shader_options_t;
|
||||
|
||||
/* TResourceType counterpart */
|
||||
typedef enum {
|
||||
GLSLANG_RESOURCE_TYPE_SAMPLER,
|
||||
GLSLANG_RESOURCE_TYPE_TEXTURE,
|
||||
GLSLANG_RESOURCE_TYPE_IMAGE,
|
||||
GLSLANG_RESOURCE_TYPE_UBO,
|
||||
GLSLANG_RESOURCE_TYPE_SSBO,
|
||||
GLSLANG_RESOURCE_TYPE_UAV,
|
||||
LAST_ELEMENT_MARKER(GLSLANG_RESOURCE_TYPE_COUNT),
|
||||
} glslang_resource_type_t;
|
||||
|
||||
#undef LAST_ELEMENT_MARKER
|
||||
|
||||
#endif
|
||||
|
||||
@@ -71,6 +71,9 @@ enum TOperator {
|
||||
EOpFunctionCall,
|
||||
EOpFunction, // For function definition
|
||||
EOpParameters, // an aggregate listing the parameters to a function
|
||||
#ifndef GLSLANG_WEB
|
||||
EOpSpirvInst,
|
||||
#endif
|
||||
|
||||
//
|
||||
// Unary operators
|
||||
@@ -923,6 +926,7 @@ enum TOperator {
|
||||
EOpMul32x16,
|
||||
|
||||
EOpTraceNV,
|
||||
EOpTraceRayMotionNV,
|
||||
EOpTraceKHR,
|
||||
EOpReportIntersection,
|
||||
EOpIgnoreIntersectionNV,
|
||||
@@ -1616,8 +1620,15 @@ public:
|
||||
virtual TIntermUnary* getAsUnaryNode() { return this; }
|
||||
virtual const TIntermUnary* getAsUnaryNode() const { return this; }
|
||||
virtual void updatePrecision();
|
||||
#ifndef GLSLANG_WEB
|
||||
void setSpirvInstruction(const TSpirvInstruction& inst) { spirvInst = inst; }
|
||||
const TSpirvInstruction& getSpirvInstruction() const { return spirvInst; }
|
||||
#endif
|
||||
protected:
|
||||
TIntermTyped* operand;
|
||||
#ifndef GLSLANG_WEB
|
||||
TSpirvInstruction spirvInst;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef TVector<TIntermNode*> TIntermSequence;
|
||||
@@ -1632,6 +1643,7 @@ public:
|
||||
~TIntermAggregate() { delete pragmaTable; }
|
||||
virtual TIntermAggregate* getAsAggregate() { return this; }
|
||||
virtual const TIntermAggregate* getAsAggregate() const { return this; }
|
||||
virtual void updatePrecision();
|
||||
virtual void setOperator(TOperator o) { op = o; }
|
||||
virtual TIntermSequence& getSequence() { return sequence; }
|
||||
virtual const TIntermSequence& getSequence() const { return sequence; }
|
||||
@@ -1648,6 +1660,10 @@ public:
|
||||
bool getDebug() const { return debug; }
|
||||
void setPragmaTable(const TPragmaTable& pTable);
|
||||
const TPragmaTable& getPragmaTable() const { return *pragmaTable; }
|
||||
#ifndef GLSLANG_WEB
|
||||
void setSpirvInstruction(const TSpirvInstruction& inst) { spirvInst = inst; }
|
||||
const TSpirvInstruction& getSpirvInstruction() const { return spirvInst; }
|
||||
#endif
|
||||
protected:
|
||||
TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
|
||||
TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
|
||||
@@ -1658,6 +1674,9 @@ protected:
|
||||
bool optimize;
|
||||
bool debug;
|
||||
TPragmaTable* pragmaTable;
|
||||
#ifndef GLSLANG_WEB
|
||||
TSpirvInstruction spirvInst;
|
||||
#endif
|
||||
};
|
||||
|
||||
//
|
||||
@@ -1675,8 +1694,11 @@ public:
|
||||
flatten(false), dontFlatten(false) {}
|
||||
virtual void traverse(TIntermTraverser*);
|
||||
virtual TIntermTyped* getCondition() const { return condition; }
|
||||
virtual void setCondition(TIntermTyped* c) { condition = c; }
|
||||
virtual TIntermNode* getTrueBlock() const { return trueBlock; }
|
||||
virtual void setTrueBlock(TIntermTyped* tb) { trueBlock = tb; }
|
||||
virtual TIntermNode* getFalseBlock() const { return falseBlock; }
|
||||
virtual void setFalseBlock(TIntermTyped* fb) { falseBlock = fb; }
|
||||
virtual TIntermSelection* getAsSelectionNode() { return this; }
|
||||
virtual const TIntermSelection* getAsSelectionNode() const { return this; }
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// This header is generated by the make-revision script.
|
||||
|
||||
#define GLSLANG_PATCH_LEVEL 3766
|
||||
@@ -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
|
||||
@@ -529,7 +500,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
|
||||
case EbtDouble:
|
||||
case EbtFloat16:
|
||||
case EbtFloat: newConstArray[i].setDConst(-unionArray[i].getDConst()); break;
|
||||
case EbtInt: newConstArray[i].setIConst(-unionArray[i].getIConst()); break;
|
||||
// Note: avoid UBSAN error regarding negating 0x80000000
|
||||
case EbtInt: newConstArray[i].setIConst(
|
||||
static_cast<unsigned int>(unionArray[i].getIConst()) == 0x80000000
|
||||
? -0x7FFFFFFF - 1
|
||||
: -unionArray[i].getIConst());
|
||||
break;
|
||||
case EbtUint: newConstArray[i].setUConst(static_cast<unsigned int>(-static_cast<int>(unionArray[i].getUConst()))); break;
|
||||
#ifndef GLSLANG_WEB
|
||||
case EbtInt8: newConstArray[i].setI8Const(-unionArray[i].getI8Const()); break;
|
||||
@@ -658,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2012-2016 LunarG, Inc.
|
||||
// Copyright (C) 2015-2020 Google, Inc.
|
||||
// Copyright (C) 2017 ARM Limited.
|
||||
// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Modifications Copyright (C) 2020-2021 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
@@ -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 },
|
||||
@@ -483,7 +484,8 @@ void TBuiltIns::relateTabledBuiltins(int /* version */, EProfile /* profile */,
|
||||
|
||||
inline bool IncludeLegacy(int version, EProfile profile, const SpvVersion& spvVersion)
|
||||
{
|
||||
return profile != EEsProfile && (version <= 130 || (spvVersion.spv == 0 && ARBCompatibility) || profile == ECompatibilityProfile);
|
||||
return profile != EEsProfile && (version <= 130 || (spvVersion.spv == 0 && version == 140 && ARBCompatibility) ||
|
||||
profile == ECompatibilityProfile);
|
||||
}
|
||||
|
||||
// Construct TBuiltInParseables base class. This can be used for language-common constructs.
|
||||
@@ -931,7 +933,203 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"\n");
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
if (profile == EEsProfile && version >= 310) { // Explicit Types
|
||||
commonBuiltins.append(
|
||||
|
||||
"float64_t sqrt(float64_t);"
|
||||
"f64vec2 sqrt(f64vec2);"
|
||||
"f64vec3 sqrt(f64vec3);"
|
||||
"f64vec4 sqrt(f64vec4);"
|
||||
|
||||
"float64_t inversesqrt(float64_t);"
|
||||
"f64vec2 inversesqrt(f64vec2);"
|
||||
"f64vec3 inversesqrt(f64vec3);"
|
||||
"f64vec4 inversesqrt(f64vec4);"
|
||||
|
||||
"float64_t abs(float64_t);"
|
||||
"f64vec2 abs(f64vec2);"
|
||||
"f64vec3 abs(f64vec3);"
|
||||
"f64vec4 abs(f64vec4);"
|
||||
|
||||
"float64_t sign(float64_t);"
|
||||
"f64vec2 sign(f64vec2);"
|
||||
"f64vec3 sign(f64vec3);"
|
||||
"f64vec4 sign(f64vec4);"
|
||||
|
||||
"float64_t floor(float64_t);"
|
||||
"f64vec2 floor(f64vec2);"
|
||||
"f64vec3 floor(f64vec3);"
|
||||
"f64vec4 floor(f64vec4);"
|
||||
|
||||
"float64_t trunc(float64_t);"
|
||||
"f64vec2 trunc(f64vec2);"
|
||||
"f64vec3 trunc(f64vec3);"
|
||||
"f64vec4 trunc(f64vec4);"
|
||||
|
||||
"float64_t round(float64_t);"
|
||||
"f64vec2 round(f64vec2);"
|
||||
"f64vec3 round(f64vec3);"
|
||||
"f64vec4 round(f64vec4);"
|
||||
|
||||
"float64_t roundEven(float64_t);"
|
||||
"f64vec2 roundEven(f64vec2);"
|
||||
"f64vec3 roundEven(f64vec3);"
|
||||
"f64vec4 roundEven(f64vec4);"
|
||||
|
||||
"float64_t ceil(float64_t);"
|
||||
"f64vec2 ceil(f64vec2);"
|
||||
"f64vec3 ceil(f64vec3);"
|
||||
"f64vec4 ceil(f64vec4);"
|
||||
|
||||
"float64_t fract(float64_t);"
|
||||
"f64vec2 fract(f64vec2);"
|
||||
"f64vec3 fract(f64vec3);"
|
||||
"f64vec4 fract(f64vec4);"
|
||||
|
||||
"float64_t mod(float64_t, float64_t);"
|
||||
"f64vec2 mod(f64vec2 , float64_t);"
|
||||
"f64vec3 mod(f64vec3 , float64_t);"
|
||||
"f64vec4 mod(f64vec4 , float64_t);"
|
||||
"f64vec2 mod(f64vec2 , f64vec2);"
|
||||
"f64vec3 mod(f64vec3 , f64vec3);"
|
||||
"f64vec4 mod(f64vec4 , f64vec4);"
|
||||
|
||||
"float64_t modf(float64_t, out float64_t);"
|
||||
"f64vec2 modf(f64vec2, out f64vec2);"
|
||||
"f64vec3 modf(f64vec3, out f64vec3);"
|
||||
"f64vec4 modf(f64vec4, out f64vec4);"
|
||||
|
||||
"float64_t min(float64_t, float64_t);"
|
||||
"f64vec2 min(f64vec2, float64_t);"
|
||||
"f64vec3 min(f64vec3, float64_t);"
|
||||
"f64vec4 min(f64vec4, float64_t);"
|
||||
"f64vec2 min(f64vec2, f64vec2);"
|
||||
"f64vec3 min(f64vec3, f64vec3);"
|
||||
"f64vec4 min(f64vec4, f64vec4);"
|
||||
|
||||
"float64_t max(float64_t, float64_t);"
|
||||
"f64vec2 max(f64vec2 , float64_t);"
|
||||
"f64vec3 max(f64vec3 , float64_t);"
|
||||
"f64vec4 max(f64vec4 , float64_t);"
|
||||
"f64vec2 max(f64vec2 , f64vec2);"
|
||||
"f64vec3 max(f64vec3 , f64vec3);"
|
||||
"f64vec4 max(f64vec4 , f64vec4);"
|
||||
|
||||
"float64_t clamp(float64_t, float64_t, float64_t);"
|
||||
"f64vec2 clamp(f64vec2 , float64_t, float64_t);"
|
||||
"f64vec3 clamp(f64vec3 , float64_t, float64_t);"
|
||||
"f64vec4 clamp(f64vec4 , float64_t, float64_t);"
|
||||
"f64vec2 clamp(f64vec2 , f64vec2 , f64vec2);"
|
||||
"f64vec3 clamp(f64vec3 , f64vec3 , f64vec3);"
|
||||
"f64vec4 clamp(f64vec4 , f64vec4 , f64vec4);"
|
||||
|
||||
"float64_t mix(float64_t, float64_t, float64_t);"
|
||||
"f64vec2 mix(f64vec2, f64vec2, float64_t);"
|
||||
"f64vec3 mix(f64vec3, f64vec3, float64_t);"
|
||||
"f64vec4 mix(f64vec4, f64vec4, float64_t);"
|
||||
"f64vec2 mix(f64vec2, f64vec2, f64vec2);"
|
||||
"f64vec3 mix(f64vec3, f64vec3, f64vec3);"
|
||||
"f64vec4 mix(f64vec4, f64vec4, f64vec4);"
|
||||
"float64_t mix(float64_t, float64_t, bool);"
|
||||
"f64vec2 mix(f64vec2, f64vec2, bvec2);"
|
||||
"f64vec3 mix(f64vec3, f64vec3, bvec3);"
|
||||
"f64vec4 mix(f64vec4, f64vec4, bvec4);"
|
||||
|
||||
"float64_t step(float64_t, float64_t);"
|
||||
"f64vec2 step(f64vec2 , f64vec2);"
|
||||
"f64vec3 step(f64vec3 , f64vec3);"
|
||||
"f64vec4 step(f64vec4 , f64vec4);"
|
||||
"f64vec2 step(float64_t, f64vec2);"
|
||||
"f64vec3 step(float64_t, f64vec3);"
|
||||
"f64vec4 step(float64_t, f64vec4);"
|
||||
|
||||
"float64_t smoothstep(float64_t, float64_t, float64_t);"
|
||||
"f64vec2 smoothstep(f64vec2 , f64vec2 , f64vec2);"
|
||||
"f64vec3 smoothstep(f64vec3 , f64vec3 , f64vec3);"
|
||||
"f64vec4 smoothstep(f64vec4 , f64vec4 , f64vec4);"
|
||||
"f64vec2 smoothstep(float64_t, float64_t, f64vec2);"
|
||||
"f64vec3 smoothstep(float64_t, float64_t, f64vec3);"
|
||||
"f64vec4 smoothstep(float64_t, float64_t, f64vec4);"
|
||||
|
||||
"float64_t length(float64_t);"
|
||||
"float64_t length(f64vec2);"
|
||||
"float64_t length(f64vec3);"
|
||||
"float64_t length(f64vec4);"
|
||||
|
||||
"float64_t distance(float64_t, float64_t);"
|
||||
"float64_t distance(f64vec2 , f64vec2);"
|
||||
"float64_t distance(f64vec3 , f64vec3);"
|
||||
"float64_t distance(f64vec4 , f64vec4);"
|
||||
|
||||
"float64_t dot(float64_t, float64_t);"
|
||||
"float64_t dot(f64vec2 , f64vec2);"
|
||||
"float64_t dot(f64vec3 , f64vec3);"
|
||||
"float64_t dot(f64vec4 , f64vec4);"
|
||||
|
||||
"f64vec3 cross(f64vec3, f64vec3);"
|
||||
|
||||
"float64_t normalize(float64_t);"
|
||||
"f64vec2 normalize(f64vec2);"
|
||||
"f64vec3 normalize(f64vec3);"
|
||||
"f64vec4 normalize(f64vec4);"
|
||||
|
||||
"float64_t faceforward(float64_t, float64_t, float64_t);"
|
||||
"f64vec2 faceforward(f64vec2, f64vec2, f64vec2);"
|
||||
"f64vec3 faceforward(f64vec3, f64vec3, f64vec3);"
|
||||
"f64vec4 faceforward(f64vec4, f64vec4, f64vec4);"
|
||||
|
||||
"float64_t reflect(float64_t, float64_t);"
|
||||
"f64vec2 reflect(f64vec2 , f64vec2 );"
|
||||
"f64vec3 reflect(f64vec3 , f64vec3 );"
|
||||
"f64vec4 reflect(f64vec4 , f64vec4 );"
|
||||
|
||||
"float64_t refract(float64_t, float64_t, float64_t);"
|
||||
"f64vec2 refract(f64vec2 , f64vec2 , float64_t);"
|
||||
"f64vec3 refract(f64vec3 , f64vec3 , float64_t);"
|
||||
"f64vec4 refract(f64vec4 , f64vec4 , float64_t);"
|
||||
|
||||
"f64mat2 matrixCompMult(f64mat2, f64mat2);"
|
||||
"f64mat3 matrixCompMult(f64mat3, f64mat3);"
|
||||
"f64mat4 matrixCompMult(f64mat4, f64mat4);"
|
||||
"f64mat2x3 matrixCompMult(f64mat2x3, f64mat2x3);"
|
||||
"f64mat2x4 matrixCompMult(f64mat2x4, f64mat2x4);"
|
||||
"f64mat3x2 matrixCompMult(f64mat3x2, f64mat3x2);"
|
||||
"f64mat3x4 matrixCompMult(f64mat3x4, f64mat3x4);"
|
||||
"f64mat4x2 matrixCompMult(f64mat4x2, f64mat4x2);"
|
||||
"f64mat4x3 matrixCompMult(f64mat4x3, f64mat4x3);"
|
||||
|
||||
"f64mat2 outerProduct(f64vec2, f64vec2);"
|
||||
"f64mat3 outerProduct(f64vec3, f64vec3);"
|
||||
"f64mat4 outerProduct(f64vec4, f64vec4);"
|
||||
"f64mat2x3 outerProduct(f64vec3, f64vec2);"
|
||||
"f64mat3x2 outerProduct(f64vec2, f64vec3);"
|
||||
"f64mat2x4 outerProduct(f64vec4, f64vec2);"
|
||||
"f64mat4x2 outerProduct(f64vec2, f64vec4);"
|
||||
"f64mat3x4 outerProduct(f64vec4, f64vec3);"
|
||||
"f64mat4x3 outerProduct(f64vec3, f64vec4);"
|
||||
|
||||
"f64mat2 transpose(f64mat2);"
|
||||
"f64mat3 transpose(f64mat3);"
|
||||
"f64mat4 transpose(f64mat4);"
|
||||
"f64mat2x3 transpose(f64mat3x2);"
|
||||
"f64mat3x2 transpose(f64mat2x3);"
|
||||
"f64mat2x4 transpose(f64mat4x2);"
|
||||
"f64mat4x2 transpose(f64mat2x4);"
|
||||
"f64mat3x4 transpose(f64mat4x3);"
|
||||
"f64mat4x3 transpose(f64mat3x4);"
|
||||
|
||||
"float64_t determinant(f64mat2);"
|
||||
"float64_t determinant(f64mat3);"
|
||||
"float64_t determinant(f64mat4);"
|
||||
|
||||
"f64mat2 inverse(f64mat2);"
|
||||
"f64mat3 inverse(f64mat3);"
|
||||
"f64mat4 inverse(f64mat4);"
|
||||
|
||||
"\n");
|
||||
}
|
||||
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
|
||||
commonBuiltins.append(
|
||||
|
||||
"int64_t abs(int64_t);"
|
||||
@@ -998,25 +1196,25 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"u64vec3 mix(u64vec3, u64vec3, bvec3);"
|
||||
"u64vec4 mix(u64vec4, u64vec4, bvec4);"
|
||||
|
||||
"int64_t doubleBitsToInt64(double);"
|
||||
"i64vec2 doubleBitsToInt64(dvec2);"
|
||||
"i64vec3 doubleBitsToInt64(dvec3);"
|
||||
"i64vec4 doubleBitsToInt64(dvec4);"
|
||||
"int64_t doubleBitsToInt64(float64_t);"
|
||||
"i64vec2 doubleBitsToInt64(f64vec2);"
|
||||
"i64vec3 doubleBitsToInt64(f64vec3);"
|
||||
"i64vec4 doubleBitsToInt64(f64vec4);"
|
||||
|
||||
"uint64_t doubleBitsToUint64(double);"
|
||||
"u64vec2 doubleBitsToUint64(dvec2);"
|
||||
"u64vec3 doubleBitsToUint64(dvec3);"
|
||||
"u64vec4 doubleBitsToUint64(dvec4);"
|
||||
"uint64_t doubleBitsToUint64(float64_t);"
|
||||
"u64vec2 doubleBitsToUint64(f64vec2);"
|
||||
"u64vec3 doubleBitsToUint64(f64vec3);"
|
||||
"u64vec4 doubleBitsToUint64(f64vec4);"
|
||||
|
||||
"double int64BitsToDouble(int64_t);"
|
||||
"dvec2 int64BitsToDouble(i64vec2);"
|
||||
"dvec3 int64BitsToDouble(i64vec3);"
|
||||
"dvec4 int64BitsToDouble(i64vec4);"
|
||||
"float64_t int64BitsToDouble(int64_t);"
|
||||
"f64vec2 int64BitsToDouble(i64vec2);"
|
||||
"f64vec3 int64BitsToDouble(i64vec3);"
|
||||
"f64vec4 int64BitsToDouble(i64vec4);"
|
||||
|
||||
"double uint64BitsToDouble(uint64_t);"
|
||||
"dvec2 uint64BitsToDouble(u64vec2);"
|
||||
"dvec3 uint64BitsToDouble(u64vec3);"
|
||||
"dvec4 uint64BitsToDouble(u64vec4);"
|
||||
"float64_t uint64BitsToDouble(uint64_t);"
|
||||
"f64vec2 uint64BitsToDouble(u64vec2);"
|
||||
"f64vec3 uint64BitsToDouble(u64vec3);"
|
||||
"f64vec4 uint64BitsToDouble(u64vec4);"
|
||||
|
||||
"int64_t packInt2x32(ivec2);"
|
||||
"uint64_t packUint2x32(uvec2);"
|
||||
@@ -1065,6 +1263,16 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"bvec3 notEqual(u64vec3, u64vec3);"
|
||||
"bvec4 notEqual(u64vec4, u64vec4);"
|
||||
|
||||
"int64_t bitCount(int64_t);"
|
||||
"i64vec2 bitCount(i64vec2);"
|
||||
"i64vec3 bitCount(i64vec3);"
|
||||
"i64vec4 bitCount(i64vec4);"
|
||||
|
||||
"int64_t bitCount(uint64_t);"
|
||||
"i64vec2 bitCount(u64vec2);"
|
||||
"i64vec3 bitCount(u64vec3);"
|
||||
"i64vec4 bitCount(u64vec4);"
|
||||
|
||||
"int64_t findLSB(int64_t);"
|
||||
"i64vec2 findLSB(i64vec2);"
|
||||
"i64vec3 findLSB(i64vec3);"
|
||||
@@ -1230,11 +1438,23 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
" int64_t atomicMin(coherent volatile inout int64_t, int64_t);"
|
||||
"uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t, int, int, int);"
|
||||
" int64_t atomicMin(coherent volatile inout int64_t, int64_t, int, int, int);"
|
||||
"float16_t atomicMin(coherent volatile inout float16_t, float16_t);"
|
||||
"float16_t atomicMin(coherent volatile inout float16_t, float16_t, int, int, int);"
|
||||
" float atomicMin(coherent volatile inout float, float);"
|
||||
" float atomicMin(coherent volatile inout float, float, int, int, int);"
|
||||
" double atomicMin(coherent volatile inout double, double);"
|
||||
" double atomicMin(coherent volatile inout double, double, int, int, int);"
|
||||
|
||||
"uint64_t atomicMax(coherent volatile inout uint64_t, uint64_t);"
|
||||
" int64_t atomicMax(coherent volatile inout int64_t, int64_t);"
|
||||
"uint64_t atomicMax(coherent volatile inout uint64_t, uint64_t, int, int, int);"
|
||||
" int64_t atomicMax(coherent volatile inout int64_t, int64_t, int, int, int);"
|
||||
"float16_t atomicMax(coherent volatile inout float16_t, float16_t);"
|
||||
"float16_t atomicMax(coherent volatile inout float16_t, float16_t, int, int, int);"
|
||||
" float atomicMax(coherent volatile inout float, float);"
|
||||
" float atomicMax(coherent volatile inout float, float, int, int, int);"
|
||||
" double atomicMax(coherent volatile inout double, double);"
|
||||
" double atomicMax(coherent volatile inout double, double, int, int, int);"
|
||||
|
||||
"uint64_t atomicAnd(coherent volatile inout uint64_t, uint64_t);"
|
||||
" int64_t atomicAnd(coherent volatile inout int64_t, int64_t);"
|
||||
@@ -1255,6 +1475,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
" int64_t atomicAdd(coherent volatile inout int64_t, int64_t);"
|
||||
"uint64_t atomicAdd(coherent volatile inout uint64_t, uint64_t, int, int, int);"
|
||||
" int64_t atomicAdd(coherent volatile inout int64_t, int64_t, int, int, int);"
|
||||
"float16_t atomicAdd(coherent volatile inout float16_t, float16_t);"
|
||||
"float16_t atomicAdd(coherent volatile inout float16_t, float16_t, int, int, int);"
|
||||
" float atomicAdd(coherent volatile inout float, float);"
|
||||
" float atomicAdd(coherent volatile inout float, float, int, int, int);"
|
||||
" double atomicAdd(coherent volatile inout double, double);"
|
||||
@@ -1264,6 +1486,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
" int64_t atomicExchange(coherent volatile inout int64_t, int64_t);"
|
||||
"uint64_t atomicExchange(coherent volatile inout uint64_t, uint64_t, int, int, int);"
|
||||
" int64_t atomicExchange(coherent volatile inout int64_t, int64_t, int, int, int);"
|
||||
"float16_t atomicExchange(coherent volatile inout float16_t, float16_t);"
|
||||
"float16_t atomicExchange(coherent volatile inout float16_t, float16_t, int, int, int);"
|
||||
" float atomicExchange(coherent volatile inout float, float);"
|
||||
" float atomicExchange(coherent volatile inout float, float, int, int, int);"
|
||||
" double atomicExchange(coherent volatile inout double, double);"
|
||||
@@ -1276,11 +1500,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
|
||||
"uint64_t atomicLoad(coherent volatile in uint64_t, int, int, int);"
|
||||
" int64_t atomicLoad(coherent volatile in int64_t, int, int, int);"
|
||||
"float16_t atomicLoad(coherent volatile in float16_t, int, int, int);"
|
||||
" float atomicLoad(coherent volatile in float, int, int, int);"
|
||||
" double atomicLoad(coherent volatile in double, int, int, int);"
|
||||
|
||||
"void atomicStore(coherent volatile out uint64_t, uint64_t, int, int, int);"
|
||||
"void atomicStore(coherent volatile out int64_t, int64_t, int, int, int);"
|
||||
"void atomicStore(coherent volatile out float16_t, float16_t, int, int, int);"
|
||||
"void atomicStore(coherent volatile out float, float, int, int, int);"
|
||||
"void atomicStore(coherent volatile out double, double, int, int, int);"
|
||||
"\n");
|
||||
@@ -1335,6 +1561,15 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"dvec4 fma(dvec4, dvec4, dvec4 );"
|
||||
"\n");
|
||||
}
|
||||
|
||||
if (profile == EEsProfile && version >= 310) { // ARB_gpu_shader_fp64
|
||||
commonBuiltins.append(
|
||||
"float64_t fma(float64_t, float64_t, float64_t);"
|
||||
"f64vec2 fma(f64vec2, f64vec2, f64vec2 );"
|
||||
"f64vec3 fma(f64vec3, f64vec3, f64vec3 );"
|
||||
"f64vec4 fma(f64vec4, f64vec4, f64vec4 );"
|
||||
"\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((profile == EEsProfile && version >= 310) ||
|
||||
@@ -1371,6 +1606,21 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
|
||||
"\n");
|
||||
}
|
||||
|
||||
if (profile == EEsProfile && version >= 310) { // ARB_gpu_shader_fp64
|
||||
commonBuiltins.append(
|
||||
"float64_t frexp(float64_t, out int);"
|
||||
"f64vec2 frexp( f64vec2, out ivec2);"
|
||||
"f64vec3 frexp( f64vec3, out ivec3);"
|
||||
"f64vec4 frexp( f64vec4, out ivec4);"
|
||||
|
||||
"float64_t ldexp(float64_t, int);"
|
||||
"f64vec2 ldexp( f64vec2, ivec2);"
|
||||
"f64vec3 ldexp( f64vec3, ivec3);"
|
||||
"f64vec4 ldexp( f64vec4, ivec4);"
|
||||
|
||||
"\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1621,6 +1871,22 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
|
||||
"\n");
|
||||
}
|
||||
if (profile != EEsProfile && version == 450) {
|
||||
commonBuiltins.append(
|
||||
"uint atomicCounterAddARB(atomic_uint, uint);"
|
||||
"uint atomicCounterSubtractARB(atomic_uint, uint);"
|
||||
"uint atomicCounterMinARB(atomic_uint, uint);"
|
||||
"uint atomicCounterMaxARB(atomic_uint, uint);"
|
||||
"uint atomicCounterAndARB(atomic_uint, uint);"
|
||||
"uint atomicCounterOrARB(atomic_uint, uint);"
|
||||
"uint atomicCounterXorARB(atomic_uint, uint);"
|
||||
"uint atomicCounterExchangeARB(atomic_uint, uint);"
|
||||
"uint atomicCounterCompSwapARB(atomic_uint, uint, uint);"
|
||||
|
||||
"\n");
|
||||
}
|
||||
|
||||
|
||||
if (profile != EEsProfile && version >= 460) {
|
||||
commonBuiltins.append(
|
||||
"uint atomicCounterAdd(atomic_uint, uint);"
|
||||
@@ -3152,7 +3418,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
|
||||
#ifndef GLSLANG_ANGLE
|
||||
// GL_AMD_gpu_shader_half_float/Explicit types
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
|
||||
commonBuiltins.append(
|
||||
"float16_t radians(float16_t);"
|
||||
"f16vec2 radians(f16vec2);"
|
||||
@@ -3500,7 +3766,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
}
|
||||
|
||||
// Explicit types
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
|
||||
commonBuiltins.append(
|
||||
"int8_t abs(int8_t);"
|
||||
"i8vec2 abs(i8vec2);"
|
||||
@@ -3900,106 +4166,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"u16vec4 unpack16(uint64_t);"
|
||||
"i32vec2 unpack32(int64_t);"
|
||||
"u32vec2 unpack32(uint64_t);"
|
||||
|
||||
"float64_t radians(float64_t);"
|
||||
"f64vec2 radians(f64vec2);"
|
||||
"f64vec3 radians(f64vec3);"
|
||||
"f64vec4 radians(f64vec4);"
|
||||
|
||||
"float64_t degrees(float64_t);"
|
||||
"f64vec2 degrees(f64vec2);"
|
||||
"f64vec3 degrees(f64vec3);"
|
||||
"f64vec4 degrees(f64vec4);"
|
||||
|
||||
"float64_t sin(float64_t);"
|
||||
"f64vec2 sin(f64vec2);"
|
||||
"f64vec3 sin(f64vec3);"
|
||||
"f64vec4 sin(f64vec4);"
|
||||
|
||||
"float64_t cos(float64_t);"
|
||||
"f64vec2 cos(f64vec2);"
|
||||
"f64vec3 cos(f64vec3);"
|
||||
"f64vec4 cos(f64vec4);"
|
||||
|
||||
"float64_t tan(float64_t);"
|
||||
"f64vec2 tan(f64vec2);"
|
||||
"f64vec3 tan(f64vec3);"
|
||||
"f64vec4 tan(f64vec4);"
|
||||
|
||||
"float64_t asin(float64_t);"
|
||||
"f64vec2 asin(f64vec2);"
|
||||
"f64vec3 asin(f64vec3);"
|
||||
"f64vec4 asin(f64vec4);"
|
||||
|
||||
"float64_t acos(float64_t);"
|
||||
"f64vec2 acos(f64vec2);"
|
||||
"f64vec3 acos(f64vec3);"
|
||||
"f64vec4 acos(f64vec4);"
|
||||
|
||||
"float64_t atan(float64_t, float64_t);"
|
||||
"f64vec2 atan(f64vec2, f64vec2);"
|
||||
"f64vec3 atan(f64vec3, f64vec3);"
|
||||
"f64vec4 atan(f64vec4, f64vec4);"
|
||||
|
||||
"float64_t atan(float64_t);"
|
||||
"f64vec2 atan(f64vec2);"
|
||||
"f64vec3 atan(f64vec3);"
|
||||
"f64vec4 atan(f64vec4);"
|
||||
|
||||
"float64_t sinh(float64_t);"
|
||||
"f64vec2 sinh(f64vec2);"
|
||||
"f64vec3 sinh(f64vec3);"
|
||||
"f64vec4 sinh(f64vec4);"
|
||||
|
||||
"float64_t cosh(float64_t);"
|
||||
"f64vec2 cosh(f64vec2);"
|
||||
"f64vec3 cosh(f64vec3);"
|
||||
"f64vec4 cosh(f64vec4);"
|
||||
|
||||
"float64_t tanh(float64_t);"
|
||||
"f64vec2 tanh(f64vec2);"
|
||||
"f64vec3 tanh(f64vec3);"
|
||||
"f64vec4 tanh(f64vec4);"
|
||||
|
||||
"float64_t asinh(float64_t);"
|
||||
"f64vec2 asinh(f64vec2);"
|
||||
"f64vec3 asinh(f64vec3);"
|
||||
"f64vec4 asinh(f64vec4);"
|
||||
|
||||
"float64_t acosh(float64_t);"
|
||||
"f64vec2 acosh(f64vec2);"
|
||||
"f64vec3 acosh(f64vec3);"
|
||||
"f64vec4 acosh(f64vec4);"
|
||||
|
||||
"float64_t atanh(float64_t);"
|
||||
"f64vec2 atanh(f64vec2);"
|
||||
"f64vec3 atanh(f64vec3);"
|
||||
"f64vec4 atanh(f64vec4);"
|
||||
|
||||
"float64_t pow(float64_t, float64_t);"
|
||||
"f64vec2 pow(f64vec2, f64vec2);"
|
||||
"f64vec3 pow(f64vec3, f64vec3);"
|
||||
"f64vec4 pow(f64vec4, f64vec4);"
|
||||
|
||||
"float64_t exp(float64_t);"
|
||||
"f64vec2 exp(f64vec2);"
|
||||
"f64vec3 exp(f64vec3);"
|
||||
"f64vec4 exp(f64vec4);"
|
||||
|
||||
"float64_t log(float64_t);"
|
||||
"f64vec2 log(f64vec2);"
|
||||
"f64vec3 log(f64vec3);"
|
||||
"f64vec4 log(f64vec4);"
|
||||
|
||||
"float64_t exp2(float64_t);"
|
||||
"f64vec2 exp2(f64vec2);"
|
||||
"f64vec3 exp2(f64vec3);"
|
||||
"f64vec4 exp2(f64vec4);"
|
||||
|
||||
"float64_t log2(float64_t);"
|
||||
"f64vec2 log2(f64vec2);"
|
||||
"f64vec3 log2(f64vec3);"
|
||||
"f64vec4 log2(f64vec4);"
|
||||
"\n");
|
||||
}
|
||||
|
||||
@@ -4403,7 +4569,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"\n");
|
||||
}
|
||||
|
||||
// GL_ARB_shader_clock & GL_EXT_shader_realtime_clock
|
||||
// GL_ARB_shader_clock& GL_EXT_shader_realtime_clock
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
commonBuiltins.append(
|
||||
"uvec2 clock2x32ARB();"
|
||||
@@ -4427,7 +4593,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"\n");
|
||||
}
|
||||
|
||||
// Builtins for GL_NV_ray_tracing/GL_EXT_ray_tracing/GL_EXT_ray_query
|
||||
// Builtins for GL_NV_ray_tracing/GL_NV_ray_tracing_motion_blur/GL_EXT_ray_tracing/GL_EXT_ray_query
|
||||
if (profile != EEsProfile && version >= 460) {
|
||||
commonBuiltins.append("void rayQueryInitializeEXT(rayQueryEXT, accelerationStructureEXT, uint, uint, vec3, float, vec3, float);"
|
||||
"void rayQueryTerminateEXT(rayQueryEXT);"
|
||||
@@ -4456,6 +4622,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
|
||||
stageBuiltins[EShLangRayGen].append(
|
||||
"void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
|
||||
"void traceRayMotionNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
|
||||
"void traceRayEXT(accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
|
||||
"void executeCallableNV(uint, int);"
|
||||
"void executeCallableEXT(uint, int);"
|
||||
@@ -4470,12 +4637,14 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"\n");
|
||||
stageBuiltins[EShLangClosestHit].append(
|
||||
"void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
|
||||
"void traceRayMotionNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
|
||||
"void traceRayEXT(accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
|
||||
"void executeCallableNV(uint, int);"
|
||||
"void executeCallableEXT(uint, int);"
|
||||
"\n");
|
||||
stageBuiltins[EShLangMiss].append(
|
||||
"void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
|
||||
"void traceRayMotionNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
|
||||
"void traceRayEXT(accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
|
||||
"void executeCallableNV(uint, int);"
|
||||
"void executeCallableEXT(uint, int);"
|
||||
@@ -4921,9 +5090,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
);
|
||||
}
|
||||
|
||||
if (version >= 450)
|
||||
if (version >= 430)
|
||||
stageBuiltins[EShLangVertex].append(
|
||||
"out int gl_ViewportMask[];" // GL_NV_viewport_array2
|
||||
);
|
||||
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangVertex].append(
|
||||
"out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
|
||||
"out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
|
||||
"out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
|
||||
@@ -5059,9 +5232,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"in int gl_InvocationID;"
|
||||
);
|
||||
|
||||
if (version >= 450)
|
||||
if (version >= 430)
|
||||
stageBuiltins[EShLangGeometry].append(
|
||||
"out int gl_ViewportMask[];" // GL_NV_viewport_array2
|
||||
);
|
||||
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangGeometry].append(
|
||||
"out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
|
||||
"out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
|
||||
"out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
|
||||
@@ -5137,7 +5314,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangTessControl].append(
|
||||
"float gl_CullDistance[];"
|
||||
);
|
||||
if (version >= 430)
|
||||
stageBuiltins[EShLangTessControl].append(
|
||||
"int gl_ViewportMask[];" // GL_NV_viewport_array2
|
||||
);
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangTessControl].append(
|
||||
"vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
|
||||
"int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
|
||||
"vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
|
||||
@@ -5240,9 +5423,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"out int gl_Layer;"
|
||||
"\n");
|
||||
|
||||
if (version >= 450)
|
||||
if (version >= 430)
|
||||
stageBuiltins[EShLangTessEvaluation].append(
|
||||
"out int gl_ViewportMask[];" // GL_NV_viewport_array2
|
||||
);
|
||||
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangTessEvaluation].append(
|
||||
"out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
|
||||
"out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
|
||||
"out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
|
||||
@@ -5684,6 +5871,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"in mat3x4 gl_WorldToObject3x4EXT;"
|
||||
"in uint gl_IncomingRayFlagsNV;"
|
||||
"in uint gl_IncomingRayFlagsEXT;"
|
||||
"in float gl_CurrentRayTimeNV;"
|
||||
"\n";
|
||||
const char *hitDecls =
|
||||
"in uvec3 gl_LaunchIDNV;"
|
||||
@@ -5719,6 +5907,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"in mat3x4 gl_WorldToObject3x4EXT;"
|
||||
"in uint gl_IncomingRayFlagsNV;"
|
||||
"in uint gl_IncomingRayFlagsEXT;"
|
||||
"in float gl_CurrentRayTimeNV;"
|
||||
"\n";
|
||||
const char *missDecls =
|
||||
"in uvec3 gl_LaunchIDNV;"
|
||||
@@ -5737,6 +5926,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"in float gl_RayTmaxEXT;"
|
||||
"in uint gl_IncomingRayFlagsNV;"
|
||||
"in uint gl_IncomingRayFlagsEXT;"
|
||||
"in float gl_CurrentRayTimeNV;"
|
||||
"\n";
|
||||
|
||||
const char *callableDecls =
|
||||
@@ -6073,38 +6263,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");
|
||||
}
|
||||
|
||||
//
|
||||
@@ -6263,6 +6459,24 @@ void TBuiltIns::addImageFunctions(TSampler sampler, const TString& typeName, int
|
||||
commonBuiltins.append(imageParams);
|
||||
commonBuiltins.append(", float");
|
||||
commonBuiltins.append(", int, int, int);\n");
|
||||
|
||||
commonBuiltins.append("float imageAtomicMin(volatile coherent ");
|
||||
commonBuiltins.append(imageParams);
|
||||
commonBuiltins.append(", float);\n");
|
||||
|
||||
commonBuiltins.append("float imageAtomicMin(volatile coherent ");
|
||||
commonBuiltins.append(imageParams);
|
||||
commonBuiltins.append(", float");
|
||||
commonBuiltins.append(", int, int, int);\n");
|
||||
|
||||
commonBuiltins.append("float imageAtomicMax(volatile coherent ");
|
||||
commonBuiltins.append(imageParams);
|
||||
commonBuiltins.append(", float);\n");
|
||||
|
||||
commonBuiltins.append("float imageAtomicMax(volatile coherent ");
|
||||
commonBuiltins.append(imageParams);
|
||||
commonBuiltins.append(", float");
|
||||
commonBuiltins.append(", int, int, int);\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7031,6 +7245,9 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
|
||||
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
|
||||
s.append(builtInConstant);
|
||||
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingVectors = %d;", resources.maxVaryingVectors);
|
||||
s.append(builtInConstant);
|
||||
}
|
||||
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs);
|
||||
@@ -7063,7 +7280,8 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents);
|
||||
s.append(builtInConstant);
|
||||
|
||||
if (version < 150 || ARBCompatibility) {
|
||||
// Moved from just being deprecated into compatibility profile only as of 4.20
|
||||
if (version < 420 || profile == ECompatibilityProfile) {
|
||||
snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats);
|
||||
s.append(builtInConstant);
|
||||
}
|
||||
@@ -7423,6 +7641,11 @@ static void BuiltInVariable(const char* name, TBuiltInVariable builtIn, TSymbolT
|
||||
symQualifier.builtIn = builtIn;
|
||||
}
|
||||
|
||||
static void RetargetVariable(const char* from, const char* to, TSymbolTable& symbolTable)
|
||||
{
|
||||
symbolTable.retargetSymbol(from, to);
|
||||
}
|
||||
|
||||
//
|
||||
// For built-in variables inside a named block.
|
||||
// SpecialQualifier() won't ever go inside a block; their member's qualifier come
|
||||
@@ -7490,8 +7713,8 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
|
||||
if (spvVersion.vulkan > 0 && spvVersion.vulkanRelaxed) {
|
||||
// treat these built-ins as aliases of VertexIndex and InstanceIndex
|
||||
BuiltInVariable("gl_VertexID", EbvVertexIndex, symbolTable);
|
||||
BuiltInVariable("gl_InstanceID", EbvInstanceIndex, symbolTable);
|
||||
RetargetVariable("gl_InstanceID", "gl_InstanceIndex", symbolTable);
|
||||
RetargetVariable("gl_VertexID", "gl_VertexIndex", symbolTable);
|
||||
}
|
||||
|
||||
if (profile != EEsProfile) {
|
||||
@@ -7862,7 +8085,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) {
|
||||
@@ -8026,6 +8249,19 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
symbolTable.setFunctionExtensions("atomicCounter" , 1, &E_GL_ARB_shader_atomic_counters);
|
||||
}
|
||||
|
||||
// E_GL_ARB_shader_atomic_counter_ops
|
||||
if (profile != EEsProfile && version == 450) {
|
||||
symbolTable.setFunctionExtensions("atomicCounterAddARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
|
||||
symbolTable.setFunctionExtensions("atomicCounterSubtractARB", 1, &E_GL_ARB_shader_atomic_counter_ops);
|
||||
symbolTable.setFunctionExtensions("atomicCounterMinARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
|
||||
symbolTable.setFunctionExtensions("atomicCounterMaxARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
|
||||
symbolTable.setFunctionExtensions("atomicCounterAndARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
|
||||
symbolTable.setFunctionExtensions("atomicCounterOrARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
|
||||
symbolTable.setFunctionExtensions("atomicCounterXorARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
|
||||
symbolTable.setFunctionExtensions("atomicCounterExchangeARB", 1, &E_GL_ARB_shader_atomic_counter_ops);
|
||||
symbolTable.setFunctionExtensions("atomicCounterCompSwapARB", 1, &E_GL_ARB_shader_atomic_counter_ops);
|
||||
}
|
||||
|
||||
// E_GL_ARB_derivative_control
|
||||
if (profile != EEsProfile && version < 450) {
|
||||
symbolTable.setFunctionExtensions("dFdxFine", 1, &E_GL_ARB_derivative_control);
|
||||
@@ -8133,7 +8369,7 @@ 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("clockRealtimeEXT", 1, &E_GL_EXT_shader_realtime_clock);
|
||||
symbolTable.setFunctionExtensions("clockRealtime2x32EXT", 1, &E_GL_EXT_shader_realtime_clock);
|
||||
|
||||
if (profile == EEsProfile && version < 320) {
|
||||
@@ -8554,11 +8790,13 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
symbolTable.setVariableExtensions("gl_WorldToObject3x4EXT", 1, &E_GL_EXT_ray_tracing);
|
||||
symbolTable.setVariableExtensions("gl_IncomingRayFlagsNV", 1, &E_GL_NV_ray_tracing);
|
||||
symbolTable.setVariableExtensions("gl_IncomingRayFlagsEXT", 1, &E_GL_EXT_ray_tracing);
|
||||
symbolTable.setVariableExtensions("gl_CurrentRayTimeNV", 1, &E_GL_NV_ray_tracing_motion_blur);
|
||||
|
||||
symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
|
||||
|
||||
|
||||
symbolTable.setFunctionExtensions("traceNV", 1, &E_GL_NV_ray_tracing);
|
||||
symbolTable.setFunctionExtensions("traceRayMotionNV", 1, &E_GL_NV_ray_tracing_motion_blur);
|
||||
symbolTable.setFunctionExtensions("traceRayEXT", 1, &E_GL_EXT_ray_tracing);
|
||||
symbolTable.setFunctionExtensions("reportIntersectionNV", 1, &E_GL_NV_ray_tracing);
|
||||
symbolTable.setFunctionExtensions("reportIntersectionEXT", 1, &E_GL_EXT_ray_tracing);
|
||||
@@ -8602,6 +8840,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
BuiltInVariable("gl_IncomingRayFlagsNV", EbvIncomingRayFlags, symbolTable);
|
||||
BuiltInVariable("gl_IncomingRayFlagsEXT", EbvIncomingRayFlags, symbolTable);
|
||||
BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
|
||||
BuiltInVariable("gl_CurrentRayTimeNV", EbvCurrentRayTimeNV, symbolTable);
|
||||
|
||||
// GL_ARB_shader_ballot
|
||||
symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
|
||||
@@ -9026,6 +9265,18 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
symbolTable.relateToOperator("clockRealtimeEXT", EOpReadClockDeviceKHR);
|
||||
symbolTable.relateToOperator("clockRealtime2x32EXT", EOpReadClockDeviceKHR);
|
||||
|
||||
if (profile != EEsProfile && version == 450) {
|
||||
symbolTable.relateToOperator("atomicCounterAddARB", EOpAtomicCounterAdd);
|
||||
symbolTable.relateToOperator("atomicCounterSubtractARB", EOpAtomicCounterSubtract);
|
||||
symbolTable.relateToOperator("atomicCounterMinARB", EOpAtomicCounterMin);
|
||||
symbolTable.relateToOperator("atomicCounterMaxARB", EOpAtomicCounterMax);
|
||||
symbolTable.relateToOperator("atomicCounterAndARB", EOpAtomicCounterAnd);
|
||||
symbolTable.relateToOperator("atomicCounterOrARB", EOpAtomicCounterOr);
|
||||
symbolTable.relateToOperator("atomicCounterXorARB", EOpAtomicCounterXor);
|
||||
symbolTable.relateToOperator("atomicCounterExchangeARB", EOpAtomicCounterExchange);
|
||||
symbolTable.relateToOperator("atomicCounterCompSwapARB", EOpAtomicCounterCompSwap);
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version >= 460) {
|
||||
symbolTable.relateToOperator("atomicCounterAdd", EOpAtomicCounterAdd);
|
||||
symbolTable.relateToOperator("atomicCounterSubtract", EOpAtomicCounterSubtract);
|
||||
@@ -9442,6 +9693,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
case EShLangMiss:
|
||||
if (profile != EEsProfile && version >= 460) {
|
||||
symbolTable.relateToOperator("traceNV", EOpTraceNV);
|
||||
symbolTable.relateToOperator("traceRayMotionNV", EOpTraceRayMotionNV);
|
||||
symbolTable.relateToOperator("traceRayEXT", EOpTraceKHR);
|
||||
symbolTable.relateToOperator("executeCallableNV", EOpExecuteCallableNV);
|
||||
symbolTable.relateToOperator("executeCallableEXT", EOpExecuteCallableKHR);
|
||||
|
||||
@@ -416,20 +416,24 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child,
|
||||
// TODO: but, did this bypass constant folding?
|
||||
//
|
||||
switch (op) {
|
||||
case EOpConstructInt8:
|
||||
case EOpConstructUint8:
|
||||
case EOpConstructInt16:
|
||||
case EOpConstructUint16:
|
||||
case EOpConstructInt:
|
||||
case EOpConstructUint:
|
||||
case EOpConstructInt64:
|
||||
case EOpConstructUint64:
|
||||
case EOpConstructBool:
|
||||
case EOpConstructFloat:
|
||||
case EOpConstructDouble:
|
||||
case EOpConstructFloat16:
|
||||
return child;
|
||||
default: break; // some compilers want this
|
||||
case EOpConstructInt8:
|
||||
case EOpConstructUint8:
|
||||
case EOpConstructInt16:
|
||||
case EOpConstructUint16:
|
||||
case EOpConstructInt:
|
||||
case EOpConstructUint:
|
||||
case EOpConstructInt64:
|
||||
case EOpConstructUint64:
|
||||
case EOpConstructBool:
|
||||
case EOpConstructFloat:
|
||||
case EOpConstructDouble:
|
||||
case EOpConstructFloat16: {
|
||||
TIntermUnary* unary_node = child->getAsUnaryNode();
|
||||
if (unary_node != nullptr)
|
||||
unary_node->updatePrecision();
|
||||
return child;
|
||||
}
|
||||
default: break; // some compilers want this
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1739,7 +1743,7 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
|
||||
case EbtUint:
|
||||
switch (from) {
|
||||
case EbtInt:
|
||||
return version >= 400 || getSource() == EShSourceHlsl;
|
||||
return version >= 400 || getSource() == EShSourceHlsl || IsRequestedExtension(E_GL_ARB_gpu_shader5);
|
||||
case EbtBool:
|
||||
return getSource() == EShSourceHlsl;
|
||||
case EbtInt16:
|
||||
@@ -2676,7 +2680,11 @@ TIntermTyped* TIntermediate::addSwizzle(TSwizzleSelectors<selectorType>& selecto
|
||||
// 'swizzleOkay' says whether or not it is okay to consider a swizzle
|
||||
// a valid part of the dereference chain.
|
||||
//
|
||||
const TIntermTyped* TIntermediate::findLValueBase(const TIntermTyped* node, bool swizzleOkay)
|
||||
// 'BufferReferenceOk' says if type is buffer_reference, the routine stop to find the most left node.
|
||||
//
|
||||
//
|
||||
|
||||
const TIntermTyped* TIntermediate::findLValueBase(const TIntermTyped* node, bool swizzleOkay , bool bufferReferenceOk)
|
||||
{
|
||||
do {
|
||||
const TIntermBinary* binary = node->getAsBinaryNode();
|
||||
@@ -2694,6 +2702,8 @@ const TIntermTyped* TIntermediate::findLValueBase(const TIntermTyped* node, bool
|
||||
return nullptr;
|
||||
}
|
||||
node = node->getAsBinaryNode()->getLeft();
|
||||
if (bufferReferenceOk && node->isReference())
|
||||
return node;
|
||||
} while (true);
|
||||
}
|
||||
|
||||
@@ -3770,6 +3780,28 @@ bool TIntermediate::promoteAggregate(TIntermAggregate& node)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Propagate precision qualifiers *up* from children to parent, and then
|
||||
// back *down* again to the children's subtrees.
|
||||
void TIntermAggregate::updatePrecision()
|
||||
{
|
||||
if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
|
||||
getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
|
||||
TPrecisionQualifier maxPrecision = EpqNone;
|
||||
TIntermSequence operands = getSequence();
|
||||
for (unsigned int i = 0; i < operands.size(); ++i) {
|
||||
TIntermTyped* typedNode = operands[i]->getAsTyped();
|
||||
assert(typedNode);
|
||||
maxPrecision = std::max(maxPrecision, typedNode->getQualifier().precision);
|
||||
}
|
||||
getQualifier().precision = maxPrecision;
|
||||
for (unsigned int i = 0; i < operands.size(); ++i) {
|
||||
TIntermTyped* typedNode = operands[i]->getAsTyped();
|
||||
assert(typedNode);
|
||||
typedNode->propagatePrecision(maxPrecision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Propagate precision qualifiers *up* from children to parent, and then
|
||||
// back *down* again to the children's subtrees.
|
||||
void TIntermBinary::updatePrecision()
|
||||
@@ -3870,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; \
|
||||
|
||||
@@ -622,6 +622,19 @@ void TParseContextBase::growGlobalUniformBlock(const TSourceLoc& loc, TType& mem
|
||||
globalUniformBlock->getWritableType().getQualifier().layoutBinding = globalUniformBinding;
|
||||
globalUniformBlock->getWritableType().getQualifier().layoutSet = globalUniformSet;
|
||||
|
||||
// Check for declarations of this default uniform that already exist due to other compilation units.
|
||||
TSymbol* symbol = symbolTable.find(memberName);
|
||||
if (symbol) {
|
||||
if (memberType != symbol->getType()) {
|
||||
TString err;
|
||||
err += "\"" + memberType.getCompleteString() + "\"";
|
||||
err += " versus ";
|
||||
err += "\"" + symbol->getType().getCompleteString() + "\"";
|
||||
error(loc, "Types must match:", memberType.getFieldName().c_str(), err.c_str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the requested member as a member to the global block.
|
||||
TType* type = new TType;
|
||||
type->shallowCopy(memberType);
|
||||
|
||||
@@ -327,6 +327,16 @@ void TParseContext::setAtomicCounterBlockDefaults(TType& block) const
|
||||
block.getQualifier().layoutMatrix = ElmRowMajor;
|
||||
}
|
||||
|
||||
void TParseContext::setInvariant(const TSourceLoc& loc, const char* builtin) {
|
||||
TSymbol* symbol = symbolTable.find(builtin);
|
||||
if (symbol && symbol->getType().getQualifier().isPipeOutput()) {
|
||||
if (intermediate.inIoAccessed(builtin))
|
||||
warn(loc, "changing qualification after use", "invariant", builtin);
|
||||
TSymbol* csymbol = symbolTable.copyUp(symbol);
|
||||
csymbol->getWritableType().getQualifier().invariant = true;
|
||||
}
|
||||
}
|
||||
|
||||
void TParseContext::handlePragma(const TSourceLoc& loc, const TVector<TString>& tokens)
|
||||
{
|
||||
#ifndef GLSLANG_WEB
|
||||
@@ -404,8 +414,33 @@ void TParseContext::handlePragma(const TSourceLoc& loc, const TVector<TString>&
|
||||
intermediate.setUseVariablePointers();
|
||||
} else if (tokens[0].compare("once") == 0) {
|
||||
warn(loc, "not implemented", "#pragma once", "");
|
||||
} else if (tokens[0].compare("glslang_binary_double_output") == 0)
|
||||
} else if (tokens[0].compare("glslang_binary_double_output") == 0) {
|
||||
intermediate.setBinaryDoubleOutput();
|
||||
} else if (spvVersion.spv > 0 && tokens[0].compare("STDGL") == 0 &&
|
||||
tokens[1].compare("invariant") == 0 && tokens[3].compare("all") == 0) {
|
||||
intermediate.setInvariantAll();
|
||||
// Set all builtin out variables invariant if declared
|
||||
setInvariant(loc, "gl_Position");
|
||||
setInvariant(loc, "gl_PointSize");
|
||||
setInvariant(loc, "gl_ClipDistance");
|
||||
setInvariant(loc, "gl_CullDistance");
|
||||
setInvariant(loc, "gl_TessLevelOuter");
|
||||
setInvariant(loc, "gl_TessLevelInner");
|
||||
setInvariant(loc, "gl_PrimitiveID");
|
||||
setInvariant(loc, "gl_Layer");
|
||||
setInvariant(loc, "gl_ViewportIndex");
|
||||
setInvariant(loc, "gl_FragDepth");
|
||||
setInvariant(loc, "gl_SampleMask");
|
||||
setInvariant(loc, "gl_ClipVertex");
|
||||
setInvariant(loc, "gl_FrontColor");
|
||||
setInvariant(loc, "gl_BackColor");
|
||||
setInvariant(loc, "gl_FrontSecondaryColor");
|
||||
setInvariant(loc, "gl_BackSecondaryColor");
|
||||
setInvariant(loc, "gl_TexCoord");
|
||||
setInvariant(loc, "gl_FogFragCoord");
|
||||
setInvariant(loc, "gl_FragColor");
|
||||
setInvariant(loc, "gl_FragData");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1092,12 +1127,31 @@ TFunction* TParseContext::handleFunctionDeclarator(const TSourceLoc& loc, TFunct
|
||||
TSymbol* symbol = symbolTable.find(function.getMangledName(), &builtIn);
|
||||
if (symbol && symbol->getAsFunction() && builtIn)
|
||||
requireProfile(loc, ~EEsProfile, "redefinition of built-in function");
|
||||
#ifndef GLSLANG_WEB
|
||||
// Check the validity of using spirv_literal qualifier
|
||||
for (int i = 0; i < function.getParamCount(); ++i) {
|
||||
if (function[i].type->getQualifier().isSpirvLiteral() && function.getBuiltInOp() != EOpSpirvInst)
|
||||
error(loc, "'spirv_literal' can only be used on functions defined with 'spirv_instruction' for argument",
|
||||
function.getName().c_str(), "%d", i + 1);
|
||||
}
|
||||
|
||||
// For function declaration with SPIR-V instruction qualifier, always ignore the built-in function and
|
||||
// respect this redeclared one.
|
||||
if (symbol && builtIn && function.getBuiltInOp() == EOpSpirvInst)
|
||||
symbol = nullptr;
|
||||
#endif
|
||||
const TFunction* prevDec = symbol ? symbol->getAsFunction() : 0;
|
||||
if (prevDec) {
|
||||
if (prevDec->isPrototyped() && prototype)
|
||||
profileRequires(loc, EEsProfile, 300, nullptr, "multiple prototypes for same function");
|
||||
if (prevDec->getType() != function.getType())
|
||||
error(loc, "overloaded functions must have the same return type", function.getName().c_str(), "");
|
||||
#ifndef GLSLANG_WEB
|
||||
if (prevDec->getSpirvInstruction() != function.getSpirvInstruction()) {
|
||||
error(loc, "overloaded functions must have the same qualifiers", function.getName().c_str(),
|
||||
"spirv_instruction");
|
||||
}
|
||||
#endif
|
||||
for (int i = 0; i < prevDec->getParamCount(); ++i) {
|
||||
if ((*prevDec)[i].type->getQualifier().storage != function[i].type->getQualifier().storage)
|
||||
error(loc, "overloaded functions must have the same parameter storage qualifiers for argument", function[i].type->getStorageQualifierString(), "%d", i+1);
|
||||
@@ -1299,6 +1353,15 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
|
||||
if (lValueErrorCheck(arguments->getLoc(), "assign", arg->getAsTyped()))
|
||||
error(arguments->getLoc(), "Non-L-value cannot be passed for 'out' or 'inout' parameters.", "out", "");
|
||||
}
|
||||
#ifndef GLSLANG_WEB
|
||||
if (formalQualifier.isSpirvLiteral()) {
|
||||
if (!arg->getAsTyped()->getQualifier().isFrontEndConstant()) {
|
||||
error(arguments->getLoc(),
|
||||
"Non front-end constant expressions cannot be passed for 'spirv_literal' parameters.",
|
||||
"spirv_literal", "");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
const TType& argType = arg->getAsTyped()->getType();
|
||||
const TQualifier& argQualifier = argType.getQualifier();
|
||||
if (argQualifier.isMemory() && (argType.containsOpaque() || argType.isReference())) {
|
||||
@@ -1353,6 +1416,11 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
|
||||
if (builtIn && fnCandidate->getBuiltInOp() != EOpNull) {
|
||||
// A function call mapped to a built-in operation.
|
||||
result = handleBuiltInFunctionCall(loc, arguments, *fnCandidate);
|
||||
#ifndef GLSLANG_WEB
|
||||
} else if (fnCandidate->getBuiltInOp() == EOpSpirvInst) {
|
||||
// When SPIR-V instruction qualifier is specified, the function call is still mapped to a built-in operation.
|
||||
result = handleBuiltInFunctionCall(loc, arguments, *fnCandidate);
|
||||
#endif
|
||||
} else {
|
||||
// This is a function call not mapped to built-in operator.
|
||||
// It could still be a built-in function, but only if PureOperatorBuiltins == false.
|
||||
@@ -1430,6 +1498,35 @@ TIntermTyped* TParseContext::handleBuiltInFunctionCall(TSourceLoc loc, TIntermNo
|
||||
} else if (result->getAsOperator())
|
||||
builtInOpCheck(loc, function, *result->getAsOperator());
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// Special handling for function call with SPIR-V instruction qualifier specified
|
||||
if (function.getBuiltInOp() == EOpSpirvInst) {
|
||||
if (auto agg = result->getAsAggregate()) {
|
||||
// Propogate spirv_by_reference/spirv_literal from parameters to arguments
|
||||
auto& sequence = agg->getSequence();
|
||||
for (unsigned i = 0; i < sequence.size(); ++i) {
|
||||
if (function[i].type->getQualifier().isSpirvByReference())
|
||||
sequence[i]->getAsTyped()->getQualifier().setSpirvByReference();
|
||||
if (function[i].type->getQualifier().isSpirvLiteral())
|
||||
sequence[i]->getAsTyped()->getQualifier().setSpirvLiteral();
|
||||
}
|
||||
|
||||
// Attach the function call to SPIR-V intruction
|
||||
agg->setSpirvInstruction(function.getSpirvInstruction());
|
||||
} else if (auto unaryNode = result->getAsUnaryNode()) {
|
||||
// Propogate spirv_by_reference/spirv_literal from parameters to arguments
|
||||
if (function[0].type->getQualifier().isSpirvByReference())
|
||||
unaryNode->getOperand()->getQualifier().setSpirvByReference();
|
||||
if (function[0].type->getQualifier().isSpirvLiteral())
|
||||
unaryNode->getOperand()->getQualifier().setSpirvLiteral();
|
||||
|
||||
// Attach the function call to SPIR-V intruction
|
||||
unaryNode->setSpirvInstruction(function.getSpirvInstruction());
|
||||
} else
|
||||
assert(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2096,7 +2193,13 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
|
||||
profileRequires(loc, ~EEsProfile, 450, nullptr, feature);
|
||||
requireExtensions(loc, 1, &E_GL_AMD_texture_gather_bias_lod, feature);
|
||||
}
|
||||
|
||||
// As per GL_ARB_sparse_texture2 extension "Offsets" parameter must be constant integral expression
|
||||
// for sparseTextureGatherOffsetsARB just as textureGatherOffsets
|
||||
if (callNode.getOp() == EOpSparseTextureGatherOffsets) {
|
||||
int offsetsArg = arg0->getType().getSampler().shadow ? 3 : 2;
|
||||
if (!(*argp)[offsetsArg]->getAsConstantUnion())
|
||||
error(loc, "argument must be compile-time constant", "offsets", "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2185,6 +2288,16 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
|
||||
"[gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]");
|
||||
}
|
||||
}
|
||||
|
||||
if (callNode.getOp() == EOpTextureOffset) {
|
||||
TSampler s = arg0->getType().getSampler();
|
||||
if (s.is2D() && s.isArrayed() && s.isShadow()) {
|
||||
if (isEsProfile())
|
||||
error(loc, "TextureOffset does not support sampler2DArrayShadow : ", "sampler", "ES Profile");
|
||||
else if (version <= 420)
|
||||
error(loc, "TextureOffset does not support sampler2DArrayShadow : ", "sampler", "version <= 420");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -2195,6 +2308,10 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
|
||||
if (!(*argp)[10]->getAsConstantUnion())
|
||||
error(loc, "argument must be compile-time constant", "payload number", "a");
|
||||
break;
|
||||
case EOpTraceRayMotionNV:
|
||||
if (!(*argp)[11]->getAsConstantUnion())
|
||||
error(loc, "argument must be compile-time constant", "payload number", "a");
|
||||
break;
|
||||
case EOpTraceKHR:
|
||||
if (!(*argp)[10]->getAsConstantUnion())
|
||||
error(loc, "argument must be compile-time constant", "payload number", "a");
|
||||
@@ -2263,18 +2380,23 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
|
||||
error(loc, "only supported on image with format r64i", fnCandidate.getName().c_str(), "");
|
||||
else if (callNode.getType().getBasicType() == EbtUint64 && imageType.getQualifier().getFormat() != ElfR64ui)
|
||||
error(loc, "only supported on image with format r64ui", fnCandidate.getName().c_str(), "");
|
||||
} else {
|
||||
bool isImageAtomicOnFloatAllowed = ((fnCandidate.getName().compare(0, 14, "imageAtomicAdd") == 0) ||
|
||||
(fnCandidate.getName().compare(0, 15, "imageAtomicLoad") == 0) ||
|
||||
(fnCandidate.getName().compare(0, 16, "imageAtomicStore") == 0) ||
|
||||
(fnCandidate.getName().compare(0, 19, "imageAtomicExchange") == 0));
|
||||
if (imageType.getSampler().type == EbtFloat && isImageAtomicOnFloatAllowed &&
|
||||
(fnCandidate.getName().compare(0, 19, "imageAtomicExchange") != 0)) // imageAtomicExchange doesn't require GL_EXT_shader_atomic_float
|
||||
} else if (imageType.getSampler().type == EbtFloat) {
|
||||
if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") == 0) {
|
||||
// imageAtomicExchange doesn't require an extension
|
||||
} else if ((fnCandidate.getName().compare(0, 14, "imageAtomicAdd") == 0) ||
|
||||
(fnCandidate.getName().compare(0, 15, "imageAtomicLoad") == 0) ||
|
||||
(fnCandidate.getName().compare(0, 16, "imageAtomicStore") == 0)) {
|
||||
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float, fnCandidate.getName().c_str());
|
||||
if (!isImageAtomicOnFloatAllowed)
|
||||
} else if ((fnCandidate.getName().compare(0, 14, "imageAtomicMin") == 0) ||
|
||||
(fnCandidate.getName().compare(0, 14, "imageAtomicMax") == 0)) {
|
||||
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float2, fnCandidate.getName().c_str());
|
||||
} else {
|
||||
error(loc, "only supported on integer images", fnCandidate.getName().c_str(), "");
|
||||
else if (imageType.getQualifier().getFormat() != ElfR32f && isEsProfile())
|
||||
}
|
||||
if (imageType.getQualifier().getFormat() != ElfR32f && isEsProfile())
|
||||
error(loc, "only supported on image with format r32f", fnCandidate.getName().c_str(), "");
|
||||
} else {
|
||||
error(loc, "not supported on this image type", fnCandidate.getName().c_str(), "");
|
||||
}
|
||||
|
||||
const size_t maxArgs = imageType.getSampler().isMultiSample() ? 5 : 4;
|
||||
@@ -2303,17 +2425,37 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
|
||||
memorySemanticsCheck(loc, fnCandidate, callNode);
|
||||
if ((callNode.getOp() == EOpAtomicAdd || callNode.getOp() == EOpAtomicExchange ||
|
||||
callNode.getOp() == EOpAtomicLoad || callNode.getOp() == EOpAtomicStore) &&
|
||||
(arg0->getType().isFloatingDomain())) {
|
||||
(arg0->getType().getBasicType() == EbtFloat ||
|
||||
arg0->getType().getBasicType() == EbtDouble)) {
|
||||
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float, fnCandidate.getName().c_str());
|
||||
} else if ((callNode.getOp() == EOpAtomicAdd || callNode.getOp() == EOpAtomicExchange ||
|
||||
callNode.getOp() == EOpAtomicLoad || callNode.getOp() == EOpAtomicStore ||
|
||||
callNode.getOp() == EOpAtomicMin || callNode.getOp() == EOpAtomicMax) &&
|
||||
arg0->getType().isFloatingDomain()) {
|
||||
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float2, fnCandidate.getName().c_str());
|
||||
}
|
||||
} else if (arg0->getType().getBasicType() == EbtInt64 || arg0->getType().getBasicType() == EbtUint64) {
|
||||
const char* const extensions[2] = { E_GL_NV_shader_atomic_int64,
|
||||
E_GL_EXT_shader_atomic_int64 };
|
||||
requireExtensions(loc, 2, extensions, fnCandidate.getName().c_str());
|
||||
} else if ((callNode.getOp() == EOpAtomicAdd || callNode.getOp() == EOpAtomicExchange) &&
|
||||
(arg0->getType().isFloatingDomain())) {
|
||||
(arg0->getType().getBasicType() == EbtFloat ||
|
||||
arg0->getType().getBasicType() == EbtDouble)) {
|
||||
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float, fnCandidate.getName().c_str());
|
||||
} else if ((callNode.getOp() == EOpAtomicAdd || callNode.getOp() == EOpAtomicExchange ||
|
||||
callNode.getOp() == EOpAtomicLoad || callNode.getOp() == EOpAtomicStore ||
|
||||
callNode.getOp() == EOpAtomicMin || callNode.getOp() == EOpAtomicMax) &&
|
||||
arg0->getType().isFloatingDomain()) {
|
||||
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float2, fnCandidate.getName().c_str());
|
||||
}
|
||||
|
||||
const TIntermTyped* base = TIntermediate::findLValueBase(arg0, true , true);
|
||||
const TType* refType = (base->getType().isReference()) ? base->getType().getReferentType() : nullptr;
|
||||
const TQualifier& qualifier = (refType != nullptr) ? refType->getQualifier() : base->getType().getQualifier();
|
||||
if (qualifier.storage != EvqShared && qualifier.storage != EvqBuffer)
|
||||
error(loc,"Atomic memory function can only be used for shader storage block member or shared variable.",
|
||||
fnCandidate.getName().c_str(), "");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2887,11 +3029,14 @@ void TParseContext::constantValueCheck(TIntermTyped* node, const char* token)
|
||||
|
||||
//
|
||||
// Both test, and if necessary spit out an error, to see if the node is really
|
||||
// an integer.
|
||||
// a 32-bit integer or can implicitly convert to one.
|
||||
//
|
||||
void TParseContext::integerCheck(const TIntermTyped* node, const char* token)
|
||||
{
|
||||
if ((node->getBasicType() == EbtInt || node->getBasicType() == EbtUint) && node->isScalar())
|
||||
auto from_type = node->getBasicType();
|
||||
if ((from_type == EbtInt || from_type == EbtUint ||
|
||||
intermediate.canImplicitlyPromote(from_type, EbtInt, EOpNull) ||
|
||||
intermediate.canImplicitlyPromote(from_type, EbtUint, EOpNull)) && node->isScalar())
|
||||
return;
|
||||
|
||||
error(node->getLoc(), "scalar integer expression required", token, "");
|
||||
@@ -2915,7 +3060,8 @@ void TParseContext::reservedErrorCheck(const TSourceLoc& loc, const TString& ide
|
||||
// "Identifiers starting with "gl_" are reserved for use by OpenGL, and may not be
|
||||
// declared in a shader; this results in a compile-time error."
|
||||
if (! symbolTable.atBuiltInLevel()) {
|
||||
if (builtInName(identifier))
|
||||
if (builtInName(identifier) && !extensionTurnedOn(E_GL_EXT_spirv_intrinsics))
|
||||
// The extension GL_EXT_spirv_intrinsics allows us to declare identifiers starting with "gl_".
|
||||
error(loc, "identifiers starting with \"gl_\" are reserved", identifier.c_str(), "");
|
||||
|
||||
// "__" are not supposed to be an error. ES 300 (and desktop) added the clarification:
|
||||
@@ -2923,7 +3069,8 @@ void TParseContext::reservedErrorCheck(const TSourceLoc& loc, const TString& ide
|
||||
// reserved; using such a name does not itself result in an error, but may result
|
||||
// in undefined behavior."
|
||||
// however, before that, ES tests required an error.
|
||||
if (identifier.find("__") != TString::npos) {
|
||||
if (identifier.find("__") != TString::npos && !extensionTurnedOn(E_GL_EXT_spirv_intrinsics)) {
|
||||
// The extension GL_EXT_spirv_intrinsics allows us to declare identifiers starting with "__".
|
||||
if (isEsProfile() && version < 300)
|
||||
error(loc, "identifiers containing consecutive underscores (\"__\") are reserved, and an error if version < 300", identifier.c_str(), "");
|
||||
else
|
||||
@@ -2944,14 +3091,16 @@ void TParseContext::reservedPpErrorCheck(const TSourceLoc& loc, const char* iden
|
||||
// single underscore) are also reserved, and defining such a name results in a
|
||||
// compile-time error."
|
||||
// however, before that, ES tests required an error.
|
||||
if (strncmp(identifier, "GL_", 3) == 0)
|
||||
if (strncmp(identifier, "GL_", 3) == 0 && !extensionTurnedOn(E_GL_EXT_spirv_intrinsics))
|
||||
// The extension GL_EXT_spirv_intrinsics allows us to declare macros prefixed with "GL_".
|
||||
ppError(loc, "names beginning with \"GL_\" can't be (un)defined:", op, identifier);
|
||||
else if (strncmp(identifier, "defined", 8) == 0)
|
||||
if (relaxedErrors())
|
||||
ppWarn(loc, "\"defined\" is (un)defined:", op, identifier);
|
||||
else
|
||||
ppError(loc, "\"defined\" can't be (un)defined:", op, identifier);
|
||||
else if (strstr(identifier, "__") != 0) {
|
||||
else if (strstr(identifier, "__") != 0 && !extensionTurnedOn(E_GL_EXT_spirv_intrinsics)) {
|
||||
// The extension GL_EXT_spirv_intrinsics allows us to declare macros prefixed with "__".
|
||||
if (isEsProfile() && version >= 300 &&
|
||||
(strcmp(identifier, "__LINE__") == 0 ||
|
||||
strcmp(identifier, "__FILE__") == 0 ||
|
||||
@@ -3099,6 +3248,7 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
|
||||
bool matrixInMatrix = false;
|
||||
bool arrayArg = false;
|
||||
bool floatArgument = false;
|
||||
bool intArgument = false;
|
||||
for (int arg = 0; arg < function.getParamCount(); ++arg) {
|
||||
if (function[arg].type->isArray()) {
|
||||
if (function[arg].type->isUnsizedArray()) {
|
||||
@@ -3129,6 +3279,8 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
|
||||
specConstType = true;
|
||||
if (function[arg].type->isFloatingDomain())
|
||||
floatArgument = true;
|
||||
if (function[arg].type->isIntegerDomain())
|
||||
intArgument = true;
|
||||
if (type.isStruct()) {
|
||||
if (function[arg].type->contains16BitFloat()) {
|
||||
requireFloat16Arithmetic(loc, "constructor", "can't construct structure containing 16-bit type");
|
||||
@@ -3234,6 +3386,15 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
|
||||
// and aren't making an array.
|
||||
makeSpecConst = ! floatArgument && ! type.isArray();
|
||||
break;
|
||||
|
||||
case EOpConstructVec2:
|
||||
case EOpConstructVec3:
|
||||
case EOpConstructVec4:
|
||||
// This was the list of valid ones, if they aren't converting from int
|
||||
// and aren't making an array.
|
||||
makeSpecConst = ! intArgument && !type.isArray();
|
||||
break;
|
||||
|
||||
default:
|
||||
// anything else wasn't white-listed in the spec as a conversion
|
||||
makeSpecConst = false;
|
||||
@@ -3540,6 +3701,8 @@ void TParseContext::globalQualifierFixCheck(const TSourceLoc& loc, TQualifier& q
|
||||
profileRequires(loc, ENoProfile, 130, nullptr, "out for stage outputs");
|
||||
profileRequires(loc, EEsProfile, 300, nullptr, "out for stage outputs");
|
||||
qualifier.storage = EvqVaryingOut;
|
||||
if (intermediate.isInvariantAll())
|
||||
qualifier.invariant = true;
|
||||
break;
|
||||
case EvqInOut:
|
||||
qualifier.storage = EvqVaryingIn;
|
||||
@@ -3556,7 +3719,7 @@ void TParseContext::globalQualifierFixCheck(const TSourceLoc& loc, TQualifier& q
|
||||
if (blockName == nullptr &&
|
||||
qualifier.layoutPacking == ElpStd430)
|
||||
{
|
||||
error(loc, "it is invalid to declare std430 qualifier on uniform", "", "");
|
||||
requireExtensions(loc, 1, &E_GL_EXT_scalar_block_layout, "default std430 layout for uniform");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -3566,6 +3729,14 @@ void TParseContext::globalQualifierFixCheck(const TSourceLoc& loc, TQualifier& q
|
||||
if (!nonuniformOkay && qualifier.isNonUniform())
|
||||
error(loc, "for non-parameter, can only apply to 'in' or no storage qualifier", "nonuniformEXT", "");
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
if (qualifier.isSpirvByReference())
|
||||
error(loc, "can only apply to parameter", "spirv_by_reference", "");
|
||||
|
||||
if (qualifier.isSpirvLiteral())
|
||||
error(loc, "can only apply to parameter", "spirv_literal", "");
|
||||
#endif
|
||||
|
||||
// Storage qualifier isn't ready for memberQualifierCheck, we should skip invariantCheck for it.
|
||||
if (!isMemberCheck || structNestingLevel > 0)
|
||||
invariantCheck(loc, qualifier);
|
||||
@@ -3827,6 +3998,41 @@ void TParseContext::mergeQualifiers(const TSourceLoc& loc, TQualifier& dst, cons
|
||||
MERGE_SINGLETON(nonUniform);
|
||||
#endif
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// SPIR-V storage class qualifier (GL_EXT_spirv_intrinsics)
|
||||
dst.spirvStorageClass = src.spirvStorageClass;
|
||||
|
||||
// SPIR-V decorate qualifiers (GL_EXT_spirv_intrinsics)
|
||||
if (src.hasSprivDecorate()) {
|
||||
if (dst.hasSprivDecorate()) {
|
||||
const TSpirvDecorate& srcSpirvDecorate = src.getSpirvDecorate();
|
||||
TSpirvDecorate& dstSpirvDecorate = dst.getSpirvDecorate();
|
||||
for (auto& decorate : srcSpirvDecorate.decorates) {
|
||||
if (dstSpirvDecorate.decorates.find(decorate.first) != dstSpirvDecorate.decorates.end())
|
||||
error(loc, "too many SPIR-V decorate qualifiers", "spirv_decorate", "(decoration=%u)", decorate.first);
|
||||
else
|
||||
dstSpirvDecorate.decorates.insert(decorate);
|
||||
}
|
||||
|
||||
for (auto& decorateId : srcSpirvDecorate.decorateIds) {
|
||||
if (dstSpirvDecorate.decorateIds.find(decorateId.first) != dstSpirvDecorate.decorateIds.end())
|
||||
error(loc, "too many SPIR-V decorate qualifiers", "spirv_decorate_id", "(decoration=%u)", decorateId.first);
|
||||
else
|
||||
dstSpirvDecorate.decorateIds.insert(decorateId);
|
||||
}
|
||||
|
||||
for (auto& decorateString : srcSpirvDecorate.decorateStrings) {
|
||||
if (dstSpirvDecorate.decorates.find(decorateString.first) != dstSpirvDecorate.decorates.end())
|
||||
error(loc, "too many SPIR-V decorate qualifiers", "spirv_decorate_string", "(decoration=%u)", decorateString.first);
|
||||
else
|
||||
dstSpirvDecorate.decorates.insert(decorateString);
|
||||
}
|
||||
} else {
|
||||
dst.spirvDecorate = src.spirvDecorate;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (repeated)
|
||||
error(loc, "replicated qualifiers", "", "");
|
||||
}
|
||||
@@ -4790,6 +4996,17 @@ void TParseContext::paramCheckFix(const TSourceLoc& loc, const TQualifier& quali
|
||||
}
|
||||
if (qualifier.isNonUniform())
|
||||
type.getQualifier().nonUniform = qualifier.nonUniform;
|
||||
#ifndef GLSLANG_WEB
|
||||
if (qualifier.isSpirvByReference())
|
||||
type.getQualifier().setSpirvByReference();
|
||||
if (qualifier.isSpirvLiteral()) {
|
||||
if (type.getBasicType() == EbtFloat || type.getBasicType() == EbtInt || type.getBasicType() == EbtUint ||
|
||||
type.getBasicType() == EbtBool)
|
||||
type.getQualifier().setSpirvLiteral();
|
||||
else
|
||||
error(loc, "cannot use spirv_literal qualifier", type.getBasicTypeString().c_str(), "");
|
||||
#endif
|
||||
}
|
||||
|
||||
paramCheckFixStorage(loc, qualifier.storage, type);
|
||||
}
|
||||
@@ -5596,14 +5813,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
||||
if (! IsPow2(value))
|
||||
error(loc, "must be a power of 2", "buffer_reference_align", "");
|
||||
else
|
||||
#ifdef __ANDROID__
|
||||
// Android NDK r15c tageting ABI 15 doesn't have full support for C++11
|
||||
// (no std::exp2/log2). ::exp2 is available from C99 but ::log2 isn't
|
||||
// available up until ABI 18 so we use the mathematical equivalent form
|
||||
publicType.qualifier.layoutBufferReferenceAlign = (unsigned int)(std::log(value) / std::log(2.0));
|
||||
#else
|
||||
publicType.qualifier.layoutBufferReferenceAlign = (unsigned int)std::log2(value);
|
||||
#endif
|
||||
publicType.qualifier.layoutBufferReferenceAlign = IntLog2(value);
|
||||
if (nonLiteral)
|
||||
error(loc, "needs a literal integer", "buffer_reference_align", "");
|
||||
return;
|
||||
@@ -5864,6 +6074,9 @@ void TParseContext::layoutObjectCheck(const TSourceLoc& loc, const TSymbol& symb
|
||||
case EvqVaryingIn:
|
||||
case EvqVaryingOut:
|
||||
if (!type.getQualifier().isTaskMemory() &&
|
||||
#ifndef GLSLANG_WEB
|
||||
!type.getQualifier().hasSprivDecorate() &&
|
||||
#endif
|
||||
(type.getBasicType() != EbtBlock ||
|
||||
(!(*type.getStruct())[0].type->getQualifier().hasLocation() &&
|
||||
(*type.getStruct())[0].type->getQualifier().builtIn == EbvNone)))
|
||||
@@ -5925,6 +6138,11 @@ void TParseContext::layoutMemberLocationArrayCheck(const TSourceLoc& loc, bool m
|
||||
// Do layout error checking with respect to a type.
|
||||
void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
|
||||
{
|
||||
#ifndef GLSLANG_WEB
|
||||
if (extensionTurnedOn(E_GL_EXT_spirv_intrinsics))
|
||||
return; // Skip any check if GL_EXT_spirv_intrinsics is turned on
|
||||
#endif
|
||||
|
||||
const TQualifier& qualifier = type.getQualifier();
|
||||
|
||||
// first, intra-layout qualifier-only error checking
|
||||
@@ -6278,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)
|
||||
@@ -6425,12 +6645,17 @@ const TFunction* TParseContext::findFunction(const TSourceLoc& loc, const TFunct
|
||||
extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float64);
|
||||
|
||||
if (isEsProfile())
|
||||
function = (extensionTurnedOn(E_GL_EXT_shader_implicit_conversions) && version >= 310) ?
|
||||
findFunction120(loc, call, builtIn) : findFunctionExact(loc, call, builtIn);
|
||||
function = (explicitTypesEnabled && version >= 310)
|
||||
? findFunctionExplicitTypes(loc, call, builtIn)
|
||||
: ((extensionTurnedOn(E_GL_EXT_shader_implicit_conversions) && version >= 310)
|
||||
? findFunction120(loc, call, builtIn)
|
||||
: 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
|
||||
@@ -7473,7 +7698,13 @@ TIntermTyped* TParseContext::addConstructor(const TSourceLoc& loc, TIntermNode*
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return intermediate.setAggregateOperator(aggrNode, op, type, loc);
|
||||
TIntermTyped *ret_node = intermediate.setAggregateOperator(aggrNode, op, type, loc);
|
||||
|
||||
TIntermAggregate *agg_node = ret_node->getAsAggregate();
|
||||
if (agg_node && (agg_node->isVector() || agg_node->isArray() || agg_node->isMatrix()))
|
||||
agg_node->updatePrecision();
|
||||
|
||||
return ret_node;
|
||||
}
|
||||
|
||||
// Function for constructor implementation. Calls addUnaryMath with appropriate EOp value
|
||||
@@ -7928,6 +8159,10 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
|
||||
memberQualifier.perViewNV = currentBlockQualifier.perViewNV;
|
||||
if (currentBlockQualifier.perTaskNV)
|
||||
memberQualifier.perTaskNV = currentBlockQualifier.perTaskNV;
|
||||
if (memberQualifier.storage == EvqSpirvStorageClass)
|
||||
error(memberLoc, "member cannot have a spirv_storage_class qualifier", memberType.getFieldName().c_str(), "");
|
||||
if (memberQualifier.hasSprivDecorate() && !memberQualifier.getSpirvDecorate().decorateIds.empty())
|
||||
error(memberLoc, "member cannot have a spirv_decorate_id qualifier", memberType.getFieldName().c_str(), "");
|
||||
#endif
|
||||
if ((currentBlockQualifier.storage == EvqUniform || currentBlockQualifier.storage == EvqBuffer) && (memberQualifier.isInterpolation() || memberQualifier.isAuxiliary()))
|
||||
error(memberLoc, "member of uniform or buffer block cannot have an auxiliary or interpolation qualifier", memberType.getFieldName().c_str(), "");
|
||||
@@ -8518,8 +8753,8 @@ void TParseContext::fixBlockUniformLayoutMatrix(TQualifier& qualifier, TTypeList
|
||||
}
|
||||
|
||||
//
|
||||
// Spread LayoutPacking to block member, if a block member is a struct, we need spread LayoutPacking to
|
||||
// this struct member too. and keep this rule for recursive.
|
||||
// Spread LayoutPacking to matrix or aggregate block members. If a block member is a struct or
|
||||
// array of struct, spread LayoutPacking recursively to its matrix or aggregate members.
|
||||
//
|
||||
void TParseContext::fixBlockUniformLayoutPacking(TQualifier& qualifier, TTypeList* originTypeList,
|
||||
TTypeList* tmpTypeList)
|
||||
@@ -8528,11 +8763,13 @@ void TParseContext::fixBlockUniformLayoutPacking(TQualifier& qualifier, TTypeLis
|
||||
for (unsigned int member = 0; member < originTypeList->size(); ++member) {
|
||||
if (qualifier.layoutPacking != ElpNone) {
|
||||
if (tmpTypeList == nullptr) {
|
||||
if ((*originTypeList)[member].type->getQualifier().layoutPacking == ElpNone) {
|
||||
if ((*originTypeList)[member].type->getQualifier().layoutPacking == ElpNone &&
|
||||
!(*originTypeList)[member].type->isScalarOrVector()) {
|
||||
(*originTypeList)[member].type->getQualifier().layoutPacking = qualifier.layoutPacking;
|
||||
}
|
||||
} else {
|
||||
if ((*tmpTypeList)[member].type->getQualifier().layoutPacking == ElpNone) {
|
||||
if ((*tmpTypeList)[member].type->getQualifier().layoutPacking == ElpNone &&
|
||||
!(*tmpTypeList)[member].type->isScalarOrVector()) {
|
||||
(*tmpTypeList)[member].type->getQualifier().layoutPacking = qualifier.layoutPacking;
|
||||
}
|
||||
}
|
||||
@@ -9013,11 +9250,14 @@ TIntermNode* TParseContext::addSwitch(const TSourceLoc& loc, TIntermTyped* expre
|
||||
// "it is an error to have no statement between a label and the end of the switch statement."
|
||||
// The specifications were updated to remove this (being ill-defined what a "statement" was),
|
||||
// so, this became a warning. However, 3.0 tests still check for the error.
|
||||
if (isEsProfile() && version <= 300 && ! relaxedErrors())
|
||||
if (isEsProfile() && (version <= 300 || version >= 320) && ! relaxedErrors())
|
||||
error(loc, "last case/default label not followed by statements", "switch", "");
|
||||
else if (!isEsProfile() && (version <= 430 || version >= 460))
|
||||
error(loc, "last case/default label not followed by statements", "switch", "");
|
||||
else
|
||||
warn(loc, "last case/default label not followed by statements", "switch", "");
|
||||
|
||||
|
||||
// emulate a break for error recovery
|
||||
lastStatements = intermediate.makeAggregate(intermediate.addBranch(EOpBreak, loc));
|
||||
lastStatements->setOperator(EOpSequence);
|
||||
|
||||
@@ -241,6 +241,7 @@ protected:
|
||||
// override this to set the language-specific name
|
||||
virtual const char* getAtomicCounterBlockName() const { return ""; }
|
||||
virtual void setAtomicCounterBlockDefaults(TType&) const {}
|
||||
virtual void setInvariant(const TSourceLoc&, const char*) {}
|
||||
virtual void finalizeAtomicCounterBlockLayout(TVariable&) {}
|
||||
bool isAtomicCounterBlock(const TSymbol& symbol) {
|
||||
const TVariable* var = symbol.getAsVariable();
|
||||
@@ -470,6 +471,21 @@ public:
|
||||
void handleSwitchAttributes(const TAttributes& attributes, TIntermNode*);
|
||||
// Determine loop control from attributes
|
||||
void handleLoopAttributes(const TAttributes& attributes, TIntermNode*);
|
||||
// Function attributes
|
||||
void handleFunctionAttributes(const TSourceLoc&, const TAttributes&);
|
||||
|
||||
// GL_EXT_spirv_intrinsics
|
||||
TSpirvRequirement* makeSpirvRequirement(const TSourceLoc& loc, const TString& name,
|
||||
const TIntermAggregate* extensions, const TIntermAggregate* capabilities);
|
||||
TSpirvRequirement* mergeSpirvRequirements(const TSourceLoc& loc, TSpirvRequirement* spirvReq1,
|
||||
TSpirvRequirement* spirvReq2);
|
||||
TSpirvTypeParameters* makeSpirvTypeParameters(const TSourceLoc& loc, const TIntermConstantUnion* constant);
|
||||
TSpirvTypeParameters* mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1,
|
||||
TSpirvTypeParameters* spirvTypeParams2);
|
||||
TSpirvInstruction* makeSpirvInstruction(const TSourceLoc& loc, const TString& name, const TString& value);
|
||||
TSpirvInstruction* makeSpirvInstruction(const TSourceLoc& loc, const TString& name, int value);
|
||||
TSpirvInstruction* mergeSpirvInstruction(const TSourceLoc& loc, TSpirvInstruction* spirvInst1,
|
||||
TSpirvInstruction* spirvInst2);
|
||||
#endif
|
||||
|
||||
void checkAndResizeMeshViewDim(const TSourceLoc&, TType&, bool isBlockMember);
|
||||
@@ -495,6 +511,7 @@ protected:
|
||||
virtual const char* getAtomicCounterBlockName() const override;
|
||||
virtual void finalizeAtomicCounterBlockLayout(TVariable&) override;
|
||||
virtual void setAtomicCounterBlockDefaults(TType& block) const override;
|
||||
virtual void setInvariant(const TSourceLoc& loc, const char* builtin) override;
|
||||
|
||||
public:
|
||||
//
|
||||
|
||||
@@ -586,6 +586,18 @@ void TScanContext::fillInKeywordMap()
|
||||
(*KeywordMap)["f64mat4x2"] = F64MAT4X2;
|
||||
(*KeywordMap)["f64mat4x3"] = F64MAT4X3;
|
||||
(*KeywordMap)["f64mat4x4"] = F64MAT4X4;
|
||||
|
||||
// GL_EXT_spirv_intrinsics
|
||||
(*KeywordMap)["spirv_instruction"] = SPIRV_INSTRUCTION;
|
||||
(*KeywordMap)["spirv_execution_mode"] = SPIRV_EXECUTION_MODE;
|
||||
(*KeywordMap)["spirv_execution_mode_id"] = SPIRV_EXECUTION_MODE_ID;
|
||||
(*KeywordMap)["spirv_decorate"] = SPIRV_DECORATE;
|
||||
(*KeywordMap)["spirv_decorate_id"] = SPIRV_DECORATE_ID;
|
||||
(*KeywordMap)["spirv_decorate_string"] = SPIRV_DECORATE_STRING;
|
||||
(*KeywordMap)["spirv_type"] = SPIRV_TYPE;
|
||||
(*KeywordMap)["spirv_storage_class"] = SPIRV_STORAGE_CLASS;
|
||||
(*KeywordMap)["spirv_by_reference"] = SPIRV_BY_REFERENCE;
|
||||
(*KeywordMap)["spirv_literal"] = SPIRV_LITERAL;
|
||||
#endif
|
||||
|
||||
(*KeywordMap)["sampler2D"] = SAMPLER2D;
|
||||
@@ -1765,6 +1777,21 @@ int TScanContext::tokenizeIdentifier()
|
||||
return keyword;
|
||||
else
|
||||
return identifierOrType();
|
||||
|
||||
case SPIRV_INSTRUCTION:
|
||||
case SPIRV_EXECUTION_MODE:
|
||||
case SPIRV_EXECUTION_MODE_ID:
|
||||
case SPIRV_DECORATE:
|
||||
case SPIRV_DECORATE_ID:
|
||||
case SPIRV_DECORATE_STRING:
|
||||
case SPIRV_TYPE:
|
||||
case SPIRV_STORAGE_CLASS:
|
||||
case SPIRV_BY_REFERENCE:
|
||||
case SPIRV_LITERAL:
|
||||
if (parseContext.symbolTable.atBuiltInLevel() ||
|
||||
parseContext.extensionTurnedOn(E_GL_EXT_spirv_intrinsics))
|
||||
return keyword;
|
||||
return identifierOrType();
|
||||
#endif
|
||||
|
||||
default:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
//
|
||||
// Copyright(C) 2021 Advanced Micro Devices, Inc.
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// 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 HOLDERS 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.
|
||||
//
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
|
||||
//
|
||||
// GL_EXT_spirv_intrinsics
|
||||
//
|
||||
#include "../Include/intermediate.h"
|
||||
#include "../Include/SpirvIntrinsics.h"
|
||||
#include "../Include/Types.h"
|
||||
#include "ParseHelper.h"
|
||||
|
||||
namespace glslang {
|
||||
|
||||
//
|
||||
// Handle SPIR-V requirements
|
||||
//
|
||||
TSpirvRequirement* TParseContext::makeSpirvRequirement(const TSourceLoc& loc, const TString& name,
|
||||
const TIntermAggregate* extensions,
|
||||
const TIntermAggregate* capabilities)
|
||||
{
|
||||
TSpirvRequirement* spirvReq = new TSpirvRequirement;
|
||||
|
||||
if (name == "extensions") {
|
||||
assert(extensions);
|
||||
for (auto extension : extensions->getSequence()) {
|
||||
assert(extension->getAsConstantUnion());
|
||||
spirvReq->extensions.insert(*extension->getAsConstantUnion()->getConstArray()[0].getSConst());
|
||||
}
|
||||
} else if (name == "capabilities") {
|
||||
assert(capabilities);
|
||||
for (auto capability : capabilities->getSequence()) {
|
||||
assert(capability->getAsConstantUnion());
|
||||
spirvReq->capabilities.insert(capability->getAsConstantUnion()->getConstArray()[0].getIConst());
|
||||
}
|
||||
} else
|
||||
error(loc, "unknow SPIR-V requirement", name.c_str(), "");
|
||||
|
||||
return spirvReq;
|
||||
}
|
||||
|
||||
TSpirvRequirement* TParseContext::mergeSpirvRequirements(const TSourceLoc& loc, TSpirvRequirement* spirvReq1,
|
||||
TSpirvRequirement* spirvReq2)
|
||||
{
|
||||
// Merge the second SPIR-V requirement to the first one
|
||||
if (!spirvReq2->extensions.empty()) {
|
||||
if (spirvReq1->extensions.empty())
|
||||
spirvReq1->extensions = spirvReq2->extensions;
|
||||
else
|
||||
error(loc, "too many SPIR-V requirements", "extensions", "");
|
||||
}
|
||||
|
||||
if (!spirvReq2->capabilities.empty()) {
|
||||
if (spirvReq1->capabilities.empty())
|
||||
spirvReq1->capabilities = spirvReq2->capabilities;
|
||||
else
|
||||
error(loc, "too many SPIR-V requirements", "capabilities", "");
|
||||
}
|
||||
|
||||
return spirvReq1;
|
||||
}
|
||||
|
||||
void TIntermediate::insertSpirvRequirement(const TSpirvRequirement* spirvReq)
|
||||
{
|
||||
if (!spirvRequirement)
|
||||
spirvRequirement = new TSpirvRequirement;
|
||||
|
||||
for (auto extension : spirvReq->extensions)
|
||||
spirvRequirement->extensions.insert(extension);
|
||||
|
||||
for (auto capability : spirvReq->capabilities)
|
||||
spirvRequirement->capabilities.insert(capability);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle SPIR-V execution modes
|
||||
//
|
||||
void TIntermediate::insertSpirvExecutionMode(int executionMode, const TIntermAggregate* args)
|
||||
{
|
||||
if (!spirvExecutionMode)
|
||||
spirvExecutionMode = new TSpirvExecutionMode;
|
||||
|
||||
TVector<const TIntermConstantUnion*> extraOperands;
|
||||
if (args) {
|
||||
for (auto arg : args->getSequence()) {
|
||||
auto extraOperand = arg->getAsConstantUnion();
|
||||
assert(extraOperand != nullptr);
|
||||
extraOperands.push_back(extraOperand);
|
||||
}
|
||||
}
|
||||
spirvExecutionMode->modes[executionMode] = extraOperands;
|
||||
}
|
||||
|
||||
void TIntermediate::insertSpirvExecutionModeId(int executionMode, const TIntermAggregate* args)
|
||||
{
|
||||
if (!spirvExecutionMode)
|
||||
spirvExecutionMode = new TSpirvExecutionMode;
|
||||
|
||||
assert(args);
|
||||
TVector<const TIntermTyped*> extraOperands;
|
||||
|
||||
for (auto arg : args->getSequence()) {
|
||||
auto extraOperand = arg->getAsTyped();
|
||||
assert(extraOperand != nullptr && extraOperand->getQualifier().isConstant());
|
||||
extraOperands.push_back(extraOperand);
|
||||
}
|
||||
spirvExecutionMode->modeIds[executionMode] = extraOperands;
|
||||
}
|
||||
|
||||
//
|
||||
// Handle SPIR-V decorate qualifiers
|
||||
//
|
||||
void TQualifier::setSpirvDecorate(int decoration, const TIntermAggregate* args)
|
||||
{
|
||||
if (!spirvDecorate)
|
||||
spirvDecorate = new TSpirvDecorate;
|
||||
|
||||
TVector<const TIntermConstantUnion*> extraOperands;
|
||||
if (args) {
|
||||
for (auto arg : args->getSequence()) {
|
||||
auto extraOperand = arg->getAsConstantUnion();
|
||||
assert(extraOperand != nullptr);
|
||||
extraOperands.push_back(extraOperand);
|
||||
}
|
||||
}
|
||||
spirvDecorate->decorates[decoration] = extraOperands;
|
||||
}
|
||||
|
||||
void TQualifier::setSpirvDecorateId(int decoration, const TIntermAggregate* args)
|
||||
{
|
||||
if (!spirvDecorate)
|
||||
spirvDecorate = new TSpirvDecorate;
|
||||
|
||||
assert(args);
|
||||
TVector<const TIntermTyped*> extraOperands;
|
||||
for (auto arg : args->getSequence()) {
|
||||
auto extraOperand = arg->getAsTyped();
|
||||
assert(extraOperand != nullptr && extraOperand->getQualifier().isConstant());
|
||||
extraOperands.push_back(extraOperand);
|
||||
}
|
||||
spirvDecorate->decorateIds[decoration] = extraOperands;
|
||||
}
|
||||
|
||||
void TQualifier::setSpirvDecorateString(int decoration, const TIntermAggregate* args)
|
||||
{
|
||||
if (!spirvDecorate)
|
||||
spirvDecorate = new TSpirvDecorate;
|
||||
|
||||
assert(args);
|
||||
TVector<const TIntermConstantUnion*> extraOperands;
|
||||
for (auto arg : args->getSequence()) {
|
||||
auto extraOperand = arg->getAsConstantUnion();
|
||||
assert(extraOperand != nullptr);
|
||||
extraOperands.push_back(extraOperand);
|
||||
}
|
||||
spirvDecorate->decorateStrings[decoration] = extraOperands;
|
||||
}
|
||||
|
||||
TString TQualifier::getSpirvDecorateQualifierString() const
|
||||
{
|
||||
assert(spirvDecorate);
|
||||
|
||||
TString qualifierString;
|
||||
|
||||
const auto appendFloat = [&](float f) { qualifierString.append(std::to_string(f).c_str()); };
|
||||
const auto appendInt = [&](int i) { qualifierString.append(std::to_string(i).c_str()); };
|
||||
const auto appendUint = [&](unsigned int u) { qualifierString.append(std::to_string(u).c_str()); };
|
||||
const auto appendBool = [&](bool b) { qualifierString.append(std::to_string(b).c_str()); };
|
||||
const auto appendStr = [&](const char* s) { qualifierString.append(s); };
|
||||
|
||||
const auto appendDecorate = [&](const TIntermTyped* constant) {
|
||||
auto& constArray = constant->getAsConstantUnion() != nullptr ? constant->getAsConstantUnion()->getConstArray()
|
||||
: constant->getAsSymbolNode()->getConstArray();
|
||||
if (constant->getBasicType() == EbtFloat) {
|
||||
float value = static_cast<float>(constArray[0].getDConst());
|
||||
appendFloat(value);
|
||||
}
|
||||
else if (constant->getBasicType() == EbtInt) {
|
||||
int value = constArray[0].getIConst();
|
||||
appendInt(value);
|
||||
}
|
||||
else if (constant->getBasicType() == EbtUint) {
|
||||
unsigned value = constArray[0].getUConst();
|
||||
appendUint(value);
|
||||
}
|
||||
else if (constant->getBasicType() == EbtBool) {
|
||||
bool value = constArray[0].getBConst();
|
||||
appendBool(value);
|
||||
}
|
||||
else if (constant->getBasicType() == EbtString) {
|
||||
const TString* value = constArray[0].getSConst();
|
||||
appendStr(value->c_str());
|
||||
}
|
||||
else
|
||||
assert(0);
|
||||
};
|
||||
|
||||
for (auto& decorate : spirvDecorate->decorates) {
|
||||
appendStr("spirv_decorate(");
|
||||
appendInt(decorate.first);
|
||||
for (auto extraOperand : decorate.second) {
|
||||
appendStr(", ");
|
||||
appendDecorate(extraOperand);
|
||||
}
|
||||
appendStr(") ");
|
||||
}
|
||||
|
||||
for (auto& decorateId : spirvDecorate->decorateIds) {
|
||||
appendStr("spirv_decorate_id(");
|
||||
appendInt(decorateId.first);
|
||||
for (auto extraOperand : decorateId.second) {
|
||||
appendStr(", ");
|
||||
appendDecorate(extraOperand);
|
||||
}
|
||||
appendStr(") ");
|
||||
}
|
||||
|
||||
for (auto& decorateString : spirvDecorate->decorateStrings) {
|
||||
appendStr("spirv_decorate_string(");
|
||||
appendInt(decorateString.first);
|
||||
for (auto extraOperand : decorateString.second) {
|
||||
appendStr(", ");
|
||||
appendDecorate(extraOperand);
|
||||
}
|
||||
appendStr(") ");
|
||||
}
|
||||
|
||||
return qualifierString;
|
||||
}
|
||||
|
||||
//
|
||||
// Handle SPIR-V type specifiers
|
||||
//
|
||||
void TPublicType::setSpirvType(const TSpirvInstruction& spirvInst, const TSpirvTypeParameters* typeParams)
|
||||
{
|
||||
if (!spirvType)
|
||||
spirvType = new TSpirvType;
|
||||
|
||||
basicType = EbtSpirvType;
|
||||
spirvType->spirvInst = spirvInst;
|
||||
if (typeParams)
|
||||
spirvType->typeParams = *typeParams;
|
||||
}
|
||||
|
||||
TSpirvTypeParameters* TParseContext::makeSpirvTypeParameters(const TSourceLoc& loc, const TIntermConstantUnion* constant)
|
||||
{
|
||||
TSpirvTypeParameters* spirvTypeParams = new TSpirvTypeParameters;
|
||||
if (constant->getBasicType() != EbtFloat &&
|
||||
constant->getBasicType() != EbtInt &&
|
||||
constant->getBasicType() != EbtUint &&
|
||||
constant->getBasicType() != EbtBool &&
|
||||
constant->getBasicType() != EbtString)
|
||||
error(loc, "this type not allowed", constant->getType().getBasicString(), "");
|
||||
else {
|
||||
assert(constant);
|
||||
spirvTypeParams->push_back(TSpirvTypeParameter(constant));
|
||||
}
|
||||
|
||||
return spirvTypeParams;
|
||||
}
|
||||
|
||||
TSpirvTypeParameters* TParseContext::mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1, TSpirvTypeParameters* spirvTypeParams2)
|
||||
{
|
||||
// Merge SPIR-V type parameters of the second one to the first one
|
||||
for (const auto& spirvTypeParam : *spirvTypeParams2)
|
||||
spirvTypeParams1->push_back(spirvTypeParam);
|
||||
return spirvTypeParams1;
|
||||
}
|
||||
|
||||
//
|
||||
// Handle SPIR-V instruction qualifiers
|
||||
//
|
||||
TSpirvInstruction* TParseContext::makeSpirvInstruction(const TSourceLoc& loc, const TString& name, const TString& value)
|
||||
{
|
||||
TSpirvInstruction* spirvInst = new TSpirvInstruction;
|
||||
if (name == "set")
|
||||
spirvInst->set = value;
|
||||
else
|
||||
error(loc, "unknown SPIR-V instruction qualifier", name.c_str(), "");
|
||||
|
||||
return spirvInst;
|
||||
}
|
||||
|
||||
TSpirvInstruction* TParseContext::makeSpirvInstruction(const TSourceLoc& loc, const TString& name, int value)
|
||||
{
|
||||
TSpirvInstruction* spirvInstuction = new TSpirvInstruction;
|
||||
if (name == "id")
|
||||
spirvInstuction->id = value;
|
||||
else
|
||||
error(loc, "unknown SPIR-V instruction qualifier", name.c_str(), "");
|
||||
|
||||
return spirvInstuction;
|
||||
}
|
||||
|
||||
TSpirvInstruction* TParseContext::mergeSpirvInstruction(const TSourceLoc& loc, TSpirvInstruction* spirvInst1, TSpirvInstruction* spirvInst2)
|
||||
{
|
||||
// Merge qualifiers of the second SPIR-V instruction to those of the first one
|
||||
if (!spirvInst2->set.empty()) {
|
||||
if (spirvInst1->set.empty())
|
||||
spirvInst1->set = spirvInst2->set;
|
||||
else
|
||||
error(loc, "too many SPIR-V instruction qualifiers", "spirv_instruction", "(set)");
|
||||
}
|
||||
|
||||
if (spirvInst2->id != -1) {
|
||||
if (spirvInst1->id == -1)
|
||||
spirvInst1->id = spirvInst2->id;
|
||||
else
|
||||
error(loc, "too many SPIR-V instruction qualifiers", "spirv_instruction", "(id)");
|
||||
}
|
||||
|
||||
return spirvInst1;
|
||||
}
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
#endif // GLSLANG_WEB
|
||||
@@ -77,6 +77,7 @@ void TType::buildMangledName(TString& mangledName) const
|
||||
case EbtAtomicUint: mangledName += "au"; break;
|
||||
case EbtAccStruct: mangledName += "as"; break;
|
||||
case EbtRayQuery: mangledName += "rq"; break;
|
||||
case EbtSpirvType: mangledName += "spv-t"; break;
|
||||
#endif
|
||||
case EbtSampler:
|
||||
switch (sampler.type) {
|
||||
@@ -278,8 +279,14 @@ TFunction::~TFunction()
|
||||
//
|
||||
TSymbolTableLevel::~TSymbolTableLevel()
|
||||
{
|
||||
for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
|
||||
delete (*it).second;
|
||||
for (tLevel::iterator it = level.begin(); it != level.end(); ++it) {
|
||||
const TString& name = it->first;
|
||||
auto retargetIter = std::find_if(retargetedSymbols.begin(), retargetedSymbols.end(),
|
||||
[&name](const std::pair<TString, TString>& i) { return i.first == name; });
|
||||
if (retargetIter == retargetedSymbols.end())
|
||||
delete (*it).second;
|
||||
}
|
||||
|
||||
|
||||
delete [] defaultPrecision;
|
||||
}
|
||||
@@ -390,6 +397,9 @@ TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf)
|
||||
implicitThis = copyOf.implicitThis;
|
||||
illegalImplicitThis = copyOf.illegalImplicitThis;
|
||||
defaultParamCount = copyOf.defaultParamCount;
|
||||
#ifndef GLSLANG_WEB
|
||||
spirvInst = copyOf.spirvInst;
|
||||
#endif
|
||||
}
|
||||
|
||||
TFunction* TFunction::clone() const
|
||||
@@ -414,6 +424,10 @@ TSymbolTableLevel* TSymbolTableLevel::clone() const
|
||||
TSymbolTableLevel *symTableLevel = new TSymbolTableLevel();
|
||||
symTableLevel->anonId = anonId;
|
||||
symTableLevel->thisLevel = thisLevel;
|
||||
symTableLevel->retargetedSymbols.clear();
|
||||
for (auto &s : retargetedSymbols) {
|
||||
symTableLevel->retargetedSymbols.push_back({s.first, s.second});
|
||||
}
|
||||
std::vector<bool> containerCopied(anonId, false);
|
||||
tLevel::const_iterator iter;
|
||||
for (iter = level.begin(); iter != level.end(); ++iter) {
|
||||
@@ -429,8 +443,21 @@ TSymbolTableLevel* TSymbolTableLevel::clone() const
|
||||
symTableLevel->insert(*container, false);
|
||||
containerCopied[anon->getAnonId()] = true;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
const TString& name = iter->first;
|
||||
auto retargetIter = std::find_if(retargetedSymbols.begin(), retargetedSymbols.end(),
|
||||
[&name](const std::pair<TString, TString>& i) { return i.first == name; });
|
||||
if (retargetIter != retargetedSymbols.end())
|
||||
continue;
|
||||
symTableLevel->insert(*iter->second->clone(), false);
|
||||
}
|
||||
}
|
||||
// Now point retargeted symbols to the newly created versions of them
|
||||
for (auto &s : retargetedSymbols) {
|
||||
TSymbol* sym = symTableLevel->find(s.second);
|
||||
if (!sym)
|
||||
continue;
|
||||
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
|
||||
|
||||
@@ -319,6 +319,15 @@ public:
|
||||
virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
|
||||
virtual const TParameter& operator[](int i) const { return parameters[i]; }
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
virtual void setSpirvInstruction(const TSpirvInstruction& inst)
|
||||
{
|
||||
relateToOperator(EOpSpirvInst);
|
||||
spirvInst = inst;
|
||||
}
|
||||
virtual const TSpirvInstruction& getSpirvInstruction() const { return spirvInst; }
|
||||
#endif
|
||||
|
||||
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
|
||||
virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
|
||||
#endif
|
||||
@@ -342,6 +351,10 @@ protected:
|
||||
// This is important for a static member function that has member variables in scope,
|
||||
// but is not allowed to use them, or see hidden symbols instead.
|
||||
int defaultParamCount;
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
TSpirvInstruction spirvInst; // SPIR-V instruction qualifiers
|
||||
#endif
|
||||
};
|
||||
|
||||
//
|
||||
@@ -400,13 +413,20 @@ public:
|
||||
TSymbolTableLevel() : defaultPrecision(0), anonId(0), thisLevel(false) { }
|
||||
~TSymbolTableLevel();
|
||||
|
||||
bool insert(TSymbol& symbol, bool separateNameSpaces)
|
||||
bool insert(const TString& name, TSymbol* symbol) {
|
||||
return level.insert(tLevelPair(name, symbol)).second;
|
||||
}
|
||||
|
||||
bool insert(TSymbol& symbol, bool separateNameSpaces, const TString& forcedKeyName = TString())
|
||||
{
|
||||
//
|
||||
// returning true means symbol was added to the table with no semantic errors
|
||||
//
|
||||
const TString& name = symbol.getName();
|
||||
if (name == "") {
|
||||
if (forcedKeyName.length()) {
|
||||
return level.insert(tLevelPair(forcedKeyName, &symbol)).second;
|
||||
}
|
||||
else if (name == "") {
|
||||
symbol.getAsVariable()->setAnonId(anonId++);
|
||||
// An empty name means an anonymous container, exposing its members to the external scope.
|
||||
// Give it a name and insert its members in the symbol table, pointing to the container.
|
||||
@@ -458,6 +478,16 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void retargetSymbol(const TString& from, const TString& to) {
|
||||
tLevel::const_iterator fromIt = level.find(from);
|
||||
tLevel::const_iterator toIt = level.find(to);
|
||||
if (fromIt == level.end() || toIt == level.end())
|
||||
return;
|
||||
delete fromIt->second;
|
||||
level[from] = toIt->second;
|
||||
retargetedSymbols.push_back({from, to});
|
||||
}
|
||||
|
||||
TSymbol* find(const TString& name) const
|
||||
{
|
||||
tLevel::const_iterator it = level.find(name);
|
||||
@@ -570,6 +600,8 @@ protected:
|
||||
|
||||
tLevel level; // named mappings
|
||||
TPrecisionQualifier *defaultPrecision;
|
||||
// pair<FromName, ToName>
|
||||
TVector<std::pair<TString, TString>> retargetedSymbols;
|
||||
int anonId;
|
||||
bool thisLevel; // True if this level of the symbol table is a structure scope containing member function
|
||||
// that are supposed to see anonymous access to member variables.
|
||||
@@ -775,6 +807,12 @@ public:
|
||||
return symbol;
|
||||
}
|
||||
|
||||
void retargetSymbol(const TString& from, const TString& to) {
|
||||
int level = currentLevel();
|
||||
table[level]->retargetSymbol(from, to);
|
||||
}
|
||||
|
||||
|
||||
// Find of a symbol that returns how many layers deep of nested
|
||||
// structures-with-member-functions ('this' scopes) deep the symbol was
|
||||
// found in.
|
||||
|
||||
@@ -165,12 +165,14 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
EShTargetLanguageVersion minSpvVersion;
|
||||
} extensionData;
|
||||
|
||||
const extensionData exts[] = { {E_GL_EXT_ray_tracing, EShTargetSpv_1_4} };
|
||||
const extensionData exts[] = { {E_GL_EXT_ray_tracing, EShTargetSpv_1_4},
|
||||
{E_GL_NV_ray_tracing_motion_blur, EShTargetSpv_1_4}
|
||||
};
|
||||
|
||||
for (size_t ii = 0; ii < sizeof(exts) / sizeof(exts[0]); ii++) {
|
||||
// Add only extensions which require > spv1.0 to save space in map
|
||||
if (exts[ii].minSpvVersion > EShTargetSpv_1_0) {
|
||||
extensionMinSpv[E_GL_EXT_ray_tracing] = exts[ii].minSpvVersion;
|
||||
extensionMinSpv[exts[ii].extensionName] = exts[ii].minSpvVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +201,7 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
extensionBehavior[E_GL_ARB_explicit_uniform_location] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shader_image_load_store] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shader_atomic_counters] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shader_atomic_counter_ops] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shader_draw_parameters] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shader_group_vote] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_derivative_control] = EBhDisable;
|
||||
@@ -223,6 +226,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;
|
||||
@@ -252,6 +258,7 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
|
||||
extensionBehavior[E_GL_EXT_shader_16bit_storage] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_shader_8bit_storage] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_subgroup_uniform_control_flow] = EBhDisable;
|
||||
|
||||
// #line and #include
|
||||
extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable;
|
||||
@@ -281,6 +288,7 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
extensionBehavior[E_GL_NV_shader_subgroup_partitioned] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_shading_rate_image] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_ray_tracing] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_ray_tracing_motion_blur] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_fragment_shader_barycentric] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_compute_shader_derivatives] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_shader_texture_footprint] = EBhDisable;
|
||||
@@ -333,6 +341,7 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
extensionBehavior[E_GL_EXT_shader_image_int64] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_terminate_invocation] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_shared_memory_block] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_spirv_intrinsics] = EBhDisable;
|
||||
|
||||
// OVR extensions
|
||||
extensionBehavior[E_GL_OVR_multiview] = EBhDisable;
|
||||
@@ -354,6 +363,7 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_int64] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_float16] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_shader_atomic_float] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_shader_atomic_float2] = EBhDisable;
|
||||
}
|
||||
|
||||
#endif // GLSLANG_WEB
|
||||
@@ -417,6 +427,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
}
|
||||
if (version >= 310) {
|
||||
preamble += "#define GL_EXT_null_initializer 1\n";
|
||||
preamble += "#define GL_EXT_subgroup_uniform_control_flow 1\n";
|
||||
}
|
||||
|
||||
} else { // !isEsProfile()
|
||||
@@ -460,6 +471,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"
|
||||
@@ -477,6 +490,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
"#define GL_EXT_debug_printf 1\n"
|
||||
"#define GL_EXT_fragment_shading_rate 1\n"
|
||||
"#define GL_EXT_shared_memory_block 1\n"
|
||||
"#define GL_EXT_shader_integer_mix 1\n"
|
||||
|
||||
// GL_KHR_shader_subgroup
|
||||
"#define GL_KHR_shader_subgroup_basic 1\n"
|
||||
@@ -494,6 +508,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
"#define GL_EXT_ray_tracing 1\n"
|
||||
"#define GL_EXT_ray_query 1\n"
|
||||
"#define GL_EXT_ray_flags_primitive_culling 1\n"
|
||||
"#define GL_EXT_spirv_intrinsics 1\n"
|
||||
|
||||
"#define GL_AMD_shader_ballot 1\n"
|
||||
"#define GL_AMD_shader_trinary_minmax 1\n"
|
||||
@@ -516,6 +531,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
"#define GL_NV_shader_subgroup_partitioned 1\n"
|
||||
"#define GL_NV_shading_rate_image 1\n"
|
||||
"#define GL_NV_ray_tracing 1\n"
|
||||
"#define GL_NV_ray_tracing_motion_blur 1\n"
|
||||
"#define GL_NV_fragment_shader_barycentric 1\n"
|
||||
"#define GL_NV_compute_shader_derivatives 1\n"
|
||||
"#define GL_NV_shader_texture_footprint 1\n"
|
||||
@@ -538,6 +554,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
"#define GL_EXT_shader_subgroup_extended_types_float16 1\n"
|
||||
|
||||
"#define GL_EXT_shader_atomic_float 1\n"
|
||||
"#define GL_EXT_shader_atomic_float2 1\n"
|
||||
;
|
||||
|
||||
if (version >= 150) {
|
||||
@@ -549,6 +566,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
}
|
||||
if (version >= 140) {
|
||||
preamble += "#define GL_EXT_null_initializer 1\n";
|
||||
preamble += "#define GL_EXT_subgroup_uniform_control_flow 1\n";
|
||||
}
|
||||
#endif // GLSLANG_WEB
|
||||
}
|
||||
@@ -602,6 +620,29 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
preamble += "\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// GL_EXT_spirv_intrinsics
|
||||
if (!isEsProfile()) {
|
||||
switch (language) {
|
||||
case EShLangVertex: preamble += "#define GL_VERTEX_SHADER 1 \n"; break;
|
||||
case EShLangTessControl: preamble += "#define GL_TESSELLATION_CONTROL_SHADER 1 \n"; break;
|
||||
case EShLangTessEvaluation: preamble += "#define GL_TESSELLATION_EVALUATION_SHADER 1 \n"; break;
|
||||
case EShLangGeometry: preamble += "#define GL_GEOMETRY_SHADER 1 \n"; break;
|
||||
case EShLangFragment: preamble += "#define GL_FRAGMENT_SHADER 1 \n"; break;
|
||||
case EShLangCompute: preamble += "#define GL_COMPUTE_SHADER 1 \n"; break;
|
||||
case EShLangRayGen: preamble += "#define GL_RAY_GENERATION_SHADER_EXT 1 \n"; break;
|
||||
case EShLangIntersect: preamble += "#define GL_INTERSECTION_SHADER_EXT 1 \n"; break;
|
||||
case EShLangAnyHit: preamble += "#define GL_ANY_HIT_SHADER_EXT 1 \n"; break;
|
||||
case EShLangClosestHit: preamble += "#define GL_CLOSEST_HIT_SHADER_EXT 1 \n"; break;
|
||||
case EShLangMiss: preamble += "#define GL_MISS_SHADER_EXT 1 \n"; break;
|
||||
case EShLangCallable: preamble += "#define GL_CALLABLE_SHADER_EXT 1 \n"; break;
|
||||
case EShLangTaskNV: preamble += "#define GL_TASK_SHADER_NV 1 \n"; break;
|
||||
case EShLangMeshNV: preamble += "#define GL_MESH_SHADER_NV 1 \n"; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
@@ -878,7 +919,7 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
|
||||
checkExtensionStage(getCurrentLoc(), extension);
|
||||
|
||||
// check if extension has additional requirements
|
||||
extensionRequires(getCurrentLoc(), extension ,behaviorString);
|
||||
extensionRequires(getCurrentLoc(), extension, behaviorString);
|
||||
|
||||
// update the requested extension
|
||||
updateExtensionBehavior(extension, behavior);
|
||||
|
||||
@@ -137,6 +137,7 @@ const char* const E_GL_ARB_explicit_attrib_location = "GL_ARB_explicit_attri
|
||||
const char* const E_GL_ARB_explicit_uniform_location = "GL_ARB_explicit_uniform_location";
|
||||
const char* const E_GL_ARB_shader_image_load_store = "GL_ARB_shader_image_load_store";
|
||||
const char* const E_GL_ARB_shader_atomic_counters = "GL_ARB_shader_atomic_counters";
|
||||
const char* const E_GL_ARB_shader_atomic_counter_ops = "GL_ARB_shader_atomic_counter_ops";
|
||||
const char* const E_GL_ARB_shader_draw_parameters = "GL_ARB_shader_draw_parameters";
|
||||
const char* const E_GL_ARB_shader_group_vote = "GL_ARB_shader_group_vote";
|
||||
const char* const E_GL_ARB_derivative_control = "GL_ARB_derivative_control";
|
||||
@@ -161,6 +162,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";
|
||||
@@ -205,6 +208,8 @@ const char* const E_GL_EXT_fragment_shading_rate = "GL_EXT_fragment_s
|
||||
const char* const E_GL_EXT_shader_image_int64 = "GL_EXT_shader_image_int64";
|
||||
const char* const E_GL_EXT_null_initializer = "GL_EXT_null_initializer";
|
||||
const char* const E_GL_EXT_shared_memory_block = "GL_EXT_shared_memory_block";
|
||||
const char* const E_GL_EXT_subgroup_uniform_control_flow = "GL_EXT_subgroup_uniform_control_flow";
|
||||
const char* const E_GL_EXT_spirv_intrinsics = "GL_EXT_spirv_intrinsics";
|
||||
|
||||
// Arrays of extensions for the above viewportEXTs duplications
|
||||
|
||||
@@ -246,6 +251,7 @@ const char* const E_GL_NV_shader_noperspective_interpolation = "GL_NV_shader_
|
||||
const char* const E_GL_NV_shader_subgroup_partitioned = "GL_NV_shader_subgroup_partitioned";
|
||||
const char* const E_GL_NV_shading_rate_image = "GL_NV_shading_rate_image";
|
||||
const char* const E_GL_NV_ray_tracing = "GL_NV_ray_tracing";
|
||||
const char* const E_GL_NV_ray_tracing_motion_blur = "GL_NV_ray_tracing_motion_blur";
|
||||
const char* const E_GL_NV_fragment_shader_barycentric = "GL_NV_fragment_shader_barycentric";
|
||||
const char* const E_GL_NV_compute_shader_derivatives = "GL_NV_compute_shader_derivatives";
|
||||
const char* const E_GL_NV_shader_texture_footprint = "GL_NV_shader_texture_footprint";
|
||||
@@ -306,6 +312,7 @@ const char* const E_GL_EXT_shader_subgroup_extended_types_float16 = "GL_EXT_shad
|
||||
const char* const E_GL_EXT_terminate_invocation = "GL_EXT_terminate_invocation";
|
||||
|
||||
const char* const E_GL_EXT_shader_atomic_float = "GL_EXT_shader_atomic_float";
|
||||
const char* const E_GL_EXT_shader_atomic_float2 = "GL_EXT_shader_atomic_float2";
|
||||
|
||||
// Arrays of extensions for the above AEP duplications
|
||||
|
||||
|
||||
@@ -123,6 +123,8 @@ TAttributeType TParseContext::attributeFromName(const TString& name) const
|
||||
return EatPeelCount;
|
||||
else if (name == "partial_count")
|
||||
return EatPartialCount;
|
||||
else if (name == "subgroup_uniform_control_flow")
|
||||
return EatSubgroupUniformControlFlow;
|
||||
else
|
||||
return EatNone;
|
||||
}
|
||||
@@ -341,6 +343,29 @@ void TParseContext::handleLoopAttributes(const TAttributes& attributes, TIntermN
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Function attributes
|
||||
//
|
||||
void TParseContext::handleFunctionAttributes(const TSourceLoc& loc, const TAttributes& attributes)
|
||||
{
|
||||
for (auto it = attributes.begin(); it != attributes.end(); ++it) {
|
||||
if (it->size() > 0) {
|
||||
warn(loc, "attribute with arguments not recognized, skipping", "", "");
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (it->name) {
|
||||
case EatSubgroupUniformControlFlow:
|
||||
intermediate.setSubgroupUniformControlFlow();
|
||||
break;
|
||||
default:
|
||||
warn(loc, "attribute does not apply to a function", "", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
#endif // GLSLANG_WEB
|
||||
|
||||
@@ -118,7 +118,8 @@ namespace glslang {
|
||||
EatFormatR8ui,
|
||||
EatFormatUnknown,
|
||||
EatNonWritable,
|
||||
EatNonReadable
|
||||
EatNonReadable,
|
||||
EatSubgroupUniformControlFlow,
|
||||
};
|
||||
|
||||
class TIntermAggregate;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -368,134 +368,144 @@ extern int yydebug;
|
||||
USUBPASSINPUTMS = 569, /* USUBPASSINPUTMS */
|
||||
F16SUBPASSINPUT = 570, /* F16SUBPASSINPUT */
|
||||
F16SUBPASSINPUTMS = 571, /* F16SUBPASSINPUTMS */
|
||||
LEFT_OP = 572, /* LEFT_OP */
|
||||
RIGHT_OP = 573, /* RIGHT_OP */
|
||||
INC_OP = 574, /* INC_OP */
|
||||
DEC_OP = 575, /* DEC_OP */
|
||||
LE_OP = 576, /* LE_OP */
|
||||
GE_OP = 577, /* GE_OP */
|
||||
EQ_OP = 578, /* EQ_OP */
|
||||
NE_OP = 579, /* NE_OP */
|
||||
AND_OP = 580, /* AND_OP */
|
||||
OR_OP = 581, /* OR_OP */
|
||||
XOR_OP = 582, /* XOR_OP */
|
||||
MUL_ASSIGN = 583, /* MUL_ASSIGN */
|
||||
DIV_ASSIGN = 584, /* DIV_ASSIGN */
|
||||
ADD_ASSIGN = 585, /* ADD_ASSIGN */
|
||||
MOD_ASSIGN = 586, /* MOD_ASSIGN */
|
||||
LEFT_ASSIGN = 587, /* LEFT_ASSIGN */
|
||||
RIGHT_ASSIGN = 588, /* RIGHT_ASSIGN */
|
||||
AND_ASSIGN = 589, /* AND_ASSIGN */
|
||||
XOR_ASSIGN = 590, /* XOR_ASSIGN */
|
||||
OR_ASSIGN = 591, /* OR_ASSIGN */
|
||||
SUB_ASSIGN = 592, /* SUB_ASSIGN */
|
||||
STRING_LITERAL = 593, /* STRING_LITERAL */
|
||||
LEFT_PAREN = 594, /* LEFT_PAREN */
|
||||
RIGHT_PAREN = 595, /* RIGHT_PAREN */
|
||||
LEFT_BRACKET = 596, /* LEFT_BRACKET */
|
||||
RIGHT_BRACKET = 597, /* RIGHT_BRACKET */
|
||||
LEFT_BRACE = 598, /* LEFT_BRACE */
|
||||
RIGHT_BRACE = 599, /* RIGHT_BRACE */
|
||||
DOT = 600, /* DOT */
|
||||
COMMA = 601, /* COMMA */
|
||||
COLON = 602, /* COLON */
|
||||
EQUAL = 603, /* EQUAL */
|
||||
SEMICOLON = 604, /* SEMICOLON */
|
||||
BANG = 605, /* BANG */
|
||||
DASH = 606, /* DASH */
|
||||
TILDE = 607, /* TILDE */
|
||||
PLUS = 608, /* PLUS */
|
||||
STAR = 609, /* STAR */
|
||||
SLASH = 610, /* SLASH */
|
||||
PERCENT = 611, /* PERCENT */
|
||||
LEFT_ANGLE = 612, /* LEFT_ANGLE */
|
||||
RIGHT_ANGLE = 613, /* RIGHT_ANGLE */
|
||||
VERTICAL_BAR = 614, /* VERTICAL_BAR */
|
||||
CARET = 615, /* CARET */
|
||||
AMPERSAND = 616, /* AMPERSAND */
|
||||
QUESTION = 617, /* QUESTION */
|
||||
INVARIANT = 618, /* INVARIANT */
|
||||
HIGH_PRECISION = 619, /* HIGH_PRECISION */
|
||||
MEDIUM_PRECISION = 620, /* MEDIUM_PRECISION */
|
||||
LOW_PRECISION = 621, /* LOW_PRECISION */
|
||||
PRECISION = 622, /* PRECISION */
|
||||
PACKED = 623, /* PACKED */
|
||||
RESOURCE = 624, /* RESOURCE */
|
||||
SUPERP = 625, /* SUPERP */
|
||||
FLOATCONSTANT = 626, /* FLOATCONSTANT */
|
||||
INTCONSTANT = 627, /* INTCONSTANT */
|
||||
UINTCONSTANT = 628, /* UINTCONSTANT */
|
||||
BOOLCONSTANT = 629, /* BOOLCONSTANT */
|
||||
IDENTIFIER = 630, /* IDENTIFIER */
|
||||
TYPE_NAME = 631, /* TYPE_NAME */
|
||||
CENTROID = 632, /* CENTROID */
|
||||
IN = 633, /* IN */
|
||||
OUT = 634, /* OUT */
|
||||
INOUT = 635, /* INOUT */
|
||||
STRUCT = 636, /* STRUCT */
|
||||
VOID = 637, /* VOID */
|
||||
WHILE = 638, /* WHILE */
|
||||
BREAK = 639, /* BREAK */
|
||||
CONTINUE = 640, /* CONTINUE */
|
||||
DO = 641, /* DO */
|
||||
ELSE = 642, /* ELSE */
|
||||
FOR = 643, /* FOR */
|
||||
IF = 644, /* IF */
|
||||
DISCARD = 645, /* DISCARD */
|
||||
RETURN = 646, /* RETURN */
|
||||
SWITCH = 647, /* SWITCH */
|
||||
CASE = 648, /* CASE */
|
||||
DEFAULT = 649, /* DEFAULT */
|
||||
TERMINATE_INVOCATION = 650, /* TERMINATE_INVOCATION */
|
||||
TERMINATE_RAY = 651, /* TERMINATE_RAY */
|
||||
IGNORE_INTERSECTION = 652, /* IGNORE_INTERSECTION */
|
||||
UNIFORM = 653, /* UNIFORM */
|
||||
SHARED = 654, /* SHARED */
|
||||
BUFFER = 655, /* BUFFER */
|
||||
FLAT = 656, /* FLAT */
|
||||
SMOOTH = 657, /* SMOOTH */
|
||||
LAYOUT = 658, /* LAYOUT */
|
||||
DOUBLECONSTANT = 659, /* DOUBLECONSTANT */
|
||||
INT16CONSTANT = 660, /* INT16CONSTANT */
|
||||
UINT16CONSTANT = 661, /* UINT16CONSTANT */
|
||||
FLOAT16CONSTANT = 662, /* FLOAT16CONSTANT */
|
||||
INT32CONSTANT = 663, /* INT32CONSTANT */
|
||||
UINT32CONSTANT = 664, /* UINT32CONSTANT */
|
||||
INT64CONSTANT = 665, /* INT64CONSTANT */
|
||||
UINT64CONSTANT = 666, /* UINT64CONSTANT */
|
||||
SUBROUTINE = 667, /* SUBROUTINE */
|
||||
DEMOTE = 668, /* DEMOTE */
|
||||
PAYLOADNV = 669, /* PAYLOADNV */
|
||||
PAYLOADINNV = 670, /* PAYLOADINNV */
|
||||
HITATTRNV = 671, /* HITATTRNV */
|
||||
CALLDATANV = 672, /* CALLDATANV */
|
||||
CALLDATAINNV = 673, /* CALLDATAINNV */
|
||||
PAYLOADEXT = 674, /* PAYLOADEXT */
|
||||
PAYLOADINEXT = 675, /* PAYLOADINEXT */
|
||||
HITATTREXT = 676, /* HITATTREXT */
|
||||
CALLDATAEXT = 677, /* CALLDATAEXT */
|
||||
CALLDATAINEXT = 678, /* CALLDATAINEXT */
|
||||
PATCH = 679, /* PATCH */
|
||||
SAMPLE = 680, /* SAMPLE */
|
||||
NONUNIFORM = 681, /* NONUNIFORM */
|
||||
COHERENT = 682, /* COHERENT */
|
||||
VOLATILE = 683, /* VOLATILE */
|
||||
RESTRICT = 684, /* RESTRICT */
|
||||
READONLY = 685, /* READONLY */
|
||||
WRITEONLY = 686, /* WRITEONLY */
|
||||
DEVICECOHERENT = 687, /* DEVICECOHERENT */
|
||||
QUEUEFAMILYCOHERENT = 688, /* QUEUEFAMILYCOHERENT */
|
||||
WORKGROUPCOHERENT = 689, /* WORKGROUPCOHERENT */
|
||||
SUBGROUPCOHERENT = 690, /* SUBGROUPCOHERENT */
|
||||
NONPRIVATE = 691, /* NONPRIVATE */
|
||||
SHADERCALLCOHERENT = 692, /* SHADERCALLCOHERENT */
|
||||
NOPERSPECTIVE = 693, /* NOPERSPECTIVE */
|
||||
EXPLICITINTERPAMD = 694, /* EXPLICITINTERPAMD */
|
||||
PERVERTEXNV = 695, /* PERVERTEXNV */
|
||||
PERPRIMITIVENV = 696, /* PERPRIMITIVENV */
|
||||
PERVIEWNV = 697, /* PERVIEWNV */
|
||||
PERTASKNV = 698, /* PERTASKNV */
|
||||
PRECISE = 699 /* PRECISE */
|
||||
SPIRV_INSTRUCTION = 572, /* SPIRV_INSTRUCTION */
|
||||
SPIRV_EXECUTION_MODE = 573, /* SPIRV_EXECUTION_MODE */
|
||||
SPIRV_EXECUTION_MODE_ID = 574, /* SPIRV_EXECUTION_MODE_ID */
|
||||
SPIRV_DECORATE = 575, /* SPIRV_DECORATE */
|
||||
SPIRV_DECORATE_ID = 576, /* SPIRV_DECORATE_ID */
|
||||
SPIRV_DECORATE_STRING = 577, /* SPIRV_DECORATE_STRING */
|
||||
SPIRV_TYPE = 578, /* SPIRV_TYPE */
|
||||
SPIRV_STORAGE_CLASS = 579, /* SPIRV_STORAGE_CLASS */
|
||||
SPIRV_BY_REFERENCE = 580, /* SPIRV_BY_REFERENCE */
|
||||
SPIRV_LITERAL = 581, /* SPIRV_LITERAL */
|
||||
LEFT_OP = 582, /* LEFT_OP */
|
||||
RIGHT_OP = 583, /* RIGHT_OP */
|
||||
INC_OP = 584, /* INC_OP */
|
||||
DEC_OP = 585, /* DEC_OP */
|
||||
LE_OP = 586, /* LE_OP */
|
||||
GE_OP = 587, /* GE_OP */
|
||||
EQ_OP = 588, /* EQ_OP */
|
||||
NE_OP = 589, /* NE_OP */
|
||||
AND_OP = 590, /* AND_OP */
|
||||
OR_OP = 591, /* OR_OP */
|
||||
XOR_OP = 592, /* XOR_OP */
|
||||
MUL_ASSIGN = 593, /* MUL_ASSIGN */
|
||||
DIV_ASSIGN = 594, /* DIV_ASSIGN */
|
||||
ADD_ASSIGN = 595, /* ADD_ASSIGN */
|
||||
MOD_ASSIGN = 596, /* MOD_ASSIGN */
|
||||
LEFT_ASSIGN = 597, /* LEFT_ASSIGN */
|
||||
RIGHT_ASSIGN = 598, /* RIGHT_ASSIGN */
|
||||
AND_ASSIGN = 599, /* AND_ASSIGN */
|
||||
XOR_ASSIGN = 600, /* XOR_ASSIGN */
|
||||
OR_ASSIGN = 601, /* OR_ASSIGN */
|
||||
SUB_ASSIGN = 602, /* SUB_ASSIGN */
|
||||
STRING_LITERAL = 603, /* STRING_LITERAL */
|
||||
LEFT_PAREN = 604, /* LEFT_PAREN */
|
||||
RIGHT_PAREN = 605, /* RIGHT_PAREN */
|
||||
LEFT_BRACKET = 606, /* LEFT_BRACKET */
|
||||
RIGHT_BRACKET = 607, /* RIGHT_BRACKET */
|
||||
LEFT_BRACE = 608, /* LEFT_BRACE */
|
||||
RIGHT_BRACE = 609, /* RIGHT_BRACE */
|
||||
DOT = 610, /* DOT */
|
||||
COMMA = 611, /* COMMA */
|
||||
COLON = 612, /* COLON */
|
||||
EQUAL = 613, /* EQUAL */
|
||||
SEMICOLON = 614, /* SEMICOLON */
|
||||
BANG = 615, /* BANG */
|
||||
DASH = 616, /* DASH */
|
||||
TILDE = 617, /* TILDE */
|
||||
PLUS = 618, /* PLUS */
|
||||
STAR = 619, /* STAR */
|
||||
SLASH = 620, /* SLASH */
|
||||
PERCENT = 621, /* PERCENT */
|
||||
LEFT_ANGLE = 622, /* LEFT_ANGLE */
|
||||
RIGHT_ANGLE = 623, /* RIGHT_ANGLE */
|
||||
VERTICAL_BAR = 624, /* VERTICAL_BAR */
|
||||
CARET = 625, /* CARET */
|
||||
AMPERSAND = 626, /* AMPERSAND */
|
||||
QUESTION = 627, /* QUESTION */
|
||||
INVARIANT = 628, /* INVARIANT */
|
||||
HIGH_PRECISION = 629, /* HIGH_PRECISION */
|
||||
MEDIUM_PRECISION = 630, /* MEDIUM_PRECISION */
|
||||
LOW_PRECISION = 631, /* LOW_PRECISION */
|
||||
PRECISION = 632, /* PRECISION */
|
||||
PACKED = 633, /* PACKED */
|
||||
RESOURCE = 634, /* RESOURCE */
|
||||
SUPERP = 635, /* SUPERP */
|
||||
FLOATCONSTANT = 636, /* FLOATCONSTANT */
|
||||
INTCONSTANT = 637, /* INTCONSTANT */
|
||||
UINTCONSTANT = 638, /* UINTCONSTANT */
|
||||
BOOLCONSTANT = 639, /* BOOLCONSTANT */
|
||||
IDENTIFIER = 640, /* IDENTIFIER */
|
||||
TYPE_NAME = 641, /* TYPE_NAME */
|
||||
CENTROID = 642, /* CENTROID */
|
||||
IN = 643, /* IN */
|
||||
OUT = 644, /* OUT */
|
||||
INOUT = 645, /* INOUT */
|
||||
STRUCT = 646, /* STRUCT */
|
||||
VOID = 647, /* VOID */
|
||||
WHILE = 648, /* WHILE */
|
||||
BREAK = 649, /* BREAK */
|
||||
CONTINUE = 650, /* CONTINUE */
|
||||
DO = 651, /* DO */
|
||||
ELSE = 652, /* ELSE */
|
||||
FOR = 653, /* FOR */
|
||||
IF = 654, /* IF */
|
||||
DISCARD = 655, /* DISCARD */
|
||||
RETURN = 656, /* RETURN */
|
||||
SWITCH = 657, /* SWITCH */
|
||||
CASE = 658, /* CASE */
|
||||
DEFAULT = 659, /* DEFAULT */
|
||||
TERMINATE_INVOCATION = 660, /* TERMINATE_INVOCATION */
|
||||
TERMINATE_RAY = 661, /* TERMINATE_RAY */
|
||||
IGNORE_INTERSECTION = 662, /* IGNORE_INTERSECTION */
|
||||
UNIFORM = 663, /* UNIFORM */
|
||||
SHARED = 664, /* SHARED */
|
||||
BUFFER = 665, /* BUFFER */
|
||||
FLAT = 666, /* FLAT */
|
||||
SMOOTH = 667, /* SMOOTH */
|
||||
LAYOUT = 668, /* LAYOUT */
|
||||
DOUBLECONSTANT = 669, /* DOUBLECONSTANT */
|
||||
INT16CONSTANT = 670, /* INT16CONSTANT */
|
||||
UINT16CONSTANT = 671, /* UINT16CONSTANT */
|
||||
FLOAT16CONSTANT = 672, /* FLOAT16CONSTANT */
|
||||
INT32CONSTANT = 673, /* INT32CONSTANT */
|
||||
UINT32CONSTANT = 674, /* UINT32CONSTANT */
|
||||
INT64CONSTANT = 675, /* INT64CONSTANT */
|
||||
UINT64CONSTANT = 676, /* UINT64CONSTANT */
|
||||
SUBROUTINE = 677, /* SUBROUTINE */
|
||||
DEMOTE = 678, /* DEMOTE */
|
||||
PAYLOADNV = 679, /* PAYLOADNV */
|
||||
PAYLOADINNV = 680, /* PAYLOADINNV */
|
||||
HITATTRNV = 681, /* HITATTRNV */
|
||||
CALLDATANV = 682, /* CALLDATANV */
|
||||
CALLDATAINNV = 683, /* CALLDATAINNV */
|
||||
PAYLOADEXT = 684, /* PAYLOADEXT */
|
||||
PAYLOADINEXT = 685, /* PAYLOADINEXT */
|
||||
HITATTREXT = 686, /* HITATTREXT */
|
||||
CALLDATAEXT = 687, /* CALLDATAEXT */
|
||||
CALLDATAINEXT = 688, /* CALLDATAINEXT */
|
||||
PATCH = 689, /* PATCH */
|
||||
SAMPLE = 690, /* SAMPLE */
|
||||
NONUNIFORM = 691, /* NONUNIFORM */
|
||||
COHERENT = 692, /* COHERENT */
|
||||
VOLATILE = 693, /* VOLATILE */
|
||||
RESTRICT = 694, /* RESTRICT */
|
||||
READONLY = 695, /* READONLY */
|
||||
WRITEONLY = 696, /* WRITEONLY */
|
||||
DEVICECOHERENT = 697, /* DEVICECOHERENT */
|
||||
QUEUEFAMILYCOHERENT = 698, /* QUEUEFAMILYCOHERENT */
|
||||
WORKGROUPCOHERENT = 699, /* WORKGROUPCOHERENT */
|
||||
SUBGROUPCOHERENT = 700, /* SUBGROUPCOHERENT */
|
||||
NONPRIVATE = 701, /* NONPRIVATE */
|
||||
SHADERCALLCOHERENT = 702, /* SHADERCALLCOHERENT */
|
||||
NOPERSPECTIVE = 703, /* NOPERSPECTIVE */
|
||||
EXPLICITINTERPAMD = 704, /* EXPLICITINTERPAMD */
|
||||
PERVERTEXNV = 705, /* PERVERTEXNV */
|
||||
PERPRIMITIVENV = 706, /* PERPRIMITIVENV */
|
||||
PERVIEWNV = 707, /* PERVIEWNV */
|
||||
PERTASKNV = 708, /* PERTASKNV */
|
||||
PRECISE = 709 /* PRECISE */
|
||||
};
|
||||
typedef enum yytokentype yytoken_kind_t;
|
||||
#endif
|
||||
@@ -527,6 +537,9 @@ union YYSTYPE
|
||||
glslang::TIntermNodePair nodePair;
|
||||
glslang::TIntermTyped* intermTypedNode;
|
||||
glslang::TAttributes* attributes;
|
||||
glslang::TSpirvRequirement* spirvReq;
|
||||
glslang::TSpirvInstruction* spirvInst;
|
||||
glslang::TSpirvTypeParameters* spirvTypeParams;
|
||||
};
|
||||
union {
|
||||
glslang::TPublicType type;
|
||||
@@ -540,7 +553,7 @@ union YYSTYPE
|
||||
glslang::TArraySizes* typeParameters;
|
||||
} interm;
|
||||
|
||||
#line 544 "MachineIndependent/glslang_tab.cpp.h"
|
||||
#line 557 "MachineIndependent/glslang_tab.cpp.h"
|
||||
|
||||
};
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -696,6 +665,10 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
|
||||
|
||||
case EOpConstructReference: out.debug << "Construct reference type"; break;
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
case EOpSpirvInst: out.debug << "spirv_instruction"; break;
|
||||
#endif
|
||||
|
||||
default: out.debug.message(EPrefixError, "Bad unary op");
|
||||
}
|
||||
|
||||
@@ -1085,6 +1058,7 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
|
||||
case EOpSubpassLoadMS: out.debug << "subpassLoadMS"; break;
|
||||
|
||||
case EOpTraceNV: out.debug << "traceNV"; break;
|
||||
case EOpTraceRayMotionNV: out.debug << "traceRayMotionNV"; break;
|
||||
case EOpTraceKHR: out.debug << "traceRayKHR"; break;
|
||||
case EOpReportIntersection: out.debug << "reportIntersectionNV"; break;
|
||||
case EOpIgnoreIntersectionNV: out.debug << "ignoreIntersectionNV"; break;
|
||||
@@ -1126,6 +1100,10 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
|
||||
case EOpIsHelperInvocation: out.debug << "IsHelperInvocation"; break;
|
||||
case EOpDebugPrintf: out.debug << "Debug printf"; break;
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
case EOpSpirvInst: out.debug << "spirv_instruction"; break;
|
||||
#endif
|
||||
|
||||
default: out.debug.message(EPrefixError, "Bad aggregation op");
|
||||
}
|
||||
|
||||
@@ -1487,6 +1465,9 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
|
||||
if (xfbMode)
|
||||
infoSink.debug << "in xfb mode\n";
|
||||
|
||||
if (getSubgroupUniformControlFlow())
|
||||
infoSink.debug << "subgroup_uniform_control_flow\n";
|
||||
|
||||
switch (language) {
|
||||
case EShLangVertex:
|
||||
break;
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
target = &inputList;
|
||||
else if (base->getQualifier().storage == EvqVaryingOut)
|
||||
target = &outputList;
|
||||
else if (base->getQualifier().isUniformOrBuffer() && !base->getQualifier().isPushConstant())
|
||||
else if (base->getQualifier().isUniformOrBuffer() && !base->getQualifier().isPushConstant() && !base->getQualifier().isShaderRecord())
|
||||
target = &uniformList;
|
||||
// If a global is being visited, then we should also traverse it incase it's evaluation
|
||||
// ends up visiting inputs we want to tag as live
|
||||
@@ -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;
|
||||
@@ -748,7 +766,7 @@ private:
|
||||
};
|
||||
|
||||
TDefaultIoResolverBase::TDefaultIoResolverBase(const TIntermediate& intermediate)
|
||||
: intermediate(intermediate)
|
||||
: referenceIntermediate(intermediate)
|
||||
, nextUniformLocation(intermediate.getUniformLocationBase())
|
||||
, nextInputLocation(0)
|
||||
, nextOutputLocation(0)
|
||||
@@ -760,17 +778,17 @@ TDefaultIoResolverBase::TDefaultIoResolverBase(const TIntermediate& intermediate
|
||||
|
||||
int TDefaultIoResolverBase::getBaseBinding(EShLanguage stage, TResourceType res, unsigned int set) const {
|
||||
return stageIntermediates[stage] ? selectBaseBinding(stageIntermediates[stage]->getShiftBinding(res), stageIntermediates[stage]->getShiftBindingForSet(res, set))
|
||||
: selectBaseBinding(intermediate.getShiftBinding(res), intermediate.getShiftBindingForSet(res, set));
|
||||
: selectBaseBinding(referenceIntermediate.getShiftBinding(res), referenceIntermediate.getShiftBindingForSet(res, set));
|
||||
}
|
||||
|
||||
const std::vector<std::string>& TDefaultIoResolverBase::getResourceSetBinding(EShLanguage stage) const {
|
||||
return stageIntermediates[stage] ? stageIntermediates[stage]->getResourceSetBinding()
|
||||
: intermediate.getResourceSetBinding();
|
||||
: referenceIntermediate.getResourceSetBinding();
|
||||
}
|
||||
|
||||
bool TDefaultIoResolverBase::doAutoBindingMapping() const { return intermediate.getAutoMapBindings(); }
|
||||
bool TDefaultIoResolverBase::doAutoBindingMapping() const { return referenceIntermediate.getAutoMapBindings(); }
|
||||
|
||||
bool TDefaultIoResolverBase::doAutoLocationMapping() const { return intermediate.getAutoMapLocations(); }
|
||||
bool TDefaultIoResolverBase::doAutoLocationMapping() const { return referenceIntermediate.getAutoMapLocations(); }
|
||||
|
||||
TDefaultIoResolverBase::TSlotSet::iterator TDefaultIoResolverBase::findSlot(int set, int slot) {
|
||||
return std::lower_bound(slots[set].begin(), slots[set].end(), slot);
|
||||
@@ -827,7 +845,7 @@ int TDefaultIoResolverBase::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
|
||||
}
|
||||
// no locations added if already present, a built-in variable, a block, or an opaque
|
||||
if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock ||
|
||||
type.isAtomic() || (type.containsOpaque() && intermediate.getSpv().openGl == 0)) {
|
||||
type.isAtomic() || type.isSpirvType() || (type.containsOpaque() && referenceIntermediate.getSpv().openGl == 0)) {
|
||||
return ent.newLocation = -1;
|
||||
}
|
||||
// no locations on blocks of built-in variables
|
||||
@@ -839,7 +857,7 @@ int TDefaultIoResolverBase::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
|
||||
return ent.newLocation = -1;
|
||||
}
|
||||
}
|
||||
int location = intermediate.getUniformLocationOverride(name);
|
||||
int location = referenceIntermediate.getUniformLocationOverride(name);
|
||||
if (location != -1) {
|
||||
return ent.newLocation = location;
|
||||
}
|
||||
@@ -855,8 +873,8 @@ int TDefaultIoResolverBase::resolveInOutLocation(EShLanguage stage, TVarEntryInf
|
||||
return ent.newLocation = -1;
|
||||
}
|
||||
|
||||
// no locations added if already present, or a built-in variable
|
||||
if (type.getQualifier().hasLocation() || type.isBuiltIn()) {
|
||||
// no locations added if already present, a built-in variable, or a variable with SPIR-V decorate
|
||||
if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getQualifier().hasSprivDecorate()) {
|
||||
return ent.newLocation = -1;
|
||||
}
|
||||
|
||||
@@ -942,8 +960,8 @@ int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInf
|
||||
if (type.getQualifier().hasLocation()) {
|
||||
return ent.newLocation = type.getQualifier().layoutLocation;
|
||||
}
|
||||
// no locations added if already present, or a built-in variable
|
||||
if (type.isBuiltIn()) {
|
||||
// no locations added if already present, a built-in variable, or a variable with SPIR-V decorate
|
||||
if (type.isBuiltIn() || type.getQualifier().hasSprivDecorate()) {
|
||||
return ent.newLocation = -1;
|
||||
}
|
||||
// no locations on blocks of built-in variables
|
||||
@@ -1024,7 +1042,8 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
|
||||
} else {
|
||||
// no locations added if already present, a built-in variable, a block, or an opaque
|
||||
if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock ||
|
||||
type.isAtomic() || (type.containsOpaque() && intermediate.getSpv().openGl == 0)) {
|
||||
type.isAtomic() || type.isSpirvType() ||
|
||||
(type.containsOpaque() && referenceIntermediate.getSpv().openGl == 0)) {
|
||||
return ent.newLocation = -1;
|
||||
}
|
||||
// no locations on blocks of built-in variables
|
||||
@@ -1037,7 +1056,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
|
||||
}
|
||||
}
|
||||
}
|
||||
int location = intermediate.getUniformLocationOverride(name.c_str());
|
||||
int location = referenceIntermediate.getUniformLocationOverride(name.c_str());
|
||||
if (location != -1) {
|
||||
return ent.newLocation = location;
|
||||
}
|
||||
@@ -1086,7 +1105,7 @@ int TDefaultGlslIoResolver::resolveBinding(EShLanguage stage, TVarEntryInfo& ent
|
||||
const TType& type = ent.symbol->getType();
|
||||
const TString& name = ent.symbol->getAccessName();
|
||||
// On OpenGL arrays of opaque types take a separate binding for each element
|
||||
int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
|
||||
int numBindings = referenceIntermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
|
||||
TResourceType resource = getResourceType(type);
|
||||
// don't need to handle uniform symbol, it will be handled in resolveUniformLocation
|
||||
if (resource == EResUbo && type.getBasicType() != EbtBlock) {
|
||||
@@ -1095,7 +1114,7 @@ int TDefaultGlslIoResolver::resolveBinding(EShLanguage stage, TVarEntryInfo& ent
|
||||
// There is no 'set' qualifier in OpenGL shading language, each resource has its own
|
||||
// binding name space, so remap the 'set' to resource type which make each resource
|
||||
// binding is valid from 0 to MAX_XXRESOURCE_BINDINGS
|
||||
int set = intermediate.getSpv().openGl != 0 ? resource : ent.newSet;
|
||||
int set = referenceIntermediate.getSpv().openGl != 0 ? resource : ent.newSet;
|
||||
int resourceKey = set;
|
||||
if (resource < EResCount) {
|
||||
if (type.getQualifier().hasBinding()) {
|
||||
@@ -1223,7 +1242,7 @@ void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink&
|
||||
const TType& type = ent.symbol->getType();
|
||||
const TString& name = ent.symbol->getAccessName();
|
||||
TResourceType resource = getResourceType(type);
|
||||
int set = intermediate.getSpv().openGl != 0 ? resource : resolveSet(ent.stage, ent);
|
||||
int set = referenceIntermediate.getSpv().openGl != 0 ? resource : resolveSet(ent.stage, ent);
|
||||
int resourceKey = set;
|
||||
|
||||
if (type.getQualifier().hasBinding()) {
|
||||
@@ -1233,7 +1252,7 @@ void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink&
|
||||
|
||||
if (iter == varSlotMap.end()) {
|
||||
// Reserve the slots for the ubo, ssbo and opaques who has explicit binding
|
||||
int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
|
||||
int numBindings = referenceIntermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
|
||||
varSlotMap[name] = binding;
|
||||
reserveSlot(resourceKey, binding, numBindings);
|
||||
} else {
|
||||
@@ -1288,7 +1307,7 @@ struct TDefaultIoResolver : public TDefaultIoResolverBase {
|
||||
const TType& type = ent.symbol->getType();
|
||||
const int set = getLayoutSet(type);
|
||||
// On OpenGL arrays of opaque types take a seperate binding for each element
|
||||
int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
|
||||
int numBindings = referenceIntermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
|
||||
TResourceType resource = getResourceType(type);
|
||||
if (resource < EResCount) {
|
||||
if (type.getQualifier().hasBinding()) {
|
||||
@@ -1633,6 +1652,37 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) {
|
||||
return TVarEntryInfo::TOrderByPriority()(p1.second, p2.second);
|
||||
});
|
||||
resolver->endResolve(EShLangCount);
|
||||
if (autoPushConstantBlockName.length()) {
|
||||
bool upgraded = false;
|
||||
for (size_t stage = 0; stage < EShLangCount; stage++) {
|
||||
if (intermediates[stage] != nullptr) {
|
||||
TVarLiveMap** pUniformVarMap = uniformResolve.uniformVarMap;
|
||||
auto at = pUniformVarMap[stage]->find(autoPushConstantBlockName);
|
||||
if (at == pUniformVarMap[stage]->end())
|
||||
continue;
|
||||
TQualifier& qualifier = at->second.symbol->getQualifier();
|
||||
if (!qualifier.isUniform())
|
||||
continue;
|
||||
TType& t = at->second.symbol->getWritableType();
|
||||
int size, stride;
|
||||
TIntermediate::getBaseAlignment(t, size, stride, autoPushConstantBlockPacking,
|
||||
qualifier.layoutMatrix == ElmRowMajor);
|
||||
if (size <= int(autoPushConstantMaxSize)) {
|
||||
qualifier.setBlockStorage(EbsPushConstant);
|
||||
qualifier.layoutPacking = autoPushConstantBlockPacking;
|
||||
upgraded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If it's been upgraded to push_constant, then remove it from the uniformVector
|
||||
// so it doesn't get a set/binding assigned to it.
|
||||
if (upgraded) {
|
||||
auto at = std::find_if(uniformVector.begin(), uniformVector.end(),
|
||||
[this](const TVarLivePair& p) { return p.first == autoPushConstantBlockName; });
|
||||
if (at != uniformVector.end())
|
||||
uniformVector.erase(at);
|
||||
}
|
||||
}
|
||||
for (size_t stage = 0; stage < EShLangCount; stage++) {
|
||||
if (intermediates[stage] != nullptr) {
|
||||
// traverse each stage, set new location to each input/output and unifom symbol, set new binding to
|
||||
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
protected:
|
||||
TDefaultIoResolverBase(TDefaultIoResolverBase&);
|
||||
TDefaultIoResolverBase& operator=(TDefaultIoResolverBase&);
|
||||
const TIntermediate& intermediate;
|
||||
const TIntermediate& referenceIntermediate;
|
||||
int nextUniformLocation;
|
||||
int nextInputLocation;
|
||||
int nextOutputLocation;
|
||||
@@ -291,7 +291,7 @@ public:
|
||||
bool virtual doMap(TIoMapResolver*, TInfoSink&) { return true; }
|
||||
};
|
||||
|
||||
// I/O mapper for OpenGL
|
||||
// I/O mapper for GLSL
|
||||
class TGlslIoMapper : public TIoMapper {
|
||||
public:
|
||||
TGlslIoMapper() {
|
||||
@@ -301,6 +301,8 @@ public:
|
||||
memset(intermediates, 0, sizeof(TIntermediate*) * (EShLangCount + 1));
|
||||
profile = ENoProfile;
|
||||
version = 0;
|
||||
autoPushConstantMaxSize = 128;
|
||||
autoPushConstantBlockPacking = ElpStd430;
|
||||
}
|
||||
virtual ~TGlslIoMapper() {
|
||||
for (size_t stage = 0; stage < EShLangCount; stage++) {
|
||||
@@ -320,6 +322,13 @@ public:
|
||||
intermediates[stage] = nullptr;
|
||||
}
|
||||
}
|
||||
// If set, the uniform block with the given name will be changed to be backed by
|
||||
// push_constant if it's size is <= maxSize
|
||||
void setAutoPushConstantBlock(const char* name, unsigned int maxSize, TLayoutPacking packing) {
|
||||
autoPushConstantBlockName = name;
|
||||
autoPushConstantMaxSize = maxSize;
|
||||
autoPushConstantBlockPacking = packing;
|
||||
}
|
||||
// grow the reflection stage by stage
|
||||
bool addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*) override;
|
||||
bool doMap(TIoMapResolver*, TInfoSink&) override;
|
||||
@@ -329,6 +338,11 @@ public:
|
||||
bool hadError = false;
|
||||
EProfile profile;
|
||||
int version;
|
||||
|
||||
private:
|
||||
TString autoPushConstantBlockName;
|
||||
unsigned int autoPushConstantMaxSize;
|
||||
TLayoutPacking autoPushConstantBlockPacking;
|
||||
};
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
@@ -312,10 +312,12 @@ 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);
|
||||
MERGE_TRUE(useStorageBuffer);
|
||||
MERGE_TRUE(invariantAll);
|
||||
MERGE_TRUE(hlslIoMapping);
|
||||
|
||||
// TODO: sourceFile
|
||||
@@ -758,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";
|
||||
}
|
||||
@@ -857,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 ||
|
||||
@@ -868,6 +883,8 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
|
||||
error(infoSink, "Interface block member layout qualifiers must match:");
|
||||
writeTypeComparison = true;
|
||||
}
|
||||
++li;
|
||||
++ri;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -953,10 +970,10 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
|
||||
// current implementation only has one offset.
|
||||
if (symbol.getQualifier().layoutMatrix != unitSymbol.getQualifier().layoutMatrix ||
|
||||
symbol.getQualifier().layoutPacking != unitSymbol.getQualifier().layoutPacking ||
|
||||
symbol.getQualifier().layoutLocation != unitSymbol.getQualifier().layoutLocation ||
|
||||
(symbol.getQualifier().hasLocation() && unitSymbol.getQualifier().hasLocation() && symbol.getQualifier().layoutLocation != unitSymbol.getQualifier().layoutLocation) ||
|
||||
symbol.getQualifier().layoutComponent != unitSymbol.getQualifier().layoutComponent ||
|
||||
symbol.getQualifier().layoutIndex != unitSymbol.getQualifier().layoutIndex ||
|
||||
symbol.getQualifier().layoutBinding != unitSymbol.getQualifier().layoutBinding ||
|
||||
(symbol.getQualifier().hasBinding() && unitSymbol.getQualifier().hasBinding() && symbol.getQualifier().layoutBinding != unitSymbol.getQualifier().layoutBinding) ||
|
||||
(symbol.getQualifier().hasBinding() && (symbol.getQualifier().layoutOffset != unitSymbol.getQualifier().layoutOffset))) {
|
||||
error(infoSink, "Layout qualification must match:");
|
||||
writeTypeComparison = true;
|
||||
@@ -1933,7 +1950,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, T
|
||||
}
|
||||
|
||||
// rule 9
|
||||
if (type.getBasicType() == EbtStruct) {
|
||||
if (type.getBasicType() == EbtStruct || type.getBasicType() == EbtBlock) {
|
||||
const TTypeList& memberList = *type.getStruct();
|
||||
|
||||
size = 0;
|
||||
@@ -2158,8 +2175,9 @@ int TIntermediate::computeBufferReferenceTypeSize(const TType& type)
|
||||
bool TIntermediate::isIoResizeArray(const TType& type, EShLanguage language) {
|
||||
return type.isArray() &&
|
||||
((language == EShLangGeometry && type.getQualifier().storage == EvqVaryingIn) ||
|
||||
(language == EShLangTessControl && type.getQualifier().storage == EvqVaryingOut &&
|
||||
(language == EShLangTessControl && (type.getQualifier().storage == EvqVaryingIn || type.getQualifier().storage == EvqVaryingOut) &&
|
||||
! type.getQualifier().patch) ||
|
||||
(language == EShLangTessEvaluation && type.getQualifier().storage == EvqVaryingIn) ||
|
||||
(language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn &&
|
||||
type.getQualifier().pervertexNV) ||
|
||||
(language == EShLangMeshNV && type.getQualifier().storage == EvqVaryingOut &&
|
||||
|
||||
@@ -290,7 +290,9 @@ public:
|
||||
resources(TBuiltInResource{}),
|
||||
numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
|
||||
invertY(false),
|
||||
dxPositionW(false),
|
||||
useStorageBuffer(false),
|
||||
invariantAll(false),
|
||||
nanMinMaxClamp(false),
|
||||
depthReplacing(false),
|
||||
uniqueId(0),
|
||||
@@ -328,7 +330,10 @@ public:
|
||||
textureSamplerTransformMode(EShTexSampTransKeep),
|
||||
needToLegalize(false),
|
||||
binaryDoubleOutput(false),
|
||||
subgroupUniformControlFlow(false),
|
||||
usePhysicalStorageBuffer(false),
|
||||
spirvRequirement(nullptr),
|
||||
spirvExecutionMode(nullptr),
|
||||
uniformLocationBase(0)
|
||||
#endif
|
||||
{
|
||||
@@ -393,6 +398,9 @@ public:
|
||||
case EShTargetSpv_1_5:
|
||||
processes.addProcess("target-env spirv1.5");
|
||||
break;
|
||||
case EShTargetSpv_1_6:
|
||||
processes.addProcess("target-env spirv1.6");
|
||||
break;
|
||||
default:
|
||||
processes.addProcess("target-env spirvUnknown");
|
||||
break;
|
||||
@@ -456,6 +464,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; }
|
||||
@@ -535,7 +551,7 @@ public:
|
||||
TIntermTyped* foldSwizzle(TIntermTyped* node, TSwizzleSelectors<TVectorSelector>& fields, const TSourceLoc&);
|
||||
|
||||
// Tree ops
|
||||
static const TIntermTyped* findLValueBase(const TIntermTyped*, bool swizzleOkay);
|
||||
static const TIntermTyped* findLValueBase(const TIntermTyped*, bool swizzleOkay , bool BufferReferenceOk = false);
|
||||
|
||||
// Linkage related
|
||||
void addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguage, TSymbolTable&);
|
||||
@@ -557,6 +573,8 @@ public:
|
||||
|
||||
void setUseStorageBuffer() { useStorageBuffer = true; }
|
||||
bool usingStorageBuffer() const { return useStorageBuffer; }
|
||||
void setInvariantAll() { invariantAll = true; }
|
||||
bool isInvariantAll() const { return invariantAll; }
|
||||
void setDepthReplacing() { depthReplacing = true; }
|
||||
bool isDepthReplacing() const { return depthReplacing; }
|
||||
bool setLocalSize(int dim, int size)
|
||||
@@ -864,6 +882,18 @@ public:
|
||||
|
||||
void setBinaryDoubleOutput() { binaryDoubleOutput = true; }
|
||||
bool getBinaryDoubleOutput() { return binaryDoubleOutput; }
|
||||
|
||||
void setSubgroupUniformControlFlow() { subgroupUniformControlFlow = true; }
|
||||
bool getSubgroupUniformControlFlow() const { return subgroupUniformControlFlow; }
|
||||
|
||||
// GL_EXT_spirv_intrinsics
|
||||
void insertSpirvRequirement(const TSpirvRequirement* spirvReq);
|
||||
bool hasSpirvRequirement() const { return spirvRequirement != nullptr; }
|
||||
const TSpirvRequirement& getSpirvRequirement() const { return *spirvRequirement; }
|
||||
void insertSpirvExecutionMode(int executionMode, const TIntermAggregate* args = nullptr);
|
||||
void insertSpirvExecutionModeId(int executionMode, const TIntermAggregate* args);
|
||||
bool hasSpirvExecutionMode() const { return spirvExecutionMode != nullptr; }
|
||||
const TSpirvExecutionMode& getSpirvExecutionMode() const { return *spirvExecutionMode; }
|
||||
#endif // GLSLANG_WEB
|
||||
|
||||
void addBlockStorageOverride(const char* nameStr, TBlockStorageClass backing)
|
||||
@@ -911,6 +941,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsRequestedExtension(const char* extension) const
|
||||
{
|
||||
return (requestedExtensions.find(extension) != requestedExtensions.end());
|
||||
}
|
||||
|
||||
void addToCallGraph(TInfoSink&, const TString& caller, const TString& callee);
|
||||
void merge(TInfoSink&, TIntermediate&);
|
||||
void finalCheck(TInfoSink&, bool keepUncalled);
|
||||
@@ -1047,7 +1082,9 @@ 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
|
||||
bool depthReplacing;
|
||||
int localSize[3];
|
||||
@@ -1115,8 +1152,12 @@ protected:
|
||||
|
||||
bool needToLegalize;
|
||||
bool binaryDoubleOutput;
|
||||
bool subgroupUniformControlFlow;
|
||||
bool usePhysicalStorageBuffer;
|
||||
|
||||
TSpirvRequirement* spirvRequirement;
|
||||
TSpirvExecutionMode* spirvExecutionMode;
|
||||
|
||||
std::unordered_map<std::string, int> uniformLocationOverrides;
|
||||
int uniformLocationBase;
|
||||
TNumericFeatures numericFeatures;
|
||||
|
||||
@@ -166,31 +166,30 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
|
||||
}
|
||||
} else {
|
||||
// matrix from vector or scalar
|
||||
int count = 0;
|
||||
const int startIndex = index;
|
||||
int nodeComps = node->getType().computeNumComponents();
|
||||
for (int i = startIndex; i < endIndex; i++) {
|
||||
if (i >= instanceSize)
|
||||
return;
|
||||
if (nodeComps == 1) {
|
||||
// If there is a single scalar parameter to a matrix
|
||||
// constructor, it is used to initialize all the
|
||||
// components on the matrix's diagonal, with the
|
||||
// remaining components initialized to 0.0.
|
||||
if (i == startIndex || (i - startIndex) % (matrixRows + 1) == 0 )
|
||||
leftUnionArray[i] = rightUnionArray[count];
|
||||
else
|
||||
leftUnionArray[i].setDConst(0.0);
|
||||
} else {
|
||||
if (nodeComps == 1) {
|
||||
for (int c = 0; c < matrixCols; ++c) {
|
||||
for (int r = 0; r < matrixRows; ++r) {
|
||||
if (r == c)
|
||||
leftUnionArray[index] = rightUnionArray[0];
|
||||
else
|
||||
leftUnionArray[index].setDConst(0.0);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int count = 0;
|
||||
for (int i = index; i < endIndex; i++) {
|
||||
if (i >= instanceSize)
|
||||
return;
|
||||
|
||||
// construct the matrix in column-major order, from
|
||||
// the components provided, in order
|
||||
leftUnionArray[i] = rightUnionArray[count];
|
||||
}
|
||||
|
||||
index++;
|
||||
|
||||
if (nodeComps > 1)
|
||||
index++;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1191,9 +1191,11 @@ int TPpContext::tokenize(TPpToken& ppToken)
|
||||
// HLSL allows string literals.
|
||||
// GLSL allows string literals with GL_EXT_debug_printf.
|
||||
if (ifdepth == 0 && parseContext.intermediate.getSource() != EShSourceHlsl) {
|
||||
parseContext.requireExtensions(ppToken.loc, 1, &E_GL_EXT_debug_printf, "string literal");
|
||||
if (!parseContext.extensionTurnedOn(E_GL_EXT_debug_printf))
|
||||
continue;
|
||||
const char* const string_literal_EXTs[] = { E_GL_EXT_debug_printf, E_GL_EXT_spirv_intrinsics };
|
||||
parseContext.requireExtensions(ppToken.loc, 2, string_literal_EXTs, "string literal");
|
||||
if (!parseContext.extensionTurnedOn(E_GL_EXT_debug_printf) &&
|
||||
!parseContext.extensionTurnedOn(E_GL_EXT_spirv_intrinsics))
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case '\'':
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -163,6 +163,7 @@ typedef enum {
|
||||
} EShTargetLanguage;
|
||||
|
||||
typedef enum {
|
||||
EShTargetUniversal = 0, // Universal
|
||||
EShTargetVulkan_1_0 = (1 << 22), // Vulkan 1.0
|
||||
EShTargetVulkan_1_1 = (1 << 22) | (1 << 12), // Vulkan 1.1
|
||||
EShTargetVulkan_1_2 = (1 << 22) | (2 << 12), // Vulkan 1.2
|
||||
@@ -179,7 +180,8 @@ typedef enum {
|
||||
EShTargetSpv_1_3 = (1 << 16) | (3 << 8), // SPIR-V 1.3
|
||||
EShTargetSpv_1_4 = (1 << 16) | (4 << 8), // SPIR-V 1.4
|
||||
EShTargetSpv_1_5 = (1 << 16) | (5 << 8), // SPIR-V 1.5
|
||||
LAST_ELEMENT_MARKER(EShTargetLanguageVersionCount = 6),
|
||||
EShTargetSpv_1_6 = (1 << 16) | (6 << 8), // SPIR-V 1.6
|
||||
LAST_ELEMENT_MARKER(EShTargetLanguageVersionCount = 7),
|
||||
} EShTargetLanguageVersion;
|
||||
|
||||
struct TInputLanguage {
|
||||
@@ -485,6 +487,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);
|
||||
@@ -508,7 +511,7 @@ public:
|
||||
//
|
||||
// setEnvInput: The input source language and stage. If generating code for a
|
||||
// specific client, the input client semantics to use and the
|
||||
// version of the that client's input semantics to use, otherwise
|
||||
// version of that client's input semantics to use, otherwise
|
||||
// use EShClientNone and version of 0, e.g. for validation mode.
|
||||
// Note 'version' does not describe the target environment,
|
||||
// just the version of the source dialect to compile under.
|
||||
@@ -722,7 +725,7 @@ class TObjectReflection {
|
||||
public:
|
||||
GLSLANG_EXPORT TObjectReflection(const std::string& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex);
|
||||
|
||||
GLSLANG_EXPORT const TType* getType() const { return type; }
|
||||
const TType* getType() const { return type; }
|
||||
GLSLANG_EXPORT int getBinding() const;
|
||||
GLSLANG_EXPORT void dump() const;
|
||||
static TObjectReflection badReflection() { return TObjectReflection(); }
|
||||
|
||||
Reference in New Issue
Block a user