libs/vkd3d-shader: Add support for vThreadIDInGroupFlattened register.

This commit is contained in:
Józef Kucia 2017-07-18 17:32:26 +02:00
parent caa1f4a37a
commit e5a4ad3385

View File

@ -1435,6 +1435,9 @@ static bool vkd3d_dxbc_compiler_get_register_name(char *buffer, unsigned int buf
case VKD3DSPR_LOCALTHREADID:
snprintf(buffer, buffer_size, "vThreadIDInGroup");
break;
case VKD3DSPR_LOCALTHREADINDEX:
snprintf(buffer, buffer_size, "vThreadIDInGroupFlattened");
break;
default:
FIXME("Unhandled register %#x.\n", reg->type);
snprintf(buffer, buffer_size, "unrecognized_%#x", reg->type);
@ -1572,6 +1575,7 @@ static uint32_t vkd3d_dxbc_compiler_get_register_id(struct vkd3d_dxbc_compiler *
case VKD3DSPR_SAMPLER:
case VKD3DSPR_THREADID:
case VKD3DSPR_LOCALTHREADID:
case VKD3DSPR_LOCALTHREADINDEX:
vkd3d_dxbc_compiler_get_register_info(compiler, reg, &register_info);
return register_info.id;
case VKD3DSPR_IMMCONST:
@ -1875,7 +1879,8 @@ static enum vkd3d_component_type vkd3d_component_type_for_register(enum vkd3d_sh
enum vkd3d_shader_input_sysval_semantic sysval)
{
if (reg_type == VKD3DSPR_THREADID
|| reg_type == VKD3DSPR_LOCALTHREADID)
|| reg_type == VKD3DSPR_LOCALTHREADID
|| reg_type == VKD3DSPR_LOCALTHREADINDEX)
return VKD3D_TYPE_INT;
switch (sysval)
@ -1906,6 +1911,9 @@ static unsigned int vkd3d_component_count_for_register(enum vkd3d_shader_registe
|| reg_type == VKD3DSPR_LOCALTHREADID)
return 3;
if (reg_type == VKD3DSPR_LOCALTHREADINDEX)
return 1;
switch (sysval)
{
case VKD3D_SIV_NONE:
@ -1960,6 +1968,10 @@ static void vkd3d_dxbc_compiler_decorate_builtin(struct vkd3d_dxbc_compiler *com
{
builtin = SpvBuiltInLocalInvocationId;
}
else if (reg_type == VKD3DSPR_LOCALTHREADINDEX)
{
builtin = SpvBuiltInLocalInvocationIndex;
}
else
{
FIXME("Unhandled builtin (register type %#x, semantic %#x).\n", reg_type, sysval);
@ -1983,13 +1995,19 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
struct rb_entry *entry = NULL;
bool use_private_var = false;
component_idx = vkd3d_write_mask_get_component_idx(dst->write_mask);
component_count = vkd3d_write_mask_component_count(dst->write_mask);
component_type = vkd3d_component_type_for_register(dst->reg.type, sysval);
/* vThreadIDInGroupFlattened is declared with no write mask in shader
* bytecode generated by fxc. */
if (!dst->write_mask)
if (!dst->write_mask && dst->reg.type == VKD3DSPR_LOCALTHREADINDEX)
{
component_idx = 0;
component_count = 1;
}
else
{
component_idx = vkd3d_write_mask_get_component_idx(dst->write_mask);
component_count = vkd3d_write_mask_component_count(dst->write_mask);
}
component_type = vkd3d_component_type_for_register(dst->reg.type, sysval);
if (!(input_component_count = vkd3d_component_count_for_register(dst->reg.type, sysval)))
input_component_count = component_count;
assert(component_count <= input_component_count);
@ -1999,7 +2017,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
storage_class, component_type, input_component_count);
vkd3d_spirv_add_iface_variable(builder, input_id);
if (dst->reg.type == VKD3DSPR_THREADID || dst->reg.type == VKD3DSPR_LOCALTHREADID
|| sysval)
|| dst->reg.type == VKD3DSPR_LOCALTHREADINDEX || sysval)
{
vkd3d_dxbc_compiler_decorate_builtin(compiler, input_id, dst->reg.type, sysval);
if (component_idx)