Commit b09078b0 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

d3d9: COM cleanup for the IDirect3DPixelShader9 iface.

parent 704f0efe
...@@ -428,9 +428,8 @@ HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, ...@@ -428,9 +428,8 @@ HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader,
* IDirect3DPixelShader implementation structure * IDirect3DPixelShader implementation structure
*/ */
typedef struct IDirect3DPixelShader9Impl { typedef struct IDirect3DPixelShader9Impl {
/* IUnknown fields */ IDirect3DPixelShader9 IDirect3DPixelShader9_iface;
const IDirect3DPixelShader9Vtbl *lpVtbl; LONG ref;
LONG ref;
struct wined3d_shader *wined3d_shader; struct wined3d_shader *wined3d_shader;
IDirect3DDevice9Ex *parentDevice; IDirect3DDevice9Ex *parentDevice;
} IDirect3DPixelShader9Impl; } IDirect3DPixelShader9Impl;
......
...@@ -2598,7 +2598,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(IDirect3DDevice9Ex ...@@ -2598,7 +2598,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(IDirect3DDevice9Ex
} }
TRACE("Created pixel shader %p.\n", object); TRACE("Created pixel shader %p.\n", object);
*shader = (IDirect3DPixelShader9 *)object; *shader = &object->IDirect3DPixelShader9_iface;
return D3D_OK; return D3D_OK;
} }
......
...@@ -153,7 +153,7 @@ HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Im ...@@ -153,7 +153,7 @@ HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Im
static inline IDirect3DPixelShader9Impl *impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface) static inline IDirect3DPixelShader9Impl *impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface)
{ {
return CONTAINING_RECORD(iface, IDirect3DPixelShader9Impl, lpVtbl); return CONTAINING_RECORD(iface, IDirect3DPixelShader9Impl, 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 **object)
...@@ -176,7 +176,7 @@ static HRESULT WINAPI d3d9_pixelshader_QueryInterface(IDirect3DPixelShader9 *ifa ...@@ -176,7 +176,7 @@ static HRESULT WINAPI d3d9_pixelshader_QueryInterface(IDirect3DPixelShader9 *ifa
static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface) static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface)
{ {
IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)iface; IDirect3DPixelShader9Impl *shader = impl_from_IDirect3DPixelShader9(iface);
ULONG refcount = InterlockedIncrement(&shader->ref); ULONG refcount = InterlockedIncrement(&shader->ref);
TRACE("%p increasing refcount to %u.\n", iface, refcount); TRACE("%p increasing refcount to %u.\n", iface, refcount);
...@@ -194,7 +194,7 @@ static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface) ...@@ -194,7 +194,7 @@ 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 = (IDirect3DPixelShader9Impl *)iface; IDirect3DPixelShader9Impl *shader = impl_from_IDirect3DPixelShader9(iface);
ULONG refcount = InterlockedDecrement(&shader->ref); ULONG refcount = InterlockedDecrement(&shader->ref);
TRACE("%p decreasing refcount to %u.\n", iface, refcount); TRACE("%p decreasing refcount to %u.\n", iface, refcount);
...@@ -214,11 +214,14 @@ static ULONG WINAPI d3d9_pixelshader_Release(IDirect3DPixelShader9 *iface) ...@@ -214,11 +214,14 @@ static ULONG WINAPI d3d9_pixelshader_Release(IDirect3DPixelShader9 *iface)
return refcount; return refcount;
} }
static HRESULT WINAPI d3d9_pixelshader_GetDevice(IDirect3DPixelShader9 *iface, IDirect3DDevice9 **device) static HRESULT WINAPI d3d9_pixelshader_GetDevice(IDirect3DPixelShader9 *iface,
IDirect3DDevice9 **device)
{ {
IDirect3DPixelShader9Impl *shader = impl_from_IDirect3DPixelShader9(iface);
TRACE("iface %p, device %p.\n", iface, device); TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)((IDirect3DPixelShader9Impl *)iface)->parentDevice; *device = (IDirect3DDevice9 *)shader->parentDevice;
IDirect3DDevice9_AddRef(*device); IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device); TRACE("Returning device %p.\n", *device);
...@@ -226,14 +229,16 @@ static HRESULT WINAPI d3d9_pixelshader_GetDevice(IDirect3DPixelShader9 *iface, I ...@@ -226,14 +229,16 @@ static HRESULT WINAPI d3d9_pixelshader_GetDevice(IDirect3DPixelShader9 *iface, I
return D3D_OK; return D3D_OK;
} }
static HRESULT WINAPI d3d9_pixelshader_GetFunction(IDirect3DPixelShader9 *iface, void *data, UINT *data_size) static HRESULT WINAPI d3d9_pixelshader_GetFunction(IDirect3DPixelShader9 *iface, void *data,
UINT *data_size)
{ {
IDirect3DPixelShader9Impl *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);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_shader_get_byte_code(((IDirect3DPixelShader9Impl *)iface)->wined3d_shader, data, data_size); hr = wined3d_shader_get_byte_code(shader->wined3d_shader, data, data_size);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
...@@ -265,7 +270,7 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl ...@@ -265,7 +270,7 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl
HRESULT hr; HRESULT hr;
shader->ref = 1; shader->ref = 1;
shader->lpVtbl = &d3d9_pixelshader_vtbl; shader->IDirect3DPixelShader9_iface.lpVtbl = &d3d9_pixelshader_vtbl;
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_shader_create_ps(device->wined3d_device, byte_code, NULL, shader, hr = wined3d_shader_create_ps(device->wined3d_device, byte_code, NULL, shader,
......
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