MayaFlux 0.1.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:
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
33 void set_render_pass(Portal::Graphics::RenderPassID render_pass_id);
34 void set_target_window(std::shared_ptr<Core::Window> window);
35
36 Portal::Graphics::RenderPipelineID get_render_pipeline_id() const { return m_render_pipeline_id; }
37
38 void on_attach(std::shared_ptr<Buffer> buffer) override;
39
40 /// Set primitive topology (e.g., triangle list, line list, point list)
42 {
43 m_primitive_topology = topology;
44 m_needs_pipeline_rebuild = true;
45 }
46
47 /// Set polygon mode (e.g., fill, line, point)
49 {
50 m_polygon_mode = mode;
51 m_needs_pipeline_rebuild = true;
52 }
53
54 /// Set cull mode (e.g., none, front, back)
56 {
57 m_cull_mode = mode;
58 m_needs_pipeline_rebuild = true;
59 }
60
61 /**
62 * @brief Bind a texture to a descriptor binding point
63 * @param binding Binding index (matches shader layout(binding = N))
64 * @param texture VKImage texture to bind
65 * @param sampler Optional sampler (uses default linear if null)
66 */
67 void bind_texture(
68 uint32_t binding,
69 const std::shared_ptr<Core::VKImage>& texture,
70 vk::Sampler sampler = nullptr);
71
72 /**
73 * @brief Bind a texture to a named descriptor
74 * @param descriptor_name Logical name (must be in config.bindings)
75 * @param texture VKImage texture to bind
76 * @param sampler Optional sampler (uses default linear if null)
77 */
78 void bind_texture(
79 const std::string& descriptor_name,
80 const std::shared_ptr<Core::VKImage>& texture,
81 vk::Sampler sampler = nullptr);
82
83protected:
84 void initialize_pipeline(const std::shared_ptr<Buffer>& buffer) override;
85 void processing_function(std::shared_ptr<Buffer> buffer) override;
86
87 void cleanup() override;
88
89private:
90 struct VertexInfo {
92 bool use_reflection {};
93 };
94
95 Portal::Graphics::RenderPipelineID m_render_pipeline_id = Portal::Graphics::INVALID_RENDER_PIPELINE;
96 Portal::Graphics::ShaderID m_geometry_shader_id = Portal::Graphics::INVALID_SHADER;
97 Portal::Graphics::ShaderID m_tess_control_shader_id = Portal::Graphics::INVALID_SHADER;
98 Portal::Graphics::ShaderID m_tess_eval_shader_id = Portal::Graphics::INVALID_SHADER;
99 Portal::Graphics::ShaderID m_fragment_shader_id = Portal::Graphics::INVALID_SHADER;
100 Portal::Graphics::RenderPassID m_render_pass_id = Portal::Graphics::INVALID_RENDER_PASS;
101 std::shared_ptr<Core::Window> m_target_window;
102
103 std::unordered_map<std::shared_ptr<VKBuffer>, VertexInfo> m_buffer_info;
104 Registry::Service::DisplayService* m_display_service = nullptr;
105
106 Portal::Graphics::PrimitiveTopology m_primitive_topology { Portal::Graphics::PrimitiveTopology::TRIANGLE_LIST };
107 Portal::Graphics::PolygonMode m_polygon_mode { Portal::Graphics::PolygonMode::FILL };
108 Portal::Graphics::CullMode m_cull_mode { Portal::Graphics::CullMode::NONE };
109
111 std::shared_ptr<Core::VKImage> texture;
112 vk::Sampler sampler;
113 };
114 std::unordered_map<uint32_t, TextureBinding> m_texture_bindings;
115};
116
117} // 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
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
Generic compute shader processor for VKBuffers.
PolygonMode
Rasterization polygon mode.
PrimitiveTopology
Vertex assembly primitive topology.
Complete configuration for shader processor.
Complete description of vertex data layout in a buffer.
Backend display and presentation service interface.