diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 710cf68acaf..0e6b3072578 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -5151,7 +5151,6 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWi BOOL tempreg_used = FALSE, tfactor_used = FALSE; BOOL op_equal; const char *final_combiner_src = "ret"; - IWineD3DDeviceImpl *device = stateblock->wineD3DDevice; /* Find out which textures are read */ for(stage = 0; stage < MAX_TEXTURES; stage++) { @@ -5242,7 +5241,7 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWi srgb_sub_high, 0.0, 0.0, 0.0); } - if(ffp_clip_emul(stateblock) && device->vs_clipping) shader_addline(&buffer, "KIL fragment.texcoord[7];\n"); + if(ffp_clip_emul(stateblock) && settings->emul_clipplanes) shader_addline(&buffer, "KIL fragment.texcoord[7];\n"); /* Generate texture sampling instructions) */ for(stage = 0; stage < MAX_TEXTURES && settings->op[stage].cop != WINED3DTOP_DISABLE; stage++) { diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 82d5527e8b7..b501bbaf26b 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -2091,6 +2091,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting unsigned int i; DWORD ttff; DWORD cop, aop, carg0, carg1, carg2, aarg0, aarg1, aarg2; + IWineD3DDeviceImpl *device = stateblock->wineD3DDevice; for(i = 0; i < GL_LIMITS(texture_stages); i++) { IWineD3DBaseTextureImpl *texture; @@ -2144,8 +2145,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting carg2 = (args[cop] & ARG2) ? stateblock->textureState[i][WINED3DTSS_COLORARG2] : ARG_UNUSED; carg0 = (args[cop] & ARG0) ? stateblock->textureState[i][WINED3DTSS_COLORARG0] : ARG_UNUSED; - if(is_invalid_op(stateblock->wineD3DDevice, i, cop, - carg1, carg2, carg0)) { + if(is_invalid_op(device, i, cop, carg1, carg2, carg0)) { carg0 = ARG_UNUSED; carg2 = ARG_UNUSED; carg1 = WINED3DTA_CURRENT; @@ -2204,8 +2204,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting } } - if(is_invalid_op(stateblock->wineD3DDevice, i, aop, - aarg1, aarg2, aarg0)) { + if(is_invalid_op(device, i, aop, aarg1, aarg2, aarg0)) { aarg0 = ARG_UNUSED; aarg2 = ARG_UNUSED; aarg1 = WINED3DTA_CURRENT; @@ -2284,6 +2283,14 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting } else { settings->sRGB_write = 0; } + if(device->vs_clipping || !use_vs(stateblock)) { + /* No need to emulate clipplanes if GL supports native vertex shader clipping or if + * the fixed function vertex pipeline is used(which always supports clipplanes) + */ + settings->emul_clipplanes = 0; + } else { + settings->emul_clipplanes = 1; + } } #undef GLINFO_LOCATION diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 3bbddd8a771..afef4af693c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1378,8 +1378,9 @@ struct texture_stage_op struct ffp_frag_settings { struct texture_stage_op op[MAX_TEXTURES]; enum fogmode fog; - /* Use an int instead of a char to get dword alignment */ - unsigned int sRGB_write; + /* Use shorts instead of chars to get dword alignment */ + unsigned short sRGB_write; + unsigned short emul_clipplanes; }; struct ffp_frag_desc