mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
libs/vkd3d-shader: Avoid generating 2 OpVectorShuffles per mov instruction.
This commit is contained in:
parent
05842705b4
commit
99d82668a0
@ -1751,10 +1751,42 @@ static void vkd3d_dxbc_compiler_emit_mov(struct vkd3d_dxbc_compiler *compiler,
|
||||
{
|
||||
const struct vkd3d_shader_dst_param *dst = &instruction->dst[0];
|
||||
const struct vkd3d_shader_src_param *src = &instruction->src[0];
|
||||
uint32_t val_id;
|
||||
uint32_t val_id, dst_val_id, type_id, dst_id, src_id;
|
||||
uint32_t components[VKD3D_VEC4_SIZE];
|
||||
unsigned int i, component_count;
|
||||
|
||||
component_count = vkd3d_write_mask_component_count(dst->write_mask);
|
||||
|
||||
if (component_count == 1 || component_count == VKD3D_VEC4_SIZE
|
||||
|| src->modifiers || src->reg.type == VKD3DSPR_IMMCONST)
|
||||
{
|
||||
val_id = vkd3d_dxbc_compiler_emit_load_src(compiler, src, dst->write_mask);
|
||||
vkd3d_dxbc_compiler_emit_store_reg(compiler, &dst->reg, dst->write_mask, val_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
||||
|
||||
type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_FLOAT, VKD3D_VEC4_SIZE);
|
||||
dst_id = vkd3d_dxbc_compiler_get_register_id(compiler, &dst->reg);
|
||||
src_id = vkd3d_dxbc_compiler_get_register_id(compiler, &src->reg);
|
||||
|
||||
val_id = vkd3d_spirv_build_op_load(builder, type_id, src_id, SpvMemoryAccessMaskNone);
|
||||
dst_val_id = vkd3d_spirv_build_op_load(builder, type_id, dst_id, SpvMemoryAccessMaskNone);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(components); ++i)
|
||||
{
|
||||
if (dst->write_mask & (VKD3DSP_WRITEMASK_0 << i))
|
||||
components[i] = VKD3D_VEC4_SIZE + vkd3d_swizzle_get_component(src->swizzle, i);
|
||||
else
|
||||
components[i] = i;
|
||||
}
|
||||
|
||||
val_id = vkd3d_spirv_build_op_vector_shuffle(builder,
|
||||
type_id, dst_val_id, val_id, components, VKD3D_VEC4_SIZE);
|
||||
|
||||
vkd3d_spirv_build_op_store(builder, dst_id, val_id, SpvMemoryAccessMaskNone);
|
||||
}
|
||||
}
|
||||
|
||||
static void vkd3d_dxbc_compiler_emit_dot(struct vkd3d_dxbc_compiler *compiler,
|
||||
@ -1827,8 +1859,7 @@ static void vkd3d_dxbc_compiler_emit_bitfield_instruction(struct vkd3d_dxbc_comp
|
||||
result_id = vkd3d_spirv_build_op_trv(builder, &builder->function_stream,
|
||||
op, type_id, src_ids, src_count);
|
||||
|
||||
vkd3d_dxbc_compiler_emit_store_reg(compiler,
|
||||
&dst->reg, write_mask, result_id);
|
||||
vkd3d_dxbc_compiler_emit_store_reg(compiler, &dst->reg, write_mask, result_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user