mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader: Check more accurately if swizzle is required.
Eliminates redundant OpVectorShuffle instructions. 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:
parent
f97b745ae7
commit
11a65da62a
@ -2528,10 +2528,13 @@ static uint32_t vkd3d_dxbc_compiler_emit_swizzle_ext(struct vkd3d_dxbc_compiler
|
||||
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
||||
uint32_t type_id, components[VKD3D_VEC4_SIZE];
|
||||
|
||||
if (swizzle == VKD3D_NO_SWIZZLE && write_mask == val_write_mask)
|
||||
component_count = vkd3d_write_mask_component_count(write_mask);
|
||||
val_component_count = vkd3d_write_mask_component_count(val_write_mask);
|
||||
|
||||
if (component_count == val_component_count
|
||||
&& vkd3d_compact_swizzle(swizzle, write_mask) == vkd3d_compact_swizzle(VKD3D_NO_SWIZZLE, val_write_mask))
|
||||
return val_id;
|
||||
|
||||
component_count = vkd3d_write_mask_component_count(write_mask);
|
||||
type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count);
|
||||
|
||||
if (component_count == 1)
|
||||
@ -2541,7 +2544,6 @@ static uint32_t vkd3d_dxbc_compiler_emit_swizzle_ext(struct vkd3d_dxbc_compiler
|
||||
return vkd3d_spirv_build_op_composite_extract1(builder, type_id, val_id, component_idx);
|
||||
}
|
||||
|
||||
val_component_count = vkd3d_write_mask_component_count(val_write_mask);
|
||||
if (val_component_count == 1)
|
||||
{
|
||||
for (i = 0, component_idx = 0; i < VKD3D_VEC4_SIZE; ++i)
|
||||
|
@ -882,6 +882,22 @@ static inline unsigned int vkd3d_swizzle_get_component(DWORD swizzle,
|
||||
return (swizzle >> VKD3D_SWIZZLE_SHIFT(idx)) & VKD3D_SWIZZLE_MASK;
|
||||
}
|
||||
|
||||
static inline unsigned int vkd3d_compact_swizzle(unsigned int swizzle, unsigned int write_mask)
|
||||
{
|
||||
unsigned int i, compacted_swizzle = 0;
|
||||
|
||||
for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
|
||||
{
|
||||
if (write_mask & (VKD3DSP_WRITEMASK_0 << i))
|
||||
{
|
||||
compacted_swizzle <<= VKD3D_SWIZZLE_SHIFT(1);
|
||||
compacted_swizzle |= vkd3d_swizzle_get_component(swizzle, i);
|
||||
}
|
||||
}
|
||||
|
||||
return compacted_swizzle;
|
||||
}
|
||||
|
||||
#define VKD3D_DXBC_MAX_SOURCE_COUNT 6
|
||||
#define VKD3D_DXBC_HEADER_SIZE (8 * sizeof(uint32_t))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user