mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-12-03 09:22:31 +00:00
- remove vid_hwgamma, force always use shader gamma
*** note to drfrag: Please don't cherry-pick this commit. Systems that do not use renderbuffers will still need this feature!
This commit is contained in:
parent
61beaeb429
commit
20c619d0a6
10 changed files with 4 additions and 200 deletions
|
@ -60,12 +60,6 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state);
|
|||
|
||||
extern bool vid_hdr_active;
|
||||
|
||||
CUSTOM_CVAR(Int, vid_hwgamma, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
if (self < 0 || self > 2) self = 2;
|
||||
if (screen != nullptr) screen->SetGamma();
|
||||
}
|
||||
|
||||
namespace OpenGLRenderer
|
||||
{
|
||||
FGLRenderer *GLRenderer;
|
||||
|
@ -282,35 +276,6 @@ void OpenGLFrameBuffer::SetVSync(bool vsync)
|
|||
glBindFramebuffer(GL_READ_FRAMEBUFFER, oldReadFramebufferBinding);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// DoSetGamma
|
||||
//
|
||||
// (Unfortunately Windows has some safety precautions that block gamma ramps
|
||||
// that are considered too extreme. As a result this doesn't work flawlessly)
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void OpenGLFrameBuffer::SetGamma()
|
||||
{
|
||||
bool useHWGamma = m_supportsGamma && ((vid_hwgamma == 0) || (vid_hwgamma == 2 && IsFullscreen()));
|
||||
if (useHWGamma)
|
||||
{
|
||||
uint16_t gammaTable[768];
|
||||
|
||||
// This formula is taken from Doomsday
|
||||
BuildGammaTable(gammaTable);
|
||||
SetGammaTable(gammaTable);
|
||||
|
||||
HWGammaActive = true;
|
||||
}
|
||||
else if (HWGammaActive)
|
||||
{
|
||||
ResetGammaTable();
|
||||
HWGammaActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -466,7 +431,7 @@ TArray<uint8_t> OpenGLFrameBuffer::GetScreenshotBuffer(int &pitch, ESSType &colo
|
|||
color_type = SS_RGB;
|
||||
|
||||
// Screenshot should not use gamma correction if it was already applied to rendered image
|
||||
gamma = 1 == vid_hwgamma || (2 == vid_hwgamma && !fullscreen) ? 1.0f : Gamma;
|
||||
gamma = 1;
|
||||
if (vid_hdr_active && fullscreen)
|
||||
gamma *= 2.2f;
|
||||
return ScreenshotBuffer;
|
||||
|
|
|
@ -24,9 +24,6 @@ public:
|
|||
void InitializeState() override;
|
||||
void Update() override;
|
||||
|
||||
// Color correction
|
||||
void SetGamma();
|
||||
|
||||
void CleanForRestart() override;
|
||||
void UpdatePalette() override;
|
||||
uint32_t GetCaps() override;
|
||||
|
|
|
@ -54,30 +54,9 @@ CUSTOM_CVAR(Bool, gl_render_precise, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
gl_seamless=self;
|
||||
}
|
||||
|
||||
CUSTOM_CVAR (Float, vid_brightness, 0.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (screen != NULL)
|
||||
{
|
||||
screen->SetGamma();
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (screen != NULL)
|
||||
{
|
||||
screen->SetGamma();
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR (Float, vid_saturation, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (screen != NULL)
|
||||
{
|
||||
screen->SetGamma();
|
||||
}
|
||||
}
|
||||
|
||||
CVAR (Float, vid_brightness, 0.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Float, vid_saturation, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR(Int, gl_satformula, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -74,8 +74,6 @@ protected:
|
|||
void SetGammaTable(uint16_t* table);
|
||||
void ResetGammaTable();
|
||||
|
||||
bool m_supportsGamma;
|
||||
|
||||
private:
|
||||
void SetFullscreenMode();
|
||||
void SetWindowedMode();
|
||||
|
|
|
@ -219,31 +219,6 @@ public:
|
|||
|
||||
EXTERN_CVAR(Float, Gamma)
|
||||
|
||||
CUSTOM_CVAR(Float, rgamma, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (NULL != screen)
|
||||
{
|
||||
screen->SetGamma();
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Float, ggamma, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (NULL != screen)
|
||||
{
|
||||
screen->SetGamma();
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Float, bgamma, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (NULL != screen)
|
||||
{
|
||||
screen->SetGamma();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -335,23 +310,6 @@ SystemGLFrameBuffer::SystemGLFrameBuffer(void*, const bool fullscreen)
|
|||
|
||||
[m_window setContentView:glView];
|
||||
|
||||
// Create table for system-wide gamma correction
|
||||
|
||||
CGGammaValue gammaTable[GAMMA_TABLE_SIZE];
|
||||
uint32_t actualChannelSize;
|
||||
|
||||
const CGError result = CGGetDisplayTransferByTable(kCGDirectMainDisplay, GAMMA_CHANNEL_SIZE,
|
||||
gammaTable, &gammaTable[GAMMA_CHANNEL_SIZE], &gammaTable[GAMMA_CHANNEL_SIZE * 2], &actualChannelSize);
|
||||
m_supportsGamma = kCGErrorSuccess == result && GAMMA_CHANNEL_SIZE == actualChannelSize;
|
||||
|
||||
if (m_supportsGamma)
|
||||
{
|
||||
for (uint32_t i = 0; i < GAMMA_TABLE_SIZE; ++i)
|
||||
{
|
||||
m_originalGamma[i] = static_cast<uint16_t>(gammaTable[i] * 65535.0f);
|
||||
}
|
||||
}
|
||||
|
||||
assert(frameBuffer == nullptr);
|
||||
frameBuffer = this;
|
||||
|
||||
|
@ -431,31 +389,6 @@ void SystemGLFrameBuffer::SwapBuffers()
|
|||
[[NSOpenGLContext currentContext] flushBuffer];
|
||||
}
|
||||
|
||||
void SystemGLFrameBuffer::SetGammaTable(uint16_t* table)
|
||||
{
|
||||
if (m_supportsGamma)
|
||||
{
|
||||
CGGammaValue gammaTable[GAMMA_TABLE_SIZE];
|
||||
|
||||
for (uint32_t i = 0; i < GAMMA_TABLE_SIZE; ++i)
|
||||
{
|
||||
gammaTable[i] = static_cast<CGGammaValue>(table[i] / 65535.0f);
|
||||
}
|
||||
|
||||
CGSetDisplayTransferByTable(kCGDirectMainDisplay, GAMMA_CHANNEL_SIZE,
|
||||
gammaTable, &gammaTable[GAMMA_CHANNEL_SIZE], &gammaTable[GAMMA_CHANNEL_SIZE * 2]);
|
||||
}
|
||||
}
|
||||
|
||||
void SystemGLFrameBuffer::ResetGammaTable()
|
||||
{
|
||||
if (m_supportsGamma)
|
||||
{
|
||||
SetGammaTable(m_originalGamma);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int SystemGLFrameBuffer::GetClientWidth()
|
||||
{
|
||||
const int clientWidth = I_GetContentViewSize(m_window).width;
|
||||
|
|
|
@ -47,9 +47,6 @@ protected:
|
|||
|
||||
void UpdateColors ();
|
||||
|
||||
Uint16 m_origGamma[3][256];
|
||||
bool m_supportsGamma;
|
||||
|
||||
static const int MIN_WIDTH = 320;
|
||||
static const int MIN_HEIGHT = 200;
|
||||
};
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
|
||||
extern IVideo *Video;
|
||||
|
||||
EXTERN_CVAR (Float, Gamma)
|
||||
EXTERN_CVAR (Int, vid_adapter)
|
||||
EXTERN_CVAR (Int, vid_displaybits)
|
||||
EXTERN_CVAR (Int, vid_maxfps)
|
||||
|
@ -250,13 +249,7 @@ SystemGLFrameBuffer::SystemGLFrameBuffer (void *, bool fullscreen)
|
|||
|
||||
GLContext = SDL_GL_CreateContext(Screen);
|
||||
if (GLContext != NULL)
|
||||
{
|
||||
m_supportsGamma = -1 != SDL_GetWindowGammaRamp(Screen,
|
||||
m_origGamma[0], m_origGamma[1], m_origGamma[2]
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_DestroyWindow(Screen);
|
||||
Screen = NULL;
|
||||
|
@ -268,8 +261,6 @@ SystemGLFrameBuffer::~SystemGLFrameBuffer ()
|
|||
{
|
||||
if (Screen)
|
||||
{
|
||||
ResetGammaTable();
|
||||
|
||||
if (GLContext)
|
||||
{
|
||||
SDL_GL_DeleteContext(GLContext);
|
||||
|
@ -280,22 +271,6 @@ SystemGLFrameBuffer::~SystemGLFrameBuffer ()
|
|||
}
|
||||
|
||||
|
||||
void SystemGLFrameBuffer::SetGammaTable(uint16_t *tbl)
|
||||
{
|
||||
if (m_supportsGamma)
|
||||
{
|
||||
SDL_SetWindowGammaRamp(Screen, &tbl[0], &tbl[256], &tbl[512]);
|
||||
}
|
||||
}
|
||||
|
||||
void SystemGLFrameBuffer::ResetGammaTable()
|
||||
{
|
||||
if (m_supportsGamma)
|
||||
{
|
||||
SDL_SetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]);
|
||||
}
|
||||
}
|
||||
|
||||
bool SystemGLFrameBuffer::IsFullscreen ()
|
||||
{
|
||||
return (SDL_GetWindowFlags (Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0;
|
||||
|
|
|
@ -357,7 +357,6 @@ SystemBaseFrameBuffer::SystemBaseFrameBuffer(void *hMonitor, bool fullscreen) :
|
|||
|
||||
HDC hDC = GetDC(Window);
|
||||
|
||||
m_supportsGamma = !!GetDeviceGammaRamp(hDC, (void *)m_origGamma);
|
||||
ReleaseDC(Window, hDC);
|
||||
}
|
||||
|
||||
|
@ -369,7 +368,6 @@ SystemBaseFrameBuffer::SystemBaseFrameBuffer(void *hMonitor, bool fullscreen) :
|
|||
|
||||
SystemBaseFrameBuffer::~SystemBaseFrameBuffer()
|
||||
{
|
||||
ResetGammaTable();
|
||||
if (!m_Fullscreen) SaveWindowedPos();
|
||||
|
||||
ShowWindow (Window, SW_SHOW);
|
||||
|
@ -382,32 +380,6 @@ SystemBaseFrameBuffer::~SystemBaseFrameBuffer()
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void SystemBaseFrameBuffer::ResetGammaTable()
|
||||
{
|
||||
if (m_supportsGamma)
|
||||
{
|
||||
HDC hDC = GetDC(Window);
|
||||
SetDeviceGammaRamp(hDC, (void *)m_origGamma);
|
||||
ReleaseDC(Window, hDC);
|
||||
}
|
||||
}
|
||||
|
||||
void SystemBaseFrameBuffer::SetGammaTable(uint16_t *tbl)
|
||||
{
|
||||
if (m_supportsGamma)
|
||||
{
|
||||
HDC hDC = GetDC(Window);
|
||||
SetDeviceGammaRamp(hDC, (void *)tbl);
|
||||
ReleaseDC(Window, hDC);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
@ -30,12 +30,8 @@ protected:
|
|||
|
||||
void PositionWindow(bool fullscreen, bool initialcall = false);
|
||||
|
||||
void ResetGammaTable();
|
||||
void SetGammaTable(uint16_t * tbl);
|
||||
|
||||
float m_Gamma, m_Brightness, m_Contrast;
|
||||
uint16_t m_origGamma[768];
|
||||
bool m_supportsGamma;
|
||||
bool m_Fullscreen = false;
|
||||
char m_displayDeviceNameBuffer[32/*CCHDEVICENAME*/]; // do not use windows.h constants here!
|
||||
char *m_displayDeviceName;
|
||||
|
|
|
@ -743,7 +743,6 @@ OptionMenu "VideoOptions" protected
|
|||
Slider "$DSPLYMNU_BRIGHTNESS", "vid_brightness", -0.8,0.8, 0.05,2
|
||||
Slider "$DSPLYMNU_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1
|
||||
Slider "$DSPLYMNU_SATURATION", "vid_saturation", -3.0, 3.0, 0.25, 2
|
||||
Option "$DSPLYMNU_HWGAMMA", "vid_hwgamma", "HWGammaModes"
|
||||
StaticText " "
|
||||
Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff"
|
||||
Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn"
|
||||
|
@ -2039,13 +2038,6 @@ OptionValue "FilterModes"
|
|||
4, "$OPTVAL_TRILINEAR"
|
||||
}
|
||||
|
||||
OptionValue "HWGammaModes"
|
||||
{
|
||||
0, "$OPTVAL_ON"
|
||||
1, "$OPTVAL_OFF"
|
||||
2, "$OPTVAL_FULLSCREENONLY"
|
||||
}
|
||||
|
||||
OptionValue "TonemapModes"
|
||||
{
|
||||
0, "$OPTVAL_OFF"
|
||||
|
|
Loading…
Reference in a new issue