Commit 577ccfdd authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Introduce helper function to generate conditional instructions.

parent f3e612bf
......@@ -5068,13 +5068,20 @@ static void shader_glsl_default(const struct wined3d_shader_instruction *ins)
shader_addline(ins->ctx->buffer, "default:\n");
}
static void shader_glsl_if(const struct wined3d_shader_instruction *ins)
static void shader_glsl_generate_conditional_op(const struct wined3d_shader_instruction *ins,
const char *op)
{
const char *condition = (ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ) ? "bool" : "!bool";
struct glsl_src_param src0_param;
struct glsl_src_param src_param;
const char *condition;
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src0_param);
shader_addline(ins->ctx->buffer, "if (%s(%s)) {\n", condition, src0_param.param_str);
condition = ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ ? "bool" : "!bool";
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src_param);
shader_addline(ins->ctx->buffer, "if (%s(%s)) %s\n", condition, src_param.param_str, op);
}
static void shader_glsl_if(const struct wined3d_shader_instruction *ins)
{
shader_glsl_generate_conditional_op(ins, "{");
}
static void shader_glsl_ifc(const struct wined3d_shader_instruction *ins)
......@@ -5128,22 +5135,19 @@ static void shader_glsl_breakc(const struct wined3d_shader_instruction *ins)
static void shader_glsl_conditional_op(const struct wined3d_shader_instruction *ins)
{
const char *condition = (ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ) ? "bool" : "!bool";
struct glsl_src_param src_param;
const char *op;
switch (ins->handler_idx)
{
case WINED3DSIH_BREAKP: op = "break"; break;
case WINED3DSIH_CONTINUEP: op = "continue"; break;
case WINED3DSIH_RETP: op = "return"; break;
case WINED3DSIH_BREAKP: op = "break;"; break;
case WINED3DSIH_CONTINUEP: op = "continue;"; break;
case WINED3DSIH_RETP: op = "return;"; break;
default:
ERR("Unhandled opcode %#x.\n", ins->handler_idx);
return;
}
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src_param);
shader_addline(ins->ctx->buffer, "if (%s(%s)) %s;\n", condition, src_param.param_str, op);
shader_glsl_generate_conditional_op(ins, op);
}
static void shader_glsl_continue(const struct wined3d_shader_instruction *ins)
......@@ -6604,11 +6608,7 @@ static void shader_glsl_texkill(const struct wined3d_shader_instruction *ins)
{
if (ins->ctx->reg_maps->shader_version.major >= 4)
{
const char *condition = ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ ? "bool" : "!bool";
struct glsl_src_param src_param;
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src_param);
shader_addline(ins->ctx->buffer, "if (%s(%s)) discard;\n", condition, src_param.param_str);
shader_glsl_generate_conditional_op(ins, "discard;");
}
else
{
......
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