Blender  V2.93
gl_state.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2020, Blender Foundation.
17  */
18 
23 #include "BKE_global.h"
24 
25 #include "BLI_math_base.h"
26 #include "BLI_math_bits.h"
27 
28 #include "GPU_capabilities.h"
29 
30 #include "glew-mx.h"
31 
32 #include "gl_context.hh"
33 #include "gl_debug.hh"
34 #include "gl_framebuffer.hh"
35 #include "gl_texture.hh"
36 
37 #include "gl_state.hh"
38 
39 namespace blender::gpu {
40 
41 /* -------------------------------------------------------------------- */
46 {
47  /* Set other states that never change. */
48  glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
49  glEnable(GL_MULTISAMPLE);
50  glEnable(GL_PRIMITIVE_RESTART);
51 
52  glDisable(GL_DITHER);
53 
54  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
55  glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
56 
57  glPrimitiveRestartIndex((GLuint)0xFFFFFFFF);
58  /* TODO: Should become default. But needs at least GL 4.3 */
60  /* Takes precedence over #GL_PRIMITIVE_RESTART. */
61  glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
62  }
63 
64  /* Limits. */
65  glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, line_width_range_);
66 
67  /* Force update using default state. */
68  current_ = ~state;
69  current_mutable_ = ~mutable_state;
70  set_state(state);
71  set_mutable_state(mutable_state);
72 }
73 
75 {
76  if (!this->use_bgl) {
77  this->set_state(this->state);
78  this->set_mutable_state(this->mutable_state);
79  this->texture_bind_apply();
80  this->image_bind_apply();
81  }
82  /* This is needed by gpu_py_offscreen. */
84 };
85 
86 /* Will set all the states regardless of the current ones. */
88 {
89  /* Little exception for clip distances since they need to keep the old count correct. */
90  uint32_t clip_distances = current_.clip_distances;
91  current_ = ~this->state;
92  current_.clip_distances = clip_distances;
93  current_mutable_ = ~this->mutable_state;
94  this->set_state(this->state);
95  this->set_mutable_state(this->mutable_state);
96 };
97 
98 void GLStateManager::set_state(const GPUState &state)
99 {
100  GPUState changed = state ^ current_;
101 
102  if (changed.blend != 0) {
103  set_blend((eGPUBlend)state.blend);
104  }
105  if (changed.write_mask != 0) {
106  set_write_mask((eGPUWriteMask)state.write_mask);
107  }
108  if (changed.depth_test != 0) {
109  set_depth_test((eGPUDepthTest)state.depth_test);
110  }
111  if (changed.stencil_test != 0 || changed.stencil_op != 0) {
113  set_stencil_mask((eGPUStencilTest)state.stencil_test, mutable_state);
114  }
115  if (changed.clip_distances != 0) {
116  set_clip_distances(state.clip_distances, current_.clip_distances);
117  }
118  if (changed.culling_test != 0) {
119  set_backface_culling((eGPUFaceCullTest)state.culling_test);
120  }
121  if (changed.logic_op_xor != 0) {
122  set_logic_op(state.logic_op_xor);
123  }
124  if (changed.invert_facing != 0) {
125  set_facing(state.invert_facing);
126  }
127  if (changed.provoking_vert != 0) {
128  set_provoking_vert((eGPUProvokingVertex)state.provoking_vert);
129  }
130  if (changed.shadow_bias != 0) {
131  set_shadow_bias(state.shadow_bias);
132  }
133 
134  /* TODO remove */
135  if (changed.polygon_smooth) {
136  if (state.polygon_smooth) {
137  glEnable(GL_POLYGON_SMOOTH);
138  }
139  else {
140  glDisable(GL_POLYGON_SMOOTH);
141  }
142  }
143  if (changed.line_smooth) {
144  if (state.line_smooth) {
145  glEnable(GL_LINE_SMOOTH);
146  }
147  else {
148  glDisable(GL_LINE_SMOOTH);
149  }
150  }
151 
152  current_ = state;
153 }
154 
155 void GLStateManager::set_mutable_state(const GPUStateMutable &state)
156 {
157  GPUStateMutable changed = state ^ current_mutable_;
158 
159  /* TODO remove, should be uniform. */
160  if (float_as_uint(changed.point_size) != 0) {
161  if (state.point_size > 0.0f) {
162  glEnable(GL_PROGRAM_POINT_SIZE);
163  }
164  else {
165  glDisable(GL_PROGRAM_POINT_SIZE);
166  glPointSize(fabsf(state.point_size));
167  }
168  }
169 
170  if (changed.line_width != 0) {
171  /* TODO remove, should use wide line shader. */
172  glLineWidth(clamp_f(state.line_width, line_width_range_[0], line_width_range_[1]));
173  }
174 
175  if (changed.depth_range[0] != 0 || changed.depth_range[1] != 0) {
176  /* TODO remove, should modify the projection matrix instead. */
177  glDepthRange(UNPACK2(state.depth_range));
178  }
179 
180  if (changed.stencil_compare_mask != 0 || changed.stencil_reference != 0 ||
181  changed.stencil_write_mask != 0) {
182  set_stencil_mask((eGPUStencilTest)current_.stencil_test, state);
183  }
184 
185  current_mutable_ = state;
186 }
187 
190 /* -------------------------------------------------------------------- */
194 void GLStateManager::set_write_mask(const eGPUWriteMask value)
195 {
196  glDepthMask((value & GPU_WRITE_DEPTH) != 0);
197  glColorMask((value & GPU_WRITE_RED) != 0,
198  (value & GPU_WRITE_GREEN) != 0,
199  (value & GPU_WRITE_BLUE) != 0,
200  (value & GPU_WRITE_ALPHA) != 0);
201 
202  if (value == GPU_WRITE_NONE) {
203  glEnable(GL_RASTERIZER_DISCARD);
204  }
205  else {
206  glDisable(GL_RASTERIZER_DISCARD);
207  }
208 }
209 
210 void GLStateManager::set_depth_test(const eGPUDepthTest value)
211 {
212  GLenum func;
213  switch (value) {
214  case GPU_DEPTH_LESS:
215  func = GL_LESS;
216  break;
218  func = GL_LEQUAL;
219  break;
220  case GPU_DEPTH_EQUAL:
221  func = GL_EQUAL;
222  break;
223  case GPU_DEPTH_GREATER:
224  func = GL_GREATER;
225  break;
227  func = GL_GEQUAL;
228  break;
229  case GPU_DEPTH_ALWAYS:
230  default:
231  func = GL_ALWAYS;
232  break;
233  }
234 
235  if (value != GPU_DEPTH_NONE) {
236  glEnable(GL_DEPTH_TEST);
237  glDepthFunc(func);
238  }
239  else {
240  glDisable(GL_DEPTH_TEST);
241  }
242 }
243 
244 void GLStateManager::set_stencil_test(const eGPUStencilTest test, const eGPUStencilOp operation)
245 {
246  switch (operation) {
248  glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
249  break;
251  glStencilOpSeparate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR_WRAP);
252  glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR_WRAP);
253  break;
255  glStencilOpSeparate(GL_BACK, GL_KEEP, GL_DECR_WRAP, GL_KEEP);
256  glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_KEEP);
257  break;
258  case GPU_STENCIL_OP_NONE:
259  default:
260  glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
261  }
262 
263  if (test != GPU_STENCIL_NONE) {
264  glEnable(GL_STENCIL_TEST);
265  }
266  else {
267  glDisable(GL_STENCIL_TEST);
268  }
269 }
270 
271 void GLStateManager::set_stencil_mask(const eGPUStencilTest test, const GPUStateMutable state)
272 {
273  GLenum func;
274  switch (test) {
275  case GPU_STENCIL_NEQUAL:
276  func = GL_NOTEQUAL;
277  break;
278  case GPU_STENCIL_EQUAL:
279  func = GL_EQUAL;
280  break;
281  case GPU_STENCIL_ALWAYS:
282  func = GL_ALWAYS;
283  break;
284  case GPU_STENCIL_NONE:
285  default:
286  glStencilMask(0x00);
287  glStencilFunc(GL_ALWAYS, 0x00, 0x00);
288  return;
289  }
290 
291  glStencilMask(state.stencil_write_mask);
292  glStencilFunc(func, state.stencil_reference, state.stencil_compare_mask);
293 }
294 
295 void GLStateManager::set_clip_distances(const int new_dist_len, const int old_dist_len)
296 {
297  for (int i = 0; i < new_dist_len; i++) {
298  glEnable(GL_CLIP_DISTANCE0 + i);
299  }
300  for (int i = new_dist_len; i < old_dist_len; i++) {
301  glDisable(GL_CLIP_DISTANCE0 + i);
302  }
303 }
304 
305 void GLStateManager::set_logic_op(const bool enable)
306 {
307  if (enable) {
308  glEnable(GL_COLOR_LOGIC_OP);
309  glLogicOp(GL_XOR);
310  }
311  else {
312  glDisable(GL_COLOR_LOGIC_OP);
313  }
314 }
315 
316 void GLStateManager::set_facing(const bool invert)
317 {
318  glFrontFace((invert) ? GL_CW : GL_CCW);
319 }
320 
321 void GLStateManager::set_backface_culling(const eGPUFaceCullTest test)
322 {
323  if (test != GPU_CULL_NONE) {
324  glEnable(GL_CULL_FACE);
325  glCullFace((test == GPU_CULL_FRONT) ? GL_FRONT : GL_BACK);
326  }
327  else {
328  glDisable(GL_CULL_FACE);
329  }
330 }
331 
332 void GLStateManager::set_provoking_vert(const eGPUProvokingVertex vert)
333 {
334  GLenum value = (vert == GPU_VERTEX_FIRST) ? GL_FIRST_VERTEX_CONVENTION :
335  GL_LAST_VERTEX_CONVENTION;
336  glProvokingVertex(value);
337 }
338 
339 void GLStateManager::set_shadow_bias(const bool enable)
340 {
341  if (enable) {
342  glEnable(GL_POLYGON_OFFSET_FILL);
343  glEnable(GL_POLYGON_OFFSET_LINE);
344  /* 2.0 Seems to be the lowest possible slope bias that works in every case. */
345  glPolygonOffset(2.0f, 1.0f);
346  }
347  else {
348  glDisable(GL_POLYGON_OFFSET_FILL);
349  glDisable(GL_POLYGON_OFFSET_LINE);
350  }
351 }
352 
353 void GLStateManager::set_blend(const eGPUBlend value)
354 {
362  GLenum src_rgb, src_alpha, dst_rgb, dst_alpha;
363  switch (value) {
364  default:
365  case GPU_BLEND_ALPHA: {
366  src_rgb = GL_SRC_ALPHA;
367  dst_rgb = GL_ONE_MINUS_SRC_ALPHA;
368  src_alpha = GL_ONE;
369  dst_alpha = GL_ONE_MINUS_SRC_ALPHA;
370  break;
371  }
373  src_rgb = GL_ONE;
374  dst_rgb = GL_ONE_MINUS_SRC_ALPHA;
375  src_alpha = GL_ONE;
376  dst_alpha = GL_ONE_MINUS_SRC_ALPHA;
377  break;
378  }
379  case GPU_BLEND_ADDITIVE: {
380  /* Do not let alpha accumulate but premult the source RGB by it. */
381  src_rgb = GL_SRC_ALPHA;
382  dst_rgb = GL_ONE;
383  src_alpha = GL_ZERO;
384  dst_alpha = GL_ONE;
385  break;
386  }
387  case GPU_BLEND_SUBTRACT:
389  /* Let alpha accumulate. */
390  src_rgb = GL_ONE;
391  dst_rgb = GL_ONE;
392  src_alpha = GL_ONE;
393  dst_alpha = GL_ONE;
394  break;
395  }
396  case GPU_BLEND_MULTIPLY: {
397  src_rgb = GL_DST_COLOR;
398  dst_rgb = GL_ZERO;
399  src_alpha = GL_DST_ALPHA;
400  dst_alpha = GL_ZERO;
401  break;
402  }
403  case GPU_BLEND_INVERT: {
404  src_rgb = GL_ONE_MINUS_DST_COLOR;
405  dst_rgb = GL_ZERO;
406  src_alpha = GL_ZERO;
407  dst_alpha = GL_ONE;
408  break;
409  }
410  case GPU_BLEND_OIT: {
411  src_rgb = GL_ONE;
412  dst_rgb = GL_ONE;
413  src_alpha = GL_ZERO;
414  dst_alpha = GL_ONE_MINUS_SRC_ALPHA;
415  break;
416  }
417  case GPU_BLEND_BACKGROUND: {
418  src_rgb = GL_ONE_MINUS_DST_ALPHA;
419  dst_rgb = GL_SRC_ALPHA;
420  src_alpha = GL_ZERO;
421  dst_alpha = GL_SRC_ALPHA;
422  break;
423  }
425  src_rgb = GL_ONE_MINUS_DST_ALPHA;
426  dst_rgb = GL_ONE;
427  src_alpha = GL_ONE_MINUS_DST_ALPHA;
428  dst_alpha = GL_ONE;
429  break;
430  }
431  case GPU_BLEND_CUSTOM: {
432  src_rgb = GL_ONE;
433  dst_rgb = GL_SRC1_COLOR;
434  src_alpha = GL_ONE;
435  dst_alpha = GL_SRC1_ALPHA;
436  break;
437  }
438  }
439 
440  if (value == GPU_BLEND_SUBTRACT) {
441  glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
442  }
443  else {
444  glBlendEquation(GL_FUNC_ADD);
445  }
446 
447  /* Always set the blend function. This avoid a rendering error when blending is disabled but
448  * GPU_BLEND_CUSTOM was used just before and the frame-buffer is using more than 1 color target.
449  */
450  glBlendFuncSeparate(src_rgb, dst_rgb, src_alpha, dst_alpha);
451  if (value != GPU_BLEND_NONE) {
452  glEnable(GL_BLEND);
453  }
454  else {
455  glDisable(GL_BLEND);
456  }
457 }
458 
461 /* -------------------------------------------------------------------- */
465 void GLStateManager::texture_bind(Texture *tex_, eGPUSamplerState sampler_type, int unit)
466 {
467  BLI_assert(unit < GPU_max_textures());
468  GLTexture *tex = static_cast<GLTexture *>(tex_);
469  if (G.debug & G_DEBUG_GPU) {
470  tex->check_feedback_loop();
471  }
472  /* Eliminate redundant binds. */
473  if ((textures_[unit] == tex->tex_id_) &&
474  (samplers_[unit] == GLTexture::samplers_[sampler_type])) {
475  return;
476  }
477  targets_[unit] = tex->target_;
478  textures_[unit] = tex->tex_id_;
479  samplers_[unit] = GLTexture::samplers_[sampler_type];
480  tex->is_bound_ = true;
481  dirty_texture_binds_ |= 1ULL << unit;
482 }
483 
484 /* Bind the texture to slot 0 for editing purpose. Used by legacy pipeline. */
486 {
487  glActiveTexture(GL_TEXTURE0);
488  glBindTexture(tex->target_, tex->tex_id_);
489  /* Will reset the first texture that was originally bound to slot 0 back before drawing. */
490  dirty_texture_binds_ |= 1ULL;
491  /* NOTE: This might leave this texture attached to this target even after update.
492  * In practice it is not causing problems as we have incorrect binding detection
493  * at higher level. */
494 }
495 
497 {
498  GLTexture *tex = static_cast<GLTexture *>(tex_);
499  if (!tex->is_bound_) {
500  return;
501  }
502 
503  GLuint tex_id = tex->tex_id_;
504  for (int i = 0; i < ARRAY_SIZE(textures_); i++) {
505  if (textures_[i] == tex_id) {
506  textures_[i] = 0;
507  samplers_[i] = 0;
508  dirty_texture_binds_ |= 1ULL << i;
509  }
510  }
511  tex->is_bound_ = false;
512 }
513 
515 {
516  for (int i = 0; i < ARRAY_SIZE(textures_); i++) {
517  if (textures_[i] != 0) {
518  textures_[i] = 0;
519  samplers_[i] = 0;
520  dirty_texture_binds_ |= 1ULL << i;
521  }
522  }
523  this->texture_bind_apply();
524 }
525 
526 void GLStateManager::texture_bind_apply()
527 {
528  if (dirty_texture_binds_ == 0) {
529  return;
530  }
531  uint64_t dirty_bind = dirty_texture_binds_;
532  dirty_texture_binds_ = 0;
533 
534  int first = bitscan_forward_uint64(dirty_bind);
535  int last = 64 - bitscan_reverse_uint64(dirty_bind);
536  int count = last - first;
537 
539  glBindTextures(first, count, textures_ + first);
540  glBindSamplers(first, count, samplers_ + first);
541  }
542  else {
543  for (int unit = first; unit < last; unit++) {
544  if ((dirty_bind >> unit) & 1UL) {
545  glActiveTexture(GL_TEXTURE0 + unit);
546  glBindTexture(targets_[unit], textures_[unit]);
547  glBindSampler(unit, samplers_[unit]);
548  }
549  }
550  }
551 }
552 
554 {
555  glPixelStorei(GL_UNPACK_ROW_LENGTH, len);
556 }
557 
559 {
560  uint64_t bound_slots = 0;
561  for (int i = 0; i < ARRAY_SIZE(textures_); i++) {
562  if (textures_[i] != 0) {
563  bound_slots |= 1ULL << i;
564  }
565  }
566  return bound_slots;
567 }
568 
571 /* -------------------------------------------------------------------- */
575 void GLStateManager::image_bind(Texture *tex_, int unit)
576 {
577  /* Minimum support is 8 image in the fragment shader. No image for other stages. */
579  GLTexture *tex = static_cast<GLTexture *>(tex_);
580  if (G.debug & G_DEBUG_GPU) {
581  tex->check_feedback_loop();
582  }
583  images_[unit] = tex->tex_id_;
584  formats_[unit] = to_gl_internal_format(tex->format_);
585  tex->is_bound_ = true;
586  dirty_image_binds_ |= 1ULL << unit;
587 }
588 
590 {
591  GLTexture *tex = static_cast<GLTexture *>(tex_);
592  if (!tex->is_bound_) {
593  return;
594  }
595 
596  GLuint tex_id = tex->tex_id_;
597  for (int i = 0; i < ARRAY_SIZE(images_); i++) {
598  if (images_[i] == tex_id) {
599  images_[i] = 0;
600  dirty_image_binds_ |= 1ULL << i;
601  }
602  }
603  tex->is_bound_ = false;
604 }
605 
607 {
608  for (int i = 0; i < ARRAY_SIZE(images_); i++) {
609  if (images_[i] != 0) {
610  images_[i] = 0;
611  dirty_image_binds_ |= 1ULL << i;
612  }
613  }
614  this->image_bind_apply();
615 }
616 
617 void GLStateManager::image_bind_apply()
618 {
619  if (dirty_image_binds_ == 0) {
620  return;
621  }
622  uint32_t dirty_bind = dirty_image_binds_;
623  dirty_image_binds_ = 0;
624 
625  int first = bitscan_forward_uint(dirty_bind);
626  int last = 32 - bitscan_reverse_uint(dirty_bind);
627  int count = last - first;
628 
630  glBindImageTextures(first, count, images_ + first);
631  }
632  else {
633  for (int unit = first; unit < last; unit++) {
634  if ((dirty_bind >> unit) & 1UL) {
635  glBindImageTexture(unit, images_[unit], 0, GL_TRUE, 0, GL_READ_WRITE, formats_[unit]);
636  }
637  }
638  }
639 }
640 
642 {
643  uint8_t bound_slots = 0;
644  for (int i = 0; i < ARRAY_SIZE(images_); i++) {
645  if (images_[i] != 0) {
646  bound_slots |= 1ULL << i;
647  }
648  }
649  return bound_slots;
650 }
651 
654 /* -------------------------------------------------------------------- */
659 {
660  glMemoryBarrier(to_gl(barrier_bits));
661 }
662 
665 } // namespace blender::gpu
@ G_DEBUG_GPU
Definition: BKE_global.h:151
#define BLI_assert(a)
Definition: BLI_assert.h:58
MINLINE float clamp_f(float value, float min, float max)
MINLINE unsigned int bitscan_forward_uint(unsigned int a)
MINLINE unsigned int float_as_uint(float f)
MINLINE unsigned int bitscan_reverse_uint(unsigned int a)
MINLINE unsigned int bitscan_forward_uint64(unsigned long long a)
MINLINE unsigned int bitscan_reverse_uint64(unsigned long long a)
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNPACK2(a)
#define ARRAY_SIZE(arr)
bool GPU_shader_image_load_store_support(void)
int GPU_max_textures(void)
#define glEnable
#define glDisable
eGPUBlend
Definition: GPU_state.h:54
@ GPU_BLEND_ADDITIVE_PREMULT
Definition: GPU_state.h:60
@ GPU_BLEND_INVERT
Definition: GPU_state.h:65
@ GPU_BLEND_OIT
Definition: GPU_state.h:68
@ GPU_BLEND_MULTIPLY
Definition: GPU_state.h:61
@ GPU_BLEND_NONE
Definition: GPU_state.h:55
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:57
@ GPU_BLEND_CUSTOM
Definition: GPU_state.h:73
@ GPU_BLEND_ADDITIVE
Definition: GPU_state.h:59
@ GPU_BLEND_SUBTRACT
Definition: GPU_state.h:62
@ GPU_BLEND_ALPHA_UNDER_PREMUL
Definition: GPU_state.h:74
@ GPU_BLEND_BACKGROUND
Definition: GPU_state.h:70
@ GPU_BLEND_ALPHA_PREMULT
Definition: GPU_state.h:58
eGPUWriteMask
Definition: GPU_state.h:25
@ GPU_WRITE_RED
Definition: GPU_state.h:27
@ GPU_WRITE_NONE
Definition: GPU_state.h:26
@ GPU_WRITE_GREEN
Definition: GPU_state.h:28
@ GPU_WRITE_BLUE
Definition: GPU_state.h:29
@ GPU_WRITE_DEPTH
Definition: GPU_state.h:31
@ GPU_WRITE_ALPHA
Definition: GPU_state.h:30
eGPUProvokingVertex
Definition: GPU_state.h:108
@ GPU_VERTEX_FIRST
Definition: GPU_state.h:110
eGPUFaceCullTest
Definition: GPU_state.h:102
@ GPU_CULL_FRONT
Definition: GPU_state.h:104
@ GPU_CULL_NONE
Definition: GPU_state.h:103
eGPUBarrier
Definition: GPU_state.h:38
eGPUStencilOp
Definition: GPU_state.h:94
@ GPU_STENCIL_OP_COUNT_DEPTH_FAIL
Definition: GPU_state.h:99
@ GPU_STENCIL_OP_COUNT_DEPTH_PASS
Definition: GPU_state.h:98
@ GPU_STENCIL_OP_REPLACE
Definition: GPU_state.h:96
@ GPU_STENCIL_OP_NONE
Definition: GPU_state.h:95
eGPUDepthTest
Definition: GPU_state.h:77
@ GPU_DEPTH_GREATER
Definition: GPU_state.h:83
@ GPU_DEPTH_EQUAL
Definition: GPU_state.h:82
@ GPU_DEPTH_ALWAYS
Definition: GPU_state.h:79
@ GPU_DEPTH_GREATER_EQUAL
Definition: GPU_state.h:84
@ GPU_DEPTH_LESS
Definition: GPU_state.h:80
@ GPU_DEPTH_LESS_EQUAL
Definition: GPU_state.h:81
@ GPU_DEPTH_NONE
Definition: GPU_state.h:78
eGPUStencilTest
Definition: GPU_state.h:87
@ GPU_STENCIL_EQUAL
Definition: GPU_state.h:90
@ GPU_STENCIL_NEQUAL
Definition: GPU_state.h:91
@ GPU_STENCIL_ALWAYS
Definition: GPU_state.h:89
@ GPU_STENCIL_NONE
Definition: GPU_state.h:88
eGPUSamplerState
Definition: GPU_texture.h:40
static bool fixed_restart_index_support
Definition: gl_context.hh:69
static bool multi_bind_support
Definition: gl_context.hh:70
void texture_bind_temp(GLTexture *tex)
Definition: gl_state.cc:485
GLFrameBuffer * active_fb
Definition: gl_state.hh:46
void image_unbind(Texture *tex) override
Definition: gl_state.cc:589
uint8_t bound_image_slots(void)
Definition: gl_state.cc:641
void image_bind(Texture *tex, int unit) override
Definition: gl_state.cc:575
uint64_t bound_texture_slots(void)
Definition: gl_state.cc:558
void texture_unpack_row_length_set(uint len) override
Definition: gl_state.cc:553
void apply_state(void) override
Definition: gl_state.cc:74
void force_state(void) override
Definition: gl_state.cc:87
void issue_barrier(eGPUBarrier barrier_bits) override
Definition: gl_state.cc:658
void texture_bind(Texture *tex, eGPUSamplerState sampler, int unit) override
Definition: gl_state.cc:465
void texture_unbind_all(void) override
Definition: gl_state.cc:514
void image_unbind_all(void) override
Definition: gl_state.cc:606
void texture_unbind(Texture *tex) override
Definition: gl_state.cc:496
int count
#define fabsf(x)
static ulong state[N]
GLenum to_gl_internal_format(eGPUTextureFormat format)
Definition: gl_texture.hh:96
static GLenum to_gl(const GPUAttachmentType type)
unsigned int uint32_t
Definition: stdint.h:83
unsigned char uint8_t
Definition: stdint.h:81
unsigned __int64 uint64_t
Definition: stdint.h:93
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition: svm_invert.h:19
#define G(x, y, z)
uint len