From 705f96fa39682262b674908fb12656dd5723cb60 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 25 Jan 2010 19:51:28 +0100 Subject: [PATCH] wined3d: Get rid of some unnecessary casts to specific shader types. --- dlls/wined3d/arb_program_shader.c | 55 ++++++++++++++++--------------- dlls/wined3d/glsl_shader.c | 55 +++++++++++++++---------------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 48f0e414f57..a76cd66646a 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -1761,8 +1761,8 @@ static void pshader_hw_texkill(const struct wined3d_shader_instruction *ins) static void pshader_hw_tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; const struct wined3d_shader_dst_param *dst = &ins->dst[0]; DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major, ins->ctx->reg_maps->shader_version.minor); @@ -1856,8 +1856,8 @@ static void pshader_hw_texcoord(const struct wined3d_shader_instruction *ins) static void pshader_hw_texreg2ar(const struct wined3d_shader_instruction *ins) { struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; DWORD flags; DWORD reg1 = ins->dst[0].reg.idx; @@ -1904,7 +1904,8 @@ static void pshader_hw_texreg2rgb(const struct wined3d_shader_instruction *ins) static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device; const struct wined3d_shader_dst_param *dst = &ins->dst[0]; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; char reg_coord[40], dst_reg[50], src_reg[50]; @@ -1936,8 +1937,8 @@ static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) /* with projective textures, texbem only divides the static texture coord, not the displacement, * so we can't let the GL handle this. */ - if (((IWineD3DDeviceImpl*) This->baseShader.device)->stateBlock->textureState[reg_dest_code][WINED3DTSS_TEXTURETRANSFORMFLAGS] - & WINED3DTTFF_PROJECTED) { + if (device->stateBlock->textureState[reg_dest_code][WINED3DTSS_TEXTURETRANSFORMFLAGS] & WINED3DTTFF_PROJECTED) + { shader_addline(buffer, "RCP TB.w, %s.w;\n", reg_coord); shader_addline(buffer, "MUL TB.xy, %s, TB.w;\n", reg_coord); shader_addline(buffer, "ADD TA.xy, TA, TB;\n"); @@ -1975,8 +1976,8 @@ static void pshader_hw_texm3x2pad(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; DWORD flags; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; @@ -1997,10 +1998,10 @@ static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; char src0_name[50], dst_name[50]; struct wined3d_shader_register tmp_reg = ins->dst[0].reg; BOOL is_color; @@ -2020,12 +2021,12 @@ static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD flags; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; char dst_str[50]; char src0_name[50], dst_name[50]; BOOL is_color; @@ -2043,12 +2044,12 @@ static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD flags; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; char dst_str[50]; char src0_name[50]; char dst_reg[50]; @@ -2085,11 +2086,11 @@ static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; DWORD flags; DWORD reg = ins->dst[0].reg.idx; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; char dst_str[50]; char src0_name[50]; @@ -4448,8 +4449,7 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) { if (shader_is_pshader_version(baseShader->baseShader.reg_maps.shader_version.type)) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface; - struct arb_pshader_private *shader_data = This->baseShader.backend_data; + struct arb_pshader_private *shader_data = baseShader->baseShader.backend_data; UINT i; if(!shader_data) return; /* This can happen if a shader was never compiled */ @@ -4471,10 +4471,11 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) { HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); HeapFree(GetProcessHeap(), 0, shader_data); - This->baseShader.backend_data = NULL; - } else { - IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *) iface; - struct arb_vshader_private *shader_data = This->baseShader.backend_data; + baseShader->baseShader.backend_data = NULL; + } + else + { + struct arb_vshader_private *shader_data = baseShader->baseShader.backend_data; UINT i; if(!shader_data) return; /* This can happen if a shader was never compiled */ @@ -4496,7 +4497,7 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) { HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); HeapFree(GetProcessHeap(), 0, shader_data); - This->baseShader.backend_data = NULL; + baseShader->baseShader.backend_data = NULL; } } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 0ab3c2c34cb..1179f51aa5b 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -2743,8 +2743,8 @@ static void shader_glsl_ret(const struct wined3d_shader_instruction *ins) ********************************************/ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major, ins->ctx->reg_maps->shader_version.minor); const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; @@ -3064,7 +3064,7 @@ static void shader_glsl_texm3x2pad(const struct wined3d_shader_instruction *ins) * Calculate the 1st or 2nd row of a 3-row matrix multiplication. */ static void shader_glsl_texm3x3pad(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; @@ -3100,11 +3100,11 @@ static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins) static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins) { DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_src_param_t src0_param; DWORD reg = ins->dst[0].reg.idx; - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[reg]; glsl_sample_function_t sample_function; @@ -3125,11 +3125,11 @@ static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins) static void shader_glsl_texm3x3(const struct wined3d_shader_instruction *ins) { DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state; glsl_src_param_t src0_param; char dst_mask[6]; DWORD reg = ins->dst[0].reg.idx; - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param); @@ -3144,7 +3144,7 @@ static void shader_glsl_texm3x3(const struct wined3d_shader_instruction *ins) * Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */ static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; DWORD reg = ins->dst[0].reg.idx; glsl_src_param_t src0_param; @@ -3176,7 +3176,7 @@ static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins * Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */ static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; DWORD reg = ins->dst[0].reg.idx; struct wined3d_shader_buffer *buffer = ins->ctx->buffer; @@ -3211,8 +3211,8 @@ static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *in */ static void shader_glsl_texbem(const struct wined3d_shader_instruction *ins) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; + IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device; const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; glsl_sample_function_t sample_function; glsl_src_param_t coord_param; @@ -4321,10 +4321,12 @@ static void set_glsl_shader_program(const struct wined3d_context *context, * load them now to have them hardcoded in the GLSL program. This saves some CPU cycles * later */ - if(pshader && !((IWineD3DPixelShaderImpl*)pshader)->baseShader.load_local_constsF) { + if (pshader && !((IWineD3DBaseShaderImpl *)pshader)->baseShader.load_local_constsF) + { hardcode_local_constants((IWineD3DBaseShaderImpl *) pshader, gl_info, programId, 'P'); } - if(vshader && !((IWineD3DVertexShaderImpl*)vshader)->baseShader.load_local_constsF) { + if (vshader && !((IWineD3DBaseShaderImpl *)vshader)->baseShader.load_local_constsF) + { hardcode_local_constants((IWineD3DBaseShaderImpl *) vshader, gl_info, programId, 'V'); } } @@ -4485,8 +4487,6 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device; struct shader_glsl_priv *priv = device->shader_priv; const struct wined3d_gl_info *gl_info; - IWineD3DPixelShaderImpl *ps = NULL; - IWineD3DVertexShaderImpl *vs = NULL; struct wined3d_context *context; /* Note: Do not use QueryInterface here to find out which shader type this is because this code @@ -4496,12 +4496,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { if(pshader) { struct glsl_pshader_private *shader_data; - ps = (IWineD3DPixelShaderImpl *) This; - shader_data = ps->baseShader.backend_data; + shader_data = This->baseShader.backend_data; if(!shader_data || shader_data->num_gl_shaders == 0) { HeapFree(GetProcessHeap(), 0, shader_data); - ps->baseShader.backend_data = NULL; + This->baseShader.backend_data = NULL; return; } @@ -4516,12 +4515,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { } } else { struct glsl_vshader_private *shader_data; - vs = (IWineD3DVertexShaderImpl *) This; - shader_data = vs->baseShader.backend_data; + shader_data = This->baseShader.backend_data; if(!shader_data || shader_data->num_gl_shaders == 0) { HeapFree(GetProcessHeap(), 0, shader_data); - vs->baseShader.backend_data = NULL; + This->baseShader.backend_data = NULL; return; } @@ -4557,7 +4555,7 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { if(pshader) { UINT i; - struct glsl_pshader_private *shader_data = ps->baseShader.backend_data; + struct glsl_pshader_private *shader_data = This->baseShader.backend_data; ENTER_GL(); for(i = 0; i < shader_data->num_gl_shaders; i++) { @@ -4567,11 +4565,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { } LEAVE_GL(); HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); - HeapFree(GetProcessHeap(), 0, shader_data); - ps->baseShader.backend_data = NULL; - } else { + } + else + { UINT i; - struct glsl_vshader_private *shader_data = vs->baseShader.backend_data; + struct glsl_vshader_private *shader_data = This->baseShader.backend_data; ENTER_GL(); for(i = 0; i < shader_data->num_gl_shaders; i++) { @@ -4581,10 +4579,11 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { } LEAVE_GL(); HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); - HeapFree(GetProcessHeap(), 0, shader_data); - vs->baseShader.backend_data = NULL; } + HeapFree(GetProcessHeap(), 0, This->baseShader.backend_data); + This->baseShader.backend_data = NULL; + context_release(context); }