easy-gl › ScopedDebugGroup

ScopedDebugGroup

RAII wrapper around Device::push_debug_group() / pop_debug_group(). Marks a named section in the GPU command stream, visible in tools like RenderDoc, NVIDIA Nsight, and Xcode GPU Frame Debugger.

Requires GL_KHR_debug (core in OpenGL 4.3+ and OpenGL ES 3.2+) and debug output enabled on the device. The constructor calls push_debug_group(); the destructor calls pop_debug_group(). Non-copyable, non-movable.

Usage in a render loop

void renderFrame(easygl::Device& device)
{
    {
        easygl::ScopedDebugGroup shadowGroup(device, "Shadow pass");
        // All GPU commands appear nested under "Shadow pass" in the profiler
        device.set_viewport(0, 0, shadowWidth, shadowHeight);
        device.draw_elements(easygl::PrimitiveType::Triangles, indexCount,
                              easygl::DataType::UnsignedInt, nullptr);
    } // pop_debug_group() called here

    {
        easygl::ScopedDebugGroup mainGroup(device, "Main pass");
        device.set_viewport(0, 0, screenWidth, screenHeight);
        device.draw_arrays(easygl::PrimitiveType::Triangles, 0, vertexCount);
    } // pop_debug_group() called here
}

Optional numeric ID

A numeric identifier can be passed as the third argument. It is displayed alongside the label in some tools:

easygl::ScopedDebugGroup group(device, "Post-process pass", 42u);

Constructor

ParameterDescription
deviceThe Device to push/pop the debug group on.
labelHuman-readable name shown in profiling tools.
id (optional)Numeric identifier (default 0).