video_core: Bump OpenGL version to 4.3 on desktop

* The current backend heavily depends on many extensions for shadow
  rendering and texture cubes in the fragment shaders. All these
  extensions were incorporated to core in 4.3. Support is practically
  ubiquitous and requiring support for it makes things a lot easier
This commit is contained in:
emufan4568 2022-08-21 01:39:16 +03:00
parent 02d1fa2e0f
commit 025cd31420
6 changed files with 21 additions and 19 deletions

View File

@ -143,14 +143,16 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
SDL_SetMainReady(); SDL_SetMainReady();
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
if (Settings::values.use_gles) { if (Settings::values.use_gles) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
} else { } else {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
} }
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);

View File

@ -9,7 +9,7 @@
#include <QOffscreenSurface> #include <QOffscreenSurface>
#include <QOpenGLContext> #include <QOpenGLContext>
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
#include <QOpenGLFunctions_3_3_Core> #include <QOpenGLFunctions_4_3_Core>
#include <fmt/format.h> #include <fmt/format.h>
#include "citra_qt/bootmanager.h" #include "citra_qt/bootmanager.h"
#include "citra_qt/main.h" #include "citra_qt/main.h"
@ -143,7 +143,7 @@ void OpenGLWindow::Present() {
VideoCore::g_renderer->TryPresent(100); VideoCore::g_renderer->TryPresent(100);
} }
context->swapBuffers(this); context->swapBuffers(this);
auto f = context->versionFunctions<QOpenGLFunctions_3_3_Core>(); auto f = context->versionFunctions<QOpenGLFunctions_4_3_Core>();
f->glFinish(); f->glFinish();
QWindow::requestUpdate(); QWindow::requestUpdate();
} }

View File

@ -2441,7 +2441,7 @@ int main(int argc, char* argv[]) {
QCoreApplication::setApplicationName(QStringLiteral("Citra")); QCoreApplication::setApplicationName(QStringLiteral("Citra"));
QSurfaceFormat format; QSurfaceFormat format;
format.setVersion(3, 3); format.setVersion(4, 3);
format.setProfile(QSurfaceFormat::CoreProfile); format.setProfile(QSurfaceFormat::CoreProfile);
format.setSwapInterval(0); format.setSwapInterval(0);
// TODO: expose a setting for buffer value (ie default/single/double/triple) // TODO: expose a setting for buffer value (ie default/single/double/triple)

View File

@ -45,8 +45,8 @@ class RasterizerCacheOpenGL;
class CachedSurface : public SurfaceParams, public std::enable_shared_from_this<CachedSurface> { class CachedSurface : public SurfaceParams, public std::enable_shared_from_this<CachedSurface> {
public: public:
CachedSurface(RasterizerCacheOpenGL& owner, TextureRuntime& runtime) : CachedSurface(SurfaceParams params, RasterizerCacheOpenGL& owner,TextureRuntime& runtime) :
owner(owner), runtime(runtime) {} SurfaceParams(params), owner(owner), runtime(runtime) {}
~CachedSurface(); ~CachedSurface();
/// Read/Write data in 3DS memory to/from gl_buffer /// Read/Write data in 3DS memory to/from gl_buffer

View File

@ -731,13 +731,14 @@ SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces(
} }
Surface RasterizerCacheOpenGL::GetFillSurface(const GPU::Regs::MemoryFillConfig& config) { Surface RasterizerCacheOpenGL::GetFillSurface(const GPU::Regs::MemoryFillConfig& config) {
Surface new_surface = std::make_shared<CachedSurface>(*this, runtime); SurfaceParams params;
params.addr = config.GetStartAddress();
params.end = config.GetEndAddress();
params.size = params.end - params.addr;
params.type = SurfaceType::Fill;
params.res_scale = std::numeric_limits<u16>::max();
new_surface->addr = config.GetStartAddress(); Surface new_surface = std::make_shared<CachedSurface>(params, *this, runtime);
new_surface->end = config.GetEndAddress();
new_surface->size = new_surface->end - new_surface->addr;
new_surface->type = SurfaceType::Fill;
new_surface->res_scale = std::numeric_limits<u16>::max();
std::memcpy(&new_surface->fill_data[0], &config.value_32bit, 4); std::memcpy(&new_surface->fill_data[0], &config.value_32bit, 4);
if (config.fill_32bit) { if (config.fill_32bit) {
@ -1085,14 +1086,13 @@ void RasterizerCacheOpenGL::InvalidateRegion(PAddr addr, u32 size, const Surface
} }
Surface RasterizerCacheOpenGL::CreateSurface(const SurfaceParams& params) { Surface RasterizerCacheOpenGL::CreateSurface(const SurfaceParams& params) {
Surface surface = std::make_shared<CachedSurface>(*this, runtime); Surface surface = std::make_shared<CachedSurface>(params, *this, runtime);
static_cast<SurfaceParams&>(*surface) = params;
surface->invalid_regions.insert(surface->GetInterval()); surface->invalid_regions.insert(surface->GetInterval());
surface->texture = // Allocate surface texture
AllocateSurfaceTexture(GetFormatTuple(surface->pixel_format), surface->GetScaledWidth(), const FormatTuple& tuple = GetFormatTuple(surface->pixel_format);
surface->GetScaledHeight()); surface->texture = AllocateSurfaceTexture(tuple, surface->GetScaledWidth(),
surface->GetScaledHeight());
return surface; return surface;
} }

View File

@ -26,7 +26,7 @@ GLuint LoadShader(const char* source, GLenum type) {
#extension GL_EXT_clip_cull_distance : enable #extension GL_EXT_clip_cull_distance : enable
#endif // defined(GL_EXT_clip_cull_distance) #endif // defined(GL_EXT_clip_cull_distance)
)" )"
: "#version 330\n"; : "#version 450 core\n";
const char* debug_type; const char* debug_type;
switch (type) { switch (type) {