diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-01-13 01:39:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-13 01:39:20 +0100 |
commit | 4fd4b0399a4cedfc44eefd5ca27e7541d523c4ea (patch) | |
tree | 5afc870f28d3f749f1d40210d014592bedb2d975 /drivers/gles3 | |
parent | 702e28f2657b3b0f50c1e118caf207c0a438f8f1 (diff) | |
parent | de8f43d95dcf92334ad2a50cd93d3ca6a0c3efd4 (diff) |
Merge pull request #15633 from binbitten/fix-mat2-align
Fix mat2 alignment
Diffstat (limited to 'drivers/gles3')
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 28 | ||||
-rw-r--r-- | drivers/gles3/shader_compiler_gles3.cpp | 4 |
2 files changed, 23 insertions, 9 deletions
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 8452afb045..7dc4f71b8e 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -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); diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 945970c6b4..f1d7085d54 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -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; |