Commit b4e664b1 by Jamie Madill Committed by Shannon Woods

Alter array instanced uniform buffer objects to use direct references to HLSL constant buffers.

This avoids using a shader scoped static storage buffer, with copies. TRAC #23299 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Authored-by: Jamie Madill
parent 529077d9
...@@ -291,7 +291,6 @@ void OutputHLSL::header() ...@@ -291,7 +291,6 @@ void OutputHLSL::header()
TString uniforms; TString uniforms;
TString interfaceBlocks; TString interfaceBlocks;
TString interfaceBlockInit;
TString varyings; TString varyings;
TString attributes; TString attributes;
...@@ -346,16 +345,9 @@ void OutputHLSL::header() ...@@ -346,16 +345,9 @@ void OutputHLSL::header()
if (arraySize > 0) if (arraySize > 0)
{ {
interfaceBlocks += "static " + interfaceBlockStructName(interfaceBlockType) + " " + decorate(interfaceBlockType.getInstanceName()) +
arrayString(interfaceBlockType) + ";\n\n";
for (unsigned int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) for (unsigned int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++)
{ {
interfaceBlocks += interfaceBlockString(interfaceBlockType, interfaceBlock.registerIndex + arrayIndex, arrayIndex); interfaceBlocks += interfaceBlockString(interfaceBlockType, interfaceBlock.registerIndex + arrayIndex, arrayIndex);
const TString &instanceName = interfaceBlockType.getInstanceName();
interfaceBlockInit += " " + decorate(instanceName) + "[" + str(arrayIndex) + "] = " +
interfaceBlockInstanceString(interfaceBlockType, arrayIndex) + ";\n";
} }
} }
else else
...@@ -364,14 +356,6 @@ void OutputHLSL::header() ...@@ -364,14 +356,6 @@ void OutputHLSL::header()
} }
} }
if (!interfaceBlockInit.empty())
{
interfaceBlocks += "void dx_initConstantBuffers()\n"
"{\n" +
interfaceBlockInit +
"}\n\n";
}
for (ReferencedSymbols::const_iterator varying = mReferencedVaryings.begin(); varying != mReferencedVaryings.end(); varying++) for (ReferencedSymbols::const_iterator varying = mReferencedVaryings.begin(); varying != mReferencedVaryings.end(); varying++)
{ {
const TType &type = varying->second->getType(); const TType &type = varying->second->getType();
...@@ -1566,8 +1550,27 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) ...@@ -1566,8 +1550,27 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
} }
break; break;
case EOpDivAssign: outputTriplet(visit, "(", " /= ", ")"); break; case EOpDivAssign: outputTriplet(visit, "(", " /= ", ")"); break;
case EOpIndexDirect: outputTriplet(visit, "", "[", "]"); break; case EOpIndexDirect:
case EOpIndexIndirect: outputTriplet(visit, "", "[", "]"); break; if (node->getLeft()->getBasicType() == EbtInterfaceBlock)
{
if (visit == PreVisit)
{
const TType &interfaceBlockType = node->getLeft()->getType();
mReferencedInterfaceBlocks[interfaceBlockType.getInstanceName()] = node->getLeft()->getAsSymbolNode();
out << interfaceBlockInstanceString(interfaceBlockType, node->getRight()->getAsConstantUnion()->getIConst(0));
return false;
}
}
else
{
outputTriplet(visit, "", "[", "]");
}
break;
case EOpIndexIndirect:
// We do not currently support indirect references to interface blocks
ASSERT(node->getLeft()->getBasicType() != EbtInterfaceBlock);
outputTriplet(visit, "", "[", "]");
break;
case EOpIndexDirectStruct: case EOpIndexDirectStruct:
case EOpIndexDirectInterfaceBlock: case EOpIndexDirectInterfaceBlock:
if (visit == InVisit) if (visit == InVisit)
......
...@@ -1265,12 +1265,6 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, int registers, const Varying ...@@ -1265,12 +1265,6 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, int registers, const Varying
vertexHLSL += "(input." + decorateAttribute(attribute.name) + ");\n"; vertexHLSL += "(input." + decorateAttribute(attribute.name) + ");\n";
} }
if (vertexHLSL.find("dx_initConstantBuffers") != std::string::npos)
{
vertexHLSL += "\n"
" dx_initConstantBuffers();\n";
}
if (shaderModel >= 4) if (shaderModel >= 4)
{ {
vertexHLSL += "\n" vertexHLSL += "\n"
...@@ -1534,12 +1528,6 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, int registers, const Varying ...@@ -1534,12 +1528,6 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, int registers, const Varying
else UNREACHABLE(); else UNREACHABLE();
} }
if (pixelHLSL.find("dx_initConstantBuffers") != std::string::npos)
{
pixelHLSL += "\n"
" dx_initConstantBuffers();\n";
}
pixelHLSL += "\n" pixelHLSL += "\n"
" gl_main();\n" " gl_main();\n"
"\n" "\n"
......
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