Blender  V3.3
GPU_state.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include "BLI_utildefines.h"
10 
11 typedef enum eGPUWriteMask {
13  GPU_WRITE_RED = (1 << 0),
14  GPU_WRITE_GREEN = (1 << 1),
15  GPU_WRITE_BLUE = (1 << 2),
16  GPU_WRITE_ALPHA = (1 << 3),
17  GPU_WRITE_DEPTH = (1 << 4),
18  GPU_WRITE_STENCIL = (1 << 5),
21 
23 
24 typedef enum eGPUBarrier {
26  GPU_BARRIER_COMMAND = (1 << 0),
35 
37 
38 /* NOTE: For Metal and Vulkan only.
39  * TODO(Metal): Update barrier calls to use stage flags. */
40 typedef enum eGPUStageBarrierBits {
48 
50 
51 
59 typedef enum eGPUBlend {
81 
82 typedef enum eGPUDepthTest {
84  GPU_DEPTH_ALWAYS, /* Used to draw to the depth buffer without really testing. */
86  GPU_DEPTH_LESS_EQUAL, /* Default. */
91 
92 typedef enum eGPUStencilTest {
98 
99 typedef enum eGPUStencilOp {
106 
107 typedef enum eGPUFaceCullTest {
108  GPU_CULL_NONE = 0, /* Culling disabled. */
112 
113 typedef enum eGPUProvokingVertex {
114  GPU_VERTEX_LAST = 0, /* Default. */
115  GPU_VERTEX_FIRST = 1, /* Follow Blender loop order. */
117 
118 #ifdef __cplusplus
119 extern "C" {
120 #endif
121 
123 void GPU_face_culling(eGPUFaceCullTest culling);
124 void GPU_depth_test(eGPUDepthTest test);
127 void GPU_front_facing(bool invert);
128 void GPU_depth_range(float near, float far);
129 void GPU_scissor_test(bool enable);
130 void GPU_line_smooth(bool enable);
136 void GPU_line_width(float width);
137 void GPU_logic_op_xor_set(bool enable);
138 void GPU_point_size(float size);
139 void GPU_polygon_smooth(bool enable);
140 
148 void GPU_program_point_size(bool enable);
149 void GPU_scissor(int x, int y, int width, int height);
150 void GPU_scissor_get(int coords[4]);
151 void GPU_viewport(int x, int y, int width, int height);
152 void GPU_viewport_size_get_f(float coords[4]);
153 void GPU_viewport_size_get_i(int coords[4]);
155 void GPU_color_mask(bool r, bool g, bool b, bool a);
156 void GPU_depth_mask(bool depth);
157 bool GPU_depth_mask_get(void);
158 void GPU_shadow_offset(bool enable);
159 void GPU_clip_distances(int distances_enabled);
160 bool GPU_mipmap_enabled(void);
161 void GPU_state_set(eGPUWriteMask write_mask,
163  eGPUFaceCullTest culling_test,
164  eGPUDepthTest depth_test,
165  eGPUStencilTest stencil_test,
166  eGPUStencilOp stencil_op,
167  eGPUProvokingVertex provoking_vert);
168 
169 void GPU_stencil_reference_set(uint reference);
170 void GPU_stencil_write_mask_set(uint write_mask);
171 void GPU_stencil_compare_mask_set(uint compare_mask);
172 
182 float GPU_line_width_get(void);
183 
184 void GPU_flush(void);
185 void GPU_finish(void);
186 void GPU_apply_state(void);
187 
188 void GPU_bgl_start(void);
189 
193 void GPU_bgl_end(void);
194 bool GPU_bgl_get(void);
195 
196 void GPU_memory_barrier(eGPUBarrier barrier);
197 
198 #ifdef __cplusplus
199 }
200 #endif
unsigned int uint
Definition: BLI_sys_types.h:67
#define ENUM_OPERATORS(_type, _max)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void GPU_memory_barrier(eGPUBarrier barrier)
Definition: gpu_state.cc:371
void GPU_program_point_size(bool enable)
Definition: gpu_state.cc:172
void GPU_face_culling(eGPUFaceCullTest culling)
Definition: gpu_state.cc:44
eGPUBlend
Definition: GPU_state.h:59
@ GPU_BLEND_ADDITIVE_PREMULT
Definition: GPU_state.h:65
@ GPU_BLEND_INVERT
Definition: GPU_state.h:70
@ GPU_BLEND_OIT
Definition: GPU_state.h:73
@ GPU_BLEND_MULTIPLY
Definition: GPU_state.h:66
@ GPU_BLEND_NONE
Definition: GPU_state.h:60
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:62
@ GPU_BLEND_CUSTOM
Definition: GPU_state.h:78
@ GPU_BLEND_ADDITIVE
Definition: GPU_state.h:64
@ GPU_BLEND_SUBTRACT
Definition: GPU_state.h:67
@ GPU_BLEND_ALPHA_UNDER_PREMUL
Definition: GPU_state.h:79
@ GPU_BLEND_BACKGROUND
Definition: GPU_state.h:75
@ GPU_BLEND_ALPHA_PREMULT
Definition: GPU_state.h:63
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:39
void GPU_bgl_end(void)
Definition: gpu_state.cc:346
void GPU_write_mask(eGPUWriteMask mask)
Definition: gpu_state.cc:90
void GPU_scissor_test(bool enable)
Definition: gpu_state.cc:180
void GPU_bgl_start(void)
Definition: gpu_state.cc:316
void GPU_line_width(float width)
Definition: gpu_state.cc:158
void GPU_apply_state(void)
Definition: gpu_state.cc:301
eGPUWriteMask
Definition: GPU_state.h:11
@ GPU_WRITE_RED
Definition: GPU_state.h:13
@ GPU_WRITE_STENCIL
Definition: GPU_state.h:18
@ GPU_WRITE_NONE
Definition: GPU_state.h:12
@ GPU_WRITE_GREEN
Definition: GPU_state.h:14
@ GPU_WRITE_BLUE
Definition: GPU_state.h:15
@ GPU_WRITE_DEPTH
Definition: GPU_state.h:17
@ GPU_WRITE_COLOR
Definition: GPU_state.h:19
@ GPU_WRITE_ALPHA
Definition: GPU_state.h:16
float GPU_line_width_get(void)
Definition: gpu_state.cc:248
void GPU_line_smooth(bool enable)
Definition: gpu_state.cc:75
eGPUProvokingVertex
Definition: GPU_state.h:113
@ GPU_VERTEX_LAST
Definition: GPU_state.h:114
@ GPU_VERTEX_FIRST
Definition: GPU_state.h:115
void GPU_logic_op_xor_set(bool enable)
Definition: gpu_state.cc:85
uint GPU_stencil_mask_get(void)
Definition: gpu_state.cc:230
void GPU_depth_mask(bool depth)
Definition: gpu_state.cc:107
void GPU_stencil_test(eGPUStencilTest test)
Definition: gpu_state.cc:70
void GPU_stencil_write_mask_set(uint write_mask)
Definition: gpu_state.cc:202
void GPU_flush(void)
Definition: gpu_state.cc:291
bool GPU_bgl_get(void)
Definition: gpu_state.cc:360
eGPUStageBarrierBits
Definition: GPU_state.h:40
@ GPU_BARRIER_STAGE_COMPUTE
Definition: GPU_state.h:43
@ GPU_BARRIER_STAGE_FRAGMENT
Definition: GPU_state.h:42
@ GPU_BARRIER_STAGE_VERTEX
Definition: GPU_state.h:41
@ GPU_BARRIER_STAGE_ANY
Definition: GPU_state.h:45
@ GPU_BARRIER_STAGE_ANY_GRAPHICS
Definition: GPU_state.h:44
eGPUFaceCullTest
Definition: GPU_state.h:107
@ GPU_CULL_FRONT
Definition: GPU_state.h:109
@ GPU_CULL_NONE
Definition: GPU_state.h:108
@ GPU_CULL_BACK
Definition: GPU_state.h:110
void GPU_finish(void)
Definition: gpu_state.cc:296
void GPU_color_mask(bool r, bool g, bool b, bool a)
Definition: gpu_state.cc:95
void GPU_depth_range(float near, float far)
Definition: gpu_state.cc:151
void GPU_viewport_size_get_i(int coords[4])
Definition: gpu_state.cc:268
void GPU_stencil_reference_set(uint reference)
Definition: gpu_state.cc:197
void GPU_scissor(int x, int y, int width, int height)
Definition: gpu_state.cc:185
eGPUBlend GPU_blend_get(void)
Definition: gpu_state.cc:218
eGPUBarrier
Definition: GPU_state.h:24
@ GPU_BARRIER_COMMAND
Definition: GPU_state.h:26
@ GPU_BARRIER_SHADER_STORAGE
Definition: GPU_state.h:29
@ GPU_BARRIER_TEXTURE_FETCH
Definition: GPU_state.h:30
@ GPU_BARRIER_NONE
Definition: GPU_state.h:25
@ GPU_BARRIER_ELEMENT_ARRAY
Definition: GPU_state.h:33
@ GPU_BARRIER_SHADER_IMAGE_ACCESS
Definition: GPU_state.h:28
@ GPU_BARRIER_VERTEX_ATTRIB_ARRAY
Definition: GPU_state.h:32
@ GPU_BARRIER_TEXTURE_UPDATE
Definition: GPU_state.h:31
@ GPU_BARRIER_FRAMEBUFFER
Definition: GPU_state.h:27
eGPUFaceCullTest GPU_face_culling_get(void)
Definition: gpu_state.cc:49
eGPUStencilOp
Definition: GPU_state.h:99
@ GPU_STENCIL_OP_COUNT_DEPTH_FAIL
Definition: GPU_state.h:104
@ GPU_STENCIL_OP_COUNT_DEPTH_PASS
Definition: GPU_state.h:103
@ GPU_STENCIL_OP_REPLACE
Definition: GPU_state.h:101
@ GPU_STENCIL_OP_NONE
Definition: GPU_state.h:100
void GPU_stencil_compare_mask_set(uint compare_mask)
Definition: gpu_state.cc:207
void GPU_front_facing(bool invert)
Definition: gpu_state.cc:55
eGPUWriteMask GPU_write_mask_get(void)
Definition: gpu_state.cc:224
void GPU_viewport(int x, int y, int width, int height)
Definition: gpu_state.cc:191
eGPUStencilTest GPU_stencil_test_get(void)
Definition: gpu_state.cc:242
void GPU_point_size(float size)
Definition: gpu_state.cc:164
bool GPU_depth_mask_get(void)
Definition: gpu_state.cc:273
eGPUDepthTest
Definition: GPU_state.h:82
@ GPU_DEPTH_GREATER
Definition: GPU_state.h:88
@ GPU_DEPTH_EQUAL
Definition: GPU_state.h:87
@ GPU_DEPTH_ALWAYS
Definition: GPU_state.h:84
@ GPU_DEPTH_GREATER_EQUAL
Definition: GPU_state.h:89
@ GPU_DEPTH_LESS
Definition: GPU_state.h:85
@ GPU_DEPTH_LESS_EQUAL
Definition: GPU_state.h:86
@ GPU_DEPTH_NONE
Definition: GPU_state.h:83
eGPUDepthTest GPU_depth_test_get(void)
Definition: gpu_state.cc:236
bool GPU_mipmap_enabled(void)
Definition: gpu_state.cc:279
void GPU_state_set(eGPUWriteMask write_mask, eGPUBlend blend, eGPUFaceCullTest culling_test, eGPUDepthTest depth_test, eGPUStencilTest stencil_test, eGPUStencilOp stencil_op, eGPUProvokingVertex provoking_vert)
Definition: gpu_state.cc:126
eGPUStencilTest
Definition: GPU_state.h:92
@ GPU_STENCIL_EQUAL
Definition: GPU_state.h:95
@ GPU_STENCIL_NEQUAL
Definition: GPU_state.h:96
@ GPU_STENCIL_ALWAYS
Definition: GPU_state.h:94
@ GPU_STENCIL_NONE
Definition: GPU_state.h:93
void GPU_depth_test(eGPUDepthTest test)
Definition: gpu_state.cc:65
void GPU_viewport_size_get_f(float coords[4])
Definition: gpu_state.cc:259
void GPU_scissor_get(int coords[4])
Definition: gpu_state.cc:254
void GPU_clip_distances(int distances_enabled)
Definition: gpu_state.cc:121
void GPU_provoking_vertex(eGPUProvokingVertex vert)
Definition: gpu_state.cc:60
void GPU_polygon_smooth(bool enable)
Definition: gpu_state.cc:80
void GPU_shadow_offset(bool enable)
Definition: gpu_state.cc:116
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition: invert.h:8
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static unsigned a[3]
Definition: RandGen.cpp:78
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
static int blend(const Tex *tex, const float texvec[3], TexResult *texres)