MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
ShaderUtils.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "vulkan/vulkan.hpp"
4
5#include "GraphicsUtils.hpp"
6
8
9namespace MayaFlux::Core {
10struct VertexBinding;
11struct VertexAttribute;
12}
13
15
16using ShaderID = uint64_t;
17using DescriptorSetID = uint64_t;
18using CommandBufferID = uint64_t;
19using FenceID = uint64_t;
20using SemaphoreID = uint64_t;
21using RenderPipelineID = uint64_t;
22using FramebufferID = uint64_t;
23
27constexpr FenceID INVALID_FENCE = 0;
31
32/**
33 * @struct ShaderCompilerConfig
34 * @brief Configuration for shader compilation
35 */
38 bool enable_debug_info = false; ///< Include debug symbols (line numbers, variable names)
39 bool enable_reflection = true; ///< Extract descriptor bindings and metadata
40 bool enable_validation = true; ///< Validate SPIR-V after compilation
41 std::vector<std::string> include_directories; ///< Paths for #include resolution
42 std::unordered_map<std::string, std::string> defines; ///< Preprocessor macros
43
45};
46
47/**
48 * @struct ShaderSource
49 * @brief Shader source descriptor for compilation
50 */
52 std::string content; ///< Shader source code or SPIR-V path
54 std::string entry_point = "main";
55
56 enum class SourceType : uint8_t {
57 GLSL_STRING, ///< In-memory GLSL source
58 GLSL_FILE, ///< Path to .comp/.vert/.frag/etc
59 SPIRV_FILE ///< Path to .spv file
60 } type
62
63 ShaderSource() = default;
64 ShaderSource(std::string content_, ShaderStage stage_, SourceType type_)
65 : content(std::move(content_))
66 , stage(stage_)
67 , type(type_)
68 {
69 }
70};
71
72/**
73 * @struct DescriptorBindingConfig
74 * @brief Portal-level descriptor binding configuration
75 */
77 uint32_t set {};
78 uint32_t binding {};
79 vk::DescriptorType type = vk::DescriptorType::eStorageBuffer;
80 vk::DescriptorBufferInfo buffer_info;
81 std::string name;
82};
83
84/**
85 * @struct PushConstantRangeInfo
86 * @brief Extracted push constant range from shader reflection
87 */
89 uint32_t offset;
90 uint32_t size;
91};
92
93/**
94 * @struct ShaderReflectionInfo
95 * @brief Extracted reflection information from compiled shader
96 */
99 std::string entry_point;
100 std::optional<std::array<uint32_t, 3>> workgroup_size;
101 std::vector<DescriptorBindingInfo> descriptor_bindings;
102 std::vector<PushConstantRangeInfo> push_constant_ranges;
103};
104
105/**
106 * @struct RasterizationConfig
107 * @brief Rasterization state configuration
108 */
119
120/**
121 * @struct DepthStencilConfig
122 * @brief Depth and stencil test configuration
123 */
132
133/**
134 * @struct BlendAttachmentConfig
135 * @brief Per-attachment blend configuration
136 */
160
161/**
162 * @struct RenderPipelineConfig
163 * @brief Complete render pipeline configuration
164 */
166 // Shader stages
172
173 // Vertex input
174 std::vector<Core::VertexBinding> vertex_bindings;
175 std::vector<Core::VertexAttribute> vertex_attributes;
176
177 // Input assembly
179
180 // Optional semantic vertex layout
181 std::optional<Kakshya::VertexLayout> semantic_vertex_layout;
182
183 // Use reflection to auto-configure from vertex shader
185
186 // Rasterization
188
189 // Depth/stencil
191
192 // Blend
193 std::vector<BlendAttachmentConfig> blend_attachments;
194
195 // Descriptor sets (similar to compute)
196 std::vector<std::vector<DescriptorBindingInfo>> descriptor_sets;
197
198 // Push constants
200
202};
203
204} // namespace MayaFlux::Portal::Graphics
PolygonMode
Rasterization polygon mode.
constexpr RenderPipelineID INVALID_RENDER_PIPELINE
constexpr ShaderID INVALID_SHADER
ShaderStage
User-friendly shader stage enum.
constexpr FenceID INVALID_FENCE
constexpr FramebufferID INVALID_FRAMEBUFFER
BlendOp
Blending operation.
PrimitiveTopology
Vertex assembly primitive topology.
CompareOp
Depth/stencil comparison operation.
constexpr DescriptorSetID INVALID_DESCRIPTOR_SET
constexpr SemaphoreID INVALID_SEMAPHORE
constexpr CommandBufferID INVALID_COMMAND_BUFFER
static BlendAttachmentConfig alpha_blend()
Create standard alpha blending configuration.
Per-attachment blend configuration.
Depth and stencil test configuration.
Extracted push constant range from shader reflection.
Rasterization state configuration.
std::vector< std::vector< DescriptorBindingInfo > > descriptor_sets
std::vector< Core::VertexAttribute > vertex_attributes
std::vector< Core::VertexBinding > vertex_bindings
std::optional< Kakshya::VertexLayout > semantic_vertex_layout
std::vector< BlendAttachmentConfig > blend_attachments
Complete render pipeline configuration.
bool enable_reflection
Extract descriptor bindings and metadata.
std::vector< std::string > include_directories
Paths for #include resolution.
bool enable_debug_info
Include debug symbols (line numbers, variable names)
bool enable_validation
Validate SPIR-V after compilation.
std::unordered_map< std::string, std::string > defines
Preprocessor macros.
Configuration for shader compilation.
std::optional< std::array< uint32_t, 3 > > workgroup_size
std::vector< PushConstantRangeInfo > push_constant_ranges
std::vector< DescriptorBindingInfo > descriptor_bindings
Extracted reflection information from compiled shader.
std::string content
Shader source code or SPIR-V path.
enum MayaFlux::Portal::Graphics::ShaderSource::SourceType type
ShaderSource(std::string content_, ShaderStage stage_, SourceType type_)
Shader source descriptor for compilation.