diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_update_descriptor.cpp | 11 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_update_descriptor.h | 10 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.cpp b/src/video_core/renderer_vulkan/vk_update_descriptor.cpp index 009dab0b6..0630ebda5 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.cpp +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.cpp | |||
| @@ -14,13 +14,18 @@ namespace Vulkan { | |||
| 14 | 14 | ||
| 15 | UpdateDescriptorQueue::UpdateDescriptorQueue(const Device& device_, Scheduler& scheduler_) | 15 | UpdateDescriptorQueue::UpdateDescriptorQueue(const Device& device_, Scheduler& scheduler_) |
| 16 | : device{device_}, scheduler{scheduler_} { | 16 | : device{device_}, scheduler{scheduler_} { |
| 17 | payload_start = payload.data(); | ||
| 17 | payload_cursor = payload.data(); | 18 | payload_cursor = payload.data(); |
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | UpdateDescriptorQueue::~UpdateDescriptorQueue() = default; | 21 | UpdateDescriptorQueue::~UpdateDescriptorQueue() = default; |
| 21 | 22 | ||
| 22 | void UpdateDescriptorQueue::TickFrame() { | 23 | void UpdateDescriptorQueue::TickFrame() { |
| 23 | payload_cursor = payload.data(); | 24 | if (++frame_index >= FRAMES_IN_FLIGHT) { |
| 25 | frame_index = 0; | ||
| 26 | } | ||
| 27 | payload_start = payload.data() + frame_index * FRAME_PAYLOAD_SIZE; | ||
| 28 | payload_cursor = payload_start; | ||
| 24 | } | 29 | } |
| 25 | 30 | ||
| 26 | void UpdateDescriptorQueue::Acquire() { | 31 | void UpdateDescriptorQueue::Acquire() { |
| @@ -28,10 +33,10 @@ void UpdateDescriptorQueue::Acquire() { | |||
| 28 | // This is the maximum number of entries a single draw call might use. | 33 | // This is the maximum number of entries a single draw call might use. |
| 29 | static constexpr size_t MIN_ENTRIES = 0x400; | 34 | static constexpr size_t MIN_ENTRIES = 0x400; |
| 30 | 35 | ||
| 31 | if (std::distance(payload.data(), payload_cursor) + MIN_ENTRIES >= payload.max_size()) { | 36 | if (std::distance(payload_start, payload_cursor) + MIN_ENTRIES >= FRAME_PAYLOAD_SIZE) { |
| 32 | LOG_WARNING(Render_Vulkan, "Payload overflow, waiting for worker thread"); | 37 | LOG_WARNING(Render_Vulkan, "Payload overflow, waiting for worker thread"); |
| 33 | scheduler.WaitWorker(); | 38 | scheduler.WaitWorker(); |
| 34 | payload_cursor = payload.data(); | 39 | payload_cursor = payload_start; |
| 35 | } | 40 | } |
| 36 | upload_start = payload_cursor; | 41 | upload_start = payload_cursor; |
| 37 | } | 42 | } |
diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.h b/src/video_core/renderer_vulkan/vk_update_descriptor.h index 625bcc809..1c1a7020b 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.h +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.h | |||
| @@ -29,6 +29,12 @@ struct DescriptorUpdateEntry { | |||
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | class UpdateDescriptorQueue final { | 31 | class UpdateDescriptorQueue final { |
| 32 | // This should be plenty for the vast majority of cases. Most desktop platforms only | ||
| 33 | // provide up to 3 swapchain images. | ||
| 34 | static constexpr size_t FRAMES_IN_FLIGHT = 5; | ||
| 35 | static constexpr size_t FRAME_PAYLOAD_SIZE = 0x10000; | ||
| 36 | static constexpr size_t PAYLOAD_SIZE = FRAME_PAYLOAD_SIZE * FRAMES_IN_FLIGHT; | ||
| 37 | |||
| 32 | public: | 38 | public: |
| 33 | explicit UpdateDescriptorQueue(const Device& device_, Scheduler& scheduler_); | 39 | explicit UpdateDescriptorQueue(const Device& device_, Scheduler& scheduler_); |
| 34 | ~UpdateDescriptorQueue(); | 40 | ~UpdateDescriptorQueue(); |
| @@ -73,9 +79,11 @@ private: | |||
| 73 | const Device& device; | 79 | const Device& device; |
| 74 | Scheduler& scheduler; | 80 | Scheduler& scheduler; |
| 75 | 81 | ||
| 82 | size_t frame_index{0}; | ||
| 76 | DescriptorUpdateEntry* payload_cursor = nullptr; | 83 | DescriptorUpdateEntry* payload_cursor = nullptr; |
| 84 | DescriptorUpdateEntry* payload_start = nullptr; | ||
| 77 | const DescriptorUpdateEntry* upload_start = nullptr; | 85 | const DescriptorUpdateEntry* upload_start = nullptr; |
| 78 | std::array<DescriptorUpdateEntry, 0x10000> payload; | 86 | std::array<DescriptorUpdateEntry, PAYLOAD_SIZE> payload; |
| 79 | }; | 87 | }; |
| 80 | 88 | ||
| 81 | } // namespace Vulkan | 89 | } // namespace Vulkan |