Blender  V3.3
basic_shader.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 Blender Foundation. */
3 
8 #include "DRW_render.h"
9 
10 #include "GPU_shader.h"
11 
12 #include "basic_private.h"
13 
14 extern char datatoc_basic_depth_frag_glsl[];
15 extern char datatoc_basic_depth_vert_glsl[];
17 
18 extern char datatoc_common_view_lib_glsl[];
20 
21 /* Shaders */
22 
23 typedef struct BASIC_Shaders {
24  /* Depth Pre Pass */
25  struct GPUShader *depth;
31 
32 static struct {
34 } e_data = {{{NULL}}}; /* Engine data */
35 
37 {
38  BASIC_Shaders *sh_data = &e_data.sh_data[config];
39  if (sh_data->depth == NULL) {
41  config == GPU_SHADER_CFG_CLIPPED ? "basic_depth_mesh_clipped" : "basic_depth_mesh");
42  }
43  return sh_data->depth;
44 }
45 
47 {
48  BASIC_Shaders *sh_data = &e_data.sh_data[config];
49  if (sh_data->pointcloud_depth == NULL) {
51  config == GPU_SHADER_CFG_CLIPPED ? "basic_depth_pointcloud_clipped" :
52  "basic_depth_pointcloud");
53  }
54  return sh_data->pointcloud_depth;
55 }
56 
58 {
59  BASIC_Shaders *sh_data = &e_data.sh_data[config];
60  if (sh_data->curves_depth == NULL) {
62  config == GPU_SHADER_CFG_CLIPPED ? "basic_depth_curves_clipped" : "basic_depth_curves");
63  }
64  return sh_data->curves_depth;
65 }
66 
68 {
69  BASIC_Shaders *sh_data = &e_data.sh_data[config];
72  config == GPU_SHADER_CFG_CLIPPED ? "basic_depth_mesh_conservative_clipped" :
73  "basic_depth_mesh_conservative");
74  }
76 }
77 
79 {
80  BASIC_Shaders *sh_data = &e_data.sh_data[config];
83  config == GPU_SHADER_CFG_CLIPPED ? "basic_depth_pointcloud_conservative_clipped" :
84  "basic_depth_pointcloud_conservative");
85  }
87 }
88 
90 {
91  for (int i = 0; i < GPU_SHADER_CFG_LEN; i++) {
92  GPUShader **sh_data_as_array = (GPUShader **)&e_data.sh_data[i];
93  for (int j = 0; j < (sizeof(BASIC_Shaders) / sizeof(GPUShader *)); j++) {
94  DRW_SHADER_FREE_SAFE(sh_data_as_array[j]);
95  }
96  }
97 }
#define DRW_SHADER_FREE_SAFE(shader)
Definition: DRW_render.h:254
struct GPUShader GPUShader
Definition: GPU_shader.h:20
eGPUShaderConfig
Definition: GPU_shader.h:364
@ GPU_SHADER_CFG_CLIPPED
Definition: GPU_shader.h:366
GPUShader * GPU_shader_create_from_info_name(const char *info_name)
Definition: gpu_shader.cc:265
#define GPU_SHADER_CFG_LEN
Definition: GPU_shader.h:368
char datatoc_common_pointcloud_lib_glsl[]
GPUShader * BASIC_shaders_depth_conservative_sh_get(eGPUShaderConfig config)
Definition: basic_shader.c:67
BASIC_Shaders sh_data[GPU_SHADER_CFG_LEN]
Definition: basic_shader.c:33
void BASIC_shaders_free(void)
Definition: basic_shader.c:89
GPUShader * BASIC_shaders_pointcloud_depth_conservative_sh_get(eGPUShaderConfig config)
Definition: basic_shader.c:78
char datatoc_common_view_lib_glsl[]
char datatoc_basic_conservative_depth_geom_glsl[]
char datatoc_basic_depth_vert_glsl[]
static struct @199 e_data
GPUShader * BASIC_shaders_pointcloud_depth_sh_get(eGPUShaderConfig config)
Definition: basic_shader.c:46
char datatoc_basic_depth_frag_glsl[]
GPUShader * BASIC_shaders_depth_sh_get(eGPUShaderConfig config)
Definition: basic_shader.c:36
GPUShader * BASIC_shaders_curves_depth_sh_get(eGPUShaderConfig config)
Definition: basic_shader.c:57
struct BASIC_Shaders BASIC_Shaders
struct GPUShader * pointcloud_depth
Definition: basic_shader.c:26
struct GPUShader * depth
Definition: basic_shader.c:25
struct GPUShader * pointcloud_depth_conservative
Definition: basic_shader.c:29
struct GPUShader * curves_depth
Definition: basic_shader.c:27
struct GPUShader * depth_conservative
Definition: basic_shader.c:28