Blender V5.3
draw_debug_shared.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
12
13#ifndef GPU_SHADER
14# include "BLI_math_vector.hh"
15
16namespace blender {
17
18using namespace blender::math;
19
20#endif
21
22/* -------------------------------------------------------------------- */
25
27 /* This is a weird layout, but needed to be able to use DRWDebugVertPair as
28 * a DrawCommand and avoid alignment issues. See drw_debug_lines_buf[] definition. */
32 /* Named vert_color to avoid global namespace collision with uniform color. */
34
38 /* Number of time this line is supposed to be displayed. Decremented by one on display. */
40};
41
43 uint in_pos1_y,
44 uint in_pos1_z,
45 uint in_pos2_x,
46 uint in_pos2_y,
47 uint in_pos2_z,
48 uint in_vert_color,
49 uint in_lifetime)
50{
51 DRWDebugVertPair debug_vert;
52 debug_vert.pos1_x = in_pos1_x;
53 debug_vert.pos1_y = in_pos1_y;
54 debug_vert.pos1_z = in_pos1_z;
55 debug_vert.pos2_x = in_pos2_x;
56 debug_vert.pos2_y = in_pos2_y;
57 debug_vert.pos2_z = in_pos2_z;
58 debug_vert.vert_color = in_vert_color;
59 debug_vert.lifetime = in_lifetime;
60 return debug_vert;
61}
62
64{
65 v_color = clamp(v_color, 0.0f, 1.0f);
66 uint result = 0;
67 result |= uint(v_color.x * 255.0) << 0u;
68 result |= uint(v_color.y * 255.0) << 8u;
69 result |= uint(v_color.z * 255.0) << 16u;
70 result |= uint(v_color.w * 255.0) << 24u;
71 return result;
72}
73
74/* Take the header (DrawCommand) into account. */
75#define DRW_DEBUG_DRAW_VERT_MAX (2 * 1024) - 1
76
77/* The debug draw buffer is laid-out as the following struct.
78 * But we use plain array in shader code instead because of driver issues. */
83
84/* Equivalent to `DRWDebugDrawBuffer.command.v_count`. */
85#define drw_debug_draw_v_count(buf) buf[0].pos1_x
90#define drw_debug_draw_offset 1
91
93
94#ifndef GPU_SHADER
95} // namespace blender
96#endif
#define host_shared
#define DRW_DEBUG_DRAW_VERT_MAX
constexpr T clamp(T, U, U) RET
BMesh Iterators.
unsigned int uint
Definition BKE_text.h:55
VecBase< float, 4 > float4
uint debug_color_pack(float4 v_color)
DRWDebugVertPair debug_line_make(uint in_pos1_x, uint in_pos1_y, uint in_pos1_z, uint in_pos2_x, uint in_pos2_y, uint in_pos2_z, uint in_vert_color, uint in_lifetime)
struct DRWDebugVertPair verts[DRW_DEBUG_DRAW_VERT_MAX]