d3d9: Don't assert for shaders with the wrong vtbl.

This commit is contained in:
Michael Stefaniuc 2014-12-16 09:57:09 +01:00 committed by Alexandre Julliard
parent f95e7a4ed3
commit 51406b471a
2 changed files with 26 additions and 2 deletions

View file

@ -167,7 +167,8 @@ struct d3d9_vertexshader *unsafe_impl_from_IDirect3DVertexShader9(IDirect3DVerte
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3d9_vertexshader_vtbl);
if (iface->lpVtbl != &d3d9_vertexshader_vtbl)
WARN("Vertex shader %p with the wrong vtbl %p\n", iface, iface->lpVtbl);
return impl_from_IDirect3DVertexShader9(iface);
}
@ -317,7 +318,8 @@ struct d3d9_pixelshader *unsafe_impl_from_IDirect3DPixelShader9(IDirect3DPixelSh
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3d9_pixelshader_vtbl);
if (iface->lpVtbl != &d3d9_pixelshader_vtbl)
WARN("Pixel shader %p with the wrong vtbl %p\n", iface, iface->lpVtbl);
return impl_from_IDirect3DPixelShader9(iface);
}

View file

@ -5518,6 +5518,7 @@ static void test_get_set_vertex_shader(void)
{
IDirect3DVertexShader9 *current_shader = NULL;
IDirect3DVertexShader9 *shader = NULL;
const IDirect3DVertexShader9Vtbl *shader_vtbl;
IDirect3DDevice9 *device;
ULONG refcount, i;
IDirect3D9 *d3d;
@ -5568,6 +5569,16 @@ static void test_get_set_vertex_shader(void)
ok(current_shader == shader, "Got unexpected shader %p, expected %p.\n", current_shader, shader);
IDirect3DVertexShader9_Release(current_shader);
/* SetVertexShader() with a bogus shader vtbl */
shader_vtbl = shader->lpVtbl;
shader->lpVtbl = (IDirect3DVertexShader9Vtbl *)0xdeadbeef;
hr = IDirect3DDevice9_SetVertexShader(device, shader);
ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
shader->lpVtbl = NULL;
hr = IDirect3DDevice9_SetVertexShader(device, shader);
ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
shader->lpVtbl = shader_vtbl;
IDirect3DVertexShader9_Release(shader);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
@ -5640,6 +5651,7 @@ static void test_get_set_pixel_shader(void)
{
IDirect3DPixelShader9 *current_shader = NULL;
IDirect3DPixelShader9 *shader = NULL;
const IDirect3DPixelShader9Vtbl *shader_vtbl;
IDirect3DDevice9 *device;
ULONG refcount, i;
IDirect3D9 *d3d;
@ -5690,6 +5702,16 @@ static void test_get_set_pixel_shader(void)
ok(current_shader == shader, "Got unexpected shader %p, expected %p.\n", current_shader, shader);
IDirect3DPixelShader9_Release(current_shader);
/* SetPixelShader() with a bogus shader vtbl */
shader_vtbl = shader->lpVtbl;
shader->lpVtbl = (IDirect3DPixelShader9Vtbl *)0xdeadbeef;
hr = IDirect3DDevice9_SetPixelShader(device, shader);
ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
shader->lpVtbl = NULL;
hr = IDirect3DDevice9_SetPixelShader(device, shader);
ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
shader->lpVtbl = shader_vtbl;
IDirect3DPixelShader9_Release(shader);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);