mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-19 03:53:03 +01:00
Co-authored-by: DrPerkyLegit <116128211+DrPerkyLegit@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Anaël <60509176+Bakoubak@users.noreply.github.com> Reviewed-on: https://git.neolegacy.dev/neoStudiosLCE/neoLegacy/pulls/4205
114 lines
3.2 KiB
C++
114 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include <d3d11.h>
|
|
#include <vector>
|
|
|
|
enum class PostProcessType
|
|
{
|
|
FXAA,
|
|
Gamma
|
|
};
|
|
|
|
enum class PostProcessStage
|
|
{
|
|
BeforeNativeHud,
|
|
AfterNativeHud,
|
|
AfterIggy
|
|
};
|
|
|
|
class PostProcesser
|
|
{
|
|
public:
|
|
static PostProcesser& GetInstance()
|
|
{
|
|
static PostProcesser instance;
|
|
return instance;
|
|
}
|
|
|
|
void Init();
|
|
void Apply() const;
|
|
void SetViewport(const D3D11_VIEWPORT& viewport);
|
|
void ResetViewport();
|
|
void CopyBackbuffer();
|
|
void ApplyFromCopied() const;
|
|
void Cleanup();
|
|
void SetGamma(float gamma);
|
|
float GetGamma() const { return m_gamma; }
|
|
void SetFXAAStrength(float strength);
|
|
void RegisterPass(PostProcessType type, PostProcessStage stage, bool enabled = true);
|
|
void SetPassEnabled(PostProcessType type, bool enabled);
|
|
void RunStage(PostProcessStage stage);
|
|
PostProcesser(const PostProcesser&) = delete;
|
|
PostProcesser& operator=(const PostProcesser&) = delete;
|
|
|
|
private:
|
|
PostProcesser();
|
|
~PostProcesser();
|
|
|
|
static bool IsRunningUnderWine();
|
|
void ApplyFXAA(const D3D11_VIEWPORT& viewport);
|
|
void ApplyGamma(const D3D11_VIEWPORT& viewport);
|
|
bool DrawFullscreen(ID3D11PixelShader* pixelShader,
|
|
ID3D11ShaderResourceView* source,
|
|
ID3D11RenderTargetView* target,
|
|
const D3D11_VIEWPORT& outputViewport,
|
|
const D3D11_VIEWPORT& sourceViewport,
|
|
float sourceWidth,
|
|
float sourceHeight,
|
|
float directionX,
|
|
float directionY,
|
|
float gamma,
|
|
float threshold,
|
|
float fxaaStrength) const;
|
|
|
|
struct RegisteredPass
|
|
{
|
|
PostProcessType type;
|
|
PostProcessStage stage;
|
|
bool enabled;
|
|
};
|
|
|
|
struct PostProcessCBData
|
|
{
|
|
float gamma;
|
|
float inverseWidth;
|
|
float inverseHeight;
|
|
float threshold;
|
|
float uvOffsetX;
|
|
float uvOffsetY;
|
|
float uvScaleX;
|
|
float uvScaleY;
|
|
float directionX;
|
|
float directionY;
|
|
float fxaaStrength;
|
|
float padding;
|
|
};
|
|
|
|
ID3D11Texture2D* m_pGammaOffscreenTex = nullptr;
|
|
ID3D11ShaderResourceView* m_pGammaOffscreenSRV = nullptr;
|
|
ID3D11RenderTargetView* m_pGammaOffscreenRTV = nullptr;
|
|
ID3D11VertexShader* m_pGammaVS = nullptr;
|
|
ID3D11PixelShader* m_pGammaPS = nullptr;
|
|
ID3D11PixelShader* m_pFXAAPS = nullptr;
|
|
ID3D11Buffer* m_pGammaCB = nullptr;
|
|
ID3D11SamplerState* m_pGammaSampler = nullptr;
|
|
ID3D11SamplerState* m_pPostProcessSampler = nullptr;
|
|
ID3D11RasterizerState* m_pGammaRastState = nullptr;
|
|
ID3D11DepthStencilState* m_pGammaDepthState = nullptr;
|
|
ID3D11BlendState* m_pGammaBlendState = nullptr;
|
|
|
|
bool m_initialized = false;
|
|
float m_gamma = 1.0f;
|
|
float m_fxaaStrength = 0.75f;
|
|
bool m_wineMode = false;
|
|
D3D11_VIEWPORT m_customViewport;
|
|
bool m_useCustomViewport = false;
|
|
UINT m_gammaTexWidth = 0;
|
|
UINT m_gammaTexHeight = 0;
|
|
std::vector<RegisteredPass> m_registeredPasses;
|
|
|
|
static const char* g_gammaVSCode;
|
|
static const char* g_gammaPSCode;
|
|
static const char* g_fxaaPSCode;
|
|
};
|