Commit 2f2995de authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Get rid of IDirect3DPixelShader9Impl.

parent df9c6aa3
...@@ -287,23 +287,17 @@ struct d3d9_vertexshader *unsafe_impl_from_IDirect3DVertexShader9(IDirect3DVerte ...@@ -287,23 +287,17 @@ struct d3d9_vertexshader *unsafe_impl_from_IDirect3DVertexShader9(IDirect3DVerte
#define D3D9_MAX_VERTEX_SHADER_CONSTANTF 256 #define D3D9_MAX_VERTEX_SHADER_CONSTANTF 256
#define D3D9_MAX_SIMULTANEOUS_RENDERTARGETS 4 #define D3D9_MAX_SIMULTANEOUS_RENDERTARGETS 4
/* --------------------- */ struct d3d9_pixelshader
/* IDirect3DPixelShader9 */ {
/* --------------------- */
/*****************************************************************************
* IDirect3DPixelShader implementation structure
*/
typedef struct IDirect3DPixelShader9Impl {
IDirect3DPixelShader9 IDirect3DPixelShader9_iface; IDirect3DPixelShader9 IDirect3DPixelShader9_iface;
LONG ref; LONG refcount;
struct wined3d_shader *wined3d_shader; struct wined3d_shader *wined3d_shader;
IDirect3DDevice9Ex *parentDevice; IDirect3DDevice9Ex *parent_device;
} IDirect3DPixelShader9Impl; };
HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, HRESULT pixelshader_init(struct d3d9_pixelshader *shader,
struct d3d9_device *device, const DWORD *byte_code) DECLSPEC_HIDDEN; struct d3d9_device *device, const DWORD *byte_code) DECLSPEC_HIDDEN;
IDirect3DPixelShader9Impl *unsafe_impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface) DECLSPEC_HIDDEN; struct d3d9_pixelshader *unsafe_impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface) DECLSPEC_HIDDEN;
/* --------------- */ /* --------------- */
/* IDirect3DQuery9 */ /* IDirect3DQuery9 */
......
...@@ -2547,7 +2547,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface, ...@@ -2547,7 +2547,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface,
const DWORD *byte_code, IDirect3DPixelShader9 **shader) const DWORD *byte_code, IDirect3DPixelShader9 **shader)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DPixelShader9Impl *object; struct d3d9_pixelshader *object;
HRESULT hr; HRESULT hr;
TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader); TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
...@@ -2576,7 +2576,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface, ...@@ -2576,7 +2576,7 @@ static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface,
static HRESULT WINAPI d3d9_device_SetPixelShader(IDirect3DDevice9Ex *iface, IDirect3DPixelShader9 *shader) static HRESULT WINAPI d3d9_device_SetPixelShader(IDirect3DDevice9Ex *iface, IDirect3DPixelShader9 *shader)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DPixelShader9Impl *shader_obj = unsafe_impl_from_IDirect3DPixelShader9(shader); struct d3d9_pixelshader *shader_obj = unsafe_impl_from_IDirect3DPixelShader9(shader);
HRESULT hr; HRESULT hr;
TRACE("iface %p, shader %p.\n", iface, shader); TRACE("iface %p, shader %p.\n", iface, shader);
...@@ -2592,7 +2592,7 @@ static HRESULT WINAPI d3d9_device_SetPixelShader(IDirect3DDevice9Ex *iface, IDir ...@@ -2592,7 +2592,7 @@ static HRESULT WINAPI d3d9_device_SetPixelShader(IDirect3DDevice9Ex *iface, IDir
static HRESULT WINAPI d3d9_device_GetPixelShader(IDirect3DDevice9Ex *iface, IDirect3DPixelShader9 **shader) static HRESULT WINAPI d3d9_device_GetPixelShader(IDirect3DDevice9Ex *iface, IDirect3DPixelShader9 **shader)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DPixelShader9Impl *shader_impl; struct d3d9_pixelshader *shader_impl;
struct wined3d_shader *wined3d_shader; struct wined3d_shader *wined3d_shader;
TRACE("iface %p, shader %p.\n", iface, shader); TRACE("iface %p, shader %p.\n", iface, shader);
......
...@@ -166,39 +166,39 @@ struct d3d9_vertexshader *unsafe_impl_from_IDirect3DVertexShader9(IDirect3DVerte ...@@ -166,39 +166,39 @@ struct d3d9_vertexshader *unsafe_impl_from_IDirect3DVertexShader9(IDirect3DVerte
return impl_from_IDirect3DVertexShader9(iface); return impl_from_IDirect3DVertexShader9(iface);
} }
static inline IDirect3DPixelShader9Impl *impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface) static inline struct d3d9_pixelshader *impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface)
{ {
return CONTAINING_RECORD(iface, IDirect3DPixelShader9Impl, IDirect3DPixelShader9_iface); return CONTAINING_RECORD(iface, struct d3d9_pixelshader, IDirect3DPixelShader9_iface);
} }
static HRESULT WINAPI d3d9_pixelshader_QueryInterface(IDirect3DPixelShader9 *iface, REFIID riid, void **object) static HRESULT WINAPI d3d9_pixelshader_QueryInterface(IDirect3DPixelShader9 *iface, REFIID riid, void **out)
{ {
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
if (IsEqualGUID(riid, &IID_IDirect3DPixelShader9) if (IsEqualGUID(riid, &IID_IDirect3DPixelShader9)
|| IsEqualGUID(riid, &IID_IUnknown)) || IsEqualGUID(riid, &IID_IUnknown))
{ {
IDirect3DPixelShader9_AddRef(iface); IDirect3DPixelShader9_AddRef(iface);
*object = iface; *out = iface;
return S_OK; return S_OK;
} }
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL; *out = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface) static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface)
{ {
IDirect3DPixelShader9Impl *shader = impl_from_IDirect3DPixelShader9(iface); struct d3d9_pixelshader *shader = impl_from_IDirect3DPixelShader9(iface);
ULONG refcount = InterlockedIncrement(&shader->ref); ULONG refcount = InterlockedIncrement(&shader->refcount);
TRACE("%p increasing refcount to %u.\n", iface, refcount); TRACE("%p increasing refcount to %u.\n", iface, refcount);
if (refcount == 1) if (refcount == 1)
{ {
IDirect3DDevice9Ex_AddRef(shader->parentDevice); IDirect3DDevice9Ex_AddRef(shader->parent_device);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_shader_incref(shader->wined3d_shader); wined3d_shader_incref(shader->wined3d_shader);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
...@@ -209,14 +209,14 @@ static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface) ...@@ -209,14 +209,14 @@ static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface)
static ULONG WINAPI d3d9_pixelshader_Release(IDirect3DPixelShader9 *iface) static ULONG WINAPI d3d9_pixelshader_Release(IDirect3DPixelShader9 *iface)
{ {
IDirect3DPixelShader9Impl *shader = impl_from_IDirect3DPixelShader9(iface); struct d3d9_pixelshader *shader = impl_from_IDirect3DPixelShader9(iface);
ULONG refcount = InterlockedDecrement(&shader->ref); ULONG refcount = InterlockedDecrement(&shader->refcount);
TRACE("%p decreasing refcount to %u.\n", iface, refcount); TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (!refcount) if (!refcount)
{ {
IDirect3DDevice9Ex *device = shader->parentDevice; IDirect3DDevice9Ex *device = shader->parent_device;
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_shader_decref(shader->wined3d_shader); wined3d_shader_decref(shader->wined3d_shader);
...@@ -229,14 +229,13 @@ static ULONG WINAPI d3d9_pixelshader_Release(IDirect3DPixelShader9 *iface) ...@@ -229,14 +229,13 @@ static ULONG WINAPI d3d9_pixelshader_Release(IDirect3DPixelShader9 *iface)
return refcount; return refcount;
} }
static HRESULT WINAPI d3d9_pixelshader_GetDevice(IDirect3DPixelShader9 *iface, static HRESULT WINAPI d3d9_pixelshader_GetDevice(IDirect3DPixelShader9 *iface, IDirect3DDevice9 **device)
IDirect3DDevice9 **device)
{ {
IDirect3DPixelShader9Impl *shader = impl_from_IDirect3DPixelShader9(iface); struct d3d9_pixelshader *shader = impl_from_IDirect3DPixelShader9(iface);
TRACE("iface %p, device %p.\n", iface, device); TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)shader->parentDevice; *device = (IDirect3DDevice9 *)shader->parent_device;
IDirect3DDevice9_AddRef(*device); IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device); TRACE("Returning device %p.\n", *device);
...@@ -244,10 +243,9 @@ static HRESULT WINAPI d3d9_pixelshader_GetDevice(IDirect3DPixelShader9 *iface, ...@@ -244,10 +243,9 @@ static HRESULT WINAPI d3d9_pixelshader_GetDevice(IDirect3DPixelShader9 *iface,
return D3D_OK; return D3D_OK;
} }
static HRESULT WINAPI d3d9_pixelshader_GetFunction(IDirect3DPixelShader9 *iface, void *data, static HRESULT WINAPI d3d9_pixelshader_GetFunction(IDirect3DPixelShader9 *iface, void *data, UINT *data_size)
UINT *data_size)
{ {
IDirect3DPixelShader9Impl *shader = impl_from_IDirect3DPixelShader9(iface); struct d3d9_pixelshader *shader = impl_from_IDirect3DPixelShader9(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size); TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
...@@ -280,11 +278,11 @@ static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops = ...@@ -280,11 +278,11 @@ static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops =
d3d9_pixelshader_wined3d_object_destroyed, d3d9_pixelshader_wined3d_object_destroyed,
}; };
HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, struct d3d9_device *device, const DWORD *byte_code) HRESULT pixelshader_init(struct d3d9_pixelshader *shader, struct d3d9_device *device, const DWORD *byte_code)
{ {
HRESULT hr; HRESULT hr;
shader->ref = 1; shader->refcount = 1;
shader->IDirect3DPixelShader9_iface.lpVtbl = &d3d9_pixelshader_vtbl; shader->IDirect3DPixelShader9_iface.lpVtbl = &d3d9_pixelshader_vtbl;
wined3d_mutex_lock(); wined3d_mutex_lock();
...@@ -297,13 +295,13 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, struct d3d9_device * ...@@ -297,13 +295,13 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, struct d3d9_device *
return hr; return hr;
} }
shader->parentDevice = &device->IDirect3DDevice9Ex_iface; shader->parent_device = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(shader->parentDevice); IDirect3DDevice9Ex_AddRef(shader->parent_device);
return D3D_OK; return D3D_OK;
} }
IDirect3DPixelShader9Impl *unsafe_impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface) struct d3d9_pixelshader *unsafe_impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface)
{ {
if (!iface) if (!iface)
return NULL; return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment