Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/gawain/src/shader_interface.c')
-rw-r--r--intern/gawain/src/shader_interface.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/intern/gawain/src/shader_interface.c b/intern/gawain/src/shader_interface.c
index 24f0a9f0e54..dff2c06f531 100644
--- a/intern/gawain/src/shader_interface.c
+++ b/intern/gawain/src/shader_interface.c
@@ -21,24 +21,24 @@
#include <stdio.h>
#endif
-static const char* BuiltinUniform_name(BuiltinUniform u)
+static const char* BuiltinUniform_name(Gwn_UniformBuiltin u)
{
static const char* names[] =
{
- [UNIFORM_NONE] = NULL,
+ [GWN_UNIFORM_NONE] = NULL,
- [UNIFORM_MODELVIEW] = "ModelViewMatrix",
- [UNIFORM_PROJECTION] = "ProjectionMatrix",
- [UNIFORM_MVP] = "ModelViewProjectionMatrix",
+ [GWN_UNIFORM_MODELVIEW] = "ModelViewMatrix",
+ [GWN_UNIFORM_PROJECTION] = "ProjectionMatrix",
+ [GWN_UNIFORM_MVP] = "ModelViewProjectionMatrix",
- [UNIFORM_MODELVIEW_INV] = "ModelViewInverseMatrix",
- [UNIFORM_PROJECTION_INV] = "ProjectionInverseMatrix",
+ [GWN_UNIFORM_MODELVIEW_INV] = "ModelViewInverseMatrix",
+ [GWN_UNIFORM_PROJECTION_INV] = "ProjectionInverseMatrix",
- [UNIFORM_NORMAL] = "NormalMatrix",
+ [GWN_UNIFORM_NORMAL] = "NormalMatrix",
- [UNIFORM_COLOR] = "color",
+ [GWN_UNIFORM_COLOR] = "color",
- [UNIFORM_CUSTOM] = NULL
+ [GWN_UNIFORM_CUSTOM] = NULL
};
return names[u];
@@ -61,17 +61,17 @@ static unsigned hash_string(const char *str)
return i;
}
-static void set_input_name(ShaderInput* input, const char* name)
+static void set_input_name(Gwn_ShaderInput* input, const char* name)
{
input->name = name;
input->name_hash = hash_string(name);
}
-// keep these in sync with BuiltinUniform order
-#define FIRST_MAT4_UNIFORM UNIFORM_MODELVIEW
-#define LAST_MAT4_UNIFORM UNIFORM_PROJECTION_INV
+// keep these in sync with Gwn_UniformBuiltin order
+#define FIRST_MAT4_UNIFORM GWN_UNIFORM_MODELVIEW
+#define LAST_MAT4_UNIFORM GWN_UNIFORM_PROJECTION_INV
-static bool setup_builtin_uniform(ShaderInput* input, const char* name)
+static bool setup_builtin_uniform(Gwn_ShaderInput* input, const char* name)
{
// TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types
@@ -80,7 +80,7 @@ static bool setup_builtin_uniform(ShaderInput* input, const char* name)
switch (input->gl_type)
{
case GL_FLOAT_MAT4:
- for (BuiltinUniform u = FIRST_MAT4_UNIFORM; u <= LAST_MAT4_UNIFORM; ++u)
+ for (Gwn_UniformBuiltin u = FIRST_MAT4_UNIFORM; u <= LAST_MAT4_UNIFORM; ++u)
{
const char* builtin_name = BuiltinUniform_name(u);
if (match(name, builtin_name))
@@ -93,22 +93,22 @@ static bool setup_builtin_uniform(ShaderInput* input, const char* name)
break;
case GL_FLOAT_MAT3:
{
- const char* builtin_name = BuiltinUniform_name(UNIFORM_NORMAL);
+ const char* builtin_name = BuiltinUniform_name(GWN_UNIFORM_NORMAL);
if (match(name, builtin_name))
{
set_input_name(input, builtin_name);
- input->builtin_type = UNIFORM_NORMAL;
+ input->builtin_type = GWN_UNIFORM_NORMAL;
return true;
}
}
break;
case GL_FLOAT_VEC4:
{
- const char* builtin_name = BuiltinUniform_name(UNIFORM_COLOR);
+ const char* builtin_name = BuiltinUniform_name(GWN_UNIFORM_COLOR);
if (match(name, builtin_name))
{
set_input_name(input, builtin_name);
- input->builtin_type = UNIFORM_COLOR;
+ input->builtin_type = GWN_UNIFORM_COLOR;
return true;
}
}
@@ -117,11 +117,11 @@ static bool setup_builtin_uniform(ShaderInput* input, const char* name)
;
}
- input->builtin_type = UNIFORM_CUSTOM;
+ input->builtin_type = GWN_UNIFORM_CUSTOM;
return false;
}
-ShaderInterface* ShaderInterface_create(GLint program)
+Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program)
{
#if DEBUG_SHADER_INTERFACE
printf("%s {\n", __func__); // enter function
@@ -138,16 +138,16 @@ ShaderInterface* ShaderInterface_create(GLint program)
const uint32_t name_buffer_len = uniform_ct * max_uniform_name_len + attrib_ct * max_attrib_name_len;
// allocate enough space for input counts, details for each input, and a buffer for name strings
- ShaderInterface* shaderface = calloc(1, offsetof(ShaderInterface, inputs) + input_ct * sizeof(ShaderInput) + name_buffer_len);
+ Gwn_ShaderInterface* shaderface = calloc(1, offsetof(Gwn_ShaderInterface, inputs) + input_ct * sizeof(Gwn_ShaderInput) + name_buffer_len);
shaderface->uniform_ct = uniform_ct;
shaderface->attrib_ct = attrib_ct;
- char* name_buffer = (char*)shaderface + offsetof(ShaderInterface, inputs) + input_ct * sizeof(ShaderInput);
+ char* name_buffer = (char*)shaderface + offsetof(Gwn_ShaderInterface, inputs) + input_ct * sizeof(Gwn_ShaderInput);
uint32_t name_buffer_offset = 0;
for (uint32_t i = 0; i < uniform_ct; ++i)
{
- ShaderInput* input = shaderface->inputs + i;
+ Gwn_ShaderInput* input = shaderface->inputs + i;
GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
char* name = name_buffer + name_buffer_offset;
GLsizei name_len = 0;
@@ -181,7 +181,7 @@ ShaderInterface* ShaderInterface_create(GLint program)
for (uint32_t i = 0; i < attrib_ct; ++i)
{
- ShaderInput* input = shaderface->inputs + uniform_ct + i;
+ Gwn_ShaderInput* input = shaderface->inputs + uniform_ct + i;
GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
char* name = name_buffer + name_buffer_offset;
GLsizei name_len = 0;
@@ -221,7 +221,7 @@ ShaderInterface* ShaderInterface_create(GLint program)
{
// realloc shaderface to shrink name buffer
const size_t shaderface_alloc =
- offsetof(ShaderInterface, inputs) + (input_ct * sizeof(ShaderInput)) + name_buffer_used;
+ offsetof(Gwn_ShaderInterface, inputs) + (input_ct * sizeof(Gwn_ShaderInput)) + name_buffer_used;
const char* shaderface_orig_start = (const char*)shaderface;
const char* shaderface_orig_end = &shaderface_orig_start[shaderface_alloc];
shaderface = realloc(shaderface, shaderface_alloc);
@@ -232,7 +232,7 @@ ShaderInterface* ShaderInterface_create(GLint program)
// each input->name will need adjustment (except static built-in names)
for (uint32_t i = 0; i < input_ct; ++i)
{
- ShaderInput* input = shaderface->inputs + i;
+ Gwn_ShaderInput* input = shaderface->inputs + i;
if (input->name >= shaderface_orig_start && input->name < shaderface_orig_end)
input->name += delta;
@@ -243,18 +243,18 @@ ShaderInterface* ShaderInterface_create(GLint program)
return shaderface;
}
-void ShaderInterface_discard(ShaderInterface* shaderface)
+void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface)
{
// allocated as one chunk, so discard is simple
free(shaderface);
}
-const ShaderInput* ShaderInterface_uniform(const ShaderInterface* shaderface, const char* name)
+const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface* shaderface, const char* name)
{
const unsigned name_hash = hash_string(name);
for (uint32_t i = 0; i < shaderface->uniform_ct; ++i)
{
- const ShaderInput* uniform = shaderface->inputs + i;
+ const Gwn_ShaderInput* uniform = shaderface->inputs + i;
#if SUPPORT_LEGACY_GLSL
if (uniform->name == NULL) continue;
@@ -271,17 +271,17 @@ const ShaderInput* ShaderInterface_uniform(const ShaderInterface* shaderface, co
return NULL; // not found
}
-const ShaderInput* ShaderInterface_builtin_uniform(const ShaderInterface* shaderface, BuiltinUniform builtin)
+const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin)
{
#if TRUST_NO_ONE
- assert(builtin != UNIFORM_NONE);
- assert(builtin != UNIFORM_CUSTOM);
+ assert(builtin != GWN_UNIFORM_NONE);
+ assert(builtin != GWN_UNIFORM_CUSTOM);
#endif
// look up by enum, not name
for (uint32_t i = 0; i < shaderface->uniform_ct; ++i)
{
- const ShaderInput* uniform = shaderface->inputs + i;
+ const Gwn_ShaderInput* uniform = shaderface->inputs + i;
if (uniform->builtin_type == builtin)
return uniform;
@@ -289,14 +289,14 @@ const ShaderInput* ShaderInterface_builtin_uniform(const ShaderInterface* shader
return NULL; // not found
}
-const ShaderInput* ShaderInterface_attrib(const ShaderInterface* shaderface, const char* name)
+const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shaderface, const char* name)
{
// attribs are stored after uniforms
const uint32_t input_ct = shaderface->uniform_ct + shaderface->attrib_ct;
const unsigned name_hash = hash_string(name);
for (uint32_t i = shaderface->uniform_ct; i < input_ct; ++i)
{
- const ShaderInput* attrib = shaderface->inputs + i;
+ const Gwn_ShaderInput* attrib = shaderface->inputs + i;
#if SUPPORT_LEGACY_GLSL
if (attrib->name == NULL) continue;