d3d10core/tests: Port test_texture2d_interfaces() from d3d11.
This commit is contained in:
parent
7889b17425
commit
f9ecce38ef
|
@ -297,6 +297,146 @@ static void test_create_texture2d(void)
|
|||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
static void test_texture2d_interfaces(void)
|
||||
{
|
||||
ID3D11Texture2D *d3d11_texture;
|
||||
D3D10_TEXTURE2D_DESC desc;
|
||||
ID3D10Texture2D *texture;
|
||||
IDXGISurface *surface;
|
||||
ID3D10Device *device;
|
||||
unsigned int i;
|
||||
ULONG refcount;
|
||||
HRESULT hr;
|
||||
|
||||
static const struct test
|
||||
{
|
||||
UINT bind_flags;
|
||||
UINT misc_flags;
|
||||
UINT expected_bind_flags;
|
||||
UINT expected_misc_flags;
|
||||
}
|
||||
desc_conversion_tests[] =
|
||||
{
|
||||
{
|
||||
D3D10_BIND_RENDER_TARGET, 0,
|
||||
D3D11_BIND_RENDER_TARGET, 0
|
||||
},
|
||||
{
|
||||
0, D3D10_RESOURCE_MISC_SHARED,
|
||||
0, D3D11_RESOURCE_MISC_SHARED
|
||||
},
|
||||
};
|
||||
|
||||
if (!(device = create_device()))
|
||||
{
|
||||
skip("Failed to create device, skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
desc.Width = 512;
|
||||
desc.Height = 512;
|
||||
desc.MipLevels = 0;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.BindFlags = D3D11_BIND_RENDER_TARGET;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
|
||||
hr = ID3D10Device_CreateTexture2D(device, &desc, NULL, &texture);
|
||||
ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x.\n", hr);
|
||||
|
||||
hr = ID3D10Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
|
||||
ok(hr == E_NOINTERFACE, "Texture should not implement IDXGISurface.\n");
|
||||
|
||||
hr = ID3D10Texture2D_QueryInterface(texture, &IID_ID3D11Texture2D, (void **)&d3d11_texture);
|
||||
ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
|
||||
"Texture should implement ID3D11Texture2D.\n");
|
||||
if (SUCCEEDED(hr)) ID3D11Texture2D_Release(d3d11_texture);
|
||||
ID3D10Texture2D_Release(texture);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
win_skip("D3D11 is not available, skipping tests.\n");
|
||||
ID3D10Device_Release(device);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(desc_conversion_tests) / sizeof(*desc_conversion_tests); ++i)
|
||||
{
|
||||
const struct test *current = &desc_conversion_tests[i];
|
||||
D3D11_TEXTURE2D_DESC d3d11_desc;
|
||||
ID3D11Device *d3d11_device;
|
||||
|
||||
desc.Width = 512;
|
||||
desc.Height = 512;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.Usage = D3D10_USAGE_DEFAULT;
|
||||
desc.BindFlags = current->bind_flags;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = current->misc_flags;
|
||||
|
||||
hr = ID3D10Device_CreateTexture2D(device, &desc, NULL, &texture);
|
||||
/* Shared resources are not supported by REF and WARP devices. */
|
||||
ok(SUCCEEDED(hr) || broken(hr == E_OUTOFMEMORY),
|
||||
"Test %u: Failed to create a 2d texture, hr %#x.\n", i, hr);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
win_skip("Failed to create ID3D10Texture2D, skipping test %u.\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
hr = ID3D10Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
|
||||
ok(SUCCEEDED(hr), "Test %u: Texture should implement IDXGISurface.\n", i);
|
||||
IDXGISurface_Release(surface);
|
||||
|
||||
hr = ID3D10Texture2D_QueryInterface(texture, &IID_ID3D11Texture2D, (void **)&d3d11_texture);
|
||||
ok(SUCCEEDED(hr), "Test %u: Texture should implement ID3D11Texture2D.\n", i);
|
||||
ID3D10Texture2D_Release(texture);
|
||||
|
||||
ID3D11Texture2D_GetDesc(d3d11_texture, &d3d11_desc);
|
||||
|
||||
ok(d3d11_desc.Width == desc.Width,
|
||||
"Test %u: Got unexpected Width %u.\n", i, d3d11_desc.Width);
|
||||
ok(d3d11_desc.Height == desc.Height,
|
||||
"Test %u: Got unexpected Height %u.\n", i, d3d11_desc.Height);
|
||||
ok(d3d11_desc.MipLevels == desc.MipLevels,
|
||||
"Test %u: Got unexpected MipLevels %u.\n", i, d3d11_desc.MipLevels);
|
||||
ok(d3d11_desc.ArraySize == desc.ArraySize,
|
||||
"Test %u: Got unexpected ArraySize %u.\n", i, d3d11_desc.ArraySize);
|
||||
ok(d3d11_desc.Format == desc.Format,
|
||||
"Test %u: Got unexpected Format %u.\n", i, d3d11_desc.Format);
|
||||
ok(d3d11_desc.SampleDesc.Count == desc.SampleDesc.Count,
|
||||
"Test %u: Got unexpected SampleDesc.Count %u.\n", i, d3d11_desc.SampleDesc.Count);
|
||||
ok(d3d11_desc.SampleDesc.Quality == desc.SampleDesc.Quality,
|
||||
"Test %u: Got unexpected SampleDesc.Quality %u.\n", i, d3d11_desc.SampleDesc.Quality);
|
||||
ok(d3d11_desc.Usage == (D3D11_USAGE)desc.Usage,
|
||||
"Test %u: Got unexpected Usage %u.\n", i, d3d11_desc.Usage);
|
||||
ok(d3d11_desc.BindFlags == current->expected_bind_flags,
|
||||
"Test %u: Got unexpected BindFlags %#x.\n", i, d3d11_desc.BindFlags);
|
||||
ok(d3d11_desc.CPUAccessFlags == desc.CPUAccessFlags,
|
||||
"Test %u: Got unexpected CPUAccessFlags %#x.\n", i, d3d11_desc.CPUAccessFlags);
|
||||
ok(d3d11_desc.MiscFlags == current->expected_misc_flags,
|
||||
"Test %u: Got unexpected MiscFlags %#x.\n", i, d3d11_desc.MiscFlags);
|
||||
|
||||
d3d11_device = NULL;
|
||||
ID3D11Texture2D_GetDevice(d3d11_texture, &d3d11_device);
|
||||
ok(!!d3d11_device, "Test %u: Got NULL, expected device pointer.\n", i);
|
||||
ID3D11Device_Release(d3d11_device);
|
||||
|
||||
ID3D11Texture2D_Release(d3d11_texture);
|
||||
}
|
||||
|
||||
refcount = ID3D10Device_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
static void test_create_texture3d(void)
|
||||
{
|
||||
ULONG refcount, expected_refcount;
|
||||
|
@ -3465,6 +3605,7 @@ START_TEST(device)
|
|||
{
|
||||
test_feature_level();
|
||||
test_create_texture2d();
|
||||
test_texture2d_interfaces();
|
||||
test_create_texture3d();
|
||||
test_create_depthstencil_view();
|
||||
test_create_rendertarget_view();
|
||||
|
|
Loading…
Reference in New Issue