From 36833d1df2ccb238efc4e9b62274ac188f814edb Mon Sep 17 00:00:00 2001 From: vladislavbelov Date: Fri, 18 Feb 2022 23:17:48 +0000 Subject: [PATCH] Moves max texture size to backend device capabilities. This was SVN commit r26409. --- source/lib/ogl.cpp | 15 +-------------- source/lib/ogl.h | 9 +-------- source/renderer/ShadowMap.cpp | 7 ++++--- source/renderer/backend/gl/Device.cpp | 5 +++++ source/renderer/backend/gl/Device.h | 1 + 5 files changed, 12 insertions(+), 25 deletions(-) diff --git a/source/lib/ogl.cpp b/source/lib/ogl.cpp index 7a8a5fa193..c36961befa 100644 --- a/source/lib/ogl.cpp +++ b/source/lib/ogl.cpp @@ -20,11 +20,8 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - * OpenGL helper functions. - */ - #include "precompiled.h" + #include "lib/ogl.h" #include "lib/code_annotation.h" @@ -416,9 +413,6 @@ bool ogl_SquelchError(GLenum err_to_ignore) // feature and limit detect //---------------------------------------------------------------------------- -GLint ogl_max_tex_size = -1; // [pixels] -GLint ogl_max_tex_units = -1; // limit on GL_TEXTUREn - #if OS_WIN bool ogl_Init(void* (load)(const char*), void* hdc) #elif !CONFIG2_GLES && !OS_MACOSX && !OS_MAC @@ -484,13 +478,6 @@ bool ogl_Init(void* (load)(const char*)) enableDummyFunctions(); - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &ogl_max_tex_size); -#if !CONFIG2_GLES - glGetIntegerv(GL_MAX_TEXTURE_UNITS, &ogl_max_tex_units); -#endif - - glEnable(GL_TEXTURE_2D); - return true; } diff --git a/source/lib/ogl.h b/source/lib/ogl.h index 2eba413ceb..b3cdc15665 100644 --- a/source/lib/ogl.h +++ b/source/lib/ogl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -143,11 +143,4 @@ extern const char* ogl_GetErrorName(GLenum err); **/ extern bool ogl_SquelchError(GLenum err_to_ignore); - -//----------------------------------------------------------------------------- -// implementation limits / feature detect - -extern GLint ogl_max_tex_size; /// [pixels] -extern GLint ogl_max_tex_units; /// limit on GL_TEXTUREn - #endif // INCLUDED_OGL diff --git a/source/renderer/ShadowMap.cpp b/source/renderer/ShadowMap.cpp index f1d4fe7340..cf2fc0c308 100644 --- a/source/renderer/ShadowMap.cpp +++ b/source/renderer/ShadowMap.cpp @@ -473,6 +473,8 @@ void ShadowMapInternals::CreateTexture() Texture.reset(); DummyTexture.reset(); + Renderer::Backend::GL::CDevice* backendDevice = g_VideoMode.GetBackendDevice(); + CFG_GET_VAL("shadowquality", QualityLevel); // Get shadow map size as next power of two up from view width/height. @@ -498,7 +500,8 @@ void ShadowMapInternals::CreateTexture() } // Clamp to the maximum texture size. - shadowMapSize = std::min(shadowMapSize, static_cast(ogl_max_tex_size)); + shadowMapSize = std::min( + shadowMapSize, static_cast(backendDevice->GetCapabilities().maxTextureSize)); Width = Height = shadowMapSize; @@ -525,8 +528,6 @@ void ShadowMapInternals::CreateTexture() LOGMESSAGE("Creating shadow texture (size %dx%d) (format = %s)", Width, Height, formatName); - Renderer::Backend::GL::CDevice* backendDevice = g_VideoMode.GetBackendDevice(); - if (g_RenderingOptions.GetShadowAlphaFix()) { DummyTexture = backendDevice->CreateTexture2D("ShadowMapDummy", diff --git a/source/renderer/backend/gl/Device.cpp b/source/renderer/backend/gl/Device.cpp index ae848ba6e3..a2bf81effb 100644 --- a/source/renderer/backend/gl/Device.cpp +++ b/source/renderer/backend/gl/Device.cpp @@ -287,6 +287,8 @@ std::unique_ptr CDevice::Create(SDL_Window* window, const bool arb) glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glEnable(GL_TEXTURE_2D); + device->m_Backbuffer = CFramebuffer::CreateBackbuffer(device.get()); Capabilities& capabilities = device->m_Capabilities; @@ -324,6 +326,9 @@ std::unique_ptr CDevice::Create(SDL_Window* window, const bool arb) glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy); capabilities.maxAnisotropy = maxAnisotropy; } + GLint maxTextureSize = 1024; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); + capabilities.maxTextureSize = maxTextureSize; #if CONFIG2_GLES const bool isDebugInCore = ogl_HaveVersion(3, 2); diff --git a/source/renderer/backend/gl/Device.h b/source/renderer/backend/gl/Device.h index a91d1cfa35..c547f6a38e 100644 --- a/source/renderer/backend/gl/Device.h +++ b/source/renderer/backend/gl/Device.h @@ -56,6 +56,7 @@ public: bool anisotropicFiltering; uint32_t maxSampleCount; float maxAnisotropy; + uint32_t maxTextureSize; }; ~CDevice();