wined3d: Get rid of IWineD3DPixelShader.

This commit is contained in:
Henri Verbeet 2011-03-29 19:21:49 +02:00 committed by Alexandre Julliard
parent 9ea2ee5f4e
commit 3d4fe0b750
14 changed files with 77 additions and 90 deletions

View File

@ -195,7 +195,7 @@ struct d3d10_pixel_shader
const struct ID3D10PixelShaderVtbl *vtbl;
LONG refcount;
IWineD3DPixelShader *wined3d_shader;
IWineD3DBaseShader *wined3d_shader;
struct wined3d_shader_signature output_signature;
};

View File

@ -429,9 +429,7 @@ static ULONG STDMETHODCALLTYPE d3d10_pixel_shader_AddRef(ID3D10PixelShader *ifac
TRACE("%p increasing refcount to %u\n", This, refcount);
if (refcount == 1)
{
IWineD3DPixelShader_AddRef(This->wined3d_shader);
}
IWineD3DBaseShader_AddRef(This->wined3d_shader);
return refcount;
}
@ -444,9 +442,7 @@ static ULONG STDMETHODCALLTYPE d3d10_pixel_shader_Release(ID3D10PixelShader *ifa
TRACE("%p decreasing refcount to %u\n", This, refcount);
if (!refcount)
{
IWineD3DPixelShader_Release(This->wined3d_shader);
}
IWineD3DBaseShader_Release(This->wined3d_shader);
return refcount;
}

View File

@ -486,9 +486,8 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im
typedef struct IDirect3DPixelShader8Impl {
IDirect3DPixelShader8 IDirect3DPixelShader8_iface;
LONG ref;
DWORD handle;
IWineD3DPixelShader *wineD3DPixelShader;
DWORD handle;
IWineD3DBaseShader *wined3d_shader;
} IDirect3DPixelShader8Impl;
HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device,

View File

@ -2410,7 +2410,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(IDirect3DDevice8 *ifac
}
TRACE("(%p) : Setting shader %p\n", This, shader);
hr = IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader->wineD3DPixelShader);
hr = IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader->wined3d_shader);
wined3d_mutex_unlock();
return hr;
@ -2419,7 +2419,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(IDirect3DDevice8 *ifac
static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *iface, DWORD *ppShader)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IWineD3DPixelShader *object;
IWineD3DBaseShader *object;
TRACE("iface %p, shader %p.\n", iface, ppShader);
@ -2433,8 +2433,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac
if (object)
{
IDirect3DPixelShader8Impl *d3d8_shader;
d3d8_shader = IWineD3DPixelShader_GetParent(object);
IWineD3DPixelShader_Release(object);
d3d8_shader = IWineD3DBaseShader_GetParent(object);
IWineD3DBaseShader_Release(object);
*ppShader = d3d8_shader->handle;
}
else
@ -2452,7 +2452,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *i
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DPixelShader8Impl *shader;
IWineD3DPixelShader *cur;
IWineD3DBaseShader *cur;
TRACE("iface %p, shader %#x.\n", iface, pShader);
@ -2469,8 +2469,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *i
cur = IWineD3DDevice_GetPixelShader(This->WineD3DDevice);
if (cur)
{
if (cur == shader->wineD3DPixelShader) IDirect3DDevice8_SetPixelShader(iface, 0);
IWineD3DPixelShader_Release(cur);
if (cur == shader->wined3d_shader)
IDirect3DDevice8_SetPixelShader(iface, 0);
IWineD3DBaseShader_Release(cur);
}
wined3d_mutex_unlock();
@ -2535,7 +2536,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(IDirect3DDevic
return D3DERR_INVALIDCALL;
}
hr = IWineD3DPixelShader_GetFunction(shader->wineD3DPixelShader, pData, pSizeOfData);
hr = IWineD3DBaseShader_GetFunction(shader->wined3d_shader, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;

View File

@ -225,7 +225,7 @@ static ULONG WINAPI d3d8_pixelshader_AddRef(IDirect3DPixelShader8 *iface)
if (refcount == 1)
{
wined3d_mutex_lock();
IWineD3DPixelShader_AddRef(shader->wineD3DPixelShader);
IWineD3DBaseShader_AddRef(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -242,7 +242,7 @@ static ULONG WINAPI d3d8_pixelshader_Release(IDirect3DPixelShader8 *iface)
if (!refcount)
{
wined3d_mutex_lock();
IWineD3DPixelShader_Release(shader->wineD3DPixelShader);
IWineD3DBaseShader_Release(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -278,7 +278,7 @@ HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl
wined3d_mutex_lock();
hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code, NULL, shader,
&d3d8_pixelshader_wined3d_parent_ops, &shader->wineD3DPixelShader);
&d3d8_pixelshader_wined3d_parent_ops, &shader->wined3d_shader);
wined3d_mutex_unlock();
if (FAILED(hr))
{

View File

@ -453,12 +453,8 @@ typedef struct IDirect3DPixelShader9Impl {
/* IUnknown fields */
const IDirect3DPixelShader9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DPixelShader9 fields */
IWineD3DPixelShader *wineD3DPixelShader;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
IWineD3DBaseShader *wined3d_shader;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DPixelShader9Impl;
HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader,

View File

@ -2527,7 +2527,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(IDirect3DDevice9Ex *if
wined3d_mutex_lock();
hr = IWineD3DDevice_SetPixelShader(((IDirect3DDevice9Impl *)iface)->WineD3DDevice,
shader ? ((IDirect3DPixelShader9Impl *)shader)->wineD3DPixelShader : NULL);
shader ? ((IDirect3DPixelShader9Impl *)shader)->wined3d_shader : NULL);
wined3d_mutex_unlock();
return hr;
@ -2536,7 +2536,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(IDirect3DDevice9Ex *if
static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(IDirect3DDevice9Ex *iface,
IDirect3DPixelShader9 **shader)
{
IWineD3DPixelShader *wined3d_shader;
IWineD3DBaseShader *wined3d_shader;
TRACE("iface %p, shader %p.\n", iface, shader);
@ -2546,9 +2546,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(IDirect3DDevice9Ex *if
wined3d_shader = IWineD3DDevice_GetPixelShader(((IDirect3DDevice9Impl *)iface)->WineD3DDevice);
if (wined3d_shader)
{
*shader = IWineD3DPixelShader_GetParent(wined3d_shader);
*shader = IWineD3DBaseShader_GetParent(wined3d_shader);
IDirect3DPixelShader9_AddRef(*shader);
IWineD3DPixelShader_Release(wined3d_shader);
IWineD3DBaseShader_Release(wined3d_shader);
}
else
{

View File

@ -179,7 +179,7 @@ static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface)
{
IDirect3DDevice9Ex_AddRef(shader->parentDevice);
wined3d_mutex_lock();
IWineD3DPixelShader_AddRef(shader->wineD3DPixelShader);
IWineD3DBaseShader_AddRef(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -198,7 +198,7 @@ static ULONG WINAPI d3d9_pixelshader_Release(IDirect3DPixelShader9 *iface)
IDirect3DDevice9Ex *device = shader->parentDevice;
wined3d_mutex_lock();
IWineD3DPixelShader_Release(shader->wineD3DPixelShader);
IWineD3DBaseShader_Release(shader->wined3d_shader);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -227,7 +227,7 @@ static HRESULT WINAPI d3d9_pixelshader_GetFunction(IDirect3DPixelShader9 *iface,
TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
wined3d_mutex_lock();
hr = IWineD3DPixelShader_GetFunction(((IDirect3DPixelShader9Impl *)iface)->wineD3DPixelShader, data, data_size);
hr = IWineD3DBaseShader_GetFunction(((IDirect3DPixelShader9Impl *)iface)->wined3d_shader, data, data_size);
wined3d_mutex_unlock();
return hr;
@ -263,7 +263,7 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl
wined3d_mutex_lock();
hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code, NULL, shader,
&d3d9_pixelshader_wined3d_parent_ops, &shader->wineD3DPixelShader);
&d3d9_pixelshader_wined3d_parent_ops, &shader->wined3d_shader);
wined3d_mutex_unlock();
if (FAILED(hr))
{

View File

@ -1576,7 +1576,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateGeometryShader(IWineD3DDevice *if
static HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface,
const DWORD *pFunction, const struct wined3d_shader_signature *output_signature,
void *parent, const struct wined3d_parent_ops *parent_ops,
IWineD3DPixelShader **ppPixelShader)
IWineD3DBaseShader **shader)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DPixelShaderImpl *object;
@ -1601,7 +1601,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface
}
TRACE("Created pixel shader %p.\n", object);
*ppPixelShader = (IWineD3DPixelShader *)object;
*shader = (IWineD3DBaseShader *)object;
return WINED3D_OK;
}
@ -3743,48 +3743,55 @@ void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This)
if (vs) device_map_vsamplers(This, ps, gl_info);
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, IWineD3DPixelShader *pShader)
static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, IWineD3DBaseShader *shader)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DPixelShader *oldShader = (IWineD3DPixelShader *)This->updateStateBlock->state.pixel_shader;
This->updateStateBlock->state.pixel_shader = (IWineD3DPixelShaderImpl *)pShader;
This->updateStateBlock->changed.pixelShader = TRUE;
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
IWineD3DBaseShader *prev = (IWineD3DBaseShader *)device->updateStateBlock->state.pixel_shader;
device->updateStateBlock->state.pixel_shader = (IWineD3DPixelShaderImpl *)shader;
device->updateStateBlock->changed.pixelShader = TRUE;
/* Handle recording of state blocks */
if (This->isRecordingState) {
if (device->isRecordingState)
TRACE("Recording... not performing anything\n");
}
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
if(pShader) IWineD3DPixelShader_AddRef(pShader);
if(oldShader) IWineD3DPixelShader_Release(oldShader);
if (device->isRecordingState)
{
TRACE("Recording... not performing anything.\n");
if (shader)
IWineD3DBaseShader_AddRef(shader);
if (prev)
IWineD3DBaseShader_Release(prev);
return WINED3D_OK;
}
if(pShader == oldShader) {
TRACE("App is setting the old pixel shader over, nothing to do\n");
if (shader == prev)
{
TRACE("App is setting the old pixel shader over, nothing to do.\n");
return WINED3D_OK;
}
if(pShader) IWineD3DPixelShader_AddRef(pShader);
if(oldShader) IWineD3DPixelShader_Release(oldShader);
if (shader)
IWineD3DBaseShader_AddRef(shader);
if (prev)
IWineD3DBaseShader_Release(prev);
TRACE("(%p) : setting pShader(%p)\n", This, pShader);
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADER);
TRACE("Setting shader %p.\n", shader);
IWineD3DDeviceImpl_MarkStateDirty(device, STATE_PIXELSHADER);
return WINED3D_OK;
}
static IWineD3DPixelShader * WINAPI IWineD3DDeviceImpl_GetPixelShader(IWineD3DDevice *iface)
static IWineD3DBaseShader * WINAPI IWineD3DDeviceImpl_GetPixelShader(IWineD3DDevice *iface)
{
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
IWineD3DPixelShader *shader;
IWineD3DBaseShader *shader;
TRACE("iface %p.\n", iface);
shader = (IWineD3DPixelShader *)device->stateBlock->state.pixel_shader;
if (shader) IWineD3DPixelShader_AddRef(shader);
shader = (IWineD3DBaseShader *)device->stateBlock->state.pixel_shader;
if (shader)
IWineD3DBaseShader_AddRef(shader);
TRACE("Returning %p.\n", shader);
return shader;

View File

@ -3641,7 +3641,7 @@ static void shader_glsl_dp2add(const struct wined3d_shader_instruction *ins)
}
}
static void shader_glsl_input_pack(IWineD3DPixelShader *iface, struct wined3d_shader_buffer *buffer,
static void shader_glsl_input_pack(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
const struct wined3d_shader_signature_element *input_signature, const struct wined3d_shader_reg_maps *reg_maps,
enum vertexprocessing_mode vertexprocessing)
{
@ -4005,7 +4005,7 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
/* Pack 3.0 inputs */
if (reg_maps->shader_version.major >= 3 && args->vp_mode != vertexshader)
{
shader_glsl_input_pack((IWineD3DPixelShader *) This, buffer,
shader_glsl_input_pack((IWineD3DBaseShader *)This, buffer,
This->baseShader.input_signature, reg_maps, args->vp_mode);
}

View File

@ -1998,12 +1998,11 @@ HRESULT geometryshader_init(struct wined3d_geometryshader *shader, IWineD3DDevic
return WINED3D_OK;
}
static HRESULT STDMETHODCALLTYPE pixelshader_QueryInterface(IWineD3DPixelShader *iface, REFIID riid, void **object)
static HRESULT STDMETHODCALLTYPE pixelshader_QueryInterface(IWineD3DBaseShader *iface, REFIID riid, void **object)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_IWineD3DPixelShader)
|| IsEqualGUID(riid, &IID_IWineD3DBaseShader)
if (IsEqualGUID(riid, &IID_IWineD3DBaseShader)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IUnknown))
{
@ -2018,7 +2017,7 @@ static HRESULT STDMETHODCALLTYPE pixelshader_QueryInterface(IWineD3DPixelShader
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE pixelshader_AddRef(IWineD3DPixelShader *iface)
static ULONG STDMETHODCALLTYPE pixelshader_AddRef(IWineD3DBaseShader *iface)
{
IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)iface;
ULONG refcount = InterlockedIncrement(&shader->baseShader.ref);
@ -2029,7 +2028,7 @@ static ULONG STDMETHODCALLTYPE pixelshader_AddRef(IWineD3DPixelShader *iface)
}
/* Do not call while under the GL lock. */
static ULONG STDMETHODCALLTYPE pixelshader_Release(IWineD3DPixelShader *iface)
static ULONG STDMETHODCALLTYPE pixelshader_Release(IWineD3DBaseShader *iface)
{
IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)iface;
ULONG refcount = InterlockedDecrement(&shader->baseShader.ref);
@ -2046,21 +2045,21 @@ static ULONG STDMETHODCALLTYPE pixelshader_Release(IWineD3DPixelShader *iface)
return refcount;
}
static void * STDMETHODCALLTYPE pixelshader_GetParent(IWineD3DPixelShader *iface)
static void * STDMETHODCALLTYPE pixelshader_GetParent(IWineD3DBaseShader *iface)
{
TRACE("iface %p.\n", iface);
return ((IWineD3DBaseShaderImpl *)iface)->baseShader.parent;
}
static HRESULT STDMETHODCALLTYPE pixelshader_GetFunction(IWineD3DPixelShader *iface, void *data, UINT *data_size)
static HRESULT STDMETHODCALLTYPE pixelshader_GetFunction(IWineD3DBaseShader *iface, void *data, UINT *data_size)
{
TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
return shader_get_function((IWineD3DBaseShaderImpl *)iface, data, data_size);
}
static HRESULT STDMETHODCALLTYPE pixelshader_SetLocalConstantsF(IWineD3DPixelShader *iface,
static HRESULT STDMETHODCALLTYPE pixelshader_SetLocalConstantsF(IWineD3DBaseShader *iface,
UINT start_idx, const float *src_data, UINT count)
{
TRACE("iface %p, start_idx %u, src_data %p, count %u.\n", iface, start_idx, src_data, count);
@ -2069,7 +2068,7 @@ static HRESULT STDMETHODCALLTYPE pixelshader_SetLocalConstantsF(IWineD3DPixelSha
start_idx, src_data, count);
}
static const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
static const IWineD3DBaseShaderVtbl IWineD3DPixelShader_Vtbl =
{
/* IUnknown methods */
pixelshader_QueryInterface,

View File

@ -501,7 +501,7 @@ ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
if (stateblock->state.vertex_shader)
IWineD3DBaseShader_Release((IWineD3DBaseShader *)stateblock->state.vertex_shader);
if (stateblock->state.pixel_shader)
IWineD3DPixelShader_Release((IWineD3DPixelShader *)stateblock->state.pixel_shader);
IWineD3DBaseShader_Release((IWineD3DBaseShader *)stateblock->state.pixel_shader);
for (counter = 0; counter < LIGHTMAP_SIZE; ++counter)
{
@ -860,9 +860,9 @@ HRESULT CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
if (stateblock->changed.pixelShader && stateblock->state.pixel_shader != src_state->pixel_shader)
{
if (src_state->pixel_shader)
IWineD3DPixelShader_AddRef((IWineD3DPixelShader *)src_state->pixel_shader);
IWineD3DBaseShader_AddRef((IWineD3DBaseShader *)src_state->pixel_shader);
if (stateblock->state.pixel_shader)
IWineD3DPixelShader_Release((IWineD3DPixelShader *)stateblock->state.pixel_shader);
IWineD3DBaseShader_Release((IWineD3DBaseShader *)stateblock->state.pixel_shader);
stateblock->state.pixel_shader = src_state->pixel_shader;
}
@ -923,7 +923,7 @@ HRESULT CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblo
apply_lights(device, &stateblock->state);
if (stateblock->changed.pixelShader)
IWineD3DDevice_SetPixelShader(device, (IWineD3DPixelShader *)stateblock->state.pixel_shader);
IWineD3DDevice_SetPixelShader(device, (IWineD3DBaseShader *)stateblock->state.pixel_shader);
/* Pixel Shader Constants. */
for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)

View File

@ -2861,11 +2861,9 @@ struct ps_np2fixup_info {
WORD num_consts;
};
typedef struct IWineD3DPixelShaderImpl {
/* IUnknown parts */
const IWineD3DPixelShaderVtbl *lpVtbl;
/* IWineD3DBaseShader */
typedef struct IWineD3DPixelShaderImpl
{
const IWineD3DBaseShaderVtbl *lpVtbl;
IWineD3DBaseShaderClass baseShader;
/* Pixel shader input semantics */

View File

@ -2402,15 +2402,6 @@ interface IWineD3DBaseShader : IWineD3DBase
);
}
[
object,
local,
uuid(818503da-6f30-11d9-c687-00046142c14f)
]
interface IWineD3DPixelShader : IWineD3DBaseShader
{
}
[
object,
local,
@ -2552,7 +2543,7 @@ interface IWineD3DDevice : IUnknown
[in] const struct wined3d_shader_signature *output_signature,
[in] void *parent,
[in] const struct wined3d_parent_ops *parent_ops,
[out] IWineD3DPixelShader **shader
[out] IWineD3DBaseShader **shader
);
HRESULT CreatePalette(
[in] DWORD flags,
@ -2714,9 +2705,9 @@ interface IWineD3DDevice : IUnknown
[out] PALETTEENTRY *entries
);
HRESULT SetPixelShader(
[in] IWineD3DPixelShader *shader
[in] IWineD3DBaseShader *shader
);
IWineD3DPixelShader *GetPixelShader(
IWineD3DBaseShader *GetPixelShader(
);
HRESULT SetPixelShaderConstantB(
[in] UINT start_register,