GroveEngine/modules/BgfxRenderer/Passes/DebugPass.cpp
StillHammer d63d8d83fa feat: Add BgfxRenderer module skeleton
- Add complete BgfxRenderer module structure (24 files)
- RHI abstraction layer (no bgfx:: exposed outside BgfxDevice.cpp)
- Frame system with lock-free allocator
- RenderGraph with ClearPass, SpritePass, DebugPass
- SceneCollector for IIO message parsing (render:* topics)
- ResourceCache with thread-safe texture/shader caching
- Full IModule integration (config via IDataNode, comm via IIO)
- CMake with FetchContent for bgfx
- Windows build script (build_renderer.bat)
- Documentation (README.md, USER_GUIDE.md, PLAN_BGFX_RENDERER.md)
- Updated .gitignore for Windows builds

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 00:41:55 +08:00

55 lines
1.6 KiB
C++

#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<uint32_t>(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