diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 5d9b78b2..8a79c116 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -6892,11 +6892,11 @@ static enum GLSLstd450 spirv_compiler_map_ext_glsl_instruction( static void spirv_compiler_emit_ext_glsl_instruction(struct spirv_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { + uint32_t instr_set_id, type_id, val_id, rev_val_id, uint_max_id, condition_id; struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; const struct vkd3d_shader_dst_param *dst = instruction->dst; const struct vkd3d_shader_src_param *src = instruction->src; uint32_t src_id[SPIRV_MAX_SRC_COUNT]; - uint32_t instr_set_id, type_id, val_id; unsigned int i, component_count; enum GLSLstd450 glsl_inst; @@ -6925,8 +6925,12 @@ static void spirv_compiler_emit_ext_glsl_instruction(struct spirv_compiler *comp { /* In D3D bits are numbered from the most significant bit. */ component_count = vsir_write_mask_component_count(dst->write_mask); - val_id = vkd3d_spirv_build_op_isub(builder, type_id, + uint_max_id = spirv_compiler_get_constant_uint_vector(compiler, UINT32_MAX, component_count); + condition_id = vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, SpvOpIEqual, + vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count), val_id, uint_max_id); + rev_val_id = vkd3d_spirv_build_op_isub(builder, type_id, spirv_compiler_get_constant_uint_vector(compiler, 31, component_count), val_id); + val_id = vkd3d_spirv_build_op_select(builder, type_id, condition_id, val_id, rev_val_id); } spirv_compiler_emit_store_dst(compiler, dst, val_id); diff --git a/tests/d3d12.c b/tests/d3d12.c index b17812b9..1fd07cca 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10577,11 +10577,11 @@ static void test_shader_instructions(void) {&ps_bits_vector, {{{0x11111111, 0x00080000}}}, {{8, 1, 28, 19}}}, - {&ps_firstbit_raw, {{{ 0, 0}}}, {{ ~0u, ~0u, ~0u, 0}}, false, true}, + {&ps_firstbit_raw, {{{ 0, 0}}}, {{ ~0u, ~0u, ~0u, 0}}}, {&ps_firstbit_raw, {{{0x80000000, 0x80000000}}}, {{ 31, 0, 1, 0}}}, {&ps_firstbit_raw, {{{0x80000001, 0x80000001}}}, {{ 0, 0, 1, 0}}}, {&ps_firstbit_raw, {{{0x11111111, 0x11111111}}}, {{ 0, 3, 3, 0}}}, - {&ps_firstbit_raw, {{{0x00080000, 0xffffffff}}}, {{ 19, 12, ~0u, 0}}, false, true}, + {&ps_firstbit_raw, {{{0x00080000, 0xffffffff}}}, {{ 19, 12, ~0u, 0}}}, {&ps_ishr, {{{0x00000000, 0x00000000, 0x00000000, 0x00000000}, {~0x1fu, 0, 32, 64}}}, {{0x00000000, 0x00000000, 0x00000000, 0x00000000}}},