Skip to content

Remove the dead legacy font fragment shader #980

Description

@coghex

Background

Engine.Graphics.Vulkan.ShaderCode exports fontFragmentShaderCode, an
18-line GLSL fragment shader documented as -- | Legacy font fragment shader (non-SDF, kept for compatibility). It has no consumers:

$ rg -n 'fontFragmentShaderCode' src/ app/ test/ test-headless/ scripts/ tools/
src/Engine/Graphics/Vulkan/ShaderCode.hs:6:    , fontFragmentShaderCode
src/Engine/Graphics/Vulkan/ShaderCode.hs:69:fontFragmentShaderCode ∷ BS.ByteString
src/Engine/Graphics/Vulkan/ShaderCode.hs:70:fontFragmentShaderCode = [frag|

The module's other seven shader exports each have a real consumer:
Engine/Graphics/Font/Draw.hs for the three font shaders,
Engine/Graphics/Vulkan/Pipeline/Bindless.hs for the four bindless shaders.
The font pipeline builder hard-codes the SDF shader —
Font/Draw.hs:135, fragModule ← createShaderModule device zero { code = fontSDFFragmentShaderCode } Nothing — and both the world pipeline
(createFontPipeline, line 111) and the UI pipeline (line 324) reach it.
No branch, flag, or config can select the legacy shader.

The "compatibility" it claims is with the non-SDF font atlas path, which is
itself unreachable: every font load in the engine goes through loadSDFFont
(Engine/Scripting/Lua/Message/Texture.hs:313), the sole implementation
behind the Lua loadFont registration, which also discards the requested
size. Engine.Graphics.Font.Load.loadFont and
Engine.Graphics.Font.Atlas.generateFontAtlas have no callers.

Because [frag| … |] is a Template Haskell quasi-quote that runs glslang at
compile time, the dead shader is recompiled on every rebuild of the module.
Because the binding is exported, GHC's unused-binding warning cannot see it,
which is why -Wall -Werror has never flagged it.

Requirements

  1. fontFragmentShaderCode no longer exists in
    src/Engine/Graphics/Vulkan/ShaderCode.hs — not the binding, not its
    Haddock, not its entry in the module export list.
  2. The module's remaining seven shader exports are unchanged and each still
    has its existing consumer.
  3. The change touches exactly one file, and the library and executable build
    warning-clean.
  4. Font rendering behaviour is unchanged: the SDF fragment shader remains the
    only fragment shader either font pipeline creates.

Acceptance

rg -n 'fontFragmentShaderCode' src/ app/ test/ test-headless/   # no matches
cabal build all

Out of scope

  • The unreachable non-SDF font atlas path (Font/Load.hs's loadFont,
    Font/Atlas.hs's generateFontAtlas and renderGlyphWithMetrics,
    Font/STB.hs's renderSTBGlyph, and the cbits/font_stb.c renderer behind
    them). Verified unreachable, but removing it cascades through the FFI layer
    and belongs with the dead-export cleanup (report CH-54), not here.
  • The UniformBufferObject duplication across this module's other GLSL blocks
    (report CH-35, blocked on Give the bindless texture-array and handle-table sizes a single definition #975).
  • Any change to SDF font rendering.

Related

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomersreviewed:approveCLI review verdict: approvetech-debtCode cleanup: stale comments, dead code, diverged duplicates, inconsistencies

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions