1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-25 22:09:35 +00:00

Add bgMode config setting.

This commit is contained in:
Sergey Lipskiy 2019-01-26 15:08:55 +07:00
parent be069adb1f
commit f79f8d406a
9 changed files with 153 additions and 42 deletions

View File

@ -35,8 +35,6 @@ void Config::resetToDefaults()
generalEmulation.enableHWLighting = 0;
generalEmulation.enableCustomSettings = 1;
generalEmulation.enableShadersStorage = 1;
generalEmulation.correctTexrectCoords = tcDisable;
generalEmulation.enableNativeResTexrects = 0;
generalEmulation.enableLegacyBlending = 0;
generalEmulation.hacks = 0;
#if defined(OS_ANDROID) || defined(OS_IOS)
@ -49,6 +47,10 @@ void Config::resetToDefaults()
generalEmulation.enableFragmentDepthWrite = 1;
#endif
graphics2D.correctTexrectCoords = tcDisable;
graphics2D.enableNativeResTexrects = 0;
graphics2D.bgMode = BGMode::bgStripped;
frameBufferEmulation.enable = 1;
frameBufferEmulation.copyDepthToRDRAM = cdSoftwareRender;
frameBufferEmulation.copyFromRDRAM = 0;
@ -130,10 +132,10 @@ void Config::validate()
if (frameBufferEmulation.enable != 0 && frameBufferEmulation.N64DepthCompare != 0)
video.multisampling = 0;
if (frameBufferEmulation.nativeResFactor == 1) {
generalEmulation.enableNativeResTexrects = 0;
generalEmulation.correctTexrectCoords = tcDisable;
graphics2D.enableNativeResTexrects = 0;
graphics2D.correctTexrectCoords = tcDisable;
} else {
if (generalEmulation.enableNativeResTexrects != 0)
generalEmulation.correctTexrectCoords = tcDisable;
if (graphics2D.enableNativeResTexrects != 0)
graphics2D.correctTexrectCoords = tcDisable;
}
}

View File

@ -5,7 +5,7 @@
#include "Types.h"
#define CONFIG_WITH_PROFILES 23U
#define CONFIG_VERSION_CURRENT 24U
#define CONFIG_VERSION_CURRENT 25U
#define BILINEAR_3POINT 0
#define BILINEAR_STANDARD 1
@ -48,8 +48,6 @@ struct Config
u32 enableHWLighting;
u32 enableCustomSettings;
u32 enableShadersStorage;
u32 correctTexrectCoords;
u32 enableNativeResTexrects;
u32 enableLegacyBlending;
u32 enableFragmentDepthWrite;
u32 enableBlitScreenWorkaround;
@ -61,6 +59,17 @@ struct Config
#endif
} generalEmulation;
enum BGMode {
bgOnePiece = 0,
bgStripped = 1
};
struct {
u32 correctTexrectCoords;
u32 enableNativeResTexrects;
u32 bgMode;
} graphics2D;
enum Aspect {
aStretch = 0,
a43 = 1,

View File

@ -142,7 +142,9 @@ void ConfigDialog::_init()
ui->enableHWLightingCheckBox->setChecked(config.generalEmulation.enableHWLighting != 0);
ui->enableShadersStorageCheckBox->setChecked(config.generalEmulation.enableShadersStorage != 0);
ui->customSettingsCheckBox->setChecked(config.generalEmulation.enableCustomSettings != 0);
switch (config.generalEmulation.correctTexrectCoords) {
// 2D graphics settings
switch (config.graphics2D.correctTexrectCoords) {
case Config::tcDisable:
ui->fixTexrectDisableRadioButton->setChecked(true);
break;
@ -153,8 +155,16 @@ void ConfigDialog::_init()
ui->fixTexrectForceRadioButton->setChecked(true);
break;
}
switch (config.graphics2D.bgMode) {
case Config::BGMode::bgOnePiece:
ui->bgModeOnePieceRadioButton->setChecked(true);
break;
case Config::BGMode::bgStripped:
ui->bgModeStrippedRadioButton->setChecked(true);
break;
}
ui->nativeRes2D_checkBox->toggle();
ui->nativeRes2D_checkBox->setChecked(config.generalEmulation.enableNativeResTexrects != 0);
ui->nativeRes2D_checkBox->setChecked(config.graphics2D.enableNativeResTexrects != 0);
ui->gammaCorrectionCheckBox->toggle();
ui->gammaCorrectionCheckBox->setChecked(config.gammaCorrection.force != 0);
@ -424,13 +434,18 @@ void ConfigDialog::accept()
config.gammaCorrection.level = ui->gammaLevelSpinBox->value();
if (ui->fixTexrectDisableRadioButton->isChecked())
config.generalEmulation.correctTexrectCoords = Config::tcDisable;
config.graphics2D.correctTexrectCoords = Config::tcDisable;
else if (ui->fixTexrectSmartRadioButton->isChecked())
config.generalEmulation.correctTexrectCoords = Config::tcSmart;
config.graphics2D.correctTexrectCoords = Config::tcSmart;
else if (ui->fixTexrectForceRadioButton->isChecked())
config.generalEmulation.correctTexrectCoords = Config::tcForce;
config.graphics2D.correctTexrectCoords = Config::tcForce;
config.generalEmulation.enableNativeResTexrects = ui->nativeRes2D_checkBox->isChecked() ? 1 : 0;
if (ui->bgModeOnePieceRadioButton->isChecked())
config.graphics2D.bgMode = Config::BGMode::bgOnePiece;
else if (ui->bgModeStrippedRadioButton->isChecked())
config.graphics2D.bgMode = Config::BGMode::bgStripped;
config.graphics2D.enableNativeResTexrects = ui->nativeRes2D_checkBox->isChecked() ? 1 : 0;
config.frameBufferEmulation.enable = ui->frameBufferCheckBox->isChecked() ? 1 : 0;

View File

@ -43,8 +43,12 @@ void _loadSettings(QSettings & settings)
config.generalEmulation.enableHWLighting = settings.value("enableHWLighting", config.generalEmulation.enableHWLighting).toInt();
config.generalEmulation.enableShadersStorage = settings.value("enableShadersStorage", config.generalEmulation.enableShadersStorage).toInt();
config.generalEmulation.enableCustomSettings = settings.value("enableCustomSettings", config.generalEmulation.enableCustomSettings).toInt();
config.generalEmulation.correctTexrectCoords = settings.value("correctTexrectCoords", config.generalEmulation.correctTexrectCoords).toInt();
config.generalEmulation.enableNativeResTexrects = settings.value("enableNativeResTexrects", config.generalEmulation.enableNativeResTexrects).toInt();
settings.endGroup();
settings.beginGroup("graphics2D");
config.graphics2D.correctTexrectCoords = settings.value("correctTexrectCoords", config.graphics2D.correctTexrectCoords).toInt();
config.graphics2D.enableNativeResTexrects = settings.value("enableNativeResTexrects", config.graphics2D.enableNativeResTexrects).toInt();
config.graphics2D.bgMode = settings.value("bgMode", config.graphics2D.bgMode).toInt();
settings.endGroup();
settings.beginGroup("frameBufferEmulation");
@ -206,8 +210,12 @@ void writeSettings(const QString & _strIniFolder)
settings.setValue("enableHWLighting", config.generalEmulation.enableHWLighting);
settings.setValue("enableShadersStorage", config.generalEmulation.enableShadersStorage);
settings.setValue("enableCustomSettings", config.generalEmulation.enableCustomSettings);
settings.setValue("correctTexrectCoords", config.generalEmulation.correctTexrectCoords);
settings.setValue("enableNativeResTexrects", config.generalEmulation.enableNativeResTexrects);
settings.endGroup();
settings.beginGroup("graphics2D");
settings.setValue("correctTexrectCoords", config.graphics2D.correctTexrectCoords);
settings.setValue("enableNativeResTexrects", config.graphics2D.enableNativeResTexrects);
settings.setValue("bgMode", config.graphics2D.bgMode);
settings.endGroup();
settings.beginGroup("frameBufferEmulation");
@ -387,8 +395,12 @@ void saveCustomRomSettings(const QString & _strIniFolder, const char * _strRomNa
WriteCustomSetting(generalEmulation, enableLOD);
WriteCustomSetting(generalEmulation, enableHWLighting);
WriteCustomSetting(generalEmulation, enableShadersStorage);
WriteCustomSetting(generalEmulation, correctTexrectCoords);
WriteCustomSetting(generalEmulation, enableNativeResTexrects);
settings.endGroup();
settings.beginGroup("graphics2D");
WriteCustomSetting(graphics2D, correctTexrectCoords);
WriteCustomSetting(graphics2D, enableNativeResTexrects);
WriteCustomSetting(graphics2D, bgMode);
settings.endGroup();
settings.beginGroup("frameBufferEmulation");

View File

@ -1655,6 +1655,66 @@
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="BgModeFrame">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Background is complex macro command used to render large (normally full screen) images. Since background image usually does not fit texture memory, the microcode split it on narrow strips and render one by one. HLE code has two modes to emulate background commands:&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;One piece&lt;/span&gt;: Whole background image rendred as one textured rectangle. This method is normally much faster, but the result is not always correct.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Stripped&lt;/span&gt;: This method emulates background commands as close as possible to actual microcode implementation. It is slower but more precise. Another problem: some games may have gaps between rendered strips in high resolution. Use &amp;quot;Render 2D elements in N64 resolution&amp;quot; option to remove the gaps.&lt;/p&gt;&lt;p&gt;[Recommended: &lt;span style=&quot; font-style:italic;&quot;&gt;Game dependent, mostly Stripped&lt;/span&gt;]&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5_2">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="bgModeLabel">
<property name="text">
<string extracomment="Background commands usually used to draw full screen 2D images, but some games use them for all 2D objects.">Backgrounds rendering mode (HLE only):</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bgModeOnePieceRadioButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string extracomment="The label for this control is &quot;Backgrounds rendering mode &quot;">One piece</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bgModeButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bgModeStrippedRadioButton">
<property name="text">
<string extracomment="The label for this control is &quot;Backgrounds rendering mode &quot;">Stripped</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bgModeButtonGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
@ -4080,10 +4140,11 @@
</connection>
</connections>
<buttongroups>
<buttongroup name="fixTexrectCoordsButtonGroup"/>
<buttongroup name="factorButtonGroup"/>
<buttongroup name="osdButtonGroup"/>
<buttongroup name="aspectButtonGroup"/>
<buttongroup name="screenshotButtonGroup"/>
<buttongroup name="factorButtonGroup"/>
<buttongroup name="osdButtonGroup"/>
<buttongroup name="fixTexrectCoordsButtonGroup"/>
<buttongroup name="bgModeButtonGroup"/>
</buttongroups>
</ui>

View File

@ -1175,7 +1175,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
DisplayWindow & wnd = dwnd();
TextureCache & cache = textureCache();
const bool bUseBilinear = gDP.otherMode.textureFilter != 0;
const bool bUseTexrectDrawer = m_bBGMode || ((config.generalEmulation.enableNativeResTexrects != 0)
const bool bUseTexrectDrawer = m_bBGMode || ((config.graphics2D.enableNativeResTexrects != 0)
&& bUseBilinear
&& pCurrentCombiner->usesTexture()
&& (pCurrentBuffer == nullptr || !pCurrentBuffer->m_cfb)
@ -1390,7 +1390,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
void GraphicsDrawer::correctTexturedRectParams(TexturedRectParams & _params)
{
if (config.generalEmulation.correctTexrectCoords == Config::tcSmart) {
if (config.graphics2D.correctTexrectCoords == Config::tcSmart) {
if (_params.ulx == m_texrectParams.ulx && _params.lrx == m_texrectParams.lrx) {
if (fabsf(_params.uly - m_texrectParams.lry) < 0.51f)
_params.uly = m_texrectParams.lry;
@ -1404,7 +1404,7 @@ void GraphicsDrawer::correctTexturedRectParams(TexturedRectParams & _params)
_params.lrx = m_texrectParams.ulx;
}
}
else if (config.generalEmulation.correctTexrectCoords == Config::tcForce) {
else if (config.graphics2D.correctTexrectCoords == Config::tcForce) {
_params.lrx += 0.25f;
_params.lry += 0.25f;
}

View File

@ -854,7 +854,7 @@ void gDPTextureRectangle(f32 ulx, f32 uly, f32 lrx, f32 lry, s32 tile, s16 s, s1
GraphicsDrawer & drawer = dwnd().getDrawer();
GraphicsDrawer::TexturedRectParams params(ulx, uly, lrx, lry, dsdx, dtdy, s, t,
flip, false, true, frameBufferList().getCurrent());
if (config.generalEmulation.enableNativeResTexrects == 0 && config.generalEmulation.correctTexrectCoords != Config::tcDisable)
if (config.graphics2D.enableNativeResTexrects == 0 && config.graphics2D.correctTexrectCoords != Config::tcDisable)
drawer.correctTexturedRectParams(params);
drawer.drawTexturedRect(params);

View File

@ -70,10 +70,6 @@ bool Config_SetDefault()
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableShadersStorage", config.generalEmulation.enableShadersStorage, "Use persistent storage for compiled shaders.");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultInt(g_configVideoGliden64, "CorrectTexrectCoords", config.generalEmulation.correctTexrectCoords, "Make texrect coordinates continuous to avoid black lines between them. (0=Off, 1=Auto, 2=Force)");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableNativeResTexrects", config.generalEmulation.enableNativeResTexrects, "Render 2D texrects in native resolution to fix misalignment between parts of 2D image.");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableLegacyBlending", config.generalEmulation.enableLegacyBlending, "Do not use shaders to emulate N64 blending modes. Works faster on slow GPU. Can cause glitches.");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableFragmentDepthWrite", config.generalEmulation.enableFragmentDepthWrite, "Enable writing of fragment depth. Some mobile GPUs do not support it, thus it made optional. Leave enabled.");
@ -90,6 +86,14 @@ bool Config_SetDefault()
res = ConfigSetDefaultFloat(g_configVideoGliden64, "PolygonOffsetUnits", config.generalEmulation.polygonOffsetUnits, "Is multiplied by an implementation-specific value to create a constant depth offset");
assert(res == M64ERR_SUCCESS);
#endif
//#2D graphics Settings
res = ConfigSetDefaultInt(g_configVideoGliden64, "CorrectTexrectCoords", config.graphics2D.correctTexrectCoords, "Make texrect coordinates continuous to avoid black lines between them. (0=Off, 1=Auto, 2=Force)");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableNativeResTexrects", config.graphics2D.enableNativeResTexrects, "Render 2D texrects in native resolution to fix misalignment between parts of 2D image.");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultInt(g_configVideoGliden64, "BackgroundsMode", config.graphics2D.bgMode, "Render backgrounds mode (HLE only). (0=One piece (fast), 1=Stripped (precise))");
assert(res == M64ERR_SUCCESS);
//#Frame Buffer Settings:"
res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableFBEmulation", config.frameBufferEmulation.enable, "Enable frame and|or depth buffer emulation.");
assert(res == M64ERR_SUCCESS);
@ -257,15 +261,18 @@ void Config_LoadCustomConfig()
if (result == M64ERR_SUCCESS) config.generalEmulation.enableHWLighting = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "generalEmulation\\enableShadersStorage", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.generalEmulation.enableShadersStorage = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "generalEmulation\\correctTexrectCoords", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.generalEmulation.correctTexrectCoords = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "generalEmulation\\enableNativeResTexrects", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.generalEmulation.enableNativeResTexrects = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "generalEmulation\\enableLegacyBlending", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.generalEmulation.enableLegacyBlending = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "generalEmulation\\enableFragmentDepthWrite", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.generalEmulation.enableFragmentDepthWrite = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "graphics2D\\correctTexrectCoords", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.graphics2D.correctTexrectCoords = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "graphics2D\\enableNativeResTexrects", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.graphics2D.enableNativeResTexrects = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "graphics2D\\bgMode", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.graphics2D.bgMode = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "frameBufferEmulation\\enable", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.frameBufferEmulation.enable = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "frameBufferEmulation\\aspect", value, sizeof(value));
@ -365,8 +372,6 @@ void Config_LoadConfig()
config.generalEmulation.enableLOD = ConfigGetParamBool(g_configVideoGliden64, "EnableLOD");
config.generalEmulation.enableHWLighting = ConfigGetParamBool(g_configVideoGliden64, "EnableHWLighting");
config.generalEmulation.enableShadersStorage = ConfigGetParamBool(g_configVideoGliden64, "EnableShadersStorage");
config.generalEmulation.correctTexrectCoords = ConfigGetParamInt(g_configVideoGliden64, "CorrectTexrectCoords");
config.generalEmulation.enableNativeResTexrects = ConfigGetParamBool(g_configVideoGliden64, "EnableNativeResTexrects");
config.generalEmulation.enableLegacyBlending = ConfigGetParamBool(g_configVideoGliden64, "EnableLegacyBlending");
config.generalEmulation.enableFragmentDepthWrite = ConfigGetParamBool(g_configVideoGliden64, "EnableFragmentDepthWrite");
config.generalEmulation.enableCustomSettings = ConfigGetParamBool(g_configVideoGliden64, "EnableCustomSettings");
@ -376,6 +381,10 @@ void Config_LoadConfig()
config.generalEmulation.polygonOffsetFactor = ConfigGetParamFloat(g_configVideoGliden64, "PolygonOffsetFactor");
config.generalEmulation.polygonOffsetUnits = ConfigGetParamFloat(g_configVideoGliden64, "PolygonOffsetUnits");
#endif
//#2D graphics Settings
config.graphics2D.correctTexrectCoords = ConfigGetParamInt(g_configVideoGliden64, "CorrectTexrectCoords");
config.graphics2D.enableNativeResTexrects = ConfigGetParamBool(g_configVideoGliden64, "EnableNativeResTexrects");
config.graphics2D.bgMode = ConfigGetParamBool(g_configVideoGliden64, "BackgroundsMode");
//#Frame Buffer Settings:"
config.frameBufferEmulation.enable = ConfigGetParamBool(g_configVideoGliden64, "EnableFBEmulation");
config.frameBufferEmulation.copyAuxToRDRAM = ConfigGetParamBool(g_configVideoGliden64, "EnableCopyAuxiliaryToRDRAM");

View File

@ -928,6 +928,9 @@ void _loadBGImage(const uObjScaleBg * _pBgInfo, bool _loadScale)
static
bool _useOldBgCode(u32 address)
{
if (config.graphics2D.bgMode == Config::BGMode::bgOnePiece)
return true;
if ((config.generalEmulation.hacks & hack_RE2) != 0)
return true;
@ -1166,7 +1169,7 @@ void BG1CycNew(u32 _bgAddr)
runCommand((G_SETTILESIZE<<24), 0);
}
if (config.generalEmulation.enableNativeResTexrects != 0)
if (config.graphics2D.enableNativeResTexrects != 0)
dwnd().getDrawer().setBackgroundDrawingMode(true);
//Part two
@ -1351,7 +1354,7 @@ void BG1CycNew(u32 _bgAddr)
}
}
if (config.generalEmulation.enableNativeResTexrects != 0) {
if (config.graphics2D.enableNativeResTexrects != 0) {
GraphicsDrawer & drawer = dwnd().getDrawer();
drawer.flush();
drawer.setBackgroundDrawingMode(false);
@ -1434,7 +1437,7 @@ void BGCopyNew(u32 _bgAddr)
s16 AT = Ch;
s16 U = A1 - A2;
if (config.generalEmulation.enableNativeResTexrects != 0)
if (config.graphics2D.enableNativeResTexrects != 0)
dwnd().getDrawer().setBackgroundDrawingMode(true);
u32 V, X, Y, Z, AA, w0, w1;
@ -1533,7 +1536,7 @@ void BGCopyNew(u32 _bgAddr)
}
}
if (config.generalEmulation.enableNativeResTexrects != 0) {
if (config.graphics2D.enableNativeResTexrects != 0) {
GraphicsDrawer & drawer = dwnd().getDrawer();
drawer.flush();
drawer.setBackgroundDrawingMode(false);