Blender V5.0
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_utildefines.h"
10
17
25typedef enum : uint32_t {
31 /* Write Stencil. These options are mutual exclusive and packed into 2 bits */
49
66
67 /* See GPU_clip_control_unit_range. */
75} DRWState;
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#define DRW_STATE_RASTERIZER_ENABLED \
86 (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_STENCIL | \
87 DRW_STATE_WRITE_STENCIL_SHADOW_PASS | DRW_STATE_WRITE_STENCIL_SHADOW_FAIL)
88#define DRW_STATE_DEPTH_TEST_ENABLED \
89 (DRW_STATE_DEPTH_ALWAYS | DRW_STATE_DEPTH_LESS | DRW_STATE_DEPTH_LESS_EQUAL | \
90 DRW_STATE_DEPTH_EQUAL | DRW_STATE_DEPTH_GREATER | DRW_STATE_DEPTH_GREATER_EQUAL)
91#define DRW_STATE_STENCIL_TEST_ENABLED \
92 (DRW_STATE_STENCIL_ALWAYS | DRW_STATE_STENCIL_EQUAL | DRW_STATE_STENCIL_NEQUAL)
93#define DRW_STATE_WRITE_STENCIL_ENABLED \
94 (DRW_STATE_WRITE_STENCIL | DRW_STATE_WRITE_STENCIL_SHADOW_PASS | \
95 DRW_STATE_WRITE_STENCIL_SHADOW_FAIL)
96
97namespace blender::draw {
98
99/* -------------------------------------------------------------------- */
102
104{
105 GPUWriteMask write_mask = GPU_WRITE_NONE;
107 write_mask |= GPU_WRITE_DEPTH;
108 }
110 write_mask |= GPU_WRITE_COLOR;
111 }
113 write_mask |= GPU_WRITE_STENCIL;
114 }
115 return write_mask;
116}
117
119{
122 return GPU_CULL_BACK;
124 return GPU_CULL_FRONT;
125 default:
126 return GPU_CULL_NONE;
127 }
128}
129
131{
134 return GPU_DEPTH_LESS;
138 return GPU_DEPTH_EQUAL;
140 return GPU_DEPTH_GREATER;
144 return GPU_DEPTH_ALWAYS;
145 default:
146 return GPU_DEPTH_NONE;
147 }
148}
149
163
165{
168 return GPU_STENCIL_ALWAYS;
170 return GPU_STENCIL_EQUAL;
172 return GPU_STENCIL_NEQUAL;
173 default:
174 return GPU_STENCIL_NONE;
175 }
176}
177
207
209{
212 return GPU_VERTEX_FIRST;
213 default:
214 return GPU_VERTEX_LAST;
215 }
216}
217
219
220}; // namespace blender::draw
#define ENUM_OPERATORS(_type, _max)
GPUDepthTest
Definition GPU_state.hh:110
@ GPU_DEPTH_GREATER
Definition GPU_state.hh:116
@ GPU_DEPTH_EQUAL
Definition GPU_state.hh:115
@ GPU_DEPTH_ALWAYS
Definition GPU_state.hh:112
@ GPU_DEPTH_GREATER_EQUAL
Definition GPU_state.hh:117
@ GPU_DEPTH_LESS
Definition GPU_state.hh:113
@ GPU_DEPTH_LESS_EQUAL
Definition GPU_state.hh:114
@ GPU_DEPTH_NONE
Definition GPU_state.hh:111
GPUBlend
Definition GPU_state.hh:84
@ GPU_BLEND_ADDITIVE_PREMULT
Definition GPU_state.hh:90
@ GPU_BLEND_INVERT
Definition GPU_state.hh:95
@ GPU_BLEND_OIT
Definition GPU_state.hh:98
@ GPU_BLEND_MULTIPLY
Definition GPU_state.hh:91
@ GPU_BLEND_NONE
Definition GPU_state.hh:85
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:87
@ GPU_BLEND_CUSTOM
Definition GPU_state.hh:103
@ GPU_BLEND_ADDITIVE
Definition GPU_state.hh:89
@ GPU_BLEND_SUBTRACT
Definition GPU_state.hh:92
@ GPU_BLEND_ALPHA_UNDER_PREMUL
Definition GPU_state.hh:104
@ GPU_BLEND_BACKGROUND
Definition GPU_state.hh:100
@ GPU_BLEND_ALPHA_PREMULT
Definition GPU_state.hh:88
GPUProvokingVertex
Definition GPU_state.hh:141
@ GPU_VERTEX_LAST
Definition GPU_state.hh:142
@ GPU_VERTEX_FIRST
Definition GPU_state.hh:143
GPUStencilTest
Definition GPU_state.hh:120
@ GPU_STENCIL_EQUAL
Definition GPU_state.hh:123
@ GPU_STENCIL_NEQUAL
Definition GPU_state.hh:124
@ GPU_STENCIL_ALWAYS
Definition GPU_state.hh:122
@ GPU_STENCIL_NONE
Definition GPU_state.hh:121
GPUWriteMask
Definition GPU_state.hh:16
@ GPU_WRITE_STENCIL
Definition GPU_state.hh:23
@ GPU_WRITE_NONE
Definition GPU_state.hh:17
@ GPU_WRITE_DEPTH
Definition GPU_state.hh:22
@ GPU_WRITE_COLOR
Definition GPU_state.hh:24
GPUFaceCullTest
Definition GPU_state.hh:135
@ GPU_CULL_FRONT
Definition GPU_state.hh:137
@ GPU_CULL_NONE
Definition GPU_state.hh:136
@ GPU_CULL_BACK
Definition GPU_state.hh:138
GPUStencilOp
Definition GPU_state.hh:127
@ GPU_STENCIL_OP_COUNT_DEPTH_FAIL
Definition GPU_state.hh:132
@ GPU_STENCIL_OP_COUNT_DEPTH_PASS
Definition GPU_state.hh:131
@ GPU_STENCIL_OP_REPLACE
Definition GPU_state.hh:129
@ GPU_STENCIL_OP_NONE
Definition GPU_state.hh:128
DRWState
Definition draw_state.hh:25
@ DRW_STATE_STENCIL_EQUAL
Definition draw_state.hh:47
@ DRW_STATE_CLIP_PLANES
Definition draw_state.hh:71
@ DRW_STATE_BLEND_ALPHA
Definition draw_state.hh:55
@ DRW_STATE_BLEND_ADD
Definition draw_state.hh:51
@ DRW_STATE_BLEND_BACKGROUND
Definition draw_state.hh:58
@ DRW_STATE_CULL_FRONT
Definition draw_state.hh:44
@ DRW_STATE_STENCIL_ALWAYS
Definition draw_state.hh:46
@ DRW_STATE_DEPTH_LESS
Definition draw_state.hh:37
@ DRW_STATE_NO_DRAW
Definition draw_state.hh:27
@ DRW_STATE_IN_FRONT_SELECT
Definition draw_state.hh:69
@ DRW_STATE_BLEND_SUB
Definition draw_state.hh:61
@ DRW_STATE_DEPTH_GREATER_EQUAL
Definition draw_state.hh:41
@ DRW_STATE_WRITE_STENCIL_SHADOW_FAIL
Definition draw_state.hh:34
@ DRW_STATE_DEPTH_EQUAL
Definition draw_state.hh:39
@ DRW_STATE_PROGRAM_POINT_SIZE
Definition draw_state.hh:74
@ DRW_STATE_WRITE_DEPTH
Definition draw_state.hh:29
@ DRW_STATE_CLIP_CONTROL_UNIT_RANGE
Definition draw_state.hh:68
@ DRW_STATE_BLEND_OIT
Definition draw_state.hh:59
@ DRW_STATE_LOGIC_INVERT
Definition draw_state.hh:64
@ DRW_STATE_SHADOW_OFFSET
Definition draw_state.hh:70
@ DRW_STATE_BLEND_ADD_FULL
Definition draw_state.hh:53
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:30
@ DRW_STATE_BLEND_ALPHA_UNDER_PREMUL
Definition draw_state.hh:65
@ DRW_STATE_DEPTH_LESS_EQUAL
Definition draw_state.hh:38
@ DRW_STATE_WRITE_STENCIL_SHADOW_PASS
Definition draw_state.hh:33
@ DRW_STATE_CULL_BACK
Definition draw_state.hh:43
@ DRW_STATE_FIRST_VERTEX_CONVENTION
Definition draw_state.hh:72
@ DRW_STATE_STENCIL_NEQUAL
Definition draw_state.hh:48
@ DRW_STATE_DEPTH_ALWAYS
Definition draw_state.hh:36
@ DRW_STATE_BLEND_CUSTOM
Definition draw_state.hh:63
@ DRW_STATE_BLEND_ALPHA_PREMUL
Definition draw_state.hh:57
@ DRW_STATE_DEPTH_GREATER
Definition draw_state.hh:40
@ DRW_STATE_BLEND_MUL
Definition draw_state.hh:60
@ DRW_STATE_WRITE_STENCIL
Definition draw_state.hh:32
#define DRW_STATE_WRITE_STENCIL_ENABLED
Definition draw_state.hh:93
#define DRW_STATE_STENCIL_TEST_ENABLED
Definition draw_state.hh:91
#define DRW_STATE_DEPTH_TEST_ENABLED
Definition draw_state.hh:88
#define DRW_STATE_BLEND_ENABLED
Definition draw_state.hh:81
static ulong state[N]
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)