mirror of
https://github.com/minetest/minetest.git
synced 2025-04-02 08:22:56 +02:00
Support deleting shader materials
This commit is contained in:
@ -264,6 +264,7 @@ class ShaderSource : public IWritableShaderSource
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShaderSource();
|
ShaderSource();
|
||||||
|
~ShaderSource() override;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- If shader material specified by name is found from cache,
|
- If shader material specified by name is found from cache,
|
||||||
@ -351,6 +352,22 @@ ShaderSource::ShaderSource()
|
|||||||
addShaderConstantSetterFactory(new MainShaderConstantSetterFactory());
|
addShaderConstantSetterFactory(new MainShaderConstantSetterFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShaderSource::~ShaderSource()
|
||||||
|
{
|
||||||
|
MutexAutoLock lock(m_shaderinfo_cache_mutex);
|
||||||
|
|
||||||
|
#if IRRLICHT_VERSION_MT_REVISION >= 15
|
||||||
|
// Delete materials
|
||||||
|
video::IGPUProgrammingServices *gpu = RenderingEngine::get_video_driver()->
|
||||||
|
getGPUProgrammingServices();
|
||||||
|
for (ShaderInfo &i : m_shaderinfo_cache) {
|
||||||
|
if (!i.name.empty())
|
||||||
|
gpu->deleteShaderMaterial(i.material);
|
||||||
|
}
|
||||||
|
m_shaderinfo_cache.clear();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
u32 ShaderSource::getShader(const std::string &name,
|
u32 ShaderSource::getShader(const std::string &name,
|
||||||
MaterialType material_type, NodeDrawType drawtype)
|
MaterialType material_type, NodeDrawType drawtype)
|
||||||
{
|
{
|
||||||
@ -472,15 +489,17 @@ void ShaderSource::rebuildShaders()
|
|||||||
{
|
{
|
||||||
MutexAutoLock lock(m_shaderinfo_cache_mutex);
|
MutexAutoLock lock(m_shaderinfo_cache_mutex);
|
||||||
|
|
||||||
/*// Oh well... just clear everything, they'll load sometime.
|
#if IRRLICHT_VERSION_MT_REVISION >= 15
|
||||||
m_shaderinfo_cache.clear();
|
// Delete materials
|
||||||
m_name_to_id.clear();*/
|
video::IGPUProgrammingServices *gpu = RenderingEngine::get_video_driver()->
|
||||||
|
getGPUProgrammingServices();
|
||||||
/*
|
for (ShaderInfo &i : m_shaderinfo_cache) {
|
||||||
FIXME: Old shader materials can't be deleted in Irrlicht,
|
if (!i.name.empty()) {
|
||||||
or can they?
|
gpu->deleteShaderMaterial(i.material);
|
||||||
(This would be nice to do in the destructor too)
|
i.material = video::EMT_SOLID; // invalidate
|
||||||
*/
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Recreate shaders
|
// Recreate shaders
|
||||||
for (ShaderInfo &i : m_shaderinfo_cache) {
|
for (ShaderInfo &i : m_shaderinfo_cache) {
|
||||||
|
Reference in New Issue
Block a user