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

wined3d: Add support for store_{raw, structured} on thread group shared memory.

parent 63b1ad59
...@@ -5278,30 +5278,44 @@ static void shader_glsl_store_uav(const struct wined3d_shader_instruction *ins) ...@@ -5278,30 +5278,44 @@ static void shader_glsl_store_uav(const struct wined3d_shader_instruction *ins)
image_coord_param.param_str, image_data_param.param_str); image_coord_param.param_str, image_data_param.param_str);
} }
static void shader_glsl_store_buffer(const struct wined3d_shader_instruction *ins) static void shader_glsl_store_raw_structured(const struct wined3d_shader_instruction *ins)
{ {
const char *prefix = shader_glsl_get_prefix(ins->ctx->reg_maps->shader_version.type); const char *prefix = shader_glsl_get_prefix(ins->ctx->reg_maps->shader_version.type);
const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps; const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data; struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
struct wined3d_string_buffer *buffer = ins->ctx->buffer; struct wined3d_string_buffer *buffer = ins->ctx->buffer;
struct glsl_src_param structure_idx, offset, data; struct glsl_src_param structure_idx, offset, data;
unsigned int i, resource_idx, stride, src_idx = 0;
struct wined3d_string_buffer *address; struct wined3d_string_buffer *address;
unsigned int i, uav_idx, src_idx = 0;
DWORD write_mask; DWORD write_mask;
BOOL is_tgsm;
uav_idx = ins->dst[0].reg.idx[0].offset; resource_idx = ins->dst[0].reg.idx[0].offset;
if (uav_idx >= ARRAY_SIZE(reg_maps->uav_resource_info)) is_tgsm = ins->dst[0].reg.type == WINED3DSPR_GROUPSHAREDMEM;
if (is_tgsm)
{ {
ERR("Invalid UAV index %u.\n", uav_idx); if (resource_idx >= reg_maps->tgsm_count)
return; {
ERR("Invalid TGSM index %u.\n", resource_idx);
return;
}
stride = reg_maps->tgsm[resource_idx].stride;
}
else
{
if (resource_idx >= ARRAY_SIZE(reg_maps->uav_resource_info))
{
ERR("Invalid UAV index %u.\n", resource_idx);
return;
}
stride = reg_maps->uav_resource_info[resource_idx].stride;
} }
address = string_buffer_get(priv->string_buffers); address = string_buffer_get(priv->string_buffers);
if (ins->handler_idx == WINED3DSIH_STORE_STRUCTURED) if (ins->handler_idx == WINED3DSIH_STORE_STRUCTURED)
{ {
shader_glsl_add_src_param(ins, &ins->src[src_idx++], WINED3DSP_WRITEMASK_0, &structure_idx); shader_glsl_add_src_param(ins, &ins->src[src_idx++], WINED3DSP_WRITEMASK_0, &structure_idx);
shader_addline(address, "%s * %u + ", structure_idx.param_str, shader_addline(address, "%s * %u + ", structure_idx.param_str, stride);
reg_maps->uav_resource_info[uav_idx].stride);
} }
shader_glsl_add_src_param(ins, &ins->src[src_idx++], WINED3DSP_WRITEMASK_0, &offset); shader_glsl_add_src_param(ins, &ins->src[src_idx++], WINED3DSP_WRITEMASK_0, &offset);
shader_addline(address, "%s / 4", offset.param_str); shader_addline(address, "%s / 4", offset.param_str);
...@@ -5313,8 +5327,12 @@ static void shader_glsl_store_buffer(const struct wined3d_shader_instruction *in ...@@ -5313,8 +5327,12 @@ static void shader_glsl_store_buffer(const struct wined3d_shader_instruction *in
shader_glsl_add_src_param(ins, &ins->src[src_idx], write_mask, &data); shader_glsl_add_src_param(ins, &ins->src[src_idx], write_mask, &data);
shader_addline(buffer, "imageStore(%s_image%u, %s + %u, uvec4(%s, 0, 0, 0));\n", if (is_tgsm)
prefix, uav_idx, address->buffer, i, data.param_str); shader_addline(buffer, "%s_g%u[%s + %u] = %s;\n",
prefix, resource_idx, address->buffer, i, data.param_str);
else
shader_addline(buffer, "imageStore(%s_image%u, %s + %u, uvec4(%s, 0, 0, 0));\n",
prefix, resource_idx, address->buffer, i, data.param_str);
} }
string_buffer_release(priv->string_buffers, address); string_buffer_release(priv->string_buffers, address);
...@@ -9653,8 +9671,8 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB ...@@ -9653,8 +9671,8 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_SINCOS */ shader_glsl_sincos, /* WINED3DSIH_SINCOS */ shader_glsl_sincos,
/* WINED3DSIH_SLT */ shader_glsl_compare, /* WINED3DSIH_SLT */ shader_glsl_compare,
/* WINED3DSIH_SQRT */ shader_glsl_map2gl, /* WINED3DSIH_SQRT */ shader_glsl_map2gl,
/* WINED3DSIH_STORE_RAW */ shader_glsl_store_buffer, /* WINED3DSIH_STORE_RAW */ shader_glsl_store_raw_structured,
/* WINED3DSIH_STORE_STRUCTURED */ shader_glsl_store_buffer, /* WINED3DSIH_STORE_STRUCTURED */ shader_glsl_store_raw_structured,
/* WINED3DSIH_STORE_UAV_TYPED */ shader_glsl_store_uav, /* WINED3DSIH_STORE_UAV_TYPED */ shader_glsl_store_uav,
/* WINED3DSIH_SUB */ shader_glsl_binop, /* WINED3DSIH_SUB */ shader_glsl_binop,
/* WINED3DSIH_SWAPC */ NULL, /* WINED3DSIH_SWAPC */ NULL,
......
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