Blender V5.3
draw_state.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "GPU_state.hh"
8
9#include "BLI_enum_flags.hh"
10
11namespace blender {
12
19
33 /* Write Stencil. These options are mutual exclusive and packed into 2 bits */
51
69
70 /* See GPU_clip_control_unit_range. */
76};
78
79#define DRW_STATE_DEFAULT \
80 (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL)
81#define DRW_STATE_BLEND_ENABLED \
82 (DRW_STATE_BLEND_ADD | DRW_STATE_BLEND_ADD_FULL | DRW_STATE_BLEND_ALPHA | \
83 DRW_STATE_BLEND_ALPHA_PREMUL | DRW_STATE_BLEND_BACKGROUND | DRW_STATE_BLEND_OIT | \
84 DRW_STATE_BLEND_MUL | DRW_STATE_BLEND_SUB | DRW_STATE_BLEND_CUSTOM | DRW_STATE_LOGIC_INVERT | \
85 DRW_STATE_BLEND_ALPHA_UNDER_PREMUL | DRW_STATE_BLEND_TRANSPARENCY)
86#define DRW_STATE_RASTERIZER_ENABLED \
87 (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_STENCIL | \
88 DRW_STATE_WRITE_STENCIL_SHADOW_PASS | DRW_STATE_WRITE_STENCIL_SHADOW_FAIL)
89#define DRW_STATE_DEPTH_TEST_ENABLED \
90 (DRW_STATE_DEPTH_ALWAYS | DRW_STATE_DEPTH_LESS | DRW_STATE_DEPTH_LESS_EQUAL | \
91 DRW_STATE_DEPTH_EQUAL | DRW_STATE_DEPTH_GREATER | DRW_STATE_DEPTH_GREATER_EQUAL)
92#define DRW_STATE_STENCIL_TEST_ENABLED \
93 (DRW_STATE_STENCIL_ALWAYS | DRW_STATE_STENCIL_EQUAL | DRW_STATE_STENCIL_NEQUAL)
94#define DRW_STATE_WRITE_STENCIL_ENABLED \
95 (DRW_STATE_WRITE_STENCIL | DRW_STATE_WRITE_STENCIL_SHADOW_PASS | \
96 DRW_STATE_WRITE_STENCIL_SHADOW_FAIL)
97
98namespace draw {
99
100/* -------------------------------------------------------------------- */
103
105{
106 GPUWriteMask write_mask = GPU_WRITE_NONE;
108 write_mask |= GPU_WRITE_DEPTH;
109 }
111 write_mask |= GPU_WRITE_COLOR;
112 }
114 write_mask |= GPU_WRITE_STENCIL;
115 }
116 return write_mask;
117}
118
120{
123 return GPU_CULL_BACK;
125 return GPU_CULL_FRONT;
126 default:
127 return GPU_CULL_NONE;
128 }
129}
130
132{
135 return GPU_DEPTH_LESS;
139 return GPU_DEPTH_EQUAL;
141 return GPU_DEPTH_GREATER;
145 return GPU_DEPTH_ALWAYS;
146 default:
147 return GPU_DEPTH_NONE;
148 }
149}
150
164
166{
169 return GPU_STENCIL_ALWAYS;
171 return GPU_STENCIL_EQUAL;
173 return GPU_STENCIL_NEQUAL;
174 default:
175 return GPU_STENCIL_NONE;
176 }
177}
178
210
212{
215 return GPU_VERTEX_FIRST;
216 default:
217 return GPU_VERTEX_LAST;
218 }
219}
220
222
223}; // namespace draw
224
225} // namespace blender
#define DRW_STATE_WRITE_STENCIL_ENABLED
Definition draw_state.hh:94
#define DRW_STATE_STENCIL_TEST_ENABLED
Definition draw_state.hh:92
#define DRW_STATE_DEPTH_TEST_ENABLED
Definition draw_state.hh:89
#define DRW_STATE_BLEND_ENABLED
Definition draw_state.hh:81
const int state
ENUM_OPERATORS(Layer::Flags)
static GPUFaceCullTest to_face_cull_test(DRWState state)
static GPUWriteMask to_write_mask(DRWState state)
static GPUDepthTest to_depth_test(DRWState state)
static GPUStencilOp to_stencil_op(DRWState state)
static GPUBlend to_blend(DRWState state)
static GPUProvokingVertex to_provoking_vertex(DRWState state)
static GPUStencilTest to_stencil_test(DRWState state)
BMesh Iterators.
@ GPU_CULL_FRONT
Definition GPU_state.hh:158
@ GPU_CULL_NONE
Definition GPU_state.hh:157
@ GPU_CULL_BACK
Definition GPU_state.hh:159
@ GPU_STENCIL_OP_COUNT_DEPTH_FAIL
Definition GPU_state.hh:153
@ GPU_STENCIL_OP_COUNT_DEPTH_PASS
Definition GPU_state.hh:152
@ GPU_STENCIL_OP_NONE
Definition GPU_state.hh:149
@ GPU_STENCIL_OP_REPLACE
Definition GPU_state.hh:150
@ GPU_BLEND_TRANSPARENCY
Definition GPU_state.hh:128
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_OIT
Definition GPU_state.hh:109
@ GPU_BLEND_ALPHA_UNDER_PREMUL
Definition GPU_state.hh:117
@ GPU_BLEND_ADDITIVE_PREMULT
Definition GPU_state.hh:93
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
@ GPU_BLEND_ADDITIVE
Definition GPU_state.hh:92
@ GPU_BLEND_BACKGROUND
Definition GPU_state.hh:111
@ GPU_BLEND_SUBTRACT
Definition GPU_state.hh:95
@ GPU_BLEND_ALPHA_PREMULT
Definition GPU_state.hh:91
@ GPU_BLEND_INVERT
Definition GPU_state.hh:100
@ GPU_BLEND_MULTIPLY
Definition GPU_state.hh:94
@ GPU_BLEND_CUSTOM
Definition GPU_state.hh:116
unsigned int uint32_t
Definition BKE_text.h:81
@ GPU_DEPTH_NONE
Definition GPU_state.hh:132
@ GPU_DEPTH_LESS_EQUAL
Definition GPU_state.hh:135
@ GPU_DEPTH_ALWAYS
Definition GPU_state.hh:133
@ GPU_DEPTH_GREATER
Definition GPU_state.hh:137
@ GPU_DEPTH_LESS
Definition GPU_state.hh:134
@ GPU_DEPTH_GREATER_EQUAL
Definition GPU_state.hh:138
@ GPU_DEPTH_EQUAL
Definition GPU_state.hh:136
@ DRW_STATE_CULL_BACK
Definition draw_state.hh:45
@ DRW_STATE_NO_DRAW
Definition draw_state.hh:29
@ DRW_STATE_CLIP_CONTROL_UNIT_RANGE
Definition draw_state.hh:71
@ DRW_STATE_BLEND_OIT
Definition draw_state.hh:61
@ DRW_STATE_FIRST_VERTEX_CONVENTION
Definition draw_state.hh:73
@ DRW_STATE_BLEND_ADD_FULL
Definition draw_state.hh:55
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:32
@ DRW_STATE_BLEND_SUB
Definition draw_state.hh:63
@ DRW_STATE_BLEND_ALPHA
Definition draw_state.hh:57
@ DRW_STATE_CLIP_PLANES
Definition draw_state.hh:72
@ DRW_STATE_BLEND_ALPHA_UNDER_PREMUL
Definition draw_state.hh:67
@ DRW_STATE_STENCIL_ALWAYS
Definition draw_state.hh:48
@ DRW_STATE_WRITE_DEPTH
Definition draw_state.hh:31
@ DRW_STATE_BLEND_ALPHA_PREMUL
Definition draw_state.hh:59
@ DRW_STATE_BLEND_CUSTOM
Definition draw_state.hh:65
@ DRW_STATE_DEPTH_ALWAYS
Definition draw_state.hh:38
@ DRW_STATE_DEPTH_LESS
Definition draw_state.hh:39
@ DRW_STATE_WRITE_STENCIL
Definition draw_state.hh:34
@ DRW_STATE_STENCIL_EQUAL
Definition draw_state.hh:49
@ DRW_STATE_DEPTH_GREATER_EQUAL
Definition draw_state.hh:43
@ DRW_STATE_BLEND_TRANSPARENCY
Definition draw_state.hh:68
@ DRW_STATE_BLEND_ADD
Definition draw_state.hh:53
@ DRW_STATE_STENCIL_NEQUAL
Definition draw_state.hh:50
@ DRW_STATE_WRITE_STENCIL_SHADOW_FAIL
Definition draw_state.hh:36
@ DRW_STATE_DEPTH_EQUAL
Definition draw_state.hh:41
@ DRW_STATE_BLEND_MUL
Definition draw_state.hh:62
@ DRW_STATE_WRITE_STENCIL_SHADOW_PASS
Definition draw_state.hh:35
@ DRW_STATE_BLEND_BACKGROUND
Definition draw_state.hh:60
@ DRW_STATE_DEPTH_LESS_EQUAL
Definition draw_state.hh:40
@ DRW_STATE_LOGIC_INVERT
Definition draw_state.hh:66
@ DRW_STATE_CULL_FRONT
Definition draw_state.hh:46
@ DRW_STATE_PROGRAM_POINT_SIZE
Definition draw_state.hh:75
@ DRW_STATE_DEPTH_GREATER
Definition draw_state.hh:42
@ GPU_STENCIL_ALWAYS
Definition GPU_state.hh:143
@ GPU_STENCIL_EQUAL
Definition GPU_state.hh:144
@ GPU_STENCIL_NONE
Definition GPU_state.hh:142
@ GPU_STENCIL_NEQUAL
Definition GPU_state.hh:145
@ GPU_WRITE_NONE
Definition GPU_state.hh:20
@ GPU_WRITE_COLOR
Definition GPU_state.hh:27
@ GPU_WRITE_STENCIL
Definition GPU_state.hh:26
@ GPU_WRITE_DEPTH
Definition GPU_state.hh:25
GPUProvokingVertex
Definition GPU_state.hh:162
@ GPU_VERTEX_LAST
Definition GPU_state.hh:163
@ GPU_VERTEX_FIRST
Definition GPU_state.hh:164