Merge pull request #15633 from binbitten/fix-mat2-align

Fix mat2 alignment
This commit is contained in:
Rémi Verschelde 2018-01-13 01:39:20 +01:00 committed by GitHub
commit 4fd4b0399a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 9 deletions

View file

@ -2184,10 +2184,15 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
Transform2D v = value;
GLfloat *gui = (GLfloat *)data;
//in std140 members of mat2 are treated as vec4s
gui[0] = v.elements[0][0];
gui[1] = v.elements[0][1];
gui[2] = v.elements[1][0];
gui[3] = v.elements[1][1];
gui[2] = 0;
gui[3] = 0;
gui[4] = v.elements[1][0];
gui[5] = v.elements[1][1];
gui[6] = 0;
gui[7] = 0;
} break;
case ShaderLanguage::TYPE_MAT3: {
@ -2362,9 +2367,15 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
case ShaderLanguage::TYPE_MAT2: {
GLfloat *gui = (GLfloat *)data;
for (int i = 0; i < 2; i++) {
gui[i] = value[i].real;
}
//in std140 members of mat2 are treated as vec4s
gui[0] = value[0].real;
gui[1] = value[1].real;
gui[2] = 0;
gui[3] = 0;
gui[4] = value[2].real;
gui[5] = value[3].real;
gui[6] = 0;
gui[7] = 0;
} break;
case ShaderLanguage::TYPE_MAT3: {
@ -2418,11 +2429,14 @@ _FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type,
case ShaderLanguage::TYPE_BVEC4:
case ShaderLanguage::TYPE_IVEC4:
case ShaderLanguage::TYPE_UVEC4:
case ShaderLanguage::TYPE_VEC4:
case ShaderLanguage::TYPE_MAT2: {
case ShaderLanguage::TYPE_VEC4: {
zeromem(data, 16);
} break;
case ShaderLanguage::TYPE_MAT2: {
zeromem(data, 32);
} break;
case ShaderLanguage::TYPE_MAT3: {
zeromem(data, 48);

View file

@ -71,9 +71,9 @@ static int _get_datatype_size(SL::DataType p_type) {
case SL::TYPE_VEC3: return 12;
case SL::TYPE_VEC4: return 16;
case SL::TYPE_MAT2:
return 24; //4 * 4 + 4 * 2
return 32; //4 * 4 + 4 * 4
case SL::TYPE_MAT3:
return 44; // 4 * 4 + 4 * 4 + 4 * 3
return 48; // 4 * 4 + 4 * 4 + 4 * 4
case SL::TYPE_MAT4: return 64;
case SL::TYPE_SAMPLER2D: return 16;
case SL::TYPE_ISAMPLER2D: return 16;