Add pbr texture handling for vulkan engine
This commit is contained in:
parent
c170c69749
commit
7817e14a5a
@ -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<std::string> m_ondemand_load_texture_paths;
|
||||
float m_render_scale;
|
||||
};
|
||||
|
@ -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; }
|
||||
|
@ -21,6 +21,7 @@ GEConfig g_config =
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
{},
|
||||
1.0f
|
||||
};
|
||||
|
@ -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<GEVulkanSceneManager*>(
|
||||
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()
|
||||
|
@ -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())
|
||||
|
@ -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
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <IGUIEnvironment.h>
|
||||
#ifndef SERVER_ONLY
|
||||
#include <ge_main.hpp>
|
||||
#include <ge_vulkan_driver.hpp>
|
||||
#endif
|
||||
|
||||
using namespace GUIEngine;
|
||||
@ -128,6 +129,12 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
|
||||
if (selection == "apply")
|
||||
{
|
||||
bool advanced_pipeline = getWidget<CheckBoxWidget>("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<SpinnerWidget>("geometry_detail")->getValue();
|
||||
UserConfigParams::m_geometry_level = val == 2 ? 0 : val == 0 ? 2 : 1;
|
||||
|
||||
OptionsScreenVideo::setImageQuality(getWidget<SpinnerWidget>
|
||||
("image_quality")->getValue());
|
||||
int quality = getWidget<SpinnerWidget>("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<CheckBoxWidget>("dynamiclight")->setActive(false);
|
||||
light = false;
|
||||
}
|
||||
if (GE::getDriver()->getDriverType() == video::EDT_VULKAN)
|
||||
getWidget<CheckBoxWidget>("dynamiclight")->setActive(true);
|
||||
getWidget<CheckBoxWidget>("motionblur")->setActive(light);
|
||||
getWidget<CheckBoxWidget>("dof")->setActive(light);
|
||||
getWidget<SpinnerWidget>("shadows")->setActive(light);
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user