diff options
Diffstat (limited to 'tools/glsl_preproc/templates')
-rw-r--r-- | tools/glsl_preproc/templates/call.c.j2 | 19 | ||||
-rw-r--r-- | tools/glsl_preproc/templates/function.c.j2 | 19 | ||||
-rw-r--r-- | tools/glsl_preproc/templates/glsl_block.c.j2 | 17 | ||||
-rw-r--r-- | tools/glsl_preproc/templates/struct.c.j2 | 5 |
4 files changed, 60 insertions, 0 deletions
diff --git a/tools/glsl_preproc/templates/call.c.j2 b/tools/glsl_preproc/templates/call.c.j2 new file mode 100644 index 0000000..61ee6c0 --- /dev/null +++ b/tools/glsl_preproc/templates/call.c.j2 @@ -0,0 +1,19 @@ +{ +{% if macro.vars %} + const {{ macro.render_struct() }} {{ macro.name }}_args = { + {% for var in macro.vars %} +#line {{ var.linenr }} + .{{ var.name }} = {{ var.expr }}, + {% endfor %} + }; +#line {{ macro.linenr }} +{% endif %} + size_t {{ macro.name }}_fn(void *, pl_str *, const uint8_t *); +{% if macro.vars %} + pl_str_builder_append(sh->buffers[{{ macro.buf }}], {{ macro.name }}_fn, + &{{ macro.name }}_args, sizeof({{ macro.name }}_args)); +{% else %} + pl_str_builder_append(sh->buffers[{{ macro.buf }}], {{ macro.name }}_fn, NULL, 0); +{% endif %} +} + diff --git a/tools/glsl_preproc/templates/function.c.j2 b/tools/glsl_preproc/templates/function.c.j2 new file mode 100644 index 0000000..9216472 --- /dev/null +++ b/tools/glsl_preproc/templates/function.c.j2 @@ -0,0 +1,19 @@ + +size_t {{ macro.name }}_fn(void *alloc, pl_str *buf, const uint8_t *ptr); +size_t {{ macro.name }}_fn(void *alloc, pl_str *buf, const uint8_t *ptr) +{ +{% if macro.vars %} +{{ macro.render_struct() }} {{ Var.STRUCT_NAME }}; +memcpy(&{{ Var.STRUCT_NAME }}, ptr, sizeof({{ Var.STRUCT_NAME }})); +{% endif %} + +{% for statement in macro.body %} +{{ statement.render() }} +{% endfor %} + +{% if macro.vars %} +return sizeof({{ Var.STRUCT_NAME }}); +{% else %} +return 0; +{% endif %} +} diff --git a/tools/glsl_preproc/templates/glsl_block.c.j2 b/tools/glsl_preproc/templates/glsl_block.c.j2 new file mode 100644 index 0000000..aa8372d --- /dev/null +++ b/tools/glsl_preproc/templates/glsl_block.c.j2 @@ -0,0 +1,17 @@ +#line {{ block.linenr }} +{% if block.refs %} + pl_str_append_asprintf_c(alloc, buf, + {% for line in block.lines %} + {{ line.fmtstr }}{{ ',' if loop.last }} + {% endfor %} + {% for ref in block.refs %} + {{ ref }}{{ ',' if not loop.last }} + {% endfor %} + ); +{% else %} + pl_str_append(alloc, buf, pl_str0( + {% for line in block.lines %} + {{ line.rawstr }} + {% endfor %} + )); +{% endif %} diff --git a/tools/glsl_preproc/templates/struct.c.j2 b/tools/glsl_preproc/templates/struct.c.j2 new file mode 100644 index 0000000..6a6a8fb --- /dev/null +++ b/tools/glsl_preproc/templates/struct.c.j2 @@ -0,0 +1,5 @@ +struct __attribute__((__packed__)) { +{% for var in macro.vars %} + {{ var.ctype }} {{ var.name }}; +{% endfor %} +} |