HLSL: Allow use of $Global members in between function calls.
This allows global initializers to use $Global members.
This commit is contained in:
@@ -1513,11 +1513,6 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
|
||||
// rest of this function doesn't care.
|
||||
entryPointTree = transformEntryPoint(loc, function, attributes);
|
||||
|
||||
// Insert the $Global constant buffer.
|
||||
// TODO: this design fails if new members are declared between function definitions.
|
||||
if (! insertGlobalUniformBlock())
|
||||
error(loc, "failed to insert the global constant buffer", "uniform", "");
|
||||
|
||||
//
|
||||
// New symbol table scope for body of function plus its arguments
|
||||
//
|
||||
@@ -6701,13 +6696,6 @@ void HlslParseContext::declareBlock(const TSourceLoc& loc, TType& type, const TS
|
||||
trackLinkage(variable);
|
||||
}
|
||||
|
||||
void HlslParseContext::finalizeGlobalUniformBlockLayout(TVariable& block)
|
||||
{
|
||||
block.getWritableType().getQualifier().layoutPacking = ElpStd140;
|
||||
block.getWritableType().getQualifier().layoutMatrix = ElmRowMajor;
|
||||
fixBlockUniformOffsets(block.getType().getQualifier(), *block.getWritableType().getWritableStruct());
|
||||
}
|
||||
|
||||
//
|
||||
// "For a block, this process applies to the entire block, or until the first member
|
||||
// is reached that has a location layout qualifier. When a block member is declared with a location
|
||||
|
||||
@@ -54,7 +54,12 @@ public:
|
||||
|
||||
void setLimits(const TBuiltInResource&) override;
|
||||
bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false) override;
|
||||
virtual const char* getGlobalUniformBlockName() override { return "$Global"; }
|
||||
virtual const char* getGlobalUniformBlockName() const override { return "$Global"; }
|
||||
virtual void setUniformBlockDefaults(TType& block) const override
|
||||
{
|
||||
block.getQualifier().layoutPacking = ElpStd140;
|
||||
block.getQualifier().layoutMatrix = ElmRowMajor;
|
||||
}
|
||||
|
||||
void reservedPpErrorCheck(const TSourceLoc&, const char* /*name*/, const char* /*op*/) override { }
|
||||
bool lineContinuationCheck(const TSourceLoc&, bool /*endOfComment*/) override { return true; }
|
||||
@@ -140,7 +145,6 @@ public:
|
||||
TIntermTyped* constructAggregate(TIntermNode*, const TType&, int, const TSourceLoc&);
|
||||
TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermTyped*, const TSourceLoc&, bool subset);
|
||||
void declareBlock(const TSourceLoc&, TType&, const TString* instanceName = 0, TArraySizes* arraySizes = 0);
|
||||
void finalizeGlobalUniformBlockLayout(TVariable& block) override;
|
||||
void fixBlockLocations(const TSourceLoc&, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation);
|
||||
void fixBlockXfbOffsets(TQualifier&, TTypeList&);
|
||||
void fixBlockUniformOffsets(const TQualifier&, TTypeList&);
|
||||
|
||||
Reference in New Issue
Block a user