Files
test/source/blender/draw/intern/shaders/draw_debug_info.hh
Clément Foucault b4b5977aed DRW: Guard debug lib using defines
This allows adding debug calls to library
sources and not trigger an error for
all shaders that reference the lib.
The particular shader that need to use
it can set `drw_debug_print_enable` and
`drw_debug_draw_enable` in their main file
and it will trigger the injection of the
debug functions.
2023-08-20 17:52:48 +02:00

62 lines
2.2 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "draw_defines.h"
#include "gpu_shader_create_info.hh"
/* -------------------------------------------------------------------- */
/** \name Debug print
*
* Allows print() function to have logging support inside shaders.
* \{ */
GPU_SHADER_CREATE_INFO(draw_debug_print)
.define("DRW_DEBUG_PRINT")
.typedef_source("draw_shader_shared.h")
.storage_buf(DRW_DEBUG_PRINT_SLOT, Qualifier::READ_WRITE, "uint", "drw_debug_print_buf[]");
GPU_SHADER_INTERFACE_INFO(draw_debug_print_display_iface, "").flat(Type::UINT, "char_index");
GPU_SHADER_CREATE_INFO(draw_debug_print_display)
.do_static_compilation(true)
.typedef_source("draw_shader_shared.h")
.storage_buf(DRW_DEBUG_PRINT_SLOT, Qualifier::READ, "uint", "drw_debug_print_buf[]")
.vertex_out(draw_debug_print_display_iface)
.fragment_out(0, Type::VEC4, "out_color")
.push_constant(Type::VEC2, "viewport_size")
.vertex_source("draw_debug_print_display_vert.glsl")
.fragment_source("draw_debug_print_display_frag.glsl")
.additional_info("draw_view");
/** \} */
/* -------------------------------------------------------------------- */
/** \name Debug draw shapes
*
* Allows to draw lines and points just like the DRW_debug module functions.
* \{ */
GPU_SHADER_CREATE_INFO(draw_debug_draw)
.define("DRW_DEBUG_DRAW")
.typedef_source("draw_shader_shared.h")
.storage_buf(DRW_DEBUG_DRAW_SLOT,
Qualifier::READ_WRITE,
"DRWDebugVert",
"drw_debug_verts_buf[]");
GPU_SHADER_INTERFACE_INFO(draw_debug_draw_display_iface, "interp").flat(Type::VEC4, "color");
GPU_SHADER_CREATE_INFO(draw_debug_draw_display)
.do_static_compilation(true)
.typedef_source("draw_shader_shared.h")
.storage_buf(DRW_DEBUG_DRAW_SLOT, Qualifier::READ, "DRWDebugVert", "drw_debug_verts_buf[]")
.vertex_out(draw_debug_draw_display_iface)
.fragment_out(0, Type::VEC4, "out_color")
.push_constant(Type::MAT4, "persmat")
.vertex_source("draw_debug_draw_display_vert.glsl")
.fragment_source("draw_debug_draw_display_frag.glsl")
.additional_info("draw_view");
/** \} */