From 0fcfb8a08231de80eaa61ad79bc014c576315005 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B3zef=20Kucia?= Date: Tue, 1 Sep 2015 00:27:37 +0200 Subject: [PATCH] d3d11/tests: Port test_create_texture3d() from d3d10core. --- dlls/d3d11/tests/d3d11.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 6cb1516c2cc..6a9d7102983 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -409,10 +409,90 @@ static void test_texture2d_interfaces(void) ok(!refcount, "Device has %u references left.\n", refcount); } +static void test_create_texture3d(void) +{ + ULONG refcount, expected_refcount; + D3D11_SUBRESOURCE_DATA data = {0}; + ID3D11Device *device, *tmp; + D3D11_TEXTURE3D_DESC desc; + ID3D11Texture3D *texture; + IDXGISurface *surface; + HRESULT hr; + + if (!(device = create_device(NULL))) + { + skip("Failed to create ID3D11Device, skipping tests.\n"); + return; + } + + desc.Width = 64; + desc.Height = 64; + desc.Depth = 64; + desc.MipLevels = 1; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_RENDER_TARGET; + desc.CPUAccessFlags = 0; + desc.MiscFlags = 0; + + hr = ID3D11Device_CreateTexture3D(device, &desc, &data, &texture); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + + expected_refcount = get_refcount((IUnknown *)device) + 1; + hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture); + ok(SUCCEEDED(hr), "Failed to create a 3d texture, hr %#x.\n", hr); + 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; + ID3D11Texture3D_GetDevice(texture, &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); + + hr = ID3D11Texture3D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface); + ok(FAILED(hr), "Texture should not implement IDXGISurface.\n"); + ID3D11Texture3D_Release(texture); + + desc.MipLevels = 0; + expected_refcount = get_refcount((IUnknown *)device) + 1; + hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture); + ok(SUCCEEDED(hr), "Failed to create a 3d texture, hr %#x.\n", hr); + 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; + ID3D11Texture3D_GetDevice(texture, &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); + + ID3D11Texture3D_GetDesc(texture, &desc); + ok(desc.Width == 64, "Got unexpected Width %u.\n", desc.Width); + ok(desc.Height == 64, "Got unexpected Height %u.\n", desc.Height); + ok(desc.Depth == 64, "Got unexpected Depth %u.\n", desc.Depth); + ok(desc.MipLevels == 7, "Got unexpected MipLevels %u.\n", desc.MipLevels); + ok(desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM, "Got unexpected Format %#x.\n", desc.Format); + ok(desc.Usage == D3D11_USAGE_DEFAULT, "Got unexpected Usage %u.\n", desc.Usage); + ok(desc.BindFlags == D3D11_BIND_RENDER_TARGET, "Got unexpected BindFlags %u.\n", desc.BindFlags); + ok(desc.CPUAccessFlags == 0, "Got unexpected CPUAccessFlags %u.\n", desc.CPUAccessFlags); + ok(desc.MiscFlags == 0, "Got unexpected MiscFlags %u.\n", desc.MiscFlags); + + hr = ID3D11Texture3D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface); + ok(FAILED(hr), "Texture should not implement IDXGISurface.\n"); + ID3D11Texture3D_Release(texture); + + refcount = ID3D11Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +} + START_TEST(d3d11) { test_create_device(); test_device_interfaces(); test_create_texture2d(); test_texture2d_interfaces(); + test_create_texture3d(); } -- 2.11.4.GIT