vkd3d-shader/spirv: Handle UINT32_MAX result from FIRSTBIT_HI and FIRSTBIT_SHI instructions.

This commit is contained in:
Conor McCarthy 2024-01-13 00:36:44 +10:00 committed by Alexandre Julliard
parent 62e15dac8d
commit ca7487a56d
Notes: Alexandre Julliard 2024-01-22 22:52:31 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/580
2 changed files with 8 additions and 4 deletions

View File

@ -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);

View File

@ -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}}},