summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jannik Vogel2016-05-23 16:03:11 +0200
committerGravatar Jannik Vogel2016-06-07 00:06:28 +0200
commitc900c092e329d2e78b9663c1c3fe401da7faaea5 (patch)
tree63c3eb37dd9871f04fad9e3b4f772d4b58e16817 /src
parentMerge pull request #1873 from archshift/remove-config (diff)
downloadyuzu-c900c092e329d2e78b9663c1c3fe401da7faaea5.tar.gz
yuzu-c900c092e329d2e78b9663c1c3fe401da7faaea5.tar.xz
yuzu-c900c092e329d2e78b9663c1c3fe401da7faaea5.zip
OpenGL: Avoid undefined behaviour for UNIFORM_BLOCK_DATA_SIZE
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h10
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.cpp4
2 files changed, 8 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index bb7f20161..bdc7bd0f2 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -316,16 +316,18 @@ private:
316 GLfloat dist_atten_scale; 316 GLfloat dist_atten_scale;
317 }; 317 };
318 318
319 /// Uniform structure for the Uniform Buffer Object, all members must be 16-byte aligned 319 /// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned
320 // NOTE: Always keep a vec4 at the end. The GL spec is not clear wether the alignment at
321 // the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not.
322 // Not following that rule will cause problems on some AMD drivers.
320 struct UniformData { 323 struct UniformData {
321 // A vec4 color for each of the six tev stages
322 GLvec4 const_color[6];
323 GLvec4 tev_combiner_buffer_color;
324 GLint alphatest_ref; 324 GLint alphatest_ref;
325 GLfloat depth_scale; 325 GLfloat depth_scale;
326 GLfloat depth_offset; 326 GLfloat depth_offset;
327 alignas(16) GLvec3 lighting_global_ambient; 327 alignas(16) GLvec3 lighting_global_ambient;
328 LightSrc light_src[8]; 328 LightSrc light_src[8];
329 alignas(16) GLvec4 const_color[6]; // A vec4 color for each of the six tev stages
330 alignas(16) GLvec4 tev_combiner_buffer_color;
329 }; 331 };
330 332
331 static_assert(sizeof(UniformData) == 0x390, "The size of the UniformData structure has changed, update the structure in the shader"); 333 static_assert(sizeof(UniformData) == 0x390, "The size of the UniformData structure has changed, update the structure in the shader");
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp
index 8332e722d..ea7ab2883 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp
@@ -552,13 +552,13 @@ struct LightSrc {
552}; 552};
553 553
554layout (std140) uniform shader_data { 554layout (std140) uniform shader_data {
555 vec4 const_color[NUM_TEV_STAGES];
556 vec4 tev_combiner_buffer_color;
557 int alphatest_ref; 555 int alphatest_ref;
558 float depth_scale; 556 float depth_scale;
559 float depth_offset; 557 float depth_offset;
560 vec3 lighting_global_ambient; 558 vec3 lighting_global_ambient;
561 LightSrc light_src[NUM_LIGHTS]; 559 LightSrc light_src[NUM_LIGHTS];
560 vec4 const_color[NUM_TEV_STAGES];
561 vec4 tev_combiner_buffer_color;
562}; 562};
563 563
564uniform sampler2D tex[3]; 564uniform sampler2D tex[3];