Discourage disabling shaders (#15210)

This commit is contained in:
sfan5 2024-09-30 22:43:08 +02:00 committed by GitHub
parent c6fc694ea6
commit 53d949bd9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 14 deletions

@ -262,7 +262,7 @@ viewing_range (Viewing range) int 190 20 4000
# Higher values result in a less detailed image. # Higher values result in a less detailed image.
undersampling (Undersampling) int 1 1 8 undersampling (Undersampling) int 1 1 8
[**Graphics Effects] [**Graphical Effects]
# Allows liquids to be translucent. # Allows liquids to be translucent.
translucent_liquids (Translucent liquids) bool true translucent_liquids (Translucent liquids) bool true
@ -468,12 +468,6 @@ enable_raytraced_culling (Enable Raytraced Culling) bool true
[*Shaders] [*Shaders]
# Shaders allow advanced visual effects and may increase performance on some video
# cards.
#
# Requires: shaders_support
enable_shaders (Shaders) bool true
[**Waving Nodes] [**Waving Nodes]
# Set to true to enable waving leaves. # Set to true to enable waving leaves.
@ -1866,6 +1860,11 @@ ignore_world_load_errors (Ignore world errors) bool false
[**Graphics] [**Graphics]
# Shaders are a fundamental part of rendering and enable advanced visual effects.
#
# Requires: shaders_support
enable_shaders (Shaders) bool true
# Path to shader directory. If no path is defined, default location will be used. # Path to shader directory. If no path is defined, default location will be used.
# #
# Requires: shaders # Requires: shaders
@ -1889,6 +1888,7 @@ cloud_radius (Cloud radius) int 12 1 62
desynchronize_mapblock_texture_animation (Desynchronize block animation) bool false desynchronize_mapblock_texture_animation (Desynchronize block animation) bool false
# Enables caching of facedir rotated meshes. # Enables caching of facedir rotated meshes.
# This is only effective with shaders disabled.
enable_mesh_cache (Mesh cache) bool false enable_mesh_cache (Mesh cache) bool false
# Delay between mesh updates on the client in ms. Increasing this will slow # Delay between mesh updates on the client in ms. Increasing this will slow

@ -322,6 +322,9 @@ public:
private: private:
// Are shaders even enabled?
bool m_enabled;
// The id of the thread that is allowed to use irrlicht directly // The id of the thread that is allowed to use irrlicht directly
std::thread::id m_main_thread; std::thread::id m_main_thread;
@ -360,6 +363,12 @@ ShaderSource::ShaderSource()
// Add a dummy ShaderInfo as the first index, named "" // Add a dummy ShaderInfo as the first index, named ""
m_shaderinfo_cache.emplace_back(); m_shaderinfo_cache.emplace_back();
m_enabled = g_settings->getBool("enable_shaders");
if (!m_enabled) {
warningstream << "You are running " PROJECT_NAME_C " with shaders disabled, "
"this is not a recommended configuration." << std::endl;
}
// Add main global constant setter // Add main global constant setter
addShaderConstantSetterFactory(new MainShaderConstantSetterFactory()); addShaderConstantSetterFactory(new MainShaderConstantSetterFactory());
} }
@ -368,9 +377,11 @@ ShaderSource::~ShaderSource()
{ {
MutexAutoLock lock(m_shaderinfo_cache_mutex); MutexAutoLock lock(m_shaderinfo_cache_mutex);
if (!m_enabled)
return;
// Delete materials // Delete materials
video::IGPUProgrammingServices *gpu = RenderingEngine::get_video_driver()-> auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices();
getGPUProgrammingServices();
for (ShaderInfo &i : m_shaderinfo_cache) { for (ShaderInfo &i : m_shaderinfo_cache) {
if (!i.name.empty()) if (!i.name.empty())
gpu->deleteShaderMaterial(i.material); gpu->deleteShaderMaterial(i.material);
@ -499,9 +510,11 @@ void ShaderSource::rebuildShaders()
{ {
MutexAutoLock lock(m_shaderinfo_cache_mutex); MutexAutoLock lock(m_shaderinfo_cache_mutex);
if (!m_enabled)
return;
// Delete materials // Delete materials
video::IGPUProgrammingServices *gpu = RenderingEngine::get_video_driver()-> auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices();
getGPUProgrammingServices();
for (ShaderInfo &i : m_shaderinfo_cache) { for (ShaderInfo &i : m_shaderinfo_cache) {
if (!i.name.empty()) { if (!i.name.empty()) {
gpu->deleteShaderMaterial(i.material); gpu->deleteShaderMaterial(i.material);
@ -548,12 +561,11 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
} }
shaderinfo.material = shaderinfo.base_material; shaderinfo.material = shaderinfo.base_material;
bool enable_shaders = g_settings->getBool("enable_shaders"); if (!m_enabled)
if (!enable_shaders)
return shaderinfo; return shaderinfo;
video::IVideoDriver *driver = RenderingEngine::get_video_driver(); video::IVideoDriver *driver = RenderingEngine::get_video_driver();
video::IGPUProgrammingServices *gpu = driver->getGPUProgrammingServices(); auto *gpu = driver->getGPUProgrammingServices();
if (!driver->queryFeature(video::EVDF_ARB_GLSL) || !gpu) { if (!driver->queryFeature(video::EVDF_ARB_GLSL) || !gpu) {
throw ShaderException(gettext("Shaders are enabled but GLSL is not " throw ShaderException(gettext("Shaders are enabled but GLSL is not "
"supported by the driver.")); "supported by the driver."));