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

wined3d: Implement SM5 imm_atomic_* instructions.

parent a3ce3b06
...@@ -4924,6 +4924,8 @@ static unsigned int shader_glsl_find_sampler(const struct wined3d_shader_sampler ...@@ -4924,6 +4924,8 @@ static unsigned int shader_glsl_find_sampler(const struct wined3d_shader_sampler
static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins) static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins)
{ {
const BOOL is_imm_instruction = WINED3DSIH_IMM_ATOMIC_AND <= ins->handler_idx
&& ins->handler_idx <= WINED3DSIH_IMM_ATOMIC_XOR;
const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps; const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
const struct wined3d_shader_version *version = &reg_maps->shader_version; const struct wined3d_shader_version *version = &reg_maps->shader_version;
struct glsl_src_param coord_param, data_param, data_param2; struct glsl_src_param coord_param, data_param, data_param2;
...@@ -4933,7 +4935,7 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins) ...@@ -4933,7 +4935,7 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins)
DWORD coord_mask; DWORD coord_mask;
const char *op; const char *op;
uav_idx = ins->dst[0].reg.idx[0].offset; uav_idx = ins->dst[is_imm_instruction].reg.idx[0].offset;
resource_type = reg_maps->uav_resource_info[uav_idx].type; resource_type = reg_maps->uav_resource_info[uav_idx].type;
if (resource_type >= ARRAY_SIZE(resource_type_info)) if (resource_type >= ARRAY_SIZE(resource_type_info))
{ {
...@@ -4946,25 +4948,36 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins) ...@@ -4946,25 +4948,36 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins)
switch (ins->handler_idx) switch (ins->handler_idx)
{ {
case WINED3DSIH_ATOMIC_AND: case WINED3DSIH_ATOMIC_AND:
case WINED3DSIH_IMM_ATOMIC_AND:
op = "imageAtomicAnd"; op = "imageAtomicAnd";
break; break;
case WINED3DSIH_ATOMIC_CMP_STORE: case WINED3DSIH_ATOMIC_CMP_STORE:
case WINED3DSIH_IMM_ATOMIC_CMP_EXCH:
op = "imageAtomicCompSwap"; op = "imageAtomicCompSwap";
break; break;
case WINED3DSIH_ATOMIC_IADD: case WINED3DSIH_ATOMIC_IADD:
case WINED3DSIH_IMM_ATOMIC_IADD:
op = "imageAtomicAdd"; op = "imageAtomicAdd";
break; break;
case WINED3DSIH_ATOMIC_OR: case WINED3DSIH_ATOMIC_OR:
case WINED3DSIH_IMM_ATOMIC_OR:
op = "imageAtomicOr"; op = "imageAtomicOr";
break; break;
case WINED3DSIH_ATOMIC_XOR: case WINED3DSIH_ATOMIC_XOR:
case WINED3DSIH_IMM_ATOMIC_XOR:
op = "imageAtomicXor"; op = "imageAtomicXor";
break; break;
case WINED3DSIH_IMM_ATOMIC_EXCH:
op = "imageAtomicExchange";
break;
default: default:
ERR("Unhandled opcode %#x.\n", ins->handler_idx); ERR("Unhandled opcode %#x.\n", ins->handler_idx);
return; return;
} }
if (is_imm_instruction)
shader_glsl_append_dst_ext(ins->ctx->buffer, ins, &ins->dst[0], data_type);
shader_glsl_add_src_param(ins, &ins->src[0], coord_mask, &coord_param); shader_glsl_add_src_param(ins, &ins->src[0], coord_mask, &coord_param);
if (reg_maps->uav_resource_info[uav_idx].flags & WINED3D_VIEW_BUFFER_RAW) if (reg_maps->uav_resource_info[uav_idx].flags & WINED3D_VIEW_BUFFER_RAW)
...@@ -4982,6 +4995,8 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins) ...@@ -4982,6 +4995,8 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins)
shader_addline(ins->ctx->buffer, ", %s", data_param2.param_str); shader_addline(ins->ctx->buffer, ", %s", data_param2.param_str);
} }
if (is_imm_instruction)
shader_addline(ins->ctx->buffer, ")");
shader_addline(ins->ctx->buffer, ");\n"); shader_addline(ins->ctx->buffer, ");\n");
} }
...@@ -9324,15 +9339,15 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB ...@@ -9324,15 +9339,15 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_IMAX */ shader_glsl_map2gl, /* WINED3DSIH_IMAX */ shader_glsl_map2gl,
/* WINED3DSIH_IMIN */ shader_glsl_map2gl, /* WINED3DSIH_IMIN */ shader_glsl_map2gl,
/* WINED3DSIH_IMM_ATOMIC_ALLOC */ NULL, /* WINED3DSIH_IMM_ATOMIC_ALLOC */ NULL,
/* WINED3DSIH_IMM_ATOMIC_AND */ NULL, /* WINED3DSIH_IMM_ATOMIC_AND */ shader_glsl_atomic,
/* WINED3DSIH_IMM_ATOMIC_CMP_EXCH */ NULL, /* WINED3DSIH_IMM_ATOMIC_CMP_EXCH */ shader_glsl_atomic,
/* WINED3DSIH_IMM_ATOMIC_CONSUME */ NULL, /* WINED3DSIH_IMM_ATOMIC_CONSUME */ NULL,
/* WINED3DSIH_IMM_ATOMIC_EXCH */ NULL, /* WINED3DSIH_IMM_ATOMIC_EXCH */ shader_glsl_atomic,
/* WINED3DSIH_IMM_ATOMIC_IADD */ NULL, /* WINED3DSIH_IMM_ATOMIC_IADD */ shader_glsl_atomic,
/* WINED3DSIH_IMM_ATOMIC_OR */ NULL, /* WINED3DSIH_IMM_ATOMIC_OR */ shader_glsl_atomic,
/* WINED3DSIH_IMM_ATOMIC_UMAX */ NULL, /* WINED3DSIH_IMM_ATOMIC_UMAX */ NULL,
/* WINED3DSIH_IMM_ATOMIC_UMIN */ NULL, /* WINED3DSIH_IMM_ATOMIC_UMIN */ NULL,
/* WINED3DSIH_IMM_ATOMIC_XOR */ NULL, /* WINED3DSIH_IMM_ATOMIC_XOR */ shader_glsl_atomic,
/* WINED3DSIH_IMUL */ shader_glsl_imul, /* WINED3DSIH_IMUL */ shader_glsl_imul,
/* WINED3DSIH_INE */ shader_glsl_relop, /* WINED3DSIH_INE */ shader_glsl_relop,
/* WINED3DSIH_INEG */ shader_glsl_unary_op, /* WINED3DSIH_INEG */ shader_glsl_unary_op,
......
...@@ -1295,13 +1295,18 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st ...@@ -1295,13 +1295,18 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
} }
if ((WINED3DSIH_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_ATOMIC_XOR) if ((WINED3DSIH_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_ATOMIC_XOR)
|| (WINED3DSIH_IMM_ATOMIC_AND <= ins.handler_idx
&& ins.handler_idx <= WINED3DSIH_IMM_ATOMIC_XOR
&& ins.handler_idx != WINED3DSIH_IMM_ATOMIC_CONSUME)
|| ins.handler_idx == WINED3DSIH_LD_UAV_TYPED) || ins.handler_idx == WINED3DSIH_LD_UAV_TYPED)
{ {
unsigned int reg_idx; unsigned int reg_idx;
if (ins.handler_idx == WINED3DSIH_LD_UAV_TYPED) if (ins.handler_idx == WINED3DSIH_LD_UAV_TYPED)
reg_idx = ins.src[1].reg.idx[0].offset; reg_idx = ins.src[1].reg.idx[0].offset;
else else if (WINED3DSIH_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_ATOMIC_XOR)
reg_idx = ins.dst[0].reg.idx[0].offset; reg_idx = ins.dst[0].reg.idx[0].offset;
else
reg_idx = ins.dst[1].reg.idx[0].offset;
if (reg_idx >= MAX_UNORDERED_ACCESS_VIEWS) if (reg_idx >= MAX_UNORDERED_ACCESS_VIEWS)
{ {
ERR("Invalid UAV index %u.\n", reg_idx); ERR("Invalid UAV index %u.\n", reg_idx);
......
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