Ian Romanick <[email protected]> writes: > From: Ian Romanick <[email protected]> > > This test passes on NVIDIA's closed-source driver (version 304.64 on > GTX 260). > > This test fails on AMD's closed-source driver (Catalyst 12.6 on HD > 3650). Queries of GL_NUM_SAMPLE_COUNTS merrily write data even when > bufSize is zero. > > v2: Add some comments describing the non-obvious test method. Use a > fixed sentinal value instead of inverting a previous result. Require > compat version 3.0. Based on review comments from Eric Anholt. > + /* Try GL_SAMPLES. > + * > + * Call it once with the full size buffer. Smash the data in the > + * buffer. Call it again with a buffer size of 1. Verify that all of > + * the data after the first element is still the smashed data. > + */ > + memset(buffer, 0x7e, buffer_size_in_bytes); > + > + glGetInternalformativ(GL_RENDERBUFFER, > + format, > + GL_SAMPLES, > + buffer_size_in_elements, > + buffer); > + pass = piglit_check_gl_error(0) > + && pass; > + > + for (i = 0; i < buffer_size_in_elements; i++) { > + buffer[i] = ~buffer[i]; > + buffer_copy[i] = buffer[i]; > + } > + > + glGetInternalformativ(GL_RENDERBUFFER, > + format, > + GL_SAMPLES, > + 1, > + buffer); > + pass = piglit_check_gl_error(0) > + && pass; > + > + for (i = 1; i < buffer_size_in_elements; i++) { > + if (buffer[i] != buffer_copy[i]) { > + fprintf(stderr, > + "pname = GL_SAMPLES, bufSize = 1 " > + "over-ran the buffer at element %u.\n", > + i); > + pass = false; > + } > + }
The code I'd been imagining:
/* Try GL_SAMPLES.
*
* Call it once with a full size buffer.
*
* Then, memset another buffer to junk and call it with a buffer size of
* 1. Verify that all of the data after the first element is still the
* junk data.
*/
glGetInternalformativ(GL_RENDERBUFFER,
format,
GL_SAMPLES,
buffer_size_in_elements,
buffer_copy);
pass = piglit_check_gl_error(0) && pass;
memset(buffer, 0x7e, buffer_size_in_bytes);
glGetInternalformativ(GL_RENDERBUFFER,
format,
GL_SAMPLES,
1,
buffer);
pass = piglit_check_gl_error(0) && pass;
if (buffer[0] != buffer_copy[0]) {
fprintf(stderr,
"pname = GL_SAMPLES, bufSize = 1 "
"failed to write the first element.\n",
i);
pass = false;
}
for (i = 1; i < buffer_size_in_elements; i++) {
if (buffer[i] != 0x7e7e7e7e) {
fprintf(stderr,
"pname = GL_SAMPLES, bufSize = 1 "
"over-ran the buffer at element %u.\n",
i);
pass = false;
}
}
Either way though, I was at least able to follow the logic this time.
pgpfVbzU8dASX.pgp
Description: PGP signature
_______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
