mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-06 04:28:24 +02:00
gl-renderer: share color mapping union for gl_shader_config
Reduce divergence between the structs to maybe allow more consolidation in the future. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
77015ae226
commit
9ce3ce4250
3 changed files with 19 additions and 30 deletions
|
|
@ -344,6 +344,15 @@ union gl_shader_config_color_curve {
|
|||
} parametric;
|
||||
};
|
||||
|
||||
union gl_shader_config_color_mapping {
|
||||
struct {
|
||||
GLuint tex3d;
|
||||
float scale;
|
||||
float offset;
|
||||
} lut3d;
|
||||
struct weston_color_mapping_matrix mat;
|
||||
};
|
||||
|
||||
struct gl_shader_config {
|
||||
struct gl_shader_requirements req;
|
||||
|
||||
|
|
@ -360,15 +369,7 @@ struct gl_shader_config {
|
|||
GLuint wireframe_tex;
|
||||
|
||||
union gl_shader_config_color_curve color_pre_curve;
|
||||
|
||||
union {
|
||||
struct {
|
||||
GLuint tex;
|
||||
GLfloat scale_offset[2];
|
||||
} lut3d;
|
||||
GLfloat matrix[9];
|
||||
} color_mapping;
|
||||
|
||||
union gl_shader_config_color_mapping color_mapping;
|
||||
union gl_shader_config_color_curve color_post_curve;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -45,14 +45,7 @@ struct gl_renderer_color_curve {
|
|||
|
||||
struct gl_renderer_color_mapping {
|
||||
enum gl_shader_color_mapping type;
|
||||
union {
|
||||
struct {
|
||||
GLuint tex3d;
|
||||
float scale;
|
||||
float offset;
|
||||
} lut3d;
|
||||
struct weston_color_mapping_matrix mat;
|
||||
} u;
|
||||
union gl_shader_config_color_mapping u;
|
||||
};
|
||||
|
||||
struct gl_renderer_color_transform {
|
||||
|
|
@ -395,20 +388,15 @@ gl_shader_config_set_color_transform(struct gl_renderer *gr,
|
|||
sconf->color_post_curve = gl_xform->post_curve.u;
|
||||
|
||||
sconf->req.color_mapping = gl_xform->mapping.type;
|
||||
sconf->color_mapping = gl_xform->mapping.u;
|
||||
switch (gl_xform->mapping.type) {
|
||||
case SHADER_COLOR_MAPPING_3DLUT:
|
||||
sconf->color_mapping.lut3d.tex = gl_xform->mapping.u.lut3d.tex3d;
|
||||
sconf->color_mapping.lut3d.scale_offset[0] =
|
||||
gl_xform->mapping.u.lut3d.scale;
|
||||
sconf->color_mapping.lut3d.scale_offset[1] =
|
||||
gl_xform->mapping.u.lut3d.offset;
|
||||
assert(sconf->color_mapping.lut3d.scale_offset[0] > 0.0);
|
||||
assert(sconf->color_mapping.lut3d.scale_offset[1] > 0.0);
|
||||
assert(sconf->color_mapping.lut3d.scale > 0.0);
|
||||
assert(sconf->color_mapping.lut3d.offset > 0.0);
|
||||
ret = true;
|
||||
break;
|
||||
case SHADER_COLOR_MAPPING_MATRIX:
|
||||
assert(sconf->req.color_mapping == SHADER_COLOR_MAPPING_MATRIX);
|
||||
ARRAY_COPY(sconf->color_mapping.matrix, gl_xform->mapping.u.mat.matrix.colmaj);
|
||||
ret = true;
|
||||
break;
|
||||
case SHADER_COLOR_MAPPING_IDENTITY:
|
||||
|
|
|
|||
|
|
@ -757,20 +757,20 @@ gl_shader_load_config(struct gl_renderer *gr,
|
|||
break;
|
||||
case SHADER_COLOR_MAPPING_3DLUT:
|
||||
assert(shader->color_mapping.lut3d.tex_uniform != -1);
|
||||
assert(sconf->color_mapping.lut3d.tex != 0);
|
||||
assert(sconf->color_mapping.lut3d.tex3d != 0);
|
||||
assert(shader->color_mapping.lut3d.scale_offset_uniform != -1);
|
||||
glActiveTexture(GL_TEXTURE0 + TEX_UNIT_COLOR_MAPPING);
|
||||
glBindTexture(GL_TEXTURE_3D, sconf->color_mapping.lut3d.tex);
|
||||
glBindTexture(GL_TEXTURE_3D, sconf->color_mapping.lut3d.tex3d);
|
||||
glUniform1i(shader->color_mapping.lut3d.tex_uniform,
|
||||
TEX_UNIT_COLOR_MAPPING);
|
||||
glUniform2fv(shader->color_mapping.lut3d.scale_offset_uniform,
|
||||
1, sconf->color_mapping.lut3d.scale_offset);
|
||||
glUniform2f(shader->color_mapping.lut3d.scale_offset_uniform,
|
||||
sconf->color_mapping.lut3d.scale, sconf->color_mapping.lut3d.offset);
|
||||
break;
|
||||
case SHADER_COLOR_MAPPING_MATRIX:
|
||||
assert(shader->color_mapping.matrix_uniform != -1);
|
||||
glUniformMatrix3fv(shader->color_mapping.matrix_uniform,
|
||||
1, GL_FALSE,
|
||||
sconf->color_mapping.matrix);
|
||||
sconf->color_mapping.mat.matrix.colmaj);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue