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
108 void CompileShaderFile(const Util::String& changedFile);
109
119
120 bool isOpen;
121};
122
123//------------------------------------------------------------------------------
126inline bool
128{
129 return this->isOpen;
130}
131
132//------------------------------------------------------------------------------
135inline bool
137{
138 return this->shaders.Contains(resId);
139}
140
141//------------------------------------------------------------------------------
146{
147 return this->shaders;
148}
149
150//------------------------------------------------------------------------------
153inline const CoreGraphics::ShaderId
155{
156 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());
157 Resources::ResourceId shader = this->shaders[resId];
158 CoreGraphics::ShaderId ret = shader.resource;
159 return ret;
160}
161
162//------------------------------------------------------------------------------
170
171//------------------------------------------------------------------------------
174inline Util::String
179
180//------------------------------------------------------------------------------
183inline void
188
189//------------------------------------------------------------------------------
192inline void
197
198//------------------------------------------------------------------------------
201inline void
206
207//------------------------------------------------------------------------------
212{
213 return this->curShaderFeatureBits;
214}
215
216} // namespace Base
217//------------------------------------------------------------------------------
218
void ClearFeatureBits(CoreGraphics::ShaderFeature::Mask m)
clear shader feature by bit mask
Definition shaderserverbase.h:202
Threading::SafeQueue< Util::String > pendingShaderCompiles
Definition shaderserverbase.h:116
Util::Dictionary< Util::String, Util::Set< Util::String > > shaderReloadMap
Definition shaderserverbase.h:114
Threading::SafeQueue< Resources::ResourceName > pendingShaderReloads
Definition shaderserverbase.h:117
bool HasShader(const Resources::ResourceName &resId) const
return true if a shader exists
Definition shaderserverbase.h:136
bool Open()
open the shader server
Definition shaderserverbase.cc:73
void ResetFeatureBits()
reset the current feature bits
Definition shaderserverbase.h:184
void SetFeatureBits(CoreGraphics::ShaderFeature::Mask m)
set shader feature by bit mask
Definition shaderserverbase.h:193
Util::String FeatureMaskToString(CoreGraphics::ShaderFeature::Mask mask)
convert shader feature bit mask into string
Definition shaderserverbase.h:175
void BeforeFrame()
update shader server outside of frame
Definition shaderserverbase.cc:315
CoreGraphics::ShaderFeature::Mask FeatureStringToMask(const Util::String &str)
convert a shader feature string into a feature bit mask
Definition shaderserverbase.h:166
void Close()
close the shader server
Definition shaderserverbase.cc:200
bool IsOpen() const
return true if the shader server is open
Definition shaderserverbase.h:127
void LoadShader(const Resources::ResourceName &shdName)
explicitly loads a shader by resource id
Definition shaderserverbase.cc:228
__DeclareSingleton(ShaderServerBase)
Util::Array< Util::String > shaderWatchFolders
Definition shaderserverbase.h:115
bool isOpen
Definition shaderserverbase.h:120
CoreGraphics::ShaderFeature shaderFeature
Definition shaderserverbase.h:111
friend class ShaderBase
Definition shaderserverbase.h:105
Util::Dictionary< Resources::ResourceName, Resources::ResourceId > shaders
Definition shaderserverbase.h:113
const Util::Dictionary< Resources::ResourceName, Resources::ResourceId > & GetAllShaders() const
get all loaded shaders
Definition shaderserverbase.h:145
void CompileShaderFile(const Util::String &changedFile)
compile a shader source
Definition shaderserverbase.cc:244
Ids::Id32 objectIdShaderVar
Definition shaderserverbase.h:118
CoreGraphics::ShaderFeature::Mask GetFeatureBits() const
get the current feature mask
Definition shaderserverbase.h:211
CoreGraphics::ShaderFeature::Mask curShaderFeatureBits
Definition shaderserverbase.h:112
CoreGraphics::ShaderIdentifier shaderIdentifierRegistry
Definition shaderserverbase.h:110
__DeclareClass(ShaderServerBase)
const CoreGraphics::ShaderId GetShader(Resources::ResourceName resId) const
get shader by name
Definition shaderserverbase.h:154
ShaderServerBase()
constructor
Definition shaderserverbase.cc:29
The common base class of Nebula.
Definition refcounted.h:45
Wrapper class for shader permutations by name.
Definition shaderfeature.h:28
Mask StringToMask(const Util::String &str)
generate a bit mask from a shader feature string
Definition shaderfeature.cc:27
Util::String MaskToString(Mask mask)
convert a bit mask into a shader feature string
Definition shaderfeature.cc:49
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