diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2022-02-09 15:39:40 +0100 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2023-01-01 22:43:57 +0100 |
commit | 0f89828073a541eaa2cfd985483f839bd2f97b74 (patch) | |
tree | 3e26c71678e17ca97ec744a884f5ecb9ae2b6c5e /src/video_core/renderer_vulkan | |
parent | MacroHLE: Add MultidrawIndirect HLE Macro. (diff) | |
download | yuzu-0f89828073a541eaa2cfd985483f839bd2f97b74.tar yuzu-0f89828073a541eaa2cfd985483f839bd2f97b74.tar.gz yuzu-0f89828073a541eaa2cfd985483f839bd2f97b74.tar.bz2 yuzu-0f89828073a541eaa2cfd985483f839bd2f97b74.tar.lz yuzu-0f89828073a541eaa2cfd985483f839bd2f97b74.tar.xz yuzu-0f89828073a541eaa2cfd985483f839bd2f97b74.tar.zst yuzu-0f89828073a541eaa2cfd985483f839bd2f97b74.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_buffer_cache.cpp | 4 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 48 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.h | 2 |
3 files changed, 34 insertions, 20 deletions
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index 6b54d7111..487d8b416 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp @@ -56,7 +56,8 @@ vk::Buffer CreateBuffer(const Device& device, u64 size) { VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | - VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; + VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | + VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; if (device.IsExtTransformFeedbackSupported()) { flags |= VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT; } @@ -516,6 +517,7 @@ void BufferCacheRuntime::ReserveNullBuffer() { if (device.IsExtTransformFeedbackSupported()) { create_info.usage |= VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT; } + create_info.usage |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; null_buffer = device.GetLogical().CreateBuffer(create_info); if (device.HasDebuggingToolAttached()) { null_buffer.SetObjectNameEXT("Null buffer"); diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 9b75f33dd..6f1adc97f 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -225,25 +225,40 @@ void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) { }); } -void RasterizerVulkan::DrawIndirect(bool is_indexed) { - PrepareDraw(is_indexed, [this, is_indexed] { - const auto params = maxwell3d->draw_manager->GetIndirectParams(); - const auto [buffer, offset] = buffer_cache.ObtainBuffer( - params.start_address, static_cast<u32>(params.buffer_size), true, false); - scheduler.Record([buffer_obj = buffer->Handle(), offset, - max_draw_counts = params.max_draw_counts, stride = params.stride, - is_indexed](vk::CommandBuffer cmdbuf) { - if (is_indexed) { - cmdbuf.DrawIndexedIndirectCount(buffer_obj, offset + 4ULL, buffer_obj, offset, - static_cast<u32>(max_draw_counts), - static_cast<u32>(stride)); +void RasterizerVulkan::DrawIndirect() { + const auto& params = maxwell3d->draw_manager->GetIndirectParams(); + buffer_cache.SetDrawIndirect(¶ms); + PrepareDraw(params.is_indexed, [this, ¶ms] { + const auto [buffer, offset] = buffer_cache.GetDrawIndirectBuffer(); + if (params.include_count) { + const auto [draw_buffer, offset_base] = buffer_cache.GetDrawIndirectCount(); + scheduler.Record([draw_buffer_obj = draw_buffer->Handle(), + buffer_obj = buffer->Handle(), offset_base, offset, + params](vk::CommandBuffer cmdbuf) { + if (params.is_indexed) { + cmdbuf.DrawIndexedIndirectCount( + buffer_obj, offset, draw_buffer_obj, offset_base, + static_cast<u32>(params.max_draw_counts), static_cast<u32>(params.stride)); + } else { + cmdbuf.DrawIndirectCount(buffer_obj, offset, draw_buffer_obj, offset_base, + static_cast<u32>(params.max_draw_counts), + static_cast<u32>(params.stride)); + } + }); + return; + } + scheduler.Record([buffer_obj = buffer->Handle(), offset, params](vk::CommandBuffer cmdbuf) { + if (params.is_indexed) { + cmdbuf.DrawIndexedIndirect(buffer_obj, offset, + static_cast<u32>(params.max_draw_counts), + static_cast<u32>(params.stride)); } else { - cmdbuf.DrawIndirectCount(buffer_obj, offset + 4ULL, buffer_obj, offset, - static_cast<u32>(max_draw_counts), - static_cast<u32>(stride)); + cmdbuf.DrawIndirect(buffer_obj, offset, static_cast<u32>(params.max_draw_counts), + static_cast<u32>(params.stride)); } }); }); + buffer_cache.SetDrawIndirect(nullptr); } void RasterizerVulkan::Clear(u32 layer_count) { @@ -425,9 +440,6 @@ void RasterizerVulkan::FlushRegion(VAddr addr, u64 size) { bool RasterizerVulkan::MustFlushRegion(VAddr addr, u64 size) { std::scoped_lock lock{texture_cache.mutex, buffer_cache.mutex}; - if (!Settings::IsGPULevelHigh()) { - return buffer_cache.IsRegionGpuModified(addr, size); - } return texture_cache.IsRegionGpuModified(addr, size) || buffer_cache.IsRegionGpuModified(addr, size); } diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index bc43a8a1f..43a210da0 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h @@ -65,7 +65,7 @@ public: ~RasterizerVulkan() override; void Draw(bool is_indexed, u32 instance_count) override; - void DrawIndirect(bool is_indexed) override; + void DrawIndirect() override; void Clear(u32 layer_count) override; void DispatchCompute() override; void ResetCounter(VideoCore::QueryType type) override; |