Add initial support for compute pipelines
This commit is contained in:
committed by
Jérôme Leclercq
parent
e4064997d8
commit
9578ba3ef5
@@ -20,6 +20,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class ComputePipeline;
|
||||
class Framebuffer;
|
||||
class RenderPass;
|
||||
class RenderPipeline;
|
||||
@@ -42,8 +43,9 @@ namespace Nz
|
||||
inline void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect);
|
||||
inline void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, std::initializer_list<ClearValues> clearValues);
|
||||
|
||||
virtual void BindComputePipeline(const ComputePipeline& pipeline) = 0;
|
||||
virtual void BindIndexBuffer(const RenderBuffer& indexBuffer, IndexType indexType, UInt64 offset = 0) = 0;
|
||||
virtual void BindPipeline(const RenderPipeline& pipeline) = 0;
|
||||
virtual void BindRenderPipeline(const RenderPipeline& pipeline) = 0;
|
||||
virtual void BindShaderBinding(UInt32 set, const ShaderBinding& binding) = 0;
|
||||
virtual void BindShaderBinding(const RenderPipelineLayout& pipelineLayout, UInt32 set, const ShaderBinding& binding) = 0;
|
||||
virtual void BindVertexBuffer(UInt32 binding, const RenderBuffer& vertexBuffer, UInt64 offset = 0) = 0;
|
||||
@@ -59,6 +61,8 @@ namespace Nz
|
||||
virtual void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) = 0;
|
||||
virtual void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstIndex = 0, UInt32 firstInstance = 0) = 0;
|
||||
|
||||
virtual void Dispatch(UInt32 workgroupX, UInt32 workgroupY, UInt32 workgroupZ) = 0;
|
||||
|
||||
virtual void EndDebugRegion() = 0;
|
||||
virtual void EndRenderPass() = 0;
|
||||
|
||||
|
||||
39
include/Nazara/Renderer/ComputePipeline.hpp
Normal file
39
include/Nazara/Renderer/ComputePipeline.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERER_COMPUTEPIPELINE_HPP
|
||||
#define NAZARA_RENDERER_COMPUTEPIPELINE_HPP
|
||||
|
||||
#include <Nazara/Renderer/RenderPipelineLayout.hpp>
|
||||
#include <Nazara/Renderer/ShaderModule.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class RenderPipelineLayout;
|
||||
class ShaderModule;
|
||||
|
||||
struct ComputePipelineInfo
|
||||
{
|
||||
std::shared_ptr<RenderPipelineLayout> pipelineLayout;
|
||||
std::shared_ptr<ShaderModule> shaderModule;
|
||||
};
|
||||
|
||||
class NAZARA_RENDERER_API ComputePipeline
|
||||
{
|
||||
public:
|
||||
ComputePipeline() = default;
|
||||
virtual ~ComputePipeline();
|
||||
|
||||
virtual const ComputePipelineInfo& GetPipelineInfo() const = 0;
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/ComputePipeline.inl>
|
||||
|
||||
#endif // NAZARA_RENDERER_COMPUTEPIPELINE_HPP
|
||||
13
include/Nazara/Renderer/ComputePipeline.inl
Normal file
13
include/Nazara/Renderer/ComputePipeline.inl
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/ComputePipeline.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
@@ -165,6 +165,7 @@ namespace Nz
|
||||
|
||||
enum class ShaderBindingType
|
||||
{
|
||||
Sampler,
|
||||
StorageBuffer,
|
||||
Texture,
|
||||
UniformBuffer,
|
||||
@@ -182,6 +183,13 @@ namespace Nz
|
||||
SpirV
|
||||
};
|
||||
|
||||
enum class TextureAccess
|
||||
{
|
||||
ReadOnly,
|
||||
ReadWrite,
|
||||
WriteOnly
|
||||
};
|
||||
|
||||
enum class TextureLayout
|
||||
{
|
||||
ColorInput,
|
||||
@@ -199,6 +207,7 @@ namespace Nz
|
||||
ColorAttachment,
|
||||
DepthStencilAttachment,
|
||||
InputAttachment,
|
||||
ShaderReadWrite,
|
||||
ShaderSampling,
|
||||
TransferSource,
|
||||
TransferDestination,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_RENDERER_RENDERDEVICE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/ComputePipeline.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/Framebuffer.hpp>
|
||||
@@ -40,6 +41,7 @@ namespace Nz
|
||||
|
||||
virtual std::shared_ptr<RenderBuffer> InstantiateBuffer(BufferType type, UInt64 size, BufferUsageFlags usageFlags, const void* initialData = nullptr) = 0;
|
||||
virtual std::shared_ptr<CommandPool> InstantiateCommandPool(QueueType queueType) = 0;
|
||||
virtual std::shared_ptr<ComputePipeline> InstantiateComputePipeline(ComputePipelineInfo pipelineInfo) = 0;
|
||||
virtual std::shared_ptr<Framebuffer> InstantiateFramebuffer(unsigned int width, unsigned int height, const std::shared_ptr<RenderPass>& renderPass, const std::vector<std::shared_ptr<Texture>>& attachments) = 0;
|
||||
virtual std::shared_ptr<RenderPass> InstantiateRenderPass(std::vector<RenderPass::Attachment> attachments, std::vector<RenderPass::SubpassDescription> subpassDescriptions, std::vector<RenderPass::SubpassDependency> subpassDependencies) = 0;
|
||||
virtual std::shared_ptr<RenderPipeline> InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) = 0;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_RENDERER_RENDERDEVICEINFO_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <string>
|
||||
|
||||
@@ -16,18 +17,27 @@ namespace Nz
|
||||
struct RenderDeviceFeatures
|
||||
{
|
||||
bool anisotropicFiltering = false;
|
||||
bool computeShaders = false;
|
||||
bool depthClamping = false;
|
||||
bool nonSolidFaceFilling = false;
|
||||
bool storageBuffers = false;
|
||||
bool textureRead = false;
|
||||
bool textureReadWithoutFormat = false;
|
||||
bool textureWrite = false;
|
||||
bool textureWriteWithoutFormat = false;
|
||||
bool unrestrictedTextureViews = false;
|
||||
};
|
||||
|
||||
struct RenderDeviceLimits
|
||||
{
|
||||
UInt64 minStorageBufferOffsetAlignment;
|
||||
UInt64 minUniformBufferOffsetAlignment;
|
||||
UInt64 maxComputeSharedMemorySize;
|
||||
UInt32 maxComputeWorkGroupInvocations;
|
||||
Vector3ui32 maxComputeWorkGroupCount;
|
||||
Vector3ui32 maxComputeWorkGroupSize;
|
||||
UInt64 maxStorageBufferSize;
|
||||
UInt64 maxUniformBufferSize;
|
||||
UInt64 minStorageBufferOffsetAlignment;
|
||||
UInt64 minUniformBufferOffsetAlignment;
|
||||
};
|
||||
|
||||
struct RenderDeviceInfo
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <variant>
|
||||
@@ -43,6 +44,18 @@ namespace Nz
|
||||
ShaderBinding& operator=(const ShaderBinding&) = delete;
|
||||
ShaderBinding& operator=(ShaderBinding&&) = delete;
|
||||
|
||||
struct SampledTextureBinding
|
||||
{
|
||||
const Texture* texture;
|
||||
const TextureSampler* sampler;
|
||||
};
|
||||
|
||||
struct SampledTextureBindings
|
||||
{
|
||||
UInt32 arraySize;
|
||||
const SampledTextureBinding* textureBindings;
|
||||
};
|
||||
|
||||
struct StorageBufferBinding
|
||||
{
|
||||
RenderBuffer* buffer;
|
||||
@@ -53,13 +66,7 @@ namespace Nz
|
||||
struct TextureBinding
|
||||
{
|
||||
const Texture* texture;
|
||||
const TextureSampler* sampler;
|
||||
};
|
||||
|
||||
struct TextureBindings
|
||||
{
|
||||
UInt32 arraySize;
|
||||
const TextureBinding* textureBindings;
|
||||
TextureAccess access;
|
||||
};
|
||||
|
||||
struct UniformBufferBinding
|
||||
@@ -72,7 +79,7 @@ namespace Nz
|
||||
struct Binding
|
||||
{
|
||||
UInt32 bindingIndex;
|
||||
std::variant<StorageBufferBinding, TextureBinding, TextureBindings, UniformBufferBinding> content;
|
||||
std::variant<SampledTextureBinding, SampledTextureBindings, StorageBufferBinding, TextureBinding, UniformBufferBinding> content;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user