Skip to content

opengl: accept the fixed-function caps a GL 1.x renderer turns off - #2995

Open
KingProNoob2 wants to merge 1 commit into
seedds:mainfrom
KingProNoob2:opengl-fixed-function-caps
Open

KingProNoob2 wants to merge 1 commit into
seedds:mainfrom
KingProNoob2:opengl-fixed-function-caps

Conversation

@KingProNoob2

Copy link
Copy Markdown

What and why

A renderer written for GL 1.x puts the fixed-function pipeline's state in order before its GLSL draws, so it disables the lights, the lighting model, the alpha test, the fog and the texture-coordinate generators first. cap_set keeps only the caps a draw reads, so it reported each of them once as a [RED] glDisable(…) not implemented line — seven lines before the first draw, with nothing wrong in the picture:

[dm] [gl] [RED] glDisable(0x4000) not implemented            (LIGHT0)
[dm] [gl] [RED] glDisable(0xb50) not implemented             (LIGHTING)
[dm] [gl] [RED] glDisable(0xbc0) not implemented             (ALPHA_TEST)
[dm] [gl] [RED] glDisable(0xc60) … glDisable(0xc63) not implemented   (TEXTURE_GEN_S/T/R/Q)

With a program bound the shader decides the lighting, whether a fragment is discarded and where its texture coordinates come from, so none of those caps can change a draw. cap_set now accepts them (GL_LIGHTING, GL_LIGHT0–7, GL_ALPHA_TEST, GL_FOG, GL_TEXTURE_GEN_S/T/R/Q, GL_COLOR_MATERIAL, GL_NORMALIZE); the layer keeps no fixed-function state for them to set.

New test, t_gl_imports / test_fixed_function_caps: it enables and disables each cap and checks that every piece of state a draw reads is exactly as it was, and that a cap the layer does keep (GL_BLEND) still sets its state.

Reference entry: Fixed-function caps a GL 1.x renderer turns off (the symptom index was regenerated with dm/tools/docs_symptoms.py).

Checked

  • Tests: make -C dm/gfx/tests GAME=<id> check_t_gl_imports — passes in its GPU, --stubs and --cpu forms (202 shared entries, the new case among them). python3 -m unittest dm/tools/tests/test_docs.py — passes. The whole dm/tools/tests suite runs with 3 errors in test_shader_toolchain_cache (mesh target selection); they fail identically with this change stashed, so they are pre-existing on this machine (macOS 27.3, Python 3.15) and not from this change.
  • Lint: dm/tools/lint_c.py compdb && tidy with Homebrew LLVM 23.1.5 reports no finding from this change. The one finding it puts above the baseline (t_gl_imports.m:705, bugprone-suspicious-memory-comparison) is in the upload test that 501df0e2 (opengl/textures: expand RED and RG uploads) added, which is already on main.
  • Games run, with title ID and version: Fate/stay night REMASTERED 010023301E41C000 v589824, a GL 3.1 renderer through EGL. Four minutes from the disclaimer through the prologue's first scene to frame 13,500: 0 [RED] lines (7 before the change), 10,500–11,700 draws per 300 frames and 19 pipelines as before, 1.95 → 2.03 GB footprint, 250–260 MB of Metal allocations; the in-game menu, its save screen and the backlog render.
  • For a change every GL game uses: scripts/regress.py impact main..HEAD reports 0 games affected, 4 not affected (the profiles with a usage manifest are NVN games) and 184 unknown — every GL profile (Balatro, Digimon Story Cyber Sleuth, DOOM 3, Mega Man Legacy Collection, Well Dweller) has no manifest. regress.py check --games 0100217023F6C000 010029D00E740000 (the two GL profiles with a smoke.tsv route) could not run here: neither game's Mac build is on this machine. Please run it if you have those builds. Beyond the new test the change cannot alter a draw: it only stops logging caps whose state the layer never kept.
  • Devices and OS: MacBook Air, Apple M4, macOS 27.3 (Apple silicon, Metal).
  • Measurements: none, and none expected: the change does not touch the GPU path; the [gl] frame draw and pipeline counts and the memory lines are unchanged run to run.

Docs

  • The finding is in docs/reference/rendering.md (Fixed-function caps a GL 1.x renderer turns off) and python3 dm/tools/docs_symptoms.py was run
  • No game files, keys or data extracted from a game in the change or the attachments

A renderer written for GL 1.x puts the fixed-function pipeline's state in
order before its shader draws, so it enables and disables the lights, the
lighting model, the alpha test, the fog and the texture-coordinate
generators first. cap_set keeps only the caps a draw reads, so it reported
each of those once as a `[RED] glDisable(…) not implemented` line: seven
lines before the first draw, with nothing wrong in the picture.

With a program bound the shader decides the lighting, whether a fragment is
discarded and where its texture coordinates come from, so none of those
caps can change a draw. cap_set now accepts them; the layer keeps no
fixed-function state for them to set.

t_gl_imports (test_fixed_function_caps) enables and disables each of them
and checks that the state a draw reads is exactly as it was, and that a cap
the layer does keep still sets its state. The GPU and --cpu forms pass.

Checked: a four-minute run of a GL 1.x renderer whose draws are all GLSL
(the prologue of a visual novel) with no [RED] line, and its save and
backlog screens. Not checked: a game that draws through the fixed-function
pipeline, which this layer does not implement at all.
@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) opengl NVIDIA's desktop OpenGL on Metal (dm/gfx/gl) docs Documentation labels Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) opengl NVIDIA's desktop OpenGL on Metal (dm/gfx/gl)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant