mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 14:50:48 +00:00
d3d8: Remove COM from the vertex shader implementation.
This commit is contained in:
parent
f056fe7bb5
commit
483b17d410
3 changed files with 23 additions and 111 deletions
|
@ -111,7 +111,6 @@ typedef struct IDirect3DSurface8Impl IDirect3DSurface8Impl;
|
|||
typedef struct IDirect3DSwapChain8Impl IDirect3DSwapChain8Impl;
|
||||
typedef struct IDirect3DVolume8Impl IDirect3DVolume8Impl;
|
||||
typedef struct IDirect3DVertexBuffer8Impl IDirect3DVertexBuffer8Impl;
|
||||
typedef struct IDirect3DVertexShader8Impl IDirect3DVertexShader8Impl;
|
||||
|
||||
/* ===========================================================================
|
||||
The interfaces themselves
|
||||
|
@ -366,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_IDirect3DVertexShader8,
|
||||
0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36);
|
||||
|
||||
DEFINE_GUID(IID_IDirect3DPixelShader8,
|
||||
0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89);
|
||||
|
||||
|
@ -386,28 +382,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;
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirect3DVertexShader8 interface
|
||||
*/
|
||||
#define INTERFACE IDirect3DVertexShader8
|
||||
DECLARE_INTERFACE_(IDirect3DVertexShader8, 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 IDirect3DVertexShader8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
|
||||
#define IDirect3DVertexShader8_AddRef(p) (p)->lpVtbl->AddRef(p)
|
||||
#define IDirect3DVertexShader8_Release(p) (p)->lpVtbl->Release(p)
|
||||
|
||||
/* ------------------------- */
|
||||
/* IDirect3DVertexShader8Impl */
|
||||
/* ------------------------- */
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirect3DPixelShader8 interface
|
||||
*/
|
||||
|
@ -430,14 +404,14 @@ DECLARE_INTERFACE_(IDirect3DPixelShader8,IUnknown)
|
|||
* IDirect3DVertexShader implementation structure
|
||||
*/
|
||||
|
||||
struct IDirect3DVertexShader8Impl {
|
||||
IDirect3DVertexShader8 IDirect3DVertexShader8_iface;
|
||||
LONG ref;
|
||||
struct d3d8_vertex_shader
|
||||
{
|
||||
struct d3d8_vertex_declaration *vertex_declaration;
|
||||
struct wined3d_shader *wined3d_shader;
|
||||
};
|
||||
|
||||
HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Impl *device,
|
||||
void d3d8_vertex_shader_destroy(struct d3d8_vertex_shader *shader) DECLSPEC_HIDDEN;
|
||||
HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, IDirect3DDevice8Impl *device,
|
||||
const DWORD *declaration, const DWORD *byte_code, DWORD shader_handle, DWORD usage) DECLSPEC_HIDDEN;
|
||||
|
||||
#define D3D8_MAX_VERTEX_SHADER_CONSTANTF 256
|
||||
|
|
|
@ -1987,7 +1987,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(IDirect3DDevice8 *
|
|||
const DWORD *declaration, const DWORD *byte_code, DWORD *shader, DWORD usage)
|
||||
{
|
||||
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
|
||||
IDirect3DVertexShader8Impl *object;
|
||||
struct d3d8_vertex_shader *object;
|
||||
DWORD shader_handle;
|
||||
DWORD handle;
|
||||
HRESULT hr;
|
||||
|
@ -2016,7 +2016,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(IDirect3DDevice8 *
|
|||
|
||||
shader_handle = handle + VS_HIGHESTFIXEDFXF + 1;
|
||||
|
||||
hr = vertexshader_init(object, This, declaration, byte_code, shader_handle, usage);
|
||||
hr = d3d8_vertex_shader_init(object, This, declaration, byte_code, shader_handle, usage);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
|
||||
|
@ -2102,7 +2102,7 @@ static struct d3d8_vertex_declaration *IDirect3DDevice8Impl_FindDecl(IDirect3DDe
|
|||
static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(IDirect3DDevice8 *iface, DWORD pShader)
|
||||
{
|
||||
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
|
||||
IDirect3DVertexShader8Impl *shader;
|
||||
struct d3d8_vertex_shader *shader;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, shader %#x.\n", iface, pShader);
|
||||
|
@ -2181,7 +2181,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(IDirect3DDevice8 *ifa
|
|||
static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(IDirect3DDevice8 *iface, DWORD pShader)
|
||||
{
|
||||
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
|
||||
IDirect3DVertexShader8Impl *shader;
|
||||
struct d3d8_vertex_shader *shader;
|
||||
struct wined3d_shader *cur;
|
||||
|
||||
TRACE("iface %p, shader %#x.\n", iface, pShader);
|
||||
|
@ -2206,10 +2206,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(IDirect3DDevice8 *
|
|||
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
if (IDirect3DVertexShader8_Release(&shader->IDirect3DVertexShader8_iface))
|
||||
{
|
||||
ERR("Shader %p has references left, this shouldn't happen.\n", shader);
|
||||
}
|
||||
d3d8_vertex_shader_destroy(shader);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
@ -2263,7 +2260,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(IDirect3DD
|
|||
{
|
||||
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
|
||||
struct d3d8_vertex_declaration *declaration;
|
||||
IDirect3DVertexShader8Impl *shader;
|
||||
struct d3d8_vertex_shader *shader;
|
||||
|
||||
TRACE("iface %p, shader %#x, data %p, data_size %p.\n",
|
||||
iface, pVertexShader, pData, pSizeOfData);
|
||||
|
@ -2301,7 +2298,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(IDirect3DDevi
|
|||
DWORD pVertexShader, void *pData, DWORD *pSizeOfData)
|
||||
{
|
||||
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
|
||||
IDirect3DVertexShader8Impl *shader = NULL;
|
||||
struct d3d8_vertex_shader *shader = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, shader %#x, data %p, data_size %p.\n",
|
||||
|
|
|
@ -22,85 +22,29 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
||||
|
||||
static inline IDirect3DVertexShader8Impl *impl_from_IDirect3DVertexShader8(IDirect3DVertexShader8 *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, IDirect3DVertexShader8Impl, IDirect3DVertexShader8_iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3d8_vertexshader_QueryInterface(IDirect3DVertexShader8 *iface, REFIID riid, void **object)
|
||||
{
|
||||
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IDirect3DVertexShader8)
|
||||
|| 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_vertexshader_AddRef(IDirect3DVertexShader8 *iface)
|
||||
{
|
||||
IDirect3DVertexShader8Impl *shader = impl_from_IDirect3DVertexShader8(iface);
|
||||
ULONG refcount = InterlockedIncrement(&shader->ref);
|
||||
|
||||
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
||||
|
||||
if (refcount == 1 && shader->wined3d_shader)
|
||||
{
|
||||
wined3d_mutex_lock();
|
||||
wined3d_shader_incref(shader->wined3d_shader);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *parent)
|
||||
{
|
||||
IDirect3DVertexShader8Impl *shader = parent;
|
||||
struct d3d8_vertex_shader *shader = parent;
|
||||
d3d8_vertex_declaration_destroy(shader->vertex_declaration);
|
||||
HeapFree(GetProcessHeap(), 0, shader);
|
||||
}
|
||||
|
||||
static ULONG WINAPI d3d8_vertexshader_Release(IDirect3DVertexShader8 *iface)
|
||||
void d3d8_vertex_shader_destroy(struct d3d8_vertex_shader *shader)
|
||||
{
|
||||
IDirect3DVertexShader8Impl *shader = impl_from_IDirect3DVertexShader8(iface);
|
||||
ULONG refcount = InterlockedDecrement(&shader->ref);
|
||||
TRACE("shader %p.\n", shader);
|
||||
|
||||
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
||||
|
||||
if (!refcount)
|
||||
if (shader->wined3d_shader)
|
||||
{
|
||||
if (shader->wined3d_shader)
|
||||
{
|
||||
wined3d_mutex_lock();
|
||||
wined3d_shader_decref(shader->wined3d_shader);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
d3d8_vertexshader_wined3d_object_destroyed(shader);
|
||||
}
|
||||
wined3d_mutex_lock();
|
||||
wined3d_shader_decref(shader->wined3d_shader);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
d3d8_vertexshader_wined3d_object_destroyed(shader);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static const IDirect3DVertexShader8Vtbl d3d8_vertexshader_vtbl =
|
||||
{
|
||||
/* IUnknown */
|
||||
d3d8_vertexshader_QueryInterface,
|
||||
d3d8_vertexshader_AddRef,
|
||||
d3d8_vertexshader_Release,
|
||||
};
|
||||
|
||||
static const struct wined3d_parent_ops d3d8_vertexshader_wined3d_parent_ops =
|
||||
{
|
||||
d3d8_vertexshader_wined3d_object_destroyed,
|
||||
|
@ -136,7 +80,7 @@ static HRESULT d3d8_vertexshader_create_vertexdeclaration(IDirect3DDevice8Impl *
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Impl *device,
|
||||
HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, IDirect3DDevice8Impl *device,
|
||||
const DWORD *declaration, const DWORD *byte_code, DWORD shader_handle, DWORD usage)
|
||||
{
|
||||
const DWORD *token = declaration;
|
||||
|
@ -161,9 +105,6 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im
|
|||
token += parse_token(token);
|
||||
}
|
||||
|
||||
shader->ref = 1;
|
||||
shader->IDirect3DVertexShader8_iface.lpVtbl = &d3d8_vertexshader_vtbl;
|
||||
|
||||
hr = d3d8_vertexshader_create_vertexdeclaration(device, declaration, shader_handle, &shader->vertex_declaration);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue