[PATCH 4/5] d3d8: Remove COM from the pixel shader implementation.
Henri Verbeet
hverbeet at codeweavers.com
Tue Jan 24 14:47:48 CST 2012
---
dlls/d3d8/d3d8_private.h | 38 +++--------------------
dlls/d3d8/device.c | 17 ++++------
dlls/d3d8/shader.c | 74 +++++-----------------------------------------
3 files changed, 20 insertions(+), 109 deletions(-)
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index fb09314..40c803f 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -365,9 +365,6 @@ struct IDirect3DVolumeTexture8Impl
HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice8Impl *device,
UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
-DEFINE_GUID(IID_IDirect3DPixelShader8,
-0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89);
-
struct d3d8_vertex_declaration
{
DWORD *elements;
@@ -382,28 +379,6 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration
HRESULT d3d8_vertex_declaration_init_fvf(struct d3d8_vertex_declaration *declaration,
IDirect3DDevice8Impl *device, DWORD fvf) DECLSPEC_HIDDEN;
-/*****************************************************************************
- * IDirect3DPixelShader8 interface
- */
-#define INTERFACE IDirect3DPixelShader8
-DECLARE_INTERFACE_(IDirect3DPixelShader8,IUnknown)
-{
- /*** IUnknown methods ***/
- STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
-};
-#undef INTERFACE
-
-/*** IUnknown methods ***/
-#define IDirect3DPixelShader8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirect3DPixelShader8_AddRef(p) (p)->lpVtbl->AddRef(p)
-#define IDirect3DPixelShader8_Release(p) (p)->lpVtbl->Release(p)
-
-/*****************************************************************************
- * IDirect3DVertexShader implementation structure
- */
-
struct d3d8_vertex_shader
{
struct d3d8_vertex_declaration *vertex_declaration;
@@ -416,17 +391,14 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, IDirect3DDevi
#define D3D8_MAX_VERTEX_SHADER_CONSTANTF 256
-/*****************************************************************************
- * IDirect3DPixelShader implementation structure
- */
-typedef struct IDirect3DPixelShader8Impl {
- IDirect3DPixelShader8 IDirect3DPixelShader8_iface;
- LONG ref;
+struct d3d8_pixel_shader
+{
DWORD handle;
struct wined3d_shader *wined3d_shader;
-} IDirect3DPixelShader8Impl;
+};
-HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device,
+void d3d8_pixel_shader_destroy(struct d3d8_pixel_shader *shader) DECLSPEC_HIDDEN;
+HRESULT d3d8_pixel_shader_init(struct d3d8_pixel_shader *shader, IDirect3DDevice8Impl *device,
const DWORD *byte_code, DWORD shader_handle) DECLSPEC_HIDDEN;
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index e724824..5777fd5 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2387,7 +2387,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *i
const DWORD *byte_code, DWORD *shader)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
- IDirect3DPixelShader8Impl *object;
+ struct d3d8_pixel_shader *object;
DWORD shader_handle;
DWORD handle;
HRESULT hr;
@@ -2419,7 +2419,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *i
shader_handle = handle + VS_HIGHESTFIXEDFXF + 1;
- hr = pixelshader_init(object, This, byte_code, shader_handle);
+ hr = d3d8_pixel_shader_init(object, This, byte_code, shader_handle);
if (FAILED(hr))
{
WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
@@ -2440,7 +2440,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *i
static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(IDirect3DDevice8 *iface, DWORD pShader)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
- IDirect3DPixelShader8Impl *shader;
+ struct d3d8_pixel_shader *shader;
HRESULT hr;
TRACE("iface %p, shader %#x.\n", iface, pShader);
@@ -2485,7 +2485,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac
object = wined3d_device_get_pixel_shader(This->wined3d_device);
if (object)
{
- IDirect3DPixelShader8Impl *d3d8_shader;
+ struct d3d8_pixel_shader *d3d8_shader;
d3d8_shader = wined3d_shader_get_parent(object);
wined3d_shader_decref(object);
*ppShader = d3d8_shader->handle;
@@ -2504,7 +2504,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac
static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *iface, DWORD pShader)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
- IDirect3DPixelShader8Impl *shader;
+ struct d3d8_pixel_shader *shader;
struct wined3d_shader *cur;
TRACE("iface %p, shader %#x.\n", iface, pShader);
@@ -2529,10 +2529,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *i
wined3d_mutex_unlock();
- if (IDirect3DPixelShader8_Release(&shader->IDirect3DPixelShader8_iface))
- {
- ERR("Shader %p has references left, this shouldn't happen.\n", shader);
- }
+ d3d8_pixel_shader_destroy(shader);
return D3D_OK;
}
@@ -2573,7 +2570,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(IDirect3DDevic
DWORD pPixelShader, void *pData, DWORD *pSizeOfData)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
- IDirect3DPixelShader8Impl *shader = NULL;
+ struct d3d8_pixel_shader *shader = NULL;
HRESULT hr;
TRACE("iface %p, shader %#x, data %p, data_size %p.\n",
diff --git a/dlls/d3d8/shader.c b/dlls/d3d8/shader.c
index 48d7a2b..546bf40 100644
--- a/dlls/d3d8/shader.c
+++ b/dlls/d3d8/shader.c
@@ -133,74 +133,18 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, IDirect3DDevi
return D3D_OK;
}
-static inline IDirect3DPixelShader8Impl *impl_from_IDirect3DPixelShader8(IDirect3DPixelShader8 *iface)
-{
- return CONTAINING_RECORD(iface, IDirect3DPixelShader8Impl, IDirect3DPixelShader8_iface);
-}
-
-static HRESULT WINAPI d3d8_pixelshader_QueryInterface(IDirect3DPixelShader8 *iface, REFIID riid, void **object)
-{
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
-
- if (IsEqualGUID(riid, &IID_IDirect3DPixelShader8)
- || IsEqualGUID(riid, &IID_IUnknown))
- {
- IUnknown_AddRef(iface);
- *object = iface;
- return S_OK;
- }
-
- WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
-
- *object = NULL;
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI d3d8_pixelshader_AddRef(IDirect3DPixelShader8 *iface)
-{
- IDirect3DPixelShader8Impl *shader = impl_from_IDirect3DPixelShader8(iface);
- ULONG refcount = InterlockedIncrement(&shader->ref);
-
- TRACE("%p increasing refcount to %u.\n", iface, refcount);
-
- if (refcount == 1)
- {
- wined3d_mutex_lock();
- wined3d_shader_incref(shader->wined3d_shader);
- wined3d_mutex_unlock();
- }
-
- return refcount;
-}
-
-static ULONG WINAPI d3d8_pixelshader_Release(IDirect3DPixelShader8 *iface)
+static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent)
{
- IDirect3DPixelShader8Impl *shader = impl_from_IDirect3DPixelShader8(iface);
- ULONG refcount = InterlockedDecrement(&shader->ref);
-
- TRACE("%p decreasing refcount to %u.\n", iface, refcount);
-
- if (!refcount)
- {
- wined3d_mutex_lock();
- wined3d_shader_decref(shader->wined3d_shader);
- wined3d_mutex_unlock();
- }
-
- return refcount;
+ HeapFree(GetProcessHeap(), 0, parent);
}
-static const IDirect3DPixelShader8Vtbl d3d8_pixelshader_vtbl =
+void d3d8_pixel_shader_destroy(struct d3d8_pixel_shader *shader)
{
- /* IUnknown */
- d3d8_pixelshader_QueryInterface,
- d3d8_pixelshader_AddRef,
- d3d8_pixelshader_Release,
-};
+ TRACE("shader %p.\n", shader);
-static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent)
-{
- HeapFree(GetProcessHeap(), 0, parent);
+ wined3d_mutex_lock();
+ wined3d_shader_decref(shader->wined3d_shader);
+ wined3d_mutex_unlock();
}
static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops =
@@ -208,13 +152,11 @@ static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops =
d3d8_pixelshader_wined3d_object_destroyed,
};
-HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device,
+HRESULT d3d8_pixel_shader_init(struct d3d8_pixel_shader *shader, IDirect3DDevice8Impl *device,
const DWORD *byte_code, DWORD shader_handle)
{
HRESULT hr;
- shader->ref = 1;
- shader->IDirect3DPixelShader8_iface.lpVtbl = &d3d8_pixelshader_vtbl;
shader->handle = shader_handle;
wined3d_mutex_lock();
--
1.7.3.4
More information about the wine-patches
mailing list