Skip to content

Vulkan: remove stale compile-time feature flags and dead branches - #301

Draft
cursor[bot] wants to merge 7 commits into
mainfrom
cursor/feature-flag-cleanup-b0c8
Draft

Vulkan: remove stale compile-time feature flags and dead branches#301
cursor[bot] wants to merge 7 commits into
mainfrom
cursor/feature-flag-cleanup-b0c8

Conversation

@cursor

@cursor cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

Summary

Removes stale compile-time feature guards in the Vulkan renderer where rollout is complete: macros are unconditionally defined in tr_local.h (or were never defined), so the #else / legacy paths were dead code.

Branch: cursor/feature-flag-cleanup-b0c8main

Flags removed / unwrapped

Flag Why safe
USE_VK_PBR, VK_CUBEMAP, VK_PBR_BRDFLUT Hard #define in tr_local.h; PBR is the only Vulkan shading path
USE_VBO, USE_FOG_COLLAPSE Hard #define in tr_local.h; non-VBO / no-fog-collapse paths unused
USE_VULKAN Vulkan renderer module is always built with USE_VULKAN; guards only added noise
USE_DEDICATED_ALLOCATION #ifndef legacy fallbacks; dedicated allocation is always enabled
USE_VBO_GRID, USE_TESS_NEEDS_* Macros commented out / never defined; guards were dead
USE_PMLIGHT Never defined anywhere; shadow code always used lightDir
#if 1 blocks (tr_curve.c, tr_shader.c) Always-on tessellation/stage paths with no toggle

Guardrails added

  • tests/scripts/test_stale_compile_flags.sh — blocks reintroduced always-on guards and orphan #endif
  • scripts/tools/unwrap_compile_flags.py / unwrap_use_vk_pbr.py — maintenance helpers
  • Wired into scripts/smoke_test.sh

Regression fixes

  • Removed orphan USE_VULKAN #endif from contract headers after unwrap
  • Restored correct #ifndef NDEBUG / #endif pairing in tr_backend.c weapon temporal resolve

Test plan

  • ./tests/scripts/test_stale_compile_flags.sh
  • cmake --build build-vk-Release --target idtech3_vulkan_x86 (Vulkan renderer sources compile; full target blocked by unrelated FreeUSD API drift)
  • ./scripts/smoke_test.sh ./build-vk-Release (full smoke — needs complete engine link)
  • Manual client/server with mod data if applicable
  • Manifest updated if sources moved or CMake gates changed (docs/ENGINE_MODULE_MANIFEST.md) — N/A (no CMake gate changes)
  • ./scripts/ci/audit_unconditional_sources.sh — N/A
Open in Web View Automation 

cursoragent and others added 7 commits August 12, 2026 10:08
- USE_VBO_GRID: never defined (SF_GRID deliberately off VBO path per tr_local.h);
  remove dead grid VBO estimate/queue/pack paths in vk_vbo.c and tr_surface.c.
- USE_TESS_NEEDS_NORMAL / USE_TESS_NEEDS_ST2: commented-out defines with no
  struct fields; remove preprocessor guards that only wrapped always-on paths.
- USE_VK_PBR dead #else: unwrap non-PBR shader module init/destroy fallbacks in
  vk_shader_modules.c and vk_shutdown.c; flatten VK_CUBEMAP/VK_PBR_BRDFLUT nesting
  in tr_local.h; unwrap reactive/object-id storage descriptor (void)0 else stubs.
- USE_DEDICATED_ALLOCATION: always defined in vk.h; drop redundant #ifndef override
  in vk_instance.c.

Behavior unchanged on the active PBR/VBO/dedicated-allocation paths.

Co-authored-by: Tim Fox <timfox@outlook.com>
USE_VK_PBR is unconditionally defined in tr_local.h for the Vulkan
renderer. Remove non-PBR #else fallbacks in pipeline creation, vertex
layout, descriptor counts, and BSP/surface helpers while keeping shader
templates and runtime vk.pbrActive gating intact.

Adds scripts/tools/unwrap_use_vk_pbr.py for future cleanups.

Co-authored-by: Tim Fox <timfox@outlook.com>
Extend feature-flag cleanup beyond dead branches (USE_VBO_GRID,
USE_TESS_NEEDS_*) by unwrapping compile-time guards for macros that
are permanently defined in the Vulkan renderer:

- USE_VBO, USE_FOG_COLLAPSE, USE_VK_PBR, USE_VULKAN
- VK_CUBEMAP, VK_PBR_BRDFLUT

Adds scripts/tools/unwrap_compile_flags.py for repeatable unwrapping
and tests/scripts/test_stale_compile_flags.sh to block reintroduction
of removed guards and orphan #endif regressions.

Fixes stray preprocessor artifacts in vk_object_id.c and tr_shade.c
left after guard removal.

Co-authored-by: Tim Fox <timfox@outlook.com>
- Restore vk_vbo.c from main and delete USE_VBO_GRID/TESS blocks (not unwrap).
- Unwrap USE_VK_PBR/USE_VBO with depth-safe endif matching.
- Fix extern C guards in shadow/frame/reflection contract headers.
- Repair tr_init.c VK_CUBEMAP nesting and remove orphan USE_VULKAN endif.
- Remove stray preprocessor lines in tr_shade.c and vk_object_id.c.
- Harden unwrap_compile_flags.py endif regex (no .*$ swallowing).

Co-authored-by: Tim Fox <timfox@outlook.com>
- USE_PMLIGHT was never defined; shadow paths always used lightDir
- Unwrap always-on #if 1 tessellation/stage optimization blocks
- Extend test_stale_compile_flags.sh to block reintroduced always-on guards
- Wire stale compile-flag test into smoke_test.sh

Co-authored-by: Tim Fox <timfox@outlook.com>
Co-authored-by: Tim Fox <timfox@outlook.com>
Co-authored-by: Tim Fox <timfox@outlook.com>
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