diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e281cbda..2f6e1d2a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -659,13 +659,9 @@ file( GLOB HEADER_FILES rendering/vulkan/renderer/*.h rendering/vulkan/shaders/*.h rendering/vulkan/textures/*.h - rendering/gl/*.h - rendering/gl/models/*.h rendering/gl/renderer/*.h - rendering/gl/scene/*.h rendering/gl/shaders/*.h rendering/gl/system/*.h - rendering/gl/textures/*.h *.h ) @@ -943,18 +939,10 @@ set (PCH_SOURCES rendering/2d/f_wipe.cpp rendering/2d/v_blend.cpp rendering/gl/renderer/gl_renderer.cpp - rendering/gl/renderer/gl_renderstate.cpp - rendering/gl/renderer/gl_renderbuffers.cpp - rendering/gl/renderer/gl_postprocess.cpp - rendering/gl/renderer/gl_postprocessstate.cpp rendering/gl/renderer/gl_stereo3d.cpp rendering/gl/shaders/gl_shader.cpp rendering/gl/shaders/gl_shaderprogram.cpp rendering/gl/system/gl_framebuffer.cpp - rendering/gl/system/gl_debug.cpp - rendering/gl/system/gl_buffers.cpp - rendering/gl/textures/gl_hwtexture.cpp - rendering/gl/textures/gl_samplers.cpp rendering/hwrenderer/hw_entrypoint.cpp rendering/hwrenderer/data/hw_vertexbuilder.cpp rendering/hwrenderer/dynlights/hw_aabbtree.cpp @@ -1149,6 +1137,14 @@ set (PCH_SOURCES common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp common/rendering/gl_load/gl_interface.cpp + common/rendering/gl/gl_renderstate.cpp + common/rendering/gl/gl_renderbuffers.cpp + common/rendering/gl/gl_postprocess.cpp + common/rendering/gl/gl_postprocessstate.cpp + common/rendering/gl/gl_debug.cpp + common/rendering/gl/gl_buffers.cpp + common/rendering/gl/gl_hwtexture.cpp + common/rendering/gl/gl_samplers.cpp common/scripting/core/dictionary.cpp common/scripting/core/dynarrays.cpp common/scripting/core/symbols.cpp @@ -1260,6 +1256,7 @@ include_directories( . common/rendering common/rendering/hwrenderer/data common/rendering/gl_load + common/rendering/gl common/scripting/vm common/scripting/jit common/scripting/core @@ -1479,6 +1476,7 @@ source_group("Common\\Rendering\\Hardware Renderer" REGULAR_EXPRESSION "^${CMAKE source_group("Common\\Rendering\\Hardware Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/hwrenderer/data/.+") source_group("Common\\Rendering\\Hardware Renderer\\Postprocessing" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/hwrenderer/postprocessing/.+") source_group("Common\\Rendering\\OpenGL Loader" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/gl_load/.+") +source_group("Common\\Rendering\\OpenGL Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/gl/.+") source_group("Common\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/.+") source_group("Common\\Textures\\Hires" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/.+") source_group("Common\\Textures\\Hires\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/hqnx/.+") diff --git a/src/rendering/gl/system/gl_buffers.cpp b/src/common/rendering/gl/gl_buffers.cpp similarity index 71% rename from src/rendering/gl/system/gl_buffers.cpp rename to src/common/rendering/gl/gl_buffers.cpp index 702aae2db..1f88195bf 100644 --- a/src/rendering/gl/system/gl_buffers.cpp +++ b/src/common/rendering/gl/gl_buffers.cpp @@ -1,32 +1,41 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2018 Christoph Oelckers -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// /* +** gl_buffers.cpp ** Low level vertex buffer class ** +**--------------------------------------------------------------------------- +** Copyright 2018-2020 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** **/ -#include "gl_system.h" +#include +#include "gl_load.h" #include "gl_buffers.h" -#include "gl/renderer/gl_renderstate.h" +#include "gl_renderstate.h" #include "v_video.h" namespace OpenGLRenderer @@ -220,4 +229,9 @@ void GLDataBuffer::BindBase() glBindBufferBase(mUseType, mBindingPoint, mBufferId); } + +GLVertexBuffer::GLVertexBuffer() : GLBuffer(GL_ARRAY_BUFFER) {} +GLIndexBuffer::GLIndexBuffer() : GLBuffer(GL_ELEMENT_ARRAY_BUFFER) {} +GLDataBuffer::GLDataBuffer(int bindingpoint, bool is_ssbo) : GLBuffer(is_ssbo ? GL_SHADER_STORAGE_BUFFER : GL_UNIFORM_BUFFER), mBindingPoint(bindingpoint) {} + } \ No newline at end of file diff --git a/src/rendering/gl/system/gl_buffers.h b/src/common/rendering/gl/gl_buffers.h similarity index 85% rename from src/rendering/gl/system/gl_buffers.h rename to src/common/rendering/gl/gl_buffers.h index a9e44061d..950556ff9 100644 --- a/src/rendering/gl/system/gl_buffers.h +++ b/src/common/rendering/gl/gl_buffers.h @@ -1,6 +1,6 @@ #pragma once -#include "hwrenderer/data/buffers.h" +#include "buffers.h" #ifdef _MSC_VER // silence bogus warning C4250: 'GLVertexBuffer': inherits 'GLBuffer::GLBuffer::SetData' via dominance @@ -50,7 +50,7 @@ class GLVertexBuffer : public IVertexBuffer, public GLBuffer size_t mStride = 0; public: - GLVertexBuffer() : GLBuffer(GL_ARRAY_BUFFER) {} + GLVertexBuffer(); void SetFormat(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute *attrs) override; void Bind(int *offsets); }; @@ -58,14 +58,14 @@ public: class GLIndexBuffer : public IIndexBuffer, public GLBuffer { public: - GLIndexBuffer() : GLBuffer(GL_ELEMENT_ARRAY_BUFFER) {} + GLIndexBuffer(); }; class GLDataBuffer : public IDataBuffer, public GLBuffer { int mBindingPoint; public: - GLDataBuffer(int bindingpoint, bool is_ssbo) : GLBuffer(is_ssbo? GL_SHADER_STORAGE_BUFFER : GL_UNIFORM_BUFFER), mBindingPoint(bindingpoint) {} + GLDataBuffer(int bindingpoint, bool is_ssbo); void BindRange(FRenderState* state, size_t start, size_t length); void BindBase(); }; diff --git a/src/rendering/gl/system/gl_debug.cpp b/src/common/rendering/gl/gl_debug.cpp similarity index 90% rename from src/rendering/gl/system/gl_debug.cpp rename to src/common/rendering/gl/gl_debug.cpp index 5c65814f7..c6c3adbfc 100644 --- a/src/rendering/gl/system/gl_debug.cpp +++ b/src/common/rendering/gl/gl_debug.cpp @@ -1,34 +1,29 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2016 Magnus Norddahl -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// /* -** gl_debig.cpp -** OpenGL debugging support functions +** OpenGL debugging support functions +** Copyright (c) 2016-2020 Magnus Norddahl ** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. */ #include "templates.h" #include "gl_system.h" -#include "gl/system/gl_debug.h" +#include "gl_debug.h" #include "stats.h" +#include "printf.h" #include #include #include diff --git a/src/rendering/gl/system/gl_debug.h b/src/common/rendering/gl/gl_debug.h similarity index 98% rename from src/rendering/gl/system/gl_debug.h rename to src/common/rendering/gl/gl_debug.h index 03c10c67e..e9d64a110 100644 --- a/src/rendering/gl/system/gl_debug.h +++ b/src/common/rendering/gl/gl_debug.h @@ -4,7 +4,6 @@ #include #include "gl_interface.h" #include "c_cvars.h" -#include "r_defs.h" #include "v_video.h" namespace OpenGLRenderer diff --git a/src/rendering/gl/textures/gl_hwtexture.cpp b/src/common/rendering/gl/gl_hwtexture.cpp similarity index 98% rename from src/rendering/gl/textures/gl_hwtexture.cpp rename to src/common/rendering/gl/gl_hwtexture.cpp index 2f807a5d6..3aa4aad79 100644 --- a/src/rendering/gl/textures/gl_hwtexture.cpp +++ b/src/common/rendering/gl/gl_hwtexture.cpp @@ -36,16 +36,14 @@ #include "gl_system.h" #include "templates.h" #include "c_cvars.h" -#include "doomtype.h" -#include "r_data/colormaps.h" #include "hw_material.h" #include "gl_interface.h" #include "hw_cvars.h" -#include "gl/system/gl_debug.h" +#include "gl_debug.h" #include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_renderstate.h" -#include "gl/textures/gl_samplers.h" +#include "gl_renderstate.h" +#include "gl_samplers.h" namespace OpenGLRenderer { diff --git a/src/rendering/gl/textures/gl_hwtexture.h b/src/common/rendering/gl/gl_hwtexture.h similarity index 100% rename from src/rendering/gl/textures/gl_hwtexture.h rename to src/common/rendering/gl/gl_hwtexture.h diff --git a/src/rendering/gl/renderer/gl_postprocess.cpp b/src/common/rendering/gl/gl_postprocess.cpp similarity index 98% rename from src/rendering/gl/renderer/gl_postprocess.cpp rename to src/common/rendering/gl/gl_postprocess.cpp index b3400f219..90b7cf335 100644 --- a/src/rendering/gl/renderer/gl_postprocess.cpp +++ b/src/common/rendering/gl/gl_postprocess.cpp @@ -21,12 +21,12 @@ #include "gl_system.h" #include "m_png.h" -#include "gl/system/gl_buffers.h" +#include "gl_buffers.h" #include "gl/system/gl_framebuffer.h" -#include "gl/system/gl_debug.h" -#include "gl/renderer/gl_renderbuffers.h" +#include "gl_debug.h" +#include "gl_renderbuffers.h" #include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_postprocessstate.h" +#include "gl_postprocessstate.h" #include "gl/shaders/gl_shaderprogram.h" #include "hwrenderer/postprocessing/hw_postprocess.h" #include "hwrenderer/postprocessing/hw_postprocess_cvars.h" diff --git a/src/rendering/gl/renderer/gl_postprocessstate.cpp b/src/common/rendering/gl/gl_postprocessstate.cpp similarity index 98% rename from src/rendering/gl/renderer/gl_postprocessstate.cpp rename to src/common/rendering/gl/gl_postprocessstate.cpp index 095aa24fe..2e6a04f05 100644 --- a/src/rendering/gl/renderer/gl_postprocessstate.cpp +++ b/src/common/rendering/gl/gl_postprocessstate.cpp @@ -22,7 +22,7 @@ #include "templates.h" #include "gl_system.h" #include "gl_interface.h" -#include "gl/renderer/gl_postprocessstate.h" +#include "gl_postprocessstate.h" namespace OpenGLRenderer { diff --git a/src/rendering/gl/renderer/gl_postprocessstate.h b/src/common/rendering/gl/gl_postprocessstate.h similarity index 100% rename from src/rendering/gl/renderer/gl_postprocessstate.h rename to src/common/rendering/gl/gl_postprocessstate.h diff --git a/src/rendering/gl/renderer/gl_renderbuffers.cpp b/src/common/rendering/gl/gl_renderbuffers.cpp similarity index 99% rename from src/rendering/gl/renderer/gl_renderbuffers.cpp rename to src/common/rendering/gl/gl_renderbuffers.cpp index b6e1000fd..3cec2c937 100644 --- a/src/rendering/gl/renderer/gl_renderbuffers.cpp +++ b/src/common/rendering/gl/gl_renderbuffers.cpp @@ -24,12 +24,12 @@ #include "gl_interface.h" #include "printf.h" #include "hw_cvars.h" -#include "gl/system/gl_debug.h" +#include "gl_debug.h" #include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_renderbuffers.h" -#include "gl/renderer/gl_postprocessstate.h" +#include "gl_renderbuffers.h" +#include "gl_postprocessstate.h" #include "gl/shaders/gl_shaderprogram.h" -#include "gl/system/gl_buffers.h" +#include "gl_buffers.h" #include "templates.h" #include diff --git a/src/rendering/gl/renderer/gl_renderbuffers.h b/src/common/rendering/gl/gl_renderbuffers.h similarity index 100% rename from src/rendering/gl/renderer/gl_renderbuffers.h rename to src/common/rendering/gl/gl_renderbuffers.h diff --git a/src/rendering/gl/renderer/gl_renderstate.cpp b/src/common/rendering/gl/gl_renderstate.cpp similarity index 99% rename from src/rendering/gl/renderer/gl_renderstate.cpp rename to src/common/rendering/gl/gl_renderstate.cpp index 34cc5ebff..8de101c2f 100644 --- a/src/rendering/gl/renderer/gl_renderstate.cpp +++ b/src/common/rendering/gl/gl_renderstate.cpp @@ -36,9 +36,9 @@ #include "gl/shaders/gl_shader.h" #include "gl/renderer/gl_renderer.h" #include "hw_lightbuffer.h" -#include "gl/renderer/gl_renderbuffers.h" -#include "gl/textures/gl_hwtexture.h" -#include "gl/system/gl_buffers.h" +#include "gl_renderbuffers.h" +#include "gl_hwtexture.h" +#include "gl_buffers.h" #include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/data/hw_viewpointbuffer.h" diff --git a/src/rendering/gl/renderer/gl_renderstate.h b/src/common/rendering/gl/gl_renderstate.h similarity index 100% rename from src/rendering/gl/renderer/gl_renderstate.h rename to src/common/rendering/gl/gl_renderstate.h diff --git a/src/rendering/gl/textures/gl_samplers.cpp b/src/common/rendering/gl/gl_samplers.cpp similarity index 99% rename from src/rendering/gl/textures/gl_samplers.cpp rename to src/common/rendering/gl/gl_samplers.cpp index 39d8146d7..12be63e43 100644 --- a/src/rendering/gl/textures/gl_samplers.cpp +++ b/src/common/rendering/gl/gl_samplers.cpp @@ -37,7 +37,7 @@ #include "gl_interface.h" #include "hw_cvars.h" -#include "gl/system/gl_debug.h" +#include "gl_debug.h" #include "gl/renderer/gl_renderer.h" #include "gl_samplers.h" #include "hw_material.h" diff --git a/src/rendering/gl/textures/gl_samplers.h b/src/common/rendering/gl/gl_samplers.h similarity index 100% rename from src/rendering/gl/textures/gl_samplers.h rename to src/common/rendering/gl/gl_samplers.h diff --git a/src/g_game.h b/src/g_game.h index 4edd33c58..0a86c2916 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -109,7 +109,5 @@ FBaseCVar* G_GetUserCVar(int playernum, const char* cvarname); extern const AActor *SendItemUse, *SendItemDrop; extern int SendItemDropAmount; -const int SAVEPICWIDTH = 216; -const int SAVEPICHEIGHT = 162; #endif diff --git a/src/rendering/gl/renderer/gl_renderer.cpp b/src/rendering/gl/renderer/gl_renderer.cpp index ecaeebbc0..356271466 100644 --- a/src/rendering/gl/renderer/gl_renderer.cpp +++ b/src/rendering/gl/renderer/gl_renderer.cpp @@ -1,28 +1,35 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2005-2016 Christoph Oelckers -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// /* -** gl1_renderer.cpp +** gl_renderer.cpp ** Renderer interface ** +**--------------------------------------------------------------------------- +** Copyright 2005-2020 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** */ #include "gl_system.h" @@ -36,6 +43,7 @@ #include "d_player.h" #include "a_dynlight.h" #include "cmdlib.h" +#include "version.h" #include "g_game.h" #include "swrenderer/r_swscene.h" #include "hwrenderer/utility/hw_clock.h" @@ -43,22 +51,22 @@ #include "gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "hw_cvars.h" -#include "gl/system/gl_debug.h" +#include "gl_debug.h" #include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_renderstate.h" -#include "gl/renderer/gl_renderbuffers.h" +#include "gl_renderstate.h" +#include "gl_renderbuffers.h" #include "gl/shaders/gl_shaderprogram.h" #include "hw_vrmodes.h" #include "flatvertices.h" #include "hwrenderer/scene/hw_skydome.h" #include "hwrenderer/scene/hw_fakeflat.h" -#include "gl/textures/gl_samplers.h" +#include "gl_samplers.h" #include "hw_lightbuffer.h" #include "hwrenderer/data/hw_viewpointbuffer.h" #include "r_videoscale.h" #include "r_data/models/models.h" -#include "gl/renderer/gl_postprocessstate.h" -#include "gl/system/gl_buffers.h" +#include "gl_postprocessstate.h" +#include "gl_buffers.h" #include "texturemanager.h" EXTERN_CVAR(Int, screenblocks) @@ -95,8 +103,6 @@ void FGLRenderer::Initialize(int width, int height) mShadowMapShader = new FShadowMapShader(); // needed for the core profile, because someone decided it was a good idea to remove the default VAO. - glGenQueries(1, &PortalQueryObject); - glGenVertexArrays(1, &mVAOID); glBindVertexArray(mVAOID); FGLDebug::LabelObject(GL_VERTEX_ARRAY, mVAOID, "FGLRenderer.mVAOID"); @@ -120,8 +126,6 @@ FGLRenderer::~FGLRenderer() glBindVertexArray(0); glDeleteVertexArrays(1, &mVAOID); } - if (PortalQueryObject != 0) glDeleteQueries(1, &PortalQueryObject); - if (mBuffers) delete mBuffers; if (mSaveBuffers) delete mSaveBuffers; if (mPresentShader) delete mPresentShader; @@ -160,44 +164,6 @@ void FGLRenderer::EndOffscreen() glBindFramebuffer(GL_FRAMEBUFFER, mOldFBID); } -//=========================================================================== -// -// -// -//=========================================================================== - -void FGLRenderer::UpdateShadowMap() -{ - if (screen->mShadowMap.PerformUpdate()) - { - FGLDebug::PushGroup("ShadowMap"); - - FGLPostProcessState savedState; - - static_cast(screen->mShadowMap.mLightList)->BindBase(); - static_cast(screen->mShadowMap.mNodesBuffer)->BindBase(); - static_cast(screen->mShadowMap.mLinesBuffer)->BindBase(); - - mBuffers->BindShadowMapFB(); - - mShadowMapShader->Bind(); - mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality; - mShadowMapShader->Uniforms->NodesCount = screen->mShadowMap.NodesCount(); - mShadowMapShader->Uniforms.SetData(); - static_cast(mShadowMapShader->Uniforms.GetBuffer())->BindBase(); - - glViewport(0, 0, gl_shadowmap_quality, 1024); - RenderScreenQuad(); - - const auto &viewport = screen->mScreenViewport; - glViewport(viewport.left, viewport.top, viewport.width, viewport.height); - - mBuffers->BindShadowMapTexture(16); - FGLDebug::PopGroup(); - screen->mShadowMap.FinishUpdate(); - } -} - //=========================================================================== // // @@ -207,14 +173,10 @@ void FGLRenderer::UpdateShadowMap() void FGLRenderer::BindToFrameBuffer(FTexture *tex) { auto BaseLayer = static_cast(tex->GetHardwareTexture(0, 0)); - - if (BaseLayer == nullptr) - { - // must create the hardware texture first - BaseLayer->BindOrCreate(tex, 0, 0, 0, 0); - FHardwareTexture::Unbind(0); - gl_RenderState.ClearLastMaterial(); - } + // must create the hardware texture first + BaseLayer->BindOrCreate(tex, 0, 0, 0, 0); + FHardwareTexture::Unbind(0); + gl_RenderState.ClearLastMaterial(); BaseLayer->BindToFrameBuffer(tex->GetWidth(), tex->GetHeight()); } diff --git a/src/rendering/gl/renderer/gl_renderer.h b/src/rendering/gl/renderer/gl_renderer.h index ab260563d..ab4e36459 100644 --- a/src/rendering/gl/renderer/gl_renderer.h +++ b/src/rendering/gl/renderer/gl_renderer.h @@ -6,7 +6,7 @@ #include "vectors.h" #include "swrenderer/r_renderer.h" #include "matrix.h" -#include "gl/renderer/gl_renderbuffers.h" +#include "gl_renderbuffers.h" #include "hwrenderer/scene/hw_portal.h" #include "hwrenderer/dynlights/hw_shadowmap.h" #include @@ -52,7 +52,6 @@ public: FSamplerManager *mSamplerManager = nullptr; unsigned int mFBID; unsigned int mVAOID; - unsigned int PortalQueryObject; unsigned int mStencilValue = 0; int mOldFBID; @@ -89,7 +88,6 @@ public: bool StartOffscreen(); void EndOffscreen(); - void UpdateShadowMap(); void BindToFrameBuffer(FTexture *mat); diff --git a/src/rendering/gl/renderer/gl_stereo3d.cpp b/src/rendering/gl/renderer/gl_stereo3d.cpp index 6df5ee69e..df6cb11ce 100644 --- a/src/rendering/gl/renderer/gl_stereo3d.cpp +++ b/src/rendering/gl/renderer/gl_stereo3d.cpp @@ -27,13 +27,13 @@ #include "gl_system.h" #include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_renderbuffers.h" +#include "gl_renderbuffers.h" #include "hw_vrmodes.h" #include "gl/system/gl_framebuffer.h" -#include "gl/renderer/gl_postprocessstate.h" +#include "gl_postprocessstate.h" #include "gl/system/gl_framebuffer.h" #include "gl/shaders/gl_shaderprogram.h" -#include "gl/system/gl_buffers.h" +#include "gl_buffers.h" #include "menu/menu.h" EXTERN_CVAR(Int, vr_mode) diff --git a/src/rendering/gl/shaders/gl_shader.cpp b/src/rendering/gl/shaders/gl_shader.cpp index a9799638a..125fbb964 100644 --- a/src/rendering/gl/shaders/gl_shader.cpp +++ b/src/rendering/gl/shaders/gl_shader.cpp @@ -41,7 +41,7 @@ #include "hw_lightbuffer.h" #include "gl_interface.h" -#include "gl/system/gl_debug.h" +#include "gl_debug.h" #include "matrix.h" #include "gl/renderer/gl_renderer.h" #include "gl/shaders/gl_shader.h" diff --git a/src/rendering/gl/shaders/gl_shader.h b/src/rendering/gl/shaders/gl_shader.h index c5068f5a2..3027376d5 100644 --- a/src/rendering/gl/shaders/gl_shader.h +++ b/src/rendering/gl/shaders/gl_shader.h @@ -23,7 +23,7 @@ #ifndef __GL_SHADERS_H__ #define __GL_SHADERS_H__ -#include "gl/renderer/gl_renderstate.h" +#include "gl_renderstate.h" #include "name.h" extern bool gl_shaderactive; diff --git a/src/rendering/gl/shaders/gl_shaderprogram.cpp b/src/rendering/gl/shaders/gl_shaderprogram.cpp index a79af0ce1..0a9e8a7a9 100644 --- a/src/rendering/gl/shaders/gl_shaderprogram.cpp +++ b/src/rendering/gl/shaders/gl_shaderprogram.cpp @@ -1,35 +1,29 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2016 Magnus Norddahl -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// /* -** gl_shaderprogram.cpp -** GLSL shader program compile and link +** Postprocessing framework +** Copyright (c) 2016-2020 Magnus Norddahl ** +** This software is provided 'as-is', without any express or implied +** warranty. In no event will the authors be held liable for any damages +** arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, +** including commercial applications, and to alter it and redistribute it +** freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not +** claim that you wrote the original software. If you use this software +** in a product, an acknowledgment in the product documentation would be +** appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be +** misrepresented as being the original software. +** 3. This notice may not be removed or altered from any source distribution. */ #include "gl_system.h" #include "v_video.h" #include "gl_interface.h" #include "hw_cvars.h" -#include "gl/system/gl_debug.h" +#include "gl_debug.h" #include "gl/shaders/gl_shaderprogram.h" #include "hwrenderer/utility/hw_shaderpatcher.h" #include "filesystem.h" @@ -268,7 +262,7 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const // If we have 4.2, always use it because it adds important new syntax. if (maxGlslVersion < 420 && gl.glslversion >= 4.2f) maxGlslVersion = 420; - int shaderVersion = MIN((int)round(gl.glslversion * 10) * 10, maxGlslVersion); + int shaderVersion = std::min((int)round(gl.glslversion * 10) * 10, maxGlslVersion); patchedCode.AppendFormat("#version %d\n", shaderVersion); // TODO: Find some way to add extension requirements to the patching diff --git a/src/rendering/gl/system/gl_framebuffer.cpp b/src/rendering/gl/system/gl_framebuffer.cpp index ea90b2101..814a2ace5 100644 --- a/src/rendering/gl/system/gl_framebuffer.cpp +++ b/src/rendering/gl/system/gl_framebuffer.cpp @@ -1,30 +1,37 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2010-2016 Christoph Oelckers -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// /* ** gl_framebuffer.cpp ** Implementation of the non-hardware specific parts of the ** OpenGL frame buffer ** -*/ +**--------------------------------------------------------------------------- +** Copyright 2010-2020 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ #include "gl_system.h" #include "v_video.h" @@ -35,8 +42,8 @@ #include "gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_renderbuffers.h" -#include "gl/textures/gl_samplers.h" +#include "gl_renderbuffers.h" +#include "gl_samplers.h" #include "hwrenderer/utility/hw_clock.h" #include "hw_vrmodes.h" #include "hwrenderer/models/hw_models.h" @@ -49,8 +56,10 @@ #include "r_videoscale.h" #include "gl_buffers.h" #include "swrenderer/r_swscene.h" +#include "gl_postprocessstate.h" #include "flatvertices.h" +#include "hw_cvars.h" EXTERN_CVAR (Bool, vid_vsync) EXTERN_CVAR(Bool, r_drawvoxels) @@ -412,7 +421,34 @@ void OpenGLFrameBuffer::SetSceneRenderTarget(bool useSSAO) void OpenGLFrameBuffer::UpdateShadowMap() { - GLRenderer->UpdateShadowMap(); + if (mShadowMap.PerformUpdate()) + { + FGLDebug::PushGroup("ShadowMap"); + + FGLPostProcessState savedState; + + static_cast(screen->mShadowMap.mLightList)->BindBase(); + static_cast(screen->mShadowMap.mNodesBuffer)->BindBase(); + static_cast(screen->mShadowMap.mLinesBuffer)->BindBase(); + + GLRenderer->mBuffers->BindShadowMapFB(); + + GLRenderer->mShadowMapShader->Bind(); + GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality; + GLRenderer->mShadowMapShader->Uniforms->NodesCount = screen->mShadowMap.NodesCount(); + GLRenderer->mShadowMapShader->Uniforms.SetData(); + static_cast(GLRenderer->mShadowMapShader->Uniforms.GetBuffer())->BindBase(); + + glViewport(0, 0, gl_shadowmap_quality, 1024); + GLRenderer->RenderScreenQuad(); + + const auto& viewport = screen->mScreenViewport; + glViewport(viewport.left, viewport.top, viewport.width, viewport.height); + + GLRenderer->mBuffers->BindShadowMapTexture(16); + FGLDebug::PopGroup(); + screen->mShadowMap.FinishUpdate(); + } } void OpenGLFrameBuffer::WaitForCommands(bool finish) diff --git a/src/rendering/vulkan/system/vk_framebuffer.cpp b/src/rendering/vulkan/system/vk_framebuffer.cpp index 7aca21c0e..cabc62b3c 100644 --- a/src/rendering/vulkan/system/vk_framebuffer.cpp +++ b/src/rendering/vulkan/system/vk_framebuffer.cpp @@ -30,6 +30,7 @@ #include "i_time.h" #include "g_game.h" #include "v_text.h" +#include "version.h" #include "hwrenderer/utility/hw_clock.h" #include "hw_vrmodes.h" diff --git a/src/version.h b/src/version.h index 1be840a5f..213e3f517 100644 --- a/src/version.h +++ b/src/version.h @@ -110,5 +110,8 @@ const char *GetVersionString(); #define GAME_DIR ".config/" GAMENAMELOWERCASE #endif +const int SAVEPICWIDTH = 216; +const int SAVEPICHEIGHT = 162; + #endif //__VERSION_H__