mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Normalise descriptor register indices to shader model 5.1.
Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
cd233fe018
commit
1acb3de9bd
@ -637,8 +637,8 @@ static void shader_sm4_read_shader_data(struct vkd3d_shader_instruction *ins,
|
||||
static void shader_sm4_set_descriptor_register_range(struct vkd3d_sm4_data *priv,
|
||||
struct vkd3d_shader_register *reg, struct vkd3d_shader_register_range *range)
|
||||
{
|
||||
range->first = reg->idx[shader_is_sm_5_1(priv) ? 1 : 0].offset;
|
||||
range->last = reg->idx[shader_is_sm_5_1(priv) ? 2 : 0].offset;
|
||||
range->first = reg->idx[1].offset;
|
||||
range->last = reg->idx[shader_is_sm_5_1(priv) ? 2 : 1].offset;
|
||||
if (range->last < range->first)
|
||||
{
|
||||
FIXME("Invalid register range [%u:%u].\n", range->first, range->last);
|
||||
@ -1516,6 +1516,21 @@ static bool shader_sm4_read_reg_idx(struct vkd3d_sm4_data *priv, const DWORD **p
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool sm4_register_is_descriptor(enum vkd3d_sm4_register_type register_type)
|
||||
{
|
||||
switch (register_type)
|
||||
{
|
||||
case VKD3D_SM4_RT_SAMPLER:
|
||||
case VKD3D_SM4_RT_RESOURCE:
|
||||
case VKD3D_SM4_RT_CONSTBUFFER:
|
||||
case VKD3D_SM5_RT_UAV:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool shader_sm4_read_param(struct vkd3d_sm4_data *priv, const DWORD **ptr, const DWORD *end,
|
||||
enum vkd3d_data_type data_type, struct vkd3d_shader_register *param,
|
||||
enum vkd3d_shader_src_modifier *modifier)
|
||||
@ -1667,13 +1682,12 @@ static bool shader_sm4_read_param(struct vkd3d_sm4_data *priv, const DWORD **ptr
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (register_type == VKD3D_SM4_RT_CONSTBUFFER && order == 2)
|
||||
else if (!shader_is_sm_5_1(priv) && sm4_register_is_descriptor(register_type))
|
||||
{
|
||||
/* SM5.1 places the buffer offset in idx[2]; earlier versions place it
|
||||
* in idx[1]. Normalize to SM5.1. */
|
||||
/* SM5.1 places a symbol identifier in idx[0] and moves
|
||||
* other values up one slot. Normalize to SM5.1. */
|
||||
param->idx[2] = param->idx[1];
|
||||
param->idx[1].rel_addr = NULL;
|
||||
param->idx[1].offset = 0;
|
||||
param->idx[1] = param->idx[0];
|
||||
}
|
||||
|
||||
map_register(priv, param);
|
||||
|
@ -766,6 +766,7 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
|
||||
{
|
||||
struct vkd3d_string_buffer *buffer = &compiler->buffer;
|
||||
unsigned int offset = reg->idx[0].offset;
|
||||
bool is_descriptor = false;
|
||||
|
||||
static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
|
||||
static const char * const misctype_reg_names[] = {"vPos", "vFace"};
|
||||
@ -847,6 +848,7 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
|
||||
|
||||
case VKD3DSPR_SAMPLER:
|
||||
shader_addline(buffer, "s");
|
||||
is_descriptor = true;
|
||||
break;
|
||||
|
||||
case VKD3DSPR_MISCTYPE:
|
||||
@ -871,6 +873,7 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
|
||||
|
||||
case VKD3DSPR_CONSTBUFFER:
|
||||
shader_addline(buffer, "cb");
|
||||
is_descriptor = true;
|
||||
break;
|
||||
|
||||
case VKD3DSPR_IMMCONSTBUFFER:
|
||||
@ -891,10 +894,12 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
|
||||
|
||||
case VKD3DSPR_RESOURCE:
|
||||
shader_addline(buffer, "t");
|
||||
is_descriptor = true;
|
||||
break;
|
||||
|
||||
case VKD3DSPR_UAV:
|
||||
shader_addline(buffer, "u");
|
||||
is_descriptor = true;
|
||||
break;
|
||||
|
||||
case VKD3DSPR_OUTPOINTID:
|
||||
@ -1057,11 +1062,11 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
|
||||
vkd3d_string_buffer_printf(buffer, "%u%s", offset, compiler->colours.reset);
|
||||
}
|
||||
|
||||
/* For CBs in sm < 5.1 we move the buffer offset from idx[1] to idx[2]
|
||||
* to normalise it with 5.1.
|
||||
* Here we should ignore it if it's a CB in sm < 5.1. */
|
||||
/* For descriptors in sm < 5.1 we move the reg->idx values up one slot
|
||||
* to normalise with 5.1.
|
||||
* Here we should ignore it if it's a descriptor in sm < 5.1. */
|
||||
if (reg->idx[1].offset != ~0u &&
|
||||
(reg->type != VKD3DSPR_CONSTBUFFER || shader_ver_ge(&compiler->shader_version, 5, 1)))
|
||||
(!is_descriptor || shader_ver_ge(&compiler->shader_version, 5, 1)))
|
||||
shader_print_subscript(compiler, reg->idx[1].offset, reg->idx[1].rel_addr);
|
||||
|
||||
if (reg->idx[2].offset != ~0u)
|
||||
|
Loading…
Reference in New Issue
Block a user