Vulkan: Add support for Descriptors
Former-commit-id: 3aeb182030040b707dd2d98ddb2991a3b7f58b19 [formerly bf30ae4035d9855f493252bd7c1c95d97e7f4bf5] Former-commit-id: 8bdbc5f6ff1bec375c80b0974bdd1e269cfca675
This commit is contained in:
parent
2e61964de4
commit
6d737b07cc
|
|
@ -1,4 +1,4 @@
|
||||||
// This file was automatically generated on 12 Jul 2016 at 17:44:44
|
// This file was automatically generated on 20 Jul 2016 at 13:49:17
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Nazara Engine - Vulkan
|
Nazara Engine - Vulkan
|
||||||
|
|
@ -35,6 +35,9 @@
|
||||||
#include <Nazara/Vulkan/VkBuffer.hpp>
|
#include <Nazara/Vulkan/VkBuffer.hpp>
|
||||||
#include <Nazara/Vulkan/VkCommandBuffer.hpp>
|
#include <Nazara/Vulkan/VkCommandBuffer.hpp>
|
||||||
#include <Nazara/Vulkan/VkCommandPool.hpp>
|
#include <Nazara/Vulkan/VkCommandPool.hpp>
|
||||||
|
#include <Nazara/Vulkan/VkDescriptorPool.hpp>
|
||||||
|
#include <Nazara/Vulkan/VkDescriptorSet.hpp>
|
||||||
|
#include <Nazara/Vulkan/VkDescriptorSetLayout.hpp>
|
||||||
#include <Nazara/Vulkan/VkDevice.hpp>
|
#include <Nazara/Vulkan/VkDevice.hpp>
|
||||||
#include <Nazara/Vulkan/VkDeviceMemory.hpp>
|
#include <Nazara/Vulkan/VkDeviceMemory.hpp>
|
||||||
#include <Nazara/Vulkan/VkDeviceObject.hpp>
|
#include <Nazara/Vulkan/VkDeviceObject.hpp>
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,9 @@ namespace Nz
|
||||||
|
|
||||||
inline void BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
|
inline void BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
||||||
|
inline void BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, const VkDescriptorSet& descriptorSets);
|
||||||
|
inline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets);
|
||||||
|
inline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets, UInt32 dynamicOffsetCount, const UInt32* dynamicOffsets);
|
||||||
inline void BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType);
|
inline void BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType);
|
||||||
inline void BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline);
|
inline void BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline);
|
||||||
inline void BindVertexBuffer(UInt32 binding, const VkBuffer buffer, const VkDeviceSize offset);
|
inline void BindVertexBuffer(UInt32 binding, const VkBuffer buffer, const VkDeviceSize offset);
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,21 @@ namespace Nz
|
||||||
return m_pool->GetDevice()->vkCmdBeginRenderPass(m_handle, &beginInfo, contents);
|
return m_pool->GetDevice()->vkCmdBeginRenderPass(m_handle, &beginInfo, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void CommandBuffer::BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, const VkDescriptorSet& descriptorSets)
|
||||||
|
{
|
||||||
|
return BindDescriptorSets(pipelineBindPoint, layout, firstSet, 1U, &descriptorSets);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CommandBuffer::BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets)
|
||||||
|
{
|
||||||
|
return BindDescriptorSets(pipelineBindPoint, layout, firstSet, descriptorSetCount, descriptorSets, 0U, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CommandBuffer::BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets, UInt32 dynamicOffsetCount, const UInt32* dynamicOffsets)
|
||||||
|
{
|
||||||
|
return m_pool->GetDevice()->vkCmdBindDescriptorSets(m_handle, pipelineBindPoint, layout, firstSet, descriptorSetCount, descriptorSets, dynamicOffsetCount, dynamicOffsets);
|
||||||
|
}
|
||||||
|
|
||||||
inline void CommandBuffer::BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
|
inline void CommandBuffer::BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
|
||||||
{
|
{
|
||||||
return m_pool->GetDevice()->vkCmdBindIndexBuffer(m_handle, buffer, offset, indexType);
|
return m_pool->GetDevice()->vkCmdBindIndexBuffer(m_handle, buffer, offset, indexType);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
// 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
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NAZARA_VULKAN_VKDESCRIPTORPOOL_HPP
|
||||||
|
#define NAZARA_VULKAN_VKDESCRIPTORPOOL_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Core/HandledObject.hpp>
|
||||||
|
#include <Nazara/Vulkan/VkDeviceObject.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
namespace Vk
|
||||||
|
{
|
||||||
|
class DescriptorPool;
|
||||||
|
class DescriptorSet;
|
||||||
|
|
||||||
|
using DescriptorPoolHandle = ObjectHandle<DescriptorPool>;
|
||||||
|
|
||||||
|
class NAZARA_VULKAN_API DescriptorPool : public DeviceObject<DescriptorPool, VkDescriptorPool, VkDescriptorPoolCreateInfo>, public HandledObject<DescriptorPool>
|
||||||
|
{
|
||||||
|
friend DeviceObject;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DescriptorPool() = default;
|
||||||
|
DescriptorPool(const DescriptorPool&) = delete;
|
||||||
|
DescriptorPool(DescriptorPool&&) = default;
|
||||||
|
~DescriptorPool() = default;
|
||||||
|
|
||||||
|
DescriptorSet AllocateDescriptorSet(const VkDescriptorSetLayout& setLayouts);
|
||||||
|
std::vector<DescriptorSet> AllocateDescriptorSets(UInt32 descriptorSetCount, const VkDescriptorSetLayout* setLayouts);
|
||||||
|
|
||||||
|
using DeviceObject::Create;
|
||||||
|
inline bool Create(const DeviceHandle& device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr);
|
||||||
|
inline bool Create(const DeviceHandle& device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr);
|
||||||
|
|
||||||
|
DescriptorPool& operator=(const DescriptorPool&) = delete;
|
||||||
|
DescriptorPool& operator=(DescriptorPool&&) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline VkResult CreateHelper(const DeviceHandle& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle);
|
||||||
|
static inline void DestroyHelper(const DeviceHandle& device, VkDescriptorPool handle, const VkAllocationCallbacks* allocator);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Vulkan/VkDescriptorPool.inl>
|
||||||
|
|
||||||
|
#endif // NAZARA_VULKAN_VKDESCRIPTORPOOL_HPP
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
// 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/Debug.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
namespace Vk
|
||||||
|
{
|
||||||
|
inline bool DescriptorPool::Create(const DeviceHandle& device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
VkDescriptorPoolCreateInfo createInfo =
|
||||||
|
{
|
||||||
|
VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, // VkStructureType sType;
|
||||||
|
nullptr, // const void* pNext;
|
||||||
|
flags, // VkDescriptorPoolCreateFlags flags;
|
||||||
|
maxSets, // uint32_t maxSets;
|
||||||
|
1U, // uint32_t poolSizeCount;
|
||||||
|
&poolSize // const VkDescriptorPoolSize* pPoolSizes;
|
||||||
|
};
|
||||||
|
|
||||||
|
return Create(device, createInfo, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool DescriptorPool::Create(const DeviceHandle& device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
VkDescriptorPoolCreateInfo createInfo =
|
||||||
|
{
|
||||||
|
VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, // VkStructureType sType;
|
||||||
|
nullptr, // const void* pNext;
|
||||||
|
flags, // VkDescriptorPoolCreateFlags flags;
|
||||||
|
maxSets, // uint32_t maxSets;
|
||||||
|
poolSizeCount, // uint32_t poolSizeCount;
|
||||||
|
poolSize // const VkDescriptorPoolSize* pPoolSizes;
|
||||||
|
};
|
||||||
|
|
||||||
|
return Create(device, createInfo, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VkResult DescriptorPool::CreateHelper(const DeviceHandle& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle)
|
||||||
|
{
|
||||||
|
return device->vkCreateDescriptorPool(*device, createInfo, allocator, handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DescriptorPool::DestroyHelper(const DeviceHandle& device, VkDescriptorPool handle, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
return device->vkDestroyDescriptorPool(*device, handle, allocator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Vulkan/DebugOff.hpp>
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
// 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
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NAZARA_VULKAN_VKDESCRIPTORSET_HPP
|
||||||
|
#define NAZARA_VULKAN_VKDESCRIPTORSET_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Math/Rect.hpp>
|
||||||
|
#include <Nazara/Vulkan/VkDescriptorPool.hpp>
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
namespace Vk
|
||||||
|
{
|
||||||
|
class DescriptorSet
|
||||||
|
{
|
||||||
|
friend DescriptorPool;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline DescriptorSet();
|
||||||
|
DescriptorSet(const DescriptorSet&) = delete;
|
||||||
|
inline DescriptorSet(DescriptorSet&& descriptorSet);
|
||||||
|
inline ~DescriptorSet();
|
||||||
|
|
||||||
|
inline void Free();
|
||||||
|
|
||||||
|
inline VkResult GetLastErrorCode() const;
|
||||||
|
|
||||||
|
inline void WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range);
|
||||||
|
inline void WriteUniformDescriptor(UInt32 binding, const VkDescriptorBufferInfo& bufferInfo);
|
||||||
|
inline void WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range);
|
||||||
|
inline void WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorBufferInfo& bufferInfo);
|
||||||
|
inline void WriteUniformDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo);
|
||||||
|
inline void WriteUniformDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo);
|
||||||
|
|
||||||
|
DescriptorSet& operator=(const DescriptorSet&) = delete;
|
||||||
|
DescriptorSet& operator=(DescriptorSet&& descriptorSet);
|
||||||
|
|
||||||
|
inline operator VkDescriptorSet() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
inline DescriptorSet(DescriptorPool& pool, VkDescriptorSet handle);
|
||||||
|
|
||||||
|
DescriptorPoolHandle m_pool;
|
||||||
|
VkAllocationCallbacks m_allocator;
|
||||||
|
VkDescriptorSet m_handle;
|
||||||
|
VkResult m_lastErrorCode;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Vulkan/VkDescriptorSet.inl>
|
||||||
|
|
||||||
|
#endif // NAZARA_VULKAN_VKDESCRIPTORSET_HPP
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
// 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/VkDescriptorSet.hpp>
|
||||||
|
#include <Nazara/Core/Error.hpp>
|
||||||
|
#include <Nazara/Vulkan/VkInstance.hpp>
|
||||||
|
#include <Nazara/Vulkan/Debug.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
namespace Vk
|
||||||
|
{
|
||||||
|
inline DescriptorSet::DescriptorSet() :
|
||||||
|
m_pool(),
|
||||||
|
m_handle(VK_NULL_HANDLE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DescriptorSet::DescriptorSet(DescriptorPool& pool, VkDescriptorSet handle) :
|
||||||
|
m_pool(&pool),
|
||||||
|
m_handle(handle)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DescriptorSet::DescriptorSet(DescriptorSet&& descriptorSet) :
|
||||||
|
m_pool(std::move(descriptorSet.m_pool)),
|
||||||
|
m_allocator(descriptorSet.m_allocator),
|
||||||
|
m_handle(descriptorSet.m_handle),
|
||||||
|
m_lastErrorCode(descriptorSet.m_lastErrorCode)
|
||||||
|
{
|
||||||
|
descriptorSet.m_handle = VK_NULL_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DescriptorSet::~DescriptorSet()
|
||||||
|
{
|
||||||
|
Free();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DescriptorSet::Free()
|
||||||
|
{
|
||||||
|
if (m_handle)
|
||||||
|
m_pool->GetDevice()->vkFreeDescriptorSets(*m_pool->GetDevice(), *m_pool, 1, &m_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VkResult DescriptorSet::GetLastErrorCode() const
|
||||||
|
{
|
||||||
|
return m_lastErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range)
|
||||||
|
{
|
||||||
|
return WriteUniformDescriptor(binding, 0U, buffer, offset, range);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, const VkDescriptorBufferInfo& bufferInfo)
|
||||||
|
{
|
||||||
|
return WriteUniformDescriptors(binding, 0U, 1U, &bufferInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range)
|
||||||
|
{
|
||||||
|
VkDescriptorBufferInfo bufferInfo =
|
||||||
|
{
|
||||||
|
buffer, // VkBuffer buffer;
|
||||||
|
offset, // VkDeviceSize offset;
|
||||||
|
range // VkDeviceSize range;
|
||||||
|
};
|
||||||
|
|
||||||
|
return WriteUniformDescriptor(binding, arrayElement, bufferInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorBufferInfo& bufferInfo)
|
||||||
|
{
|
||||||
|
return WriteUniformDescriptors(binding, arrayElement, 1U, &bufferInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo)
|
||||||
|
{
|
||||||
|
return WriteUniformDescriptors(binding, 0U, descriptorCount, bufferInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo)
|
||||||
|
{
|
||||||
|
VkWriteDescriptorSet writeDescriptorSet =
|
||||||
|
{
|
||||||
|
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // VkStructureType sType;
|
||||||
|
nullptr, // const void* pNext;
|
||||||
|
m_handle, // VkDescriptorSet dstSet;
|
||||||
|
binding, // uint32_t dstBinding;
|
||||||
|
arrayElement, // uint32_t dstArrayElement;
|
||||||
|
descriptorCount, // uint32_t descriptorCount;
|
||||||
|
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, // VkDescriptorType descriptorType;
|
||||||
|
nullptr, // const VkDescriptorImageInfo* pImageInfo;
|
||||||
|
bufferInfo, // const VkDescriptorBufferInfo* pBufferInfo;
|
||||||
|
nullptr // const VkBufferView* pTexelBufferView;
|
||||||
|
};
|
||||||
|
|
||||||
|
return m_pool->GetDevice()->vkUpdateDescriptorSets(*m_pool->GetDevice(), 1U, &writeDescriptorSet, 0U, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DescriptorSet& DescriptorSet::operator=(DescriptorSet&& descriptorSet)
|
||||||
|
{
|
||||||
|
m_allocator = descriptorSet.m_allocator;
|
||||||
|
m_handle = descriptorSet.m_handle;
|
||||||
|
m_lastErrorCode = descriptorSet.m_lastErrorCode;
|
||||||
|
m_pool = std::move(descriptorSet.m_pool);
|
||||||
|
m_handle = descriptorSet.m_handle;
|
||||||
|
|
||||||
|
descriptorSet.m_handle = VK_NULL_HANDLE;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DescriptorSet::operator VkDescriptorSet() const
|
||||||
|
{
|
||||||
|
return m_handle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Vulkan/DebugOff.hpp>
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
// 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
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NAZARA_VULKAN_VKDESCRIPTORSETLAYOUT_HPP
|
||||||
|
#define NAZARA_VULKAN_VKDESCRIPTORSETLAYOUT_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Vulkan/VkDeviceObject.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
namespace Vk
|
||||||
|
{
|
||||||
|
class DescriptorSetLayout : public DeviceObject<DescriptorSetLayout, VkDescriptorSetLayout, VkDescriptorSetLayoutCreateInfo>
|
||||||
|
{
|
||||||
|
friend DeviceObject;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DescriptorSetLayout() = default;
|
||||||
|
DescriptorSetLayout(const DescriptorSetLayout&) = delete;
|
||||||
|
DescriptorSetLayout(DescriptorSetLayout&&) = default;
|
||||||
|
~DescriptorSetLayout() = default;
|
||||||
|
|
||||||
|
using DeviceObject::Create;
|
||||||
|
inline bool Create(const DeviceHandle& device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr);
|
||||||
|
inline bool Create(const DeviceHandle& device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr);
|
||||||
|
|
||||||
|
DescriptorSetLayout& operator=(const DescriptorSetLayout&) = delete;
|
||||||
|
DescriptorSetLayout& operator=(DescriptorSetLayout&&) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline VkResult CreateHelper(const DeviceHandle& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle);
|
||||||
|
static inline void DestroyHelper(const DeviceHandle& device, VkDescriptorSetLayout handle, const VkAllocationCallbacks* allocator);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Vulkan/VkDescriptorSetLayout.inl>
|
||||||
|
|
||||||
|
#endif // NAZARA_VULKAN_VKDESCRIPTORSETLAYOUT_HPP
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
// 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/VkDescriptorSetLayout.hpp>
|
||||||
|
#include <Nazara/Vulkan/Debug.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
namespace Vk
|
||||||
|
{
|
||||||
|
inline bool DescriptorSetLayout::Create(const DeviceHandle& device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
return Create(device, 1U, &binding, flags, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool DescriptorSetLayout::Create(const DeviceHandle& device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
VkDescriptorSetLayoutCreateInfo createInfo =
|
||||||
|
{
|
||||||
|
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, // VkStructureType sType;
|
||||||
|
nullptr, // const void* pNext;
|
||||||
|
flags, // VkDescriptorSetLayoutCreateFlags flags;
|
||||||
|
bindingCount, // uint32_t bindingCount;
|
||||||
|
binding // const VkDescriptorSetLayoutBinding* pBindings;
|
||||||
|
};
|
||||||
|
|
||||||
|
return Create(device, createInfo, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VkResult DescriptorSetLayout::CreateHelper(const DeviceHandle& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle)
|
||||||
|
{
|
||||||
|
return device->vkCreateDescriptorSetLayout(*device, createInfo, allocator, handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DescriptorSetLayout::DestroyHelper(const DeviceHandle& device, VkDescriptorSetLayout handle, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
return device->vkDestroyDescriptorSetLayout(*device, handle, allocator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Vulkan/DebugOff.hpp>
|
||||||
|
|
@ -63,6 +63,7 @@ namespace Nz
|
||||||
|
|
||||||
// Vulkan core
|
// Vulkan core
|
||||||
NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateCommandBuffers);
|
NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateCommandBuffers);
|
||||||
|
NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateDescriptorSets);
|
||||||
NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateMemory);
|
NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateMemory);
|
||||||
NAZARA_VULKAN_DEVICE_FUNCTION(vkBeginCommandBuffer);
|
NAZARA_VULKAN_DEVICE_FUNCTION(vkBeginCommandBuffer);
|
||||||
NAZARA_VULKAN_DEVICE_FUNCTION(vkBindBufferMemory);
|
NAZARA_VULKAN_DEVICE_FUNCTION(vkBindBufferMemory);
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -50,6 +50,7 @@ namespace Nz
|
||||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||||
|
|
||||||
NAZARA_VULKAN_LOAD_DEVICE(vkAllocateCommandBuffers);
|
NAZARA_VULKAN_LOAD_DEVICE(vkAllocateCommandBuffers);
|
||||||
|
NAZARA_VULKAN_LOAD_DEVICE(vkAllocateDescriptorSets);
|
||||||
NAZARA_VULKAN_LOAD_DEVICE(vkAllocateMemory);
|
NAZARA_VULKAN_LOAD_DEVICE(vkAllocateMemory);
|
||||||
NAZARA_VULKAN_LOAD_DEVICE(vkBeginCommandBuffer);
|
NAZARA_VULKAN_LOAD_DEVICE(vkBeginCommandBuffer);
|
||||||
NAZARA_VULKAN_LOAD_DEVICE(vkBindBufferMemory);
|
NAZARA_VULKAN_LOAD_DEVICE(vkBindBufferMemory);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue