From 536782bc1c74a65f72f0530141715f1f76acc001 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 11 Jan 2019 21:01:10 +0330 Subject: [PATCH] wined3d: Support WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST in the GLSL blitter. Both the ARBfp and fixed-function blitter support WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST, but the fixed-function blitter requires a compatibility context, and the ARBfp blitter isn't created when the GLSL blitter is available. This fixes a regression introduced by commit 6fc027e5acfb7f7c7f50af421658e5442e896588. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45874 Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/glsl_shader.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index fc0b2c78bd0..d6fd565bd80 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -13116,7 +13116,8 @@ static BOOL glsl_blitter_supported(enum wined3d_blit_op blit_op, const struct wi blit_op = WINED3D_BLIT_OP_COLOR_BLIT; } - if (blit_op != WINED3D_BLIT_OP_COLOR_BLIT && blit_op != WINED3D_BLIT_OP_COLOR_BLIT_CKEY) + if (blit_op != WINED3D_BLIT_OP_COLOR_BLIT && blit_op != WINED3D_BLIT_OP_COLOR_BLIT_CKEY + && blit_op != WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST) { TRACE("Unsupported blit_op %#x.\n", blit_op); return FALSE; @@ -13168,6 +13169,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli const struct wined3d_gl_info *gl_info = context->gl_info; struct wined3d_texture *staging_texture = NULL; struct wined3d_glsl_blitter *glsl_blitter; + struct wined3d_color_key alpha_test_key; struct glsl_blitter_program *program; struct wined3d_blitter *next; unsigned int src_level; @@ -13284,8 +13286,20 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli context_invalidate_state(context, STATE_FRAMEBUFFER); } - if (!(program = glsl_blitter_get_program(glsl_blitter, context, src_texture_gl, - op == WINED3D_BLIT_OP_COLOR_BLIT_CKEY))) + if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST) + { + const struct wined3d_format *f = src_texture->resource.format; + + alpha_test_key.color_space_low_value = 0; + alpha_test_key.color_space_high_value = ~(((1u << f->alpha_size) - 1) << f->alpha_offset); + colour_key = &alpha_test_key; + } + else if (op != WINED3D_BLIT_OP_COLOR_BLIT_CKEY) + { + colour_key = NULL; + } + + if (!(program = glsl_blitter_get_program(glsl_blitter, context, src_texture_gl, !!colour_key))) { ERR("Failed to get blitter program.\n"); return dst_location; @@ -13310,7 +13324,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli default: break; } - if (op == WINED3D_BLIT_OP_COLOR_BLIT_CKEY) + if (colour_key) { struct wined3d_color float_key[2];