vkd3d-shader/hlsl: Store swizzles in vsir format.

The previous format matched sm1 and sm4, but if we're going to be feeding
everything through vsir, we want vsir's format.
This commit is contained in:
Elizabeth Figura 2024-09-25 22:33:12 -05:00 committed by Henri Verbeet
parent 474a0ac4e2
commit 09095403ac
Notes: Henri Verbeet 2024-12-12 17:48:24 +01:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1297
2 changed files with 4 additions and 26 deletions

View File

@ -50,37 +50,17 @@
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#define HLSL_SWIZZLE_X (0u) #define HLSL_SWIZZLE VKD3D_SHADER_SWIZZLE
#define HLSL_SWIZZLE_Y (1u)
#define HLSL_SWIZZLE_Z (2u)
#define HLSL_SWIZZLE_W (3u)
#define HLSL_SWIZZLE(x, y, z, w) \
(((HLSL_SWIZZLE_ ## x) << 0) \
| ((HLSL_SWIZZLE_ ## y) << 2) \
| ((HLSL_SWIZZLE_ ## z) << 4) \
| ((HLSL_SWIZZLE_ ## w) << 6))
#define HLSL_SWIZZLE_MASK (0x3u)
#define HLSL_SWIZZLE_SHIFT(idx) (2u * (idx))
static inline unsigned int hlsl_swizzle_get_component(uint32_t swizzle, unsigned int idx) static inline unsigned int hlsl_swizzle_get_component(uint32_t swizzle, unsigned int idx)
{ {
return (swizzle >> HLSL_SWIZZLE_SHIFT(idx)) & HLSL_SWIZZLE_MASK; return vsir_swizzle_get_component(swizzle, idx);
}
static inline uint32_t vsir_swizzle_from_hlsl(uint32_t swizzle)
{
return vkd3d_shader_create_swizzle(hlsl_swizzle_get_component(swizzle, 0),
hlsl_swizzle_get_component(swizzle, 1),
hlsl_swizzle_get_component(swizzle, 2),
hlsl_swizzle_get_component(swizzle, 3));
} }
static inline void hlsl_swizzle_set_component(uint32_t *swizzle, unsigned int idx, unsigned int component) static inline void hlsl_swizzle_set_component(uint32_t *swizzle, unsigned int idx, unsigned int component)
{ {
*swizzle &= ~(HLSL_SWIZZLE_MASK << HLSL_SWIZZLE_SHIFT(idx)); *swizzle &= ~(VKD3D_SHADER_SWIZZLE_MASK << VKD3D_SHADER_SWIZZLE_SHIFT(idx));
*swizzle |= component << HLSL_SWIZZLE_SHIFT(idx); *swizzle |= component << VKD3D_SHADER_SWIZZLE_SHIFT(idx);
} }
enum hlsl_type_class enum hlsl_type_class

View File

@ -6824,7 +6824,6 @@ static uint32_t generate_vsir_get_src_swizzle(uint32_t src_writemask, uint32_t d
swizzle = hlsl_swizzle_from_writemask(src_writemask); swizzle = hlsl_swizzle_from_writemask(src_writemask);
swizzle = hlsl_map_swizzle(swizzle, dst_writemask); swizzle = hlsl_map_swizzle(swizzle, dst_writemask);
swizzle = vsir_swizzle_from_hlsl(swizzle);
return swizzle; return swizzle;
} }
@ -7895,7 +7894,6 @@ static void generate_vsir_instr_swizzle(struct hlsl_ctx *ctx,
swizzle = hlsl_swizzle_from_writemask(val->reg.writemask); swizzle = hlsl_swizzle_from_writemask(val->reg.writemask);
swizzle = hlsl_combine_swizzles(swizzle, swizzle_instr->u.vector, instr->data_type->dimx); swizzle = hlsl_combine_swizzles(swizzle, swizzle_instr->u.vector, instr->data_type->dimx);
swizzle = hlsl_map_swizzle(swizzle, ins->dst[0].write_mask); swizzle = hlsl_map_swizzle(swizzle, ins->dst[0].write_mask);
swizzle = vsir_swizzle_from_hlsl(swizzle);
src_param = &ins->src[0]; src_param = &ins->src[0];
VKD3D_ASSERT(val->type != HLSL_IR_CONSTANT); VKD3D_ASSERT(val->type != HLSL_IR_CONSTANT);