[Piglit] [PATCH 2/2] arb_shader_atomic_counters: recursion checks require a second paste macro
Ilia Mirkin
imirkin at alum.mit.edu
Mon Jun 16 22:52:44 PDT 2014
---
GLSL appears to defer to CPP. In CPP the intermediate macro is necessary due
to recursion checks. e.g. if you have
#define PASTE(A, B) A ## B
#define I I
PASTE(I, I)
Then unfortunate things would happen if it auto-evaluated the macros
repeatedly. As it is, the above would evaluate to 'II'.
tests/spec/arb_shader_atomic_counters/max-counters.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/tests/spec/arb_shader_atomic_counters/max-counters.c b/tests/spec/arb_shader_atomic_counters/max-counters.c
index 409247d..6207d22 100644
--- a/tests/spec/arb_shader_atomic_counters/max-counters.c
+++ b/tests/spec/arb_shader_atomic_counters/max-counters.c
@@ -158,7 +158,8 @@ run_test_fragment_max_buffers(unsigned num_buffers)
char *src = atomic_counters_generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
- "#define Y(I) y##I\n"
+ "#define PASTE(A,B) A ## B\n"
+ "#define Y(I) PASTE(y, I)\n"
"\n"
"out ivec4 fcolor;\n"
"\n"
@@ -190,7 +191,8 @@ run_test_vertex_max_buffers(unsigned num_buffers)
char *src = atomic_counters_generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
- "#define X(I) x##I\n"
+ "#define PASTE(A,B) A ## B\n"
+ "#define X(I) PASTE(x, I)\n"
"\n"
"in vec4 position;\n"
"flat out ivec4 vcolor;\n"
@@ -225,7 +227,8 @@ run_test_combined_max_buffers(unsigned num_fragment_buffers,
char *fs_source = atomic_counters_generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
- "#define Y(I) y##I\n"
+ "#define PASTE(A,B) A ## B\n"
+ "#define Y(I) PASTE(y, I)\n"
"\n"
"out ivec4 fcolor;\n"
"\n"
@@ -245,7 +248,8 @@ run_test_combined_max_buffers(unsigned num_fragment_buffers,
char *vs_source = atomic_counters_generate_source(
"#version 140\n"
"#extension GL_ARB_shader_atomic_counters : enable\n"
- "#define X(I) x##I\n"
+ "#define PASTE(A,B) A ## B\n"
+ "#define X(I) PASTE(x, I)\n"
"\n"
"in vec4 position;\n"
"flat out ivec4 vcolor;\n"
--
1.8.5.5
More information about the Piglit
mailing list