Fix mat2 alignment
This commit is contained in:
parent
0041efec1d
commit
de8f43d95d
@ -2184,10 +2184,15 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
|
|||||||
Transform2D v = value;
|
Transform2D v = value;
|
||||||
GLfloat *gui = (GLfloat *)data;
|
GLfloat *gui = (GLfloat *)data;
|
||||||
|
|
||||||
|
//in std140 members of mat2 are treated as vec4s
|
||||||
gui[0] = v.elements[0][0];
|
gui[0] = v.elements[0][0];
|
||||||
gui[1] = v.elements[0][1];
|
gui[1] = v.elements[0][1];
|
||||||
gui[2] = v.elements[1][0];
|
gui[2] = 0;
|
||||||
gui[3] = v.elements[1][1];
|
gui[3] = 0;
|
||||||
|
gui[4] = v.elements[1][0];
|
||||||
|
gui[5] = v.elements[1][1];
|
||||||
|
gui[6] = 0;
|
||||||
|
gui[7] = 0;
|
||||||
} break;
|
} break;
|
||||||
case ShaderLanguage::TYPE_MAT3: {
|
case ShaderLanguage::TYPE_MAT3: {
|
||||||
|
|
||||||
@ -2362,9 +2367,15 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
|
|||||||
case ShaderLanguage::TYPE_MAT2: {
|
case ShaderLanguage::TYPE_MAT2: {
|
||||||
GLfloat *gui = (GLfloat *)data;
|
GLfloat *gui = (GLfloat *)data;
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
//in std140 members of mat2 are treated as vec4s
|
||||||
gui[i] = value[i].real;
|
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;
|
} break;
|
||||||
case ShaderLanguage::TYPE_MAT3: {
|
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_BVEC4:
|
||||||
case ShaderLanguage::TYPE_IVEC4:
|
case ShaderLanguage::TYPE_IVEC4:
|
||||||
case ShaderLanguage::TYPE_UVEC4:
|
case ShaderLanguage::TYPE_UVEC4:
|
||||||
case ShaderLanguage::TYPE_VEC4:
|
case ShaderLanguage::TYPE_VEC4: {
|
||||||
case ShaderLanguage::TYPE_MAT2: {
|
|
||||||
|
|
||||||
zeromem(data, 16);
|
zeromem(data, 16);
|
||||||
} break;
|
} break;
|
||||||
|
case ShaderLanguage::TYPE_MAT2: {
|
||||||
|
|
||||||
|
zeromem(data, 32);
|
||||||
|
} break;
|
||||||
case ShaderLanguage::TYPE_MAT3: {
|
case ShaderLanguage::TYPE_MAT3: {
|
||||||
|
|
||||||
zeromem(data, 48);
|
zeromem(data, 48);
|
||||||
|
@ -71,9 +71,9 @@ static int _get_datatype_size(SL::DataType p_type) {
|
|||||||
case SL::TYPE_VEC3: return 12;
|
case SL::TYPE_VEC3: return 12;
|
||||||
case SL::TYPE_VEC4: return 16;
|
case SL::TYPE_VEC4: return 16;
|
||||||
case SL::TYPE_MAT2:
|
case SL::TYPE_MAT2:
|
||||||
return 24; //4 * 4 + 4 * 2
|
return 32; //4 * 4 + 4 * 4
|
||||||
case SL::TYPE_MAT3:
|
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_MAT4: return 64;
|
||||||
case SL::TYPE_SAMPLER2D: return 16;
|
case SL::TYPE_SAMPLER2D: return 16;
|
||||||
case SL::TYPE_ISAMPLER2D: return 16;
|
case SL::TYPE_ISAMPLER2D: return 16;
|
||||||
|
Loading…
Reference in New Issue
Block a user