Uniform block related fixes
- The rowMajor qualifier should only be set for matrices
- Shared and std140 layouts are always considered active
- Fixed registerSize() for uniform blocks
Change-Id: Id0ccd4f1f1c3342915643d87e166234e61b83f4f
Reviewed-on: https://swiftshader-review.googlesource.com/4631
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/compiler/OutputASM.cpp b/src/OpenGL/compiler/OutputASM.cpp
index 76bedfa..14f5674 100644
--- a/src/OpenGL/compiler/OutputASM.cpp
+++ b/src/OpenGL/compiler/OutputASM.cpp
@@ -103,7 +103,7 @@
const BlockMemberInfo memberInfo(static_cast<int>(mCurrentOffset * BytesPerComponent),
static_cast<int>(arrayStride * BytesPerComponent),
static_cast<int>(matrixStride * BytesPerComponent),
- isRowMajor);
+ (matrixStride > 0) && isRowMajor);
advanceOffset(type, type.getArraySize(), isRowMajor, arrayStride, matrixStride);
@@ -451,6 +451,16 @@
declareVarying(symbol, -1);
}
}
+
+ TInterfaceBlock* block = symbol->getType().getInterfaceBlock();
+ // OpenGL ES 3.0.4 spec, section 2.12.6 Uniform Variables:
+ // "All members of a named uniform block declared with a shared or std140 layout qualifier
+ // are considered active, even if they are not referenced in any shader in the program.
+ // The uniform block itself is also considered active, even if no member of the block is referenced."
+ if(block && ((block->blockStorage() == EbsShared) || (block->blockStorage() == EbsStd140)))
+ {
+ uniformRegister(symbol);
+ }
}
bool OutputASM::visitBinary(Visit visit, TIntermBinary *node)
@@ -2012,6 +2022,10 @@
{
return registerSize(*((*(type.getStruct()->fields().begin()))->type()), 0);
}
+ else if(type.isInterfaceBlock())
+ {
+ return registerSize(*((*(type.getInterfaceBlock()->fields().begin()))->type()), 0);
+ }
return type.registerSize();
}