VenomEngine
Cross-Platform Modern Graphics Engine
Loading...
Searching...
No Matches
ShaderPipeline.h
Go to the documentation of this file.
1
8#pragma once
9
12
13namespace venom
14{
15namespace common
16{
17class VENOM_COMMON_API ShaderResource : public GraphicsCachedResource
18{
19public:
21
22 Vector<String> shaderPaths;
23};
24
25enum class ShaderVertexFormat
26{
27 Float,
28 Vec2,
29 Vec3,
30 Vec4,
31 Int,
32 IVec2,
33 IVec3,
34 IVec4,
35 Uint,
36 UVec2,
37 UVec3,
38 UVec4,
39 Mat2,
40 Mat3,
41 Mat4
42};
43
45{
46public:
48 virtual ~ShaderPipelineImpl() = default;
49
56 vc::Error LoadShaderFromFile(const std::string & path);
57
59 {
60 const ShaderVertexFormat format;
61 const uint32_t binding;
62 const uint32_t location;
63 const uint32_t offset;
64 };
72 void AddVertexBufferToLayout(const ShaderVertexFormat format, const uint32_t binding, const uint32_t location, const uint32_t offset);
77 void AddVertexBufferToLayout(const VertexBufferLayout & layout);
82 void AddVertexBufferToLayout(const std::vector<VertexBufferLayout> & layouts);
83
84 virtual void SetMultiSamplingCount(const int samples) = 0;
85 inline vc::Error SetLineWidth(const float width) { _SetLineWidth(width); return _ReloadShaderAfterSettings(); }
86 inline vc::Error SetDepthTest(const bool enable) { _SetDepthTest(enable); return _ReloadShaderAfterSettings(); }
87 inline vc::Error SetDepthWrite(const bool enable) { _SetDepthWrite(enable); return _ReloadShaderAfterSettings(); }
88
89 inline void SetRenderingPipelineType(const RenderingPipelineType type) { _renderingPipelineType = type; }
90 inline void SetRenderingPipelineIndex(const uint32_t index) { _renderingPipelineIndex = index; }
91
92protected:
93 virtual void _SetLineWidth(const float width) = 0;
94 virtual void _SetDepthTest(const bool enable) = 0;
95 virtual void _SetDepthWrite(const bool enable) = 0;
96 virtual vc::Error _LoadShader(const std::string & path) = 0;
97 virtual void _AddVertexBufferToLayout(const uint32_t vertexSize, const uint32_t binding, const uint32_t location, const uint32_t offset, const ShaderVertexFormat format) = 0;
98
99 virtual vc::Error _ReloadShader() = 0;
100 inline vc::Error _ReloadShaderAfterSettings() {
101 if (_loaded) return _ReloadShader();
102 return vc::Error::Success;
103 }
104protected:
105 RenderingPipelineType _renderingPipelineType;
106 uint32_t _renderingPipelineIndex;
107 bool _loaded;
108};
109
110class VENOM_COMMON_API ShaderPipeline : public PluginObjectImplWrapper
111{
112public:
114 ShaderPipeline(const char * path);
116
117 inline void SetRenderingPipelineIndex(const uint32_t index) { _impl->As<ShaderPipelineImpl>()->SetRenderingPipelineIndex(index); }
118 inline void SetRenderingPipelineType(const RenderingPipelineType type) { _impl->As<ShaderPipelineImpl>()->SetRenderingPipelineType(type); }
119 inline vc::Error LoadShaderFromFile(const char * path) { return _impl->As<ShaderPipelineImpl>()->LoadShaderFromFile(path); }
120 inline void AddVertexBufferToLayout(const ShaderVertexFormat format, const uint32_t binding, const uint32_t location, const uint32_t offset) { _impl->As<ShaderPipelineImpl>()->AddVertexBufferToLayout(format, binding, location, offset); }
121 inline void AddVertexBufferToLayout(const ShaderPipelineImpl::VertexBufferLayout & layout) { _impl->As<ShaderPipelineImpl>()->AddVertexBufferToLayout(layout); }
122 inline void AddVertexBufferToLayout(const std::vector<ShaderPipelineImpl::VertexBufferLayout> & layouts) { _impl->As<ShaderPipelineImpl>()->AddVertexBufferToLayout(layouts); }
123 inline void SetLineWidth(const float width) { _impl->As<ShaderPipelineImpl>()->SetLineWidth(width); }
124 inline void SetDepthTest(const bool enable) { _impl->As<ShaderPipelineImpl>()->SetDepthTest(enable); }
125 inline void SetDepthWrite(const bool enable) { _impl->As<ShaderPipelineImpl>()->SetDepthWrite(enable); }
126};
127}
128}
Base class for cached resource holders.
Definition GraphicsPluginObject.h:57
Base class for cached resources.
Definition GraphicsPluginObject.h:29
Base class for graphics plugin objects.
Definition GraphicsPluginObject.h:80
Interface for the PluginObject different implementations.
Definition PluginObject.h:56
Wrapper for the PluginObjectImpl, inherited by classes like Model or Mesh to make them usable as comp...
Definition PluginObject.h:76
Definition ShaderPipeline.h:111
Definition ShaderPipeline.h:45
Definition ShaderPipeline.h:18
Contains the entirety of the code of the VenomEngine project.
Definition Config.h:13