wined3d: Store the sRGB constants as wined3d_vec4 structures.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2019-08-19 16:24:29 +04:30 committed by Alexandre Julliard
parent f193979a18
commit 000eab8727
4 changed files with 19 additions and 17 deletions

View File

@ -3668,10 +3668,10 @@ static GLuint shader_arb_generate_pshader(const struct wined3d_shader *shader,
if (args->super.srgb_correction) if (args->super.srgb_correction)
{ {
shader_addline(buffer, "PARAM srgb_consts0 = "); shader_addline(buffer, "PARAM srgb_consts0 = ");
shader_arb_append_imm_vec4(buffer, wined3d_srgb_const0); shader_arb_append_imm_vec4(buffer, &wined3d_srgb_const[0].x);
shader_addline(buffer, ";\n"); shader_addline(buffer, ";\n");
shader_addline(buffer, "PARAM srgb_consts1 = "); shader_addline(buffer, "PARAM srgb_consts1 = ");
shader_arb_append_imm_vec4(buffer, wined3d_srgb_const1); shader_arb_append_imm_vec4(buffer, &wined3d_srgb_const[1].x);
shader_addline(buffer, ";\n"); shader_addline(buffer, ";\n");
} }
@ -6371,10 +6371,10 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, con
if (settings->sRGB_write) if (settings->sRGB_write)
{ {
shader_addline(&buffer, "PARAM srgb_consts0 = "); shader_addline(&buffer, "PARAM srgb_consts0 = ");
shader_arb_append_imm_vec4(&buffer, wined3d_srgb_const0); shader_arb_append_imm_vec4(&buffer, &wined3d_srgb_const[0].x);
shader_addline(&buffer, ";\n"); shader_addline(&buffer, ";\n");
shader_addline(&buffer, "PARAM srgb_consts1 = "); shader_addline(&buffer, "PARAM srgb_consts1 = ");
shader_arb_append_imm_vec4(&buffer, wined3d_srgb_const1); shader_arb_append_imm_vec4(&buffer, &wined3d_srgb_const[1].x);
shader_addline(&buffer, ";\n"); shader_addline(&buffer, ";\n");
} }

View File

@ -7701,10 +7701,10 @@ static GLuint shader_glsl_generate_fragment_shader(const struct wined3d_context_
if (args->srgb_correction) if (args->srgb_correction)
{ {
shader_addline(buffer, "const vec4 srgb_const0 = "); shader_addline(buffer, "const vec4 srgb_const0 = ");
shader_glsl_append_imm_vec(buffer, wined3d_srgb_const0, 4, gl_info); shader_glsl_append_imm_vec(buffer, &wined3d_srgb_const[0].x, 4, gl_info);
shader_addline(buffer, ";\n"); shader_addline(buffer, ";\n");
shader_addline(buffer, "const vec4 srgb_const1 = "); shader_addline(buffer, "const vec4 srgb_const1 = ");
shader_glsl_append_imm_vec(buffer, wined3d_srgb_const1, 4, gl_info); shader_glsl_append_imm_vec(buffer, &wined3d_srgb_const[1].x, 4, gl_info);
shader_addline(buffer, ";\n"); shader_addline(buffer, ";\n");
} }
if (reg_maps->vpos || reg_maps->usesdsy) if (reg_maps->vpos || reg_maps->usesdsy)
@ -9555,10 +9555,10 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *
if (settings->sRGB_write) if (settings->sRGB_write)
{ {
shader_addline(buffer, "const vec4 srgb_const0 = "); shader_addline(buffer, "const vec4 srgb_const0 = ");
shader_glsl_append_imm_vec(buffer, wined3d_srgb_const0, 4, gl_info); shader_glsl_append_imm_vec(buffer, &wined3d_srgb_const[0].x, 4, gl_info);
shader_addline(buffer, ";\n"); shader_addline(buffer, ";\n");
shader_addline(buffer, "const vec4 srgb_const1 = "); shader_addline(buffer, "const vec4 srgb_const1 = ");
shader_glsl_append_imm_vec(buffer, wined3d_srgb_const1, 4, gl_info); shader_glsl_append_imm_vec(buffer, &wined3d_srgb_const[1].x, 4, gl_info);
shader_addline(buffer, ";\n"); shader_addline(buffer, ";\n");
} }

View File

@ -32,10 +32,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
/* pow, mul_high, sub_high, mul_low */ const struct wined3d_vec4 wined3d_srgb_const[] =
const float wined3d_srgb_const0[] = {0.41666f, 1.055f, 0.055f, 12.92f}; {
/* cmp */ /* pow, mul_high, sub_high, mul_low */
const float wined3d_srgb_const1[] = {0.0031308f, 0.0f, 0.0f, 0.0f}; {0.41666f, 1.055f, 0.055f, 12.92f},
/* cmp */
{0.0031308f, 0.0f, 0.0f, 0.0f},
};
static const char * const shader_opcode_names[] = static const char * const shader_opcode_names[] =
{ {

View File

@ -1482,17 +1482,16 @@ static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_col
wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f; wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
} }
extern const float wined3d_srgb_const0[] DECLSPEC_HIDDEN; extern const struct wined3d_vec4 wined3d_srgb_const[] DECLSPEC_HIDDEN;
extern const float wined3d_srgb_const1[] DECLSPEC_HIDDEN;
static inline float wined3d_srgb_from_linear(float colour) static inline float wined3d_srgb_from_linear(float colour)
{ {
if (colour < 0.0f) if (colour < 0.0f)
return 0.0f; return 0.0f;
if (colour < wined3d_srgb_const1[0]) if (colour < wined3d_srgb_const[1].x)
return colour * wined3d_srgb_const0[3]; return colour * wined3d_srgb_const[0].w;
if (colour < 1.0f) if (colour < 1.0f)
return wined3d_srgb_const0[1] * powf(colour, wined3d_srgb_const0[0]) - wined3d_srgb_const0[2]; return wined3d_srgb_const[0].y * powf(colour, wined3d_srgb_const[0].x) - wined3d_srgb_const[0].z;
return 1.0f; return 1.0f;
} }