Commit 24d4a52e authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d8: Remove COM from the pixel shader implementation.

parent 483b17d4
...@@ -365,9 +365,6 @@ struct IDirect3DVolumeTexture8Impl ...@@ -365,9 +365,6 @@ struct IDirect3DVolumeTexture8Impl
HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice8Impl *device, HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice8Impl *device,
UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN; 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 struct d3d8_vertex_declaration
{ {
DWORD *elements; DWORD *elements;
...@@ -382,28 +379,6 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration ...@@ -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, HRESULT d3d8_vertex_declaration_init_fvf(struct d3d8_vertex_declaration *declaration,
IDirect3DDevice8Impl *device, DWORD fvf) DECLSPEC_HIDDEN; 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_shader
{ {
struct d3d8_vertex_declaration *vertex_declaration; struct d3d8_vertex_declaration *vertex_declaration;
...@@ -416,17 +391,14 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, IDirect3DDevi ...@@ -416,17 +391,14 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, IDirect3DDevi
#define D3D8_MAX_VERTEX_SHADER_CONSTANTF 256 #define D3D8_MAX_VERTEX_SHADER_CONSTANTF 256
/***************************************************************************** struct d3d8_pixel_shader
* IDirect3DPixelShader implementation structure {
*/
typedef struct IDirect3DPixelShader8Impl {
IDirect3DPixelShader8 IDirect3DPixelShader8_iface;
LONG ref;
DWORD handle; DWORD handle;
struct wined3d_shader *wined3d_shader; 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; const DWORD *byte_code, DWORD shader_handle) DECLSPEC_HIDDEN;
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
......
...@@ -2387,7 +2387,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *i ...@@ -2387,7 +2387,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *i
const DWORD *byte_code, DWORD *shader) const DWORD *byte_code, DWORD *shader)
{ {
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface); IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DPixelShader8Impl *object; struct d3d8_pixel_shader *object;
DWORD shader_handle; DWORD shader_handle;
DWORD handle; DWORD handle;
HRESULT hr; HRESULT hr;
...@@ -2419,7 +2419,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *i ...@@ -2419,7 +2419,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *i
shader_handle = handle + VS_HIGHESTFIXEDFXF + 1; 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)) if (FAILED(hr))
{ {
WARN("Failed to initialize pixel shader, hr %#x.\n", hr); WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
...@@ -2440,7 +2440,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *i ...@@ -2440,7 +2440,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *i
static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(IDirect3DDevice8 *iface, DWORD pShader) static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(IDirect3DDevice8 *iface, DWORD pShader)
{ {
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface); IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DPixelShader8Impl *shader; struct d3d8_pixel_shader *shader;
HRESULT hr; HRESULT hr;
TRACE("iface %p, shader %#x.\n", iface, pShader); TRACE("iface %p, shader %#x.\n", iface, pShader);
...@@ -2485,7 +2485,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac ...@@ -2485,7 +2485,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac
object = wined3d_device_get_pixel_shader(This->wined3d_device); object = wined3d_device_get_pixel_shader(This->wined3d_device);
if (object) if (object)
{ {
IDirect3DPixelShader8Impl *d3d8_shader; struct d3d8_pixel_shader *d3d8_shader;
d3d8_shader = wined3d_shader_get_parent(object); d3d8_shader = wined3d_shader_get_parent(object);
wined3d_shader_decref(object); wined3d_shader_decref(object);
*ppShader = d3d8_shader->handle; *ppShader = d3d8_shader->handle;
...@@ -2504,7 +2504,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac ...@@ -2504,7 +2504,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac
static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *iface, DWORD pShader) static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *iface, DWORD pShader)
{ {
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface); IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DPixelShader8Impl *shader; struct d3d8_pixel_shader *shader;
struct wined3d_shader *cur; struct wined3d_shader *cur;
TRACE("iface %p, shader %#x.\n", iface, pShader); TRACE("iface %p, shader %#x.\n", iface, pShader);
...@@ -2529,10 +2529,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *i ...@@ -2529,10 +2529,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *i
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (IDirect3DPixelShader8_Release(&shader->IDirect3DPixelShader8_iface)) d3d8_pixel_shader_destroy(shader);
{
ERR("Shader %p has references left, this shouldn't happen.\n", shader);
}
return D3D_OK; return D3D_OK;
} }
...@@ -2573,7 +2570,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(IDirect3DDevic ...@@ -2573,7 +2570,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(IDirect3DDevic
DWORD pPixelShader, void *pData, DWORD *pSizeOfData) DWORD pPixelShader, void *pData, DWORD *pSizeOfData)
{ {
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface); IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DPixelShader8Impl *shader = NULL; struct d3d8_pixel_shader *shader = NULL;
HRESULT hr; HRESULT hr;
TRACE("iface %p, shader %#x, data %p, data_size %p.\n", TRACE("iface %p, shader %#x, data %p, data_size %p.\n",
......
...@@ -133,74 +133,18 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, IDirect3DDevi ...@@ -133,74 +133,18 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, IDirect3DDevi
return D3D_OK; return D3D_OK;
} }
static inline IDirect3DPixelShader8Impl *impl_from_IDirect3DPixelShader8(IDirect3DPixelShader8 *iface) static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent)
{
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)
{ {
IDirect3DPixelShader8Impl *shader = impl_from_IDirect3DPixelShader8(iface); HeapFree(GetProcessHeap(), 0, parent);
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;
} }
static const IDirect3DPixelShader8Vtbl d3d8_pixelshader_vtbl = void d3d8_pixel_shader_destroy(struct d3d8_pixel_shader *shader)
{ {
/* IUnknown */ TRACE("shader %p.\n", shader);
d3d8_pixelshader_QueryInterface,
d3d8_pixelshader_AddRef,
d3d8_pixelshader_Release,
};
static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent) wined3d_mutex_lock();
{ wined3d_shader_decref(shader->wined3d_shader);
HeapFree(GetProcessHeap(), 0, parent); wined3d_mutex_unlock();
} }
static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops = 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 = ...@@ -208,13 +152,11 @@ static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops =
d3d8_pixelshader_wined3d_object_destroyed, 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) const DWORD *byte_code, DWORD shader_handle)
{ {
HRESULT hr; HRESULT hr;
shader->ref = 1;
shader->IDirect3DPixelShader8_iface.lpVtbl = &d3d8_pixelshader_vtbl;
shader->handle = shader_handle; shader->handle = shader_handle;
wined3d_mutex_lock(); wined3d_mutex_lock();
......
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