Add new Renderer architecture (far from complete)
Former-commit-id: 52226793d7a087dfe0523315d3303934daffee49 [formerly 9de1c04df6b371f861a2eee8bba38902ee5041cd] [formerly ecd3099df5498722f6390447f40bd3907b8e40c4 [formerly 3076df585565fc9759ab3e718270f2e5ef620840]] Former-commit-id: 92d52f967d0b088d1271afef26069e08cacd6b0f [formerly 5fe27e2ead104278951c772c2121a7b677f88d4d] Former-commit-id: fb6c2456d8edd3ec022d5d953f79fecdd4f2b8f4
This commit is contained in:
122
include/Nazara/VulkanRenderer/VkDescriptorSet.inl
Normal file
122
include/Nazara/VulkanRenderer/VkDescriptorSet.inl
Normal file
@@ -0,0 +1,122 @@
|
||||
// Copyright (C) 2016 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Vulkan Renderer"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/VkDescriptorSet.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/VulkanRenderer/VkInstance.hpp>
|
||||
#include <Nazara/VulkanRenderer/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/VulkanRenderer/DebugOff.hpp>
|
||||
Reference in New Issue
Block a user