Code Room
Vibe codingHard
Question
An AI assistant wrote this per-frame material update for an OpenGL renderer in C++. Visually it's correct, but the profiler shows a multi-millisecond CPU stall every frame and GPU occupancy is low. Review the render loop and explain why updating the uniform this way stalls the pipeline.
void Renderer::DrawObjects(float time) { for (auto& obj : objects) { glUseProgram(obj.shader); GLint loc = glGetUniformLocation(obj.shader, "uTime"); // every object, every frame glUniform1f(loc, time); glUniformMatrix4fv(modelLoc, 1, GL_FALSE, &obj.model[0][0]); obj.material->Bind(); // re-uploads full texture set glDrawElements(GL_TRIANGLES, obj.indexCount, GL_UNSIGNED_INT, 0); }}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.
Learn the concepts
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.