Skip to content

RENDERER: Remove hardware gamma control. - #1143

Open
dsvensson wants to merge 4 commits into
QW-Group:masterfrom
qw-ctf:remove-vid-hwgammacontrol
Open

RENDERER: Remove hardware gamma control.#1143
dsvensson wants to merge 4 commits into
QW-Group:masterfrom
qw-ctf:remove-vid-hwgammacontrol

Conversation

@dsvensson

Copy link
Copy Markdown
Collaborator

Hardware gamma (vid_hwgammacontrol) sets the display gamma ramp via SDL_SetWindowGammaRamp, which SDL 3.x deprecates/removes. The concept is also being phased out at the OS level — notably Wayland has no equivalent, so it was already a no-op for many Linux users. This removes the feature and everything that only existed to serve it, leaving software gamma (applied in the post-process shader) as the single path.

Removed

  • vid_hwgammacontrol and the gamma-ramp engine (VID_SetDeviceGammaRamp), including the never-compiled X11/XF86VidMode fallback.
  • Cvars that only fed the hardware ramp: gl_hwblend, vid_hwgamma_fps, vid_gamma_workaround.
  • The -nohwgamma command-line flag, Ruleset_AllowNoHardwareGamma, and the related help documentation.

Notes

  • With gl_hwblend gone, the view blend (damage/powerup/water flashes) is now gated on vid_software_palette: the post-process shader applies it when software palette is on, R_PolyBlend draws the quad when off. No visible change at default gamma/contrast.
  • vid_software_palette now defaults to 1 on all platforms (macOS previously relied on hardware gamma), so gamma correction works everywhere by default.

dsvensson and others added 4 commits June 19, 2026 01:22
Preparation for removing vid_hwgammacontrol (it relies on
SDL_SetWindowGammaRamp, which SDL3 removes). With hardware gamma on its
way out, vid_hwgamma_enabled is effectively always false, so collapse
every consumer to its software path:

- Delete V_UpdatePalette() (it only ever built and applied the hardware
  gamma ramp) and the ramps[] buffer, and drop its call site.
- Delete applyHWGamma() and its screenshot call sites. Gamma now lives in
  the framebuffer via the post-process shader, so screenshots capture it
  without a manual ramp pass.
- Apply the view blend through the post-process palette shader when
  vid_software_palette is enabled (GLM frameConstants.v_blend / GLC
  blend_values) and gate R_PolyBlend on vid_software_palette so the blend
  is applied exactly once instead of being double-applied.
- Drop the now-constant vid_hwgamma_enabled branches in the brighten and
  screen-clear paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deletes the now-unreachable hardware gamma implementation. It relied on
SDL_SetWindowGammaRamp (removed in SDL3) and an X11/XF86VidMode fallback
that was never even compiled (X11_GAMMA_WORKAROUND is undefined). Software
gamma via the post-process shader (vid_software_palette) is the path that
remains.

Removed from vid_sdl2.c:
- VID_SetDeviceGammaRamp[Real], VID_RestoreSystemGamma,
  VID_X11_GetGammaRampSize and all #ifdef X11_GAMMA_WORKAROUND blocks
  (focus-lost/gained, shutdown, reload, sysramps, xf86vmode include).
- The vid_hwgammacontrol and vid_gamma_workaround cvars and the
  vid_hwgamma_enabled flag.

Removed elsewhere:
- gl_hwblend and vid_hwgamma_fps cvars (only fed the hardware ramp).
- glConfig.gammacrap (tr_types.h) and the VID_SetDeviceGammaRamp /
  vid_hwgamma_enabled declarations (vid.h).
- The -nohwgamma command-line parameter and Ruleset_AllowNoHardwareGamma,
  plus the smackdown lock that forced vid_hwgammacontrol to "2".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drops the vid_hwgammacontrol, vid_hwgamma_fps and gl_hwblend variable
entries and the -nohwgamma command-line parameter, and updates the
remaining gamma docs (-oldgamma, vid_software_palette and its
vid_framebuffer_palette alias) so they no longer reference the removed
hardware gamma path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
macOS defaulted vid_software_palette to 0 because it relied on hardware
gamma (vid_hwgammacontrol "2") for gamma correction. With the hardware
gamma path removed, the post-process shader is the only gamma mechanism,
so enable it by default everywhere instead of leaving macOS without gamma.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dsvensson
dsvensson requested a review from ciscon June 19, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants