From c5c713721285282c1ed466d287435a88b7b533ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20D=C3=B6singer?= Date: Thu, 9 Apr 2015 22:48:17 +0200 Subject: [PATCH] wined3d: Simplify alpha test and color keying in GLSL. --- dlls/wined3d/glsl_shader.c | 35 +++++++++++++++++++++++++++++++++-- dlls/wined3d/state.c | 3 --- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index c67243f27bb..1a1b6b01fc4 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -7572,6 +7572,37 @@ static void glsl_fragment_pipe_invalidate_constants(struct wined3d_context *cont context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_PS; } +static void glsl_fragment_pipe_alpha_test(struct wined3d_context *context, + const struct wined3d_state *state, DWORD state_id) +{ + const struct wined3d_gl_info *gl_info = context->gl_info; + int glParm; + float ref; + + TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); + + if (state->render_states[WINED3D_RS_ALPHATESTENABLE]) + { + gl_info->gl_ops.gl.p_glEnable(GL_ALPHA_TEST); + checkGLcall("glEnable GL_ALPHA_TEST"); + } + else + { + gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST); + checkGLcall("glDisable GL_ALPHA_TEST"); + return; + } + + ref = ((float)state->render_states[WINED3D_RS_ALPHAREF]) / 255.0f; + glParm = wined3d_gl_compare_func(state->render_states[WINED3D_RS_ALPHAFUNC]); + + if (glParm) + { + gl_info->gl_ops.gl.p_glAlphaFunc(glParm, ref); + checkGLcall("glAlphaFunc"); + } +} + static const struct StateEntryTemplate glsl_fragment_pipe_state_template[] = { {STATE_VDECL, {STATE_VDECL, glsl_fragment_pipe_vdecl }, WINED3D_GL_EXT_NONE }, @@ -7651,8 +7682,8 @@ static const struct StateEntryTemplate glsl_fragment_pipe_state_template[] = {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), glsl_fragment_pipe_shader }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_ALPHAFUNC), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_ALPHAREF), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), NULL }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), state_alpha_test }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), NULL }, WINED3D_GL_EXT_NONE }, + {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), glsl_fragment_pipe_alpha_test }, WINED3D_GL_EXT_NONE }, + {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_FOGENABLE), {STATE_RENDER(WINED3D_RS_FOGENABLE), glsl_fragment_pipe_fog }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_FOGTABLEMODE), {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_FOGVERTEXMODE), {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index edf1e71a99f..b3ac4f178c5 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -528,9 +528,6 @@ void state_alpha_test(struct wined3d_context *context, const struct wined3d_stat context_apply_state(context, state, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP)); context->last_was_ckey = enable_ckey; - if (context->d3d_info->shader_color_key) - enable_ckey = FALSE; - if (state->render_states[WINED3D_RS_ALPHATESTENABLE] || (state->render_states[WINED3D_RS_COLORKEYENABLE] && enable_ckey)) { -- 2.11.4.GIT