diff --git a/lib/graphics_engine/include/ge_main.hpp b/lib/graphics_engine/include/ge_main.hpp index 7fa2a8ba5..656963c99 100644 --- a/lib/graphics_engine/include/ge_main.hpp +++ b/lib/graphics_engine/include/ge_main.hpp @@ -26,6 +26,7 @@ bool m_convert_irrlicht_mesh; bool m_texture_compression; bool m_fullscreen_desktop; bool m_enable_draw_call_cache; +bool m_pbr; std::unordered_set m_ondemand_load_texture_paths; float m_render_scale; }; diff --git a/lib/graphics_engine/include/ge_vulkan_driver.hpp b/lib/graphics_engine/include/ge_vulkan_driver.hpp index ac74f8208..ca618da1d 100644 --- a/lib/graphics_engine/include/ge_vulkan_driver.hpp +++ b/lib/graphics_engine/include/ge_vulkan_driver.hpp @@ -341,7 +341,7 @@ namespace GE destroySwapChainRelated(false/*handle_surface*/); createSwapChainRelated(false/*handle_surface*/); } - void updateRenderScale(float value); + void updateDriver(bool reload_shaders = false); uint32_t getGraphicsFamily() const { return m_graphics_family; } unsigned getGraphicsQueueCount() const { return m_graphics_queue_count; } diff --git a/lib/graphics_engine/src/ge_main.cpp b/lib/graphics_engine/src/ge_main.cpp index ea486dcd0..04b02d9b8 100644 --- a/lib/graphics_engine/src/ge_main.cpp +++ b/lib/graphics_engine/src/ge_main.cpp @@ -21,6 +21,7 @@ GEConfig g_config = false, true, false, + false, {}, 1.0f }; diff --git a/lib/graphics_engine/src/ge_vulkan_driver.cpp b/lib/graphics_engine/src/ge_vulkan_driver.cpp index 99222ebb9..6ae8f7202 100644 --- a/lib/graphics_engine/src/ge_vulkan_driver.cpp +++ b/lib/graphics_engine/src/ge_vulkan_driver.cpp @@ -2505,15 +2505,22 @@ bool GEVulkanDriver::setRenderTarget(video::ITexture* texture, } // setRenderTarget // ---------------------------------------------------------------------------- -void GEVulkanDriver::updateRenderScale(float value) +void GEVulkanDriver::updateDriver(bool reload_shaders) { - if (getGEConfig()->m_render_scale == value) - return; waitIdle(); setDisableWaitIdle(true); clearDrawCallsCache(); destroySwapChainRelated(false/*handle_surface*/); - getGEConfig()->m_render_scale = value; + if (reload_shaders) + { + GEVulkanShaderManager::destroy(); + GEVulkanShaderManager::init(this); + delete m_mesh_texture_descriptor; + m_mesh_texture_descriptor = new GEVulkanTextureDescriptor( + GEVulkanShaderManager::getSamplerSize(), + GEVulkanShaderManager::getMeshTextureLayer(), + GEVulkanFeatures::supportsBindMeshTexturesAtOnce()); + } createSwapChainRelated(false/*handle_surface*/); for (auto& dc : static_cast( m_irrlicht_device->getSceneManager())->getDrawCalls()) @@ -2522,7 +2529,7 @@ void GEVulkanDriver::updateRenderScale(float value) GEVulkan2dRenderer::destroy(); GEVulkan2dRenderer::init(this); setDisableWaitIdle(false); -} // updateRenderScale +} // updateDriver // ---------------------------------------------------------------------------- void GEVulkanDriver::clearDrawCallsCache() diff --git a/lib/graphics_engine/src/ge_vulkan_shader_manager.cpp b/lib/graphics_engine/src/ge_vulkan_shader_manager.cpp index f27d8640b..dfff09c0a 100644 --- a/lib/graphics_engine/src/ge_vulkan_shader_manager.cpp +++ b/lib/graphics_engine/src/ge_vulkan_shader_manager.cpp @@ -25,7 +25,6 @@ irr::io::IFileSystem* g_file_system = NULL; std::string g_predefines = ""; -// More when PBR is used later uint32_t g_mesh_texture_layer = 2; uint32_t g_sampler_size = 512; @@ -55,6 +54,13 @@ void GEVulkanShaderManager::init(GEVulkanDriver* vk) std::ostringstream oss; oss << "#version 450\n"; + if (getGEConfig()->m_pbr) + { + oss << "#define PBR_ENABLED 1\n"; + g_mesh_texture_layer = 8; + } + else + g_mesh_texture_layer = 2; oss << "#define SAMPLER_SIZE " << g_sampler_size << "\n"; oss << "#define TOTAL_MESH_TEXTURE_LAYER " << g_mesh_texture_layer << "\n"; if (GEVulkanFeatures::supportsBindTexturesAtOnce()) diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index cf95fb38e..71d1ac1da 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -512,6 +512,8 @@ begin: UserConfigParams::m_texture_compression; GE::getGEConfig()->m_render_scale = UserConfigParams::m_scale_rtts_factor; + GE::getGEConfig()->m_pbr = + UserConfigParams::m_dynamic_lights; #endif } else diff --git a/src/states_screens/dialogs/custom_video_settings.cpp b/src/states_screens/dialogs/custom_video_settings.cpp index 7bdfbed97..1b8add4c0 100644 --- a/src/states_screens/dialogs/custom_video_settings.cpp +++ b/src/states_screens/dialogs/custom_video_settings.cpp @@ -32,6 +32,7 @@ #include #ifndef SERVER_ONLY #include +#include #endif using namespace GUIEngine; @@ -128,6 +129,12 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s if (selection == "apply") { bool advanced_pipeline = getWidget("dynamiclight")->getState(); + bool update_needed = false; + if (UserConfigParams::m_dynamic_lights != advanced_pipeline) + { + update_needed = true; + GE::getGEConfig()->m_pbr = advanced_pipeline; + } UserConfigParams::m_dynamic_lights = advanced_pipeline; UserConfigParams::m_dof = @@ -182,15 +189,18 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s const int val = getWidget("geometry_detail")->getValue(); UserConfigParams::m_geometry_level = val == 2 ? 0 : val == 0 ? 2 : 1; - - OptionsScreenVideo::setImageQuality(getWidget - ("image_quality")->getValue()); + int quality = getWidget("image_quality")->getValue(); user_config->saveConfig(); ModalDialog::dismiss(); OptionsScreenVideo::getInstance()->updateGfxSlider(); OptionsScreenVideo::getInstance()->updateBlurSlider(); +#ifndef SERVER_ONLY + if (update_needed && GE::getDriver()->getDriverType() == video::EDT_VULKAN) + GE::getVKDriver()->updateDriver(true); +#endif + OptionsScreenVideo::setImageQuality(quality); return GUIEngine::EVENT_BLOCK; } else if (selection == "cancel") @@ -218,6 +228,8 @@ void CustomVideoSettingsDialog::updateActivation() getWidget("dynamiclight")->setActive(false); light = false; } + if (GE::getDriver()->getDriverType() == video::EDT_VULKAN) + getWidget("dynamiclight")->setActive(true); getWidget("motionblur")->setActive(light); getWidget("dof")->setActive(light); getWidget("shadows")->setActive(light); diff --git a/src/states_screens/options/options_screen_video.cpp b/src/states_screens/options/options_screen_video.cpp index 9248a7a2e..fddb47915 100644 --- a/src/states_screens/options/options_screen_video.cpp +++ b/src/states_screens/options/options_screen_video.cpp @@ -897,8 +897,12 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name, UserConfigParams::m_scale_rtts_factor = m_scale_rtts_custom_presets[level].value; #ifndef SERVER_ONLY - if (GE::getVKDriver()) - GE::getVKDriver()->updateRenderScale(UserConfigParams::m_scale_rtts_factor); + GE::GEVulkanDriver* gevk = GE::getVKDriver(); + if (gevk && GE::getGEConfig()->m_render_scale != UserConfigParams::m_scale_rtts_factor) + { + GE::getGEConfig()->m_render_scale = UserConfigParams::m_scale_rtts_factor; + gevk->updateDriver(); + } #endif updateScaleRTTsSlider(); }