[PATCH 3/8] wined3d: Check for support before creating volume textures.
Stefan Dösinger
stefan at codeweavers.com
Tue Sep 17 04:39:45 CDT 2013
---
dlls/d3dx9_36/tests/texture.c | 10 ++++++++--
dlls/wined3d/texture.c | 8 +++++---
dlls/wined3d/volume.c | 5 -----
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c
index c168052..49f9446 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_dxt5, has_cube_dxt5;
+static int has_2d_dxt5, has_cube_dxt5, has_volume_dxt5;
/* 2x2 16-bit dds, no mipmaps */
static const unsigned char dds_16bit[] = {
@@ -1565,7 +1565,10 @@ 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);
- ok(hr == D3D_OK, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
+ if (has_volume_dxt5)
+ 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);
if (SUCCEEDED(hr))
{
levelcount = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
@@ -1816,6 +1819,9 @@ START_TEST(texture)
hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_CUBETEXTURE, D3DFMT_DXT5);
has_cube_dxt5 = SUCCEEDED(hr);
+ hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
+ D3DFMT_X8R8G8B8, 0, D3DRTYPE_VOLUMETEXTURE, D3DFMT_DXT5);
+ has_volume_dxt5 = SUCCEEDED(hr);
test_D3DXCheckTextureRequirements(device);
test_D3DXCheckCubeTextureRequirements(device);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 56d13f6..e38adcf 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1126,6 +1126,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
UINT tmp_w, tmp_h, tmp_d;
unsigned int i;
HRESULT hr;
+ const struct wined3d_format *format;
/* TODO: It should only be possible to create textures for formats
* that are reported as supported. */
@@ -1135,10 +1136,11 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
return WINED3DERR_INVALIDCALL;
}
- if (!gl_info->supported[EXT_TEXTURE3D])
+ format = wined3d_get_format(&device->adapter->gl_info, desc->format);
+ if (desc->pool != WINED3D_POOL_SCRATCH)
{
- WARN("(%p) : Texture cannot be created - no volume texture support.\n", texture);
- return WINED3DERR_INVALIDCALL;
+ if (!(format->flags & WINED3DFMT_FLAG_VOLUME))
+ return WINED3DERR_INVALIDCALL;
}
/* Calculate levels for mip mapping. */
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 540db93..0cdec02 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -670,11 +670,6 @@ static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_device
HRESULT hr;
UINT size;
- if (!gl_info->supported[EXT_TEXTURE3D])
- {
- WARN("Volume cannot be created - no volume texture support.\n");
- return WINED3DERR_INVALIDCALL;
- }
/* TODO: Write tests for other resources and move this check
* to resource_init, if applicable. */
if (usage & WINED3DUSAGE_DYNAMIC
--
1.8.1.5
More information about the wine-patches
mailing list