diff --git a/src/xenia/gpu/vulkan/buffer_cache.cc b/src/xenia/gpu/vulkan/buffer_cache.cc index 2db1b3b65..7c8db8b8a 100644 --- a/src/xenia/gpu/vulkan/buffer_cache.cc +++ b/src/xenia/gpu/vulkan/buffer_cache.cc @@ -134,6 +134,45 @@ VkResult BufferCache::Initialize() { return VK_SUCCESS; } +VkResult xe::gpu::vulkan::BufferCache::CreateVertexDescriptorPool() { + VkResult status; + + std::vector pool_sizes; + pool_sizes.push_back({ + VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, + 4096, + }); + vertex_descriptor_pool_ = + std::make_unique(*device_, 32768, pool_sizes); + + // 32 storage buffers available to vertex shader. + // TODO(DrChat): In the future, this could hold memexport staging data. + VkDescriptorSetLayoutBinding binding = { + 0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, + 32, VK_SHADER_STAGE_VERTEX_BIT, + nullptr, + }; + + VkDescriptorSetLayoutCreateInfo layout_info = { + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, + nullptr, + 0, + 1, + &binding, + }; + vkCreateDescriptorSetLayout(*device_, &layout_info, nullptr, + &vertex_descriptor_set_layout_); + + return VK_SUCCESS; +} + +void xe::gpu::vulkan::BufferCache::FreeVertexDescriptorPool() { + vertex_descriptor_pool_.reset(); + + VK_SAFE_DESTROY(vkDestroyDescriptorSetLayout, *device_, + vertex_descriptor_set_layout_, nullptr); +} + VkResult BufferCache::CreateConstantDescriptorSet() { VkResult status = VK_SUCCESS; diff --git a/src/xenia/gpu/vulkan/buffer_cache.h b/src/xenia/gpu/vulkan/buffer_cache.h index edef36180..0e579c01f 100644 --- a/src/xenia/gpu/vulkan/buffer_cache.h +++ b/src/xenia/gpu/vulkan/buffer_cache.h @@ -15,6 +15,7 @@ #include "xenia/gpu/xenos.h" #include "xenia/memory.h" #include "xenia/ui/vulkan/circular_buffer.h" +#include "xenia/ui/vulkan/fenced_pools.h" #include "xenia/ui/vulkan/vulkan.h" #include "xenia/ui/vulkan/vulkan_device.h" @@ -106,6 +107,9 @@ class BufferCache { VmaAllocationInfo alloc_info; }; + VkResult CreateVertexDescriptorPool(); + void FreeVertexDescriptorPool(); + VkResult CreateConstantDescriptorSet(); void FreeConstantDescriptorSet(); @@ -136,6 +140,10 @@ class BufferCache { std::unique_ptr transient_buffer_ = nullptr; std::map> transient_cache_; + // Vertex buffer descriptors + std::unique_ptr vertex_descriptor_pool_ = nullptr; + VkDescriptorSetLayout vertex_descriptor_set_layout_ = nullptr; + // Descriptor set used to hold vertex/pixel shader float constants VkDescriptorPool constant_descriptor_pool_ = nullptr; VkDescriptorSetLayout constant_descriptor_set_layout_ = nullptr;