| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Brecht Van Lommel. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \file GPU_shader.h
 | 
					
						
							|  |  |  |  *  \ingroup gpu | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __GPU_SHADER_H__
 | 
					
						
							|  |  |  | #define __GPU_SHADER_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct GPUShader GPUShader; | 
					
						
							| 
									
										
										
										
											2015-12-23 20:39:03 +01:00
										 |  |  | struct GPUTexture; | 
					
						
							| 
									
										
										
										
											2017-02-07 11:20:15 +01:00
										 |  |  | struct GPUUniformBuffer; | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* GPU Shader
 | 
					
						
							|  |  |  |  * - only for fragment shaders now | 
					
						
							|  |  |  |  * - must call texture bind before setting a texture as uniform! */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum { | 
					
						
							|  |  |  | 	GPU_SHADER_FLAGS_NONE = 0, | 
					
						
							|  |  |  | 	GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV = (1 << 0), | 
					
						
							| 
									
										
										
										
											2016-02-02 12:48:18 +01:00
										 |  |  | 	GPU_SHADER_FLAGS_NEW_SHADING        = (1 << 1), | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2016-01-10 07:12:10 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | GPUShader *GPU_shader_create( | 
					
						
							|  |  |  |         const char *vertexcode, | 
					
						
							|  |  |  |         const char *fragcode, | 
					
						
							|  |  |  |         const char *geocode, | 
					
						
							|  |  |  |         const char *libcode, | 
					
						
							| 
									
										
										
										
											2017-04-08 02:21:13 -04:00
										 |  |  |         const char *defines); | 
					
						
							| 
									
										
										
										
											2016-01-10 07:12:10 +11:00
										 |  |  | GPUShader *GPU_shader_create_ex( | 
					
						
							|  |  |  |         const char *vertexcode, | 
					
						
							|  |  |  |         const char *fragcode, | 
					
						
							|  |  |  |         const char *geocode, | 
					
						
							|  |  |  |         const char *libcode, | 
					
						
							|  |  |  |         const char *defines, | 
					
						
							|  |  |  |         const int flags); | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | void GPU_shader_free(GPUShader *shader); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GPU_shader_bind(GPUShader *shader); | 
					
						
							|  |  |  | void GPU_shader_unbind(void); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-07 11:20:15 +01:00
										 |  |  | int GPU_shader_get_program(GPUShader *shader); | 
					
						
							| 
									
										
										
										
											2017-03-02 21:46:54 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-21 00:53:48 +01:00
										 |  |  | void *GPU_shader_get_interface(GPUShader *shader); | 
					
						
							| 
									
										
										
										
											2017-03-02 21:46:54 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | void *GPU_fx_shader_get_interface(GPUShader *shader); | 
					
						
							|  |  |  | void GPU_fx_shader_set_interface(GPUShader *shader, void *interface); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | int GPU_shader_get_uniform(GPUShader *shader, const char *name); | 
					
						
							| 
									
										
										
										
											2017-10-08 15:49:25 +02:00
										 |  |  | int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin); | 
					
						
							| 
									
										
										
										
											2017-02-07 11:20:15 +01:00
										 |  |  | int GPU_shader_get_uniform_block(GPUShader *shader, const char *name); | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, | 
					
						
							|  |  |  | 	int arraysize, const float *value); | 
					
						
							|  |  |  | void GPU_shader_uniform_vector_int(GPUShader *shader, int location, int length, | 
					
						
							|  |  |  | 	int arraysize, const int *value); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-07 11:20:15 +01:00
										 |  |  | void GPU_shader_uniform_buffer(GPUShader *shader, int location, struct GPUUniformBuffer *ubo); | 
					
						
							| 
									
										
										
										
											2015-12-23 20:39:03 +01:00
										 |  |  | void GPU_shader_uniform_texture(GPUShader *shader, int location, struct GPUTexture *tex); | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | void GPU_shader_uniform_int(GPUShader *shader, int location, int value); | 
					
						
							|  |  |  | void GPU_shader_geometry_stage_primitive_io(GPUShader *shader, int input, int output, int number); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int GPU_shader_get_attribute(GPUShader *shader, const char *name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Builtin/Non-generated shaders */ | 
					
						
							|  |  |  | typedef enum GPUBuiltinShader { | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  | 	GPU_SHADER_VSM_STORE, | 
					
						
							|  |  |  | 	GPU_SHADER_SEP_GAUSSIAN_BLUR, | 
					
						
							|  |  |  | 	GPU_SHADER_SMOKE, | 
					
						
							|  |  |  | 	GPU_SHADER_SMOKE_FIRE, | 
					
						
							|  |  |  | 	GPU_SHADER_SMOKE_COBA, | 
					
						
							| 
									
										
										
										
											2016-08-04 15:59:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-25 03:19:10 -04:00
										 |  |  | 	/* specialized drawing */ | 
					
						
							| 
									
										
										
										
											2016-09-17 13:33:02 +02:00
										 |  |  | 	GPU_SHADER_TEXT, | 
					
						
							| 
									
										
										
										
											2016-10-25 03:19:10 -04:00
										 |  |  | 	GPU_SHADER_EDGES_FRONT_BACK_PERSP, | 
					
						
							|  |  |  | 	GPU_SHADER_EDGES_FRONT_BACK_ORTHO, | 
					
						
							| 
									
										
										
										
											2016-11-05 19:26:13 +01:00
										 |  |  | 	GPU_SHADER_EDGES_OVERLAY_SIMPLE, | 
					
						
							|  |  |  | 	GPU_SHADER_EDGES_OVERLAY, | 
					
						
							| 
									
										
										
										
											2017-02-11 00:02:28 -05:00
										 |  |  | 	GPU_SHADER_KEYFRAME_DIAMOND, | 
					
						
							| 
									
										
										
										
											2017-02-07 13:04:08 +01:00
										 |  |  | 	GPU_SHADER_SIMPLE_LIGHTING, | 
					
						
							| 
									
										
										
										
											2017-05-10 20:14:52 +10:00
										 |  |  | 	GPU_SHADER_SIMPLE_LIGHTING_FLAT_COLOR, | 
					
						
							| 
									
										
										
										
											2017-03-11 16:10:03 +01:00
										 |  |  | 	GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR, | 
					
						
							| 
									
										
										
										
											2017-05-03 18:55:40 +02:00
										 |  |  | 	GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR_ALPHA, | 
					
						
							| 
									
										
										
										
											2016-08-16 14:58:53 -04:00
										 |  |  | 	/* for simple 2D drawing */ | 
					
						
							| 
									
										
										
										
											2016-08-04 15:59:38 -04:00
										 |  |  | 	GPU_SHADER_2D_UNIFORM_COLOR, | 
					
						
							| 
									
										
										
										
											2016-08-08 04:56:02 -04:00
										 |  |  | 	GPU_SHADER_2D_FLAT_COLOR, | 
					
						
							| 
									
										
										
										
											2016-08-04 15:59:38 -04:00
										 |  |  | 	GPU_SHADER_2D_SMOOTH_COLOR, | 
					
						
							| 
									
										
										
										
											2016-11-18 16:04:25 +01:00
										 |  |  | 	GPU_SHADER_2D_IMAGE_COLOR, | 
					
						
							| 
									
										
										
										
											2017-04-19 16:52:47 +02:00
										 |  |  | 	GPU_SHADER_2D_IMAGE_ALPHA_COLOR, | 
					
						
							| 
									
										
										
										
											2017-02-07 13:04:08 +01:00
										 |  |  | 	GPU_SHADER_2D_CHECKER, | 
					
						
							| 
									
										
										
										
											2017-02-16 21:49:20 -02:00
										 |  |  | 	GPU_SHADER_2D_DIAG_STRIPES, | 
					
						
							| 
									
										
										
										
											2016-08-16 14:58:53 -04:00
										 |  |  | 	/* for simple 3D drawing */ | 
					
						
							|  |  |  | 	GPU_SHADER_3D_UNIFORM_COLOR, | 
					
						
							| 
									
										
										
										
											2017-08-17 01:38:07 +10:00
										 |  |  | 	GPU_SHADER_3D_UNIFORM_COLOR_U32, | 
					
						
							| 
									
										
										
										
											2017-02-07 11:20:15 +01:00
										 |  |  | 	GPU_SHADER_3D_UNIFORM_COLOR_INSTANCE, | 
					
						
							| 
									
										
										
										
											2016-08-16 14:58:53 -04:00
										 |  |  | 	GPU_SHADER_3D_FLAT_COLOR, | 
					
						
							| 
									
										
										
										
											2017-05-05 05:17:31 +10:00
										 |  |  | 	GPU_SHADER_3D_FLAT_COLOR_U32,  /* use for select-id's */ | 
					
						
							| 
									
										
										
										
											2016-08-16 14:58:53 -04:00
										 |  |  | 	GPU_SHADER_3D_SMOOTH_COLOR, | 
					
						
							| 
									
										
										
										
											2016-09-13 02:51:38 -04:00
										 |  |  | 	GPU_SHADER_3D_DEPTH_ONLY, | 
					
						
							| 
									
										
										
										
											2017-04-05 01:28:48 +02:00
										 |  |  | 	GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR, | 
					
						
							| 
									
										
										
										
											2016-10-18 00:08:34 -04:00
										 |  |  | 	/* basic image drawing */ | 
					
						
							| 
									
										
										
										
											2017-05-11 16:20:10 +02:00
										 |  |  | 	GPU_SHADER_2D_IMAGE_LINEAR_TO_SRGB, | 
					
						
							| 
									
										
										
										
											2017-02-24 01:07:40 +01:00
										 |  |  | 	GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR, | 
					
						
							| 
									
										
										
										
											2016-11-08 10:51:42 -05:00
										 |  |  | 	GPU_SHADER_2D_IMAGE_MASK_UNIFORM_COLOR, | 
					
						
							| 
									
										
										
										
											2016-10-18 00:08:34 -04:00
										 |  |  | 	GPU_SHADER_3D_IMAGE_MODULATE_ALPHA, | 
					
						
							|  |  |  | 	GPU_SHADER_3D_IMAGE_RECT_MODULATE_ALPHA, | 
					
						
							| 
									
										
										
										
											2016-10-21 20:48:08 +00:00
										 |  |  | 	GPU_SHADER_3D_IMAGE_DEPTH, | 
					
						
							| 
									
										
										
										
											2017-01-09 17:58:13 +01:00
										 |  |  | 	/* stereo 3d */ | 
					
						
							|  |  |  | 	GPU_SHADER_2D_IMAGE_INTERLACE, | 
					
						
							| 
									
										
										
										
											2016-09-30 20:44:22 -04:00
										 |  |  | 	/* points */ | 
					
						
							| 
									
										
										
										
											2016-10-06 14:20:20 -04:00
										 |  |  | 	GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR, | 
					
						
							| 
									
										
										
										
											2017-02-28 02:18:52 -05:00
										 |  |  | 	GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA, | 
					
						
							|  |  |  | 	GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA, | 
					
						
							|  |  |  | 	GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA, | 
					
						
							| 
									
										
										
										
											2016-10-06 16:31:49 -04:00
										 |  |  | 	GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR, | 
					
						
							| 
									
										
										
										
											2016-10-06 14:20:20 -04:00
										 |  |  | 	GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR, | 
					
						
							| 
									
										
										
										
											2016-09-30 20:44:22 -04:00
										 |  |  | 	GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR, | 
					
						
							| 
									
										
										
										
											2017-02-28 02:18:52 -05:00
										 |  |  | 	GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA, | 
					
						
							|  |  |  | 	GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA, | 
					
						
							| 
									
										
										
										
											2016-09-30 20:44:22 -04:00
										 |  |  | 	GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR, | 
					
						
							| 
									
										
										
										
											2016-10-01 17:32:29 -04:00
										 |  |  | 	GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR, | 
					
						
							| 
									
										
										
										
											2017-02-24 15:33:09 -05:00
										 |  |  | 	/* lines */ | 
					
						
							| 
									
										
										
										
											2017-07-13 16:44:02 +02:00
										 |  |  | 	GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR, | 
					
						
							|  |  |  | 	GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR, | 
					
						
							| 
									
										
										
										
											2017-02-07 11:20:15 +01:00
										 |  |  | 	/* lamp drawing */ | 
					
						
							|  |  |  | 	GPU_SHADER_3D_GROUNDPOINT, | 
					
						
							|  |  |  | 	GPU_SHADER_3D_GROUNDLINE, | 
					
						
							| 
									
										
										
										
											2017-02-11 21:15:46 +01:00
										 |  |  | 	GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR, | 
					
						
							| 
									
										
										
										
											2017-02-22 12:46:27 +01:00
										 |  |  | 	/* bone drawing */ | 
					
						
							|  |  |  | 	GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR, | 
					
						
							|  |  |  | 	GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR, | 
					
						
							| 
									
										
										
										
											2017-03-04 00:09:22 +01:00
										 |  |  | 	/* camera drawing */ | 
					
						
							|  |  |  | 	GPU_SHADER_CAMERA, | 
					
						
							|  |  |  | 	/* distance in front of objects */ | 
					
						
							|  |  |  | 	GPU_SHADER_DISTANCE_LINES, | 
					
						
							| 
									
										
										
										
											2017-02-15 02:54:52 +01:00
										 |  |  | 	/* axis name */ | 
					
						
							| 
									
										
										
										
											2017-02-22 12:50:03 +01:00
										 |  |  | 	GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS, | 
					
						
							| 
									
										
										
										
											2017-04-10 22:22:37 +02:00
										 |  |  | 	GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED, | 
					
						
							| 
									
										
										
										
											2017-02-09 20:55:31 +01:00
										 |  |  | 	/* instance */ | 
					
						
							|  |  |  | 	GPU_SHADER_INSTANCE_UNIFORM_COLOR, | 
					
						
							| 
									
										
										
										
											2017-04-10 22:22:37 +02:00
										 |  |  | 	GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, /* Uniformly scaled */ | 
					
						
							|  |  |  | 	GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE, | 
					
						
							| 
									
										
										
										
											2017-03-05 05:22:40 +01:00
										 |  |  | 	GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR, | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-18 11:41:59 +02:00
										 |  |  | 	GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID, | 
					
						
							| 
									
										
										
										
											2017-05-18 12:10:10 +02:00
										 |  |  | 	GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE, | 
					
						
							| 
									
										
										
										
											2017-05-17 12:34:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-16 15:12:32 -02:00
										 |  |  | 	GPU_SHADER_3D_INSTANCE_MBALL_HELPERS, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-08 22:53:59 -06:00
										 |  |  | 	GPU_NUM_BUILTIN_SHADERS /* (not an actual shader) */ | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | } GPUBuiltinShader; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-09 17:58:13 +01:00
										 |  |  | /* Keep these in sync with:
 | 
					
						
							|  |  |  |  *  gpu_shader_image_interlace_frag.glsl | 
					
						
							|  |  |  |  *  gpu_shader_image_rect_interlace_frag.glsl | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | typedef enum GPUInterlaceShader { | 
					
						
							|  |  |  | 	GPU_SHADER_INTERLACE_ROW               = 0, | 
					
						
							|  |  |  | 	GPU_SHADER_INTERLACE_COLUMN            = 1, | 
					
						
							|  |  |  | 	GPU_SHADER_INTERLACE_CHECKER           = 2, | 
					
						
							|  |  |  | } GPUInterlaceShader; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader); | 
					
						
							|  |  |  | GPUShader *GPU_shader_get_builtin_fx_shader(int effects, bool persp); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GPU_shader_free_builtin_shaders(void); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Vertex attributes for shaders */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define GPU_MAX_ATTRIB 32
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct GPUVertexAttribs { | 
					
						
							|  |  |  | 	struct { | 
					
						
							|  |  |  | 		int type; | 
					
						
							|  |  |  | 		int glindex; | 
					
						
							| 
									
										
										
										
											2016-05-31 14:39:49 +02:00
										 |  |  | 		int glinfoindoex; | 
					
						
							| 
									
										
										
										
											2015-12-06 21:20:19 +01:00
										 |  |  | 		int gltexco; | 
					
						
							|  |  |  | 		int attribid; | 
					
						
							|  |  |  | 		char name[64];	/* MAX_CUSTOMDATA_LAYER_NAME */ | 
					
						
							|  |  |  | 	} layer[GPU_MAX_ATTRIB]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int totlayer; | 
					
						
							|  |  |  | } GPUVertexAttribs; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif  /* __GPU_SHADER_H__ */
 |