aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/shader_cache.cpp
diff options
context:
space:
mode:
authorkraibse <33869366+kraibse@users.noreply.github.com>2026-11-01 03:20:42 +0100
committerkraibse <33869366+kraibse@users.noreply.github.com>2026-11-02 00:11:25 +0100
commit10e70639058b9adc4f7fc77e11982bb834fce86b (patch)
treedbf3bb3e3037f3bff66a9fcafc0bf03785e35871 /src/video_core/shader_cache.cpp
parentcce6d44af23f08a7287a66d745fec34e38c9eb25 (diff)
nx2: capture and lower native shader programs once
Native programs were captured and lowered when their ShaderInfo was made and again for every environment built for their pipelines. The ShaderInfo now keeps the lowered code and the environments adopt it. Capture also reads a 4 KiB page at a time instead of flushing caches per instruction, and cached native programs fold bank 1 reads like live ones. Ported from Wael3rd/Eglantine-MKW (0ae093058e, 65a6aa877a, df076133c4). Assisted-by: Claude Sonnet 5.5 (porting the fixes) (cherry picked from commit 3af11ac401ad3061c183281d8c98c16c1d6da456)
Diffstat (limited to 'src/video_core/shader_cache.cpp')
-rw-r--r--src/video_core/shader_cache.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/video_core/shader_cache.cpp b/src/video_core/shader_cache.cpp
index f03df6bac5..5faed0dba9 100644
--- a/src/video_core/shader_cache.cpp
+++ b/src/video_core/shader_cache.cpp
@@ -112,7 +112,8 @@ bool ShaderCache::RefreshStages(std::array<u64, 6>& unique_hashes) try {
if (!shader_info) {
const u32 start_address{native ? 0 : shader_config.offset};
try {
- // Native programs are lowered while the environment is built.
+ // Native programs are lowered while the environment is built (once: the
+ // ShaderInfo keeps the result for the pipeline's environments).
RethrowIfRejected(*cpu_shader_addr);
GraphicsEnvironment env{*maxwell3d, *gpu_memory, program, native ? shader_addr : base_addr, start_address};
shader_info = MakeShaderInfo(env, *cpu_shader_addr);
@@ -229,7 +230,8 @@ void ShaderCache::GetGraphicsEnvironments(GraphicsEnvironments& result,
const GPUVAddr address = native
? (static_cast<u64>(config.reserved[0] & 0xff) << 32) | config.reserved[1]
: base_addr;
- env = GraphicsEnvironment{*maxwell3d, *gpu_memory, program, address, start_address};
+ env = GraphicsEnvironment{*maxwell3d, *gpu_memory, program, address, start_address,
+ shader_infos[index]->lowered_native};
env.SetCachedSize(shader_infos[index]->size_bytes);
result.env_ptrs[env_index++] = &env;
}
@@ -369,6 +371,7 @@ const ShaderInfo* ShaderCache::MakeShaderInfo(GenericEnvironment& env, VAddr cpu
info->unique_hash = env.CalculateHash();
info->size_bytes = env.ReadSizeBytes();
}
+ info->lowered_native = env.LoweredNative();
const size_t size_bytes{env.SourceSizeBytes() ? env.SourceSizeBytes() : info->size_bytes};
const ShaderInfo* const result{info.get()};
Register(std::move(info), cpu_addr, size_bytes);