wined3d: Add support for UAV reads.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-11-23 14:36:09 +01:00 committed by Alexandre Julliard
parent 29aa581cdd
commit 0131d4e6d1
3 changed files with 26 additions and 4 deletions

View File

@ -2068,7 +2068,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
/* Declare images */
for (i = 0; i < ARRAY_SIZE(reg_maps->uav_resource_info); ++i)
{
const char *image_type_prefix, *image_type;
const char *image_type_prefix, *image_type, *read_format;
if (!reg_maps->uav_resource_info[i].type)
continue;
@ -2079,18 +2079,22 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
case WINED3D_DATA_UNORM:
case WINED3D_DATA_SNORM:
image_type_prefix = "";
read_format = "r32f";
break;
case WINED3D_DATA_INT:
image_type_prefix = "i";
read_format = "r32i";
break;
case WINED3D_DATA_UINT:
image_type_prefix = "u";
read_format = "r32ui";
break;
default:
image_type_prefix = "";
read_format = "";
ERR("Unhandled resource data type %#x.\n", reg_maps->uav_resource_info[i].data_type);
break;
}
@ -2111,8 +2115,12 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
break;
}
shader_addline(buffer, "writeonly uniform %s%s %s_image%u;\n",
image_type_prefix, image_type, prefix, i);
if (reg_maps->uav_read_mask & (1u << i))
shader_addline(buffer, "layout(%s) uniform %s%s %s_image%u;\n",
read_format, image_type_prefix, image_type, prefix, i);
else
shader_addline(buffer, "writeonly uniform %s%s %s_image%u;\n",
image_type_prefix, image_type, prefix, i);
}
/* Declare uniforms for NP2 texcoord fixup:

View File

@ -1228,7 +1228,20 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
}
}
if (ins.handler_idx == WINED3DSIH_NRM) reg_maps->usesnrm = 1;
if (ins.handler_idx == WINED3DSIH_ATOMIC_IADD)
{
unsigned int reg_idx = ins.dst[0].reg.idx[0].offset;
if (reg_idx >= MAX_UNORDERED_ACCESS_VIEWS)
{
ERR("Invalid UAV index %u.\n", reg_idx);
break;
}
reg_maps->uav_read_mask |= (1u << reg_idx);
}
else if (ins.handler_idx == WINED3DSIH_NRM)
{
reg_maps->usesnrm = 1;
}
else if (ins.handler_idx == WINED3DSIH_DSY
|| ins.handler_idx == WINED3DSIH_DSY_COARSE
|| ins.handler_idx == WINED3DSIH_DSY_FINE)

View File

@ -839,6 +839,7 @@ struct wined3d_shader_reg_maps
BYTE bumpmat; /* MAX_TEXTURES, 8 */
BYTE luminanceparams; /* MAX_TEXTURES, 8 */
struct wined3d_shader_resource_info uav_resource_info[MAX_UNORDERED_ACCESS_VIEWS];
DWORD uav_read_mask; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
WORD usesnrm : 1;
WORD vpos : 1;