On 20 May 2016 at 19:55, Matteo Bruni <mbruni(a)codeweavers.com> wrote:
+static void shader_glsl_generate_alpha_test(struct wined3d_string_buffer *buffer, + const struct wined3d_gl_info *gl_info, enum wined3d_cmp_func alpha_func) +{ + /* alpha_func is the PASS condition, not the DISCARD condition. Instead of + * flipping all the operators here, just negate the comparison below. */ + static const char * const comparison_operator[] = + { + "", /* WINED3D_CMP_NEVER */ + "<", /* WINED3D_CMP_LESS */ + "==", /* WINED3D_CMP_EQUAL */ + "<=", /* WINED3D_CMP_LESSEQUAL */ + ">", /* WINED3D_CMP_GREATER */ + "!=", /* WINED3D_CMP_NOTEQUAL */ + ">=", /* WINED3D_CMP_GREATEREQUAL */ + "" /* WINED3D_CMP_ALWAYS */ + }; + + if (alpha_func == WINED3D_CMP_ALWAYS) + return; + + if (alpha_func != WINED3D_CMP_NEVER) + shader_addline(buffer, "if (!(%s[0].a %s alpha_test_ref))\n", + get_fragment_output(gl_info), comparison_operator[alpha_func - WINED3D_CMP_NEVER]); + shader_addline(buffer, " discard;\n"); +} I'm calling this good enough for a start. In case of WINED3D_CMP_EQUAL and WINED3D_CMP_NOTEQUAL in particular there may come a point where we'll have to do a range check like for color keys though.