summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2015-09-29 19:24:04 +0300
committerFrancisco Jerez <currojerez@riseup.net>2015-10-03 18:16:17 +0300
commit8349602964854b31c91bc64973da29518620502a (patch)
tree23207fb3c52c0366cabfc1e2d5caaaa298bc9cfc
parentd9e3621a2eb6deb12a326ed1376a7ae45a1c9d52 (diff)
arb_shader_atomic_counters: Make atomic_counters_generate_source local to max-counters.
This isn't used anywhere except for the max-counters test so we can move the definition into the C file of that test and make it static. Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au>
-rw-r--r--tests/spec/arb_shader_atomic_counters/common.c48
-rw-r--r--tests/spec/arb_shader_atomic_counters/common.h4
-rw-r--r--tests/spec/arb_shader_atomic_counters/max-counters.c65
3 files changed, 57 insertions, 60 deletions
diff --git a/tests/spec/arb_shader_atomic_counters/common.c b/tests/spec/arb_shader_atomic_counters/common.c
index 95d809e38..b9660091b 100644
--- a/tests/spec/arb_shader_atomic_counters/common.c
+++ b/tests/spec/arb_shader_atomic_counters/common.c
@@ -259,52 +259,4 @@ atomic_counters_get_limits()
return ls;
}
-static char *
-iterate_template(const char *template, unsigned n)
-{
- char *ss;
- int i, ret;
-
- ss = strdup("");
- assert(ss);
-
- for (i = 0; i < n; ++i) {
- char *s, *tmp = ss;
-
- ret = asprintf(&s, template, i);
- assert(ret >= 0);
-
- ret = asprintf(&ss, "%s%s", tmp, s);
- assert(ret >= 0);
-
- free(tmp);
- free(s);
- }
-
- return ss;
-}
-
-/**
- * Generate source code by substituting the first occurrence of "%s"
- * in \a src_template with \a n copies of \a decl_template and the
- * second occurrence of "%s" with \a n copies of \a insn_template.
- */
-char *
-atomic_counters_generate_source(const char *src_template,
- const char *decl_template,
- const char *insn_template, unsigned n)
-{
- char *decls = iterate_template(decl_template, n);
- char *insns = iterate_template(insn_template, n);
- char *src;
- int ret;
-
- ret = asprintf(&src, src_template, decls, insns);
- assert(ret);
-
- free(decls);
- free(insns);
-
- return src;
-}
diff --git a/tests/spec/arb_shader_atomic_counters/common.h b/tests/spec/arb_shader_atomic_counters/common.h
index 5611f8ec8..de39877ca 100644
--- a/tests/spec/arb_shader_atomic_counters/common.h
+++ b/tests/spec/arb_shader_atomic_counters/common.h
@@ -56,10 +56,6 @@ atomic_counters_draw_patch(GLuint prog, unsigned buf_size,
bool
atomic_counters_supported(GLenum shader_stage);
-char *
-atomic_counters_generate_source(const char *src_template, const char *decl_template,
- const char *insn_template, unsigned n);
-
struct atomic_counters_limits {
int fragment_counters;
int vertex_counters;
diff --git a/tests/spec/arb_shader_atomic_counters/max-counters.c b/tests/spec/arb_shader_atomic_counters/max-counters.c
index 6207d2246..69b42144c 100644
--- a/tests/spec/arb_shader_atomic_counters/max-counters.c
+++ b/tests/spec/arb_shader_atomic_counters/max-counters.c
@@ -39,11 +39,60 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
PIGLIT_GL_TEST_CONFIG_END
+static char *
+iterate_template(const char *template, unsigned n)
+{
+ char *ss;
+ int i, ret;
+
+ ss = strdup("");
+ assert(ss);
+
+ for (i = 0; i < n; ++i) {
+ char *s, *tmp = ss;
+
+ ret = asprintf(&s, template, i);
+ assert(ret >= 0);
+
+ ret = asprintf(&ss, "%s%s", tmp, s);
+ assert(ret >= 0);
+
+ free(tmp);
+ free(s);
+ }
+
+ return ss;
+}
+
+/**
+ * Generate source code by substituting the first occurrence of "%s"
+ * in \a src_template with \a n copies of \a decl_template and the
+ * second occurrence of "%s" with \a n copies of \a insn_template.
+ */
+static char *
+generate_source(const char *src_template,
+ const char *decl_template, const char *insn_template,
+ unsigned n)
+{
+ char *decls = iterate_template(decl_template, n);
+ char *insns = iterate_template(insn_template, n);
+ char *src;
+ int ret;
+
+ ret = asprintf(&src, src_template, decls, insns);
+ assert(ret);
+
+ free(decls);
+ free(insns);
+
+ return src;
+}
+
static bool
run_test_vertex_max_counters(unsigned num_counters)
{
/* Generate a shader with 'num_counters' counters. */
- char *vs_source = atomic_counters_generate_source(
+ char *vs_source = generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
"\n"
@@ -74,7 +123,7 @@ static bool
run_test_fragment_max_counters(unsigned num_counters)
{
/* Generate a shader with 'num_counters' counters. */
- char *fs_source = atomic_counters_generate_source(
+ char *fs_source = generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
"\n"
@@ -104,7 +153,7 @@ run_test_combined_max_counters(unsigned num_fragment_counters,
unsigned num_vertex_counters)
{
/* Generate a shader with 'num_fragment_counters' counters. */
- char *fs_source = atomic_counters_generate_source(
+ char *fs_source = generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
"\n"
@@ -122,7 +171,7 @@ run_test_combined_max_counters(unsigned num_fragment_counters,
" y += atomicCounterDecrement(fx%d);\n",
num_fragment_counters);
/* Generate a shader with 'num_vertex_counters' counters. */
- char *vs_source = atomic_counters_generate_source(
+ char *vs_source = generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
"\n"
@@ -155,7 +204,7 @@ static bool
run_test_fragment_max_buffers(unsigned num_buffers)
{
/* Generate a shader with 'num_buffers' buffers. */
- char *src = atomic_counters_generate_source(
+ char *src = generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
"#define PASTE(A,B) A ## B\n"
@@ -188,7 +237,7 @@ static bool
run_test_vertex_max_buffers(unsigned num_buffers)
{
/* Generate a shader with 'num_buffers' buffers. */
- char *src = atomic_counters_generate_source(
+ char *src = generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
"#define PASTE(A,B) A ## B\n"
@@ -224,7 +273,7 @@ run_test_combined_max_buffers(unsigned num_fragment_buffers,
unsigned num_vertex_buffers)
{
/* Generate a shader with 'num_fragment_buffers' buffers. */
- char *fs_source = atomic_counters_generate_source(
+ char *fs_source = generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
"#define PASTE(A,B) A ## B\n"
@@ -245,7 +294,7 @@ run_test_combined_max_buffers(unsigned num_fragment_buffers,
" x += atomicCounterDecrement(y%d);\n",
num_fragment_buffers);
/* Generate a shader with 'num_vertex_buffers' buffers. */
- char *vs_source = atomic_counters_generate_source(
+ char *vs_source = generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
"#define PASTE(A,B) A ## B\n"