Blender V4.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_utildefines.h"
10
74
76
77#define DRW_STATE_DEFAULT \
78 (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL)
79#define DRW_STATE_BLEND_ENABLED \
80 (DRW_STATE_BLEND_ADD | DRW_STATE_BLEND_ADD_FULL | DRW_STATE_BLEND_ALPHA | \
81 DRW_STATE_BLEND_ALPHA_PREMUL | DRW_STATE_BLEND_BACKGROUND | DRW_STATE_BLEND_OIT | \
82 DRW_STATE_BLEND_MUL | DRW_STATE_BLEND_SUB | DRW_STATE_BLEND_CUSTOM | DRW_STATE_LOGIC_INVERT)
83#define DRW_STATE_RASTERIZER_ENABLED \
84 (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_STENCIL | \
85 DRW_STATE_WRITE_STENCIL_SHADOW_PASS | DRW_STATE_WRITE_STENCIL_SHADOW_FAIL)
86#define DRW_STATE_DEPTH_TEST_ENABLED \
87 (DRW_STATE_DEPTH_ALWAYS | DRW_STATE_DEPTH_LESS | DRW_STATE_DEPTH_LESS_EQUAL | \
88 DRW_STATE_DEPTH_EQUAL | DRW_STATE_DEPTH_GREATER | DRW_STATE_DEPTH_GREATER_EQUAL)
89#define DRW_STATE_STENCIL_TEST_ENABLED \
90 (DRW_STATE_STENCIL_ALWAYS | DRW_STATE_STENCIL_EQUAL | DRW_STATE_STENCIL_NEQUAL)
91#define DRW_STATE_WRITE_STENCIL_ENABLED \
92 (DRW_STATE_WRITE_STENCIL | DRW_STATE_WRITE_STENCIL_SHADOW_PASS | \
93 DRW_STATE_WRITE_STENCIL_SHADOW_FAIL)
94
95namespace blender::draw {
96
97/* -------------------------------------------------------------------- */
102{
103 eGPUWriteMask write_mask = GPU_WRITE_NONE;
105 write_mask |= GPU_WRITE_DEPTH;
106 }
108 write_mask |= GPU_WRITE_COLOR;
109 }
111 write_mask |= GPU_WRITE_STENCIL;
112 }
113 return write_mask;
114}
115
117{
120 return GPU_CULL_BACK;
122 return GPU_CULL_FRONT;
123 default:
124 return GPU_CULL_NONE;
125 }
126}
127
129{
132 return GPU_DEPTH_LESS;
136 return GPU_DEPTH_EQUAL;
138 return GPU_DEPTH_GREATER;
142 return GPU_DEPTH_ALWAYS;
143 default:
144 return GPU_DEPTH_NONE;
145 }
146}
147
161
163{
166 return GPU_STENCIL_ALWAYS;
168 return GPU_STENCIL_EQUAL;
170 return GPU_STENCIL_NEQUAL;
171 default:
172 return GPU_STENCIL_NONE;
173 }
174}
175
205
215
218}; // namespace blender::draw
#define ENUM_OPERATORS(_type, _max)
eGPUBlend
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
eGPUWriteMask
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
eGPUProvokingVertex
Definition GPU_state.hh:138
@ GPU_VERTEX_LAST
Definition GPU_state.hh:139
@ GPU_VERTEX_FIRST
Definition GPU_state.hh:140
eGPUFaceCullTest
Definition GPU_state.hh:132
@ GPU_CULL_FRONT
Definition GPU_state.hh:134
@ GPU_CULL_NONE
Definition GPU_state.hh:133
@ GPU_CULL_BACK
Definition GPU_state.hh:135
eGPUStencilOp
Definition GPU_state.hh:124
@ GPU_STENCIL_OP_COUNT_DEPTH_FAIL
Definition GPU_state.hh:129
@ GPU_STENCIL_OP_COUNT_DEPTH_PASS
Definition GPU_state.hh:128
@ GPU_STENCIL_OP_REPLACE
Definition GPU_state.hh:126
@ GPU_STENCIL_OP_NONE
Definition GPU_state.hh:125
eGPUDepthTest
Definition GPU_state.hh:107
@ GPU_DEPTH_GREATER
Definition GPU_state.hh:113
@ GPU_DEPTH_EQUAL
Definition GPU_state.hh:112
@ GPU_DEPTH_ALWAYS
Definition GPU_state.hh:109
@ GPU_DEPTH_GREATER_EQUAL
Definition GPU_state.hh:114
@ GPU_DEPTH_LESS
Definition GPU_state.hh:110
@ GPU_DEPTH_LESS_EQUAL
Definition GPU_state.hh:111
@ GPU_DEPTH_NONE
Definition GPU_state.hh:108
eGPUStencilTest
Definition GPU_state.hh:117
@ GPU_STENCIL_EQUAL
Definition GPU_state.hh:120
@ GPU_STENCIL_NEQUAL
Definition GPU_state.hh:121
@ GPU_STENCIL_ALWAYS
Definition GPU_state.hh:119
@ GPU_STENCIL_NONE
Definition GPU_state.hh:118
#define DRW_STATE_WRITE_STENCIL_ENABLED
Definition draw_state.hh:91
DRWState
Definition draw_state.hh:25
@ DRW_STATE_STENCIL_EQUAL
Definition draw_state.hh:47
@ DRW_STATE_CLIP_PLANES
Definition draw_state.hh:69
@ 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:67
@ 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:72
@ DRW_STATE_WRITE_DEPTH
Definition draw_state.hh:29
@ 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:68
@ 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:70
@ 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_STENCIL_TEST_ENABLED
Definition draw_state.hh:89
#define DRW_STATE_DEPTH_TEST_ENABLED
Definition draw_state.hh:86
#define DRW_STATE_BLEND_ENABLED
Definition draw_state.hh:79
static ulong state[N]
static eGPUDepthTest to_depth_test(DRWState state)
static eGPUBlend to_blend(DRWState state)
static eGPUProvokingVertex to_provoking_vertex(DRWState state)
static eGPUStencilOp to_stencil_op(DRWState state)
static eGPUStencilTest to_stencil_test(DRWState state)
static eGPUWriteMask to_write_mask(DRWState state)
static eGPUFaceCullTest to_face_cull_test(DRWState state)