- removed backend dependencies on game data.

This commit is contained in:
Christoph Oelckers 2023-01-15 08:20:50 +01:00
parent c8b3d95d6f
commit bafd6be342
6 changed files with 35 additions and 27 deletions

View file

@ -4,6 +4,15 @@
struct HWDrawInfo; struct HWDrawInfo;
enum class ELightBlendMode : uint8_t
{
CLAMP = 0,
CLAMP_COLOR = 1,
NOCLAMP = 2,
DEFAULT = CLAMP,
};
struct HWViewpointUniforms struct HWViewpointUniforms
{ {
VSMatrix mProjectionMatrix; VSMatrix mProjectionMatrix;

View file

@ -29,8 +29,6 @@
#include "stats.h" #include "stats.h"
#include "g_levellocals.h"
Postprocess hw_postprocess; Postprocess hw_postprocess;
PPResource *PPResource::First = nullptr; PPResource *PPResource::First = nullptr;
@ -601,9 +599,9 @@ void PPTonemap::UpdateTextures()
void PPTonemap::Render(PPRenderState *renderstate) 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; return;
} }
@ -611,7 +609,7 @@ void PPTonemap::Render(PPRenderState *renderstate)
UpdateTextures(); UpdateTextures();
PPShader *shader = nullptr; PPShader *shader = nullptr;
switch (level_tonemap) switch (current_tonemap)
{ {
default: default:
case ETonemapMode::Linear: shader = &LinearShader; break; case ETonemapMode::Linear: shader = &LinearShader; break;
@ -627,7 +625,7 @@ void PPTonemap::Render(PPRenderState *renderstate)
renderstate->Shader = shader; renderstate->Shader = shader;
renderstate->Viewport = screen->mScreenViewport; renderstate->Viewport = screen->mScreenViewport;
renderstate->SetInputCurrent(0); renderstate->SetInputCurrent(0);
if (level_tonemap == ETonemapMode::Palette) if (current_tonemap == ETonemapMode::Palette)
renderstate->SetInputTexture(1, &PaletteTexture); renderstate->SetInputTexture(1, &PaletteTexture);
renderstate->SetOutputNext(); renderstate->SetOutputNext();
renderstate->SetNoBlend(); renderstate->SetNoBlend();

View file

@ -13,6 +13,19 @@ typedef IntRect PPViewport;
class PPTexture; class PPTexture;
class PPShader; class PPShader;
enum class ETonemapMode : uint8_t
{
None,
Uncharted2,
HejlDawson,
Reinhard,
Linear,
Palette,
NumTonemapModes
};
enum class PPFilterMode { Nearest, Linear }; enum class PPFilterMode { Nearest, Linear };
enum class PPWrapMode { Clamp, Repeat }; enum class PPWrapMode { Clamp, Repeat };
enum class PPTextureType { CurrentPipelineTexture, NextPipelineTexture, PPTexture, SceneColor, SceneFog, SceneNormal, SceneDepth, SwapChain, ShadowMap }; enum class PPTextureType { CurrentPipelineTexture, NextPipelineTexture, PPTexture, SceneColor, SceneFog, SceneNormal, SceneDepth, SwapChain, ShadowMap };
@ -541,6 +554,7 @@ private:
class PPTonemap class PPTonemap
{ {
public: public:
void SetTonemapMode(ETonemapMode tm) { level_tonemap = tm; }
void Render(PPRenderState *renderstate); void Render(PPRenderState *renderstate);
void ClearTonemapPalette() { PaletteTexture = {}; } void ClearTonemapPalette() { PaletteTexture = {}; }
@ -554,7 +568,7 @@ private:
PPShader HejlDawsonShader = { "shaders/pp/tonemap.fp", "#define HEJLDAWSON\n", {} }; PPShader HejlDawsonShader = { "shaders/pp/tonemap.fp", "#define HEJLDAWSON\n", {} };
PPShader Uncharted2Shader = { "shaders/pp/tonemap.fp", "#define UNCHARTED2\n", {} }; PPShader Uncharted2Shader = { "shaders/pp/tonemap.fp", "#define UNCHARTED2\n", {} };
PPShader PaletteShader = { "shaders/pp/tonemap.fp", "#define PALETTE\n", {} }; PPShader PaletteShader = { "shaders/pp/tonemap.fp", "#define PALETTE\n", {} };
ETonemapMode level_tonemap = ETonemapMode::None;
}; };
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -830,8 +844,11 @@ public:
PPCustomShaders customShaders; PPCustomShaders customShaders;
void SetTonemapMode(ETonemapMode tm) { tonemap.SetTonemapMode(tm); }
void Pass1(PPRenderState *state, int fixedcm, int sceneWidth, int sceneHeight); void Pass1(PPRenderState *state, int fixedcm, int sceneWidth, int sceneHeight);
void Pass2(PPRenderState* state, int fixedcm, float flash, int sceneWidth, int sceneHeight); void Pass2(PPRenderState* state, int fixedcm, float flash, int sceneWidth, int sceneHeight);
}; };
extern Postprocess hw_postprocess; extern Postprocess hw_postprocess;

View file

@ -53,24 +53,4 @@ enum class ELightMode : int8_t
DoomSoftware = 16 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 #endif

View file

@ -40,6 +40,8 @@
#include "sc_man.h" #include "sc_man.h"
#include "file_zip.h" #include "file_zip.h"
#include "screenjob.h" #include "screenjob.h"
#include "hwrenderer/postprocessing/hw_postprocess.h"
#include "hw_viewpointuniforms.h"
struct level_info_t; struct level_info_t;
struct cluster_info_t; struct cluster_info_t;

View file

@ -273,6 +273,7 @@ void WriteSavePic(player_t* player, FileWriter* file, int width, int height)
screen->SetSaveBuffers(true); screen->SetSaveBuffers(true);
screen->ImageTransitionScene(true); screen->ImageTransitionScene(true);
hw_postprocess.SetTonemapMode(level.info ? level.info->tonemap : ETonemapMode::None);
hw_ClearFakeFlat(); hw_ClearFakeFlat();
screen->mVertexData->Reset(); screen->mVertexData->Reset();
RenderState.SetVertexBuffer(screen->mVertexData); RenderState.SetVertexBuffer(screen->mVertexData);
@ -317,6 +318,7 @@ sector_t* RenderView(player_t* player)
auto RenderState = screen->RenderState(); auto RenderState = screen->RenderState();
RenderState->SetVertexBuffer(screen->mVertexData); RenderState->SetVertexBuffer(screen->mVertexData);
screen->mVertexData->Reset(); screen->mVertexData->Reset();
hw_postprocess.SetTonemapMode(level.info ? level.info->tonemap : ETonemapMode::None);
sector_t* retsec; sector_t* retsec;
if (!V_IsHardwareRenderer()) if (!V_IsHardwareRenderer())