diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 82901c6fb..e9cf66b0f 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -9311,6 +9311,7 @@ struct temp_allocator enum vkd3d_shader_register_type type; unsigned int idx; bool force_first; + bool fixed_mask; } *ssa_regs, *temp_regs; size_t ssa_count, temp_count; unsigned int new_temp_count; @@ -9430,7 +9431,16 @@ static void temp_allocator_set_dst(struct temp_allocator *allocator, dst->reg.type = VKD3DSPR_TEMP; dst->reg.dimension = VSIR_DIMENSION_VEC4; dst->reg.idx[0].offset = reg->temp_id; + + if (reg->fixed_mask) + { + VKD3D_ASSERT((reg->allocated_mask & dst->write_mask) == dst->write_mask); + return; + } + remapped_mask = vsir_combine_write_masks(reg->allocated_mask, dst->write_mask); + VKD3D_ASSERT(vkd3d_popcount(remapped_mask) == vkd3d_popcount(dst->write_mask)); + if (dst->write_mask != remapped_mask) { dst->write_mask = remapped_mask; @@ -9508,6 +9518,7 @@ static void temp_allocator_open_register(struct temp_allocator *allocator, struc { reg->temp_id = i; reg->allocated_mask = liveness_reg->mask; + reg->fixed_mask = true; current_allocation[i] |= reg->allocated_mask; allocator->new_temp_count = max(allocator->new_temp_count, i + 1); TRACE("Allocated r%u%s for %s (liveness %u-%u).\n", @@ -9534,6 +9545,7 @@ static void temp_allocator_open_register(struct temp_allocator *allocator, struc reg->temp_id = i; reg->allocated_mask = vsir_combine_write_masks(available_mask, mask); + reg->fixed_mask = false; current_allocation[i] |= reg->allocated_mask; allocator->new_temp_count = max(allocator->new_temp_count, i + 1); TRACE("Allocated r%u%s for %s (liveness %u-%u).\n", diff --git a/tests/hlsl/trigonometry.shader_test b/tests/hlsl/trigonometry.shader_test index 2710ed88d..b15727a34 100644 --- a/tests/hlsl/trigonometry.shader_test +++ b/tests/hlsl/trigonometry.shader_test @@ -1,3 +1,8 @@ +[require] +% The sincos instruction has different semantics in SM2 and SM3. Test both versions. +compile shader model 2.0 +compile shader model 3.0 + [vertex shader] void main(float4 pos : position, out float tex : texcoord, out float4 out_pos : sv_position) {