wined3d: Handle D3DRS_SRGBWRITEENABLE in clears when ARB_framebuffer_sRGB is not supported.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
787a2716e1
commit
66d8e38ba4
|
@ -905,7 +905,6 @@ static void clear_test(void)
|
||||||
IDirect3DDevice9 *device;
|
IDirect3DDevice9 *device;
|
||||||
IDirect3D9 *d3d;
|
IDirect3D9 *d3d;
|
||||||
ULONG refcount;
|
ULONG refcount;
|
||||||
D3DCAPS9 caps;
|
|
||||||
HWND window;
|
HWND window;
|
||||||
|
|
||||||
window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||||
|
@ -1155,9 +1154,6 @@ static void clear_test(void)
|
||||||
IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
|
IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
/* Test D3DRS_SRGBWRITEENABLE interactions with clears. */
|
/* Test D3DRS_SRGBWRITEENABLE interactions with clears. */
|
||||||
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
|
|
||||||
ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
|
|
||||||
|
|
||||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f7f7f7f, 0.0, 0);
|
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f7f7f7f, 0.0, 0);
|
||||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
@ -1195,10 +1191,7 @@ static void clear_test(void)
|
||||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||||
|
|
||||||
color = getPixelColor(device, 320, 240);
|
color = getPixelColor(device, 320, 240);
|
||||||
if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_POSTBLENDSRGBCONVERT)
|
ok(color_match(color, 0x00bbbbbb, 1), "Clear has color %08x.\n", color);
|
||||||
ok(color_match(color, 0x00bbbbbb, 1), "Clear has color %08x.\n", color);
|
|
||||||
else
|
|
||||||
todo_wine ok(color_match(color, 0x00bbbbbb, 1), "Clear has color %08x.\n", color);
|
|
||||||
|
|
||||||
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, FALSE);
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, FALSE);
|
||||||
ok(SUCCEEDED(hr), "Failed to disable sRGB write, hr %#x.\n", hr);
|
ok(SUCCEEDED(hr), "Failed to disable sRGB write, hr %#x.\n", hr);
|
||||||
|
@ -1250,10 +1243,7 @@ static void clear_test(void)
|
||||||
ok(SUCCEEDED(hr), "Failed to blit surface, hr %#x.\n", hr);
|
ok(SUCCEEDED(hr), "Failed to blit surface, hr %#x.\n", hr);
|
||||||
|
|
||||||
color = getPixelColor(device, 320, 240);
|
color = getPixelColor(device, 320, 240);
|
||||||
if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_POSTBLENDSRGBCONVERT)
|
ok(color_match(color, 0x00bbbbbb, 1), "Clear has color %08x.\n", color);
|
||||||
ok(color_match(color, 0x00bbbbbb, 1), "Clear has color %08x.\n", color);
|
|
||||||
else
|
|
||||||
todo_wine ok(color_match(color, 0x00bbbbbb, 1), "Clear has color %08x.\n", color);
|
|
||||||
|
|
||||||
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, FALSE);
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, FALSE);
|
||||||
ok(SUCCEEDED(hr), "Failed to disable sRGB write, hr %#x.\n", hr);
|
ok(SUCCEEDED(hr), "Failed to disable sRGB write, hr %#x.\n", hr);
|
||||||
|
|
|
@ -294,6 +294,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
|
||||||
const RECT *clear_rect = (rect_count > 0 && rects) ? (const RECT *)rects : NULL;
|
const RECT *clear_rect = (rect_count > 0 && rects) ? (const RECT *)rects : NULL;
|
||||||
const struct wined3d_gl_info *gl_info;
|
const struct wined3d_gl_info *gl_info;
|
||||||
UINT drawable_width, drawable_height;
|
UINT drawable_width, drawable_height;
|
||||||
|
struct wined3d_color corrected_color;
|
||||||
struct wined3d_context *context;
|
struct wined3d_context *context;
|
||||||
GLbitfield clear_mask = 0;
|
GLbitfield clear_mask = 0;
|
||||||
BOOL render_offscreen;
|
BOOL render_offscreen;
|
||||||
|
@ -402,6 +403,34 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!gl_info->supported[ARB_FRAMEBUFFER_SRGB]
|
||||||
|
&& device->state.render_states[WINED3D_RS_SRGBWRITEENABLE])
|
||||||
|
{
|
||||||
|
if (fb->render_targets[0]->format_flags & WINED3DFMT_FLAG_SRGB_WRITE)
|
||||||
|
{
|
||||||
|
if (rt_count > 1)
|
||||||
|
WARN("Clearing multiple sRGB render targets with no 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE));
|
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE));
|
||||||
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1));
|
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1));
|
||||||
|
|
Loading…
Reference in New Issue