Skip to content

feat(hle): the title's gamma ramp is applied at present - #112

Merged
phobos665 merged 1 commit into
mainfrom
title/constantine-parity
Nov 2, 2026
Merged

phobos665 merged 1 commit into
mainfrom
title/constantine-parity

Conversation

@phobos665

Copy link
Copy Markdown
Owner

D3DDevice_SetGammaRamp was lifted and did nothing: the console applies the ramp in the DAC as each frame is scanned out, so nothing drawn ever carries it, and no replacement put it anywhere. It is now replaced, and the ramp (the Xbox's three 256-byte tables) is looked up per channel in the display resolve (d3d8_display_set_gamma), as a 256x1 texture read only when the ramp is not the identity.

Constantine sets identity ramps at its default brightness, so its picture is unchanged there; its Brightness option now takes effect. Not yet seen on screen with a non-identity ramp: MoltenVK's swap chain cannot be read back to check it on a Mac.

D3DDevice_SetGammaRamp was lifted and did nothing: the console applies
the ramp in the DAC as each frame is scanned out, so nothing drawn ever
carries it, and no replacement put it anywhere. It is now replaced, and
the ramp (the Xbox's three 256-byte tables) is looked up per channel in
the display resolve (d3d8_display_set_gamma), as a 256x1 texture read
only when the ramp is not the identity.

Constantine sets identity ramps at its default brightness, so its
picture is unchanged there; its Brightness option now takes effect.
Not yet seen on screen with a non-identity ramp: MoltenVK's swap chain
cannot be read back to check it on a Mac.
@phobos665
phobos665 merged commit 1fc8ff4 into main Nov 2, 2026
5 of 7 checks passed
@phobos665
phobos665 deleted the title/constantine-parity branch November 2, 2026 09:25
phobos665 added a commit that referenced this pull request Nov 2, 2026
Since #112, every title on a Vulkan host (macOS, Linux, Android) has
shown a black window. Windows on D3D11 is unaffected.

## Cause

#112 gave the display resolve a second texture, the title's gamma ramp
at `t10`. The resolve is the draw that copies each frame to the screen.

The Vulkan backend has one descriptor set, and it lists exactly the
texture slots the renderer binds: `t0`–`t3`, `t8` and `t9`.
`build_pipeline` refuses any shader that uses a slot outside that list,
so the shader gets no pipeline and its draws are skipped. That happened
to the resolve on every frame, whether or not the title sets a gamma
ramp, because the shader declares `t10` either way.

The log reported it once per run: `[RHI] vulkan: a shader uses binding
26, which the descriptor set does not declare`.

## Fix

Add slot 10 to `g_tex_slots`. The comment above the list now says that a
new slot must be added there at the same time as it is used in a shader.

## How it was found and checked

Max Payne went black when its toolkit pin moved past #112.
- **With the fix:** the warning no longer appears, Max Payne runs at 60
fps with its gamma ramp applied, and the window shows the game again.
- **Why it went unnoticed:** the frame dumps used in testing
(`RECOMP_HLE_D3D8_DUMP`) read the back buffer before the resolve, so
they looked normal. The "MoltenVK swap-chain readback returns black"
seen while working on #112 was very likely this bug too.

Not checked: Linux and Android. They take the same code path.
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.

1 participant