From 025cd314206e4dbebd7571db26dfc71985496fd6 Mon Sep 17 00:00:00 2001 From: emufan4568 Date: Sun, 21 Aug 2022 01:39:16 +0300 Subject: [PATCH] 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 --- src/citra/emu_window/emu_window_sdl2.cpp | 4 +++- src/citra_qt/bootmanager.cpp | 4 ++-- src/citra_qt/main.cpp | 2 +- .../rasterizer_cache/cached_surface.h | 4 ++-- .../rasterizer_cache/rasterizer_cache.cpp | 24 +++++++++---------- .../renderer_opengl/gl_shader_util.cpp | 2 +- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp index e5a0594c4..ad02d9a15 100644 --- a/src/citra/emu_window/emu_window_sdl2.cpp +++ b/src/citra/emu_window/emu_window_sdl2.cpp @@ -143,14 +143,16 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) { SDL_SetMainReady(); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); 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_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); } 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_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); } + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 3a3eeb322..00b291d3c 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include "citra_qt/bootmanager.h" #include "citra_qt/main.h" @@ -143,7 +143,7 @@ void OpenGLWindow::Present() { VideoCore::g_renderer->TryPresent(100); } context->swapBuffers(this); - auto f = context->versionFunctions(); + auto f = context->versionFunctions(); f->glFinish(); QWindow::requestUpdate(); } diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 29effcf24..84c1ec6a8 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -2441,7 +2441,7 @@ int main(int argc, char* argv[]) { QCoreApplication::setApplicationName(QStringLiteral("Citra")); QSurfaceFormat format; - format.setVersion(3, 3); + format.setVersion(4, 3); format.setProfile(QSurfaceFormat::CoreProfile); format.setSwapInterval(0); // TODO: expose a setting for buffer value (ie default/single/double/triple) diff --git a/src/video_core/rasterizer_cache/cached_surface.h b/src/video_core/rasterizer_cache/cached_surface.h index cd1bcaf1a..7f8ac97bf 100644 --- a/src/video_core/rasterizer_cache/cached_surface.h +++ b/src/video_core/rasterizer_cache/cached_surface.h @@ -45,8 +45,8 @@ class RasterizerCacheOpenGL; class CachedSurface : public SurfaceParams, public std::enable_shared_from_this { public: - CachedSurface(RasterizerCacheOpenGL& owner, TextureRuntime& runtime) : - owner(owner), runtime(runtime) {} + CachedSurface(SurfaceParams params, RasterizerCacheOpenGL& owner,TextureRuntime& runtime) : + SurfaceParams(params), owner(owner), runtime(runtime) {} ~CachedSurface(); /// Read/Write data in 3DS memory to/from gl_buffer diff --git a/src/video_core/rasterizer_cache/rasterizer_cache.cpp b/src/video_core/rasterizer_cache/rasterizer_cache.cpp index 88d2b5ab9..2a64506c1 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache.cpp +++ b/src/video_core/rasterizer_cache/rasterizer_cache.cpp @@ -731,13 +731,14 @@ SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces( } Surface RasterizerCacheOpenGL::GetFillSurface(const GPU::Regs::MemoryFillConfig& config) { - Surface new_surface = std::make_shared(*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::max(); - new_surface->addr = config.GetStartAddress(); - 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::max(); + Surface new_surface = std::make_shared(params, *this, runtime); std::memcpy(&new_surface->fill_data[0], &config.value_32bit, 4); if (config.fill_32bit) { @@ -1085,14 +1086,13 @@ void RasterizerCacheOpenGL::InvalidateRegion(PAddr addr, u32 size, const Surface } Surface RasterizerCacheOpenGL::CreateSurface(const SurfaceParams& params) { - Surface surface = std::make_shared(*this, runtime); - static_cast(*surface) = params; - + Surface surface = std::make_shared(params, *this, runtime); surface->invalid_regions.insert(surface->GetInterval()); - surface->texture = - AllocateSurfaceTexture(GetFormatTuple(surface->pixel_format), surface->GetScaledWidth(), - surface->GetScaledHeight()); + // Allocate surface texture + const FormatTuple& tuple = GetFormatTuple(surface->pixel_format); + surface->texture = AllocateSurfaceTexture(tuple, surface->GetScaledWidth(), + surface->GetScaledHeight()); return surface; } diff --git a/src/video_core/renderer_opengl/gl_shader_util.cpp b/src/video_core/renderer_opengl/gl_shader_util.cpp index 036cd49a3..eaae6f582 100644 --- a/src/video_core/renderer_opengl/gl_shader_util.cpp +++ b/src/video_core/renderer_opengl/gl_shader_util.cpp @@ -26,7 +26,7 @@ GLuint LoadShader(const char* source, GLenum type) { #extension GL_EXT_clip_cull_distance : enable #endif // defined(GL_EXT_clip_cull_distance) )" - : "#version 330\n"; + : "#version 450 core\n"; const char* debug_type; switch (type) {