Add MSAA support

This commit is contained in:
VoxelTek 2025-07-24 02:04:04 +10:00
parent f642707159
commit ef3b316fbd
5 changed files with 159 additions and 35 deletions

View File

@ -13,6 +13,7 @@
#include <QKeyEvent>
#include <QMessageBox>
#include <QProcess>
#include <cmath>
#include <SDL3/SDL.h>
#include <mxdirectx/legodxinfo.h>
#include <ui_maindialog.h>
@ -100,6 +101,9 @@ CMainDialog::CMainDialog(QWidget* pParent) : QDialog(pParent)
connect(m_ui->maxActorsSlider, &QSlider::valueChanged, this, &CMainDialog::MaxActorsChanged);
connect(m_ui->maxActorsSlider, &QSlider::sliderMoved, this, &CMainDialog::MaxActorsChanged);
connect(m_ui->msaaSlider, &QSlider::valueChanged, this, &CMainDialog::MSAAChanged);
connect(m_ui->msaaSlider, &QSlider::sliderMoved, this, &CMainDialog::MSAAChanged);
connect(m_ui->aspectRatioComboBox, &QComboBox::currentIndexChanged, this, &CMainDialog::AspectRatioChanged);
connect(m_ui->xResSpinBox, &QSpinBox::valueChanged, this, &CMainDialog::XResChanged);
connect(m_ui->yResSpinBox, &QSpinBox::valueChanged, this, &CMainDialog::YResChanged);
@ -312,9 +316,9 @@ void CMainDialog::UpdateInterface()
m_ui->transitionTypeComboBox->setCurrentIndex(currentConfigApp->m_transition_type);
m_ui->dataPath->setText(QString::fromStdString(currentConfigApp->m_cd_path));
m_ui->savePath->setText(QString::fromStdString(currentConfigApp->m_save_path));
m_ui->textureCheckBox->setChecked(currentConfigApp->m_texture_load);
m_ui->texturePath->setText(QString::fromStdString(currentConfigApp->m_texture_path));
m_ui->texturePath->setEnabled(currentConfigApp->m_texture_load);
m_ui->texturePathOpen->setEnabled(currentConfigApp->m_texture_load);
@ -322,6 +326,13 @@ void CMainDialog::UpdateInterface()
m_ui->xResSpinBox->setValue(currentConfigApp->m_x_res);
m_ui->yResSpinBox->setValue(currentConfigApp->m_y_res);
m_ui->framerateSpinBox->setValue(static_cast<int>(std::round(1000.0f / currentConfigApp->m_frame_delta)));
m_ui->maxLoDSlider->setValue((int) (currentConfigApp->m_max_lod * 10));
m_ui->LoDNum->setNum(currentConfigApp->m_max_lod);
m_ui->maxActorsSlider->setValue(currentConfigApp->m_max_actors);
m_ui->maxActorsNum->setNum(currentConfigApp->m_max_actors);
m_ui->msaaSlider->setValue(log2(currentConfigApp->m_msaa));
m_ui->msaaNum->setNum(currentConfigApp->m_msaa);
}
// FUNCTION: CONFIG 0x004045e0
@ -532,15 +543,22 @@ void CMainDialog::SavePathEdited()
void CMainDialog::MaxLoDChanged(int value)
{
currentConfigApp->m_max_lod = static_cast<float>(value) / 10.0f;
m_ui->LoDNum->setNum(value);
m_modified = true;
UpdateInterface();
}
void CMainDialog::MaxActorsChanged(int value)
{
currentConfigApp->m_max_actors = value;
m_ui->maxActorsNum->setNum(value);
m_modified = true;
UpdateInterface();
}
void CMainDialog::MSAAChanged(int value)
{
currentConfigApp->m_msaa = exp2(value);
m_modified = true;
UpdateInterface();
}
void CMainDialog::SelectTexturePathDialog()

View File

@ -60,6 +60,7 @@ private slots:
void SavePathEdited();
void MaxLoDChanged(int value);
void MaxActorsChanged(int value);
void MSAAChanged(int value);
void SelectTexturePathDialog();
void TexturePathEdited();
void XResChanged(int i);

View File

@ -84,6 +84,7 @@ bool CConfigApp::InitInstance()
m_3d_video_ram = FALSE;
m_joystick_index = -1;
m_display_bit_depth = 16;
m_msaa = 1;
m_haptic = TRUE;
m_touch_scheme = 2;
m_texture_load = TRUE;
@ -182,6 +183,7 @@ bool CConfigApp::ReadRegisterSettings()
m_joystick_index = iniparser_getint(dict, "isle:JoystickIndex", m_joystick_index);
m_max_lod = iniparser_getdouble(dict, "isle:Max LOD", m_max_lod);
m_max_actors = iniparser_getint(dict, "isle:Max Allowed Extras", m_max_actors);
m_msaa = iniparser_getint(dict, "isle:MSAA", m_msaa);
m_texture_load = iniparser_getboolean(dict, "extensions:texture loader", m_texture_load);
m_texture_path = iniparser_getstring(dict, "texture loader:texture path", m_texture_path.c_str());
m_aspect_ratio = iniparser_getint(dict, "isle:Aspect Ratio", m_aspect_ratio);
@ -267,6 +269,19 @@ bool CConfigApp::ValidateSettings()
m_full_screen = TRUE;
is_modified = TRUE;
}
if (!(m_msaa & (m_msaa - 1))) { //Check if MSAA is power of 2 (1, 2, 4, 8, etc)
m_msaa = exp2(round(log2(m_msaa))); //Closest power of 2
is_modified = TRUE;
}
if (m_msaa > 16) {
m_msaa = 16;
is_modified = TRUE;
}
else if (m_msaa < 1){
m_msaa = 1;
is_modified = TRUE;
}
return is_modified;
}
@ -344,6 +359,7 @@ void CConfigApp::WriteRegisterSettings() const
iniparser_set(dict, "isle:savepath", m_save_path.c_str());
SetIniInt(dict, "isle:Display Bit Depth", m_display_bit_depth);
SetIniInt(dict, "isle:MSAA", m_msaa);
SetIniBool(dict, "isle:Flip Surfaces", m_flip_surfaces);
SetIniBool(dict, "isle:Full Screen", m_full_screen);
SetIniBool(dict, "isle:Exclusive Full Screen", m_exclusive_full_screen);

View File

@ -70,6 +70,7 @@ class CConfigApp {
MxDriver* m_driver;
Direct3DDeviceInfo* m_device;
int m_display_bit_depth;
int m_msaa;
bool m_flip_surfaces;
bool m_full_screen;
bool m_exclusive_full_screen;

View File

@ -56,6 +56,9 @@
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="buddy">
<cstring>fullscreenRadioContainer_2</cstring>
</property>
</widget>
</item>
<item>
@ -353,12 +356,18 @@ A higher setting will cause higher quality textures to be drawn regardless of di
</property>
<property name="minimumSize">
<size>
<width>15</width>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>35</string>
<string>3.5</string>
</property>
</widget>
</item>
@ -533,10 +542,16 @@ The game will gradually increase the number of actors until this maximum is reac
</property>
<property name="minimumSize">
<size>
<width>15</width>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>20</string>
</property>
@ -602,8 +617,59 @@ The game will gradually increase the number of actors until this maximum is reac
<property name="title">
<string>General</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QWidget" name="fullscreenRadioContainer_2" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;Windowed:&lt;/span&gt; Runs in a window, the initial resolution of which is dictated by Windowed Resolution. &lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;Fullscreen:&lt;/span&gt; Runs in a borderless window that consumes the entire screen. &lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;Exclusive Fullscreen:&lt;/span&gt; Grants the app full control of the display for better performance and lower input lag. May cause slower alt-tabbing.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<layout class="QVBoxLayout" name="fullscreenRadioContainer">
<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="QRadioButton" name="windowedRadioButton">
<property name="text">
<string>Windowed</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="fullscreenRadioButton">
<property name="text">
<string>Fullscreen</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="exFullscreenRadioButton">
<property name="text">
<string>Exclusive Fullscreen</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSpinBox" name="framerateSpinBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Maximum framerate. Values above 100fps are untested.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -622,31 +688,6 @@ The game will gradually increase the number of actors until this maximum is reac
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="fullscreenRadioContainer">
<item>
<widget class="QRadioButton" name="windowedRadioButton">
<property name="text">
<string>Windowed</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="fullscreenRadioButton">
<property name="text">
<string>Fullscreen</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="exFullscreenRadioButton">
<property name="text">
<string>Exclusive Fullscreen</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -781,6 +822,53 @@ The game will gradually increase the number of actors until this maximum is reac
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="msaaBox">
<property name="title">
<string>MSAA</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QSlider" name="msaaSlider">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>4</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TickPosition::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="msaaNum">
<property name="minimumSize">
<size>
<width>16</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>1</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
@ -789,7 +877,7 @@ The game will gradually increase the number of actors until this maximum is reac
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>0</height>
</size>
</property>
</spacer>
@ -877,7 +965,7 @@ The game will gradually increase the number of actors until this maximum is reac
<string>Settings for Texture Loader extension.</string>
</property>
<property name="title">
<string>Texture Loader Extension</string>
<string>Texture Loader</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>