vkd3d-shader: Separate the allocated and used mask in struct vkd3d_shader_signature_element.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-09-18 11:38:09 -05:00 committed by Alexandre Julliard
parent 1165ad3f00
commit 82c42588e7
3 changed files with 34 additions and 15 deletions

View File

@ -1074,8 +1074,15 @@ struct vkd3d_shader_signature_element
enum vkd3d_shader_component_type component_type;
/** Register index. */
unsigned int register_index;
/** Register mask. */
/** Mask of the register components allocated to this varying. */
unsigned int mask;
/**
* Subset of \ref mask which the shader reads from or writes to. Unlike
* Direct3D shader bytecode, the mask for output and tessellation signatures
* is not inverted, i.e. bits set in this field denote components which are
* written to.
*/
unsigned int used_mask;
/** Minimum interpolation precision. */
enum vkd3d_shader_minimum_precision min_precision;
};

View File

@ -2139,7 +2139,7 @@ static int shader_parse_signature(DWORD tag, const char *data, DWORD data_size,
for (i = 0; i < count; ++i)
{
DWORD name_offset;
DWORD name_offset, mask;
if (has_stream_index)
read_dword(&ptr, &e[i].stream_index);
@ -2157,7 +2157,19 @@ static int shader_parse_signature(DWORD tag, const char *data, DWORD data_size,
read_dword(&ptr, &e[i].sysval_semantic);
read_dword(&ptr, &e[i].component_type);
read_dword(&ptr, &e[i].register_index);
read_dword(&ptr, &e[i].mask);
read_dword(&ptr, &mask);
e[i].mask = mask & 0xff;
e[i].used_mask = (mask >> 8) & 0xff;
switch (tag)
{
case TAG_OSGN:
case TAG_OSG1:
case TAG_OSG5:
case TAG_PCSG:
case TAG_PSG1:
e[i].used_mask = e[i].mask & ~e[i].used_mask;
break;
}
if (has_min_precision)
read_dword(&ptr, &e[i].min_precision);
@ -2167,7 +2179,7 @@ static int shader_parse_signature(DWORD tag, const char *data, DWORD data_size,
TRACE("Stream: %u, semantic: %s, semantic idx: %u, sysval_semantic %#x, "
"type %u, register idx: %u, use_mask %#x, input_mask %#x, precision %u.\n",
e[i].stream_index, debugstr_a(e[i].semantic_name), e[i].semantic_index, e[i].sysval_semantic,
e[i].component_type, e[i].register_index, (e[i].mask >> 8) & 0xff, e[i].mask & 0xff, e[i].min_precision);
e[i].component_type, e[i].register_index, e[i].used_mask, e[i].mask, e[i].min_precision);
}
s->elements = e;

View File

@ -4139,7 +4139,7 @@ static bool needs_private_io_variable(const struct vkd3d_shader_signature *signa
if (current->register_index != reg_idx)
continue;
write_mask |= current->mask & 0xff;
write_mask |= current->mask;
++count;
if (current->sysval_semantic)
@ -4216,7 +4216,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
builtin = get_spirv_builtin_for_sysval(compiler, sysval);
write_mask = signature_element->mask & 0xff;
write_mask = signature_element->mask;
component_count = vkd3d_write_mask_component_count(dst->write_mask);
if (builtin)
@ -4228,8 +4228,8 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
else
{
component_type = signature_element->component_type;
input_component_count = vkd3d_write_mask_component_count(signature_element->mask & 0xff);
component_idx = vkd3d_write_mask_get_component_idx(signature_element->mask & 0xff);
input_component_count = vkd3d_write_mask_component_count(signature_element->mask);
component_idx = vkd3d_write_mask_get_component_idx(signature_element->mask);
}
if ((use_private_var = builtin && builtin->fixup_pfn))
@ -4657,10 +4657,10 @@ static void vkd3d_dxbc_compiler_emit_output(struct vkd3d_dxbc_compiler *compiler
builtin = vkd3d_get_spirv_builtin(compiler, dst->reg.type, sysval);
write_mask = signature_element->mask & 0xff;
write_mask = signature_element->mask;
component_idx = vkd3d_write_mask_get_component_idx(dst->write_mask);
output_component_count = vkd3d_write_mask_component_count(signature_element->mask & 0xff);
output_component_count = vkd3d_write_mask_component_count(signature_element->mask);
if (builtin)
{
component_type = builtin->component_type;
@ -4833,9 +4833,9 @@ static void vkd3d_dxbc_compiler_emit_store_shader_output(struct vkd3d_dxbc_compi
unsigned int i, index, array_idx;
uint32_t output_id;
dst_write_mask = output->mask & 0xff;
dst_write_mask = output->mask;
write_mask &= dst_write_mask;
use_mask = (output->mask >> 8) & 0xff;
use_mask = output->used_mask;
if (!write_mask)
return;
@ -4847,7 +4847,7 @@ static void vkd3d_dxbc_compiler_emit_store_shader_output(struct vkd3d_dxbc_compi
}
swizzle = get_shader_output_swizzle(compiler, output->register_index);
uninit_mask = dst_write_mask & use_mask;
uninit_mask = dst_write_mask & ~use_mask;
if (uninit_mask)
{
/* Set values to 0 for not initialized shader output components. */
@ -6180,7 +6180,7 @@ static void vkd3d_dxbc_compiler_emit_default_control_point_phase(struct vkd3d_dx
const struct vkd3d_shader_signature_element *output = &output_signature->elements[i];
const struct vkd3d_shader_signature_element *input = &input_signature->elements[i];
assert((input->mask & 0xff) == (output->mask & 0xff));
assert(input->mask == output->mask);
assert(input->component_type == output->component_type);
if ((input_builtin = get_spirv_builtin_for_sysval(compiler, vkd3d_siv_from_sysval(input->sysval_semantic))))
@ -6191,7 +6191,7 @@ static void vkd3d_dxbc_compiler_emit_default_control_point_phase(struct vkd3d_dx
else
{
component_type = input->component_type;
component_count = vkd3d_write_mask_component_count(input->mask & 0xff);
component_count = vkd3d_write_mask_component_count(input->mask);
}
if (input_builtin)