[Piglit] [PATCH 4/4] arb_transform_feedback2: Misc. API error checks

Ian Romanick idr at freedesktop.org
Sun Oct 27 16:31:21 PDT 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/18/2013 10:54 AM, Dylan Baker wrote:
> On Friday, October 04, 2013 06:11:01 PM Ian Romanick wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>> 
>> This covers most of the errors mentioned in the spec that aren't 
>> already covered in cannot-bind-when-active.c and
>> gen-names-only.c. Most of the other errors should be covered by
>> existing EXT_transform_feedback tests.
>> 
>> Mesa currently passes all of these tests.
>> 
>> NVIDIA (304.64 on GTX 260) fails several subtests.
>> 
>> Pause active feedback only: Incorrectly generates error in 
>> glEndTransformFeedback.
>> 
>> TransformFeedbackVaryings only when inactive: Doesn't generate
>> any errors when it should.
>> 
>> Draw only from "ended" object: Generates GL_INVALID_VALUE
>> instead of GL_INVALID_OPERATION.
>> 
>> AMD has not been tested.
>> 
>> v2: Convert to use piglit subtest reporting.  Fix fs_only_prog
>> to actually only have a fragment shader attached.
>> 
>> v3: Quite significant re-write.  Per Paul's suggestion, each of
>> the tests is no a subtest that can be individually selected from
>> the command line.  This uses infrastructure in
>> piglit-framework-gl to handle the subtests.  This also eliminates
>> the work-around for NVIDIA's glEndTransformFeedback-while-paused
>> bug.
>> 
>> The code currently in all.tests for getting the list of subtests
>> is just a place holder.  We'll want to refactor this out
>> somewhere else before pushing.
>> 
>> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com> Cc:
>> Kenneth Graunke <kenneth at whitecape.org> Cc: Paul Berry
>> <stereotype441 at gmail.com> Cc: Dylan Baker
>> <baker.dylan.c at gmail.com> --- tests/all.tests
>> |   9 + .../spec/arb_transform_feedback2/CMakeLists.gl.txt |   1
>> + tests/spec/arb_transform_feedback2/api-errors.c    | 626 
>> +++++++++++++++++++++ 3 files changed, 636 insertions(+) create
>> mode 100644 tests/spec/arb_transform_feedback2/api-errors.c
>> 
>> diff --git a/tests/all.tests b/tests/all.tests index
>> ac95e7a..60128ec 100644 --- a/tests/all.tests +++
>> b/tests/all.tests @@ -6,6 +6,7 @@ import os import os.path as
>> path import platform import shlex +import subprocess
>> 
>> from framework.core import Group, TestProfile from
>> framework.exectest import PlainExecTest @@ -2306,6 +2307,14 @@
>> arb_transform_feedback2['draw-auto'] = 
>> PlainExecTest(['arb_transform_feedback2-d 
>> arb_transform_feedback2['istranformfeedback'] = 
>> PlainExecTest(['arb_transform_feedback2-istransformfeedback',
>> '-auto']) arb_transform_feedback2['glGenTransformFeedbacks names
>> only'] = 
>> concurrent_test('arb_transform_feedback2-gen-names-only') 
>> arb_transform_feedback2['cannot bind when another object is
>> active'] = 
>> concurrent_test('arb_transform_feedback2-cannot-bind-when-active')
>> + +process = subprocess.Popen([path.join(testBinDir, 
>> 'arb_transform_feedback2-api-errors'), '-list-subtests'], 
>> stdout=subprocess.PIPE) + +arb_transform_feedback2['misc. API
>> error checks'] = {}
> 
> You shoudl probably use Group() instead of {} here, since that's
> what is done in the rest of all.tests

Okay.  I didn't know that you could have a Group that contained other
Groups, but I guess that makes sense.

>> +for line in process.stdout: +    [option, name] =
>> line.split(":") +    arb_transform_feedback2['misc. API error
>> checks'][name.strip()] = 
>> concurrent_test('arb_transform_feedback2-api-errors -subtest 
>> {0}'.format(option.strip())) + arb_transform_feedback2['misc. API
>> queries'] =
> 
> If you want this to be a standard interface you should use helper
> functions. I've split this into two functions, so that the
> add_subtests could be used by tests that don't use the
> -list-subtests option

That makes sense.  I like it.  Any suggestion where these functions
should live?

> Here's an example:
> 
> def get_subtests(binary): """ Return a list of subtests """ #
> Universal_newlines causes python to return \n for newlines
> regardless of # the platform output =
> subprocess.check_output([path.join(testBinDir, binary), 
> '-list-subtests'], universal_newlines=True)
> 
> # Strip the last newline so element[-1] != [''] return [l.split(":
> ") for l in output.strip().split('\n')]
> 
> 
> def add_subtests(group, binary, subtests,
> test_type=concurrent_test): """ helper for adding tests with
> subtests
> 
> group: a group object to store the tests in binary: The name of the
> test binary subtests: An iterable contains iterable pairs in the
> form: (<subtest argument>, <subtest name), such as provided by 
> get_subtests() test_type: a callable that adds a test. default:
> concurrent_test
> 
> """ for value in subtests: group[value[1]] = test_type("{0}
> -subtest {1}".format(binary, value[0]))
> 
> Usage would be something like this: arb_transform_feedback2['misc.
> API error checks'] = Group() 
> add_subtests(arb_transform_feedback2['misc. API error checks'], 
> 'arb_transform_feedback2-api-errors', 
> get_subtests('arb_transform_feedback2-api-errors'))
> 
> I think these work, I get the same output using these helpers and
> using your original code, which is a single test that skips.

Hmm... there should have been a bunch of tests that skip.  With
GL_ARB_transform_feedback2 enabled (via
'MESA_EXTENSION_OVERRIDE=+GL_ARB_transform_feedback2'), I get a bunch
of tests in a "misc. API queries" group and a single, dangling "misc.
API queries" test.  Do you think the problem is that the tests report
as subtests (using piglit_report_subtest_result) with the same name
that add_subtests adds them as?

I haven't looked at the actual json output yet...

>> concurrent_test('arb_transform_feedback2-api-queries') 
>> arb_transform_feedback2['counting with pause'] = 
>> concurrent_test('arb_transform_feedback2-pause-counting')
>> 
>> diff --git
>> a/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt 
>> b/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt index 
>> c6287a1..3d74f91 100644 ---
>> a/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt +++
>> b/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt @@ -9,6
>> +9,7 @@ link_libraries ( ${OPENGL_glu_LIBRARY} )
>> 
>> +piglit_add_executable (arb_transform_feedback2-api-errors
>> api-errors.c) piglit_add_executable
>> (arb_transform_feedback2-api-queries api-queries.c) 
>> piglit_add_executable
>> (arb_transform_feedback2-cannot-bind-when-active 
>> cannot-bind-when-active.c) piglit_add_executable 
>> (arb_transform_feedback2-change-objects-while-paused 
>> change-objects-while-paused.c) diff --git 
>> a/tests/spec/arb_transform_feedback2/api-errors.c 
>> b/tests/spec/arb_transform_feedback2/api-errors.c new file mode
>> 100644 index 0000000..4858899 --- /dev/null +++
>> b/tests/spec/arb_transform_feedback2/api-errors.c @@ -0,0 +1,626
>> @@ +/* + * Copyright © 2012 Intel Corporation
> 
> It's 2013 for a few more weeks...

I've been sitting on this test since 2012. :(  git-log says:

commit 311697d49492624ab55d948a3cd289d70f693341
Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Sun Jul 8 01:34:47 2012 -0700

>> + * + * 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. + */ 
>> + +/** + * \file api-errors.c + * Verify a handful of error
>> conditions required by the spec. + * + * None of these subtests
>> is large enough to warrant a separate test case. + */ + +#define
>> PIGLIT_SUBTEST_LIST subtests + +#include
>> "piglit-util-gl-common.h" + +static enum piglit_result
>> delete_inactive_only(void); +static enum piglit_result
>> paired_begin_end(void); +static enum piglit_result
>> pause_active_only(void); +static enum piglit_result
>> resume_paused_only(void); +static enum piglit_result
>> vertex_shader_required(void); +static enum piglit_result
>> change_varyings_inactive_only(void); +static enum piglit_result
>> change_program_inactive_or_paused(void); +static enum
>> piglit_result link_program_inactive_only(void); +static enum
>> piglit_result resume_same_program_only(void); +static enum
>> piglit_result draw_from_valid_object_only(void); +static enum
>> piglit_result draw_from_ended_object_only(void); + +static const
>> struct piglit_gl_subtest subtests[] = { +	{ +		"Cannot delete
>> while active", +		"delete-inactive-only", +
>> delete_inactive_only +	}, +	{ +		"Paired begin and end", +
>> "paired-begin-end", +		paired_begin_end +	}, +	{ +		"Pause active
>> feedback only", +		"pause-active-only", +		pause_active_only +
>> }, +	{ +		"Resume paused feedback only", +
>> "resume-paused-only", +		resume_paused_only +	}, +	{ +		"Vertex
>> shader required", +		"vertex-shader-required", +
>> vertex_shader_required +	}, +	{ +		"TransformFeedbackVaryings
>> only when inactive", +		"change-varyings-inactive-only", +
>> change_varyings_inactive_only +	}, +	{ +		"Change program only
>> when inactive or paused", +
>> "change-program-inactive-or-paused", +
>> change_program_inactive_or_paused +	}, +	{ +		"Link program only
>> when inactive", +		"link-program-inactive-only", +
>> link_program_inactive_only +	}, +	{ +		"Resume with the same
>> program only", +		"resume-same-program-only", +
>> resume_same_program_only +	}, +	{ +		"Draw only from valid
>> object", +		"draw-from-valid-object-only", +
>> draw_from_valid_object_only +	}, +	{ +		/* Do this one last.  If
>> it fails, it will delete the object +		 * and cause all of the
>> othere subtests to fail. +		 */ +		"Draw only from \"ended\"
>> object", +		"draw-from-ended-object-only", +
>> draw_from_ended_object_only +	}, +	{ +		NULL, +		NULL, +		NULL +
>> } +}; + +PIGLIT_GL_TEST_CONFIG_BEGIN + +
>> config.supports_gl_compat_version = 10; +	config.window_visual =
>> PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +enum
>> piglit_result +piglit_display(void) +{ +	return PIGLIT_FAIL; +} 
>> + +static const char vstext[] = +	"varying vec4 x;\n" +	"varying
>> vec4 y;\n" +	"void main()\n" +	"{\n" +	"    gl_Position =
>> vec4(0);\n" +	"    x = vec4(0);\n" +	"    y = vec4(0);\n" +	"}" +
>> ; + +static const char fstext[] = +	"void main() { gl_FragColor =
>> vec4(0); }"; + +static const char *varyings[] = {"x"}; +static
>> GLuint id; +static GLuint prog; +static GLuint fs_only_prog; 
>> +static GLuint buf; + +enum piglit_result
>> delete_inactive_only(void) +{ +	bool pass = true; + +	/* The
>> ARB_transform_feedback2 spec says: +	 * +	 *     "The error
>> INVALID_OPERATION is generated by +	 *
>> DeleteTransformFeedbacks if the transform feedback operation +	 *
>> for any object named by <ids> is currently active." +	 * +	 *
>> However, shortly before that it also says, +	 * +	 *     "If an
>> active transform feedback object is deleted its name +	 *
>> immediately becomes unused, but the underlying object is not +	 *
>> deleted until it is no longer active." +	 * +	 * So, that seems a
>> bit contradictory. +	 */ +
>> glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(0) && pass; + +
>> glDeleteTransformFeedbacks(1, &id); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glEndTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +enum
>> piglit_result paired_begin_end(void) +{ +	bool pass = true; + +
>> /* The ARB_transform_feedback2 spec says: +	 * +	 *
>> "Transform feedback commands must be paired; the error +	 *
>> INVALID_OPERATION is generated by BeginTransformFeedback if +	 *
>> transform feedback is active, and by EndTransformFeedback if +	 *
>> transform feedback is inactive. Transform feedback is initially +
>> *     inactive." +	 * +	 * The first case is already tested by
>> the cannot-bind-when-active +	 * test. +	 */ +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id); + +
>> glEndTransformFeedback(); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(0) && pass; + +	glEndTransformFeedback(); +
>> pass = piglit_check_gl_error(0) && pass; + +
>> glEndTransformFeedback(); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +	return
>> pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +enum piglit_result
>> pause_active_only(void) +{ +	bool pass = true; + +	/* The
>> ARB_transform_feedback2 spec says: +	 * +	 *     "The error
>> INVALID_OPERATION is generated by +	 *     PauseTransformFeedback
>> if the currently bound transform +	 *     feedback is not active
>> or is paused." +	 */ +	glPauseTransformFeedback(); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(0) && pass; + +
>> glPauseTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	glPauseTransformFeedback(); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +	/* There
>> is no need for an explicit resume here.  Section 13.2.2 +	 *
>> (Transform Feedback Primitive Capture) of the OpenGL 4.3 spec
>> says: +	 * +	 *     "EndTransformFeedback first performs an
>> implicit +	 *     ResumeTransformFeedback (see below) if
>> transform feedback is +	 *     paused." +	 * +	 * NOTE: Previous
>> versions of the spec had an error in this section +	 * that was
>> corrected in 4.3. +	 */ +	glEndTransformFeedback(); +	pass =
>> piglit_check_gl_error(0) && pass; + +	return pass ? PIGLIT_PASS :
>> PIGLIT_FAIL; +} + +enum piglit_result resume_paused_only(void) 
>> +{ +	bool pass = true; + +	/* The ARB_transform_feedback2 spec
>> says: +	 * +	 *     "The error INVALID_OPERATION is generated by 
>> +	 *     ResumeTransformFeedback if the currently bound
>> transform +	 *     feedback is not active or is not paused." +
>> */ +	glResumeTransformFeedback(); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(0) && pass; + +
>> glResumeTransformFeedback(); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glPauseTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	glResumeTransformFeedback(); +	pass =
>> piglit_check_gl_error(0) && pass; + +	glEndTransformFeedback(); +
>> pass = piglit_check_gl_error(0) && pass; + +	return pass ?
>> PIGLIT_PASS : PIGLIT_FAIL; +} + +enum piglit_result
>> vertex_shader_required(void) +{ +	bool pass = true; + +	if
>> (piglit_is_extension_supported("GL_NV_transform_feedback2")) { +
>> piglit_report_subtest_result(PIGLIT_SKIP, +					     "Vertex
>> shader required"); +		return true; +	} + +	/* The
>> ARB_transform_feedback2 spec says: +	 * +	 *     "The error
>> INVALID_OPERATION is generated by +	 *     BeginTransformFeedback
>> if no vertex or geometry shader is +	 *     active." +	 */ +
>> glUseProgram(fs_only_prog); + +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id); +	pass =
>> piglit_check_gl_error(0) && pass; + +
>> glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glUseProgram(prog); + +	return pass ? PIGLIT_PASS : PIGLIT_FAIL; 
>> +} + +enum piglit_result change_varyings_inactive_only(void) +{ +
>> bool pass = true; + +	/* The ARB_transform_feedback2 spec says: +
>> * +	 *     "The error INVALID_OPERATION is generated: +	 * +	 *
>> * by TransformFeedbackVaryings if the current transform +	 *
>> feedback object is active, even if paused;" +	 */ +
>> glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(0) && pass; + +
>> glTransformFeedbackVaryings(prog, 1, varyings, +
>> GL_INTERLEAVED_ATTRIBS); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glPauseTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	glTransformFeedbackVaryings(prog, 1, varyings, +
>> GL_INTERLEAVED_ATTRIBS); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glResumeTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	glEndTransformFeedback(); +	pass =
>> piglit_check_gl_error(0) && pass; + +	return pass ? PIGLIT_PASS :
>> PIGLIT_FAIL; +} + +enum piglit_result
>> change_program_inactive_or_paused(void) +{ +	bool pass = true; + 
>> +	/* The ARB_transform_feedback2 spec says: +	 * +	 *     "The
>> error INVALID_OPERATION is generated: +	 * +	 *         * by
>> UseProgram if the current transform feedback object is +	 *
>> active and not paused;" +	 */ +
>> glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(0) && pass; + +
>> glUseProgram(fs_only_prog); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glPauseTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	glUseProgram(fs_only_prog); +	pass =
>> piglit_check_gl_error(0) && pass; + +	/* Restore the program or
>> glResumeTransformFeedback will generate an +	 * error. +	 */ +
>> glUseProgram(prog); +	pass = piglit_check_gl_error(0) && pass; + 
>> +	/* Work-around drivers with glEndTransformFeedback bugs.  See +
>> * pause_active_only above. +	 */ +	glResumeTransformFeedback(); +
>> pass = piglit_check_gl_error(0) && pass; + +
>> glEndTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	glUseProgram(prog); +	pass = piglit_check_gl_error(0)
>> && pass; + +	return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +enum
>> piglit_result link_program_inactive_only(void) +{ +	bool pass =
>> true; + +	/* The ARB_transform_feedback2 spec says: +	 * +	 *
>> "The error INVALID_OPERATION is generated: +	 * +	 *         * by
>> LinkProgram if <program> is the name of a program +	 *
>> being used by one or more transform feedback objects, +	 *
>> even if the objects are not currently bound or are +	 *
>> paused;" +	 */ +	glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(0) && pass; + +	glLinkProgram(prog); +	pass
>> = piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glPauseTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	glLinkProgram(prog); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); +	pass =
>> piglit_check_gl_error(0) && pass; + +	glLinkProgram(prog); +	pass
>> = piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glUseProgram(0); +	pass = piglit_check_gl_error(0) && pass; + +
>> glLinkProgram(prog); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glUseProgram(prog); +	pass = piglit_check_gl_error(0) && pass; + 
>> +	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id); +	pass =
>> piglit_check_gl_error(0) && pass; + +	/* Work-around drivers with
>> glEndTransformFeedback bugs.  See +	 * pause_active_only above. +
>> */ +	glResumeTransformFeedback(); +	pass =
>> piglit_check_gl_error(0) && pass; + +	glEndTransformFeedback(); +
>> pass = piglit_check_gl_error(0) && pass; + +	return pass ?
>> PIGLIT_PASS : PIGLIT_FAIL; +} + +enum piglit_result
>> resume_same_program_only(void) +{ +	bool pass = true; + +	/* The
>> ARB_transform_feedback2 spec says: +	 * +	 *     "The error
>> INVALID_OPERATION is generated: +	 * +	 *         * by
>> ResumeTransformFeedback if the program object being +	 *
>> used by the current transform feedback object is not +	 *
>> active." +	 */ +	glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(0) && pass; + +
>> glPauseTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	glUseProgram(0); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	glResumeTransformFeedback(); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glUseProgram(prog); +	pass = piglit_check_gl_error(0) && pass; + 
>> +	/* Work-around drivers with glEndTransformFeedback bugs.  See +
>> * pause_active_only above. +	 */ +	glResumeTransformFeedback(); +
>> pass = piglit_check_gl_error(0) && pass; + +
>> glEndTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +enum
>> piglit_result draw_from_valid_object_only(void) +{ +	bool pass =
>> true; +	GLuint bad_id; + +	/* The ARB_transform_feedback2 spec
>> says: +	 * +	 *     "The error INVALID_VALUE is generated if <id>
>> is not the name +	 *     of a transform feedback object." +	 */ +
>> glGenTransformFeedbacks(1, &bad_id); + +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, bad_id); +
>> glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); + +
>> glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(0) && pass; + +	glEndTransformFeedback(); +
>> pass = piglit_check_gl_error(0) && pass; + +
>> glDeleteTransformFeedbacks(1, &bad_id); +	pass =
>> piglit_check_gl_error(0) && pass; + +
>> glDrawTransformFeedback(GL_TRIANGLES, bad_id); +	pass =
>> piglit_check_gl_error(GL_INVALID_VALUE) && pass; + +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id); + +	return
>> pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +enum piglit_result
>> draw_from_ended_object_only(void) +{ +	bool pass = true; +	GLuint
>> bad_id; + +	/* The ARB_transform_feedback2 spec says: +	 * +	 *
>> "The error INVALID_OPERATION is generated if +	 *
>> EndTransformFeedback has never been called while the object +	 *
>> named by <id> was bound." +	 */ +	glGenTransformFeedbacks(1,
>> &bad_id); + +	glDrawTransformFeedback(GL_TRIANGLES, bad_id); +
>> pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, bad_id); +
>> glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); + +
>> glBeginTransformFeedback(GL_TRIANGLES); +	pass =
>> piglit_check_gl_error(0) && pass; + +
>> glPauseTransformFeedback(); +	pass = piglit_check_gl_error(0) &&
>> pass; + +	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); +
>> pass = piglit_check_gl_error(0) && pass; + +
>> glDrawTransformFeedback(GL_TRIANGLES, bad_id); +	pass =
>> piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, bad_id); +	pass =
>> piglit_check_gl_error(0) && pass; + +	/* Work-around drivers with
>> glEndTransformFeedback bugs.  See +	 * pause_active_only above. +
>> */ +	glResumeTransformFeedback(); +	pass =
>> piglit_check_gl_error(0) && pass; + +	glEndTransformFeedback(); +
>> pass = piglit_check_gl_error(0) && pass; + +
>> glDeleteTransformFeedbacks(1, &bad_id); +	pass =
>> piglit_check_gl_error(0) && pass; + +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id); + +	return
>> pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +void piglit_init(int
>> argc, char **argv) +{ +	GLuint vs; +	GLuint fs; +	enum
>> piglit_result result; + +	piglit_require_transform_feedback(); +
>> piglit_require_GLSL(); +
>> piglit_require_extension("GL_ARB_transform_feedback2"); + +	/*
>> This is all just the boot-strap work for the test. +	 */ +
>> glGenBuffers(1, &buf); +
>> glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf); +
>> glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 1024, NULL,
>> GL_STREAM_READ); + +	vs =
>> piglit_compile_shader_text(GL_VERTEX_SHADER, vstext); +	fs =
>> piglit_compile_shader_text(GL_FRAGMENT_SHADER, fstext); +	prog =
>> glCreateProgram(); +	glAttachShader(prog, vs); +
>> glAttachShader(prog, fs); + +	glTransformFeedbackVaryings(prog,
>> 1, varyings, +				    GL_INTERLEAVED_ATTRIBS); +
>> glLinkProgram(prog); +	if (!piglit_link_check_status(prog)) { +
>> result = PIGLIT_FAIL; +		goto done; +	} + +	fs_only_prog =
>> piglit_link_simple_program(fs, 0); +	if (fs_only_prog == 0) { +
>> result = PIGLIT_FAIL; +		goto done; +	} + +	glUseProgram(prog); 
>> + +	glGenTransformFeedbacks(1, &id); + +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id); +
>> glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); + +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); + +	result =
>> piglit_run_selected_subtests(subtests, +
>> config.selected_subtests, +
>> config.num_selected_subtests, +					      PIGLIT_SKIP); + +
>> glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); + +done: +
>> glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0); +
>> glDeleteBuffers(1, &buf); + +	glDeleteTransformFeedbacks(1,
>> &id); + +	glUseProgram(0); +	glDeleteShader(vs); +
>> glDeleteShader(fs); +	glDeleteProgram(prog); +
>> glDeleteProgram(fs_only_prog); + +	piglit_report_result(result); 
>> +}

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)

iEYEARECAAYFAlJtokkACgkQX1gOwKyEAw+ChACgjsxLikRcS4HKL+tsJF6kv4iF
Aq4AoJgRzFGLrk0W4RICUSIwVuVK2pLb
=FpmD
-----END PGP SIGNATURE-----


More information about the Piglit mailing list