diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index deed580191e..ef7ad82617f 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -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); diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 34baea7694b..0760917362e 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -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); diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index 5075b01663d..34d34b13042 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -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); diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 631f4727d41..b55c1f2f197 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -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); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 43be6e8d3a1..171f6690e2c 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -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); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 3c466ce3e69..988a82f8d61 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -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); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 213d616c92c..48134c56212 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -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); diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 630a7452b21..9bdc7737e21 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -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));