summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-03-28 21:55:47 -0300
committerGravatar ameerj2021-07-22 21:51:25 -0400
commit3c758d9b538e957a20ea6db136741ad2bd16406d (patch)
treea1ef655bba3fd5aca5ab18ddaef3f312d1850b26 /src
parentshader: Fix ISCADD logic for PO/CC (diff)
downloadyuzu-3c758d9b538e957a20ea6db136741ad2bd16406d.tar.gz
yuzu-3c758d9b538e957a20ea6db136741ad2bd16406d.tar.xz
yuzu-3c758d9b538e957a20ea6db136741ad2bd16406d.zip
vk_pipeline_cache: Fix size hashing of shaders
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index 0d6a32bfd..8b2816c13 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -68,7 +68,7 @@ public:
68 } 68 }
69 cached_lowest = start_address; 69 cached_lowest = start_address;
70 cached_highest = start_address + static_cast<u32>(*size); 70 cached_highest = start_address + static_cast<u32>(*size);
71 return Common::CityHash128(reinterpret_cast<const char*>(code.data()), code.size()); 71 return Common::CityHash128(reinterpret_cast<const char*>(code.data()), *size);
72 } 72 }
73 73
74 void SetCachedSize(size_t size_bytes) { 74 void SetCachedSize(size_t size_bytes) {
@@ -126,12 +126,10 @@ public:
126 .write(reinterpret_cast<const char*>(&read_highest), sizeof(read_highest)) 126 .write(reinterpret_cast<const char*>(&read_highest), sizeof(read_highest))
127 .write(reinterpret_cast<const char*>(&stage), sizeof(stage)) 127 .write(reinterpret_cast<const char*>(&stage), sizeof(stage))
128 .write(data.get(), code_size); 128 .write(data.get(), code_size);
129 file.flush();
130 for (const auto [key, type] : texture_types) { 129 for (const auto [key, type] : texture_types) {
131 file.write(reinterpret_cast<const char*>(&key), sizeof(key)) 130 file.write(reinterpret_cast<const char*>(&key), sizeof(key))
132 .write(reinterpret_cast<const char*>(&type), sizeof(type)); 131 .write(reinterpret_cast<const char*>(&type), sizeof(type));
133 } 132 }
134 file.flush();
135 if (stage == Shader::Stage::Compute) { 133 if (stage == Shader::Stage::Compute) {
136 const std::array<u32, 3> workgroup_size{WorkgroupSize()}; 134 const std::array<u32, 3> workgroup_size{WorkgroupSize()};
137 const u32 shared_memory_size{SharedMemorySize()}; 135 const u32 shared_memory_size{SharedMemorySize()};
@@ -141,7 +139,6 @@ public:
141 } else { 139 } else {
142 file.write(reinterpret_cast<const char*>(&sph), sizeof(sph)); 140 file.write(reinterpret_cast<const char*>(&sph), sizeof(sph));
143 } 141 }
144 file.flush();
145 } 142 }
146 143
147protected: 144protected:
@@ -161,10 +158,10 @@ protected:
161 code.resize(size / INST_SIZE); 158 code.resize(size / INST_SIZE);
162 u64* const data = code.data() + offset / INST_SIZE; 159 u64* const data = code.data() + offset / INST_SIZE;
163 gpu_memory->ReadBlock(guest_addr, data, BLOCK_SIZE); 160 gpu_memory->ReadBlock(guest_addr, data, BLOCK_SIZE);
164 for (size_t i = 0; i < BLOCK_SIZE; i += INST_SIZE) { 161 for (size_t index = 0; index < BLOCK_SIZE; index += INST_SIZE) {
165 const u64 inst = data[i / INST_SIZE]; 162 const u64 inst = data[index / INST_SIZE];
166 if (inst == SELF_BRANCH_A || inst == SELF_BRANCH_B) { 163 if (inst == SELF_BRANCH_A || inst == SELF_BRANCH_B) {
167 return offset + i; 164 return offset + index;
168 } 165 }
169 } 166 }
170 guest_addr += BLOCK_SIZE; 167 guest_addr += BLOCK_SIZE;
@@ -751,7 +748,7 @@ GraphicsPipeline PipelineCache::CreateGraphicsPipeline() {
751 continue; 748 continue;
752 } 749 }
753 const auto program{static_cast<Maxwell::ShaderProgram>(index)}; 750 const auto program{static_cast<Maxwell::ShaderProgram>(index)};
754 GraphicsEnvironment& env{graphics_envs[index]}; 751 auto& env{graphics_envs[index]};
755 const u32 start_address{maxwell3d.regs.shader_config[index].offset}; 752 const u32 start_address{maxwell3d.regs.shader_config[index].offset};
756 env = GraphicsEnvironment{maxwell3d, gpu_memory, program, base_addr, start_address}; 753 env = GraphicsEnvironment{maxwell3d, gpu_memory, program, base_addr, start_address};
757 env.SetCachedSize(shader_infos[index]->size_bytes); 754 env.SetCachedSize(shader_infos[index]->size_bytes);
@@ -771,6 +768,8 @@ ComputePipeline PipelineCache::CreateComputePipeline(const ComputePipelineCacheK
771 const GPUVAddr program_base{kepler_compute.regs.code_loc.Address()}; 768 const GPUVAddr program_base{kepler_compute.regs.code_loc.Address()};
772 const auto& qmd{kepler_compute.launch_description}; 769 const auto& qmd{kepler_compute.launch_description};
773 ComputeEnvironment env{kepler_compute, gpu_memory, program_base, qmd.program_start}; 770 ComputeEnvironment env{kepler_compute, gpu_memory, program_base, qmd.program_start};
771 env.SetCachedSize(shader->size_bytes);
772
774 main_pools.ReleaseContents(); 773 main_pools.ReleaseContents();
775 ComputePipeline pipeline{CreateComputePipeline(main_pools, key, env)}; 774 ComputePipeline pipeline{CreateComputePipeline(main_pools, key, env)};
776 if (!pipeline_cache_filename.empty()) { 775 if (!pipeline_cache_filename.empty()) {