This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/gpu/intern/gpu_debug.cc
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

76 lines
1.5 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2020 Blender Foundation. All rights reserved. */
/** \file
* \ingroup gpu
*
* Debug features of OpenGL.
*/
#include "BKE_global.h"
#include "BLI_string.h"
#include "gpu_context_private.hh"
#include "GPU_debug.h"
using namespace blender;
using namespace blender::gpu;
void GPU_debug_group_begin(const char *name)
{
if (!(G.debug & G_DEBUG_GPU)) {
return;
}
Context *ctx = Context::get();
DebugStack &stack = ctx->debug_stack;
stack.append(StringRef(name));
ctx->debug_group_begin(name, stack.size());
}
void GPU_debug_group_end()
{
if (!(G.debug & G_DEBUG_GPU)) {
return;
}
Context *ctx = Context::get();
ctx->debug_stack.pop_last();
ctx->debug_group_end();
}
void GPU_debug_get_groups_names(int name_buf_len, char *r_name_buf)
{
Context *ctx = Context::get();
if (ctx == nullptr) {
return;
}
DebugStack &stack = ctx->debug_stack;
if (stack.size() == 0) {
r_name_buf[0] = '\0';
return;
}
size_t sz = 0;
for (StringRef &name : stack) {
sz += BLI_snprintf_rlen(r_name_buf + sz, name_buf_len - sz, "%s > ", name.data());
}
r_name_buf[sz - 3] = '\0';
}
bool GPU_debug_group_match(const char *ref)
{
/* Otherwise there will be no names. */
BLI_assert(G.debug & G_DEBUG_GPU);
Context *ctx = Context::get();
if (ctx == nullptr) {
return false;
}
const DebugStack &stack = ctx->debug_stack;
for (const StringRef &name : stack) {
if (name == ref) {
return true;
}
}
return false;
}