PBR: default Forward+, device-local light SSBO for tile cull#154
Draft
PBR: default Forward+, device-local light SSBO for tile cull#154
Conversation
r_forwardPlusShade changes PBR fragment specialization on world draw pipelines only. vk_destroy_pipelines() also destroyed gamma, overlay compose, bloom, SMAA, and other post paths unrelated to Forward+, which could leave the swapchain with no valid gamma blit (black screen with audio). Add vk_destroy_world_graphics_pipelines() (same slice as vk_release_resources: indices >= vk.pipelines_world_base) and use it for r_forwardPlusShade invalidation. Persistent pipelines (skybox, fog, etc.) stay valid; PBR world pipelines are recreated lazily via vk_gen_pipeline as before. Co-authored-by: Tim Fox <timfox@outlook.com>
vk_destroy_world_graphics_pipelines() must not shrink vk.pipelines_count or zero Vk_Pipeline_Def rows: shader_t stores uint32_t indices into the table; dropping the tail reuses slots and breaks cached indices (wrong draws or vk_gen_pipeline ERR_FATAL). Destroy only VkPipeline handles; lazy recreation picks up the new r_forwardPlusShade specialization. Co-authored-by: Tim Fox <timfox@outlook.com>
- r_forwardPlus default 1 (latched): prioritize clustered tile cull + PBR path - Light records: pack to host staging, vkCmdCopyBuffer to DEVICE_LOCAL SSBO each frame so compute cull and fragment shaders read VRAM (not host-mapped SSBO) - vk_forward_plus_upload_refdef after RB_BeginDrawingView: transfer barriers - Tile cull light buffer barrier updated for device-local read path - docs/FORWARD_PLUS_PIPELINE_AUDIT.md: ordering and sync notes Startup log: [VK][Forward+] r_forwardPlus=1 device-local light SSBO + staging... Co-authored-by: Tim Fox <timfox@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PBR / Forward+ as the default path (Vulkan)
r_forwardPlusnow defaults to 1 (still latched; set0+vid_restartto disable). This turns on GPU tile cull + PBR descriptor integration without users manually enabling scaffolding.Device-local light SSBO (more “GPU”, less host-mapped shader memory)
Dynamic light records are still packed on the CPU (source data is
dlight_tinrefdef), but the read path forforward_plus_tile_culland PBR fragment code now uses a device-localSTORAGE | TRANSFER_DSTbuffer. Each frame we copy only the used prefix (header + n records) from a host staging buffer viavkCmdCopyBuffer, with correct transfer and shader barriers. This matches the architecture goal: compute + PBR sample lights from VRAM instead of a host-visible SSBO.New call
vk_forward_plus_upload_refdef()runs afterRB_BeginDrawingView(command buffer valid, inside main pass) and beforevk_forward_plus_dispatch_tile_cull().Docs
docs/FORWARD_PLUS_PIPELINE_AUDIT.mdupdated for ordering and synchronization.Validation
./scripts/compile_engine.sh vulkanctest(19/19 passed)Notes / follow-ups
dlight_tin a UBO/SSBO from the game without a CPUrefdefpath—larger change.