mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
OpenGL: Avoid undefined behaviour for UNIFORM_BLOCK_DATA_SIZE
This commit is contained in:
parent
e08fcb0df4
commit
c900c092e3
@ -316,16 +316,18 @@ private:
|
|||||||
GLfloat dist_atten_scale;
|
GLfloat dist_atten_scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Uniform structure for the Uniform Buffer Object, all members must be 16-byte aligned
|
/// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned
|
||||||
|
// NOTE: Always keep a vec4 at the end. The GL spec is not clear wether the alignment at
|
||||||
|
// the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not.
|
||||||
|
// Not following that rule will cause problems on some AMD drivers.
|
||||||
struct UniformData {
|
struct UniformData {
|
||||||
// A vec4 color for each of the six tev stages
|
|
||||||
GLvec4 const_color[6];
|
|
||||||
GLvec4 tev_combiner_buffer_color;
|
|
||||||
GLint alphatest_ref;
|
GLint alphatest_ref;
|
||||||
GLfloat depth_scale;
|
GLfloat depth_scale;
|
||||||
GLfloat depth_offset;
|
GLfloat depth_offset;
|
||||||
alignas(16) GLvec3 lighting_global_ambient;
|
alignas(16) GLvec3 lighting_global_ambient;
|
||||||
LightSrc light_src[8];
|
LightSrc light_src[8];
|
||||||
|
alignas(16) GLvec4 const_color[6]; // A vec4 color for each of the six tev stages
|
||||||
|
alignas(16) GLvec4 tev_combiner_buffer_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(UniformData) == 0x390, "The size of the UniformData structure has changed, update the structure in the shader");
|
static_assert(sizeof(UniformData) == 0x390, "The size of the UniformData structure has changed, update the structure in the shader");
|
||||||
|
@ -552,13 +552,13 @@ struct LightSrc {
|
|||||||
};
|
};
|
||||||
|
|
||||||
layout (std140) uniform shader_data {
|
layout (std140) uniform shader_data {
|
||||||
vec4 const_color[NUM_TEV_STAGES];
|
|
||||||
vec4 tev_combiner_buffer_color;
|
|
||||||
int alphatest_ref;
|
int alphatest_ref;
|
||||||
float depth_scale;
|
float depth_scale;
|
||||||
float depth_offset;
|
float depth_offset;
|
||||||
vec3 lighting_global_ambient;
|
vec3 lighting_global_ambient;
|
||||||
LightSrc light_src[NUM_LIGHTS];
|
LightSrc light_src[NUM_LIGHTS];
|
||||||
|
vec4 const_color[NUM_TEV_STAGES];
|
||||||
|
vec4 tev_combiner_buffer_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
uniform sampler2D tex[3];
|
uniform sampler2D tex[3];
|
||||||
|
Loading…
Reference in New Issue
Block a user