OpenGL: Implement RenderPipelineLayout
This commit is contained in:
@@ -12,11 +12,7 @@
|
||||
#include <Nazara/Renderer/RenderPipelineLayout.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Config.hpp>
|
||||
#include <Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Device.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DescriptorPool.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DescriptorSet.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DescriptorSetLayout.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/PipelineLayout.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
@@ -28,39 +24,59 @@ namespace Nz
|
||||
friend OpenGLShaderBinding;
|
||||
|
||||
public:
|
||||
OpenGLRenderPipelineLayout() = default;
|
||||
OpenGLRenderPipelineLayout(RenderPipelineLayoutInfo layoutInfo);
|
||||
OpenGLRenderPipelineLayout(const OpenGLRenderPipelineLayout&) = delete;
|
||||
OpenGLRenderPipelineLayout(OpenGLRenderPipelineLayout&&) = delete;
|
||||
~OpenGLRenderPipelineLayout();
|
||||
|
||||
ShaderBindingPtr AllocateShaderBinding() override;
|
||||
|
||||
bool Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo);
|
||||
inline const RenderPipelineLayoutInfo& GetLayoutInfo() const;
|
||||
|
||||
inline Vk::Device* GetDevice() const;
|
||||
inline std::size_t GetTextureDescriptorCount() const;
|
||||
inline std::size_t GetUniformBufferDescriptorCount() const;
|
||||
|
||||
inline const Vk::DescriptorSetLayout& GetDescriptorSetLayout() const;
|
||||
inline const Vk::PipelineLayout& GetPipelineLayout() const;
|
||||
OpenGLRenderPipelineLayout& operator=(const OpenGLRenderPipelineLayout&) = delete;
|
||||
OpenGLRenderPipelineLayout& operator=(OpenGLRenderPipelineLayout&&) = delete;
|
||||
|
||||
private:
|
||||
struct DescriptorPool;
|
||||
struct TextureDescriptor;
|
||||
struct UniformBufferDescriptor;
|
||||
|
||||
DescriptorPool& AllocatePool();
|
||||
ShaderBindingPtr AllocateFromPool(std::size_t poolIndex);
|
||||
TextureDescriptor& GetTextureDescriptor(std::size_t poolIndex, std::size_t bindingIndex, std::size_t textureIndex);
|
||||
UniformBufferDescriptor& GetUniformBufferDescriptor(std::size_t poolIndex, std::size_t bindingIndex, std::size_t uniformBufferIndex);
|
||||
void Release(ShaderBinding& binding);
|
||||
inline void TryToShrink();
|
||||
|
||||
struct TextureDescriptor
|
||||
{
|
||||
GLuint texture;
|
||||
GLuint sampler;
|
||||
};
|
||||
|
||||
struct UniformBufferDescriptor
|
||||
{
|
||||
GLuint buffer;
|
||||
GLintptr offset;
|
||||
GLsizeiptr size;
|
||||
};
|
||||
|
||||
struct DescriptorPool
|
||||
{
|
||||
using BindingStorage = std::aligned_storage_t<sizeof(OpenGLShaderBinding), alignof(OpenGLShaderBinding)>;
|
||||
|
||||
Bitset<UInt64> freeBindings;
|
||||
Vk::DescriptorPool descriptorPool;
|
||||
std::vector<TextureDescriptor> textureDescriptor;
|
||||
std::vector<UniformBufferDescriptor> uniformBufferDescriptor;
|
||||
std::unique_ptr<BindingStorage[]> storage;
|
||||
};
|
||||
|
||||
MovablePtr<Vk::Device> m_device;
|
||||
std::size_t m_textureDescriptorCount;
|
||||
std::size_t m_uniformBufferDescriptorCount;
|
||||
std::vector<DescriptorPool> m_descriptorPools;
|
||||
Vk::DescriptorSetLayout m_descriptorSetLayout;
|
||||
Vk::PipelineLayout m_pipelineLayout;
|
||||
RenderPipelineLayoutInfo m_layoutInfo;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline Vk::Device* OpenGLRenderPipelineLayout::GetDevice() const
|
||||
inline const RenderPipelineLayoutInfo& OpenGLRenderPipelineLayout::GetLayoutInfo() const
|
||||
{
|
||||
return m_device.Get();
|
||||
return m_layoutInfo;
|
||||
}
|
||||
|
||||
inline const Vk::DescriptorSetLayout& OpenGLRenderPipelineLayout::GetDescriptorSetLayout() const
|
||||
inline std::size_t OpenGLRenderPipelineLayout::GetTextureDescriptorCount() const
|
||||
{
|
||||
return m_descriptorSetLayout;
|
||||
return m_textureDescriptorCount;
|
||||
}
|
||||
|
||||
inline const Vk::PipelineLayout& OpenGLRenderPipelineLayout::GetPipelineLayout() const
|
||||
inline std::size_t OpenGLRenderPipelineLayout::GetUniformBufferDescriptorCount() const
|
||||
{
|
||||
return m_pipelineLayout;
|
||||
return m_uniformBufferDescriptorCount;
|
||||
}
|
||||
|
||||
inline void OpenGLRenderPipelineLayout::TryToShrink()
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#define NAZARA_OPENGLRENDERER_OPENGLSHADERBINDING_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Config.hpp>
|
||||
#include <Nazara/Renderer/ShaderBinding.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DescriptorSet.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -18,13 +18,12 @@ namespace Nz
|
||||
class NAZARA_OPENGLRENDERER_API OpenGLShaderBinding : public ShaderBinding
|
||||
{
|
||||
public:
|
||||
inline OpenGLShaderBinding(OpenGLRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex, Vk::DescriptorSet descriptorSet);
|
||||
inline OpenGLShaderBinding(OpenGLRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex);
|
||||
OpenGLShaderBinding(const OpenGLShaderBinding&) = default;
|
||||
OpenGLShaderBinding(OpenGLShaderBinding&&) noexcept = default;
|
||||
~OpenGLShaderBinding() = default;
|
||||
|
||||
inline std::size_t GetBindingIndex() const;
|
||||
inline const Vk::DescriptorSet& GetDescriptorSet() const;
|
||||
inline std::size_t GetPoolIndex() const;
|
||||
inline const OpenGLRenderPipelineLayout& GetOwner() const;
|
||||
|
||||
@@ -36,7 +35,6 @@ namespace Nz
|
||||
private:
|
||||
void Release() override;
|
||||
|
||||
Vk::AutoDescriptorSet m_descriptorSet;
|
||||
OpenGLRenderPipelineLayout& m_owner;
|
||||
std::size_t m_bindingIndex;
|
||||
std::size_t m_poolIndex;
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline OpenGLShaderBinding::OpenGLShaderBinding(OpenGLRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex, Vk::DescriptorSet descriptorSet) :
|
||||
m_descriptorSet(std::move(descriptorSet)),
|
||||
inline OpenGLShaderBinding::OpenGLShaderBinding(OpenGLRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex) :
|
||||
m_owner(owner),
|
||||
m_bindingIndex(bindingIndex),
|
||||
m_poolIndex(poolIndex)
|
||||
@@ -25,11 +24,6 @@ namespace Nz
|
||||
return m_poolIndex;
|
||||
}
|
||||
|
||||
inline const Vk::DescriptorSet& OpenGLShaderBinding::GetDescriptorSet() const
|
||||
{
|
||||
return m_descriptorSet;
|
||||
}
|
||||
|
||||
inline const OpenGLRenderPipelineLayout& OpenGLShaderBinding::GetOwner() const
|
||||
{
|
||||
return m_owner;
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Nz
|
||||
PixelFormat GetFormat() const override;
|
||||
UInt8 GetLevelCount() const override;
|
||||
Vector3ui GetSize(UInt8 level = 0) const override;
|
||||
inline const GL::Texture& GetTexture() const;
|
||||
ImageType GetType() const override;
|
||||
|
||||
bool Update(const void* ptr) override;
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline const GL::Texture& OpenGLTexture::GetTexture() const
|
||||
{
|
||||
return m_texture;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
|
||||
Reference in New Issue
Block a user