Luanti 5.15.0-dev
 
Loading...
Searching...
No Matches
ShaderSource Class Reference
+ Inheritance diagram for ShaderSource:
+ Collaboration diagram for ShaderSource:

Public Member Functions

 ShaderSource ()
 
 ~ShaderSource () override
 
u32 getShaderIdDirect (const std::string &name, const ShaderConstants &input_const, video::E_MATERIAL_TYPE base_mat, IShaderUniformSetterRC *setter_cb)
 
u32 getShader (const std::string &name, const ShaderConstants &input_const, video::E_MATERIAL_TYPE base_mat, IShaderUniformSetterRC *setter_cb=nullptr) override
 Generates or gets a shader.
 
const ShaderInfogetShaderInfo (u32 id) override
 returns information about an existing shader
 
void processQueue () override
 
void insertSourceShader (const std::string &name_of_shader, const std::string &filename, const std::string &program) override
 
void rebuildShaders () override
 
void addShaderConstantSetter (std::unique_ptr< IShaderConstantSetter > setter) override
 
void addShaderUniformSetterFactory (std::unique_ptr< IShaderUniformSetterFactory > setter) override
 
bool supportsSampler2DArray () const override
 Returns true if 'sampler2DArray' is supported in GLSL.
 
- Public Member Functions inherited from IWritableShaderSource
 IWritableShaderSource ()=default
 
virtual ~IWritableShaderSource ()=default
 
- Public Member Functions inherited from IShaderSource
 IShaderSource ()=default
 
virtual ~IShaderSource ()=default
 
u32 getShader (const std::string &name, MaterialType material_type, NodeDrawType drawtype=NDT_NORMAL, bool array_texture=false)
 Helper: Generates or gets a shader suitable for nodes and entities.
 
u32 getShaderRaw (const std::string &name, bool blendAlpha=false)
 Helper: Generates or gets a shader for common, general use.
 

Private Member Functions

void generateShader (ShaderInfo &info)
 
void putConstant (std::ostream &os, const ShaderConstants::mapped_type &it)
 outputs a constant to an ostream
 

Private Attributes

std::thread::id m_main_thread
 
bool m_fully_programmable = false
 
bool m_have_glsl3 = false
 
SourceShaderCache m_sourcecache
 
std::vector< ShaderInfom_shaderinfo_cache
 
std::mutex m_shaderinfo_cache_mutex
 
std::vector< std::unique_ptr< IShaderConstantSetter > > m_constant_setters
 
std::vector< std::unique_ptr< IShaderUniformSetterFactory > > m_uniform_factories
 

Constructor & Destructor Documentation

◆ ShaderSource()

ShaderSource::ShaderSource ( )

References addShaderConstantSetter(), addShaderUniformSetterFactory(), RenderingEngine::get_video_driver(), infostream, m_fully_programmable, m_have_glsl3, m_main_thread, and m_shaderinfo_cache.

+ Here is the call graph for this function:

◆ ~ShaderSource()

ShaderSource::~ShaderSource ( )
override

References RenderingEngine::get_video_driver(), infostream, m_shaderinfo_cache, and m_shaderinfo_cache_mutex.

+ Here is the call graph for this function:

Member Function Documentation

◆ addShaderConstantSetter()

void ShaderSource::addShaderConstantSetter ( std::unique_ptr< IShaderConstantSetter > setter)
inlineoverridevirtual
Note
Takes ownership of setter.

Implements IWritableShaderSource.

References m_constant_setters.

Referenced by ShaderSource().

+ Here is the caller graph for this function:

◆ addShaderUniformSetterFactory()

void ShaderSource::addShaderUniformSetterFactory ( std::unique_ptr< IShaderUniformSetterFactory > setter)
inlineoverridevirtual
Note
Takes ownership of setter.

Implements IWritableShaderSource.

References m_uniform_factories.

Referenced by ShaderSource().

+ Here is the caller graph for this function:

◆ generateShader()

void ShaderSource::generateShader ( ShaderInfo & info)
private

Unique name of this shader, for debug/logging

References ShaderInfo::base_material, dumpShaderProgram(), errorstream, fmtgettext(), RenderingEngine::get_video_driver(), SourceShaderCache::getOrLoad(), infostream, ShaderInfo::input_constants, m_constant_setters, m_fully_programmable, m_have_glsl3, m_sourcecache, m_uniform_factories, ShaderInfo::material, ShaderInfo::name, putConstant(), ShaderInfo::setter_cb, trim(), and warningstream.

Referenced by getShaderIdDirect(), and rebuildShaders().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getShader()

u32 ShaderSource::getShader ( const std::string & name,
const ShaderConstants & input_const,
video::E_MATERIAL_TYPE base_mat,
IShaderUniformSetterRC * setter_cb = nullptr )
overridevirtual

Generates or gets a shader.

Note that the input constants are not for passing the entire world into the shader. Use IShaderConstantSetter to handle user settings.

Parameters
namename of the shader (directory on disk)
input_constprimary key constants for this shader
base_matbase material to use
setter_cbadditional uniform setter to use
Returns
shader ID
Note
base_material only controls alpha behavior

Implements IShaderSource.

References errorstream, getShaderIdDirect(), infostream, GetResult< Key, T, Caller, CallerData >::item, GetResult< Key, T, Caller, CallerData >::key, m_main_thread, and MutexedQueue< T >::pop_frontNoEx().

+ Here is the call graph for this function:

◆ getShaderIdDirect()

u32 ShaderSource::getShaderIdDirect ( const std::string & name,
const ShaderConstants & input_const,
video::E_MATERIAL_TYPE base_mat,
IShaderUniformSetterRC * setter_cb )

References ShaderInfo::base_material, generateShader(), infostream, ShaderInfo::input_constants, m_main_thread, m_shaderinfo_cache, m_shaderinfo_cache_mutex, ShaderInfo::name, sanity_check, and ShaderInfo::setter_cb.

Referenced by getShader().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getShaderInfo()

const ShaderInfo & ShaderSource::getShaderInfo ( u32 id)
overridevirtual

returns information about an existing shader

Use this to get the material ID to plug into video::SMaterial.

Implements IShaderSource.

References m_shaderinfo_cache, and m_shaderinfo_cache_mutex.

◆ insertSourceShader()

void ShaderSource::insertSourceShader ( const std::string & name_of_shader,
const std::string & filename,
const std::string & program )
overridevirtual

Implements IWritableShaderSource.

References SourceShaderCache::insert(), m_main_thread, m_sourcecache, and sanity_check.

+ Here is the call graph for this function:

◆ processQueue()

void ShaderSource::processQueue ( )
overridevirtual

Implements IWritableShaderSource.

◆ putConstant()

void ShaderSource::putConstant ( std::ostream & os,
const ShaderConstants::mapped_type & it )
inlineprivate

outputs a constant to an ostream

Referenced by generateShader().

+ Here is the caller graph for this function:

◆ rebuildShaders()

void ShaderSource::rebuildShaders ( )
overridevirtual

Implements IWritableShaderSource.

References generateShader(), RenderingEngine::get_video_driver(), infostream, m_shaderinfo_cache, and m_shaderinfo_cache_mutex.

+ Here is the call graph for this function:

◆ supportsSampler2DArray()

bool ShaderSource::supportsSampler2DArray ( ) const
inlineoverridevirtual

Returns true if 'sampler2DArray' is supported in GLSL.

Implements IShaderSource.

References RenderingEngine::get_video_driver(), m_fully_programmable, and m_have_glsl3.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_constant_setters

std::vector<std::unique_ptr<IShaderConstantSetter> > ShaderSource::m_constant_setters
private

◆ m_fully_programmable

bool ShaderSource::m_fully_programmable = false
private

◆ m_have_glsl3

bool ShaderSource::m_have_glsl3 = false
private

◆ m_main_thread

std::thread::id ShaderSource::m_main_thread
private

◆ m_shaderinfo_cache

std::vector<ShaderInfo> ShaderSource::m_shaderinfo_cache
private

◆ m_shaderinfo_cache_mutex

std::mutex ShaderSource::m_shaderinfo_cache_mutex
private

◆ m_sourcecache

SourceShaderCache ShaderSource::m_sourcecache
private

◆ m_uniform_factories

std::vector<std::unique_ptr<IShaderUniformSetterFactory> > ShaderSource::m_uniform_factories
private

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