wined3d: Introduce helper function to generate conditional instructions.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f3e612bf16
commit
577ccfdda9
|
@ -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_generate_conditional_op(const struct wined3d_shader_instruction *ins,
|
||||
const char *op)
|
||||
{
|
||||
struct glsl_src_param src_param;
|
||||
const char *condition;
|
||||
|
||||
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)
|
||||
{
|
||||
const char *condition = (ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ) ? "bool" : "!bool";
|
||||
struct glsl_src_param src0_param;
|
||||
|
||||
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);
|
||||
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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue