Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- include/vkd3d_shader.h | 33 ++++++++++++++++---------------- libs/vkd3d-shader/dxbc.c | 7 ++++--- libs/vkd3d-shader/spirv.c | 16 ++++++++-------- libs/vkd3d-shader/trace.c | 10 +++++----- libs/vkd3d-shader/vkd3d_shader_private.h | 4 ++-- libs/vkd3d/state.c | 7 ++++--- 6 files changed, 40 insertions(+), 37 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 054b512..d00ec45 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -701,22 +701,23 @@ struct vkd3d_shader_signature };
/* swizzle bits fields: wwzzyyxx */ -#define VKD3D_SWIZZLE_X (0u) -#define VKD3D_SWIZZLE_Y (1u) -#define VKD3D_SWIZZLE_Z (2u) -#define VKD3D_SWIZZLE_W (3u) - -#define VKD3D_SWIZZLE_MASK (0x3u) -#define VKD3D_SWIZZLE_SHIFT(idx) (2u * (idx)) - -#define VKD3D_SWIZZLE(x, y, z, w) \ - (((x & VKD3D_SWIZZLE_MASK) << VKD3D_SWIZZLE_SHIFT(0)) \ - | ((y & VKD3D_SWIZZLE_MASK) << VKD3D_SWIZZLE_SHIFT(1)) \ - | ((z & VKD3D_SWIZZLE_MASK) << VKD3D_SWIZZLE_SHIFT(2)) \ - | ((w & VKD3D_SWIZZLE_MASK) << VKD3D_SWIZZLE_SHIFT(3))) - -#define VKD3D_NO_SWIZZLE \ - VKD3D_SWIZZLE(VKD3D_SWIZZLE_X, VKD3D_SWIZZLE_Y, VKD3D_SWIZZLE_Z, VKD3D_SWIZZLE_W) +#define VKD3D_SHADER_SWIZZLE_X (0u) +#define VKD3D_SHADER_SWIZZLE_Y (1u) +#define VKD3D_SHADER_SWIZZLE_Z (2u) +#define VKD3D_SHADER_SWIZZLE_W (3u) + +#define VKD3D_SHADER_SWIZZLE_MASK (0x3u) +#define VKD3D_SHADER_SWIZZLE_SHIFT(idx) (2u * (idx)) + +#define VKD3D_SHADER_SWIZZLE(x, y, z, w) \ + (((x & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(0)) \ + | ((y & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(1)) \ + | ((z & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(2)) \ + | ((w & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(3))) + +#define VKD3D_SHADER_NO_SWIZZLE \ + VKD3D_SHADER_SWIZZLE(VKD3D_SHADER_SWIZZLE_X, VKD3D_SHADER_SWIZZLE_Y, \ + VKD3D_SHADER_SWIZZLE_Z, VKD3D_SHADER_SWIZZLE_W)
#ifndef VKD3D_SHADER_NO_PROTOTYPES
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 6a63fd6..5fba83b 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -1658,7 +1658,7 @@ static bool shader_sm4_read_src_param(struct vkd3d_sm4_data *priv, const DWORD *
if (src_param->reg.type == VKD3DSPR_IMMCONST) { - src_param->swizzle = VKD3D_NO_SWIZZLE; + src_param->swizzle = VKD3D_SHADER_NO_SWIZZLE; } else { @@ -1669,9 +1669,10 @@ static bool shader_sm4_read_src_param(struct vkd3d_sm4_data *priv, const DWORD * { case VKD3D_SM4_SWIZZLE_NONE: if (shader_sm4_is_scalar_register(&src_param->reg)) - src_param->swizzle = VKD3D_SWIZZLE(VKD3D_SWIZZLE_X, VKD3D_SWIZZLE_X, VKD3D_SWIZZLE_X, VKD3D_SWIZZLE_X); + src_param->swizzle = VKD3D_SHADER_SWIZZLE(VKD3D_SHADER_SWIZZLE_X, + VKD3D_SHADER_SWIZZLE_X, VKD3D_SHADER_SWIZZLE_X, VKD3D_SHADER_SWIZZLE_X); else - src_param->swizzle = VKD3D_NO_SWIZZLE; + src_param->swizzle = VKD3D_SHADER_NO_SWIZZLE; break;
case VKD3D_SM4_SWIZZLE_SCALAR: diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 667d851..94d7eff 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2963,7 +2963,7 @@ static uint32_t vkd3d_dxbc_compiler_get_register_id(struct vkd3d_dxbc_compiler * static bool vkd3d_swizzle_is_equal(unsigned int dst_write_mask, unsigned int swizzle, unsigned int write_mask) { - return vkd3d_compact_swizzle(VKD3D_NO_SWIZZLE, dst_write_mask) == vkd3d_compact_swizzle(swizzle, write_mask); + return vkd3d_compact_swizzle(VKD3D_SHADER_NO_SWIZZLE, dst_write_mask) == vkd3d_compact_swizzle(swizzle, write_mask); }
static uint32_t vkd3d_dxbc_compiler_emit_swizzle(struct vkd3d_dxbc_compiler *compiler, @@ -4162,7 +4162,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
val_id = vkd3d_dxbc_compiler_emit_swizzle(compiler, val_id, vkd3d_write_mask_from_component_count(input_component_count) << component_idx, - VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_NO_SWIZZLE, dst->write_mask); + VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_SHADER_NO_SWIZZLE, dst->write_mask);
vkd3d_dxbc_compiler_emit_store_reg(compiler, &dst_reg, dst->write_mask, val_id); } @@ -4257,9 +4257,9 @@ static unsigned int get_shader_output_swizzle(const struct vkd3d_dxbc_compiler * const struct vkd3d_shader_spirv_target_info *info;
if (!(info = compiler->spirv_target_info)) - return VKD3D_NO_SWIZZLE; + return VKD3D_SHADER_NO_SWIZZLE; if (register_idx >= info->output_swizzle_count) - return VKD3D_NO_SWIZZLE; + return VKD3D_SHADER_NO_SWIZZLE; return info->output_swizzles[register_idx]; }
@@ -4488,7 +4488,7 @@ static void vkd3d_dxbc_compiler_emit_output(struct vkd3d_dxbc_compiler *compiler
if ((use_private_variable = builtin && builtin->spirv_array_size)) write_mask = VKD3DSP_WRITEMASK_ALL; - else if (get_shader_output_swizzle(compiler, signature_element->register_index) != VKD3D_NO_SWIZZLE + else if (get_shader_output_swizzle(compiler, signature_element->register_index) != VKD3D_SHADER_NO_SWIZZLE || needs_private_io_variable(shader_signature, signature_element->register_index, builtin, &output_component_count, &write_mask) || is_patch_constant) @@ -4704,8 +4704,8 @@ static void vkd3d_dxbc_compiler_emit_store_shader_output(struct vkd3d_dxbc_compi
chain_id = vkd3d_spirv_build_op_access_chain1(builder, ptr_type_id, output_id, vkd3d_dxbc_compiler_get_constant_uint(compiler, index)); - object_id = vkd3d_dxbc_compiler_emit_swizzle(compiler, val_id, - write_mask, output_info->component_type, VKD3D_NO_SWIZZLE, VKD3DSP_WRITEMASK_0 << i); + object_id = vkd3d_dxbc_compiler_emit_swizzle(compiler, val_id, write_mask, + output_info->component_type, VKD3D_SHADER_NO_SWIZZLE, VKD3DSP_WRITEMASK_0 << i); vkd3d_dxbc_compiler_emit_store(compiler, chain_id, VKD3DSP_WRITEMASK_0, output_info->component_type, SpvStorageClassOutput, VKD3DSP_WRITEMASK_0 << i, object_id); ++index; @@ -6978,7 +6978,7 @@ static int vkd3d_dxbc_compiler_emit_control_flow_instruction(struct vkd3d_dxbc_c assert(compiler->control_flow_depth); assert(cf_info->current_block == VKD3D_BLOCK_SWITCH);
- assert(src->swizzle == VKD3D_NO_SWIZZLE && src->reg.type == VKD3DSPR_IMMCONST); + assert(src->swizzle == VKD3D_SHADER_NO_SWIZZLE && src->reg.type == VKD3DSPR_IMMCONST); value = *src->reg.u.immconst_uint;
if (!vkd3d_array_reserve((void **)&cf_info->u.switch_.case_blocks, &cf_info->u.switch_.case_blocks_size, diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 8ea2d0c..7ba9695 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -1124,13 +1124,13 @@ static void shader_dump_src_param(struct vkd3d_string_buffer *buffer, default: shader_addline(buffer, "_unknown_modifier(%#x)", src_modifier); }
- if (swizzle != VKD3D_NO_SWIZZLE) + if (swizzle != VKD3D_SHADER_NO_SWIZZLE) { static const char swizzle_chars[] = "xyzw"; - DWORD swizzle_x = (swizzle >> VKD3D_SWIZZLE_SHIFT(0)) & VKD3D_SWIZZLE_MASK; - DWORD swizzle_y = (swizzle >> VKD3D_SWIZZLE_SHIFT(1)) & VKD3D_SWIZZLE_MASK; - DWORD swizzle_z = (swizzle >> VKD3D_SWIZZLE_SHIFT(2)) & VKD3D_SWIZZLE_MASK; - DWORD swizzle_w = (swizzle >> VKD3D_SWIZZLE_SHIFT(3)) & VKD3D_SWIZZLE_MASK; + DWORD swizzle_x = (swizzle >> VKD3D_SHADER_SWIZZLE_SHIFT(0)) & VKD3D_SHADER_SWIZZLE_MASK; + DWORD swizzle_y = (swizzle >> VKD3D_SHADER_SWIZZLE_SHIFT(1)) & VKD3D_SHADER_SWIZZLE_MASK; + DWORD swizzle_z = (swizzle >> VKD3D_SHADER_SWIZZLE_SHIFT(2)) & VKD3D_SHADER_SWIZZLE_MASK; + DWORD swizzle_w = (swizzle >> VKD3D_SHADER_SWIZZLE_SHIFT(3)) & VKD3D_SHADER_SWIZZLE_MASK;
if (swizzle_x == swizzle_y && swizzle_x == swizzle_z diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 8948283..49de8f0 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -886,7 +886,7 @@ static inline unsigned int vkd3d_write_mask_from_component_count(unsigned int co static inline unsigned int vkd3d_swizzle_get_component(DWORD swizzle, unsigned int idx) { - return (swizzle >> VKD3D_SWIZZLE_SHIFT(idx)) & VKD3D_SWIZZLE_MASK; + return (swizzle >> VKD3D_SHADER_SWIZZLE_SHIFT(idx)) & VKD3D_SHADER_SWIZZLE_MASK; }
static inline unsigned int vkd3d_compact_swizzle(unsigned int swizzle, unsigned int write_mask) @@ -897,7 +897,7 @@ static inline unsigned int vkd3d_compact_swizzle(unsigned int swizzle, unsigned { if (write_mask & (VKD3DSP_WRITEMASK_0 << i)) { - compacted_swizzle <<= VKD3D_SWIZZLE_SHIFT(1); + compacted_swizzle <<= VKD3D_SHADER_SWIZZLE_SHIFT(1); compacted_swizzle |= vkd3d_swizzle_get_component(swizzle, i); } } diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index a3c9b41..e6803ca 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1953,9 +1953,10 @@ static HRESULT compute_input_layout_offsets(const struct d3d12_device *device, static unsigned int vkd3d_get_rt_format_swizzle(const struct vkd3d_format *format) { if (format->dxgi_format == DXGI_FORMAT_A8_UNORM) - return VKD3D_SWIZZLE(VKD3D_SWIZZLE_W, VKD3D_SWIZZLE_X, VKD3D_SWIZZLE_Y, VKD3D_SWIZZLE_Z); + return VKD3D_SHADER_SWIZZLE(VKD3D_SHADER_SWIZZLE_W, VKD3D_SHADER_SWIZZLE_X, + VKD3D_SHADER_SWIZZLE_Y, VKD3D_SHADER_SWIZZLE_Z);
- return VKD3D_NO_SWIZZLE; + return VKD3D_SHADER_NO_SWIZZLE; }
STATIC_ASSERT(sizeof(struct vkd3d_shader_transform_feedback_element) == sizeof(D3D12_SO_DECLARATION_ENTRY)); @@ -2102,7 +2103,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s if (desc->RTVFormats[i] == DXGI_FORMAT_UNKNOWN) { graphics->null_attachment_mask |= 1u << i; - ps_output_swizzle[i] = VKD3D_NO_SWIZZLE; + ps_output_swizzle[i] = VKD3D_SHADER_NO_SWIZZLE; graphics->rtv_formats[i] = VK_FORMAT_UNDEFINED; } else if ((format = vkd3d_get_format(device, desc->RTVFormats[i], false)))