[Piglit] [PATCH 3/8] GL_ARB_copy_buffer: Add a test for syncing with glBufferData();

Eric Anholt eric at anholt.net
Wed Oct 30 23:04:40 CET 2013


Ian Romanick <idr at freedesktop.org> writes:

> On 10/08/2013 02:09 PM, Eric Anholt wrote:
>> Like the subdata test, make sure that we get back the right results
>> when putting new data in our source or dest after a copy.
>> ---
>>  tests/all.tests                              |   1 +
>>  tests/spec/arb_copy_buffer/CMakeLists.gl.txt |   1 +
>>  tests/spec/arb_copy_buffer/data-sync.c       | 109 +++++++++++++++++++++++++++
>>  3 files changed, 111 insertions(+)
>>  create mode 100644 tests/spec/arb_copy_buffer/data-sync.c
>> 
>> diff --git a/tests/all.tests b/tests/all.tests
>> index 5c7bd3f..dfb3b79 100644
>> --- a/tests/all.tests
>> +++ b/tests/all.tests
>> @@ -2485,6 +2485,7 @@ arb_copy_buffer = Group()
>>  spec['ARB_copy_buffer'] = arb_copy_buffer
>>  add_plain_test(arb_copy_buffer, 'copy_buffer_coherency')
>>  add_plain_test(arb_copy_buffer, 'copybuffersubdata')
>> +arb_copy_buffer['data-sync'] = concurrent_test('arb_copy_buffer-data-sync')
>>  arb_copy_buffer['dlist'] = concurrent_test('arb_copy_buffer-dlist')
>>  arb_copy_buffer['get'] = concurrent_test('arb_copy_buffer-get')
>>  arb_copy_buffer['negative-bound-zero'] = concurrent_test('arb_copy_buffer-negative-bound-zero')
>> diff --git a/tests/spec/arb_copy_buffer/CMakeLists.gl.txt b/tests/spec/arb_copy_buffer/CMakeLists.gl.txt
>> index 5332f6d..6e5695e 100644
>> --- a/tests/spec/arb_copy_buffer/CMakeLists.gl.txt
>> +++ b/tests/spec/arb_copy_buffer/CMakeLists.gl.txt
>> @@ -11,6 +11,7 @@ link_libraries (
>>  
>>  piglit_add_executable (copy_buffer_coherency copy_buffer_coherency.c)
>>  piglit_add_executable (copybuffersubdata copybuffersubdata.c)
>> +piglit_add_executable (arb_copy_buffer-data-sync data-sync.c)
>>  piglit_add_executable (arb_copy_buffer-dlist dlist.c)
>>  piglit_add_executable (arb_copy_buffer-get get.c)
>>  piglit_add_executable (arb_copy_buffer-overlap overlap.c)
>> diff --git a/tests/spec/arb_copy_buffer/data-sync.c b/tests/spec/arb_copy_buffer/data-sync.c
>> new file mode 100644
>> index 0000000..0618722
>> --- /dev/null
>> +++ b/tests/spec/arb_copy_buffer/data-sync.c
>> @@ -0,0 +1,109 @@
>> +/*
>> + * Copyright © 2013 Intel Corporation
>> + *
>> + * 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 data-sync.c
>> + *
>> + * Tests that glBufferData() synchronizes correctly with
>> + * glCopyBufferSubData().
>> + *
>> + * We make sure that a glBufferData() over the read buffer after the
>> + * copy has no effect, while a glBufferData() over the write buffer
>> + * after the copy does have an effect.
>> + */
>> +
>> +#include "piglit-util-gl-common.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +
>> +	config.supports_gl_compat_version = 10;
>
> Same comment as previous test.
>
>> +	config.supports_gl_core_version = 31;
>> +
>> +	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
>> +
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +void
>> +piglit_init(int argc, char *argv[])
>> +{
>> +	bool pass = true;
>> +	uint32_t dummy_data_1[4], dummy_data_2[4];
>> +	uint32_t good_data[4] = {0, 1, 2, 3};
>> +	uint32_t result_data[4];
>> +	bool subtest_pass;
>> +	size_t size = sizeof(good_data);
>> +	GLuint buffer_handles[2];
>> +
>> +	memset(dummy_data_1, 0xaa, size);
>> +	memset(dummy_data_2, 0xbb, size);
>> +
>> +	piglit_require_gl_version(15);
>> +
>> +	piglit_require_extension("GL_ARB_copy_buffer");
>> +
>> +	glGenBuffersARB(2, buffer_handles);
>> +	glBindBufferARB(GL_COPY_READ_BUFFER, buffer_handles[0]);
>> +	glBindBufferARB(GL_COPY_WRITE_BUFFER, buffer_handles[1]);
>
> Same comment as previous test.
>
>> +
>> +	glBufferData(GL_COPY_READ_BUFFER, size, good_data, GL_STREAM_COPY);
>> +	glBufferData(GL_COPY_WRITE_BUFFER, size, dummy_data_1, GL_STREAM_COPY);
>> +	glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER,
>> +			    0, 0, size);
>> +	glBufferData(GL_COPY_READ_BUFFER, size, dummy_data_2, GL_STREAM_COPY);
>> +	memset(result_data, 0xd0, size);
>> +	glGetBufferSubData(GL_COPY_WRITE_BUFFER, 0, size, result_data);
>> +	subtest_pass = memcmp(good_data, result_data, size) == 0;
>> +	if (!subtest_pass) {
>> +		fprintf(stderr, "found 0x%08x 0x%08x 0x%08x 0x%08x\n",
>> +			result_data[0], result_data[1],
>> +			result_data[2], result_data[3]);
>> +		pass = false;
>> +	}
>> +	piglit_report_subtest_result(subtest_pass ? PIGLIT_PASS : PIGLIT_FAIL,
>> +				     "overwrite source data");
>> +
>> +	glBufferData(GL_COPY_READ_BUFFER, size, dummy_data_2, GL_STREAM_COPY);
>> +	glBufferData(GL_COPY_WRITE_BUFFER, size, dummy_data_1, GL_STREAM_COPY);
>> +	glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER,
>> +			    0, 0, size);
>> +	glBufferData(GL_COPY_WRITE_BUFFER, size, dummy_data_2, GL_STREAM_COPY);
>
> This copies dummy_data_2 to COPY_WRITE_BUFFER, the writes dummy_data-2
> to COPY_WRITE_BUFFER... then compares with good_data.  Should one of
> these be good_data?

Huh, looks like I trashed this and the previous test in a late refactor
I had done I'd realized that subdata of the buffer's size was resulting
in us skipping the whole path I cared about, so I reworked all the tests
to bufferdata(NULL, pagesize) and then upload little bits of data it
actually cared about.  You're right about good_data here, and this is
the fix to the previous test:

@@ -64,8 +64,8 @@ piglit_init(int argc, char *argv[])
 
        glBufferData(GL_COPY_READ_BUFFER, 4096, NULL, GL_STREAM_COPY);
        glBufferData(GL_COPY_WRITE_BUFFER, 4096, NULL, GL_STREAM_COPY);
-       glGetBufferSubData(GL_COPY_READ_BUFFER, 0, size, good_data);
-       glGetBufferSubData(GL_COPY_WRITE_BUFFER, 0, size, dummy_data_1);
+       glBufferSubData(GL_COPY_READ_BUFFER, 0, size, good_data);
+       glBufferSubData(GL_COPY_WRITE_BUFFER, 0, size, dummy_data_1);
 
        glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER,
                            0, 0, size);
@@ -85,8 +85,8 @@ piglit_init(int argc, char *argv[])
 
        glBufferData(GL_COPY_READ_BUFFER, 4096, NULL, GL_STREAM_COPY);
        glBufferData(GL_COPY_WRITE_BUFFER, 4096, NULL, GL_STREAM_COPY);
-       glGetBufferSubData(GL_COPY_READ_BUFFER, 0, size, dummy_data_1);
-       glGetBufferSubData(GL_COPY_WRITE_BUFFER, 0, size, dummy_data_2);
+       glBufferSubData(GL_COPY_READ_BUFFER, 0, size, dummy_data_1);
+       glBufferSubData(GL_COPY_WRITE_BUFFER, 0, size, dummy_data_2);
        glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER,
                            0, 0, size);
        glBufferSubData(GL_COPY_WRITE_BUFFER, 0, size, good_data);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20131030/6d3f0998/attachment.pgp>


More information about the Piglit mailing list