From 542e7bb8e7554bd7676f4f14d20ca4ad014472de Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 12 May 2025 15:45:45 +0200 Subject: [PATCH] Compositor: Add GPU debug groups This PR adds debug groups to improve using GPU tools like debuggers and profilers. It will try to use the node type as debug group name when available. Pull Request: https://projects.blender.org/blender/blender/pulls/138768 --- source/blender/compositor/intern/node_operation.cc | 8 ++++++++ source/blender/compositor/intern/shader_operation.cc | 3 +++ 2 files changed, 11 insertions(+) diff --git a/source/blender/compositor/intern/node_operation.cc b/source/blender/compositor/intern/node_operation.cc index ea8fec67942..29e8b7ef5af 100644 --- a/source/blender/compositor/intern/node_operation.cc +++ b/source/blender/compositor/intern/node_operation.cc @@ -12,6 +12,8 @@ #include "BKE_node.hh" +#include "GPU_debug.hh" + #include "COM_algorithm_compute_preview.hh" #include "COM_context.hh" #include "COM_input_descriptor.hh" @@ -48,12 +50,18 @@ NodeOperation::NodeOperation(Context &context, DNode node) : Operation(context), void NodeOperation::evaluate() { + if (context().use_gpu()) { + GPU_debug_group_begin(node().bnode()->typeinfo->idname.c_str()); + } const timeit::TimePoint before_time = timeit::Clock::now(); Operation::evaluate(); const timeit::TimePoint after_time = timeit::Clock::now(); if (context().profiler()) { context().profiler()->set_node_evaluation_time(node_.instance_key(), after_time - before_time); } + if (context().use_gpu()) { + GPU_debug_group_end(); + } } void NodeOperation::compute_preview() diff --git a/source/blender/compositor/intern/shader_operation.cc b/source/blender/compositor/intern/shader_operation.cc index 351d890376b..1f3c7e8b128 100644 --- a/source/blender/compositor/intern/shader_operation.cc +++ b/source/blender/compositor/intern/shader_operation.cc @@ -13,6 +13,7 @@ #include "DNA_customdata_types.h" #include "GPU_context.hh" +#include "GPU_debug.hh" #include "GPU_material.hh" #include "GPU_shader.hh" #include "GPU_texture.hh" @@ -54,6 +55,7 @@ ShaderOperation::~ShaderOperation() void ShaderOperation::execute() { + GPU_debug_group_begin("ShaderOperation"); const Domain domain = compute_domain(); for (StringRef identifier : output_sockets_to_output_identifiers_map_.values()) { Result &result = get_result(identifier); @@ -73,6 +75,7 @@ void ShaderOperation::execute() GPU_texture_image_unbind_all(); GPU_uniformbuf_debug_unbind_all(); GPU_shader_unbind(); + GPU_debug_group_end(); } void ShaderOperation::bind_material_resources(GPUShader *shader)