summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorKelebek1 <eeeedddccc@hotmail.co.uk>2023-06-04 22:09:57 +0200
committerKelebek1 <eeeedddccc@hotmail.co.uk>2023-06-08 13:13:27 +0200
commitace6c2318be5e8c5b2ad5f489d8144f28505d5f9 (patch)
tree0bde2e03aa840aba635109f6281215f64e99bb37 /src/video_core/renderer_vulkan
parentMerge pull request #10655 from Morph1984/msvc-cxx20 (diff)
downloadyuzu-ace6c2318be5e8c5b2ad5f489d8144f28505d5f9.tar
yuzu-ace6c2318be5e8c5b2ad5f489d8144f28505d5f9.tar.gz
yuzu-ace6c2318be5e8c5b2ad5f489d8144f28505d5f9.tar.bz2
yuzu-ace6c2318be5e8c5b2ad5f489d8144f28505d5f9.tar.lz
yuzu-ace6c2318be5e8c5b2ad5f489d8144f28505d5f9.tar.xz
yuzu-ace6c2318be5e8c5b2ad5f489d8144f28505d5f9.tar.zst
yuzu-ace6c2318be5e8c5b2ad5f489d8144f28505d5f9.zip
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_buffer_cache.cpp54
-rw-r--r--src/video_core/renderer_vulkan/vk_buffer_cache.h3
2 files changed, 56 insertions, 1 deletions
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp
index daa128399..d72d99899 100644
--- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp
@@ -7,7 +7,6 @@
#include <span>
#include <vector>
-#include "video_core/buffer_cache/buffer_cache.h"
#include "video_core/renderer_vulkan/maxwell_to_vk.h"
#include "video_core/renderer_vulkan/vk_buffer_cache.h"
#include "video_core/renderer_vulkan/vk_scheduler.h"
@@ -502,6 +501,40 @@ void BufferCacheRuntime::BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset
}
}
+void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings& bindings) {
+ boost::container::small_vector<VkBuffer, 32> buffer_handles;
+ for (u32 index = 0; index < bindings.buffers.size(); index++) {
+ auto& buffer = *reinterpret_cast<Buffer*>(bindings.buffers[index]);
+ auto handle = buffer.Handle();
+ if (handle == VK_NULL_HANDLE) {
+ bindings.offsets[index] = 0;
+ bindings.sizes[index] = VK_WHOLE_SIZE;
+ if (!device.HasNullDescriptor()) {
+ ReserveNullBuffer();
+ handle = *null_buffer;
+ }
+ }
+ buffer_handles.push_back(handle);
+ }
+ if (device.IsExtExtendedDynamicStateSupported()) {
+ scheduler.Record([bindings = bindings,
+ buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) {
+ cmdbuf.BindVertexBuffers2EXT(
+ bindings.min_index, bindings.max_index - bindings.min_index, buffer_handles.data(),
+ reinterpret_cast<const VkDeviceSize*>(bindings.offsets.data()),
+ reinterpret_cast<const VkDeviceSize*>(bindings.sizes.data()),
+ reinterpret_cast<const VkDeviceSize*>(bindings.strides.data()));
+ });
+ } else {
+ scheduler.Record([bindings = bindings,
+ buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) {
+ cmdbuf.BindVertexBuffers(
+ bindings.min_index, bindings.max_index - bindings.min_index, buffer_handles.data(),
+ reinterpret_cast<const VkDeviceSize*>(bindings.offsets.data()));
+ });
+ }
+}
+
void BufferCacheRuntime::BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset,
u32 size) {
if (!device.IsExtTransformFeedbackSupported()) {
@@ -523,6 +556,25 @@ void BufferCacheRuntime::BindTransformFeedbackBuffer(u32 index, VkBuffer buffer,
});
}
+void BufferCacheRuntime::BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings) {
+ if (!device.IsExtTransformFeedbackSupported()) {
+ // Already logged in the rasterizer
+ return;
+ }
+ boost::container::small_vector<VkBuffer, 4> buffer_handles;
+ for (u32 index = 0; index < bindings.buffers.size(); index++) {
+ auto& buffer = *reinterpret_cast<Buffer*>(bindings.buffers[index]);
+ buffer_handles.push_back(buffer.Handle());
+ }
+ scheduler.Record(
+ [bindings = bindings, buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) {
+ cmdbuf.BindTransformFeedbackBuffersEXT(
+ 0, static_cast<u32>(buffer_handles.size()), buffer_handles.data(),
+ reinterpret_cast<const VkDeviceSize*>(bindings.offsets.data()),
+ reinterpret_cast<const VkDeviceSize*>(bindings.sizes.data()));
+ });
+}
+
void BufferCacheRuntime::ReserveNullBuffer() {
if (null_buffer) {
return;
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h
index 92b4f7859..92d3e9f32 100644
--- a/src/video_core/renderer_vulkan/vk_buffer_cache.h
+++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h
@@ -18,6 +18,7 @@ namespace Vulkan {
class Device;
class DescriptorPool;
class Scheduler;
+struct HostVertexBinding;
class BufferCacheRuntime;
@@ -96,8 +97,10 @@ public:
void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count);
void BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, u32 stride);
+ void BindVertexBuffers(VideoCommon::HostBindings& bindings);
void BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size);
+ void BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings);
std::span<u8> BindMappedUniformBuffer([[maybe_unused]] size_t stage,
[[maybe_unused]] u32 binding_index, u32 size) {