[Piglit] [PATCH 2/2] arb_texture_buffer_object/max-size: skip if the buffer can't be allocated

sroland at vmware.com sroland at vmware.com
Mon Jan 1 05:41:19 UTC 2018


From: Roland Scheidegger <sroland at vmware.com>

The max size reported by GL_MAX_TEXTURE_BUFFER_SIZE only guarantees that
buffers which contain that many texels can be sampled from. It does not mean
it is guaranteed the corresponding huge buffers can be allocated in the first
place. (r600 for instance will report some huge number, the test cuts this
to 512 million texels, but naturally fails to allocate the 2GB buffer for it,
at least on my card with 1GB vram. The driver actually will report 0.7 times
the max of vram and gart size, but since the gl cap is in texels this doesn't
really help as the test uses rgba8 format.)
Since the test specifically tries to test the max, skip it when this happens
(instead of trying lower sizes).
---
 tests/spec/arb_texture_buffer_object/max-size.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/spec/arb_texture_buffer_object/max-size.c b/tests/spec/arb_texture_buffer_object/max-size.c
index 19f4ddf04..b94d2d094 100644
--- a/tests/spec/arb_texture_buffer_object/max-size.c
+++ b/tests/spec/arb_texture_buffer_object/max-size.c
@@ -76,6 +76,7 @@ piglit_init(int argc, char **argv)
 	static const uint8_t data[4] = {0x00, 0xff, 0x00, 0x00};
 	GLuint prog;
 	GLint max;
+	GLenum err;
 
 	prog = piglit_build_simple_program(vs_source, fs_source);
 	glUseProgram(prog);
@@ -101,6 +102,11 @@ piglit_init(int argc, char **argv)
 	glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, tbo);
 	glBufferData(GL_TEXTURE_BUFFER,
 		     max * sizeof(data), NULL, GL_STATIC_READ);
+	err = glGetError();
+	if (err == GL_OUT_OF_MEMORY) {
+		printf("couldn't allocate buffer due to OOM, skipping.\n");
+		piglit_report_result(PIGLIT_SKIP);
+	}
 	glBufferSubData(GL_TEXTURE_BUFFER,
 			(max - 1) * sizeof(data), sizeof(data), data);
 
-- 
2.12.3



More information about the Piglit mailing list