Stefan Dösinger : wined3d: Report incorrect filtering settings in ValidateDevice.
Alexandre Julliard
julliard at winehq.org
Tue Sep 2 08:33:29 CDT 2008
Module: wine
Branch: master
Commit: 8b1727ae62f249f0d909ca76b0ae402f6e912613
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8b1727ae62f249f0d909ca76b0ae402f6e912613
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Thu Aug 21 15:10:46 2008 +0200
wined3d: Report incorrect filtering settings in ValidateDevice.
---
dlls/d3d9/tests/texture.c | 88 +++++++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/device.c | 40 +++++++++++++++++++-
2 files changed, 126 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d9/tests/texture.c b/dlls/d3d9/tests/texture.c
index bbc98a7..7212d3c 100644
--- a/dlls/d3d9/tests/texture.c
+++ b/dlls/d3d9/tests/texture.c
@@ -236,6 +236,93 @@ static void test_mipmap_gen(IDirect3DDevice9 *device)
IDirect3DTexture9_Release(texture);
}
+static void test_filter(IDirect3DDevice9 *device) {
+ HRESULT hr;
+ IDirect3DTexture9 *texture;
+ IDirect3D9 *d3d9;
+ DWORD passes = 0;
+ unsigned int i;
+ struct filter_tests {
+ DWORD magfilter, minfilter, mipfilter;
+ BOOL has_texture;
+ HRESULT result;
+ } tests[] = {
+ { D3DTEXF_NONE, D3DTEXF_NONE, D3DTEXF_NONE, FALSE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
+ { D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_NONE, FALSE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
+ { D3DTEXF_NONE, D3DTEXF_POINT, D3DTEXF_NONE, FALSE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
+ { D3DTEXF_POINT, D3DTEXF_POINT, D3DTEXF_NONE, FALSE, D3D_OK },
+ { D3DTEXF_POINT, D3DTEXF_POINT, D3DTEXF_POINT, FALSE, D3D_OK },
+
+ { D3DTEXF_NONE, D3DTEXF_NONE, D3DTEXF_NONE, TRUE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
+ { D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_NONE, TRUE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
+ { D3DTEXF_POINT, D3DTEXF_POINT, D3DTEXF_NONE, TRUE, D3D_OK },
+ { D3DTEXF_POINT, D3DTEXF_POINT, D3DTEXF_POINT, TRUE, D3D_OK },
+
+ { D3DTEXF_NONE, D3DTEXF_NONE, D3DTEXF_NONE, TRUE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
+ { D3DTEXF_LINEAR, D3DTEXF_NONE, D3DTEXF_NONE, TRUE, D3DERR_UNSUPPORTEDTEXTUREFILTER },
+ { D3DTEXF_LINEAR, D3DTEXF_POINT, D3DTEXF_NONE, TRUE, E_FAIL },
+ { D3DTEXF_POINT, D3DTEXF_LINEAR, D3DTEXF_NONE, TRUE, E_FAIL },
+ { D3DTEXF_POINT, D3DTEXF_POINT, D3DTEXF_LINEAR, TRUE, E_FAIL },
+
+ };
+
+ hr = IDirect3DDevice9_GetDirect3D(device, &d3d9);
+ ok(hr == D3D_OK, "IDirect3DDevice9_GetDirect3D(levels = 1) returned %08x\n", hr);
+ hr = IDirect3D9_CheckDeviceFormat(d3d9, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0,
+ D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F);
+ if(FAILED(hr)) {
+ skip("D3DFMT_A32B32G32R32F not supported\n");
+ goto out;
+ }
+ hr = IDirect3D9_CheckDeviceFormat(d3d9, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER,
+ D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F);
+ if(SUCCEEDED(hr)) {
+ skip("D3DFMT_A32B32G32R32F supports filtering\n");
+ goto out;
+ }
+
+ hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 0, 0, D3DFMT_A32B32G32R32F,
+ D3DPOOL_MANAGED, &texture, 0);
+ ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture returned %08x\n", hr);
+
+ /* Needed for ValidateDevice */
+ hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
+ ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %08x\n", hr);
+
+ for(i = 0; i < (sizeof(tests) / sizeof(tests[0])); i++) {
+ if(tests[i].has_texture) {
+ hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
+ ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture returned %08x\n", hr);
+ } else {
+ hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
+ ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture returned %08x\n", hr);
+ }
+
+ hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, tests[i].magfilter);
+ ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState returned %08x\n", hr);
+ hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, tests[i].minfilter);
+ ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState returned %08x\n", hr);
+ hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, tests[i].mipfilter);
+ ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState returned %08x\n", hr);
+
+ passes = 0xdeadbeef;
+ hr = IDirect3DDevice9_ValidateDevice(device, &passes);
+ ok(hr == tests[i].result, "ValidateDevice failed: Texture %s, min %u, mag %u, mip %u. Got %08x, expected %08x\n",
+ tests[i].has_texture ? "TRUE" : "FALSE", tests[i].magfilter, tests[i].minfilter,
+ tests[i].mipfilter, hr, tests[i].result);
+ if(SUCCEEDED(hr)) {
+ ok(passes != 0, "ValidateDevice succeeded, passes is %u\n", passes);
+ } else {
+ ok(passes == 0xdeadbeef, "ValidateDevice failed, passes is %u\n", passes);
+ }
+ }
+
+ hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
+
+ out:
+ IDirect3D9_Release(d3d9);
+}
+
START_TEST(texture)
{
D3DCAPS9 caps;
@@ -257,4 +344,5 @@ START_TEST(texture)
test_texture_stage_states(device_ptr, caps.MaxTextureBlendStages);
test_cube_textures(device_ptr, caps.TextureCaps);
test_mipmap_gen(device_ptr);
+ test_filter(device_ptr);
}
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 73e4242..609b77f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5576,10 +5576,46 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *if
static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface, DWORD* pNumPasses) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+ IWineD3DBaseTextureImpl *texture;
+ const GlPixelFormatDesc *gl_info;
+ DWORD i;
+
+ TRACE("(%p) : %p \n", This, pNumPasses);
+
+ for(i = 0; i < MAX_COMBINED_SAMPLERS; i++) {
+ if(This->stateBlock->samplerState[i][WINED3DSAMP_MINFILTER] == WINED3DTEXF_NONE) {
+ WARN("Sampler state %u has minfilter D3DTEXF_NONE, returning D3DERR_UNSUPPORTEDTEXTUREFILTER\n", i);
+ return WINED3DERR_UNSUPPORTEDTEXTUREFILTER;
+ }
+ if(This->stateBlock->samplerState[i][WINED3DSAMP_MAGFILTER] == WINED3DTEXF_NONE) {
+ WARN("Sampler state %u has magfilter D3DTEXF_NONE, returning D3DERR_UNSUPPORTEDTEXTUREFILTER\n", i);
+ return WINED3DERR_UNSUPPORTEDTEXTUREFILTER;
+ }
+
+ texture = (IWineD3DBaseTextureImpl *) This->stateBlock->textures[i];
+ if(!texture) continue;
+ getFormatDescEntry(texture->resource.format, &GLINFO_LOCATION, &gl_info);
+ if(gl_info->Flags & WINED3DFMT_FLAG_FILTERING) continue;
+
+ if(This->stateBlock->samplerState[i][WINED3DSAMP_MAGFILTER] != WINED3DTEXF_POINT) {
+ WARN("Non-filterable texture and mag filter enabled on samper %u, returning E_FAIL\n", i);
+ return E_FAIL;
+ }
+ if(This->stateBlock->samplerState[i][WINED3DSAMP_MINFILTER] != WINED3DTEXF_POINT) {
+ WARN("Non-filterable texture and min filter enabled on samper %u, returning E_FAIL\n", i);
+ return E_FAIL;
+ }
+ if(This->stateBlock->samplerState[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_NONE &&
+ This->stateBlock->samplerState[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_POINT /* sic! */) {
+ WARN("Non-filterable texture and mip filter enabled on samper %u, returning E_FAIL\n", i);
+ return E_FAIL;
+ }
+ }
+
/* return a sensible default */
*pNumPasses = 1;
- /* TODO: If the window is minimized then validate device should return something other than WINED3D_OK */
- FIXME("(%p) : stub\n", This);
+
+ TRACE("returning D3D_OK\n");
return WINED3D_OK;
}
More information about the wine-cvs
mailing list