HLSL: non-static member functions: track and find active anonymous 'this' scopes and members.
Thanks to @steve-lunarg for his input and discussions on handling member functions.
This commit is contained in:
@@ -2743,12 +2743,16 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
||||
std::vector<spv::Decoration> paramPrecisions;
|
||||
glslang::TIntermSequence& parameters = glslFunction->getSequence()[0]->getAsAggregate()->getSequence();
|
||||
|
||||
bool implicitThis = (int)parameters.size() > 0 && parameters[0]->getAsSymbolNode()->getName() == glslangIntermediate->implicitThisName;
|
||||
|
||||
for (int p = 0; p < (int)parameters.size(); ++p) {
|
||||
const glslang::TType& paramType = parameters[p]->getAsTyped()->getType();
|
||||
spv::Id typeId = convertGlslangToSpvType(paramType);
|
||||
if (paramType.containsOpaque() ||
|
||||
// can we pass by reference?
|
||||
if (paramType.containsOpaque() || // sampler, etc.
|
||||
(paramType.getBasicType() == glslang::EbtBlock &&
|
||||
paramType.getQualifier().storage == glslang::EvqBuffer))
|
||||
paramType.getQualifier().storage == glslang::EvqBuffer) || // SSBO
|
||||
p == 0 && implicitThis) // implicit 'this'
|
||||
typeId = builder.makePointer(TranslateStorageClass(paramType), typeId);
|
||||
else if (paramType.getQualifier().storage != glslang::EvqConstReadOnly)
|
||||
typeId = builder.makePointer(spv::StorageClassFunction, typeId);
|
||||
@@ -2762,6 +2766,8 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
||||
spv::Function *function = builder.makeFunctionEntry(TranslatePrecisionDecoration(glslFunction->getType()),
|
||||
convertGlslangToSpvType(glslFunction->getType()),
|
||||
glslFunction->getName().c_str(), paramTypes, paramPrecisions, &functionBlock);
|
||||
if (implicitThis)
|
||||
function->setImplicitThis();
|
||||
|
||||
// Track function to emit/call later
|
||||
functionMap[glslFunction->getName().c_str()] = function;
|
||||
@@ -3233,7 +3239,8 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
|
||||
const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType();
|
||||
spv::Id arg;
|
||||
if (paramType.containsOpaque() ||
|
||||
(paramType.getBasicType() == glslang::EbtBlock && qualifiers[a] == glslang::EvqBuffer)) {
|
||||
(paramType.getBasicType() == glslang::EbtBlock && qualifiers[a] == glslang::EvqBuffer) ||
|
||||
(a == 0 && function->hasImplicitThis())) {
|
||||
builder.setAccessChain(lValues[lValueCount]);
|
||||
arg = builder.accessChainGetLValue();
|
||||
++lValueCount;
|
||||
|
||||
Reference in New Issue
Block a user