Nebula
Loading...
Searching...
No Matches
shaderserverbase.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
25//------------------------------------------------------------------------------
26#include "core/refcounted.h"
27#include "core/singleton.h"
28#include "coregraphics/shader.h"
30#include "coregraphics/shader.h"
33#include "threading/safequeue.h"
34#include "util/set.h"
35
36namespace Threading
37{
38class Thread;
39}
40
41namespace IO
42{
43class FileWatcher;
44class FileWatcherThread;
45}
46
47namespace CoreGraphics
48{
49class Shader;
50}
51
52namespace Frame
53{
54class FrameScript;
55};
56
57namespace Base
58{
60{
63public:
67 virtual ~ShaderServerBase();
68
70 bool Open();
72 void Close();
74 bool IsOpen() const;
75
77 bool HasShader(const Resources::ResourceName& resId) const;
78
83
85 void ResetFeatureBits();
96
98 void LoadShader(const Resources::ResourceName& shdName);
99
101 void BeforeFrame();
102
103protected:
105 friend class ShaderBase;
106
115
116 bool isOpen;
117};
118
119//------------------------------------------------------------------------------
122inline bool
124{
125 return this->isOpen;
126}
127
128//------------------------------------------------------------------------------
131inline bool
133{
134 return this->shaders.Contains(resId);
135}
136
137//------------------------------------------------------------------------------
142{
143 return this->shaders;
144}
145
146//------------------------------------------------------------------------------
149inline const CoreGraphics::ShaderId
151{
152 n_assert_fmt(this->shaders.Contains(resId), "%s not found!\n This might be a problem with your export. Check the exports folder!\n", resId.Value());
153 Resources::ResourceId shader = this->shaders[resId];
154 CoreGraphics::ShaderId ret = shader.resource;
155 return ret;
156}
157
158//------------------------------------------------------------------------------
163{
164 return this->shaderFeature.StringToMask(str);
165}
166
167//------------------------------------------------------------------------------
170inline Util::String
175
176//------------------------------------------------------------------------------
179inline void
184
185//------------------------------------------------------------------------------
188inline void
193
194//------------------------------------------------------------------------------
197inline void
202
203//------------------------------------------------------------------------------
208{
209 return this->curShaderFeatureBits;
210}
211
212} // namespace Base
213//------------------------------------------------------------------------------
214
void ClearFeatureBits(CoreGraphics::ShaderFeature::Mask m)
clear shader feature by bit mask
Definition shaderserverbase.h:198
Util::Dictionary< Util::String, Util::Set< Util::String > > shaderReloadMap
Definition shaderserverbase.h:111
Threading::SafeQueue< Resources::ResourceName > pendingShaderReloads
Definition shaderserverbase.h:113
bool HasShader(const Resources::ResourceName &resId) const
return true if a shader exists
Definition shaderserverbase.h:132
bool Open()
open the shader server
Definition shaderserverbase.cc:73
void ResetFeatureBits()
reset the current feature bits
Definition shaderserverbase.h:180
void SetFeatureBits(CoreGraphics::ShaderFeature::Mask m)
set shader feature by bit mask
Definition shaderserverbase.h:189
Util::String FeatureMaskToString(CoreGraphics::ShaderFeature::Mask mask)
convert shader feature bit mask into string
Definition shaderserverbase.h:171
void BeforeFrame()
update shader server outside of frame
Definition shaderserverbase.cc:302
CoreGraphics::ShaderFeature::Mask FeatureStringToMask(const Util::String &str)
convert a shader feature string into a feature bit mask
Definition shaderserverbase.h:162
virtual ~ShaderServerBase()
destructor
Definition shaderserverbase.cc:40
void Close()
close the shader server
Definition shaderserverbase.cc:259
bool IsOpen() const
return true if the shader server is open
Definition shaderserverbase.h:123
void LoadShader(const Resources::ResourceName &shdName)
explicitly loads a shader by resource id
Definition shaderserverbase.cc:286
__DeclareSingleton(ShaderServerBase)
Util::Array< Util::String > shaderWatchFolders
Definition shaderserverbase.h:112
bool isOpen
Definition shaderserverbase.h:116
CoreGraphics::ShaderFeature shaderFeature
Definition shaderserverbase.h:108
friend class ShaderBase
Definition shaderserverbase.h:105
Util::Dictionary< Resources::ResourceName, Resources::ResourceId > shaders
Definition shaderserverbase.h:110
const Util::Dictionary< Resources::ResourceName, Resources::ResourceId > & GetAllShaders() const
get all loaded shaders
Definition shaderserverbase.h:141
Ids::Id32 objectIdShaderVar
Definition shaderserverbase.h:114
CoreGraphics::ShaderFeature::Mask GetFeatureBits() const
get the current feature mask
Definition shaderserverbase.h:207
CoreGraphics::ShaderFeature::Mask curShaderFeatureBits
Definition shaderserverbase.h:109
CoreGraphics::ShaderIdentifier shaderIdentifierRegistry
Definition shaderserverbase.h:107
__DeclareClass(ShaderServerBase)
const CoreGraphics::ShaderId GetShader(Resources::ResourceName resId) const
get shader by name
Definition shaderserverbase.h:150
ShaderServerBase()
constructor
Definition shaderserverbase.cc:29
The common base class of Nebula.
Definition refcounted.h:38
Wrapper class for shader permutations by name.
Definition shaderfeature.h:28
uint Mask
a shader feature bit mask
Definition shaderfeature.h:31
The ShaderIdentifier is a zero-indexed registry which is used to identify shaders in a constant time ...
Definition shaderidentifier.h:33
A FrameScript describes render operations being done to produce a single frame.
Definition framescript.h:41
For registering callbacks for file modification events.
Definition filewatcher.h:75
Thread-safe version of Util::Queue.
Definition safequeue.h:27
Nebula's dynamic array class.
Definition array.h:61
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:35
const char * Value() const
get contained string as char ptr (fast)
Definition stringatom.h:362
Nebula's universal string class.
Definition string.h:50
#define n_assert_fmt(exp, msg,...)
Definition debug.h:61
Definition gamecontentserverbase.cc:10
Acceleration structures are used to enable ray tracing on the GPU by dividing the scene into a BVH.
Definition accelerationstructure.h:24
ImGUI debug interface for inspecting frame scripts.
Definition shaderserverbase.h:53
Instances of wrapped stream classes.
Definition multiplayerfeatureunit.cc:324
uint32_t Id32
Definition id.h:138
Util::StringAtom ResourceName
Definition resourceid.h:33
The Jobs2 system provides a set of threads and a pool of jobs from which threads can pickup work.
Definition jobs2.h:16
A shader represents an entire shader resource, containing several stages and programs.
Definition shader.h:47