Remix all image quality options

This commit is contained in:
Benau 2017-03-16 01:04:53 +08:00
parent 1a0034bb9e
commit 02c8c87d5d
5 changed files with 128 additions and 95 deletions

View File

@ -147,16 +147,8 @@
<spacer width="10" height="10"/>
<label text="Texture compression" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="hd-textures"/>
<spacer width="10" height="10"/>
<label text="Use high definition textures" I18N="Video settings"/>
</div>
</div>
<spacer height="20" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">
@ -168,9 +160,9 @@
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">
<label text="Texture filtering" I18N="Video settings" width="40%"/>
<label text="Rendered image quality" I18N="Video settings" width="40%"/>
<spacer width="10" height="10"/>
<gauge id="filtering" min_value="0" max_value="5" width="50%" />
<gauge id="image_quality" min_value="0" max_value="3" width="50%" />
</div>
<spacer height="4" width="10" />

View File

@ -35,23 +35,24 @@ STKTexManager::STKTexManager() : m_pbo(0), m_thread_size(0),
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
if (CVS->supportsThreadedTextureLoading())
{
UserConfigParams::m_hq_mipmap = true;
pthread_mutex_init(&m_threaded_load_textures_mutex, NULL);
pthread_cond_init(&m_cond_request, NULL);
m_thread_size = HardwareStats::getNumProcessors();
m_thread_size = core::clamp(m_thread_size, 1, 8);
static const unsigned max_pbo_size = 128 * 1024 * 1024;
const unsigned each_capacity = max_pbo_size / m_thread_size;
m_thread_size = core::clamp(m_thread_size, 1,
UserConfigParams::m_hq_mipmap ? m_thread_size : 3);
const unsigned each_capacity = 16 * 1024 * 1024;
const unsigned pbo_size = each_capacity * m_thread_size;
Log::info("STKTexManager", "%d thread(s) for texture loading,"
" each capacity %d MB", m_thread_size,
each_capacity / 1024 / 1024);
" each capacity 16 MB.", m_thread_size);
if (UserConfigParams::m_hq_mipmap)
Log::info("STKTexManager", "High quality mipmap enabled.");
glGenBuffers(1, &m_pbo);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_pbo);
glBufferStorage(GL_PIXEL_UNPACK_BUFFER, max_pbo_size, NULL,
glBufferStorage(GL_PIXEL_UNPACK_BUFFER, pbo_size, NULL,
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT |
GL_MAP_COHERENT_BIT);
uint8_t* pbo_ptr = (uint8_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER,
0, max_pbo_size, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT |
0, pbo_size, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT |
GL_MAP_COHERENT_BIT);
size_t offset = 0;
for (int i = 0; i < m_thread_size; i++)
@ -63,7 +64,6 @@ STKTexManager::STKTexManager() : m_pbo(0), m_thread_size(0),
}
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
#endif
} // STKTexManager

View File

@ -61,8 +61,6 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
getWidget<CheckBoxWidget>("anim_gfx")->setState(UserConfigParams::m_graphical_effects);
getWidget<CheckBoxWidget>("weather_gfx")->setState(UserConfigParams::m_weather_effects);
getWidget<CheckBoxWidget>("dof")->setState(UserConfigParams::m_dof);
getWidget<CheckBoxWidget>("hd-textures")
->setState((UserConfigParams::m_high_definition_textures & 0x01)==0x01);
SpinnerWidget* kart_anim = getWidget<SpinnerWidget>("steering_animations");
kart_anim->addLabel(_("Disabled")); // 0
@ -79,33 +77,24 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
//I18N: Geometry level disabled : lowest level, no details
geometry_level->addLabel(_("Disabled"));
//I18N: Geometry level low : few details are displayed
geometry_level->addLabel(_("low"));
geometry_level->addLabel(_("Low"));
//I18N: Geometry level high : everything is displayed
geometry_level->addLabel(_("high"));
geometry_level->addLabel(_("High"));
geometry_level->setValue(
UserConfigParams::m_geometry_level == 2 ? 0 :
UserConfigParams::m_geometry_level == 0 ? 2 : 1);
SpinnerWidget* filtering = getWidget<SpinnerWidget>("filtering");
int value = 0;
if (UserConfigParams::m_anisotropic == 2) value = 2;
else if (UserConfigParams::m_anisotropic == 4) value = 3;
else if (UserConfigParams::m_anisotropic == 8) value = 4;
else if (UserConfigParams::m_anisotropic == 16) value = 5;
else if (UserConfigParams::m_trilinear) value = 1;
filtering->addLabel(_("Bilinear")); // 0
filtering->addLabel(_("Trilinear")); // 1
filtering->addLabel(_("Anisotropic x2")); // 2
filtering->addLabel(_("Anisotropic x4")); // 3
filtering->addLabel(_("Anisotropic x8")); // 4
filtering->addLabel(_("Anisotropic x16")); // 5
filtering->setValue(value);
SpinnerWidget* filtering = getWidget<SpinnerWidget>("image_quality");
filtering->addLabel(_("Very Low"));
filtering->addLabel(_("Low"));
filtering->addLabel(_("High"));
filtering->addLabel(_("Very High"));
filtering->setValue(OptionsScreenVideo::getImageQuality());
SpinnerWidget* shadows = getWidget<SpinnerWidget>("shadows");
shadows->addLabel(_("Disabled")); // 0
shadows->addLabel(_("low")); // 1
shadows->addLabel(_("high")); // 2
shadows->addLabel(_("Low")); // 1
shadows->addLabel(_("High")); // 2
if (CVS->supportsShadows())
shadows->setValue(UserConfigParams::m_shadows_resolution / 512);
else
@ -195,11 +184,6 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
UserConfigParams::m_weather_effects =
getWidget<CheckBoxWidget>("weather_gfx")->getState();
// Set bit 0 for enabled/disabled, and set bit 1 to indicate that this
// is now a user's choice and should not be overwritten by any default
UserConfigParams::m_high_definition_textures =
getWidget<CheckBoxWidget>("hd-textures")->getState() ? 0x03 : 0x02;
UserConfigParams::m_show_steering_animations =
getWidget<SpinnerWidget>("steering_animations")->getValue();
@ -207,33 +191,8 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
getWidget<SpinnerWidget>("geometry_detail")->getValue();
UserConfigParams::m_geometry_level = val == 2 ? 0 : val == 0 ? 2 : 1;
switch (getWidget<SpinnerWidget>("filtering")->getValue())
{
case 0:
UserConfigParams::m_anisotropic = 0;
UserConfigParams::m_trilinear = false;
break;
case 1:
UserConfigParams::m_anisotropic = 0;
UserConfigParams::m_trilinear = true;
break;
case 2:
UserConfigParams::m_anisotropic = 2;
UserConfigParams::m_trilinear = true;
break;
case 3:
UserConfigParams::m_anisotropic = 4;
UserConfigParams::m_trilinear = true;
break;
case 4:
UserConfigParams::m_anisotropic = 8;
UserConfigParams::m_trilinear = true;
break;
case 5:
UserConfigParams::m_anisotropic = 16;
UserConfigParams::m_trilinear = true;
break;
}
OptionsScreenVideo::setImageQuality(getWidget<SpinnerWidget>
("image_quality")->getValue());
user_config->saveConfig();

View File

@ -53,32 +53,32 @@ void OptionsScreenVideo::initPresets()
({
false /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */,
false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */, false /* weather */,
false /* animatedScenery */, 0 /* animatedCharacters */, 0 /* anisotropy */,
false /* depth of field */, false /* global illumination */, true /* degraded IBL */, 0 /* hd_textures */
false /* animatedScenery */, 0 /* animatedCharacters */, 0 /* image_quality */,
false /* depth of field */, false /* global illumination */, true /* degraded IBL */
});
m_presets.push_back
({
false /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */,
false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */, false /* weather */,
true /* animatedScenery */, 1 /* animatedCharacters */, 4 /* anisotropy */,
false /* depth of field */, false /* global illumination */, true /* degraded IBL */, 0 /* hd_textures */
true /* animatedScenery */, 1 /* animatedCharacters */, 1 /* image_quality */,
false /* depth of field */, false /* global illumination */, true /* degraded IBL */
});
m_presets.push_back
({
true /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */,
false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */, true /* weather */,
true /* animatedScenery */, 1 /* animatedCharacters */, 4 /* anisotropy */,
false /* depth of field */, false /* global illumination */, true /* degraded IBL */, 1 /* hd_textures */
true /* animatedScenery */, 1 /* animatedCharacters */, 2 /* image_quality */,
false /* depth of field */, false /* global illumination */, true /* degraded IBL */
});
m_presets.push_back
({
true /* light */, 0 /* shadow */, false /* bloom */, true /* motionblur */,
true /* lightshaft */, true /* glow */, true /* mlaa */, false /* ssao */, true /* weather */,
true /* animatedScenery */, 1 /* animatedCharacters */, 8 /* anisotropy */,
false /* depth of field */, false /* global illumination */, false /* degraded IBL */, 1 /* hd_textures */
true /* animatedScenery */, 1 /* animatedCharacters */, 2 /* image_quality */,
false /* depth of field */, false /* global illumination */, false /* degraded IBL */
});
m_presets.push_back
@ -91,8 +91,8 @@ void OptionsScreenVideo::initPresets()
#else
2 /* animatedCharacters */,
#endif
16 /* anisotropy */,
true /* depth of field */, false /* global illumination */, false /* degraded IBL */, 1 /* hd_textures */
3 /* image_quality */,
true /* depth of field */, false /* global illumination */, false /* degraded IBL */
});
m_presets.push_back
@ -105,8 +105,8 @@ void OptionsScreenVideo::initPresets()
#else
2 /* animatedCharacters */,
#endif
16 /* anisotropy */,
true /* depth of field */, true /* global illumination */, false /* degraded IBL */, 1 /* hd_textures */
3 /* image_quality */,
true /* depth of field */, true /* global illumination */, false /* degraded IBL */
});
} // initPresets
@ -139,6 +139,74 @@ struct Resolution
}
};
// ----------------------------------------------------------------------------
int OptionsScreenVideo::getImageQuality()
{
if (UserConfigParams::m_scale_rtts_factor == 0.8f &&
UserConfigParams::m_trilinear == false &&
UserConfigParams::m_anisotropic == 0 &&
(UserConfigParams::m_high_definition_textures & 0x01) == 0x00 &&
UserConfigParams::m_hq_mipmap == false)
return 0;
if (UserConfigParams::m_scale_rtts_factor == 1.0f &&
UserConfigParams::m_trilinear == true &&
UserConfigParams::m_anisotropic == 2 &&
(UserConfigParams::m_high_definition_textures & 0x01) == 0x00 &&
UserConfigParams::m_hq_mipmap == false)
return 1;
if (UserConfigParams::m_scale_rtts_factor == 1.0f &&
UserConfigParams::m_trilinear == true &&
UserConfigParams::m_anisotropic == 4 &&
(UserConfigParams::m_high_definition_textures & 0x01) == 0x01 &&
UserConfigParams::m_hq_mipmap == false)
return 2;
if (UserConfigParams::m_scale_rtts_factor == 1.0f &&
UserConfigParams::m_trilinear == true &&
UserConfigParams::m_anisotropic == 16 &&
(UserConfigParams::m_high_definition_textures & 0x01) == 0x01 &&
UserConfigParams::m_hq_mipmap == true)
return 3;
return 2;
} // getImageQuality
// ----------------------------------------------------------------------------
void OptionsScreenVideo::setImageQuality(int quality)
{
switch (quality)
{
case 0:
UserConfigParams::m_scale_rtts_factor = 0.8f;
UserConfigParams::m_trilinear = false;
UserConfigParams::m_anisotropic = 0;
UserConfigParams::m_high_definition_textures = 0x02;
UserConfigParams::m_hq_mipmap = false;
break;
case 1:
UserConfigParams::m_scale_rtts_factor = 1.0f;
UserConfigParams::m_trilinear = true;
UserConfigParams::m_anisotropic = 2;
UserConfigParams::m_high_definition_textures = 0x02;
UserConfigParams::m_hq_mipmap = false;
break;
case 2:
UserConfigParams::m_scale_rtts_factor = 1.0f;
UserConfigParams::m_trilinear = true;
UserConfigParams::m_anisotropic = 4;
UserConfigParams::m_high_definition_textures = 0x03;
UserConfigParams::m_hq_mipmap = false;
break;
case 3:
UserConfigParams::m_scale_rtts_factor = 1.0f;
UserConfigParams::m_trilinear = true;
UserConfigParams::m_anisotropic = 16;
UserConfigParams::m_high_definition_textures = 0x03;
UserConfigParams::m_hq_mipmap = true;
break;
default:
assert(false);
}
} // setImageQuality
// ----------------------------------------------------------------------------
OptionsScreenVideo::OptionsScreenVideo() : Screen("options_video.stkgui"),
@ -341,7 +409,7 @@ void OptionsScreenVideo::updateGfxSlider()
{
if (m_presets[l].animatedCharacters == UserConfigParams::m_show_steering_animations &&
m_presets[l].animatedScenery == UserConfigParams::m_graphical_effects &&
m_presets[l].anisotropy == UserConfigParams::m_anisotropic &&
m_presets[l].image_quality == getImageQuality() &&
m_presets[l].bloom == UserConfigParams::m_bloom &&
m_presets[l].glow == UserConfigParams::m_glow &&
m_presets[l].lights == UserConfigParams::m_dynamic_lights &&
@ -354,8 +422,7 @@ void OptionsScreenVideo::updateGfxSlider()
m_presets[l].weather == UserConfigParams::m_weather_effects &&
m_presets[l].dof == UserConfigParams::m_dof &&
m_presets[l].global_illumination == UserConfigParams::m_gi &&
m_presets[l].degraded_ibl == UserConfigParams::m_degraded_IBL &&
m_presets[l].hd_textures == (UserConfigParams::m_high_definition_textures & 0x01))
m_presets[l].degraded_ibl == UserConfigParams::m_degraded_IBL)
{
gfx->setValue(l + 1);
found = true;
@ -395,6 +462,19 @@ void OptionsScreenVideo::updateTooltip()
//I18N: if no kart animations are enabled
const core::stringw none = _LTR("None");
//I18N: in the graphical options tooltip;
// indicates the rendered image quality is very low
const core::stringw very_low = _LTR("Very Low");
//I18N: in the graphical options tooltip;
// indicates the rendered image quality is low
const core::stringw low = _LTR("Low");
//I18N: in the graphical options tooltip;
// indicates the rendered image quality is high
const core::stringw high = _LTR("High");
//I18N: in the graphical options tooltip;
// indicates the rendered image quality is very high
const core::stringw very_high = _LTR("Very High");
//I18N: in graphical options
// tooltip = tooltip + L"\n" + _("Pixel shaders: %s",
// UserConfigParams::m_pixel_shaders ? enabled : disabled);
@ -448,9 +528,11 @@ void OptionsScreenVideo::updateTooltip()
UserConfigParams::m_gi ? enabled : disabled);
//I18N: in graphical options
tooltip = tooltip + L"\n" + _("Use high definition textures: %s",
(UserConfigParams::m_high_definition_textures & 0x1) == 0 ? disabled : enabled);
int quality = getImageQuality();
tooltip = tooltip + L"\n" + _("Rendered image quality: %s",
quality == 0 ? very_low : quality == 1 ? low : quality == 2 ?
high : very_high);
gfx->setTooltip(tooltip);
} // updateTooltip
@ -518,7 +600,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
UserConfigParams::m_show_steering_animations = m_presets[level].animatedCharacters;
UserConfigParams::m_graphical_effects = m_presets[level].animatedScenery;
UserConfigParams::m_anisotropic = m_presets[level].anisotropy;
setImageQuality(m_presets[level].image_quality);
UserConfigParams::m_bloom = m_presets[level].bloom;
UserConfigParams::m_glow = m_presets[level].glow;
UserConfigParams::m_dynamic_lights = m_presets[level].lights;
@ -532,7 +614,6 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
UserConfigParams::m_dof = m_presets[level].dof;
UserConfigParams::m_gi = m_presets[level].global_illumination;
UserConfigParams::m_degraded_IBL = m_presets[level].degraded_ibl;
UserConfigParams::m_high_definition_textures = 0x02 | m_presets[level].hd_textures;
updateGfxSlider();
}

View File

@ -38,12 +38,11 @@ struct GFXPreset
bool weather;
bool animatedScenery;
int animatedCharacters;
int anisotropy;
int image_quality;
/** Depth of field */
bool dof;
bool global_illumination;
bool degraded_ibl;
int hd_textures;
};
/**
@ -81,6 +80,8 @@ public:
virtual void unloaded() OVERRIDE;
void updateGfxSlider();
static int getImageQuality();
static void setImageQuality(int quality);
};
#endif