Skip to content

Commit bca2486

Browse files
authored
Merge branch 'supertuxkart:master' into multitouch_adjusts
2 parents 14e3658 + 33c4815 commit bca2486

File tree

16 files changed

+244
-96
lines changed

16 files changed

+244
-96
lines changed

data/gui/dialogs/custom_video_settings.stkgui

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@
103103
<spacer width="10" height="10"/>
104104
<label text="Ambient occlusion" I18N="Video settings"/>
105105
</div>
106+
107+
<spacer height="4" width="10" />
108+
109+
<div layout="horizontal-row" proportion="1" height="fit">
110+
<checkbox id="ssr"/>
111+
<spacer width="10" height="10"/>
112+
<label text="Screen space reflection" I18N="Video settings"/>
113+
</div>
106114
</div>
107115

108116
<spacer height="4" width="10" />

data/shaders/IBL.frag

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
uniform sampler2D ntex;
22
uniform sampler2D dtex;
3-
#if !defined(GL_ES)
43
uniform sampler2DShadow stex;
5-
#endif
64
uniform sampler2D albedo;
75
uniform sampler2D ssao;
86
uniform sampler2D ctex;
97

8+
uniform int ssr;
9+
1010
#ifdef GL_ES
1111
layout (location = 0) out vec4 Diff;
1212
layout (location = 1) out vec4 Spec;
@@ -20,8 +20,6 @@ out vec4 Spec;
2020
#stk_include "utils/getPosFromUVDepth.frag"
2121
#stk_include "utils/DiffuseIBL.frag"
2222
#stk_include "utils/SpecularIBL.frag"
23-
24-
#if !defined(GL_ES)
2523
#stk_include "utils/screen_space_reflection.frag"
2624

2725
vec3 gtaoMultiBounce(float visibility, vec3 albedo)
@@ -33,7 +31,7 @@ vec3 gtaoMultiBounce(float visibility, vec3 albedo)
3331

3432
return max(vec3(visibility), ((visibility * a + b) * visibility + c) * visibility);
3533
}
36-
#endif
34+
3735

3836
// Main ===================================================================
3937

@@ -53,10 +51,13 @@ void main(void)
5351
// Lagarde and de Rousiers 2014, "Moving Frostbite to PBR"
5452
float ao_spec = clamp(pow(max(dot(normal, eyedir), 0.) + ao, exp2(-16.0 * (1.0 - specval) - 1.0)) - 1.0 + ao, 0.0, 1.0);
5553

56-
#ifdef GL_ES
57-
Diff = vec4(0.25 * DiffuseIBL(normal) * ao, 1.);
58-
Spec = vec4(.25 * SpecularIBL(normal, eyedir, specval) * ao_spec, 1.);
59-
#else
54+
if (ssr == 0)
55+
{
56+
Diff = vec4(0.25 * DiffuseIBL(normal) * ao, 1.);
57+
Spec = vec4(.25 * SpecularIBL(normal, eyedir, specval) * ao_spec, 1.);
58+
return;
59+
}
60+
6061
vec3 surface_color = texture(ctex, uv).xyz;
6162
vec3 ao_multi = gtaoMultiBounce(ao, surface_color);
6263
vec3 ao_spec_multi = gtaoMultiBounce(ao_spec, surface_color);
@@ -104,6 +105,5 @@ void main(void)
104105

105106
Diff = vec4(0.25 * DiffuseIBL(normal) * ao_multi, 1.);
106107
Spec = vec4(outColor.rgb * ao_spec_multi, 1.0);
107-
#endif
108108

109109
}

lib/graphics_engine/include/ge_vulkan_driver.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ namespace GE
505505

506506
unsigned int m_current_frame;
507507
uint32_t m_image_index;
508+
unsigned int m_current_semaphore;
508509
video::SColor m_clear_color, m_rtt_clear_color;
509510
core::rect<s32> m_clip;
510511
core::matrix4 m_pre_rotation_matrix;

lib/graphics_engine/src/ge_vulkan_driver.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ GEVulkanDriver::GEVulkanDriver(const SIrrlichtCreationParameters& params,
527527

528528
m_current_frame = 0;
529529
m_image_index = 0;
530+
m_current_semaphore = 0;
530531
m_clear_color = video::SColor(0);
531532
m_rtt_clear_color = m_clear_color;
532533
m_white_texture = NULL;
@@ -1387,8 +1388,10 @@ void GEVulkanDriver::createSyncObjects()
13871388
fence_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
13881389
fence_info.flags = VK_FENCE_CREATE_SIGNALED_BIT;
13891390

1390-
for (unsigned int i = 0; i < getMaxFrameInFlight(); i++)
1391+
for (unsigned int i = 0; i < m_vk->swap_chain_images.size(); i++)
13911392
{
1393+
// Semaphores are per swapchain image
1394+
// See https://github.com/SaschaWillems/Vulkan/commit/64ba09900257ef0971c8ac0013a5f6448f51a45b
13921395
VkSemaphore image_available_semaphore;
13931396
VkResult result = vkCreateSemaphore(m_vk->device, &semaphore_info, NULL,
13941397
&image_available_semaphore);
@@ -1408,16 +1411,19 @@ void GEVulkanDriver::createSyncObjects()
14081411
throw std::runtime_error(
14091412
"vkCreateSemaphore on render_finished_semaphore failed");
14101413
}
1414+
m_vk->image_available_semaphores.push_back(image_available_semaphore);
1415+
m_vk->render_finished_semaphores.push_back(render_finished_semaphore);
1416+
}
14111417

1418+
for (unsigned int i = 0; i < getMaxFrameInFlight(); i++)
1419+
{
14121420
VkFence in_flight_fence;
1413-
result = vkCreateFence(m_vk->device, &fence_info, NULL,
1421+
VkResult result = vkCreateFence(m_vk->device, &fence_info, NULL,
14141422
&in_flight_fence);
14151423

14161424
if (result != VK_SUCCESS)
14171425
throw std::runtime_error("vkCreateFence failed");
14181426

1419-
m_vk->image_available_semaphores.push_back(image_available_semaphore);
1420-
m_vk->render_finished_semaphores.push_back(render_finished_semaphore);
14211427
m_vk->in_flight_fences.push_back(in_flight_fence);
14221428
}
14231429
} // createSyncObjects
@@ -1798,7 +1804,7 @@ bool GEVulkanDriver::endScene()
17981804
vkResetFences(m_vk->device, 1, &fence);
17991805
vkResetCommandPool(m_vk->device, m_vk->command_pools[m_current_frame], 0);
18001806

1801-
VkSemaphore semaphore = m_vk->image_available_semaphores[m_current_frame];
1807+
VkSemaphore semaphore = m_vk->image_available_semaphores[m_current_semaphore];
18021808
VkResult result = vkAcquireNextImageKHR(m_vk->device, m_vk->swap_chain,
18031809
std::numeric_limits<uint64_t>::max(), semaphore, VK_NULL_HANDLE,
18041810
&m_image_index);
@@ -1813,9 +1819,9 @@ bool GEVulkanDriver::endScene()
18131819

18141820
buildCommandBuffers();
18151821

1816-
VkSemaphore wait_semaphores[] = {m_vk->image_available_semaphores[m_current_frame]};
1822+
VkSemaphore wait_semaphores[] = {m_vk->image_available_semaphores[m_current_semaphore]};
18171823
VkPipelineStageFlags wait_stages[] = {VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT};
1818-
VkSemaphore signal_semaphores[] = {m_vk->render_finished_semaphores[m_current_frame]};
1824+
VkSemaphore signal_semaphores[] = {m_vk->render_finished_semaphores[m_current_semaphore]};
18191825

18201826
VkSubmitInfo submit_info = {};
18211827
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
@@ -1838,7 +1844,7 @@ bool GEVulkanDriver::endScene()
18381844

18391845
VkSemaphore semaphores[] =
18401846
{
1841-
m_vk->render_finished_semaphores[m_current_frame]
1847+
m_vk->render_finished_semaphores[m_current_semaphore]
18421848
};
18431849
VkSwapchainKHR swap_chains[] =
18441850
{
@@ -1856,6 +1862,8 @@ bool GEVulkanDriver::endScene()
18561862
m_current_frame = (m_current_frame + 1) % getMaxFrameInFlight();
18571863
m_current_buffer_idx =
18581864
(m_current_buffer_idx + 1) % (getMaxFrameInFlight() + 1);
1865+
m_current_semaphore = (m_current_semaphore + 1) %
1866+
m_vk->swap_chain_images.size();
18591867

18601868
if (m_present_queue)
18611869
result = vkQueuePresentKHR(m_present_queue, &present_info);

src/config/user_config.hpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,13 @@ namespace UserConfigParams
679679
&m_video_group, "Enable high definition textures. Bit flag: "
680680
"bit 0 = enabled/disabled; bit 1 = set by user/set as default"));
681681
PARAM_PREFIX BoolUserConfigParam m_glow
682-
PARAM_DEFAULT(BoolUserConfigParam(true, "enable_glow",
682+
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_glow",
683683
&m_video_group, "Enable Glow"));
684684
PARAM_PREFIX BoolUserConfigParam m_bloom
685-
PARAM_DEFAULT(BoolUserConfigParam(true, "enable_bloom",
685+
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_bloom",
686686
&m_video_group, "Enable Bloom"));
687687
PARAM_PREFIX BoolUserConfigParam m_light_shaft
688-
PARAM_DEFAULT(BoolUserConfigParam(true, "enable_light_shaft",
688+
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_light_shaft",
689689
&m_video_group, "Enable Light Shafts"));
690690
PARAM_PREFIX BoolUserConfigParam m_dynamic_lights
691691
PARAM_DEFAULT(BoolUserConfigParam(true, "enable_dynamic_lights",
@@ -704,9 +704,11 @@ namespace UserConfigParams
704704
PARAM_DEFAULT(IntUserConfigParam(512, "max_texture_size",
705705
&m_video_group, "Max texture size when high definition textures are "
706706
"disabled"));
707-
707+
PARAM_PREFIX BoolUserConfigParam m_ssr
708+
PARAM_DEFAULT(BoolUserConfigParam(false, "ssr",
709+
&m_video_group, "Enable screen space reflection"));
708710
PARAM_PREFIX BoolUserConfigParam m_hq_mipmap
709-
PARAM_DEFAULT(BoolUserConfigParam(true, "hq_mipmap",
711+
PARAM_DEFAULT(BoolUserConfigParam(false, "hq_mipmap",
710712
&m_video_group, "Generate mipmap for textures using "
711713
"high quality method with SSE"));
712714
PARAM_PREFIX FloatUserConfigParam m_font_size
@@ -973,14 +975,13 @@ namespace UserConfigParams
973975
"Whether to display animated characters") );
974976

975977
PARAM_PREFIX IntUserConfigParam m_geometry_level
976-
PARAM_DEFAULT( IntUserConfigParam(3,
977-
"geometry_level", &m_graphics_quality,
978-
"Geometry quality ; determines level-of-detail distances and the maximum quality of models "
979-
"if the switching distance would be too close. For backwards compatibility 2 means lowest level,"
980-
"1 is then better than 2 and 0 than 1. Then levels 3 to 5 work normally with higher being better.") );
978+
PARAM_DEFAULT( IntUserConfigParam(2,
979+
"geometry-level", &m_graphics_quality,
980+
"Geometry quality 0=lowest level, no details; "
981+
"5=everything is displayed") );
981982

982983
PARAM_PREFIX IntUserConfigParam m_anisotropic
983-
PARAM_DEFAULT( IntUserConfigParam(16, "anisotropic",
984+
PARAM_DEFAULT( IntUserConfigParam(4, "anisotropic",
984985
&m_graphics_quality,
985986
"Quality of anisotropic filtering (usual values include 2-4-8-16; 0 to disable)") );
986987

@@ -993,27 +994,27 @@ namespace UserConfigParams
993994
"motionblur_enabled", &m_graphics_quality,
994995
"Whether motion blur should be enabled") );
995996
PARAM_PREFIX BoolUserConfigParam m_mlaa
996-
PARAM_DEFAULT( BoolUserConfigParam(true,
997+
PARAM_DEFAULT( BoolUserConfigParam(false,
997998
"mlaa", &m_graphics_quality,
998999
"Whether MLAA anti-aliasing should be enabled") );
9991000
PARAM_PREFIX BoolUserConfigParam m_ssao
10001001
PARAM_DEFAULT(BoolUserConfigParam(false,
10011002
"ssao", &m_graphics_quality,
10021003
"Enable Screen Space Ambient Occlusion") );
10031004
PARAM_PREFIX BoolUserConfigParam m_light_scatter
1004-
PARAM_DEFAULT(BoolUserConfigParam(true,
1005+
PARAM_DEFAULT(BoolUserConfigParam(false,
10051006
"light_scatter", &m_graphics_quality,
10061007
"Enable light scattering shaders") );
10071008
PARAM_PREFIX IntUserConfigParam m_shadows_resolution
1008-
PARAM_DEFAULT( IntUserConfigParam(512,
1009+
PARAM_DEFAULT( IntUserConfigParam(0,
10091010
"shadows_resolution", &m_graphics_quality,
10101011
"Shadow resolution (0 = disabled") );
10111012
PARAM_PREFIX BoolUserConfigParam m_pcss
10121013
PARAM_DEFAULT( BoolUserConfigParam(false,
10131014
"pcss", &m_graphics_quality,
10141015
"Enable Percentage Closer Soft Shadows") );
10151016
PARAM_PREFIX BoolUserConfigParam m_degraded_IBL
1016-
PARAM_DEFAULT(BoolUserConfigParam(false,
1017+
PARAM_DEFAULT(BoolUserConfigParam(true,
10171018
"Degraded_IBL", &m_graphics_quality,
10181019
"Disable specular IBL"));
10191020

src/graphics/irr_driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#include "scriptengine/property_animator.hpp"
7878
#include "states_screens/dialogs/confirm_resolution_dialog.hpp"
7979
#include "states_screens/dialogs/message_dialog.hpp"
80+
#include "states_screens/options/options_screen_video.hpp"
8081
#include "states_screens/state_manager.hpp"
8182
#include "tracks/track_manager.hpp"
8283
#include "tracks/track.hpp"
@@ -560,6 +561,7 @@ void IrrDriver::initDevice()
560561
if (UserConfigParams::m_swap_interval > 1)
561562
UserConfigParams::m_swap_interval = 1;
562563
564+
OptionsScreenVideo::setSSR();
563565
// Try 32 and, upon failure, 24 then 16 bit per pixels
564566
for (int bits=32; bits>15; bits -=8)
565567
{

src/graphics/lighting_passes.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include <ICameraSceneNode.h>
3636
#include <cmath>
37+
#include <ge_main.hpp>
3738

3839
class LightBaseClass
3940
{
@@ -187,14 +188,14 @@ class PointLightScatterShader : public TextureShader<PointLightScatterShader,
187188
};
188189

189190
// ============================================================================
190-
class IBLShader : public TextureShader<IBLShader, 7>
191+
class IBLShader : public TextureShader<IBLShader, 7, int>
191192
{
192193
public:
193194
IBLShader()
194195
{
195196
loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert",
196197
GL_FRAGMENT_SHADER, "IBL.frag");
197-
assignUniforms();
198+
assignUniforms("ssr");
198199
assignSamplerNames(0, "ntex", ST_NEAREST_FILTERED,
199200
1, "dtex", ST_NEAREST_FILTERED,
200201
2, "stex", ST_SHADOW_SAMPLER,
@@ -412,7 +413,8 @@ void LightingPasses::renderEnvMap(GLuint normal_depth_texture,
412413
albedo_buffer,
413414
ssao_texture,
414415
diffuse_color_texture);
415-
IBLShader::getInstance()->setUniforms();
416+
IBLShader::getInstance()->setUniforms(int(
417+
GE::getGEConfig()->m_screen_space_reflection_type != GE::GSSRT_DISABLED));
416418
}
417419

418420
glDrawArrays(GL_TRIANGLES, 0, 3);

src/graphics/lod_node.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ void LODNode::autoComputeLevel(float scale)
228228

229229
// Step 2a - Distance multiplier based on the user's input
230230
float aggressivity = 1.0;
231-
if( UserConfigParams::m_geometry_level == 2) aggressivity = 1.0; // 2 in the params is the lowest setting
231+
if( UserConfigParams::m_geometry_level == 0) aggressivity = 1.0;
232232
else if(UserConfigParams::m_geometry_level == 1) aggressivity = 1.42;
233-
else if(UserConfigParams::m_geometry_level == 0) aggressivity = 2.0;
233+
else if(UserConfigParams::m_geometry_level == 2) aggressivity = 2.0;
234234
else if(UserConfigParams::m_geometry_level == 3) aggressivity = 2.84;
235235
else if(UserConfigParams::m_geometry_level == 4) aggressivity = 4.0;
236236
else if(UserConfigParams::m_geometry_level == 5) aggressivity = 5.7;
@@ -239,9 +239,9 @@ void LODNode::autoComputeLevel(float scale)
239239

240240
// Step 2b - Determine the minimum distance for a model switch based on user input
241241
float temp_switch_dist = max_draw;
242-
if( UserConfigParams::m_geometry_level == 2) temp_switch_dist *= 0.75f; // 2 in the params is the lowest setting
242+
if( UserConfigParams::m_geometry_level == 0) temp_switch_dist *= 0.75f;
243243
else if(UserConfigParams::m_geometry_level == 1) temp_switch_dist *= 0.55f;
244-
else if(UserConfigParams::m_geometry_level == 0) temp_switch_dist *= 0.4f;
244+
else if(UserConfigParams::m_geometry_level == 2) temp_switch_dist *= 0.4f;
245245
else if(UserConfigParams::m_geometry_level == 3) temp_switch_dist *= 0.3f;
246246
else if(UserConfigParams::m_geometry_level == 4) temp_switch_dist *= 0.23f;
247247
else if(UserConfigParams::m_geometry_level == 5) temp_switch_dist *= 0.18f;

src/states_screens/dialogs/custom_video_settings.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,7 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
8383
geometry_level->addLabel(_("Very High"));
8484
//I18N: Geometry level ultra : everything is displayed, Level-of-Details distances are extremely high
8585
geometry_level->addLabel(_("Ultra"));
86-
// This strange code is needed because a lower geometry level value
87-
// used to be better. The values are now from best to worst: 5, 4, 3, 0, 1, 2.
88-
// This keeps compatibility with 1.X installs.
89-
// FIXME when profile-compatibility is not a concern.
90-
geometry_level->setValue(
91-
UserConfigParams::m_geometry_level == 2 ? 0 :
92-
UserConfigParams::m_geometry_level == 0 ? 2 : UserConfigParams::m_geometry_level);
86+
geometry_level->setValue(UserConfigParams::m_geometry_level);
9387

9488
SpinnerWidget* filtering = getWidget<SpinnerWidget>("image_quality");
9589
filtering->addLabel(_("Very Low"));
@@ -116,6 +110,7 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
116110
getWidget<CheckBoxWidget>("mlaa")->setState(UserConfigParams::m_mlaa);
117111
getWidget<CheckBoxWidget>("glow")->setState(UserConfigParams::m_glow);
118112
getWidget<CheckBoxWidget>("ssao")->setState(UserConfigParams::m_ssao);
113+
getWidget<CheckBoxWidget>("ssr")->setState(UserConfigParams::m_ssr);
119114
getWidget<CheckBoxWidget>("bloom")->setState(UserConfigParams::m_bloom);
120115
getWidget<CheckBoxWidget>("lightscattering")->setState(UserConfigParams::m_light_scatter);
121116
if (CVS->isEXTTextureCompressionS3TCUsable())
@@ -178,7 +173,8 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
178173

179174
UserConfigParams::m_ssao =
180175
advanced_pipeline && getWidget<CheckBoxWidget>("ssao")->getState();
181-
176+
UserConfigParams::m_ssr =
177+
advanced_pipeline && getWidget<CheckBoxWidget>("ssr")->getState();
182178
UserConfigParams::m_light_shaft =
183179
advanced_pipeline && getWidget<CheckBoxWidget>("lightshaft")->getState();
184180

@@ -211,21 +207,23 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
211207
UserConfigParams::m_animated_characters =
212208
getWidget<CheckBoxWidget>("animated_characters")->getState();
213209

214-
const int val =
215-
getWidget<SpinnerWidget>("geometry_detail")->getValue();
216-
// This strange code is needed because a lower geometry level value
217-
// used to be better. This keeps compatibility with 1.X installs.
218-
UserConfigParams::m_geometry_level = val == 2 ? 0 :
219-
val == 0 ? 2 : val;
210+
UserConfigParams::m_geometry_level =
211+
getWidget<SpinnerWidget>("geometry_detail")->getValue();;
220212
int quality = getWidget<SpinnerWidget>("image_quality")->getValue();
221213

222214
user_config->saveConfig();
223215

224216
ModalDialog::dismiss();
225217
OptionsScreenVideo::getInstance()->updateGfxSlider();
226218
OptionsScreenVideo::getInstance()->updateBlurSlider();
227-
if ((pbr_changed || ibl_changed) && GE::getDriver()->getDriverType() == video::EDT_VULKAN)
228-
GE::getVKDriver()->updateDriver(false/*scale_changed*/, pbr_changed, ibl_changed);
219+
GE::GEScreenSpaceReflectionType prev_gssrt = GE::getGEConfig()->m_screen_space_reflection_type;
220+
OptionsScreenVideo::setSSR();
221+
if (GE::getDriver()->getDriverType() == video::EDT_VULKAN)
222+
{
223+
bool need_recreate_swapchain = GE::getGEConfig()->m_screen_space_reflection_type != prev_gssrt;
224+
if (need_recreate_swapchain || pbr_changed || ibl_changed)
225+
GE::getVKDriver()->updateDriver(need_recreate_swapchain, pbr_changed, ibl_changed);
226+
}
229227
// sameRestart will have the same effect
230228
if (!(CVS->isGLSL() && pbr_changed))
231229
OptionsScreenVideo::setImageQuality(quality, force_reload_texture);
@@ -265,6 +263,7 @@ void CustomVideoSettingsDialog::updateActivation()
265263
getWidget<SpinnerWidget>("shadows")->setActive(light);
266264
getWidget<CheckBoxWidget>("mlaa")->setActive(light);
267265
getWidget<CheckBoxWidget>("ssao")->setActive(light);
266+
getWidget<CheckBoxWidget>("ssr")->setActive(light || (vk && real_light));
268267
getWidget<CheckBoxWidget>("lightshaft")->setActive(light);
269268
getWidget<CheckBoxWidget>("ibl")->setActive(light || (vk && real_light));
270269
getWidget<CheckBoxWidget>("glow")->setActive(light);

0 commit comments

Comments
 (0)