[PATCH 5/5] d3d11/tests: Port test_create_blend_state() from d3d10core.
Józef Kucia
jkucia at codeweavers.com
Wed Oct 7 19:55:57 CDT 2015
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d11/tests/d3d11.c | 228 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 228 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 1dee78b..595ae7c 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -1558,6 +1558,233 @@ static void test_create_shader(void)
}
}
+static void test_create_blend_state(void)
+{
+ static const D3D11_BLEND_DESC desc_conversion_tests[] =
+ {
+ {
+ FALSE, FALSE,
+ {
+ {
+ FALSE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
+ D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD
+ },
+ },
+ },
+ {
+ FALSE, TRUE,
+ {
+ {
+ TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
+ D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
+ },
+ {
+ FALSE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
+ D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_RED
+ },
+ {
+ TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
+ D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
+ },
+ {
+ FALSE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
+ D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_GREEN
+ },
+ {
+ TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, 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_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_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_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
+ },
+ },
+ },
+ {
+ FALSE, TRUE,
+ {
+ {
+ TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, 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_SUBTRACT,
+ D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
+ },
+ {
+ TRUE, D3D11_BLEND_ZERO, D3D11_BLEND_ONE, 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_ONE, D3D11_BLEND_ONE, D3D11_BLEND_OP_MAX,
+ D3D11_BLEND_ONE, D3D11_BLEND_ZERO, 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_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
+ },
+ {
+ FALSE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
+ D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
+ },
+ {
+ FALSE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD,
+ D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL
+ },
+ },
+ },
+ };
+
+ ID3D11BlendState *blend_state1, *blend_state2;
+ D3D11_BLEND_DESC desc, obtained_desc;
+ ID3D10BlendState *d3d10_blend_state;
+ D3D10_BLEND_DESC d3d10_blend_desc;
+ ULONG refcount, expected_refcount;
+ ID3D11Device *device, *tmp;
+ unsigned int i, j;
+ HRESULT hr;
+
+ if (!(device = create_device(NULL)))
+ {
+ skip("Failed to create device.\n");
+ return;
+ }
+
+ hr = ID3D11Device_CreateBlendState(device, NULL, &blend_state1);
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+
+ memset(&desc, 0, sizeof(desc));
+ desc.AlphaToCoverageEnable = FALSE;
+ desc.IndependentBlendEnable = FALSE;
+ desc.RenderTarget[0].BlendEnable = FALSE;
+ desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
+ desc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO;
+ desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
+ desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
+ desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
+ desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
+ desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
+
+ expected_refcount = get_refcount((IUnknown *)device) + 1;
+ hr = ID3D11Device_CreateBlendState(device, &desc, &blend_state1);
+ ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr);
+ hr = ID3D11Device_CreateBlendState(device, &desc, &blend_state2);
+ ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr);
+ ok(blend_state1 == blend_state2, "Got different blend state objects.\n");
+ refcount = get_refcount((IUnknown *)device);
+ ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
+ tmp = NULL;
+ expected_refcount = refcount + 1;
+ ID3D11BlendState_GetDevice(blend_state1, &tmp);
+ ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
+ refcount = get_refcount((IUnknown *)device);
+ ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+ ID3D11Device_Release(tmp);
+
+ ID3D11BlendState_GetDesc(blend_state1, &obtained_desc);
+ ok(obtained_desc.AlphaToCoverageEnable == FALSE, "Got unexpected alpha to coverage enable %#x.\n",
+ obtained_desc.AlphaToCoverageEnable);
+ ok(obtained_desc.IndependentBlendEnable == FALSE, "Got unexpected independent blend enable %#x.\n",
+ obtained_desc.IndependentBlendEnable);
+ for (i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
+ {
+ ok(obtained_desc.RenderTarget[i].BlendEnable == FALSE,
+ "Got unexpected blend enable %#x for render target %u.\n",
+ obtained_desc.RenderTarget[i].BlendEnable, i);
+ ok(obtained_desc.RenderTarget[i].SrcBlend == D3D11_BLEND_ONE,
+ "Got unexpected src blend %u for render target %u.\n",
+ obtained_desc.RenderTarget[i].SrcBlend, i);
+ ok(obtained_desc.RenderTarget[i].DestBlend == D3D11_BLEND_ZERO,
+ "Got unexpected dest blend %u for render target %u.\n",
+ obtained_desc.RenderTarget[i].DestBlend, i);
+ ok(obtained_desc.RenderTarget[i].BlendOp == D3D11_BLEND_OP_ADD,
+ "Got unexpected blend op %u for render target %u.\n",
+ obtained_desc.RenderTarget[i].BlendOp, i);
+ ok(obtained_desc.RenderTarget[i].SrcBlendAlpha == D3D11_BLEND_ONE,
+ "Got unexpected src blend alpha %u for render target %u.\n",
+ obtained_desc.RenderTarget[i].SrcBlendAlpha, i);
+ ok(obtained_desc.RenderTarget[i].DestBlendAlpha == D3D11_BLEND_ZERO,
+ "Got unexpected dest blend alpha %u for render target %u.\n",
+ obtained_desc.RenderTarget[i].DestBlendAlpha, i);
+ ok(obtained_desc.RenderTarget[i].BlendOpAlpha == D3D11_BLEND_OP_ADD,
+ "Got unexpected blend op alpha %u for render target %u.\n",
+ obtained_desc.RenderTarget[i].BlendOpAlpha, i);
+ ok(obtained_desc.RenderTarget[i].RenderTargetWriteMask == D3D11_COLOR_WRITE_ENABLE_ALL,
+ "Got unexpected render target write mask %#x for render target %u.\n",
+ obtained_desc.RenderTarget[0].RenderTargetWriteMask, i);
+ }
+
+ refcount = ID3D11BlendState_Release(blend_state1);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+ refcount = ID3D11BlendState_Release(blend_state2);
+ ok(!refcount, "Blend state has %u references left.\n", refcount);
+
+ for (i = 0; i < sizeof(desc_conversion_tests) / sizeof(*desc_conversion_tests); ++i)
+ {
+ const D3D11_BLEND_DESC *current_desc = &desc_conversion_tests[i];
+
+ hr = ID3D11Device_CreateBlendState(device, current_desc, &blend_state1);
+ ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr);
+
+ hr = ID3D11BlendState_QueryInterface(blend_state1, &IID_ID3D10BlendState, (void **)&d3d10_blend_state);
+ ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
+ "Blend state should implement ID3D10BlendState.\n");
+ if (FAILED(hr))
+ {
+ win_skip("Blend state does not implement ID3D10BlendState.\n");
+ ID3D11BlendState_Release(blend_state1);
+ break;
+ }
+
+ ID3D10BlendState_GetDesc(d3d10_blend_state, &d3d10_blend_desc);
+ ok(d3d10_blend_desc.AlphaToCoverageEnable == current_desc->AlphaToCoverageEnable,
+ "Got unexpected alpha to coverage enable %#x for test %u.\n",
+ d3d10_blend_desc.AlphaToCoverageEnable, i);
+ ok(d3d10_blend_desc.SrcBlend == (D3D10_BLEND)current_desc->RenderTarget[0].SrcBlend,
+ "Got unexpected src blend %u for test %u.\n", d3d10_blend_desc.SrcBlend, i);
+ ok(d3d10_blend_desc.DestBlend == (D3D10_BLEND)current_desc->RenderTarget[0].DestBlend,
+ "Got unexpected dest blend %u for test %u.\n", d3d10_blend_desc.DestBlend, i);
+ ok(d3d10_blend_desc.BlendOp == (D3D10_BLEND_OP)current_desc->RenderTarget[0].BlendOp,
+ "Got unexpected blend op %u for test %u.\n", d3d10_blend_desc.BlendOp, i);
+ ok(d3d10_blend_desc.SrcBlendAlpha == (D3D10_BLEND)current_desc->RenderTarget[0].SrcBlendAlpha,
+ "Got unexpected src blend alpha %u for test %u.\n", d3d10_blend_desc.SrcBlendAlpha, i);
+ ok(d3d10_blend_desc.DestBlendAlpha == (D3D10_BLEND)current_desc->RenderTarget[0].DestBlendAlpha,
+ "Got unexpected dest blend alpha %u for test %u.\n", d3d10_blend_desc.DestBlendAlpha, i);
+ ok(d3d10_blend_desc.BlendOpAlpha == (D3D10_BLEND_OP)current_desc->RenderTarget[0].BlendOpAlpha,
+ "Got unexpected blend op alpha %u for test %u.\n", d3d10_blend_desc.BlendOpAlpha, i);
+ for (j = 0; j < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; j++)
+ {
+ unsigned int k = current_desc->IndependentBlendEnable ? j : 0;
+ ok(d3d10_blend_desc.BlendEnable[j] == current_desc->RenderTarget[k].BlendEnable,
+ "Got unexpected blend enable %#x for test %u, render target %u.\n",
+ d3d10_blend_desc.BlendEnable[j], i, j);
+ ok(d3d10_blend_desc.RenderTargetWriteMask[j] == current_desc->RenderTarget[k].RenderTargetWriteMask,
+ "Got unexpected render target write mask %#x for test %u, render target %u.\n",
+ d3d10_blend_desc.RenderTargetWriteMask[j], i, j);
+ }
+
+ ID3D10BlendState_Release(d3d10_blend_state);
+
+ refcount = ID3D11BlendState_Release(blend_state1);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ }
+
+ refcount = ID3D11Device_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+}
+
static void test_create_depthstencil_state(void)
{
ID3D11DepthStencilState *ds_state1, *ds_state2;
@@ -1911,6 +2138,7 @@ START_TEST(d3d11)
test_create_rendertarget_view();
test_create_shader_resource_view();
test_create_shader();
+ test_create_blend_state();
test_create_depthstencil_state();
test_create_rasterizer_state();
test_device_removed_reason();
--
2.4.9
More information about the wine-patches
mailing list