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