mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Implement cross-platform max MSAA level detection
This commit is contained in:
parent
f04ac8296d
commit
ddec3866a7
|
@ -25,6 +25,7 @@ void Config::resetToDefaults()
|
|||
video.fullscreenRefresh = 60;
|
||||
video.fxaa = 0;
|
||||
video.multisampling = 0;
|
||||
video.maxMultiSampling = 0;
|
||||
video.verticalSync = 0;
|
||||
|
||||
#if defined(OS_MAC_OS_X)
|
||||
|
|
|
@ -26,7 +26,7 @@ struct Config
|
|||
u32 windowedWidth, windowedHeight;
|
||||
u32 fullscreenWidth, fullscreenHeight, fullscreenRefresh;
|
||||
u32 fxaa;
|
||||
u32 multisampling;
|
||||
u32 multisampling, maxMultiSampling;
|
||||
u32 verticalSync;
|
||||
u32 threadedVideo;
|
||||
} video;
|
||||
|
|
|
@ -19,6 +19,11 @@ bool DisplayWindow::start()
|
|||
m_drawer._initData();
|
||||
m_buffersSwapCount = 0;
|
||||
|
||||
// only query max MSAA when needed
|
||||
if (m_maxMsaa == 0) {
|
||||
m_maxMsaa = gfxContext.getMaxMSAALevel();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -193,5 +198,5 @@ void DisplayWindow::readScreen2(void * _dest, int * _width, int * _height, int _
|
|||
|
||||
u32 DisplayWindow::maxMSAALevel() const
|
||||
{
|
||||
return _maxMSAALevel();
|
||||
return m_maxMsaa;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ protected:
|
|||
u32 m_screenRefresh = 0;
|
||||
u32 m_resizeWidth = 0;
|
||||
u32 m_resizeHeight = 0;
|
||||
u32 m_maxMsaa = 0;
|
||||
f32 m_scaleX = 0;
|
||||
f32 m_scaleY = 0;
|
||||
f32 m_adjustScale = 0;
|
||||
|
@ -82,7 +83,6 @@ private:
|
|||
virtual void _readScreen(void **_pDest, long *_pWidth, long *_pHeight) = 0;
|
||||
virtual void _readScreen2(void * _dest, int * _width, int * _height, int _front) = 0;
|
||||
virtual graphics::ObjectHandle _getDefaultFramebuffer() = 0;
|
||||
virtual u32 _maxMSAALevel() const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ void _loadSettings(GlSettings & settings)
|
|||
config.video.windowedHeight = settings.value("windowedHeight", config.video.windowedHeight).toInt();
|
||||
config.video.fullscreenRefresh = settings.value("fullscreenRefresh", config.video.fullscreenRefresh).toInt();
|
||||
config.video.multisampling = settings.value("multisampling", config.video.multisampling).toInt();
|
||||
config.video.maxMultiSampling = settings.value("maxMultiSampling", config.video.maxMultiSampling).toInt();
|
||||
config.video.fxaa= settings.value("fxaa", config.video.fxaa).toInt();
|
||||
config.video.verticalSync = settings.value("verticalSync", config.video.verticalSync).toInt();
|
||||
config.video.threadedVideo = settings.value("threadedVideo", config.video.threadedVideo).toInt();
|
||||
|
@ -210,6 +211,7 @@ void writeSettings(const char * _strIniFolder)
|
|||
settings.setValue("windowedHeight", config.video.windowedHeight);
|
||||
settings.setValue("fullscreenRefresh", config.video.fullscreenRefresh);
|
||||
settings.setValue("multisampling", config.video.multisampling);
|
||||
settings.setValue("maxMultiSampling", config.video.maxMultiSampling);
|
||||
settings.setValue("fxaa", config.video.fxaa);
|
||||
settings.setValue("verticalSync", config.video.verticalSync);
|
||||
settings.setValue("threadedVideo", config.video.threadedVideo);
|
||||
|
|
|
@ -412,7 +412,18 @@ void CVideoTab::LoadSettings(bool /*blockCustomSettings*/) {
|
|||
if (fullscreenRate == i)
|
||||
RefreshRateComboBox.SetCurSel(index);
|
||||
}
|
||||
const u32 maxMSAALevel = m_Dlg.getMSAALevel();
|
||||
|
||||
u32 maxMSAALevel = m_Dlg.getMSAALevel();
|
||||
if (maxMSAALevel == 0 && config.video.maxMultiSampling == 0) {
|
||||
// default value
|
||||
maxMSAALevel = 8;
|
||||
} else if (maxMSAALevel == 0 && config.video.maxMultiSampling != 0) {
|
||||
// use cached value
|
||||
maxMSAALevel = config.video.maxMultiSampling;
|
||||
} else {
|
||||
// assign cached value
|
||||
config.video.maxMultiSampling = maxMSAALevel;
|
||||
}
|
||||
const unsigned int multisampling = config.video.fxaa == 0 && config.video.multisampling > 0
|
||||
? min(config.video.multisampling, maxMSAALevel)
|
||||
: maxMSAALevel;
|
||||
|
|
|
@ -168,9 +168,21 @@ void ConfigDialog::_init(bool reInit, bool blockCustomSettings)
|
|||
ui->fullScreenResolutionComboBox->setCurrentIndex(fullscreenMode);
|
||||
ui->fullScreenRefreshRateComboBox->setCurrentIndex(fullscreenRate);
|
||||
|
||||
if (m_maxMSAA == 0 && config.video.maxMultiSampling == 0) {
|
||||
// default value
|
||||
m_maxMSAA = 8;
|
||||
} else if (m_maxMSAA == 0 && config.video.maxMultiSampling != 0) {
|
||||
// use cached value
|
||||
m_maxMSAA = config.video.maxMultiSampling;
|
||||
} else {
|
||||
// assign cached value
|
||||
config.video.maxMultiSampling = m_maxMSAA;
|
||||
}
|
||||
|
||||
const unsigned int multisampling = config.video.fxaa == 0 && config.video.multisampling > 0
|
||||
? std::min(config.video.multisampling, m_maxMSAA)
|
||||
: m_maxMSAA;
|
||||
|
||||
ui->aliasingSlider->blockSignals(true);
|
||||
ui->aliasingSlider->setMaximum(powof(m_maxMSAA));
|
||||
ui->aliasingSlider->setValue(powof(multisampling));
|
||||
|
|
|
@ -27,6 +27,7 @@ void _loadSettings(QSettings & settings)
|
|||
config.video.windowedHeight = settings.value("windowedHeight", config.video.windowedHeight).toInt();
|
||||
config.video.fullscreenRefresh = settings.value("fullscreenRefresh", config.video.fullscreenRefresh).toInt();
|
||||
config.video.multisampling = settings.value("multisampling", config.video.multisampling).toInt();
|
||||
config.video.maxMultiSampling = settings.value("maxMultiSampling", config.video.maxMultiSampling).toInt();
|
||||
config.video.fxaa= settings.value("fxaa", config.video.fxaa).toInt();
|
||||
config.video.verticalSync = settings.value("verticalSync", config.video.verticalSync).toInt();
|
||||
config.video.threadedVideo = settings.value("threadedVideo", config.video.threadedVideo).toInt();
|
||||
|
@ -209,6 +210,7 @@ void writeSettings(const QString & _strIniFolder)
|
|||
settings.setValue("windowedHeight", config.video.windowedHeight);
|
||||
settings.setValue("fullscreenRefresh", config.video.fullscreenRefresh);
|
||||
settings.setValue("multisampling", config.video.multisampling);
|
||||
settings.setValue("maxMultiSampling", config.video.maxMultiSampling);
|
||||
settings.setValue("fxaa", config.video.fxaa);
|
||||
settings.setValue("verticalSync", config.video.verticalSync);
|
||||
settings.setValue("threadedVideo", config.video.threadedVideo);
|
||||
|
|
|
@ -349,6 +349,11 @@ f32 Context::getMaxLineWidth()
|
|||
return m_impl->getMaxLineWidth();
|
||||
}
|
||||
|
||||
s32 Context::getMaxMSAALevel()
|
||||
{
|
||||
return m_impl->getMaxMSAALevel();
|
||||
}
|
||||
|
||||
bool Context::isError() const
|
||||
{
|
||||
return m_impl->isError();
|
||||
|
|
|
@ -285,6 +285,7 @@ namespace graphics {
|
|||
f32 getMaxLineWidth();
|
||||
|
||||
/*---------------Misc-------------*/
|
||||
s32 getMaxMSAALevel();
|
||||
|
||||
bool isError() const;
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ namespace graphics {
|
|||
virtual void drawLine(f32 _width, SPVertex * _vertices) = 0;
|
||||
virtual f32 getMaxLineWidth() = 0;
|
||||
virtual bool isSupported(SpecialFeatures _feature) const = 0;
|
||||
virtual s32 getMaxMSAALevel() = 0;
|
||||
virtual bool isError() const = 0;
|
||||
virtual bool isFramebufferError() const = 0;
|
||||
};
|
||||
|
|
|
@ -5326,36 +5326,6 @@ private:
|
|||
std::function<void()> m_swapBuffersCallback;
|
||||
};
|
||||
|
||||
class WindowsMaxMSAALevelCommand : public OpenGlCommand
|
||||
{
|
||||
public:
|
||||
WindowsMaxMSAALevelCommand() :
|
||||
OpenGlCommand(true, false, "WindowsMaxMSAALevelCommand", false)
|
||||
{
|
||||
}
|
||||
|
||||
static std::shared_ptr<OpenGlCommand> get(u32& returnValue)
|
||||
{
|
||||
static int poolId = OpenGlCommandPool::get().getNextAvailablePool();
|
||||
auto ptr = getFromPool<WindowsMaxMSAALevelCommand>(poolId);
|
||||
ptr->set(returnValue);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void commandToExecute() override
|
||||
{
|
||||
*m_returnValue = WindowsWGL::maxMSAALevel();
|
||||
}
|
||||
|
||||
private:
|
||||
void set(u32& returnValue)
|
||||
{
|
||||
m_returnValue = &returnValue;
|
||||
}
|
||||
|
||||
u32* m_returnValue;
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
||||
#ifdef __clang__
|
||||
|
|
|
@ -1658,20 +1658,4 @@ namespace opengl {
|
|||
|
||||
return textureSize;
|
||||
}
|
||||
|
||||
u32 FunctionWrapper::maxMSAALevel()
|
||||
{
|
||||
#if defined(OS_WINDOWS) && !defined(MUPENPLUSAPI)
|
||||
u32 returnValue;
|
||||
|
||||
if (m_threaded_wrapper)
|
||||
executeCommand(WindowsMaxMSAALevelCommand::get(returnValue));
|
||||
else
|
||||
WindowsMaxMSAALevelCommand::get(returnValue)->performCommandSingleThreaded();
|
||||
|
||||
return returnValue;
|
||||
#else
|
||||
return 8;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,6 +221,5 @@ namespace opengl {
|
|||
static void WaitForSwapBuffersQueued();
|
||||
|
||||
static int getTextureBytes(GLenum format, GLenum type, int width, int height);
|
||||
static u32 maxMSAALevel();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ private:
|
|||
void _changeWindow() override;
|
||||
void _readScreen(void **_pDest, long *_pWidth, long *_pHeight) override {}
|
||||
void _readScreen2(void * _dest, int * _width, int * _height, int _front) override;
|
||||
u32 _maxMSAALevel() const override;
|
||||
#ifdef M64P_GLIDENUI
|
||||
bool _supportsWithRateFunctions = true;
|
||||
#endif // M64P_GLIDENUI
|
||||
|
@ -326,10 +325,3 @@ graphics::ObjectHandle DisplayWindowMupen64plus::_getDefaultFramebuffer()
|
|||
return graphics::ObjectHandle(CoreVideo_GL_GetDefaultFramebuffer());
|
||||
return graphics::ObjectHandle::null;
|
||||
}
|
||||
|
||||
u32 DisplayWindowMupen64plus::_maxMSAALevel() const
|
||||
{
|
||||
FunctionWrapper::setThreadedMode(config.video.threadedVideo);
|
||||
|
||||
return FunctionWrapper::maxMSAALevel();
|
||||
}
|
||||
|
|
|
@ -524,6 +524,13 @@ bool ContextImpl::isSupported(graphics::SpecialFeatures _feature) const
|
|||
return false;
|
||||
}
|
||||
|
||||
s32 ContextImpl::getMaxMSAALevel()
|
||||
{
|
||||
GLint maxMSAALevel = 0;
|
||||
glGetIntegerv(GL_MAX_SAMPLES, &maxMSAALevel);
|
||||
return maxMSAALevel;
|
||||
}
|
||||
|
||||
bool ContextImpl::isError() const
|
||||
{
|
||||
return Utils::isGLError();
|
||||
|
|
|
@ -150,6 +150,8 @@ namespace opengl {
|
|||
|
||||
bool isSupported(graphics::SpecialFeatures _feature) const override;
|
||||
|
||||
s32 getMaxMSAALevel() override;
|
||||
|
||||
bool isError() const override;
|
||||
|
||||
bool isFramebufferError() const override;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
HGLRC WindowsWGL::hRC = NULL;
|
||||
HDC WindowsWGL::hDC = NULL;
|
||||
unsigned int WindowsWGL::m_sMaxMsaa = 0;
|
||||
|
||||
bool WindowsWGL::start()
|
||||
{
|
||||
|
@ -107,57 +106,6 @@ bool WindowsWGL::start()
|
|||
}
|
||||
}
|
||||
|
||||
if (m_sMaxMsaa > 0)
|
||||
return true;
|
||||
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB =
|
||||
(PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
|
||||
if (wglChoosePixelFormatARB != nullptr) {
|
||||
|
||||
const int piAttribIList16[] =
|
||||
{
|
||||
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
|
||||
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
|
||||
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
|
||||
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
|
||||
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
|
||||
WGL_COLOR_BITS_ARB, 32,
|
||||
WGL_DEPTH_BITS_ARB, 24,
|
||||
WGL_STENCIL_BITS_ARB, 8,
|
||||
WGL_SAMPLE_BUFFERS_ARB, 1,
|
||||
WGL_SAMPLES_EXT, 16,
|
||||
0 // zero term
|
||||
};
|
||||
const float pfAttribFList[] = { 0.0f };
|
||||
|
||||
int piFormats;
|
||||
unsigned int nNumFormats;
|
||||
int res = wglChoosePixelFormatARB(hDC, piAttribIList16, pfAttribFList, 1, &piFormats, &nNumFormats);
|
||||
if (res > 0 && nNumFormats > 0)
|
||||
m_sMaxMsaa = 16;
|
||||
else {
|
||||
const int piAttribIList8[] =
|
||||
{
|
||||
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
|
||||
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
|
||||
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
|
||||
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
|
||||
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
|
||||
WGL_COLOR_BITS_ARB, 32,
|
||||
WGL_DEPTH_BITS_ARB, 24,
|
||||
WGL_STENCIL_BITS_ARB, 8,
|
||||
WGL_SAMPLE_BUFFERS_ARB, 1,
|
||||
WGL_SAMPLES_EXT, 8,
|
||||
0 // zero term
|
||||
};
|
||||
res = wglChoosePixelFormatARB(hDC, piAttribIList16, pfAttribFList, 1, &piFormats, &nNumFormats);
|
||||
if (res > 0 && nNumFormats > 0)
|
||||
m_sMaxMsaa = 8;
|
||||
else
|
||||
m_sMaxMsaa = 4;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -183,13 +131,3 @@ void WindowsWGL::swapBuffers()
|
|||
else
|
||||
SwapBuffers(hDC);
|
||||
}
|
||||
|
||||
unsigned int WindowsWGL::maxMSAALevel()
|
||||
{
|
||||
if (hRC != NULL || m_sMaxMsaa > 0)
|
||||
return m_sMaxMsaa;
|
||||
|
||||
start();
|
||||
stop();
|
||||
return m_sMaxMsaa;
|
||||
}
|
||||
|
|
|
@ -11,11 +11,9 @@ public:
|
|||
static bool start();
|
||||
static void stop();
|
||||
static void swapBuffers();
|
||||
static unsigned int maxMSAALevel();
|
||||
|
||||
private:
|
||||
static HGLRC hRC;
|
||||
static HDC hDC;
|
||||
static unsigned int m_sMaxMsaa;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ private:
|
|||
void _changeWindow() override;
|
||||
void _readScreen(void **_pDest, long *_pWidth, long *_pHeight) override;
|
||||
void _readScreen2(void * _dest, int * _width, int * _height, int _front) override {}
|
||||
u32 _maxMSAALevel() const override;
|
||||
graphics::ObjectHandle _getDefaultFramebuffer() override;
|
||||
};
|
||||
|
||||
|
@ -228,8 +227,3 @@ graphics::ObjectHandle DisplayWindowWindows::_getDefaultFramebuffer()
|
|||
{
|
||||
return graphics::ObjectHandle::null;
|
||||
}
|
||||
|
||||
u32 DisplayWindowWindows::_maxMSAALevel() const
|
||||
{
|
||||
return FunctionWrapper::maxMSAALevel();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user