wined3d: Remove COM from the shader implementation.

This commit is contained in:
Henri Verbeet 2011-03-30 20:49:25 +02:00 committed by Alexandre Julliard
parent 5555d904be
commit f8f83ff2f7
17 changed files with 153 additions and 206 deletions

View File

@ -169,7 +169,7 @@ struct d3d10_vertex_shader
const struct ID3D10VertexShaderVtbl *vtbl;
LONG refcount;
IWineD3DBaseShader *wined3d_shader;
struct wined3d_shader *wined3d_shader;
struct wined3d_shader_signature output_signature;
};
@ -182,7 +182,7 @@ struct d3d10_geometry_shader
const struct ID3D10GeometryShaderVtbl *vtbl;
LONG refcount;
IWineD3DBaseShader *wined3d_shader;
struct wined3d_shader *wined3d_shader;
struct wined3d_shader_signature output_signature;
};
@ -195,7 +195,7 @@ struct d3d10_pixel_shader
const struct ID3D10PixelShaderVtbl *vtbl;
LONG refcount;
IWineD3DBaseShader *wined3d_shader;
struct wined3d_shader *wined3d_shader;
struct wined3d_shader_signature output_signature;
};

View File

@ -162,7 +162,7 @@ static ULONG STDMETHODCALLTYPE d3d10_vertex_shader_AddRef(ID3D10VertexShader *if
TRACE("%p increasing refcount to %u\n", This, refcount);
if (refcount == 1)
IWineD3DBaseShader_AddRef(This->wined3d_shader);
wined3d_shader_incref(This->wined3d_shader);
return refcount;
}
@ -175,7 +175,7 @@ static ULONG STDMETHODCALLTYPE d3d10_vertex_shader_Release(ID3D10VertexShader *i
TRACE("%p decreasing refcount to %u\n", This, refcount);
if (!refcount)
IWineD3DBaseShader_Release(This->wined3d_shader);
wined3d_shader_decref(This->wined3d_shader);
return refcount;
}
@ -307,7 +307,7 @@ static ULONG STDMETHODCALLTYPE d3d10_geometry_shader_Release(ID3D10GeometryShade
TRACE("%p decreasing refcount to %u\n", This, refcount);
if (!refcount)
IWineD3DBaseShader_Release(This->wined3d_shader);
wined3d_shader_decref(This->wined3d_shader);
return refcount;
}
@ -429,7 +429,7 @@ static ULONG STDMETHODCALLTYPE d3d10_pixel_shader_AddRef(ID3D10PixelShader *ifac
TRACE("%p increasing refcount to %u\n", This, refcount);
if (refcount == 1)
IWineD3DBaseShader_AddRef(This->wined3d_shader);
wined3d_shader_incref(This->wined3d_shader);
return refcount;
}
@ -442,7 +442,7 @@ static ULONG STDMETHODCALLTYPE d3d10_pixel_shader_Release(ID3D10PixelShader *ifa
TRACE("%p decreasing refcount to %u\n", This, refcount);
if (!refcount)
IWineD3DBaseShader_Release(This->wined3d_shader);
wined3d_shader_decref(This->wined3d_shader);
return refcount;
}

View File

@ -472,7 +472,7 @@ struct IDirect3DVertexShader8Impl {
IDirect3DVertexShader8 IDirect3DVertexShader8_iface;
LONG ref;
IDirect3DVertexDeclaration8 *vertex_declaration;
IWineD3DBaseShader *wined3d_shader;
struct wined3d_shader *wined3d_shader;
};
HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Impl *device,
@ -487,7 +487,7 @@ typedef struct IDirect3DPixelShader8Impl {
IDirect3DPixelShader8 IDirect3DPixelShader8_iface;
LONG ref;
DWORD handle;
IWineD3DBaseShader *wined3d_shader;
struct wined3d_shader *wined3d_shader;
} IDirect3DPixelShader8Impl;
HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device,
@ -495,7 +495,7 @@ HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN;
void load_local_constants(const DWORD *d3d8_elements, IWineD3DBaseShader *wined3d_vertex_shader) DECLSPEC_HIDDEN;
void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader *wined3d_vertex_shader) DECLSPEC_HIDDEN;
size_t parse_token(const DWORD *pToken) DECLSPEC_HIDDEN;
#endif /* __WINE_D3DX8_PRIVATE_H */

View File

@ -2121,12 +2121,11 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(IDirect3DDevice8 *ifa
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(IDirect3DDevice8 *iface,
DWORD pShader)
static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(IDirect3DDevice8 *iface, DWORD pShader)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DVertexShader8Impl *shader;
IWineD3DBaseShader *cur;
struct wined3d_shader *cur;
TRACE("iface %p, shader %#x.\n", iface, pShader);
@ -2145,7 +2144,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(IDirect3DDevice8
{
if (cur == shader->wined3d_shader)
IDirect3DDevice8_SetVertexShader(iface, 0);
IWineD3DBaseShader_Release(cur);
wined3d_shader_decref(cur);
}
wined3d_mutex_unlock();
@ -2268,7 +2267,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(IDirect3DDevi
return D3D_OK;
}
hr = IWineD3DBaseShader_GetFunction(shader->wined3d_shader, pData, pSizeOfData);
hr = wined3d_shader_get_byte_code(shader->wined3d_shader, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
@ -2419,7 +2418,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(IDirect3DDevice8 *ifac
static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *iface, DWORD *ppShader)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IWineD3DBaseShader *object;
struct wined3d_shader *object;
TRACE("iface %p, shader %p.\n", iface, ppShader);
@ -2433,8 +2432,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac
if (object)
{
IDirect3DPixelShader8Impl *d3d8_shader;
d3d8_shader = IWineD3DBaseShader_GetParent(object);
IWineD3DBaseShader_Release(object);
d3d8_shader = wined3d_shader_get_parent(object);
wined3d_shader_decref(object);
*ppShader = d3d8_shader->handle;
}
else
@ -2452,7 +2451,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *i
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DPixelShader8Impl *shader;
IWineD3DBaseShader *cur;
struct wined3d_shader *cur;
TRACE("iface %p, shader %#x.\n", iface, pShader);
@ -2471,7 +2470,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *i
{
if (cur == shader->wined3d_shader)
IDirect3DDevice8_SetPixelShader(iface, 0);
IWineD3DBaseShader_Release(cur);
wined3d_shader_decref(cur);
}
wined3d_mutex_unlock();
@ -2536,7 +2535,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(IDirect3DDevic
return D3DERR_INVALIDCALL;
}
hr = IWineD3DBaseShader_GetFunction(shader->wined3d_shader, pData, pSizeOfData);
hr = wined3d_shader_get_byte_code(shader->wined3d_shader, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;

View File

@ -55,7 +55,7 @@ static ULONG WINAPI d3d8_vertexshader_AddRef(IDirect3DVertexShader8 *iface)
if (refcount == 1 && shader->wined3d_shader)
{
wined3d_mutex_lock();
IWineD3DBaseShader_AddRef(shader->wined3d_shader);
wined3d_shader_incref(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -81,7 +81,7 @@ static ULONG WINAPI d3d8_vertexshader_Release(IDirect3DVertexShader8 *iface)
if (shader->wined3d_shader)
{
wined3d_mutex_lock();
IWineD3DBaseShader_Release(shader->wined3d_shader);
wined3d_shader_decref(shader->wined3d_shader);
wined3d_mutex_unlock();
}
else
@ -225,7 +225,7 @@ static ULONG WINAPI d3d8_pixelshader_AddRef(IDirect3DPixelShader8 *iface)
if (refcount == 1)
{
wined3d_mutex_lock();
IWineD3DBaseShader_AddRef(shader->wined3d_shader);
wined3d_shader_incref(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -242,7 +242,7 @@ static ULONG WINAPI d3d8_pixelshader_Release(IDirect3DPixelShader8 *iface)
if (!refcount)
{
wined3d_mutex_lock();
IWineD3DBaseShader_Release(shader->wined3d_shader);
wined3d_shader_decref(shader->wined3d_shader);
wined3d_mutex_unlock();
}

View File

@ -199,7 +199,7 @@ size_t parse_token(const DWORD* pToken)
return tokenlen;
}
void load_local_constants(const DWORD *d3d8_elements, IWineD3DBaseShader *wined3d_vertex_shader)
void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader *wined3d_vertex_shader)
{
const DWORD *token = d3d8_elements;
@ -224,7 +224,7 @@ void load_local_constants(const DWORD *d3d8_elements, IWineD3DBaseShader *wined3
*(const float *)(token + i * 4 + 4));
}
}
hr = IWineD3DBaseShader_SetLocalConstantsF(wined3d_vertex_shader,
hr = wined3d_shader_set_local_constants_float(wined3d_vertex_shader,
constant_idx, (const float *)token + 1, count);
if (FAILED(hr)) ERR("Failed setting shader constants\n");
}

View File

@ -432,7 +432,7 @@ typedef struct IDirect3DVertexShader9Impl {
/* IUnknown fields */
const IDirect3DVertexShader9Vtbl *lpVtbl;
LONG ref;
IWineD3DBaseShader *wined3d_shader;
struct wined3d_shader *wined3d_shader;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DVertexShader9Impl;
@ -453,7 +453,7 @@ typedef struct IDirect3DPixelShader9Impl {
/* IUnknown fields */
const IDirect3DPixelShader9Vtbl *lpVtbl;
LONG ref;
IWineD3DBaseShader *wined3d_shader;
struct wined3d_shader *wined3d_shader;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DPixelShader9Impl;

View File

@ -2242,7 +2242,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(IDirect3DDevice9Ex *i
static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(IDirect3DDevice9Ex *iface,
IDirect3DVertexShader9 **shader)
{
IWineD3DBaseShader *wined3d_shader;
struct wined3d_shader *wined3d_shader;
TRACE("iface %p, shader %p.\n", iface, shader);
@ -2250,9 +2250,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(IDirect3DDevice9Ex *i
wined3d_shader = IWineD3DDevice_GetVertexShader(((IDirect3DDevice9Impl *)iface)->WineD3DDevice);
if (wined3d_shader)
{
*shader = IWineD3DBaseShader_GetParent(wined3d_shader);
*shader = wined3d_shader_get_parent(wined3d_shader);
IDirect3DVertexShader9_AddRef(*shader);
IWineD3DBaseShader_Release(wined3d_shader);
wined3d_shader_decref(wined3d_shader);
}
else
{
@ -2536,7 +2536,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(IDirect3DDevice9Ex *if
static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(IDirect3DDevice9Ex *iface,
IDirect3DPixelShader9 **shader)
{
IWineD3DBaseShader *wined3d_shader;
struct wined3d_shader *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 = IWineD3DBaseShader_GetParent(wined3d_shader);
*shader = wined3d_shader_get_parent(wined3d_shader);
IDirect3DPixelShader9_AddRef(*shader);
IWineD3DBaseShader_Release(wined3d_shader);
wined3d_shader_decref(wined3d_shader);
}
else
{

View File

@ -51,7 +51,7 @@ static ULONG WINAPI d3d9_vertexshader_AddRef(IDirect3DVertexShader9 *iface)
{
IDirect3DDevice9Ex_AddRef(shader->parentDevice);
wined3d_mutex_lock();
IWineD3DBaseShader_AddRef(shader->wined3d_shader);
wined3d_shader_incref(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -70,7 +70,7 @@ static ULONG WINAPI d3d9_vertexshader_Release(IDirect3DVertexShader9 *iface)
IDirect3DDevice9Ex *device = shader->parentDevice;
wined3d_mutex_lock();
IWineD3DBaseShader_Release(shader->wined3d_shader);
wined3d_shader_decref(shader->wined3d_shader);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -100,7 +100,7 @@ static HRESULT WINAPI d3d9_vertexshader_GetFunction(IDirect3DVertexShader9 *ifac
TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
wined3d_mutex_lock();
hr = IWineD3DBaseShader_GetFunction(((IDirect3DVertexShader9Impl *)iface)->wined3d_shader, data, data_size);
hr = wined3d_shader_get_byte_code(((IDirect3DVertexShader9Impl *)iface)->wined3d_shader, data, data_size);
wined3d_mutex_unlock();
return hr;
@ -179,7 +179,7 @@ static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface)
{
IDirect3DDevice9Ex_AddRef(shader->parentDevice);
wined3d_mutex_lock();
IWineD3DBaseShader_AddRef(shader->wined3d_shader);
wined3d_shader_incref(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();
IWineD3DBaseShader_Release(shader->wined3d_shader);
wined3d_shader_decref(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 = IWineD3DBaseShader_GetFunction(((IDirect3DPixelShader9Impl *)iface)->wined3d_shader, data, data_size);
hr = wined3d_shader_get_byte_code(((IDirect3DPixelShader9Impl *)iface)->wined3d_shader, data, data_size);
wined3d_mutex_unlock();
return hr;

View File

@ -944,7 +944,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
{
/* oPos, oFog and oPts in D3D */
static const char * const rastout_reg_names[] = {"TMP_OUT", "result.fogcoord", "result.pointsize"};
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
BOOL pshader = shader_is_pshader_version(reg_maps->shader_version.type);
struct shader_arb_ctx_priv *ctx = ins->ctx->backend_data;
@ -1340,7 +1340,7 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
const struct wined3d_texture *texture;
const char *tex_type;
BOOL np2_fixup = FALSE;
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
IWineD3DDeviceImpl *device = shader->device;
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
const char *mod;
@ -1756,7 +1756,7 @@ static void shader_hw_nop(const struct wined3d_shader_instruction *ins)
static void shader_hw_mov(const struct wined3d_shader_instruction *ins)
{
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
BOOL pshader = shader_is_pshader_version(reg_maps->shader_version.type);
struct shader_arb_ctx_priv *ctx = ins->ctx->backend_data;
@ -3206,7 +3206,7 @@ static void shader_hw_ret(const struct wined3d_shader_instruction *ins)
{
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
BOOL vshader = shader_is_vshader_version(ins->ctx->reg_maps->shader_version.type);
if(priv->target_version == ARB) return;
@ -5257,7 +5257,7 @@ static void free_recorded_instruction(struct list *list)
static void shader_arb_handle_instruction(const struct wined3d_shader_instruction *ins) {
SHADER_HANDLER hw_fct;
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
struct control_frame *control_frame;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
BOOL bool_const;

View File

@ -9,7 +9,7 @@
* Copyright 2006-2008 Stefan Dösinger for CodeWeavers
* Copyright 2006-2008 Henri Verbeet
* Copyright 2007 Andrew Riedi
* Copyright 2009-2010 Henri Verbeet for CodeWeavers
* Copyright 2009-2011 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -3350,9 +3350,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShader(IWineD3DDevice *iface,
if (device->isRecordingState)
{
if (shader)
IWineD3DBaseShader_AddRef(shader);
wined3d_shader_incref(shader);
if (prev)
IWineD3DBaseShader_Release(prev);
wined3d_shader_decref(prev);
TRACE("Recording... not performing anything.\n");
return WINED3D_OK;
}
@ -3365,9 +3365,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShader(IWineD3DDevice *iface,
TRACE("(%p) : setting shader(%p)\n", device, shader);
if (shader)
IWineD3DBaseShader_AddRef(shader);
wined3d_shader_incref(shader);
if (prev)
IWineD3DBaseShader_Release(prev);
wined3d_shader_decref(prev);
IWineD3DDeviceImpl_MarkStateDirty(device, STATE_VSHADER);
@ -3383,7 +3383,7 @@ static IWineD3DBaseShader * WINAPI IWineD3DDeviceImpl_GetVertexShader(IWineD3DDe
shader = (IWineD3DBaseShader *)device->stateBlock->state.vertex_shader;
if (shader)
IWineD3DBaseShader_AddRef(shader);
wined3d_shader_incref(shader);
TRACE("Returning %p.\n", shader);
return shader;
@ -3759,9 +3759,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, I
{
TRACE("Recording... not performing anything.\n");
if (shader)
IWineD3DBaseShader_AddRef(shader);
wined3d_shader_incref(shader);
if (prev)
IWineD3DBaseShader_Release(prev);
wined3d_shader_decref(prev);
return WINED3D_OK;
}
@ -3772,9 +3772,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, I
}
if (shader)
IWineD3DBaseShader_AddRef(shader);
wined3d_shader_incref(shader);
if (prev)
IWineD3DBaseShader_Release(prev);
wined3d_shader_decref(prev);
TRACE("Setting shader %p.\n", shader);
IWineD3DDeviceImpl_MarkStateDirty(device, STATE_PIXELSHADER);
@ -3789,9 +3789,9 @@ static IWineD3DBaseShader * WINAPI IWineD3DDeviceImpl_GetPixelShader(IWineD3DDev
TRACE("iface %p.\n", iface);
shader = (IWineD3DBaseShader *)device->stateBlock->state.pixel_shader;
shader = device->stateBlock->state.pixel_shader;
if (shader)
IWineD3DBaseShader_AddRef(shader);
wined3d_shader_incref(shader);
TRACE("Returning %p.\n", shader);
return shader;

View File

@ -1317,7 +1317,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
/* oPos, oFog and oPts in D3D */
static const char * const hwrastout_reg_names[] = {"OUT[10]", "OUT[11].x", "OUT[11].y"};
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
char pshader = shader_is_pshader_version(reg_maps->shader_version.type);
@ -2842,7 +2842,7 @@ static void shader_glsl_loop(const struct wined3d_shader_instruction *ins)
{
struct wined3d_shader_loop_state *loop_state = ins->ctx->loop_state;
glsl_src_param_t src1_param;
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
const DWORD *control_values = NULL;
const local_constant *constant;
@ -2925,7 +2925,7 @@ static void shader_glsl_end(const struct wined3d_shader_instruction *ins)
static void shader_glsl_rep(const struct wined3d_shader_instruction *ins)
{
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
struct wined3d_shader_loop_state *loop_state = ins->ctx->loop_state;
glsl_src_param_t src0_param;
const DWORD *control_values = NULL;
@ -3035,7 +3035,7 @@ static void shader_glsl_ret(const struct wined3d_shader_instruction *ins)
********************************************/
static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
{
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
IWineD3DDeviceImpl *device = shader->device;
DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major,
ins->ctx->reg_maps->shader_version.minor);
@ -3125,7 +3125,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins)
{
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
IWineD3DDeviceImpl *device = shader->device;
const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
glsl_sample_function_t sample_function;
@ -3158,7 +3158,7 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins)
static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins)
{
struct IWineD3DBaseShaderImpl *shader = ins->ctx->shader;
struct wined3d_shader *shader = ins->ctx->shader;
IWineD3DDeviceImpl *device = shader->device;
const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
glsl_sample_function_t sample_function;

View File

@ -1546,54 +1546,6 @@ const shader_backend_t none_shader_backend = {
shader_none_color_fixup_supported,
};
static HRESULT shader_get_function(IWineD3DBaseShaderImpl *shader, void *data, UINT *data_size)
{
if (!data)
{
*data_size = shader->functionLength;
return WINED3D_OK;
}
if (*data_size < shader->functionLength)
{
/* MSDN claims (for d3d8 at least) that if *pSizeOfData is smaller
* than the required size we should write the required size and
* return D3DERR_MOREDATA. That's not actually true. */
return WINED3DERR_INVALIDCALL;
}
memcpy(data, shader->function, shader->functionLength);
return WINED3D_OK;
}
/* Set local constants for d3d8 shaders. */
static HRESULT shader_set_local_constants_float(IWineD3DBaseShaderImpl *shader,
UINT start_idx, const float *src_data, UINT count)
{
UINT end_idx = start_idx + count;
UINT i;
if (end_idx > shader->limits.constant_float)
{
WARN("end_idx %u > float constants limit %u.\n",
end_idx, shader->limits.constant_float);
end_idx = shader->limits.constant_float;
}
for (i = start_idx; i < end_idx; ++i)
{
local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
if (!lconst) return E_OUTOFMEMORY;
lconst->idx = i;
memcpy(lconst->value, src_data + (i - start_idx) * 4 /* 4 components */, 4 * sizeof(float));
list_add_head(&shader->constantsF, &lconst->entry);
}
return WINED3D_OK;
}
static HRESULT shader_set_function(IWineD3DBaseShaderImpl *shader, const DWORD *byte_code,
const struct wined3d_shader_signature *output_signature, DWORD float_const_count)
{
@ -1641,29 +1593,8 @@ static HRESULT shader_set_function(IWineD3DBaseShaderImpl *shader, const DWORD *
return WINED3D_OK;
}
static HRESULT STDMETHODCALLTYPE wined3d_shader_QueryInterface(IWineD3DBaseShader *iface,
REFIID riid, void **object)
ULONG CDECL wined3d_shader_incref(struct wined3d_shader *shader)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_IWineD3DBaseShader)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| 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 STDMETHODCALLTYPE wined3d_shader_AddRef(IWineD3DBaseShader *iface)
{
IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface;
ULONG refcount = InterlockedIncrement(&shader->ref);
TRACE("%p increasing refcount to %u.\n", shader, refcount);
@ -1672,9 +1603,8 @@ static ULONG STDMETHODCALLTYPE wined3d_shader_AddRef(IWineD3DBaseShader *iface)
}
/* Do not call while under the GL lock. */
static ULONG STDMETHODCALLTYPE wined3d_shader_Release(IWineD3DBaseShader *iface)
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
{
IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface;
ULONG refcount = InterlockedDecrement(&shader->ref);
TRACE("%p decreasing refcount to %u.\n", shader, refcount);
@ -1689,39 +1619,67 @@ static ULONG STDMETHODCALLTYPE wined3d_shader_Release(IWineD3DBaseShader *iface)
return refcount;
}
static void * STDMETHODCALLTYPE wined3d_shader_GetParent(IWineD3DBaseShader *iface)
void * CDECL wined3d_shader_get_parent(const struct wined3d_shader *shader)
{
TRACE("iface %p.\n", iface);
TRACE("shader %p.\n", shader);
return ((IWineD3DBaseShaderImpl *)iface)->parent;
return shader->parent;
}
static HRESULT STDMETHODCALLTYPE wined3d_shader_GetFunction(IWineD3DBaseShader *iface, void *data, UINT *data_size)
HRESULT CDECL wined3d_shader_get_byte_code(const struct wined3d_shader *shader,
void *byte_code, UINT *byte_code_size)
{
TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
TRACE("shader %p, byte_code %p, byte_code_size %p.\n", shader, byte_code, byte_code_size);
return shader_get_function((IWineD3DBaseShaderImpl *)iface, data, data_size);
if (!byte_code)
{
*byte_code_size = shader->functionLength;
return WINED3D_OK;
}
if (*byte_code_size < shader->functionLength)
{
/* MSDN claims (for d3d8 at least) that if *byte_code_size is smaller
* than the required size we should write the required size and
* return D3DERR_MOREDATA. That's not actually true. */
return WINED3DERR_INVALIDCALL;
}
memcpy(byte_code, shader->function, shader->functionLength);
return WINED3D_OK;
}
static HRESULT STDMETHODCALLTYPE wined3d_shader_SetLocalConstantsF(IWineD3DBaseShader *iface,
/* Set local constants for d3d8 shaders. */
HRESULT CDECL wined3d_shader_set_local_constants_float(struct wined3d_shader *shader,
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);
UINT end_idx = start_idx + count;
UINT i;
return shader_set_local_constants_float((IWineD3DBaseShaderImpl *)iface,
start_idx, src_data, count);
TRACE("shader %p, start_idx %u, src_data %p, count %u.\n", shader, start_idx, src_data, count);
if (end_idx > shader->limits.constant_float)
{
WARN("end_idx %u > float constants limit %u.\n",
end_idx, shader->limits.constant_float);
end_idx = shader->limits.constant_float;
}
for (i = start_idx; i < end_idx; ++i)
{
struct local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
if (!lconst)
return E_OUTOFMEMORY;
lconst->idx = i;
memcpy(lconst->value, src_data + (i - start_idx) * 4 /* 4 components */, 4 * sizeof(float));
list_add_head(&shader->constantsF, &lconst->entry);
}
return WINED3D_OK;
}
static const IWineD3DBaseShaderVtbl wined3d_shader_vtbl =
{
wined3d_shader_QueryInterface,
wined3d_shader_AddRef,
wined3d_shader_Release,
wined3d_shader_GetParent,
wined3d_shader_GetFunction,
wined3d_shader_SetLocalConstantsF,
};
void find_vs_compile_args(const struct wined3d_state *state,
IWineD3DBaseShaderImpl *shader, struct vs_compile_args *args)
{
@ -1742,7 +1700,7 @@ static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_id
return FALSE;
}
BOOL vshader_get_input(struct IWineD3DBaseShaderImpl *shader,
BOOL vshader_get_input(struct wined3d_shader *shader,
BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum)
{
WORD map = shader->reg_maps.input_registers;
@ -1847,9 +1805,7 @@ HRESULT vertexshader_init(IWineD3DBaseShaderImpl *shader, IWineD3DDeviceImpl *de
if (!byte_code) return WINED3DERR_INVALIDCALL;
shader->lpVtbl = &wined3d_shader_vtbl;
shader_init(shader, device, parent, parent_ops);
hr = shader_set_function(shader, byte_code, output_signature, device->d3d_vshader_constantF);
if (FAILED(hr))
{
@ -1893,9 +1849,7 @@ HRESULT geometryshader_init(IWineD3DBaseShaderImpl *shader, IWineD3DDeviceImpl *
{
HRESULT hr;
shader->lpVtbl = &wined3d_shader_vtbl;
shader_init(shader, device, parent, parent_ops);
hr = shader_set_function(shader, byte_code, output_signature, 0);
if (FAILED(hr))
{
@ -2105,9 +2059,7 @@ HRESULT pixelshader_init(IWineD3DBaseShaderImpl *shader, IWineD3DDeviceImpl *dev
if (!byte_code) return WINED3DERR_INVALIDCALL;
shader->lpVtbl = &wined3d_shader_vtbl;
shader_init(shader, device, parent, parent_ops);
hr = shader_set_function(shader, byte_code, output_signature, device->d3d_pshader_constantF);
if (FAILED(hr))
{

View File

@ -499,9 +499,9 @@ ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
if (stateblock->state.index_buffer)
wined3d_buffer_decref(stateblock->state.index_buffer);
if (stateblock->state.vertex_shader)
IWineD3DBaseShader_Release((IWineD3DBaseShader *)stateblock->state.vertex_shader);
wined3d_shader_decref(stateblock->state.vertex_shader);
if (stateblock->state.pixel_shader)
IWineD3DBaseShader_Release((IWineD3DBaseShader *)stateblock->state.pixel_shader);
wined3d_shader_decref(stateblock->state.pixel_shader);
for (counter = 0; counter < LIGHTMAP_SIZE; ++counter)
{
@ -599,9 +599,9 @@ HRESULT CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
stateblock->state.vertex_shader, src_state->vertex_shader);
if (src_state->vertex_shader)
IWineD3DBaseShader_AddRef((IWineD3DBaseShader *)src_state->vertex_shader);
wined3d_shader_incref(src_state->vertex_shader);
if (stateblock->state.vertex_shader)
IWineD3DBaseShader_Release((IWineD3DBaseShader *)stateblock->state.vertex_shader);
wined3d_shader_decref(stateblock->state.vertex_shader);
stateblock->state.vertex_shader = src_state->vertex_shader;
}
@ -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)
IWineD3DBaseShader_AddRef((IWineD3DBaseShader *)src_state->pixel_shader);
wined3d_shader_incref(src_state->pixel_shader);
if (stateblock->state.pixel_shader)
IWineD3DBaseShader_Release((IWineD3DBaseShader *)stateblock->state.pixel_shader);
wined3d_shader_decref(stateblock->state.pixel_shader);
stateblock->state.pixel_shader = src_state->pixel_shader;
}

View File

@ -61,6 +61,12 @@
@ cdecl wined3d_resource_get_desc(ptr ptr)
@ cdecl wined3d_resource_get_parent(ptr)
@ cdecl wined3d_shader_decref(ptr)
@ cdecl wined3d_shader_get_byte_code(ptr ptr ptr)
@ cdecl wined3d_shader_get_parent(ptr)
@ cdecl wined3d_shader_incref(ptr)
@ cdecl wined3d_shader_set_local_constants_float(ptr long ptr long)
@ cdecl wined3d_stateblock_apply(ptr)
@ cdecl wined3d_stateblock_capture(ptr)
@ cdecl wined3d_stateblock_decref(ptr)

View File

@ -55,7 +55,8 @@
typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
typedef struct IWineD3DDeviceImpl IWineD3DDeviceImpl;
typedef struct IWineD3DSwapChainImpl IWineD3DSwapChainImpl;
struct IWineD3DBaseShaderImpl;
typedef struct wined3d_shader IWineD3DBaseShaderImpl;
typedef struct wined3d_shader IWineD3DBaseShader;
/* Texture format fixups */
@ -586,7 +587,7 @@ struct wined3d_shader_loop_state
struct wined3d_shader_context
{
struct IWineD3DBaseShaderImpl *shader;
struct wined3d_shader *shader;
const struct wined3d_gl_info *gl_info;
const struct wined3d_shader_reg_maps *reg_maps;
struct wined3d_shader_buffer *buffer;
@ -757,7 +758,7 @@ typedef struct {
void (*shader_load_constants)(const struct wined3d_context *context, char usePS, char useVS);
void (*shader_load_np2fixup_constants)(void *shader_priv, const struct wined3d_gl_info *gl_info,
const struct wined3d_state *state);
void (*shader_destroy)(struct IWineD3DBaseShaderImpl *shader);
void (*shader_destroy)(struct wined3d_shader *shader);
HRESULT (*shader_alloc_private)(IWineD3DDeviceImpl *device);
void (*shader_free_private)(IWineD3DDeviceImpl *device);
BOOL (*shader_dirtifyable_constants)(void);
@ -2336,12 +2337,12 @@ struct wined3d_state
INT load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
GLenum gl_primitive_type;
struct IWineD3DBaseShaderImpl *vertex_shader;
struct wined3d_shader *vertex_shader;
BOOL vs_consts_b[MAX_CONST_B];
INT vs_consts_i[MAX_CONST_I * 4];
float *vs_consts_f;
struct IWineD3DBaseShaderImpl *pixel_shader;
struct wined3d_shader *pixel_shader;
BOOL ps_consts_b[MAX_CONST_B];
INT ps_consts_i[MAX_CONST_I * 4];
float *ps_consts_f;
@ -2682,7 +2683,7 @@ int shader_addline(struct wined3d_shader_buffer *buffer, const char *fmt, ...) P
int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
/* Vertex shader utility functions */
extern BOOL vshader_get_input(struct IWineD3DBaseShaderImpl *shader,
extern BOOL vshader_get_input(struct wined3d_shader *shader,
BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
struct wined3d_vertex_shader
@ -2703,10 +2704,8 @@ struct wined3d_pixel_shader
DWORD color0_reg;
};
typedef struct IWineD3DBaseShaderImpl {
/* IUnknown */
const IWineD3DBaseShaderVtbl *lpVtbl;
struct wined3d_shader
{
LONG ref;
SHADER_LIMITS limits;
DWORD *function;
@ -2740,7 +2739,7 @@ typedef struct IWineD3DBaseShaderImpl {
struct wined3d_vertex_shader vs;
struct wined3d_pixel_shader ps;
} u;
} IWineD3DBaseShaderImpl;
};
HRESULT geometryshader_init(IWineD3DBaseShaderImpl *shader, IWineD3DDeviceImpl *device,
const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,

View File

@ -2096,6 +2096,7 @@ struct wined3d_clipper;
struct wined3d_palette;
struct wined3d_query;
struct wined3d_resource;
struct wined3d_shader;
struct wined3d_stateblock;
struct wined3d_texture;
struct wined3d_vertex_declaration;
@ -2384,24 +2385,6 @@ interface IWineD3DSwapChain : IWineD3DBase
);
}
[
object,
local,
uuid(eac93065-a4df-446f-86a1-9ef2bca40a3c)
]
interface IWineD3DBaseShader : IWineD3DBase
{
HRESULT GetFunction(
[out] void *data,
[in, out] UINT *data_size
);
HRESULT SetLocalConstantsF(
[in] UINT start_idx,
[in] const float *src_data,
[in] UINT vector4f_count
);
}
[
object,
local,
@ -2529,21 +2512,21 @@ interface IWineD3DDevice : IUnknown
[in] const struct wined3d_shader_signature *output_signature,
[in] void *parent,
[in] const struct wined3d_parent_ops *parent_ops,
[out] IWineD3DBaseShader **shader
[out] struct wined3d_shader **shader
);
HRESULT CreateGeometryShader(
[in] const DWORD *byte_code,
[in] const struct wined3d_shader_signature *output_signature,
[in] void *parent,
[in] const struct wined3d_parent_ops *parent_ops,
[out] IWineD3DBaseShader **shader
[out] struct wined3d_shader **shader
);
HRESULT CreatePixelShader(
[in] const DWORD *function,
[in] const struct wined3d_shader_signature *output_signature,
[in] void *parent,
[in] const struct wined3d_parent_ops *parent_ops,
[out] IWineD3DBaseShader **shader
[out] struct wined3d_shader **shader
);
HRESULT CreatePalette(
[in] DWORD flags,
@ -2705,9 +2688,9 @@ interface IWineD3DDevice : IUnknown
[out] PALETTEENTRY *entries
);
HRESULT SetPixelShader(
[in] IWineD3DBaseShader *shader
[in] struct wined3d_shader *shader
);
IWineD3DBaseShader *GetPixelShader(
struct wined3d_shader *GetPixelShader(
);
HRESULT SetPixelShaderConstantB(
[in] UINT start_register,
@ -2830,9 +2813,9 @@ interface IWineD3DDevice : IUnknown
[out] struct wined3d_vertex_declaration **declaration
);
HRESULT SetVertexShader(
[in] IWineD3DBaseShader *shader
[in] struct wined3d_shader *shader
);
IWineD3DBaseShader *GetVertexShader(
struct wined3d_shader *GetVertexShader(
);
HRESULT SetVertexShaderConstantB(
[in] UINT start_register,
@ -3092,6 +3075,14 @@ void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource,
struct wined3d_resource_desc *desc);
void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource);
ULONG __cdecl wined3d_shader_decref(struct wined3d_shader *shader);
HRESULT __cdecl wined3d_shader_get_byte_code(const struct wined3d_shader *shader,
void *byte_code, UINT *byte_code_size);
void * __cdecl wined3d_shader_get_parent(const struct wined3d_shader *shader);
ULONG __cdecl wined3d_shader_incref(struct wined3d_shader *shader);
HRESULT __cdecl wined3d_shader_set_local_constants_float(struct wined3d_shader *shader,
UINT start_idx, const float *src_data, UINT vector4f_count);
HRESULT __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock);
HRESULT __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);