Berserk
ShaderTechnique.hpp
Go to the documentation of this file.
1 /**********************************************************************************/
2 /* This file is part of Berserk Engine project */
3 /* https://github.com/EgorOrachyov/Berserk */
4 /**********************************************************************************/
5 /* MIT License */
6 /* */
7 /* Copyright (c) 2018 - 2021 Egor Orachyov */
8 /* */
9 /* Permission is hereby granted, free of charge, to any person obtaining a copy */
10 /* of this software and associated documentation files (the "Software"), to deal */
11 /* in the Software without restriction, including without limitation the rights */
12 /* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
13 /* copies of the Software, and to permit persons to whom the Software is */
14 /* furnished to do so, subject to the following conditions: */
15 /* */
16 /* The above copyright notice and this permission notice shall be included in all */
17 /* copies or substantial portions of the Software. */
18 /* */
19 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
20 /* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
21 /* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
22 /* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
23 /* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
24 /* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
25 /* SOFTWARE. */
26 /**********************************************************************************/
27 
28 #ifndef BERSERK_SHADERTECHNIQUE_HPP
29 #define BERSERK_SHADERTECHNIQUE_HPP
30 
31 #include <core/Config.hpp>
32 #include <core/Typedefs.hpp>
34 #include <core/templates/Mask.hpp>
36 
37 #include <vector>
38 
40 
50 enum class ShaderTechniqueTag {
51 
52 };
53 
59 
64 class ShaderTechnique final : public RefCnt {
65 public:
67  BRK_API ShaderTechnique() = default;
68  BRK_API ~ShaderTechnique() override = default;
69 
71  BRK_API void SetName(StringName name);
73  BRK_API void SetTags(const ShaderTechniqueTags &tags);
75  BRK_API void SetRHIType(RHIType rhiType);
79  BRK_API void SetPasses(std::vector<Ref<ShaderPass>> passes);
81  BRK_API void SetShader(class Shader *shader);
82 
84  BRK_API void FillPipelineDesc(RHIGraphicsPipelineDesc &desc, uint32 passIdx) const;
85 
87  BRK_API bool IsCompiled() const;
88 
94  BRK_API size_t GetPassesCount() const { return mPasses.size(); }
95 
97  BRK_API const StringName &GetName() const { return mName; }
99  BRK_API const ShaderTechniqueTags &GetTags() const { return mTags; }
101  BRK_API RHIType GetRHIType() const { return mRHIType; }
103  BRK_API RHIShaderLanguage GetRHILanguage() const { return mRHILanguage; }
105  BRK_API const std::vector<Ref<ShaderPass>> &GetPasses() const { return mPasses; }
107  BRK_API class Shader *GetShader() const { return mShader; }
108 
109 private:
111  StringName mName;
113  ShaderTechniqueTags mTags;
115  RHIType mRHIType = RHIType::Unknown;
119  std::vector<Ref<ShaderPass>> mPasses;
121  class Shader *mShader = nullptr;
123  mutable bool mIsCompiled = false;
124 };
125 
131 
132 #endif//BERSERK_SHADERTECHNIQUE_HPP
#define BRK_NS_END
Definition: Config.hpp:48
#define BRK_API
Definition: Config.hpp:32
std::uint32_t uint32
Definition: Typedefs.hpp:44
Graphics pipeline descriptor.
Definition: RHIGraphicsPipeline.hpp:208
Reference counted base object.
Definition: RefCnt.hpp:52
Technique tags used to select techniques.
Represents particular approach to draw single object.
Definition: ShaderTechnique.hpp:64
BRK_API void SetRHILanguage(RHIShaderLanguage language)
Definition: ShaderTechnique.cpp:46
BRK_API class Shader * GetShader() const
Definition: ShaderTechnique.hpp:107
BRK_API RHIType GetRHIType() const
Definition: ShaderTechnique.hpp:101
BRK_API void SetPasses(std::vector< Ref< ShaderPass >> passes)
Definition: ShaderTechnique.cpp:50
BRK_API RHIShaderLanguage GetRHILanguage() const
Definition: ShaderTechnique.hpp:103
BRK_API void SetShader(class Shader *shader)
Definition: ShaderTechnique.cpp:55
BRK_API const StringName & GetName() const
Definition: ShaderTechnique.hpp:97
BRK_API const ShaderTechniqueTags & GetTags() const
Definition: ShaderTechnique.hpp:99
BRK_API ShaderTechnique()=default
BRK_API void SetRHIType(RHIType rhiType)
Definition: ShaderTechnique.cpp:42
BRK_API bool IsCompiled() const
Definition: ShaderTechnique.cpp:64
BRK_API void SetName(StringName name)
Definition: ShaderTechnique.cpp:34
BRK_API ~ShaderTechnique() override=default
BRK_API void FillPipelineDesc(RHIGraphicsPipelineDesc &desc, uint32 passIdx) const
Definition: ShaderTechnique.cpp:59
BRK_API const std::vector< Ref< ShaderPass > > & GetPasses() const
Definition: ShaderTechnique.hpp:105
BRK_API Ref< const ShaderPass > GetPass(const StringName &name) const
Definition: ShaderTechnique.cpp:74
BRK_API size_t GetPassesCount() const
Definition: ShaderTechnique.hpp:94
BRK_API void SetTags(const ShaderTechniqueTags &tags)
Definition: ShaderTechnique.cpp:38
Defines complete rendering flow for the object.
Definition: Shader.hpp:86
Cached shared utf-8 string id.
Definition: StringName.hpp:61
RHIType
Definition: RHIDefs.hpp:43
RHIShaderLanguage
Definition: RHIDefs.hpp:127
Definition: GLDevice.cpp:46