[Piglit] [PATCH 3/5] vp-max-array: Exercise GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB with a contant array

Ian Romanick idr at freedesktop.org
Tue Aug 30 11:25:11 PDT 2011


From: Ian Romanick <ian.d.romanick at intel.com>

This is essentially the same test as for
GL_MAX_PROGRAM_PARAMETERS_ARB, but it uses indirect addressing to
force all of the parameters to be used.
---
 tests/shaders/vp-max-array.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/tests/shaders/vp-max-array.c b/tests/shaders/vp-max-array.c
index 78de261..1a67a75 100644
--- a/tests/shaders/vp-max-array.c
+++ b/tests/shaders/vp-max-array.c
@@ -48,6 +48,13 @@ static const char template_footer[] =
 	"END\n"
 	;
 
+static const char max_native_template_footer[] =
+	"	};\n"
+	"ADDRESS	a;\n"
+	"ARL	a.x, vertex.position.x;\n"
+	"MOV	result.color, colors[a.x];\n"
+	"END\n"
+	;
 
 enum piglit_result
 piglit_display(void)
@@ -119,6 +126,7 @@ piglit_init(int argc, char **argv)
 	 */
 	len = sizeof(template_header)
 		+ sizeof(template_footer)
+		+ sizeof(max_native_template_footer)
 		+ (80 * max_parameters) + 1;
 	shader_source = malloc(len);
 	if (shader_source == NULL)
@@ -147,4 +155,30 @@ piglit_init(int argc, char **argv)
 	       sizeof(template_footer));
 
 	(void) piglit_compile_program(GL_VERTEX_PROGRAM_ARB, shader_source);
+
+	/* Generate a program that uses the full native parameter space using
+	 * an array of constants.  The array is accessed indirectly, so the
+	 * assembler cannot know which elements may be used.  As a result, it
+	 * has to upload all of them.  This exercises
+	 * GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB.
+	 */
+	offset = snprintf(shader_source, len, template_header,
+			  max_native_parameters);
+	for (i = 0; i < max_native_parameters; i++) {
+		int comma = (i < (max_native_parameters - 1)) ? ',' : ' ';
+		int used = snprintf(& shader_source[offset],
+				    len - offset,
+				    "\t\t{ %.1f, %.1f, %.1f, %.1f }%c\n",
+				    (float) i,
+				    (float) i + 0.2,
+				    (float) i + 0.4,
+				    (float) i + 0.6,
+				    comma);
+		offset += used;
+	}
+
+	memcpy(& shader_source[offset], max_native_template_footer,
+	       sizeof(max_native_template_footer));
+
+	(void) piglit_compile_program(GL_VERTEX_PROGRAM_ARB, shader_source);
 }
-- 
1.7.4.4



More information about the Piglit mailing list