Skip to content

Vulkan: remove stale compile-time feature flags (b004) - #299

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

Vulkan: remove stale compile-time feature flags (b004)#299
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/feature-flag-cleanup-b004

Conversation

@cursor

@cursor cursor Bot commented Aug 10, 2026

Copy link
Copy Markdown

Summary

Reduces renderer technical debt by removing compile-time feature flags and dead branches that are permanently on (or never defined) in the Vulkan-only build.

Branch: cursor/feature-flag-cleanup-b004main

Flags removed

Flag Why safe
USE_VBO_GRID Never defined; tr_local.h documents SF_GRID stays off the static VBO path
USE_TESS_NEEDS_NORMAL / USE_TESS_NEEDS_ST2 Commented-out defines; guarded fields never compiled
USE_VK_PBR dead #else PBR always enabled; non-PBR fallback paths unreachable
USE_DEDICATED_ALLOCATION #ifndef Macro always defined in non-debug vk.h
USE_VBO, USE_FOG_COLLAPSE, USE_VULKAN, VK_CUBEMAP, VK_PBR_BRDFLUT guards Permanently defined for Vulkan renderer; runtime toggles remain via r_vbo, r_pbr, etc.
OpenGL-era USE_VULKAN #else stubs Vulkan-only renderer; legacy GL branches dead

Tooling

  • scripts/tools/unwrap_use_vk_pbr.py — unwrap dead PBR #else branches
  • scripts/tools/unwrap_compile_flags.py — repeatable unwrap for always-on macros
  • tests/scripts/test_stale_compile_flags.sh — blocks reintroduced stale guards

Test plan

  • tests/scripts/test_vulkan_regression_source_guards.sh
  • tests/scripts/test_stale_compile_flags.sh (new)
  • tests/scripts/test_cpp20_sources.sh
  • Preprocessor balance scan across renderers/
  • ./scripts/smoke_test.sh (full build; prior runs blocked by unrelated FreeUSD FetchContent env issue in cloud VM)

Not changed (low confidence)

  • GLSL shader templates still use -DUSE_VK_PBR for variant generation
  • Optional CMake gates: USE_VULKAN_RTX, USE_EXPERIMENTAL_RENDERERS, USE_VUDA, USE_IMGUI
Open in Web View Automation 

cursoragent and others added 3 commits August 10, 2026 10:05
- 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>
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