[Bf-blender-cvs] [beb375cdb25] blender2.8: GPU_codegen: Fix geometry shader.
Clément Foucault
noreply at git.blender.org
Wed Jun 28 21:15:51 CEST 2017
Commit: beb375cdb250d0d2eab6d060e2049fe1e48b79db
Author: Clément Foucault
Date: Wed Jun 28 21:28:24 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBbeb375cdb250d0d2eab6d060e2049fe1e48b79db
GPU_codegen: Fix geometry shader.
===================================================================
M source/blender/gpu/intern/gpu_codegen.c
===================================================================
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index afdb927fbcc..87fbccc0c87 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -979,36 +979,38 @@ static char *code_generate_geometry_new(ListBase *nodes, const char *geom_code)
GPUInput *input;
char *code;
+ /* Create prototype because attributes cannot be declared before layout. */
+ BLI_dynstr_appendf(ds, "void pass_attrib(in int vert);\n");
+ BLI_dynstr_append(ds, "#define ATTRIB\n");
+
+ BLI_dynstr_append(ds, geom_code);
+
/* Generate varying declarations. */
for (node = nodes->first; node; node = node->next) {
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, "in %s var%dg[];\n",
- GPU_DATATYPE_STR[input->type],
- input->attribid);
- BLI_dynstr_appendf(ds, "out %s var%d;\n",
- GPU_DATATYPE_STR[input->type],
- input->attribid);
- }
+ BLI_dynstr_appendf(ds, "in %s var%dg[];\n",
+ GPU_DATATYPE_STR[input->type],
+ input->attribid);
+ BLI_dynstr_appendf(ds, "out %s var%d;\n",
+ GPU_DATATYPE_STR[input->type],
+ input->attribid);
}
}
}
+
/* Generate varying assignments. */
- BLI_dynstr_append(ds, "#define ATTRIB\n");
BLI_dynstr_appendf(ds, "void pass_attrib(in int vert) {\n");
for (node = nodes->first; node; node = node->next) {
for (input = node->inputs.first; input; input = input->next) {
if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
/* TODO let shader choose what to do depending on what the attrib is. */
- BLI_dynstr_appendf(ds, "\tvar%d = var%dg[vert];", input->attribid, input->attribid);
+ BLI_dynstr_appendf(ds, "\tvar%d = var%dg[vert];\n", input->attribid, input->attribid);
}
}
}
BLI_dynstr_append(ds, "}\n");
- BLI_dynstr_append(ds, geom_code);
-
code = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
More information about the Bf-blender-cvs
mailing list