namespace glslang {
HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& interm, bool parsingBuiltins,
- int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink,
+ int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language,
+ TInfoSink& infoSink,
const TString sourceEntryPointName,
bool forwardCompatible, EShMessages messages) :
- TParseContextBase(symbolTable, interm, parsingBuiltins, version, profile, spvVersion, language, infoSink, forwardCompatible, messages),
+ TParseContextBase(symbolTable, interm, parsingBuiltins, version, profile, spvVersion, language, infoSink,
+ forwardCompatible, messages),
annotationNestingLevel(0),
inputPatch(nullptr),
builtInIoIndex(nullptr),
// Print a message formated such that if you click on the message it will take you right to
// the line through most UIs.
const glslang::TSourceLoc& sourceLoc = input.getSourceLoc();
- infoSink.info << sourceLoc.name << "(" << sourceLoc.line << "): error at column " << sourceLoc.column << ", HLSL parsing failed.\n";
+ infoSink.info << sourceLoc.name << "(" << sourceLoc.line << "): error at column " << sourceLoc.column
+ << ", HLSL parsing failed.\n";
++numErrors;
return false;
}
return false;
}
-void HlslParseContext::growGlobalUniformBlock(const TSourceLoc& loc, TType& memberType, const TString& memberName, TTypeList* newTypeList)
+void HlslParseContext::growGlobalUniformBlock(const TSourceLoc& loc, TType& memberType, const TString& memberName,
+ TTypeList* newTypeList)
{
newTypeList = nullptr;
correctUniform(memberType.getQualifier());
// fall through...
case EOpAssign:
{
- // Since this is an lvalue, we'll convert an image load to a sequence like this (to still provide the value):
+ // Since this is an lvalue, we'll convert an image load to a sequence like this
+ // (to still provide the value):
// OpSequence
// OpImageStore(object, lhs, rhs)
// rhs
- // But if it's not a simple symbol RHS (say, a fn call), we don't want to duplicate the RHS, so we'll convert
- // instead to this:
+ // But if it's not a simple symbol RHS (say, a fn call), we don't want to duplicate the RHS,
+ // so we'll convert instead to this:
// OpSequence
// rhsTmp = rhs
// OpImageStore(object, coord, rhsTmp)
variableCheck(base);
if (! base->isArray() && ! base->isMatrix() && ! base->isVector()) {
if (base->getAsSymbolNode())
- error(loc, " left of '[' is not of type array, matrix, or vector ", base->getAsSymbolNode()->getName().c_str(), "");
+ error(loc, " left of '[' is not of type array, matrix, or vector ",
+ base->getAsSymbolNode()->getName().c_str(), "");
else
error(loc, " left of '[' is not of type array, matrix, or vector ", "expression", "");
} else if (base->getType().getQualifier().storage == EvqConst && index->getQualifier().storage == EvqConst)
}
// Handle seeing a binary node with a math operation.
-TIntermTyped* HlslParseContext::handleBinaryMath(const TSourceLoc& loc, const char* str, TOperator op, TIntermTyped* left, TIntermTyped* right)
+TIntermTyped* HlslParseContext::handleBinaryMath(const TSourceLoc& loc, const char* str, TOperator op,
+ TIntermTyped* left, TIntermTyped* right)
{
TIntermTyped* result = intermediate.addBinaryMath(op, left, right, loc);
if (result == nullptr)
}
// Handle seeing a unary node with a math operation.
-TIntermTyped* HlslParseContext::handleUnaryMath(const TSourceLoc& loc, const char* str, TOperator op, TIntermTyped* childNode)
+TIntermTyped* HlslParseContext::handleUnaryMath(const TSourceLoc& loc, const char* str, TOperator op,
+ TIntermTyped* childNode)
{
TIntermTyped* result = intermediate.addUnaryMath(op, childNode, loc);
// Keep 'result' pointing to 'base', since we expect an operator[] to go by next.
} else {
if (field == "mips")
- error(loc, "unexpected texture type for .mips[][] operator:", base->getType().getCompleteString().c_str(), "");
+ error(loc, "unexpected texture type for .mips[][] operator:",
+ base->getType().getCompleteString().c_str(), "");
else
- error(loc, "unexpected operator on texture type:", field.c_str(), base->getType().getCompleteString().c_str());
+ error(loc, "unexpected operator on texture type:", field.c_str(),
+ base->getType().getCompleteString().c_str());
}
} else if (base->isVector() || base->isScalar()) {
TSwizzleSelectors<TVectorSelector> selectors;
} else {
TIntermTyped* index = intermediate.addSwizzle(selectors, loc);
result = intermediate.addIndex(EOpVectorSwizzle, base, index, loc);
- result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, selectors.size()));
+ result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision,
+ selectors.size()));
}
}
} else if (base->isMatrix()) {
result = intermediate.foldDereference(base, selectors[0].coord1, loc);
result = intermediate.foldDereference(result, selectors[0].coord2, loc);
} else {
- result = intermediate.addIndex(EOpIndexDirect, base, intermediate.addConstantUnion(selectors[0].coord1, loc), loc);
+ result = intermediate.addIndex(EOpIndexDirect, base,
+ intermediate.addConstantUnion(selectors[0].coord1, loc),
+ loc);
TType dereferencedCol(base->getType(), 0);
result->setType(dereferencedCol);
- result = intermediate.addIndex(EOpIndexDirect, result, intermediate.addConstantUnion(selectors[0].coord2, loc), loc);
+ result = intermediate.addIndex(EOpIndexDirect, result,
+ intermediate.addConstantUnion(selectors[0].coord2, loc),
+ loc);
TType dereferenced(dereferencedCol, 0);
result->setType(dereferenced);
}
if (base->getType().getQualifier().isFrontEndConstant())
result = intermediate.foldDereference(base, column, loc);
else {
- result = intermediate.addIndex(EOpIndexDirect, base, intermediate.addConstantUnion(column, loc), loc);
+ result = intermediate.addIndex(EOpIndexDirect, base, intermediate.addConstantUnion(column, loc),
+ loc);
TType dereferenced(base->getType(), 0);
result->setType(dereferenced);
}
// general case, not a column, not a single component
TIntermTyped* index = intermediate.addSwizzle(selectors, loc);
result = intermediate.addIndex(EOpMatrixSwizzle, base, index, loc);
- result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, selectors.size()));
+ result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision,
+ selectors.size()));
}
}
} else if (base->getBasicType() == EbtStruct || base->getBasicType() == EbtBlock) {
// Get iterator to (now at end) set of builtin interstage IO members
const auto firstIo = std::stable_partition(userStructure->begin(), userStructure->end(),
- [this](const TTypeLoc& t) {return !t.type->isBuiltInInterstageIO(language);});
+ [this](const TTypeLoc& t) {
+ return !t.type->isBuiltInInterstageIO(language);
+ });
// Move those to the builtin IO. However, we also propagate arrayness (just one level is handled
// now) to this variable.
for (auto ioType = firstIo; ioType != userStructure->end(); ++ioType) {
const TType& memberType = *ioType->type;
- TVariable* ioVar = makeInternalVariable(name + (name.empty() ? "" : "_") + memberType.getFieldName(), memberType);
+ TVariable* ioVar = makeInternalVariable(name + (name.empty() ? "" : "_") + memberType.getFieldName(),
+ memberType);
if (arraySizes)
ioVar->getWritableType().newArraySizes(*arraySizes);
if (memberType.isBuiltInInterstageIO(language)) {
// It's one of the interstage IO variables we split off.
- TIntermTyped* builtIn = intermediate.addSymbol(*interstageBuiltInIo[tInterstageIoData(memberType, base->getType())], loc);
+ TIntermTyped* builtIn = intermediate.addSymbol(*interstageBuiltInIo[tInterstageIoData(memberType,
+ base->getType())], loc);
// If there's an array reference to an outer split struct, we re-apply it here.
if (builtInIoIndex != nullptr) {
// For struct buffers with counters, we must pass the counter buffer as hidden parameter.
// This adds the hidden parameter to the parameter list in 'paramNodes' if needed.
// Otherwise, it's a no-op
-void HlslParseContext::addStructBufferHiddenCounterParam(const TSourceLoc& loc, TParameter& param, TIntermAggregate*& paramNodes)
+void HlslParseContext::addStructBufferHiddenCounterParam(const TSourceLoc& loc, TParameter& param,
+ TIntermAggregate*& paramNodes)
{
if (! hasStructBuffCounter(*param.type))
return;
// Returns an aggregate of parameter-symbol nodes.
//
TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& loc, TFunction& function,
- const TAttributeMap& attributes, TIntermNode*& entryPointTree)
+ const TAttributeMap& attributes,
+ TIntermNode*& entryPointTree)
{
currentCaller = function.getMangledName();
TSymbol* symbol = symbolTable.find(function.getMangledName());
const TTypeList* structure = variable->getType().getStruct();
for (int mem = 0; mem < (int)structure->size(); ++mem) {
paramNodes = intermediate.growAggregate(paramNodes,
- flattenAccess(variable->getUniqueId(), mem, *(*structure)[mem].type),
+ flattenAccess(variable->getUniqueId(), mem,
+ *(*structure)[mem].type),
loc);
}
} else {
// MaxVertexCount
const TIntermAggregate* maxVertexCount = attributes[EatMaxVertexCount];
if (maxVertexCount != nullptr) {
- if (! intermediate.setVertices(maxVertexCount->getSequence()[0]->getAsConstantUnion()->getConstArray()[0].getIConst())) {
+ if (! intermediate.setVertices(maxVertexCount->getSequence()[0]->getAsConstantUnion()->
+ getConstArray()[0].getIConst())) {
error(loc, "cannot change previously set maxvertexcount attribute", "", "");
}
}
}
if (! intermediate.setVertexSpacing(partitioning))
- error(loc, "cannot change previously set partitioning", TQualifier::getVertexSpacingString(partitioning), "");
+ error(loc, "cannot change previously set partitioning",
+ TQualifier::getVertexSpacingString(partitioning), "");
}
}
// Handle [outputcontrolpoints("...")]
const TIntermAggregate* outputControlPoints = attributes[EatOutputControlPoints];
if (outputControlPoints != nullptr) {
- const TConstUnion& ctrlPointConst = outputControlPoints->getSequence()[0]->getAsConstantUnion()->getConstArray()[0];
+ const TConstUnion& ctrlPointConst =
+ outputControlPoints->getSequence()[0]->getAsConstantUnion()->getConstArray()[0];
if (ctrlPointConst.getType() != EbtInt) {
error(loc, "invalid outputcontrolpoints", "", "");
} else {
// Returns nullptr if no entry-point tree was built, otherwise, returns
// a subtree that creates the entry point.
//
-TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunction& userFunction, const TAttributeMap& attributes)
+TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunction& userFunction,
+ const TAttributeMap& attributes)
{
// Return true if this is a tessellation patch constant function input to a domain shader.
const auto isDsPcfInput = [this](const TType& type) {
return synthFunctionDef;
}
-void HlslParseContext::handleFunctionBody(const TSourceLoc& loc, TFunction& function, TIntermNode* functionBody, TIntermNode*& node)
+void HlslParseContext::handleFunctionBody(const TSourceLoc& loc, TFunction& function, TIntermNode* functionBody,
+ TIntermNode*& node)
{
node = intermediate.growAggregate(node, functionBody);
intermediate.setAggregateOperator(node, EOpFunction, function.getType(), loc);
}
- // If we haven't created the output arleady, create it now.
+ // If we haven't created the output already, create it now.
if (*clipCullVar == nullptr) {
// ClipDistance and CullDistance are handled specially in the entry point output
// copy algorithm, because they may need to be unpacked from components of vectors
// expected to then not exist for opaque types, because they will turn into aliases.
//
// Return a node that contains the non-aliased assignments that must continue to exist.
-TIntermAggregate* HlslParseContext::flattenedInit(const TSourceLoc& loc, TIntermSymbol* symbol, const TIntermAggregate& initializer)
+TIntermAggregate* HlslParseContext::flattenedInit(const TSourceLoc& loc, TIntermSymbol* symbol,
+ const TIntermAggregate& initializer)
{
TIntermAggregate* initList = nullptr;
// synthesize an access to each member, and then an assignment to it
//
// Also, assignment to matrix swizzles requires multiple component assignments,
// intercept those as well.
-TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op, TIntermTyped* left, TIntermTyped* right)
+TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op, TIntermTyped* left,
+ TIntermTyped* right)
{
if (left == nullptr || right == nullptr)
return nullptr;
// An assignment to matrix swizzle must be decomposed into individual assignments.
// These must be selected component-wise from the RHS and stored component-wise
// into the LHS.
-TIntermTyped* HlslParseContext::handleAssignToMatrixSwizzle(const TSourceLoc& loc, TOperator op, TIntermTyped* left, TIntermTyped* right)
+TIntermTyped* HlslParseContext::handleAssignToMatrixSwizzle(const TSourceLoc& loc, TOperator op, TIntermTyped* left,
+ TIntermTyped* right)
{
assert(left->getAsOperator() && left->getAsOperator()->getOp() == EOpMatrixSwizzle);
//
// Create a combined sampler/texture from separate sampler and texture.
//
-TIntermAggregate* HlslParseContext::handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex, TIntermTyped* argSampler)
+TIntermAggregate* HlslParseContext::handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex,
+ TIntermTyped* argSampler)
{
TIntermAggregate* txcombine = new TIntermAggregate(EOpConstructTextureSampler);
if (isByteAddressBuffer)
- argIndex = intermediate.addBinaryNode(EOpRightShift, argIndex, intermediate.addConstantUnion(2, loc, true),
+ argIndex = intermediate.addBinaryNode(EOpRightShift, argIndex,
+ intermediate.addConstantUnion(2, loc, true),
loc, TType(EbtInt));
// Index into the array to find the item being loaded.
// First, we'll store the address in a variable to avoid multiple shifts
// (we must convert the byte address to an item address)
TIntermTyped* byteAddrIdx = intermediate.addBinaryNode(EOpRightShift, argIndex,
- intermediate.addConstantUnion(2, loc, true), loc, TType(EbtInt));
+ intermediate.addConstantUnion(2, loc, true),
+ loc, TType(EbtInt));
TVariable* byteAddrSym = makeInternalVariable("byteAddrTemp", TType(EbtInt, EvqTemporary));
TIntermTyped* byteAddrIdxVar = intermediate.addSymbol(*byteAddrSym, loc);
// add index offset
if (idx != 0)
- offsetIdx = intermediate.addBinaryNode(EOpAdd, offsetIdx, intermediate.addConstantUnion(idx, loc, true),
+ offsetIdx = intermediate.addBinaryNode(EOpAdd, offsetIdx,
+ intermediate.addConstantUnion(idx, loc, true),
loc, TType(EbtInt));
- const TOperator idxOp = (offsetIdx->getQualifier().storage == EvqConst) ? EOpIndexDirect : EOpIndexIndirect;
+ const TOperator idxOp = (offsetIdx->getQualifier().storage == EvqConst) ? EOpIndexDirect
+ : EOpIndexIndirect;
vec = intermediate.growAggregate(vec, intermediate.addIndex(idxOp, argArray, offsetIdx, loc));
}
if (idx != 0)
offsetIdx = intermediate.addBinaryNode(EOpAdd, offsetIdx, idxConst, loc, TType(EbtInt));
- const TOperator idxOp = (offsetIdx->getQualifier().storage == EvqConst) ? EOpIndexDirect : EOpIndexIndirect;
+ const TOperator idxOp = (offsetIdx->getQualifier().storage == EvqConst) ? EOpIndexDirect
+ : EOpIndexIndirect;
TIntermTyped* lValue = intermediate.addIndex(idxOp, argArray, offsetIdx, loc);
TIntermTyped* rValue = (size == 1) ? argValue :
body = intermediate.growAggregate(body, assign, loc);
} else {
const int length = argArray->getType().getOuterArraySize();
- TIntermTyped* assign = intermediate.addAssign(EOpAssign, argNumItems, intermediate.addConstantUnion(length, loc, true), loc);
+ TIntermTyped* assign = intermediate.addAssign(EOpAssign, argNumItems,
+ intermediate.addConstantUnion(length, loc, true), loc);
body = intermediate.growAggregate(body, assign, loc);
}
intermediate.getBaseAlignment(argArray->getType(), size, stride, false,
argArray->getType().getQualifier().layoutMatrix == ElmRowMajor);
- TIntermTyped* assign = intermediate.addAssign(EOpAssign, argStride, intermediate.addConstantUnion(stride, loc, true), loc);
+ TIntermTyped* assign = intermediate.addAssign(EOpAssign, argStride,
+ intermediate.addConstantUnion(stride, loc, true), loc);
body = intermediate.growAggregate(body, assign);
}
{
TIntermTyped* oldCounter = incDecCounter(-1);
- TIntermTyped* newCounter = intermediate.addBinaryNode(EOpAdd, oldCounter, intermediate.addConstantUnion(-1, loc, true), loc,
- oldCounter->getType());
+ TIntermTyped* newCounter = intermediate.addBinaryNode(EOpAdd, oldCounter,
+ intermediate.addConstantUnion(-1, loc, true), loc,
+ oldCounter->getType());
node = intermediate.addIndex(EOpIndexIndirect, argArray, newCounter, loc);
TIntermAggregate* compoundStatement = intermediate.makeAggregate(tmpArgAssign, loc);
- const TType boolType(EbtBool, EvqTemporary, arg0->getVectorSize(), arg0->getMatrixCols(), arg0->getMatrixRows());
+ const TType boolType(EbtBool, EvqTemporary, arg0->getVectorSize(), arg0->getMatrixCols(),
+ arg0->getMatrixRows());
TIntermTyped* isnan = handleUnaryMath(loc, "isnan", EOpIsNan, intermediate.addSymbol(*tempArg, loc));
isnan->setType(boolType);
// Error check for a function requiring specific extensions present.
if (builtIn && fnCandidate->getNumExtensions())
- requireExtensions(loc, fnCandidate->getNumExtensions(), fnCandidate->getExtensions(), fnCandidate->getName().c_str());
+ requireExtensions(loc, fnCandidate->getNumExtensions(), fnCandidate->getExtensions(),
+ fnCandidate->getName().c_str());
// turn an implicit member-function resolution into an explicit call
TString callerName;
op = fnCandidate->getBuiltInOp();
if (builtIn && op != EOpNull) {
// A function call mapped to a built-in operation.
- result = intermediate.addBuiltInFunctionCall(loc, op, fnCandidate->getParamCount() == 1, arguments, fnCandidate->getType());
+ result = intermediate.addBuiltInFunctionCall(loc, op, fnCandidate->getParamCount() == 1, arguments,
+ fnCandidate->getType());
if (result == nullptr) {
error(arguments->getLoc(), " wrong operand type", "Internal Error",
"built in unary operator function. Type: %s",
}
// generic error recovery
- // TODO: simplification: localize all the error recoveries that look like this, and taking type into account to reduce cascades
+ // TODO: simplification: localize all the error recoveries that look like this, and taking type into account to
+ // reduce cascades
if (result == nullptr)
result = intermediate.addConstantUnion(0.0, EbtFloat, loc);
internalAggregate->getType());
internalSymbolNode->setLoc(arg->getLoc());
// This makes the deepest level, the member-wise copy
- TIntermAggregate* assignAgg = handleAssign(arg->getLoc(), EOpAssign, internalSymbolNode, arg)->getAsAggregate();
+ TIntermAggregate* assignAgg = handleAssign(arg->getLoc(), EOpAssign,
+ internalSymbolNode, arg)->getAsAggregate();
// Now, pair that with the resulting aggregate.
assignAgg = intermediate.growAggregate(assignAgg, internalSymbolNode, arg->getLoc());
TIntermSymbol* tempArgNode = intermediate.addSymbol(*tempArg, loc);
// This makes the deepest level, the member-wise copy
- TIntermTyped* tempAssign = handleAssign(arguments[i]->getLoc(), EOpAssign, arguments[i]->getAsTyped(), tempArgNode);
+ TIntermTyped* tempAssign = handleAssign(arguments[i]->getLoc(), EOpAssign, arguments[i]->getAsTyped(),
+ tempArgNode);
tempAssign = handleLvalue(arguments[i]->getLoc(), "assign", tempAssign);
conversionTree = intermediate.growAggregate(conversionTree, tempAssign, arguments[i]->getLoc());
case EOpTextureGather:
// More than two arguments needs gpu_shader5, and rectangular or shadow needs gpu_shader5,
// otherwise, need GL_ARB_texture_gather.
- if (fnCandidate.getParamCount() > 2 || fnCandidate[0].type->getSampler().dim == EsdRect || fnCandidate[0].type->getSampler().shadow) {
+ if (fnCandidate.getParamCount() > 2 || fnCandidate[0].type->getSampler().dim == EsdRect ||
+ fnCandidate[0].type->getSampler().shadow) {
if (! fnCandidate[0].type->getSampler().shadow)
compArg = 2;
}
for (int c = 0; c < type.getVectorSize(); ++c) {
int offset = aggArgs[arg]->getAsConstantUnion()->getConstArray()[c].getIConst();
if (offset > resources.maxProgramTexelOffset || offset < resources.minProgramTexelOffset)
- error(loc, "value is out of range:", "texel offset", "[gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]");
+ error(loc, "value is out of range:", "texel offset",
+ "[gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]");
}
}
}
// desktop 4.4 and later: swizzles may be used
const TIntermTyped* base = TIntermediate::findLValueBase(arg0, true);
if (base == nullptr || base->getType().getQualifier().storage != EvqVaryingIn)
- error(loc, "first argument must be an interpolant, or interpolant-array element", fnCandidate.getName().c_str(), "");
+ error(loc, "first argument must be an interpolant, or interpolant-array element",
+ fnCandidate.getName().c_str(), "");
}
break;
// Convert to a scalar boolean, or if not allowed by HLSL semantics,
// report an error and return nullptr.
-TIntermTyped* HlslParseContext::convertConditionalExpression(const TSourceLoc& loc, TIntermTyped* condition, bool mustBeScalar)
+TIntermTyped* HlslParseContext::convertConditionalExpression(const TSourceLoc& loc, TIntermTyped* condition,
+ bool mustBeScalar)
{
if (mustBeScalar && !condition->getType().isScalarOrVec1()) {
error(loc, "requires a scalar", "conditional expression", "");
return nullptr;
}
- return intermediate.addConversion(EOpConstructBool, TType(EbtBool, EvqTemporary, condition->getVectorSize()), condition);
+ return intermediate.addConversion(EOpConstructBool, TType(EbtBool, EvqTemporary, condition->getVectorSize()),
+ condition);
}
//
TArraySizes& arraySizes = type.getArraySizes();
// At least the dimensionalities have to match.
- if (! function[0].type->isArray() || arraySizes.getNumDims() != function[0].type->getArraySizes().getNumDims() + 1) {
+ if (! function[0].type->isArray() ||
+ arraySizes.getNumDims() != function[0].type->getArraySizes().getNumDims() + 1) {
error(loc, "array constructor argument not correct type to construct array element", "constructor", "");
return true;
}
return true;
}
if (function.getType().getSampler().shadow != function[1].type->getSampler().shadow) {
- error(loc, "sampler-constructor second argument presence of shadow must match constructor presence of shadow", token, "");
+ error(loc, "sampler-constructor second argument presence of shadow must match constructor presence of shadow",
+ token, "");
return true;
}
int shadowIndex = sampler.shadow ? 1 : 0;
int externalIndex = sampler.external ? 1 : 0;
- return EsdNumDims * (EbtNumTypes * (2 * (2 * arrayIndex + shadowIndex) + externalIndex) + sampler.type) + sampler.dim;
+ return EsdNumDims *
+ (EbtNumTypes * (2 * (2 * arrayIndex + shadowIndex) + externalIndex) + sampler.type) + sampler.dim;
}
//
// Do all the semantic checking for declaring or redeclaring an array, with and
// without a size, and make the right changes to the symbol table.
//
-void HlslParseContext::declareArray(const TSourceLoc& loc, const TString& identifier, const TType& type, TSymbol*& symbol, bool track)
+void HlslParseContext::declareArray(const TSourceLoc& loc, const TString& identifier, const TType& type,
+ TSymbol*& symbol, bool track)
{
if (symbol == nullptr) {
bool currentScope;
TType& existingType = symbol->getWritableType();
if (existingType.isExplicitlySizedArray()) {
- // be more lenient for input arrays to geometry shaders and tessellation control outputs, where the redeclaration is the same size
+ // be more lenient for input arrays to geometry shaders and tessellation control outputs,
+ // where the redeclaration is the same size
return;
}
//
// Enforce non-initializer type/qualifier rules.
//
-void HlslParseContext::fixConstInit(const TSourceLoc& loc, const TString& identifier, TType& type, TIntermTyped*& initializer)
+void HlslParseContext::fixConstInit(const TSourceLoc& loc, const TString& identifier, TType& type,
+ TIntermTyped*& initializer)
{
//
// Make the qualifier make sense, given that there is an initializer.
// Either redeclare the requested block, or give an error message why it can't be done.
//
// TODO: functionality: explicitly sizing members of redeclared blocks is not giving them an explicit size
-void HlslParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newTypeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes)
+void HlslParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newTypeList, const TString& blockName,
+ const TString* instanceName, TArraySizes* arraySizes)
{
// Redeclaring a built-in block...
TType& oldType = *member->type;
const TType& newType = *newMember->type;
if (! newType.sameElementType(oldType))
- error(memberLoc, "cannot redeclare block member with a different type", member->type->getFieldName().c_str(), "");
+ error(memberLoc, "cannot redeclare block member with a different type",
+ member->type->getFieldName().c_str(), "");
if (oldType.isArray() != newType.isArray())
- error(memberLoc, "cannot change arrayness of redeclared block member", member->type->getFieldName().c_str(), "");
+ error(memberLoc, "cannot change arrayness of redeclared block member",
+ member->type->getFieldName().c_str(), "");
else if (! oldType.sameArrayness(newType) && oldType.isExplicitlySizedArray())
- error(memberLoc, "cannot change array size of redeclared block member", member->type->getFieldName().c_str(), "");
+ error(memberLoc, "cannot change array size of redeclared block member",
+ member->type->getFieldName().c_str(), "");
if (newType.getQualifier().isMemory())
- error(memberLoc, "cannot add memory qualifier to redeclared block member", member->type->getFieldName().c_str(), "");
+ error(memberLoc, "cannot add memory qualifier to redeclared block member",
+ member->type->getFieldName().c_str(), "");
if (newType.getQualifier().hasLayout())
- error(memberLoc, "cannot add layout to redeclared block member", member->type->getFieldName().c_str(), "");
+ error(memberLoc, "cannot add layout to redeclared block member",
+ member->type->getFieldName().c_str(), "");
if (newType.getQualifier().patch)
- error(memberLoc, "cannot add patch to redeclared block member", member->type->getFieldName().c_str(), "");
+ error(memberLoc, "cannot add patch to redeclared block member",
+ member->type->getFieldName().c_str(), "");
oldType.getQualifier().centroid = newType.getQualifier().centroid;
oldType.getQualifier().sample = newType.getQualifier().sample;
oldType.getQualifier().invariant = newType.getQualifier().invariant;
// Put the id's layout qualifier value into the public type, for qualifiers having a number set.
// This is before we know any type information for error checking.
-void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qualifier, TString& id, const TIntermTyped* node)
+void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qualifier, TString& id,
+ const TIntermTyped* node)
{
const char* feature = "layout-id value";
// const char* nonLiteralFeature = "non-literal layout-id value";
// "It is a compile-time error to specify an *xfb_buffer* that is greater than
// the implementation-dependent constant gl_MaxTransformFeedbackBuffers."
if (value >= resources.maxTransformFeedbackBuffers)
- error(loc, "buffer is too large:", id.c_str(), "gl_MaxTransformFeedbackBuffers is %d", resources.maxTransformFeedbackBuffers);
+ error(loc, "buffer is too large:", id.c_str(), "gl_MaxTransformFeedbackBuffers is %d",
+ resources.maxTransformFeedbackBuffers);
if (value >= (int)TQualifier::layoutXfbBufferEnd)
error(loc, "buffer is too large:", id.c_str(), "internal max is %d", TQualifier::layoutXfbBufferEnd - 1);
else
// "The resulting stride (implicit or explicit), when divided by 4, must be less than or equal to the
// implementation-dependent constant gl_MaxTransformFeedbackInterleavedComponents."
if (value > 4 * resources.maxTransformFeedbackInterleavedComponents)
- error(loc, "1/4 stride is too large:", id.c_str(), "gl_MaxTransformFeedbackInterleavedComponents is %d", resources.maxTransformFeedbackInterleavedComponents);
+ error(loc, "1/4 stride is too large:", id.c_str(), "gl_MaxTransformFeedbackInterleavedComponents is %d",
+ resources.maxTransformFeedbackInterleavedComponents);
else if (value >= (int)TQualifier::layoutXfbStrideEnd)
error(loc, "stride is too large:", id.c_str(), "internal max is %d", TQualifier::layoutXfbStrideEnd - 1);
if (value < (int)TQualifier::layoutXfbStrideEnd)
// 'parseType' is the type part of the declaration (to the left)
// 'arraySizes' is the arrayness tagged on the identifier (to the right)
//
-TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, const TString& identifier, TType& type, TIntermTyped* initializer)
+TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, const TString& identifier, TType& type,
+ TIntermTyped* initializer)
{
if (voidErrorCheck(loc, identifier, type.getBasicType()))
return nullptr;
}
// Make a symbol node holding a new internal temporary variable.
-TIntermSymbol* HlslParseContext::makeInternalVariableNode(const TSourceLoc& loc, const char* name, const TType& type) const
+TIntermSymbol* HlslParseContext::makeInternalVariableNode(const TSourceLoc& loc, const char* name,
+ const TType& type) const
{
TVariable* tmpVar = makeInternalVariable(name, type);
tmpVar->getWritableType().getQualifier().makeTemporary();
//
// Return the successfully declared variable.
//
-TVariable* HlslParseContext::declareNonArray(const TSourceLoc& loc, const TString& identifier, const TType& type, bool track)
+TVariable* HlslParseContext::declareNonArray(const TSourceLoc& loc, const TString& identifier, const TType& type,
+ bool track)
{
// make a new variable
TVariable* variable = new TVariable(&identifier, type);
// Returning nullptr just means there is no code to execute to handle the
// initializer, which will, for example, be the case for constant initializers.
//
-TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyped* initializer, TVariable* variable, bool flattened)
+TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyped* initializer, TVariable* variable,
+ bool flattened)
{
//
// Identifier must be of type constant, a global, or a temporary, and
// recursively process each element
TType elementType(arrayType, 0); // dereferenced type
for (int i = 0; i < arrayType.getOuterArraySize(); ++i) {
- initList->getSequence()[i] = convertInitializerList(loc, elementType, initList->getSequence()[i]->getAsTyped(), scalarInit);
+ initList->getSequence()[i] = convertInitializerList(loc, elementType,
+ initList->getSequence()[i]->getAsTyped(), scalarInit);
if (initList->getSequence()[i] == nullptr)
return nullptr;
}
return nullptr;
}
for (size_t i = 0; i < type.getStruct()->size(); ++i) {
- initList->getSequence()[i] = convertInitializerList(loc, *(*type.getStruct())[i].type, initList->getSequence()[i]->getAsTyped(), scalarInit);
+ initList->getSequence()[i] = convertInitializerList(loc, *(*type.getStruct())[i].type,
+ initList->getSequence()[i]->getAsTyped(), scalarInit);
if (initList->getSequence()[i] == nullptr)
return nullptr;
}
}
TType vectorType(type, 0); // dereferenced type
for (int i = 0; i < type.getMatrixCols(); ++i) {
- initList->getSequence()[i] = convertInitializerList(loc, vectorType, initList->getSequence()[i]->getAsTyped(), scalarInit);
+ initList->getSequence()[i] = convertInitializerList(loc, vectorType,
+ initList->getSequence()[i]->getAsTyped(), scalarInit);
if (initList->getSequence()[i] == nullptr)
return nullptr;
}
// error check; we're at bottom, so work is finished below
if (type.getVectorSize() != (int)initList->getSequence().size()) {
- error(loc, "wrong vector size (or rows in a matrix column):", "initializer list", type.getCompleteString().c_str());
+ error(loc, "wrong vector size (or rows in a matrix column):", "initializer list",
+ type.getCompleteString().c_str());
return nullptr;
}
} else if (type.isScalar()) {
//
// Returns nullptr for an error or the constructed node.
//
-TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op, TIntermTyped* node, const TSourceLoc& loc, bool subset)
+TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op, TIntermTyped* node,
+ const TSourceLoc& loc, bool subset)
{
TIntermTyped* newNode;
TOperator basicOp;
TVariable& variable = *new TVariable(instanceName, blockType);
if (! symbolTable.insert(variable)) {
if (*instanceName == "")
- error(loc, "nameless block contains a member that already has a name at global scope", "" /* blockName->c_str() */, "");
+ error(loc, "nameless block contains a member that already has a name at global scope",
+ "" /* blockName->c_str() */, "");
else
error(loc, "block instance name redefinition", variable.getName().c_str(), "");
memberQualifier.layoutLocation = nextLocation;
memberQualifier.layoutComponent = 0;
}
- nextLocation = memberQualifier.layoutLocation + intermediate.computeTypeLocationSize(*typeList[member].type);
+ nextLocation = memberQualifier.layoutLocation +
+ intermediate.computeTypeLocationSize(*typeList[member].type);
}
}
}
int dummyStride;
int memberAlignment = intermediate.getBaseAlignment(*typeList[member].type, memberSize, dummyStride,
qualifier.layoutPacking == ElpStd140,
- subMatrixLayout != ElmNone ? subMatrixLayout == ElmRowMajor
- : qualifier.layoutMatrix == ElmRowMajor);
+ subMatrixLayout != ElmNone
+ ? subMatrixLayout == ElmRowMajor
+ : qualifier.layoutMatrix == ElmRowMajor);
if (memberQualifier.hasOffset()) {
// "The specified offset must be a multiple
// of the base alignment of the type of the block member it qualifies, or a compile-time error results."
case ElgIsolines:
break;
default:
- error(loc, "cannot apply to input", TQualifier::getGeometryString(publicType.shaderQualifiers.geometry), "");
+ error(loc, "cannot apply to input", TQualifier::getGeometryString(publicType.shaderQualifiers.geometry),
+ "");
}
} else if (publicType.qualifier.storage == EvqVaryingOut) {
handleOutputGeometry(loc, publicType.shaderQualifiers.geometry);
} else
- error(loc, "cannot apply to:", TQualifier::getGeometryString(publicType.shaderQualifiers.geometry), GetStorageQualifierString(publicType.qualifier.storage));
+ error(loc, "cannot apply to:", TQualifier::getGeometryString(publicType.shaderQualifiers.geometry),
+ GetStorageQualifierString(publicType.qualifier.storage));
}
if (publicType.shaderQualifiers.spacing != EvsNone)
intermediate.setVertexSpacing(publicType.shaderQualifiers.spacing);
globalOutputDefaults.layoutXfbBuffer = qualifier.layoutXfbBuffer;
if (globalOutputDefaults.hasXfbBuffer() && qualifier.hasXfbStride()) {
if (! intermediate.setXfbBufferStride(globalOutputDefaults.layoutXfbBuffer, qualifier.layoutXfbStride))
- error(loc, "all stride settings must match for xfb buffer", "xfb_stride", "%d", qualifier.layoutXfbBuffer);
+ error(loc, "all stride settings must match for xfb buffer", "xfb_stride", "%d",
+ qualifier.layoutXfbBuffer);
}
break;
default:
// Turn the top-level node sequence built up of wrapupSwitchSubsequence
// into a switch node.
//
-TIntermNode* HlslParseContext::addSwitch(const TSourceLoc& loc, TIntermTyped* expression, TIntermAggregate* lastStatements, TSelectionControl control)
+TIntermNode* HlslParseContext::addSwitch(const TSourceLoc& loc, TIntermTyped* expression,
+ TIntermAggregate* lastStatements, TSelectionControl control)
{
wrapupSwitchSubsequence(lastStatements, nullptr);
TIntermSymbol* pcfResultVar = intermediate.addSymbol(*pcfCallResult, loc);
TIntermNode* pcfResultAssign = handleAssign(loc, EOpAssign, pcfResultVar, pcfCall);
- TIntermNode* pcfResultToOut = handleAssign(loc, EOpAssign, pcfOutputSym, intermediate.addSymbol(*pcfCallResult, loc));
+ TIntermNode* pcfResultToOut = handleAssign(loc, EOpAssign, pcfOutputSym,
+ intermediate.addSymbol(*pcfCallResult, loc));
pcfCallSequence = intermediate.growAggregate(pcfCallSequence, pcfResultAssign);
pcfCallSequence = intermediate.growAggregate(pcfCallSequence, pcfResultToOut);