Blender  V2.93
gpu_matrix.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  * The Original Code is Copyright (C) 2012 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "gpu_context_private.hh"
25 #include "gpu_matrix_private.h"
26 
27 #define SUPPRESS_GENERIC_MATRIX_API
28 #define USE_GPU_PY_MATRIX_API /* only so values are declared */
29 #include "GPU_matrix.h"
30 #undef USE_GPU_PY_MATRIX_API
31 
32 #include "BLI_math_matrix.h"
33 #include "BLI_math_rotation.h"
34 #include "BLI_math_vector.h"
35 
36 #include "MEM_guardedalloc.h"
37 
38 using namespace blender::gpu;
39 
40 #define MATRIX_STACK_DEPTH 32
41 
42 using Mat4 = float[4][4];
43 using Mat3 = float[3][3];
44 
45 struct MatrixStack {
48 };
49 
53 
54  bool dirty;
55 
56  /* TODO: cache of derived matrices (Normal, MVP, inverse MVP, etc)
57  * generate as needed for shaders, invalidate when original matrices change
58  *
59  * TODO: separate Model from View transform? Batches/objects have model,
60  * camera/eye has view & projection
61  */
62 };
63 
64 #define ModelViewStack Context::get()->matrix_state->model_view_stack
65 #define ModelView ModelViewStack.stack[ModelViewStack.top]
66 
67 #define ProjectionStack Context::get()->matrix_state->projection_stack
68 #define Projection ProjectionStack.stack[ProjectionStack.top]
69 
71 {
72 #define MATRIX_4X4_IDENTITY \
73  { \
74  {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f, 0.0f}, \
75  { \
76  0.0f, 0.0f, 0.0f, 1.0f \
77  } \
78  }
79 
80  GPUMatrixState *state = (GPUMatrixState *)MEM_mallocN(sizeof(*state), __func__);
81  const MatrixStack identity_stack = {{MATRIX_4X4_IDENTITY}, 0};
82 
83  state->model_view_stack = state->projection_stack = identity_stack;
84  state->dirty = true;
85 
86 #undef MATRIX_4X4_IDENTITY
87 
88  return state;
89 }
90 
92 {
94 }
95 
96 static void gpu_matrix_state_active_set_dirty(bool value)
97 {
99  state->dirty = value;
100 }
101 
103 {
105  state->model_view_stack.top = 0;
106  state->projection_stack.top = 0;
110 }
111 
112 #ifdef WITH_GPU_SAFETY
113 
114 /* Check if matrix is numerically good */
115 static void checkmat(cosnt float *m)
116 {
117  const int n = 16;
118  for (int i = 0; i < n; i++) {
119 # if _MSC_VER
120  BLI_assert(_finite(m[i]));
121 # else
122  BLI_assert(!isinf(m[i]));
123 # endif
124  }
125 }
126 
127 # define CHECKMAT(m) checkmat((const float *)m)
128 
129 #else
130 
131 # define CHECKMAT(m)
132 
133 #endif
134 
135 void GPU_matrix_push(void)
136 {
138  ModelViewStack.top++;
140 }
141 
142 void GPU_matrix_pop(void)
143 {
144  BLI_assert(ModelViewStack.top > 0);
145  ModelViewStack.top--;
147 }
148 
150 {
152  ProjectionStack.top++;
154 }
155 
157 {
158  BLI_assert(ProjectionStack.top > 0);
159  ProjectionStack.top--;
161 }
162 
163 void GPU_matrix_set(const float m[4][4])
164 {
165  copy_m4_m4(ModelView, m);
166  CHECKMAT(ModelView3D);
168 }
169 
171 {
173  CHECKMAT(Projection3D);
175 }
176 
177 void GPU_matrix_projection_set(const float m[4][4])
178 {
180  CHECKMAT(Projection3D);
182 }
183 
185 {
188 }
189 
190 void GPU_matrix_translate_2f(float x, float y)
191 {
192  Mat4 m;
193  unit_m4(m);
194  m[3][0] = x;
195  m[3][1] = y;
196  GPU_matrix_mul(m);
197 }
198 
199 void GPU_matrix_translate_2fv(const float vec[2])
200 {
201  GPU_matrix_translate_2f(vec[0], vec[1]);
202 }
203 
204 void GPU_matrix_translate_3f(float x, float y, float z)
205 {
206 #if 1
207  translate_m4(ModelView, x, y, z);
209 #else /* above works well in early testing, below is generic version */
210  Mat4 m;
211  unit_m4(m);
212  m[3][0] = x;
213  m[3][1] = y;
214  m[3][2] = z;
215  GPU_matrix_mul(m);
216 #endif
218 }
219 
220 void GPU_matrix_translate_3fv(const float vec[3])
221 {
222  GPU_matrix_translate_3f(vec[0], vec[1], vec[2]);
223 }
224 
225 void GPU_matrix_scale_1f(float factor)
226 {
227  Mat4 m;
228  scale_m4_fl(m, factor);
229  GPU_matrix_mul(m);
230 }
231 
232 void GPU_matrix_scale_2f(float x, float y)
233 {
234  Mat4 m = {{0.0f}};
235  m[0][0] = x;
236  m[1][1] = y;
237  m[2][2] = 1.0f;
238  m[3][3] = 1.0f;
239  GPU_matrix_mul(m);
240 }
241 
242 void GPU_matrix_scale_2fv(const float vec[2])
243 {
244  GPU_matrix_scale_2f(vec[0], vec[1]);
245 }
246 
247 void GPU_matrix_scale_3f(float x, float y, float z)
248 {
249  Mat4 m = {{0.0f}};
250  m[0][0] = x;
251  m[1][1] = y;
252  m[2][2] = z;
253  m[3][3] = 1.0f;
254  GPU_matrix_mul(m);
255 }
256 
257 void GPU_matrix_scale_3fv(const float vec[3])
258 {
259  GPU_matrix_scale_3f(vec[0], vec[1], vec[2]);
260 }
261 
262 void GPU_matrix_mul(const float m[4][4])
263 {
267 }
268 
270 {
271  /* essentially RotateAxis('Z')
272  * TODO: simpler math for 2D case
273  */
275 }
276 
277 void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
278 {
279  const float axis[3] = {x, y, z};
280  GPU_matrix_rotate_3fv(deg, axis);
281 }
282 
283 void GPU_matrix_rotate_3fv(float deg, const float axis[3])
284 {
285  Mat4 m;
286  axis_angle_to_mat4(m, axis, DEG2RADF(deg));
287  GPU_matrix_mul(m);
288 }
289 
290 void GPU_matrix_rotate_axis(float deg, char axis)
291 {
292  /* rotate_m4 works in place */
293  rotate_m4(ModelView, axis, DEG2RADF(deg));
296 }
297 
298 static void mat4_ortho_set(
299  float m[4][4], float left, float right, float bottom, float top, float near, float far)
300 {
301  m[0][0] = 2.0f / (right - left);
302  m[1][0] = 0.0f;
303  m[2][0] = 0.0f;
304  m[3][0] = -(right + left) / (right - left);
305 
306  m[0][1] = 0.0f;
307  m[1][1] = 2.0f / (top - bottom);
308  m[2][1] = 0.0f;
309  m[3][1] = -(top + bottom) / (top - bottom);
310 
311  m[0][2] = 0.0f;
312  m[1][2] = 0.0f;
313  m[2][2] = -2.0f / (far - near);
314  m[3][2] = -(far + near) / (far - near);
315 
316  m[0][3] = 0.0f;
317  m[1][3] = 0.0f;
318  m[2][3] = 0.0f;
319  m[3][3] = 1.0f;
320 
322 }
323 
324 static void mat4_frustum_set(
325  float m[4][4], float left, float right, float bottom, float top, float near, float far)
326 {
327  m[0][0] = 2.0f * near / (right - left);
328  m[1][0] = 0.0f;
329  m[2][0] = (right + left) / (right - left);
330  m[3][0] = 0.0f;
331 
332  m[0][1] = 0.0f;
333  m[1][1] = 2.0f * near / (top - bottom);
334  m[2][1] = (top + bottom) / (top - bottom);
335  m[3][1] = 0.0f;
336 
337  m[0][2] = 0.0f;
338  m[1][2] = 0.0f;
339  m[2][2] = -(far + near) / (far - near);
340  m[3][2] = -2.0f * far * near / (far - near);
341 
342  m[0][3] = 0.0f;
343  m[1][3] = 0.0f;
344  m[2][3] = -1.0f;
345  m[3][3] = 0.0f;
346 
348 }
349 
350 static void mat4_look_from_origin(float m[4][4], float lookdir[3], float camup[3])
351 {
352  /* This function is loosely based on Mesa implementation.
353  *
354  * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
355  * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
356  *
357  * Permission is hereby granted, free of charge, to any person obtaining a
358  * copy of this software and associated documentation files (the "Software"),
359  * to deal in the Software without restriction, including without limitation
360  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
361  * and/or sell copies of the Software, and to permit persons to whom the
362  * Software is furnished to do so, subject to the following conditions:
363  *
364  * The above copyright notice including the dates of first publication and
365  * either this permission notice or a reference to
366  * http://oss.sgi.com/projects/FreeB/
367  * shall be included in all copies or substantial portions of the Software.
368  *
369  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
370  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
371  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
372  * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
373  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
374  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
375  * SOFTWARE.
376  *
377  * Except as contained in this notice, the name of Silicon Graphics, Inc.
378  * shall not be used in advertising or otherwise to promote the sale, use or
379  * other dealings in this Software without prior written authorization from
380  * Silicon Graphics, Inc.
381  */
382  float side[3];
383 
384  normalize_v3(lookdir);
385 
386  cross_v3_v3v3(side, lookdir, camup);
387 
388  normalize_v3(side);
389 
390  cross_v3_v3v3(camup, side, lookdir);
391 
392  m[0][0] = side[0];
393  m[1][0] = side[1];
394  m[2][0] = side[2];
395  m[3][0] = 0.0f;
396 
397  m[0][1] = camup[0];
398  m[1][1] = camup[1];
399  m[2][1] = camup[2];
400  m[3][1] = 0.0f;
401 
402  m[0][2] = -lookdir[0];
403  m[1][2] = -lookdir[1];
404  m[2][2] = -lookdir[2];
405  m[3][2] = 0.0f;
406 
407  m[0][3] = 0.0f;
408  m[1][3] = 0.0f;
409  m[2][3] = 0.0f;
410  m[3][3] = 1.0f;
411 
413 }
414 
415 void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
416 {
417  mat4_ortho_set(Projection, left, right, bottom, top, near, far);
420 }
421 
422 void GPU_matrix_ortho_set_z(float near, float far)
423 {
425  Projection[2][2] = -2.0f / (far - near);
426  Projection[3][2] = -(far + near) / (far - near);
428 }
429 
430 void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top)
431 {
432  Mat4 m;
433  mat4_ortho_set(m, left, right, bottom, top, -1.0f, 1.0f);
434  CHECKMAT(Projection2D);
436 }
437 
439  float left, float right, float bottom, float top, float near, float far)
440 {
444 }
445 
446 void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far)
447 {
448  float half_height = tanf(fovy * (float)(M_PI / 360.0)) * near;
449  float half_width = half_height * aspect;
450  GPU_matrix_frustum_set(-half_width, +half_width, -half_height, +half_height, near, far);
451 }
452 
453 void GPU_matrix_look_at(float eyeX,
454  float eyeY,
455  float eyeZ,
456  float centerX,
457  float centerY,
458  float centerZ,
459  float upX,
460  float upY,
461  float upZ)
462 {
463  Mat4 cm;
464  float lookdir[3];
465  float camup[3] = {upX, upY, upZ};
466 
467  lookdir[0] = centerX - eyeX;
468  lookdir[1] = centerY - eyeY;
469  lookdir[2] = centerZ - eyeZ;
470 
471  mat4_look_from_origin(cm, lookdir, camup);
472 
473  GPU_matrix_mul(cm);
474  GPU_matrix_translate_3f(-eyeX, -eyeY, -eyeZ);
475 }
476 
477 void GPU_matrix_project(const float world[3],
478  const float model[4][4],
479  const float proj[4][4],
480  const int view[4],
481  float win[3])
482 {
483  float v[4];
484 
485  mul_v4_m4v3(v, model, world);
486  mul_m4_v4(proj, v);
487 
488  if (v[3] != 0.0f) {
489  mul_v3_fl(v, 1.0f / v[3]);
490  }
491 
492  win[0] = view[0] + (view[2] * (v[0] + 1)) * 0.5f;
493  win[1] = view[1] + (view[3] * (v[1] + 1)) * 0.5f;
494  win[2] = (v[2] + 1) * 0.5f;
495 }
496 
513  const struct GPUMatrixUnproject_Precalc *precalc, float co[3])
514 {
515  /* 'precalc->dims' is the result of 'projmat_dimensions(proj, ...)'. */
516  co[0] = precalc->dims.xmin + co[0] * (precalc->dims.xmax - precalc->dims.xmin);
517  co[1] = precalc->dims.ymin + co[1] * (precalc->dims.ymax - precalc->dims.ymin);
518 
519  if (precalc->is_persp) {
520  co[2] = precalc->dims.zmax * precalc->dims.zmin /
521  (precalc->dims.zmax + co[2] * (precalc->dims.zmin - precalc->dims.zmax));
522  co[0] *= co[2];
523  co[1] *= co[2];
524  }
525  else {
526  co[2] = precalc->dims.zmin + co[2] * (precalc->dims.zmax - precalc->dims.zmin);
527  }
528  co[2] *= -1;
529 }
530 
532  const float model[4][4],
533  const float proj[4][4],
534  const int view[4])
535 {
536  precalc->is_persp = proj[3][3] == 0.0f;
538  &precalc->dims.xmin,
539  &precalc->dims.xmax,
540  &precalc->dims.ymin,
541  &precalc->dims.ymax,
542  &precalc->dims.zmin,
543  &precalc->dims.zmax);
544  if (isinf(precalc->dims.zmax)) {
545  /* We cannot retrieve the actual value of the clip_end.
546  * Use `FLT_MAX` to avoid nans. */
547  precalc->dims.zmax = FLT_MAX;
548  }
549  for (int i = 0; i < 4; i++) {
550  precalc->view[i] = (float)view[i];
551  }
552  if (!invert_m4_m4(precalc->model_inverted, model)) {
553  unit_m4(precalc->model_inverted);
554  return false;
555  }
556  return true;
557 }
558 
560  const float win[3],
561  float r_world[3])
562 {
563  float in[3] = {
564  (win[0] - precalc->view[0]) / precalc->view[2],
565  (win[1] - precalc->view[1]) / precalc->view[3],
566  win[2],
567  };
569  mul_v3_m4v3(r_world, precalc->model_inverted, in);
570 }
571 
572 bool GPU_matrix_unproject(const float win[3],
573  const float model[4][4],
574  const float proj[4][4],
575  const int view[4],
576  float r_world[3])
577 {
578  struct GPUMatrixUnproject_Precalc precalc;
579  if (!GPU_matrix_unproject_precalc(&precalc, model, proj, view)) {
580  zero_v3(r_world);
581  return false;
582  }
583  GPU_matrix_unproject_with_precalc(&precalc, win, r_world);
584  return true;
585 }
586 
587 const float (*GPU_matrix_model_view_get(float m[4][4]))[4]
588 {
589  if (m) {
590  copy_m4_m4(m, ModelView);
591  return m;
592  }
593 
594  return ModelView;
595 }
596 
597 const float (*GPU_matrix_projection_get(float m[4][4]))[4]
598 {
599  if (m) {
601  return m;
602  }
603 
604  return Projection;
605 }
606 
607 const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4]
608 {
609  if (m == nullptr) {
610  static Mat4 temp;
611  m = temp;
612  }
613 
615  return m;
616 }
617 
618 const float (*GPU_matrix_normal_get(float m[3][3]))[3]
619 {
620  if (m == nullptr) {
621  static Mat3 temp3;
622  m = temp3;
623  }
624 
625  copy_m3_m4(m, (const float(*)[4])GPU_matrix_model_view_get(nullptr));
626 
627  invert_m3(m);
628  transpose_m3(m);
629 
630  return m;
631 }
632 
633 const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3]
634 {
635  if (m == nullptr) {
636  static Mat3 temp3;
637  m = temp3;
638  }
639 
641  invert_m3(m);
642 
643  return m;
644 }
645 
647 {
648  /* set uniform values to matrix stack values
649  * call this before a draw call if desired matrices are dirty
650  * call glUseProgram before this, as glUniform expects program to be bound
651  */
655 
659 
660  if (MV != -1) {
662  shader, MV, 16, 1, (const float *)GPU_matrix_model_view_get(nullptr));
663  }
664  if (P != -1) {
665  GPU_shader_uniform_vector(shader, P, 16, 1, (const float *)GPU_matrix_projection_get(nullptr));
666  }
667  if (MVP != -1) {
669  shader, MVP, 16, 1, (const float *)GPU_matrix_model_view_projection_get(nullptr));
670  }
671  if (N != -1) {
672  GPU_shader_uniform_vector(shader, N, 9, 1, (const float *)GPU_matrix_normal_get(nullptr));
673  }
674  if (MV_inv != -1) {
675  Mat4 m;
677  invert_m4(m);
678  GPU_shader_uniform_vector(shader, MV_inv, 16, 1, (const float *)m);
679  }
680  if (P_inv != -1) {
681  Mat4 m;
683  invert_m4(m);
684  GPU_shader_uniform_vector(shader, P_inv, 16, 1, (const float *)m);
685  }
686 
688 }
689 
691 {
693  return state->dirty;
694 }
695 
696 /* -------------------------------------------------------------------- */
699 BLI_STATIC_ASSERT(GPU_PY_MATRIX_STACK_LEN + 1 == MATRIX_STACK_DEPTH, "define mismatch");
700 
701 /* Return int since caller is may subtract. */
702 
704 {
706  return (int)state->model_view_stack.top;
707 }
708 
710 {
712  return (int)state->projection_stack.top;
713 }
714 
717 /* -------------------------------------------------------------------- */
724 float GPU_polygon_offset_calc(const float (*winmat)[4], float viewdist, float dist)
725 {
726  /* Seems like we have a factor of 2 more offset than 2.79 for some reason. Correct for this. */
727  dist *= 0.5f;
728 
729  if (winmat[3][3] > 0.5f) {
730 #if 1
731  return 0.00001f * dist * viewdist; // ortho tweaking
732 #else
733  static float depth_fac = 0.0f;
734  if (depth_fac == 0.0f) {
735  /* Hard-code for 24 bit precision. */
736  int depthbits = 24;
737  depth_fac = 1.0f / (float)((1 << depthbits) - 1);
738  }
739  ofs = (-1.0 / winmat[2][2]) * dist * depth_fac;
740 
741  UNUSED_VARS(viewdist);
742 #endif
743  }
744 
745  /* This adjustment effectively results in reducing the Z value by 0.25%.
746  *
747  * winmat[4][3] actually evaluates to `-2 * far * near / (far - near)`,
748  * is very close to -0.2 with default clip range,
749  * and is used as the coefficient multiplied by `w / z`,
750  * thus controlling the z dependent part of the depth value.
751  */
752  return winmat[3][2] * -0.0025f * dist;
753 }
754 
758 void GPU_polygon_offset(float viewdist, float dist)
759 {
760  static float winmat[4][4], offset = 0.0f;
761 
762  if (dist != 0.0f) {
763  /* hack below is to mimic polygon offset */
765 
766  /* dist is from camera to center point */
767 
768  float ofs = GPU_polygon_offset_calc(winmat, viewdist, dist);
769 
770  winmat[3][2] -= ofs;
771  offset += ofs;
772  }
773  else {
774  winmat[3][2] += offset;
775  offset = 0.0;
776  }
777 
779 }
780 
typedef float(TangentPoint)[2]
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define M_PI
Definition: BLI_math_base.h:38
void projmat_dimensions_db(const float projmat[4][4], double *r_left, double *r_right, double *r_bottom, double *r_top, double *r_near, double *r_far)
Definition: math_geom.c:4992
void mul_v4_m4v3(float r[4], const float M[4][4], const float v[3])
Definition: math_matrix.c:892
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:262
bool invert_m4(float R[4][4])
Definition: math_matrix.c:1187
void mul_m4_v4(const float M[4][4], float r[4])
Definition: math_matrix.c:866
void copy_m3_m4(float m1[3][3], const float m2[4][4])
Definition: math_matrix.c:105
void unit_m4(float m[4][4])
Definition: rct.c:1140
void translate_m4(float mat[4][4], float tx, float ty, float tz)
Definition: math_matrix.c:2325
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1278
void scale_m4_fl(float R[4][4], float scale)
Definition: math_matrix.c:2309
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:742
bool invert_m3(float R[3][3])
Definition: math_matrix.c:1152
void transpose_m3(float R[3][3])
Definition: math_matrix.c:1312
void mul_m4_m4_post(float R[4][4], const float B[4][4])
Definition: math_matrix.c:383
void rotate_m4(float mat[4][4], const char axis, const float angle)
Definition: math_matrix.c:2352
#define DEG2RADF(_deg)
void axis_angle_to_mat4(float R[4][4], const float axis[3], const float angle)
MINLINE float normalize_v3(float r[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void zero_v3(float r[3])
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNUSED_VARS(...)
static AppView * view
_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 z
_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 right
_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 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 top
_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 bottom
struct GPUShader GPUShader
Definition: GPU_shader.h:33
void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, int arraysize, const float *value)
Definition: gpu_shader.cc:617
@ GPU_UNIFORM_PROJECTION
Definition: GPU_shader.h:92
@ GPU_UNIFORM_MODELVIEW
Definition: GPU_shader.h:91
@ GPU_UNIFORM_PROJECTION_INV
Definition: GPU_shader.h:99
@ GPU_UNIFORM_MODELVIEW_INV
Definition: GPU_shader.h:98
@ GPU_UNIFORM_NORMAL
Definition: GPU_shader.h:102
@ GPU_UNIFORM_MVP
Definition: GPU_shader.h:94
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
Definition: gpu_shader.cc:558
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v
GPUMatrixState * matrix_state
static Context * get(void)
Definition: gpu_context.cc:88
World world
void GPU_matrix_look_at(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
Definition: gpu_matrix.cc:453
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:142
const float(* GPU_matrix_normal_inverse_get(float m[3][3]))[3]
Definition: gpu_matrix.cc:633
static void gpu_mul_invert_projmat_m4_unmapped_v3_with_precalc(const struct GPUMatrixUnproject_Precalc *precalc, float co[3])
Definition: gpu_matrix.cc:512
bool GPU_matrix_dirty_get(void)
Definition: gpu_matrix.cc:690
void GPU_matrix_translate_2fv(const float vec[2])
Definition: gpu_matrix.cc:199
#define MATRIX_4X4_IDENTITY
const float(* GPU_matrix_projection_get(float m[4][4]))[4]
Definition: gpu_matrix.cc:597
void GPU_matrix_rotate_axis(float deg, char axis)
Definition: gpu_matrix.cc:290
void GPU_matrix_mul(const float m[4][4])
Definition: gpu_matrix.cc:262
float GPU_polygon_offset_calc(const float(*winmat)[4], float viewdist, float dist)
Definition: gpu_matrix.cc:724
static void mat4_frustum_set(float m[4][4], float left, float right, float bottom, float top, float near, float far)
Definition: gpu_matrix.cc:324
bool GPU_matrix_unproject_precalc(struct GPUMatrixUnproject_Precalc *precalc, const float model[4][4], const float proj[4][4], const int view[4])
Definition: gpu_matrix.cc:531
void GPU_matrix_projection_set(const float m[4][4])
Definition: gpu_matrix.cc:177
void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
Definition: gpu_matrix.cc:415
void GPU_matrix_scale_2f(float x, float y)
Definition: gpu_matrix.cc:232
void GPU_matrix_bind(GPUShader *shader)
Definition: gpu_matrix.cc:646
void GPU_matrix_set(const float m[4][4])
Definition: gpu_matrix.cc:163
#define CHECKMAT(m)
Definition: gpu_matrix.cc:131
void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far)
Definition: gpu_matrix.cc:446
void GPU_matrix_identity_projection_set(void)
Definition: gpu_matrix.cc:170
void GPU_matrix_pop_projection(void)
Definition: gpu_matrix.cc:156
int GPU_matrix_stack_level_get_projection(void)
Definition: gpu_matrix.cc:709
void GPU_matrix_scale_2fv(const float vec[2])
Definition: gpu_matrix.cc:242
void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far)
Definition: gpu_matrix.cc:438
void GPU_matrix_ortho_set_z(float near, float far)
Definition: gpu_matrix.cc:422
void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top)
Definition: gpu_matrix.cc:430
GPUMatrixState * GPU_matrix_state_create(void)
Definition: gpu_matrix.cc:70
#define MATRIX_STACK_DEPTH
Definition: gpu_matrix.cc:40
float[3][3] Mat3
Definition: gpu_matrix.cc:43
const float(* GPU_matrix_model_view_get(float m[4][4]))[4]
Definition: gpu_matrix.cc:587
const float(* GPU_matrix_model_view_projection_get(float m[4][4]))[4]
Definition: gpu_matrix.cc:607
static void mat4_ortho_set(float m[4][4], float left, float right, float bottom, float top, float near, float far)
Definition: gpu_matrix.cc:298
void GPU_matrix_scale_3fv(const float vec[3])
Definition: gpu_matrix.cc:257
void GPU_matrix_scale_3f(float x, float y, float z)
Definition: gpu_matrix.cc:247
static void gpu_matrix_state_active_set_dirty(bool value)
Definition: gpu_matrix.cc:96
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:135
#define Projection
Definition: gpu_matrix.cc:68
bool GPU_matrix_unproject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float r_world[3])
Definition: gpu_matrix.cc:572
#define ModelView
Definition: gpu_matrix.cc:65
void GPU_matrix_unproject_with_precalc(const struct GPUMatrixUnproject_Precalc *precalc, const float win[3], float r_world[3])
Definition: gpu_matrix.cc:559
void GPU_matrix_scale_1f(float factor)
Definition: gpu_matrix.cc:225
void GPU_matrix_rotate_3fv(float deg, const float axis[3])
Definition: gpu_matrix.cc:283
void GPU_matrix_rotate_2d(float deg)
Definition: gpu_matrix.cc:269
void GPU_matrix_reset(void)
Definition: gpu_matrix.cc:102
int GPU_matrix_stack_level_get_model_view(void)
Definition: gpu_matrix.cc:703
void GPU_matrix_state_discard(GPUMatrixState *state)
Definition: gpu_matrix.cc:91
static void mat4_look_from_origin(float m[4][4], float lookdir[3], float camup[3])
Definition: gpu_matrix.cc:350
#define ProjectionStack
Definition: gpu_matrix.cc:67
#define ModelViewStack
Definition: gpu_matrix.cc:64
void GPU_matrix_project(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3])
Definition: gpu_matrix.cc:477
void GPU_matrix_translate_3fv(const float vec[3])
Definition: gpu_matrix.cc:220
void GPU_matrix_translate_3f(float x, float y, float z)
Definition: gpu_matrix.cc:204
void GPU_polygon_offset(float viewdist, float dist)
Definition: gpu_matrix.cc:758
void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
Definition: gpu_matrix.cc:277
void GPU_matrix_identity_set(void)
Definition: gpu_matrix.cc:184
void GPU_matrix_translate_2f(float x, float y)
Definition: gpu_matrix.cc:190
const float(* GPU_matrix_normal_get(float m[3][3]))[3]
Definition: gpu_matrix.cc:618
void GPU_matrix_push_projection(void)
Definition: gpu_matrix.cc:149
#define tanf(x)
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
static float P(float k)
Definition: math_interp.c:41
static ulong state[N]
static int left
BLI_STATIC_ASSERT(sizeof(GPUState)==sizeof(uint64_t), "GPUState is too big.")
params N
signed int int32_t
Definition: stdint.h:80
MatrixStack model_view_stack
Definition: gpu_matrix.cc:51
MatrixStack projection_stack
Definition: gpu_matrix.cc:52
struct GPUMatrixUnproject_Precalc::@608 dims