d3d11/tests: Add some tests for invalid RTVs.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2017-12-07 22:56:20 +01:00 committed by Alexandre Julliard
parent 83a30fad0a
commit 7453e93eeb
1 changed files with 117 additions and 0 deletions

View File

@ -7986,13 +7986,87 @@ static void test_render_target_views(void)
{{2, 2}, {DXGI_FORMAT_UNKNOWN, D3D11_RTV_DIMENSION_TEXTURE2DARRAY, 1, 1, 1}, {{2, 2}, {DXGI_FORMAT_UNKNOWN, D3D11_RTV_DIMENSION_TEXTURE2DARRAY, 1, 1, 1},
{0x00000000, 0x00000000, 0x00000000, 0xff0000ff}}, {0x00000000, 0x00000000, 0x00000000, 0xff0000ff}},
}; };
#define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN
#define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM
#define RGBA8_SRGB DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
#define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS
#define DIM_UNKNOWN D3D11_RTV_DIMENSION_UNKNOWN
#define TEX_1D D3D11_RTV_DIMENSION_TEXTURE1D
#define TEX_1D_ARRAY D3D11_RTV_DIMENSION_TEXTURE1DARRAY
#define TEX_2D D3D11_RTV_DIMENSION_TEXTURE2D
#define TEX_2D_ARRAY D3D11_RTV_DIMENSION_TEXTURE2DARRAY
#define TEX_3D D3D11_RTV_DIMENSION_TEXTURE3D
static const struct
{
struct
{
D3D11_RTV_DIMENSION dimension;
unsigned int miplevel_count;
unsigned int depth_or_array_size;
DXGI_FORMAT format;
} texture;
struct rtv_desc rtv_desc;
}
invalid_desc_tests[] =
{
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, DIM_UNKNOWN}},
{{TEX_2D, 6, 4, RGBA8_UNORM}, {RGBA8_UNORM, DIM_UNKNOWN}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D, 0}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D_ARRAY, 0, 0, 1}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 0, 0, 1}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 0, 0, ~0u}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_TL, TEX_2D, 0}},
{{TEX_2D, 1, 1, RGBA8_TL}, {FMT_UNKNOWN, TEX_2D, 0}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D, 1}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 0, 0}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 1, 0, 1}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 0, 2}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 1, 1}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UINT, TEX_2D, 0, 0, 1}},
{{TEX_2D, 1, 1, RGBA8_UINT}, {RGBA8_UNORM, TEX_2D, 0, 0, 1}},
{{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_SRGB, TEX_2D, 0, 0, 1}},
{{TEX_2D, 1, 1, RGBA8_SRGB}, {RGBA8_UNORM, TEX_2D, 0, 0, 1}},
{{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D, 0}},
{{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D_ARRAY, 0, 0, 1}},
{{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D, 0}},
{{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 0, 1}},
{{TEX_3D, 1, 9, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D, 0}},
{{TEX_3D, 1, 9, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D_ARRAY, 0, 0, 1}},
{{TEX_3D, 1, 9, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D, 0}},
{{TEX_3D, 1, 9, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 0, 1}},
{{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 0, 0, 0}},
{{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 1, 0, 1}},
{{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_TL, TEX_3D, 0, 0, 1}},
{{TEX_3D, 1, 9, RGBA8_UNORM}, {RGBA8_TL, TEX_3D, 0, 0, 1}},
{{TEX_3D, 4, 8, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 0, 0, 9}},
{{TEX_3D, 4, 8, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 3, 0, 2}},
{{TEX_3D, 4, 8, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 2, 0, 4}},
{{TEX_3D, 4, 8, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 1, 0, 8}},
{{TEX_3D, 4, 8, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 0, 8, ~0u}},
{{TEX_3D, 4, 8, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 1, 4, ~0u}},
{{TEX_3D, 4, 8, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 2, 2, ~0u}},
{{TEX_3D, 4, 8, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 3, 1, ~0u}},
};
#undef FMT_UNKNOWN
#undef RGBA8_UNORM
#undef RGBA8_SRGB
#undef RGBA8_TL
#undef DIM_UNKNOWN
#undef TEX_1D
#undef TEX_1D_ARRAY
#undef TEX_2D
#undef TEX_2D_ARRAY
#undef TEX_3D
struct d3d11_test_context test_context; struct d3d11_test_context test_context;
D3D11_RENDER_TARGET_VIEW_DESC rtv_desc; D3D11_RENDER_TARGET_VIEW_DESC rtv_desc;
D3D11_TEXTURE3D_DESC texture3d_desc;
D3D11_TEXTURE2D_DESC texture_desc; D3D11_TEXTURE2D_DESC texture_desc;
ID3D11DeviceContext *context; ID3D11DeviceContext *context;
ID3D11RenderTargetView *rtv; ID3D11RenderTargetView *rtv;
ID3D11Texture3D *texture3d;
ID3D11Texture2D *texture; ID3D11Texture2D *texture;
ID3D11Resource *resource;
ID3D11Device *device; ID3D11Device *device;
unsigned int i, j, k; unsigned int i, j, k;
void *data; void *data;
@ -8055,6 +8129,49 @@ static void test_render_target_views(void)
ID3D11Texture2D_Release(texture); ID3D11Texture2D_Release(texture);
} }
texture3d_desc.Width = 32;
texture3d_desc.Height = 32;
texture3d_desc.Depth = 32;
texture3d_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
texture3d_desc.Usage = D3D11_USAGE_DEFAULT;
texture3d_desc.BindFlags = D3D11_BIND_RENDER_TARGET;
texture3d_desc.CPUAccessFlags = 0;
texture3d_desc.MiscFlags = 0;
for (i = 0; i < ARRAY_SIZE(invalid_desc_tests); ++i)
{
assert(invalid_desc_tests[i].texture.dimension == D3D11_RTV_DIMENSION_TEXTURE2D
|| invalid_desc_tests[i].texture.dimension == D3D11_RTV_DIMENSION_TEXTURE3D);
if (invalid_desc_tests[i].texture.dimension == D3D11_RTV_DIMENSION_TEXTURE2D)
{
texture_desc.MipLevels = invalid_desc_tests[i].texture.miplevel_count;
texture_desc.ArraySize = invalid_desc_tests[i].texture.depth_or_array_size;
texture_desc.Format = invalid_desc_tests[i].texture.format;
texture_desc.MiscFlags = 0;
hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
ok(SUCCEEDED(hr), "Test %u: Failed to create 2d texture, hr %#x.\n", i, hr);
resource = (ID3D11Resource *)texture;
}
else
{
texture3d_desc.MipLevels = invalid_desc_tests[i].texture.miplevel_count;
texture3d_desc.Depth = invalid_desc_tests[i].texture.depth_or_array_size;
texture3d_desc.Format = invalid_desc_tests[i].texture.format;
hr = ID3D11Device_CreateTexture3D(device, &texture3d_desc, NULL, &texture3d);
ok(SUCCEEDED(hr), "Test %u: Failed to create 3d texture, hr %#x.\n", i, hr);
resource = (ID3D11Resource *)texture3d;
}
get_rtv_desc(&rtv_desc, &invalid_desc_tests[i].rtv_desc);
hr = ID3D11Device_CreateRenderTargetView(device, resource, &rtv_desc, &rtv);
ok(hr == E_INVALIDARG, "Test %u: Got unexpected hr %#x.\n", i, hr);
ID3D11Resource_Release(resource);
}
HeapFree(GetProcessHeap(), 0, data); HeapFree(GetProcessHeap(), 0, data);
release_test_context(&test_context); release_test_context(&test_context);
} }