diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-06-28 22:28:24 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-06-28 22:28:24 +0300 |
commit | beb375cdb250d0d2eab6d060e2049fe1e48b79db (patch) | |
tree | 6be51511f9847c147ac265e6ecf49e1b31addb63 /source/blender/gpu | |
parent | ada6e720f941dbd50e75b04feea6dae16b8ffc55 (diff) |
GPU_codegen: Fix geometry shader.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 26 |
1 files changed, 14 insertions, 12 deletions
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); |