diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 8ce92b8db47..e521101aa2a 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -108,7 +108,19 @@ static void get_srv_desc(D3D10_SHADER_RESOURCE_VIEW_DESC *d3d10_desc, const stru { d3d10_desc->Format = desc->format; d3d10_desc->ViewDimension = desc->dimension; - if (desc->dimension == D3D10_SRV_DIMENSION_TEXTURE2D) + if (desc->dimension == D3D10_SRV_DIMENSION_TEXTURE1D) + { + U(*d3d10_desc).Texture1D.MostDetailedMip = desc->miplevel_idx; + U(*d3d10_desc).Texture1D.MipLevels = desc->miplevel_count; + } + else if (desc->dimension == D3D10_SRV_DIMENSION_TEXTURE1DARRAY) + { + U(*d3d10_desc).Texture1DArray.MostDetailedMip = desc->miplevel_idx; + U(*d3d10_desc).Texture1DArray.MipLevels = desc->miplevel_count; + U(*d3d10_desc).Texture1DArray.FirstArraySlice = desc->layer_idx; + U(*d3d10_desc).Texture1DArray.ArraySize = desc->layer_count; + } + else if (desc->dimension == D3D10_SRV_DIMENSION_TEXTURE2D) { U(*d3d10_desc).Texture2D.MostDetailedMip = desc->miplevel_idx; U(*d3d10_desc).Texture2D.MipLevels = desc->miplevel_count; @@ -120,12 +132,23 @@ static void get_srv_desc(D3D10_SHADER_RESOURCE_VIEW_DESC *d3d10_desc, const stru U(*d3d10_desc).Texture2DArray.FirstArraySlice = desc->layer_idx; U(*d3d10_desc).Texture2DArray.ArraySize = desc->layer_count; } + else if (desc->dimension == D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY) + { + U(*d3d10_desc).Texture2DMSArray.FirstArraySlice = desc->layer_idx; + U(*d3d10_desc).Texture2DMSArray.ArraySize = desc->layer_count; + } + else if (desc->dimension == D3D10_SRV_DIMENSION_TEXTURE3D) + { + U(*d3d10_desc).Texture3D.MostDetailedMip = desc->miplevel_idx; + U(*d3d10_desc).Texture3D.MipLevels = desc->miplevel_count; + } else if (desc->dimension == D3D10_SRV_DIMENSION_TEXTURECUBE) { U(*d3d10_desc).TextureCube.MostDetailedMip = desc->miplevel_idx; U(*d3d10_desc).TextureCube.MipLevels = desc->miplevel_count; } - else + else if (desc->dimension != D3D10_SRV_DIMENSION_UNKNOWN + && desc->dimension != D3D10_SRV_DIMENSION_TEXTURE2DMS) { trace("Unhandled view dimension %#x.\n", desc->dimension); } @@ -167,6 +190,24 @@ static void check_srv_desc_(unsigned int line, const D3D10_SHADER_RESOURCE_VIEW_ "Got ArraySize %u, expected %u.\n", U(*desc).Texture2DArray.ArraySize, expected_desc->layer_count); } + else if (desc->ViewDimension == D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY) + { + ok_(__FILE__, line)(U(*desc).Texture2DMSArray.FirstArraySlice == expected_desc->layer_idx, + "Got FirstArraySlice %u, expected %u.\n", + U(*desc).Texture2DMSArray.FirstArraySlice, expected_desc->layer_idx); + ok_(__FILE__, line)(U(*desc).Texture2DMSArray.ArraySize == expected_desc->layer_count, + "Got ArraySize %u, expected %u.\n", + U(*desc).Texture2DMSArray.ArraySize, expected_desc->layer_count); + } + else if (desc->ViewDimension == D3D10_SRV_DIMENSION_TEXTURE3D) + { + ok_(__FILE__, line)(U(*desc).Texture3D.MostDetailedMip == expected_desc->miplevel_idx, + "Got MostDetailedMip %u, expected %u.\n", + U(*desc).Texture3D.MostDetailedMip, expected_desc->miplevel_idx); + ok_(__FILE__, line)(U(*desc).Texture3D.MipLevels == expected_desc->miplevel_count, + "Got MipLevels %u, expected %u.\n", + U(*desc).Texture3D.MipLevels, expected_desc->miplevel_count); + } else if (desc->ViewDimension == D3D10_SRV_DIMENSION_TEXTURECUBE) { ok_(__FILE__, line)(U(*desc).TextureCube.MostDetailedMip == expected_desc->miplevel_idx, @@ -176,7 +217,7 @@ static void check_srv_desc_(unsigned int line, const D3D10_SHADER_RESOURCE_VIEW_ "Got MipLevels %u, expected %u.\n", U(*desc).TextureCube.MipLevels, expected_desc->miplevel_count); } - else + else if (desc->ViewDimension != D3D10_SRV_DIMENSION_TEXTURE2DMS) { trace("Unhandled view dimension %#x.\n", desc->ViewDimension); } @@ -2013,22 +2054,37 @@ static void test_render_target_views(void) static void test_create_shader_resource_view(void) { D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc; - D3D10_TEXTURE2D_DESC texture_desc; + D3D10_TEXTURE3D_DESC texture3d_desc; + D3D10_TEXTURE2D_DESC texture2d_desc; ULONG refcount, expected_refcount; ID3D10ShaderResourceView *srview; ID3D10Device *device, *tmp; - ID3D10Texture2D *texture; + ID3D10Texture3D *texture3d; + ID3D10Texture2D *texture2d; + ID3D10Resource *texture; ID3D10Buffer *buffer; IUnknown *iface; unsigned int i; HRESULT hr; +#define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN +#define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM +#define RGBA8_TL DXGI_FORMAT_R8G8B8A8_TYPELESS +#define DIM_UNKNOWN D3D10_SRV_DIMENSION_UNKNOWN +#define TEX_1D D3D10_SRV_DIMENSION_TEXTURE1D +#define TEX_1D_ARRAY D3D10_SRV_DIMENSION_TEXTURE1DARRAY +#define TEX_2D D3D10_SRV_DIMENSION_TEXTURE2D +#define TEX_2D_ARRAY D3D10_SRV_DIMENSION_TEXTURE2DARRAY +#define TEX_2DMS D3D10_SRV_DIMENSION_TEXTURE2DMS +#define TEX_2DMS_ARR D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY +#define TEX_3D D3D10_SRV_DIMENSION_TEXTURE3D +#define TEX_CUBE D3D10_SRV_DIMENSION_TEXTURECUBE static const struct { struct { unsigned int miplevel_count; - unsigned int array_size; + unsigned int depth_or_array_size; DXGI_FORMAT format; } texture; struct srv_desc srv_desc; @@ -2036,37 +2092,108 @@ static void test_create_shader_resource_view(void) } tests[] = { -#define FMT_UNKNOWN DXGI_FORMAT_UNKNOWN -#define RGBA8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM -#define TEX_2D D3D10_SRV_DIMENSION_TEXTURE2D -#define TEX_2D_ARRAY D3D10_SRV_DIMENSION_TEXTURE2DARRAY -#define TEX_CUBE D3D10_SRV_DIMENSION_TEXTURECUBE - {{10, 1, RGBA8_UNORM}, {0}, {RGBA8_UNORM, TEX_2D, 0, 10}}, - {{10, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D, 0, -1}, {RGBA8_UNORM, TEX_2D, 0, 10}}, - {{10, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D, 0, -1}, {RGBA8_UNORM, TEX_2D, 0, 10}}, - {{10, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D, 0, 10}, {RGBA8_UNORM, TEX_2D, 0, 10}}, - {{10, 4, RGBA8_UNORM}, {0}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 10, 0, 4}}, - {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 0, -1, 0, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 10, 0, 4}}, - {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 1, -1, 0, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 1, 9, 0, 4}}, - {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 3, -1, 0, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 3, 7, 0, 4}}, - {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 5, -1, 0, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 5, 5, 0, 4}}, - {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 9, -1, 0, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 9, 1, 0, 4}}, - {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 0, -1, 1, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 10, 1, 3}}, - {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 0, -1, 2, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 10, 2, 2}}, - {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 0, -1, 3, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 10, 3, 1}}, - {{2, 6, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_CUBE, 0, -1,}, {RGBA8_UNORM, TEX_CUBE, 0, 2}}, - {{2, 6, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_CUBE, 0, 1,}, {RGBA8_UNORM, TEX_CUBE , 0, 1}}, - {{2, 6, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_CUBE, 1, 1,}, {RGBA8_UNORM, TEX_CUBE , 1, 1}}, + {{10, 1, RGBA8_UNORM}, {0}, {RGBA8_UNORM, TEX_2D, 0, 10}}, + {{10, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D, 0, -1}, {RGBA8_UNORM, TEX_2D, 0, 10}}, + {{10, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D, 0, -1}, {RGBA8_UNORM, TEX_2D, 0, 10}}, + {{10, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D, 0, 10}, {RGBA8_UNORM, TEX_2D, 0, 10}}, + {{ 1, 1, RGBA8_TL}, {RGBA8_UNORM, TEX_2D, 0, -1}, {RGBA8_UNORM, TEX_2D, 0, 1}}, + {{10, 1, RGBA8_TL}, {RGBA8_UNORM, TEX_2D, 0, -1}, {RGBA8_UNORM, TEX_2D, 0, 10}}, + {{10, 4, RGBA8_UNORM}, {0}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 10, 0, 4}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 0, -1, 0, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 10, 0, 4}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 1, -1, 0, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 1, 9, 0, 4}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 3, -1, 0, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 3, 7, 0, 4}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 5, -1, 0, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 5, 5, 0, 4}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 9, -1, 0, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 9, 1, 0, 4}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 0, -1, 1, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 10, 1, 3}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 0, -1, 2, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 10, 2, 2}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2D_ARRAY, 0, -1, 3, -1}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 10, 3, 1}}, + {{ 1, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2DMS}, {RGBA8_UNORM, TEX_2DMS}}, + {{ 1, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2DMS}, {RGBA8_UNORM, TEX_2DMS}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2DMS}, {RGBA8_UNORM, TEX_2DMS}}, + {{ 1, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2DMS_ARR, 0, 1, 0, 1}, {RGBA8_UNORM, TEX_2DMS_ARR, 0, 1, 0, 1}}, + {{ 1, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2DMS_ARR, 0, 1, 0, -1}, {RGBA8_UNORM, TEX_2DMS_ARR, 0, 1, 0, 1}}, + {{10, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2DMS_ARR, 0, 1, 0, 1}, {RGBA8_UNORM, TEX_2DMS_ARR, 0, 1, 0, 1}}, + {{10, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2DMS_ARR, 0, 1, 0, -1}, {RGBA8_UNORM, TEX_2DMS_ARR, 0, 1, 0, 1}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2DMS_ARR, 0, 1, 0, 1}, {RGBA8_UNORM, TEX_2DMS_ARR, 0, 1, 0, 1}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2DMS_ARR, 0, 1, 0, 4}, {RGBA8_UNORM, TEX_2DMS_ARR, 0, 1, 0, 4}}, + {{10, 4, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_2DMS_ARR, 0, 1, 0, -1}, {RGBA8_UNORM, TEX_2DMS_ARR, 0, 1, 0, 4}}, + {{ 1, 12, RGBA8_UNORM}, {0}, {RGBA8_UNORM, TEX_3D, 0, 1}}, + {{ 1, 12, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_3D, 0, 1}, {RGBA8_UNORM, TEX_3D, 0, 1}}, + {{ 1, 12, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_3D, 0, -1}, {RGBA8_UNORM, TEX_3D, 0, 1}}, + {{ 4, 12, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_3D, 0, -1}, {RGBA8_UNORM, TEX_3D, 0, 4}}, + {{ 2, 6, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_CUBE, 0, -1}, {RGBA8_UNORM, TEX_CUBE, 0, 2}}, + {{ 2, 6, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_CUBE, 0, 1}, {RGBA8_UNORM, TEX_CUBE , 0, 1}}, + {{ 2, 6, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_CUBE, 1, 1}, {RGBA8_UNORM, TEX_CUBE , 1, 1}}, + }; + static const struct + { + struct + { + D3D10_SRV_DIMENSION dimension; + unsigned int miplevel_count; + unsigned int depth_or_array_size; + DXGI_FORMAT format; + } texture; + struct srv_desc srv_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, 1}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D_ARRAY, 0, 1, 0, 1}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 0, 1}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_TL, TEX_2D, 0, -1}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_TL, TEX_2D, 0, 1}}, + {{TEX_2D, 1, 1, RGBA8_TL}, {FMT_UNKNOWN, TEX_2D, 0, -1}}, + {{TEX_2D, 1, 1, RGBA8_TL}, {FMT_UNKNOWN, TEX_2D, 0, 1}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D, 0, 0}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D, 0, 2}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D, 1, 1}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 0, 0, 0}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 0, 0, 1}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 1, 0, 0}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 2, 0, 1}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 1, 1, 0, 1}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 1, 0, 2}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 1, 1, 1}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2DMS_ARR, 0, 1, 0, 2}}, + {{TEX_2D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2DMS_ARR, 0, 1, 1, 1}}, + {{TEX_2D, 1, 6, RGBA8_UNORM}, {RGBA8_UNORM, TEX_CUBE, 0, 0}}, + {{TEX_2D, 1, 6, RGBA8_UNORM}, {RGBA8_UNORM, TEX_CUBE, 0, 2}}, + {{TEX_2D, 1, 6, RGBA8_UNORM}, {RGBA8_UNORM, TEX_CUBE, 1, 1}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D, 0, 1}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D_ARRAY, 0, 1, 0, 1}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D, 0, 1}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_CUBE, 0, 1}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 1, 0, 1}}, + {{TEX_3D, 1, 9, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D, 0, 1}}, + {{TEX_3D, 1, 9, RGBA8_UNORM}, {RGBA8_UNORM, TEX_1D_ARRAY, 0, 1, 0, 1}}, + {{TEX_3D, 1, 9, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D, 0, 1}}, + {{TEX_3D, 1, 9, RGBA8_UNORM}, {RGBA8_UNORM, TEX_CUBE, 0, 1}}, + {{TEX_3D, 1, 9, RGBA8_UNORM}, {RGBA8_UNORM, TEX_2D_ARRAY, 0, 1, 0, 1}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 0, 0}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_TL, TEX_3D, 0, 1}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_3D, 0, 2}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {FMT_UNKNOWN, TEX_3D, 1, 1}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 0, 2}}, + {{TEX_3D, 1, 1, RGBA8_UNORM}, {RGBA8_UNORM, TEX_3D, 1, 1}}, + }; #undef FMT_UNKNOWN #undef RGBA8_UNORM +#undef DIM_UNKNOWN +#undef TEX_1D +#undef TEX_1D_ARRAY #undef TEX_2D #undef TEX_2D_ARRAY +#undef TEX_2DMS +#undef TEX_2DMS_ARR +#undef TEX_3D #undef TEX_CUBE - }; if (!(device = create_device())) { - skip("Failed to create device, skipping tests.\n"); + skip("Failed to create device.\n"); return; } @@ -2082,7 +2209,7 @@ static void test_create_shader_resource_view(void) expected_refcount = get_refcount((IUnknown *)device) + 1; hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)buffer, &srv_desc, &srview); - ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x\n", hr); + ok(SUCCEEDED(hr), "Failed to create a shader resource view, 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; @@ -2105,28 +2232,49 @@ static void test_create_shader_resource_view(void) ID3D10ShaderResourceView_Release(srview); ID3D10Buffer_Release(buffer); - texture_desc.Width = 512; - texture_desc.Height = 512; - texture_desc.SampleDesc.Count = 1; - texture_desc.SampleDesc.Quality = 0; - texture_desc.Usage = D3D10_USAGE_DEFAULT; - texture_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; - texture_desc.CPUAccessFlags = 0; + texture2d_desc.Width = 512; + texture2d_desc.Height = 512; + texture2d_desc.SampleDesc.Count = 1; + texture2d_desc.SampleDesc.Quality = 0; + texture2d_desc.Usage = D3D10_USAGE_DEFAULT; + texture2d_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; + texture2d_desc.CPUAccessFlags = 0; + + texture3d_desc.Width = 64; + texture3d_desc.Height = 64; + texture3d_desc.Usage = D3D10_USAGE_DEFAULT; + texture3d_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; + texture3d_desc.CPUAccessFlags = 0; + texture3d_desc.MiscFlags = 0; for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i) { D3D10_SHADER_RESOURCE_VIEW_DESC *current_desc; - texture_desc.MipLevels = tests[i].texture.miplevel_count; - texture_desc.ArraySize = tests[i].texture.array_size; - texture_desc.Format = tests[i].texture.format; - texture_desc.MiscFlags = 0; + if (tests[i].expected_srv_desc.dimension != D3D10_SRV_DIMENSION_TEXTURE3D) + { + texture2d_desc.MipLevels = tests[i].texture.miplevel_count; + texture2d_desc.ArraySize = tests[i].texture.depth_or_array_size; + texture2d_desc.Format = tests[i].texture.format; + texture2d_desc.MiscFlags = 0; - if (tests[i].srv_desc.dimension == D3D10_SRV_DIMENSION_TEXTURECUBE) - texture_desc.MiscFlags |= D3D10_RESOURCE_MISC_TEXTURECUBE; + if (tests[i].srv_desc.dimension == D3D10_SRV_DIMENSION_TEXTURECUBE) + texture2d_desc.MiscFlags |= D3D10_RESOURCE_MISC_TEXTURECUBE; - hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture); - ok(SUCCEEDED(hr), "Test %u: Failed to create a 2d texture, hr %#x.\n", i, hr); + hr = ID3D10Device_CreateTexture2D(device, &texture2d_desc, NULL, &texture2d); + ok(SUCCEEDED(hr), "Test %u: Failed to create 2d texture, hr %#x.\n", i, hr); + texture = (ID3D10Resource *)texture2d; + } + else + { + texture3d_desc.MipLevels = tests[i].texture.miplevel_count; + texture3d_desc.Depth = tests[i].texture.depth_or_array_size; + texture3d_desc.Format = tests[i].texture.format; + + hr = ID3D10Device_CreateTexture3D(device, &texture3d_desc, NULL, &texture3d); + ok(SUCCEEDED(hr), "Test %u: Failed to create 3d texture, hr %#x.\n", i, hr); + texture = (ID3D10Resource *)texture3d; + } if (tests[i].srv_desc.dimension == D3D10_SRV_DIMENSION_UNKNOWN) { @@ -2138,7 +2286,7 @@ static void test_create_shader_resource_view(void) get_srv_desc(current_desc, &tests[i].srv_desc); } - hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)texture, current_desc, &srview); + hr = ID3D10Device_CreateShaderResourceView(device, texture, current_desc, &srview); ok(SUCCEEDED(hr), "Test %u: Failed to create a shader resource view, hr %#x.\n", i, hr); hr = ID3D10ShaderResourceView_QueryInterface(srview, &IID_ID3D10ShaderResourceView1, (void **)&iface); @@ -2155,7 +2303,44 @@ static void test_create_shader_resource_view(void) check_srv_desc(&srv_desc, &tests[i].expected_srv_desc); ID3D10ShaderResourceView_Release(srview); - ID3D10Texture2D_Release(texture); + ID3D10Resource_Release(texture); + } + + for (i = 0; i < sizeof(invalid_desc_tests) / sizeof(*invalid_desc_tests); ++i) + { + assert(invalid_desc_tests[i].texture.dimension == D3D10_SRV_DIMENSION_TEXTURE2D + || invalid_desc_tests[i].texture.dimension == D3D10_SRV_DIMENSION_TEXTURE3D); + + if (invalid_desc_tests[i].texture.dimension == D3D10_SRV_DIMENSION_TEXTURE2D) + { + texture2d_desc.MipLevels = invalid_desc_tests[i].texture.miplevel_count; + texture2d_desc.ArraySize = invalid_desc_tests[i].texture.depth_or_array_size; + texture2d_desc.Format = invalid_desc_tests[i].texture.format; + texture2d_desc.MiscFlags = 0; + + if (invalid_desc_tests[i].srv_desc.dimension == D3D10_SRV_DIMENSION_TEXTURECUBE) + texture2d_desc.MiscFlags |= D3D10_RESOURCE_MISC_TEXTURECUBE; + + hr = ID3D10Device_CreateTexture2D(device, &texture2d_desc, NULL, &texture2d); + ok(SUCCEEDED(hr), "Test %u: Failed to create 2d texture, hr %#x.\n", i, hr); + texture = (ID3D10Resource *)texture2d; + } + 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 = ID3D10Device_CreateTexture3D(device, &texture3d_desc, NULL, &texture3d); + ok(SUCCEEDED(hr), "Test %u: Failed to create 3d texture, hr %#x.\n", i, hr); + texture = (ID3D10Resource *)texture3d; + } + + get_srv_desc(&srv_desc, &invalid_desc_tests[i].srv_desc); + hr = ID3D10Device_CreateShaderResourceView(device, texture, &srv_desc, &srview); + ok(hr == E_INVALIDARG, "Test %u: Got unexpected hr %#x.\n", i, hr); + + ID3D10Resource_Release(texture); } refcount = ID3D10Device_Release(device);