rpx ModuleMatches

This commit is contained in:
Luminyx 2026-02-07 03:51:32 -05:00
parent b072a7e9fc
commit 8a4c99cd1d
No known key found for this signature in database
GPG Key ID: C590EEF718016830
8 changed files with 46 additions and 57 deletions

View File

@ -328,7 +328,7 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules)
}
m_title_ids = ParseTitleIds(rules, "titleIds");
if(m_title_ids.empty() && !m_universal)
if(m_title_ids.empty())
throw std::exception();
auto option_fsPriority = rules.FindOption("fsPriority");
@ -532,9 +532,6 @@ std::string GraphicPack2::GetNormalizedPathString() const
bool GraphicPack2::ContainsTitleId(uint64_t title_id) const
{
if (m_universal)
return true;
const auto it = std::find_if(m_title_ids.begin(), m_title_ids.end(), [title_id](uint64 id) { return id == title_id; });
return it != m_title_ids.end();
}
@ -1191,7 +1188,7 @@ std::vector<GraphicPack2::PresetPtr> GraphicPack2::GetActivePresets() const
return result;
}
std::vector<uint64> GraphicPack2::ParseTitleIds(IniParser& rules, const char* option_name)
std::vector<uint64> GraphicPack2::ParseTitleIds(IniParser& rules, const char* option_name) const
{
std::vector<uint64> result;
@ -1201,13 +1198,6 @@ std::vector<uint64> GraphicPack2::ParseTitleIds(IniParser& rules, const char* op
for (auto& token : TokenizeView(*option_text, ','))
{
if (token == "*")
{
m_universal = true;
result.clear();
break;
}
try
{
result.emplace_back(ConvertString<uint64>(token, 16));

View File

@ -109,7 +109,6 @@ public:
bool Reload();
bool HasName() const { return !m_name.empty(); }
bool IsUniversal() const { return m_universal; }
const std::string& GetName() const { return m_name.empty() ? m_virtualPath : m_name; }
const std::string& GetVirtualPath() const { return m_virtualPath; } // returns the path in the gfx tree hierarchy
@ -232,7 +231,6 @@ private:
bool m_activated = false; // set if the graphic pack is currently used by the running game
std::vector<uint64_t> m_title_ids;
bool m_patchedFilesLoaded = false; // set to true once patched files are loaded
bool m_universal = false; // set if this pack applies to every title id
sint32 m_vsync_frequency = -1;
sint32 m_fs_priority = 100;
@ -260,7 +258,7 @@ private:
std::unordered_map<std::string, PresetVar> ParsePresetVars(IniParser& rules) const;
std::vector<uint64> ParseTitleIds(IniParser& rules, const char* option_name);
std::vector<uint64> ParseTitleIds(IniParser& rules, const char* option_name) const;
CustomShader LoadShader(const fs::path& path, uint64 shader_base_hash, uint64 shader_aux_hash, GP_SHADER_TYPE shader_type, bool isMetalShader) const;
void ApplyShaderPresets(std::string& shader_source) const;

View File

@ -135,13 +135,7 @@ void GraphicPack2::LoadPatchFiles()
void GraphicPack2::EnablePatches()
{
std::lock_guard<std::recursive_mutex> lock(mtx_patches);
if (m_universal) // universal gp only applies to the rpx
{
ApplyPatchesForModule(list_modules[0]);
return;
}
std::lock_guard<std::recursive_mutex> lock(mtx_patches);
for (auto& itr : list_modules)
ApplyPatchesForModule(itr);
}
@ -178,7 +172,7 @@ void GraphicPack2::ApplyPatchesForModule(const RPLModule* rpl)
std::vector<PatchGroup*> list_groups;
for (auto itr : list_patchGroups)
{
if (m_universal || itr->matchesCRC(rpl->patchCRC))
if (itr->matchesCRC(rpl->patchCRC) || (itr->m_isRpxOnlyTarget && rpl->fileInfo.flags & 2))
list_groups.emplace_back(itr);
}
// apply all groups at once
@ -194,7 +188,7 @@ void GraphicPack2::RevertPatchesForModule(const RPLModule* rpl)
std::vector<PatchGroup*> list_groups;
for (auto itr : list_patchGroups)
{
if (m_universal || itr->matchesCRC(rpl->patchCRC))
if (itr->matchesCRC(rpl->patchCRC) || (itr->m_isRpxOnlyTarget && rpl->fileInfo.flags & 2))
list_groups.emplace_back(itr);
}
// undo all groups at once

View File

@ -260,4 +260,5 @@ private:
uint32 codeCaveSize;
MEMPTR<void> codeCaveMem;
bool m_isApplied{};
bool m_isRpxOnlyTarget{};
};

View File

@ -41,7 +41,7 @@ void GraphicPack2::CancelParsingPatches()
void GraphicPack2::AddPatchGroup(PatchGroup* group)
{
if (group->list_moduleMatches.empty() && !m_universal)
if (group->list_moduleMatches.empty() && !group->m_isRpxOnlyTarget)
{
LogPatchesSyntaxError(-1, fmt::format("Group \"{}\" has no moduleMatches definition", group->name));
CancelParsingPatches();
@ -347,6 +347,12 @@ bool GraphicPack2::ParseCemuPatchesTxtInternal(MemStreamReader& patchesStream)
// read the checksums
while (true)
{
if (parser.matchWordI("rpx"))
{
currentGroup->m_isRpxOnlyTarget = true;
break;
}
uint32 checksum = 0;
if (parser.parseU32(checksum) == false)
{

View File

@ -267,6 +267,7 @@ bool RPLLoader_ProcessHeaders(std::string_view moduleName, uint8* rplData, uint3
rplLoaderContext->fileInfo.tlsModuleIndex = fileInfoPtr->tlsModuleIndex;
rplLoaderContext->fileInfo.sdataBase1 = fileInfoPtr->sdataBase1;
rplLoaderContext->fileInfo.sdataBase2 = fileInfoPtr->sdataBase2;
rplLoaderContext->fileInfo.flags = fileInfoPtr->flags;
// init section address table
rplLoaderContext->sectionAddressTable2.resize(sectionCount);

View File

@ -113,7 +113,7 @@ typedef struct
/* +0x28 */ uint32be sdataBase2;
/* +0x2C */ uint32be ukn2C;
/* +0x30 */ uint32be ukn30;
/* +0x34 */ uint32be ukn34;
/* +0x34 */ uint32be flags;
/* +0x38 */ uint32be ukn38;
/* +0x3C */ uint32be ukn3C;
/* +0x40 */ uint32be minimumToolkitVersion;
@ -198,6 +198,8 @@ struct RPLModule
uint32 sdataBase1;
uint32 sdataBase2;
uint32 flags;
}fileInfo;
// parsed CRC
std::vector<uint32> crcTable;

View File

@ -43,47 +43,44 @@ void GraphicPacksWindow2::FillGraphicPackList() const
for(auto& p : graphic_packs)
{
if (!p->IsUniversal())
// filter graphic packs by given title id
if (m_filter_installed_games && !m_installed_games.empty())
{
// filter graphic packs by given title id
if (m_filter_installed_games && !m_installed_games.empty())
bool found = false;
for (uint64 titleId : p->GetTitleIds())
{
if (std::find(m_installed_games.cbegin(), m_installed_games.cend(), titleId) != m_installed_games.cend())
{
found = true;
break;
}
}
if (!found)
continue;
}
// filter graphic packs by given title id
if(has_filter)
{
bool found = false;
if (boost::icontains(p->GetVirtualPath(), m_filter))
found = true;
else
{
bool found = false;
for (uint64 titleId : p->GetTitleIds())
{
if (std::find(m_installed_games.cbegin(), m_installed_games.cend(), titleId) != m_installed_games.cend())
if (boost::icontains(fmt::format("{:x}", titleId), m_filter))
{
found = true;
break;
}
}
if (!found)
continue;
}
// filter graphic packs by given title id
if(has_filter)
{
bool found = false;
if (boost::icontains(p->GetVirtualPath(), m_filter))
found = true;
else
{
for (uint64 titleId : p->GetTitleIds())
{
if (boost::icontains(fmt::format("{:x}", titleId), m_filter))
{
found = true;
break;
}
}
}
if (!found)
continue;
}
if (!found)
continue;
}
const auto& path = p->GetVirtualPath();