From dab01d435ea006c0a40dac093b7b25e312f4aae1 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 29 Mar 2011 19:21:50 +0200 Subject: [PATCH] wined3d: Get rid of IWineD3DVertexShaderImpl. --- dlls/wined3d/arb_program_shader.c | 39 +++++++++++++++++-------------- dlls/wined3d/device.c | 4 ++-- dlls/wined3d/glsl_shader.c | 22 ++++++++--------- dlls/wined3d/shader.c | 27 +++++++++++---------- dlls/wined3d/wined3d_private.h | 38 ++++++++++++++---------------- 5 files changed, 65 insertions(+), 65 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 710134ecf18..1a83f9d0f16 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -3898,8 +3898,8 @@ static DWORD find_input_signature(struct shader_arb_priv *priv, const struct win return found_sig->idx; } -static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_num, struct shader_arb_ctx_priv *priv_ctx, - struct arb_vs_compiled_shader *compiled) +static void init_output_registers(IWineD3DBaseShaderImpl *shader, DWORD sig_num, + struct shader_arb_ctx_priv *priv_ctx, struct arb_vs_compiled_shader *compiled) { unsigned int i, j; static const char * const texcoords[8] = @@ -4075,16 +4075,16 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu } /* GL locking is done by the caller */ -static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, +static GLuint shader_arb_generate_vshader(IWineD3DBaseShaderImpl *shader, const struct wined3d_gl_info *gl_info, struct wined3d_shader_buffer *buffer, const struct arb_vs_compile_args *args, struct arb_vs_compiled_shader *compiled) { - const struct arb_vshader_private *shader_data = This->baseShader.backend_data; - const struct wined3d_shader_reg_maps *reg_maps = &This->baseShader.reg_maps; - CONST DWORD *function = This->baseShader.function; + const struct arb_vshader_private *shader_data = shader->baseShader.backend_data; + const struct wined3d_shader_reg_maps *reg_maps = &shader->baseShader.reg_maps; + const DWORD *function = shader->baseShader.function; const local_constant *lconst; GLuint ret; - DWORD next_local, *lconst_map = local_const_mapping((IWineD3DBaseShaderImpl *) This); + DWORD next_local, *lconst_map = local_const_mapping(shader); struct shader_arb_ctx_priv priv_ctx; unsigned int i; GLint errPos; @@ -4092,7 +4092,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, memset(&priv_ctx, 0, sizeof(priv_ctx)); priv_ctx.cur_vs_args = args; list_init(&priv_ctx.control_frames); - init_output_registers(This, args->ps_signature, &priv_ctx, compiled); + init_output_registers(shader, args->ps_signature, &priv_ctx, compiled); /* Create the hw ARB shader */ shader_addline(buffer, "!!ARBvp1.0\n"); @@ -4129,15 +4129,15 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, shader_addline(buffer, "TEMP TA;\n"); /* Base Declarations */ - next_local = shader_generate_arb_declarations((IWineD3DBaseShaderImpl *)This, - reg_maps, buffer, gl_info, lconst_map, &priv_ctx.vs_clipplanes, &priv_ctx); + next_local = shader_generate_arb_declarations(shader, reg_maps, buffer, + gl_info, lconst_map, &priv_ctx.vs_clipplanes, &priv_ctx); for(i = 0; i < MAX_CONST_I; i++) { compiled->int_consts[i] = WINED3D_CONST_NUM_UNUSED; if(reg_maps->integer_constants & (1 << i) && priv_ctx.target_version >= NV2) { - const DWORD *control_values = find_loop_control_values((IWineD3DBaseShaderImpl *) This, i); + const DWORD *control_values = find_loop_control_values(shader, i); if(control_values) { @@ -4170,7 +4170,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, */ if (!gl_info->supported[NV_VERTEX_PROGRAM]) { - IWineD3DDeviceImpl *device = This->baseShader.device; + IWineD3DDeviceImpl *device = shader->baseShader.device; const char *color_init = arb_get_helper_value(WINED3D_SHADER_TYPE_VERTEX, ARB_0001); shader_addline(buffer, "MOV result.color.secondary, %s;\n", color_init); @@ -4189,7 +4189,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, /* The shader starts with the main function */ priv_ctx.in_main_func = TRUE; /* Base Shader Body */ - shader_generate_main((IWineD3DBaseShaderImpl *)This, buffer, reg_maps, function, &priv_ctx); + shader_generate_main(shader, buffer, reg_maps, function, &priv_ctx); if (!priv_ctx.footer_written) vshader_add_footer(&priv_ctx, shader_data, args, reg_maps, gl_info, buffer); @@ -4225,8 +4225,10 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, if (!native) WARN("Program exceeds native resource limits.\n"); /* Load immediate constants */ - if(lconst_map) { - LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) { + if (lconst_map) + { + LIST_FOR_EACH_ENTRY(lconst, &shader->baseShader.constantsF, local_constant, entry) + { const float *value = (const float *)lconst->value; GL_EXTCALL(glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, lconst_map[lconst->idx], value)); } @@ -4332,7 +4334,8 @@ static inline BOOL vs_args_equal(const struct arb_vs_compile_args *stored, const return !memcmp(stored->loop_ctrl, new->loop_ctrl, sizeof(stored->loop_ctrl)); } -static struct arb_vs_compiled_shader *find_arb_vshader(IWineD3DVertexShaderImpl *shader, const struct arb_vs_compile_args *args) +static struct arb_vs_compiled_shader *find_arb_vshader(IWineD3DBaseShaderImpl *shader, + const struct arb_vs_compile_args *args) { IWineD3DDeviceImpl *device = shader->baseShader.device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; @@ -4473,7 +4476,7 @@ static void find_arb_ps_compile_args(const struct wined3d_state *state, } static void find_arb_vs_compile_args(const struct wined3d_state *state, - IWineD3DVertexShaderImpl *shader, struct arb_vs_compile_args *args) + IWineD3DBaseShaderImpl *shader, struct arb_vs_compile_args *args) { IWineD3DDeviceImpl *device = shader->baseShader.device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; @@ -4618,7 +4621,7 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS, if (useVS) { - IWineD3DVertexShaderImpl *vs = state->vertex_shader; + IWineD3DBaseShaderImpl *vs = state->vertex_shader; struct arb_vs_compile_args compile_args; struct arb_vs_compiled_shader *compiled; diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 61f0d629e16..6d4004101c1 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1516,7 +1516,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexShader(IWineD3DDevice *ifac IWineD3DBaseShader **shader) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - IWineD3DVertexShaderImpl *object; + IWineD3DBaseShaderImpl *object; HRESULT hr; if (This->vs_selected_mode == SHADER_NONE) @@ -3344,7 +3344,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShader(IWineD3DDevice *iface, IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface; IWineD3DBaseShader *prev = (IWineD3DBaseShader *)device->updateStateBlock->state.vertex_shader; - device->updateStateBlock->state.vertex_shader = (IWineD3DVertexShaderImpl *)shader; + device->updateStateBlock->state.vertex_shader = (IWineD3DBaseShaderImpl *)shader; device->updateStateBlock->changed.vertexShader = TRUE; if (device->isRecordingState) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index ff2d4fe65cf..796f3ef0437 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -109,7 +109,7 @@ struct glsl_shader_prog_link { GLint luminanceoffset_location[MAX_TEXTURES]; GLint ycorrection_location; GLenum vertex_color_clamp; - IWineD3DVertexShaderImpl *vshader; + IWineD3DBaseShaderImpl *vshader; IWineD3DPixelShaderImpl *pshader; struct vs_compile_args vs_args; struct ps_compile_args ps_args; @@ -118,7 +118,7 @@ struct glsl_shader_prog_link { }; typedef struct { - IWineD3DVertexShaderImpl *vshader; + IWineD3DBaseShaderImpl *vshader; IWineD3DPixelShaderImpl *pshader; struct ps_compile_args ps_args; struct vs_compile_args vs_args; @@ -3710,7 +3710,7 @@ static void add_glsl_program_entry(struct shader_glsl_priv *priv, struct glsl_sh } static struct glsl_shader_prog_link *get_glsl_program_entry(struct shader_glsl_priv *priv, - IWineD3DVertexShaderImpl *vshader, IWineD3DPixelShaderImpl *pshader, + IWineD3DBaseShaderImpl *vshader, IWineD3DPixelShaderImpl *pshader, struct vs_compile_args *vs_args, struct ps_compile_args *ps_args) { struct wine_rb_entry *entry; @@ -3838,7 +3838,7 @@ static void handle_ps3_input(struct wined3d_shader_buffer *buffer, /* GL locking is done by the caller */ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer *buffer, - IWineD3DVertexShaderImpl *vs, IWineD3DPixelShaderImpl *ps, const struct wined3d_gl_info *gl_info) + IWineD3DBaseShaderImpl *vs, IWineD3DPixelShaderImpl *ps, const struct wined3d_gl_info *gl_info) { GLhandleARB ret = 0; DWORD ps_major = ps ? ps->baseShader.reg_maps.shader_version.major : 0; @@ -4070,12 +4070,12 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context /* GL locking is done by the caller */ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context, - struct wined3d_shader_buffer *buffer, IWineD3DVertexShaderImpl *This, + struct wined3d_shader_buffer *buffer, IWineD3DBaseShaderImpl *shader, const struct vs_compile_args *args) { - const struct wined3d_shader_reg_maps *reg_maps = &This->baseShader.reg_maps; + const struct wined3d_shader_reg_maps *reg_maps = &shader->baseShader.reg_maps; const struct wined3d_gl_info *gl_info = context->gl_info; - CONST DWORD *function = This->baseShader.function; + const DWORD *function = shader->baseShader.function; struct shader_glsl_ctx_priv priv_ctx; /* Create the hw GLSL shader program and assign it as the shader->prgId */ @@ -4090,10 +4090,10 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context priv_ctx.cur_vs_args = args; /* Base Declarations */ - shader_generate_glsl_declarations(context, buffer, (IWineD3DBaseShaderImpl *)This, reg_maps, &priv_ctx); + shader_generate_glsl_declarations(context, buffer, shader, reg_maps, &priv_ctx); /* Base Shader Body */ - shader_generate_main((IWineD3DBaseShaderImpl *)This, buffer, reg_maps, function, &priv_ctx); + shader_generate_main(shader, buffer, reg_maps, function, &priv_ctx); /* Unpack outputs */ shader_addline(buffer, "order_ps_input(OUT);\n"); @@ -4217,7 +4217,7 @@ static inline BOOL vs_args_equal(const struct vs_compile_args *stored, const str } static GLhandleARB find_glsl_vshader(const struct wined3d_context *context, - struct wined3d_shader_buffer *buffer, IWineD3DVertexShaderImpl *shader, + struct wined3d_shader_buffer *buffer, IWineD3DBaseShaderImpl *shader, const struct vs_compile_args *args) { UINT i; @@ -4292,7 +4292,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, IWineD3DDeviceImpl *device, BOOL use_ps, BOOL use_vs) { const struct wined3d_state *state = &device->stateBlock->state; - IWineD3DVertexShaderImpl *vshader = use_vs ? state->vertex_shader : NULL; + IWineD3DBaseShaderImpl *vshader = use_vs ? state->vertex_shader : NULL; IWineD3DPixelShaderImpl *pshader = use_ps ? state->pixel_shader : NULL; const struct wined3d_gl_info *gl_info = context->gl_info; struct shader_glsl_priv *priv = device->shader_priv; diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index ee95ca8a42f..e7e5a1887e9 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1665,7 +1665,7 @@ static HRESULT STDMETHODCALLTYPE vertexshader_QueryInterface(IWineD3DBaseShader static ULONG STDMETHODCALLTYPE vertexshader_AddRef(IWineD3DBaseShader *iface) { - IWineD3DVertexShaderImpl *shader = (IWineD3DVertexShaderImpl *)iface; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface; ULONG refcount = InterlockedIncrement(&shader->baseShader.ref); TRACE("%p increasing refcount to %u.\n", shader, refcount); @@ -1676,14 +1676,14 @@ static ULONG STDMETHODCALLTYPE vertexshader_AddRef(IWineD3DBaseShader *iface) /* Do not call while under the GL lock. */ static ULONG STDMETHODCALLTYPE vertexshader_Release(IWineD3DBaseShader *iface) { - IWineD3DVertexShaderImpl *shader = (IWineD3DVertexShaderImpl *)iface; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface; ULONG refcount = InterlockedDecrement(&shader->baseShader.ref); TRACE("%p decreasing refcount to %u.\n", shader, refcount); if (!refcount) { - shader_cleanup((IWineD3DBaseShaderImpl *)shader); + shader_cleanup(shader); shader->baseShader.parent_ops->wined3d_object_destroyed(shader->baseShader.parent); HeapFree(GetProcessHeap(), 0, shader); } @@ -1728,7 +1728,7 @@ static const IWineD3DBaseShaderVtbl IWineD3DVertexShader_Vtbl = }; void find_vs_compile_args(const struct wined3d_state *state, - IWineD3DVertexShaderImpl *shader, struct vs_compile_args *args) + IWineD3DBaseShaderImpl *shader, struct vs_compile_args *args) { args->fog_src = state->render_states[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE ? VS_FOG_COORD : VS_FOG_Z; @@ -1747,7 +1747,7 @@ static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_id return FALSE; } -BOOL vshader_get_input(struct IWineD3DVertexShaderImpl *shader, +BOOL vshader_get_input(struct IWineD3DBaseShaderImpl *shader, BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) { WORD map = shader->baseShader.reg_maps.input_registers; @@ -1757,8 +1757,8 @@ BOOL vshader_get_input(struct IWineD3DVertexShaderImpl *shader, { if (!(map & 1)) continue; - if (match_usage(shader->attributes[i].usage, - shader->attributes[i].usage_idx, usage_req, usage_idx_req)) + if (match_usage(shader->u.vs.attributes[i].usage, + shader->u.vs.attributes[i].usage_idx, usage_req, usage_idx_req)) { *regnum = i; return TRUE; @@ -1767,7 +1767,7 @@ BOOL vshader_get_input(struct IWineD3DVertexShaderImpl *shader, return FALSE; } -static void vertexshader_set_limits(IWineD3DVertexShaderImpl *shader) +static void vertexshader_set_limits(IWineD3DBaseShaderImpl *shader) { DWORD shader_version = WINED3D_SHADER_VERSION(shader->baseShader.reg_maps.shader_version.major, shader->baseShader.reg_maps.shader_version.minor); @@ -1841,7 +1841,7 @@ static void vertexshader_set_limits(IWineD3DVertexShaderImpl *shader) } } -HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *device, +HRESULT vertexshader_init(IWineD3DBaseShaderImpl *shader, IWineD3DDeviceImpl *device, const DWORD *byte_code, const struct wined3d_shader_signature *output_signature, void *parent, const struct wined3d_parent_ops *parent_ops) { @@ -1855,12 +1855,11 @@ HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl * shader->lpVtbl = &IWineD3DVertexShader_Vtbl; shader_init(&shader->baseShader, device, parent, parent_ops); - hr = shader_set_function((IWineD3DBaseShaderImpl *)shader, byte_code, - output_signature, device->d3d_vshader_constantF); + hr = shader_set_function(shader, byte_code, output_signature, device->d3d_vshader_constantF); if (FAILED(hr)) { WARN("Failed to set function, hr %#x.\n", hr); - shader_cleanup((IWineD3DBaseShaderImpl *)shader); + shader_cleanup(shader); return hr; } @@ -1869,9 +1868,9 @@ HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl * { if (!(map & 1) || !shader->baseShader.input_signature[i].semantic_name) continue; - shader->attributes[i].usage = + shader->u.vs.attributes[i].usage = shader_usage_from_semantic_name(shader->baseShader.input_signature[i].semantic_name); - shader->attributes[i].usage_idx = shader->baseShader.input_signature[i].semantic_idx; + shader->u.vs.attributes[i].usage_idx = shader->baseShader.input_signature[i].semantic_idx; } if (output_signature) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index df0d6fbb1ff..b61c86fa2f4 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2336,7 +2336,7 @@ struct wined3d_state INT load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */ GLenum gl_primitive_type; - struct IWineD3DVertexShaderImpl *vertex_shader; + struct IWineD3DBaseShaderImpl *vertex_shader; BOOL vs_consts_b[MAX_CONST_B]; INT vs_consts_i[MAX_CONST_I * 4]; float *vs_consts_f; @@ -2682,7 +2682,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 IWineD3DVertexShaderImpl *shader, +extern BOOL vshader_get_input(struct IWineD3DBaseShaderImpl *shader, BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN; /***************************************************************************** @@ -2720,14 +2720,30 @@ typedef struct IWineD3DBaseShaderClass } IWineD3DBaseShaderClass; +struct wined3d_vertex_shader +{ + struct wined3d_shader_attribute attributes[MAX_ATTRIBS]; +}; + typedef struct IWineD3DBaseShaderImpl { /* IUnknown */ const IWineD3DBaseShaderVtbl *lpVtbl; /* IWineD3DBaseShader */ IWineD3DBaseShaderClass baseShader; + + union + { + struct wined3d_vertex_shader vs; + } u; } IWineD3DBaseShaderImpl; +void find_vs_compile_args(const struct wined3d_state *state, + IWineD3DBaseShaderImpl *shader, struct vs_compile_args *args) DECLSPEC_HIDDEN; +HRESULT vertexshader_init(IWineD3DBaseShaderImpl *shader, IWineD3DDeviceImpl *device, + const DWORD *byte_code, const struct wined3d_shader_signature *output_signature, + void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN; + void shader_buffer_clear(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN; BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN; void shader_buffer_free(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN; @@ -2812,24 +2828,6 @@ static inline BOOL shader_constant_is_local(IWineD3DBaseShaderImpl* This, DWORD } -/***************************************************************************** - * IDirect3DVertexShader implementation structures - */ -typedef struct IWineD3DVertexShaderImpl -{ - const IWineD3DBaseShaderVtbl *lpVtbl; - IWineD3DBaseShaderClass baseShader; - - /* Vertex shader attributes. */ - struct wined3d_shader_attribute attributes[MAX_ATTRIBS]; -} IWineD3DVertexShaderImpl; - -void find_vs_compile_args(const struct wined3d_state *state, - IWineD3DVertexShaderImpl *shader, struct vs_compile_args *args) DECLSPEC_HIDDEN; -HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *device, - const DWORD *byte_code, const struct wined3d_shader_signature *output_signature, - void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN; - struct wined3d_geometryshader { const struct IWineD3DBaseShaderVtbl *vtbl;