3 #include "Backend/Device.hpp"
5 #include "ObjectHandle.hpp"
8 #include "Descriptor.hpp"
10 #include <unordered_map>
14 namespace mn::Graphics
21 None, Vertex, Fragment, Compute
40 u32 element_count, element_size, format;
45 MN_SYMBOL
Shader(std::filesystem::path path, ShaderType type);
48 MN_SYMBOL
void fromFile(std::filesystem::path path, ShaderType type);
49 MN_SYMBOL
void fromString(
const std::string& contents, ShaderType type,
const std::string& path =
"");
50 MN_SYMBOL
void fromSpv(
const std::vector<uint32_t>& contents, ShaderType type);
52 auto getType()
const {
return type; }
54 const auto& getAttributes()
const { MIDNIGHT_ASSERT(type == ShaderType::Vertex,
"Attributes only for vertex shader");
return *attributes; }
58 std::optional<std::vector<Attribute>> attributes;
61 struct PipelineBuilder;
72 auto getBindingStride()
const {
return binding_strides[0]; }
74 MN_SYMBOL
void setPushConstant(
const std::unique_ptr<Backend::CommandBuffer>& cmd,
const void* data)
const;
77 void setPushConstant(
const std::unique_ptr<Backend::CommandBuffer>& cmd,
const T& value)
const
79 MIDNIGHT_ASSERT(
sizeof(T) == push_constant_size,
"Push constant size descrepancy");
80 setPushConstant(cmd,
reinterpret_cast<const void*
>(&value));
83 auto getLayoutHandle()
const {
return layout; }
84 const auto& getDescriptorLayouts()
const {
return descriptor_layouts; }
89 uint32_t push_constant_size;
90 std::vector<std::shared_ptr<Descriptor::Layout>> descriptor_layouts;
91 std::vector<uint32_t> binding_strides;
98 MN_SYMBOL
static PipelineBuilder fromLua(
const std::string& source_dir,
const std::string& script);
100 MN_SYMBOL
PipelineBuilder& addShader(std::filesystem::path path, ShaderType type);
110 MN_SYMBOL
PipelineBuilder& addDescriptorLayout(std::shared_ptr<Descriptor::Layout> d);
120 push_constant_size =
sizeof(T);
124 [[nodiscard]] MN_SYMBOL
Pipeline build()
const;
131 std::vector<uint32_t> attachment_formats;
132 std::vector<std::shared_ptr<Descriptor::Layout>> descriptor_layouts;
133 std::pair<uint32_t, uint32_t> size;
134 std::unordered_map<ShaderType, std::shared_ptr<Shader>> modules;
135 Topology top = Topology::Triangles;
136 Polygon poly = Polygon::Fill;
137 bool backface_cull =
true, blending =
true, depth =
true, clockwise =
true;
138 uint32_t depth_format = 0, push_constant_size = 0;
Definition: ObjectHandle.hpp:9
Definition: Pipeline.hpp:96
Definition: Pipeline.hpp:64
Definition: Pipeline.hpp:39
Definition: Pipeline.hpp:35
Definition: TypedHandle.hpp:9