Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d10core/tests/d3d10core.c | 113 +++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+)
diff --git a/dlls/d3d10core/tests/d3d10core.c b/dlls/d3d10core/tests/d3d10core.c index c793f21b08..6b19379900 100644 --- a/dlls/d3d10core/tests/d3d10core.c +++ b/dlls/d3d10core/tests/d3d10core.c @@ -18177,6 +18177,118 @@ static void test_color_mask(void) release_test_context(&test_context); }
+static void test_independent_blend(void) +{ + struct d3d10core_test_context test_context; + D3D10_TEXTURE2D_DESC texture_desc; + ID3D10RenderTargetView *rtvs[8]; + ID3D10BlendState *blend_state; + struct resource_readback rb; + D3D10_BLEND_DESC blend_desc; + ID3D10Texture2D *rts[8]; + ID3D10PixelShader *ps; + ID3D10Device *device; + unsigned int i; + DWORD color; + HRESULT hr; + + static const DWORD ps_code[] = + { +#if 0 + void main(float4 position : SV_Position, + out float4 t0 : SV_Target0, out float4 t1 : SV_Target1, + out float4 t2 : SV_Target2, out float4 t3 : SV_Target3, + out float4 t4 : SV_Target4, out float4 t5 : SV_Target5, + out float4 t6 : SV_Target6, out float4 t7 : SV_Target7) + { + t0 = t1 = t2 = t3 = t4 = t5 = t6 = t7 = float4(0.0f, 1.0f, 0.0f, 0.5f); + } +#endif + 0x43425844, 0x77c86d8c, 0xc729bc00, 0xa7df8ead, 0xcc87ad10, 0x00000001, 0x000002b0, 0x00000003, + 0x0000002c, 0x00000060, 0x0000013c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, + 0x4e47534f, 0x000000d4, 0x00000008, 0x00000008, 0x000000c8, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x000000c8, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, + 0x000000c8, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x000000c8, 0x00000003, + 0x00000000, 0x00000003, 0x00000003, 0x0000000f, 0x000000c8, 0x00000004, 0x00000000, 0x00000003, + 0x00000004, 0x0000000f, 0x000000c8, 0x00000005, 0x00000000, 0x00000003, 0x00000005, 0x0000000f, + 0x000000c8, 0x00000006, 0x00000000, 0x00000003, 0x00000006, 0x0000000f, 0x000000c8, 0x00000007, + 0x00000000, 0x00000003, 0x00000007, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, + 0x0000016c, 0x00000040, 0x0000005b, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2, + 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000003, 0x03000065, + 0x001020f2, 0x00000004, 0x03000065, 0x001020f2, 0x00000005, 0x03000065, 0x001020f2, 0x00000006, + 0x03000065, 0x001020f2, 0x00000007, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000004, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000005, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000006, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000007, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f000000, 0x0100003e, + }; + + static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f}; + + if (!init_test_context(&test_context)) + return; + + device = test_context.device; + + hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps); + ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr); + ID3D10Device_PSSetShader(device, ps); + + blend_desc.AlphaToCoverageEnable = FALSE; + blend_desc.SrcBlend = D3D10_BLEND_SRC_ALPHA; + blend_desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA; + blend_desc.BlendOp = D3D10_BLEND_OP_ADD; + blend_desc.SrcBlendAlpha = D3D10_BLEND_ONE; + blend_desc.DestBlendAlpha = D3D10_BLEND_ZERO; + blend_desc.BlendOpAlpha = D3D10_BLEND_OP_ADD; + for (i = 0; i < 8; ++i) + { + blend_desc.BlendEnable[i] = i & 1; + blend_desc.RenderTargetWriteMask[i] = D3D10_COLOR_WRITE_ENABLE_ALL; + } + + hr = ID3D10Device_CreateBlendState(device, &blend_desc, &blend_state); + ok(hr == S_OK, "Failed to create blend state, hr %#x.\n", hr); + ID3D10Device_OMSetBlendState(device, blend_state, NULL, D3D10_DEFAULT_SAMPLE_MASK); + + for (i = 0; i < 8; ++i) + { + ID3D10Texture2D_GetDesc(test_context.backbuffer, &texture_desc); + hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &rts[i]); + ok(hr == S_OK, "Failed to create texture %u, hr %#x.\n", i, hr); + + hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)rts[i], NULL, &rtvs[i]); + ok(hr == S_OK, "Failed to create rendertarget view %u, hr %#x.\n", i, hr); + } + + ID3D10Device_OMSetRenderTargets(device, 8, rtvs, NULL); + + for (i = 0; i < 8; ++i) + ID3D10Device_ClearRenderTargetView(device, rtvs[i], red); + draw_quad(&test_context); + + for (i = 0; i < 8; ++i) + { + get_texture_readback(rts[i], 0, &rb); + color = get_readback_color(&rb, 320, 240); + todo_wine_if (i & 1) + ok(color == ((i & 1) ? 0x80008080 : 0x8000ff00), "%u: Got unexpected color 0x%08x.\n", i, color); + release_resource_readback(&rb); + + ID3D10Texture2D_Release(rts[i]); + ID3D10RenderTargetView_Release(rtvs[i]); + } + + ID3D10BlendState_Release(blend_state); + ID3D10PixelShader_Release(ps); + release_test_context(&test_context); +} + START_TEST(d3d10core) { unsigned int argc, i; @@ -18296,6 +18408,7 @@ START_TEST(d3d10core) queue_test(test_render_a8); queue_test(test_desktop_window); queue_test(test_color_mask); + queue_test(test_independent_blend);
run_queued_tests();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/tests/d3d11.c | 147 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index b643a22f17..22c7b0d4fb 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -29851,6 +29851,152 @@ static void test_color_mask(void) release_test_context(&test_context); }
+static void test_independent_blend(void) +{ + struct d3d11_test_context test_context; + D3D11_TEXTURE2D_DESC texture_desc; + ID3D11RenderTargetView *rtvs[8]; + ID3D11BlendState *blend_state; + ID3D11DeviceContext *context; + struct resource_readback rb; + ID3D11Texture2D *rts[8]; + ID3D11PixelShader *ps; + ID3D11Device *device; + unsigned int i; + DWORD color; + HRESULT hr; + + static const DWORD ps_code[] = + { +#if 0 + void main(float4 position : SV_Position, + out float4 t0 : SV_Target0, out float4 t1 : SV_Target1, + out float4 t2 : SV_Target2, out float4 t3 : SV_Target3, + out float4 t4 : SV_Target4, out float4 t5 : SV_Target5, + out float4 t6 : SV_Target6, out float4 t7 : SV_Target7) + { + t0 = t1 = t2 = t3 = t4 = t5 = t6 = t7 = float4(0.1f, 0.2f, 0.3f, 0.4f); + } +#endif + 0x43425844, 0xb3dca7dc, 0x4a31f0f1, 0x747569cb, 0xae7af5ce, 0x00000001, 0x000002b0, 0x00000003, + 0x0000002c, 0x00000060, 0x0000013c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, + 0x4e47534f, 0x000000d4, 0x00000008, 0x00000008, 0x000000c8, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x000000c8, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, + 0x000000c8, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x000000c8, 0x00000003, + 0x00000000, 0x00000003, 0x00000003, 0x0000000f, 0x000000c8, 0x00000004, 0x00000000, 0x00000003, + 0x00000004, 0x0000000f, 0x000000c8, 0x00000005, 0x00000000, 0x00000003, 0x00000005, 0x0000000f, + 0x000000c8, 0x00000006, 0x00000000, 0x00000003, 0x00000006, 0x0000000f, 0x000000c8, 0x00000007, + 0x00000000, 0x00000003, 0x00000007, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, + 0x0000016c, 0x00000040, 0x0000005b, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2, + 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000003, 0x03000065, + 0x001020f2, 0x00000004, 0x03000065, 0x001020f2, 0x00000005, 0x03000065, 0x001020f2, 0x00000006, + 0x03000065, 0x001020f2, 0x00000007, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3dcccccd, + 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3dcccccd, + 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x3dcccccd, + 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x3dcccccd, + 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000004, 0x00004002, 0x3dcccccd, + 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000005, 0x00004002, 0x3dcccccd, + 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000006, 0x00004002, 0x3dcccccd, + 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x08000036, 0x001020f2, 0x00000007, 0x00004002, 0x3dcccccd, + 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x0100003e, + }; + + D3D11_BLEND_DESC blend_desc = + { + .IndependentBlendEnable = TRUE, + .RenderTarget = + { + {TRUE, D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_DEST_ALPHA, D3D11_BLEND_OP_ADD, + D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL}, + {TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, + D3D11_BLEND_ZERO, D3D11_BLEND_ONE, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL}, + {TRUE, D3D11_BLEND_SRC_COLOR, D3D11_BLEND_DEST_COLOR, D3D11_BLEND_OP_ADD, + D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_DEST_ALPHA, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL}, + {TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ONE, D3D11_BLEND_OP_MIN, + D3D11_BLEND_ONE, D3D11_BLEND_ONE, D3D11_BLEND_OP_MIN, D3D11_COLOR_WRITE_ENABLE_ALL}, + {TRUE, D3D11_BLEND_BLEND_FACTOR, D3D11_BLEND_BLEND_FACTOR, D3D11_BLEND_OP_ADD, + D3D11_BLEND_ZERO, D3D11_BLEND_ONE, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL}, + {TRUE, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_INV_BLEND_FACTOR, D3D11_BLEND_OP_SUBTRACT, + D3D11_BLEND_ONE, D3D11_BLEND_ONE, D3D11_BLEND_OP_REV_SUBTRACT, D3D11_COLOR_WRITE_ENABLE_ALL}, + {FALSE}, + {TRUE, D3D11_BLEND_DEST_COLOR, D3D11_BLEND_SRC_COLOR, D3D11_BLEND_OP_ADD, + D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_INV_DEST_ALPHA, D3D11_BLEND_OP_SUBTRACT, + D3D11_COLOR_WRITE_ENABLE_ALL}, + }, + }; + + static const DWORD expected_colors[] = + {0x66426e1c, 0xb34c3319, 0xa6214a05, 0x66333319, 0xb34c4829, 0x4d19000a, 0xb333801a, 0x081f3305}; + + static const float clear_color[] = {0.1f, 0.5f, 0.2f, 0.7f}; + static const float blend_factor[] = {0.8f, 0.4f, 0.6f, 0.2f}; + + if (!init_test_context(&test_context, NULL)) + return; + + device = test_context.device; + context = test_context.immediate_context; + + hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps); + ok(hr == S_OK, "Failed to create pixel shader, hr %#x.\n", hr); + ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0); + + hr = ID3D11Device_CreateBlendState(device, &blend_desc, &blend_state); + ok(hr == S_OK, "Failed to create blend state, hr %#x.\n", hr); + ID3D11DeviceContext_OMSetBlendState(context, blend_state, blend_factor, D3D11_DEFAULT_SAMPLE_MASK); + ID3D11BlendState_Release(blend_state); + + for (i = 0; i < 8; ++i) + { + ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc); + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &rts[i]); + ok(hr == S_OK, "Failed to create texture %u, hr %#x.\n", i, hr); + + hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)rts[i], NULL, &rtvs[i]); + ok(hr == S_OK, "Failed to create rendertarget view %u, hr %#x.\n", i, hr); + } + + ID3D11DeviceContext_OMSetRenderTargets(context, 8, rtvs, NULL); + + for (i = 0; i < 8; ++i) + ID3D11DeviceContext_ClearRenderTargetView(context, rtvs[i], clear_color); + draw_quad(&test_context); + + for (i = 0; i < 8; ++i) + { + get_texture_readback(rts[i], 0, &rb); + color = get_readback_color(&rb, 320, 240, 0); + todo_wine_if (i) + ok(compare_color(color, expected_colors[i], 1), "%u: Got unexpected color 0x%08x.\n", i, color); + release_resource_readback(&rb); + } + + blend_desc.IndependentBlendEnable = FALSE; + hr = ID3D11Device_CreateBlendState(device, &blend_desc, &blend_state); + ok(hr == S_OK, "Failed to create blend state, hr %#x.\n", hr); + ID3D11DeviceContext_OMSetBlendState(context, blend_state, blend_factor, D3D11_DEFAULT_SAMPLE_MASK); + ID3D11BlendState_Release(blend_state); + + for (i = 0; i < 8; ++i) + ID3D11DeviceContext_ClearRenderTargetView(context, rtvs[i], clear_color); + draw_quad(&test_context); + + for (i = 0; i < 8; ++i) + { + get_texture_readback(rts[i], 0, &rb); + color = get_readback_color(&rb, 320, 240, 0); + ok(compare_color(color, expected_colors[0], 1), "%u: Got unexpected color 0x%08x.\n", i, color); + release_resource_readback(&rb); + + ID3D11Texture2D_Release(rts[i]); + ID3D11RenderTargetView_Release(rtvs[i]); + } + + ID3D11PixelShader_Release(ps); + release_test_context(&test_context); +} + START_TEST(d3d11) { unsigned int argc, i; @@ -30012,6 +30158,7 @@ START_TEST(d3d11) queue_test(test_desktop_window); queue_test(test_sample_attached_rtv); queue_test(test_color_mask); + queue_test(test_independent_blend);
run_queued_tests(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=66813
Your paranoid android.
=== debiant (32 bit Chinese:China report) ===
d3d11: d3d11.c:6119: Test succeeded inside todo block: Got unexpected PrimitivesStorageNeeded: 0.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 92 ++++++++++++++++++++-------------- dlls/wined3d/stateblock.c | 45 ++++------------- dlls/wined3d/wined3d_private.h | 6 +-- include/wine/wined3d.h | 2 +- 4 files changed, 68 insertions(+), 77 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index bcad597178..c3775934ca 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -528,6 +528,13 @@ static void device_free_rasterizer_state(struct wine_rb_entry *entry, void *cont wined3d_rasterizer_state_decref(state); }
+static void device_free_blend_state(struct wine_rb_entry *entry, void *context) +{ + struct wined3d_blend_state *state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_blend_state, entry); + + wined3d_blend_state_decref(state); +} + void wined3d_device_cleanup(struct wined3d_device *device) { unsigned int i; @@ -535,8 +542,8 @@ void wined3d_device_cleanup(struct wined3d_device *device) if (device->swapchain_count) wined3d_device_uninit_3d(device);
- wined3d_blend_state_decref(device->blend_state_atoc_enabled); wine_rb_destroy(&device->rasterizer_states, device_free_rasterizer_state, NULL); + wine_rb_destroy(&device->blend_states, device_free_blend_state, NULL);
wined3d_cs_destroy(device->cs);
@@ -3485,10 +3492,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, const struct wined3d_stateblock_state *state = &stateblock->stateblock_state; const struct wined3d_saved_states *changed = &stateblock->changed; const unsigned int word_bit_count = sizeof(DWORD) * CHAR_BIT; - BOOL set_blend_state, set_rasterizer_state = FALSE; - struct wined3d_blend_state *blend_state; + BOOL set_blend_state = FALSE, set_rasterizer_state = FALSE; unsigned int i, j, start, idx; - struct wined3d_color colour; struct wined3d_range range; DWORD map, stage;
@@ -3565,20 +3570,6 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, } }
- if ((set_blend_state = changed->blend_state - || wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_ADAPTIVETESS_Y))) - { - blend_state = state->rs[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC - ? device->blend_state_atoc_enabled : state->blend_state; - - if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_BLENDFACTOR)) - wined3d_color_from_d3dcolor(&colour, stateblock->stateblock_state.rs[WINED3D_RS_BLENDFACTOR]); - else - wined3d_device_get_blend_state(device, &colour); - - wined3d_device_set_blend_state(device, blend_state, &colour); - } - for (i = 0; i < ARRAY_SIZE(changed->renderState); ++i) { map = changed->renderState[i]; @@ -3590,12 +3581,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, switch (idx) { case WINED3D_RS_BLENDFACTOR: - if (!set_blend_state) - { - blend_state = wined3d_device_get_blend_state(device, &colour); - wined3d_color_from_d3dcolor(&colour, state->rs[idx]); - wined3d_device_set_blend_state(device, blend_state, &colour); - } + set_blend_state = TRUE; break;
case WINED3D_RS_FILLMODE: @@ -3653,6 +3639,41 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, } }
+ if (set_blend_state || changed->alpha_to_coverage + || wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_ADAPTIVETESS_Y)) + { + struct wined3d_blend_state *blend_state; + struct wined3d_blend_state_desc desc; + struct wine_rb_entry *entry; + struct wined3d_color colour; + + memset(&desc, 0, sizeof(desc)); + desc.alpha_to_coverage = state->alpha_to_coverage; + if (state->rs[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC) + desc.alpha_to_coverage = TRUE; + + if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_BLENDFACTOR)) + wined3d_color_from_d3dcolor(&colour, state->rs[WINED3D_RS_BLENDFACTOR]); + else + wined3d_device_get_blend_state(device, &colour); + + if ((entry = wine_rb_get(&device->blend_states, &desc))) + { + blend_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_blend_state, entry); + wined3d_device_set_blend_state(device, blend_state, &colour); + } + else if (SUCCEEDED(wined3d_blend_state_create(device, &desc, NULL, + &wined3d_null_parent_ops, &blend_state))) + { + wined3d_device_set_blend_state(device, blend_state, &colour); + if (wine_rb_put(&device->blend_states, &desc, &blend_state->entry) == -1) + { + ERR("Failed to insert blend state.\n"); + wined3d_blend_state_decref(blend_state); + } + } + } + for (i = 0; i < ARRAY_SIZE(changed->textureState); ++i) { map = changed->textureState[i]; @@ -5459,6 +5480,13 @@ static int wined3d_rasterizer_state_compare(const void *key, const struct wine_r return memcmp(&state->desc, key, sizeof(state->desc)); }
+static int wined3d_blend_state_compare(const void *key, const struct wine_rb_entry *entry) +{ + const struct wined3d_blend_state *state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_blend_state, entry); + + return memcmp(&state->desc, key, sizeof(state->desc)); +} + static BOOL wined3d_select_feature_level(const struct wined3d_adapter *adapter, const enum wined3d_feature_level *levels, unsigned int level_count, enum wined3d_feature_level *selected_level) @@ -5488,7 +5516,6 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined struct wined3d_adapter *adapter = wined3d->adapters[adapter_idx]; const struct wined3d_fragment_pipe_ops *fragment_pipeline; const struct wined3d_vertex_pipe_ops *vertex_pipeline; - struct wined3d_blend_state_desc blend_state_desc; unsigned int i; HRESULT hr;
@@ -5520,6 +5547,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
wine_rb_init(&device->samplers, wined3d_sampler_compare); wine_rb_init(&device->rasterizer_states, wined3d_rasterizer_state_compare); + wine_rb_init(&device->blend_states, wined3d_blend_state_compare);
if (vertex_pipeline->vp_states && fragment_pipeline->states && FAILED(hr = compile_state_table(device->state_table, device->multistate_funcs, @@ -5529,6 +5557,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined ERR("Failed to compile state table, hr %#x.\n", hr); wine_rb_destroy(&device->samplers, NULL, NULL); wine_rb_destroy(&device->rasterizer_states, NULL, NULL); + wine_rb_destroy(&device->blend_states, NULL, NULL); wined3d_decref(device->wined3d); return hr; } @@ -5545,18 +5574,6 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined goto err; }
- memset(&blend_state_desc, 0, sizeof(blend_state_desc)); - blend_state_desc.alpha_to_coverage = TRUE; - - if (FAILED(hr = wined3d_blend_state_create(device, &blend_state_desc, - NULL, &wined3d_null_parent_ops, &device->blend_state_atoc_enabled))) - { - ERR("Failed to create blend state object, hr %#x.\n", hr); - wined3d_cs_destroy(device->cs); - state_cleanup(&device->state); - goto err; - } - return WINED3D_OK;
err: @@ -5566,6 +5583,7 @@ err: } wine_rb_destroy(&device->samplers, NULL, NULL); wine_rb_destroy(&device->rasterizer_states, NULL, NULL); + wine_rb_destroy(&device->blend_states, NULL, NULL); wined3d_decref(device->wined3d); return hr; } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 70943afdda..248f413f62 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -208,7 +208,7 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, states->pixelShader = 1; states->vertexShader = 1; states->scissorRect = 1; - states->blend_state = 1; + states->alpha_to_coverage = 1; states->lights = 1; states->transforms = 1;
@@ -263,7 +263,7 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state
states->vertexDecl = 1; states->vertexShader = 1; - states->blend_state = 1; + states->alpha_to_coverage = 1; states->lights = 1;
for (i = 0; i < ARRAY_SIZE(vertex_states_render); ++i) @@ -479,7 +479,6 @@ void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) { struct wined3d_light_info *light, *cursor; struct wined3d_vertex_declaration *decl; - struct wined3d_blend_state *blend_state; struct wined3d_texture *texture; struct wined3d_buffer *buffer; struct wined3d_shader *shader; @@ -535,12 +534,6 @@ void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) heap_free(light); } } - - if ((blend_state = state->blend_state)) - { - state->blend_state = NULL; - wined3d_blend_state_decref(blend_state); - } }
void state_cleanup(struct wined3d_state *state) @@ -974,14 +967,8 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock, if (stateblock->changed.lights) wined3d_state_record_lights(stateblock->stateblock_state.light_state, state->light_state);
- if (stateblock->changed.blend_state && stateblock->stateblock_state.blend_state != state->blend_state) - { - if (state->blend_state) - wined3d_blend_state_incref(state->blend_state); - if (stateblock->stateblock_state.blend_state) - wined3d_blend_state_decref(stateblock->stateblock_state.blend_state); - stateblock->stateblock_state.blend_state = state->blend_state; - } + if (stateblock->changed.alpha_to_coverage) + stateblock->stateblock_state.alpha_to_coverage = state->alpha_to_coverage;
TRACE("Capture done.\n"); } @@ -1058,14 +1045,10 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock, wined3d_stateblock_set_ps_consts_b(device_state, range.offset, range.size, &state->ps_consts_b[range.offset]); }
- if (stateblock->changed.blend_state) + if (stateblock->changed.alpha_to_coverage) { - if (state->blend_state) - wined3d_blend_state_incref(state->blend_state); - if (device_state->stateblock_state.blend_state) - wined3d_blend_state_decref(device_state->stateblock_state.blend_state); - device_state->stateblock_state.blend_state = state->blend_state; - device_state->changed.blend_state = 1; + device_state->stateblock_state.alpha_to_coverage = state->alpha_to_coverage; + device_state->changed.alpha_to_coverage = 1; }
/* Render states. */ @@ -1359,18 +1342,8 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb if (state == WINED3D_RS_POINTSIZE && (value == WINED3D_ALPHA_TO_COVERAGE_ENABLE || value == WINED3D_ALPHA_TO_COVERAGE_DISABLE)) { - stateblock->changed.blend_state = 1; - - if (value == WINED3D_ALPHA_TO_COVERAGE_ENABLE && !stateblock->stateblock_state.blend_state) - { - wined3d_blend_state_incref(stateblock->device->blend_state_atoc_enabled); - stateblock->stateblock_state.blend_state = stateblock->device->blend_state_atoc_enabled; - } - else if (value == WINED3D_ALPHA_TO_COVERAGE_DISABLE && stateblock->stateblock_state.blend_state) - { - wined3d_blend_state_decref(stateblock->stateblock_state.blend_state); - stateblock->stateblock_state.blend_state = NULL; - } + stateblock->changed.alpha_to_coverage = 1; + stateblock->stateblock_state.alpha_to_coverage = (value == WINED3D_ALPHA_TO_COVERAGE_ENABLE); } }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 5c00883d41..4034ed28f0 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3144,6 +3144,7 @@ struct wined3d_blend_state const struct wined3d_parent_ops *parent_ops;
struct wined3d_device *device; + struct wine_rb_entry entry; };
struct wined3d_rasterizer_state @@ -3294,7 +3295,7 @@ struct wined3d_device
struct list resources; /* a linked list to track resources created by the device */ struct list shaders; /* a linked list to track shaders (pixel and vertex) */ - struct wine_rb_tree samplers, rasterizer_states; + struct wine_rb_tree samplers, rasterizer_states, blend_states;
/* Render Target Support */ struct wined3d_fb_state fb; @@ -3322,7 +3323,6 @@ struct wined3d_device /* Context management */ struct wined3d_context **contexts; UINT context_count; - struct wined3d_blend_state *blend_state_atoc_enabled; };
void wined3d_device_cleanup(struct wined3d_device *device) DECLSPEC_HIDDEN; @@ -3941,7 +3941,7 @@ struct wined3d_saved_states DWORD vertexShader : 1; DWORD scissorRect : 1; DWORD store_stream_offset : 1; - DWORD blend_state : 1; + DWORD alpha_to_coverage : 1; DWORD lights : 1; DWORD transforms : 1; DWORD padding : 1; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index fbcc6bb332..571e3d8d35 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2163,6 +2163,7 @@ struct wined3d_stateblock_state BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
DWORD rs[WINEHIGHEST_RENDER_STATE + 1]; + BOOL alpha_to_coverage;
struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS]; DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1]; @@ -2175,7 +2176,6 @@ struct wined3d_stateblock_state RECT scissor_rect;
struct wined3d_light_state *light_state; - struct wined3d_blend_state *blend_state; };
struct wined3d_parent_ops
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/device.c | 3 --- dlls/d3d11/state.c | 1 + dlls/wined3d/context.c | 10 +++---- dlls/wined3d/device.c | 2 ++ dlls/wined3d/shader.c | 2 +- dlls/wined3d/state.c | 61 +++++++++++++++++++----------------------- dlls/wined3d/utils.c | 4 +-- include/wine/wined3d.h | 1 + 8 files changed, 40 insertions(+), 44 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 555d998da2..76f8c821a1 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -721,7 +721,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi { wined3d_device_set_blend_state(device->wined3d_device, NULL, (const struct wined3d_color *)blend_factor); - wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, FALSE); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_COLORWRITEENABLE, D3D11_COLOR_WRITE_ENABLE_ALL); wined3d_device_set_render_state(device->wined3d_device, @@ -737,8 +736,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi wined3d_device_set_blend_state(device->wined3d_device, blend_state_impl->wined3d_state, (const struct wined3d_color *)blend_factor); desc = &blend_state_impl->desc; - wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, - desc->RenderTarget[0].BlendEnable); if (desc->RenderTarget[0].BlendEnable) { const D3D11_RENDER_TARGET_BLEND_DESC *d = &desc->RenderTarget[0]; diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index dd2eb6306e..269ec5eb12 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -389,6 +389,7 @@ HRESULT d3d_blend_state_create(struct d3d_device *device, const D3D11_BLEND_DESC }
wined3d_desc.alpha_to_coverage = desc->AlphaToCoverageEnable; + wined3d_desc.enable = desc->RenderTarget[0].BlendEnable;
/* We cannot fail after creating a wined3d_blend_state object. It * would lead to double free. */ diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index f4a5189ba1..eda09d95af 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -3148,7 +3148,7 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_TEST); context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ZENABLE)); gl_info->gl_ops.gl.p_glDisable(GL_BLEND); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE)); + context_invalidate_state(context, STATE_BLEND); gl_info->gl_ops.gl.p_glDisable(GL_CULL_FACE); gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST); context_invalidate_state(context, STATE_RASTERIZER); @@ -3426,7 +3426,7 @@ BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, } checkGLcall("setting up state for clear");
- context_invalidate_state(&context_gl->c, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE)); + context_invalidate_state(&context_gl->c, STATE_BLEND); context_invalidate_state(&context_gl->c, STATE_RASTERIZER); context_invalidate_state(&context_gl->c, STATE_SCISSORRECT);
@@ -4458,7 +4458,7 @@ static void wined3d_context_gl_setup_target(struct wined3d_context_gl *context_g * the alpha blend state changes with different render target formats. */ if (!context_gl->c.current_rt.texture) { - context_invalidate_state(&context_gl->c, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE)); + context_invalidate_state(&context_gl->c, STATE_BLEND); } else { @@ -4470,12 +4470,12 @@ static void wined3d_context_gl_setup_target(struct wined3d_context_gl *context_g /* Disable blending when the alpha mask has changed and when a format doesn't support blending. */ if ((old->alpha_size && !new->alpha_size) || (!old->alpha_size && new->alpha_size) || !(texture->resource.format_flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)) - context_invalidate_state(&context_gl->c, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE)); + context_invalidate_state(&context_gl->c, STATE_BLEND);
/* Update sRGB writing when switching between formats that do/do not support sRGB writing */ if ((context_gl->c.current_rt.texture->resource.format_flags & WINED3DFMT_FLAG_SRGB_WRITE) != (texture->resource.format_flags & WINED3DFMT_FLAG_SRGB_WRITE)) - context_invalidate_state(&context_gl->c, STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE)); + context_invalidate_state(&context_gl->c, STATE_BLEND); }
/* When switching away from an offscreen render target, and we're not diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index c3775934ca..3f8bd02d1d 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3581,6 +3581,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, switch (idx) { case WINED3D_RS_BLENDFACTOR: + case WINED3D_RS_ALPHABLENDENABLE: set_blend_state = TRUE; break;
@@ -3651,6 +3652,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, desc.alpha_to_coverage = state->alpha_to_coverage; if (state->rs[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC) desc.alpha_to_coverage = TRUE; + desc.enable = state->rs[WINED3D_RS_ALPHABLENDENABLE];
if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_BLENDFACTOR)) wined3d_color_from_d3dcolor(&colour, state->rs[WINED3D_RS_BLENDFACTOR]); diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 757631a73e..13e55cff8a 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -3909,7 +3909,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 static unsigned int warned = 0;
args->srgb_correction = 1; - if (state->render_states[WINED3D_RS_ALPHABLENDENABLE] && !warned++) + if (state->blend_state && state->blend_state->desc.enable && !warned++) WARN("Blending into a sRGB render target with no GL_ARB_framebuffer_sRGB " "support, expect rendering artifacts.\n"); } diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index ca59eba1d7..0931d60fe8 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -525,15 +525,16 @@ static void gl_blend_from_d3d(GLenum *src_blend, GLenum *dst_blend, } }
-static void state_blend(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) +static void state_blend(struct wined3d_context *context, const struct wined3d_state *state) { const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; + const struct wined3d_blend_state *b = state->blend_state; const struct wined3d_format *rt_format; GLenum src_blend, dst_blend; unsigned int rt_fmt_flags; BOOL enable_blend;
- enable_blend = state->fb->render_targets[0] && state->render_states[WINED3D_RS_ALPHABLENDENABLE]; + enable_blend = state->fb->render_targets[0] && b && b->desc.enable; if (enable_blend) { rt_format = state->fb->render_targets[0]->format; @@ -589,8 +590,8 @@ static void state_blend(struct wined3d_context *context, const struct wined3d_st checkGLcall("glBlendFunc"); }
- /* Colorkey fixup for stage 0 alphaop depends on - * WINED3D_RS_ALPHABLENDENABLE state, so it may need updating. */ + /* Colorkey fixup for stage 0 alphaop depends on blend state, so it may need + * updating. */ if (state->render_states[WINED3D_RS_COLORKEYENABLE]) context_apply_state(context, state, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP)); } @@ -611,26 +612,21 @@ static void state_blend_factor(struct wined3d_context *context, const struct win checkGLcall("glBlendColor"); }
-static void state_blend_object(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) +static void blend(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; - BOOL alpha_to_coverage = FALSE; + const struct wined3d_blend_state *b = state->blend_state;
- if (!gl_info->supported[ARB_MULTISAMPLE]) - return; - - if (state->blend_state) + if (gl_info->supported[ARB_MULTISAMPLE]) { - struct wined3d_blend_state_desc *desc = &state->blend_state->desc; - alpha_to_coverage = desc->alpha_to_coverage; + if (b && b->desc.alpha_to_coverage) + gl_info->gl_ops.gl.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); + else + gl_info->gl_ops.gl.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); + checkGLcall("glEnable GL_SAMPLE_ALPHA_TO_COVERAGE"); }
- if (alpha_to_coverage) - gl_info->gl_ops.gl.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); - else - gl_info->gl_ops.gl.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); - - checkGLcall("blend state"); + state_blend(context, state); }
void state_alpha_test(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) @@ -3222,10 +3218,9 @@ void tex_alphaop(struct wined3d_context *context, const struct wined3d_state *st * SELECTARG/CURRENT, yet puts garbage in diffuse alpha (zeroes). This works on native, because the * game disables alpha test and alpha blending. Alpha test is overwritten by wine's for purposes of * color-keying though, so this will lead to missing geometry if texture alpha is modulated (pixels - * fail alpha test). To get around this, ALPHABLENDENABLE state is checked: if the app enables alpha - * blending, it can be expected to provide meaningful values in diffuse alpha, so it should be - * modulated with texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture - * alpha. + * fail alpha test). To get around this, blend state is checked: if the app enables alpha blending, + * it can be expected to provide meaningful values in diffuse alpha, so it should be modulated with + * texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture alpha. * * What to do with multitexturing? So far no app has been found that uses color keying with * multitexturing */ @@ -3236,7 +3231,7 @@ void tex_alphaop(struct wined3d_context *context, const struct wined3d_state *st } else if (op == WINED3D_TOP_SELECT_ARG1 && arg1 != WINED3DTA_TEXTURE) { - if (state->render_states[WINED3D_RS_ALPHABLENDENABLE]) + if (state->blend_state && state->blend_state->desc.enable) { arg2 = WINED3DTA_TEXTURE; op = WINED3D_TOP_MODULATE; @@ -3245,7 +3240,7 @@ void tex_alphaop(struct wined3d_context *context, const struct wined3d_state *st } else if (op == WINED3D_TOP_SELECT_ARG2 && arg2 != WINED3DTA_TEXTURE) { - if (state->render_states[WINED3D_RS_ALPHABLENDENABLE]) + if (state->blend_state && state->blend_state->desc.enable) { arg1 = WINED3DTA_TEXTURE; op = WINED3D_TOP_MODULATE; @@ -4509,16 +4504,15 @@ const struct wined3d_state_entry_template misc_state_template[] = { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING, { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING, state_uav_warn }, WINED3D_GL_EXT_NONE }, { STATE_STREAM_OUTPUT, { STATE_STREAM_OUTPUT, state_so, }, WINED3D_GL_VERSION_3_2 }, { STATE_STREAM_OUTPUT, { STATE_STREAM_OUTPUT, state_so_warn, }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_SRCBLEND), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_DESTBLEND), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), state_blend }, WINED3D_GL_EXT_NONE }, + { STATE_RENDER(WINED3D_RS_SRCBLEND), { STATE_BLEND, NULL }, WINED3D_GL_EXT_NONE }, + { STATE_RENDER(WINED3D_RS_DESTBLEND), { STATE_BLEND, NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_EDGEANTIALIAS), { STATE_RENDER(WINED3D_RS_EDGEANTIALIAS), state_line_antialias}, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_SEPARATEALPHABLENDENABLE), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_SRCBLENDALPHA), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_BLENDOPALPHA), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, - { STATE_BLEND, { STATE_BLEND, state_blend_object }, WINED3D_GL_EXT_NONE }, + { STATE_RENDER(WINED3D_RS_SEPARATEALPHABLENDENABLE), { STATE_BLEND, NULL }, WINED3D_GL_EXT_NONE }, + { STATE_RENDER(WINED3D_RS_SRCBLENDALPHA), { STATE_BLEND, NULL }, WINED3D_GL_EXT_NONE }, + { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA), { STATE_BLEND, NULL }, WINED3D_GL_EXT_NONE }, + { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA), { STATE_BLEND, NULL }, WINED3D_GL_EXT_NONE }, + { STATE_RENDER(WINED3D_RS_BLENDOPALPHA), { STATE_BLEND, NULL }, WINED3D_GL_EXT_NONE }, + { STATE_BLEND, { STATE_BLEND, blend }, WINED3D_GL_EXT_NONE }, { STATE_BLEND_FACTOR, { STATE_BLEND_FACTOR, state_blend_factor }, EXT_BLEND_COLOR }, { STATE_BLEND_FACTOR, { STATE_BLEND_FACTOR, state_blend_factor_w}, WINED3D_GL_EXT_NONE }, { STATE_STREAMSRC, { STATE_STREAMSRC, streamsrc }, WINED3D_GL_EXT_NONE }, @@ -5427,6 +5421,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) { 8, 8}, { 17, 18}, { 21, 22}, + { 27, 27}, { 42, 45}, { 47, 47}, { 61, 127}, diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index f696b92214..82a4e2ca0d 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6134,7 +6134,7 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d } else if (aop == WINED3D_TOP_SELECT_ARG1 && aarg1 != WINED3DTA_TEXTURE) { - if (state->render_states[WINED3D_RS_ALPHABLENDENABLE]) + if (state->blend_state && state->blend_state->desc.enable) { aarg2 = WINED3DTA_TEXTURE; aop = WINED3D_TOP_MODULATE; @@ -6143,7 +6143,7 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d } else if (aop == WINED3D_TOP_SELECT_ARG2 && aarg2 != WINED3DTA_TEXTURE) { - if (state->render_states[WINED3D_RS_ALPHABLENDENABLE]) + if (state->blend_state && state->blend_state->desc.enable) { aarg1 = WINED3DTA_TEXTURE; aop = WINED3D_TOP_MODULATE; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 571e3d8d35..f6353bed32 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2029,6 +2029,7 @@ struct wined3d_buffer_desc struct wined3d_blend_state_desc { BOOL alpha_to_coverage; + BOOL enable; };
struct wined3d_rasterizer_state_desc
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/device.c | 1 - dlls/d3d11/state.c | 1 + dlls/wined3d/device.c | 2 ++ dlls/wined3d/state.c | 6 ++---- include/wine/wined3d.h | 1 + 5 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 76f8c821a1..e09527d5a7 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -740,7 +740,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi { const D3D11_RENDER_TARGET_BLEND_DESC *d = &desc->RenderTarget[0];
- wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLEND, d->SrcBlend); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLEND, d->DestBlend); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOP, d->BlendOp); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SEPARATEALPHABLENDENABLE, TRUE); diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 269ec5eb12..1cc579c86a 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -390,6 +390,7 @@ HRESULT d3d_blend_state_create(struct d3d_device *device, const D3D11_BLEND_DESC
wined3d_desc.alpha_to_coverage = desc->AlphaToCoverageEnable; wined3d_desc.enable = desc->RenderTarget[0].BlendEnable; + wined3d_desc.src = desc->RenderTarget[0].SrcBlend;
/* We cannot fail after creating a wined3d_blend_state object. It * would lead to double free. */ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 3f8bd02d1d..54efdb05a7 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3582,6 +3582,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, { case WINED3D_RS_BLENDFACTOR: case WINED3D_RS_ALPHABLENDENABLE: + case WINED3D_RS_SRCBLEND: set_blend_state = TRUE; break;
@@ -3653,6 +3654,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, if (state->rs[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC) desc.alpha_to_coverage = TRUE; desc.enable = state->rs[WINED3D_RS_ALPHABLENDENABLE]; + desc.src = state->rs[WINED3D_RS_SRCBLEND];
if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_BLENDFACTOR)) wined3d_color_from_d3dcolor(&colour, state->rs[WINED3D_RS_BLENDFACTOR]); diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 0931d60fe8..aa85193bdd 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -557,8 +557,7 @@ static void state_blend(struct wined3d_context *context, const struct wined3d_st gl_info->gl_ops.gl.p_glEnable(GL_BLEND); checkGLcall("glEnable(GL_BLEND)");
- gl_blend_from_d3d(&src_blend, &dst_blend, - state->render_states[WINED3D_RS_SRCBLEND], + gl_blend_from_d3d(&src_blend, &dst_blend, b->desc.src, state->render_states[WINED3D_RS_DESTBLEND], rt_format);
/* Re-apply BLENDOP(ALPHA) because of a possible SEPARATEALPHABLENDENABLE change */ @@ -4504,7 +4503,6 @@ const struct wined3d_state_entry_template misc_state_template[] = { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING, { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING, state_uav_warn }, WINED3D_GL_EXT_NONE }, { STATE_STREAM_OUTPUT, { STATE_STREAM_OUTPUT, state_so, }, WINED3D_GL_VERSION_3_2 }, { STATE_STREAM_OUTPUT, { STATE_STREAM_OUTPUT, state_so_warn, }, WINED3D_GL_EXT_NONE }, - { STATE_RENDER(WINED3D_RS_SRCBLEND), { STATE_BLEND, NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_DESTBLEND), { STATE_BLEND, NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_EDGEANTIALIAS), { STATE_RENDER(WINED3D_RS_EDGEANTIALIAS), state_line_antialias}, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_SEPARATEALPHABLENDENABLE), { STATE_BLEND, NULL }, WINED3D_GL_EXT_NONE }, @@ -5419,7 +5417,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) { 1, 1}, { 3, 3}, { 8, 8}, - { 17, 18}, + { 17, 19}, { 21, 22}, { 27, 27}, { 42, 45}, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index f6353bed32..923f184d96 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2030,6 +2030,7 @@ struct wined3d_blend_state_desc { BOOL alpha_to_coverage; BOOL enable; + enum wined3d_blend src; };
struct wined3d_rasterizer_state_desc
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=66816
Your paranoid android.
=== debiant (32 bit report) ===
d3d11: d3d11.c:16860: Test failed: Got {-1.00787401e+000, 0.00000000e+000, 1.00000000e+000, 5.03937006e-001}, expected {-1.00000000e+000, 0.00000000e+000, 1.00000000e+000, 5.03937006e-001} at (0, 0), sub-resource 0.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=66812
Your paranoid android.
=== debiant (32 bit Japanese:Japan report) ===
Report validation errors: d3d10core:d3d10core has no test summary line (early exit of the main process?) d3d10core:d3d10core has unaccounted for failure messages d3d10core:d3d10core has unaccounted for todo messages d3d10core:d3d10core has unaccounted for skip messages d3d10core:d3d10core returned success despite having failures