🔍 Module Scanned
src/engine/graphics/vulkan/ (automated audit scan)
📝 Summary
The ResourceManager.createShader() function is a stub that always returns error.ExtensionNotPresent instead of actually compiling and creating Vulkan shader modules. This means any code path that calls rhi.createShader() will fail, which appears to bypass the actual GLSL→SPIR-V compilation pipeline that should be used for terrain and other shaders.
📍 Location
- File:
src/engine/graphics/vulkan/resource_manager.zig:433-441
- Function/Scope:
createShader
🔴 Severity: High
- High: Memory leaks, race conditions, incorrect rendering, broken features
💥 Impact
Any code that calls rhi.createShader() or ResourceManager.createShader() will receive an ExtensionNotPresent error. This appears to be dead/stub code, as the actual shader compilation likely happens elsewhere in the pipeline. However, if any production code path relies on this function, shader loading will fail silently. Additionally, the function name ExtensionNotPresent is misleading since shader creation is a core Vulkan feature, not an extension.
🔎 Evidence
pub fn createShader(self: *ResourceManager, vertex_src: [*c]const u8, fragment_src: [*c]const u8) rhi.RhiError!rhi.ShaderHandle {
_ = self;
_ = vertex_src;
_ = fragment_src;
// TODO: Implement actual shader creation when ready.
// For now, return error to avoid silent failure.
// NOTE: If engine code calls this, it will now fail loudly, which is better than silent failure.
return error.ExtensionNotPresent; // Or proper NotImpl error
}
The function:
- Accepts vertex and fragment GLSL source strings but ignores them
- Returns a misleading error
ExtensionNotPresent instead of a proper error like NotImplemented or ShaderCreationFailed
- Has a TODO comment indicating it's incomplete
- Has a corresponding
destroyShader implementation that does nothing meaningful (_ = self; _ = handle;)
🛠️ Proposed Fix
Either:
- Implement full shader creation: Use
vkCreateShaderModule with SPIR-V bytecode compiled from GLSL sources via glslangValidator or a Zig-native compiler
- Add proper error handling: Change
ExtensionNotPresent to NotImplemented or ShaderCreationNotSupported to accurately reflect the state
- Wire up destroyShader: The current
destroyShader does nothing - if shaders are created elsewhere, this should be wired up to actually destroy them
- Document the shader pipeline: If shader creation happens elsewhere (e.g., in a pipeline manager), add a comment explaining where and why
✅ Acceptance Criteria
📚 References
- Vulkan spec:
vkCreateShaderModule - core Vulkan feature, not an extension
- Related:
build_options debug flags in rhi_vulkan.zig for shader validation
- Context: The render pipeline likely depends on external SPIR-V compilation via
glslangValidator during build time
🔍 Module Scanned
src/engine/graphics/vulkan/(automated audit scan)📝 Summary
The
ResourceManager.createShader()function is a stub that always returnserror.ExtensionNotPresentinstead of actually compiling and creating Vulkan shader modules. This means any code path that callsrhi.createShader()will fail, which appears to bypass the actual GLSL→SPIR-V compilation pipeline that should be used for terrain and other shaders.📍 Location
src/engine/graphics/vulkan/resource_manager.zig:433-441createShader🔴 Severity: High
💥 Impact
Any code that calls
rhi.createShader()orResourceManager.createShader()will receive anExtensionNotPresenterror. This appears to be dead/stub code, as the actual shader compilation likely happens elsewhere in the pipeline. However, if any production code path relies on this function, shader loading will fail silently. Additionally, the function nameExtensionNotPresentis misleading since shader creation is a core Vulkan feature, not an extension.🔎 Evidence
The function:
ExtensionNotPresentinstead of a proper error likeNotImplementedorShaderCreationFaileddestroyShaderimplementation that does nothing meaningful (_ = self; _ = handle;)🛠️ Proposed Fix
Either:
vkCreateShaderModulewith SPIR-V bytecode compiled from GLSL sources viaglslangValidatoror a Zig-native compilerExtensionNotPresenttoNotImplementedorShaderCreationNotSupportedto accurately reflect the statedestroyShaderdoes nothing - if shaders are created elsewhere, this should be wired up to actually destroy them✅ Acceptance Criteria
createShadereither implements actual shader creation or returns a meaningful errordestroyShaderproperly cleans up shader modules when creation is implementedExtensionNotPresent)createShaderhandle the error appropriately📚 References
vkCreateShaderModule- core Vulkan feature, not an extensionbuild_optionsdebug flags inrhi_vulkan.zigfor shader validationglslangValidatorduring build time