[Piglit] [PATCH] gl-2.0/vertexattribpointer: new test for glVertexAttribPointer

Brian Paul brianp at vmware.com
Tue Jun 3 06:17:38 PDT 2014


On 06/02/2014 11:26 AM, Jose Fonseca wrote:
>
>
> ----- Original Message -----
>> Tests all the type/size/normalize combinations for glVertexAttribPointer.
>> Note- a similar test should be written for GL 3.0's glVertexAttribIPointer.
>> ---
>>   tests/all.py                            |    1 +
>>   tests/spec/gl-2.0/CMakeLists.gl.txt     |    1 +
>>   tests/spec/gl-2.0/vertexattribpointer.c |  256
>>   +++++++++++++++++++++++++++++++
>>   3 files changed, 258 insertions(+)
>>   create mode 100644 tests/spec/gl-2.0/vertexattribpointer.c
>>
>> diff --git a/tests/all.py b/tests/all.py
>> index d449e47..a42e79e 100644
>> --- a/tests/all.py
>> +++ b/tests/all.py
>> @@ -865,6 +865,7 @@ spec['!OpenGL 2.0'] = gl20
>>   add_concurrent_test(gl20, 'attribs')
>>   add_concurrent_test(gl20, 'gl-2.0-edgeflag')
>>   add_concurrent_test(gl20, 'gl-2.0-edgeflag-immediate')
>> +add_concurrent_test(gl20, 'gl-2.0-vertexattribpointer')
>>   add_plain_test(gl20, 'attrib-assignments')
>>   add_plain_test(gl20, 'getattriblocation-conventional')
>>   add_plain_test(gl20, 'clip-flag-behavior')
>> diff --git a/tests/spec/gl-2.0/CMakeLists.gl.txt
>> b/tests/spec/gl-2.0/CMakeLists.gl.txt
>> index b930eef..3ac0d68 100644
>> --- a/tests/spec/gl-2.0/CMakeLists.gl.txt
>> +++ b/tests/spec/gl-2.0/CMakeLists.gl.txt
>> @@ -13,3 +13,4 @@ link_libraries (
>>   piglit_add_executable (vertex-program-two-side vertex-program-two-side.c)
>>   piglit_add_executable (gl-2.0-edgeflag edgeflag.c)
>>   piglit_add_executable (gl-2.0-edgeflag-immediate edgeflag-immediate.c)
>> +piglit_add_executable (gl-2.0-vertexattribpointer vertexattribpointer.c)
>> diff --git a/tests/spec/gl-2.0/vertexattribpointer.c
>> b/tests/spec/gl-2.0/vertexattribpointer.c
>> new file mode 100644
>> index 0000000..b232c99
>> --- /dev/null
>> +++ b/tests/spec/gl-2.0/vertexattribpointer.c
>> @@ -0,0 +1,256 @@
>> +/*
>> + * Copyright 2014 VMware, Inc.
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the
>> "Software"),
>> + * to deal in the Software without restriction, including without limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the next
>> + * paragraph) shall be included in all copies or substantial portions of the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
>> OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
>> OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
>> + * DEALINGS IN THE SOFTWARE.
>> + */
>> +
>> +/**
>> + * Test glVertexAttribPointer with all combinations of types, sizes and
>> + * normalized/unnormalized.
>> + */
>> +
>> +#include "piglit-util-gl-common.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +	config.supports_gl_compat_version = 20;
>> +	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +
>> +static const char *vertShaderText =
>> +	"uniform float scale, bias; \n"
>> +	"attribute vec4 attr; \n"
>> +	"varying vec4 color; \n"
>> +	" \n"
>> +	"void main() \n"
>> +	"{ \n"
>> +	"   gl_Position = gl_Vertex; \n"
>> +	"   color = attr * scale + bias; \n"
>> +	"} \n";
>> +
>> +static const char *fragShaderText =
>> +	"varying vec4 color;\n"
>> +	"void main()\n"
>> +	"{ \n"
>> +	"   gl_FragColor = color; \n"
>> +	"} \n";
>> +
>> +
>> +static const GLfloat float4_data[] = { 0.5, 0.0, 0.75, 1.0 };
>> +static const GLubyte ubyte4_data[] = { 100, 0, 200, 255 };
>> +static const GLbyte byte4_data[] = { 50, 0, -25, -50 };
>> +static const GLushort ushort4_data[] = { 16000, 0, 32000, 65535 };
>> +static const GLshort short4_data[] = { 2000, 0, -4000, -8000 };
>> +static const GLuint uint4_data[] = { 10000000, 0, 20000000, 80000000 };
>> +static const GLint int4_data[] = { 10000000, 0, -20000000, -40000000 };
>> +
>> +static GLuint Prog;
>> +static GLint ScaleUniform, BiasUniform, AttrAttrib;
>> +
>> +
>> +/*
>> + * Test glVertexAttribArray(type, size, normalized)
>> + */
>> +static bool
>> +test_array(GLenum type, GLuint size, GLboolean normalized)
>> +{
>> +	static const GLfloat verts[4][2] = {
>> +		{ -1.0, -1.0 },
>> +		{ 1.0, -1.0 },
>> +		{ 1.0, 1.0 },
>> +		{ -1.0, 1.0 }
>> +	};
>> +	GLubyte attr_buffer[100];
>> +	float scale, bias;
>
> I'm surprised that not using double for scale doesn't cause problems, especially with the 32bit types, as precision is lost.  But then again everything is converted to 8bit unorms in the end so there's not much sensitity anyway.
>
> To have a more strict test, instead of passing scale/bias we should pass the expected values to as uniforms, and the shader would produce a green/red pass/fail result accordingly.  This would get you at least 24bits of precision instead of just 8bits.

Yeah, I like that idea better.  I'll do a v2...

-Brian




More information about the Piglit mailing list