wined3d: Introduce wined3d_colour_srgb_from_linear().

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:28 +04:30 committed by Alexandre Julliard
parent af8401ba0c
commit f193979a18
2 changed files with 27 additions and 21 deletions

View File

@ -291,7 +291,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
struct wined3d_context_gl *context_gl;
struct wined3d_texture *target = NULL;
UINT drawable_width, drawable_height;
struct wined3d_color corrected_color;
struct wined3d_color colour_srgb;
struct wined3d_context *context;
GLbitfield clear_mask = 0;
BOOL render_offscreen;
@ -430,25 +430,11 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
if (!gl_info->supported[ARB_FRAMEBUFFER_SRGB] && needs_srgb_write(context, state, fb))
{
if (rt_count > 1)
WARN("Clearing multiple sRGB render targets with no GL_ARB_framebuffer_sRGB "
WARN("Clearing multiple sRGB render targets without GL_ARB_framebuffer_sRGB "
"support, this might cause graphical issues.\n");
corrected_color.r = color->r < wined3d_srgb_const1[0]
? color->r * wined3d_srgb_const0[3]
: pow(color->r, wined3d_srgb_const0[0]) * wined3d_srgb_const0[1]
- wined3d_srgb_const0[2];
corrected_color.r = min(max(corrected_color.r, 0.0f), 1.0f);
corrected_color.g = color->g < wined3d_srgb_const1[0]
? color->g * wined3d_srgb_const0[3]
: pow(color->g, wined3d_srgb_const0[0]) * wined3d_srgb_const0[1]
- wined3d_srgb_const0[2];
corrected_color.g = min(max(corrected_color.g, 0.0f), 1.0f);
corrected_color.b = color->b < wined3d_srgb_const1[0]
? color->b * wined3d_srgb_const0[3]
: pow(color->b, wined3d_srgb_const0[0]) * wined3d_srgb_const0[1]
- wined3d_srgb_const0[2];
corrected_color.b = min(max(corrected_color.b, 0.0f), 1.0f);
color = &corrected_color;
wined3d_colour_srgb_from_linear(&colour_srgb, color);
color = &colour_srgb;
}
gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

View File

@ -1482,6 +1482,29 @@ static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_col
wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
}
extern const float wined3d_srgb_const0[] DECLSPEC_HIDDEN;
extern const float wined3d_srgb_const1[] DECLSPEC_HIDDEN;
static inline float wined3d_srgb_from_linear(float colour)
{
if (colour < 0.0f)
return 0.0f;
if (colour < wined3d_srgb_const1[0])
return colour * wined3d_srgb_const0[3];
if (colour < 1.0f)
return wined3d_srgb_const0[1] * powf(colour, wined3d_srgb_const0[0]) - wined3d_srgb_const0[2];
return 1.0f;
}
static inline void wined3d_colour_srgb_from_linear(struct wined3d_color *colour_srgb,
const struct wined3d_color *colour)
{
colour_srgb->r = wined3d_srgb_from_linear(colour->r);
colour_srgb->g = wined3d_srgb_from_linear(colour->g);
colour_srgb->b = wined3d_srgb_from_linear(colour->b);
colour_srgb->a = colour->a;
}
#define WINED3D_HIGHEST_TRANSFORM_STATE WINED3D_TS_WORLD_MATRIX(255) /* Highest value in wined3d_transform_state. */
void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info,
@ -2978,9 +3001,6 @@ const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *frag
void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
void wined3d_ftoa(float value, char *s) DECLSPEC_HIDDEN;
extern const float wined3d_srgb_const0[] DECLSPEC_HIDDEN;
extern const float wined3d_srgb_const1[] DECLSPEC_HIDDEN;
enum wined3d_ffp_vs_fog_mode
{
WINED3D_FFP_VS_FOG_OFF = 0,