3#include <litefx/rendering_builders.hpp>
4#include "vulkan_api.hpp"
7#if defined(BUILD_DEFINE_BUILDERS)
16 class LITEFX_VULKAN_API VulkanShaderProgramBuilder :
public ShaderProgramBuilder<VulkanShaderProgramBuilder, VulkanShaderProgram> {
17 LITEFX_IMPLEMENTATION(VulkanShaderProgramBuilderImpl);
24 explicit VulkanShaderProgramBuilder(
const VulkanDevice& device);
25 VulkanShaderProgramBuilder(
const VulkanShaderProgramBuilder&) =
delete;
26 VulkanShaderProgramBuilder(VulkanShaderProgramBuilder&&) =
delete;
27 virtual ~VulkanShaderProgramBuilder() noexcept;
32 virtual
void build() override;
37 virtual VulkanShaderProgramBuilder& withShaderModule(const ShaderStage& type, const
String& fileName, const
String& entryPoint = "main") override;
40 virtual VulkanShaderProgramBuilder& withShaderModule(const ShaderStage& type, std::istream& stream, const
String& name, const
String& entryPoint = "main") override;
43 virtual VulkanShaderProgramBuilder& withVertexShaderModule(const
String& fileName, const
String& entryPoint = "main") override;
46 virtual VulkanShaderProgramBuilder& withVertexShaderModule(std::istream& stream, const
String& name, const
String& entryPoint = "main") override;
49 virtual VulkanShaderProgramBuilder& withTessellationControlShaderModule(const
String& fileName, const
String& entryPoint = "main") override;
52 virtual VulkanShaderProgramBuilder& withTessellationControlShaderModule(std::istream& stream, const
String& name, const
String& entryPoint = "main") override;
55 virtual VulkanShaderProgramBuilder& withTessellationEvaluationShaderModule(const
String& fileName, const
String& entryPoint = "main") override;
58 virtual VulkanShaderProgramBuilder& withTessellationEvaluationShaderModule(std::istream& stream, const
String& name, const
String& entryPoint = "main") override;
61 virtual VulkanShaderProgramBuilder& withGeometryShaderModule(const
String& fileName, const
String& entryPoint = "main") override;
64 virtual VulkanShaderProgramBuilder& withGeometryShaderModule(std::istream& stream, const
String& name, const
String& entryPoint = "main") override;
67 virtual VulkanShaderProgramBuilder& withFragmentShaderModule(const
String& fileName, const
String& entryPoint = "main") override;
70 virtual VulkanShaderProgramBuilder& withFragmentShaderModule(std::istream& stream, const
String& name, const
String& entryPoint = "main") override;
73 virtual VulkanShaderProgramBuilder& withComputeShaderModule(const
String& fileName, const
String& entryPoint = "main") override;
76 virtual VulkanShaderProgramBuilder& withComputeShaderModule(std::istream& stream, const
String& name, const
String& entryPoint = "main") override;
83 class LITEFX_VULKAN_API VulkanRasterizerBuilder : public RasterizerBuilder<VulkanRasterizerBuilder, VulkanRasterizer> {
84 LITEFX_IMPLEMENTATION(VulkanRasterizerBuilderImpl);
90 explicit VulkanRasterizerBuilder() noexcept;
91 VulkanRasterizerBuilder(const VulkanRasterizerBuilder&) noexcept = delete;
92 VulkanRasterizerBuilder(VulkanRasterizerBuilder&&) noexcept = delete;
93 virtual ~VulkanRasterizerBuilder() noexcept;
98 virtual
void build() override;
103 virtual VulkanRasterizerBuilder& polygonMode(const PolygonMode& mode = PolygonMode::Solid) noexcept override;
106 virtual VulkanRasterizerBuilder& cullMode(const CullMode& cullMode = CullMode::BackFaces) noexcept override;
109 virtual VulkanRasterizerBuilder& cullOrder(const CullOrder& cullOrder = CullOrder::CounterClockWise) noexcept override;
112 virtual VulkanRasterizerBuilder& lineWidth(const
Float& lineWidth = 1.f) noexcept override;
115 virtual VulkanRasterizerBuilder& depthBias(const
DepthStencilState::DepthBias& depthBias) noexcept override;
118 virtual VulkanRasterizerBuilder& depthState(const
DepthStencilState::DepthState& depthState) noexcept override;
121 virtual VulkanRasterizerBuilder& stencilState(const
DepthStencilState::StencilState& stencilState) noexcept override;
129 class LITEFX_VULKAN_API VulkanVertexBufferLayoutBuilder : public VertexBufferLayoutBuilder<VulkanVertexBufferLayoutBuilder, VulkanVertexBufferLayout, VulkanInputAssemblerBuilder> {
131 using VertexBufferLayoutBuilder<VulkanVertexBufferLayoutBuilder, VulkanVertexBufferLayout, VulkanInputAssemblerBuilder>::VertexBufferLayoutBuilder;
148 virtual VulkanVertexBufferLayoutBuilder& withAttribute(
const BufferFormat& format,
const UInt32& offset,
const AttributeSemantic& semantic = AttributeSemantic::Unknown,
const UInt32& semanticIndex = 0);
158 virtual VulkanVertexBufferLayoutBuilder& withAttribute(
const UInt32& location,
const BufferFormat& format,
const UInt32& offset,
const AttributeSemantic& semantic = AttributeSemantic::Unknown,
const UInt32& semanticIndex = 0);
165 class LITEFX_VULKAN_API VulkanInputAssemblerBuilder :
public InputAssemblerBuilder<VulkanInputAssemblerBuilder, VulkanInputAssembler> {
166 LITEFX_IMPLEMENTATION(VulkanInputAssemblerBuilderImpl);
172 explicit VulkanInputAssemblerBuilder() noexcept;
173 VulkanInputAssemblerBuilder(const VulkanInputAssemblerBuilder&) noexcept = delete;
174 VulkanInputAssemblerBuilder(VulkanInputAssemblerBuilder&&) noexcept = delete;
175 virtual ~VulkanInputAssemblerBuilder() noexcept;
180 virtual
void build() override;
185 virtual VulkanInputAssemblerBuilder& topology(const PrimitiveTopology& topology) override;
188 virtual
void use(
UniquePtr<VulkanVertexBufferLayout>&& layout) override;
191 virtual
void use(
UniquePtr<VulkanIndexBufferLayout>&& layout) override;
200 virtual VulkanVertexBufferLayoutBuilder vertexBuffer(const
size_t& elementSize, const
UInt32& binding = 0);
206 virtual VulkanInputAssemblerBuilder& indexType(const IndexType& type);
215 class LITEFX_VULKAN_API VulkanDescriptorSetLayoutBuilder : public DescriptorSetLayoutBuilder<VulkanDescriptorSetLayoutBuilder, VulkanDescriptorSetLayout, VulkanPipelineLayoutBuilder> {
216 LITEFX_IMPLEMENTATION(VulkanDescriptorSetLayoutBuilderImpl);
228 explicit VulkanDescriptorSetLayoutBuilder(VulkanPipelineLayoutBuilder& parent,
const UInt32& space = 0,
const ShaderStage& stages = ShaderStage::Compute | ShaderStage::Fragment | ShaderStage::Geometry | ShaderStage::TessellationControl | ShaderStage::TessellationEvaluation | ShaderStage::Vertex,
const UInt32& poolSize = 1024,
const UInt32& maxUnboundedArraySize = 104857);
229 VulkanDescriptorSetLayoutBuilder(
const VulkanDescriptorSetLayoutBuilder&) =
delete;
230 VulkanDescriptorSetLayoutBuilder(VulkanDescriptorSetLayoutBuilder&&) =
delete;
231 virtual ~VulkanDescriptorSetLayoutBuilder() noexcept;
236 virtual
void build() override;
241 virtual VulkanDescriptorSetLayoutBuilder& withDescriptor(
UniquePtr<VulkanDescriptorLayout>&& layout) override;
244 virtual VulkanDescriptorSetLayoutBuilder& withDescriptor(const DescriptorType& type, const
UInt32& binding, const
UInt32& descriptorSize, const
UInt32& descriptors = 1) override;
247 virtual VulkanDescriptorSetLayoutBuilder& withStaticSampler(const
UInt32& binding, const FilterMode& magFilter = FilterMode::Nearest, const FilterMode& minFilter = FilterMode::Nearest, const BorderMode& borderU = BorderMode::Repeat, const BorderMode& borderV = BorderMode::Repeat, const BorderMode& borderW = BorderMode::Repeat, const MipMapMode& mipMapMode = MipMapMode::Nearest, const
Float& mipMapBias = 0.f, const
Float& minLod = 0.f, const
Float& maxLod = std::numeric_limits<
Float>::max(), const
Float& anisotropy = 0.f) override;
255 virtual VulkanDescriptorSetLayoutBuilder& space(const
UInt32& space) noexcept;
261 virtual VulkanDescriptorSetLayoutBuilder& shaderStages(const ShaderStage& stages) noexcept;
267 virtual VulkanDescriptorSetLayoutBuilder& poolSize(const
UInt32& poolSize) noexcept;
274 class LITEFX_VULKAN_API VulkanPushConstantsLayoutBuilder : public PushConstantsLayoutBuilder<VulkanPushConstantsLayoutBuilder, VulkanPushConstantsLayout, VulkanPipelineLayoutBuilder> {
275 LITEFX_IMPLEMENTATION(VulkanPushConstantsLayoutBuilderImpl);
283 explicit VulkanPushConstantsLayoutBuilder(VulkanPipelineLayoutBuilder& parent,
const UInt32& size);
284 VulkanPushConstantsLayoutBuilder(
const VulkanPushConstantsLayoutBuilder&) =
delete;
285 VulkanPushConstantsLayoutBuilder(VulkanPushConstantsLayoutBuilder&&) =
delete;
286 virtual ~VulkanPushConstantsLayoutBuilder() noexcept;
291 virtual
void build() override;
296 virtual VulkanPushConstantsLayoutBuilder& withRange(const ShaderStage& shaderStages, const
UInt32& offset, const
UInt32& size, const
UInt32& space, const
UInt32& binding) override;
305 class LITEFX_VULKAN_API VulkanPipelineLayoutBuilder : public PipelineLayoutBuilder<VulkanPipelineLayoutBuilder, VulkanPipelineLayout> {
306 LITEFX_IMPLEMENTATION(VulkanPipelineLayoutBuilderImpl);
307 friend class VulkanDescriptorSetLayoutBuilder;
314 explicit VulkanPipelineLayoutBuilder(
const VulkanDevice& device);
315 VulkanPipelineLayoutBuilder(VulkanPipelineLayoutBuilder&&) =
delete;
316 VulkanPipelineLayoutBuilder(
const VulkanPipelineLayoutBuilder&) =
delete;
317 virtual ~VulkanPipelineLayoutBuilder() noexcept;
322 virtual
void build() override;
327 virtual
void use(
UniquePtr<VulkanDescriptorSetLayout>&& layout) override;
330 virtual
void use(
UniquePtr<VulkanPushConstantsLayout>&& layout) override;
340 virtual VulkanDescriptorSetLayoutBuilder descriptorSet(const
UInt32& space = 0, const ShaderStage& stages = ShaderStage::Fragment | ShaderStage::Geometry | ShaderStage::TessellationControl | ShaderStage::TessellationEvaluation | ShaderStage::
Vertex, const
UInt32& poolSize = 1024);
346 virtual VulkanPushConstantsLayoutBuilder pushConstants(const
UInt32& size);
353 virtual const VulkanDevice& device() const noexcept;
360 class LITEFX_VULKAN_API VulkanRenderPipelineBuilder : public RenderPipelineBuilder<VulkanRenderPipelineBuilder, VulkanRenderPipeline> {
361 LITEFX_IMPLEMENTATION(VulkanRenderPipelineBuilderImpl);
369 explicit VulkanRenderPipelineBuilder(
const VulkanRenderPass& renderPass,
const String& name =
"");
370 VulkanRenderPipelineBuilder(VulkanRenderPipelineBuilder&&) =
delete;
371 VulkanRenderPipelineBuilder(
const VulkanRenderPipelineBuilder&) =
delete;
372 virtual ~VulkanRenderPipelineBuilder() noexcept;
377 virtual
void build() override;
382 virtual VulkanRenderPipelineBuilder& shaderProgram(
SharedPtr<VulkanShaderProgram> shaderProgram) override;
385 virtual VulkanRenderPipelineBuilder& layout(
SharedPtr<VulkanPipelineLayout> layout) override;
388 virtual VulkanRenderPipelineBuilder& rasterizer(
SharedPtr<VulkanRasterizer> rasterizer) override;
391 virtual VulkanRenderPipelineBuilder& inputAssembler(
SharedPtr<VulkanInputAssembler> inputAssembler) override;
394 virtual VulkanRenderPipelineBuilder& viewport(
SharedPtr<
IViewport> viewport) override;
397 virtual VulkanRenderPipelineBuilder& scissor(
SharedPtr<
IScissor> scissor) override;
400 virtual VulkanRenderPipelineBuilder& enableAlphaToCoverage(const
bool& enable = true) override;
407 class LITEFX_VULKAN_API VulkanComputePipelineBuilder : public ComputePipelineBuilder<VulkanComputePipelineBuilder, VulkanComputePipeline> {
408 LITEFX_IMPLEMENTATION(VulkanComputePipelineBuilderImpl);
416 explicit VulkanComputePipelineBuilder(
const VulkanDevice& device,
const String& name =
"");
417 VulkanComputePipelineBuilder(VulkanComputePipelineBuilder&&) =
delete;
418 VulkanComputePipelineBuilder(
const VulkanComputePipelineBuilder&) =
delete;
419 virtual ~VulkanComputePipelineBuilder() noexcept;
424 virtual
void build() override;
429 virtual VulkanComputePipelineBuilder& shaderProgram(
SharedPtr<VulkanShaderProgram> program) override;
432 virtual VulkanComputePipelineBuilder& layout(
SharedPtr<VulkanPipelineLayout> layout) override;
439 class LITEFX_VULKAN_API VulkanRenderPassBuilder : public RenderPassBuilder<VulkanRenderPassBuilder, VulkanRenderPass> {
440 LITEFX_IMPLEMENTATION(VulkanRenderPassBuilderImpl)
448 explicit VulkanRenderPassBuilder(
const VulkanDevice& device,
const String& name =
"") noexcept;
456 explicit VulkanRenderPassBuilder(const VulkanDevice& device, const MultiSamplingLevel& samples = MultiSamplingLevel::x1, const
String& name = "") noexcept;
464 explicit VulkanRenderPassBuilder(const VulkanDevice& device, const
UInt32& commandBuffers, const
String& name = "") noexcept;
473 explicit VulkanRenderPassBuilder(const VulkanDevice& device, const
UInt32& commandBuffers, const MultiSamplingLevel& multiSamplingLevel, const
String& name = "") noexcept;
474 VulkanRenderPassBuilder(const VulkanRenderPassBuilder&) noexcept = delete;
475 VulkanRenderPassBuilder(VulkanRenderPassBuilder&&) noexcept = delete;
476 virtual ~VulkanRenderPassBuilder() noexcept;
481 virtual
void build() override;
486 virtual VulkanRenderPassBuilder& commandBuffers(const
UInt32& count) override;
489 virtual VulkanRenderPassBuilder& multiSamplingLevel(const MultiSamplingLevel& samples) override;
492 virtual VulkanRenderPassBuilder& renderTarget(const RenderTargetType& type, const Format& format, const
Vector4f& clearValues = { 0.0f, 0.0f, 0.0f, 0.0f },
bool clearColor =
true,
bool clearStencil =
true,
bool isVolatile =
false)
override;
495 virtual VulkanRenderPassBuilder& renderTarget(
const String& name,
const RenderTargetType& type,
const Format& format,
const Vector4f& clearValues = { 0.0f, 0.0f, 0.0f, 0.0f },
bool clearColor =
true,
bool clearStencil =
true,
bool isVolatile =
false)
override;
498 virtual VulkanRenderPassBuilder& renderTarget(
const UInt32& location,
const RenderTargetType& type,
const Format& format,
const Vector4f& clearValues = { 0.0f, 0.0f, 0.0f, 0.0f },
bool clearColor =
true,
bool clearStencil =
true,
bool isVolatile =
false)
override;
501 virtual VulkanRenderPassBuilder& renderTarget(
const String& name,
const UInt32& location,
const RenderTargetType& type,
const Format& format,
const Vector4f& clearValues = { 0.0f, 0.0f, 0.0f, 0.0f },
bool clearColor =
true,
bool clearStencil =
true,
bool isVolatile =
false)
override;
504 virtual VulkanRenderPassBuilder& renderTarget(VulkanInputAttachmentMapping& output,
const RenderTargetType& type,
const Format& format,
const Vector4f& clearValues = { 0.0f, 0.0f, 0.0f, 0.0f },
bool clearColor =
true,
bool clearStencil =
true,
bool isVolatile =
false)
override;
507 virtual VulkanRenderPassBuilder& renderTarget(
const String& name, VulkanInputAttachmentMapping& output,
const RenderTargetType& type,
const Format& format,
const Vector4f& clearValues = { 0.0f, 0.0f, 0.0f, 0.0f },
bool clearColor =
true,
bool clearStencil =
true,
bool isVolatile =
false)
override;
510 virtual VulkanRenderPassBuilder& renderTarget(VulkanInputAttachmentMapping& output,
const UInt32& location,
const RenderTargetType& type,
const Format& format,
const Vector4f& clearValues = { 0.0f, 0.0f, 0.0f, 0.0f },
bool clearColor =
true,
bool clearStencil =
true,
bool isVolatile =
false)
override;
513 virtual VulkanRenderPassBuilder& renderTarget(
const String& name, VulkanInputAttachmentMapping& output,
const UInt32& location,
const RenderTargetType& type,
const Format& format,
const Vector4f& clearValues = { 0.0f, 0.0f, 0.0f, 0.0f },
bool clearColor =
true,
bool clearStencil =
true,
bool isVolatile =
false)
override;
516 virtual VulkanRenderPassBuilder& inputAttachment(
const VulkanInputAttachmentMapping& inputAttachment)
override;
519 virtual VulkanRenderPassBuilder& inputAttachment(
const UInt32& inputLocation,
const VulkanRenderPass& renderPass,
const UInt32& outputLocation)
override;
522 virtual VulkanRenderPassBuilder& inputAttachment(
const UInt32& inputLocation,
const VulkanRenderPass& renderPass,
const RenderTarget& renderTarget)
override;
Stores the depth/stencil state of a see IRasterizer.
Definition: rendering_api.hpp:2066
The interface of a scissor.
Definition: rendering_api.hpp:2415
Interface for a viewport.
Definition: rendering_api.hpp:2331
Implements a render target.
Definition: rendering_api.hpp:1994
uint32_t UInt32
Definition: math.hpp:37
float_t Float
Definition: math.hpp:40
std::string String
Definition: string.hpp:19
std::shared_ptr< T > SharedPtr
Represents a shared pointer, that expresses non-exclusive ownership.
Definition: containers.hpp:94
std::unique_ptr< T, TDeleter > UniquePtr
Represents a unique pointer, that expresses exclusive ownership.
Definition: containers.hpp:87
Definition: graphics.hpp:11