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:
authorAntony Riakiotakis <kalast@gmail.com>2014-04-02 16:07:45 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-04-02 16:08:04 +0400
commit965e5039f5d158c7c89d525e83b830f9ad10adc0 (patch)
tree14c65dd638311dcec90f8d9ee56fcb4b738e6310 /source/blender/gpu/intern/gpu_codegen.c
parent26b2645d62f3f60b0125dcb14a8daa03920a6031 (diff)
Refactor to recent matcap built-ins to not use the built in system.
Those variables would get declared on fragment shader level and since we use reserved opengl variables, some compilers would throw an error (NVIDIA allows, some ATI compilers may break). Instead, use a separate opengl built-in category especially for them. This works on NVIDIA, and will wait for tests of this commit from ATI users.
Diffstat (limited to 'source/blender/gpu/intern/gpu_codegen.c')
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 18b512309bd..2687157d01b 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -365,10 +365,6 @@ const char *GPU_builtin_name(GPUBuiltin builtin)
return "unfobcolor";
else if (builtin == GPU_AUTO_BUMPSCALE)
return "unfobautobumpscale";
- else if (builtin == GPU_MATCAP_NORMAL)
- return "gl_SecondaryColor";
- else if (builtin == GPU_COLOR)
- return "gl_Color";
else
return "";
}
@@ -583,8 +579,15 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
else
BLI_dynstr_appendf(ds, "cons%d", input->id);
}
- else if (input->source == GPU_SOURCE_ATTRIB)
+ else if (input->source == GPU_SOURCE_ATTRIB) {
BLI_dynstr_appendf(ds, "var%d", input->attribid);
+ }
+ else if (input->source == GPU_SOURCE_OPENGL_BUILTIN) {
+ if (input->oglbuiltin == GPU_MATCAP_NORMAL)
+ BLI_dynstr_append(ds, "gl_SecondaryColor");
+ else if (input->oglbuiltin == GPU_COLOR)
+ BLI_dynstr_append(ds, "gl_Color");
+ }
BLI_dynstr_append(ds, ", ");
}
@@ -670,14 +673,14 @@ static char *code_generate_vertex(ListBase *nodes)
BLI_dynstr_appendf(ds, "\tvar%d = att%d;\n", input->attribid, input->attribid);
}
/* unfortunately special handling is needed here because we abuse gl_Color/gl_SecondaryColor flat shading */
- else if (input->source == GPU_SOURCE_BUILTIN) {
- if (input->builtin == GPU_MATCAP_NORMAL) {
+ else if (input->source == GPU_SOURCE_OPENGL_BUILTIN) {
+ if (input->oglbuiltin == GPU_MATCAP_NORMAL) {
/* remap to 0.0 - 1.0 range. This is done because OpenGL 2.0 clamps colors
* between shader stages and we want the full range of the normal */
BLI_dynstr_appendf(ds, "\tvec3 matcapcol = vec3(0.5, 0.5, 0.5) * varnormal + vec3(0.5, 0.5, 0.5);\n");
BLI_dynstr_appendf(ds, "\tgl_FrontSecondaryColor = vec4(matcapcol, 1.0);\n");
}
- else if (input->builtin == GPU_COLOR) {
+ else if (input->oglbuiltin == GPU_COLOR) {
BLI_dynstr_appendf(ds, "\tgl_FrontColor = gl_Color;\n");
}
}
@@ -747,7 +750,8 @@ static void GPU_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes)
/* attributes don't need to be bound, they already have
* an id that the drawing functions will use */
if (input->source == GPU_SOURCE_ATTRIB ||
- input->source == GPU_SOURCE_BUILTIN)
+ input->source == GPU_SOURCE_BUILTIN ||
+ input->source == GPU_SOURCE_OPENGL_BUILTIN)
{
continue;
}
@@ -915,6 +919,14 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type)
MEM_freeN(link);
}
+ else if (link->oglbuiltin) {
+ /* builtin uniform */
+ input->type = type;
+ input->source = GPU_SOURCE_OPENGL_BUILTIN;
+ input->oglbuiltin = link->oglbuiltin;
+
+ MEM_freeN(link);
+ }
else if (link->output) {
/* link to a node output */
input->type = type;
@@ -1207,6 +1219,15 @@ GPUNodeLink *GPU_builtin(GPUBuiltin builtin)
return link;
}
+GPUNodeLink *GPU_opengl_builtin(GPUOpenGLBuiltin builtin)
+{
+ GPUNodeLink *link = GPU_node_link_create(0);
+
+ link->oglbuiltin = builtin;
+
+ return link;
+}
+
bool GPU_link(GPUMaterial *mat, const char *name, ...)
{
GPUNode *node;