OpenGL: codegen formatting
Formatting of generated GLSL code: - attribute/varying for version 120 - in/out for version 130+ - minor cosmetic stuff Tested working on Windows 10, GL 4.3.
This commit is contained in:
@@ -501,7 +501,7 @@ static int codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes)
|
||||
input->texid);
|
||||
}
|
||||
else if (input->source == GPU_SOURCE_BUILTIN) {
|
||||
/* only define each builting uniform/varying once */
|
||||
/* only define each builtin uniform/varying once */
|
||||
if (!(builtins & input->builtin)) {
|
||||
builtins |= input->builtin;
|
||||
name = GPU_builtin_name(input->builtin);
|
||||
@@ -511,7 +511,8 @@ static int codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes)
|
||||
GPU_DATATYPE_STR[input->type], name);
|
||||
}
|
||||
else {
|
||||
BLI_dynstr_appendf(ds, "varying %s %s;\n",
|
||||
BLI_dynstr_appendf(ds, "%s %s %s;\n",
|
||||
GLEW_VERSION_3_0 ? "in" : "varying",
|
||||
GPU_DATATYPE_STR[input->type], name);
|
||||
}
|
||||
}
|
||||
@@ -537,7 +538,8 @@ static int codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes)
|
||||
BLI_dynstr_appendf(ds, "#ifndef USE_OPENSUBDIV\n");
|
||||
}
|
||||
#endif
|
||||
BLI_dynstr_appendf(ds, "varying %s var%d;\n",
|
||||
BLI_dynstr_appendf(ds, "%s %s var%d;\n",
|
||||
GLEW_VERSION_3_0 ? "in" : "varying",
|
||||
GPU_DATATYPE_STR[input->type], input->attribid);
|
||||
#ifdef WITH_OPENSUBDIV
|
||||
if (skip_opensubdiv) {
|
||||
@@ -662,11 +664,10 @@ static char *code_generate_fragment(ListBase *nodes, GPUOutput *output)
|
||||
BLI_dynstr_appendf(ds, "/* %s */\n", name);
|
||||
#endif
|
||||
|
||||
BLI_dynstr_append(ds, "void main(void)\n");
|
||||
BLI_dynstr_append(ds, "{\n");
|
||||
BLI_dynstr_append(ds, "void main()\n{\n");
|
||||
|
||||
if (builtins & GPU_VIEW_NORMAL)
|
||||
BLI_dynstr_append(ds, "\tvec3 facingnormal = (gl_FrontFacing)? varnormal: -varnormal;\n");
|
||||
BLI_dynstr_append(ds, "\tvec3 facingnormal = gl_FrontFacing? varnormal: -varnormal;\n");
|
||||
|
||||
/* Calculate tangent space. */
|
||||
#ifdef WITH_OPENSUBDIV
|
||||
@@ -729,9 +730,11 @@ static char *code_generate_vertex(ListBase *nodes, const GPUMatType type)
|
||||
BLI_dynstr_appendf(ds, "#ifndef USE_OPENSUBDIV\n");
|
||||
}
|
||||
#endif
|
||||
BLI_dynstr_appendf(ds, "attribute %s att%d;\n",
|
||||
BLI_dynstr_appendf(ds, "%s %s att%d;\n",
|
||||
GLEW_VERSION_3_0 ? "in" : "attribute",
|
||||
GPU_DATATYPE_STR[input->type], input->attribid);
|
||||
BLI_dynstr_appendf(ds, "varying %s var%d;\n",
|
||||
BLI_dynstr_appendf(ds, "%s %s var%d;\n",
|
||||
GLEW_VERSION_3_0 ? "out" : "varying",
|
||||
GPU_DATATYPE_STR[input->type], input->attribid);
|
||||
#ifdef WITH_OPENSUBDIV
|
||||
if (skip_opensubdiv) {
|
||||
@@ -791,7 +794,7 @@ static char *code_generate_vertex(ListBase *nodes, const GPUMatType type)
|
||||
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, "\tvec3 matcapcol = vec3(0.5) * varnormal + vec3(0.5);\n");
|
||||
BLI_dynstr_appendf(ds, "\tgl_FrontSecondaryColor = vec4(matcapcol, 1.0);\n");
|
||||
}
|
||||
else if (input->oglbuiltin == GPU_COLOR) {
|
||||
@@ -799,7 +802,7 @@ static char *code_generate_vertex(ListBase *nodes, const GPUMatType type)
|
||||
}
|
||||
}
|
||||
|
||||
BLI_dynstr_append(ds, "}\n\n");
|
||||
BLI_dynstr_append(ds, "}\n");
|
||||
|
||||
code = BLI_dynstr_get_cstring(ds);
|
||||
|
||||
@@ -826,7 +829,8 @@ static char *code_generate_geometry(ListBase *nodes, bool use_opensubdiv)
|
||||
for (input = node->inputs.first; input; input = input->next) {
|
||||
if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
|
||||
if (input->attribtype == CD_MTFACE) {
|
||||
BLI_dynstr_appendf(ds, "varying %s var%d;\n",
|
||||
BLI_dynstr_appendf(ds, "%s %s var%d;\n",
|
||||
GLEW_VERSION_3_0 ? "in" : "varying",
|
||||
GPU_DATATYPE_STR[input->type],
|
||||
input->attribid);
|
||||
BLI_dynstr_appendf(ds, "uniform int fvar%d_offset;\n",
|
||||
@@ -856,7 +860,7 @@ static char *code_generate_geometry(ListBase *nodes, bool use_opensubdiv)
|
||||
}
|
||||
#endif
|
||||
|
||||
BLI_dynstr_append(ds, "}\n\n");
|
||||
BLI_dynstr_append(ds, "}\n");
|
||||
code = BLI_dynstr_get_cstring(ds);
|
||||
BLI_dynstr_free(ds);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user