From fc7f8c8663040746c0d78172421a96486e4116d6 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 15 Feb 2021 23:05:45 +0100 Subject: [PATCH] early-access version 1464 --- README.md | 2 +- .../renderer_vulkan/vk_buffer_cache.cpp | 4 --- .../renderer_vulkan/vk_buffer_cache.h | 6 ++-- .../renderer_vulkan/vk_update_descriptor.cpp | 10 +++---- .../renderer_vulkan/vk_update_descriptor.h | 28 ++++++++++--------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 619d9cda9..724b82658 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1463. +This is the source code for early-access 1464. ## Legal Notice 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 100755 --- 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 100755 --- 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 100755 --- 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 100755 --- 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 -#include +#include #include "common/common_types.h" #include "video_core/vulkan_common/vulkan_wrapper.h" @@ -16,13 +15,15 @@ class Device; class VKScheduler; struct DescriptorUpdateEntry { + 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 payload; + std::array payload; }; } // namespace Vulkan