summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp50
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.h7
2 files changed, 32 insertions, 25 deletions
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index 23252e658..d2c6b1189 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -203,6 +203,8 @@ public:
203 return BindStatic<30>(scheduler); 203 return BindStatic<30>(scheduler);
204 case 31: 204 case 31:
205 return BindStatic<31>(scheduler); 205 return BindStatic<31>(scheduler);
206 case 32:
207 return BindStatic<32>(scheduler);
206 } 208 }
207 UNREACHABLE(); 209 UNREACHABLE();
208 } 210 }
@@ -526,7 +528,6 @@ bool RasterizerVulkan::AccelerateDisplay(const Tegra::FramebufferConfig& config,
526 VideoCore::Surface::PixelFormatFromGPUPixelFormat(config.pixel_format)}; 528 VideoCore::Surface::PixelFormatFromGPUPixelFormat(config.pixel_format)};
527 ASSERT_MSG(params.width == config.width, "Framebuffer width is different"); 529 ASSERT_MSG(params.width == config.width, "Framebuffer width is different");
528 ASSERT_MSG(params.height == config.height, "Framebuffer height is different"); 530 ASSERT_MSG(params.height == config.height, "Framebuffer height is different");
529 // ASSERT_MSG(params.pixel_format == pixel_format, "Framebuffer pixel_format is different");
530 531
531 screen_info.image = &surface->GetImage(); 532 screen_info.image = &surface->GetImage();
532 screen_info.width = params.width; 533 screen_info.width = params.width;
@@ -536,17 +537,24 @@ bool RasterizerVulkan::AccelerateDisplay(const Tegra::FramebufferConfig& config,
536} 537}
537 538
538void RasterizerVulkan::FlushWork() { 539void RasterizerVulkan::FlushWork() {
540 static constexpr u32 DRAWS_TO_DISPATCH = 4096;
541
542 // Only check multiples of 8 draws
543 static_assert(DRAWS_TO_DISPATCH % 8 == 0);
539 if ((++draw_counter & 7) != 7) { 544 if ((++draw_counter & 7) != 7) {
540 return; 545 return;
541 } 546 }
542 if (draw_counter < 4096) { 547
543 // Flush work to the worker thread every 8 draws 548 if (draw_counter < DRAWS_TO_DISPATCH) {
549 // Send recorded tasks to the worker thread
544 scheduler.DispatchWork(); 550 scheduler.DispatchWork();
545 } else { 551 return;
546 // Flush work to the GPU (and implicitly the worker thread) every N draws
547 scheduler.Flush();
548 draw_counter = 0;
549 } 552 }
553
554 // Otherwise (every certain number of draws) flush execution.
555 // This submits commands to the Vulkan driver.
556 scheduler.Flush();
557 draw_counter = 0;
550} 558}
551 559
552RasterizerVulkan::Texceptions RasterizerVulkan::UpdateAttachments() { 560RasterizerVulkan::Texceptions RasterizerVulkan::UpdateAttachments() {
@@ -593,18 +601,16 @@ bool RasterizerVulkan::WalkAttachmentOverlaps(const CachedSurfaceView& attachmen
593 601
594std::tuple<vk::Framebuffer, vk::Extent2D> RasterizerVulkan::ConfigureFramebuffers( 602std::tuple<vk::Framebuffer, vk::Extent2D> RasterizerVulkan::ConfigureFramebuffers(
595 vk::RenderPass renderpass) { 603 vk::RenderPass renderpass) {
596 FramebufferCacheKey fbkey; 604 FramebufferCacheKey key{renderpass, std::numeric_limits<u32>::max(),
597 fbkey.renderpass = renderpass; 605 std::numeric_limits<u32>::max()};
598 fbkey.width = std::numeric_limits<u32>::max();
599 fbkey.height = std::numeric_limits<u32>::max();
600 606
601 const auto MarkAsModifiedAndPush = [&](const View& view) { 607 const auto MarkAsModifiedAndPush = [&](const View& view) {
602 if (view == nullptr) { 608 if (view == nullptr) {
603 return false; 609 return false;
604 } 610 }
605 fbkey.views.push_back(view->GetHandle()); 611 key.views.push_back(view->GetHandle());
606 fbkey.width = std::min(fbkey.width, view->GetWidth()); 612 key.width = std::min(key.width, view->GetWidth());
607 fbkey.height = std::min(fbkey.height, view->GetHeight()); 613 key.height = std::min(key.height, view->GetHeight());
608 return true; 614 return true;
609 }; 615 };
610 616
@@ -617,18 +623,18 @@ std::tuple<vk::Framebuffer, vk::Extent2D> RasterizerVulkan::ConfigureFramebuffer
617 texture_cache.MarkDepthBufferInUse(); 623 texture_cache.MarkDepthBufferInUse();
618 } 624 }
619 625
620 const auto [fbentry, is_cache_miss] = framebuffer_cache.try_emplace(fbkey); 626 const auto [fbentry, is_cache_miss] = framebuffer_cache.try_emplace(key);
621 auto& framebuffer = fbentry->second; 627 auto& framebuffer = fbentry->second;
622 if (is_cache_miss) { 628 if (is_cache_miss) {
623 const vk::FramebufferCreateInfo framebuffer_ci( 629 const vk::FramebufferCreateInfo framebuffer_ci({}, key.renderpass,
624 {}, fbkey.renderpass, static_cast<u32>(fbkey.views.size()), fbkey.views.data(), 630 static_cast<u32>(key.views.size()),
625 fbkey.width, fbkey.height, 1); 631 key.views.data(), key.width, key.height, 1);
626 const auto dev = device.GetLogical(); 632 const auto dev = device.GetLogical();
627 const auto& dld = device.GetDispatchLoader(); 633 const auto& dld = device.GetDispatchLoader();
628 framebuffer = dev.createFramebufferUnique(framebuffer_ci, nullptr, dld); 634 framebuffer = dev.createFramebufferUnique(framebuffer_ci, nullptr, dld);
629 } 635 }
630 636
631 return {*framebuffer, vk::Extent2D{fbkey.width, fbkey.height}}; 637 return {*framebuffer, vk::Extent2D{key.width, key.height}};
632} 638}
633 639
634RasterizerVulkan::DrawParameters RasterizerVulkan::SetupGeometry(FixedPipelineState& fixed_state, 640RasterizerVulkan::DrawParameters RasterizerVulkan::SetupGeometry(FixedPipelineState& fixed_state,
@@ -771,8 +777,8 @@ void RasterizerVulkan::SetupIndexBuffer(BufferBindings& buffer_bindings, DrawPar
771 if (!is_indexed) { 777 if (!is_indexed) {
772 break; 778 break;
773 } 779 }
774 auto [buffer, offset] = 780 const GPUVAddr gpu_addr = regs.index_array.IndexStart();
775 buffer_cache.UploadMemory(regs.index_array.IndexStart(), CalculateIndexBufferSize()); 781 auto [buffer, offset] = buffer_cache.UploadMemory(gpu_addr, CalculateIndexBufferSize());
776 782
777 auto format = regs.index_array.format; 783 auto format = regs.index_array.format;
778 const bool is_uint8 = format == Maxwell::IndexFormat::UnsignedByte; 784 const bool is_uint8 = format == Maxwell::IndexFormat::UnsignedByte;
@@ -918,7 +924,7 @@ void RasterizerVulkan::SetupGlobalBuffer(const GlobalBufferEntry& entry, GPUVAdd
918 924
919void RasterizerVulkan::SetupTexelBuffer(const Tegra::Texture::TICEntry& tic, 925void RasterizerVulkan::SetupTexelBuffer(const Tegra::Texture::TICEntry& tic,
920 const TexelBufferEntry& entry) { 926 const TexelBufferEntry& entry) {
921 auto view = texture_cache.GetTextureSurface(tic, entry); 927 const auto view = texture_cache.GetTextureSurface(tic, entry);
922 ASSERT(view->IsBufferView()); 928 ASSERT(view->IsBufferView());
923 929
924 update_descriptor_queue.AddTexelBuffer(view->GetBufferView()); 930 update_descriptor_queue.AddTexelBuffer(view->GetBufferView());
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h
index 2ecc19e7a..7be71e734 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.h
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.h
@@ -11,6 +11,7 @@
11#include <vector> 11#include <vector>
12 12
13#include <boost/container/static_vector.hpp> 13#include <boost/container/static_vector.hpp>
14#include <boost/functional/hash.hpp>
14 15
15#include "common/common_types.h" 16#include "common/common_types.h"
16#include "video_core/memory_manager.h" 17#include "video_core/memory_manager.h"
@@ -51,10 +52,10 @@ using ImageViewsPack =
51 boost::container::static_vector<vk::ImageView, Maxwell::NumRenderTargets + 1>; 52 boost::container::static_vector<vk::ImageView, Maxwell::NumRenderTargets + 1>;
52 53
53struct FramebufferCacheKey { 54struct FramebufferCacheKey {
54 vk::RenderPass renderpass; 55 vk::RenderPass renderpass{};
56 u32 width = 0;
57 u32 height = 0;
55 ImageViewsPack views; 58 ImageViewsPack views;
56 u32 width;
57 u32 height;
58 59
59 std::size_t Hash() const noexcept { 60 std::size_t Hash() const noexcept {
60 std::size_t hash = 0; 61 std::size_t hash = 0;