yuzu-emu
/
yuzu
Archived
1
0
Fork 0

vulkan_common: promote descriptor update template usage to core

This commit is contained in:
Liam 2022-12-02 17:04:28 -05:00
parent a948ab3e48
commit e44a804ec7
8 changed files with 36 additions and 37 deletions

View File

@ -44,7 +44,7 @@ public:
}); });
} }
vk::DescriptorUpdateTemplateKHR CreateTemplate(VkDescriptorSetLayout descriptor_set_layout, vk::DescriptorUpdateTemplate CreateTemplate(VkDescriptorSetLayout descriptor_set_layout,
VkPipelineLayout pipeline_layout, VkPipelineLayout pipeline_layout,
bool use_push_descriptor) const { bool use_push_descriptor) const {
if (entries.empty()) { if (entries.empty()) {
@ -52,9 +52,9 @@ public:
} }
const VkDescriptorUpdateTemplateType type = const VkDescriptorUpdateTemplateType type =
use_push_descriptor ? VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR use_push_descriptor ? VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR
: VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR; : VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET;
return device->GetLogical().CreateDescriptorUpdateTemplateKHR({ return device->GetLogical().CreateDescriptorUpdateTemplate({
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR, .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO,
.pNext = nullptr, .pNext = nullptr,
.flags = 0, .flags = 0,
.descriptorUpdateEntryCount = static_cast<u32>(entries.size()), .descriptorUpdateEntryCount = static_cast<u32>(entries.size()),

View File

@ -93,7 +93,7 @@ constexpr DescriptorBankInfo ASTC_BANK_INFO{
.score = 2, .score = 2,
}; };
constexpr VkDescriptorUpdateTemplateEntryKHR INPUT_OUTPUT_DESCRIPTOR_UPDATE_TEMPLATE{ constexpr VkDescriptorUpdateTemplateEntry INPUT_OUTPUT_DESCRIPTOR_UPDATE_TEMPLATE{
.dstBinding = 0, .dstBinding = 0,
.dstArrayElement = 0, .dstArrayElement = 0,
.descriptorCount = 2, .descriptorCount = 2,
@ -102,7 +102,7 @@ constexpr VkDescriptorUpdateTemplateEntryKHR INPUT_OUTPUT_DESCRIPTOR_UPDATE_TEMP
.stride = sizeof(DescriptorUpdateEntry), .stride = sizeof(DescriptorUpdateEntry),
}; };
constexpr std::array<VkDescriptorUpdateTemplateEntryKHR, ASTC_NUM_BINDINGS> constexpr std::array<VkDescriptorUpdateTemplateEntry, ASTC_NUM_BINDINGS>
ASTC_PASS_DESCRIPTOR_UPDATE_TEMPLATE_ENTRY{{ ASTC_PASS_DESCRIPTOR_UPDATE_TEMPLATE_ENTRY{{
{ {
.dstBinding = ASTC_BINDING_INPUT_BUFFER, .dstBinding = ASTC_BINDING_INPUT_BUFFER,
@ -134,7 +134,7 @@ struct AstcPushConstants {
ComputePass::ComputePass(const Device& device_, DescriptorPool& descriptor_pool, ComputePass::ComputePass(const Device& device_, DescriptorPool& descriptor_pool,
vk::Span<VkDescriptorSetLayoutBinding> bindings, vk::Span<VkDescriptorSetLayoutBinding> bindings,
vk::Span<VkDescriptorUpdateTemplateEntryKHR> templates, vk::Span<VkDescriptorUpdateTemplateEntry> templates,
const DescriptorBankInfo& bank_info, const DescriptorBankInfo& bank_info,
vk::Span<VkPushConstantRange> push_constants, std::span<const u32> code) vk::Span<VkPushConstantRange> push_constants, std::span<const u32> code)
: device{device_} { : device{device_} {
@ -155,13 +155,13 @@ ComputePass::ComputePass(const Device& device_, DescriptorPool& descriptor_pool,
.pPushConstantRanges = push_constants.data(), .pPushConstantRanges = push_constants.data(),
}); });
if (!templates.empty()) { if (!templates.empty()) {
descriptor_template = device.GetLogical().CreateDescriptorUpdateTemplateKHR({ descriptor_template = device.GetLogical().CreateDescriptorUpdateTemplate({
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR, .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO,
.pNext = nullptr, .pNext = nullptr,
.flags = 0, .flags = 0,
.descriptorUpdateEntryCount = templates.size(), .descriptorUpdateEntryCount = templates.size(),
.pDescriptorUpdateEntries = templates.data(), .pDescriptorUpdateEntries = templates.data(),
.templateType = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR, .templateType = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET,
.descriptorSetLayout = *descriptor_set_layout, .descriptorSetLayout = *descriptor_set_layout,
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.pipelineLayout = *layout, .pipelineLayout = *layout,

View File

@ -29,14 +29,14 @@ class ComputePass {
public: public:
explicit ComputePass(const Device& device, DescriptorPool& descriptor_pool, explicit ComputePass(const Device& device, DescriptorPool& descriptor_pool,
vk::Span<VkDescriptorSetLayoutBinding> bindings, vk::Span<VkDescriptorSetLayoutBinding> bindings,
vk::Span<VkDescriptorUpdateTemplateEntryKHR> templates, vk::Span<VkDescriptorUpdateTemplateEntry> templates,
const DescriptorBankInfo& bank_info, const DescriptorBankInfo& bank_info,
vk::Span<VkPushConstantRange> push_constants, std::span<const u32> code); vk::Span<VkPushConstantRange> push_constants, std::span<const u32> code);
~ComputePass(); ~ComputePass();
protected: protected:
const Device& device; const Device& device;
vk::DescriptorUpdateTemplateKHR descriptor_template; vk::DescriptorUpdateTemplate descriptor_template;
vk::PipelineLayout layout; vk::PipelineLayout layout;
vk::Pipeline pipeline; vk::Pipeline pipeline;
vk::DescriptorSetLayout descriptor_set_layout; vk::DescriptorSetLayout descriptor_set_layout;

View File

@ -55,7 +55,7 @@ private:
vk::DescriptorSetLayout descriptor_set_layout; vk::DescriptorSetLayout descriptor_set_layout;
DescriptorAllocator descriptor_allocator; DescriptorAllocator descriptor_allocator;
vk::PipelineLayout pipeline_layout; vk::PipelineLayout pipeline_layout;
vk::DescriptorUpdateTemplateKHR descriptor_update_template; vk::DescriptorUpdateTemplate descriptor_update_template;
vk::Pipeline pipeline; vk::Pipeline pipeline;
std::condition_variable build_condvar; std::condition_variable build_condvar;

View File

@ -151,7 +151,7 @@ private:
vk::DescriptorSetLayout descriptor_set_layout; vk::DescriptorSetLayout descriptor_set_layout;
DescriptorAllocator descriptor_allocator; DescriptorAllocator descriptor_allocator;
vk::PipelineLayout pipeline_layout; vk::PipelineLayout pipeline_layout;
vk::DescriptorUpdateTemplateKHR descriptor_update_template; vk::DescriptorUpdateTemplate descriptor_update_template;
vk::Pipeline pipeline; vk::Pipeline pipeline;
std::condition_variable build_condvar; std::condition_variable build_condvar;

View File

@ -80,7 +80,6 @@ constexpr std::array REQUIRED_EXTENSIONS{
// Core in 1.2, but required due to use of extension methods, // Core in 1.2, but required due to use of extension methods,
// and well-supported by drivers // and well-supported by drivers
VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME,
VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME, VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME,
#ifdef _WIN32 #ifdef _WIN32
VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME,

View File

@ -130,7 +130,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept {
X(vkCreateComputePipelines); X(vkCreateComputePipelines);
X(vkCreateDescriptorPool); X(vkCreateDescriptorPool);
X(vkCreateDescriptorSetLayout); X(vkCreateDescriptorSetLayout);
X(vkCreateDescriptorUpdateTemplateKHR); X(vkCreateDescriptorUpdateTemplate);
X(vkCreateEvent); X(vkCreateEvent);
X(vkCreateFence); X(vkCreateFence);
X(vkCreateFramebuffer); X(vkCreateFramebuffer);
@ -149,7 +149,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept {
X(vkDestroyCommandPool); X(vkDestroyCommandPool);
X(vkDestroyDescriptorPool); X(vkDestroyDescriptorPool);
X(vkDestroyDescriptorSetLayout); X(vkDestroyDescriptorSetLayout);
X(vkDestroyDescriptorUpdateTemplateKHR); X(vkDestroyDescriptorUpdateTemplate);
X(vkDestroyEvent); X(vkDestroyEvent);
X(vkDestroyFence); X(vkDestroyFence);
X(vkDestroyFramebuffer); X(vkDestroyFramebuffer);
@ -188,7 +188,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept {
X(vkSetDebugUtilsObjectNameEXT); X(vkSetDebugUtilsObjectNameEXT);
X(vkSetDebugUtilsObjectTagEXT); X(vkSetDebugUtilsObjectTagEXT);
X(vkUnmapMemory); X(vkUnmapMemory);
X(vkUpdateDescriptorSetWithTemplateKHR); X(vkUpdateDescriptorSetWithTemplate);
X(vkUpdateDescriptorSets); X(vkUpdateDescriptorSets);
X(vkWaitForFences); X(vkWaitForFences);
X(vkWaitSemaphores); X(vkWaitSemaphores);
@ -366,9 +366,9 @@ void Destroy(VkDevice device, VkDescriptorSetLayout handle, const DeviceDispatch
dld.vkDestroyDescriptorSetLayout(device, handle, nullptr); dld.vkDestroyDescriptorSetLayout(device, handle, nullptr);
} }
void Destroy(VkDevice device, VkDescriptorUpdateTemplateKHR handle, void Destroy(VkDevice device, VkDescriptorUpdateTemplate handle,
const DeviceDispatch& dld) noexcept { const DeviceDispatch& dld) noexcept {
dld.vkDestroyDescriptorUpdateTemplateKHR(device, handle, nullptr); dld.vkDestroyDescriptorUpdateTemplate(device, handle, nullptr);
} }
void Destroy(VkDevice device, VkDeviceMemory handle, const DeviceDispatch& dld) noexcept { void Destroy(VkDevice device, VkDeviceMemory handle, const DeviceDispatch& dld) noexcept {
@ -744,11 +744,11 @@ CommandPool Device::CreateCommandPool(const VkCommandPoolCreateInfo& ci) const {
return CommandPool(object, handle, *dld); return CommandPool(object, handle, *dld);
} }
DescriptorUpdateTemplateKHR Device::CreateDescriptorUpdateTemplateKHR( DescriptorUpdateTemplate Device::CreateDescriptorUpdateTemplate(
const VkDescriptorUpdateTemplateCreateInfoKHR& ci) const { const VkDescriptorUpdateTemplateCreateInfo& ci) const {
VkDescriptorUpdateTemplateKHR object; VkDescriptorUpdateTemplate object;
Check(dld->vkCreateDescriptorUpdateTemplateKHR(handle, &ci, nullptr, &object)); Check(dld->vkCreateDescriptorUpdateTemplate(handle, &ci, nullptr, &object));
return DescriptorUpdateTemplateKHR(object, handle, *dld); return DescriptorUpdateTemplate(object, handle, *dld);
} }
QueryPool Device::CreateQueryPool(const VkQueryPoolCreateInfo& ci) const { QueryPool Device::CreateQueryPool(const VkQueryPoolCreateInfo& ci) const {

View File

@ -247,7 +247,7 @@ struct DeviceDispatch : InstanceDispatch {
PFN_vkCreateComputePipelines vkCreateComputePipelines{}; PFN_vkCreateComputePipelines vkCreateComputePipelines{};
PFN_vkCreateDescriptorPool vkCreateDescriptorPool{}; PFN_vkCreateDescriptorPool vkCreateDescriptorPool{};
PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout{}; PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout{};
PFN_vkCreateDescriptorUpdateTemplateKHR vkCreateDescriptorUpdateTemplateKHR{}; PFN_vkCreateDescriptorUpdateTemplate vkCreateDescriptorUpdateTemplate{};
PFN_vkCreateEvent vkCreateEvent{}; PFN_vkCreateEvent vkCreateEvent{};
PFN_vkCreateFence vkCreateFence{}; PFN_vkCreateFence vkCreateFence{};
PFN_vkCreateFramebuffer vkCreateFramebuffer{}; PFN_vkCreateFramebuffer vkCreateFramebuffer{};
@ -266,7 +266,7 @@ struct DeviceDispatch : InstanceDispatch {
PFN_vkDestroyCommandPool vkDestroyCommandPool{}; PFN_vkDestroyCommandPool vkDestroyCommandPool{};
PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool{}; PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool{};
PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout{}; PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout{};
PFN_vkDestroyDescriptorUpdateTemplateKHR vkDestroyDescriptorUpdateTemplateKHR{}; PFN_vkDestroyDescriptorUpdateTemplate vkDestroyDescriptorUpdateTemplate{};
PFN_vkDestroyEvent vkDestroyEvent{}; PFN_vkDestroyEvent vkDestroyEvent{};
PFN_vkDestroyFence vkDestroyFence{}; PFN_vkDestroyFence vkDestroyFence{};
PFN_vkDestroyFramebuffer vkDestroyFramebuffer{}; PFN_vkDestroyFramebuffer vkDestroyFramebuffer{};
@ -305,7 +305,7 @@ struct DeviceDispatch : InstanceDispatch {
PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT{}; PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT{};
PFN_vkSetDebugUtilsObjectTagEXT vkSetDebugUtilsObjectTagEXT{}; PFN_vkSetDebugUtilsObjectTagEXT vkSetDebugUtilsObjectTagEXT{};
PFN_vkUnmapMemory vkUnmapMemory{}; PFN_vkUnmapMemory vkUnmapMemory{};
PFN_vkUpdateDescriptorSetWithTemplateKHR vkUpdateDescriptorSetWithTemplateKHR{}; PFN_vkUpdateDescriptorSetWithTemplate vkUpdateDescriptorSetWithTemplate{};
PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets{}; PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets{};
PFN_vkWaitForFences vkWaitForFences{}; PFN_vkWaitForFences vkWaitForFences{};
PFN_vkWaitSemaphores vkWaitSemaphores{}; PFN_vkWaitSemaphores vkWaitSemaphores{};
@ -327,7 +327,7 @@ void Destroy(VkDevice, VkBufferView, const DeviceDispatch&) noexcept;
void Destroy(VkDevice, VkCommandPool, const DeviceDispatch&) noexcept; void Destroy(VkDevice, VkCommandPool, const DeviceDispatch&) noexcept;
void Destroy(VkDevice, VkDescriptorPool, const DeviceDispatch&) noexcept; void Destroy(VkDevice, VkDescriptorPool, const DeviceDispatch&) noexcept;
void Destroy(VkDevice, VkDescriptorSetLayout, const DeviceDispatch&) noexcept; void Destroy(VkDevice, VkDescriptorSetLayout, const DeviceDispatch&) noexcept;
void Destroy(VkDevice, VkDescriptorUpdateTemplateKHR, const DeviceDispatch&) noexcept; void Destroy(VkDevice, VkDescriptorUpdateTemplate, const DeviceDispatch&) noexcept;
void Destroy(VkDevice, VkDeviceMemory, const DeviceDispatch&) noexcept; void Destroy(VkDevice, VkDeviceMemory, const DeviceDispatch&) noexcept;
void Destroy(VkDevice, VkEvent, const DeviceDispatch&) noexcept; void Destroy(VkDevice, VkEvent, const DeviceDispatch&) noexcept;
void Destroy(VkDevice, VkFence, const DeviceDispatch&) noexcept; void Destroy(VkDevice, VkFence, const DeviceDispatch&) noexcept;
@ -559,7 +559,7 @@ private:
using DebugUtilsMessenger = Handle<VkDebugUtilsMessengerEXT, VkInstance, InstanceDispatch>; using DebugUtilsMessenger = Handle<VkDebugUtilsMessengerEXT, VkInstance, InstanceDispatch>;
using DescriptorSetLayout = Handle<VkDescriptorSetLayout, VkDevice, DeviceDispatch>; using DescriptorSetLayout = Handle<VkDescriptorSetLayout, VkDevice, DeviceDispatch>;
using DescriptorUpdateTemplateKHR = Handle<VkDescriptorUpdateTemplateKHR, VkDevice, DeviceDispatch>; using DescriptorUpdateTemplate = Handle<VkDescriptorUpdateTemplate, VkDevice, DeviceDispatch>;
using Pipeline = Handle<VkPipeline, VkDevice, DeviceDispatch>; using Pipeline = Handle<VkPipeline, VkDevice, DeviceDispatch>;
using PipelineLayout = Handle<VkPipelineLayout, VkDevice, DeviceDispatch>; using PipelineLayout = Handle<VkPipelineLayout, VkDevice, DeviceDispatch>;
using QueryPool = Handle<VkQueryPool, VkDevice, DeviceDispatch>; using QueryPool = Handle<VkQueryPool, VkDevice, DeviceDispatch>;
@ -840,8 +840,8 @@ public:
CommandPool CreateCommandPool(const VkCommandPoolCreateInfo& ci) const; CommandPool CreateCommandPool(const VkCommandPoolCreateInfo& ci) const;
DescriptorUpdateTemplateKHR CreateDescriptorUpdateTemplateKHR( DescriptorUpdateTemplate CreateDescriptorUpdateTemplate(
const VkDescriptorUpdateTemplateCreateInfoKHR& ci) const; const VkDescriptorUpdateTemplateCreateInfo& ci) const;
QueryPool CreateQueryPool(const VkQueryPoolCreateInfo& ci) const; QueryPool CreateQueryPool(const VkQueryPoolCreateInfo& ci) const;
@ -869,9 +869,9 @@ public:
void UpdateDescriptorSets(Span<VkWriteDescriptorSet> writes, void UpdateDescriptorSets(Span<VkWriteDescriptorSet> writes,
Span<VkCopyDescriptorSet> copies) const noexcept; Span<VkCopyDescriptorSet> copies) const noexcept;
void UpdateDescriptorSet(VkDescriptorSet set, VkDescriptorUpdateTemplateKHR update_template, void UpdateDescriptorSet(VkDescriptorSet set, VkDescriptorUpdateTemplate update_template,
const void* data) const noexcept { const void* data) const noexcept {
dld->vkUpdateDescriptorSetWithTemplateKHR(handle, set, update_template, data); dld->vkUpdateDescriptorSetWithTemplate(handle, set, update_template, data);
} }
VkResult AcquireNextImageKHR(VkSwapchainKHR swapchain, u64 timeout, VkSemaphore semaphore, VkResult AcquireNextImageKHR(VkSwapchainKHR swapchain, u64 timeout, VkSemaphore semaphore,
@ -980,7 +980,7 @@ public:
dynamic_offsets.size(), dynamic_offsets.data()); dynamic_offsets.size(), dynamic_offsets.data());
} }
void PushDescriptorSetWithTemplateKHR(VkDescriptorUpdateTemplateKHR update_template, void PushDescriptorSetWithTemplateKHR(VkDescriptorUpdateTemplate update_template,
VkPipelineLayout layout, u32 set, VkPipelineLayout layout, u32 set,
const void* data) const noexcept { const void* data) const noexcept {
dld->vkCmdPushDescriptorSetWithTemplateKHR(handle, update_template, layout, set, data); dld->vkCmdPushDescriptorSetWithTemplateKHR(handle, update_template, layout, set, data);