diff options
author | bunnei <bunneidev@gmail.com> | 2021-02-19 21:27:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 21:27:10 +0100 |
commit | 728ee181ebdabf61ef7d4d9bd688cdfde4a9eaff (patch) | |
tree | dedc977cb43bcc562efc424ab7b357187dd25a9e /src | |
parent | Merge pull request #5957 from lat9nq/update-dynarmic (diff) | |
parent | vk_update_descriptor: Inline and improve code for binding buffers (diff) | |
download | yuzu-728ee181ebdabf61ef7d4d9bd688cdfde4a9eaff.tar yuzu-728ee181ebdabf61ef7d4d9bd688cdfde4a9eaff.tar.gz yuzu-728ee181ebdabf61ef7d4d9bd688cdfde4a9eaff.tar.bz2 yuzu-728ee181ebdabf61ef7d4d9bd688cdfde4a9eaff.tar.lz yuzu-728ee181ebdabf61ef7d4d9bd688cdfde4a9eaff.tar.xz yuzu-728ee181ebdabf61ef7d4d9bd688cdfde4a9eaff.tar.zst yuzu-728ee181ebdabf61ef7d4d9bd688cdfde4a9eaff.zip |
Diffstat (limited to 'src')
4 files changed, 24 insertions, 24 deletions
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index 848eedd66..668633e7b 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp @@ -201,10 +201,6 @@ void BufferCacheRuntime::BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, }); } -void BufferCacheRuntime::BindBuffer(VkBuffer buffer, u32 offset, u32 size) { - update_descriptor_queue.AddBuffer(buffer, offset, size); -} - void BufferCacheRuntime::ReserveQuadArrayLUT(u32 num_indices, bool wait_for_idle) { if (num_indices <= current_num_indices) { return; diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h index 041e6515c..982e92191 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.h +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h @@ -8,6 +8,7 @@ #include "video_core/engines/maxwell_3d.h" #include "video_core/renderer_vulkan/vk_compute_pass.h" #include "video_core/renderer_vulkan/vk_staging_buffer_pool.h" +#include "video_core/renderer_vulkan/vk_update_descriptor.h" #include "video_core/vulkan_common/vulkan_memory_allocator.h" #include "video_core/vulkan_common/vulkan_wrapper.h" @@ -16,7 +17,6 @@ namespace Vulkan { class Device; class VKDescriptorPool; class VKScheduler; -class VKUpdateDescriptorQueue; class BufferCacheRuntime; @@ -86,7 +86,9 @@ public: } private: - void BindBuffer(VkBuffer buffer, u32 offset, u32 size); + void BindBuffer(VkBuffer buffer, u32 offset, u32 size) { + update_descriptor_queue.AddBuffer(buffer, offset, size); + } void ReserveQuadArrayLUT(u32 num_indices, bool wait_for_idle); diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.cpp b/src/video_core/renderer_vulkan/vk_update_descriptor.cpp index f99273c6a..dc45fdcb1 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.cpp +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.cpp @@ -20,20 +20,20 @@ VKUpdateDescriptorQueue::VKUpdateDescriptorQueue(const Device& device_, VKSchedu VKUpdateDescriptorQueue::~VKUpdateDescriptorQueue() = default; void VKUpdateDescriptorQueue::TickFrame() { - payload.clear(); + payload_cursor = payload.data(); } void VKUpdateDescriptorQueue::Acquire() { // Minimum number of entries required. // This is the maximum number of entries a single draw call migth use. - static constexpr std::size_t MIN_ENTRIES = 0x400; + static constexpr size_t MIN_ENTRIES = 0x400; - if (payload.size() + MIN_ENTRIES >= payload.max_size()) { + if (std::distance(payload.data(), payload_cursor) + MIN_ENTRIES >= payload.max_size()) { LOG_WARNING(Render_Vulkan, "Payload overflow, waiting for worker thread"); scheduler.WaitWorker(); - payload.clear(); + payload_cursor = payload.data(); } - upload_start = &*payload.end(); + upload_start = payload_cursor; } void VKUpdateDescriptorQueue::Send(VkDescriptorUpdateTemplateKHR update_template, diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.h b/src/video_core/renderer_vulkan/vk_update_descriptor.h index e214f7195..d35e77c44 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.h +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.h @@ -4,8 +4,7 @@ #pragma once -#include <variant> -#include <boost/container/static_vector.hpp> +#include <array> #include "common/common_types.h" #include "video_core/vulkan_common/vulkan_wrapper.h" @@ -16,13 +15,15 @@ class Device; class VKScheduler; struct DescriptorUpdateEntry { - DescriptorUpdateEntry(VkDescriptorImageInfo image_) : image{image_} {} + struct Empty {}; + DescriptorUpdateEntry() = default; + DescriptorUpdateEntry(VkDescriptorImageInfo image_) : image{image_} {} DescriptorUpdateEntry(VkDescriptorBufferInfo buffer_) : buffer{buffer_} {} - DescriptorUpdateEntry(VkBufferView texel_buffer_) : texel_buffer{texel_buffer_} {} union { + Empty empty{}; VkDescriptorImageInfo image; VkDescriptorBufferInfo buffer; VkBufferView texel_buffer; @@ -41,39 +42,40 @@ public: void Send(VkDescriptorUpdateTemplateKHR update_template, VkDescriptorSet set); void AddSampledImage(VkImageView image_view, VkSampler sampler) { - payload.emplace_back(VkDescriptorImageInfo{ + *(payload_cursor++) = VkDescriptorImageInfo{ .sampler = sampler, .imageView = image_view, .imageLayout = VK_IMAGE_LAYOUT_GENERAL, - }); + }; } void AddImage(VkImageView image_view) { - payload.emplace_back(VkDescriptorImageInfo{ + *(payload_cursor++) = VkDescriptorImageInfo{ .sampler = VK_NULL_HANDLE, .imageView = image_view, .imageLayout = VK_IMAGE_LAYOUT_GENERAL, - }); + }; } - void AddBuffer(VkBuffer buffer, u64 offset, size_t size) { - payload.emplace_back(VkDescriptorBufferInfo{ + void AddBuffer(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size) { + *(payload_cursor++) = VkDescriptorBufferInfo{ .buffer = buffer, .offset = offset, .range = size, - }); + }; } void AddTexelBuffer(VkBufferView texel_buffer) { - payload.emplace_back(texel_buffer); + *(payload_cursor++) = texel_buffer; } private: const Device& device; VKScheduler& scheduler; + DescriptorUpdateEntry* payload_cursor = nullptr; const DescriptorUpdateEntry* upload_start = nullptr; - boost::container::static_vector<DescriptorUpdateEntry, 0x10000> payload; + std::array<DescriptorUpdateEntry, 0x10000> payload; }; } // namespace Vulkan |