![]() |
Divide Framework 0.1
A free and open-source 3D Framework under heavy development
|
#include <ShaderProgram.h>
Classes | |
struct | BindingsPerSet |
struct | LastRequestedShader |
struct | LoadData |
struct | ShaderQueueEntry |
Public Types | |
using | RenderTargets = std::array< bool, to_base(RTColourAttachmentSlot::COUNT)> |
using | ShaderLoadData = std::array< LoadData, to_base(ShaderType::COUNT)> |
using | ShaderProgramMap = eastl::fixed_vector< ShaderProgram *, U16_MAX, true > |
using | AtomMap = hashMap< U64, string > |
using | AtomInclusionMap = hashMap< U64, eastl::set< U64 > > |
using | ShaderQueue = eastl::stack< ShaderQueueEntry, vector< ShaderQueueEntry > > |
using | BindingsPerSetArray = std::array< BindingsPerSet, MAX_BINDINGS_PER_DESCRIPTOR_SET > |
using | SetUsageData = std::array< bool, to_base(DescriptorSetUsage::COUNT)> |
using | BindingSetData = std::array< BindingsPerSetArray, to_base(DescriptorSetUsage::COUNT)> |
![]() | |
enum class | Type : U8 { RENDER_TARGET , SHADER_BUFFER , BUFFER , SHADER , SHADER_PROGRAM , TEXTURE , COUNT } |
Public Member Functions | |
ShaderProgram (PlatformContext &context, const ResourceDescriptor< ShaderProgram > &descriptor) | |
~ShaderProgram () override | |
bool | load (PlatformContext &context) override |
Loading and unloading interface. | |
bool | postLoad () override |
bool | unload () override |
bool | recompile () |
bool | recompile (bool &skipped) |
Rebuild the specified shader stages from source code. | |
virtual ShaderResult | validatePreBind (bool rebind=true) |
bool | uploadUniformData (const UniformData &data, DescriptorSet &set, GFX::MemoryBarrierCommand &memCmdInOut) |
const ShaderProgramDescriptor & | descriptor () const noexcept |
PROPERTY_RW (bool, highPriority, true) | |
PROPERTY_RW (bool, useShaderCache, true) | |
PROPERTY_R_IW (BindingsPerSetArray, perDrawDescriptorSetLayout) | |
PROPERTY_R_IW (RenderTargets, fragmentOutputs) | |
PROPERTY_R_IW (SetUsageData, setUsage) | |
![]() | |
CachedResource (const ResourceDescriptorBase &descriptor, std::string_view typeName) | |
virtual bool | load (PlatformContext &context) |
Loading and unloading interface. | |
virtual bool | postLoad () |
virtual bool | unload () |
void | setState (ResourceState currentState) final |
![]() | |
Resource (std::string_view resourceName, std::string_view typeName) | |
ResourceState | getState () const noexcept |
PROPERTY_R (Str< 32 >, typeName) | |
PROPERTY_R (Str< 256 >, resourceName) | |
![]() | |
GUIDWrapper () noexcept | |
GUIDWrapper (const GUIDWrapper &old) noexcept | |
GUIDWrapper (GUIDWrapper &&old) noexcept | |
virtual | ~GUIDWrapper ()=default |
FORCE_INLINE I64 | getGUID () const noexcept |
GUIDWrapper & | operator= (const GUIDWrapper &old)=delete |
GUIDWrapper & | operator= (GUIDWrapper &&other)=delete |
![]() | |
virtual | ~GraphicsResource () |
GFXDevice & | context () const noexcept |
U64 | nameHash () const noexcept |
![]() | |
NonCopyable (const NonCopyable &)=delete | |
NonCopyable & | operator= (const NonCopyable &)=delete |
NonCopyable (NonCopyable &&)=default | |
NonCopyable & | operator= (NonCopyable &&)=default |
![]() | |
NonMovable (NonMovable &&)=delete | |
NonMovable & | operator= (NonMovable &&)=delete |
NonMovable (const NonMovable &)=default | |
NonMovable & | operator= (const NonMovable &)=default |
Static Public Member Functions | |
static void | Idle (PlatformContext &platformContext, bool fast) |
static void | InitStaticData () |
static void | DestroyStaticData () |
static ErrorCode | OnStartup (PlatformContext &context) |
static bool | OnShutdown () |
static void | OnBeginFrame (GFXDevice &gfx) |
static void | OnEndFrame (GFXDevice &gfx) |
static bool | RecompileShaderProgram (const std::string_view name) |
Queue a shaderProgram recompile request. | |
static bool | UnregisterShaderProgram (ShaderProgram *shaderProgram) |
Remove a shaderProgram from the program cache. | |
static void | RegisterShaderProgram (ShaderProgram *shaderProgram) |
Add a shaderProgram to the program cache. | |
static void | RebuildAllShaders () |
static vector< ResourcePath > | GetAllAtomLocations () |
static I32 | ShaderProgramCount () noexcept |
static void | OnAtomChange (std::string_view atomName, FileUpdateEvent evt) |
static U8 | GetGLBindingForDescriptorSlot (DescriptorSetUsage usage, U8 slot) noexcept |
static std::pair< DescriptorSetUsage, U8 > | GetDescriptorSlotForGLBinding (U8 binding, DescriptorSetBindingType type) noexcept |
static BindingSetData & | GetBindingSetData () noexcept |
static void | RegisterSetLayoutBinding (DescriptorSetUsage usage, U8 slot, DescriptorSetBindingType type, ShaderStageVisibility visibility) |
static ErrorCode | SubmitSetLayouts (GFXDevice &gfx) |
static U32 | GetBindingCount (DescriptorSetUsage usage, DescriptorSetBindingType type) |
![]() | |
static I64 | generateGUID () noexcept |
Static Public Attributes | |
static constexpr const char * | UNIFORM_BLOCK_NAME = "dvd_uniforms" |
static U8 | k_commandBufferID = U8_MAX - MAX_BINDINGS_PER_DESCRIPTOR_SET |
static Mutex | g_cacheLock |
Protected Member Functions | |
virtual bool | loadInternal (hashMap< U64, PerFileShaderData > &fileData, bool overwrite) |
bool | loadSourceCode (const ModuleDefines &defines, bool reloadExisting, LoadData &loadDataInOut, Reflection::UniformsSet &previousUniformsInOut, U8 &blockIndexInOut) |
void | loadAndParseGLSL (const ModuleDefines &defines, LoadData &loadDataInOut, Reflection::UniformsSet &previousUniformsInOut, U8 &blockIndexInOut, eastl::set< U64 > &atomIDsInOut) |
void | initDrawDescriptorSetLayout (const PerFileShaderData &loadData) |
void | initUniformUploader (const PerFileShaderData &loadData) |
![]() | |
PROPERTY_RW (ResourcePath, assetLocation) | |
PROPERTY_RW (Str< 256 >, assetName) | |
PROPERTY_R (size_t, descriptorHash) | |
virtual void | setState (ResourceState currentState) |
![]() | |
GraphicsResource (GFXDevice &context, Type type, I64 GUID, U64 nameHash) | |
![]() | |
NonCopyable ()=default | |
~NonCopyable ()=default | |
![]() | |
NonMovable ()=default | |
~NonMovable ()=default | |
Static Protected Member Functions | |
static bool | SaveToCache (LoadData::ShaderCacheType cache, const LoadData &dataIn, const eastl::set< U64 > &atomIDsIn) |
static bool | LoadFromCache (LoadData::ShaderCacheType cache, LoadData &dataInOut, eastl::set< U64 > &atomIDsOut) |
static void | OnThreadCreated (const GFXDevice &gfx, const std::thread::id &threadID, bool isMainRenderThread) |
Protected Attributes | |
const ShaderProgramDescriptor | _descriptor |
vector< UniformBlockUploader > | _uniformBlockBuffers |
eastl::set< U64 > | _usedAtomIDs |
![]() | |
Mutex | _callbackLock {} |
![]() | |
std::atomic< ResourceState > | _resourceState |
![]() | |
const I64 | _guid |
![]() | |
GFXDevice & | _context |
Static Protected Attributes | |
static ShaderQueue | s_recompileQueue |
static ShaderQueue | s_recompileFailedQueue |
static ShaderProgramMap | s_shaderPrograms |
Shader program cache. | |
static eastl::fixed_vector< ShaderProgram *, U16_MAX, false > | s_usedShaderPrograms |
static LastRequestedShader | s_lastRequestedShaderProgram = {} |
static SharedMutex | s_programLock |
static std::atomic_int | s_shaderCount |
static I64 | s_shaderFileWatcherID = -1 |
static Mutex | s_atomLock |
Shaders loaded from files are kept as atoms. | |
static AtomMap | s_atoms |
static AtomInclusionMap | s_atomIncludes |
static ResourcePath | shaderAtomLocationPrefix [to_base(ShaderType::COUNT)+1] |
static Str< 8 > | shaderAtomExtensionName [to_base(ShaderType::COUNT)+1] |
static U64 | shaderAtomExtensionHash [to_base(ShaderType::COUNT)+1] |
static BindingSetData | s_bindingsPerSet |
Static Private Member Functions | |
static void | EraseAtom (const U64 atomHash) |
static void | EraseAtomLocked (const U64 atomHash) |
static const string & | ShaderFileRead (const ResourcePath &filePath, std::string_view atomName, bool recurse, eastl::set< U64 > &foundAtomIDsInOut, bool &wasParsed) |
static const string & | ShaderFileReadLocked (const ResourcePath &filePath, std::string_view atomName, bool recurse, eastl::set< U64 > &foundAtomIDsInOut, bool &wasParsed) |
Open the file found at 'filePath' matching 'atomName' and return it's source code. | |
static void | PreprocessIncludes (std::string_view name, string &sourceInOut, I32 level, eastl::set< U64 > &foundAtomIDsInOut, bool lock) |
Friends | |
template<typename T > | |
class | ImplResourceLoader |
class | PlatformContext |
Definition at line 117 of file ShaderProgram.h.
using Divide::ShaderProgram::AtomInclusionMap = hashMap<U64 , eastl::set<U64> > |
Definition at line 169 of file ShaderProgram.h.
using Divide::ShaderProgram::AtomMap = hashMap<U64 , string> |
Definition at line 168 of file ShaderProgram.h.
using Divide::ShaderProgram::BindingSetData = std::array<BindingsPerSetArray, to_base( DescriptorSetUsage::COUNT )> |
Definition at line 180 of file ShaderProgram.h.
using Divide::ShaderProgram::BindingsPerSetArray = std::array<BindingsPerSet, MAX_BINDINGS_PER_DESCRIPTOR_SET> |
Definition at line 178 of file ShaderProgram.h.
using Divide::ShaderProgram::RenderTargets = std::array<bool, to_base( RTColourAttachmentSlot::COUNT )> |
Definition at line 163 of file ShaderProgram.h.
using Divide::ShaderProgram::SetUsageData = std::array<bool, to_base(DescriptorSetUsage::COUNT)> |
Definition at line 179 of file ShaderProgram.h.
using Divide::ShaderProgram::ShaderLoadData = std::array<LoadData, to_base( ShaderType::COUNT )> |
Definition at line 164 of file ShaderProgram.h.
using Divide::ShaderProgram::ShaderProgramMap = eastl::fixed_vector<ShaderProgram*, U16_MAX, true> |
Definition at line 166 of file ShaderProgram.h.
using Divide::ShaderProgram::ShaderQueue = eastl::stack<ShaderQueueEntry, vector<ShaderQueueEntry> > |
Definition at line 170 of file ShaderProgram.h.
|
explicit |
Definition at line 882 of file ShaderProgram.cpp.
|
override |
Definition at line 903 of file ShaderProgram.cpp.
|
inlinenoexcept |
Definition at line 229 of file ShaderProgram.h.
|
static |
Definition at line 1024 of file ShaderProgram.cpp.
|
staticprivate |
Definition at line 2077 of file ShaderProgram.cpp.
|
staticprivate |
Definition at line 2084 of file ShaderProgram.cpp.
|
static |
Definition at line 1327 of file ShaderProgram.cpp.
|
static |
Definition at line 1229 of file ShaderProgram.cpp.
|
staticnoexcept |
Definition at line 1191 of file ShaderProgram.cpp.
|
staticnoexcept |
Definition at line 1173 of file ShaderProgram.cpp.
|
staticnoexcept |
Definition at line 1168 of file ShaderProgram.cpp.
|
static |
Definition at line 977 of file ShaderProgram.cpp.
|
protected |
Definition at line 1724 of file ShaderProgram.cpp.
|
static |
Definition at line 1019 of file ShaderProgram.cpp.
|
protected |
Definition at line 1795 of file ShaderProgram.cpp.
|
overridevirtual |
Loading and unloading interface.
Reimplemented from Divide::CachedResource.
Definition at line 909 of file ShaderProgram.cpp.
|
protected |
Definition at line 1950 of file ShaderProgram.cpp.
|
staticprotected |
Definition at line 1575 of file ShaderProgram.cpp.
|
protectedvirtual |
Reimplemented in Divide::glShaderProgram, and Divide::vkShaderProgram.
Definition at line 1650 of file ShaderProgram.cpp.
|
protected |
Definition at line 1852 of file ShaderProgram.cpp.
|
static |
Definition at line 2112 of file ShaderProgram.cpp.
|
static |
Definition at line 1259 of file ShaderProgram.cpp.
|
static |
Definition at line 1264 of file ShaderProgram.cpp.
|
static |
Definition at line 1139 of file ShaderProgram.cpp.
|
static |
Definition at line 1060 of file ShaderProgram.cpp.
|
staticprotected |
Definition at line 967 of file ShaderProgram.cpp.
|
overridevirtual |
Reimplemented from Divide::CachedResource.
Definition at line 922 of file ShaderProgram.cpp.
|
staticprivate |
Definition at line 1361 of file ShaderProgram.cpp.
Divide::ShaderProgram::PROPERTY_R_IW | ( | BindingsPerSetArray | , |
perDrawDescriptorSetLayout | |||
) |
Divide::ShaderProgram::PROPERTY_R_IW | ( | RenderTargets | , |
fragmentOutputs | |||
) |
Divide::ShaderProgram::PROPERTY_R_IW | ( | SetUsageData | , |
setUsage | |||
) |
Divide::ShaderProgram::PROPERTY_RW | ( | bool | , |
highPriority | , | ||
true | |||
) |
Divide::ShaderProgram::PROPERTY_RW | ( | bool | , |
useShaderCache | , | ||
true | |||
) |
|
static |
Definition at line 1317 of file ShaderProgram.cpp.
|
inline |
Definition at line 191 of file ShaderProgram.h.
bool Divide::ShaderProgram::recompile | ( | bool & | skipped | ) |
Rebuild the specified shader stages from source code.
Definition at line 942 of file ShaderProgram.cpp.
|
static |
Queue a shaderProgram recompile request.
Calling this will force a recompilation of all shader stages for the program that matches the name specified.
Definition at line 1030 of file ShaderProgram.cpp.
|
static |
Definition at line 1196 of file ShaderProgram.cpp.
|
static |
Add a shaderProgram to the program cache.
Whenever a new program is created, it's registered with the manager.
Definition at line 1283 of file ShaderProgram.cpp.
|
staticprotected |
Definition at line 1502 of file ShaderProgram.cpp.
|
staticprivate |
Definition at line 1355 of file ShaderProgram.cpp.
|
staticprivate |
Open the file found at 'filePath' matching 'atomName' and return it's source code.
Definition at line 1455 of file ShaderProgram.cpp.
|
inlinestaticnoexcept |
Definition at line 224 of file ShaderProgram.h.
Definition at line 1127 of file ShaderProgram.cpp.
|
overridevirtual |
Reimplemented from Divide::CachedResource.
Definition at line 928 of file ShaderProgram.cpp.
|
static |
Remove a shaderProgram from the program cache.
Unloading/Deleting a program will unregister it from the manager.
Definition at line 1300 of file ShaderProgram.cpp.
bool Divide::ShaderProgram::uploadUniformData | ( | const UniformData & | data, |
DescriptorSet & | set, | ||
GFX::MemoryBarrierCommand & | memCmdInOut | ||
) |
Definition at line 1833 of file ShaderProgram.cpp.
|
virtual |
Reimplemented in Divide::glShaderProgram, and Divide::vkShaderProgram.
Definition at line 962 of file ShaderProgram.cpp.
|
friend |
Definition at line 306 of file ShaderProgram.h.
|
friend |
Definition at line 311 of file ShaderProgram.h.
|
protected |
Definition at line 308 of file ShaderProgram.h.
|
protected |
Definition at line 315 of file ShaderProgram.h.
|
protected |
Definition at line 316 of file ShaderProgram.h.
|
static |
Definition at line 251 of file ShaderProgram.h.
|
static |
Definition at line 123 of file ShaderProgram.h.
|
staticprotected |
Definition at line 326 of file ShaderProgram.h.
|
staticprotected |
Shaders loaded from files are kept as atoms.
Definition at line 324 of file ShaderProgram.h.
|
staticprotected |
Definition at line 325 of file ShaderProgram.h.
|
staticprotected |
Definition at line 333 of file ShaderProgram.h.
|
staticprotected |
Definition at line 270 of file ShaderProgram.h.
|
staticprotected |
Definition at line 271 of file ShaderProgram.h.
|
staticprotected |
Definition at line 260 of file ShaderProgram.h.
|
staticprotected |
Definition at line 259 of file ShaderProgram.h.
|
staticprotected |
Definition at line 319 of file ShaderProgram.h.
|
staticprotected |
Definition at line 321 of file ShaderProgram.h.
|
staticprotected |
Shader program cache.
Definition at line 262 of file ShaderProgram.h.
|
staticprotected |
Definition at line 263 of file ShaderProgram.h.
|
staticprotected |
Definition at line 331 of file ShaderProgram.h.
|
staticprotected |
Definition at line 330 of file ShaderProgram.h.
|
staticprotected |
Definition at line 329 of file ShaderProgram.h.
|
staticconstexpr |
Definition at line 121 of file ShaderProgram.h.