Vulkan: Add support for Descriptors

Former-commit-id: 3aeb182030040b707dd2d98ddb2991a3b7f58b19 [formerly bf30ae4035d9855f493252bd7c1c95d97e7f4bf5]
Former-commit-id: 8bdbc5f6ff1bec375c80b0974bdd1e269cfca675
This commit is contained in:
Lynix
2016-07-21 12:25:05 +02:00
parent 2e61964de4
commit 6d737b07cc
12 changed files with 450 additions and 1 deletions

View File

@@ -0,0 +1,53 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Vulkan"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Vulkan/VkDescriptorPool.hpp>
#include <Nazara/Vulkan/VkDescriptorSet.hpp>
#include <Nazara/Vulkan/Debug.hpp>
namespace Nz
{
namespace Vk
{
DescriptorSet DescriptorPool::AllocateDescriptorSet(const VkDescriptorSetLayout& setLayouts)
{
VkDescriptorSetAllocateInfo createInfo =
{
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType;
nullptr, // const void* pNext;
m_handle, // VkDescriptorPool descriptorPool;
1U, // uint32_t descriptorSetCount;
&setLayouts // const VkDescriptorSetLayout* pSetLayouts;
};
VkDescriptorSet handle = VK_NULL_HANDLE;
m_lastErrorCode = m_device->vkAllocateDescriptorSets(*m_device, &createInfo, &handle);
return DescriptorSet(*this, handle);
}
std::vector<DescriptorSet> DescriptorPool::AllocateDescriptorSets(UInt32 descriptorSetCount, const VkDescriptorSetLayout* setLayouts)
{
VkDescriptorSetAllocateInfo createInfo =
{
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType;
nullptr, // const void* pNext;
m_handle, // VkDescriptorPool descriptorPool;
descriptorSetCount, // uint32_t descriptorSetCount;
setLayouts // const VkDescriptorSetLayout* pSetLayouts;
};
std::vector<VkDescriptorSet> handles(descriptorSetCount, VK_NULL_HANDLE);
m_lastErrorCode = m_device->vkAllocateDescriptorSets(*m_device, &createInfo, handles.data());
if (m_lastErrorCode != VkResult::VK_SUCCESS)
return std::vector<DescriptorSet>();
std::vector<DescriptorSet> descriptorSets;
for (UInt32 i = 0; i < descriptorSetCount; ++i)
descriptorSets.emplace_back(DescriptorSet(*this, handles[i]));
return descriptorSets;
}
}
}

View File

@@ -50,6 +50,7 @@ namespace Nz
ErrorFlags flags(ErrorFlag_ThrowException, true);
NAZARA_VULKAN_LOAD_DEVICE(vkAllocateCommandBuffers);
NAZARA_VULKAN_LOAD_DEVICE(vkAllocateDescriptorSets);
NAZARA_VULKAN_LOAD_DEVICE(vkAllocateMemory);
NAZARA_VULKAN_LOAD_DEVICE(vkBeginCommandBuffer);
NAZARA_VULKAN_LOAD_DEVICE(vkBindBufferMemory);