Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Divide::glShader Class Referencefinal

#include <glShader.h>

+ Inheritance diagram for Divide::glShader:

Public Member Functions

 glShader (GFXDevice &context, const std::string_view name, const U32 generation)
 
 ~glShader () override
 
bool load (const ShaderProgram::ShaderLoadData &data)
 
 PROPERTY_R_IW (gl46core::UseProgramStageMask, stageMask, gl46core::UseProgramStageMask::GL_NONE_BIT)
 
 PROPERTY_R_IW (gl46core::GLuint, handle, GL_NULL_HANDLE)
 
- Public Member Functions inherited from Divide::ShaderModule
 ShaderModule (GFXDevice &context, const std::string_view name, U32 generation)
 
virtual ~ShaderModule () override
 
void registerParent (ShaderProgram *parent)
 
void deregisterParent (ShaderProgram *parent)
 
 PROPERTY_R (Str< 256 >, name)
 
 PROPERTY_R (bool, valid, false)
 
 PROPERTY_R (bool, inUse, true)
 
 PROPERTY_R (U32, generation, 0u)
 
 PROPERTY_R (U64, lastUsedFrame, U64_MAX - MAX_FRAME_LIFETIME - 1u)
 
- Public Member Functions inherited from Divide::GUIDWrapper
 GUIDWrapper () noexcept
 
 GUIDWrapper (const GUIDWrapper &old) noexcept
 
 GUIDWrapper (GUIDWrapper &&old) noexcept
 
virtual ~GUIDWrapper ()=default
 
FORCE_INLINE I64 getGUID () const noexcept
 
GUIDWrapperoperator= (const GUIDWrapper &old)=delete
 
GUIDWrapperoperator= (GUIDWrapper &&other)=delete
 
- Public Member Functions inherited from Divide::GraphicsResource
virtual ~GraphicsResource ()
 
GFXDevicecontext () const noexcept
 
U64 nameHash () const noexcept
 
- Public Member Functions inherited from Divide::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable (NonCopyable &&)=default
 
NonCopyableoperator= (NonCopyable &&)=default
 
- Public Member Functions inherited from Divide::NonMovable
 NonMovable (NonMovable &&)=delete
 
NonMovableoperator= (NonMovable &&)=delete
 
 NonMovable (const NonMovable &)=default
 
NonMovableoperator= (const NonMovable &)=default
 

Static Public Member Functions

static glShaderEntry LoadShader (GFXDevice &context, glShaderProgram *parent, const std::string_view name, U32 targetGeneration, ShaderProgram::ShaderLoadData &data)
 Add or refresh a shader from the cache.
 
- Static Public Member Functions inherited from Divide::ShaderModule
static ShaderModuleGetShader (const std::string_view name)
 Returns a reference to an already loaded shader, null otherwise.
 
static void Idle (bool fast)
 
static void InitStaticData ()
 
static void DestroyStaticData ()
 
- Static Public Member Functions inherited from Divide::GUIDWrapper
static I64 generateGUID () noexcept
 

Private Member Functions

ShaderResult uploadToGPU ()
 
void onParentValidation ()
 
void uploadPushConstants (const PushConstantsStruct &pushConstants)
 

Private Attributes

ShaderProgram::ShaderLoadData _loadData
 
vector< gl46core::GLuint > _shaderIDs
 
bool _linked = false
 
gl46core::GLint _pushConstantsLocation {-2}
 

Friends

class glShaderProgram
 

Additional Inherited Members

- Public Types inherited from Divide::GraphicsResource
enum class  Type : U8 {
  RENDER_TARGET , SHADER_BUFFER , BUFFER , SHADER ,
  SHADER_PROGRAM , TEXTURE , COUNT
}
 
- Protected Types inherited from Divide::ShaderModule
using ShaderMap = hashMap< U64, ShaderModule_uptr >
 
- Protected Member Functions inherited from Divide::GraphicsResource
 GraphicsResource (GFXDevice &context, Type type, I64 GUID, U64 nameHash)
 
- Protected Member Functions inherited from Divide::NonCopyable
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 
- Protected Member Functions inherited from Divide::NonMovable
 NonMovable ()=default
 
 ~NonMovable ()=default
 
- Static Protected Member Functions inherited from Divide::ShaderModule
static ShaderModuleGetShaderLocked (const std::string_view name)
 
- Protected Attributes inherited from Divide::ShaderModule
Mutex _parentLock
 
eastl::fixed_vector< ShaderProgram *, 4, true > _parents
 
- Protected Attributes inherited from Divide::GUIDWrapper
const I64 _guid
 
- Protected Attributes inherited from Divide::GraphicsResource
GFXDevice_context
 
- Static Protected Attributes inherited from Divide::ShaderModule
static constexpr U32 MAX_FRAME_LIFETIME = Config::TARGET_FRAME_RATE * 10
 
static std::atomic_bool s_modulesRemoved
 Shader cache.
 
static ShaderMap s_shaderNameMap
 
static SharedMutex s_shaderNameLock
 

Detailed Description

glShader represents one of a program's rendering stages (vertex, geometry, fragment, etc) It can be used simultaneously in multiple programs/pipelines

Definition at line 58 of file glShader.h.

Constructor & Destructor Documentation

◆ glShader()

Divide::glShader::glShader ( GFXDevice context,
const std::string_view  name,
const U32  generation 
)
explicit

The shader's name is the period-separated list of properties, type is the render stage this shader is used for

Definition at line 50 of file glShader.cpp.

◆ ~glShader()

Divide::glShader::~glShader ( )
override

Definition at line 55 of file glShader.cpp.

Member Function Documentation

◆ load()

bool Divide::glShader::load ( const ShaderProgram::ShaderLoadData data)

Definition at line 284 of file glShader.cpp.

◆ LoadShader()

glShaderEntry Divide::glShader::LoadShader ( GFXDevice context,
glShaderProgram parent,
const std::string_view  name,
U32  targetGeneration,
ShaderProgram::ShaderLoadData data 
)
static

Add or refresh a shader from the cache.

Load a shader by name, source code and stage.

Definition at line 320 of file glShader.cpp.

◆ onParentValidation()

void Divide::glShader::onParentValidation ( )
private

Definition at line 357 of file glShader.cpp.

◆ PROPERTY_R_IW() [1/2]

Divide::glShader::PROPERTY_R_IW ( gl46core::GLuint  ,
handle  ,
GL_NULL_HANDLE   
)

◆ PROPERTY_R_IW() [2/2]

Divide::glShader::PROPERTY_R_IW ( gl46core::UseProgramStageMask  ,
stageMask  ,
gl46core::UseProgramStageMask::GL_NONE_BIT   
)

◆ uploadPushConstants()

void Divide::glShader::uploadPushConstants ( const PushConstantsStruct pushConstants)
private

Definition at line 371 of file glShader.cpp.

◆ uploadToGPU()

ShaderResult Divide::glShader::uploadToGPU ( )
private

Definition at line 67 of file glShader.cpp.

Friends And Related Function Documentation

◆ glShaderProgram

friend class glShaderProgram
friend

Definition at line 79 of file glShader.h.

Member Data Documentation

◆ _linked

bool Divide::glShader::_linked = false
private

Definition at line 89 of file glShader.h.

◆ _loadData

ShaderProgram::ShaderLoadData Divide::glShader::_loadData
private

Definition at line 87 of file glShader.h.

◆ _pushConstantsLocation

gl46core::GLint Divide::glShader::_pushConstantsLocation {-2}
private

Definition at line 90 of file glShader.h.

◆ _shaderIDs

vector<gl46core::GLuint> Divide::glShader::_shaderIDs
private

Definition at line 88 of file glShader.h.


The documentation for this class was generated from the following files: