Skip to content

Commit 53d949b

Browse files
authored
Discourage disabling shaders (luanti-org#15210)
1 parent c6fc694 commit 53d949b

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

builtin/settingtypes.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ viewing_range (Viewing range) int 190 20 4000
262262
# Higher values result in a less detailed image.
263263
undersampling (Undersampling) int 1 1 8
264264

265-
[**Graphics Effects]
265+
[**Graphical Effects]
266266

267267
# Allows liquids to be translucent.
268268
translucent_liquids (Translucent liquids) bool true
@@ -468,12 +468,6 @@ enable_raytraced_culling (Enable Raytraced Culling) bool true
468468

469469
[*Shaders]
470470

471-
# Shaders allow advanced visual effects and may increase performance on some video
472-
# cards.
473-
#
474-
# Requires: shaders_support
475-
enable_shaders (Shaders) bool true
476-
477471
[**Waving Nodes]
478472

479473
# Set to true to enable waving leaves.
@@ -1866,6 +1860,11 @@ ignore_world_load_errors (Ignore world errors) bool false
18661860

18671861
[**Graphics]
18681862

1863+
# Shaders are a fundamental part of rendering and enable advanced visual effects.
1864+
#
1865+
# Requires: shaders_support
1866+
enable_shaders (Shaders) bool true
1867+
18691868
# Path to shader directory. If no path is defined, default location will be used.
18701869
#
18711870
# Requires: shaders
@@ -1889,6 +1888,7 @@ cloud_radius (Cloud radius) int 12 1 62
18891888
desynchronize_mapblock_texture_animation (Desynchronize block animation) bool false
18901889

18911890
# Enables caching of facedir rotated meshes.
1891+
# This is only effective with shaders disabled.
18921892
enable_mesh_cache (Mesh cache) bool false
18931893

18941894
# Delay between mesh updates on the client in ms. Increasing this will slow

src/client/shader.cpp

+19-7
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ class ShaderSource : public IWritableShaderSource
322322

323323
private:
324324

325+
// Are shaders even enabled?
326+
bool m_enabled;
327+
325328
// The id of the thread that is allowed to use irrlicht directly
326329
std::thread::id m_main_thread;
327330

@@ -360,6 +363,12 @@ ShaderSource::ShaderSource()
360363
// Add a dummy ShaderInfo as the first index, named ""
361364
m_shaderinfo_cache.emplace_back();
362365

366+
m_enabled = g_settings->getBool("enable_shaders");
367+
if (!m_enabled) {
368+
warningstream << "You are running " PROJECT_NAME_C " with shaders disabled, "
369+
"this is not a recommended configuration." << std::endl;
370+
}
371+
363372
// Add main global constant setter
364373
addShaderConstantSetterFactory(new MainShaderConstantSetterFactory());
365374
}
@@ -368,9 +377,11 @@ ShaderSource::~ShaderSource()
368377
{
369378
MutexAutoLock lock(m_shaderinfo_cache_mutex);
370379

380+
if (!m_enabled)
381+
return;
382+
371383
// Delete materials
372-
video::IGPUProgrammingServices *gpu = RenderingEngine::get_video_driver()->
373-
getGPUProgrammingServices();
384+
auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices();
374385
for (ShaderInfo &i : m_shaderinfo_cache) {
375386
if (!i.name.empty())
376387
gpu->deleteShaderMaterial(i.material);
@@ -499,9 +510,11 @@ void ShaderSource::rebuildShaders()
499510
{
500511
MutexAutoLock lock(m_shaderinfo_cache_mutex);
501512

513+
if (!m_enabled)
514+
return;
515+
502516
// Delete materials
503-
video::IGPUProgrammingServices *gpu = RenderingEngine::get_video_driver()->
504-
getGPUProgrammingServices();
517+
auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices();
505518
for (ShaderInfo &i : m_shaderinfo_cache) {
506519
if (!i.name.empty()) {
507520
gpu->deleteShaderMaterial(i.material);
@@ -548,12 +561,11 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
548561
}
549562
shaderinfo.material = shaderinfo.base_material;
550563

551-
bool enable_shaders = g_settings->getBool("enable_shaders");
552-
if (!enable_shaders)
564+
if (!m_enabled)
553565
return shaderinfo;
554566

555567
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
556-
video::IGPUProgrammingServices *gpu = driver->getGPUProgrammingServices();
568+
auto *gpu = driver->getGPUProgrammingServices();
557569
if (!driver->queryFeature(video::EVDF_ARB_GLSL) || !gpu) {
558570
throw ShaderException(gettext("Shaders are enabled but GLSL is not "
559571
"supported by the driver."));

0 commit comments

Comments
 (0)