summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-01-23 21:15:42 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2021-02-13 06:18:38 +0100
commit3a2eefb16cf6916344bdb655189cbc546e49ef7e (patch)
tree1f9915c1b87e9fffca0a80f85386201c89f2251f /src/video_core
parentbuffer_cache: Add extra bytes to guest SSBOs (diff)
downloadyuzu-3a2eefb16cf6916344bdb655189cbc546e49ef7e.tar
yuzu-3a2eefb16cf6916344bdb655189cbc546e49ef7e.tar.gz
yuzu-3a2eefb16cf6916344bdb655189cbc546e49ef7e.tar.bz2
yuzu-3a2eefb16cf6916344bdb655189cbc546e49ef7e.tar.lz
yuzu-3a2eefb16cf6916344bdb655189cbc546e49ef7e.tar.xz
yuzu-3a2eefb16cf6916344bdb655189cbc546e49ef7e.tar.zst
yuzu-3a2eefb16cf6916344bdb655189cbc546e49ef7e.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_vulkan/vk_buffer_cache.cpp39
-rw-r--r--src/video_core/renderer_vulkan/vk_buffer_cache.h5
2 files changed, 40 insertions, 4 deletions
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp
index 4f1e4ec28..848eedd66 100644
--- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp
@@ -140,16 +140,22 @@ void BufferCacheRuntime::BindIndexBuffer(PrimitiveTopology topology, IndexFormat
u32 offset, [[maybe_unused]] u32 size) {
VkIndexType vk_index_type = MaxwellToVK::IndexFormat(index_format);
VkDeviceSize vk_offset = offset;
+ VkBuffer vk_buffer = buffer;
if (topology == PrimitiveTopology::Quads) {
vk_index_type = VK_INDEX_TYPE_UINT32;
- std::tie(buffer, vk_offset) =
+ std::tie(vk_buffer, vk_offset) =
quad_index_pass.Assemble(index_format, num_indices, base_vertex, buffer, offset);
} else if (vk_index_type == VK_INDEX_TYPE_UINT8_EXT && !device.IsExtIndexTypeUint8Supported()) {
vk_index_type = VK_INDEX_TYPE_UINT16;
- std::tie(buffer, vk_offset) = uint8_pass.Assemble(num_indices, buffer, offset);
+ std::tie(vk_buffer, vk_offset) = uint8_pass.Assemble(num_indices, buffer, offset);
}
- scheduler.Record([buffer, vk_offset, vk_index_type](vk::CommandBuffer cmdbuf) {
- cmdbuf.BindIndexBuffer(buffer, vk_offset, vk_index_type);
+ if (vk_buffer == VK_NULL_HANDLE) {
+ // Vulkan doesn't support null index buffers. Replace it with our own null buffer.
+ ReserveNullIndexBuffer();
+ vk_buffer = *null_index_buffer;
+ }
+ scheduler.Record([vk_buffer, vk_offset, vk_index_type](vk::CommandBuffer cmdbuf) {
+ cmdbuf.BindIndexBuffer(vk_buffer, vk_offset, vk_index_type);
});
}
@@ -276,4 +282,29 @@ void BufferCacheRuntime::ReserveQuadArrayLUT(u32 num_indices, bool wait_for_idle
});
}
+void BufferCacheRuntime::ReserveNullIndexBuffer() {
+ if (null_index_buffer) {
+ return;
+ }
+ null_index_buffer = device.GetLogical().CreateBuffer(VkBufferCreateInfo{
+ .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
+ .pNext = nullptr,
+ .flags = 0,
+ .size = 4,
+ .usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
+ .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
+ .queueFamilyIndexCount = 0,
+ .pQueueFamilyIndices = nullptr,
+ });
+ if (device.HasDebuggingToolAttached()) {
+ null_index_buffer.SetObjectNameEXT("Null index buffer");
+ }
+ null_index_buffer_commit = memory_allocator.Commit(null_index_buffer, MemoryUsage::DeviceLocal);
+
+ scheduler.RequestOutsideRenderPassOperationContext();
+ scheduler.Record([buffer = *null_index_buffer](vk::CommandBuffer cmdbuf) {
+ cmdbuf.FillBuffer(buffer, 0, VK_WHOLE_SIZE, 0);
+ });
+}
+
} // namespace Vulkan
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h
index 7ff7e0d55..041e6515c 100644
--- a/src/video_core/renderer_vulkan/vk_buffer_cache.h
+++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h
@@ -90,6 +90,8 @@ private:
void ReserveQuadArrayLUT(u32 num_indices, bool wait_for_idle);
+ void ReserveNullIndexBuffer();
+
const Device& device;
MemoryAllocator& memory_allocator;
VKScheduler& scheduler;
@@ -101,6 +103,9 @@ private:
VkIndexType quad_array_lut_index_type{};
u32 current_num_indices = 0;
+ vk::Buffer null_index_buffer;
+ MemoryCommit null_index_buffer_commit;
+
Uint8Pass uint8_pass;
QuadIndexedPass quad_index_pass;
};