#include "DebugPass.h" #include "../RHI/RHIDevice.h" namespace grove { void DebugPass::setup(rhi::IRHIDevice& device) { // Create dynamic vertex buffer for debug lines rhi::BufferDesc vbDesc; vbDesc.type = rhi::BufferDesc::Vertex; vbDesc.size = MAX_DEBUG_LINES * 2 * sizeof(float) * 6; // 2 verts per line, pos + color vbDesc.data = nullptr; vbDesc.dynamic = true; m_lineVB = device.createBuffer(vbDesc); // Note: Shader loading will be done via ResourceCache } void DebugPass::shutdown(rhi::IRHIDevice& device) { device.destroy(m_lineVB); device.destroy(m_lineShader); } void DebugPass::execute(const FramePacket& frame, rhi::RHICommandBuffer& cmd) { // Skip if no debug primitives if (frame.debugLineCount == 0 && frame.debugRectCount == 0) { return; } // Set render state for debug (no blending, no depth) rhi::RenderState state; state.blend = rhi::BlendMode::None; state.cull = rhi::CullMode::None; state.depthTest = false; state.depthWrite = false; cmd.setState(state); // Build vertex data for lines // Each line needs 2 vertices with position (x, y, z) and color (r, g, b, a) if (frame.debugLineCount > 0) { cmd.setVertexBuffer(m_lineVB); cmd.draw(static_cast(frame.debugLineCount * 2)); cmd.submit(0, m_lineShader, 0); } // Rectangles are rendered as line loops or filled quads // For now, just lines (wireframe) if (frame.debugRectCount > 0) { // Each rect = 4 lines = 8 vertices // TODO: Build rect line data and draw } } } // namespace grove