mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-15 06:10:05 +00:00
Non-functional: Factor out entry-point logic from handleFunctionDefinition().
This commit is contained in:
parent
33dadd1287
commit
94dfb7a523
@ -2,5 +2,5 @@
|
||||
// For the version, it uses the latest git tag followed by the number of commits.
|
||||
// For the date, it uses the current date (when then script is run).
|
||||
|
||||
#define GLSLANG_REVISION "Overload400-PrecQual.1770"
|
||||
#define GLSLANG_DATE "13-Jan-2017"
|
||||
#define GLSLANG_REVISION "Overload400-PrecQual.1772"
|
||||
#define GLSLANG_DATE "18-Jan-2017"
|
||||
|
@ -1572,20 +1572,9 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
|
||||
currentFunctionType = new TType(EbtVoid);
|
||||
functionReturnsValue = false;
|
||||
|
||||
inEntryPoint = function.getName().compare(intermediate.getEntryPointName().c_str()) == 0;
|
||||
if (inEntryPoint) {
|
||||
intermediate.setEntryPointMangledName(function.getMangledName().c_str());
|
||||
intermediate.incrementEntryPointCount();
|
||||
remapEntryPointIO(function);
|
||||
if (entryPointOutput) {
|
||||
if (shouldFlatten(entryPointOutput->getType()))
|
||||
flatten(loc, *entryPointOutput);
|
||||
if (shouldSplit(entryPointOutput->getType()))
|
||||
split(*entryPointOutput);
|
||||
assignLocations(*entryPointOutput);
|
||||
}
|
||||
} else
|
||||
remapNonEntryPointIO(function);
|
||||
// Entry points need different I/O and other handling, transform it so the
|
||||
// rest of this function doesn't care.
|
||||
transformEntryPoint(loc, function, attributes);
|
||||
|
||||
// Insert the $Global constant buffer.
|
||||
// TODO: this design fails if new members are declared between function definitions.
|
||||
@ -1649,23 +1638,47 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
|
||||
controlFlowNestingLevel = 0;
|
||||
postEntryPointReturn = false;
|
||||
|
||||
// Handle function attributes
|
||||
if (inEntryPoint) {
|
||||
const TIntermAggregate* numThreads = attributes[EatNumThreads];
|
||||
if (numThreads != nullptr) {
|
||||
const TIntermSequence& sequence = numThreads->getSequence();
|
||||
return paramNodes;
|
||||
}
|
||||
|
||||
for (int lid = 0; lid < int(sequence.size()); ++lid)
|
||||
intermediate.setLocalSize(lid, sequence[lid]->getAsConstantUnion()->getConstArray()[0].getIConst());
|
||||
}
|
||||
//
|
||||
// Do all special handling for the entry point.
|
||||
//
|
||||
void HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunction& function, const TAttributeMap& attributes)
|
||||
{
|
||||
inEntryPoint = function.getName().compare(intermediate.getEntryPointName().c_str()) == 0;
|
||||
|
||||
const TIntermAggregate* maxVertexCount = attributes[EatMaxVertexCount];
|
||||
if (maxVertexCount != nullptr) {
|
||||
intermediate.setVertices(maxVertexCount->getSequence()[0]->getAsConstantUnion()->getConstArray()[0].getIConst());
|
||||
}
|
||||
if (!inEntryPoint) {
|
||||
remapNonEntryPointIO(function);
|
||||
return;
|
||||
}
|
||||
|
||||
return paramNodes;
|
||||
// entry point logic...
|
||||
|
||||
intermediate.setEntryPointMangledName(function.getMangledName().c_str());
|
||||
intermediate.incrementEntryPointCount();
|
||||
|
||||
// Handle parameters and return value
|
||||
remapEntryPointIO(function);
|
||||
if (entryPointOutput) {
|
||||
if (shouldFlatten(entryPointOutput->getType()))
|
||||
flatten(loc, *entryPointOutput);
|
||||
if (shouldSplit(entryPointOutput->getType()))
|
||||
split(*entryPointOutput);
|
||||
assignLocations(*entryPointOutput);
|
||||
}
|
||||
|
||||
// Handle function attributes
|
||||
const TIntermAggregate* numThreads = attributes[EatNumThreads];
|
||||
if (numThreads != nullptr) {
|
||||
const TIntermSequence& sequence = numThreads->getSequence();
|
||||
|
||||
for (int lid = 0; lid < int(sequence.size()); ++lid)
|
||||
intermediate.setLocalSize(lid, sequence[lid]->getAsConstantUnion()->getConstArray()[0].getIConst());
|
||||
}
|
||||
const TIntermAggregate* maxVertexCount = attributes[EatMaxVertexCount];
|
||||
if (maxVertexCount != nullptr)
|
||||
intermediate.setVertices(maxVertexCount->getSequence()[0]->getAsConstantUnion()->getConstArray()[0].getIConst());
|
||||
}
|
||||
|
||||
void HlslParseContext::handleFunctionBody(const TSourceLoc& loc, TFunction& function, TIntermNode* functionBody, TIntermNode*& node)
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
void assignLocations(TVariable& variable);
|
||||
TFunction& handleFunctionDeclarator(const TSourceLoc&, TFunction& function, bool prototype);
|
||||
TIntermAggregate* handleFunctionDefinition(const TSourceLoc&, TFunction&, const TAttributeMap&);
|
||||
void transformEntryPoint(const TSourceLoc&, TFunction&, const TAttributeMap&);
|
||||
void handleFunctionBody(const TSourceLoc&, TFunction&, TIntermNode* functionBody, TIntermNode*& node);
|
||||
void remapEntryPointIO(TFunction& function);
|
||||
void remapNonEntryPointIO(TFunction& function);
|
||||
|
Loading…
Reference in New Issue
Block a user