GPU/HW: Add quad line detection (Wild Arms 2)

This commit is contained in:
Stenzek
2024-03-02 15:50:46 +10:00
parent 250fb56838
commit 713d396a7e
12 changed files with 395 additions and 64 deletions

View File

@ -33,7 +33,7 @@ namespace GameDatabase {
enum : u32
{
GAME_DATABASE_CACHE_SIGNATURE = 0x45434C48,
GAME_DATABASE_CACHE_VERSION = 6,
GAME_DATABASE_CACHE_VERSION = 7,
};
static Entry* GetMutableEntry(const std::string_view& serial);
@ -184,6 +184,31 @@ static std::optional<T> GetOptionalTFromObject(const ryml::ConstNodeRef& object,
return ret;
}
template<typename T>
static std::optional<T> ParseOptionalTFromObject(const ryml::ConstNodeRef& object, std::string_view key,
std::optional<T> (*from_string_function)(const char* str))
{
std::optional<T> ret;
const ryml::ConstNodeRef member = object.find_child(to_csubstr(key));
if (member.valid())
{
const c4::csubstr val = member.val();
if (!val.empty())
{
ret = from_string_function(TinyString(to_stringview(val)));
if (!ret.has_value())
Log_ErrorFmt("Unknown value for {}: {}", key, to_stringview(val));
}
else
{
Log_ErrorFmt("Unexpected empty value in {}", key);
}
}
return ret;
}
void GameDatabase::EnsureLoaded()
{
if (s_loaded)
@ -335,6 +360,8 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
settings.gpu_pgxp_tolerance = gpu_pgxp_tolerance.value();
if (gpu_pgxp_depth_threshold.has_value())
settings.SetPGXPDepthClearThreshold(gpu_pgxp_depth_threshold.value());
if (gpu_line_detect_mode.has_value())
settings.gpu_line_detect_mode = gpu_line_detect_mode.value();
if (HasTrait(Trait::ForceInterpreter))
{
@ -713,6 +740,7 @@ bool GameDatabase::LoadFromCache()
!ReadOptionalFromStream(stream.get(), &entry.gpu_max_run_ahead) ||
!ReadOptionalFromStream(stream.get(), &entry.gpu_pgxp_tolerance) ||
!ReadOptionalFromStream(stream.get(), &entry.gpu_pgxp_depth_threshold) ||
!ReadOptionalFromStream(stream.get(), &entry.gpu_line_detect_mode) ||
!stream->ReadSizePrefixedString(&entry.disc_set_name) || !stream->ReadU32(&num_disc_set_serials))
{
Log_DevPrintf("Cache entry is corrupted.");
@ -811,6 +839,7 @@ bool GameDatabase::SaveToCache()
result = result && WriteOptionalToStream(stream.get(), entry.gpu_max_run_ahead);
result = result && WriteOptionalToStream(stream.get(), entry.gpu_pgxp_tolerance);
result = result && WriteOptionalToStream(stream.get(), entry.gpu_pgxp_depth_threshold);
result = result && WriteOptionalToStream(stream.get(), entry.gpu_line_detect_mode);
result = result && stream->WriteSizePrefixedString(entry.disc_set_name);
result = result && stream->WriteU32(static_cast<u32>(entry.disc_set_serials.size()));
@ -1019,6 +1048,8 @@ bool GameDatabase::ParseYamlEntry(Entry* entry, const ryml::ConstNodeRef& value)
entry->gpu_max_run_ahead = GetOptionalTFromObject<u32>(settings, "gpuMaxRunAhead");
entry->gpu_pgxp_tolerance = GetOptionalTFromObject<float>(settings, "gpuPGXPTolerance");
entry->gpu_pgxp_depth_threshold = GetOptionalTFromObject<float>(settings, "gpuPGXPDepthThreshold");
entry->gpu_line_detect_mode =
ParseOptionalTFromObject<GPULineDetectMode>(settings, "gpuLineDetectMode", &Settings::ParseLineDetectModeName);
}
if (const ryml::ConstNodeRef disc_set = value.find_child("discSet"); disc_set.valid() && disc_set.has_children())