diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index d7959cf8a1a..e65bc5b8f76 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -4677,7 +4677,7 @@ static void shader_arb_select(const struct wined3d_context *context, enum wined3 checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)"); priv->current_fprogram_id = 0; } - priv->fragment_pipe->enable_extension(gl_info, fragment_mode == WINED3D_SHADER_MODE_FFP); + priv->fragment_pipe->enable_extension(gl_info, TRUE); } if (vertex_mode == WINED3D_SHADER_MODE_SHADER) @@ -4724,13 +4724,47 @@ static void shader_arb_select(const struct wined3d_context *context, enum wined3 } } } - else if (gl_info->supported[ARB_VERTEX_PROGRAM]) + else + { + if (gl_info->supported[ARB_VERTEX_PROGRAM]) + { + priv->current_vprogram_id = 0; + gl_info->gl_ops.gl.p_glDisable(GL_VERTEX_PROGRAM_ARB); + checkGLcall("glDisable(GL_VERTEX_PROGRAM_ARB)"); + } + priv->vertex_pipe->vp_enable(gl_info, TRUE); + } +} + + +/* Context activation is done by the caller. */ +static void shader_arb_disable(void *shader_priv, const struct wined3d_context *context) +{ + const struct wined3d_gl_info *gl_info = context->gl_info; + struct shader_arb_priv *priv = shader_priv; + + if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) + { + gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB); + checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)"); + priv->current_fprogram_id = 0; + } + priv->fragment_pipe->enable_extension(gl_info, FALSE); + + if (gl_info->supported[ARB_VERTEX_PROGRAM]) { priv->current_vprogram_id = 0; gl_info->gl_ops.gl.p_glDisable(GL_VERTEX_PROGRAM_ARB); checkGLcall("glDisable(GL_VERTEX_PROGRAM_ARB)"); } - priv->vertex_pipe->vp_enable(gl_info, vertex_mode == WINED3D_SHADER_MODE_FFP); + priv->vertex_pipe->vp_enable(gl_info, FALSE); + + if (gl_info->supported[ARB_COLOR_BUFFER_FLOAT] && priv->last_vs_color_unclamp) + { + GL_EXTCALL(glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FIXED_ONLY_ARB)); + checkGLcall("glClampColorARB"); + priv->last_vs_color_unclamp = FALSE; + } } /* Context activation is done by the caller. */ @@ -5628,6 +5662,7 @@ const struct wined3d_shader_backend_ops arb_program_shader_backend = { shader_arb_handle_instruction, shader_arb_select, + shader_arb_disable, shader_arb_select_depth_blt, shader_arb_deselect_depth_blt, shader_arb_update_float_vertex_constants, diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 3cfdb0400f4..98bcbc86165 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1,7 +1,7 @@ /* * Context and render target management in wined3d * - * Copyright 2007-2008 Stefan Dösinger for CodeWeavers + * Copyright 2007-2011, 2013 Stefan Dösinger for CodeWeavers * Copyright 2009-2011 Henri Verbeet for CodeWeavers * * This library is free software; you can redistribute it and/or @@ -1922,7 +1922,7 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con set_blit_dimension(gl_info, rt_size.cx, rt_size.cy); /* Disable shaders */ - device->shader_backend->shader_select(context, WINED3D_SHADER_MODE_NONE, WINED3D_SHADER_MODE_NONE); + device->shader_backend->shader_disable(device->shader_priv, context); context->select_shader = 1; context->load_constants = 1; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 674f263a388..bf530cba2a7 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -3,7 +3,7 @@ * * Copyright 2006 Jason Green * Copyright 2006-2007 Henri Verbeet - * Copyright 2007-2008 Stefan Dösinger for CodeWeavers + * Copyright 2007-2009, 2013 Stefan Dösinger for CodeWeavers * Copyright 2009-2011 Henri Verbeet for CodeWeavers * * This library is free software; you can redistribute it and/or @@ -5823,6 +5823,26 @@ static void shader_glsl_select(const struct wined3d_context *context, enum wined } } +/* Context activation is done by the caller. */ +static void shader_glsl_disable(void *shader_priv, const struct wined3d_context *context) +{ + const struct wined3d_gl_info *gl_info = context->gl_info; + struct shader_glsl_priv *priv = shader_priv; + + priv->glsl_program = NULL; + GL_EXTCALL(glUseProgramObjectARB(0)); + checkGLcall("glUseProgramObjectARB"); + + priv->vertex_pipe->vp_enable(gl_info, FALSE); + priv->fragment_pipe->enable_extension(gl_info, FALSE); + + if (gl_info->supported[ARB_COLOR_BUFFER_FLOAT]) + { + GL_EXTCALL(glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FIXED_ONLY_ARB)); + checkGLcall("glClampColorARB"); + } +} + /* Context activation is done by the caller. */ static void shader_glsl_select_depth_blt(void *shader_priv, const struct wined3d_gl_info *gl_info, enum tex_types tex_type, const SIZE *ds_mask_size) @@ -5907,7 +5927,7 @@ static void shader_glsl_destroy(struct wined3d_shader *shader) { TRACE("Deleting pixel shader %u.\n", gl_shaders[i].prgId); if (priv->glsl_program && priv->glsl_program->ps.id == gl_shaders[i].prgId) - shader_glsl_select(context, WINED3D_SHADER_MODE_NONE, WINED3D_SHADER_MODE_NONE); + shader_glsl_disable(priv, context); GL_EXTCALL(glDeleteObjectARB(gl_shaders[i].prgId)); checkGLcall("glDeleteObjectARB"); } @@ -5930,7 +5950,7 @@ static void shader_glsl_destroy(struct wined3d_shader *shader) { TRACE("Deleting vertex shader %u.\n", gl_shaders[i].prgId); if (priv->glsl_program && priv->glsl_program->vs.id == gl_shaders[i].prgId) - shader_glsl_select(context, WINED3D_SHADER_MODE_NONE, WINED3D_SHADER_MODE_NONE); + shader_glsl_disable(priv, context); GL_EXTCALL(glDeleteObjectARB(gl_shaders[i].prgId)); checkGLcall("glDeleteObjectARB"); } @@ -5953,7 +5973,7 @@ static void shader_glsl_destroy(struct wined3d_shader *shader) { TRACE("Deleting geometry shader %u.\n", gl_shaders[i].id); if (priv->glsl_program && priv->glsl_program->gs.id == gl_shaders[i].id) - shader_glsl_select(context, WINED3D_SHADER_MODE_NONE, WINED3D_SHADER_MODE_NONE); + shader_glsl_disable(priv, context); GL_EXTCALL(glDeleteObjectARB(gl_shaders[i].id)); checkGLcall("glDeleteObjectARB"); } @@ -6342,6 +6362,7 @@ const struct wined3d_shader_backend_ops glsl_shader_backend = { shader_glsl_handle_instruction, shader_glsl_select, + shader_glsl_disable, shader_glsl_select_depth_blt, shader_glsl_deselect_depth_blt, shader_glsl_update_float_vertex_constants, diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 515caed245c..b4802d2dbd1 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -4,7 +4,7 @@ * Copyright 2004 Christian Costa * Copyright 2005 Oliver Stieber * Copyright 2006 Ivan Gyurdiev - * Copyright 2007-2008 Stefan Dösinger for CodeWeavers + * Copyright 2007-2008, 2013 Stefan Dösinger for CodeWeavers * Copyright 2009-2011 Henri Verbeet for CodeWeavers * * This library is free software; you can redistribute it and/or @@ -1516,6 +1516,7 @@ static void shader_none_load_np2fixup_constants(void *shader_priv, static void shader_none_destroy(struct wined3d_shader *shader) {} static void shader_none_context_destroyed(void *shader_priv, const struct wined3d_context *context) {} +/* Context activation is done by the caller. */ static void shader_none_select(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, enum wined3d_shader_mode fragment_mode) { @@ -1527,6 +1528,16 @@ static void shader_none_select(const struct wined3d_context *context, enum wined priv->fragment_pipe->enable_extension(gl_info, fragment_mode == WINED3D_SHADER_MODE_FFP); } +/* Context activation is done by the caller. */ +static void shader_none_disable(void *shader_priv, const struct wined3d_context *context) +{ + struct shader_none_priv *priv = shader_priv; + const struct wined3d_gl_info *gl_info = context->gl_info; + + priv->vertex_pipe->vp_enable(gl_info, FALSE); + priv->fragment_pipe->enable_extension(gl_info, FALSE); +} + static HRESULT shader_none_alloc(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe, const struct fragment_pipeline *fragment_pipe) { @@ -1603,6 +1614,7 @@ const struct wined3d_shader_backend_ops none_shader_backend = { shader_none_handle_instruction, shader_none_select, + shader_none_disable, shader_none_select_depth_blt, shader_none_deselect_depth_blt, shader_none_update_float_vertex_constants, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9af9e797599..6d8e5560aa1 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -787,7 +787,6 @@ struct vs_compile_args { enum wined3d_shader_mode { - WINED3D_SHADER_MODE_NONE, WINED3D_SHADER_MODE_FFP, WINED3D_SHADER_MODE_SHADER, }; @@ -802,6 +801,7 @@ struct wined3d_shader_backend_ops void (*shader_handle_instruction)(const struct wined3d_shader_instruction *); void (*shader_select)(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, enum wined3d_shader_mode fragment_mode); + void (*shader_disable)(void *shader_priv, const struct wined3d_context *context); void (*shader_select_depth_blt)(void *shader_priv, const struct wined3d_gl_info *gl_info, enum tex_types tex_type, const SIZE *ds_mask_size); void (*shader_deselect_depth_blt)(void *shader_priv, const struct wined3d_gl_info *gl_info);