mirror of https://github.com/snes9xgit/snes9x.git
Vulkan: Move descriptor pool out of context.
This commit is contained in:
parent
20768ed8b2
commit
e6c4f617cc
|
@ -22,7 +22,6 @@ Context::~Context()
|
|||
wait_idle();
|
||||
swapchain.reset();
|
||||
command_pool.reset();
|
||||
descriptor_pool.reset();
|
||||
allocator.destroy();
|
||||
surface.reset();
|
||||
wait_idle();
|
||||
|
@ -179,28 +178,11 @@ bool Context::init()
|
|||
init_device();
|
||||
init_vma();
|
||||
init_command_pool();
|
||||
init_descriptor_pool();
|
||||
|
||||
wait_idle();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Context::init_descriptor_pool()
|
||||
{
|
||||
auto descriptor_pool_size = vk::DescriptorPoolSize{}
|
||||
.setDescriptorCount(9)
|
||||
.setType(vk::DescriptorType::eCombinedImageSampler);
|
||||
auto descriptor_pool_create_info = vk::DescriptorPoolCreateInfo{}
|
||||
.setPoolSizes(descriptor_pool_size)
|
||||
.setMaxSets(20)
|
||||
.setFlags(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet);
|
||||
|
||||
auto retval = device.createDescriptorPoolUnique(descriptor_pool_create_info);
|
||||
descriptor_pool = std::move(retval.value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Context::init_command_pool()
|
||||
{
|
||||
vk::CommandPoolCreateInfo cpci({}, graphics_queue_family_index);
|
||||
|
|
|
@ -50,7 +50,6 @@ class Context
|
|||
uint32_t graphics_queue_family_index;
|
||||
vk::Queue queue;
|
||||
vk::UniqueCommandPool command_pool;
|
||||
vk::UniqueDescriptorPool descriptor_pool;
|
||||
std::unique_ptr<Swapchain> swapchain;
|
||||
vk::UniqueInstance instance;
|
||||
vk::PhysicalDevice physical_device;
|
||||
|
@ -61,7 +60,6 @@ class Context
|
|||
bool init_vma();
|
||||
bool init_device();
|
||||
bool init_command_pool();
|
||||
bool init_descriptor_pool();
|
||||
int preferred_device;
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_KHR
|
||||
|
|
|
@ -48,6 +48,7 @@ SimpleOutput::~SimpleOutput()
|
|||
context->wait_idle();
|
||||
textures.clear();
|
||||
descriptors.clear();
|
||||
descriptor_pool.reset();
|
||||
device.destroySampler(linear_sampler);
|
||||
device.destroySampler(nearest_sampler);
|
||||
}
|
||||
|
@ -55,11 +56,17 @@ SimpleOutput::~SimpleOutput()
|
|||
void SimpleOutput::create_objects()
|
||||
{
|
||||
descriptors.clear();
|
||||
descriptor_pool.reset();
|
||||
|
||||
vk::DescriptorPoolSize descriptor_pool_size(vk::DescriptorType::eCombinedImageSampler, 20);
|
||||
vk::DescriptorPoolCreateInfo dpci(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, 20,
|
||||
descriptor_pool_size);
|
||||
descriptor_pool = device.createDescriptorPoolUnique(dpci).value;
|
||||
|
||||
for (int i = 0; i < queue_size; i++)
|
||||
{
|
||||
vk::DescriptorSetAllocateInfo dsai{};
|
||||
dsai
|
||||
.setDescriptorPool(context->descriptor_pool.get())
|
||||
auto dsai = vk::DescriptorSetAllocateInfo{}
|
||||
.setDescriptorPool(descriptor_pool.get())
|
||||
.setDescriptorSetCount(1)
|
||||
.setSetLayouts(descriptor_set_layout.get());
|
||||
auto descriptor = device.allocateDescriptorSetsUnique(dsai).value;
|
||||
|
|
|
@ -25,6 +25,7 @@ class SimpleOutput
|
|||
vk::Device device;
|
||||
Vulkan::Swapchain *swapchain;
|
||||
|
||||
vk::UniqueDescriptorPool descriptor_pool;
|
||||
vk::UniqueDescriptorSetLayout descriptor_set_layout;
|
||||
vk::UniquePipelineLayout pipeline_layout;
|
||||
vk::UniquePipeline pipeline;
|
||||
|
|
Loading…
Reference in New Issue