refactor: split CPUBackend::Render() and CUDABackend::Render()#53
Conversation
PR Review: refactor/split-large-functions (#48)Overall: Clean, mechanical refactoring. No behavioral changes introduced. One pre-existing optimization opportunity noted. Ready to merge as-is. Issues Found1. 2. BVH SoA packing runs every frame in Suggestion (follow-up, not blocking): Guard BVH packing with the same scene version check, or track a separate BVH version. // BVH packing only when BVH actually changed
if (scene.Version != m_LastISPCSceneVersion) { /* BVH packing here */ }3. Minor formatting in void CopyInteropToVulkan();
// ── CUDA state ── ← reads as belonging to the function aboveAdd a blank line between them for visual separation. 4. VerdictNo bugs, no regressions, good extraction boundaries. The three new private methods ( |
|
My review aligns with the existing PR comment. Here's my analysis: Verdict: Clean refactoring. No bugs, no regressions.Good:
Pre-existing issue (now more visible): BVH SoA packing in Minor nit: |
…#48) CPUBackend: extract RenderISPC() and RenderCPUFallback() private methods. CUDABackend: extract UploadSceneAndBVHIfChanged() and CopyInteropToVulkan(). Render() sizes: CPUBackend 205→30 lines, CUDABackend 192→110 lines.
cf0beb7 to
c97c698
Compare
PR Review:
|
…n (CI fix) After extracting RenderCPUFallback(), outputBuffer became a function parameter instead of being in the outer scope. The inner lambda at line 215 needs explicit capture.
|
I've read all four changed files. Here's my review: Verdict: Clean mechanical refactoring. Two real issues, one pre-existing improvement opportunity.1. Indentation regression in
|
… capture through all nested levels)
PR Review:
|
…h scene version (review feedback) Lines 225-226 had wrong indent level (5 instead of 6 tabs). BVH SoA packing now inside if(scene.Version != m_LastISPCSceneVersion), avoiding wasted work on consecutive frames when scene hasn't changed.
PR Review:
|
| Issue | Commit | Status |
|---|---|---|
Blank line between CopyInteropToVulkan() and // ── CUDA state ── in CUDABackend.h |
c97c698 |
Fixed |
Lambda missing outputBuffer capture (MSVC CI failure) |
786807d, 221190a |
Fixed |
Indentation regression at CPUBackend.cpp:225-226 (2 tabs → 6 tabs) |
2a7685b |
Fixed |
BVH SoA packing outside scene version guard in RenderISPC() |
2a7685b |
Fixed |
Positive observations
m_AccumFrameIndexhoisting (CPUBackend.cpp:50) — previously set only in the#elsefallback branch; now set unconditionally before branching. Fixes a latent asymmetry where the member was stale during ISPC rendering.- Extraction boundaries are well-chosen — each of the 4 new methods has a single, clear responsibility.
reinterpret_castusage (CUDABackend.cpp:61, 198, 214) consistent with PR refactor: phase_6_code_quality — C_style_casts_to_named_iota_constexpr_centralized_constants #18 cast elimination standards.
No remaining issues
The current tip (2a7685b) has zero bugs, zero regressions, and clean formatting. No changes needed.






Closes #48. Extract RenderISPC/RenderCPUFallback (CPUBackend) and UploadSceneAndBVHIfChanged/CopyInteropToVulkan (CUDABackend).