Commit 422bf938 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Handle SM4 if instruction modifiers.

parent 8d48454a
......@@ -4156,10 +4156,11 @@ static void shader_glsl_rep(const struct wined3d_shader_instruction *ins)
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 (bool(%s)) {\n", src0_param.param_str);
shader_addline(ins->ctx->buffer, "if (%s(%s)) {\n", condition, src0_param.param_str);
}
static void shader_glsl_ifc(const struct wined3d_shader_instruction *ins)
......
......@@ -2259,7 +2259,16 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe
shader_addline(&buffer, "%s", shader_opcode_names[ins.handler_idx]);
if (ins.handler_idx == WINED3DSIH_IFC
if (ins.handler_idx == WINED3DSIH_IF)
{
switch (ins.flags)
{
case WINED3D_SHADER_CONDITIONAL_OP_NZ: shader_addline(&buffer, "_nz"); break;
case WINED3D_SHADER_CONDITIONAL_OP_Z: shader_addline(&buffer, "_z"); break;
default: shader_addline(&buffer, "_unrecognized(%#x)", ins.flags); break;
}
}
else if (ins.handler_idx == WINED3DSIH_IFC
|| ins.handler_idx == WINED3DSIH_BREAKC)
{
switch (ins.flags)
......
......@@ -103,6 +103,8 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_bytecode);
#define WINED3D_SM4_INSTRUCTION_FLAG_SATURATE 0x4
#define WINED3D_SM4_CONDITIONAL_NZ (0x1u << 18)
enum wined3d_sm4_opcode
{
WINED3D_SM4_OP_ADD = 0x00,
......@@ -379,6 +381,15 @@ static BOOL shader_sm4_read_src_param(struct wined3d_sm4_data *priv, const DWORD
static BOOL shader_sm4_read_dst_param(struct wined3d_sm4_data *priv, const DWORD **ptr,
enum wined3d_data_type data_type, struct wined3d_shader_dst_param *dst_param);
static void shader_sm4_read_if(struct wined3d_shader_instruction *ins,
DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
struct wined3d_sm4_data *priv)
{
shader_sm4_read_src_param(priv, &tokens, WINED3D_DATA_UINT, &priv->src_param[0]);
ins->flags = (opcode_token & WINED3D_SM4_CONDITIONAL_NZ) ?
WINED3D_SHADER_CONDITIONAL_OP_NZ : WINED3D_SHADER_CONDITIONAL_OP_Z;
}
static void shader_sm4_read_shader_data(struct wined3d_shader_instruction *ins,
DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
struct wined3d_sm4_data *priv)
......@@ -627,7 +638,8 @@ static const struct wined3d_sm4_opcode_info opcode_table[] =
{WINED3D_SM4_OP_FTOU, WINED3DSIH_FTOU, "u", "f"},
{WINED3D_SM4_OP_GE, WINED3DSIH_GE, "u", "ff"},
{WINED3D_SM4_OP_IADD, WINED3DSIH_IADD, "i", "ii"},
{WINED3D_SM4_OP_IF, WINED3DSIH_IF, "", "u"},
{WINED3D_SM4_OP_IF, WINED3DSIH_IF, "", "u",
shader_sm4_read_if},
{WINED3D_SM4_OP_IEQ, WINED3DSIH_IEQ, "u", "ii"},
{WINED3D_SM4_OP_IGE, WINED3DSIH_IGE, "u", "ii"},
{WINED3D_SM4_OP_ILT, WINED3DSIH_ILT, "u", "ii"},
......
......@@ -497,6 +497,12 @@ enum wined3d_shader_rel_op
WINED3D_SHADER_REL_OP_LE = 6,
};
enum wined3d_shader_conditional_op
{
WINED3D_SHADER_CONDITIONAL_OP_NZ = 0,
WINED3D_SHADER_CONDITIONAL_OP_Z = 1
};
#define WINED3D_SM1_VS 0xfffeu
#define WINED3D_SM1_PS 0xffffu
#define WINED3D_SM4_PS 0x0000u
......
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