Commit 346e8cf8 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

wined3d: Generate shader epilogue before conditional returns.

parent 83f845df
...@@ -5131,20 +5131,20 @@ static void shader_glsl_default(const struct wined3d_shader_instruction *ins) ...@@ -5131,20 +5131,20 @@ static void shader_glsl_default(const struct wined3d_shader_instruction *ins)
shader_addline(ins->ctx->buffer, "default:\n"); shader_addline(ins->ctx->buffer, "default:\n");
} }
static void shader_glsl_generate_conditional_op(const struct wined3d_shader_instruction *ins, static void shader_glsl_generate_condition(const struct wined3d_shader_instruction *ins)
const char *op)
{ {
struct glsl_src_param src_param; struct glsl_src_param src_param;
const char *condition; const char *condition;
condition = ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ ? "bool" : "!bool"; 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_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_addline(ins->ctx->buffer, "if (%s(%s))\n", condition, src_param.param_str);
} }
static void shader_glsl_if(const struct wined3d_shader_instruction *ins) static void shader_glsl_if(const struct wined3d_shader_instruction *ins)
{ {
shader_glsl_generate_conditional_op(ins, "{"); shader_glsl_generate_condition(ins);
shader_addline(ins->ctx->buffer, "{\n");
} }
static void shader_glsl_ifc(const struct wined3d_shader_instruction *ins) static void shader_glsl_ifc(const struct wined3d_shader_instruction *ins)
...@@ -5203,15 +5203,29 @@ static void shader_glsl_conditional_op(const struct wined3d_shader_instruction * ...@@ -5203,15 +5203,29 @@ static void shader_glsl_conditional_op(const struct wined3d_shader_instruction *
switch (ins->handler_idx) switch (ins->handler_idx)
{ {
case WINED3DSIH_BREAKP: op = "break;"; break; case WINED3DSIH_BREAKP:
case WINED3DSIH_CONTINUEP: op = "continue;"; break; op = "break;";
case WINED3DSIH_RETP: op = "return;"; break; break;
case WINED3DSIH_CONTINUEP:
op = "continue;";
break;
case WINED3DSIH_RETP:
op = "return;";
break;
default: default:
ERR("Unhandled opcode %#x.\n", ins->handler_idx); ERR("Unhandled opcode %#x.\n", ins->handler_idx);
return; return;
} }
shader_glsl_generate_conditional_op(ins, op); shader_glsl_generate_condition(ins);
if (ins->handler_idx == WINED3DSIH_RETP)
{
shader_addline(ins->ctx->buffer, "{\n");
shader_glsl_generate_shader_epilogue(ins->ctx);
}
shader_addline(ins->ctx->buffer, " %s\n", op);
if (ins->handler_idx == WINED3DSIH_RETP)
shader_addline(ins->ctx->buffer, "}\n");
} }
static void shader_glsl_continue(const struct wined3d_shader_instruction *ins) static void shader_glsl_continue(const struct wined3d_shader_instruction *ins)
...@@ -6764,7 +6778,8 @@ static void shader_glsl_texkill(const struct wined3d_shader_instruction *ins) ...@@ -6764,7 +6778,8 @@ static void shader_glsl_texkill(const struct wined3d_shader_instruction *ins)
{ {
if (ins->ctx->reg_maps->shader_version.major >= 4) if (ins->ctx->reg_maps->shader_version.major >= 4)
{ {
shader_glsl_generate_conditional_op(ins, "discard;"); shader_glsl_generate_condition(ins);
shader_addline(ins->ctx->buffer, " discard;\n");
} }
else 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