mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-18 04:53:06 +01:00
Updated glslang.
This commit is contained in:
@@ -59,22 +59,22 @@ static EShLanguage c_shader_stage(glslang_stage_t stage)
|
||||
return EShLangFragment;
|
||||
case GLSLANG_STAGE_COMPUTE:
|
||||
return EShLangCompute;
|
||||
case GLSLANG_STAGE_RAYGEN_NV:
|
||||
case GLSLANG_STAGE_RAYGEN:
|
||||
return EShLangRayGen;
|
||||
case GLSLANG_STAGE_INTERSECT_NV:
|
||||
case GLSLANG_STAGE_INTERSECT:
|
||||
return EShLangIntersect;
|
||||
case GLSLANG_STAGE_ANYHIT_NV:
|
||||
case GLSLANG_STAGE_ANYHIT:
|
||||
return EShLangAnyHit;
|
||||
case GLSLANG_STAGE_CLOSESTHIT_NV:
|
||||
case GLSLANG_STAGE_CLOSESTHIT:
|
||||
return EShLangClosestHit;
|
||||
case GLSLANG_STAGE_MISS_NV:
|
||||
case GLSLANG_STAGE_MISS:
|
||||
return EShLangMiss;
|
||||
case GLSLANG_STAGE_CALLABLE_NV:
|
||||
case GLSLANG_STAGE_CALLABLE:
|
||||
return EShLangCallable;
|
||||
case GLSLANG_STAGE_TASK_NV:
|
||||
return EShLangTaskNV;
|
||||
case GLSLANG_STAGE_MESH_NV:
|
||||
return EShLangMeshNV;
|
||||
case GLSLANG_STAGE_TASK:
|
||||
return EShLangTask;
|
||||
case GLSLANG_STAGE_MESH:
|
||||
return EShLangMesh;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -86,6 +86,8 @@ GLSLANG_EXPORT void glslang_program_SPIRV_generate(glslang_program_t* program, g
|
||||
glslang_spv_options_t spv_options;
|
||||
spv_options.generate_debug_info = false;
|
||||
spv_options.strip_debug_info = false;
|
||||
spv_options.emit_nonsemantic_shader_debug_info = false;
|
||||
spv_options.emit_nonsemantic_shader_debug_source = false;
|
||||
spv_options.disable_optimizer = true;
|
||||
spv_options.optimize_size = false;
|
||||
spv_options.disassemble = false;
|
||||
|
||||
1
3rdparty/glslang/SPIRV/GLSL.ext.EXT.h
vendored
1
3rdparty/glslang/SPIRV/GLSL.ext.EXT.h
vendored
@@ -39,5 +39,6 @@ static const char* const E_SPV_EXT_shader_atomic_float_add = "SPV_EXT_shader_ato
|
||||
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";
|
||||
static const char* const E_SPV_EXT_mesh_shader = "SPV_EXT_mesh_shader";
|
||||
|
||||
#endif // #ifndef GLSLextEXT_H
|
||||
|
||||
246
3rdparty/glslang/SPIRV/GlslangToSpv.cpp
vendored
246
3rdparty/glslang/SPIRV/GlslangToSpv.cpp
vendored
@@ -280,6 +280,9 @@ protected:
|
||||
|
||||
// Used later for generating OpTraceKHR/OpExecuteCallableKHR
|
||||
std::unordered_map<unsigned int, glslang::TIntermSymbol *> locationToSymbol[2];
|
||||
|
||||
// Used by Task shader while generating opearnds for OpEmitMeshTasksEXT
|
||||
spv::Id taskPayloadID;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -315,7 +318,7 @@ spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile
|
||||
}
|
||||
|
||||
// Translate glslang language (stage) to SPIR-V execution model.
|
||||
spv::ExecutionModel TranslateExecutionModel(EShLanguage stage)
|
||||
spv::ExecutionModel TranslateExecutionModel(EShLanguage stage, bool isMeshShaderEXT = false)
|
||||
{
|
||||
switch (stage) {
|
||||
case EShLangVertex: return spv::ExecutionModelVertex;
|
||||
@@ -331,8 +334,8 @@ spv::ExecutionModel TranslateExecutionModel(EShLanguage stage)
|
||||
case EShLangClosestHit: return spv::ExecutionModelClosestHitKHR;
|
||||
case EShLangMiss: return spv::ExecutionModelMissKHR;
|
||||
case EShLangCallable: return spv::ExecutionModelCallableKHR;
|
||||
case EShLangTaskNV: return spv::ExecutionModelTaskNV;
|
||||
case EShLangMeshNV: return spv::ExecutionModelMeshNV;
|
||||
case EShLangTask: return (isMeshShaderEXT)? spv::ExecutionModelTaskEXT : spv::ExecutionModelTaskNV;
|
||||
case EShLangMesh: return (isMeshShaderEXT)? spv::ExecutionModelMeshEXT: spv::ExecutionModelMeshNV;
|
||||
#endif
|
||||
default:
|
||||
assert(0);
|
||||
@@ -763,7 +766,7 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
|
||||
return spv::BuiltInSampleMask;
|
||||
|
||||
case glslang::EbvLayer:
|
||||
if (glslangIntermediate->getStage() == EShLangMeshNV) {
|
||||
if (glslangIntermediate->getStage() == EShLangMesh) {
|
||||
return spv::BuiltInLayer;
|
||||
}
|
||||
if (glslangIntermediate->getStage() == EShLangGeometry ||
|
||||
@@ -1078,6 +1081,16 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
|
||||
case glslang::EbvMeshViewIndicesNV:
|
||||
return spv::BuiltInMeshViewIndicesNV;
|
||||
|
||||
// SPV_EXT_mesh_shader
|
||||
case glslang::EbvPrimitivePointIndicesEXT:
|
||||
return spv::BuiltInPrimitivePointIndicesEXT;
|
||||
case glslang::EbvPrimitiveLineIndicesEXT:
|
||||
return spv::BuiltInPrimitiveLineIndicesEXT;
|
||||
case glslang::EbvPrimitiveTriangleIndicesEXT:
|
||||
return spv::BuiltInPrimitiveTriangleIndicesEXT;
|
||||
case glslang::EbvCullPrimitiveEXT:
|
||||
return spv::BuiltInCullPrimitiveEXT;
|
||||
|
||||
// sm builtins
|
||||
case glslang::EbvWarpsPerSM:
|
||||
builder.addExtension(spv::E_SPV_NV_shader_sm_builtins);
|
||||
@@ -1321,6 +1334,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::EvqtaskPayloadSharedEXT : return spv::StorageClassTaskPayloadWorkgroupEXT;
|
||||
case glslang::EvqSpirvStorageClass: return static_cast<spv::StorageClass>(type.getQualifier().spirvStorageClass);
|
||||
#endif
|
||||
default:
|
||||
@@ -1338,7 +1352,9 @@ void TGlslangToSpvTraverser::TranslateLiterals(const glslang::TVector<const glsl
|
||||
for (auto constant : constants) {
|
||||
if (constant->getBasicType() == glslang::EbtFloat) {
|
||||
float floatValue = static_cast<float>(constant->getConstArray()[0].getDConst());
|
||||
unsigned literal = *reinterpret_cast<unsigned*>(&floatValue);
|
||||
unsigned literal;
|
||||
static_assert(sizeof(literal) == sizeof(floatValue), "sizeof(unsigned) != sizeof(float)");
|
||||
memcpy(&literal, &floatValue, sizeof(literal));
|
||||
literals.push_back(literal);
|
||||
} else if (constant->getBasicType() == glslang::EbtInt) {
|
||||
unsigned literal = constant->getConstArray()[0].getIConst();
|
||||
@@ -1464,6 +1480,8 @@ void InheritQualifiers(glslang::TQualifier& child, const glslang::TQualifier& pa
|
||||
child.perViewNV = true;
|
||||
if (parent.perTaskNV)
|
||||
child.perTaskNV = true;
|
||||
if (parent.storage == glslang::EvqtaskPayloadSharedEXT)
|
||||
child.storage = glslang::EvqtaskPayloadSharedEXT;
|
||||
if (parent.patch)
|
||||
child.patch = true;
|
||||
if (parent.sample)
|
||||
@@ -1523,9 +1541,12 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
||||
inEntryPoint(false), entryPointTerminated(false), linkageOnly(false),
|
||||
glslangIntermediate(glslangIntermediate),
|
||||
nanMinMaxClamp(glslangIntermediate->getNanMinMaxClamp()),
|
||||
nonSemanticDebugPrintf(0)
|
||||
nonSemanticDebugPrintf(0),
|
||||
taskPayloadID(0)
|
||||
{
|
||||
spv::ExecutionModel executionModel = TranslateExecutionModel(glslangIntermediate->getStage());
|
||||
bool isMeshShaderExt = (glslangIntermediate->getRequestedExtensions().find(glslang::E_GL_EXT_mesh_shader) !=
|
||||
glslangIntermediate->getRequestedExtensions().end());
|
||||
spv::ExecutionModel executionModel = TranslateExecutionModel(glslangIntermediate->getStage(), isMeshShaderExt);
|
||||
|
||||
builder.clearAccessChain();
|
||||
builder.setSource(TranslateSourceLanguage(glslangIntermediate->getSource(), glslangIntermediate->getProfile()),
|
||||
@@ -1557,6 +1578,10 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
||||
for (auto iItr = include_txt.begin(); iItr != include_txt.end(); ++iItr)
|
||||
builder.addInclude(iItr->first, iItr->second);
|
||||
}
|
||||
|
||||
builder.setEmitNonSemanticShaderDebugInfo(options.emitNonSemanticShaderDebugInfo);
|
||||
builder.setEmitNonSemanticShaderDebugSource(options.emitNonSemanticShaderDebugSource);
|
||||
|
||||
stdBuiltins = builder.import("GLSL.std.450");
|
||||
|
||||
spv::AddressingModel addressingModel = spv::AddressingModelLogical;
|
||||
@@ -1801,7 +1826,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
||||
case EShLangAnyHit:
|
||||
case EShLangClosestHit:
|
||||
case EShLangMiss:
|
||||
case EShLangCallable:
|
||||
case EShLangCallable:
|
||||
{
|
||||
auto& extensions = glslangIntermediate->getRequestedExtensions();
|
||||
if (extensions.find("GL_NV_ray_tracing") == extensions.end()) {
|
||||
@@ -1821,10 +1846,15 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EShLangTaskNV:
|
||||
case EShLangMeshNV:
|
||||
builder.addCapability(spv::CapabilityMeshShadingNV);
|
||||
builder.addExtension(spv::E_SPV_NV_mesh_shader);
|
||||
case EShLangTask:
|
||||
case EShLangMesh:
|
||||
if(isMeshShaderExt) {
|
||||
builder.addCapability(spv::CapabilityMeshShadingEXT);
|
||||
builder.addExtension(spv::E_SPV_EXT_mesh_shader);
|
||||
} else {
|
||||
builder.addCapability(spv::CapabilityMeshShadingNV);
|
||||
builder.addExtension(spv::E_SPV_NV_mesh_shader);
|
||||
}
|
||||
if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_6) {
|
||||
std::vector<spv::Id> dimConstId;
|
||||
for (int dim = 0; dim < 3; ++dim) {
|
||||
@@ -1841,7 +1871,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
||||
glslangIntermediate->getLocalSize(1),
|
||||
glslangIntermediate->getLocalSize(2));
|
||||
}
|
||||
if (glslangIntermediate->getStage() == EShLangMeshNV) {
|
||||
if (glslangIntermediate->getStage() == EShLangMesh) {
|
||||
builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices,
|
||||
glslangIntermediate->getVertices());
|
||||
builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputPrimitivesNV,
|
||||
@@ -1960,7 +1990,6 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
|
||||
|
||||
if (symbol->getType().getQualifier().isSpecConstant())
|
||||
spec_constant_op_mode_setter.turnOnSpecConstantOpMode();
|
||||
|
||||
#ifdef ENABLE_HLSL
|
||||
// Skip symbol handling if it is string-typed
|
||||
if (symbol->getBasicType() == glslang::EbtString)
|
||||
@@ -1971,6 +2000,9 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
|
||||
// Formal function parameters were mapped during makeFunctions().
|
||||
spv::Id id = getSymbolId(symbol);
|
||||
|
||||
if (symbol->getType().getQualifier().isTaskPayload())
|
||||
taskPayloadID = id; // cache the taskPayloadID to be used it as operand for OpEmitMeshTasksEXT
|
||||
|
||||
if (builder.isPointer(id)) {
|
||||
if (!symbol->getType().getQualifier().isParamInput() &&
|
||||
!symbol->getType().getQualifier().isParamOutput()) {
|
||||
@@ -2498,6 +2530,14 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force variable declaration - Debug Mode Only
|
||||
if (node->getOp() == glslang::EOpDeclare) {
|
||||
builder.clearAccessChain();
|
||||
node->getOperand()->traverse(this);
|
||||
builder.clearAccessChain();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start by evaluating the operand
|
||||
|
||||
// Does it need a swizzle inversion? If so, evaluation is inverted;
|
||||
@@ -2514,7 +2554,7 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
|
||||
operandNode = node->getOperand()->getAsBinaryNode()->getLeft();
|
||||
else
|
||||
operandNode = node->getOperand();
|
||||
|
||||
|
||||
operandNode->traverse(this);
|
||||
|
||||
spv::Id operand = spv::NoResult;
|
||||
@@ -2758,32 +2798,38 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
spv::Decoration precision = TranslatePrecisionDecoration(node->getOperationPrecision());
|
||||
|
||||
switch (node->getOp()) {
|
||||
case glslang::EOpScope:
|
||||
case glslang::EOpSequence:
|
||||
{
|
||||
if (preVisit)
|
||||
if (visit == glslang::EvPreVisit) {
|
||||
++sequenceDepth;
|
||||
else
|
||||
if (sequenceDepth == 1) {
|
||||
// If this is the parent node of all the functions, we want to see them
|
||||
// early, so all call points have actual SPIR-V functions to reference.
|
||||
// In all cases, still let the traverser visit the children for us.
|
||||
makeFunctions(node->getAsAggregate()->getSequence());
|
||||
|
||||
// Also, we want all globals initializers to go into the beginning of the entry point, before
|
||||
// anything else gets there, so visit out of order, doing them all now.
|
||||
makeGlobalInitializers(node->getAsAggregate()->getSequence());
|
||||
|
||||
//Pre process linker objects for ray tracing stages
|
||||
if (glslangIntermediate->isRayTracingStage())
|
||||
collectRayTracingLinkerObjects();
|
||||
|
||||
// Initializers are done, don't want to visit again, but functions and link objects need to be processed,
|
||||
// so do them manually.
|
||||
visitFunctions(node->getAsAggregate()->getSequence());
|
||||
|
||||
return false;
|
||||
} else {
|
||||
if (node->getOp() == glslang::EOpScope)
|
||||
builder.enterScope(0);
|
||||
}
|
||||
} else {
|
||||
if (sequenceDepth > 1 && node->getOp() == glslang::EOpScope)
|
||||
builder.leaveScope();
|
||||
--sequenceDepth;
|
||||
|
||||
if (sequenceDepth == 1) {
|
||||
// If this is the parent node of all the functions, we want to see them
|
||||
// early, so all call points have actual SPIR-V functions to reference.
|
||||
// In all cases, still let the traverser visit the children for us.
|
||||
makeFunctions(node->getAsAggregate()->getSequence());
|
||||
|
||||
// Also, we want all globals initializers to go into the beginning of the entry point, before
|
||||
// anything else gets there, so visit out of order, doing them all now.
|
||||
makeGlobalInitializers(node->getAsAggregate()->getSequence());
|
||||
|
||||
//Pre process linker objects for ray tracing stages
|
||||
if (glslangIntermediate->isRayTracingStage())
|
||||
collectRayTracingLinkerObjects();
|
||||
|
||||
// Initializers are done, don't want to visit again, but functions and link objects need to be processed,
|
||||
// so do them manually.
|
||||
visitFunctions(node->getAsAggregate()->getSequence());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -2812,13 +2858,16 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
if (isShaderEntryPoint(node)) {
|
||||
inEntryPoint = true;
|
||||
builder.setBuildPoint(shaderEntry->getLastBlock());
|
||||
builder.enterFunction(shaderEntry);
|
||||
currentFunction = shaderEntry;
|
||||
} else {
|
||||
handleFunctionEntry(node);
|
||||
}
|
||||
if (options.generateDebugInfo) {
|
||||
const auto& loc = node->getLoc();
|
||||
currentFunction->setDebugLineInfo(builder.getSourceFile(), loc.line, loc.column);
|
||||
const char* sourceFileName = loc.getFilename();
|
||||
spv::Id sourceFileId = sourceFileName ? builder.getStringId(sourceFileName) : builder.getSourceFile();
|
||||
currentFunction->setDebugLineInfo(sourceFileId, loc.line, loc.column);
|
||||
}
|
||||
} else {
|
||||
if (inEntryPoint)
|
||||
@@ -3109,6 +3158,8 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
case glslang::EOpExecuteCallableNV:
|
||||
case glslang::EOpExecuteCallableKHR:
|
||||
case glslang::EOpWritePackedPrimitiveIndices4x8NV:
|
||||
case glslang::EOpEmitMeshTasksEXT:
|
||||
case glslang::EOpSetMeshOutputsEXT:
|
||||
noReturnValue = true;
|
||||
break;
|
||||
case glslang::EOpRayQueryInitialize:
|
||||
@@ -3503,7 +3554,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
OpDecorations decorations = { precision,
|
||||
OpDecorations decorations = { precision,
|
||||
TranslateNoContractionDecoration(node->getType().getQualifier()),
|
||||
TranslateNonUniformDecoration(node->getType().getQualifier()) };
|
||||
result = createUnaryOperation(
|
||||
@@ -3625,7 +3676,7 @@ bool TGlslangToSpvTraverser::visitSelection(glslang::TVisit /* visit */, glslang
|
||||
// smear condition to vector, if necessary (AST is always scalar)
|
||||
// Before 1.4, smear like for mix(), starting with 1.4, keep it scalar
|
||||
if (glslangIntermediate->getSpv().spv < glslang::EShTargetSpv_1_4 && builder.isVector(trueValue)) {
|
||||
condition = builder.smearScalar(spv::NoPrecision, condition,
|
||||
condition = builder.smearScalar(spv::NoPrecision, condition,
|
||||
builder.makeVectorType(builder.makeBoolType(),
|
||||
builder.getNumComponents(trueValue)));
|
||||
}
|
||||
@@ -3796,8 +3847,8 @@ bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIn
|
||||
// by a block-ending branch. But we don't want to put any other body/test
|
||||
// instructions in it, since the body/test may have arbitrary instructions,
|
||||
// including merges of its own.
|
||||
builder.setLine(node->getLoc().line, node->getLoc().getFilename());
|
||||
builder.setBuildPoint(&blocks.head);
|
||||
builder.setLine(node->getLoc().line, node->getLoc().getFilename());
|
||||
builder.createLoopMerge(&blocks.merge, &blocks.continue_target, control, operands);
|
||||
if (node->testFirst() && node->getTest()) {
|
||||
spv::Block& test = builder.makeNewBlock();
|
||||
@@ -4016,7 +4067,7 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol*
|
||||
initializer = builder.makeNullConstant(spvType);
|
||||
}
|
||||
|
||||
return builder.createVariable(spv::NoPrecision, storageClass, spvType, name, initializer);
|
||||
return builder.createVariable(spv::NoPrecision, storageClass, spvType, name, initializer, false);
|
||||
}
|
||||
|
||||
// Return type Id of the sampled type.
|
||||
@@ -4104,7 +4155,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
if (explicitLayout != glslang::ElpNone)
|
||||
spvType = builder.makeUintType(32);
|
||||
else
|
||||
spvType = builder.makeBoolType();
|
||||
spvType = builder.makeBoolType(false);
|
||||
break;
|
||||
case glslang::EbtInt:
|
||||
spvType = builder.makeIntType(32);
|
||||
@@ -4204,7 +4255,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
spvType = builder.makeImageType(getSampledType(sampler), TranslateDimensionality(sampler),
|
||||
sampler.isShadow(), sampler.isArrayed(), sampler.isMultiSample(),
|
||||
sampler.isImageClass() ? 2 : 1, TranslateImageFormat(type));
|
||||
if (sampler.isCombined() &&
|
||||
if (sampler.isCombined() &&
|
||||
(!sampler.isBuffer() || glslangIntermediate->getSpv().spv < glslang::EShTargetSpv_1_6)) {
|
||||
// Already has both image and sampler, make the combined type. Only combine sampler to
|
||||
// buffer if before SPIR-V 1.6.
|
||||
@@ -4247,7 +4298,9 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
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);
|
||||
unsigned literal;
|
||||
static_assert(sizeof(literal) == sizeof(floatValue), "sizeof(unsigned) != sizeof(float)");
|
||||
memcpy(&literal, &floatValue, sizeof(literal));
|
||||
operands.push_back({false, literal});
|
||||
} else if (typeParam.constant->getBasicType() == glslang::EbtInt) {
|
||||
unsigned literal = typeParam.constant->getConstArray()[0].getIConst();
|
||||
@@ -4392,7 +4445,7 @@ bool TGlslangToSpvTraverser::filterMember(const glslang::TType& member)
|
||||
extensions.find("GL_NV_stereo_view_rendering") == extensions.end())
|
||||
return true;
|
||||
|
||||
if (glslangIntermediate->getStage() != EShLangMeshNV) {
|
||||
if (glslangIntermediate->getStage() != EShLangMesh) {
|
||||
if (member.getFieldName() == "gl_ViewportMask" &&
|
||||
extensions.find("GL_NV_viewport_array2") == extensions.end())
|
||||
return true;
|
||||
@@ -4422,14 +4475,14 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
|
||||
// except sometimes for blocks
|
||||
std::vector<std::pair<glslang::TType*, glslang::TQualifier> > deferredForwardPointers;
|
||||
for (int i = 0; i < (int)glslangMembers->size(); i++) {
|
||||
glslang::TType& glslangMember = *(*glslangMembers)[i].type;
|
||||
if (glslangMember.hiddenMember()) {
|
||||
auto& glslangMember = (*glslangMembers)[i];
|
||||
if (glslangMember.type->hiddenMember()) {
|
||||
++memberDelta;
|
||||
if (type.getBasicType() == glslang::EbtBlock)
|
||||
memberRemapper[glslangTypeToIdMap[glslangMembers]][i] = -1;
|
||||
} else {
|
||||
if (type.getBasicType() == glslang::EbtBlock) {
|
||||
if (filterMember(glslangMember)) {
|
||||
if (filterMember(*glslangMember.type)) {
|
||||
memberDelta++;
|
||||
memberRemapper[glslangTypeToIdMap[glslangMembers]][i] = -1;
|
||||
continue;
|
||||
@@ -4437,7 +4490,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
|
||||
memberRemapper[glslangTypeToIdMap[glslangMembers]][i] = i - memberDelta;
|
||||
}
|
||||
// modify just this child's view of the qualifier
|
||||
glslang::TQualifier memberQualifier = glslangMember.getQualifier();
|
||||
glslang::TQualifier memberQualifier = glslangMember.type->getQualifier();
|
||||
InheritQualifiers(memberQualifier, qualifier);
|
||||
|
||||
// manually inherit location
|
||||
@@ -4448,25 +4501,38 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
|
||||
bool lastBufferBlockMember = qualifier.storage == glslang::EvqBuffer &&
|
||||
i == (int)glslangMembers->size() - 1;
|
||||
|
||||
// Make forward pointers for any pointer members, and create a list of members to
|
||||
// convert to spirv types after creating the struct.
|
||||
if (glslangMember.isReference()) {
|
||||
if (forwardPointers.find(glslangMember.getReferentType()) == forwardPointers.end()) {
|
||||
deferredForwardPointers.push_back(std::make_pair(&glslangMember, memberQualifier));
|
||||
}
|
||||
spvMembers.push_back(
|
||||
convertGlslangToSpvType(glslangMember, explicitLayout, memberQualifier, lastBufferBlockMember,
|
||||
true));
|
||||
} else {
|
||||
spvMembers.push_back(
|
||||
convertGlslangToSpvType(glslangMember, explicitLayout, memberQualifier, lastBufferBlockMember,
|
||||
false));
|
||||
// Make forward pointers for any pointer members.
|
||||
if (glslangMember.type->isReference() &&
|
||||
forwardPointers.find(glslangMember.type->getReferentType()) == forwardPointers.end()) {
|
||||
deferredForwardPointers.push_back(std::make_pair(glslangMember.type, memberQualifier));
|
||||
}
|
||||
|
||||
// Create the member type.
|
||||
auto const spvMember = convertGlslangToSpvType(*glslangMember.type, explicitLayout, memberQualifier, lastBufferBlockMember,
|
||||
glslangMember.type->isReference());
|
||||
spvMembers.push_back(spvMember);
|
||||
|
||||
// Update the builder with the type's location so that we can create debug types for the structure members.
|
||||
// There doesn't exist a "clean" entry point for this information to be passed along to the builder so, for now,
|
||||
// it is stored in the builder and consumed during the construction of composite debug types.
|
||||
// TODO: This probably warrants further investigation. This approach was decided to be the least ugly of the
|
||||
// quick and dirty approaches that were tried.
|
||||
// Advantages of this approach:
|
||||
// + Relatively clean. No direct calls into debug type system.
|
||||
// + Handles nested recursive structures.
|
||||
// Disadvantages of this approach:
|
||||
// + Not as clean as desired. Traverser queries/sets persistent state. This is fragile.
|
||||
// + Table lookup during creation of composite debug types. This really shouldn't be necessary.
|
||||
if(options.emitNonSemanticShaderDebugInfo) {
|
||||
builder.debugTypeLocs[spvMember].name = glslangMember.type->getFieldName().c_str();
|
||||
builder.debugTypeLocs[spvMember].line = glslangMember.loc.line;
|
||||
builder.debugTypeLocs[spvMember].column = glslangMember.loc.column;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make the SPIR-V type
|
||||
spv::Id spvType = builder.makeStructType(spvMembers, type.getTypeName().c_str());
|
||||
spv::Id spvType = builder.makeStructType(spvMembers, type.getTypeName().c_str(), false);
|
||||
if (! HasNonLayoutQualifiers(type, qualifier))
|
||||
structMap[explicitLayout][qualifier.layoutMatrix][glslangMembers] = spvType;
|
||||
|
||||
@@ -5060,6 +5126,7 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
||||
// GLSL has copy-in/copy-out semantics. They can be handled though with a pointer to a copy.
|
||||
|
||||
std::vector<spv::Id> paramTypes;
|
||||
std::vector<char const*> paramNames;
|
||||
std::vector<std::vector<spv::Decoration>> paramDecorations; // list of decorations per parameter
|
||||
glslang::TIntermSequence& parameters = glslFunction->getSequence()[0]->getAsAggregate()->getSequence();
|
||||
|
||||
@@ -5084,10 +5151,14 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
||||
paramTypes.push_back(typeId);
|
||||
}
|
||||
|
||||
for (auto const parameter:parameters) {
|
||||
paramNames.push_back(parameter->getAsSymbolNode()->getName().c_str());
|
||||
}
|
||||
|
||||
spv::Block* functionBlock;
|
||||
spv::Function *function = builder.makeFunctionEntry(TranslatePrecisionDecoration(glslFunction->getType()),
|
||||
convertGlslangToSpvType(glslFunction->getType()),
|
||||
glslFunction->getName().c_str(), paramTypes,
|
||||
glslFunction->getName().c_str(), paramTypes, paramNames,
|
||||
paramDecorations, &functionBlock);
|
||||
if (implicitThis)
|
||||
function->setImplicitThis();
|
||||
@@ -5177,6 +5248,7 @@ void TGlslangToSpvTraverser::handleFunctionEntry(const glslang::TIntermAggregate
|
||||
currentFunction = functionMap[node->getName().c_str()];
|
||||
spv::Block* functionBlock = currentFunction->getEntryBlock();
|
||||
builder.setBuildPoint(functionBlock);
|
||||
builder.enterFunction(currentFunction);
|
||||
}
|
||||
|
||||
void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate& node, std::vector<spv::Id>& arguments,
|
||||
@@ -5827,10 +5899,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
||||
assert(builder.isStructType(resultStructType));
|
||||
|
||||
//resType (SPIR-V type) contains 6 elements:
|
||||
//Member 0 must be a Boolean type scalar(LOD),
|
||||
//Member 1 must be a vector of integer type, whose Signedness operand is 0(anchor),
|
||||
//Member 2 must be a vector of integer type, whose Signedness operand is 0(offset),
|
||||
//Member 3 must be a vector of integer type, whose Signedness operand is 0(mask),
|
||||
//Member 0 must be a Boolean type scalar(LOD),
|
||||
//Member 1 must be a vector of integer type, whose Signedness operand is 0(anchor),
|
||||
//Member 2 must be a vector of integer type, whose Signedness operand is 0(offset),
|
||||
//Member 3 must be a vector of integer type, whose Signedness operand is 0(mask),
|
||||
//Member 4 must be a scalar of integer type, whose Signedness operand is 0(lod),
|
||||
//Member 5 must be a scalar of integer type, whose Signedness operand is 0(granularity).
|
||||
std::vector<spv::Id> members;
|
||||
@@ -5843,7 +5915,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
||||
//call ImageFootprintNV
|
||||
spv::Id res = builder.createTextureCall(precision, resType, sparse, cracked.fetch, cracked.proj,
|
||||
cracked.gather, noImplicitLod, params, signExtensionMask());
|
||||
|
||||
|
||||
//copy resType (SPIR-V type) to resultStructType(OpenGL type)
|
||||
for (int i = 0; i < 5; i++) {
|
||||
builder.clearAccessChain();
|
||||
@@ -5896,7 +5968,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<spv::Id> result( 1,
|
||||
std::vector<spv::Id> result( 1,
|
||||
builder.createTextureCall(precision, resultType(), sparse, cracked.fetch, cracked.proj, cracked.gather,
|
||||
noImplicitLod, params, signExtensionMask())
|
||||
);
|
||||
@@ -7419,7 +7491,7 @@ spv::Id TGlslangToSpvTraverser::createAtomicOperation(glslang::TOperator op, spv
|
||||
} else {
|
||||
scopeId = builder.makeUintConstant(spv::ScopeDevice);
|
||||
}
|
||||
// semantics default to relaxed
|
||||
// semantics default to relaxed
|
||||
spv::Id semanticsId = builder.makeUintConstant(lvalueCoherentFlags.isVolatile() &&
|
||||
glslangIntermediate->usingVulkanMemoryModel() ?
|
||||
spv::MemorySemanticsVolatileMask :
|
||||
@@ -8523,6 +8595,15 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
|
||||
case glslang::EOpWritePackedPrimitiveIndices4x8NV:
|
||||
builder.createNoResultOp(spv::OpWritePackedPrimitiveIndices4x8NV, operands);
|
||||
return 0;
|
||||
case glslang::EOpEmitMeshTasksEXT:
|
||||
if (taskPayloadID)
|
||||
operands.push_back(taskPayloadID);
|
||||
// As per SPV_EXT_mesh_shader make it a terminating instruction in the current block
|
||||
builder.makeStatementTerminator(spv::OpEmitMeshTasksEXT, operands, "post-OpEmitMeshTasksEXT");
|
||||
return 0;
|
||||
case glslang::EOpSetMeshOutputsEXT:
|
||||
builder.createNoResultOp(spv::OpSetMeshOutputsEXT, operands);
|
||||
return 0;
|
||||
case glslang::EOpCooperativeMatrixMulAdd:
|
||||
opCode = spv::OpCooperativeMatrixMulAddNV;
|
||||
break;
|
||||
@@ -9007,13 +9088,21 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
|
||||
// add per-primitive, per-view. per-task decorations to a struct member (member >= 0) or an object
|
||||
void TGlslangToSpvTraverser::addMeshNVDecoration(spv::Id id, int member, const glslang::TQualifier& qualifier)
|
||||
{
|
||||
bool isMeshShaderExt = (glslangIntermediate->getRequestedExtensions().find(glslang::E_GL_EXT_mesh_shader) !=
|
||||
glslangIntermediate->getRequestedExtensions().end());
|
||||
|
||||
if (member >= 0) {
|
||||
if (qualifier.perPrimitiveNV) {
|
||||
// Need to add capability/extension for fragment shader.
|
||||
// Mesh shader already adds this by default.
|
||||
if (glslangIntermediate->getStage() == EShLangFragment) {
|
||||
builder.addCapability(spv::CapabilityMeshShadingNV);
|
||||
builder.addExtension(spv::E_SPV_NV_mesh_shader);
|
||||
if(isMeshShaderExt) {
|
||||
builder.addCapability(spv::CapabilityMeshShadingEXT);
|
||||
builder.addExtension(spv::E_SPV_EXT_mesh_shader);
|
||||
} else {
|
||||
builder.addCapability(spv::CapabilityMeshShadingNV);
|
||||
builder.addExtension(spv::E_SPV_NV_mesh_shader);
|
||||
}
|
||||
}
|
||||
builder.addMemberDecoration(id, (unsigned)member, spv::DecorationPerPrimitiveNV);
|
||||
}
|
||||
@@ -9026,8 +9115,13 @@ void TGlslangToSpvTraverser::addMeshNVDecoration(spv::Id id, int member, const g
|
||||
// Need to add capability/extension for fragment shader.
|
||||
// Mesh shader already adds this by default.
|
||||
if (glslangIntermediate->getStage() == EShLangFragment) {
|
||||
builder.addCapability(spv::CapabilityMeshShadingNV);
|
||||
builder.addExtension(spv::E_SPV_NV_mesh_shader);
|
||||
if(isMeshShaderExt) {
|
||||
builder.addCapability(spv::CapabilityMeshShadingEXT);
|
||||
builder.addExtension(spv::E_SPV_EXT_mesh_shader);
|
||||
} else {
|
||||
builder.addCapability(spv::CapabilityMeshShadingNV);
|
||||
builder.addExtension(spv::E_SPV_NV_mesh_shader);
|
||||
}
|
||||
}
|
||||
builder.addDecoration(id, spv::DecorationPerPrimitiveNV);
|
||||
}
|
||||
|
||||
171
3rdparty/glslang/SPIRV/NonSemanticShaderDebugInfo100.h
vendored
Normal file
171
3rdparty/glslang/SPIRV/NonSemanticShaderDebugInfo100.h
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
// Copyright (c) 2018 The Khronos Group Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and/or associated documentation files (the "Materials"),
|
||||
// to deal in the Materials without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Materials, and to permit persons to whom the
|
||||
// Materials are furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Materials.
|
||||
//
|
||||
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
|
||||
// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
|
||||
// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
|
||||
//
|
||||
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
|
||||
// IN THE MATERIALS.
|
||||
|
||||
#ifndef SPIRV_UNIFIED1_NonSemanticShaderDebugInfo100_H_
|
||||
#define SPIRV_UNIFIED1_NonSemanticShaderDebugInfo100_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
NonSemanticShaderDebugInfo100Version = 100,
|
||||
NonSemanticShaderDebugInfo100Version_BitWidthPadding = 0x7fffffff
|
||||
};
|
||||
enum {
|
||||
NonSemanticShaderDebugInfo100Revision = 6,
|
||||
NonSemanticShaderDebugInfo100Revision_BitWidthPadding = 0x7fffffff
|
||||
};
|
||||
|
||||
enum NonSemanticShaderDebugInfo100Instructions {
|
||||
NonSemanticShaderDebugInfo100DebugInfoNone = 0,
|
||||
NonSemanticShaderDebugInfo100DebugCompilationUnit = 1,
|
||||
NonSemanticShaderDebugInfo100DebugTypeBasic = 2,
|
||||
NonSemanticShaderDebugInfo100DebugTypePointer = 3,
|
||||
NonSemanticShaderDebugInfo100DebugTypeQualifier = 4,
|
||||
NonSemanticShaderDebugInfo100DebugTypeArray = 5,
|
||||
NonSemanticShaderDebugInfo100DebugTypeVector = 6,
|
||||
NonSemanticShaderDebugInfo100DebugTypedef = 7,
|
||||
NonSemanticShaderDebugInfo100DebugTypeFunction = 8,
|
||||
NonSemanticShaderDebugInfo100DebugTypeEnum = 9,
|
||||
NonSemanticShaderDebugInfo100DebugTypeComposite = 10,
|
||||
NonSemanticShaderDebugInfo100DebugTypeMember = 11,
|
||||
NonSemanticShaderDebugInfo100DebugTypeInheritance = 12,
|
||||
NonSemanticShaderDebugInfo100DebugTypePtrToMember = 13,
|
||||
NonSemanticShaderDebugInfo100DebugTypeTemplate = 14,
|
||||
NonSemanticShaderDebugInfo100DebugTypeTemplateParameter = 15,
|
||||
NonSemanticShaderDebugInfo100DebugTypeTemplateTemplateParameter = 16,
|
||||
NonSemanticShaderDebugInfo100DebugTypeTemplateParameterPack = 17,
|
||||
NonSemanticShaderDebugInfo100DebugGlobalVariable = 18,
|
||||
NonSemanticShaderDebugInfo100DebugFunctionDeclaration = 19,
|
||||
NonSemanticShaderDebugInfo100DebugFunction = 20,
|
||||
NonSemanticShaderDebugInfo100DebugLexicalBlock = 21,
|
||||
NonSemanticShaderDebugInfo100DebugLexicalBlockDiscriminator = 22,
|
||||
NonSemanticShaderDebugInfo100DebugScope = 23,
|
||||
NonSemanticShaderDebugInfo100DebugNoScope = 24,
|
||||
NonSemanticShaderDebugInfo100DebugInlinedAt = 25,
|
||||
NonSemanticShaderDebugInfo100DebugLocalVariable = 26,
|
||||
NonSemanticShaderDebugInfo100DebugInlinedVariable = 27,
|
||||
NonSemanticShaderDebugInfo100DebugDeclare = 28,
|
||||
NonSemanticShaderDebugInfo100DebugValue = 29,
|
||||
NonSemanticShaderDebugInfo100DebugOperation = 30,
|
||||
NonSemanticShaderDebugInfo100DebugExpression = 31,
|
||||
NonSemanticShaderDebugInfo100DebugMacroDef = 32,
|
||||
NonSemanticShaderDebugInfo100DebugMacroUndef = 33,
|
||||
NonSemanticShaderDebugInfo100DebugImportedEntity = 34,
|
||||
NonSemanticShaderDebugInfo100DebugSource = 35,
|
||||
NonSemanticShaderDebugInfo100DebugFunctionDefinition = 101,
|
||||
NonSemanticShaderDebugInfo100DebugSourceContinued = 102,
|
||||
NonSemanticShaderDebugInfo100DebugLine = 103,
|
||||
NonSemanticShaderDebugInfo100DebugNoLine = 104,
|
||||
NonSemanticShaderDebugInfo100DebugBuildIdentifier = 105,
|
||||
NonSemanticShaderDebugInfo100DebugStoragePath = 106,
|
||||
NonSemanticShaderDebugInfo100DebugEntryPoint = 107,
|
||||
NonSemanticShaderDebugInfo100DebugTypeMatrix = 108,
|
||||
NonSemanticShaderDebugInfo100InstructionsMax = 0x7fffffff
|
||||
};
|
||||
|
||||
|
||||
enum NonSemanticShaderDebugInfo100DebugInfoFlags {
|
||||
NonSemanticShaderDebugInfo100None = 0x0000,
|
||||
NonSemanticShaderDebugInfo100FlagIsProtected = 0x01,
|
||||
NonSemanticShaderDebugInfo100FlagIsPrivate = 0x02,
|
||||
NonSemanticShaderDebugInfo100FlagIsPublic = 0x03,
|
||||
NonSemanticShaderDebugInfo100FlagIsLocal = 0x04,
|
||||
NonSemanticShaderDebugInfo100FlagIsDefinition = 0x08,
|
||||
NonSemanticShaderDebugInfo100FlagFwdDecl = 0x10,
|
||||
NonSemanticShaderDebugInfo100FlagArtificial = 0x20,
|
||||
NonSemanticShaderDebugInfo100FlagExplicit = 0x40,
|
||||
NonSemanticShaderDebugInfo100FlagPrototyped = 0x80,
|
||||
NonSemanticShaderDebugInfo100FlagObjectPointer = 0x100,
|
||||
NonSemanticShaderDebugInfo100FlagStaticMember = 0x200,
|
||||
NonSemanticShaderDebugInfo100FlagIndirectVariable = 0x400,
|
||||
NonSemanticShaderDebugInfo100FlagLValueReference = 0x800,
|
||||
NonSemanticShaderDebugInfo100FlagRValueReference = 0x1000,
|
||||
NonSemanticShaderDebugInfo100FlagIsOptimized = 0x2000,
|
||||
NonSemanticShaderDebugInfo100FlagIsEnumClass = 0x4000,
|
||||
NonSemanticShaderDebugInfo100FlagTypePassByValue = 0x8000,
|
||||
NonSemanticShaderDebugInfo100FlagTypePassByReference = 0x10000,
|
||||
NonSemanticShaderDebugInfo100FlagUnknownPhysicalLayout = 0x20000,
|
||||
NonSemanticShaderDebugInfo100DebugInfoFlagsMax = 0x7fffffff
|
||||
};
|
||||
|
||||
enum NonSemanticShaderDebugInfo100BuildIdentifierFlags {
|
||||
NonSemanticShaderDebugInfo100IdentifierPossibleDuplicates = 0x01,
|
||||
NonSemanticShaderDebugInfo100BuildIdentifierFlagsMax = 0x7fffffff
|
||||
};
|
||||
|
||||
enum NonSemanticShaderDebugInfo100DebugBaseTypeAttributeEncoding {
|
||||
NonSemanticShaderDebugInfo100Unspecified = 0,
|
||||
NonSemanticShaderDebugInfo100Address = 1,
|
||||
NonSemanticShaderDebugInfo100Boolean = 2,
|
||||
NonSemanticShaderDebugInfo100Float = 3,
|
||||
NonSemanticShaderDebugInfo100Signed = 4,
|
||||
NonSemanticShaderDebugInfo100SignedChar = 5,
|
||||
NonSemanticShaderDebugInfo100Unsigned = 6,
|
||||
NonSemanticShaderDebugInfo100UnsignedChar = 7,
|
||||
NonSemanticShaderDebugInfo100DebugBaseTypeAttributeEncodingMax = 0x7fffffff
|
||||
};
|
||||
|
||||
enum NonSemanticShaderDebugInfo100DebugCompositeType {
|
||||
NonSemanticShaderDebugInfo100Class = 0,
|
||||
NonSemanticShaderDebugInfo100Structure = 1,
|
||||
NonSemanticShaderDebugInfo100Union = 2,
|
||||
NonSemanticShaderDebugInfo100DebugCompositeTypeMax = 0x7fffffff
|
||||
};
|
||||
|
||||
enum NonSemanticShaderDebugInfo100DebugTypeQualifier {
|
||||
NonSemanticShaderDebugInfo100ConstType = 0,
|
||||
NonSemanticShaderDebugInfo100VolatileType = 1,
|
||||
NonSemanticShaderDebugInfo100RestrictType = 2,
|
||||
NonSemanticShaderDebugInfo100AtomicType = 3,
|
||||
NonSemanticShaderDebugInfo100DebugTypeQualifierMax = 0x7fffffff
|
||||
};
|
||||
|
||||
enum NonSemanticShaderDebugInfo100DebugOperation {
|
||||
NonSemanticShaderDebugInfo100Deref = 0,
|
||||
NonSemanticShaderDebugInfo100Plus = 1,
|
||||
NonSemanticShaderDebugInfo100Minus = 2,
|
||||
NonSemanticShaderDebugInfo100PlusUconst = 3,
|
||||
NonSemanticShaderDebugInfo100BitPiece = 4,
|
||||
NonSemanticShaderDebugInfo100Swap = 5,
|
||||
NonSemanticShaderDebugInfo100Xderef = 6,
|
||||
NonSemanticShaderDebugInfo100StackValue = 7,
|
||||
NonSemanticShaderDebugInfo100Constu = 8,
|
||||
NonSemanticShaderDebugInfo100Fragment = 9,
|
||||
NonSemanticShaderDebugInfo100DebugOperationMax = 0x7fffffff
|
||||
};
|
||||
|
||||
enum NonSemanticShaderDebugInfo100DebugImportedEntity {
|
||||
NonSemanticShaderDebugInfo100ImportedModule = 0,
|
||||
NonSemanticShaderDebugInfo100ImportedDeclaration = 1,
|
||||
NonSemanticShaderDebugInfo100DebugImportedEntityMax = 0x7fffffff
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SPIRV_UNIFIED1_NonSemanticShaderDebugInfo100_H_
|
||||
746
3rdparty/glslang/SPIRV/SpvBuilder.cpp
vendored
746
3rdparty/glslang/SPIRV/SpvBuilder.cpp
vendored
@@ -59,12 +59,15 @@ namespace spv {
|
||||
|
||||
Builder::Builder(unsigned int spvVersion, unsigned int magicNumber, SpvBuildLogger* buildLogger) :
|
||||
spvVersion(spvVersion),
|
||||
source(SourceLanguageUnknown),
|
||||
sourceLang(SourceLanguageUnknown),
|
||||
sourceVersion(0),
|
||||
sourceFileStringId(NoResult),
|
||||
currentLine(0),
|
||||
currentFile(nullptr),
|
||||
currentFileId(NoResult),
|
||||
lastDebugScopeId(NoResult),
|
||||
emitOpLines(false),
|
||||
emitNonSemanticShaderDebugInfo(false),
|
||||
addressModel(AddressingModelLogical),
|
||||
memoryModel(MemoryModelGLSL450),
|
||||
builderNumber(magicNumber),
|
||||
@@ -98,8 +101,12 @@ void Builder::setLine(int lineNum)
|
||||
{
|
||||
if (lineNum != 0 && lineNum != currentLine) {
|
||||
currentLine = lineNum;
|
||||
if (emitOpLines)
|
||||
addLine(sourceFileStringId, currentLine, 0);
|
||||
if (emitOpLines) {
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
addDebugScopeAndLine(currentFileId, currentLine, 0);
|
||||
else
|
||||
addLine(sourceFileStringId, currentLine, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +125,10 @@ void Builder::setLine(int lineNum, const char* filename)
|
||||
currentFile = filename;
|
||||
if (emitOpLines) {
|
||||
spv::Id strId = getStringId(filename);
|
||||
addLine(strId, currentLine, 0);
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
addDebugScopeAndLine(strId, currentLine, 0);
|
||||
else
|
||||
addLine(strId, currentLine, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,22 +142,49 @@ void Builder::addLine(Id fileName, int lineNum, int column)
|
||||
buildPoint->addInstruction(std::unique_ptr<Instruction>(line));
|
||||
}
|
||||
|
||||
void Builder::addDebugScopeAndLine(Id fileName, int lineNum, int column)
|
||||
{
|
||||
if (currentDebugScopeId.top() != lastDebugScopeId) {
|
||||
spv::Id resultId = getUniqueId();
|
||||
Instruction* scopeInst = new Instruction(resultId, makeVoidType(), OpExtInst);
|
||||
scopeInst->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
scopeInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugScope);
|
||||
scopeInst->addIdOperand(currentDebugScopeId.top());
|
||||
buildPoint->addInstruction(std::unique_ptr<Instruction>(scopeInst));
|
||||
lastDebugScopeId = currentDebugScopeId.top();
|
||||
}
|
||||
spv::Id resultId = getUniqueId();
|
||||
Instruction* lineInst = new Instruction(resultId, makeVoidType(), OpExtInst);
|
||||
lineInst->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
lineInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugLine);
|
||||
lineInst->addIdOperand(makeDebugSource(fileName));
|
||||
lineInst->addIdOperand(makeUintConstant(lineNum));
|
||||
lineInst->addIdOperand(makeUintConstant(lineNum));
|
||||
lineInst->addIdOperand(makeUintConstant(column));
|
||||
lineInst->addIdOperand(makeUintConstant(column));
|
||||
buildPoint->addInstruction(std::unique_ptr<Instruction>(lineInst));
|
||||
}
|
||||
|
||||
// For creating new groupedTypes (will return old type if the requested one was already made).
|
||||
Id Builder::makeVoidType()
|
||||
{
|
||||
Instruction* type;
|
||||
if (groupedTypes[OpTypeVoid].size() == 0) {
|
||||
type = new Instruction(getUniqueId(), NoType, OpTypeVoid);
|
||||
Id typeId = getUniqueId();
|
||||
type = new Instruction(typeId, NoType, OpTypeVoid);
|
||||
groupedTypes[OpTypeVoid].push_back(type);
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
// Core OpTypeVoid used for debug void type
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
debugId[typeId] = typeId;
|
||||
} else
|
||||
type = groupedTypes[OpTypeVoid].back();
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeBoolType()
|
||||
Id Builder::makeBoolType(bool const compilerGenerated)
|
||||
{
|
||||
Instruction* type;
|
||||
if (groupedTypes[OpTypeBool].size() == 0) {
|
||||
@@ -158,6 +195,12 @@ Id Builder::makeBoolType()
|
||||
} else
|
||||
type = groupedTypes[OpTypeBool].back();
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo && !compilerGenerated)
|
||||
{
|
||||
auto const debugResultId = makeBoolDebugType(32);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
@@ -172,6 +215,12 @@ Id Builder::makeSamplerType()
|
||||
} else
|
||||
type = groupedTypes[OpTypeSampler].back();
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
{
|
||||
auto const debugResultId = makeCompositeDebugType({}, "type.sampler", NonSemanticShaderDebugInfo100Structure, true);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
@@ -268,6 +317,12 @@ Id Builder::makeIntegerType(int width, bool hasSign)
|
||||
break;
|
||||
}
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
{
|
||||
auto const debugResultId = makeIntegerDebugType(width, hasSign);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
@@ -305,6 +360,12 @@ Id Builder::makeFloatType(int width)
|
||||
break;
|
||||
}
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
{
|
||||
auto const debugResultId = makeFloatDebugType(width);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
@@ -312,7 +373,7 @@ Id Builder::makeFloatType(int width)
|
||||
// See makeStructResultType() for non-decorated structs
|
||||
// needed as the result of some instructions, which does
|
||||
// check for duplicates.
|
||||
Id Builder::makeStructType(const std::vector<Id>& members, const char* name)
|
||||
Id Builder::makeStructType(const std::vector<Id>& members, const char* name, bool const compilerGenerated)
|
||||
{
|
||||
// Don't look for previous one, because in the general case,
|
||||
// structs can be duplicated except for decorations.
|
||||
@@ -326,6 +387,12 @@ Id Builder::makeStructType(const std::vector<Id>& members, const char* name)
|
||||
module.mapInstruction(type);
|
||||
addName(type->getResultId(), name);
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo && !compilerGenerated)
|
||||
{
|
||||
auto const debugResultId = makeCompositeDebugType(members, name, NonSemanticShaderDebugInfo100Structure);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
@@ -372,6 +439,12 @@ Id Builder::makeVectorType(Id component, int size)
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
{
|
||||
auto const debugResultId = makeVectorDebugType(component, size);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
@@ -398,6 +471,12 @@ Id Builder::makeMatrixType(Id component, int cols, int rows)
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
{
|
||||
auto const debugResultId = makeMatrixDebugType(column, cols);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
@@ -484,6 +563,12 @@ Id Builder::makeArrayType(Id element, Id sizeId, int stride)
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
{
|
||||
auto const debugResultId = makeArrayDebugType(element, sizeId);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
@@ -494,6 +579,12 @@ Id Builder::makeRuntimeArray(Id element)
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
{
|
||||
auto const debugResultId = makeArrayDebugType(element, makeUintConstant(0));
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
@@ -513,11 +604,25 @@ Id Builder::makeFunctionType(Id returnType, const std::vector<Id>& paramTypes)
|
||||
}
|
||||
}
|
||||
if (! mismatch)
|
||||
{
|
||||
// If compiling HLSL, glslang will create a wrapper function around the entrypoint. Accordingly, a void(void)
|
||||
// function type is created for the wrapper function. However, nonsemantic shader debug information is disabled
|
||||
// while creating the HLSL wrapper. Consequently, if we encounter another void(void) function, we need to create
|
||||
// the associated debug function type if it hasn't been created yet.
|
||||
if(emitNonSemanticShaderDebugInfo && debugId[type->getResultId()] == 0) {
|
||||
assert(sourceLang == spv::SourceLanguageHLSL);
|
||||
assert(getTypeClass(returnType) == OpTypeVoid && paramTypes.size() == 0);
|
||||
|
||||
Id debugTypeId = makeDebugFunctionType(returnType, {});
|
||||
debugId[type->getResultId()] = debugTypeId;
|
||||
}
|
||||
return type->getResultId();
|
||||
}
|
||||
}
|
||||
|
||||
// not found, make it
|
||||
type = new Instruction(getUniqueId(), NoType, OpTypeFunction);
|
||||
Id typeId = getUniqueId();
|
||||
type = new Instruction(typeId, NoType, OpTypeFunction);
|
||||
type->addIdOperand(returnType);
|
||||
for (int p = 0; p < (int)paramTypes.size(); ++p)
|
||||
type->addIdOperand(paramTypes[p]);
|
||||
@@ -525,9 +630,34 @@ Id Builder::makeFunctionType(Id returnType, const std::vector<Id>& paramTypes)
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
// make debug type and map it
|
||||
if (emitNonSemanticShaderDebugInfo) {
|
||||
Id debugTypeId = makeDebugFunctionType(returnType, paramTypes);
|
||||
debugId[typeId] = debugTypeId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeDebugFunctionType(Id returnType, const std::vector<Id>& paramTypes)
|
||||
{
|
||||
assert(debugId[returnType] != 0);
|
||||
|
||||
Id typeId = getUniqueId();
|
||||
auto type = new Instruction(typeId, makeVoidType(), OpExtInst);
|
||||
type->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeFunction);
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic));
|
||||
type->addIdOperand(debugId[returnType]);
|
||||
for (auto const paramType : paramTypes) {
|
||||
assert(isPointerType(paramType) || isArrayType(paramType));
|
||||
type->addIdOperand(debugId[getContainedTypeId(paramType)]);
|
||||
}
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
return typeId;
|
||||
}
|
||||
|
||||
Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, bool ms, unsigned sampled,
|
||||
ImageFormat format)
|
||||
{
|
||||
@@ -609,6 +739,22 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo
|
||||
}
|
||||
#endif
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
{
|
||||
auto TypeName = [&dim]() -> char const* {
|
||||
switch (dim) {
|
||||
case Dim1D: return "type.1d.image";
|
||||
case Dim2D: return "type.2d.image";
|
||||
case Dim3D: return "type.3d.image";
|
||||
case DimCube: return "type.cube.image";
|
||||
default: return "type.image";
|
||||
}
|
||||
};
|
||||
|
||||
auto const debugResultId = makeCompositeDebugType({}, TypeName(), NonSemanticShaderDebugInfo100Class, true);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
@@ -630,9 +776,376 @@ Id Builder::makeSampledImageType(Id imageType)
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
{
|
||||
auto const debugResultId = makeCompositeDebugType({}, "type.sampled.image", NonSemanticShaderDebugInfo100Class, true);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeDebugInfoNone()
|
||||
{
|
||||
if (debugInfoNone != 0)
|
||||
return debugInfoNone;
|
||||
|
||||
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
inst->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugInfoNone);
|
||||
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(inst));
|
||||
module.mapInstruction(inst);
|
||||
|
||||
debugInfoNone = inst->getResultId();
|
||||
|
||||
return debugInfoNone;
|
||||
}
|
||||
|
||||
Id Builder::makeBoolDebugType(int const size)
|
||||
{
|
||||
// try to find it
|
||||
Instruction* type;
|
||||
for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].size(); ++t) {
|
||||
type = groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic][t];
|
||||
if (type->getIdOperand(0) == getStringId("bool") &&
|
||||
type->getIdOperand(1) == static_cast<unsigned int>(size) &&
|
||||
type->getIdOperand(2) == NonSemanticShaderDebugInfo100Boolean)
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
type->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic);
|
||||
|
||||
type->addIdOperand(getStringId("bool")); // name id
|
||||
type->addIdOperand(makeUintConstant(size)); // size id
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Boolean)); // encoding id
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100None)); // flags id
|
||||
|
||||
groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].push_back(type);
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeIntegerDebugType(int const width, bool const hasSign)
|
||||
{
|
||||
// try to find it
|
||||
Instruction* type;
|
||||
for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].size(); ++t) {
|
||||
type = groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic][t];
|
||||
if (type->getIdOperand(0) == (hasSign ? getStringId("int") : getStringId("uint")) &&
|
||||
type->getIdOperand(1) == static_cast<unsigned int>(width) &&
|
||||
type->getIdOperand(2) == (hasSign ? NonSemanticShaderDebugInfo100Signed : NonSemanticShaderDebugInfo100Unsigned))
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
// not found, make it
|
||||
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
type->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic);
|
||||
if(hasSign == true) {
|
||||
type->addIdOperand(getStringId("int")); // name id
|
||||
} else {
|
||||
type->addIdOperand(getStringId("uint")); // name id
|
||||
}
|
||||
type->addIdOperand(makeUintConstant(width)); // size id
|
||||
if(hasSign == true) {
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Signed)); // encoding id
|
||||
} else {
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Unsigned)); // encoding id
|
||||
}
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100None)); // flags id
|
||||
|
||||
groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].push_back(type);
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeFloatDebugType(int const width)
|
||||
{
|
||||
// try to find it
|
||||
Instruction* type;
|
||||
for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].size(); ++t) {
|
||||
type = groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic][t];
|
||||
if (type->getIdOperand(0) == getStringId("float") &&
|
||||
type->getIdOperand(1) == static_cast<unsigned int>(width) &&
|
||||
type->getIdOperand(2) == NonSemanticShaderDebugInfo100Float)
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
// not found, make it
|
||||
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
type->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic);
|
||||
type->addIdOperand(getStringId("float")); // name id
|
||||
type->addIdOperand(makeUintConstant(width)); // size id
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Float)); // encoding id
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100None)); // flags id
|
||||
|
||||
groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].push_back(type);
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeSequentialDebugType(Id const baseType, Id const componentCount, NonSemanticShaderDebugInfo100Instructions const sequenceType)
|
||||
{
|
||||
assert(sequenceType == NonSemanticShaderDebugInfo100DebugTypeArray ||
|
||||
sequenceType == NonSemanticShaderDebugInfo100DebugTypeVector);
|
||||
|
||||
// try to find it
|
||||
Instruction* type;
|
||||
for (int t = 0; t < (int)groupedDebugTypes[sequenceType].size(); ++t) {
|
||||
type = groupedDebugTypes[sequenceType][t];
|
||||
if (type->getIdOperand(0) == baseType &&
|
||||
type->getIdOperand(1) == makeUintConstant(componentCount))
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
// not found, make it
|
||||
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
type->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
type->addImmediateOperand(sequenceType);
|
||||
type->addIdOperand(debugId[baseType]); // base type
|
||||
type->addIdOperand(componentCount); // component count
|
||||
|
||||
groupedDebugTypes[sequenceType].push_back(type);
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeArrayDebugType(Id const baseType, Id const componentCount)
|
||||
{
|
||||
return makeSequentialDebugType(baseType, componentCount, NonSemanticShaderDebugInfo100DebugTypeArray);
|
||||
}
|
||||
|
||||
Id Builder::makeVectorDebugType(Id const baseType, int const componentCount)
|
||||
{
|
||||
return makeSequentialDebugType(baseType, makeUintConstant(componentCount), NonSemanticShaderDebugInfo100DebugTypeVector);;
|
||||
}
|
||||
|
||||
Id Builder::makeMatrixDebugType(Id const vectorType, int const vectorCount, bool columnMajor)
|
||||
{
|
||||
// try to find it
|
||||
Instruction* type;
|
||||
for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeMatrix].size(); ++t) {
|
||||
type = groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeMatrix][t];
|
||||
if (type->getIdOperand(0) == vectorType &&
|
||||
type->getIdOperand(1) == makeUintConstant(vectorCount))
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
// not found, make it
|
||||
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
type->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeMatrix);
|
||||
type->addIdOperand(debugId[vectorType]); // vector type id
|
||||
type->addIdOperand(makeUintConstant(vectorCount)); // component count id
|
||||
type->addIdOperand(makeBoolConstant(columnMajor)); // column-major id
|
||||
|
||||
groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeMatrix].push_back(type);
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeMemberDebugType(Id const memberType, DebugTypeLoc const& debugTypeLoc)
|
||||
{
|
||||
assert(debugId[memberType] != 0);
|
||||
|
||||
Instruction* type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
type->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeMember);
|
||||
type->addIdOperand(getStringId(debugTypeLoc.name)); // name id
|
||||
type->addIdOperand(debugId[memberType]); // type id
|
||||
type->addIdOperand(makeDebugSource(sourceFileStringId)); // source id TODO: verify this works across include directives
|
||||
type->addIdOperand(makeUintConstant(debugTypeLoc.line)); // line id TODO: currentLine is always zero
|
||||
type->addIdOperand(makeUintConstant(debugTypeLoc.column)); // TODO: column id
|
||||
type->addIdOperand(makeUintConstant(0)); // TODO: offset id
|
||||
type->addIdOperand(makeUintConstant(0)); // TODO: size id
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic)); // flags id
|
||||
|
||||
groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeMember].push_back(type);
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
// Note: To represent a source language opaque type, this instruction must have no Members operands, Size operand must be
|
||||
// DebugInfoNone, and Name must start with @ to avoid clashes with user defined names.
|
||||
Id Builder::makeCompositeDebugType(std::vector<Id> const& memberTypes, char const*const name,
|
||||
NonSemanticShaderDebugInfo100DebugCompositeType const tag, bool const isOpaqueType)
|
||||
{
|
||||
// Create the debug member types.
|
||||
std::vector<Id> memberDebugTypes;
|
||||
for(auto const memberType : memberTypes) {
|
||||
assert(debugTypeLocs.find(memberType) != debugTypeLocs.end());
|
||||
|
||||
memberDebugTypes.emplace_back(makeMemberDebugType(memberType, debugTypeLocs[memberType]));
|
||||
|
||||
// TODO: Need to rethink this method of passing location information.
|
||||
// debugTypeLocs.erase(memberType);
|
||||
}
|
||||
|
||||
// Create The structure debug type.
|
||||
Instruction* type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
type->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeComposite);
|
||||
type->addIdOperand(getStringId(name)); // name id
|
||||
type->addIdOperand(makeUintConstant(tag)); // tag id
|
||||
type->addIdOperand(makeDebugSource(sourceFileStringId)); // source id TODO: verify this works across include directives
|
||||
type->addIdOperand(makeUintConstant(currentLine)); // line id TODO: currentLine always zero?
|
||||
type->addIdOperand(makeUintConstant(0)); // TODO: column id
|
||||
type->addIdOperand(makeDebugCompilationUnit()); // scope id
|
||||
if(isOpaqueType == true) {
|
||||
// Prepend '@' to opaque types.
|
||||
type->addIdOperand(getStringId('@' + std::string(name))); // linkage name id
|
||||
type->addIdOperand(makeDebugInfoNone()); // size id
|
||||
} else {
|
||||
type->addIdOperand(getStringId(name)); // linkage name id
|
||||
type->addIdOperand(makeUintConstant(0)); // TODO: size id
|
||||
}
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic)); // flags id
|
||||
assert(isOpaqueType == false || (isOpaqueType == true && memberDebugTypes.empty()));
|
||||
for(auto const memberDebugType : memberDebugTypes) {
|
||||
type->addIdOperand(memberDebugType);
|
||||
}
|
||||
|
||||
groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeComposite].push_back(type);
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeDebugSource(const Id fileName) {
|
||||
if (debugSourceId.find(fileName) != debugSourceId.end())
|
||||
return debugSourceId[fileName];
|
||||
spv::Id resultId = getUniqueId();
|
||||
Instruction* sourceInst = new Instruction(resultId, makeVoidType(), OpExtInst);
|
||||
sourceInst->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
sourceInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugSource);
|
||||
sourceInst->addIdOperand(fileName);
|
||||
if (emitNonSemanticShaderDebugSource) {
|
||||
spv::Id sourceId = 0;
|
||||
if (fileName == sourceFileStringId) {
|
||||
sourceId = getStringId(sourceText);
|
||||
} else {
|
||||
auto incItr = includeFiles.find(fileName);
|
||||
assert(incItr != includeFiles.end());
|
||||
sourceId = getStringId(*incItr->second);
|
||||
}
|
||||
sourceInst->addIdOperand(sourceId);
|
||||
}
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(sourceInst));
|
||||
module.mapInstruction(sourceInst);
|
||||
debugSourceId[fileName] = resultId;
|
||||
return resultId;
|
||||
}
|
||||
|
||||
Id Builder::makeDebugCompilationUnit() {
|
||||
if (nonSemanticShaderCompilationUnitId != 0)
|
||||
return nonSemanticShaderCompilationUnitId;
|
||||
spv::Id resultId = getUniqueId();
|
||||
Instruction* sourceInst = new Instruction(resultId, makeVoidType(), OpExtInst);
|
||||
sourceInst->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
sourceInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugCompilationUnit);
|
||||
sourceInst->addIdOperand(makeUintConstant(1)); // TODO(greg-lunarg): Get rid of magic number
|
||||
sourceInst->addIdOperand(makeUintConstant(4)); // TODO(greg-lunarg): Get rid of magic number
|
||||
sourceInst->addIdOperand(makeDebugSource(sourceFileStringId));
|
||||
sourceInst->addIdOperand(makeUintConstant(sourceLang));
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(sourceInst));
|
||||
module.mapInstruction(sourceInst);
|
||||
nonSemanticShaderCompilationUnitId = resultId;
|
||||
return resultId;
|
||||
}
|
||||
|
||||
Id Builder::createDebugGlobalVariable(Id const type, char const*const name, Id const variable)
|
||||
{
|
||||
assert(type != 0);
|
||||
|
||||
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
inst->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugGlobalVariable);
|
||||
inst->addIdOperand(getStringId(name)); // name id
|
||||
inst->addIdOperand(type); // type id
|
||||
inst->addIdOperand(makeDebugSource(sourceFileStringId)); // source id
|
||||
inst->addIdOperand(makeUintConstant(currentLine)); // line id TODO: currentLine always zero?
|
||||
inst->addIdOperand(makeUintConstant(0)); // TODO: column id
|
||||
inst->addIdOperand(makeDebugCompilationUnit()); // scope id
|
||||
inst->addIdOperand(getStringId(name)); // linkage name id
|
||||
inst->addIdOperand(variable); // variable id
|
||||
inst->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsDefinition)); // flags id
|
||||
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(inst));
|
||||
module.mapInstruction(inst);
|
||||
|
||||
return inst->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::createDebugLocalVariable(Id type, char const*const name, size_t const argNumber)
|
||||
{
|
||||
assert(name != nullptr);
|
||||
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
inst->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugLocalVariable);
|
||||
inst->addIdOperand(getStringId(name)); // name id
|
||||
inst->addIdOperand(type); // type id
|
||||
inst->addIdOperand(makeDebugSource(sourceFileStringId)); // source id
|
||||
inst->addIdOperand(makeUintConstant(currentLine)); // line id
|
||||
inst->addIdOperand(makeUintConstant(0)); // TODO: column id
|
||||
inst->addIdOperand(currentDebugScopeId.top()); // scope id
|
||||
inst->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsLocal)); // flags id
|
||||
if(argNumber != 0) {
|
||||
inst->addIdOperand(makeUintConstant(argNumber));
|
||||
}
|
||||
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(inst));
|
||||
module.mapInstruction(inst);
|
||||
|
||||
return inst->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeDebugExpression()
|
||||
{
|
||||
if (debugExpression != 0)
|
||||
return debugExpression;
|
||||
|
||||
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
inst->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugExpression);
|
||||
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(inst));
|
||||
module.mapInstruction(inst);
|
||||
|
||||
debugExpression = inst->getResultId();
|
||||
|
||||
return debugExpression;
|
||||
}
|
||||
|
||||
Id Builder::makeDebugDeclare(Id const debugLocalVariable, Id const localVariable)
|
||||
{
|
||||
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
|
||||
inst->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugDeclare);
|
||||
inst->addIdOperand(debugLocalVariable); // debug local variable id
|
||||
inst->addIdOperand(localVariable); // local variable id
|
||||
inst->addIdOperand(makeDebugExpression()); // expression id
|
||||
buildPoint->addInstruction(std::unique_ptr<Instruction>(inst));
|
||||
|
||||
return inst->getResultId();
|
||||
}
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
Id Builder::makeAccelerationStructureType()
|
||||
{
|
||||
@@ -920,6 +1433,17 @@ bool Builder::isSpecConstantOpCode(Op opcode) const
|
||||
}
|
||||
}
|
||||
|
||||
bool Builder::isRayTracingOpCode(Op opcode) const
|
||||
{
|
||||
switch (opcode) {
|
||||
case OpTypeAccelerationStructureKHR:
|
||||
case OpTypeRayQueryKHR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Id Builder::makeNullConstant(Id typeId)
|
||||
{
|
||||
Instruction* constant;
|
||||
@@ -1136,6 +1660,19 @@ Id Builder::makeFpConstant(Id type, double d, bool specConstant)
|
||||
return NoResult;
|
||||
}
|
||||
|
||||
Id Builder::importNonSemanticShaderDebugInfoInstructions()
|
||||
{
|
||||
assert(emitNonSemanticShaderDebugInfo == true);
|
||||
|
||||
if(nonSemanticShaderDebugInfo == 0)
|
||||
{
|
||||
this->addExtension(spv::E_SPV_KHR_non_semantic_info);
|
||||
nonSemanticShaderDebugInfo = this->import("NonSemantic.Shader.DebugInfo.100");
|
||||
}
|
||||
|
||||
return nonSemanticShaderDebugInfo;
|
||||
}
|
||||
|
||||
Id Builder::findCompositeConstant(Op typeClass, Id typeId, const std::vector<Id>& comps)
|
||||
{
|
||||
Instruction* constant = 0;
|
||||
@@ -1447,23 +1984,34 @@ Function* Builder::makeEntryPoint(const char* entryPoint)
|
||||
assert(! entryPointFunction);
|
||||
|
||||
Block* entry;
|
||||
std::vector<Id> params;
|
||||
std::vector<Id> paramsTypes;
|
||||
std::vector<char const*> paramNames;
|
||||
std::vector<std::vector<Decoration>> decorations;
|
||||
|
||||
entryPointFunction = makeFunctionEntry(NoPrecision, makeVoidType(), entryPoint, params, decorations, &entry);
|
||||
auto const returnType = makeVoidType();
|
||||
|
||||
restoreNonSemanticShaderDebugInfo = emitNonSemanticShaderDebugInfo;
|
||||
if(sourceLang == spv::SourceLanguageHLSL) {
|
||||
emitNonSemanticShaderDebugInfo = false;
|
||||
}
|
||||
|
||||
entryPointFunction = makeFunctionEntry(NoPrecision, returnType, entryPoint, paramsTypes, paramNames, decorations, &entry);
|
||||
|
||||
emitNonSemanticShaderDebugInfo = restoreNonSemanticShaderDebugInfo;
|
||||
|
||||
return entryPointFunction;
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const char* name,
|
||||
const std::vector<Id>& paramTypes,
|
||||
const std::vector<Id>& paramTypes, const std::vector<char const*>& paramNames,
|
||||
const std::vector<std::vector<Decoration>>& decorations, Block **entry)
|
||||
{
|
||||
// Make the function and initial instructions in it
|
||||
Id typeId = makeFunctionType(returnType, paramTypes);
|
||||
Id firstParamId = paramTypes.size() == 0 ? 0 : getUniqueIds((int)paramTypes.size());
|
||||
Function* function = new Function(getUniqueId(), returnType, typeId, firstParamId, module);
|
||||
Id funcId = getUniqueId();
|
||||
Function* function = new Function(funcId, returnType, typeId, firstParamId, module);
|
||||
|
||||
// Set up the precisions
|
||||
setPrecision(function->getId(), precision);
|
||||
@@ -1475,11 +2023,39 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const
|
||||
}
|
||||
}
|
||||
|
||||
// Make the debug function instruction
|
||||
if (emitNonSemanticShaderDebugInfo) {
|
||||
Id nameId = getStringId(unmangleFunctionName(name));
|
||||
Id debugFuncId = makeDebugFunction(function, nameId, typeId);
|
||||
debugId[funcId] = debugFuncId;
|
||||
currentDebugScopeId.push(debugFuncId);
|
||||
lastDebugScopeId = NoResult;
|
||||
}
|
||||
|
||||
// CFG
|
||||
if (entry) {
|
||||
*entry = new Block(getUniqueId(), *function);
|
||||
function->addBlock(*entry);
|
||||
setBuildPoint(*entry);
|
||||
assert(entry != nullptr);
|
||||
*entry = new Block(getUniqueId(), *function);
|
||||
function->addBlock(*entry);
|
||||
setBuildPoint(*entry);
|
||||
|
||||
// DebugScope and DebugLine for parameter DebugDeclares
|
||||
if (emitNonSemanticShaderDebugInfo && (int)paramTypes.size() > 0) {
|
||||
addDebugScopeAndLine(currentFileId, currentLine, 0);
|
||||
}
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo) {
|
||||
assert(paramTypes.size() == paramNames.size());
|
||||
for(size_t p = 0; p < paramTypes.size(); ++p)
|
||||
{
|
||||
auto const& paramType = paramTypes[p];
|
||||
assert(isPointerType(paramType) || isArrayType(paramType));
|
||||
assert(debugId[getContainedTypeId(paramType)] != 0);
|
||||
auto const& paramName = paramNames[p];
|
||||
auto const debugLocalVariableId = createDebugLocalVariable(debugId[getContainedTypeId(paramType)], paramName, p+1);
|
||||
debugId[firstParamId + p] = debugLocalVariableId;
|
||||
|
||||
makeDebugDeclare(debugLocalVariableId, firstParamId + p);
|
||||
}
|
||||
}
|
||||
|
||||
if (name)
|
||||
@@ -1487,9 +2063,62 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const
|
||||
|
||||
functions.push_back(std::unique_ptr<Function>(function));
|
||||
|
||||
// Clear debug scope stack
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
currentDebugScopeId.pop();
|
||||
|
||||
return function;
|
||||
}
|
||||
|
||||
Id Builder::makeDebugFunction(Function* function, Id nameId, Id funcTypeId) {
|
||||
assert(function != nullptr);
|
||||
assert(nameId != 0);
|
||||
assert(funcTypeId != 0);
|
||||
assert(debugId[funcTypeId] != 0);
|
||||
|
||||
Id funcId = getUniqueId();
|
||||
auto type = new Instruction(funcId, makeVoidType(), OpExtInst);
|
||||
type->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugFunction);
|
||||
type->addIdOperand(nameId);
|
||||
type->addIdOperand(debugId[funcTypeId]);
|
||||
type->addIdOperand(makeDebugSource(currentFileId)); // Will be fixed later when true filename available
|
||||
type->addIdOperand(makeUintConstant(currentLine)); // Will be fixed later when true line available
|
||||
type->addIdOperand(makeUintConstant(0)); // column
|
||||
type->addIdOperand(makeDebugCompilationUnit()); // scope
|
||||
type->addIdOperand(nameId); // linkage name
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic));
|
||||
type->addIdOperand(makeUintConstant(currentLine)); // TODO(greg-lunarg): correct scope line
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
return funcId;
|
||||
}
|
||||
|
||||
Id Builder::makeDebugLexicalBlock(uint32_t line) {
|
||||
Id lexId = getUniqueId();
|
||||
auto lex = new Instruction(lexId, makeVoidType(), OpExtInst);
|
||||
lex->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
lex->addImmediateOperand(NonSemanticShaderDebugInfo100DebugLexicalBlock);
|
||||
lex->addIdOperand(makeDebugSource(currentFileId));
|
||||
lex->addIdOperand(makeUintConstant(line));
|
||||
lex->addIdOperand(makeUintConstant(0)); // column
|
||||
lex->addIdOperand(currentDebugScopeId.top()); // scope
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(lex));
|
||||
module.mapInstruction(lex);
|
||||
return lexId;
|
||||
}
|
||||
|
||||
std::string Builder::unmangleFunctionName(std::string const& name) const
|
||||
{
|
||||
assert(name.length() > 0);
|
||||
|
||||
if(name.rfind('(') != std::string::npos) {
|
||||
return name.substr(0, name.rfind('('));
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
void Builder::makeReturn(bool implicit, Id retVal)
|
||||
{
|
||||
@@ -1504,6 +2133,48 @@ void Builder::makeReturn(bool implicit, Id retVal)
|
||||
createAndSetNoPredecessorBlock("post-return");
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
void Builder::enterScope(uint32_t line)
|
||||
{
|
||||
// Generate new lexical scope debug instruction
|
||||
Id lexId = makeDebugLexicalBlock(line);
|
||||
currentDebugScopeId.push(lexId);
|
||||
lastDebugScopeId = NoResult;
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
void Builder::leaveScope()
|
||||
{
|
||||
// Pop current scope from stack and clear current scope
|
||||
currentDebugScopeId.pop();
|
||||
lastDebugScopeId = NoResult;
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
void Builder::enterFunction(Function const* function)
|
||||
{
|
||||
// Save and disable debugInfo for HLSL entry point function. It is a wrapper
|
||||
// function with no user code in it.
|
||||
restoreNonSemanticShaderDebugInfo = emitNonSemanticShaderDebugInfo;
|
||||
if (sourceLang == spv::SourceLanguageHLSL && function == entryPointFunction) {
|
||||
emitNonSemanticShaderDebugInfo = false;
|
||||
}
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo) {
|
||||
// Initialize scope state
|
||||
Id funcId = function->getFuncId();
|
||||
currentDebugScopeId.push(debugId[funcId]);
|
||||
// Create DebugFunctionDefinition
|
||||
spv::Id resultId = getUniqueId();
|
||||
Instruction* defInst = new Instruction(resultId, makeVoidType(), OpExtInst);
|
||||
defInst->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
defInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugFunctionDefinition);
|
||||
defInst->addIdOperand(debugId[funcId]);
|
||||
defInst->addIdOperand(funcId);
|
||||
buildPoint->addInstruction(std::unique_ptr<Instruction>(defInst));
|
||||
}
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
void Builder::leaveFunction()
|
||||
{
|
||||
@@ -1519,6 +2190,12 @@ void Builder::leaveFunction()
|
||||
makeReturn(true, createUndefined(function.getReturnType()));
|
||||
}
|
||||
}
|
||||
|
||||
// Clear function scope from debug scope stack
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
currentDebugScopeId.pop();
|
||||
|
||||
emitNonSemanticShaderDebugInfo = restoreNonSemanticShaderDebugInfo;
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
@@ -1529,7 +2206,18 @@ void Builder::makeStatementTerminator(spv::Op opcode, const char *name)
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
Id Builder::createVariable(Decoration precision, StorageClass storageClass, Id type, const char* name, Id initializer)
|
||||
void Builder::makeStatementTerminator(spv::Op opcode, const std::vector<Id>& operands, const char* name)
|
||||
{
|
||||
// It's assumed that the terminator instruction is always of void return type
|
||||
// However in future if there is a need for non void return type, new helper
|
||||
// methods can be created.
|
||||
createNoResultOp(opcode, operands);
|
||||
createAndSetNoPredecessorBlock(name);
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
Id Builder::createVariable(Decoration precision, StorageClass storageClass, Id type, const char* name, Id initializer,
|
||||
bool const compilerGenerated)
|
||||
{
|
||||
Id pointerType = makePointer(storageClass, type);
|
||||
Instruction* inst = new Instruction(getUniqueId(), pointerType, OpVariable);
|
||||
@@ -1541,11 +2229,26 @@ Id Builder::createVariable(Decoration precision, StorageClass storageClass, Id t
|
||||
case StorageClassFunction:
|
||||
// Validation rules require the declaration in the entry block
|
||||
buildPoint->getParent().addLocalVariable(std::unique_ptr<Instruction>(inst));
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo && !compilerGenerated)
|
||||
{
|
||||
auto const debugLocalVariableId = createDebugLocalVariable(debugId[type], name);
|
||||
debugId[inst->getResultId()] = debugLocalVariableId;
|
||||
|
||||
makeDebugDeclare(debugLocalVariableId, inst->getResultId());
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(inst));
|
||||
module.mapInstruction(inst);
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo && !isRayTracingOpCode(getOpCode(type)))
|
||||
{
|
||||
auto const debugResultId = createDebugGlobalVariable(debugId[type], name, inst->getResultId());
|
||||
debugId[inst->getResultId()] = debugResultId;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1575,7 +2278,7 @@ spv::MemoryAccessMask Builder::sanitizeMemoryAccessForStorageClass(spv::MemoryAc
|
||||
case spv::StorageClassPhysicalStorageBufferEXT:
|
||||
break;
|
||||
default:
|
||||
memoryAccess = spv::MemoryAccessMask(memoryAccess &
|
||||
memoryAccess = spv::MemoryAccessMask(memoryAccess &
|
||||
~(spv::MemoryAccessMakePointerAvailableKHRMask |
|
||||
spv::MemoryAccessMakePointerVisibleKHRMask |
|
||||
spv::MemoryAccessNonPrivatePointerKHRMask));
|
||||
@@ -2051,7 +2754,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
|
||||
texArgs[numArgs++] = parameters.granularity;
|
||||
if (parameters.coarse != NoResult)
|
||||
texArgs[numArgs++] = parameters.coarse;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Set up the optional arguments
|
||||
@@ -3271,10 +3974,10 @@ void Builder::dumpSourceInstructions(const spv::Id fileId, const std::string& te
|
||||
const int opSourceWordCount = 4;
|
||||
const int nonNullBytesPerInstruction = 4 * (maxWordCount - opSourceWordCount) - 1;
|
||||
|
||||
if (source != SourceLanguageUnknown) {
|
||||
if (sourceLang != SourceLanguageUnknown) {
|
||||
// OpSource Language Version File Source
|
||||
Instruction sourceInst(NoResult, NoType, OpSource);
|
||||
sourceInst.addImmediateOperand(source);
|
||||
sourceInst.addImmediateOperand(sourceLang);
|
||||
sourceInst.addImmediateOperand(sourceVersion);
|
||||
// File operand
|
||||
if (fileId != NoResult) {
|
||||
@@ -3307,6 +4010,7 @@ void Builder::dumpSourceInstructions(const spv::Id fileId, const std::string& te
|
||||
// Dump an OpSource[Continued] sequence for the source and every include file
|
||||
void Builder::dumpSourceInstructions(std::vector<unsigned int>& out) const
|
||||
{
|
||||
if (emitNonSemanticShaderDebugInfo) return;
|
||||
dumpSourceInstructions(sourceFileStringId, sourceText, out);
|
||||
for (auto iItr = includeFiles.begin(); iItr != includeFiles.end(); ++iItr)
|
||||
dumpSourceInstructions(iItr->first, *iItr->second, out);
|
||||
|
||||
106
3rdparty/glslang/SPIRV/SpvBuilder.h
vendored
106
3rdparty/glslang/SPIRV/SpvBuilder.h
vendored
@@ -50,6 +50,10 @@
|
||||
#include "Logger.h"
|
||||
#include "spirv.hpp"
|
||||
#include "spvIR.h"
|
||||
namespace spv {
|
||||
#include "GLSL.ext.KHR.h"
|
||||
#include "NonSemanticShaderDebugInfo100.h"
|
||||
}
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
@@ -82,7 +86,7 @@ public:
|
||||
|
||||
void setSource(spv::SourceLanguage lang, int version)
|
||||
{
|
||||
source = lang;
|
||||
sourceLang = lang;
|
||||
sourceVersion = version;
|
||||
}
|
||||
spv::Id getStringId(const std::string& str)
|
||||
@@ -106,11 +110,25 @@ public:
|
||||
void setSourceFile(const std::string& file)
|
||||
{
|
||||
sourceFileStringId = getStringId(file);
|
||||
currentFileId = sourceFileStringId;
|
||||
}
|
||||
void setSourceText(const std::string& text) { sourceText = text; }
|
||||
void addSourceExtension(const char* ext) { sourceExtensions.push_back(ext); }
|
||||
void addModuleProcessed(const std::string& p) { moduleProcesses.push_back(p.c_str()); }
|
||||
void setEmitOpLines() { emitOpLines = true; }
|
||||
void setEmitNonSemanticShaderDebugInfo(bool const emit)
|
||||
{
|
||||
emitNonSemanticShaderDebugInfo = emit;
|
||||
|
||||
if(emit)
|
||||
{
|
||||
importNonSemanticShaderDebugInfoInstructions();
|
||||
}
|
||||
}
|
||||
void setEmitNonSemanticShaderDebugSource(bool const src)
|
||||
{
|
||||
emitNonSemanticShaderDebugSource = src;
|
||||
}
|
||||
void addExtension(const char* ext) { extensions.insert(ext); }
|
||||
void removeExtension(const char* ext)
|
||||
{
|
||||
@@ -163,10 +181,11 @@ public:
|
||||
void setLine(int line, const char* filename);
|
||||
// Low-level OpLine. See setLine() for a layered helper.
|
||||
void addLine(Id fileName, int line, int column);
|
||||
void addDebugScopeAndLine(Id fileName, int line, int column);
|
||||
|
||||
// For creating new types (will return old type if the requested one was already made).
|
||||
Id makeVoidType();
|
||||
Id makeBoolType();
|
||||
Id makeBoolType(bool const compilerGenerated = true);
|
||||
Id makePointer(StorageClass, Id pointee);
|
||||
Id makeForwardPointer(StorageClass);
|
||||
Id makePointerFromForwardPointer(StorageClass, Id forwardPointerType, Id pointee);
|
||||
@@ -174,7 +193,7 @@ public:
|
||||
Id makeIntType(int width) { return makeIntegerType(width, true); }
|
||||
Id makeUintType(int width) { return makeIntegerType(width, false); }
|
||||
Id makeFloatType(int width);
|
||||
Id makeStructType(const std::vector<Id>& members, const char*);
|
||||
Id makeStructType(const std::vector<Id>& members, const char* name, bool const compilerGenerated = true);
|
||||
Id makeStructResultType(Id type0, Id type1);
|
||||
Id makeVectorType(Id component, int size);
|
||||
Id makeMatrixType(Id component, int cols, int rows);
|
||||
@@ -187,6 +206,36 @@ public:
|
||||
Id makeCooperativeMatrixType(Id component, Id scope, Id rows, Id cols);
|
||||
Id makeGenericType(spv::Op opcode, std::vector<spv::IdImmediate>& operands);
|
||||
|
||||
// SPIR-V NonSemantic Shader DebugInfo Instructions
|
||||
struct DebugTypeLoc {
|
||||
std::string name {};
|
||||
int line {0};
|
||||
int column {0};
|
||||
};
|
||||
std::unordered_map<Id, DebugTypeLoc> debugTypeLocs;
|
||||
Id makeDebugInfoNone();
|
||||
Id makeBoolDebugType(int const size);
|
||||
Id makeIntegerDebugType(int const width, bool const hasSign);
|
||||
Id makeFloatDebugType(int const width);
|
||||
Id makeSequentialDebugType(Id const baseType, Id const componentCount, NonSemanticShaderDebugInfo100Instructions const sequenceType);
|
||||
Id makeArrayDebugType(Id const baseType, Id const componentCount);
|
||||
Id makeVectorDebugType(Id const baseType, int const componentCount);
|
||||
Id makeMatrixDebugType(Id const vectorType, int const vectorCount, bool columnMajor = true);
|
||||
Id makeMemberDebugType(Id const memberType, DebugTypeLoc const& debugTypeLoc);
|
||||
Id makeCompositeDebugType(std::vector<Id> const& memberTypes, char const*const name,
|
||||
NonSemanticShaderDebugInfo100DebugCompositeType const tag, bool const isOpaqueType = false);
|
||||
Id makeDebugSource(const Id fileName);
|
||||
Id makeDebugCompilationUnit();
|
||||
Id createDebugGlobalVariable(Id const type, char const*const name, Id const variable);
|
||||
Id createDebugLocalVariable(Id type, char const*const name, size_t const argNumber = 0);
|
||||
Id makeDebugExpression();
|
||||
Id makeDebugDeclare(Id const debugLocalVariable, Id const localVariable);
|
||||
Id makeDebugValue(Id const debugLocalVariable, Id const value);
|
||||
Id makeDebugFunctionType(Id returnType, const std::vector<Id>& paramTypes);
|
||||
Id makeDebugFunction(Function* function, Id nameId, Id funcTypeId);
|
||||
Id makeDebugLexicalBlock(uint32_t line);
|
||||
std::string unmangleFunctionName(std::string const& name) const;
|
||||
|
||||
// accelerationStructureNV type
|
||||
Id makeAccelerationStructureType();
|
||||
// rayQueryEXT type
|
||||
@@ -261,6 +310,8 @@ public:
|
||||
// See if a resultId is valid for use as an initializer.
|
||||
bool isValidInitializer(Id resultId) const { return isConstant(resultId) || isGlobalVariable(resultId); }
|
||||
|
||||
bool isRayTracingOpCode(Op opcode) const;
|
||||
|
||||
int getScalarTypeWidth(Id typeId) const
|
||||
{
|
||||
Id scalarTypeId = getScalarTypeId(typeId);
|
||||
@@ -322,6 +373,8 @@ public:
|
||||
Id makeFloat16Constant(float f16, bool specConstant = false);
|
||||
Id makeFpConstant(Id type, double d, bool specConstant = false);
|
||||
|
||||
Id importNonSemanticShaderDebugInfoInstructions();
|
||||
|
||||
// Turn the array of constants into a proper spv constant of the requested type.
|
||||
Id makeCompositeConstant(Id type, const std::vector<Id>& comps, bool specConst = false);
|
||||
|
||||
@@ -344,7 +397,12 @@ public:
|
||||
void addMemberDecoration(Id, unsigned int member, Decoration, const std::vector<const char*>& strings);
|
||||
|
||||
// At the end of what block do the next create*() instructions go?
|
||||
void setBuildPoint(Block* bp) { buildPoint = bp; }
|
||||
// Also reset current last DebugScope and current source line to unknown
|
||||
void setBuildPoint(Block* bp) {
|
||||
buildPoint = bp;
|
||||
lastDebugScopeId = NoResult;
|
||||
currentLine = 0;
|
||||
}
|
||||
Block* getBuildPoint() const { return buildPoint; }
|
||||
|
||||
// Make the entry-point function. The returned pointer is only valid
|
||||
@@ -355,12 +413,22 @@ public:
|
||||
// Return the function, pass back the entry.
|
||||
// The returned pointer is only valid for the lifetime of this builder.
|
||||
Function* makeFunctionEntry(Decoration precision, Id returnType, const char* name,
|
||||
const std::vector<Id>& paramTypes, const std::vector<std::vector<Decoration>>& precisions, Block **entry = 0);
|
||||
const std::vector<Id>& paramTypes, const std::vector<char const*>& paramNames,
|
||||
const std::vector<std::vector<Decoration>>& precisions, Block **entry = 0);
|
||||
|
||||
// Create a return. An 'implicit' return is one not appearing in the source
|
||||
// code. In the case of an implicit return, no post-return block is inserted.
|
||||
void makeReturn(bool implicit, Id retVal = 0);
|
||||
|
||||
// Initialize state and generate instructions for new lexical scope
|
||||
void enterScope(uint32_t line);
|
||||
|
||||
// Set state and generate instructions to exit current lexical scope
|
||||
void leaveScope();
|
||||
|
||||
// Prepare builder for generation of instructions for a function.
|
||||
void enterFunction(Function const* function);
|
||||
|
||||
// Generate all the code needed to finish up a function.
|
||||
void leaveFunction();
|
||||
|
||||
@@ -368,9 +436,13 @@ public:
|
||||
// discard, terminate-invocation, terminateRayEXT, or ignoreIntersectionEXT
|
||||
void makeStatementTerminator(spv::Op opcode, const char *name);
|
||||
|
||||
// Create block terminator instruction for statements that have input operands
|
||||
// such as OpEmitMeshTasksEXT
|
||||
void makeStatementTerminator(spv::Op opcode, const std::vector<Id>& operands, const char* name);
|
||||
|
||||
// Create a global or function local or IO variable.
|
||||
Id createVariable(Decoration precision, StorageClass, Id type, const char* name = nullptr,
|
||||
Id initializer = NoResult);
|
||||
Id createVariable(Decoration precision, StorageClass storageClass, Id type, const char* name = nullptr,
|
||||
Id initializer = NoResult, bool const compilerGenerated = true);
|
||||
|
||||
// Create an intermediate with an undefined value.
|
||||
Id createUndefined(Id type);
|
||||
@@ -805,13 +877,23 @@ public:
|
||||
const;
|
||||
|
||||
unsigned int spvVersion; // the version of SPIR-V to emit in the header
|
||||
SourceLanguage source;
|
||||
SourceLanguage sourceLang;
|
||||
int sourceVersion;
|
||||
spv::Id sourceFileStringId;
|
||||
spv::Id nonSemanticShaderCompilationUnitId {0};
|
||||
spv::Id nonSemanticShaderDebugInfo {0};
|
||||
spv::Id debugInfoNone {0};
|
||||
spv::Id debugExpression {0}; // Debug expression with zero operations.
|
||||
std::string sourceText;
|
||||
int currentLine;
|
||||
const char* currentFile;
|
||||
spv::Id currentFileId;
|
||||
std::stack<spv::Id> currentDebugScopeId;
|
||||
spv::Id lastDebugScopeId;
|
||||
bool emitOpLines;
|
||||
bool emitNonSemanticShaderDebugInfo;
|
||||
bool restoreNonSemanticShaderDebugInfo;
|
||||
bool emitNonSemanticShaderDebugSource;
|
||||
std::set<std::string> extensions;
|
||||
std::vector<const char*> sourceExtensions;
|
||||
std::vector<const char*> moduleProcesses;
|
||||
@@ -845,6 +927,8 @@ public:
|
||||
std::unordered_map<unsigned int, std::vector<Instruction*>> groupedStructConstants;
|
||||
// map type opcodes to type instructions
|
||||
std::unordered_map<unsigned int, std::vector<Instruction*>> groupedTypes;
|
||||
// map type opcodes to debug type instructions
|
||||
std::unordered_map<unsigned int, std::vector<Instruction*>> groupedDebugTypes;
|
||||
// list of OpConstantNull instructions
|
||||
std::vector<Instruction*> nullConstants;
|
||||
|
||||
@@ -860,6 +944,12 @@ public:
|
||||
// map from include file name ids to their contents
|
||||
std::map<spv::Id, const std::string*> includeFiles;
|
||||
|
||||
// map from core id to debug id
|
||||
std::map <spv::Id, spv::Id> debugId;
|
||||
|
||||
// map from file name string id to DebugSource id
|
||||
std::unordered_map<spv::Id, spv::Id> debugSourceId;
|
||||
|
||||
// The stream for outputting warnings and errors.
|
||||
SpvBuildLogger* logger;
|
||||
}; // end Builder class
|
||||
|
||||
16
3rdparty/glslang/SPIRV/SpvTools.h
vendored
16
3rdparty/glslang/SPIRV/SpvTools.h
vendored
@@ -53,14 +53,14 @@
|
||||
namespace glslang {
|
||||
|
||||
struct SpvOptions {
|
||||
SpvOptions() : generateDebugInfo(false), stripDebugInfo(false), disableOptimizer(true),
|
||||
optimizeSize(false), disassemble(false), validate(false) { }
|
||||
bool generateDebugInfo;
|
||||
bool stripDebugInfo;
|
||||
bool disableOptimizer;
|
||||
bool optimizeSize;
|
||||
bool disassemble;
|
||||
bool validate;
|
||||
bool generateDebugInfo {false};
|
||||
bool stripDebugInfo {false};
|
||||
bool disableOptimizer {true};
|
||||
bool optimizeSize {false};
|
||||
bool disassemble {false};
|
||||
bool validate {false};
|
||||
bool emitNonSemanticShaderDebugInfo {false};
|
||||
bool emitNonSemanticShaderDebugSource{ false };
|
||||
};
|
||||
|
||||
#if ENABLE_OPT
|
||||
|
||||
22
3rdparty/glslang/SPIRV/doc.cpp
vendored
22
3rdparty/glslang/SPIRV/doc.cpp
vendored
@@ -97,6 +97,8 @@ const char* ExecutionModelString(int model)
|
||||
case 6: return "Kernel";
|
||||
case ExecutionModelTaskNV: return "TaskNV";
|
||||
case ExecutionModelMeshNV: return "MeshNV";
|
||||
case ExecutionModelTaskEXT: return "TaskEXT";
|
||||
case ExecutionModelMeshEXT: return "MeshEXT";
|
||||
|
||||
default: return "Bad";
|
||||
|
||||
@@ -242,7 +244,7 @@ const char* StorageClassString(int StorageClass)
|
||||
case StorageClassIncomingCallableDataKHR: return "IncomingCallableDataKHR";
|
||||
|
||||
case StorageClassPhysicalStorageBufferEXT: return "PhysicalStorageBufferEXT";
|
||||
|
||||
case StorageClassTaskPayloadWorkgroupEXT: return "TaskPayloadWorkgroupEXT";
|
||||
default: return "Bad";
|
||||
}
|
||||
}
|
||||
@@ -433,6 +435,10 @@ const char* BuiltInString(int builtIn)
|
||||
case BuiltInWarpIDNV: return "WarpIDNV";
|
||||
case BuiltInSMIDNV: return "SMIDNV";
|
||||
case BuiltInCurrentRayTimeNV: return "CurrentRayTimeNV";
|
||||
case BuiltInPrimitivePointIndicesEXT: return "PrimitivePointIndicesEXT";
|
||||
case BuiltInPrimitiveLineIndicesEXT: return "PrimitiveLineIndicesEXT";
|
||||
case BuiltInPrimitiveTriangleIndicesEXT: return "PrimitiveTriangleIndicesEXT";
|
||||
case BuiltInCullPrimitiveEXT: return "CullPrimitiveEXT";
|
||||
|
||||
default: return "Bad";
|
||||
}
|
||||
@@ -940,6 +946,7 @@ const char* CapabilityString(int info)
|
||||
case CapabilityFragmentBarycentricKHR: return "FragmentBarycentricKHR";
|
||||
case CapabilityMeshShadingNV: return "MeshShadingNV";
|
||||
case CapabilityImageFootprintNV: return "ImageFootprintNV";
|
||||
case CapabilityMeshShadingEXT: return "MeshShadingEXT";
|
||||
// case CapabilityShadingRateNV: return "ShadingRateNV"; // superseded by FragmentDensityEXT
|
||||
case CapabilitySampleMaskOverrideCoverageNV: return "SampleMaskOverrideCoverageNV";
|
||||
case CapabilityFragmentDensityEXT: return "FragmentDensityEXT";
|
||||
@@ -1407,6 +1414,8 @@ const char* OpcodeString(int op)
|
||||
case OpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV";
|
||||
case OpImageSampleFootprintNV: return "OpImageSampleFootprintNV";
|
||||
case OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV";
|
||||
case OpEmitMeshTasksEXT: return "OpEmitMeshTasksEXT";
|
||||
case OpSetMeshOutputsEXT: return "OpSetMeshOutputsEXT";
|
||||
|
||||
case OpTypeRayQueryKHR: return "OpTypeRayQueryKHR";
|
||||
case OpRayQueryInitializeKHR: return "OpRayQueryInitializeKHR";
|
||||
@@ -2981,6 +2990,17 @@ void Parameterize()
|
||||
InstructionDesc[OpWritePackedPrimitiveIndices4x8NV].operands.push(OperandId, "'Index Offset'");
|
||||
InstructionDesc[OpWritePackedPrimitiveIndices4x8NV].operands.push(OperandId, "'Packed Indices'");
|
||||
|
||||
InstructionDesc[OpEmitMeshTasksEXT].operands.push(OperandId, "'groupCountX'");
|
||||
InstructionDesc[OpEmitMeshTasksEXT].operands.push(OperandId, "'groupCountY'");
|
||||
InstructionDesc[OpEmitMeshTasksEXT].operands.push(OperandId, "'groupCountZ'");
|
||||
InstructionDesc[OpEmitMeshTasksEXT].operands.push(OperandId, "'Payload'");
|
||||
InstructionDesc[OpEmitMeshTasksEXT].setResultAndType(false, false);
|
||||
|
||||
InstructionDesc[OpSetMeshOutputsEXT].operands.push(OperandId, "'vertexCount'");
|
||||
InstructionDesc[OpSetMeshOutputsEXT].operands.push(OperandId, "'primitiveCount'");
|
||||
InstructionDesc[OpSetMeshOutputsEXT].setResultAndType(false, false);
|
||||
|
||||
|
||||
InstructionDesc[OpTypeCooperativeMatrixNV].operands.push(OperandId, "'Component Type'");
|
||||
InstructionDesc[OpTypeCooperativeMatrixNV].operands.push(OperandId, "'Scope'");
|
||||
InstructionDesc[OpTypeCooperativeMatrixNV].operands.push(OperandId, "'Rows'");
|
||||
|
||||
33
3rdparty/glslang/SPIRV/spirv.hpp
vendored
33
3rdparty/glslang/SPIRV/spirv.hpp
vendored
@@ -1,19 +1,19 @@
|
||||
// Copyright (c) 2014-2020 The Khronos Group Inc.
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and/or associated documentation files (the "Materials"),
|
||||
// to deal in the Materials without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Materials, and to permit persons to whom the
|
||||
// Materials are furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Materials.
|
||||
//
|
||||
//
|
||||
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
|
||||
// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
|
||||
// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
|
||||
//
|
||||
// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
|
||||
//
|
||||
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
// Enumeration tokens for SPIR-V, in various styles:
|
||||
// C, C++, C++11, JSON, Lua, Python, C#, D
|
||||
//
|
||||
//
|
||||
// - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL
|
||||
// - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL
|
||||
// - C++11 will use enum classes in the spv namespace, e.g.: spv::SourceLanguage::GLSL
|
||||
@@ -36,7 +36,7 @@
|
||||
// - C# will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
// e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
// - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL
|
||||
//
|
||||
//
|
||||
// Some tokens act like mask values, which can be OR'd together,
|
||||
// while others are mutually exclusive. The mask-like ones have
|
||||
// "Mask" in their name, and a parallel enum that has the shift
|
||||
@@ -91,6 +91,8 @@ enum ExecutionModel {
|
||||
ExecutionModelMissNV = 5317,
|
||||
ExecutionModelCallableKHR = 5318,
|
||||
ExecutionModelCallableNV = 5318,
|
||||
ExecutionModelTaskEXT = 5364,
|
||||
ExecutionModelMeshEXT = 5365,
|
||||
ExecutionModelMax = 0x7fffffff,
|
||||
};
|
||||
|
||||
@@ -166,10 +168,13 @@ enum ExecutionMode {
|
||||
ExecutionModeStencilRefUnchangedBackAMD = 5082,
|
||||
ExecutionModeStencilRefGreaterBackAMD = 5083,
|
||||
ExecutionModeStencilRefLessBackAMD = 5084,
|
||||
ExecutionModeOutputLinesEXT = 5269,
|
||||
ExecutionModeOutputLinesNV = 5269,
|
||||
ExecutionModeOutputPrimitivesEXT = 5270,
|
||||
ExecutionModeOutputPrimitivesNV = 5270,
|
||||
ExecutionModeDerivativeGroupQuadsNV = 5289,
|
||||
ExecutionModeDerivativeGroupLinearNV = 5290,
|
||||
ExecutionModeOutputTrianglesEXT = 5298,
|
||||
ExecutionModeOutputTrianglesNV = 5298,
|
||||
ExecutionModePixelInterlockOrderedEXT = 5366,
|
||||
ExecutionModePixelInterlockUnorderedEXT = 5367,
|
||||
@@ -218,6 +223,7 @@ enum StorageClass {
|
||||
StorageClassShaderRecordBufferNV = 5343,
|
||||
StorageClassPhysicalStorageBuffer = 5349,
|
||||
StorageClassPhysicalStorageBufferEXT = 5349,
|
||||
StorageClassTaskPayloadWorkgroupEXT = 5402,
|
||||
StorageClassCodeSectionINTEL = 5605,
|
||||
StorageClassDeviceOnlyINTEL = 5936,
|
||||
StorageClassHostOnlyINTEL = 5937,
|
||||
@@ -500,6 +506,7 @@ enum Decoration {
|
||||
DecorationPassthroughNV = 5250,
|
||||
DecorationViewportRelativeNV = 5252,
|
||||
DecorationSecondaryViewportRelativeNV = 5256,
|
||||
DecorationPerPrimitiveEXT = 5271,
|
||||
DecorationPerPrimitiveNV = 5271,
|
||||
DecorationPerViewNV = 5272,
|
||||
DecorationPerTaskNV = 5273,
|
||||
@@ -647,6 +654,10 @@ enum BuiltIn {
|
||||
BuiltInFragmentSizeNV = 5292,
|
||||
BuiltInFragInvocationCountEXT = 5293,
|
||||
BuiltInInvocationsPerPixelNV = 5293,
|
||||
BuiltInPrimitivePointIndicesEXT = 5294,
|
||||
BuiltInPrimitiveLineIndicesEXT = 5295,
|
||||
BuiltInPrimitiveTriangleIndicesEXT = 5296,
|
||||
BuiltInCullPrimitiveEXT = 5299,
|
||||
BuiltInLaunchIdKHR = 5319,
|
||||
BuiltInLaunchIdNV = 5319,
|
||||
BuiltInLaunchSizeKHR = 5320,
|
||||
@@ -983,7 +994,8 @@ enum Capability {
|
||||
CapabilityFragmentFullyCoveredEXT = 5265,
|
||||
CapabilityMeshShadingNV = 5266,
|
||||
CapabilityImageFootprintNV = 5282,
|
||||
CapabilityFragmentBarycentricKHR = 5284,
|
||||
CapabilityMeshShadingEXT = 5283,
|
||||
CapabilityFragmentBarycentricKHR = 5284,
|
||||
CapabilityFragmentBarycentricNV = 5284,
|
||||
CapabilityComputeDerivativeGroupQuadsNV = 5288,
|
||||
CapabilityFragmentDensityEXT = 5291,
|
||||
@@ -1577,6 +1589,8 @@ enum Op {
|
||||
OpFragmentFetchAMD = 5012,
|
||||
OpReadClockKHR = 5056,
|
||||
OpImageSampleFootprintNV = 5283,
|
||||
OpEmitMeshTasksEXT = 5294,
|
||||
OpSetMeshOutputsEXT = 5295,
|
||||
OpGroupNonUniformPartitionNV = 5296,
|
||||
OpWritePackedPrimitiveIndices4x8NV = 5299,
|
||||
OpReportIntersectionKHR = 5334,
|
||||
@@ -2234,6 +2248,8 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
|
||||
case OpReadClockKHR: *hasResult = true; *hasResultType = true; break;
|
||||
case OpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break;
|
||||
case OpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break;
|
||||
case OpEmitMeshTasksEXT: *hasResult = false; *hasResultType = false; break;
|
||||
case OpSetMeshOutputsEXT: *hasResult = false; *hasResultType = false; break;
|
||||
case OpWritePackedPrimitiveIndices4x8NV: *hasResult = false; *hasResultType = false; break;
|
||||
case OpReportIntersectionNV: *hasResult = true; *hasResultType = true; break;
|
||||
case OpIgnoreIntersectionNV: *hasResult = false; *hasResultType = false; break;
|
||||
@@ -2515,4 +2531,3 @@ inline FragmentShadingRateMask operator|(FragmentShadingRateMask a, FragmentShad
|
||||
} // end namespace spv
|
||||
|
||||
#endif // #ifndef spirv_HPP
|
||||
|
||||
|
||||
1
3rdparty/glslang/SPIRV/spvIR.h
vendored
1
3rdparty/glslang/SPIRV/spvIR.h
vendored
@@ -349,6 +349,7 @@ public:
|
||||
const std::vector<Block*>& getBlocks() const { return blocks; }
|
||||
void addLocalVariable(std::unique_ptr<Instruction> inst);
|
||||
Id getReturnType() const { return functionInstruction.getTypeId(); }
|
||||
Id getFuncId() const { return functionInstruction.getResultId(); }
|
||||
void setReturnPrecision(Decoration precision)
|
||||
{
|
||||
if (precision == DecorationRelaxedPrecision)
|
||||
|
||||
36
3rdparty/glslang/StandAlone/ResourceLimits.cpp
vendored
36
3rdparty/glslang/StandAlone/ResourceLimits.cpp
vendored
@@ -134,6 +134,15 @@ const TBuiltInResource DefaultTBuiltInResource = {
|
||||
/* .maxTaskWorkGroupSizeY_NV = */ 1,
|
||||
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
|
||||
/* .maxMeshViewCountNV = */ 4,
|
||||
/* .maxMeshOutputVerticesEXT = */ 256,
|
||||
/* .maxMeshOutputPrimitivesEXT = */ 256,
|
||||
/* .maxMeshWorkGroupSizeX_EXT = */ 128,
|
||||
/* .maxMeshWorkGroupSizeY_EXT = */ 128,
|
||||
/* .maxMeshWorkGroupSizeZ_EXT = */ 128,
|
||||
/* .maxTaskWorkGroupSizeX_EXT = */ 128,
|
||||
/* .maxTaskWorkGroupSizeY_EXT = */ 128,
|
||||
/* .maxTaskWorkGroupSizeZ_EXT = */ 128,
|
||||
/* .maxMeshViewCountEXT = */ 4,
|
||||
/* .maxDualSourceDrawBuffersEXT = */ 1,
|
||||
|
||||
/* .limits = */ {
|
||||
@@ -244,6 +253,15 @@ std::string GetDefaultTBuiltInResourceString()
|
||||
<< "MaxTaskWorkGroupSizeY_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeY_NV << "\n"
|
||||
<< "MaxTaskWorkGroupSizeZ_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeZ_NV << "\n"
|
||||
<< "MaxMeshViewCountNV " << DefaultTBuiltInResource.maxMeshViewCountNV << "\n"
|
||||
<< "MaxMeshOutputVerticesEXT " << DefaultTBuiltInResource.maxMeshOutputVerticesEXT << "\n"
|
||||
<< "MaxMeshOutputPrimitivesEXT " << DefaultTBuiltInResource.maxMeshOutputPrimitivesEXT << "\n"
|
||||
<< "MaxMeshWorkGroupSizeX_EXT " << DefaultTBuiltInResource.maxMeshWorkGroupSizeX_EXT << "\n"
|
||||
<< "MaxMeshWorkGroupSizeY_EXT " << DefaultTBuiltInResource.maxMeshWorkGroupSizeY_EXT << "\n"
|
||||
<< "MaxMeshWorkGroupSizeZ_EXT " << DefaultTBuiltInResource.maxMeshWorkGroupSizeZ_EXT << "\n"
|
||||
<< "MaxTaskWorkGroupSizeX_EXT " << DefaultTBuiltInResource.maxTaskWorkGroupSizeX_EXT << "\n"
|
||||
<< "MaxTaskWorkGroupSizeY_EXT " << DefaultTBuiltInResource.maxTaskWorkGroupSizeY_EXT << "\n"
|
||||
<< "MaxTaskWorkGroupSizeZ_EXT " << DefaultTBuiltInResource.maxTaskWorkGroupSizeZ_EXT << "\n"
|
||||
<< "MaxMeshViewCountEXT " << DefaultTBuiltInResource.maxMeshViewCountEXT << "\n"
|
||||
<< "MaxDualSourceDrawBuffersEXT " << DefaultTBuiltInResource.maxDualSourceDrawBuffersEXT << "\n"
|
||||
<< "nonInductiveForLoops " << DefaultTBuiltInResource.limits.nonInductiveForLoops << "\n"
|
||||
<< "whileLoops " << DefaultTBuiltInResource.limits.whileLoops << "\n"
|
||||
@@ -469,6 +487,24 @@ void DecodeResourceLimits(TBuiltInResource* resources, char* config)
|
||||
resources->maxTaskWorkGroupSizeZ_NV = value;
|
||||
else if (tokenStr == "MaxMeshViewCountNV")
|
||||
resources->maxMeshViewCountNV = value;
|
||||
else if (tokenStr == "MaxMeshOutputVerticesEXT")
|
||||
resources->maxMeshOutputVerticesEXT = value;
|
||||
else if (tokenStr == "MaxMeshOutputPrimitivesEXT")
|
||||
resources->maxMeshOutputPrimitivesEXT = value;
|
||||
else if (tokenStr == "MaxMeshWorkGroupSizeX_EXT")
|
||||
resources->maxMeshWorkGroupSizeX_EXT = value;
|
||||
else if (tokenStr == "MaxMeshWorkGroupSizeY_EXT")
|
||||
resources->maxMeshWorkGroupSizeY_EXT = value;
|
||||
else if (tokenStr == "MaxMeshWorkGroupSizeZ_EXT")
|
||||
resources->maxMeshWorkGroupSizeZ_EXT = value;
|
||||
else if (tokenStr == "MaxTaskWorkGroupSizeX_EXT")
|
||||
resources->maxTaskWorkGroupSizeX_EXT = value;
|
||||
else if (tokenStr == "MaxTaskWorkGroupSizeY_EXT")
|
||||
resources->maxTaskWorkGroupSizeY_EXT = value;
|
||||
else if (tokenStr == "MaxTaskWorkGroupSizeZ_EXT")
|
||||
resources->maxTaskWorkGroupSizeZ_EXT = value;
|
||||
else if (tokenStr == "MaxMeshViewCountEXT")
|
||||
resources->maxMeshViewCountEXT = value;
|
||||
else if (tokenStr == "nonInductiveForLoops")
|
||||
resources->limits.nonInductiveForLoops = (value != 0);
|
||||
else if (tokenStr == "whileLoops")
|
||||
|
||||
37
3rdparty/glslang/StandAlone/StandAlone.cpp
vendored
37
3rdparty/glslang/StandAlone/StandAlone.cpp
vendored
@@ -113,6 +113,8 @@ bool SpvToolsDisassembler = false;
|
||||
bool SpvToolsValidate = false;
|
||||
bool NaNClamp = false;
|
||||
bool stripDebugInfo = false;
|
||||
bool emitNonSemanticShaderDebugInfo = false;
|
||||
bool emitNonSemanticShaderDebugSource = false;
|
||||
bool beQuiet = false;
|
||||
bool VulkanRulesRelaxed = false;
|
||||
bool autoSampledTextures = false;
|
||||
@@ -293,8 +295,8 @@ const char* GetBinaryName(EShLanguage stage)
|
||||
case EShLangClosestHit: name = "rchit.spv"; break;
|
||||
case EShLangMiss: name = "rmiss.spv"; break;
|
||||
case EShLangCallable: name = "rcall.spv"; break;
|
||||
case EShLangMeshNV: name = "mesh.spv"; break;
|
||||
case EShLangTaskNV: name = "task.spv"; break;
|
||||
case EShLangMesh : name = "mesh.spv"; break;
|
||||
case EShLangTask : name = "task.spv"; break;
|
||||
default: name = "unknown"; break;
|
||||
}
|
||||
} else
|
||||
@@ -969,11 +971,21 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
|
||||
case 'g':
|
||||
// Override previous -g or -g0 argument
|
||||
stripDebugInfo = false;
|
||||
emitNonSemanticShaderDebugInfo = false;
|
||||
Options &= ~EOptionDebug;
|
||||
if (argv[0][2] == '0')
|
||||
stripDebugInfo = true;
|
||||
else
|
||||
else {
|
||||
Options |= EOptionDebug;
|
||||
if (argv[0][2] == 'V') {
|
||||
emitNonSemanticShaderDebugInfo = true;
|
||||
if (argv[0][3] == 'S') {
|
||||
emitNonSemanticShaderDebugSource = true;
|
||||
} else {
|
||||
emitNonSemanticShaderDebugSource = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
@@ -1379,6 +1391,9 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
|
||||
if (EnhancedMsgs)
|
||||
shader->setEnhancedMsgs();
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
shader->setDebugInfo(true);
|
||||
|
||||
// Set up the environment, some subsettings take precedence over earlier
|
||||
// ways of setting things.
|
||||
if (Options & EOptionSpv) {
|
||||
@@ -1470,9 +1485,15 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
|
||||
std::vector<unsigned int> spirv;
|
||||
spv::SpvBuildLogger logger;
|
||||
glslang::SpvOptions spvOptions;
|
||||
if (Options & EOptionDebug)
|
||||
if (Options & EOptionDebug) {
|
||||
spvOptions.generateDebugInfo = true;
|
||||
else if (stripDebugInfo)
|
||||
if (emitNonSemanticShaderDebugInfo) {
|
||||
spvOptions.emitNonSemanticShaderDebugInfo = true;
|
||||
if (emitNonSemanticShaderDebugSource) {
|
||||
spvOptions.emitNonSemanticShaderDebugSource = true;
|
||||
}
|
||||
}
|
||||
} else if (stripDebugInfo)
|
||||
spvOptions.stripDebugInfo = true;
|
||||
spvOptions.disableOptimizer = (Options & EOptionOptimizeDisable) != 0;
|
||||
spvOptions.optimizeSize = (Options & EOptionOptimizeSize) != 0;
|
||||
@@ -1780,9 +1801,9 @@ EShLanguage FindLanguage(const std::string& name, bool parseStageName)
|
||||
else if (stageName == "rcall")
|
||||
return EShLangCallable;
|
||||
else if (stageName == "mesh")
|
||||
return EShLangMeshNV;
|
||||
return EShLangMesh;
|
||||
else if (stageName == "task")
|
||||
return EShLangTaskNV;
|
||||
return EShLangTask;
|
||||
|
||||
usage();
|
||||
return EShLangVertex;
|
||||
@@ -1906,6 +1927,8 @@ void usage()
|
||||
" SPV_GOOGLE_hlsl_functionality1 extension\n"
|
||||
" -g generate debug information\n"
|
||||
" -g0 strip debug information\n"
|
||||
" -gV generate nonsemantic shader debug information\n"
|
||||
" -gVS generate nonsemantic shader debug information with source\n"
|
||||
" -h print this usage message\n"
|
||||
" -i intermediate tree (glslang AST) is printed out\n"
|
||||
" -l link all input files together to form a single module\n"
|
||||
|
||||
2
3rdparty/glslang/build_info.h
vendored
2
3rdparty/glslang/build_info.h
vendored
@@ -35,7 +35,7 @@
|
||||
#define GLSLANG_BUILD_INFO
|
||||
|
||||
#define GLSLANG_VERSION_MAJOR 11
|
||||
#define GLSLANG_VERSION_MINOR 10
|
||||
#define GLSLANG_VERSION_MINOR 11
|
||||
#define GLSLANG_VERSION_PATCH 0
|
||||
#define GLSLANG_VERSION_FLAVOR ""
|
||||
|
||||
|
||||
@@ -192,10 +192,10 @@ static EShLanguage c_shader_stage(glslang_stage_t stage)
|
||||
return EShLangMiss;
|
||||
case GLSLANG_STAGE_CALLABLE_NV:
|
||||
return EShLangCallable;
|
||||
case GLSLANG_STAGE_TASK_NV:
|
||||
return EShLangTaskNV;
|
||||
case GLSLANG_STAGE_MESH_NV:
|
||||
return EShLangMeshNV;
|
||||
case GLSLANG_STAGE_TASK:
|
||||
return EShLangTask;
|
||||
case GLSLANG_STAGE_MESH:
|
||||
return EShLangMesh;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3428,7 +3428,7 @@ bool HlslGrammar::acceptCompoundStatement(TIntermNode*& retStatement)
|
||||
}
|
||||
}
|
||||
if (compoundStatement)
|
||||
compoundStatement->setOperator(EOpSequence);
|
||||
compoundStatement->setOperator(intermediate.getDebugInfo() ? EOpScope : EOpSequence);
|
||||
|
||||
retStatement = compoundStatement;
|
||||
|
||||
|
||||
@@ -2442,6 +2442,11 @@ void HlslParseContext::remapNonEntryPointIO(TFunction& function)
|
||||
clearUniformInputOutput(function[i].type->getQualifier());
|
||||
}
|
||||
|
||||
TIntermNode* HlslParseContext::handleDeclare(const TSourceLoc& loc, TIntermTyped* var)
|
||||
{
|
||||
return intermediate.addUnaryNode(EOpDeclare, var, loc, TType(EbtVoid));
|
||||
}
|
||||
|
||||
// Handle function returns, including type conversions to the function return type
|
||||
// if necessary.
|
||||
TIntermNode* HlslParseContext::handleReturnValue(const TSourceLoc& loc, TIntermTyped* value)
|
||||
@@ -8035,11 +8040,16 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, const TStr
|
||||
if (flattenVar)
|
||||
flatten(*symbol->getAsVariable(), symbolTable.atGlobalLevel());
|
||||
|
||||
if (initializer == nullptr)
|
||||
return nullptr;
|
||||
TVariable* variable = symbol->getAsVariable();
|
||||
|
||||
if (initializer == nullptr) {
|
||||
if (intermediate.getDebugInfo())
|
||||
return executeDeclaration(loc, variable);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Deal with initializer
|
||||
TVariable* variable = symbol->getAsVariable();
|
||||
if (variable == nullptr) {
|
||||
error(loc, "initializer requires a variable, not a member", identifier.c_str(), "");
|
||||
return nullptr;
|
||||
@@ -8106,6 +8116,24 @@ TVariable* HlslParseContext::declareNonArray(const TSourceLoc& loc, const TStrin
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Return a declaration of a temporary variable
|
||||
//
|
||||
// This is used to force a variable to be declared in the correct scope
|
||||
// when debug information is being generated.
|
||||
|
||||
TIntermNode* HlslParseContext::executeDeclaration(const TSourceLoc& loc, TVariable* variable)
|
||||
{
|
||||
//
|
||||
// Identifier must be of type temporary.
|
||||
//
|
||||
TStorageQualifier qualifier = variable->getType().getQualifier().storage;
|
||||
if (qualifier != EvqTemporary)
|
||||
return nullptr;
|
||||
|
||||
TIntermSymbol* intermSymbol = intermediate.addSymbol(*variable, loc);
|
||||
return handleDeclare(loc, intermSymbol);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle all types of initializers from the grammar.
|
||||
//
|
||||
|
||||
@@ -87,6 +87,7 @@ public:
|
||||
void handleFunctionBody(const TSourceLoc&, TFunction&, TIntermNode* functionBody, TIntermNode*& node);
|
||||
void remapEntryPointIO(TFunction& function, TVariable*& returnValue, TVector<TVariable*>& inputs, TVector<TVariable*>& outputs);
|
||||
void remapNonEntryPointIO(TFunction& function);
|
||||
TIntermNode* handleDeclare(const TSourceLoc&, TIntermTyped*);
|
||||
TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*);
|
||||
void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg);
|
||||
TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
|
||||
@@ -243,6 +244,7 @@ protected:
|
||||
TIntermSymbol* makeInternalVariableNode(const TSourceLoc&, const char* name, const TType&) const;
|
||||
TVariable* declareNonArray(const TSourceLoc&, const TString& identifier, const TType&, bool track);
|
||||
void declareArray(const TSourceLoc&, const TString& identifier, const TType&, TSymbol*&, bool track);
|
||||
TIntermNode* executeDeclaration(const TSourceLoc&, TVariable* variable);
|
||||
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
|
||||
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer, TIntermTyped* scalarInit);
|
||||
bool isScalarConstructor(const TIntermNode*);
|
||||
|
||||
13
3rdparty/glslang/glslang/Include/BaseTypes.h
vendored
13
3rdparty/glslang/glslang/Include/BaseTypes.h
vendored
@@ -105,6 +105,8 @@ enum TStorageQualifier {
|
||||
EvqCallableData,
|
||||
EvqCallableDataIn,
|
||||
|
||||
EvqtaskPayloadSharedEXT,
|
||||
|
||||
// parameters
|
||||
EvqIn, // also, for 'in' in the grammar before we know if it's a pipeline input or an 'in' parameter
|
||||
EvqOut, // also, for 'out' in the grammar before we know if it's a pipeline output or an 'out' parameter
|
||||
@@ -287,6 +289,11 @@ enum TBuiltInVariable {
|
||||
EbvLayerPerViewNV,
|
||||
EbvMeshViewCountNV,
|
||||
EbvMeshViewIndicesNV,
|
||||
//GL_EXT_mesh_shader
|
||||
EbvPrimitivePointIndicesEXT,
|
||||
EbvPrimitiveLineIndicesEXT,
|
||||
EbvPrimitiveTriangleIndicesEXT,
|
||||
EbvCullPrimitiveEXT,
|
||||
|
||||
// sm builtins
|
||||
EbvWarpsPerSM,
|
||||
@@ -360,6 +367,7 @@ __inline const char* GetStorageQualifierString(TStorageQualifier q)
|
||||
case EvqHitAttr: return "hitAttributeNV"; break;
|
||||
case EvqCallableData: return "callableDataNV"; break;
|
||||
case EvqCallableDataIn: return "callableDataInNV"; break;
|
||||
case EvqtaskPayloadSharedEXT: return "taskPayloadSharedEXT"; break;
|
||||
default: return "unknown qualifier";
|
||||
}
|
||||
}
|
||||
@@ -496,6 +504,11 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
|
||||
case EbvLayerPerViewNV: return "LayerPerViewNV";
|
||||
case EbvMeshViewCountNV: return "MeshViewCountNV";
|
||||
case EbvMeshViewIndicesNV: return "MeshViewIndicesNV";
|
||||
// GL_EXT_mesh_shader
|
||||
case EbvPrimitivePointIndicesEXT: return "PrimitivePointIndicesEXT";
|
||||
case EbvPrimitiveLineIndicesEXT: return "PrimitiveLineIndicesEXT";
|
||||
case EbvPrimitiveTriangleIndicesEXT: return "PrimitiveTriangleIndicesEXT";
|
||||
case EbvCullPrimitiveEXT: return "CullPrimitiveEXT";
|
||||
|
||||
case EbvWarpsPerSM: return "WarpsPerSMNV";
|
||||
case EbvSMCount: return "SMCountNV";
|
||||
|
||||
4
3rdparty/glslang/glslang/Include/Common.h
vendored
4
3rdparty/glslang/glslang/Include/Common.h
vendored
@@ -67,7 +67,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*/) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API)
|
||||
#include <basetsd.h>
|
||||
#ifndef snprintf
|
||||
#define snprintf sprintf_s
|
||||
@@ -219,7 +219,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) || (defined(MINGW_HAS_SECURE_API) && 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
|
||||
|
||||
@@ -142,6 +142,15 @@ struct TBuiltInResource {
|
||||
int maxTaskWorkGroupSizeY_NV;
|
||||
int maxTaskWorkGroupSizeZ_NV;
|
||||
int maxMeshViewCountNV;
|
||||
int maxMeshOutputVerticesEXT;
|
||||
int maxMeshOutputPrimitivesEXT;
|
||||
int maxMeshWorkGroupSizeX_EXT;
|
||||
int maxMeshWorkGroupSizeY_EXT;
|
||||
int maxMeshWorkGroupSizeZ_EXT;
|
||||
int maxTaskWorkGroupSizeX_EXT;
|
||||
int maxTaskWorkGroupSizeY_EXT;
|
||||
int maxTaskWorkGroupSizeZ_EXT;
|
||||
int maxMeshViewCountEXT;
|
||||
int maxDualSourceDrawBuffersEXT;
|
||||
|
||||
TLimits limits;
|
||||
|
||||
7
3rdparty/glslang/glslang/Include/Types.h
vendored
7
3rdparty/glslang/glslang/Include/Types.h
vendored
@@ -833,7 +833,7 @@ public:
|
||||
}
|
||||
storage = EvqUniform;
|
||||
break;
|
||||
case EbsStorageBuffer :
|
||||
case EbsStorageBuffer :
|
||||
storage = EvqBuffer;
|
||||
break;
|
||||
#ifndef GLSLANG_WEB
|
||||
@@ -856,6 +856,7 @@ public:
|
||||
bool isPerPrimitive() const { return perPrimitiveNV; }
|
||||
bool isPerView() const { return perViewNV; }
|
||||
bool isTaskMemory() const { return perTaskNV; }
|
||||
bool isTaskPayload() const { return storage == EvqtaskPayloadSharedEXT; }
|
||||
bool isAnyPayload() const {
|
||||
return storage == EvqPayload || storage == EvqPayloadIn;
|
||||
}
|
||||
@@ -875,7 +876,7 @@ public:
|
||||
return ! patch && isPipeInput();
|
||||
case EShLangFragment:
|
||||
return (pervertexNV || pervertexEXT) && isPipeInput();
|
||||
case EShLangMeshNV:
|
||||
case EShLangMesh:
|
||||
return ! perTaskNV && isPipeOutput();
|
||||
|
||||
default:
|
||||
@@ -2543,7 +2544,7 @@ public:
|
||||
void setStruct(TTypeList* s) { assert(isStruct()); structure = s; }
|
||||
TTypeList* getWritableStruct() const { assert(isStruct()); return structure; } // This should only be used when known to not be sharing with other threads
|
||||
void setBasicType(const TBasicType& t) { basicType = t; }
|
||||
|
||||
|
||||
int computeNumComponents() const
|
||||
{
|
||||
int components = 0;
|
||||
|
||||
@@ -148,6 +148,15 @@ typedef struct glslang_resource_s {
|
||||
int max_task_work_group_size_y_nv;
|
||||
int max_task_work_group_size_z_nv;
|
||||
int max_mesh_view_count_nv;
|
||||
int max_mesh_output_vertices_ext;
|
||||
int max_mesh_output_primitives_ext;
|
||||
int max_mesh_work_group_size_x_ext;
|
||||
int max_mesh_work_group_size_y_ext;
|
||||
int max_mesh_work_group_size_z_ext;
|
||||
int max_task_work_group_size_x_ext;
|
||||
int max_task_work_group_size_y_ext;
|
||||
int max_task_work_group_size_z_ext;
|
||||
int max_mesh_view_count_ext;
|
||||
int maxDualSourceDrawBuffersEXT;
|
||||
|
||||
glslang_limits_t limits;
|
||||
@@ -207,6 +216,8 @@ typedef struct glslang_spv_options_s {
|
||||
bool optimize_size;
|
||||
bool disassemble;
|
||||
bool validate;
|
||||
bool emit_nonsemantic_shader_debug_info;
|
||||
bool emit_nonsemantic_shader_debug_source;
|
||||
} glslang_spv_options_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -43,14 +43,22 @@ typedef enum {
|
||||
GLSLANG_STAGE_GEOMETRY,
|
||||
GLSLANG_STAGE_FRAGMENT,
|
||||
GLSLANG_STAGE_COMPUTE,
|
||||
GLSLANG_STAGE_RAYGEN_NV,
|
||||
GLSLANG_STAGE_INTERSECT_NV,
|
||||
GLSLANG_STAGE_ANYHIT_NV,
|
||||
GLSLANG_STAGE_CLOSESTHIT_NV,
|
||||
GLSLANG_STAGE_MISS_NV,
|
||||
GLSLANG_STAGE_CALLABLE_NV,
|
||||
GLSLANG_STAGE_TASK_NV,
|
||||
GLSLANG_STAGE_MESH_NV,
|
||||
GLSLANG_STAGE_RAYGEN,
|
||||
GLSLANG_STAGE_RAYGEN_NV = GLSLANG_STAGE_RAYGEN,
|
||||
GLSLANG_STAGE_INTERSECT,
|
||||
GLSLANG_STAGE_INTERSECT_NV = GLSLANG_STAGE_INTERSECT,
|
||||
GLSLANG_STAGE_ANYHIT,
|
||||
GLSLANG_STAGE_ANYHIT_NV = GLSLANG_STAGE_ANYHIT,
|
||||
GLSLANG_STAGE_CLOSESTHIT,
|
||||
GLSLANG_STAGE_CLOSESTHIT_NV = GLSLANG_STAGE_CLOSESTHIT,
|
||||
GLSLANG_STAGE_MISS,
|
||||
GLSLANG_STAGE_MISS_NV = GLSLANG_STAGE_MISS,
|
||||
GLSLANG_STAGE_CALLABLE,
|
||||
GLSLANG_STAGE_CALLABLE_NV = GLSLANG_STAGE_CALLABLE,
|
||||
GLSLANG_STAGE_TASK,
|
||||
GLSLANG_STAGE_TASK_NV = GLSLANG_STAGE_TASK,
|
||||
GLSLANG_STAGE_MESH,
|
||||
GLSLANG_STAGE_MESH_NV = GLSLANG_STAGE_MESH,
|
||||
LAST_ELEMENT_MARKER(GLSLANG_STAGE_COUNT),
|
||||
} glslang_stage_t; // would be better as stage, but this is ancient now
|
||||
|
||||
@@ -62,14 +70,22 @@ typedef enum {
|
||||
GLSLANG_STAGE_GEOMETRY_MASK = (1 << GLSLANG_STAGE_GEOMETRY),
|
||||
GLSLANG_STAGE_FRAGMENT_MASK = (1 << GLSLANG_STAGE_FRAGMENT),
|
||||
GLSLANG_STAGE_COMPUTE_MASK = (1 << GLSLANG_STAGE_COMPUTE),
|
||||
GLSLANG_STAGE_RAYGEN_NV_MASK = (1 << GLSLANG_STAGE_RAYGEN_NV),
|
||||
GLSLANG_STAGE_INTERSECT_NV_MASK = (1 << GLSLANG_STAGE_INTERSECT_NV),
|
||||
GLSLANG_STAGE_ANYHIT_NV_MASK = (1 << GLSLANG_STAGE_ANYHIT_NV),
|
||||
GLSLANG_STAGE_CLOSESTHIT_NV_MASK = (1 << GLSLANG_STAGE_CLOSESTHIT_NV),
|
||||
GLSLANG_STAGE_MISS_NV_MASK = (1 << GLSLANG_STAGE_MISS_NV),
|
||||
GLSLANG_STAGE_CALLABLE_NV_MASK = (1 << GLSLANG_STAGE_CALLABLE_NV),
|
||||
GLSLANG_STAGE_TASK_NV_MASK = (1 << GLSLANG_STAGE_TASK_NV),
|
||||
GLSLANG_STAGE_MESH_NV_MASK = (1 << GLSLANG_STAGE_MESH_NV),
|
||||
GLSLANG_STAGE_RAYGEN_MASK = (1 << GLSLANG_STAGE_RAYGEN),
|
||||
GLSLANG_STAGE_RAYGEN_NV_MASK = GLSLANG_STAGE_RAYGEN_MASK,
|
||||
GLSLANG_STAGE_INTERSECT_MASK = (1 << GLSLANG_STAGE_INTERSECT),
|
||||
GLSLANG_STAGE_INTERSECT_NV_MASK = GLSLANG_STAGE_INTERSECT_MASK,
|
||||
GLSLANG_STAGE_ANYHIT_MASK = (1 << GLSLANG_STAGE_ANYHIT),
|
||||
GLSLANG_STAGE_ANYHIT_NV_MASK = GLSLANG_STAGE_ANYHIT_MASK,
|
||||
GLSLANG_STAGE_CLOSESTHIT_MASK = (1 << GLSLANG_STAGE_CLOSESTHIT),
|
||||
GLSLANG_STAGE_CLOSESTHIT_NV_MASK = GLSLANG_STAGE_CLOSESTHIT_MASK,
|
||||
GLSLANG_STAGE_MISS_MASK = (1 << GLSLANG_STAGE_MISS),
|
||||
GLSLANG_STAGE_MISS_NV_MASK = GLSLANG_STAGE_MISS_MASK,
|
||||
GLSLANG_STAGE_CALLABLE_MASK = (1 << GLSLANG_STAGE_CALLABLE),
|
||||
GLSLANG_STAGE_CALLABLE_NV_MASK = GLSLANG_STAGE_CALLABLE_MASK,
|
||||
GLSLANG_STAGE_TASK_MASK = (1 << GLSLANG_STAGE_TASK),
|
||||
GLSLANG_STAGE_TASK_NV_MASK = GLSLANG_STAGE_TASK_MASK,
|
||||
GLSLANG_STAGE_MESH_MASK = (1 << GLSLANG_STAGE_MESH),
|
||||
GLSLANG_STAGE_MESH_NV_MASK = GLSLANG_STAGE_MESH_MASK,
|
||||
LAST_ELEMENT_MARKER(GLSLANG_STAGE_MASK_COUNT),
|
||||
} glslang_stage_mask_t;
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ class TIntermediate;
|
||||
enum TOperator {
|
||||
EOpNull, // if in a node, should only mean a node is still being built
|
||||
EOpSequence, // denotes a list of statements, or parameters, etc.
|
||||
EOpScope, // Used by debugging to denote a scoped list of statements
|
||||
EOpLinkerObjects, // for aggregate node of objects the linker may need, if not reference by the rest of the AST
|
||||
EOpFunctionCall,
|
||||
EOpFunction, // For function definition
|
||||
@@ -91,6 +92,8 @@ enum TOperator {
|
||||
|
||||
EOpCopyObject,
|
||||
|
||||
EOpDeclare, // Used by debugging to force declaration of variable in correct scope
|
||||
|
||||
// (u)int* -> bool
|
||||
EOpConvInt8ToBool,
|
||||
EOpConvUint8ToBool,
|
||||
@@ -934,6 +937,8 @@ enum TOperator {
|
||||
EOpExecuteCallableNV,
|
||||
EOpExecuteCallableKHR,
|
||||
EOpWritePackedPrimitiveIndices4x8NV,
|
||||
EOpEmitMeshTasksEXT,
|
||||
EOpSetMeshOutputsEXT,
|
||||
|
||||
//
|
||||
// GL_EXT_ray_query operations
|
||||
|
||||
@@ -2268,11 +2268,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
|
||||
"\n"
|
||||
);
|
||||
stageBuiltins[EShLangMeshNV].append(
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"void subgroupMemoryBarrierShared();"
|
||||
"\n"
|
||||
);
|
||||
stageBuiltins[EShLangTaskNV].append(
|
||||
stageBuiltins[EShLangTask].append(
|
||||
"void subgroupMemoryBarrierShared();"
|
||||
"\n"
|
||||
);
|
||||
@@ -4298,10 +4298,10 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"void barrier();"
|
||||
);
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
|
||||
stageBuiltins[EShLangMeshNV].append(
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"void barrier();"
|
||||
);
|
||||
stageBuiltins[EShLangTaskNV].append(
|
||||
stageBuiltins[EShLangTask].append(
|
||||
"void barrier();"
|
||||
);
|
||||
}
|
||||
@@ -4326,11 +4326,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
commonBuiltins.append("void memoryBarrierImage();");
|
||||
}
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
|
||||
stageBuiltins[EShLangMeshNV].append(
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"void memoryBarrierShared();"
|
||||
"void groupMemoryBarrier();"
|
||||
);
|
||||
stageBuiltins[EShLangTaskNV].append(
|
||||
stageBuiltins[EShLangTask].append(
|
||||
"void memoryBarrierShared();"
|
||||
"void groupMemoryBarrier();"
|
||||
);
|
||||
@@ -4655,10 +4655,21 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
|
||||
// Builtins for GL_NV_mesh_shader
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
|
||||
stageBuiltins[EShLangMeshNV].append(
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"void writePackedPrimitiveIndices4x8NV(uint, uint);"
|
||||
"\n");
|
||||
}
|
||||
// Builtins for GL_EXT_mesh_shader
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
|
||||
// Builtins for GL_EXT_mesh_shader
|
||||
stageBuiltins[EShLangTask].append(
|
||||
"void EmitMeshTasksEXT(uint, uint, uint);"
|
||||
"\n");
|
||||
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"void SetMeshOutputsEXT(uint, uint);"
|
||||
"\n");
|
||||
}
|
||||
#endif // !GLSLANG_ANGLE
|
||||
#endif // !GLSLANG_WEB
|
||||
|
||||
@@ -4855,7 +4866,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
|
||||
// per-vertex attributes
|
||||
stageBuiltins[EShLangMeshNV].append(
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"out gl_MeshPerVertexNV {"
|
||||
"vec4 gl_Position;"
|
||||
"float gl_PointSize;"
|
||||
@@ -4868,7 +4879,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
);
|
||||
|
||||
// per-primitive attributes
|
||||
stageBuiltins[EShLangMeshNV].append(
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"perprimitiveNV out gl_MeshPerPrimitiveNV {"
|
||||
"int gl_PrimitiveID;"
|
||||
"int gl_Layer;"
|
||||
@@ -4879,7 +4890,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"} gl_MeshPrimitivesNV[];"
|
||||
);
|
||||
|
||||
stageBuiltins[EShLangMeshNV].append(
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"out uint gl_PrimitiveCountNV;"
|
||||
"out uint gl_PrimitiveIndicesNV[];"
|
||||
|
||||
@@ -4893,10 +4904,38 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
|
||||
"in highp uvec3 gl_GlobalInvocationID;"
|
||||
"in highp uint gl_LocalInvocationIndex;"
|
||||
|
||||
"\n");
|
||||
|
||||
stageBuiltins[EShLangTaskNV].append(
|
||||
// GL_EXT_mesh_shader
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"out uint gl_PrimitivePointIndicesEXT[];"
|
||||
"out uvec2 gl_PrimitiveLineIndicesEXT[];"
|
||||
"out uvec3 gl_PrimitiveTriangleIndicesEXT[];"
|
||||
"in highp uvec3 gl_NumWorkGroups;"
|
||||
"\n");
|
||||
|
||||
// per-vertex attributes
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"out gl_MeshPerVertexEXT {"
|
||||
"vec4 gl_Position;"
|
||||
"float gl_PointSize;"
|
||||
"float gl_ClipDistance[];"
|
||||
"float gl_CullDistance[];"
|
||||
"} gl_MeshVerticesEXT[];"
|
||||
);
|
||||
|
||||
// per-primitive attributes
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"perprimitiveEXT out gl_MeshPerPrimitiveEXT {"
|
||||
"int gl_PrimitiveID;"
|
||||
"int gl_Layer;"
|
||||
"int gl_ViewportIndex;"
|
||||
"bool gl_CullPrimitiveEXT;"
|
||||
"int gl_PrimitiveShadingRateEXT;"
|
||||
"} gl_MeshPrimitivesEXT[];"
|
||||
);
|
||||
|
||||
stageBuiltins[EShLangTask].append(
|
||||
"out uint gl_TaskCountNV;"
|
||||
|
||||
"const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
|
||||
@@ -4909,27 +4948,28 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
|
||||
"in uint gl_MeshViewCountNV;"
|
||||
"in uint gl_MeshViewIndicesNV[4];"
|
||||
|
||||
"in highp uvec3 gl_NumWorkGroups;"
|
||||
"\n");
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
stageBuiltins[EShLangMeshNV].append(
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"in highp int gl_DeviceIndex;" // GL_EXT_device_group
|
||||
"in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
|
||||
"in int gl_ViewIndex;" // GL_EXT_multiview
|
||||
"\n");
|
||||
|
||||
stageBuiltins[EShLangTaskNV].append(
|
||||
stageBuiltins[EShLangTask].append(
|
||||
"in highp int gl_DeviceIndex;" // GL_EXT_device_group
|
||||
"in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
|
||||
"\n");
|
||||
|
||||
if (version >= 460) {
|
||||
stageBuiltins[EShLangMeshNV].append(
|
||||
stageBuiltins[EShLangMesh].append(
|
||||
"in int gl_DrawID;"
|
||||
"\n");
|
||||
|
||||
stageBuiltins[EShLangTaskNV].append(
|
||||
stageBuiltins[EShLangTask].append(
|
||||
"in int gl_DrawID;"
|
||||
"\n");
|
||||
}
|
||||
@@ -5704,8 +5744,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
stageBuiltins[EShLangGeometry] .append(ballotDecls);
|
||||
stageBuiltins[EShLangCompute] .append(ballotDecls);
|
||||
stageBuiltins[EShLangFragment] .append(fragmentBallotDecls);
|
||||
stageBuiltins[EShLangMeshNV] .append(ballotDecls);
|
||||
stageBuiltins[EShLangTaskNV] .append(ballotDecls);
|
||||
stageBuiltins[EShLangMesh] .append(ballotDecls);
|
||||
stageBuiltins[EShLangTask] .append(ballotDecls);
|
||||
stageBuiltins[EShLangRayGen] .append(rtBallotDecls);
|
||||
stageBuiltins[EShLangIntersect] .append(rtBallotDecls);
|
||||
// No volatile qualifier on these builtins in any-hit
|
||||
@@ -5773,10 +5813,10 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
stageBuiltins[EShLangCompute] .append(subgroupDecls);
|
||||
stageBuiltins[EShLangCompute] .append(computeSubgroupDecls);
|
||||
stageBuiltins[EShLangFragment] .append(fragmentSubgroupDecls);
|
||||
stageBuiltins[EShLangMeshNV] .append(subgroupDecls);
|
||||
stageBuiltins[EShLangMeshNV] .append(computeSubgroupDecls);
|
||||
stageBuiltins[EShLangTaskNV] .append(subgroupDecls);
|
||||
stageBuiltins[EShLangTaskNV] .append(computeSubgroupDecls);
|
||||
stageBuiltins[EShLangMesh] .append(subgroupDecls);
|
||||
stageBuiltins[EShLangMesh] .append(computeSubgroupDecls);
|
||||
stageBuiltins[EShLangTask] .append(subgroupDecls);
|
||||
stageBuiltins[EShLangTask] .append(computeSubgroupDecls);
|
||||
stageBuiltins[EShLangRayGen] .append(rtSubgroupDecls);
|
||||
stageBuiltins[EShLangIntersect] .append(rtSubgroupDecls);
|
||||
// No volatile qualifier on these builtins in any-hit
|
||||
@@ -7613,6 +7653,23 @@ static void SpecialQualifier(const char* name, TStorageQualifier qualifier, TBui
|
||||
symQualifier.builtIn = builtIn;
|
||||
}
|
||||
|
||||
//
|
||||
// Modify the symbol's flat decoration.
|
||||
//
|
||||
// Safe to call even if name is not present.
|
||||
//
|
||||
// Originally written to transform gl_SubGroupSizeARB from uniform to fragment input in Vulkan.
|
||||
//
|
||||
static void ModifyFlatDecoration(const char* name, bool flat, TSymbolTable& symbolTable)
|
||||
{
|
||||
TSymbol* symbol = symbolTable.find(name);
|
||||
if (symbol == nullptr)
|
||||
return;
|
||||
|
||||
TQualifier& symQualifier = symbol->getWritableType().getQualifier();
|
||||
symQualifier.flat = flat;
|
||||
}
|
||||
|
||||
//
|
||||
// To tag built-in variables with their TBuiltInVariable enum. Use this when the
|
||||
// normal declaration text already gets the qualifier right, and all that's needed
|
||||
@@ -7996,9 +8053,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
|
||||
|
||||
if (spvVersion.vulkan > 0)
|
||||
if (spvVersion.vulkan > 0) {
|
||||
// Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
|
||||
SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
|
||||
if (language == EShLangFragment)
|
||||
ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
|
||||
}
|
||||
else
|
||||
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
|
||||
}
|
||||
@@ -8430,9 +8490,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
|
||||
|
||||
if (spvVersion.vulkan > 0)
|
||||
if (spvVersion.vulkan > 0) {
|
||||
// Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
|
||||
SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
|
||||
if (language == EShLangFragment)
|
||||
ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
|
||||
}
|
||||
else
|
||||
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
|
||||
}
|
||||
@@ -8647,9 +8710,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
|
||||
|
||||
if (spvVersion.vulkan > 0)
|
||||
if (spvVersion.vulkan > 0) {
|
||||
// Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
|
||||
SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
|
||||
if (language == EShLangFragment)
|
||||
ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
|
||||
}
|
||||
else
|
||||
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
|
||||
}
|
||||
@@ -8837,9 +8903,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
|
||||
|
||||
if (spvVersion.vulkan > 0)
|
||||
if (spvVersion.vulkan > 0) {
|
||||
// Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
|
||||
SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
|
||||
if (language == EShLangFragment)
|
||||
ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
|
||||
}
|
||||
else
|
||||
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
|
||||
|
||||
@@ -8883,7 +8952,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
}
|
||||
break;
|
||||
|
||||
case EShLangMeshNV:
|
||||
case EShLangMesh:
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
|
||||
// per-vertex builtins
|
||||
symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_Position", 1, &E_GL_NV_mesh_shader);
|
||||
@@ -8927,12 +8996,19 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
symbolTable.setVariableExtensions("gl_PrimitiveIndicesNV", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshViewCountNV", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshViewIndicesNV", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
|
||||
|
||||
if (profile != EEsProfile) {
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupSize", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupID", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationID", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_GlobalInvocationID", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationIndex", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
} else {
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
|
||||
}
|
||||
BuiltInVariable("gl_PrimitiveCountNV", EbvPrimitiveCountNV, symbolTable);
|
||||
BuiltInVariable("gl_PrimitiveIndicesNV", EbvPrimitiveIndicesNV, symbolTable);
|
||||
BuiltInVariable("gl_MeshViewCountNV", EbvMeshViewCountNV, symbolTable);
|
||||
@@ -8950,12 +9026,54 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
symbolTable.setVariableExtensions("gl_MaxMeshViewCountNV", 1, &E_GL_NV_mesh_shader);
|
||||
|
||||
// builtin functions
|
||||
symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
|
||||
if (profile != EEsProfile) {
|
||||
symbolTable.setFunctionExtensions("barrier", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("memoryBarrierShared", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("groupMemoryBarrier", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
} else {
|
||||
symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
|
||||
}
|
||||
symbolTable.setFunctionExtensions("writePackedPrimitiveIndices4x8NV", 1, &E_GL_NV_mesh_shader);
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
// GL_EXT_Mesh_shader
|
||||
symbolTable.setVariableExtensions("gl_PrimitivePointIndicesEXT", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_PrimitiveLineIndicesEXT", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_PrimitiveTriangleIndicesEXT", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_NumWorkGroups", 1, &E_GL_EXT_mesh_shader);
|
||||
|
||||
BuiltInVariable("gl_PrimitivePointIndicesEXT", EbvPrimitivePointIndicesEXT, symbolTable);
|
||||
BuiltInVariable("gl_PrimitiveLineIndicesEXT", EbvPrimitiveLineIndicesEXT, symbolTable);
|
||||
BuiltInVariable("gl_PrimitiveTriangleIndicesEXT", EbvPrimitiveTriangleIndicesEXT, symbolTable);
|
||||
BuiltInVariable("gl_NumWorkGroups", EbvNumWorkGroups, symbolTable);
|
||||
|
||||
symbolTable.setVariableExtensions("gl_MeshVerticesEXT", "gl_Position", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshVerticesEXT", "gl_PointSize", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshVerticesEXT", "gl_ClipDistance", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshVerticesEXT", "gl_CullDistance", 1, &E_GL_EXT_mesh_shader);
|
||||
|
||||
BuiltInVariable("gl_MeshVerticesEXT", "gl_Position", EbvPosition, symbolTable);
|
||||
BuiltInVariable("gl_MeshVerticesEXT", "gl_PointSize", EbvPointSize, symbolTable);
|
||||
BuiltInVariable("gl_MeshVerticesEXT", "gl_ClipDistance", EbvClipDistance, symbolTable);
|
||||
BuiltInVariable("gl_MeshVerticesEXT", "gl_CullDistance", EbvCullDistance, symbolTable);
|
||||
|
||||
symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_PrimitiveID", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_Layer", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_ViewportIndex", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_CullPrimitiveEXT", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_PrimitiveShadingRateEXT", 1, &E_GL_EXT_mesh_shader);
|
||||
|
||||
BuiltInVariable("gl_MeshPrimitivesEXT", "gl_PrimitiveID", EbvPrimitiveId, symbolTable);
|
||||
BuiltInVariable("gl_MeshPrimitivesEXT", "gl_Layer", EbvLayer, symbolTable);
|
||||
BuiltInVariable("gl_MeshPrimitivesEXT", "gl_ViewportIndex", EbvViewportIndex, symbolTable);
|
||||
BuiltInVariable("gl_MeshPrimitivesEXT", "gl_CullPrimitiveEXT", EbvCullPrimitiveEXT, symbolTable);
|
||||
BuiltInVariable("gl_MeshPrimitivesEXT", "gl_PrimitiveShadingRateEXT", EbvPrimitiveShadingRateKHR, symbolTable);
|
||||
|
||||
symbolTable.setFunctionExtensions("SetMeshOutputsEXT", 1, &E_GL_EXT_mesh_shader);
|
||||
|
||||
// GL_EXT_device_group
|
||||
symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
|
||||
BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
|
||||
@@ -8966,6 +9084,9 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
if (version >= 460) {
|
||||
BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
|
||||
}
|
||||
// GL_EXT_multiview
|
||||
BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
|
||||
symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
|
||||
|
||||
// GL_ARB_shader_ballot
|
||||
symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
|
||||
@@ -8983,9 +9104,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
|
||||
|
||||
if (spvVersion.vulkan > 0)
|
||||
if (spvVersion.vulkan > 0) {
|
||||
// Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
|
||||
SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
|
||||
if (language == EShLangFragment)
|
||||
ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
|
||||
}
|
||||
else
|
||||
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
|
||||
}
|
||||
@@ -9035,16 +9159,24 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
}
|
||||
break;
|
||||
|
||||
case EShLangTaskNV:
|
||||
case EShLangTask:
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
|
||||
symbolTable.setVariableExtensions("gl_TaskCountNV", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshViewCountNV", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MeshViewIndicesNV", 1, &E_GL_NV_mesh_shader);
|
||||
if (profile != EEsProfile) {
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupSize", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupID", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationID", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_GlobalInvocationID", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationIndex", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
} else {
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
|
||||
}
|
||||
|
||||
BuiltInVariable("gl_TaskCountNV", EbvTaskCountNV, symbolTable);
|
||||
BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable);
|
||||
@@ -9058,12 +9190,23 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
symbolTable.setVariableExtensions("gl_MaxTaskWorkGroupSizeNV", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_MaxMeshViewCountNV", 1, &E_GL_NV_mesh_shader);
|
||||
|
||||
symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
|
||||
if (profile != EEsProfile) {
|
||||
symbolTable.setFunctionExtensions("barrier", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("memoryBarrierShared", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("groupMemoryBarrier", Num_AEP_mesh_shader, AEP_mesh_shader);
|
||||
} else {
|
||||
symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
|
||||
symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
|
||||
}
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
// GL_EXT_mesh_shader
|
||||
symbolTable.setFunctionExtensions("EmitMeshTasksEXT", 1, &E_GL_EXT_mesh_shader);
|
||||
symbolTable.setVariableExtensions("gl_NumWorkGroups", 1, &E_GL_EXT_mesh_shader);
|
||||
BuiltInVariable("gl_NumWorkGroups", EbvNumWorkGroups, symbolTable);
|
||||
|
||||
// GL_EXT_device_group
|
||||
symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
|
||||
BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
|
||||
@@ -9091,9 +9234,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
|
||||
BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
|
||||
|
||||
if (spvVersion.vulkan > 0)
|
||||
if (spvVersion.vulkan > 0) {
|
||||
// Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
|
||||
SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
|
||||
if (language == EShLangFragment)
|
||||
ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
|
||||
}
|
||||
else
|
||||
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
|
||||
}
|
||||
@@ -9687,17 +9833,27 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
symbolTable.relateToOperator("executeCallableEXT", EOpExecuteCallableKHR);
|
||||
}
|
||||
break;
|
||||
case EShLangMeshNV:
|
||||
case EShLangMesh:
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
|
||||
symbolTable.relateToOperator("writePackedPrimitiveIndices4x8NV", EOpWritePackedPrimitiveIndices4x8NV);
|
||||
symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
|
||||
symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
|
||||
symbolTable.relateToOperator("subgroupMemoryBarrierShared", EOpSubgroupMemoryBarrierShared);
|
||||
}
|
||||
// fall through
|
||||
case EShLangTaskNV:
|
||||
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
symbolTable.relateToOperator("SetMeshOutputsEXT", EOpSetMeshOutputsEXT);
|
||||
}
|
||||
break;
|
||||
case EShLangTask:
|
||||
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
|
||||
symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
|
||||
symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
|
||||
symbolTable.relateToOperator("subgroupMemoryBarrierShared", EOpSubgroupMemoryBarrierShared);
|
||||
}
|
||||
if (profile != EEsProfile && version >= 450) {
|
||||
symbolTable.relateToOperator("EmitMeshTasksEXT", EOpEmitMeshTasksEXT);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -2733,10 +2733,10 @@ TIntermAggregate* TIntermediate::addForLoop(TIntermNode* body, TIntermNode* init
|
||||
TIntermAggregate* loopSequence = (initializer == nullptr ||
|
||||
initializer->getAsAggregate() == nullptr) ? makeAggregate(initializer, loc)
|
||||
: initializer->getAsAggregate();
|
||||
if (loopSequence != nullptr && loopSequence->getOp() == EOpSequence)
|
||||
if (loopSequence != nullptr && (loopSequence->getOp() == EOpSequence || loopSequence->getOp() == EOpScope))
|
||||
loopSequence->setOp(EOpNull);
|
||||
loopSequence = growAggregate(loopSequence, node);
|
||||
loopSequence->setOperator(EOpSequence);
|
||||
loopSequence->setOperator(getDebugInfo() ? EOpScope : EOpSequence);
|
||||
|
||||
return loopSequence;
|
||||
}
|
||||
|
||||
@@ -502,6 +502,16 @@ TIntermTyped* TParseContext::handleVariable(const TSourceLoc& loc, TSymbol* symb
|
||||
error(loc, "cannot be used (maybe an instance name is needed)", string->c_str(), "");
|
||||
variable = nullptr;
|
||||
}
|
||||
|
||||
if (language == EShLangMesh && variable) {
|
||||
TLayoutGeometry primitiveType = intermediate.getOutputPrimitive();
|
||||
if ((variable->getMangledName() == "gl_PrimitiveTriangleIndicesEXT" && primitiveType != ElgTriangles) ||
|
||||
(variable->getMangledName() == "gl_PrimitiveLineIndicesEXT" && primitiveType != ElgLines) ||
|
||||
(variable->getMangledName() == "gl_PrimitivePointIndicesEXT" && primitiveType != ElgPoints)) {
|
||||
error(loc, "cannot be used (ouput primitive type mismatch)", string->c_str(), "");
|
||||
variable = nullptr;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (symbol)
|
||||
error(loc, "variable name expected", string->c_str(), "");
|
||||
@@ -717,7 +727,7 @@ bool TParseContext::isIoResizeArray(const TType& type) const
|
||||
! type.getQualifier().patch) ||
|
||||
(language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn &&
|
||||
(type.getQualifier().pervertexNV || type.getQualifier().pervertexEXT)) ||
|
||||
(language == EShLangMeshNV && type.getQualifier().storage == EvqVaryingOut &&
|
||||
(language == EShLangMesh && type.getQualifier().storage == EvqVaryingOut &&
|
||||
!type.getQualifier().perTaskNV));
|
||||
}
|
||||
|
||||
@@ -794,7 +804,7 @@ void TParseContext::checkIoArraysConsistency(const TSourceLoc &loc, bool tailOnl
|
||||
|
||||
// As I/O array sizes don't change, fetch requiredSize only once,
|
||||
// except for mesh shaders which could have different I/O array sizes based on type qualifiers.
|
||||
if (firstIteration || (language == EShLangMeshNV)) {
|
||||
if (firstIteration || (language == EShLangMesh)) {
|
||||
requiredSize = getIoArrayImplicitSize(type.getQualifier(), &featureString);
|
||||
if (requiredSize == 0)
|
||||
break;
|
||||
@@ -823,10 +833,11 @@ int TParseContext::getIoArrayImplicitSize(const TQualifier &qualifier, TString *
|
||||
// Number of vertices for Fragment shader is always three.
|
||||
expectedSize = 3;
|
||||
str = "vertices";
|
||||
} else if (language == EShLangMeshNV) {
|
||||
} else if (language == EShLangMesh) {
|
||||
unsigned int maxPrimitives =
|
||||
intermediate.getPrimitives() != TQualifier::layoutNotSet ? intermediate.getPrimitives() : 0;
|
||||
if (qualifier.builtIn == EbvPrimitiveIndicesNV) {
|
||||
if (qualifier.builtIn == EbvPrimitiveIndicesNV || qualifier.builtIn == EbvPrimitiveTriangleIndicesEXT ||
|
||||
qualifier.builtIn == EbvPrimitiveLineIndicesEXT || qualifier.builtIn == EbvPrimitivePointIndicesEXT) {
|
||||
expectedSize = maxPrimitives * TQualifier::mapGeometryToSize(intermediate.getOutputPrimitive());
|
||||
str = "max_primitives*";
|
||||
str += TQualifier::getGeometryString(intermediate.getOutputPrimitive());
|
||||
@@ -858,7 +869,7 @@ void TParseContext::checkIoArrayConsistency(const TSourceLoc& loc, int requiredS
|
||||
if (type.getOuterArraySize() > requiredSize)
|
||||
error(loc, " cannot be greater than 3 for pervertexEXT", feature, name.c_str());
|
||||
}
|
||||
else if (language == EShLangMeshNV)
|
||||
else if (language == EShLangMesh)
|
||||
error(loc, "inconsistent output array size of", feature, name.c_str());
|
||||
else
|
||||
assert(0);
|
||||
@@ -2000,18 +2011,18 @@ void TParseContext::memorySemanticsCheck(const TSourceLoc& loc, const TFunction&
|
||||
break;
|
||||
}
|
||||
|
||||
if ((semantics & gl_SemanticsAcquire) &&
|
||||
if ((semantics & gl_SemanticsAcquire) &&
|
||||
(callNode.getOp() == EOpAtomicStore || callNode.getOp() == EOpImageAtomicStore)) {
|
||||
error(loc, "gl_SemanticsAcquire must not be used with (image) atomic store",
|
||||
fnCandidate.getName().c_str(), "");
|
||||
}
|
||||
if ((semantics & gl_SemanticsRelease) &&
|
||||
if ((semantics & gl_SemanticsRelease) &&
|
||||
(callNode.getOp() == EOpAtomicLoad || callNode.getOp() == EOpImageAtomicLoad)) {
|
||||
error(loc, "gl_SemanticsRelease must not be used with (image) atomic load",
|
||||
fnCandidate.getName().c_str(), "");
|
||||
}
|
||||
if ((semantics & gl_SemanticsAcquireRelease) &&
|
||||
(callNode.getOp() == EOpAtomicStore || callNode.getOp() == EOpImageAtomicStore ||
|
||||
if ((semantics & gl_SemanticsAcquireRelease) &&
|
||||
(callNode.getOp() == EOpAtomicStore || callNode.getOp() == EOpImageAtomicStore ||
|
||||
callNode.getOp() == EOpAtomicLoad || callNode.getOp() == EOpImageAtomicLoad)) {
|
||||
error(loc, "gl_SemanticsAcquireRelease must not be used with (image) atomic load/store",
|
||||
fnCandidate.getName().c_str(), "");
|
||||
@@ -2462,7 +2473,7 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
|
||||
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)
|
||||
if (qualifier.storage != EvqShared && qualifier.storage != EvqBuffer && qualifier.storage != EvqtaskPayloadSharedEXT)
|
||||
error(loc,"Atomic memory function can only be used for shader storage block member or shared variable.",
|
||||
fnCandidate.getName().c_str(), "");
|
||||
|
||||
@@ -2560,7 +2571,7 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
|
||||
}
|
||||
|
||||
if (profile != EEsProfile && version < 450) {
|
||||
if ((*argp)[0]->getAsTyped()->getBasicType() != EbtFloat &&
|
||||
if ((*argp)[0]->getAsTyped()->getBasicType() != EbtFloat &&
|
||||
(*argp)[0]->getAsTyped()->getBasicType() != EbtDouble &&
|
||||
(*argp)[1]->getAsTyped()->getBasicType() != EbtFloat &&
|
||||
(*argp)[1]->getAsTyped()->getBasicType() != EbtDouble &&
|
||||
@@ -2995,6 +3006,10 @@ bool TParseContext::lValueErrorCheck(const TSourceLoc& loc, const char* op, TInt
|
||||
message = "can't modify EvqFragStencil if using early_fragment_tests";
|
||||
break;
|
||||
|
||||
case EvqtaskPayloadSharedEXT:
|
||||
if (language == EShLangMesh)
|
||||
message = "can't modify variable with storage qualifier taskPayloadSharedEXT in mesh shaders";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -3033,7 +3048,7 @@ void TParseContext::rValueErrorCheck(const TSourceLoc& loc, const char* op, TInt
|
||||
if (symNode && symNode->getQualifier().isExplicitInterpolation())
|
||||
error(loc, "can't read from explicitly-interpolated object: ", op, symNode->getName().c_str());
|
||||
|
||||
// local_size_{xyz} must be assigned or specialized before gl_WorkGroupSize can be assigned.
|
||||
// local_size_{xyz} must be assigned or specialized before gl_WorkGroupSize can be assigned.
|
||||
if(node->getQualifier().builtIn == EbvWorkGroupSize &&
|
||||
!(intermediate.isLocalSizeSet() || intermediate.isLocalSizeSpecialized()))
|
||||
error(loc, "can't read from gl_WorkGroupSize before a fixed workgroup size has been declared", op, "");
|
||||
@@ -3831,6 +3846,9 @@ void TParseContext::globalQualifierTypeCheck(const TSourceLoc& loc, const TQuali
|
||||
if (qualifier.isPatch() && qualifier.isInterpolation())
|
||||
error(loc, "cannot use interpolation qualifiers with patch", "patch", "");
|
||||
|
||||
if (qualifier.isTaskPayload() && publicType.basicType == EbtBlock)
|
||||
error(loc, "taskPayloadSharedEXT variables should not be declared as interface blocks", "taskPayloadSharedEXT", "");
|
||||
|
||||
if (qualifier.isTaskMemory() && publicType.basicType != EbtBlock)
|
||||
error(loc, "taskNV variables can be declared only as blocks", "taskNV", "");
|
||||
|
||||
@@ -3988,7 +4006,7 @@ void TParseContext::mergeQualifiers(const TSourceLoc& loc, TQualifier& dst, cons
|
||||
(src.workgroupcoherent && (dst.coherent || dst.devicecoherent || dst.queuefamilycoherent || dst.subgroupcoherent || dst.shadercallcoherent)) ||
|
||||
(src.subgroupcoherent && (dst.coherent || dst.devicecoherent || dst.queuefamilycoherent || dst.workgroupcoherent || dst.shadercallcoherent)) ||
|
||||
(src.shadercallcoherent && (dst.coherent || dst.devicecoherent || dst.queuefamilycoherent || dst.workgroupcoherent || dst.subgroupcoherent)))) {
|
||||
error(loc, "only one coherent/devicecoherent/queuefamilycoherent/workgroupcoherent/subgroupcoherent/shadercallcoherent qualifier allowed",
|
||||
error(loc, "only one coherent/devicecoherent/queuefamilycoherent/workgroupcoherent/subgroupcoherent/shadercallcoherent qualifier allowed",
|
||||
GetPrecisionQualifierString(src.precision), "");
|
||||
}
|
||||
#endif
|
||||
@@ -4346,10 +4364,10 @@ void TParseContext::arraySizesCheck(const TSourceLoc& loc, const TQualifier& qua
|
||||
extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader))
|
||||
return;
|
||||
break;
|
||||
case EShLangMeshNV:
|
||||
case EShLangMesh:
|
||||
if (qualifier.storage == EvqVaryingOut)
|
||||
if ((isEsProfile() && version >= 320) ||
|
||||
extensionTurnedOn(E_GL_NV_mesh_shader))
|
||||
extensionsTurnedOn(Num_AEP_mesh_shader, AEP_mesh_shader))
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
@@ -4633,6 +4651,9 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
|
||||
identifier == "gl_SampleMask" ||
|
||||
identifier == "gl_Layer" ||
|
||||
identifier == "gl_PrimitiveIndicesNV" ||
|
||||
identifier == "gl_PrimitivePointIndicesEXT" ||
|
||||
identifier == "gl_PrimitiveLineIndicesEXT" ||
|
||||
identifier == "gl_PrimitiveTriangleIndicesEXT" ||
|
||||
identifier == "gl_TexCoord") {
|
||||
|
||||
// Find the existing symbol, if any.
|
||||
@@ -4771,7 +4792,8 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
|
||||
profileRequires(loc, ~EEsProfile, 410, E_GL_ARB_separate_shader_objects, feature);
|
||||
|
||||
if (blockName != "gl_PerVertex" && blockName != "gl_PerFragment" &&
|
||||
blockName != "gl_MeshPerVertexNV" && blockName != "gl_MeshPerPrimitiveNV") {
|
||||
blockName != "gl_MeshPerVertexNV" && blockName != "gl_MeshPerPrimitiveNV" &&
|
||||
blockName != "gl_MeshPerVertexEXT" && blockName != "gl_MeshPerPrimitiveEXT") {
|
||||
error(loc, "cannot redeclare block: ", "block declaration", blockName.c_str());
|
||||
return;
|
||||
}
|
||||
@@ -5340,11 +5362,11 @@ void TParseContext::finish()
|
||||
if (!isEsProfile() && version < 430)
|
||||
requireExtensions(getCurrentLoc(), 1, &E_GL_ARB_compute_shader, "compute shaders");
|
||||
break;
|
||||
case EShLangTaskNV:
|
||||
requireExtensions(getCurrentLoc(), 1, &E_GL_NV_mesh_shader, "task shaders");
|
||||
case EShLangTask:
|
||||
requireExtensions(getCurrentLoc(), Num_AEP_mesh_shader, AEP_mesh_shader, "task shaders");
|
||||
break;
|
||||
case EShLangMeshNV:
|
||||
requireExtensions(getCurrentLoc(), 1, &E_GL_NV_mesh_shader, "mesh shaders");
|
||||
case EShLangMesh:
|
||||
requireExtensions(getCurrentLoc(), Num_AEP_mesh_shader, AEP_mesh_shader, "mesh shaders");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -5454,12 +5476,12 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
||||
intermediate.setUsePhysicalStorageBuffer();
|
||||
return;
|
||||
}
|
||||
if (language == EShLangGeometry || language == EShLangTessEvaluation || language == EShLangMeshNV) {
|
||||
if (language == EShLangGeometry || language == EShLangTessEvaluation || language == EShLangMesh) {
|
||||
if (id == TQualifier::getGeometryString(ElgTriangles)) {
|
||||
publicType.shaderQualifiers.geometry = ElgTriangles;
|
||||
return;
|
||||
}
|
||||
if (language == EShLangGeometry || language == EShLangMeshNV) {
|
||||
if (language == EShLangGeometry || language == EShLangMesh) {
|
||||
if (id == TQualifier::getGeometryString(ElgPoints)) {
|
||||
publicType.shaderQualifiers.geometry = ElgPoints;
|
||||
return;
|
||||
@@ -5737,7 +5759,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
||||
return;
|
||||
} else if (id == "location") {
|
||||
profileRequires(loc, EEsProfile, 300, nullptr, "location");
|
||||
const char* exts[2] = { E_GL_ARB_separate_shader_objects, E_GL_ARB_explicit_attrib_location };
|
||||
const char* exts[2] = { E_GL_ARB_separate_shader_objects, E_GL_ARB_explicit_attrib_location };
|
||||
// GL_ARB_explicit_uniform_location requires 330 or GL_ARB_explicit_attrib_location we do not need to add it here
|
||||
profileRequires(loc, ~EEsProfile, 330, 2, exts, "location");
|
||||
if ((unsigned int)value >= TQualifier::layoutLocationEnd)
|
||||
@@ -5947,9 +5969,9 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
||||
}
|
||||
break;
|
||||
|
||||
case EShLangMeshNV:
|
||||
case EShLangMesh:
|
||||
if (id == "max_vertices") {
|
||||
requireExtensions(loc, 1, &E_GL_NV_mesh_shader, "max_vertices");
|
||||
requireExtensions(loc, Num_AEP_mesh_shader, AEP_mesh_shader, "max_vertices");
|
||||
publicType.shaderQualifiers.vertices = value;
|
||||
if (value > resources.maxMeshOutputVerticesNV)
|
||||
error(loc, "too large, must be less than gl_MaxMeshOutputVerticesNV", "max_vertices", "");
|
||||
@@ -5958,7 +5980,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
||||
return;
|
||||
}
|
||||
if (id == "max_primitives") {
|
||||
requireExtensions(loc, 1, &E_GL_NV_mesh_shader, "max_primitives");
|
||||
requireExtensions(loc, Num_AEP_mesh_shader, AEP_mesh_shader, "max_primitives");
|
||||
publicType.shaderQualifiers.primitives = value;
|
||||
if (value > resources.maxMeshOutputPrimitivesNV)
|
||||
error(loc, "too large, must be less than gl_MaxMeshOutputPrimitivesNV", "max_primitives", "");
|
||||
@@ -5968,14 +5990,14 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
||||
}
|
||||
// Fall through
|
||||
|
||||
case EShLangTaskNV:
|
||||
case EShLangTask:
|
||||
// Fall through
|
||||
#endif
|
||||
case EShLangCompute:
|
||||
if (id.compare(0, 11, "local_size_") == 0) {
|
||||
#ifndef GLSLANG_WEB
|
||||
if (language == EShLangMeshNV || language == EShLangTaskNV) {
|
||||
requireExtensions(loc, 1, &E_GL_NV_mesh_shader, "gl_WorkGroupSize");
|
||||
if (language == EShLangMesh || language == EShLangTask) {
|
||||
requireExtensions(loc, Num_AEP_mesh_shader, AEP_mesh_shader, "gl_WorkGroupSize");
|
||||
} else {
|
||||
profileRequires(loc, EEsProfile, 310, 0, "gl_WorkGroupSize");
|
||||
profileRequires(loc, ~EEsProfile, 430, E_GL_ARB_compute_shader, "gl_WorkGroupSize");
|
||||
@@ -6251,6 +6273,9 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
|
||||
if (type.getBasicType() == EbtBlock)
|
||||
error(loc, "cannot apply to uniform or buffer block", "location", "");
|
||||
break;
|
||||
case EvqtaskPayloadSharedEXT:
|
||||
error(loc, "cannot apply to taskPayloadSharedEXT", "location", "");
|
||||
break;
|
||||
#ifndef GLSLANG_WEB
|
||||
case EvqPayload:
|
||||
case EvqPayloadIn:
|
||||
@@ -6612,7 +6637,7 @@ void TParseContext::checkNoShaderLayouts(const TSourceLoc& loc, const TShaderQua
|
||||
error(loc, message, "local_size id", "");
|
||||
}
|
||||
if (shaderQualifiers.vertices != TQualifier::layoutNotSet) {
|
||||
if (language == EShLangGeometry || language == EShLangMeshNV)
|
||||
if (language == EShLangGeometry || language == EShLangMesh)
|
||||
error(loc, message, "max_vertices", "");
|
||||
else if (language == EShLangTessControl)
|
||||
error(loc, message, "vertices", "");
|
||||
@@ -6624,7 +6649,7 @@ void TParseContext::checkNoShaderLayouts(const TSourceLoc& loc, const TShaderQua
|
||||
if (shaderQualifiers.postDepthCoverage)
|
||||
error(loc, message, "post_depth_coverage", "");
|
||||
if (shaderQualifiers.primitives != TQualifier::layoutNotSet) {
|
||||
if (language == EShLangMeshNV)
|
||||
if (language == EShLangMesh)
|
||||
error(loc, message, "max_primitives", "");
|
||||
else
|
||||
assert(0);
|
||||
@@ -7270,6 +7295,8 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
|
||||
requireInt8Arithmetic(loc, "qualifier", "(u)int8 types can only be in uniform block or buffer storage");
|
||||
}
|
||||
|
||||
if (type.getQualifier().storage == EvqtaskPayloadSharedEXT)
|
||||
intermediate.addTaskPayloadEXTCount();
|
||||
if (type.getQualifier().storage == EvqShared && type.containsCoopMat())
|
||||
error(loc, "qualifier", "Cooperative matrix types must not be used in shared memory", "");
|
||||
|
||||
@@ -8236,6 +8263,8 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
|
||||
memberQualifier.perViewNV = currentBlockQualifier.perViewNV;
|
||||
if (currentBlockQualifier.perTaskNV)
|
||||
memberQualifier.perTaskNV = currentBlockQualifier.perTaskNV;
|
||||
if (currentBlockQualifier.storage == EvqtaskPayloadSharedEXT)
|
||||
memberQualifier.storage = EvqtaskPayloadSharedEXT;
|
||||
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())
|
||||
@@ -8536,23 +8565,23 @@ void TParseContext::blockStageIoCheck(const TSourceLoc& loc, const TQualifier& q
|
||||
// It is a compile-time error to have an input block in a vertex shader or an output block in a fragment shader
|
||||
// "Compute shaders do not permit user-defined input variables..."
|
||||
requireStage(loc, (EShLanguageMask)(EShLangTessControlMask|EShLangTessEvaluationMask|EShLangGeometryMask|
|
||||
EShLangFragmentMask|EShLangMeshNVMask), "input block");
|
||||
EShLangFragmentMask|EShLangMeshMask), "input block");
|
||||
if (language == EShLangFragment) {
|
||||
profileRequires(loc, EEsProfile, 320, Num_AEP_shader_io_blocks, AEP_shader_io_blocks, "fragment input block");
|
||||
} else if (language == EShLangMeshNV && ! qualifier.isTaskMemory()) {
|
||||
} else if (language == EShLangMesh && ! qualifier.isTaskMemory()) {
|
||||
error(loc, "input blocks cannot be used in a mesh shader", "out", "");
|
||||
}
|
||||
break;
|
||||
case EvqVaryingOut:
|
||||
profileRequires(loc, ~EEsProfile, 150, E_GL_ARB_separate_shader_objects, "output block");
|
||||
requireStage(loc, (EShLanguageMask)(EShLangVertexMask|EShLangTessControlMask|EShLangTessEvaluationMask|
|
||||
EShLangGeometryMask|EShLangMeshNVMask|EShLangTaskNVMask), "output block");
|
||||
EShLangGeometryMask|EShLangMeshMask|EShLangTaskMask), "output block");
|
||||
// ES 310 can have a block before shader_io is turned on, so skip this test for built-ins
|
||||
if (language == EShLangVertex && ! parsingBuiltins) {
|
||||
profileRequires(loc, EEsProfile, 320, Num_AEP_shader_io_blocks, AEP_shader_io_blocks, "vertex output block");
|
||||
} else if (language == EShLangMeshNV && qualifier.isTaskMemory()) {
|
||||
} else if (language == EShLangMesh && qualifier.isTaskMemory()) {
|
||||
error(loc, "can only use on input blocks in mesh shader", "taskNV", "");
|
||||
} else if (language == EShLangTaskNV && ! qualifier.isTaskMemory()) {
|
||||
} else if (language == EShLangTask && ! qualifier.isTaskMemory()) {
|
||||
error(loc, "output blocks cannot be used in a task shader", "out", "");
|
||||
}
|
||||
break;
|
||||
@@ -8966,7 +8995,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
|
||||
{
|
||||
#ifndef GLSLANG_WEB
|
||||
if (publicType.shaderQualifiers.vertices != TQualifier::layoutNotSet) {
|
||||
assert(language == EShLangTessControl || language == EShLangGeometry || language == EShLangMeshNV);
|
||||
assert(language == EShLangTessControl || language == EShLangGeometry || language == EShLangMesh);
|
||||
const char* id = (language == EShLangTessControl) ? "vertices" : "max_vertices";
|
||||
|
||||
if (publicType.qualifier.storage != EvqVaryingOut)
|
||||
@@ -8978,7 +9007,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
|
||||
checkIoArraysConsistency(loc);
|
||||
}
|
||||
if (publicType.shaderQualifiers.primitives != TQualifier::layoutNotSet) {
|
||||
assert(language == EShLangMeshNV);
|
||||
assert(language == EShLangMesh);
|
||||
const char* id = "max_primitives";
|
||||
|
||||
if (publicType.qualifier.storage != EvqVaryingOut)
|
||||
@@ -9002,7 +9031,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
|
||||
case ElgTrianglesAdjacency:
|
||||
case ElgQuads:
|
||||
case ElgIsolines:
|
||||
if (language == EShLangMeshNV) {
|
||||
if (language == EShLangMesh) {
|
||||
error(loc, "cannot apply to input", TQualifier::getGeometryString(publicType.shaderQualifiers.geometry), "");
|
||||
break;
|
||||
}
|
||||
@@ -9019,7 +9048,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
|
||||
switch (publicType.shaderQualifiers.geometry) {
|
||||
case ElgLines:
|
||||
case ElgTriangles:
|
||||
if (language != EShLangMeshNV) {
|
||||
if (language != EShLangMesh) {
|
||||
error(loc, "cannot apply to 'out'", TQualifier::getGeometryString(publicType.shaderQualifiers.geometry), "");
|
||||
break;
|
||||
}
|
||||
@@ -9075,24 +9104,56 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
|
||||
error(loc, "too large; see gl_MaxComputeWorkGroupSize", "local_size", "");
|
||||
}
|
||||
#ifndef GLSLANG_WEB
|
||||
else if (language == EShLangMeshNV) {
|
||||
else if (language == EShLangMesh) {
|
||||
switch (i) {
|
||||
case 0: max = resources.maxMeshWorkGroupSizeX_NV; break;
|
||||
case 1: max = resources.maxMeshWorkGroupSizeY_NV; break;
|
||||
case 2: max = resources.maxMeshWorkGroupSizeZ_NV; break;
|
||||
case 0:
|
||||
max = extensionTurnedOn(E_GL_EXT_mesh_shader) ?
|
||||
resources.maxMeshWorkGroupSizeX_EXT :
|
||||
resources.maxMeshWorkGroupSizeX_NV;
|
||||
break;
|
||||
case 1:
|
||||
max = extensionTurnedOn(E_GL_EXT_mesh_shader) ?
|
||||
resources.maxMeshWorkGroupSizeY_EXT :
|
||||
resources.maxMeshWorkGroupSizeY_NV ;
|
||||
break;
|
||||
case 2:
|
||||
max = extensionTurnedOn(E_GL_EXT_mesh_shader) ?
|
||||
resources.maxMeshWorkGroupSizeZ_EXT :
|
||||
resources.maxMeshWorkGroupSizeZ_NV ;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (intermediate.getLocalSize(i) > (unsigned int)max)
|
||||
error(loc, "too large; see gl_MaxMeshWorkGroupSizeNV", "local_size", "");
|
||||
} else if (language == EShLangTaskNV) {
|
||||
if (intermediate.getLocalSize(i) > (unsigned int)max) {
|
||||
TString maxsErrtring = "too large, see ";
|
||||
maxsErrtring.append(extensionTurnedOn(E_GL_EXT_mesh_shader) ?
|
||||
"gl_MaxMeshWorkGroupSizeEXT" : "gl_MaxMeshWorkGroupSizeNV");
|
||||
error(loc, maxsErrtring.c_str(), "local_size", "");
|
||||
}
|
||||
} else if (language == EShLangTask) {
|
||||
switch (i) {
|
||||
case 0: max = resources.maxTaskWorkGroupSizeX_NV; break;
|
||||
case 1: max = resources.maxTaskWorkGroupSizeY_NV; break;
|
||||
case 2: max = resources.maxTaskWorkGroupSizeZ_NV; break;
|
||||
case 0:
|
||||
max = extensionTurnedOn(E_GL_EXT_mesh_shader) ?
|
||||
resources.maxTaskWorkGroupSizeX_EXT :
|
||||
resources.maxTaskWorkGroupSizeX_NV;
|
||||
break;
|
||||
case 1:
|
||||
max = extensionTurnedOn(E_GL_EXT_mesh_shader) ?
|
||||
resources.maxTaskWorkGroupSizeY_EXT:
|
||||
resources.maxTaskWorkGroupSizeY_NV;
|
||||
break;
|
||||
case 2:
|
||||
max = extensionTurnedOn(E_GL_EXT_mesh_shader) ?
|
||||
resources.maxTaskWorkGroupSizeZ_EXT:
|
||||
resources.maxTaskWorkGroupSizeZ_NV;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (intermediate.getLocalSize(i) > (unsigned int)max)
|
||||
error(loc, "too large; see gl_MaxTaskWorkGroupSizeNV", "local_size", "");
|
||||
if (intermediate.getLocalSize(i) > (unsigned int)max) {
|
||||
TString maxsErrtring = "too large, see ";
|
||||
maxsErrtring.append(extensionTurnedOn(E_GL_EXT_mesh_shader) ?
|
||||
"gl_MaxTaskWorkGroupSizeEXT" : "gl_MaxTaskWorkGroupSizeNV");
|
||||
error(loc, maxsErrtring.c_str(), "local_size", "");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
@@ -9181,7 +9242,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
|
||||
error(loc, "can only apply to 'in'", "derivative_group_linearNV", "");
|
||||
}
|
||||
// Check mesh out array sizes, once all the necessary out qualifiers are defined.
|
||||
if ((language == EShLangMeshNV) &&
|
||||
if ((language == EShLangMesh) &&
|
||||
(intermediate.getVertices() != TQualifier::layoutNotSet) &&
|
||||
(intermediate.getPrimitives() != TQualifier::layoutNotSet) &&
|
||||
(intermediate.getOutputPrimitive() != ElgNone))
|
||||
@@ -9198,7 +9259,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
|
||||
// Exit early as further checks are not valid
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
const TQualifier& qualifier = publicType.qualifier;
|
||||
|
||||
if (qualifier.isAuxiliary() ||
|
||||
@@ -9396,4 +9457,3 @@ const TTypeList* TParseContext::recordStructCopy(TStructRecord& record, const TT
|
||||
}
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
|
||||
@@ -758,6 +758,8 @@ void TScanContext::fillInKeywordMap()
|
||||
(*KeywordMap)["perprimitiveNV"] = PERPRIMITIVENV;
|
||||
(*KeywordMap)["perviewNV"] = PERVIEWNV;
|
||||
(*KeywordMap)["taskNV"] = PERTASKNV;
|
||||
(*KeywordMap)["perprimitiveEXT"] = PERPRIMITIVEEXT;
|
||||
(*KeywordMap)["taskPayloadSharedEXT"] = TASKPAYLOADWORKGROUPEXT;
|
||||
|
||||
(*KeywordMap)["fcoopmatNV"] = FCOOPMATNV;
|
||||
(*KeywordMap)["icoopmatNV"] = ICOOPMATNV;
|
||||
@@ -1740,12 +1742,18 @@ int TScanContext::tokenizeIdentifier()
|
||||
case PERPRIMITIVENV:
|
||||
case PERVIEWNV:
|
||||
case PERTASKNV:
|
||||
if ((!parseContext.isEsProfile() && parseContext.version >= 450) ||
|
||||
(parseContext.isEsProfile() && parseContext.version >= 320) ||
|
||||
if (parseContext.symbolTable.atBuiltInLevel() ||
|
||||
parseContext.extensionTurnedOn(E_GL_NV_mesh_shader))
|
||||
return keyword;
|
||||
return identifierOrType();
|
||||
|
||||
case PERPRIMITIVEEXT:
|
||||
case TASKPAYLOADWORKGROUPEXT:
|
||||
if (parseContext.symbolTable.atBuiltInLevel() ||
|
||||
parseContext.extensionTurnedOn(E_GL_EXT_mesh_shader))
|
||||
return keyword;
|
||||
return identifierOrType();
|
||||
|
||||
case FCOOPMATNV:
|
||||
afterType = true;
|
||||
if (parseContext.symbolTable.atBuiltInLevel() ||
|
||||
|
||||
@@ -391,13 +391,13 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
|
||||
// check for mesh
|
||||
if ((profile != EEsProfile && version >= 450) ||
|
||||
(profile == EEsProfile && version >= 320))
|
||||
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMeshNV, source,
|
||||
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMesh, source,
|
||||
infoSink, commonTable, symbolTables);
|
||||
|
||||
// check for task
|
||||
if ((profile != EEsProfile && version >= 450) ||
|
||||
(profile == EEsProfile && version >= 320))
|
||||
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source,
|
||||
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTask, source,
|
||||
infoSink, commonTable, symbolTables);
|
||||
#endif // !GLSLANG_ANGLE
|
||||
#endif // !GLSLANG_WEB
|
||||
@@ -650,8 +650,8 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
|
||||
version = 460;
|
||||
}
|
||||
break;
|
||||
case EShLangMeshNV:
|
||||
case EShLangTaskNV:
|
||||
case EShLangMesh:
|
||||
case EShLangTask:
|
||||
if ((profile == EEsProfile && version < 320) ||
|
||||
(profile != EEsProfile && version < 450)) {
|
||||
correct = false;
|
||||
@@ -1839,6 +1839,7 @@ void TShader::setOverrideVersion(int version)
|
||||
overrideVersion = version;
|
||||
}
|
||||
|
||||
void TShader::setDebugInfo(bool debugInfo) { intermediate->setDebugInfo(debugInfo); }
|
||||
void TShader::setInvertY(bool invert) { intermediate->setInvertY(invert); }
|
||||
void TShader::setDxPositionW(bool invert) { intermediate->setDxPositionW(invert); }
|
||||
void TShader::setEnhancedMsgs() { intermediate->setEnhancedMsgs(); }
|
||||
|
||||
@@ -166,7 +166,8 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
} extensionData;
|
||||
|
||||
const extensionData exts[] = { {E_GL_EXT_ray_tracing, EShTargetSpv_1_4},
|
||||
{E_GL_NV_ray_tracing_motion_blur, EShTargetSpv_1_4}
|
||||
{E_GL_NV_ray_tracing_motion_blur, EShTargetSpv_1_4},
|
||||
{E_GL_EXT_mesh_shader, EShTargetSpv_1_4}
|
||||
};
|
||||
|
||||
for (size_t ii = 0; ii < sizeof(exts) / sizeof(exts[0]); ii++) {
|
||||
@@ -345,6 +346,7 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
extensionBehavior[E_GL_EXT_terminate_invocation] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_shared_memory_block] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_spirv_intrinsics] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_mesh_shader] = EBhDisable;
|
||||
|
||||
// OVR extensions
|
||||
extensionBehavior[E_GL_OVR_multiview] = EBhDisable;
|
||||
@@ -511,6 +513,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
"#define GL_EXT_ray_flags_primitive_culling 1\n"
|
||||
"#define GL_EXT_ray_cull_mask 1\n"
|
||||
"#define GL_EXT_spirv_intrinsics 1\n"
|
||||
"#define GL_EXT_mesh_shader 1\n"
|
||||
|
||||
"#define GL_AMD_shader_ballot 1\n"
|
||||
"#define GL_AMD_shader_trinary_minmax 1\n"
|
||||
@@ -641,8 +644,8 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
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;
|
||||
case EShLangTask: preamble += "#define GL_TASK_SHADER_NV 1 \n"; break;
|
||||
case EShLangMesh: preamble += "#define GL_MESH_SHADER_NV 1 \n"; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -668,8 +671,8 @@ const char* StageName(EShLanguage stage)
|
||||
case EShLangClosestHit: return "closest-hit";
|
||||
case EShLangMiss: return "miss";
|
||||
case EShLangCallable: return "callable";
|
||||
case EShLangMeshNV: return "mesh";
|
||||
case EShLangTaskNV: return "task";
|
||||
case EShLangMesh: return "mesh";
|
||||
case EShLangTask: return "task";
|
||||
#endif
|
||||
default: return "unknown stage";
|
||||
}
|
||||
@@ -1060,10 +1063,22 @@ void TParseVersions::checkExtensionStage(const TSourceLoc& loc, const char * con
|
||||
{
|
||||
// GL_NV_mesh_shader extension is only allowed in task/mesh shaders
|
||||
if (strcmp(extension, "GL_NV_mesh_shader") == 0) {
|
||||
requireStage(loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask | EShLangFragmentMask),
|
||||
requireStage(loc, (EShLanguageMask)(EShLangTaskMask | EShLangMeshMask | EShLangFragmentMask),
|
||||
"#extension GL_NV_mesh_shader");
|
||||
profileRequires(loc, ECoreProfile, 450, 0, "#extension GL_NV_mesh_shader");
|
||||
profileRequires(loc, EEsProfile, 320, 0, "#extension GL_NV_mesh_shader");
|
||||
if (extensionTurnedOn(E_GL_EXT_mesh_shader)) {
|
||||
error(loc, "GL_EXT_mesh_shader is already turned on, and not allowed with", "#extension", extension);
|
||||
}
|
||||
}
|
||||
else if (strcmp(extension, "GL_EXT_mesh_shader") == 0) {
|
||||
requireStage(loc, (EShLanguageMask)(EShLangTaskMask | EShLangMeshMask | EShLangFragmentMask),
|
||||
"#extension GL_EXT_mesh_shader");
|
||||
profileRequires(loc, ECoreProfile, 450, 0, "#extension GL_EXT_mesh_shader");
|
||||
profileRequires(loc, EEsProfile, 320, 0, "#extension GL_EXT_mesh_shader");
|
||||
if (extensionTurnedOn(E_GL_NV_mesh_shader)) {
|
||||
error(loc, "GL_NV_mesh_shader is already turned on, and not allowed with", "#extension", extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -211,6 +211,7 @@ const char* const E_GL_EXT_shared_memory_block = "GL_EXT_shared_mem
|
||||
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";
|
||||
const char* const E_GL_EXT_fragment_shader_barycentric = "GL_EXT_fragment_shader_barycentric";
|
||||
const char* const E_GL_EXT_mesh_shader = "GL_EXT_mesh_shader";
|
||||
|
||||
// Arrays of extensions for the above viewportEXTs duplications
|
||||
|
||||
@@ -288,7 +289,7 @@ const char* const E_GL_EXT_tessellation_shader = "GL_EXT_tessel
|
||||
const char* const E_GL_EXT_tessellation_point_size = "GL_EXT_tessellation_point_size";
|
||||
const char* const E_GL_EXT_texture_buffer = "GL_EXT_texture_buffer";
|
||||
const char* const E_GL_EXT_texture_cube_map_array = "GL_EXT_texture_cube_map_array";
|
||||
const char* const E_GL_EXT_shader_integer_mix = "GL_EXT_shader_integer_mix";
|
||||
const char* const E_GL_EXT_shader_integer_mix = "GL_EXT_shader_integer_mix";
|
||||
|
||||
// OES matching AEP
|
||||
const char* const E_GL_OES_geometry_shader = "GL_OES_geometry_shader";
|
||||
@@ -349,6 +350,9 @@ const int Num_AEP_texture_buffer = sizeof(AEP_texture_buffer)/sizeof(AEP_texture
|
||||
const char* const AEP_texture_cube_map_array[] = { E_GL_EXT_texture_cube_map_array, E_GL_OES_texture_cube_map_array };
|
||||
const int Num_AEP_texture_cube_map_array = sizeof(AEP_texture_cube_map_array)/sizeof(AEP_texture_cube_map_array[0]);
|
||||
|
||||
const char* const AEP_mesh_shader[] = { E_GL_NV_mesh_shader, E_GL_EXT_mesh_shader };
|
||||
const int Num_AEP_mesh_shader = sizeof(AEP_mesh_shader)/sizeof(AEP_mesh_shader[0]);
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
#endif // _VERSIONS_INCLUDED_
|
||||
|
||||
@@ -315,7 +315,7 @@ GLSLANG_WEB_EXCLUDE_ON
|
||||
%token <lex> PATCH SAMPLE NONUNIFORM
|
||||
%token <lex> COHERENT VOLATILE RESTRICT READONLY WRITEONLY DEVICECOHERENT QUEUEFAMILYCOHERENT WORKGROUPCOHERENT
|
||||
%token <lex> SUBGROUPCOHERENT NONPRIVATE SHADERCALLCOHERENT
|
||||
%token <lex> NOPERSPECTIVE EXPLICITINTERPAMD PERVERTEXEXT PERVERTEXNV PERPRIMITIVENV PERVIEWNV PERTASKNV
|
||||
%token <lex> NOPERSPECTIVE EXPLICITINTERPAMD PERVERTEXEXT PERVERTEXNV PERPRIMITIVENV PERVIEWNV PERTASKNV PERPRIMITIVEEXT TASKPAYLOADWORKGROUPEXT
|
||||
%token <lex> PRECISE
|
||||
GLSLANG_WEB_EXCLUDE_OFF
|
||||
|
||||
@@ -1301,24 +1301,34 @@ GLSLANG_WEB_EXCLUDE_ON
|
||||
| PERPRIMITIVENV {
|
||||
// No need for profile version or extension check. Shader stage already checks both.
|
||||
parseContext.globalCheck($1.loc, "perprimitiveNV");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshNVMask), "perprimitiveNV");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshMask), "perprimitiveNV");
|
||||
// Fragment shader stage doesn't check for extension. So we explicitly add below extension check.
|
||||
if (parseContext.language == EShLangFragment)
|
||||
parseContext.requireExtensions($1.loc, 1, &E_GL_NV_mesh_shader, "perprimitiveNV");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.perPrimitiveNV = true;
|
||||
}
|
||||
| PERPRIMITIVEEXT {
|
||||
// No need for profile version or extension check. Shader stage already checks both.
|
||||
parseContext.globalCheck($1.loc, "perprimitiveEXT");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshMask), "perprimitiveEXT");
|
||||
// Fragment shader stage doesn't check for extension. So we explicitly add below extension check.
|
||||
if (parseContext.language == EShLangFragment)
|
||||
parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_mesh_shader, "perprimitiveEXT");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.perPrimitiveNV = true;
|
||||
}
|
||||
| PERVIEWNV {
|
||||
// No need for profile version or extension check. Shader stage already checks both.
|
||||
parseContext.globalCheck($1.loc, "perviewNV");
|
||||
parseContext.requireStage($1.loc, EShLangMeshNV, "perviewNV");
|
||||
parseContext.requireStage($1.loc, EShLangMesh, "perviewNV");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.perViewNV = true;
|
||||
}
|
||||
| PERTASKNV {
|
||||
// No need for profile version or extension check. Shader stage already checks both.
|
||||
parseContext.globalCheck($1.loc, "taskNV");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask), "taskNV");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskMask | EShLangMeshMask), "taskNV");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.perTaskNV = true;
|
||||
}
|
||||
@@ -1469,7 +1479,7 @@ storage_qualifier
|
||||
parseContext.globalCheck($1.loc, "shared");
|
||||
parseContext.profileRequires($1.loc, ECoreProfile | ECompatibilityProfile, 430, E_GL_ARB_compute_shader, "shared");
|
||||
parseContext.profileRequires($1.loc, EEsProfile, 310, 0, "shared");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangComputeMask | EShLangMeshNVMask | EShLangTaskNVMask), "shared");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangComputeMask | EShLangMeshMask | EShLangTaskMask), "shared");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.storage = EvqShared;
|
||||
}
|
||||
@@ -1656,6 +1666,13 @@ GLSLANG_WEB_EXCLUDE_ON
|
||||
parseContext.unimplemented($1.loc, "subroutine");
|
||||
$$.init($1.loc);
|
||||
}
|
||||
| TASKPAYLOADWORKGROUPEXT {
|
||||
// No need for profile version or extension check. Shader stage already checks both.
|
||||
parseContext.globalCheck($1.loc, "taskPayloadSharedEXT");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskMask | EShLangMeshMask), "taskPayloadSharedEXT ");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.storage = EvqtaskPayloadSharedEXT;
|
||||
}
|
||||
GLSLANG_WEB_EXCLUDE_OFF
|
||||
;
|
||||
|
||||
@@ -3726,7 +3743,7 @@ compound_statement
|
||||
}
|
||||
RIGHT_BRACE {
|
||||
if ($3 && $3->getAsAggregate())
|
||||
$3->getAsAggregate()->setOperator(EOpSequence);
|
||||
$3->getAsAggregate()->setOperator(parseContext.intermediate.getDebugInfo() ? EOpScope : EOpSequence);
|
||||
$$ = $3;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -151,7 +151,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
|
||||
|
||||
%parse-param {glslang::TParseContext* pParseContext}
|
||||
%lex-param {parseContext}
|
||||
%pure-parser // enable thread safety
|
||||
%define api.pure // enable thread safety
|
||||
%expect 1 // One shift reduce conflict because of if | else
|
||||
|
||||
%token <lex> CONST BOOL INT UINT FLOAT
|
||||
@@ -315,7 +315,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
|
||||
%token <lex> PATCH SAMPLE NONUNIFORM
|
||||
%token <lex> COHERENT VOLATILE RESTRICT READONLY WRITEONLY DEVICECOHERENT QUEUEFAMILYCOHERENT WORKGROUPCOHERENT
|
||||
%token <lex> SUBGROUPCOHERENT NONPRIVATE SHADERCALLCOHERENT
|
||||
%token <lex> NOPERSPECTIVE EXPLICITINTERPAMD PERVERTEXEXT PERVERTEXNV PERPRIMITIVENV PERVIEWNV PERTASKNV
|
||||
%token <lex> NOPERSPECTIVE EXPLICITINTERPAMD PERVERTEXEXT PERVERTEXNV PERPRIMITIVENV PERVIEWNV PERTASKNV PERPRIMITIVEEXT TASKPAYLOADWORKGROUPEXT
|
||||
%token <lex> PRECISE
|
||||
|
||||
|
||||
@@ -1301,24 +1301,34 @@ interpolation_qualifier
|
||||
| PERPRIMITIVENV {
|
||||
// No need for profile version or extension check. Shader stage already checks both.
|
||||
parseContext.globalCheck($1.loc, "perprimitiveNV");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshNVMask), "perprimitiveNV");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshMask), "perprimitiveNV");
|
||||
// Fragment shader stage doesn't check for extension. So we explicitly add below extension check.
|
||||
if (parseContext.language == EShLangFragment)
|
||||
parseContext.requireExtensions($1.loc, 1, &E_GL_NV_mesh_shader, "perprimitiveNV");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.perPrimitiveNV = true;
|
||||
}
|
||||
| PERPRIMITIVEEXT {
|
||||
// No need for profile version or extension check. Shader stage already checks both.
|
||||
parseContext.globalCheck($1.loc, "perprimitiveEXT");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshMask), "perprimitiveEXT");
|
||||
// Fragment shader stage doesn't check for extension. So we explicitly add below extension check.
|
||||
if (parseContext.language == EShLangFragment)
|
||||
parseContext.requireExtensions($1.loc, 1, &E_GL_EXT_mesh_shader, "perprimitiveEXT");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.perPrimitiveNV = true;
|
||||
}
|
||||
| PERVIEWNV {
|
||||
// No need for profile version or extension check. Shader stage already checks both.
|
||||
parseContext.globalCheck($1.loc, "perviewNV");
|
||||
parseContext.requireStage($1.loc, EShLangMeshNV, "perviewNV");
|
||||
parseContext.requireStage($1.loc, EShLangMesh, "perviewNV");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.perViewNV = true;
|
||||
}
|
||||
| PERTASKNV {
|
||||
// No need for profile version or extension check. Shader stage already checks both.
|
||||
parseContext.globalCheck($1.loc, "taskNV");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask), "taskNV");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskMask | EShLangMeshMask), "taskNV");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.perTaskNV = true;
|
||||
}
|
||||
@@ -1469,7 +1479,7 @@ storage_qualifier
|
||||
parseContext.globalCheck($1.loc, "shared");
|
||||
parseContext.profileRequires($1.loc, ECoreProfile | ECompatibilityProfile, 430, E_GL_ARB_compute_shader, "shared");
|
||||
parseContext.profileRequires($1.loc, EEsProfile, 310, 0, "shared");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangComputeMask | EShLangMeshNVMask | EShLangTaskNVMask), "shared");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangComputeMask | EShLangMeshMask | EShLangTaskMask), "shared");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.storage = EvqShared;
|
||||
}
|
||||
@@ -1656,6 +1666,13 @@ storage_qualifier
|
||||
parseContext.unimplemented($1.loc, "subroutine");
|
||||
$$.init($1.loc);
|
||||
}
|
||||
| TASKPAYLOADWORKGROUPEXT {
|
||||
// No need for profile version or extension check. Shader stage already checks both.
|
||||
parseContext.globalCheck($1.loc, "taskPayloadSharedEXT");
|
||||
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskMask | EShLangMeshMask), "taskPayloadSharedEXT ");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.storage = EvqtaskPayloadSharedEXT;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@@ -3726,7 +3743,7 @@ compound_statement
|
||||
}
|
||||
RIGHT_BRACE {
|
||||
if ($3 && $3->getAsAggregate())
|
||||
$3->getAsAggregate()->setOperator(EOpSequence);
|
||||
$3->getAsAggregate()->setOperator(parseContext.intermediate.getDebugInfo() ? EOpScope : EOpSequence);
|
||||
$$ = $3;
|
||||
}
|
||||
;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -506,7 +506,9 @@ extern int yydebug;
|
||||
PERPRIMITIVENV = 707, /* PERPRIMITIVENV */
|
||||
PERVIEWNV = 708, /* PERVIEWNV */
|
||||
PERTASKNV = 709, /* PERTASKNV */
|
||||
PRECISE = 710 /* PRECISE */
|
||||
PERPRIMITIVEEXT = 710, /* PERPRIMITIVEEXT */
|
||||
TASKPAYLOADWORKGROUPEXT = 711, /* TASKPAYLOADWORKGROUPEXT */
|
||||
PRECISE = 712 /* PRECISE */
|
||||
};
|
||||
typedef enum yytokentype yytoken_kind_t;
|
||||
#endif
|
||||
@@ -554,7 +556,7 @@ union YYSTYPE
|
||||
glslang::TArraySizes* typeParameters;
|
||||
} interm;
|
||||
|
||||
#line 558 "MachineIndependent/glslang_tab.cpp.h"
|
||||
#line 560 "MachineIndependent/glslang_tab.cpp.h"
|
||||
|
||||
};
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
|
||||
@@ -665,6 +665,8 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
|
||||
|
||||
case EOpConstructReference: out.debug << "Construct reference type"; break;
|
||||
|
||||
case EOpDeclare: out.debug << "Declare"; break;
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
case EOpSpirvInst: out.debug << "spirv_instruction"; break;
|
||||
#endif
|
||||
@@ -692,6 +694,7 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
|
||||
|
||||
switch (node->getOp()) {
|
||||
case EOpSequence: out.debug << "Sequence\n"; return true;
|
||||
case EOpScope: out.debug << "Scope\n"; return true;
|
||||
case EOpLinkerObjects: out.debug << "Linker Objects\n"; return true;
|
||||
case EOpComma: out.debug << "Comma"; break;
|
||||
case EOpFunction: out.debug << "Function Definition: " << node->getName(); break;
|
||||
@@ -1068,6 +1071,8 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
|
||||
case EOpExecuteCallableNV: out.debug << "executeCallableNV"; break;
|
||||
case EOpExecuteCallableKHR: out.debug << "executeCallableKHR"; break;
|
||||
case EOpWritePackedPrimitiveIndices4x8NV: out.debug << "writePackedPrimitiveIndices4x8NV"; break;
|
||||
case EOpEmitMeshTasksEXT: out.debug << "EmitMeshTasksEXT"; break;
|
||||
case EOpSetMeshOutputsEXT: out.debug << "SetMeshOutputsEXT"; break;
|
||||
|
||||
case EOpRayQueryInitialize: out.debug << "rayQueryInitializeEXT"; break;
|
||||
case EOpRayQueryTerminate: out.debug << "rayQueryTerminateEXT"; break;
|
||||
@@ -1107,7 +1112,7 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
|
||||
default: out.debug.message(EPrefixError, "Bad aggregation op");
|
||||
}
|
||||
|
||||
if (node->getOp() != EOpSequence && node->getOp() != EOpParameters)
|
||||
if (node->getOp() != EOpSequence && node->getOp() != EOpScope && node->getOp() != EOpParameters)
|
||||
out.debug << " (" << node->getCompleteString() << ")";
|
||||
|
||||
out.debug << "\n";
|
||||
@@ -1522,12 +1527,12 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
|
||||
infoSink.debug << "interlock ordering = " << TQualifier::getInterlockOrderingString(interlockOrdering) << "\n";
|
||||
break;
|
||||
|
||||
case EShLangMeshNV:
|
||||
case EShLangMesh:
|
||||
infoSink.debug << "max_vertices = " << vertices << "\n";
|
||||
infoSink.debug << "max_primitives = " << primitives << "\n";
|
||||
infoSink.debug << "output primitive = " << TQualifier::getGeometryString(outputPrimitive) << "\n";
|
||||
// Fall through
|
||||
case EShLangTaskNV:
|
||||
case EShLangTask:
|
||||
// Fall through
|
||||
case EShLangCompute:
|
||||
infoSink.debug << "local_size = (" << localSize[0] << ", " << localSize[1] << ", " << localSize[2] << ")\n";
|
||||
|
||||
@@ -120,7 +120,7 @@ void TIntermediate::mergeUniformObjects(TInfoSink& infoSink, TIntermediate& unit
|
||||
}
|
||||
|
||||
//
|
||||
// do error checking on the shader boundary in / out vars
|
||||
// do error checking on the shader boundary in / out vars
|
||||
//
|
||||
void TIntermediate::checkStageIO(TInfoSink& infoSink, TIntermediate& unit) {
|
||||
if (unit.treeRoot == nullptr || treeRoot == nullptr)
|
||||
@@ -212,7 +212,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
|
||||
if (vertices == TQualifier::layoutNotSet)
|
||||
vertices = unit.vertices;
|
||||
else if (unit.vertices != TQualifier::layoutNotSet && vertices != unit.vertices) {
|
||||
if (language == EShLangGeometry || language == EShLangMeshNV)
|
||||
if (language == EShLangGeometry || language == EShLangMesh)
|
||||
error(infoSink, "Contradictory layout max_vertices values");
|
||||
else if (language == EShLangTessControl)
|
||||
error(infoSink, "Contradictory layout vertices values");
|
||||
@@ -222,7 +222,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
|
||||
if (primitives == TQualifier::layoutNotSet)
|
||||
primitives = unit.primitives;
|
||||
else if (primitives != unit.primitives) {
|
||||
if (language == EShLangMeshNV)
|
||||
if (language == EShLangMesh)
|
||||
error(infoSink, "Contradictory layout max_primitives values");
|
||||
else
|
||||
assert(0);
|
||||
@@ -319,6 +319,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
|
||||
MERGE_TRUE(autoMapLocations);
|
||||
MERGE_TRUE(invertY);
|
||||
MERGE_TRUE(dxPositionW);
|
||||
MERGE_TRUE(debugInfo);
|
||||
MERGE_TRUE(flattenUniformArrays);
|
||||
MERGE_TRUE(useUnknownFormat);
|
||||
MERGE_TRUE(hlslOffsets);
|
||||
@@ -637,18 +638,18 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
|
||||
class TMergeBlockTraverser : public TIntermTraverser {
|
||||
public:
|
||||
TMergeBlockTraverser(const TIntermSymbol* newSym)
|
||||
: newSymbol(newSym), unitType(nullptr), unit(nullptr), memberIndexUpdates(nullptr)
|
||||
: newSymbol(newSym), newType(nullptr), unit(nullptr), memberIndexUpdates(nullptr)
|
||||
{
|
||||
}
|
||||
TMergeBlockTraverser(const TIntermSymbol* newSym, const glslang::TType* unitType, glslang::TIntermediate* unit,
|
||||
const std::map<unsigned int, unsigned int>* memberIdxUpdates)
|
||||
: TIntermTraverser(false, true), newSymbol(newSym), unitType(unitType), unit(unit), memberIndexUpdates(memberIdxUpdates)
|
||||
: TIntermTraverser(false, true), newSymbol(newSym), newType(unitType), unit(unit), memberIndexUpdates(memberIdxUpdates)
|
||||
{
|
||||
}
|
||||
virtual ~TMergeBlockTraverser() {}
|
||||
|
||||
const TIntermSymbol* newSymbol;
|
||||
const glslang::TType* unitType; // copy of original type
|
||||
const glslang::TType* newType; // shallow copy of the new type
|
||||
glslang::TIntermediate* unit; // intermediate that is being updated
|
||||
const std::map<unsigned int, unsigned int>* memberIndexUpdates;
|
||||
|
||||
@@ -664,10 +665,10 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
|
||||
|
||||
virtual bool visitBinary(TVisit, glslang::TIntermBinary* node)
|
||||
{
|
||||
if (!unit || !unitType || !memberIndexUpdates || memberIndexUpdates->empty())
|
||||
if (!unit || !newType || !memberIndexUpdates || memberIndexUpdates->empty())
|
||||
return true;
|
||||
|
||||
if (node->getOp() == EOpIndexDirectStruct && node->getLeft()->getType() == *unitType) {
|
||||
if (node->getOp() == EOpIndexDirectStruct && node->getLeft()->getType() == *newType) {
|
||||
// this is a dereference to a member of the block since the
|
||||
// member list changed, need to update this to point to the
|
||||
// right index
|
||||
@@ -692,12 +693,12 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
|
||||
TMergeBlockTraverser finalLinkTraverser(block);
|
||||
getTreeRoot()->traverse(&finalLinkTraverser);
|
||||
|
||||
// The 'unit' intermediate needs the block structures update, but also structure entry indices
|
||||
// The 'unit' intermediate needs the block structures update, but also structure entry indices
|
||||
// may have changed from the old block to the new one that it was merged into, so update those
|
||||
// in 'visitBinary'
|
||||
TType unitType;
|
||||
unitType.shallowCopy(unitBlock->getType());
|
||||
TMergeBlockTraverser unitFinalLinkTraverser(block, &unitType, unit, &memberIndexUpdates);
|
||||
TType newType;
|
||||
newType.shallowCopy(block->getType());
|
||||
TMergeBlockTraverser unitFinalLinkTraverser(block, &newType, unit, &memberIndexUpdates);
|
||||
unit->getTreeRoot()->traverse(&unitFinalLinkTraverser);
|
||||
|
||||
// update the member list
|
||||
@@ -1012,7 +1013,7 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
|
||||
}
|
||||
|
||||
// Auxiliary and interpolation...
|
||||
// "interpolation qualification (e.g., flat) and auxiliary qualification (e.g. centroid) may differ.
|
||||
// "interpolation qualification (e.g., flat) and auxiliary qualification (e.g. centroid) may differ.
|
||||
// These mismatches are allowed between any pair of stages ...
|
||||
// those provided in the fragment shader supersede those provided in previous stages."
|
||||
if (!crossStage &&
|
||||
@@ -1294,8 +1295,8 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
|
||||
error(infoSink, "At least one shader must specify a layout(max_vertices = value)");
|
||||
break;
|
||||
case EShLangFragment:
|
||||
// for GL_ARB_post_depth_coverage, EarlyFragmentTest is set automatically in
|
||||
// ParseHelper.cpp. So if we reach here, this must be GL_EXT_post_depth_coverage
|
||||
// for GL_ARB_post_depth_coverage, EarlyFragmentTest is set automatically in
|
||||
// ParseHelper.cpp. So if we reach here, this must be GL_EXT_post_depth_coverage
|
||||
// requiring explicit early_fragment_tests
|
||||
if (getPostDepthCoverage() && !getEarlyFragmentTests())
|
||||
error(infoSink, "post_depth_coverage requires early_fragment_tests");
|
||||
@@ -1312,7 +1313,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
|
||||
if (numShaderRecordBlocks > 1)
|
||||
error(infoSink, "Only one shaderRecordNV buffer block is allowed per stage");
|
||||
break;
|
||||
case EShLangMeshNV:
|
||||
case EShLangMesh:
|
||||
// NV_mesh_shader doesn't allow use of both single-view and per-view builtins.
|
||||
if (inIoAccessed("gl_Position") && inIoAccessed("gl_PositionPerViewNV"))
|
||||
error(infoSink, "Can only use one of gl_Position or gl_PositionPerViewNV");
|
||||
@@ -1331,9 +1332,11 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
|
||||
if (primitives == TQualifier::layoutNotSet)
|
||||
error(infoSink, "At least one shader must specify a layout(max_primitives = value)");
|
||||
// fall through
|
||||
case EShLangTaskNV:
|
||||
case EShLangTask:
|
||||
if (numTaskNVBlocks > 1)
|
||||
error(infoSink, "Only one taskNV interface block is allowed per shader");
|
||||
if (numTaskEXTPayloads > 1)
|
||||
error(infoSink, "Only single variable of type taskPayloadSharedEXT is allowed per shader");
|
||||
sharedBlockCheck(infoSink);
|
||||
break;
|
||||
default:
|
||||
@@ -2226,7 +2229,7 @@ int TIntermediate::getScalarAlignment(const TType& type, int& size, int& stride,
|
||||
|
||||
if (type.isVector()) {
|
||||
int scalarAlign = getBaseAlignmentScalar(type, size);
|
||||
|
||||
|
||||
size *= type.getVectorSize();
|
||||
return scalarAlign;
|
||||
}
|
||||
@@ -2247,7 +2250,7 @@ int TIntermediate::getScalarAlignment(const TType& type, int& size, int& stride,
|
||||
|
||||
assert(0); // all cases should be covered above
|
||||
size = 1;
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int TIntermediate::getMemberAlignment(const TType& type, int& size, int& stride, TLayoutPacking layoutPacking, bool rowMajor)
|
||||
@@ -2338,7 +2341,7 @@ bool TIntermediate::isIoResizeArray(const TType& type, EShLanguage language) {
|
||||
(language == EShLangTessEvaluation && type.getQualifier().storage == EvqVaryingIn) ||
|
||||
(language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn &&
|
||||
(type.getQualifier().pervertexNV || type.getQualifier().pervertexEXT)) ||
|
||||
(language == EShLangMeshNV && type.getQualifier().storage == EvqVaryingOut &&
|
||||
(language == EShLangMesh && type.getQualifier().storage == EvqVaryingOut &&
|
||||
!type.getQualifier().perTaskNV));
|
||||
}
|
||||
#endif // not GLSLANG_WEB
|
||||
|
||||
@@ -292,6 +292,7 @@ public:
|
||||
invertY(false),
|
||||
dxPositionW(false),
|
||||
enhancedMsgs(false),
|
||||
debugInfo(false),
|
||||
useStorageBuffer(false),
|
||||
invariantAll(false),
|
||||
nanMinMaxClamp(false),
|
||||
@@ -322,6 +323,7 @@ public:
|
||||
primitives(TQualifier::layoutNotSet),
|
||||
numTaskNVBlocks(0),
|
||||
layoutPrimitiveCulling(false),
|
||||
numTaskEXTPayloads(0),
|
||||
autoMapBindings(false),
|
||||
autoMapLocations(false),
|
||||
flattenUniformArrays(false),
|
||||
@@ -461,6 +463,12 @@ public:
|
||||
const std::string& getEntryPointName() const { return entryPointName; }
|
||||
const std::string& getEntryPointMangledName() const { return entryPointMangledName; }
|
||||
|
||||
void setDebugInfo(bool debuginfo)
|
||||
{
|
||||
debugInfo = debuginfo;
|
||||
}
|
||||
bool getDebugInfo() const { return debugInfo; }
|
||||
|
||||
void setInvertY(bool invert)
|
||||
{
|
||||
invertY = invert;
|
||||
@@ -639,6 +647,7 @@ public:
|
||||
int getNumPushConstants() const { return 0; }
|
||||
void addShaderRecordCount() { }
|
||||
void addTaskNVCount() { }
|
||||
void addTaskPayloadEXTCount() { }
|
||||
void setUseVulkanMemoryModel() { }
|
||||
bool usingVulkanMemoryModel() const { return false; }
|
||||
bool usingPhysicalStorageBuffer() const { return false; }
|
||||
@@ -756,6 +765,7 @@ public:
|
||||
int getNumPushConstants() const { return numPushConstants; }
|
||||
void addShaderRecordCount() { ++numShaderRecordBlocks; }
|
||||
void addTaskNVCount() { ++numTaskNVBlocks; }
|
||||
void addTaskPayloadEXTCount() { ++numTaskEXTPayloads; }
|
||||
|
||||
bool setInvocations(int i)
|
||||
{
|
||||
@@ -1109,6 +1119,7 @@ protected:
|
||||
bool invertY;
|
||||
bool dxPositionW;
|
||||
bool enhancedMsgs;
|
||||
bool debugInfo;
|
||||
bool useStorageBuffer;
|
||||
bool invariantAll;
|
||||
bool nanMinMaxClamp; // true if desiring min/max/clamp to favor non-NaN over NaN
|
||||
@@ -1160,6 +1171,7 @@ protected:
|
||||
int primitives;
|
||||
int numTaskNVBlocks;
|
||||
bool layoutPrimitiveCulling;
|
||||
int numTaskEXTPayloads;
|
||||
|
||||
// Base shift values
|
||||
std::array<unsigned int, EResCount> shiftBinding;
|
||||
|
||||
@@ -56,52 +56,6 @@ namespace glslang {
|
||||
// Thread cleanup
|
||||
//
|
||||
|
||||
//
|
||||
// Wrapper for Linux call to DetachThread. This is required as pthread_cleanup_push() expects
|
||||
// the cleanup routine to return void.
|
||||
//
|
||||
static void DetachThreadLinux(void *)
|
||||
{
|
||||
DetachThread();
|
||||
}
|
||||
|
||||
//
|
||||
// Registers cleanup handler, sets cancel type and state, and executes the thread specific
|
||||
// cleanup handler. This function will be called in the Standalone.cpp for regression
|
||||
// testing. When OpenGL applications are run with the driver code, Linux OS does the
|
||||
// thread cleanup.
|
||||
//
|
||||
void OS_CleanupThreadData(void)
|
||||
{
|
||||
#if defined(__ANDROID__) || defined(__Fuchsia__)
|
||||
DetachThreadLinux(NULL);
|
||||
#else
|
||||
int old_cancel_state, old_cancel_type;
|
||||
void *cleanupArg = NULL;
|
||||
|
||||
//
|
||||
// Set thread cancel state and push cleanup handler.
|
||||
//
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancel_state);
|
||||
pthread_cleanup_push(DetachThreadLinux, (void *) cleanupArg);
|
||||
|
||||
//
|
||||
// Put the thread in deferred cancellation mode.
|
||||
//
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &old_cancel_type);
|
||||
|
||||
//
|
||||
// Pop cleanup handler and execute it prior to unregistering the cleanup handler.
|
||||
//
|
||||
pthread_cleanup_pop(1);
|
||||
|
||||
//
|
||||
// Restore the thread's previous cancellation mode.
|
||||
//
|
||||
pthread_setcanceltype(old_cancel_state, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
export default (() => {
|
||||
const initialize = () => {
|
||||
return new Promise(resolve => {
|
||||
Module({
|
||||
locateFile() {
|
||||
const i = import.meta.url.lastIndexOf('/')
|
||||
return import.meta.url.substring(0, i) + '/glslang.wasm';
|
||||
},
|
||||
onRuntimeInitialized() {
|
||||
resolve({
|
||||
compileGLSLZeroCopy: this.compileGLSLZeroCopy,
|
||||
compileGLSL: this.compileGLSL,
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
let instance;
|
||||
return () => {
|
||||
if (!instance) {
|
||||
instance = initialize();
|
||||
}
|
||||
return instance;
|
||||
};
|
||||
})();
|
||||
@@ -1,287 +0,0 @@
|
||||
//
|
||||
// Copyright (C) 2019 Google, 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.
|
||||
//
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#include "../../../SPIRV/GlslangToSpv.h"
|
||||
#include "../../../glslang/Public/ShaderLang.h"
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#define EMSCRIPTEN_KEEPALIVE
|
||||
#endif
|
||||
|
||||
const TBuiltInResource DefaultTBuiltInResource = {
|
||||
/* .MaxLights = */ 32,
|
||||
/* .MaxClipPlanes = */ 6,
|
||||
/* .MaxTextureUnits = */ 32,
|
||||
/* .MaxTextureCoords = */ 32,
|
||||
/* .MaxVertexAttribs = */ 64,
|
||||
/* .MaxVertexUniformComponents = */ 4096,
|
||||
/* .MaxVaryingFloats = */ 64,
|
||||
/* .MaxVertexTextureImageUnits = */ 32,
|
||||
/* .MaxCombinedTextureImageUnits = */ 80,
|
||||
/* .MaxTextureImageUnits = */ 32,
|
||||
/* .MaxFragmentUniformComponents = */ 4096,
|
||||
/* .MaxDrawBuffers = */ 32,
|
||||
/* .MaxVertexUniformVectors = */ 128,
|
||||
/* .MaxVaryingVectors = */ 8,
|
||||
/* .MaxFragmentUniformVectors = */ 16,
|
||||
/* .MaxVertexOutputVectors = */ 16,
|
||||
/* .MaxFragmentInputVectors = */ 15,
|
||||
/* .MinProgramTexelOffset = */ -8,
|
||||
/* .MaxProgramTexelOffset = */ 7,
|
||||
/* .MaxClipDistances = */ 8,
|
||||
/* .MaxComputeWorkGroupCountX = */ 65535,
|
||||
/* .MaxComputeWorkGroupCountY = */ 65535,
|
||||
/* .MaxComputeWorkGroupCountZ = */ 65535,
|
||||
/* .MaxComputeWorkGroupSizeX = */ 1024,
|
||||
/* .MaxComputeWorkGroupSizeY = */ 1024,
|
||||
/* .MaxComputeWorkGroupSizeZ = */ 64,
|
||||
/* .MaxComputeUniformComponents = */ 1024,
|
||||
/* .MaxComputeTextureImageUnits = */ 16,
|
||||
/* .MaxComputeImageUniforms = */ 8,
|
||||
/* .MaxComputeAtomicCounters = */ 8,
|
||||
/* .MaxComputeAtomicCounterBuffers = */ 1,
|
||||
/* .MaxVaryingComponents = */ 60,
|
||||
/* .MaxVertexOutputComponents = */ 64,
|
||||
/* .MaxGeometryInputComponents = */ 64,
|
||||
/* .MaxGeometryOutputComponents = */ 128,
|
||||
/* .MaxFragmentInputComponents = */ 128,
|
||||
/* .MaxImageUnits = */ 8,
|
||||
/* .MaxCombinedImageUnitsAndFragmentOutputs = */ 8,
|
||||
/* .MaxCombinedShaderOutputResources = */ 8,
|
||||
/* .MaxImageSamples = */ 0,
|
||||
/* .MaxVertexImageUniforms = */ 0,
|
||||
/* .MaxTessControlImageUniforms = */ 0,
|
||||
/* .MaxTessEvaluationImageUniforms = */ 0,
|
||||
/* .MaxGeometryImageUniforms = */ 0,
|
||||
/* .MaxFragmentImageUniforms = */ 8,
|
||||
/* .MaxCombinedImageUniforms = */ 8,
|
||||
/* .MaxGeometryTextureImageUnits = */ 16,
|
||||
/* .MaxGeometryOutputVertices = */ 256,
|
||||
/* .MaxGeometryTotalOutputComponents = */ 1024,
|
||||
/* .MaxGeometryUniformComponents = */ 1024,
|
||||
/* .MaxGeometryVaryingComponents = */ 64,
|
||||
/* .MaxTessControlInputComponents = */ 128,
|
||||
/* .MaxTessControlOutputComponents = */ 128,
|
||||
/* .MaxTessControlTextureImageUnits = */ 16,
|
||||
/* .MaxTessControlUniformComponents = */ 1024,
|
||||
/* .MaxTessControlTotalOutputComponents = */ 4096,
|
||||
/* .MaxTessEvaluationInputComponents = */ 128,
|
||||
/* .MaxTessEvaluationOutputComponents = */ 128,
|
||||
/* .MaxTessEvaluationTextureImageUnits = */ 16,
|
||||
/* .MaxTessEvaluationUniformComponents = */ 1024,
|
||||
/* .MaxTessPatchComponents = */ 120,
|
||||
/* .MaxPatchVertices = */ 32,
|
||||
/* .MaxTessGenLevel = */ 64,
|
||||
/* .MaxViewports = */ 16,
|
||||
/* .MaxVertexAtomicCounters = */ 0,
|
||||
/* .MaxTessControlAtomicCounters = */ 0,
|
||||
/* .MaxTessEvaluationAtomicCounters = */ 0,
|
||||
/* .MaxGeometryAtomicCounters = */ 0,
|
||||
/* .MaxFragmentAtomicCounters = */ 8,
|
||||
/* .MaxCombinedAtomicCounters = */ 8,
|
||||
/* .MaxAtomicCounterBindings = */ 1,
|
||||
/* .MaxVertexAtomicCounterBuffers = */ 0,
|
||||
/* .MaxTessControlAtomicCounterBuffers = */ 0,
|
||||
/* .MaxTessEvaluationAtomicCounterBuffers = */ 0,
|
||||
/* .MaxGeometryAtomicCounterBuffers = */ 0,
|
||||
/* .MaxFragmentAtomicCounterBuffers = */ 1,
|
||||
/* .MaxCombinedAtomicCounterBuffers = */ 1,
|
||||
/* .MaxAtomicCounterBufferSize = */ 16384,
|
||||
/* .MaxTransformFeedbackBuffers = */ 4,
|
||||
/* .MaxTransformFeedbackInterleavedComponents = */ 64,
|
||||
/* .MaxCullDistances = */ 8,
|
||||
/* .MaxCombinedClipAndCullDistances = */ 8,
|
||||
/* .MaxSamples = */ 4,
|
||||
/* .maxMeshOutputVerticesNV = */ 256,
|
||||
/* .maxMeshOutputPrimitivesNV = */ 512,
|
||||
/* .maxMeshWorkGroupSizeX_NV = */ 32,
|
||||
/* .maxMeshWorkGroupSizeY_NV = */ 1,
|
||||
/* .maxMeshWorkGroupSizeZ_NV = */ 1,
|
||||
/* .maxTaskWorkGroupSizeX_NV = */ 32,
|
||||
/* .maxTaskWorkGroupSizeY_NV = */ 1,
|
||||
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
|
||||
/* .maxMeshViewCountNV = */ 4,
|
||||
/* .maxDualSourceDrawBuffersEXT = */ 1,
|
||||
|
||||
/* .limits = */ {
|
||||
/* .nonInductiveForLoops = */ 1,
|
||||
/* .whileLoops = */ 1,
|
||||
/* .doWhileLoops = */ 1,
|
||||
/* .generalUniformIndexing = */ 1,
|
||||
/* .generalAttributeMatrixVectorIndexing = */ 1,
|
||||
/* .generalVaryingIndexing = */ 1,
|
||||
/* .generalSamplerIndexing = */ 1,
|
||||
/* .generalVariableIndexing = */ 1,
|
||||
/* .generalConstantMatrixVectorIndexing = */ 1,
|
||||
}};
|
||||
|
||||
static bool initialized = false;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Takes in a GLSL shader as a string and converts it to SPIR-V in binary form.
|
||||
*
|
||||
* |glsl| Null-terminated string containing the shader to be converted.
|
||||
* |stage_int| Magic number indicating the type of shader being processed.
|
||||
* Legal values are as follows:
|
||||
* Vertex = 0
|
||||
* Fragment = 4
|
||||
* Compute = 5
|
||||
* |gen_debug| Flag to indicate if debug information should be generated.
|
||||
* |spirv| Output parameter for a pointer to the resulting SPIR-V data.
|
||||
* |spirv_len| Output parameter for the length of the output binary buffer.
|
||||
*
|
||||
* Returns a void* pointer which, if not null, must be destroyed by
|
||||
* destroy_output_buffer.o. (This is not the same pointer returned in |spirv|.)
|
||||
* If null, the compilation failed.
|
||||
*/
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
void* convert_glsl_to_spirv(const char* glsl,
|
||||
int stage_int,
|
||||
bool gen_debug,
|
||||
glslang::EShTargetLanguageVersion spirv_version,
|
||||
uint32_t** spirv,
|
||||
size_t* spirv_len)
|
||||
{
|
||||
if (glsl == nullptr) {
|
||||
fprintf(stderr, "Input pointer null\n");
|
||||
return nullptr;
|
||||
}
|
||||
if (spirv == nullptr || spirv_len == nullptr) {
|
||||
fprintf(stderr, "Output pointer null\n");
|
||||
return nullptr;
|
||||
}
|
||||
*spirv = nullptr;
|
||||
*spirv_len = 0;
|
||||
|
||||
if (stage_int != 0 && stage_int != 4 && stage_int != 5) {
|
||||
fprintf(stderr, "Invalid shader stage\n");
|
||||
return nullptr;
|
||||
}
|
||||
EShLanguage stage = static_cast<EShLanguage>(stage_int);
|
||||
switch (spirv_version) {
|
||||
case glslang::EShTargetSpv_1_0:
|
||||
case glslang::EShTargetSpv_1_1:
|
||||
case glslang::EShTargetSpv_1_2:
|
||||
case glslang::EShTargetSpv_1_3:
|
||||
case glslang::EShTargetSpv_1_4:
|
||||
case glslang::EShTargetSpv_1_5:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Invalid SPIR-V version number\n");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
glslang::InitializeProcess();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
glslang::TShader shader(stage);
|
||||
shader.setStrings(&glsl, 1);
|
||||
shader.setEnvInput(glslang::EShSourceGlsl, stage, glslang::EShClientVulkan, 100);
|
||||
shader.setEnvClient(glslang::EShClientVulkan, glslang::EShTargetVulkan_1_0);
|
||||
shader.setEnvTarget(glslang::EShTargetSpv, spirv_version);
|
||||
if (!shader.parse(&DefaultTBuiltInResource, 100, true, EShMsgDefault)) {
|
||||
fprintf(stderr, "Parse failed\n");
|
||||
fprintf(stderr, "%s\n", shader.getInfoLog());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
glslang::TProgram program;
|
||||
program.addShader(&shader);
|
||||
if (!program.link(EShMsgDefault)) {
|
||||
fprintf(stderr, "Link failed\n");
|
||||
fprintf(stderr, "%s\n", program.getInfoLog());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
glslang::SpvOptions spvOptions;
|
||||
spvOptions.generateDebugInfo = gen_debug;
|
||||
spvOptions.optimizeSize = false;
|
||||
spvOptions.disassemble = false;
|
||||
spvOptions.validate = false;
|
||||
|
||||
std::vector<uint32_t>* output = new std::vector<uint32_t>;
|
||||
glslang::GlslangToSpv(*program.getIntermediate(stage), *output, nullptr, &spvOptions);
|
||||
|
||||
*spirv_len = output->size();
|
||||
*spirv = output->data();
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroys a buffer created by convert_glsl_to_spirv
|
||||
*/
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
void destroy_output_buffer(void* p)
|
||||
{
|
||||
delete static_cast<std::vector<uint32_t>*>(p);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
/*
|
||||
* For non-Emscripten builds we supply a generic main, so that the glslang.js
|
||||
* build target can generate an executable with a trivial use case instead of
|
||||
* generating a WASM binary. This is done so that there is a target that can be
|
||||
* built and output analyzed using desktop tools, since WASM binaries are
|
||||
* specific to the Emscripten toolchain.
|
||||
*/
|
||||
#ifndef __EMSCRIPTEN__
|
||||
int main() {
|
||||
const char* input = R"(#version 310 es
|
||||
|
||||
void main() { })";
|
||||
|
||||
uint32_t* output;
|
||||
size_t output_len;
|
||||
|
||||
void* id = convert_glsl_to_spirv(input, 4, false, glslang::EShTargetSpv_1_0, &output, &output_len);
|
||||
assert(output != nullptr);
|
||||
assert(output_len != 0);
|
||||
destroy_output_buffer(id);
|
||||
return 0;
|
||||
}
|
||||
#endif // ifndef __EMSCRIPTEN__
|
||||
@@ -1,56 +0,0 @@
|
||||
Module['compileGLSLZeroCopy'] = function(glsl, shader_stage, gen_debug, spirv_version) {
|
||||
gen_debug = !!gen_debug;
|
||||
|
||||
var shader_stage_int; // EShLanguage
|
||||
switch (shader_stage) {
|
||||
case 'vertex': shader_stage_int = 0; break;
|
||||
case 'fragment': shader_stage_int = 4; break;
|
||||
case 'compute': shader_stage_int = 5; break;
|
||||
default:
|
||||
throw new Error("shader_stage must be 'vertex', 'fragment', or 'compute'.");
|
||||
}
|
||||
|
||||
spirv_version = spirv_version || '1.0';
|
||||
var spirv_version_int; // EShTargetLanguageVersion
|
||||
switch (spirv_version) {
|
||||
case '1.0': spirv_version_int = (1 << 16) | (0 << 8); break;
|
||||
case '1.1': spirv_version_int = (1 << 16) | (1 << 8); break;
|
||||
case '1.2': spirv_version_int = (1 << 16) | (2 << 8); break;
|
||||
case '1.3': spirv_version_int = (1 << 16) | (3 << 8); break;
|
||||
case '1.4': spirv_version_int = (1 << 16) | (4 << 8); break;
|
||||
case '1.5': spirv_version_int = (1 << 16) | (5 << 8); break;
|
||||
default:
|
||||
throw new Error("spirv_version must be '1.0' ~ '1.5'.");
|
||||
}
|
||||
|
||||
var p_output = Module['_malloc'](4);
|
||||
var p_output_len = Module['_malloc'](4);
|
||||
var id = ccall('convert_glsl_to_spirv',
|
||||
'number',
|
||||
['string', 'number', 'boolean', 'number', 'number', 'number'],
|
||||
[glsl, shader_stage_int, gen_debug, spirv_version_int, p_output, p_output_len]);
|
||||
var output = getValue(p_output, 'i32');
|
||||
var output_len = getValue(p_output_len, 'i32');
|
||||
Module['_free'](p_output);
|
||||
Module['_free'](p_output_len);
|
||||
|
||||
if (id === 0) {
|
||||
throw new Error('GLSL compilation failed');
|
||||
}
|
||||
|
||||
var ret = {};
|
||||
var outputIndexU32 = output / 4;
|
||||
ret['data'] = Module['HEAPU32'].subarray(outputIndexU32, outputIndexU32 + output_len);
|
||||
ret['free'] = function() {
|
||||
Module['_destroy_output_buffer'](id);
|
||||
};
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
Module['compileGLSL'] = function(glsl, shader_stage, gen_debug, spirv_version) {
|
||||
var compiled = Module['compileGLSLZeroCopy'](glsl, shader_stage, gen_debug, spirv_version);
|
||||
var ret = compiled['data'].slice()
|
||||
compiled['free']();
|
||||
return ret;
|
||||
};
|
||||
@@ -1,74 +0,0 @@
|
||||
//
|
||||
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include "InitializeDll.h"
|
||||
|
||||
#define STRICT
|
||||
#define VC_EXTRALEAN 1
|
||||
#include <windows.h>
|
||||
#include <assert.h>
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
switch (fdwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
|
||||
if (! glslang::InitProcess())
|
||||
return FALSE;
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
|
||||
if (! glslang::InitThread())
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
|
||||
if (! glslang::DetachThread())
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
|
||||
glslang::DetachProcess();
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0 && "DllMain(): Reason for calling DLL Main is unknown");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -54,8 +54,6 @@ void ReleaseGlobalLock();
|
||||
|
||||
typedef unsigned int (*TThreadEntrypoint)(void*);
|
||||
|
||||
void OS_CleanupThreadData(void);
|
||||
|
||||
void OS_DumpMemoryCounters();
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
17
3rdparty/glslang/glslang/Public/ShaderLang.h
vendored
17
3rdparty/glslang/glslang/Public/ShaderLang.h
vendored
@@ -108,8 +108,10 @@ typedef enum {
|
||||
EShLangMissNV = EShLangMiss,
|
||||
EShLangCallable,
|
||||
EShLangCallableNV = EShLangCallable,
|
||||
EShLangTaskNV,
|
||||
EShLangMeshNV,
|
||||
EShLangTask,
|
||||
EShLangTaskNV = EShLangTask,
|
||||
EShLangMesh,
|
||||
EShLangMeshNV = EShLangMesh,
|
||||
LAST_ELEMENT_MARKER(EShLangCount),
|
||||
} EShLanguage; // would be better as stage, but this is ancient now
|
||||
|
||||
@@ -132,8 +134,10 @@ typedef enum : unsigned {
|
||||
EShLangMissNVMask = EShLangMissMask,
|
||||
EShLangCallableMask = (1 << EShLangCallable),
|
||||
EShLangCallableNVMask = EShLangCallableMask,
|
||||
EShLangTaskNVMask = (1 << EShLangTaskNV),
|
||||
EShLangMeshNVMask = (1 << EShLangMeshNV),
|
||||
EShLangTaskMask = (1 << EShLangTask),
|
||||
EShLangTaskNVMask = EShLangTaskMask,
|
||||
EShLangMeshMask = (1 << EShLangMesh),
|
||||
EShLangMeshNVMask = EShLangMeshMask,
|
||||
LAST_ELEMENT_MARKER(EShLanguageMaskCount),
|
||||
} EShLanguageMask;
|
||||
|
||||
@@ -301,7 +305,7 @@ typedef struct {
|
||||
|
||||
//
|
||||
// ShHandle held by but opaque to the driver. It is allocated,
|
||||
// managed, and de-allocated by the compiler/linker. It's contents
|
||||
// managed, and de-allocated by the compiler/linker. Its contents
|
||||
// are defined by and used by the compiler and linker. For example,
|
||||
// symbol table information and object code passed from the compiler
|
||||
// to the linker can be stored where ShHandle points.
|
||||
@@ -472,6 +476,7 @@ public:
|
||||
GLSLANG_EXPORT void addProcesses(const std::vector<std::string>&);
|
||||
GLSLANG_EXPORT void setUniqueId(unsigned long long id);
|
||||
GLSLANG_EXPORT void setOverrideVersion(int version);
|
||||
GLSLANG_EXPORT void setDebugInfo(bool debugInfo);
|
||||
|
||||
// IO resolver binding data: see comments in ShaderLang.cpp
|
||||
GLSLANG_EXPORT void setShiftBinding(TResourceType res, unsigned int base);
|
||||
@@ -525,7 +530,7 @@ public:
|
||||
// See the definitions of TEnvironment, EShSource, EShLanguage,
|
||||
// and EShClient for choices and more detail.
|
||||
//
|
||||
// setEnvClient: The client that will be hosting the execution, and it's version.
|
||||
// setEnvClient: The client that will be hosting the execution, and its version.
|
||||
// Note 'version' is not the version of the languages involved, but
|
||||
// the version of the client environment.
|
||||
// Use EShClientNone and version of 0 if there is no client, e.g.
|
||||
|
||||
Reference in New Issue
Block a user