diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h index 50d31b0bea3..17c3baed358 100644 --- a/dlls/d3d10core/d3d10core_private.h +++ b/dlls/d3d10core/d3d10core_private.h @@ -203,6 +203,7 @@ struct d3d10_pixel_shader HRESULT d3d10_pixel_shader_init(struct d3d10_pixel_shader *shader, struct d3d10_device *device, const void *byte_code, SIZE_T byte_code_length) DECLSPEC_HIDDEN; +struct d3d10_pixel_shader *unsafe_impl_from_ID3D10PixelShader(ID3D10PixelShader *iface) DECLSPEC_HIDDEN; HRESULT shader_parse_signature(const char *data, DWORD data_size, struct wined3d_shader_signature *s) DECLSPEC_HIDDEN; void shader_free_signature(struct wined3d_shader_signature *s) DECLSPEC_HIDDEN; diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c index 0f4b75fb402..149afa99a94 100644 --- a/dlls/d3d10core/device.c +++ b/dlls/d3d10core/device.c @@ -133,7 +133,7 @@ static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device *iface, ID3D10PixelShader *shader) { struct d3d10_device *This = impl_from_ID3D10Device(iface); - struct d3d10_pixel_shader *ps = (struct d3d10_pixel_shader *)shader; + struct d3d10_pixel_shader *ps = unsafe_impl_from_ID3D10PixelShader(shader); TRACE("iface %p, shader %p\n", iface, shader); diff --git a/dlls/d3d10core/shader.c b/dlls/d3d10core/shader.c index fe112dcb3a2..79131e1cfdd 100644 --- a/dlls/d3d10core/shader.c +++ b/dlls/d3d10core/shader.c @@ -419,6 +419,11 @@ HRESULT d3d10_geometry_shader_init(struct d3d10_geometry_shader *shader, struct return S_OK; } +static inline struct d3d10_pixel_shader *impl_from_ID3D10PixelShader(ID3D10PixelShader *iface) +{ + return CONTAINING_RECORD(iface, struct d3d10_pixel_shader, vtbl); +} + /* IUnknown methods */ static HRESULT STDMETHODCALLTYPE d3d10_pixel_shader_QueryInterface(ID3D10PixelShader *iface, @@ -553,3 +558,12 @@ HRESULT d3d10_pixel_shader_init(struct d3d10_pixel_shader *shader, struct d3d10_ return S_OK; } + +struct d3d10_pixel_shader *unsafe_impl_from_ID3D10PixelShader(ID3D10PixelShader *iface) +{ + if (!iface) + return NULL; + assert(iface->lpVtbl == &d3d10_pixel_shader_vtbl); + + return impl_from_ID3D10PixelShader(iface); +}