3#include "rendering_api.hpp"
4#include "rendering.hpp"
6#if defined(BUILD_DEFINE_BUILDERS)
15 template <
typename TDerived,
typename TShaderProgram>
requires
16 rtti::implements<TShaderProgram, ShaderProgram<typename TShaderProgram::shader_module_type>>
17 class ShaderProgramBuilder :
public Builder<TDerived, TShaderProgram, std::nullptr_t, SharedPtr<TShaderProgram>> {
20 using shader_program_type = TShaderProgram;
21 using shader_module_type = shader_program_type::shader_module_type;
30 virtual TDerived& withShaderModule(
const ShaderStage& type,
const String& fileName,
const String& entryPoint =
"main") = 0;
39 virtual TDerived& withShaderModule(
const ShaderStage& type, std::istream& stream,
const String& name,
const String& entryPoint =
"main") = 0;
46 virtual TDerived& withVertexShaderModule(
const String& fileName,
const String& entryPoint =
"main") = 0;
54 virtual TDerived& withVertexShaderModule(std::istream& stream,
const String& name,
const String& entryPoint =
"main") = 0;
61 virtual TDerived& withTessellationControlShaderModule(
const String& fileName,
const String& entryPoint =
"main") = 0;
69 virtual TDerived& withTessellationControlShaderModule(std::istream& stream,
const String& name,
const String& entryPoint =
"main") = 0;
76 virtual TDerived& withTessellationEvaluationShaderModule(
const String& fileName,
const String& entryPoint =
"main") = 0;
84 virtual TDerived& withTessellationEvaluationShaderModule(std::istream& stream,
const String& name,
const String& entryPoint =
"main") = 0;
91 virtual TDerived& withGeometryShaderModule(
const String& fileName,
const String& entryPoint =
"main") = 0;
99 virtual TDerived& withGeometryShaderModule(std::istream& stream,
const String& name,
const String& entryPoint =
"main") = 0;
106 virtual TDerived& withFragmentShaderModule(
const String& fileName,
const String& entryPoint =
"main") = 0;
114 virtual TDerived& withFragmentShaderModule(std::istream& stream,
const String& name,
const String& entryPoint =
"main") = 0;
121 virtual TDerived& withComputeShaderModule(
const String& fileName,
const String& entryPoint =
"main") = 0;
129 virtual TDerived& withComputeShaderModule(std::istream& stream,
const String& name,
const String& entryPoint =
"main") = 0;
138 template <
typename TDerived,
typename TRasterizer>
requires
139 rtti::implements<TRasterizer, IRasterizer>
140 class RasterizerBuilder :
public Builder<TDerived, TRasterizer, std::nullptr_t, SharedPtr<TRasterizer>> {
143 using rasterizer_type = TRasterizer;
150 virtual TDerived& polygonMode(
const PolygonMode& mode)
noexcept = 0;
156 virtual TDerived& cullMode(
const CullMode& mode)
noexcept = 0;
162 virtual TDerived& cullOrder(
const CullOrder& order)
noexcept = 0;
168 virtual TDerived& lineWidth(
const Float& width)
noexcept = 0;
195 template <
typename TDerived,
typename TVertexBufferLayout,
typename TParent>
requires
196 rtti::implements<TVertexBufferLayout, IVertexBufferLayout>
197 class VertexBufferLayoutBuilder :
public Builder<TDerived, TVertexBufferLayout, TParent> {
200 using vertex_buffer_layout_type = TVertexBufferLayout;
217 template <
typename TDerived,
typename TDescriptorSetLayout,
typename TParent>
requires
218 rtti::implements<TDescriptorSetLayout, DescriptorSetLayout<typename TDescriptorSetLayout::descriptor_layout_type, typename TDescriptorSetLayout::descriptor_set_type>>
219 class DescriptorSetLayoutBuilder :
public Builder<TDerived, TDescriptorSetLayout, TParent> {
222 using descriptor_set_layout_type = TDescriptorSetLayout;
223 using descriptor_layout_type = descriptor_set_layout_type::descriptor_layout_type;
224 using descriptor_set_type = descriptor_set_layout_type::descriptor_set_type;
240 virtual TDerived& withDescriptor(
const DescriptorType& type,
const UInt32& binding,
const UInt32& descriptorSize,
const UInt32& descriptors = 1) = 0;
256 virtual TDerived& 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) = 0;
265 virtual TDerived& withConstantBuffer(
const UInt32& binding,
const UInt32& descriptorSize,
const UInt32& descriptors = 1) {
266 return this->withDescriptor(DescriptorType::ConstantBuffer, binding, descriptorSize, descriptors);
275 virtual TDerived& withBuffer(
const UInt32& binding,
const UInt32& descriptors = 1,
const bool& writable =
false) {
276 return this->withDescriptor(writable ? DescriptorType::RWBuffer : DescriptorType::Buffer, binding, 0, descriptors);
285 virtual TDerived& withStructuredBuffer(
const UInt32& binding,
const UInt32& descriptors = 1,
const bool& writable =
false) {
286 return this->withDescriptor(writable ? DescriptorType::RWStructuredBuffer : DescriptorType::StructuredBuffer, binding, 0, descriptors);
295 virtual TDerived& withByteAddressBuffer(
const UInt32& binding,
const UInt32& descriptors = 1,
const bool& writable =
false) {
296 return this->withDescriptor(writable ? DescriptorType::RWByteAddressBuffer : DescriptorType::ByteAddressBuffer, binding, 0, descriptors);
305 virtual TDerived& withTexture(
const UInt32& binding,
const UInt32& descriptors = 1,
const bool& writable =
false) {
306 return this->withDescriptor(writable ? DescriptorType::RWTexture : DescriptorType::Texture, binding, 0, descriptors);
313 virtual TDerived& withInputAttachment(
const UInt32& binding) {
314 return this->withDescriptor(DescriptorType::InputAttachment, binding, 0);
322 virtual TDerived& withSampler(
const UInt32& binding,
const UInt32& descriptors = 1) {
323 return this->withDescriptor(DescriptorType::Sampler, binding, 0, descriptors);
332 this->withDescriptor(std::move(layout));
342 template <
typename TDerived,
typename TPushConstantsLayout,
typename TParent>
requires
343 rtti::implements<TPushConstantsLayout, PushConstantsLayout<typename TPushConstantsLayout::push_constants_range_type>>
344 class PushConstantsLayoutBuilder :
public Builder<TDerived, TPushConstantsLayout, TParent> {
347 using push_constants_layout_type = TPushConstantsLayout;
348 using push_constants_range_type = push_constants_layout_type::push_constants_range_type;
359 virtual TDerived& withRange(
const ShaderStage& shaderStages,
const UInt32& offset,
const UInt32& size,
const UInt32& space,
const UInt32& binding) = 0;
368 template <
typename TDerived,
typename TPipelineLayout>
requires
369 rtti::implements<TPipelineLayout, PipelineLayout<typename TPipelineLayout::descriptor_set_layout_type, typename TPipelineLayout::push_constants_layout_type>>
370 class PipelineLayoutBuilder :
public Builder<TDerived, TPipelineLayout, std::nullptr_t, SharedPtr<TPipelineLayout>> {
373 using pipeline_layout_type = TPipelineLayout;
374 using descriptor_set_layout_type = pipeline_layout_type::descriptor_set_layout_type;
375 using push_constants_layout_type = pipeline_layout_type::push_constants_layout_type;
399 template <
typename TDerived,
typename TInputAssembler>
requires
400 rtti::implements<TInputAssembler, InputAssembler<typename TInputAssembler::vertex_buffer_layout_type, typename TInputAssembler::index_buffer_layout_type>>
401 class InputAssemblerBuilder :
public Builder<TDerived, TInputAssembler, std::nullptr_t, SharedPtr<TInputAssembler>> {
404 using input_assembler_type = TInputAssembler;
405 using vertex_buffer_layout_type = input_assembler_type::vertex_buffer_layout_type;
406 using index_buffer_layout_type = input_assembler_type::index_buffer_layout_type;
413 virtual TDerived& topology(
const PrimitiveTopology& topology) = 0;
435 template <
typename TDerived,
typename TRenderPipeline>
requires
436 rtti::implements<TRenderPipeline, RenderPipeline<typename TRenderPipeline::pipeline_layout_type, typename TRenderPipeline::shader_program_type, typename TRenderPipeline::input_assembler_type, typename TRenderPipeline::rasterizer_type>>
437 class RenderPipelineBuilder :
public Builder<TDerived, TRenderPipeline> {
440 using render_pipeline_type = TRenderPipeline;
441 using pipeline_layout_type = render_pipeline_type::pipeline_layout_type;
442 using shader_program_type = render_pipeline_type::shader_program_type;
443 using input_assembler_type = render_pipeline_type::input_assembler_type;
444 using rasterizer_type = render_pipeline_type::rasterizer_type;
494 virtual TDerived& enableAlphaToCoverage(
const bool& enable =
true) = 0;
503 template <
typename TDerived,
typename TComputePipeline>
requires
504 rtti::implements<TComputePipeline, ComputePipeline<typename TComputePipeline::pipeline_layout_type, typename TComputePipeline::shader_program_type>>
505 class ComputePipelineBuilder :
public Builder<TDerived, TComputePipeline> {
508 using compute_pipeline_type = TComputePipeline;
509 using pipeline_layout_type = compute_pipeline_type::pipeline_layout_type;
510 using shader_program_type = compute_pipeline_type::shader_program_type;
536 template <
typename TDerived,
typename TRenderPass>
requires
537 rtti::implements<TRenderPass, RenderPass<typename TRenderPass::render_pipeline_type, typename TRenderPass::frame_buffer_type, typename TRenderPass::input_attachment_mapping_type>>
538 class RenderPassBuilder :
public Builder<TDerived, TRenderPass> {
541 using render_pass_type = TRenderPass;
542 using input_attachment_mapping_type = render_pass_type::input_attachment_mapping_type;
549 virtual TDerived& commandBuffers(
const UInt32& count) = 0;
555 virtual TDerived& multiSamplingLevel(
const MultiSamplingLevel& samples) = 0;
566 virtual TDerived& 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) = 0;
578 virtual TDerived& 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) = 0;
590 virtual TDerived& 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) = 0;
603 virtual TDerived& 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) = 0;
615 virtual TDerived& renderTarget(input_attachment_mapping_type& 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) = 0;
628 virtual TDerived& renderTarget(
const String& name, input_attachment_mapping_type& 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) = 0;
641 virtual TDerived& renderTarget(input_attachment_mapping_type& 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) = 0;
655 virtual TDerived& renderTarget(
const String& name, input_attachment_mapping_type& 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) = 0;
661 virtual TDerived& inputAttachment(
const input_attachment_mapping_type& inputAttachment) = 0;
669 virtual TDerived& inputAttachment(
const UInt32& inputLocation,
const render_pass_type& renderPass,
const UInt32& outputLocation) = 0;
677 virtual TDerived& inputAttachment(
const UInt32& inputLocation,
const render_pass_type& renderPass,
const RenderTarget& renderTarget) = 0;
Describes an generic builder type.
Definition: containers.hpp:509
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
Describes the rasterizer depth bias.
Definition: rendering_api.hpp:2100
Describes the rasterizer depth state.
Definition: rendering_api.hpp:2073
Describes the rasterizer stencil state.
Definition: rendering_api.hpp:2152