Skip to content

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

Draft
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/feature-flag-cleanup-489e
Draft

Vulkan: remove stale compile-time feature flags and dead branches#297
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/feature-flag-cleanup-489e

Conversation

@cursor

@cursor cursor Bot commented Aug 9, 2026

Copy link
Copy Markdown

Summary

Reduces technical debt by removing stale compile-time feature flags and dead conditional branches in the Vulkan renderer. Behavior of the active path is preserved.

Flags removed

Flag Why safe to delete
USE_VBO_GRID Never defined; SF_GRID intentionally stays off the VBO path (comment in tr_local.h)
USE_TESS_NEEDS_NORMAL / USE_TESS_NEEDS_ST2 Commented out and never defined
USE_VK_PBR dead #else branches Always #define USE_VK_PBR in tr_local.h; legacy non-PBR shader module path removed
USE_DEDICATED_ALLOCATION dead #ifndef Always #define USE_DEDICATED_ALLOCATION in vk.h
USE_VULKAN dead #ifndef branches Vulkan-only renderer tree; OpenGL fallback stubs deleted
USE_VBO / USE_FOG_COLLAPSE / USE_VK_PBR one-sided #ifdef guards Always defined; guards unwrapped to reduce noise

Tooling

  • scripts/tools/unwrap_use_vk_pbr.py — unwrap #ifdef USE_VK_PBR / #else blocks (cherry-picked)
  • scripts/tools/unwrap_compile_flags.py — generic unwrap for always-on flags

Stats

~3,500 lines removed across 187 files.

Behavioral parity checks

  • tests/scripts/test_vulkan_regression_source_guards.sh — PASS
  • tests/scripts/test_cpp20_sources.sh — PASS
  • Preprocessor #if/#endif balance scan across renderers/ — clean
  • Zero remaining USE_VBO_GRID, USE_TESS_NEEDS, #ifndef USE_VK_PBR, #ifndef USE_VULKAN in renderers/
  • Full engine build — blocked in this environment by FreeUSD FetchContent (unrelated to this diff)

Test plan

  • ./scripts/bootstrap.sh engine
  • ./scripts/smoke_test.sh ./build-vk-Release
  • Manual: client with mod data if applicable

Candidates deferred (low confidence)

  • #ifdef USE_VK_PBR in GLSL shader templates (gen_frag.tmpl, gen_vert.tmpl) — still used for shader variant compilation
  • Runtime cvars (r_forwardPlus, r_rtx, etc.) — user-tunable, not compile-time flags
  • Optional CMake gates (USE_VULKAN_RTX, USE_EXPERIMENTAL_RENDERERS) — still meaningful build toggles
Open in Web View Automation 

cursoragent and others added 3 commits August 9, 2026 10:02
- 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>
…COLLAPSE, USE_VK_PBR)

Remove dead OpenGL fallback branches and one-sided preprocessor guards for
flags that are permanently enabled in the Vulkan renderer. Adds
scripts/tools/unwrap_compile_flags.py for repeatable cleanup.

Fix stray #endif in vk_object_id.c after guard removal.
Restore explicit #define USE_VULKAN in tr_common.h.

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