| 
									
										
										
										
											2018-07-17 14:46:44 +02: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) 2016 by Mike Erwin. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Blender Foundation | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | /** \file blender/gpu/GPU_shader_interface.h
 | 
					
						
							| 
									
										
										
										
											2018-07-17 14:46:44 +02:00
										 |  |  |  *  \ingroup gpu | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  |  * GPU shader interface (C --> GLSL) | 
					
						
							| 
									
										
										
										
											2018-07-17 14:46:44 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | #ifndef __GPU_SHADER_INTERFACE_H__
 | 
					
						
							|  |  |  | #define __GPU_SHADER_INTERFACE_H__
 | 
					
						
							| 
									
										
										
										
											2017-03-02 21:27:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  | #include "GPU_common.h"
 | 
					
						
							| 
									
										
										
										
											2017-03-02 21:27:51 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef enum { | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	GPU_UNIFORM_NONE = 0, /* uninitialized/unknown */ | 
					
						
							| 
									
										
										
										
											2017-03-02 21:27:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	GPU_UNIFORM_MODEL,      /* mat4 ModelMatrix */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_VIEW,       /* mat4 ViewMatrix */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_MODELVIEW,  /* mat4 ModelViewMatrix */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_PROJECTION, /* mat4 ProjectionMatrix */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_VIEWPROJECTION, /* mat4 ViewProjectionMatrix */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_MVP,        /* mat4 ModelViewProjectionMatrix */ | 
					
						
							| 
									
										
										
										
											2017-04-12 17:56:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	GPU_UNIFORM_MODEL_INV,           /* mat4 ModelMatrixInverse */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_VIEW_INV,            /* mat4 ViewMatrixInverse */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_MODELVIEW_INV,       /* mat4 ModelViewMatrixInverse */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_PROJECTION_INV,      /* mat4 ProjectionMatrixInverse */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_VIEWPROJECTION_INV,  /* mat4 ViewProjectionMatrixInverse */ | 
					
						
							| 
									
										
										
										
											2017-03-02 21:27:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	GPU_UNIFORM_NORMAL,      /* mat3 NormalMatrix */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_ORCO,        /* vec3 OrcoTexCoFactors[] */ | 
					
						
							| 
									
										
										
										
											2017-04-15 19:19:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	GPU_UNIFORM_COLOR, /* vec4 color */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_EYE, /* vec3 eye */ | 
					
						
							|  |  |  | 	GPU_UNIFORM_CALLID, /* int callId */ | 
					
						
							| 
									
										
										
										
											2018-10-09 17:32:13 +02:00
										 |  |  | 	GPU_UNIFORM_OBJECT_INFO, /* vec3 objectInfo */ | 
					
						
							| 
									
										
										
										
											2017-03-02 21:27:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	GPU_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ | 
					
						
							| 
									
										
										
										
											2017-10-05 16:19:14 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	GPU_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */ | 
					
						
							|  |  |  | } GPUUniformBuiltin; | 
					
						
							| 
									
										
										
										
											2017-03-02 21:27:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | typedef struct GPUShaderInput { | 
					
						
							| 
									
										
										
										
											2018-07-18 23:09:31 +10:00
										 |  |  | 	struct GPUShaderInput *next; | 
					
						
							| 
									
										
										
										
											2017-10-05 18:26:50 +02:00
										 |  |  | 	uint32_t name_offset; | 
					
						
							| 
									
										
										
										
											2018-07-17 14:46:44 +02:00
										 |  |  | 	uint name_hash; | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	GPUUniformBuiltin builtin_type; /* only for uniform inputs */ | 
					
						
							| 
									
										
										
										
											2018-07-17 14:46:44 +02:00
										 |  |  | 	uint32_t gl_type; /* only for attrib inputs */ | 
					
						
							|  |  |  | 	int32_t size; /* only for attrib inputs */ | 
					
						
							| 
									
										
										
										
											2018-06-16 12:44:20 -06:00
										 |  |  | 	int32_t location; | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | } GPUShaderInput; | 
					
						
							| 
									
										
										
										
											2017-03-02 21:27:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | #define GPU_NUM_SHADERINTERFACE_BUCKETS 257
 | 
					
						
							|  |  |  | #define GPU_SHADERINTERFACE_REF_ALLOC_COUNT 16
 | 
					
						
							| 
									
										
										
										
											2017-10-04 17:36:52 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | typedef struct GPUShaderInterface { | 
					
						
							| 
									
										
										
										
											2018-06-16 12:44:20 -06:00
										 |  |  | 	int32_t program; | 
					
						
							| 
									
										
										
										
											2017-10-05 18:26:50 +02:00
										 |  |  | 	uint32_t name_buffer_offset; | 
					
						
							| 
									
										
										
										
											2018-07-18 23:09:31 +10:00
										 |  |  | 	GPUShaderInput *attrib_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; | 
					
						
							|  |  |  | 	GPUShaderInput *uniform_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; | 
					
						
							|  |  |  | 	GPUShaderInput *ubo_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; | 
					
						
							|  |  |  | 	GPUShaderInput *builtin_uniforms[GPU_NUM_UNIFORMS]; | 
					
						
							|  |  |  | 	char *name_buffer; | 
					
						
							|  |  |  | 	struct GPUBatch **batches; /* references to batches using this interface */ | 
					
						
							| 
									
										
										
										
											2018-07-17 14:46:44 +02:00
										 |  |  | 	uint batches_len; | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | } GPUShaderInterface; | 
					
						
							| 
									
										
										
										
											2017-03-02 21:27:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 23:09:31 +10:00
										 |  |  | GPUShaderInterface *GPU_shaderinterface_create(int32_t program_id); | 
					
						
							|  |  |  | void GPU_shaderinterface_discard(GPUShaderInterface *); | 
					
						
							| 
									
										
										
										
											2017-04-12 17:56:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 23:09:31 +10:00
										 |  |  | const GPUShaderInput *GPU_shaderinterface_uniform(const GPUShaderInterface *, const char *name); | 
					
						
							|  |  |  | const GPUShaderInput *GPU_shaderinterface_uniform_builtin(const GPUShaderInterface *, GPUUniformBuiltin); | 
					
						
							|  |  |  | const GPUShaderInput *GPU_shaderinterface_ubo(const GPUShaderInterface *, const char *name); | 
					
						
							|  |  |  | const GPUShaderInput *GPU_shaderinterface_attr(const GPUShaderInterface *, const char *name); | 
					
						
							| 
									
										
										
										
											2018-02-20 01:55:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-17 14:46:44 +02:00
										 |  |  | /* keep track of batches using this interface */ | 
					
						
							| 
									
										
										
										
											2018-07-18 23:09:31 +10:00
										 |  |  | void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *, struct GPUBatch *); | 
					
						
							|  |  |  | void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface *, struct GPUBatch *); | 
					
						
							| 
									
										
										
										
											2018-07-17 14:46:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | #endif /* __GPU_SHADER_INTERFACE_H__ */
 |