diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index b259ed5959f..db783d89c2e 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -437,6 +437,7 @@ typedef struct IDirect3DPixelShader9Impl { HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code) DECLSPEC_HIDDEN; +IDirect3DPixelShader9Impl *unsafe_impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface) DECLSPEC_HIDDEN; /* --------------- */ /* IDirect3DQuery9 */ diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 89f292a4975..2f7a38fb5a2 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2607,13 +2607,14 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(IDirect3DDevice9Ex *if IDirect3DPixelShader9 *shader) { IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface); + IDirect3DPixelShader9Impl *shader_obj = unsafe_impl_from_IDirect3DPixelShader9(shader); HRESULT hr; TRACE("iface %p, shader %p.\n", iface, shader); wined3d_mutex_lock(); hr = wined3d_device_set_pixel_shader(This->wined3d_device, - shader ? ((IDirect3DPixelShader9Impl *)shader)->wined3d_shader : NULL); + shader_obj ? shader_obj->wined3d_shader : NULL); wined3d_mutex_unlock(); return hr; diff --git a/dlls/d3d9/shader.c b/dlls/d3d9/shader.c index c36600dcd60..66f1c07d92d 100644 --- a/dlls/d3d9/shader.c +++ b/dlls/d3d9/shader.c @@ -18,6 +18,7 @@ */ #include "config.h" +#include #include "d3d9_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d9); @@ -150,6 +151,11 @@ HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Im return D3D_OK; } +static inline IDirect3DPixelShader9Impl *impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface) +{ + return CONTAINING_RECORD(iface, IDirect3DPixelShader9Impl, lpVtbl); +} + static HRESULT WINAPI d3d9_pixelshader_QueryInterface(IDirect3DPixelShader9 *iface, REFIID riid, void **object) { TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); @@ -276,3 +282,12 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl return D3D_OK; } + +IDirect3DPixelShader9Impl *unsafe_impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface) +{ + if (!iface) + return NULL; + assert(iface->lpVtbl == &d3d9_pixelshader_vtbl); + + return impl_from_IDirect3DPixelShader9(iface); +}