Code Room
Vibe codingHardvc-g368
Subject Ai code reviewLevel Senior–Staff~18 minCommon in Algorithms & data structures interviewsIndustries Computer games, Software development

Question

An AI assistant wrote this per-frame post-processing pass for a custom Vulkan-ish renderer wrapper in C++. Image is correct but frame time is dominated by GPU bubbles and the profiler flags 'readback stall.' Review the update and explain why touching the uniform/buffer this way stalls the GPU each frame.

cpp
void Bloom::Render(float threshold) {    // upload params into a GPU buffer the shader reads    void* ptr = MapBuffer(paramBuffer);      // maps the in-flight buffer    memcpy(ptr, &threshold, sizeof(float));    UnmapBuffer(paramBuffer);    // read last frame's average luminance back to drive auto-exposure    float lum = ReadbackBuffer(lumBuffer);   // blocks until GPU finishes    Dispatch(bloomShader, lum, threshold);}
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.