2

I have this UBO:

layout(std140)uniform _ObjMatrix
{
    layout(row_major)mat4x3 ViewMatrix[256];
};

On OpenGL desktop, the size is 3*Vec4*256 elements (total size 12288 bytes) - this is what I was expecting = OK

However when running on my mobile phone, OpenGL ES 3.0, the size is 4*Vec4*256 elements (total size 16384 bytes) = Not OK

I thought std140 should guarantee same layout on all platforms?

So what's the problem and how to fix it?

I need the smaller size for faster performance (because of smaller bandwidth for transfers)

Works OK on Desktop, Apple iOS, but fails on 2 Android ARM Mali GPU's, perhaps it's a bug in ARM Mali drivers

solidpixel
  • 10,688
  • 1
  • 20
  • 33
Esenthel
  • 499
  • 4
  • 17
  • Just to avoid duplicated effort - I answered this one over on the community.arm.com forums. It looks like a Mali driver bug handling non-square row-major matrices. – solidpixel Jul 30 '19 at 10:08

1 Answers1

3

This is a confirmed Mali driver bug which affects row_major annotation for array declarations. The workaround is to apply the row_major annotation to the uniform block rather than the array element:

layout(std140, row_major) uniform _ObjMatrix {
    mat4x3 ViewMatrix[256];
};
solidpixel
  • 10,688
  • 1
  • 20
  • 33