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 *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file blender/gpu/gwn_shader_interface.h
|
|
|
|
* \ingroup gpu
|
|
|
|
*
|
|
|
|
* Gawain shader interface (C --> GLSL)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GWN_SHADER_INTERFACE_H__
|
|
|
|
#define __GWN_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-17 14:46:44 +02:00
|
|
|
GWN_UNIFORM_NONE = 0, /* uninitialized/unknown */
|
2017-03-02 21:27:51 -05:00
|
|
|
|
2018-07-17 14:46:44 +02:00
|
|
|
GWN_UNIFORM_MODEL, /* mat4 ModelMatrix */
|
|
|
|
GWN_UNIFORM_VIEW, /* mat4 ViewMatrix */
|
|
|
|
GWN_UNIFORM_MODELVIEW, /* mat4 ModelViewMatrix */
|
|
|
|
GWN_UNIFORM_PROJECTION, /* mat4 ProjectionMatrix */
|
|
|
|
GWN_UNIFORM_VIEWPROJECTION, /* mat4 ViewProjectionMatrix */
|
|
|
|
GWN_UNIFORM_MVP, /* mat4 ModelViewProjectionMatrix */
|
2017-04-12 17:56:26 -04:00
|
|
|
|
2018-07-17 14:46:44 +02:00
|
|
|
GWN_UNIFORM_MODEL_INV, /* mat4 ModelMatrixInverse */
|
|
|
|
GWN_UNIFORM_VIEW_INV, /* mat4 ViewMatrixInverse */
|
|
|
|
GWN_UNIFORM_MODELVIEW_INV, /* mat4 ModelViewMatrixInverse */
|
|
|
|
GWN_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */
|
|
|
|
GWN_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */
|
2017-03-02 21:27:51 -05:00
|
|
|
|
2018-07-17 14:46:44 +02:00
|
|
|
GWN_UNIFORM_NORMAL, /* mat3 NormalMatrix */
|
|
|
|
GWN_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */
|
|
|
|
GWN_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */
|
|
|
|
GWN_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */
|
2017-04-15 19:19:00 -04:00
|
|
|
|
2018-07-17 14:46:44 +02:00
|
|
|
GWN_UNIFORM_COLOR, /* vec4 color */
|
|
|
|
GWN_UNIFORM_EYE, /* vec3 eye */
|
|
|
|
GWN_UNIFORM_CALLID, /* int callId */
|
2017-03-02 21:27:51 -05:00
|
|
|
|
2018-07-17 14:46:44 +02:00
|
|
|
GWN_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */
|
2017-10-05 16:19:14 +05:00
|
|
|
|
2018-07-17 14:46:44 +02:00
|
|
|
GWN_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */
|
2017-06-19 20:18:04 +10:00
|
|
|
} Gwn_UniformBuiltin;
|
2017-03-02 21:27:51 -05:00
|
|
|
|
2017-08-17 20:37:37 +10:00
|
|
|
typedef struct Gwn_ShaderInput {
|
2017-10-05 18:26:50 +02:00
|
|
|
struct Gwn_ShaderInput* next;
|
|
|
|
uint32_t name_offset;
|
2018-07-17 14:46:44 +02:00
|
|
|
uint name_hash;
|
|
|
|
Gwn_UniformBuiltin builtin_type; /* only for uniform inputs */
|
|
|
|
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;
|
2017-06-19 20:18:04 +10:00
|
|
|
} Gwn_ShaderInput;
|
2017-03-02 21:27:51 -05:00
|
|
|
|
2017-10-06 16:25:38 +02:00
|
|
|
#define GWN_NUM_SHADERINTERFACE_BUCKETS 257
|
2018-02-20 01:55:19 +01:00
|
|
|
#define GWN_SHADERINTERFACE_REF_ALLOC_COUNT 16
|
2017-10-04 17:36:52 +05:00
|
|
|
|
2017-08-17 20:37:37 +10:00
|
|
|
typedef struct Gwn_ShaderInterface {
|
2018-06-16 12:44:20 -06:00
|
|
|
int32_t program;
|
2017-10-05 18:26:50 +02:00
|
|
|
uint32_t name_buffer_offset;
|
|
|
|
Gwn_ShaderInput* attrib_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
|
|
|
|
Gwn_ShaderInput* uniform_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
|
2017-10-06 14:57:21 +02:00
|
|
|
Gwn_ShaderInput* ubo_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
|
2017-10-05 16:19:14 +05:00
|
|
|
Gwn_ShaderInput* builtin_uniforms[GWN_NUM_UNIFORMS];
|
2017-10-05 18:26:50 +02:00
|
|
|
char* name_buffer;
|
2018-07-17 14:46:44 +02:00
|
|
|
struct Gwn_Batch** batches; /* references to batches using this interface */
|
|
|
|
uint batches_len;
|
2017-06-19 20:18:04 +10:00
|
|
|
} Gwn_ShaderInterface;
|
2017-03-02 21:27:51 -05:00
|
|
|
|
2018-06-16 12:44:20 -06:00
|
|
|
Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id);
|
2017-06-19 20:18:04 +10:00
|
|
|
void GWN_shaderinterface_discard(Gwn_ShaderInterface*);
|
2017-04-12 17:56:26 -04:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name);
|
|
|
|
const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface*, Gwn_UniformBuiltin);
|
2017-10-06 14:57:21 +02:00
|
|
|
const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface*, const char* name);
|
2017-06-19 20:18:04 +10:00
|
|
|
const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface*, 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-02-20 01:55:19 +01:00
|
|
|
void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*);
|
|
|
|
void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*);
|
2018-07-17 14:46:44 +02:00
|
|
|
|
|
|
|
#endif /* __GWN_SHADER_INTERFACE_H__ */
|