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

wined3d: Implement SM5 atomic_iadd instruction.

parent 71ad7a89
......@@ -5202,6 +5202,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
/* WINED3DSIH_ABS */ shader_hw_map2gl,
/* WINED3DSIH_ADD */ shader_hw_map2gl,
/* WINED3DSIH_AND */ NULL,
/* WINED3DSIH_ATOMIC_IADD */ NULL,
/* WINED3DSIH_BEM */ pshader_hw_bem,
/* WINED3DSIH_BFI */ NULL,
/* WINED3DSIH_BFREV */ NULL,
......
......@@ -2821,8 +2821,9 @@ static void shader_glsl_get_swizzle(const struct wined3d_shader_src_param *param
/* From a given parameter token, generate the corresponding GLSL string.
* Also, return the actual register name and swizzle in case the
* caller needs this information as well. */
static void shader_glsl_add_src_param(const struct wined3d_shader_instruction *ins,
const struct wined3d_shader_src_param *wined3d_src, DWORD mask, struct glsl_src_param *glsl_src)
static void shader_glsl_add_src_param_ext(const struct wined3d_shader_instruction *ins,
const struct wined3d_shader_src_param *wined3d_src, DWORD mask, struct glsl_src_param *glsl_src,
enum wined3d_data_type data_type)
{
BOOL is_color = FALSE;
char swizzle_str[6];
......@@ -2842,7 +2843,7 @@ static void shader_glsl_add_src_param(const struct wined3d_shader_instruction *i
{
char reg_name[200];
switch (wined3d_src->reg.data_type)
switch (data_type)
{
case WINED3D_DATA_FLOAT:
sprintf(reg_name, "%s", glsl_src->reg_name);
......@@ -2856,7 +2857,7 @@ static void shader_glsl_add_src_param(const struct wined3d_shader_instruction *i
sprintf(reg_name, "floatBitsToUint(%s)", glsl_src->reg_name);
break;
default:
FIXME("Unhandled data type %#x.\n", wined3d_src->reg.data_type);
FIXME("Unhandled data type %#x.\n", data_type);
sprintf(reg_name, "%s", glsl_src->reg_name);
break;
}
......@@ -2865,6 +2866,12 @@ static void shader_glsl_add_src_param(const struct wined3d_shader_instruction *i
}
}
static void shader_glsl_add_src_param(const struct wined3d_shader_instruction *ins,
const struct wined3d_shader_src_param *wined3d_src, DWORD mask, struct glsl_src_param *glsl_src)
{
shader_glsl_add_src_param_ext(ins, wined3d_src, mask, glsl_src, wined3d_src->reg.data_type);
}
/* From a given parameter token, generate the corresponding GLSL string.
* Also, return the actual register name and swizzle in case the
* caller needs this information as well. */
......@@ -4720,6 +4727,56 @@ static unsigned int shader_glsl_find_sampler(const struct wined3d_shader_sampler
return ~0u;
}
static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins)
{
static const unsigned int image_coord_size[] =
{
0, /* WINED3D_SHADER_RESOURCE_NONE */
0, /* WINED3D_SHADER_RESOURCE_BUFFER */
1, /* WINED3D_SHADER_RESOURCE_TEXTURE_1D */
2, /* WINED3D_SHADER_RESOURCE_TEXTURE_2D */
0, /* WINED3D_SHADER_RESOURCE_TEXTURE_2DMS */
3, /* WINED3D_SHADER_RESOURCE_TEXTURE_3D */
0, /* WINED3D_SHADER_RESOURCE_TEXTURE_CUBE */
2, /* WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY */
3, /* WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY */
0, /* WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY */
};
const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
const struct wined3d_shader_version *version = &reg_maps->shader_version;
struct glsl_src_param image_coord_param, image_data_param;
enum wined3d_shader_resource_type resource_type;
enum wined3d_data_type data_type;
unsigned int uav_idx;
DWORD coord_mask;
const char *op;
switch (ins->handler_idx)
{
case WINED3DSIH_ATOMIC_IADD: op = "imageAtomicAdd"; break;
default:
ERR("Unhandled opcode %#x.\n", ins->handler_idx);
return;
}
uav_idx = ins->dst[0].reg.idx[0].offset;
resource_type = reg_maps->uav_resource_info[uav_idx].type;
if (resource_type >= ARRAY_SIZE(image_coord_size))
{
ERR("Unexpected resource type %#x.\n", resource_type);
resource_type = WINED3D_SHADER_RESOURCE_TEXTURE_2D;
}
data_type = reg_maps->uav_resource_info[uav_idx].data_type;
coord_mask = (1u << image_coord_size[resource_type]) - 1;
shader_glsl_add_src_param(ins, &ins->src[0], coord_mask, &image_coord_param);
shader_glsl_add_src_param_ext(ins, &ins->src[1], WINED3DSP_WRITEMASK_ALL, &image_data_param, data_type);
shader_addline(ins->ctx->buffer, "%s(%s_image%u, %s, %s);\n",
op, shader_glsl_get_prefix(version->type), uav_idx,
image_coord_param.param_str, image_data_param.param_str);
}
static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins)
{
static const unsigned int texture_size_component_count[] =
......@@ -8765,6 +8822,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_ABS */ shader_glsl_map2gl,
/* WINED3DSIH_ADD */ shader_glsl_binop,
/* WINED3DSIH_AND */ shader_glsl_binop,
/* WINED3DSIH_ATOMIC_IADD */ shader_glsl_atomic,
/* WINED3DSIH_BEM */ shader_glsl_bem,
/* WINED3DSIH_BFI */ NULL,
/* WINED3DSIH_BFREV */ NULL,
......
......@@ -43,6 +43,7 @@ static const char * const shader_opcode_names[] =
/* WINED3DSIH_ABS */ "abs",
/* WINED3DSIH_ADD */ "add",
/* WINED3DSIH_AND */ "and",
/* WINED3DSIH_ATOMIC_IADD */ "atomic_iadd",
/* WINED3DSIH_BEM */ "bem",
/* WINED3DSIH_BFI */ "bfi",
/* WINED3DSIH_BFREV */ "bfrev",
......
......@@ -243,6 +243,7 @@ enum wined3d_sm4_opcode
WINED3D_SM5_OP_STORE_RAW = 0xa6,
WINED3D_SM5_OP_LD_STRUCTURED = 0xa7,
WINED3D_SM5_OP_STORE_STRUCTURED = 0xa8,
WINED3D_SM5_OP_ATOMIC_IADD = 0xad,
WINED3D_SM5_OP_IMM_ATOMIC_ALLOC = 0xb2,
WINED3D_SM5_OP_IMM_ATOMIC_CONSUME = 0xb3,
};
......@@ -858,6 +859,7 @@ static const struct wined3d_sm4_opcode_info opcode_table[] =
{WINED3D_SM5_OP_STORE_RAW, WINED3DSIH_STORE_RAW, "U", "iu"},
{WINED3D_SM5_OP_LD_STRUCTURED, WINED3DSIH_LD_STRUCTURED, "u", "uuR"},
{WINED3D_SM5_OP_STORE_STRUCTURED, WINED3DSIH_STORE_STRUCTURED, "U", "iiu"},
{WINED3D_SM5_OP_ATOMIC_IADD, WINED3DSIH_ATOMIC_IADD, "U", "ii"},
{WINED3D_SM5_OP_IMM_ATOMIC_ALLOC, WINED3DSIH_IMM_ATOMIC_ALLOC, "u", "U"},
{WINED3D_SM5_OP_IMM_ATOMIC_CONSUME, WINED3DSIH_IMM_ATOMIC_CONSUME, "u", "U"},
};
......
......@@ -557,6 +557,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_ABS,
WINED3DSIH_ADD,
WINED3DSIH_AND,
WINED3DSIH_ATOMIC_IADD,
WINED3DSIH_BEM,
WINED3DSIH_BFI,
WINED3DSIH_BFREV,
......
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