summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/rasterizer_cache.h44
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp3
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp46
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.h8
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp38
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.h7
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp3
7 files changed, 62 insertions, 87 deletions
diff --git a/src/video_core/rasterizer_cache.h b/src/video_core/rasterizer_cache.h
index 6de1597a2..22987751e 100644
--- a/src/video_core/rasterizer_cache.h
+++ b/src/video_core/rasterizer_cache.h
@@ -18,22 +18,14 @@
18 18
19class RasterizerCacheObject { 19class RasterizerCacheObject {
20public: 20public:
21 explicit RasterizerCacheObject(const u8* host_ptr) 21 explicit RasterizerCacheObject(const VAddr cpu_addr) : cpu_addr{cpu_addr} {}
22 : host_ptr{host_ptr}, cache_addr{ToCacheAddr(host_ptr)} {}
23 22
24 virtual ~RasterizerCacheObject(); 23 virtual ~RasterizerCacheObject();
25 24
26 CacheAddr GetCacheAddr() const { 25 VAddr GetCpuAddr() const {
27 return cache_addr; 26 return cpu_addr;
28 } 27 }
29 28
30 const u8* GetHostPtr() const {
31 return host_ptr;
32 }
33
34 /// Gets the address of the shader in guest memory, required for cache management
35 virtual VAddr GetCpuAddr() const = 0;
36
37 /// Gets the size of the shader in guest memory, required for cache management 29 /// Gets the size of the shader in guest memory, required for cache management
38 virtual std::size_t GetSizeInBytes() const = 0; 30 virtual std::size_t GetSizeInBytes() const = 0;
39 31
@@ -68,8 +60,7 @@ private:
68 bool is_registered{}; ///< Whether the object is currently registered with the cache 60 bool is_registered{}; ///< Whether the object is currently registered with the cache
69 bool is_dirty{}; ///< Whether the object is dirty (out of sync with guest memory) 61 bool is_dirty{}; ///< Whether the object is dirty (out of sync with guest memory)
70 u64 last_modified_ticks{}; ///< When the object was last modified, used for in-order flushing 62 u64 last_modified_ticks{}; ///< When the object was last modified, used for in-order flushing
71 const u8* host_ptr{}; ///< Pointer to the memory backing this cached region 63 VAddr cpu_addr{}; ///< Cpu address memory, unique from emulated virtual address space
72 CacheAddr cache_addr{}; ///< Cache address memory, unique from emulated virtual address space
73}; 64};
74 65
75template <class T> 66template <class T>
@@ -80,7 +71,7 @@ public:
80 explicit RasterizerCache(VideoCore::RasterizerInterface& rasterizer) : rasterizer{rasterizer} {} 71 explicit RasterizerCache(VideoCore::RasterizerInterface& rasterizer) : rasterizer{rasterizer} {}
81 72
82 /// Write any cached resources overlapping the specified region back to memory 73 /// Write any cached resources overlapping the specified region back to memory
83 void FlushRegion(CacheAddr addr, std::size_t size) { 74 void FlushRegion(VAddr addr, std::size_t size) {
84 std::lock_guard lock{mutex}; 75 std::lock_guard lock{mutex};
85 76
86 const auto& objects{GetSortedObjectsFromRegion(addr, size)}; 77 const auto& objects{GetSortedObjectsFromRegion(addr, size)};
@@ -90,7 +81,7 @@ public:
90 } 81 }
91 82
92 /// Mark the specified region as being invalidated 83 /// Mark the specified region as being invalidated
93 void InvalidateRegion(CacheAddr addr, u64 size) { 84 void InvalidateRegion(VAddr addr, u64 size) {
94 std::lock_guard lock{mutex}; 85 std::lock_guard lock{mutex};
95 86
96 const auto& objects{GetSortedObjectsFromRegion(addr, size)}; 87 const auto& objects{GetSortedObjectsFromRegion(addr, size)};
@@ -114,27 +105,20 @@ public:
114 105
115protected: 106protected:
116 /// Tries to get an object from the cache with the specified cache address 107 /// Tries to get an object from the cache with the specified cache address
117 T TryGet(CacheAddr addr) const { 108 T TryGet(VAddr addr) const {
118 const auto iter = map_cache.find(addr); 109 const auto iter = map_cache.find(addr);
119 if (iter != map_cache.end()) 110 if (iter != map_cache.end())
120 return iter->second; 111 return iter->second;
121 return nullptr; 112 return nullptr;
122 } 113 }
123 114
124 T TryGet(const void* addr) const {
125 const auto iter = map_cache.find(ToCacheAddr(addr));
126 if (iter != map_cache.end())
127 return iter->second;
128 return nullptr;
129 }
130
131 /// Register an object into the cache 115 /// Register an object into the cache
132 virtual void Register(const T& object) { 116 virtual void Register(const T& object) {
133 std::lock_guard lock{mutex}; 117 std::lock_guard lock{mutex};
134 118
135 object->SetIsRegistered(true); 119 object->SetIsRegistered(true);
136 interval_cache.add({GetInterval(object), ObjectSet{object}}); 120 interval_cache.add({GetInterval(object), ObjectSet{object}});
137 map_cache.insert({object->GetCacheAddr(), object}); 121 map_cache.insert({object->GetCpuAddr(), object});
138 rasterizer.UpdatePagesCachedCount(object->GetCpuAddr(), object->GetSizeInBytes(), 1); 122 rasterizer.UpdatePagesCachedCount(object->GetCpuAddr(), object->GetSizeInBytes(), 1);
139 } 123 }
140 124
@@ -144,7 +128,7 @@ protected:
144 128
145 object->SetIsRegistered(false); 129 object->SetIsRegistered(false);
146 rasterizer.UpdatePagesCachedCount(object->GetCpuAddr(), object->GetSizeInBytes(), -1); 130 rasterizer.UpdatePagesCachedCount(object->GetCpuAddr(), object->GetSizeInBytes(), -1);
147 const CacheAddr addr = object->GetCacheAddr(); 131 const VAddr addr = object->GetCpuAddr();
148 interval_cache.subtract({GetInterval(object), ObjectSet{object}}); 132 interval_cache.subtract({GetInterval(object), ObjectSet{object}});
149 map_cache.erase(addr); 133 map_cache.erase(addr);
150 } 134 }
@@ -173,7 +157,7 @@ protected:
173 157
174private: 158private:
175 /// Returns a list of cached objects from the specified memory region, ordered by access time 159 /// Returns a list of cached objects from the specified memory region, ordered by access time
176 std::vector<T> GetSortedObjectsFromRegion(CacheAddr addr, u64 size) { 160 std::vector<T> GetSortedObjectsFromRegion(VAddr addr, u64 size) {
177 if (size == 0) { 161 if (size == 0) {
178 return {}; 162 return {};
179 } 163 }
@@ -197,13 +181,13 @@ private:
197 } 181 }
198 182
199 using ObjectSet = std::set<T>; 183 using ObjectSet = std::set<T>;
200 using ObjectCache = std::unordered_map<CacheAddr, T>; 184 using ObjectCache = std::unordered_map<VAddr, T>;
201 using IntervalCache = boost::icl::interval_map<CacheAddr, ObjectSet>; 185 using IntervalCache = boost::icl::interval_map<VAddr, ObjectSet>;
202 using ObjectInterval = typename IntervalCache::interval_type; 186 using ObjectInterval = typename IntervalCache::interval_type;
203 187
204 static auto GetInterval(const T& object) { 188 static auto GetInterval(const T& object) {
205 return ObjectInterval::right_open(object->GetCacheAddr(), 189 return ObjectInterval::right_open(object->GetCpuAddr(),
206 object->GetCacheAddr() + object->GetSizeInBytes()); 190 object->GetCpuAddr() + object->GetSizeInBytes());
207 } 191 }
208 192
209 ObjectCache map_cache; 193 ObjectCache map_cache;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 1f603b668..93a6c72f8 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -671,9 +671,8 @@ void RasterizerOpenGL::InvalidateRegion(VAddr addr, u64 size) {
671 if (!addr || !size) { 671 if (!addr || !size) {
672 return; 672 return;
673 } 673 }
674 CacheAddr cache_addr = ToCacheAddr(system.Memory().GetPointer(addr));
675 texture_cache.InvalidateRegion(addr, size); 674 texture_cache.InvalidateRegion(addr, size);
676 shader_cache.InvalidateRegion(cache_addr, size); 675 shader_cache.InvalidateRegion(addr, size);
677 buffer_cache.InvalidateRegion(addr, size); 676 buffer_cache.InvalidateRegion(addr, size);
678 query_cache.InvalidateRegion(addr, size); 677 query_cache.InvalidateRegion(addr, size);
679} 678}
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 046ee55a5..6d2ff20f9 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -214,11 +214,11 @@ std::unordered_set<GLenum> GetSupportedFormats() {
214 214
215} // Anonymous namespace 215} // Anonymous namespace
216 216
217CachedShader::CachedShader(const u8* host_ptr, VAddr cpu_addr, std::size_t size_in_bytes, 217CachedShader::CachedShader(VAddr cpu_addr, std::size_t size_in_bytes,
218 std::shared_ptr<VideoCommon::Shader::Registry> registry, 218 std::shared_ptr<VideoCommon::Shader::Registry> registry,
219 ShaderEntries entries, std::shared_ptr<OGLProgram> program) 219 ShaderEntries entries, std::shared_ptr<OGLProgram> program)
220 : RasterizerCacheObject{host_ptr}, registry{std::move(registry)}, entries{std::move(entries)}, 220 : RasterizerCacheObject{cpu_addr}, registry{std::move(registry)}, entries{std::move(entries)},
221 cpu_addr{cpu_addr}, size_in_bytes{size_in_bytes}, program{std::move(program)} {} 221 size_in_bytes{size_in_bytes}, program{std::move(program)} {}
222 222
223CachedShader::~CachedShader() = default; 223CachedShader::~CachedShader() = default;
224 224
@@ -254,9 +254,8 @@ Shader CachedShader::CreateStageFromMemory(const ShaderParameters& params,
254 entry.bindless_samplers = registry->GetBindlessSamplers(); 254 entry.bindless_samplers = registry->GetBindlessSamplers();
255 params.disk_cache.SaveEntry(std::move(entry)); 255 params.disk_cache.SaveEntry(std::move(entry));
256 256
257 return std::shared_ptr<CachedShader>(new CachedShader(params.host_ptr, params.cpu_addr, 257 return std::shared_ptr<CachedShader>(new CachedShader(
258 size_in_bytes, std::move(registry), 258 params.cpu_addr, size_in_bytes, std::move(registry), MakeEntries(ir), std::move(program)));
259 MakeEntries(ir), std::move(program)));
260} 259}
261 260
262Shader CachedShader::CreateKernelFromMemory(const ShaderParameters& params, ProgramCode code) { 261Shader CachedShader::CreateKernelFromMemory(const ShaderParameters& params, ProgramCode code) {
@@ -279,17 +278,16 @@ Shader CachedShader::CreateKernelFromMemory(const ShaderParameters& params, Prog
279 entry.bindless_samplers = registry->GetBindlessSamplers(); 278 entry.bindless_samplers = registry->GetBindlessSamplers();
280 params.disk_cache.SaveEntry(std::move(entry)); 279 params.disk_cache.SaveEntry(std::move(entry));
281 280
282 return std::shared_ptr<CachedShader>(new CachedShader(params.host_ptr, params.cpu_addr, 281 return std::shared_ptr<CachedShader>(new CachedShader(
283 size_in_bytes, std::move(registry), 282 params.cpu_addr, size_in_bytes, std::move(registry), MakeEntries(ir), std::move(program)));
284 MakeEntries(ir), std::move(program)));
285} 283}
286 284
287Shader CachedShader::CreateFromCache(const ShaderParameters& params, 285Shader CachedShader::CreateFromCache(const ShaderParameters& params,
288 const PrecompiledShader& precompiled_shader, 286 const PrecompiledShader& precompiled_shader,
289 std::size_t size_in_bytes) { 287 std::size_t size_in_bytes) {
290 return std::shared_ptr<CachedShader>(new CachedShader( 288 return std::shared_ptr<CachedShader>(
291 params.host_ptr, params.cpu_addr, size_in_bytes, precompiled_shader.registry, 289 new CachedShader(params.cpu_addr, size_in_bytes, precompiled_shader.registry,
292 precompiled_shader.entries, precompiled_shader.program)); 290 precompiled_shader.entries, precompiled_shader.program));
293} 291}
294 292
295ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer, Core::System& system, 293ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer, Core::System& system,
@@ -449,12 +447,14 @@ Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
449 const GPUVAddr address{GetShaderAddress(system, program)}; 447 const GPUVAddr address{GetShaderAddress(system, program)};
450 448
451 // Look up shader in the cache based on address 449 // Look up shader in the cache based on address
452 const auto host_ptr{memory_manager.GetPointer(address)}; 450 const auto cpu_addr{memory_manager.GpuToCpuAddress(address)};
453 Shader shader{TryGet(host_ptr)}; 451 Shader shader{cpu_addr ? TryGet(*cpu_addr) : nullptr};
454 if (shader) { 452 if (shader) {
455 return last_shaders[static_cast<std::size_t>(program)] = shader; 453 return last_shaders[static_cast<std::size_t>(program)] = shader;
456 } 454 }
457 455
456 const auto host_ptr{memory_manager.GetPointer(address)};
457
458 // No shader found - create a new one 458 // No shader found - create a new one
459 ProgramCode code{GetShaderCode(memory_manager, address, host_ptr)}; 459 ProgramCode code{GetShaderCode(memory_manager, address, host_ptr)};
460 ProgramCode code_b; 460 ProgramCode code_b;
@@ -465,9 +465,9 @@ Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
465 465
466 const auto unique_identifier = GetUniqueIdentifier( 466 const auto unique_identifier = GetUniqueIdentifier(
467 GetShaderType(program), program == Maxwell::ShaderProgram::VertexA, code, code_b); 467 GetShaderType(program), program == Maxwell::ShaderProgram::VertexA, code, code_b);
468 const auto cpu_addr{*memory_manager.GpuToCpuAddress(address)}; 468
469 const ShaderParameters params{system, disk_cache, device, 469 const ShaderParameters params{system, disk_cache, device,
470 cpu_addr, host_ptr, unique_identifier}; 470 *cpu_addr, host_ptr, unique_identifier};
471 471
472 const auto found = runtime_cache.find(unique_identifier); 472 const auto found = runtime_cache.find(unique_identifier);
473 if (found == runtime_cache.end()) { 473 if (found == runtime_cache.end()) {
@@ -484,18 +484,20 @@ Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
484 484
485Shader ShaderCacheOpenGL::GetComputeKernel(GPUVAddr code_addr) { 485Shader ShaderCacheOpenGL::GetComputeKernel(GPUVAddr code_addr) {
486 auto& memory_manager{system.GPU().MemoryManager()}; 486 auto& memory_manager{system.GPU().MemoryManager()};
487 const auto host_ptr{memory_manager.GetPointer(code_addr)}; 487 const auto cpu_addr{memory_manager.GpuToCpuAddress(code_addr)};
488 auto kernel = TryGet(host_ptr); 488
489 auto kernel = cpu_addr ? TryGet(*cpu_addr) : nullptr;
489 if (kernel) { 490 if (kernel) {
490 return kernel; 491 return kernel;
491 } 492 }
492 493
494 const auto host_ptr{memory_manager.GetPointer(code_addr)};
493 // No kernel found, create a new one 495 // No kernel found, create a new one
494 auto code{GetShaderCode(memory_manager, code_addr, host_ptr)}; 496 auto code{GetShaderCode(memory_manager, code_addr, host_ptr)};
495 const auto unique_identifier{GetUniqueIdentifier(ShaderType::Compute, false, code)}; 497 const auto unique_identifier{GetUniqueIdentifier(ShaderType::Compute, false, code)};
496 const auto cpu_addr{*memory_manager.GpuToCpuAddress(code_addr)}; 498
497 const ShaderParameters params{system, disk_cache, device, 499 const ShaderParameters params{system, disk_cache, device,
498 cpu_addr, host_ptr, unique_identifier}; 500 *cpu_addr, host_ptr, unique_identifier};
499 501
500 const auto found = runtime_cache.find(unique_identifier); 502 const auto found = runtime_cache.find(unique_identifier);
501 if (found == runtime_cache.end()) { 503 if (found == runtime_cache.end()) {
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h
index 4935019fc..c836df5bd 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.h
+++ b/src/video_core/renderer_opengl/gl_shader_cache.h
@@ -65,11 +65,6 @@ public:
65 /// Gets the GL program handle for the shader 65 /// Gets the GL program handle for the shader
66 GLuint GetHandle() const; 66 GLuint GetHandle() const;
67 67
68 /// Returns the guest CPU address of the shader
69 VAddr GetCpuAddr() const override {
70 return cpu_addr;
71 }
72
73 /// Returns the size in bytes of the shader 68 /// Returns the size in bytes of the shader
74 std::size_t GetSizeInBytes() const override { 69 std::size_t GetSizeInBytes() const override {
75 return size_in_bytes; 70 return size_in_bytes;
@@ -90,13 +85,12 @@ public:
90 std::size_t size_in_bytes); 85 std::size_t size_in_bytes);
91 86
92private: 87private:
93 explicit CachedShader(const u8* host_ptr, VAddr cpu_addr, std::size_t size_in_bytes, 88 explicit CachedShader(VAddr cpu_addr, std::size_t size_in_bytes,
94 std::shared_ptr<VideoCommon::Shader::Registry> registry, 89 std::shared_ptr<VideoCommon::Shader::Registry> registry,
95 ShaderEntries entries, std::shared_ptr<OGLProgram> program); 90 ShaderEntries entries, std::shared_ptr<OGLProgram> program);
96 91
97 std::shared_ptr<VideoCommon::Shader::Registry> registry; 92 std::shared_ptr<VideoCommon::Shader::Registry> registry;
98 ShaderEntries entries; 93 ShaderEntries entries;
99 VAddr cpu_addr = 0;
100 std::size_t size_in_bytes = 0; 94 std::size_t size_in_bytes = 0;
101 std::shared_ptr<OGLProgram> program; 95 std::shared_ptr<OGLProgram> program;
102}; 96};
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index 557b9d662..c2a426aeb 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -158,11 +158,11 @@ u32 FillDescriptorLayout(const ShaderEntries& entries,
158} // Anonymous namespace 158} // Anonymous namespace
159 159
160CachedShader::CachedShader(Core::System& system, Tegra::Engines::ShaderType stage, 160CachedShader::CachedShader(Core::System& system, Tegra::Engines::ShaderType stage,
161 GPUVAddr gpu_addr, VAddr cpu_addr, u8* host_ptr, 161 GPUVAddr gpu_addr, VAddr cpu_addr, ProgramCode program_code,
162 ProgramCode program_code, u32 main_offset) 162 u32 main_offset)
163 : RasterizerCacheObject{host_ptr}, gpu_addr{gpu_addr}, cpu_addr{cpu_addr}, 163 : RasterizerCacheObject{cpu_addr}, gpu_addr{gpu_addr}, program_code{std::move(program_code)},
164 program_code{std::move(program_code)}, registry{stage, GetEngine(system, stage)}, 164 registry{stage, GetEngine(system, stage)}, shader_ir{this->program_code, main_offset,
165 shader_ir{this->program_code, main_offset, compiler_settings, registry}, 165 compiler_settings, registry},
166 entries{GenerateShaderEntries(shader_ir)} {} 166 entries{GenerateShaderEntries(shader_ir)} {}
167 167
168CachedShader::~CachedShader() = default; 168CachedShader::~CachedShader() = default;
@@ -201,19 +201,19 @@ std::array<Shader, Maxwell::MaxShaderProgram> VKPipelineCache::GetShaders() {
201 201
202 auto& memory_manager{system.GPU().MemoryManager()}; 202 auto& memory_manager{system.GPU().MemoryManager()};
203 const GPUVAddr program_addr{GetShaderAddress(system, program)}; 203 const GPUVAddr program_addr{GetShaderAddress(system, program)};
204 const auto host_ptr{memory_manager.GetPointer(program_addr)}; 204 const std::optional cpu_addr = memory_manager.GpuToCpuAddress(program_addr);
205 auto shader = TryGet(host_ptr); 205 ASSERT(cpu_addr);
206 auto shader = cpu_addr ? TryGet(*cpu_addr) : nullptr;
206 if (!shader) { 207 if (!shader) {
208 const auto host_ptr{memory_manager.GetPointer(program_addr)};
209
207 // No shader found - create a new one 210 // No shader found - create a new one
208 constexpr u32 stage_offset = 10; 211 constexpr u32 stage_offset = 10;
209 const auto stage = static_cast<Tegra::Engines::ShaderType>(index == 0 ? 0 : index - 1); 212 const auto stage = static_cast<Tegra::Engines::ShaderType>(index == 0 ? 0 : index - 1);
210 auto code = GetShaderCode(memory_manager, program_addr, host_ptr, false); 213 auto code = GetShaderCode(memory_manager, program_addr, host_ptr, false);
211 214
212 const std::optional cpu_addr = memory_manager.GpuToCpuAddress(program_addr);
213 ASSERT(cpu_addr);
214
215 shader = std::make_shared<CachedShader>(system, stage, program_addr, *cpu_addr, 215 shader = std::make_shared<CachedShader>(system, stage, program_addr, *cpu_addr,
216 host_ptr, std::move(code), stage_offset); 216 std::move(code), stage_offset);
217 Register(shader); 217 Register(shader);
218 } 218 }
219 shaders[index] = std::move(shader); 219 shaders[index] = std::move(shader);
@@ -253,18 +253,19 @@ VKComputePipeline& VKPipelineCache::GetComputePipeline(const ComputePipelineCach
253 253
254 auto& memory_manager = system.GPU().MemoryManager(); 254 auto& memory_manager = system.GPU().MemoryManager();
255 const auto program_addr = key.shader; 255 const auto program_addr = key.shader;
256 const auto host_ptr = memory_manager.GetPointer(program_addr);
257 256
258 auto shader = TryGet(host_ptr); 257 const auto cpu_addr = memory_manager.GpuToCpuAddress(program_addr);
258 ASSERT(cpu_addr);
259
260 auto shader = cpu_addr ? TryGet(*cpu_addr) : nullptr;
259 if (!shader) { 261 if (!shader) {
260 // No shader found - create a new one 262 // No shader found - create a new one
261 const auto cpu_addr = memory_manager.GpuToCpuAddress(program_addr); 263 const auto host_ptr = memory_manager.GetPointer(program_addr);
262 ASSERT(cpu_addr);
263 264
264 auto code = GetShaderCode(memory_manager, program_addr, host_ptr, true); 265 auto code = GetShaderCode(memory_manager, program_addr, host_ptr, true);
265 constexpr u32 kernel_main_offset = 0; 266 constexpr u32 kernel_main_offset = 0;
266 shader = std::make_shared<CachedShader>(system, Tegra::Engines::ShaderType::Compute, 267 shader = std::make_shared<CachedShader>(system, Tegra::Engines::ShaderType::Compute,
267 program_addr, *cpu_addr, host_ptr, std::move(code), 268 program_addr, *cpu_addr, std::move(code),
268 kernel_main_offset); 269 kernel_main_offset);
269 Register(shader); 270 Register(shader);
270 } 271 }
@@ -345,8 +346,9 @@ VKPipelineCache::DecompileShaders(const GraphicsPipelineCacheKey& key) {
345 } 346 }
346 347
347 const GPUVAddr gpu_addr = GetShaderAddress(system, program_enum); 348 const GPUVAddr gpu_addr = GetShaderAddress(system, program_enum);
348 const auto host_ptr = memory_manager.GetPointer(gpu_addr); 349 const auto cpu_addr = memory_manager.GpuToCpuAddress(gpu_addr);
349 const auto shader = TryGet(host_ptr); 350 ASSERT(cpu_addr);
351 const auto shader = TryGet(*cpu_addr);
350 ASSERT(shader); 352 ASSERT(shader);
351 353
352 const std::size_t stage = index == 0 ? 0 : index - 1; // Stage indices are 0 - 5 354 const std::size_t stage = index == 0 ? 0 : index - 1; // Stage indices are 0 - 5
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h
index c4c112290..27c01732f 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h
@@ -113,17 +113,13 @@ namespace Vulkan {
113class CachedShader final : public RasterizerCacheObject { 113class CachedShader final : public RasterizerCacheObject {
114public: 114public:
115 explicit CachedShader(Core::System& system, Tegra::Engines::ShaderType stage, GPUVAddr gpu_addr, 115 explicit CachedShader(Core::System& system, Tegra::Engines::ShaderType stage, GPUVAddr gpu_addr,
116 VAddr cpu_addr, u8* host_ptr, ProgramCode program_code, u32 main_offset); 116 VAddr cpu_addr, ProgramCode program_code, u32 main_offset);
117 ~CachedShader(); 117 ~CachedShader();
118 118
119 GPUVAddr GetGpuAddr() const { 119 GPUVAddr GetGpuAddr() const {
120 return gpu_addr; 120 return gpu_addr;
121 } 121 }
122 122
123 VAddr GetCpuAddr() const override {
124 return cpu_addr;
125 }
126
127 std::size_t GetSizeInBytes() const override { 123 std::size_t GetSizeInBytes() const override {
128 return program_code.size() * sizeof(u64); 124 return program_code.size() * sizeof(u64);
129 } 125 }
@@ -149,7 +145,6 @@ private:
149 Tegra::Engines::ShaderType stage); 145 Tegra::Engines::ShaderType stage);
150 146
151 GPUVAddr gpu_addr{}; 147 GPUVAddr gpu_addr{};
152 VAddr cpu_addr{};
153 ProgramCode program_code; 148 ProgramCode program_code;
154 VideoCommon::Shader::Registry registry; 149 VideoCommon::Shader::Registry registry;
155 VideoCommon::Shader::ShaderIR shader_ir; 150 VideoCommon::Shader::ShaderIR shader_ir;
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index 199533517..1466018fa 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -509,9 +509,8 @@ void RasterizerVulkan::InvalidateRegion(VAddr addr, u64 size) {
509 if (!addr || !size) { 509 if (!addr || !size) {
510 return; 510 return;
511 } 511 }
512 CacheAddr cache_addr = ToCacheAddr(system.Memory().GetPointer(addr));
513 texture_cache.InvalidateRegion(addr, size); 512 texture_cache.InvalidateRegion(addr, size);
514 pipeline_cache.InvalidateRegion(cache_addr, size); 513 pipeline_cache.InvalidateRegion(addr, size);
515 buffer_cache.InvalidateRegion(addr, size); 514 buffer_cache.InvalidateRegion(addr, size);
516 query_cache.InvalidateRegion(addr, size); 515 query_cache.InvalidateRegion(addr, size);
517} 516}