wined3d: Simplify alpha test and color keying in GLSL.

This commit is contained in:
Stefan Dösinger 2015-04-09 22:48:17 +02:00 committed by Alexandre Julliard
parent 5c7707dc77
commit c5c7137212
2 changed files with 33 additions and 5 deletions

View File

@ -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 },

View File

@ -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))
{