From bafd6be342a7ada8276750b63d43c376977ff20b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jan 2023 08:20:50 +0100 Subject: [PATCH] - removed backend dependencies on game data. --- .../hwrenderer/data/hw_viewpointuniforms.h | 9 +++++++++ .../postprocessing/hw_postprocess.cpp | 10 ++++------ .../postprocessing/hw_postprocess.h | 19 +++++++++++++++++- src/doomtype.h | 20 ------------------- src/gamedata/g_mapinfo.h | 2 ++ src/rendering/hwrenderer/hw_entrypoint.cpp | 2 ++ 6 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/common/rendering/hwrenderer/data/hw_viewpointuniforms.h b/src/common/rendering/hwrenderer/data/hw_viewpointuniforms.h index 031bace0a5..def3b48089 100644 --- a/src/common/rendering/hwrenderer/data/hw_viewpointuniforms.h +++ b/src/common/rendering/hwrenderer/data/hw_viewpointuniforms.h @@ -4,6 +4,15 @@ struct HWDrawInfo; +enum class ELightBlendMode : uint8_t +{ + CLAMP = 0, + CLAMP_COLOR = 1, + NOCLAMP = 2, + + DEFAULT = CLAMP, +}; + struct HWViewpointUniforms { VSMatrix mProjectionMatrix; diff --git a/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp b/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp index e2f625ca71..9cf1badb77 100644 --- a/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp +++ b/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp @@ -29,8 +29,6 @@ #include "stats.h" -#include "g_levellocals.h" - Postprocess hw_postprocess; PPResource *PPResource::First = nullptr; @@ -601,9 +599,9 @@ void PPTonemap::UpdateTextures() void PPTonemap::Render(PPRenderState *renderstate) { - ETonemapMode level_tonemap = (level.info && level.info->tonemap != ETonemapMode::None) ? level.info->tonemap : ETonemapMode((int)gl_tonemap); + ETonemapMode current_tonemap = (level_tonemap != ETonemapMode::None) ? level_tonemap : ETonemapMode((int)gl_tonemap); - if (level_tonemap == ETonemapMode::None) + if (current_tonemap == ETonemapMode::None) { return; } @@ -611,7 +609,7 @@ void PPTonemap::Render(PPRenderState *renderstate) UpdateTextures(); PPShader *shader = nullptr; - switch (level_tonemap) + switch (current_tonemap) { default: case ETonemapMode::Linear: shader = &LinearShader; break; @@ -627,7 +625,7 @@ void PPTonemap::Render(PPRenderState *renderstate) renderstate->Shader = shader; renderstate->Viewport = screen->mScreenViewport; renderstate->SetInputCurrent(0); - if (level_tonemap == ETonemapMode::Palette) + if (current_tonemap == ETonemapMode::Palette) renderstate->SetInputTexture(1, &PaletteTexture); renderstate->SetOutputNext(); renderstate->SetNoBlend(); diff --git a/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.h b/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.h index 26845b1d4e..357396da76 100644 --- a/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.h +++ b/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.h @@ -13,6 +13,19 @@ typedef IntRect PPViewport; class PPTexture; class PPShader; +enum class ETonemapMode : uint8_t +{ + None, + Uncharted2, + HejlDawson, + Reinhard, + Linear, + Palette, + NumTonemapModes +}; + + + enum class PPFilterMode { Nearest, Linear }; enum class PPWrapMode { Clamp, Repeat }; enum class PPTextureType { CurrentPipelineTexture, NextPipelineTexture, PPTexture, SceneColor, SceneFog, SceneNormal, SceneDepth, SwapChain, ShadowMap }; @@ -541,6 +554,7 @@ private: class PPTonemap { public: + void SetTonemapMode(ETonemapMode tm) { level_tonemap = tm; } void Render(PPRenderState *renderstate); void ClearTonemapPalette() { PaletteTexture = {}; } @@ -554,7 +568,7 @@ private: PPShader HejlDawsonShader = { "shaders/pp/tonemap.fp", "#define HEJLDAWSON\n", {} }; PPShader Uncharted2Shader = { "shaders/pp/tonemap.fp", "#define UNCHARTED2\n", {} }; PPShader PaletteShader = { "shaders/pp/tonemap.fp", "#define PALETTE\n", {} }; - + ETonemapMode level_tonemap = ETonemapMode::None; }; ///////////////////////////////////////////////////////////////////////////// @@ -830,8 +844,11 @@ public: PPCustomShaders customShaders; + void SetTonemapMode(ETonemapMode tm) { tonemap.SetTonemapMode(tm); } void Pass1(PPRenderState *state, int fixedcm, int sceneWidth, int sceneHeight); void Pass2(PPRenderState* state, int fixedcm, float flash, int sceneWidth, int sceneHeight); }; + extern Postprocess hw_postprocess; + diff --git a/src/doomtype.h b/src/doomtype.h index 269b8363b6..2a3fecbd0f 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -53,24 +53,4 @@ enum class ELightMode : int8_t DoomSoftware = 16 }; -enum class ELightBlendMode : uint8_t -{ - CLAMP = 0, - CLAMP_COLOR = 1, - NOCLAMP = 2, - - DEFAULT = CLAMP, -}; - -enum class ETonemapMode : uint8_t -{ - None, - Uncharted2, - HejlDawson, - Reinhard, - Linear, - Palette, - NumTonemapModes -}; - #endif diff --git a/src/gamedata/g_mapinfo.h b/src/gamedata/g_mapinfo.h index 63cf962b47..166a534399 100644 --- a/src/gamedata/g_mapinfo.h +++ b/src/gamedata/g_mapinfo.h @@ -40,6 +40,8 @@ #include "sc_man.h" #include "file_zip.h" #include "screenjob.h" +#include "hwrenderer/postprocessing/hw_postprocess.h" +#include "hw_viewpointuniforms.h" struct level_info_t; struct cluster_info_t; diff --git a/src/rendering/hwrenderer/hw_entrypoint.cpp b/src/rendering/hwrenderer/hw_entrypoint.cpp index 42106f472f..e80d7ef669 100644 --- a/src/rendering/hwrenderer/hw_entrypoint.cpp +++ b/src/rendering/hwrenderer/hw_entrypoint.cpp @@ -273,6 +273,7 @@ void WriteSavePic(player_t* player, FileWriter* file, int width, int height) screen->SetSaveBuffers(true); screen->ImageTransitionScene(true); + hw_postprocess.SetTonemapMode(level.info ? level.info->tonemap : ETonemapMode::None); hw_ClearFakeFlat(); screen->mVertexData->Reset(); RenderState.SetVertexBuffer(screen->mVertexData); @@ -317,6 +318,7 @@ sector_t* RenderView(player_t* player) auto RenderState = screen->RenderState(); RenderState->SetVertexBuffer(screen->mVertexData); screen->mVertexData->Reset(); + hw_postprocess.SetTonemapMode(level.info ? level.info->tonemap : ETonemapMode::None); sector_t* retsec; if (!V_IsHardwareRenderer())