Commit b9197c81 by John Kessenich

Web: Make switched methods all be non-virtual, more web-dependent code,

added a few more HLSL flag tests. This was mostly focused on the SPV generator. Saves about 17K.
parent d8834df9
...@@ -528,6 +528,7 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo ...@@ -528,6 +528,7 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type)); constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type); module.mapInstruction(type);
#ifndef GLSLANG_WEB
// deal with capabilities // deal with capabilities
switch (dim) { switch (dim) {
case DimBuffer: case DimBuffer:
...@@ -573,6 +574,7 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo ...@@ -573,6 +574,7 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo
addCapability(CapabilityImageMSArray); addCapability(CapabilityImageMSArray);
} }
} }
#endif
return type->getResultId(); return type->getResultId();
} }
...@@ -1018,21 +1020,28 @@ Id Builder::makeFloat16Constant(float f16, bool specConstant) ...@@ -1018,21 +1020,28 @@ Id Builder::makeFloat16Constant(float f16, bool specConstant)
Id Builder::makeFpConstant(Id type, double d, bool specConstant) Id Builder::makeFpConstant(Id type, double d, bool specConstant)
{ {
assert(isFloatType(type)); #ifdef GLSLANG_WEB
const int width = 32;
assert(width == getScalarTypeWidth(type));
#else
const int width = getScalarTypeWidth(type);
#endif
switch (getScalarTypeWidth(type)) { assert(isFloatType(type));
case 16:
return makeFloat16Constant((float)d, specConstant);
case 32:
return makeFloatConstant((float)d, specConstant);
case 64:
return makeDoubleConstant(d, specConstant);
default:
break;
}
assert(false); switch (width) {
return NoResult; case 16:
return makeFloat16Constant((float)d, specConstant);
case 32:
return makeFloatConstant((float)d, specConstant);
case 64:
return makeDoubleConstant(d, specConstant);
default:
break;
}
assert(false);
return NoResult;
} }
Id Builder::findCompositeConstant(Op typeClass, Id typeId, const std::vector<Id>& comps) Id Builder::findCompositeConstant(Op typeClass, Id typeId, const std::vector<Id>& comps)
...@@ -1895,6 +1904,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse, ...@@ -1895,6 +1904,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
mask = (ImageOperandsMask)(mask | ImageOperandsConstOffsetsMask); mask = (ImageOperandsMask)(mask | ImageOperandsConstOffsetsMask);
texArgs[numArgs++] = parameters.offsets; texArgs[numArgs++] = parameters.offsets;
} }
#ifndef GLSLANG_WEB
if (parameters.sample) { if (parameters.sample) {
mask = (ImageOperandsMask)(mask | ImageOperandsSampleMask); mask = (ImageOperandsMask)(mask | ImageOperandsSampleMask);
texArgs[numArgs++] = parameters.sample; texArgs[numArgs++] = parameters.sample;
...@@ -1912,6 +1922,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse, ...@@ -1912,6 +1922,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
if (parameters.volatil) { if (parameters.volatil) {
mask = mask | ImageOperandsVolatileTexelKHRMask; mask = mask | ImageOperandsVolatileTexelKHRMask;
} }
#endif
mask = mask | signExtensionMask; mask = mask | signExtensionMask;
if (mask == ImageOperandsMaskNone) if (mask == ImageOperandsMaskNone)
--numArgs; // undo speculative reservation for the mask argument --numArgs; // undo speculative reservation for the mask argument
...@@ -2302,7 +2313,12 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>& ...@@ -2302,7 +2313,12 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
int numRows = getTypeNumRows(resultTypeId); int numRows = getTypeNumRows(resultTypeId);
Instruction* instr = module.getInstruction(componentTypeId); Instruction* instr = module.getInstruction(componentTypeId);
unsigned bitCount = instr->getImmediateOperand(0); #ifdef GLSLANG_WEB
const unsigned bitCount = 32;
assert(bitcount == instr->getImmediateOperand(0));
#else
const unsigned bitCount = instr->getImmediateOperand(0);
#endif
// Optimize matrix constructed from a bigger matrix // Optimize matrix constructed from a bigger matrix
if (isMatrix(sources[0]) && getNumColumns(sources[0]) >= numCols && getNumRows(sources[0]) >= numRows) { if (isMatrix(sources[0]) && getNumColumns(sources[0]) >= numCols && getNumRows(sources[0]) >= numRows) {
......
...@@ -201,7 +201,11 @@ public: ...@@ -201,7 +201,11 @@ public:
bool isMatrixType(Id typeId) const { return getTypeClass(typeId) == OpTypeMatrix; } bool isMatrixType(Id typeId) const { return getTypeClass(typeId) == OpTypeMatrix; }
bool isStructType(Id typeId) const { return getTypeClass(typeId) == OpTypeStruct; } bool isStructType(Id typeId) const { return getTypeClass(typeId) == OpTypeStruct; }
bool isArrayType(Id typeId) const { return getTypeClass(typeId) == OpTypeArray; } bool isArrayType(Id typeId) const { return getTypeClass(typeId) == OpTypeArray; }
#ifdef GLSLANG_WEB
bool isCooperativeMatrixType(Id typeId)const { return false; }
#else
bool isCooperativeMatrixType(Id typeId)const { return getTypeClass(typeId) == OpTypeCooperativeMatrixNV; } bool isCooperativeMatrixType(Id typeId)const { return getTypeClass(typeId) == OpTypeCooperativeMatrixNV; }
#endif
bool isAggregateType(Id typeId) const { return isArrayType(typeId) || isStructType(typeId) || isCooperativeMatrixType(typeId); } bool isAggregateType(Id typeId) const { return isArrayType(typeId) || isStructType(typeId) || isCooperativeMatrixType(typeId); }
bool isImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeImage; } bool isImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeImage; }
bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; } bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; }
...@@ -557,6 +561,14 @@ public: ...@@ -557,6 +561,14 @@ public:
// Accumulate whether anything in the chain of structures has coherent decorations. // Accumulate whether anything in the chain of structures has coherent decorations.
struct CoherentFlags { struct CoherentFlags {
CoherentFlags() { clear(); }
#ifdef GLSLANG_WEB
void clear() { }
bool isVolatile() const { return false; }
CoherentFlags operator |=(const CoherentFlags &other) { return *this; }
#else
bool isVolatile() const { return volatil; }
unsigned coherent : 1; unsigned coherent : 1;
unsigned devicecoherent : 1; unsigned devicecoherent : 1;
unsigned queuefamilycoherent : 1; unsigned queuefamilycoherent : 1;
...@@ -577,7 +589,6 @@ public: ...@@ -577,7 +589,6 @@ public:
isImage = 0; isImage = 0;
} }
CoherentFlags() { clear(); }
CoherentFlags operator |=(const CoherentFlags &other) { CoherentFlags operator |=(const CoherentFlags &other) {
coherent |= other.coherent; coherent |= other.coherent;
devicecoherent |= other.devicecoherent; devicecoherent |= other.devicecoherent;
...@@ -589,6 +600,7 @@ public: ...@@ -589,6 +600,7 @@ public:
isImage |= other.isImage; isImage |= other.isImage;
return *this; return *this;
} }
#endif
}; };
CoherentFlags coherentFlags; CoherentFlags coherentFlags;
}; };
......
...@@ -58,8 +58,8 @@ using depth_greater ...@@ -58,8 +58,8 @@ using depth_greater
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction" 18 EntryPoint Fragment 4 "PixelShaderFunction" 18
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
ExecutionMode 4 DepthGreater
ExecutionMode 4 DepthReplacing ExecutionMode 4 DepthReplacing
ExecutionMode 4 DepthGreater
Source HLSL 500 Source HLSL 500
Name 4 "PixelShaderFunction" Name 4 "PixelShaderFunction"
Name 10 "@PixelShaderFunction(f1;" Name 10 "@PixelShaderFunction(f1;"
......
...@@ -50,8 +50,8 @@ using depth_less ...@@ -50,8 +50,8 @@ using depth_less
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction" 14 EntryPoint Fragment 4 "PixelShaderFunction" 14
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
ExecutionMode 4 DepthLess
ExecutionMode 4 DepthReplacing ExecutionMode 4 DepthReplacing
ExecutionMode 4 DepthLess
Source HLSL 500 Source HLSL 500
Name 4 "PixelShaderFunction" Name 4 "PixelShaderFunction"
Name 8 "@PixelShaderFunction(" Name 8 "@PixelShaderFunction("
......
...@@ -170,8 +170,8 @@ using depth_greater ...@@ -170,8 +170,8 @@ using depth_greater
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 22 27 31 36 45 48 51 55 EntryPoint Fragment 4 "main" 22 27 31 36 45 48 51 55
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
ExecutionMode 4 DepthGreater
ExecutionMode 4 DepthReplacing ExecutionMode 4 DepthReplacing
ExecutionMode 4 DepthGreater
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
Name 8 "T" Name 8 "T"
......
598528 ../build/install/bin/glslangValidator.exe 409600 ../build/install/bin/glslangValidator.exe
...@@ -8,8 +8,8 @@ spv.depthOut.frag ...@@ -8,8 +8,8 @@ spv.depthOut.frag
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 8 10 14 EntryPoint Fragment 4 "main" 8 10 14
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
ExecutionMode 4 DepthGreater
ExecutionMode 4 DepthReplacing ExecutionMode 4 DepthReplacing
ExecutionMode 4 DepthGreater
Source GLSL 450 Source GLSL 450
Name 4 "main" Name 4 "main"
Name 8 "gl_FragDepth" Name 8 "gl_FragDepth"
......
...@@ -527,7 +527,8 @@ __inline bool isTypeFloat(TBasicType type) ...@@ -527,7 +527,8 @@ __inline bool isTypeFloat(TBasicType type)
} }
} }
__inline int getTypeRank(TBasicType type) { __inline int getTypeRank(TBasicType type)
{
int res = -1; int res = -1;
switch(type) { switch(type) {
case EbtInt8: case EbtInt8:
......
...@@ -1354,10 +1354,6 @@ public: ...@@ -1354,10 +1354,6 @@ public:
case EOpTexture: case EOpTexture:
case EOpSparseTexture: case EOpSparseTexture:
break; break;
case EOpTextureClamp:
case EOpSparseTextureClamp:
cracked.lodClamp = true;
break;
case EOpTextureProj: case EOpTextureProj:
cracked.proj = true; cracked.proj = true;
break; break;
...@@ -1369,11 +1365,6 @@ public: ...@@ -1369,11 +1365,6 @@ public:
case EOpSparseTextureOffset: case EOpSparseTextureOffset:
cracked.offset = true; cracked.offset = true;
break; break;
case EOpTextureOffsetClamp:
case EOpSparseTextureOffsetClamp:
cracked.offset = true;
cracked.lodClamp = true;
break;
case EOpTextureFetch: case EOpTextureFetch:
case EOpSparseTextureFetch: case EOpSparseTextureFetch:
cracked.fetch = true; cracked.fetch = true;
...@@ -1409,11 +1400,6 @@ public: ...@@ -1409,11 +1400,6 @@ public:
case EOpSparseTextureGrad: case EOpSparseTextureGrad:
cracked.grad = true; cracked.grad = true;
break; break;
case EOpTextureGradClamp:
case EOpSparseTextureGradClamp:
cracked.grad = true;
cracked.lodClamp = true;
break;
case EOpTextureGradOffset: case EOpTextureGradOffset:
case EOpSparseTextureGradOffset: case EOpSparseTextureGradOffset:
cracked.grad = true; cracked.grad = true;
...@@ -1428,6 +1414,21 @@ public: ...@@ -1428,6 +1414,21 @@ public:
cracked.offset = true; cracked.offset = true;
cracked.proj = true; cracked.proj = true;
break; break;
#ifndef GLSLANG_WEB
case EOpTextureClamp:
case EOpSparseTextureClamp:
cracked.lodClamp = true;
break;
case EOpTextureOffsetClamp:
case EOpSparseTextureOffsetClamp:
cracked.offset = true;
cracked.lodClamp = true;
break;
case EOpTextureGradClamp:
case EOpSparseTextureGradClamp:
cracked.grad = true;
cracked.lodClamp = true;
break;
case EOpTextureGradOffsetClamp: case EOpTextureGradOffsetClamp:
case EOpSparseTextureGradOffsetClamp: case EOpSparseTextureGradOffsetClamp:
cracked.grad = true; cracked.grad = true;
...@@ -1497,6 +1498,7 @@ public: ...@@ -1497,6 +1498,7 @@ public:
case EOpSubpassLoadMS: case EOpSubpassLoadMS:
cracked.subpass = true; cracked.subpass = true;
break; break;
#endif
default: default:
break; break;
} }
......
...@@ -153,13 +153,13 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op, ...@@ -153,13 +153,13 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op,
case EvqConst: message = "can't modify a const"; break; case EvqConst: message = "can't modify a const"; break;
case EvqConstReadOnly: message = "can't modify a const"; break; case EvqConstReadOnly: message = "can't modify a const"; break;
case EvqUniform: message = "can't modify a uniform"; break; case EvqUniform: message = "can't modify a uniform"; break;
#ifndef GLSLANG_WEB
case EvqBuffer: case EvqBuffer:
if (node->getQualifier().readonly) if (node->getQualifier().readonly)
message = "can't modify a readonly buffer"; message = "can't modify a readonly buffer";
if (node->getQualifier().isShaderRecordNV()) if (node->getQualifier().isShaderRecordNV())
message = "can't modify a shaderrecordnv qualified buffer"; message = "can't modify a shaderrecordnv qualified buffer";
break; break;
#ifndef GLSLANG_WEB
case EvqHitAttrNV: case EvqHitAttrNV:
if (language != EShLangIntersectNV) if (language != EShLangIntersectNV)
message = "cannot modify hitAttributeNV in this stage"; message = "cannot modify hitAttributeNV in this stage";
......
...@@ -1147,6 +1147,7 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction ...@@ -1147,6 +1147,7 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
error(arguments->getLoc(), "Non-L-value cannot be passed for 'out' or 'inout' parameters.", "out", ""); error(arguments->getLoc(), "Non-L-value cannot be passed for 'out' or 'inout' parameters.", "out", "");
} }
TQualifier& argQualifier = arg->getAsTyped()->getQualifier(); TQualifier& argQualifier = arg->getAsTyped()->getQualifier();
#ifndef GLSLANG_WEB
if (argQualifier.isMemory()) { if (argQualifier.isMemory()) {
const char* message = "argument cannot drop memory qualifier when passed to formal parameter"; const char* message = "argument cannot drop memory qualifier when passed to formal parameter";
if (argQualifier.volatil && ! formalQualifier.volatil) if (argQualifier.volatil && ! formalQualifier.volatil)
...@@ -1176,7 +1177,7 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction ...@@ -1176,7 +1177,7 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
argQualifier.getFormat() != ElfNone)) argQualifier.getFormat() != ElfNone))
error(arguments->getLoc(), "image formats must match", "format", ""); error(arguments->getLoc(), "image formats must match", "format", "");
} }
#endif
if (builtIn && arg->getAsTyped()->getType().contains16BitFloat()) if (builtIn && arg->getAsTyped()->getType().contains16BitFloat())
requireFloat16Arithmetic(arguments->getLoc(), "built-in function", "float16 types can only be in uniform block or buffer storage"); requireFloat16Arithmetic(arguments->getLoc(), "built-in function", "float16 types can only be in uniform block or buffer storage");
if (builtIn && arg->getAsTyped()->getType().contains16BitInt()) if (builtIn && arg->getAsTyped()->getType().contains16BitInt())
...@@ -7507,7 +7508,7 @@ void TParseContext::blockQualifierCheck(const TSourceLoc& loc, const TQualifier& ...@@ -7507,7 +7508,7 @@ void TParseContext::blockQualifierCheck(const TSourceLoc& loc, const TQualifier&
error(loc, "cannot use interpolation qualifiers on an interface block", "flat/smooth/noperspective", ""); error(loc, "cannot use interpolation qualifiers on an interface block", "flat/smooth/noperspective", "");
if (qualifier.centroid) if (qualifier.centroid)
error(loc, "cannot use centroid qualifier on an interface block", "centroid", ""); error(loc, "cannot use centroid qualifier on an interface block", "centroid", "");
if (qualifier.sample) if (qualifier.isSample())
error(loc, "cannot use sample qualifier on an interface block", "sample", ""); error(loc, "cannot use sample qualifier on an interface block", "sample", "");
if (qualifier.invariant) if (qualifier.invariant)
error(loc, "cannot use invariant qualifier on an interface block", "invariant", ""); error(loc, "cannot use invariant qualifier on an interface block", "invariant", "");
......
...@@ -538,13 +538,14 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy ...@@ -538,13 +538,14 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
if (symbol.getQualifier().centroid != unitSymbol.getQualifier().centroid || if (symbol.getQualifier().centroid != unitSymbol.getQualifier().centroid ||
symbol.getQualifier().smooth != unitSymbol.getQualifier().smooth || symbol.getQualifier().smooth != unitSymbol.getQualifier().smooth ||
symbol.getQualifier().flat != unitSymbol.getQualifier().flat || symbol.getQualifier().flat != unitSymbol.getQualifier().flat ||
symbol.getQualifier().sample != unitSymbol.getQualifier().sample || symbol.getQualifier().isSample()!= unitSymbol.getQualifier().isSample() ||
symbol.getQualifier().patch != unitSymbol.getQualifier().patch || symbol.getQualifier().isPatch() != unitSymbol.getQualifier().isPatch() ||
symbol.getQualifier().isNonPerspective() != unitSymbol.getQualifier().isNonPerspective()) { symbol.getQualifier().isNonPerspective() != unitSymbol.getQualifier().isNonPerspective()) {
error(infoSink, "Interpolation and auxiliary storage qualifiers must match:"); error(infoSink, "Interpolation and auxiliary storage qualifiers must match:");
writeTypeComparison = true; writeTypeComparison = true;
} }
#ifndef GLSLANG_WEB
// Memory... // Memory...
if (symbol.getQualifier().coherent != unitSymbol.getQualifier().coherent || if (symbol.getQualifier().coherent != unitSymbol.getQualifier().coherent ||
symbol.getQualifier().devicecoherent != unitSymbol.getQualifier().devicecoherent || symbol.getQualifier().devicecoherent != unitSymbol.getQualifier().devicecoherent ||
...@@ -559,6 +560,7 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy ...@@ -559,6 +560,7 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
error(infoSink, "Memory qualifiers must match:"); error(infoSink, "Memory qualifiers must match:");
writeTypeComparison = true; writeTypeComparison = true;
} }
#endif
// Layouts... // Layouts...
// TODO: 4.4 enhanced layouts: Generalize to include offset/align: current spec // TODO: 4.4 enhanced layouts: Generalize to include offset/align: current spec
...@@ -608,9 +610,6 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled) ...@@ -608,9 +610,6 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
warn(infoSink, "Entry point not found"); warn(infoSink, "Entry point not found");
} }
if (getNumPushConstants() > 1)
error(infoSink, "Only one push_constant block is allowed per stage");
// recursion and missing body checking // recursion and missing body checking
checkCallGraphCycles(infoSink); checkCallGraphCycles(infoSink);
checkCallGraphBodies(infoSink, keepUncalled); checkCallGraphBodies(infoSink, keepUncalled);
...@@ -619,6 +618,9 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled) ...@@ -619,6 +618,9 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
inOutLocationCheck(infoSink); inOutLocationCheck(infoSink);
#ifndef GLSLANG_WEB #ifndef GLSLANG_WEB
if (getNumPushConstants() > 1)
error(infoSink, "Only one push_constant block is allowed per stage");
// invocations // invocations
if (invocations == TQualifier::layoutNotSet) if (invocations == TQualifier::layoutNotSet)
invocations = 1; invocations = 1;
......
...@@ -481,6 +481,8 @@ public: ...@@ -481,6 +481,8 @@ public:
bool usingVulkanMemoryModel() const { return false; } bool usingVulkanMemoryModel() const { return false; }
bool usingPhysicalStorageBuffer() const { return false; } bool usingPhysicalStorageBuffer() const { return false; }
bool usingVariablePointers() const { return false; } bool usingVariablePointers() const { return false; }
unsigned getXfbStride(int buffer) const { return 0; }
bool hasLayoutDerivativeModeNone() const { return false; }
#else #else
void output(TInfoSink&, bool tree); void output(TInfoSink&, bool tree);
...@@ -544,6 +546,7 @@ public: ...@@ -544,6 +546,7 @@ public:
} }
bool getAutoMapLocations() const { return autoMapLocations; } bool getAutoMapLocations() const { return autoMapLocations; }
#ifdef ENABLE_HLSL
void setFlattenUniformArrays(bool flatten) void setFlattenUniformArrays(bool flatten)
{ {
flattenUniformArrays = flatten; flattenUniformArrays = flatten;
...@@ -551,6 +554,7 @@ public: ...@@ -551,6 +554,7 @@ public:
processes.addProcess("flatten-uniform-arrays"); processes.addProcess("flatten-uniform-arrays");
} }
bool getFlattenUniformArrays() const { return flattenUniformArrays; } bool getFlattenUniformArrays() const { return flattenUniformArrays; }
#endif
void setNoStorageFormat(bool b) void setNoStorageFormat(bool b)
{ {
useUnknownFormat = b; useUnknownFormat = b;
...@@ -576,12 +580,14 @@ public: ...@@ -576,12 +580,14 @@ public:
} }
bool usingVariablePointers() const { return useVariablePointers; } bool usingVariablePointers() const { return useVariablePointers; }
#ifdef ENABLE_HLSL
template<class T> T addCounterBufferName(const T& name) const { return name + implicitCounterName; } template<class T> T addCounterBufferName(const T& name) const { return name + implicitCounterName; }
bool hasCounterBufferName(const TString& name) const { bool hasCounterBufferName(const TString& name) const {
size_t len = strlen(implicitCounterName); size_t len = strlen(implicitCounterName);
return name.size() > len && return name.size() > len &&
name.compare(name.size() - len, len, implicitCounterName) == 0; name.compare(name.size() - len, len, implicitCounterName) == 0;
} }
#endif
void setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode) { textureSamplerTransformMode = mode; } void setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode) { textureSamplerTransformMode = mode; }
int getNumPushConstants() const { return numPushConstants; } int getNumPushConstants() const { return numPushConstants; }
...@@ -703,6 +709,7 @@ public: ...@@ -703,6 +709,7 @@ public:
void setGeoPassthroughEXT() { geoPassthroughEXT = true; } void setGeoPassthroughEXT() { geoPassthroughEXT = true; }
bool getGeoPassthroughEXT() const { return geoPassthroughEXT; } bool getGeoPassthroughEXT() const { return geoPassthroughEXT; }
void setLayoutDerivativeMode(ComputeDerivativeMode mode) { computeDerivativeMode = mode; } void setLayoutDerivativeMode(ComputeDerivativeMode mode) { computeDerivativeMode = mode; }
bool hasLayoutDerivativeModeNone() const { return computeDerivativeMode != LayoutDerivativeNone; }
ComputeDerivativeMode getLayoutDerivativeModeNone() const { return computeDerivativeMode; } ComputeDerivativeMode getLayoutDerivativeModeNone() const { return computeDerivativeMode; }
bool setPrimitives(int m) bool setPrimitives(int m)
{ {
......
...@@ -68,30 +68,30 @@ public: ...@@ -68,30 +68,30 @@ public:
virtual void requireStage(const TSourceLoc&, EShLanguage, const char* featureDesc); virtual void requireStage(const TSourceLoc&, EShLanguage, const char* featureDesc);
#ifdef GLSLANG_WEB #ifdef GLSLANG_WEB
bool isEsProfile() const { return true; } bool isEsProfile() const { return true; }
virtual void initializeExtensionBehavior() { } void initializeExtensionBehavior() { }
virtual void checkDeprecated(const TSourceLoc&, int queryProfiles, int depVersion, const char* featureDesc) { } void checkDeprecated(const TSourceLoc&, int queryProfiles, int depVersion, const char* featureDesc) { }
virtual void requireNotRemoved(const TSourceLoc&, int queryProfiles, int removedVersion, const char* featureDesc) { } void requireNotRemoved(const TSourceLoc&, int queryProfiles, int removedVersion, const char* featureDesc) { }
virtual void requireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[], void requireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc) { } const char* featureDesc) { }
virtual void ppRequireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[], void ppRequireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc) { } const char* featureDesc) { }
virtual TExtensionBehavior getExtensionBehavior(const char*) { return EBhMissing; } TExtensionBehavior getExtensionBehavior(const char*) { return EBhMissing; }
virtual bool extensionTurnedOn(const char* const extension) { return false; } bool extensionTurnedOn(const char* const extension) { return false; }
virtual bool extensionsTurnedOn(int numExtensions, const char* const extensions[]) { return false; } bool extensionsTurnedOn(int numExtensions, const char* const extensions[]) { return false; }
virtual void updateExtensionBehavior(int line, const char* const extension, const char* behavior) { } void updateExtensionBehavior(int line, const char* const extension, const char* behavior) { }
virtual void updateExtensionBehavior(const char* const extension, TExtensionBehavior) { } void updateExtensionBehavior(const char* const extension, TExtensionBehavior) { }
virtual void checkExtensionStage(const TSourceLoc&, const char* const extension) { } void checkExtensionStage(const TSourceLoc&, const char* const extension) { }
virtual void fullIntegerCheck(const TSourceLoc&, const char* op) { } void fullIntegerCheck(const TSourceLoc&, const char* op) { }
virtual void doubleCheck(const TSourceLoc&, const char* op) { } void doubleCheck(const TSourceLoc&, const char* op) { }
virtual bool float16Arithmetic() { return false; } bool float16Arithmetic() { return false; }
virtual void requireFloat16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { } void requireFloat16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { }
virtual bool int16Arithmetic() { return false; } bool int16Arithmetic() { return false; }
virtual void requireInt16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { } void requireInt16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { }
virtual bool int8Arithmetic() { return false; } bool int8Arithmetic() { return false; }
virtual void requireInt8Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { } void requireInt8Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { }
virtual void int64Check(const TSourceLoc&, const char* op, bool builtIn = false) { } void int64Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
virtual void explicitFloat32Check(const TSourceLoc&, const char* op, bool builtIn = false) { } void explicitFloat32Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
virtual void explicitFloat64Check(const TSourceLoc&, const char* op, bool builtIn = false) { } void explicitFloat64Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
#else #else
bool isEsProfile() const { return profile == EEsProfile; } bool isEsProfile() const { return profile == EEsProfile; }
virtual void initializeExtensionBehavior(); virtual void initializeExtensionBehavior();
......
...@@ -1085,6 +1085,7 @@ void TReflection::buildAttributeReflection(EShLanguage stage, const TIntermediat ...@@ -1085,6 +1085,7 @@ void TReflection::buildAttributeReflection(EShLanguage stage, const TIntermediat
// build counter block index associations for buffers // build counter block index associations for buffers
void TReflection::buildCounterIndices(const TIntermediate& intermediate) void TReflection::buildCounterIndices(const TIntermediate& intermediate)
{ {
#ifdef ENABLE_HLSL
// search for ones that have counters // search for ones that have counters
for (int i = 0; i < int(indexToUniformBlock.size()); ++i) { for (int i = 0; i < int(indexToUniformBlock.size()); ++i) {
const TString counterName(intermediate.addCounterBufferName(indexToUniformBlock[i].name).c_str()); const TString counterName(intermediate.addCounterBufferName(indexToUniformBlock[i].name).c_str());
...@@ -1093,6 +1094,7 @@ void TReflection::buildCounterIndices(const TIntermediate& intermediate) ...@@ -1093,6 +1094,7 @@ void TReflection::buildCounterIndices(const TIntermediate& intermediate)
if (index >= 0) if (index >= 0)
indexToUniformBlock[i].counterIndex = index; indexToUniformBlock[i].counterIndex = index;
} }
#endif
} }
// build Shader Stages mask for all uniforms // build Shader Stages mask for all uniforms
......
...@@ -434,8 +434,8 @@ public: ...@@ -434,8 +434,8 @@ public:
void setInvertY(bool invert); void setInvertY(bool invert);
#ifdef ENABLE_HLSL #ifdef ENABLE_HLSL
void setHlslIoMapping(bool hlslIoMap); void setHlslIoMapping(bool hlslIoMap);
#endif
void setFlattenUniformArrays(bool flatten); void setFlattenUniformArrays(bool flatten);
#endif
void setNoStorageFormat(bool useUnknownFormat); void setNoStorageFormat(bool useUnknownFormat);
void setNanMinMaxClamp(bool nanMinMaxClamp); void setNanMinMaxClamp(bool nanMinMaxClamp);
void setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode); void setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode);
......
...@@ -227,7 +227,9 @@ public: ...@@ -227,7 +227,9 @@ public:
shader.setAutoMapBindings(true); shader.setAutoMapBindings(true);
} }
shader.setTextureSamplerTransformMode(texSampTransMode); shader.setTextureSamplerTransformMode(texSampTransMode);
#ifdef ENABLE_HLSL
shader.setFlattenUniformArrays(flattenUniformArrays); shader.setFlattenUniformArrays(flattenUniformArrays);
#endif
if (controls & EShMsgSpvRules) { if (controls & EShMsgSpvRules) {
if (controls & EShMsgVulkanRules) { if (controls & EShMsgVulkanRules) {
...@@ -300,7 +302,9 @@ public: ...@@ -300,7 +302,9 @@ public:
shader.setShiftSsboBinding(baseSsboBinding); shader.setShiftSsboBinding(baseSsboBinding);
shader.setAutoMapBindings(autoMapBindings); shader.setAutoMapBindings(autoMapBindings);
shader.setAutoMapLocations(true); shader.setAutoMapLocations(true);
#ifdef ENABLE_HLSL
shader.setFlattenUniformArrays(flattenUniformArrays); shader.setFlattenUniformArrays(flattenUniformArrays);
#endif
bool success = compile(&shader, code, entryPointName, controls); bool success = compile(&shader, code, entryPointName, controls);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment