mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 08:05:46 -04:00
PGXP: Add geometry tolerance setting
This commit is contained in:
@ -446,6 +446,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
|
||||
si.SetBoolValue("GPU", "PGXPVertexCache", false);
|
||||
si.SetBoolValue("GPU", "PGXPCPU", false);
|
||||
si.SetBoolValue("GPU", "PGXPPreserveProjFP", false);
|
||||
si.SetFloatValue("GPU", "PGXPTolerance", -1.0f);
|
||||
|
||||
si.SetStringValue("Display", "CropMode", Settings::GetDisplayCropModeName(Settings::DEFAULT_DISPLAY_CROP_MODE));
|
||||
si.SetIntValue("Display", "ActiveStartOffset", 0);
|
||||
|
@ -718,13 +718,23 @@ PGXP_value* PGXP_GetCachedVertex(short sx, short sy)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static float TruncateVertexPosition(float p)
|
||||
static ALWAYS_INLINE_RELEASE float TruncateVertexPosition(float p)
|
||||
{
|
||||
const s32 int_part = static_cast<s32>(p);
|
||||
const float int_part_f = static_cast<float>(int_part);
|
||||
return static_cast<float>(static_cast<s16>(int_part << 5) >> 5) + (p - int_part_f);
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE_RELEASE bool IsWithinTolerance(float precise_x, float precise_y, int int_x, int int_y)
|
||||
{
|
||||
const float tolerance = g_settings.gpu_pgxp_tolerance;
|
||||
if (tolerance < 0.0f)
|
||||
return true;
|
||||
|
||||
return (std::abs(precise_x - static_cast<float>(int_x)) <= tolerance &&
|
||||
std::abs(precise_y - static_cast<float>(int_y)) <= tolerance);
|
||||
}
|
||||
|
||||
bool GetPreciseVertex(u32 addr, u32 value, int x, int y, int xOffs, int yOffs, float* out_x, float* out_y, float* out_w)
|
||||
{
|
||||
const PGXP_value* vert = ReadMem(addr);
|
||||
@ -734,9 +744,11 @@ bool GetPreciseVertex(u32 addr, u32 value, int x, int y, int xOffs, int yOffs, f
|
||||
*out_x = TruncateVertexPosition(vert->x) + static_cast<float>(xOffs);
|
||||
*out_y = TruncateVertexPosition(vert->y) + static_cast<float>(yOffs);
|
||||
*out_w = vert->z / 32768.0f;
|
||||
|
||||
// This value does not have a valid W coordinate
|
||||
return ((vert->flags & VALID_2) == VALID_2);
|
||||
if (IsWithinTolerance(*out_x, *out_y, x, y))
|
||||
{
|
||||
// check validity of z component
|
||||
return ((vert->flags & VALID_2) == VALID_2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -752,18 +764,20 @@ bool GetPreciseVertex(u32 addr, u32 value, int x, int y, int xOffs, int yOffs, f
|
||||
*out_x = TruncateVertexPosition(vert->x) + static_cast<float>(xOffs);
|
||||
*out_y = TruncateVertexPosition(vert->y) + static_cast<float>(yOffs);
|
||||
*out_w = vert->z / 32768.0f;
|
||||
return false; // iCB: Getting the wrong w component causes too great an error when using perspective correction
|
||||
// so disable it
|
||||
}
|
||||
else
|
||||
{
|
||||
// no valid value can be found anywhere, use the native PSX data
|
||||
*out_x = static_cast<float>(x);
|
||||
*out_y = static_cast<float>(y);
|
||||
*out_w = 1.0f;
|
||||
return false;
|
||||
|
||||
if (IsWithinTolerance(*out_x, *out_y, x, y))
|
||||
{
|
||||
return false; // iCB: Getting the wrong w component causes too great an error when using perspective correction
|
||||
// so disable it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// no valid value can be found anywhere, use the native PSX data
|
||||
*out_x = static_cast<float>(x);
|
||||
*out_y = static_cast<float>(y);
|
||||
*out_w = 1.0f;
|
||||
return false;
|
||||
}
|
||||
|
||||
// pgxp_cpu.c
|
||||
|
@ -158,6 +158,7 @@ void Settings::Load(SettingsInterface& si)
|
||||
gpu_pgxp_vertex_cache = si.GetBoolValue("GPU", "PGXPVertexCache", false);
|
||||
gpu_pgxp_cpu = si.GetBoolValue("GPU", "PGXPCPU", false);
|
||||
gpu_pgxp_preserve_proj_fp = si.GetBoolValue("GPU", "PGXPPreserveProjFP", false);
|
||||
gpu_pgxp_tolerance = si.GetFloatValue("GPU", "PGXPTolerance", -1.0f);
|
||||
|
||||
display_crop_mode =
|
||||
ParseDisplayCropMode(
|
||||
@ -290,6 +291,7 @@ void Settings::Save(SettingsInterface& si) const
|
||||
si.SetBoolValue("GPU", "PGXPVertexCache", gpu_pgxp_vertex_cache);
|
||||
si.SetBoolValue("GPU", "PGXPCPU", gpu_pgxp_cpu);
|
||||
si.SetBoolValue("GPU", "PGXPPreserveProjFP", gpu_pgxp_preserve_proj_fp);
|
||||
si.SetFloatValue("GPU", "PGXPTolerance", gpu_pgxp_tolerance);
|
||||
|
||||
si.SetStringValue("Display", "CropMode", GetDisplayCropModeName(display_crop_mode));
|
||||
si.SetIntValue("Display", "ActiveStartOffset", display_active_start_offset);
|
||||
|
@ -110,9 +110,9 @@ struct Settings
|
||||
bool gpu_pgxp_cpu = false;
|
||||
bool gpu_pgxp_preserve_proj_fp = false;
|
||||
DisplayCropMode display_crop_mode = DisplayCropMode::None;
|
||||
DisplayAspectRatio display_aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
s16 display_active_start_offset = 0;
|
||||
s16 display_active_end_offset = 0;
|
||||
DisplayAspectRatio display_aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
bool display_force_4_3_for_24bit = false;
|
||||
bool gpu_24bit_chroma_smoothing = false;
|
||||
bool display_linear_filtering = true;
|
||||
@ -125,6 +125,7 @@ struct Settings
|
||||
bool display_show_resolution = false;
|
||||
bool video_sync_enabled = true;
|
||||
float display_max_fps = 0.0f;
|
||||
float gpu_pgxp_tolerance = -1.0f;
|
||||
|
||||
bool cdrom_read_thread = true;
|
||||
bool cdrom_region_check = true;
|
||||
|
Reference in New Issue
Block a user