Add full support for uniform structs.
TRAC #23750
Signed-off-by: Geoff Lang
Signed-off-by: Nicolas Capens
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 28d9812..f0093ab 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -3596,16 +3596,16 @@
{
const bool isRowMajorMatrix = (type.isMatrix() && type.getLayoutQualifier().matrixPacking == EmpRowMajor);
Uniform uniform(glVariableType(type), glVariablePrecision(type), name.c_str(),
- (unsigned int)type.getArraySize(), (unsigned int)registerIndex);
+ (unsigned int)type.getArraySize(), (unsigned int)registerIndex, 0);
output.push_back(uniform);
return uniform;
}
else
{
- Uniform structUniform(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), (unsigned int)registerIndex);
+ Uniform structUniform(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(),
+ (unsigned int)registerIndex, GL_INVALID_INDEX);
- int fieldRegister = registerIndex;
const TFieldList &fields = structure->fields();
for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
@@ -3613,10 +3613,12 @@
TField *field = fields[fieldIndex];
TType *fieldType = field->type();
- const Uniform &fieldVariable = declareUniformToList(*fieldType, field->name(), fieldRegister, structUniform.fields);
- fieldRegister += HLSLVariableRegisterCount(fieldVariable);
+ declareUniformToList(*fieldType, field->name(), GL_INVALID_INDEX, structUniform.fields);
}
+ // assign register offset information -- this will override the information in any sub-structures.
+ HLSLVariableGetRegisterInfo(registerIndex, &structUniform);
+
output.push_back(structUniform);
return structUniform;