mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-29 16:51:20 +00:00
shader: memoize the tessellation layout per LS/HS pair and VGT configuration
This commit is contained in:
1 parent
f3e01aaf1e
commit
c715891242
1 file changed
+14
-1
@@ -47,6 +47,8 @@ struct ShaderMapEntry {
|
|||||||
|
|
||||||
static std::unique_ptr<std::unordered_map<uint64_t, ShaderMapEntry>> g_shader_map;
|
static std::unique_ptr<std::unordered_map<uint64_t, ShaderMapEntry>> g_shader_map;
|
||||||
static std::mutex g_shader_map_mutex;
|
static std::mutex g_shader_map_mutex;
|
||||||
|
static std::unordered_map<uint64_t, ShaderTessellationInputInfo> g_tess_layouts;
|
||||||
|
static std::mutex g_tess_layouts_mutex;
|
||||||
|
|
||||||
void ShaderInit() {
|
void ShaderInit() {
|
||||||
EXIT_IF(g_shader_map != nullptr);
|
EXIT_IF(g_shader_map != nullptr);
|
||||||
@@ -652,7 +654,18 @@ PrepareTessellationPrograms(const HW::VertexShaderInfo& regs, const HW::Context&
|
|||||||
};
|
};
|
||||||
EXIT_IF(tess.input_control_points == 0 || tess.input_control_points > 32 ||
|
EXIT_IF(tess.input_control_points == 0 || tess.input_control_points > 32 ||
|
||||||
tess.output_control_points == 0 || tess.output_control_points > 32);
|
tess.output_control_points == 0 || tess.output_control_points > 32);
|
||||||
ShaderRecompiler::AnalyzeTessellationPrograms(params[0].code, params[1].code, tess);
|
// Reflection decodes both programs; the key also covers the VGT fields cached in tess.
|
||||||
|
const uint64_t key[] = {local_hash, control_hash,
|
||||||
|
uint64_t {sh.m_vgtLsHsConfig & 0xfff00u} << 32u | sh.m_vgtTfParam};
|
||||||
|
{
|
||||||
|
std::scoped_lock lock(g_tess_layouts_mutex);
|
||||||
|
auto [entry, inserted] = g_tess_layouts.try_emplace(XXH3_64bits(key, sizeof(key)), tess);
|
||||||
|
if (inserted) {
|
||||||
|
ShaderRecompiler::AnalyzeTessellationPrograms(params[0].code, params[1].code,
|
||||||
|
entry->second);
|
||||||
|
}
|
||||||
|
tess = entry->second;
|
||||||
|
}
|
||||||
for (auto& stage: input_info) {
|
for (auto& stage: input_info) {
|
||||||
stage.tess = tess;
|
stage.tess = tess;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user