Commit 2c60906e authored by H. Verbeet's avatar H. Verbeet Committed by Alexandre Julliard

wined3d: Rewrite shader_glsl_cnd() to properly take the write mask into account.

Take the difference between ps 1.4 and earlier versions into account.
parent 693b6ef8
...@@ -1192,20 +1192,34 @@ void shader_glsl_cmp(SHADER_OPCODE_ARG* arg) { ...@@ -1192,20 +1192,34 @@ void shader_glsl_cmp(SHADER_OPCODE_ARG* arg) {
} }
/** Process the CND opcode in GLSL (dst = (src0 < 0.5) ? src1 : src2) */ /** Process the CND opcode in GLSL (dst = (src0 < 0.5) ? src1 : src2) */
/* For ps 1.1-1.3, only a single component of src0 is used. For ps 1.4
* the compare is done per component of src0. */
void shader_glsl_cnd(SHADER_OPCODE_ARG* arg) { void shader_glsl_cnd(SHADER_OPCODE_ARG* arg) {
IWineD3DBaseShaderImpl* shader = (IWineD3DBaseShaderImpl*) arg->shader;
char src0_str[100], src1_str[100], src2_str[100];
char src0_reg[50], src1_reg[50], src2_reg[50];
char src0_mask[6], src1_mask[6], src2_mask[6];
DWORD write_mask;
size_t mask_size;
char tmpLine[256]; write_mask = shader_glsl_append_dst(arg->buffer, arg);
char dst_str[100], src0_str[100], src1_str[100], src2_str[100];
char dst_reg[50], src0_reg[50], src1_reg[50], src2_reg[50];
char dst_mask[6], src0_mask[6], src1_mask[6], src2_mask[6];
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str); if (shader->baseShader.hex_version < WINED3DPS_VERSION(1, 4)) {
shader_glsl_add_src_param_old(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str); mask_size = 1;
shader_glsl_add_src_param_old(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str); shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], WINED3DSP_WRITEMASK_0, src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param_old(arg, arg->src[2], arg->src_addr[2], src2_reg, src2_mask, src2_str); } else {
shader_glsl_add_dst_old(arg->dst, dst_reg, dst_mask, tmpLine); mask_size = shader_glsl_get_write_mask_size(write_mask);
shader_addline(arg->buffer, "%s(%s < 0.5) ? %s : %s)%s;\n", shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], write_mask, src0_reg, src0_mask, src0_str);
tmpLine, src0_str, src1_str, src2_str, dst_mask); }
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], write_mask, src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[2], arg->src_addr[2], write_mask, src2_reg, src2_mask, src2_str);
if (mask_size > 1) {
shader_addline(arg->buffer, "mix(%s, %s, vec%d(lessThan(%s, vec%d(0.5)))));\n", src2_str, src1_str, mask_size, src0_str, mask_size);
} else {
shader_addline(arg->buffer, "%s < 0.5 ? %s : %s);\n", src0_str, src1_str, src2_str);
}
} }
/** GLSL code generation for WINED3DSIO_MAD: Multiply the first 2 opcodes, then add the last */ /** GLSL code generation for WINED3DSIO_MAD: Multiply the first 2 opcodes, then add the last */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment