From 66c995f3aa26cb3e860144d9cf38883fadf6e4e3 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Tue, 26 Jul 2022 17:04:22 +0300 Subject: [PATCH] [SPIR-V] Saturate point sprite coordinates --- src/xenia/gpu/spirv_shader_translator.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/xenia/gpu/spirv_shader_translator.cc b/src/xenia/gpu/spirv_shader_translator.cc index 452ac1450..199d0f99c 100644 --- a/src/xenia/gpu/spirv_shader_translator.cc +++ b/src/xenia/gpu/spirv_shader_translator.cc @@ -1619,8 +1619,17 @@ void SpirvShaderTranslator::StartFragmentShaderInMain() { spv::Id param_gen_z, param_gen_w; if (modification.pixel.param_gen_point) { assert_true(input_point_coordinates_ != spv::NoResult); + // Saturate to avoid negative point coordinates if the center of the pixel + // is not covered, and extrapolation is done. + id_vector_temp_.clear(); + id_vector_temp_.reserve(3); + id_vector_temp_.push_back( + builder_->createLoad(input_point_coordinates_, spv::NoPrecision)); + id_vector_temp_.push_back(const_float2_0_); + id_vector_temp_.push_back(const_float2_1_); spv::Id param_gen_point_coordinates = - builder_->createLoad(input_point_coordinates_, spv::NoPrecision); + builder_->createBuiltinCall(type_float2_, ext_inst_glsl_std_450_, + GLSLstd450NClamp, id_vector_temp_); param_gen_z = builder_->createCompositeExtract( param_gen_point_coordinates, type_float_, 0); param_gen_w = builder_->createCompositeExtract(