[Piglit] [PATCH] arb_texture_buffer_range: Fix buffer alignment in ranges-2 test

Anthony Pesch apesch at nvidia.com
Thu May 9 18:41:21 UTC 2019


Pinging to see if anyone has the time to review.

  - Anthony

On 4/15/19 4:24 PM, Anthony Pesch wrote:
> From: Anthony Pesch <apesch at nvidia.com>
> 
> The ranges-2 test was failing due to glTexBufferRange returning GL_INVALID_VALUE
> when the offset parameter wasn't GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT byte aligned.
> 
>  From the OpenGL 4.6 Core spec:
> 
> An INVALID_VALUE error is generated if offset is not an integer multiple of the
> value of TEXTURE_BUFFER_OFFSET_ALIGNMENT.
> ---
>   .../spec/arb_texture_buffer_range/ranges-2.c  | 24 +++++++++++++++----
>   1 file changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/spec/arb_texture_buffer_range/ranges-2.c b/tests/spec/arb_texture_buffer_range/ranges-2.c
> index 3477e4b52..b9cd543b0 100644
> --- a/tests/spec/arb_texture_buffer_range/ranges-2.c
> +++ b/tests/spec/arb_texture_buffer_range/ranges-2.c
> @@ -91,22 +91,25 @@ float data[] = {
>   	0, 0,		0.5, 0,
>   };
>   
> +int aligned_size = 0;
> +int chunk_size = 24 * sizeof(float);
> +int num_chunks = 4;
> +
>   enum piglit_result
>   piglit_display(void) {
>   	int i;
> -	int chunk_size = 24 * sizeof(float);
>   	bool pass = true;
>   
>   	glClearColor(0.2, 0.2, 0.2, 0.2);
>   	glClear(GL_COLOR_BUFFER_BIT);
>   
> -	for (i = 0; i < sizeof(data) / chunk_size; i++) {
> +	for (i = 0; i < num_chunks; i++) {
>   		glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F,
> -				 tbo, i * chunk_size, chunk_size);
> +				 tbo, i * aligned_size, chunk_size);
>   		glDrawArrays(GL_TRIANGLES, 0, 6);
>   	}
>   
> -	for (i = 0; i < sizeof(data) / chunk_size; i++) {
> +	for (i = 0; i < num_chunks; i++) {
>   		float c[4] = {
>   			data[i * 24 + 2],
>   			data[i * 24 + 3],
> @@ -128,8 +131,14 @@ piglit_display(void) {
>   
>   void
>   piglit_init(int argc, char **argv) {
> +	GLint align, i;
> +	uint8_t *chunk;
> +
>   	piglit_require_extension("GL_ARB_texture_buffer_range");
>   
> +	glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &align);
> +	aligned_size = chunk_size % align == 0 ? chunk_size : align;
> +
>   	prog = piglit_build_simple_program(vs_source, fs_source);
>   	glUseProgram(prog);
>   
> @@ -138,7 +147,12 @@ piglit_init(int argc, char **argv) {
>   
>   	glGenBuffers(1, &tbo);
>   	glBindBuffer(GL_ARRAY_BUFFER, tbo);
> -	glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
> +	glBufferData(GL_ARRAY_BUFFER, aligned_size * num_chunks, NULL, GL_STATIC_DRAW);
> +
> +	for (i = 0, chunk = data; i < num_chunks; i++) {
> +		glBufferSubData(GL_ARRAY_BUFFER, aligned_size * i, chunk_size, chunk);
> +		chunk += chunk_size;
> +	}
>   
>   	glGenTextures(1, &tex);
>   	glBindTexture(GL_TEXTURE_BUFFER, tex);
> 


More information about the Piglit mailing list