MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
RenderProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "ShaderProcessor.hpp"
5
6namespace MayaFlux::Core {
7class VKImage;
8}
9
10namespace MayaFlux::Buffers {
11
12/**
13 * @class RenderShaderProcessor
14 * @brief Graphics rendering processor - inherits from ShaderProcessor
15 *
16 * Overrides pipeline creation to use RenderFlow instead of ComputePress.
17 * Records draw commands but does NOT submit/present.
18 */
19class MAYAFLUX_API RenderProcessor : public ShaderProcessor {
20public:
21 RenderProcessor(const ShaderConfig& config);
22
24 {
25 cleanup();
26 }
27
28 void set_geometry_shader(const std::string& geometry_path);
29 void set_tess_control_shader(const std::string& tess_control_path);
30 void set_tess_eval_shader(const std::string& tess_eval_path);
31 void set_fragment_shader(const std::string& fragment_path);
32 void set_target_window(std::shared_ptr<Core::Window> window);
33
35
36 void on_attach(const std::shared_ptr<Buffer>& buffer) override;
37
38 /// Set primitive topology (e.g., triangle list, line list, point list)
40 {
41 m_primitive_topology = topology;
42 m_needs_pipeline_rebuild = true;
43 }
44
45 /// Set polygon mode (e.g., fill, line, point)
47 {
48 m_polygon_mode = mode;
49 m_needs_pipeline_rebuild = true;
50 }
51
52 /// Set cull mode (e.g., none, front, back)
54 {
55 m_cull_mode = mode;
56 m_needs_pipeline_rebuild = true;
57 }
58
59 /**
60 * @brief Bind a texture to a descriptor binding point
61 * @param binding Binding index (matches shader layout(binding = N))
62 * @param texture VKImage texture to bind
63 * @param sampler Optional sampler (uses default linear if null)
64 */
65 void bind_texture(
66 uint32_t binding,
67 const std::shared_ptr<Core::VKImage>& texture,
68 vk::Sampler sampler = nullptr);
69
70 /**
71 * @brief Bind a texture to a named descriptor
72 * @param descriptor_name Logical name (must be in config.bindings)
73 * @param texture VKImage texture to bind
74 * @param sampler Optional sampler (uses default linear if null)
75 */
76 void bind_texture(
77 const std::string& descriptor_name,
78 const std::shared_ptr<Core::VKImage>& texture,
79 vk::Sampler sampler = nullptr);
80
81 /**
82 * @brief Check if pipeline is created
83 */
84 bool is_pipeline_ready() const { return m_pipeline_id != Portal::Graphics::INVALID_RENDER_PIPELINE; }
85
86protected:
87 void initialize_pipeline(const std::shared_ptr<VKBuffer>& buffer) override;
88 void execute_shader(const std::shared_ptr<VKBuffer>& buffer) override;
89 void initialize_descriptors(const std::shared_ptr<VKBuffer>& buffer) override;
90
91 bool on_before_execute(Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr<VKBuffer>& buffer) override;
92
93 void cleanup() override;
94
95private:
96 struct VertexInfo {
98 bool use_reflection {};
99 };
100
101 Portal::Graphics::RenderPipelineID m_pipeline_id = Portal::Graphics::INVALID_RENDER_PIPELINE;
102 Portal::Graphics::ShaderID m_geometry_shader_id = Portal::Graphics::INVALID_SHADER;
103 Portal::Graphics::ShaderID m_tess_control_shader_id = Portal::Graphics::INVALID_SHADER;
104 Portal::Graphics::ShaderID m_tess_eval_shader_id = Portal::Graphics::INVALID_SHADER;
105 Portal::Graphics::ShaderID m_fragment_shader_id = Portal::Graphics::INVALID_SHADER;
106 std::shared_ptr<Core::Window> m_target_window;
107
108 std::unordered_map<std::shared_ptr<VKBuffer>, VertexInfo> m_buffer_info;
109 Registry::Service::DisplayService* m_display_service = nullptr;
110
111 Portal::Graphics::PrimitiveTopology m_primitive_topology { Portal::Graphics::PrimitiveTopology::TRIANGLE_LIST };
112 Portal::Graphics::PolygonMode m_polygon_mode { Portal::Graphics::PolygonMode::FILL };
113 Portal::Graphics::CullMode m_cull_mode { Portal::Graphics::CullMode::NONE };
114
116 std::shared_ptr<Core::VKImage> texture;
117 vk::Sampler sampler;
118 };
119 std::unordered_map<uint32_t, TextureBinding> m_texture_bindings;
120};
121
122} // namespace MayaFlux::Buffers
void set_cull_mode(Portal::Graphics::CullMode mode)
Set cull mode (e.g., none, front, back)
void set_primitive_topology(Portal::Graphics::PrimitiveTopology topology)
Set primitive topology (e.g., triangle list, line list, point list)
std::unordered_map< std::shared_ptr< VKBuffer >, VertexInfo > m_buffer_info
bool is_pipeline_ready() const
Check if pipeline is created.
std::unordered_map< uint32_t, TextureBinding > m_texture_bindings
Portal::Graphics::RenderPipelineID get_render_pipeline_id() const
void set_polygon_mode(Portal::Graphics::PolygonMode mode)
Set polygon mode (e.g., fill, line, point)
std::shared_ptr< Core::Window > m_target_window
Abstract base class for shader-based buffer processing.
PolygonMode
Rasterization polygon mode.
PrimitiveTopology
Vertex assembly primitive topology.
Complete description of vertex data layout in a buffer.
Backend display and presentation service interface.