| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2005 Blender Foundation. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup gpu | 
					
						
							| 
									
										
										
										
											2018-08-30 01:56:08 +10:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BLI_math_base.h"
 | 
					
						
							|  |  |  | #include "BLI_math_vector.h"
 | 
					
						
							| 
									
										
										
										
											2017-09-27 18:03:00 +02:00
										 |  |  | #include "BLI_path_util.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-02 18:31:38 +02:00
										 |  |  | #include "BLI_string.h"
 | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  | #include "BLI_string_utils.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-27 18:03:00 +02:00
										 |  |  | #include "BKE_appdir.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | #include "BKE_global.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-27 18:03:00 +02:00
										 |  |  | #include "DNA_space_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 16:30:13 +02:00
										 |  |  | #include "GPU_matrix.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "GPU_platform.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | #include "GPU_shader.h"
 | 
					
						
							|  |  |  | #include "GPU_texture.h"
 | 
					
						
							| 
									
										
										
										
											2020-08-20 23:09:37 +02:00
										 |  |  | #include "GPU_uniform_buffer.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  | /* TODO(jbakker): Need a better way to retrieve create_infos. */ | 
					
						
							|  |  |  | #include "gpu_shader_create_info_private.hh"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-07 13:28:42 -04:00
										 |  |  | /* Adjust these constants as needed. */ | 
					
						
							|  |  |  | #define MAX_DEFINE_LENGTH 256
 | 
					
						
							| 
									
										
										
										
											2020-03-11 17:12:01 +01:00
										 |  |  | #define MAX_EXT_DEFINE_LENGTH 512
 | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Non-generated shaders */ | 
					
						
							| 
									
										
										
										
											2016-09-13 02:51:38 -04:00
										 |  |  | extern char datatoc_gpu_shader_depth_only_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-08-16 14:58:53 -04:00
										 |  |  | extern char datatoc_gpu_shader_uniform_color_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-02-07 13:04:08 +01:00
										 |  |  | extern char datatoc_gpu_shader_checker_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-02-16 21:49:20 -02:00
										 |  |  | extern char datatoc_gpu_shader_diag_stripes_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-02-07 13:04:08 +01:00
										 |  |  | extern char datatoc_gpu_shader_simple_lighting_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-08-16 14:58:53 -04:00
										 |  |  | extern char datatoc_gpu_shader_flat_color_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-10-26 03:57:14 -04:00
										 |  |  | extern char datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-04-17 13:00:09 +02:00
										 |  |  | extern char datatoc_gpu_shader_flat_id_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-08-23 22:29:29 +02:00
										 |  |  | extern char datatoc_gpu_shader_2D_area_borders_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-12-01 19:49:31 +01:00
										 |  |  | extern char datatoc_gpu_shader_2D_area_borders_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-10-15 02:30:59 -04:00
										 |  |  | extern char datatoc_gpu_shader_2D_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-08-08 04:56:02 -04:00
										 |  |  | extern char datatoc_gpu_shader_2D_flat_color_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-04-20 15:15:10 +02:00
										 |  |  | extern char datatoc_gpu_shader_2D_smooth_color_uniform_alpha_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-08-04 15:59:38 -04:00
										 |  |  | extern char datatoc_gpu_shader_2D_smooth_color_vert_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_2D_smooth_color_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-11-18 16:04:25 +01:00
										 |  |  | extern char datatoc_gpu_shader_2D_image_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-03-27 23:57:29 +02:00
										 |  |  | extern char datatoc_gpu_shader_2D_image_rect_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-03-31 19:32:28 +02:00
										 |  |  | extern char datatoc_gpu_shader_2D_image_multi_rect_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-03-29 03:06:33 +02:00
										 |  |  | extern char datatoc_gpu_shader_2D_widget_base_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-04-06 23:54:24 +02:00
										 |  |  | extern char datatoc_gpu_shader_2D_widget_base_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-04-06 10:09:23 +02:00
										 |  |  | extern char datatoc_gpu_shader_2D_widget_shadow_vert_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_2D_widget_shadow_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-04-05 15:27:53 +02:00
										 |  |  | extern char datatoc_gpu_shader_2D_nodelink_frag_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_2D_nodelink_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-11-18 16:04:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-18 00:08:34 -04:00
										 |  |  | extern char datatoc_gpu_shader_3D_image_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-02-13 18:09:58 +01:00
										 |  |  | extern char datatoc_gpu_shader_image_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2020-02-11 15:18:55 +01:00
										 |  |  | extern char datatoc_gpu_shader_image_overlays_merge_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2020-03-19 08:06:49 +01:00
										 |  |  | extern char datatoc_gpu_shader_image_overlays_stereo_merge_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-11-18 16:04:25 +01:00
										 |  |  | extern char datatoc_gpu_shader_image_color_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-04-26 15:42:08 +02:00
										 |  |  | extern char datatoc_gpu_shader_image_desaturate_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2021-11-05 14:51:55 +01:00
										 |  |  | extern char datatoc_gpu_shader_image_modulate_alpha_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-03-31 19:32:28 +02:00
										 |  |  | extern char datatoc_gpu_shader_image_varying_color_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-02-24 01:07:40 +01:00
										 |  |  | extern char datatoc_gpu_shader_image_shuffle_color_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-10-15 02:30:59 -04:00
										 |  |  | extern char datatoc_gpu_shader_3D_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-04-16 15:04:07 -04:00
										 |  |  | extern char datatoc_gpu_shader_3D_normal_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-08-16 14:58:53 -04:00
										 |  |  | extern char datatoc_gpu_shader_3D_flat_color_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2020-04-23 23:05:39 +02:00
										 |  |  | extern char datatoc_gpu_shader_3D_polyline_frag_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_3D_polyline_geom_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_3D_polyline_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-08-16 14:58:53 -04:00
										 |  |  | extern char datatoc_gpu_shader_3D_smooth_color_vert_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_3D_smooth_color_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-02-11 21:15:46 +01:00
										 |  |  | extern char datatoc_gpu_shader_3D_passthrough_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-04-05 01:28:48 +02:00
										 |  |  | extern char datatoc_gpu_shader_3D_clipped_uniform_color_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-08-04 15:59:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 20:55:31 +01:00
										 |  |  | extern char datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-02-07 11:20:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-28 02:18:52 -05:00
										 |  |  | extern char datatoc_gpu_shader_point_uniform_color_aa_frag_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_point_uniform_color_outline_aa_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-09-29 19:42:09 +02:00
										 |  |  | extern char datatoc_gpu_shader_point_varying_color_varying_outline_aa_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-09-30 20:44:22 -04:00
										 |  |  | extern char datatoc_gpu_shader_point_varying_color_frag_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_3D_point_fixed_size_varying_color_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-10-01 17:32:29 -04:00
										 |  |  | extern char datatoc_gpu_shader_3D_point_varying_size_varying_color_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-02-28 02:18:52 -05:00
										 |  |  | extern char datatoc_gpu_shader_3D_point_uniform_size_aa_vert_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_2D_point_uniform_size_aa_vert_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_2D_point_uniform_size_outline_aa_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-09-30 20:44:22 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-13 16:44:02 +02:00
										 |  |  | extern char datatoc_gpu_shader_2D_line_dashed_uniform_color_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-02-24 15:33:09 -05:00
										 |  |  | extern char datatoc_gpu_shader_2D_line_dashed_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-07-13 16:44:02 +02:00
										 |  |  | extern char datatoc_gpu_shader_3D_line_dashed_uniform_color_vert_glsl[]; | 
					
						
							| 
									
										
										
										
											2017-02-24 15:33:09 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-17 13:33:02 +02:00
										 |  |  | extern char datatoc_gpu_shader_text_vert_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_text_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2021-09-23 15:53:38 +02:00
										 |  |  | extern char datatoc_gpu_shader_keyframe_shape_vert_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_keyframe_shape_frag_glsl[]; | 
					
						
							| 
									
										
										
										
											2016-09-17 13:33:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-31 10:22:19 +02:00
										 |  |  | extern char datatoc_gpu_shader_gpencil_stroke_vert_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_gpencil_stroke_frag_glsl[]; | 
					
						
							|  |  |  | extern char datatoc_gpu_shader_gpencil_stroke_geom_glsl[]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  | extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[]; | 
					
						
							| 
									
										
										
										
											2018-07-31 10:22:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-14 20:44:45 +02:00
										 |  |  | extern char datatoc_gpu_shader_colorspace_lib_glsl[]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-10 11:06:22 +11:00
										 |  |  | const struct GPUShaderConfigData GPU_shader_cfg_data[GPU_SHADER_CFG_LEN] = { | 
					
						
							|  |  |  |     [GPU_SHADER_CFG_DEFAULT] = | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             .lib = "", | 
					
						
							| 
									
										
										
										
											2020-04-14 20:44:45 +02:00
										 |  |  |             .def = "#define blender_srgb_to_framebuffer_space(a) a\n", | 
					
						
							| 
									
										
										
										
											2019-02-10 11:06:22 +11:00
										 |  |  |         }, | 
					
						
							|  |  |  |     [GPU_SHADER_CFG_CLIPPED] = | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             .lib = datatoc_gpu_shader_cfg_world_clip_lib_glsl, | 
					
						
							| 
									
										
										
										
											2020-04-14 20:44:45 +02:00
										 |  |  |             .def = "#define USE_WORLD_CLIP_PLANES\n" | 
					
						
							|  |  |  |                    "#define blender_srgb_to_framebuffer_space(a) a\n", | 
					
						
							| 
									
										
										
										
											2019-02-10 11:06:22 +11:00
										 |  |  |         }, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  | /* cache of built-in shaders (each is created on first use) */ | 
					
						
							| 
									
										
										
										
											2019-03-16 19:48:28 +01:00
										 |  |  | static GPUShader *builtin_shaders[GPU_SHADER_CFG_LEN][GPU_SHADER_BUILTIN_LEN] = {{NULL}}; | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |   const char *name; | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  |   const char *vert; | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |   /** Optional. */ | 
					
						
							|  |  |  |   const char *geom; | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  |   const char *frag; | 
					
						
							| 
									
										
										
										
											2019-01-26 10:04:10 +11:00
										 |  |  |   /** Optional. */ | 
					
						
							|  |  |  |   const char *defs; | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const char *create_info; | 
					
						
							|  |  |  |   const char *clipped_create_info; | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  | } GPUShaderStages; | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  | static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_TEXT] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_TEXT", | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |             .create_info = "gpu_shader_text", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2021-09-23 15:53:38 +02:00
										 |  |  |     [GPU_SHADER_KEYFRAME_SHAPE] = | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2021-09-23 15:53:38 +02:00
										 |  |  |             .name = "GPU_SHADER_KEYFRAME_SHAPE", | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |             .create_info = "gpu_shader_keyframe_shape", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         }, | 
					
						
							|  |  |  |     [GPU_SHADER_SIMPLE_LIGHTING] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_SIMPLE_LIGHTING", | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |             .create_info = "gpu_shader_simple_lighting", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2021-11-05 14:51:55 +01:00
										 |  |  |     [GPU_SHADER_3D_IMAGE_MODULATE_ALPHA] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |             .name = "GPU_SHADER_3D_IMAGE_MODULATE_ALPHA", | 
					
						
							|  |  |  |             .create_info = "gpu_shader_3D_image_modulate_alpha", | 
					
						
							| 
									
										
										
										
											2021-11-05 14:51:55 +01:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_2D_CHECKER] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_2D_CHECKER", | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |             .create_info = "gpu_shader_2D_checker", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_2D_DIAG_STRIPES] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_2D_DIAG_STRIPES", | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |             .create_info = "gpu_shader_2D_diag_stripes", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |     [GPU_SHADER_2D_UNIFORM_COLOR] = {.name = "GPU_SHADER_2D_UNIFORM_COLOR", | 
					
						
							|  |  |  |                                      .create_info = "gpu_shader_2D_uniform_color"}, | 
					
						
							|  |  |  |     [GPU_SHADER_2D_FLAT_COLOR] = {.name = "GPU_SHADER_2D_FLAT_COLOR", | 
					
						
							|  |  |  |                                   .create_info = "gpu_shader_2D_flat_color"}, | 
					
						
							|  |  |  |     [GPU_SHADER_2D_SMOOTH_COLOR] = {.name = "GPU_SHADER_2D_SMOOTH_COLOR", | 
					
						
							|  |  |  |                                     .create_info = "gpu_shader_2D_smooth_color"}, | 
					
						
							| 
									
										
										
										
											2022-01-21 14:24:30 +01:00
										 |  |  |     [GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE] = | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             .name = "GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE", | 
					
						
							|  |  |  | #ifdef __APPLE__
 | 
					
						
							|  |  |  |             /* GPUShaderCreateInfo is disabled on MacOS due to mismatch with OCIO shader. See
 | 
					
						
							|  |  |  |              * T95052 for more details. */ | 
					
						
							| 
									
										
										
										
											2022-01-21 14:35:27 +01:00
										 |  |  |             .vert = datatoc_gpu_shader_2D_image_vert_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_image_overlays_merge_frag_glsl, | 
					
						
							| 
									
										
										
										
											2022-01-21 14:24:30 +01:00
										 |  |  | #else
 | 
					
						
							|  |  |  |             .create_info = "gpu_shader_2D_image_overlays_merge", | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2020-03-19 08:06:49 +01:00
										 |  |  |     [GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE] = | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |         {.name = "GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE", | 
					
						
							|  |  |  |          .create_info = "gpu_shader_2D_image_overlays_stereo_merge"}, | 
					
						
							|  |  |  |     [GPU_SHADER_2D_IMAGE] = {.name = "GPU_SHADER_2D_IMAGE", .create_info = "gpu_shader_2D_image"}, | 
					
						
							|  |  |  |     [GPU_SHADER_2D_IMAGE_COLOR] = {.name = "GPU_SHADER_2D_IMAGE_COLOR", | 
					
						
							|  |  |  |                                    .create_info = "gpu_shader_2D_image_color"}, | 
					
						
							|  |  |  |     [GPU_SHADER_2D_IMAGE_DESATURATE_COLOR] = {.name = "GPU_SHADER_2D_IMAGE_DESATURATE_COLOR", | 
					
						
							|  |  |  |                                               .create_info = | 
					
						
							|  |  |  |                                                   "gpu_shader_2D_image_desaturate_color"}, | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR", | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |             .create_info = "gpu_shader_2D_image_shuffle_color", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |     [GPU_SHADER_2D_IMAGE_RECT_COLOR] = {.name = "GPU_SHADER_2D_IMAGE_RECT_COLOR", | 
					
						
							|  |  |  |                                         .create_info = "gpu_shader_2D_image_rect_color"}, | 
					
						
							| 
									
										
										
										
											2022-01-18 13:13:23 +01:00
										 |  |  |     [GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR] = {.name = "GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR", | 
					
						
							|  |  |  |                                               .create_info = | 
					
						
							|  |  |  |                                                   "gpu_shader_2D_image_multi_rect_color"}, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_3D_UNIFORM_COLOR] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_3D_UNIFORM_COLOR", | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |             .create_info = "gpu_shader_3D_uniform_color", | 
					
						
							|  |  |  |             .clipped_create_info = "gpu_shader_3D_uniform_color_clipped", | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     [GPU_SHADER_3D_FLAT_COLOR] = {.name = "GPU_SHADER_3D_FLAT_COLOR", | 
					
						
							|  |  |  |                                   .create_info = "gpu_shader_3D_flat_color", | 
					
						
							|  |  |  |                                   .clipped_create_info = "gpu_shader_3D_flat_color_clipped"}, | 
					
						
							|  |  |  |     [GPU_SHADER_3D_SMOOTH_COLOR] = {.name = "GPU_SHADER_3D_SMOOTH_COLOR", | 
					
						
							|  |  |  |                                     .create_info = "gpu_shader_3D_smooth_color", | 
					
						
							|  |  |  |                                     .clipped_create_info = "gpu_shader_3D_smooth_color_clipped"}, | 
					
						
							|  |  |  |     [GPU_SHADER_3D_DEPTH_ONLY] = {.name = "GPU_SHADER_3D_DEPTH_ONLY", | 
					
						
							|  |  |  |                                   .create_info = "gpu_shader_3D_depth_only", | 
					
						
							|  |  |  |                                   .clipped_create_info = "gpu_shader_3D_depth_only_clipped"}, | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |             .vert = datatoc_gpu_shader_3D_clipped_uniform_color_vert_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_uniform_color_frag_glsl, | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-23 23:05:39 +02:00
										 |  |  |     [GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR", | 
					
						
							| 
									
										
										
										
											2020-04-23 23:05:39 +02:00
										 |  |  |             .vert = datatoc_gpu_shader_3D_polyline_vert_glsl, | 
					
						
							|  |  |  |             .geom = datatoc_gpu_shader_3D_polyline_geom_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_3D_polyline_frag_glsl, | 
					
						
							|  |  |  |             .defs = "#define UNIFORM\n", | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     [GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR", | 
					
						
							| 
									
										
										
										
											2020-04-23 23:05:39 +02:00
										 |  |  |             .vert = datatoc_gpu_shader_3D_polyline_vert_glsl, | 
					
						
							|  |  |  |             .geom = datatoc_gpu_shader_3D_polyline_geom_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_3D_polyline_frag_glsl, | 
					
						
							|  |  |  |             .defs = "#define UNIFORM\n" | 
					
						
							|  |  |  |                     "#define CLIP\n", | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     [GPU_SHADER_3D_POLYLINE_FLAT_COLOR] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_3D_POLYLINE_FLAT_COLOR", | 
					
						
							| 
									
										
										
										
											2020-04-23 23:05:39 +02:00
										 |  |  |             .vert = datatoc_gpu_shader_3D_polyline_vert_glsl, | 
					
						
							|  |  |  |             .geom = datatoc_gpu_shader_3D_polyline_geom_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_3D_polyline_frag_glsl, | 
					
						
							|  |  |  |             .defs = "#define FLAT\n", | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     [GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR", | 
					
						
							| 
									
										
										
										
											2020-04-23 23:05:39 +02:00
										 |  |  |             .vert = datatoc_gpu_shader_3D_polyline_vert_glsl, | 
					
						
							|  |  |  |             .geom = datatoc_gpu_shader_3D_polyline_geom_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_3D_polyline_frag_glsl, | 
					
						
							|  |  |  |             .defs = "#define SMOOTH\n", | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |             .vert = datatoc_gpu_shader_2D_line_dashed_uniform_color_vert_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_2D_line_dashed_frag_glsl, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     [GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |             .vert = datatoc_gpu_shader_3D_line_dashed_uniform_color_vert_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_2D_line_dashed_frag_glsl, | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA", | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |             .create_info = "gpu_shader_2D_point_uniform_size_uniform_color_aa", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         }, | 
					
						
							|  |  |  |     [GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA", | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |             .create_info = "gpu_shader_2D_point_uniform_size_uniform_color_outline_aa", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         }, | 
					
						
							|  |  |  |     [GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR] = | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |         {.name = "GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR", | 
					
						
							|  |  |  |          .create_info = "gpu_shader_3D_point_fixed_size_varying_color"}, | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR] = | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |         {.name = "GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR", | 
					
						
							|  |  |  |          .create_info = "gpu_shader_3D_point_varying_size_varying_color"}, | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA] = | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |         {.name = "GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA", | 
					
						
							|  |  |  |          .create_info = "gpu_shader_3D_point_uniform_size_uniform_color_aa", | 
					
						
							|  |  |  |          .clipped_create_info = "gpu_shader_3D_point_uniform_size_uniform_color_aa_clipped"}, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |             .vert = datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_flat_color_frag_glsl, | 
					
						
							| 
									
										
										
										
											2019-01-26 10:04:10 +11:00
										 |  |  |             .defs = "#define UNIFORM_SCALE\n", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |     [GPU_SHADER_2D_AREA_BORDERS] = {.name = "GPU_SHADER_2D_AREA_BORDERS", | 
					
						
							|  |  |  |                                     .create_info = "gpu_shader_2D_area_borders"}, | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_2D_WIDGET_BASE] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_2D_WIDGET_BASE", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |             .vert = datatoc_gpu_shader_2D_widget_base_vert_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_2D_widget_base_frag_glsl, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |     [GPU_SHADER_2D_WIDGET_BASE_INST] = | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_2D_WIDGET_BASE_INST", | 
					
						
							| 
									
										
										
										
											2019-01-26 10:04:10 +11:00
										 |  |  |             .vert = datatoc_gpu_shader_2D_widget_base_vert_glsl, | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |             .frag = datatoc_gpu_shader_2D_widget_base_frag_glsl, | 
					
						
							| 
									
										
										
										
											2019-01-26 10:04:10 +11:00
										 |  |  |             .defs = "#define USE_INSTANCE\n", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |         }, | 
					
						
							|  |  |  |     [GPU_SHADER_2D_WIDGET_SHADOW] = | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-09-16 01:40:04 +02:00
										 |  |  |             .name = "GPU_SHADER_2D_WIDGET_SHADOW", | 
					
						
							| 
									
										
										
										
											2019-01-26 09:46:29 +11:00
										 |  |  |             .vert = datatoc_gpu_shader_2D_widget_shadow_vert_glsl, | 
					
						
							|  |  |  |             .frag = datatoc_gpu_shader_2D_widget_shadow_frag_glsl, | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |     [GPU_SHADER_2D_NODELINK] = {.name = "GPU_SHADER_2D_NODELINK", | 
					
						
							|  |  |  |                                 .create_info = "gpu_shader_2D_nodelink"}, | 
					
						
							| 
									
										
										
										
											2022-01-17 14:32:03 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |     [GPU_SHADER_2D_NODELINK_INST] = {.name = "GPU_SHADER_2D_NODELINK_INST", | 
					
						
							|  |  |  |                                      .create_info = "gpu_shader_2D_nodelink_inst"}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [GPU_SHADER_GPENCIL_STROKE] = {.name = "GPU_SHADER_GPENCIL_STROKE", | 
					
						
							|  |  |  |                                    .create_info = "gpu_shader_gpencil_stroke"}, | 
					
						
							| 
									
										
										
										
											2018-09-14 09:32:19 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  | GPUShader *GPU_shader_get_builtin_shader_with_config(eGPUBuiltinShader shader, | 
					
						
							| 
									
										
										
										
											2019-02-10 11:02:06 +11:00
										 |  |  |                                                      eGPUShaderConfig sh_cfg) | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  |   BLI_assert(shader < GPU_SHADER_BUILTIN_LEN); | 
					
						
							| 
									
										
										
										
											2019-02-10 11:02:06 +11:00
										 |  |  |   BLI_assert(sh_cfg < GPU_SHADER_CFG_LEN); | 
					
						
							|  |  |  |   GPUShader **sh_p = &builtin_shaders[sh_cfg][shader]; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  |   if (*sh_p == NULL) { | 
					
						
							| 
									
										
										
										
											2019-01-26 10:04:10 +11:00
										 |  |  |     const GPUShaderStages *stages = &builtin_shader_stages[shader]; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  |     /* common case */ | 
					
						
							| 
									
										
										
										
											2019-02-10 11:02:06 +11:00
										 |  |  |     if (sh_cfg == GPU_SHADER_CFG_DEFAULT) { | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |       if (stages->create_info != NULL) { | 
					
						
							|  |  |  |         *sh_p = GPU_shader_create_from_info(gpu_shader_create_info_get(stages->create_info)); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       else { | 
					
						
							|  |  |  |         *sh_p = GPU_shader_create_from_arrays_named( | 
					
						
							|  |  |  |             stages->name, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 .vert = (const char *[]){stages->vert, NULL}, | 
					
						
							|  |  |  |                 .geom = (const char *[]){stages->geom, NULL}, | 
					
						
							|  |  |  |                 .frag = | 
					
						
							|  |  |  |                     (const char *[]){datatoc_gpu_shader_colorspace_lib_glsl, stages->frag, NULL}, | 
					
						
							|  |  |  |                 .defs = (const char *[]){stages->defs, NULL}, | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-02-10 11:02:06 +11:00
										 |  |  |     else if (sh_cfg == GPU_SHADER_CFG_CLIPPED) { | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  |       /* Remove eventually, for now ensure support for each shader has been added. */ | 
					
						
							|  |  |  |       BLI_assert(ELEM(shader, | 
					
						
							|  |  |  |                       GPU_SHADER_3D_UNIFORM_COLOR, | 
					
						
							|  |  |  |                       GPU_SHADER_3D_SMOOTH_COLOR, | 
					
						
							|  |  |  |                       GPU_SHADER_3D_DEPTH_ONLY, | 
					
						
							|  |  |  |                       GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, | 
					
						
							|  |  |  |                       GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA, | 
					
						
							| 
									
										
										
										
											2019-05-30 20:02:05 +10:00
										 |  |  |                       GPU_SHADER_3D_FLAT_COLOR, | 
					
						
							| 
									
										
										
										
											2019-12-02 01:40:58 +01:00
										 |  |  |                       GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR)); | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  |       /* In rare cases geometry shaders calculate clipping themselves. */ | 
					
						
							| 
									
										
										
										
											2022-01-17 14:45:22 +01:00
										 |  |  |       if (stages->clipped_create_info != NULL) { | 
					
						
							|  |  |  |         *sh_p = GPU_shader_create_from_info( | 
					
						
							|  |  |  |             gpu_shader_create_info_get(stages->clipped_create_info)); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       else { | 
					
						
							|  |  |  |         const char *world_clip_lib = datatoc_gpu_shader_cfg_world_clip_lib_glsl; | 
					
						
							|  |  |  |         const char *world_clip_def = "#define USE_WORLD_CLIP_PLANES\n"; | 
					
						
							|  |  |  |         *sh_p = GPU_shader_create_from_arrays_named( | 
					
						
							|  |  |  |             stages->name, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 .vert = (const char *[]){world_clip_lib, stages->vert, NULL}, | 
					
						
							|  |  |  |                 .geom = (const char *[]){stages->geom ? world_clip_lib : NULL, stages->geom, NULL}, | 
					
						
							|  |  |  |                 .frag = | 
					
						
							|  |  |  |                     (const char *[]){datatoc_gpu_shader_colorspace_lib_glsl, stages->frag, NULL}, | 
					
						
							|  |  |  |                 .defs = (const char *[]){world_clip_def, stages->defs, NULL}, | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |       BLI_assert(0); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  |   return *sh_p; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-07-28 20:04:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  | GPUShader *GPU_shader_get_builtin_shader(eGPUBuiltinShader shader) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return GPU_shader_get_builtin_shader_with_config(shader, GPU_SHADER_CFG_DEFAULT); | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-14 09:32:19 -03:00
										 |  |  | void GPU_shader_get_builtin_shader_code(eGPUBuiltinShader shader, | 
					
						
							| 
									
										
										
										
											2018-09-15 08:00:29 +10:00
										 |  |  |                                         const char **r_vert, | 
					
						
							|  |  |  |                                         const char **r_frag, | 
					
						
							|  |  |  |                                         const char **r_geom, | 
					
						
							|  |  |  |                                         const char **r_defines) | 
					
						
							| 
									
										
										
										
											2018-09-14 09:32:19 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-01-26 10:04:10 +11:00
										 |  |  |   const GPUShaderStages *stages = &builtin_shader_stages[shader]; | 
					
						
							| 
									
										
										
										
											2018-09-15 08:00:29 +10:00
										 |  |  |   *r_vert = stages->vert; | 
					
						
							|  |  |  |   *r_frag = stages->frag; | 
					
						
							|  |  |  |   *r_geom = stages->geom; | 
					
						
							| 
									
										
										
										
											2019-01-26 10:04:10 +11:00
										 |  |  |   *r_defines = stages->defs; | 
					
						
							| 
									
										
										
										
											2018-09-14 09:32:19 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | void GPU_shader_free_builtin_shaders(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-02-06 09:15:16 +11:00
										 |  |  |   for (int i = 0; i < GPU_SHADER_CFG_LEN; i++) { | 
					
						
							|  |  |  |     for (int j = 0; j < GPU_SHADER_BUILTIN_LEN; j++) { | 
					
						
							|  |  |  |       if (builtin_shaders[i][j]) { | 
					
						
							|  |  |  |         GPU_shader_free(builtin_shaders[i][j]); | 
					
						
							|  |  |  |         builtin_shaders[i][j] = NULL; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-10-16 18:43:24 -04:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | } |