|
| 1 | +# High Priority Items - Vulkan Renderer |
| 2 | + |
| 3 | +**Last Updated**: 2026-01-09 |
| 4 | +**Status**: Active Development |
| 5 | + |
| 6 | +This document lists all high-priority TODOs, FIXMEs, and critical issues that need to be addressed in the Vulkan renderer. Items are categorized by priority and impact. |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## 🔴 CRITICAL PRIORITY |
| 11 | + |
| 12 | +**Issues that affect stability, memory safety, or core rendering functionality. Must be fixed immediately.** |
| 13 | + |
| 14 | +### 1. Memory Leaks & Resource Cleanup |
| 15 | + |
| 16 | +#### `tr_rtx.c:105` - RTX Resource Cleanup |
| 17 | +- **Issue**: RTX renderer may not properly clean up Vulkan resources on shutdown |
| 18 | +- **Impact**: Memory leaks, resource exhaustion |
| 19 | +- **Status**: TODO - Clean up Vulkan resources if needed |
| 20 | +- **Action Required**: Implement proper cleanup in `RTX_Shutdown()` |
| 21 | + |
| 22 | +#### `rtx/vk_rtx_main.cpp:250` - RTX-Specific Resources |
| 23 | +- **Issue**: RTX-specific resources not properly cleaned up |
| 24 | +- **Impact**: Memory leaks on renderer shutdown |
| 25 | +- **Status**: TODO - Shutdown RTX-specific resources |
| 26 | +- **Action Required**: Add cleanup for acceleration structures, shader binding tables, descriptor sets |
| 27 | + |
| 28 | +#### `gltf_loader.c:178` - Descriptor Set Cleanup |
| 29 | +- **Issue**: Descriptor sets allocated but not freed |
| 30 | +- **Impact**: Descriptor pool exhaustion |
| 31 | +- **Status**: TODO - Free descriptor set |
| 32 | +- **Action Required**: Track and free descriptor sets when models are unloaded |
| 33 | + |
| 34 | +### 2. Core Rendering Functionality |
| 35 | + |
| 36 | +#### `tr_backend.c:1161` - Render Pass State |
| 37 | +- **Issue**: CRITICAL comment - Ensure main render pass is started before UI rendering |
| 38 | +- **Impact**: Rendering corruption, crashes |
| 39 | +- **Status**: Documented but needs verification |
| 40 | +- **Action Required**: Add validation to ensure render pass is active before UI rendering |
| 41 | + |
| 42 | +#### `tr_backend.c:1837` - Missing Implementation |
| 43 | +- **Issue**: TODO: implement! ZZZZZZZZZZZ (critical missing implementation) |
| 44 | +- **Impact**: Unknown - needs investigation |
| 45 | +- **Status**: Critical missing implementation |
| 46 | +- **Action Required**: Identify what functionality is missing and implement it |
| 47 | + |
| 48 | +#### `tr_font_vk.c:38` - Font Texture Creation |
| 49 | +- **Issue**: TODO - Implement proper Vulkan font texture creation |
| 50 | +- **Impact**: Font rendering may not work correctly |
| 51 | +- **Status**: Currently uses STB fallback |
| 52 | +- **Action Required**: Implement native Vulkan font texture creation |
| 53 | + |
| 54 | +### 3. Image Layout & Synchronization |
| 55 | + |
| 56 | +#### Multiple CRITICAL comments in `vk.c` - Image Layout Handling |
| 57 | +- **Locations**: Lines 6246, 8529, 8551, 8695, 8710, 8730, 8756, 8775, 8848, 8908, 9442, 9487, 9522 |
| 58 | +- **Issue**: Image layout transitions must be handled correctly to prevent corruption |
| 59 | +- **Impact**: Rendering artifacts, driver errors, crashes |
| 60 | +- **Status**: Documented with CRITICAL comments |
| 61 | +- **Action Required**: |
| 62 | + - Verify all layout transitions are correct |
| 63 | + - Add validation for layout state |
| 64 | + - Ensure proper barriers between layout transitions |
| 65 | + |
| 66 | +#### `tr_shade.c:77, 93` - ScreenMap Capture |
| 67 | +- **Issue**: CRITICAL comments about screenMap usage and capture |
| 68 | +- **Impact**: Incorrect screenMap usage can cause rendering corruption |
| 69 | +- **Status**: Documented but needs verification |
| 70 | +- **Action Required**: Ensure screenMap is only used if captured THIS frame |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## 🟠 HIGH PRIORITY |
| 75 | + |
| 76 | +**Important features or code quality issues that should be fixed soon.** |
| 77 | + |
| 78 | +### 4. Light Clustering System |
| 79 | + |
| 80 | +#### `tr_lightclusters.c:22` - Buffer Storage |
| 81 | +- **Issue**: TODO - Add Vulkan buffer storage for cluster headers and indices |
| 82 | +- **Impact**: Clustered forward+ lighting not functional |
| 83 | +- **Status**: Stub implementation |
| 84 | +- **Action Required**: |
| 85 | + 1. Declare static VkBuffer lcHeaderBuffer, lcIndexBuffer |
| 86 | + 2. Allocate buffers with VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
| 87 | + 3. Use device-local memory with staging buffer for uploads |
| 88 | + 4. Bind buffers to descriptor sets (bindings 6 and 7 per tr_lightclusters.glsl) |
| 89 | + 5. Update buffers each frame in R_BuildLightClusters() |
| 90 | + |
| 91 | +#### `tr_lightclusters.c:52, 80` - Light Binning Implementation |
| 92 | +- **Issue**: TODO - Implement full light binning (clustered/forward+) |
| 93 | +- **Impact**: Dynamic lighting performance degradation |
| 94 | +- **Status**: No-op implementation |
| 95 | +- **Action Required**: |
| 96 | + 1. Allocate/resize Vulkan buffers (see TODO above) |
| 97 | + 2. Reset cluster headers (lightOffset=0, lightCount=0 for all clusters) |
| 98 | + 3. For each dynamic light in tr.refdef.dlights: |
| 99 | + - Compute screen-space AABB of light influence |
| 100 | + - Map depth range to Z slices using logarithmic distribution |
| 101 | + - For each affected cluster (tileX, tileY, sliceZ): |
| 102 | + - Append light index to cluster's light list |
| 103 | + 4. Upload cluster data to GPU buffers via staging buffer |
| 104 | + 5. Bind buffers to shader descriptor sets for use in lighting shaders |
| 105 | + |
| 106 | +### 5. Shader System Issues |
| 107 | + |
| 108 | +#### `tr_shader.c:2616` - Modulated Add Collapse |
| 109 | +- **Issue**: TODO - Verify and fix modulated add + modulated add collapse logic |
| 110 | +- **Impact**: Visual artifacts with shaders using multiple modulated add stages |
| 111 | +- **Status**: Known issue documented |
| 112 | +- **Action Required**: |
| 113 | + - Test all combinations of modulated add blending modes |
| 114 | + - Fix collapse table if incorrect |
| 115 | + - Consider disabling multitexture collapse for problematic shaders |
| 116 | + |
| 117 | +#### `tr_sky.c:600, 608` - Sky fullClouds Field |
| 118 | +- **Issue**: TODO - Add fullClouds field to skyParms_t structure |
| 119 | +- **Impact**: Sky rendering may not correctly handle full cloud coverage |
| 120 | +- **Status**: Hardcoded to always enable full clouds |
| 121 | +- **Action Required**: |
| 122 | + 1. Add `qboolean fullClouds;` to skyParms_t typedef in tr_local.h |
| 123 | + 2. Parse fullClouds from shader files in tr_shader.c |
| 124 | + 3. Replace hardcoded (1) with shader->sky.fullClouds check in tr_sky.c |
| 125 | + |
| 126 | +### 6. Pipeline & State Management |
| 127 | + |
| 128 | +#### `tr_backend.c:1865` - Extended Dynamic State |
| 129 | +- **Issue**: TODO - Implement full support using VK_EXT_extended_dynamic_state3 |
| 130 | +- **Impact**: Pipeline recreation overhead for color mask changes |
| 131 | +- **Status**: Currently requires pipeline recreation |
| 132 | +- **Action Required**: |
| 133 | + 1. Check for VK_EXT_extended_dynamic_state3 extension support |
| 134 | + 2. Enable VK_DYNAMIC_STATE_COLOR_WRITE_MASK_EXT in pipeline creation |
| 135 | + 3. Call vkCmdSetColorWriteMaskEXT() instead of storing state |
| 136 | + 4. Alternatively, track color mask state and include it in pipeline hash/key |
| 137 | + |
| 138 | +#### `tr_surface.c:1447` - Vertex Layout Optimization |
| 139 | +- **Issue**: TODO - Use common vertex layout and avoid TESS_ST0 binding if not needed |
| 140 | +- **Impact**: Minor performance optimization |
| 141 | +- **Status**: Currently includes TESS_ST0 even when not needed |
| 142 | +- **Action Required**: Update axis pipeline to not require texture coordinates, change to `vk_bind_geometry( TESS_XYZ | TESS_RGBA0 )` |
| 143 | + |
| 144 | +### 7. Compute Scheduler |
| 145 | + |
| 146 | +#### `vk_compute_scheduler.cpp:250` - Dependency Checking |
| 147 | +- **Issue**: TODO - Implement proper dependency checking by verifying dependency jobs are completed |
| 148 | +- **Impact**: Jobs may execute out of order, causing incorrect results |
| 149 | +- **Status**: Currently assumes dependencies are resolved |
| 150 | +- **Action Required**: |
| 151 | + 1. For each dependency in internal_job->dependencies[]: |
| 152 | + - Look up dependency job in compute_scheduler.active_jobs map |
| 153 | + - Check if dependency job state is JOB_STATE_COMPLETED |
| 154 | + - If any dependency is not completed, mark dependencies_resolved = qfalse |
| 155 | + 2. Only mark job as ready when all dependencies are completed |
| 156 | + |
| 157 | +#### `vk_compute_scheduler.cpp:796, 809` - Semaphore Arrays |
| 158 | +- **Issue**: TODO - Add semaphore array to vk_compute_job_t structure |
| 159 | +- **Impact**: Cannot use semaphore synchronization for compute jobs |
| 160 | +- **Status**: Functions exist but don't store semaphores |
| 161 | +- **Action Required**: |
| 162 | + - For wait semaphores: Add VkSemaphore wait_semaphores[MAX_WAIT_SEMAPHORES], VkPipelineStageFlags wait_stages[MAX_WAIT_SEMAPHORES], uint32_t wait_semaphore_count |
| 163 | + - For signal semaphores: Add VkSemaphore signal_semaphores[MAX_SIGNAL_SEMAPHORES], uint32_t signal_semaphore_count |
| 164 | + - Store semaphores in arrays when functions are called |
| 165 | + - Use arrays in vkQueueSubmit() when submitting the job |
| 166 | + |
| 167 | +### 8. GPU Timing & Profiling |
| 168 | + |
| 169 | +#### `vk_sync.c:247, 252, 257` - GPU Timing Queries |
| 170 | +- **Issue**: TODO - Implement GPU timing queries for performance profiling |
| 171 | +- **Impact**: Cannot measure GPU performance, difficult to optimize |
| 172 | +- **Status**: Stub implementation |
| 173 | +- **Action Required**: |
| 174 | + 1. Allocate query pool if not already created (one per frame in flight) |
| 175 | + 2. Reset query pool: vkCmdResetQueryPool() or VK_EXT_host_query_reset |
| 176 | + 3. Record begin timestamp: vkCmdWriteTimestamp(vk.cmd->command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, query_pool, query_index) |
| 177 | + 4. Record end timestamp: vkCmdWriteTimestamp(vk.cmd->command_buffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, query_pool, query_index) |
| 178 | + 5. Retrieve timestamps: vkGetQueryPoolResults(device, query_pool, query_index, 2, sizeof(uint64_t)*2, timestamps, sizeof(uint64_t), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT) |
| 179 | + 6. Calculate delta: (end_timestamp - begin_timestamp) * timestamp_period |
| 180 | + 7. Convert to milliseconds: delta_ns / 1e6 |
| 181 | + |
| 182 | +--- |
| 183 | + |
| 184 | +## 🟡 MEDIUM PRIORITY |
| 185 | + |
| 186 | +**Optional features or improvements that can be addressed when time permits.** |
| 187 | + |
| 188 | +### 9. Ray Tracing Integration |
| 189 | + |
| 190 | +#### `vk_raytracing.cpp:28, 39, 50` - RTX Renderer Integration |
| 191 | +- **Issue**: TODO - Call RTX renderer functions when fully integrated |
| 192 | +- **Impact**: Hardware ray tracing not functional |
| 193 | +- **Status**: Interface stubs exist |
| 194 | +- **Action Required**: |
| 195 | + 1. RTX renderer module must be compiled and linked |
| 196 | + 2. RTX_vk_rt_init(), RTX_vk_rt_shutdown(), RTX_vk_rt_trace_rays() must be implemented |
| 197 | + 3. Check for ray tracing extension support before calling |
| 198 | + 4. Uncomment function calls in vk_raytracing.cpp |
| 199 | + |
| 200 | +### 10. Terrain System |
| 201 | + |
| 202 | +#### `vk_terrain.c` - Multiple TODOs |
| 203 | +- **Issues**: Heightmap loading, height editing, material painting, ray tracing |
| 204 | +- **Impact**: Terrain system incomplete |
| 205 | +- **Status**: Core rendering works, editing features missing |
| 206 | +- **Action Required**: See individual TODOs in vk_terrain.c for implementation steps |
| 207 | + |
| 208 | +### 11. Surface Sprites |
| 209 | + |
| 210 | +#### `vk_surface_sprites.c:265, 414` - Sprite Management |
| 211 | +- **Issues**: Sprite type removal, ray tracing for interaction |
| 212 | +- **Impact**: Limited sprite system functionality |
| 213 | +- **Status**: Basic rendering works, advanced features missing |
| 214 | +- **Action Required**: See individual TODOs in vk_surface_sprites.c |
| 215 | + |
| 216 | +--- |
| 217 | + |
| 218 | +## ✅ RECENTLY FIXED |
| 219 | + |
| 220 | +### Fog Collapse FIXME - `tr_shader.c:4215` |
| 221 | +- **Status**: ✅ FIXED |
| 222 | +- **Fix**: Added NULL checks for mirror pipelines, proper fallback logic |
| 223 | +- **Date**: 2026-01-09 |
| 224 | +- **Details**: Fog collapse now works safely even when mirror pipelines are disabled |
| 225 | + |
| 226 | +--- |
| 227 | + |
| 228 | +## Summary Statistics |
| 229 | + |
| 230 | +- **Critical Items**: 8 |
| 231 | +- **High Priority Items**: 12 |
| 232 | +- **Medium Priority Items**: 15+ |
| 233 | +- **Recently Fixed**: 1 |
| 234 | + |
| 235 | +## Recommended Fix Order |
| 236 | + |
| 237 | +1. **Week 1**: Fix all CRITICAL items (memory leaks, core functionality, image layouts) |
| 238 | +2. **Week 2**: Fix HIGH priority items (light clustering, shader issues, compute scheduler) |
| 239 | +3. **Week 3+**: Address MEDIUM items as features are needed (RTX, terrain editing) |
| 240 | + |
| 241 | +## Notes |
| 242 | + |
| 243 | +- Many CRITICAL items are related to resource cleanup and image layout handling |
| 244 | +- HIGH priority items focus on performance and feature completeness |
| 245 | +- MEDIUM priority items are mostly optional features (RTX, terrain editing) |
| 246 | +- All items have been documented with implementation steps where applicable |
| 247 | +- Regular review and updates to this document are recommended |
| 248 | + |
| 249 | +--- |
| 250 | + |
| 251 | +**Document Maintainer**: Development Team |
| 252 | +**Review Frequency**: Weekly during active development |
0 commit comments