From 7109bebd024ee68ec2b3ef0a6b29e72ded08abc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Sun, 26 Apr 2015 16:09:10 +0200 Subject: [PATCH] wined3d: Move volume DXTn handling to apply_format_fixups. --- dlls/d3d8/tests/device.c | 24 ++++-------------------- dlls/d3d9/tests/device.c | 24 ++++-------------------- dlls/d3dx9_36/tests/texture.c | 15 +++++++++++++-- dlls/wined3d/directx.c | 19 ------------------- dlls/wined3d/utils.c | 16 ++++++++++++++++ 5 files changed, 37 insertions(+), 61 deletions(-) diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 64c29116823..7158cf74b3c 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -5953,7 +5953,7 @@ static void test_volume_blocks(void) D3DLOCKED_BOX locked_box; BYTE *base; INT expected_row_pitch, expected_slice_pitch; - BOOL support, support_2d; + BOOL support; BOOL pow2; unsigned int offset, expected_offset; @@ -5977,9 +5977,6 @@ static void test_volume_blocks(void) hr = IDirect3D8_CheckDeviceFormat(d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_VOLUMETEXTURE, formats[i].fmt); support = SUCCEEDED(hr); - hr = IDirect3D8_CheckDeviceFormat(d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, - 0, D3DRTYPE_TEXTURE, formats[i].fmt); - support_2d = SUCCEEDED(hr); /* Test creation restrictions */ for (w = 1; w <= 8; w++) @@ -6000,7 +5997,6 @@ static void test_volume_blocks(void) for (j = 0; j < sizeof(create_tests) / sizeof(*create_tests); j++) { BOOL may_succeed = FALSE; - BOOL todo = FALSE; if (create_tests[j].need_runtime_support && !formats[i].core_fmt && !support) expect_hr = D3DERR_INVALIDCALL; @@ -6009,10 +6005,7 @@ static void test_volume_blocks(void) else if (pow2 && !size_is_pow2 && create_tests[j].need_driver_support) expect_hr = D3DERR_INVALIDCALL; else if (create_tests[j].need_driver_support && !support) - { - todo = support_2d; expect_hr = D3DERR_INVALIDCALL; - } else expect_hr = D3D_OK; @@ -6028,18 +6021,9 @@ static void test_volume_blocks(void) if (!formats[i].core_fmt && !support && FAILED(expect_hr)) may_succeed = TRUE; - if (todo) - { - todo_wine ok(hr == expect_hr || ((SUCCEEDED(hr) && may_succeed)), - "Got unexpected hr %#x for format %s, pool %s, size %ux%ux%u.\n", - hr, formats[i].name, create_tests[j].name, w, h, d); - } - else - { - ok(hr == expect_hr || ((SUCCEEDED(hr) && may_succeed)), - "Got unexpected hr %#x for format %s, pool %s, size %ux%ux%u.\n", - hr, formats[i].name, create_tests[j].name, w, h, d); - } + ok(hr == expect_hr || ((SUCCEEDED(hr) && may_succeed)), + "Got unexpected hr %#x for format %s, pool %s, size %ux%ux%u.\n", + hr, formats[i].name, create_tests[j].name, w, h, d); if (FAILED(hr)) ok(texture == NULL, "Got texture ptr %p, expected NULL.\n", texture); diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 4d48ea89c01..cb4a6e88d52 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -8567,7 +8567,7 @@ static void test_volume_blocks(void) D3DLOCKED_BOX locked_box; BYTE *base; INT expected_row_pitch, expected_slice_pitch; - BOOL support, support_2d; + BOOL support; BOOL pow2; unsigned int offset, expected_offset; @@ -8591,9 +8591,6 @@ static void test_volume_blocks(void) hr = IDirect3D9_CheckDeviceFormat(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_VOLUMETEXTURE, formats[i].fmt); support = SUCCEEDED(hr); - hr = IDirect3D9_CheckDeviceFormat(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, - 0, D3DRTYPE_TEXTURE, formats[i].fmt); - support_2d = SUCCEEDED(hr); /* Test creation restrictions */ for (w = 1; w <= 8; w++) @@ -8614,7 +8611,6 @@ static void test_volume_blocks(void) for (j = 0; j < sizeof(create_tests) / sizeof(*create_tests); j++) { BOOL may_succeed = FALSE; - BOOL todo = FALSE; if (create_tests[j].need_runtime_support && !formats[i].core_fmt && !support) expect_hr = D3DERR_INVALIDCALL; @@ -8623,10 +8619,7 @@ static void test_volume_blocks(void) else if (pow2 && !size_is_pow2 && create_tests[j].need_driver_support) expect_hr = D3DERR_INVALIDCALL; else if (create_tests[j].need_driver_support && !support) - { - todo = support_2d; expect_hr = D3DERR_INVALIDCALL; - } else expect_hr = D3D_OK; @@ -8642,18 +8635,9 @@ static void test_volume_blocks(void) if (!formats[i].core_fmt && !support && FAILED(expect_hr)) may_succeed = TRUE; - if (todo) - { - todo_wine ok(hr == expect_hr || ((SUCCEEDED(hr) && may_succeed)), - "Got unexpected hr %#x for format %s, pool %s, size %ux%ux%u.\n", - hr, formats[i].name, create_tests[j].name, w, h, d); - } - else - { - ok(hr == expect_hr || ((SUCCEEDED(hr) && may_succeed)), - "Got unexpected hr %#x for format %s, pool %s, size %ux%ux%u.\n", - hr, formats[i].name, create_tests[j].name, w, h, d); - } + ok(hr == expect_hr || ((SUCCEEDED(hr) && may_succeed)), + "Got unexpected hr %#x for format %s, pool %s, size %ux%ux%u.\n", + hr, formats[i].name, create_tests[j].name, w, h, d); if (FAILED(hr)) ok(texture == NULL, "Got texture ptr %p, expected NULL.\n", texture); diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index c90e2d57eb6..095650f11d3 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -25,7 +25,7 @@ #include "d3dx9tex.h" #include "resources.h" -static int has_2d_dxt3, has_2d_dxt5, has_cube_dxt5; +static int has_2d_dxt3, has_2d_dxt5, has_cube_dxt5, has_3d_dxt3; /* 2x2 16-bit dds, no mipmaps */ static const unsigned char dds_16bit[] = { @@ -575,6 +575,14 @@ static void test_D3DXCheckVolumeTextureRequirements(IDirect3DDevice9 *device) ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK); ok(format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_X8R8G8B8); + format = D3DFMT_DXT3; + hr = D3DXCheckVolumeTextureRequirements(device, NULL, NULL, NULL, NULL, 0, &format, D3DPOOL_DEFAULT); + ok(hr == D3D_OK, "D3DXCheckVolumeTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK); + if (has_3d_dxt3) + ok(format == D3DFMT_DXT3, "Returned format %u, expected %u\n", format, D3DFMT_DXT3); + else + todo_wine ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8); + /* mipmaps */ if (!(caps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP)) { @@ -1774,7 +1782,7 @@ static void test_D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *devic ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); hr = D3DXCreateVolumeTextureFromFileInMemory(device, dds_volume_map, sizeof(dds_volume_map), &volume_texture); - if (has_2d_dxt3) + if (has_3d_dxt3) ok(hr == D3D_OK, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK); else todo_wine ok(hr == D3D_OK, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK); @@ -1788,6 +1796,7 @@ static void test_D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *devic ok(volume_desc.Width == 4, "Got width %u, expected 4\n", volume_desc.Width); ok(volume_desc.Height == 4, "Got height %u, expected 4\n", volume_desc.Height); ok(volume_desc.Depth == 2, "Got depth %u, expected 2\n", volume_desc.Depth); + ok(volume_desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected D3DPOOL_MANAGED\n", volume_desc.Pool); hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 1, &volume_desc); ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK); @@ -2031,6 +2040,8 @@ START_TEST(texture) hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_CUBETEXTURE, D3DFMT_DXT5); has_cube_dxt5 = SUCCEEDED(hr); + has_3d_dxt3 = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, + D3DFMT_X8R8G8B8, 0, D3DRTYPE_VOLUMETEXTURE, D3DFMT_DXT3)); test_D3DXCheckTextureRequirements(device); test_D3DXCheckCubeTextureRequirements(device); diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 84c3aa24199..faa1a7f2e7d 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -4490,25 +4490,6 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad case WINED3D_RTYPE_VOLUME_TEXTURE: case WINED3D_RTYPE_VOLUME: - /* The GL_EXT_texture_compression_s3tc spec requires that loading - * an s3tc compressed texture results in an error. While the D3D - * refrast does support s3tc volumes, at least the nvidia Windows - * driver does not, so we're free not to support this format. */ - switch (check_format_id) - { - case WINED3DFMT_DXT1: - case WINED3DFMT_DXT2: - case WINED3DFMT_DXT3: - case WINED3DFMT_DXT4: - case WINED3DFMT_DXT5: - TRACE("[FAILED] - DXTn does not support 3D textures.\n"); - return WINED3DERR_NOTAVAILABLE; - - default: - /* Do nothing, continue with checking the format below */ - break; - } - format_flags |= WINED3DFMT_FLAG_TEXTURE; allowed_usage = WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_SOFTWAREPROCESSING diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 1d34440fc3f..b45e0bf01d3 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -2293,6 +2293,22 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_ || !adapter->fragment_pipe->color_fixup_supported(format->color_fixup)) format_clear_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE); } + + /* GL_EXT_texture_compression_s3tc does not support 3D textures. Some Windows drivers + * for dx9 GPUs support it, some do not, so not supporting DXTn volumes is OK for d3d9. + * + * Note that GL_NV_texture_compression_vtc adds this functionality to OpenGL, but the + * block layout is not compatible with the one used by d3d. See volume_dxt5_test. */ + idx = getFmtIdx(WINED3DFMT_DXT1); + gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; + idx = getFmtIdx(WINED3DFMT_DXT2); + gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; + idx = getFmtIdx(WINED3DFMT_DXT3); + gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; + idx = getFmtIdx(WINED3DFMT_DXT4); + gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; + idx = getFmtIdx(WINED3DFMT_DXT5); + gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; } static BOOL init_format_vertex_info(struct wined3d_gl_info *gl_info)