Add support for column/row major layout qualifiers in generated HLSL.
TRAC #23271
Signed-off-by: Nicolas Capens
Signed-off-by: Shannon Woods
Authored-by: Jamie Madill
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 9d2c5d7..f183ab5 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -214,17 +214,19 @@
TString OutputHLSL::interfaceBlockMemberTypeString(const TType &memberType)
{
- // TODO: layout support
+ const TLayoutMatrixPacking matrixPacking = memberType.getLayoutQualifier().matrixPacking;
+ ASSERT(matrixPacking != EmpUnspecified);
if (memberType.isMatrix())
{
// Use HLSL row-major packing for GLSL column-major matrices
- return "row_major " + typeString(memberType);
+ const TString &matrixPackString = (matrixPacking == EmpRowMajor ? "column_major" : "row_major");
+ return matrixPackString + " " + typeString(memberType);
}
else if (memberType.getBasicType() == EbtStruct)
{
// Use HLSL row-major packing for GLSL column-major matrices
- return structureTypeName(memberType, true);
+ return structureTypeName(memberType, matrixPacking == EmpColumnMajor);
}
else
{
@@ -287,16 +289,6 @@
ShShaderType shaderType = mContext.shaderType;
TInfoSinkBase &out = mHeader;
- for (StructDeclarations::iterator structDeclaration = mStructDeclarations.begin(); structDeclaration != mStructDeclarations.end(); structDeclaration++)
- {
- out << *structDeclaration;
- }
-
- for (Constructors::iterator constructor = mConstructors.begin(); constructor != mConstructors.end(); constructor++)
- {
- out << *constructor;
- }
-
TString uniforms;
TString interfaceBlocks;
TString interfaceBlockInit;
@@ -402,6 +394,16 @@
mActiveAttributes.push_back(shaderVar);
}
+ for (StructDeclarations::iterator structDeclaration = mStructDeclarations.begin(); structDeclaration != mStructDeclarations.end(); structDeclaration++)
+ {
+ out << *structDeclaration;
+ }
+
+ for (Constructors::iterator constructor = mConstructors.begin(); constructor != mConstructors.end(); constructor++)
+ {
+ out << *constructor;
+ }
+
if (shaderType == SH_FRAGMENT_SHADER)
{
TExtensionBehavior::const_iterator iter = mContext.extensionBehavior().find("GL_EXT_draw_buffers");