vkd3d-shader/spirv: Flush NaN to zero in ftoi.

This commit is contained in:
Zebediah Figura 2023-09-08 13:45:34 -05:00 committed by Alexandre Julliard
parent a5b6162d25
commit 257a351f37
Notes: Alexandre Julliard 2023-09-25 22:27:00 +02: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/289

View File

@ -7004,7 +7004,7 @@ static void spirv_compiler_emit_udiv(struct spirv_compiler *compiler,
static void spirv_compiler_emit_ftoi(struct spirv_compiler *compiler,
const struct vkd3d_shader_instruction *instruction)
{
uint32_t src_id, int_min_id, int_max_id, float_max_id, condition_id, val_id;
uint32_t src_id, int_min_id, int_max_id, zero_id, float_max_id, condition_id, val_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;
@ -7035,6 +7035,10 @@ static void spirv_compiler_emit_ftoi(struct spirv_compiler *compiler,
val_id = vkd3d_spirv_build_op_tr1(builder, &builder->function_stream, SpvOpConvertFToS, dst_type_id, val_id);
val_id = vkd3d_spirv_build_op_select(builder, dst_type_id, condition_id, int_max_id, val_id);
zero_id = spirv_compiler_get_constant_int_vector(compiler, 0, component_count);
condition_id = vkd3d_spirv_build_op_tr1(builder, &builder->function_stream, SpvOpIsNan, condition_type_id, src_id);
val_id = vkd3d_spirv_build_op_select(builder, dst_type_id, condition_id, zero_id, val_id);
spirv_compiler_emit_store_dst(compiler, dst, val_id);
}