subresource_range);
}
+std::unique_ptr<Vulkan_descriptor_set_layout> Vulkan_descriptor_set_layout::create(
+ Vulkan_device &device, const VkDescriptorSetLayoutCreateInfo &create_info)
+{
+ assert(create_info.sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO);
+ constexpr VkDescriptorSetLayoutCreateFlags supported_flags = 0;
+ assert((create_info.flags & ~supported_flags) == 0);
+ assert(create_info.bindingCount == 0 || create_info.pBindings);
+ std::vector<Binding> bindings;
+ bindings.reserve(create_info.bindingCount);
+ for(std::uint32_t i = 0; i<create_info.bindingCount;i++)
+ bindings.emplace_back(create_info.pBindings[i]);
+ return std::make_unique<Vulkan_descriptor_set_layout>(std::move(bindings));
+}
+
std::unique_ptr<Vulkan_render_pass> Vulkan_render_pass::create(
Vulkan_device &device, const VkRenderPassCreateInfo &create_info)
{
const VkImageViewCreateInfo &create_info);
};
+struct Vulkan_sampler : public Vulkan_nondispatchable_object<Vulkan_sampler, VkSampler>
+{
+#warning finish implementing Vulkan_sampler
+};
+
+struct Vulkan_descriptor_set_layout
+ : public Vulkan_nondispatchable_object<Vulkan_descriptor_set_layout, VkDescriptorSetLayout>
+{
+ struct Binding
+ {
+ std::uint32_t binding;
+ VkDescriptorType descriptor_type;
+ std::uint32_t descriptor_count;
+ std::unique_ptr<Vulkan_sampler *[]> immutable_samplers;
+ explicit Binding(const VkDescriptorSetLayoutBinding &descriptor_set_layout_binding)
+ : binding(descriptor_set_layout_binding.binding),
+ descriptor_type(descriptor_set_layout_binding.descriptorType),
+ descriptor_count(descriptor_set_layout_binding.descriptorCount),
+ immutable_samplers()
+ {
+ if((descriptor_type == VK_DESCRIPTOR_TYPE_SAMPLER
+ || descriptor_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
+ && descriptor_count != 0
+ && descriptor_set_layout_binding.pImmutableSamplers)
+ {
+ immutable_samplers.reset(new Vulkan_sampler *[descriptor_count]);
+ for(std::uint32_t i = 0; i < descriptor_count; i++)
+ {
+ auto *sampler = Vulkan_sampler::from_handle(
+ descriptor_set_layout_binding.pImmutableSamplers[i]);
+ assert(sampler);
+ immutable_samplers[i] = sampler;
+ }
+ }
+ }
+ };
+ std::vector<Binding> bindings;
+ explicit Vulkan_descriptor_set_layout(std::vector<Binding> bindings) noexcept
+ : bindings(std::move(bindings))
+ {
+ }
+ static std::unique_ptr<Vulkan_descriptor_set_layout> create(
+ Vulkan_device &device, const VkDescriptorSetLayoutCreateInfo &create_info);
+};
+
struct Vulkan_render_pass : public Vulkan_nondispatchable_object<Vulkan_render_pass, VkRenderPass>
{
#warning finish implementing Vulkan_render_pass
extern "C" VKAPI_ATTR VkResult VKAPI_CALL
vkCreateDescriptorSetLayout(VkDevice device,
- const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
+ const VkDescriptorSetLayoutCreateInfo *create_info,
const VkAllocationCallbacks *allocator,
- VkDescriptorSetLayout *pSetLayout)
+ VkDescriptorSetLayout *set_layout)
{
validate_allocator(allocator);
-#warning finish implementing vkCreateDescriptorSetLayout
- assert(!"vkCreateDescriptorSetLayout is not implemented");
+ assert(device);
+ assert(create_info);
+ assert(set_layout);
+ return vulkan_icd::catch_exceptions_and_return_result(
+ [&]()
+ {
+ auto create_result = vulkan::Vulkan_descriptor_set_layout::create(
+ *vulkan::Vulkan_device::from_handle(device), *create_info);
+ *set_layout = move_to_handle(std::move(create_result));
+ return VK_SUCCESS;
+ });
}
extern "C" VKAPI_ATTR void VKAPI_CALL
vkDestroyDescriptorSetLayout(VkDevice device,
- VkDescriptorSetLayout descriptorSetLayout,
+ VkDescriptorSetLayout descriptor_set_layout,
const VkAllocationCallbacks *allocator)
{
validate_allocator(allocator);
-#warning finish implementing vkDestroyDescriptorSetLayout
- assert(!"vkDestroyDescriptorSetLayout is not implemented");
+ assert(device);
+ vulkan::Vulkan_descriptor_set_layout::move_from_handle(descriptor_set_layout).reset();
}
extern "C" VKAPI_ATTR VkResult VKAPI_CALL