Add texture in demo
This commit is contained in:
@@ -10,9 +10,11 @@
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/RenderPipelineLayout.hpp>
|
||||
#include <Nazara/VulkanRenderer/Config.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Device.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Device.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
@@ -23,13 +25,21 @@ namespace Nz
|
||||
VulkanRenderPipelineLayout() = default;
|
||||
~VulkanRenderPipelineLayout() = default;
|
||||
|
||||
Vk::DescriptorSet AllocateDescriptorSet();
|
||||
|
||||
bool Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo);
|
||||
|
||||
inline const Vk::DescriptorSetLayout& GetDescriptorSetLayout() const;
|
||||
inline const Vk::PipelineLayout& GetPipelineLayout() const;
|
||||
|
||||
private:
|
||||
struct DescriptorPool
|
||||
{
|
||||
Vk::DescriptorPool descriptorPool;
|
||||
};
|
||||
|
||||
MovablePtr<Vk::Device> m_device;
|
||||
std::vector<DescriptorPool> m_descriptorPools;
|
||||
Vk::DescriptorSetLayout m_descriptorSetLayout;
|
||||
Vk::PipelineLayout m_pipelineLayout;
|
||||
RenderPipelineLayoutInfo m_layoutInfo;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/RenderPass.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Sampler.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Semaphore.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Surface.hpp>
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace Nz
|
||||
inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange* ranges);
|
||||
|
||||
inline void CopyBuffer(VkBuffer source, VkBuffer target, UInt32 size, UInt32 sourceOffset = 0, UInt32 targetOffset = 0);
|
||||
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height);
|
||||
|
||||
inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0);
|
||||
inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0);
|
||||
|
||||
@@ -203,6 +203,29 @@ namespace Nz
|
||||
return m_pool->GetDevice()->vkCmdCopyBuffer(m_handle, source, target, 1, ®ion);
|
||||
}
|
||||
|
||||
inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height)
|
||||
{
|
||||
VkBufferImageCopy region = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{ // imageSubresource
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, //< aspectMask
|
||||
0,
|
||||
0,
|
||||
1
|
||||
},
|
||||
{ // imageOffset
|
||||
0, 0, 0
|
||||
},
|
||||
{ // imageExtent
|
||||
width, height, 1U
|
||||
}
|
||||
};
|
||||
|
||||
return m_pool->GetDevice()->vkCmdCopyBufferToImage(m_handle, source, target, targetLayout, 1, ®ion);
|
||||
}
|
||||
|
||||
inline void CommandBuffer::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance)
|
||||
{
|
||||
return m_pool->GetDevice()->vkCmdDraw(m_handle, vertexCount, instanceCount, firstVertex, firstInstance);
|
||||
|
||||
@@ -30,6 +30,13 @@ namespace Nz
|
||||
|
||||
inline bool IsValid() const;
|
||||
|
||||
inline void WriteCombinedImageSamplerDescriptor(UInt32 binding, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout);
|
||||
inline void WriteCombinedImageSamplerDescriptor(UInt32 binding, const VkDescriptorImageInfo& imageInfo);
|
||||
inline void WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout);
|
||||
inline void WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorImageInfo& imageInfo);
|
||||
inline void WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo);
|
||||
inline void WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo);
|
||||
|
||||
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);
|
||||
|
||||
@@ -50,6 +50,55 @@ namespace Nz
|
||||
return m_handle != VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout)
|
||||
{
|
||||
return WriteCombinedImageSamplerDescriptor(binding, 0, sampler, imageView, imageLayout);
|
||||
}
|
||||
|
||||
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, const VkDescriptorImageInfo& imageInfo)
|
||||
{
|
||||
return WriteCombinedImageSamplerDescriptor(binding, 0, imageInfo);
|
||||
}
|
||||
|
||||
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout)
|
||||
{
|
||||
VkDescriptorImageInfo imageInfo = {
|
||||
sampler,
|
||||
imageView,
|
||||
imageLayout
|
||||
};
|
||||
|
||||
return WriteCombinedImageSamplerDescriptors(binding, arrayElement, 1U, &imageInfo);
|
||||
}
|
||||
|
||||
inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorImageInfo& imageInfo)
|
||||
{
|
||||
return WriteCombinedImageSamplerDescriptors(binding, arrayElement, 1U, &imageInfo);
|
||||
}
|
||||
|
||||
inline void DescriptorSet::WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo)
|
||||
{
|
||||
return WriteCombinedImageSamplerDescriptors(binding, 0U, descriptorCount, imageInfo);
|
||||
}
|
||||
|
||||
inline void DescriptorSet::WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo)
|
||||
{
|
||||
VkWriteDescriptorSet writeDescriptorSet = {
|
||||
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
nullptr,
|
||||
m_handle,
|
||||
binding,
|
||||
arrayElement,
|
||||
descriptorCount,
|
||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
imageInfo,
|
||||
nullptr,
|
||||
nullptr
|
||||
};
|
||||
|
||||
return m_pool->GetDevice()->vkUpdateDescriptorSets(*m_pool->GetDevice(), 1U, &writeDescriptorSet, 0U, nullptr);
|
||||
}
|
||||
|
||||
inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range)
|
||||
{
|
||||
return WriteUniformDescriptor(binding, 0U, buffer, offset, range);
|
||||
|
||||
39
include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp
Normal file
39
include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2020 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_VULKANRENDERER_VKSAMPLER_HPP
|
||||
#define NAZARA_VULKANRENDERER_VKSAMPLER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
class Sampler : public DeviceObject<Sampler, VkSampler, VkSamplerCreateInfo>
|
||||
{
|
||||
friend DeviceObject;
|
||||
|
||||
public:
|
||||
Sampler() = default;
|
||||
Sampler(const Sampler&) = delete;
|
||||
Sampler(Sampler&&) = default;
|
||||
~Sampler() = default;
|
||||
|
||||
Sampler& operator=(const Sampler&) = delete;
|
||||
Sampler& operator=(Sampler&&) = delete;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkSamplerCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSampler* handle);
|
||||
static inline void DestroyHelper(Device& device, VkSampler handle, const VkAllocationCallbacks* allocator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Sampler.inl>
|
||||
|
||||
#endif // NAZARA_VULKANRENDERER_VKSAMPLER_HPP
|
||||
24
include/Nazara/VulkanRenderer/Wrapper/Sampler.inl
Normal file
24
include/Nazara/VulkanRenderer/Wrapper/Sampler.inl
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2020 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/Wrapper/Sampler.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline VkResult Sampler::CreateHelper(Device& device, const VkSamplerCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSampler* handle)
|
||||
{
|
||||
return device.vkCreateSampler(device, createInfo, allocator, handle);
|
||||
}
|
||||
|
||||
inline void Sampler::DestroyHelper(Device& device, VkSampler handle, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
return device.vkDestroySampler(device, handle, allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/DebugOff.hpp>
|
||||
Reference in New Issue
Block a user