summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar ameerj2020-07-30 15:41:11 -0400
committerGravatar ameerj2020-08-16 12:02:22 -0400
commit4539073ce1d8fd6df03263e826d3805b4909e055 (patch)
treed0ed30c327c5b6da9c6d6c8ba256803167f00de2 /src/video_core/renderer_vulkan
parentVk Async pipeline compilation (diff)
downloadyuzu-4539073ce1d8fd6df03263e826d3805b4909e055.tar.gz
yuzu-4539073ce1d8fd6df03263e826d3805b4909e055.tar.xz
yuzu-4539073ce1d8fd6df03263e826d3805b4909e055.zip
Address feedback. Bruteforce delete duplicates
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp16
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.h19
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp18
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.h2
5 files changed, 38 insertions, 19 deletions
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h
index 39c73a139..d50bd347c 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h
@@ -54,7 +54,7 @@ public:
54 return renderpass; 54 return renderpass;
55 } 55 }
56 56
57 const GraphicsPipelineCacheKey& GetCacheKey() { 57 const GraphicsPipelineCacheKey& GetCacheKey() const {
58 return m_key; 58 return m_key;
59 } 59 }
60 60
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index 45d4dcb8c..a7ce621ca 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -205,20 +205,20 @@ std::array<Shader*, Maxwell::MaxShaderProgram> VKPipelineCache::GetShaders() {
205 return last_shaders = shaders; 205 return last_shaders = shaders;
206} 206}
207 207
208VKGraphicsPipeline& VKPipelineCache::GetGraphicsPipeline( 208VKGraphicsPipeline* VKPipelineCache::GetGraphicsPipeline(
209 const GraphicsPipelineCacheKey& key, VideoCommon::Shader::AsyncShaders& async_shaders) { 209 const GraphicsPipelineCacheKey& key, VideoCommon::Shader::AsyncShaders& async_shaders) {
210 MICROPROFILE_SCOPE(Vulkan_PipelineCache); 210 MICROPROFILE_SCOPE(Vulkan_PipelineCache);
211 211
212 if (last_graphics_pipeline && last_graphics_key == key) { 212 if (last_graphics_pipeline && last_graphics_key == key) {
213 return *last_graphics_pipeline; 213 return last_graphics_pipeline;
214 } 214 }
215 last_graphics_key = key; 215 last_graphics_key = key;
216 216
217 if (device.UseAsynchronousShaders()) { 217 if (device.UseAsynchronousShaders()) {
218 auto work = async_shaders.GetCompletedWork(); 218 auto work = async_shaders.GetCompletedWork();
219 for (std::size_t i = 0; i < work.size(); ++i) { 219 for (auto& w : work) {
220 auto& entry = graphics_cache.at(work[i].pipeline->GetCacheKey()); 220 auto& entry = graphics_cache.at(w.pipeline->GetCacheKey());
221 entry = std::move(work[i].pipeline); 221 entry = std::move(w.pipeline);
222 } 222 }
223 const auto [pair, is_cache_miss] = graphics_cache.try_emplace(key); 223 const auto [pair, is_cache_miss] = graphics_cache.try_emplace(key);
224 if (is_cache_miss) { 224 if (is_cache_miss) {
@@ -227,7 +227,8 @@ VKGraphicsPipeline& VKPipelineCache::GetGraphicsPipeline(
227 async_shaders.QueueVulkanShader(this, bindings, program, key.renderpass_params, 227 async_shaders.QueueVulkanShader(this, bindings, program, key.renderpass_params,
228 key.padding, key.shaders, key.fixed_state); 228 key.padding, key.shaders, key.fixed_state);
229 } 229 }
230 return *(last_graphics_pipeline = graphics_cache.at(key).get()); 230 last_graphics_pipeline = graphics_cache.at(key).get();
231 return last_graphics_pipeline;
231 } 232 }
232 233
233 const auto [pair, is_cache_miss] = graphics_cache.try_emplace(key); 234 const auto [pair, is_cache_miss] = graphics_cache.try_emplace(key);
@@ -239,7 +240,8 @@ VKGraphicsPipeline& VKPipelineCache::GetGraphicsPipeline(
239 update_descriptor_queue, renderpass_cache, key, 240 update_descriptor_queue, renderpass_cache, key,
240 bindings, program); 241 bindings, program);
241 } 242 }
242 return *(last_graphics_pipeline = entry.get()); 243 last_graphics_pipeline = entry.get();
244 return last_graphics_pipeline;
243} 245}
244 246
245VKComputePipeline& VKPipelineCache::GetComputePipeline(const ComputePipelineCacheKey& key) { 247VKComputePipeline& VKPipelineCache::GetComputePipeline(const ComputePipelineCacheKey& key) {
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h
index c70da6da4..404f2b3f7 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h
@@ -153,31 +153,46 @@ public:
153 153
154 std::array<Shader*, Maxwell::MaxShaderProgram> GetShaders(); 154 std::array<Shader*, Maxwell::MaxShaderProgram> GetShaders();
155 155
156 VKGraphicsPipeline& GetGraphicsPipeline(const GraphicsPipelineCacheKey& key, 156 VKGraphicsPipeline* GetGraphicsPipeline(const GraphicsPipelineCacheKey& key,
157 VideoCommon::Shader::AsyncShaders& async_shaders); 157 VideoCommon::Shader::AsyncShaders& async_shaders);
158 158
159 VKComputePipeline& GetComputePipeline(const ComputePipelineCacheKey& key); 159 VKComputePipeline& GetComputePipeline(const ComputePipelineCacheKey& key);
160 160
161 const VKDevice& GetDevice() { 161 const VKDevice& GetDevice() const {
162 return device; 162 return device;
163 } 163 }
164 164
165 VKScheduler& GetScheduler() { 165 VKScheduler& GetScheduler() {
166 return scheduler; 166 return scheduler;
167 } 167 }
168 const VKScheduler& GetScheduler() const {
169 return scheduler;
170 }
168 171
169 VKDescriptorPool& GetDescriptorPool() { 172 VKDescriptorPool& GetDescriptorPool() {
170 return descriptor_pool; 173 return descriptor_pool;
171 } 174 }
172 175
176 const VKDescriptorPool& GetDescriptorPool() const {
177 return descriptor_pool;
178 }
179
173 VKUpdateDescriptorQueue& GetUpdateDescriptorQueue() { 180 VKUpdateDescriptorQueue& GetUpdateDescriptorQueue() {
174 return update_descriptor_queue; 181 return update_descriptor_queue;
175 } 182 }
176 183
184 const VKUpdateDescriptorQueue& GetUpdateDescriptorQueue() const {
185 return update_descriptor_queue;
186 }
187
177 VKRenderPassCache& GetRenderpassCache() { 188 VKRenderPassCache& GetRenderpassCache() {
178 return renderpass_cache; 189 return renderpass_cache;
179 } 190 }
180 191
192 const VKRenderPassCache& GetRenderpassCache() const {
193 return renderpass_cache;
194 }
195
181protected: 196protected:
182 void OnShaderRemoval(Shader* shader) final; 197 void OnShaderRemoval(Shader* shader) final;
183 198
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index 6310e898c..fc1b51a96 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -404,10 +404,12 @@ RasterizerVulkan::RasterizerVulkan(Core::System& system, Core::Frontend::EmuWind
404 wfi_event{device.GetLogical().CreateNewEvent()}, async_shaders{renderer} { 404 wfi_event{device.GetLogical().CreateNewEvent()}, async_shaders{renderer} {
405 scheduler.SetQueryCache(query_cache); 405 scheduler.SetQueryCache(query_cache);
406 if (device.UseAsynchronousShaders()) { 406 if (device.UseAsynchronousShaders()) {
407 // The following is subject to move into the allocate workers method, to be api agnostic
408
407 // Max worker threads we should allow 409 // Max worker threads we should allow
408 constexpr auto MAX_THREADS = 2u; 410 constexpr u32 MAX_THREADS = 4;
409 // Amount of threads we should reserve for other parts of yuzu 411 // Amount of threads we should reserve for other parts of yuzu
410 constexpr auto RESERVED_THREADS = 6u; 412 constexpr u32 RESERVED_THREADS = 6;
411 // Get the amount of threads we can use(this can return zero) 413 // Get the amount of threads we can use(this can return zero)
412 const auto cpu_thread_count = 414 const auto cpu_thread_count =
413 std::max(RESERVED_THREADS, std::thread::hardware_concurrency()); 415 std::max(RESERVED_THREADS, std::thread::hardware_concurrency());
@@ -456,16 +458,16 @@ void RasterizerVulkan::Draw(bool is_indexed, bool is_instanced) {
456 key.renderpass_params = GetRenderPassParams(texceptions); 458 key.renderpass_params = GetRenderPassParams(texceptions);
457 key.padding = 0; 459 key.padding = 0;
458 460
459 auto& pipeline = pipeline_cache.GetGraphicsPipeline(key, async_shaders); 461 auto pipeline = pipeline_cache.GetGraphicsPipeline(key, async_shaders);
460 if (&pipeline == nullptr || pipeline.GetHandle() == VK_NULL_HANDLE) { 462 if (pipeline == nullptr || pipeline->GetHandle() == VK_NULL_HANDLE) {
461 // Async graphics pipeline was not ready. 463 // Async graphics pipeline was not ready.
462 system.GPU().TickWork(); 464 system.GPU().TickWork();
463 return; 465 return;
464 } 466 }
465 467
466 scheduler.BindGraphicsPipeline(pipeline.GetHandle()); 468 scheduler.BindGraphicsPipeline(pipeline->GetHandle());
467 469
468 const auto renderpass = pipeline.GetRenderPass(); 470 const auto renderpass = pipeline->GetRenderPass();
469 const auto [framebuffer, render_area] = ConfigureFramebuffers(renderpass); 471 const auto [framebuffer, render_area] = ConfigureFramebuffers(renderpass);
470 scheduler.RequestRenderpass(renderpass, framebuffer, render_area); 472 scheduler.RequestRenderpass(renderpass, framebuffer, render_area);
471 473
@@ -475,8 +477,8 @@ void RasterizerVulkan::Draw(bool is_indexed, bool is_instanced) {
475 477
476 BeginTransformFeedback(); 478 BeginTransformFeedback();
477 479
478 const auto pipeline_layout = pipeline.GetLayout(); 480 const auto pipeline_layout = pipeline->GetLayout();
479 const auto descriptor_set = pipeline.CommitDescriptorSet(); 481 const auto descriptor_set = pipeline->CommitDescriptorSet();
480 scheduler.Record([pipeline_layout, descriptor_set, draw_params](vk::CommandBuffer cmdbuf) { 482 scheduler.Record([pipeline_layout, descriptor_set, draw_params](vk::CommandBuffer cmdbuf) {
481 if (descriptor_set) { 483 if (descriptor_set) {
482 cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 484 cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout,
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h
index 27604b9a3..f640ba649 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.h
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.h
@@ -287,7 +287,6 @@ private:
287 VKMemoryManager& memory_manager; 287 VKMemoryManager& memory_manager;
288 StateTracker& state_tracker; 288 StateTracker& state_tracker;
289 VKScheduler& scheduler; 289 VKScheduler& scheduler;
290 VideoCommon::Shader::AsyncShaders async_shaders;
291 290
292 VKStagingBufferPool staging_pool; 291 VKStagingBufferPool staging_pool;
293 VKDescriptorPool descriptor_pool; 292 VKDescriptorPool descriptor_pool;
@@ -307,6 +306,7 @@ private:
307 vk::Buffer default_buffer; 306 vk::Buffer default_buffer;
308 VKMemoryCommit default_buffer_commit; 307 VKMemoryCommit default_buffer_commit;
309 vk::Event wfi_event; 308 vk::Event wfi_event;
309 VideoCommon::Shader::AsyncShaders async_shaders;
310 310
311 std::array<View, Maxwell::NumRenderTargets> color_attachments; 311 std::array<View, Maxwell::NumRenderTargets> color_attachments;
312 View zeta_attachment; 312 View zeta_attachment;