[Base] Float clamping cleanup
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "xenia/gpu/d3d12/d3d12_graphics_system.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/gpu/d3d12/d3d12_command_processor.h"
|
||||
|
||||
@@ -409,12 +409,13 @@ void GetHostViewportInfo(const RegisterFile& regs, uint32_t resolution_scale,
|
||||
float axis_0 = offset_axis - scale_axis_abs;
|
||||
float axis_1 = offset_axis + scale_axis_abs;
|
||||
float axis_max_unscaled_float = float(xy_max_unscaled[i]);
|
||||
// fmax to drop NaN and < 0, min as float (axis_max_unscaled_float is well
|
||||
// below 2^24) to safely drop very large values.
|
||||
// max(0.0f, xy) drops NaN and < 0 - max picks the first argument in the
|
||||
// !(a < b) case (always for NaN), min as float (axis_max_unscaled_float
|
||||
// is well below 2^24) to safely drop very large values.
|
||||
uint32_t axis_0_int =
|
||||
uint32_t(std::min(std::fmax(axis_0, 0.0f), axis_max_unscaled_float));
|
||||
uint32_t(std::min(axis_max_unscaled_float, std::max(0.0f, axis_0)));
|
||||
uint32_t axis_1_int =
|
||||
uint32_t(std::min(std::fmax(axis_1, 0.0f), axis_max_unscaled_float));
|
||||
uint32_t(std::min(axis_max_unscaled_float, std::max(0.0f, axis_1)));
|
||||
uint32_t axis_extent_int = axis_1_int - axis_0_int;
|
||||
viewport_info_out.xy_offset[i] = axis_0_int * resolution_scale;
|
||||
viewport_info_out.xy_extent[i] = axis_extent_int * resolution_scale;
|
||||
@@ -517,9 +518,8 @@ void GetHostViewportInfo(const RegisterFile& regs, uint32_t resolution_scale,
|
||||
// extension. But cases when this really matters are yet to be found -
|
||||
// trying to fix this will result in more correct depth values, but
|
||||
// incorrect clipping.
|
||||
z_min = std::min(std::fmax(host_clip_offset_z, 0.0f), 1.0f);
|
||||
z_max = std::min(std::fmax(host_clip_offset_z + host_clip_scale_z, 0.0f),
|
||||
1.0f);
|
||||
z_min = xe::saturate_unsigned(host_clip_offset_z);
|
||||
z_max = xe::saturate_unsigned(host_clip_offset_z + host_clip_scale_z);
|
||||
// Direct3D 12 doesn't allow reverse depth range - on some drivers it
|
||||
// works, on some drivers it doesn't, actually, but it was never
|
||||
// explicitly allowed by the specification.
|
||||
|
||||
@@ -585,10 +585,11 @@ bool RenderTargetCache::Update(bool is_rasterization_done,
|
||||
// Using floor, or, rather, truncation (because maxing with zero anyway)
|
||||
// similar to how viewport scissoring behaves on real AMD, Intel and Nvidia
|
||||
// GPUs on Direct3D 12, also like in draw_util::GetHostViewportInfo.
|
||||
// fmax to drop NaN and < 0, min as float (height_used is well below 2^24)
|
||||
// to safely drop very large values.
|
||||
height_used = uint32_t(
|
||||
std::min(std::fmax(viewport_bottom, 0.0f), float(height_used)));
|
||||
// max(0.0f, viewport_bottom) to drop NaN and < 0 - max picks the first
|
||||
// argument in the !(a < b) case (always for NaN), min as float (height_used
|
||||
// is well below 2^24) to safely drop very large values.
|
||||
height_used =
|
||||
uint32_t(std::min(float(height_used), std::max(0.0f, viewport_bottom)));
|
||||
}
|
||||
int32_t scissor_bottom =
|
||||
int32_t(regs.Get<reg::PA_SC_WINDOW_SCISSOR_BR>().br_y);
|
||||
|
||||
@@ -1031,7 +1031,7 @@ void ProgressBar(float frac, float width, float height = 0,
|
||||
if (height == 0) {
|
||||
height = ImGui::GetTextLineHeightWithSpacing();
|
||||
}
|
||||
frac = xe::saturate(frac);
|
||||
frac = xe::saturate_unsigned(frac);
|
||||
|
||||
const auto fontAtlas = ImGui::GetIO().Fonts;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user