wined3d: Do not enable blending for edge/line antialiasing.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-08-10 11:38:42 +02:00 committed by Alexandre Julliard
parent b808b0758d
commit eaa20836d2
8 changed files with 59 additions and 62 deletions

View File

@ -9325,11 +9325,11 @@ static void test_line_antialiasing_blending(void)
ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, &red.x);
draw_color_quad(&test_context, &green);
todo_wine check_texture_color(test_context.backbuffer, 0x7f00ff00, 1);
check_texture_color(test_context.backbuffer, 0x7f00ff00, 1);
ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, &green.x);
draw_color_quad(&test_context, &red);
todo_wine check_texture_color(test_context.backbuffer, 0xcc0000ff, 1);
check_texture_color(test_context.backbuffer, 0xcc0000ff, 1);
ID3D10RasterizerState_Release(rasterizer_state);
release_test_context(&test_context);

View File

@ -10237,11 +10237,11 @@ static void test_line_antialiasing_blending(void)
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, &red.x);
draw_color_quad(&test_context, &green);
todo_wine check_texture_color(test_context.backbuffer, 0x7f00ff00, 1);
check_texture_color(test_context.backbuffer, 0x7f00ff00, 1);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, &green.x);
draw_color_quad(&test_context, &red);
todo_wine check_texture_color(test_context.backbuffer, 0xcc0000ff, 1);
check_texture_color(test_context.backbuffer, 0xcc0000ff, 1);
ID3D11RasterizerState_Release(rasterizer_state);
release_test_context(&test_context);

View File

@ -9509,7 +9509,7 @@ static void test_edge_antialiasing_blending(void)
hr = IDirect3DDevice8_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = getPixelColor(device, 320, 240);
todo_wine ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
@ -9520,7 +9520,7 @@ static void test_edge_antialiasing_blending(void)
hr = IDirect3DDevice8_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = getPixelColor(device, 320, 240);
todo_wine ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
refcount = IDirect3DDevice8_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);

View File

@ -21882,7 +21882,7 @@ static void test_line_antialiasing_blending(void)
hr = IDirect3DDevice9_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = getPixelColor(device, 320, 240);
todo_wine ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
@ -21893,7 +21893,7 @@ static void test_line_antialiasing_blending(void)
hr = IDirect3DDevice9_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = getPixelColor(device, 320, 240);
todo_wine ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);

View File

@ -10429,7 +10429,7 @@ static void test_edge_antialiasing_blending(void)
hr = IDirect3DDevice2_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(offscreen, 320, 240);
todo_wine ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
viewport_set_background(device, viewport, green_background);
hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
@ -10441,7 +10441,7 @@ static void test_edge_antialiasing_blending(void)
hr = IDirect3DDevice2_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(offscreen, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
IDirectDrawSurface_Release(offscreen);
destroy_viewport(device, viewport);

View File

@ -11763,7 +11763,7 @@ static void test_edge_antialiasing_blending(void)
hr = IDirect3DDevice3_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(offscreen, 320, 240);
todo_wine ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
@ -11775,7 +11775,7 @@ static void test_edge_antialiasing_blending(void)
hr = IDirect3DDevice3_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(offscreen, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
IDirectDrawSurface4_Release(offscreen);
IDirectDraw3_Release(ddraw);

View File

@ -12065,7 +12065,7 @@ static void test_edge_antialiasing_blending(void)
hr = IDirect3DDevice7_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(offscreen, 320, 240);
todo_wine ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
@ -12077,7 +12077,7 @@ static void test_edge_antialiasing_blending(void)
hr = IDirect3DDevice7_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = get_surface_color(offscreen, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
IDirectDrawSurface7_Release(offscreen);
IDirectDraw7_Release(ddraw);

View File

@ -440,60 +440,16 @@ static void state_blend(struct wined3d_context *context, const struct wined3d_st
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_format *rt_format;
BOOL enable_blend, enable_line_smooth;
GLenum src_blend, dst_blend;
unsigned int rt_fmt_flags;
if (!state->fb->render_targets[0])
{
gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
return;
}
rt_format = state->fb->render_targets[0]->format;
rt_fmt_flags = state->fb->render_targets[0]->format_flags;
/* According to the red book, GL_LINE_SMOOTH needs GL_BLEND with specific
* blending parameters to work. */
if (state->render_states[WINED3D_RS_ALPHABLENDENABLE]
|| state->render_states[WINED3D_RS_EDGEANTIALIAS]
|| state->render_states[WINED3D_RS_ANTIALIASEDLINEENABLE])
{
/* Disable blending in all cases even without pixelshaders.
* With blending on we could face a big performance penalty.
* The d3d9 visual test confirms the behavior. */
if (context->render_offscreen && !(rt_fmt_flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING))
{
gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
checkGLcall("glDisable GL_BLEND");
return;
}
else
{
gl_info->gl_ops.gl.p_glEnable(GL_BLEND);
checkGLcall("glEnable GL_BLEND");
}
}
else
{
gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
checkGLcall("glDisable GL_BLEND");
/* Nothing more to do - get out */
return;
};
gl_blend_from_d3d(&src_blend, &dst_blend,
state->render_states[WINED3D_RS_SRCBLEND],
state->render_states[WINED3D_RS_DESTBLEND], rt_format);
if (state->render_states[WINED3D_RS_EDGEANTIALIAS]
|| state->render_states[WINED3D_RS_ANTIALIASEDLINEENABLE])
enable_line_smooth = state->render_states[WINED3D_RS_EDGEANTIALIAS]
|| state->render_states[WINED3D_RS_ANTIALIASEDLINEENABLE];
if (enable_line_smooth)
{
gl_info->gl_ops.gl.p_glEnable(GL_LINE_SMOOTH);
checkGLcall("glEnable(GL_LINE_SMOOTH)");
if (src_blend != GL_SRC_ALPHA)
WARN("WINED3D_RS_EDGEANTIALIAS enabled, but unexpected src blending param.\n");
if (dst_blend != GL_ONE_MINUS_SRC_ALPHA && dst_blend != GL_ONE)
WARN("WINED3D_RS_EDGEANTIALIAS enabled, but unexpected dst blending param.\n");
}
else
{
@ -501,6 +457,47 @@ static void state_blend(struct wined3d_context *context, const struct wined3d_st
checkGLcall("glDisable(GL_LINE_SMOOTH)");
}
enable_blend = state->fb->render_targets[0] && state->render_states[WINED3D_RS_ALPHABLENDENABLE];
if (enable_blend)
{
rt_format = state->fb->render_targets[0]->format;
rt_fmt_flags = state->fb->render_targets[0]->format_flags;
/* Disable blending in all cases even without pixelshaders.
* With blending on we could face a big performance penalty.
* The d3d9 visual test confirms the behavior. */
if (context->render_offscreen && !(rt_fmt_flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING))
enable_blend = FALSE;
}
if (enable_blend)
{
gl_info->gl_ops.gl.p_glEnable(GL_BLEND);
checkGLcall("glEnable(GL_BLEND)");
}
else
{
gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
checkGLcall("glDisable(GL_BLEND)");
if (enable_line_smooth)
WARN("LINE/EDGEANTIALIAS enabled with disabled blending.\n");
return;
}
gl_blend_from_d3d(&src_blend, &dst_blend,
state->render_states[WINED3D_RS_SRCBLEND],
state->render_states[WINED3D_RS_DESTBLEND], rt_format);
/* According to the red book, GL_LINE_SMOOTH needs GL_BLEND with specific
* blending parameters to work. */
if (enable_line_smooth)
{
if (src_blend != GL_SRC_ALPHA)
WARN("LINE/EDGEANTIALIAS enabled, but unexpected src blending param.\n");
if (dst_blend != GL_ONE_MINUS_SRC_ALPHA && dst_blend != GL_ONE)
WARN("LINE/EDGEANTIALIAS enabled, but unexpected dst blending param.\n");
}
/* Re-apply BLENDOP(ALPHA) because of a possible SEPARATEALPHABLENDENABLE change */
if (!isStateDirty(context, STATE_RENDER(WINED3D_RS_BLENDOP)))
state_blendop(context, state, STATE_RENDER(WINED3D_RS_BLENDOPALPHA));