From 26782ce6cb6ebed1c992394d1ba688803e982d86 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Wed, 1 Mar 2017 17:12:43 +0000 Subject: [PATCH] texturing: add max-texture-size2 --- tests/texturing/CMakeLists.gl.txt | 1 + tests/texturing/max-texture-size2.c | 162 ++++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 tests/texturing/max-texture-size2.c diff --git a/tests/texturing/CMakeLists.gl.txt b/tests/texturing/CMakeLists.gl.txt index 9ab4d7a..a1d8d3f 100644 --- a/tests/texturing/CMakeLists.gl.txt +++ b/tests/texturing/CMakeLists.gl.txt @@ -46,6 +46,7 @@ piglit_add_executable (lodclamp lodclamp.c) piglit_add_executable (lodclamp-between lodclamp-between.c) piglit_add_executable (lodclamp-between-max lodclamp-between-max.c) piglit_add_executable (max-texture-size max-texture-size.c) +piglit_add_executable (max-texture-size2 max-texture-size2.c) piglit_add_executable (max-texture-size-level max-texture-size-level.c) piglit_add_executable (max-samplers max-samplers.c) piglit_add_executable (mipmap-setup mipmap-setup.c) diff --git a/tests/texturing/max-texture-size2.c b/tests/texturing/max-texture-size2.c new file mode 100644 index 0000000..2a99878 --- /dev/null +++ b/tests/texturing/max-texture-size2.c @@ -0,0 +1,162 @@ +/* Copyright © 2017 Julien Isorce + * + * 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 max-texture-size2.c + * Verify that large textures are handled properly in mesa driver. + * + * TODO + */ + +#include "piglit-util-gl.h" +#define COLOR_COMPONENTS 4 /*GL_RGBA*/ + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +static void +test_large_texture() +{ + GLuint tex; + int subSize, maxSize; + GLfloat *pixels = NULL; + GLenum target = GL_TEXTURE_2D; + GLenum internalformat = GL_RGBA8; + GLenum glErr = GL_NO_ERROR; + GLsync fence = 0; + GLboolean use_fence = getenv("USE_FENCE") ? GL_TRUE : GL_FALSE; + int nbIteration = getenv("TWICE_ITERATION") ? 4 : 2; + enum piglit_result result = PIGLIT_PASS; + int i; + + for (i = 0; i < nbIteration; i++) { + glGenTextures(1, &tex); + glBindTexture(target, tex); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + /* Query the largest supported texture size */ + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize); + + /* Notes: + * With subSize = maxSize it succeeds. + * + * With subSize = 3 * maxSize / 4; then "radeon: Failed to allocate a buffer" + * [drm:radeon_cs_ioctl [radeon]] *ERROR* Failed to parse relocation -12! + * + * With subSize = maxSize / 2; then "radeon: Not enough memory for command submission" + * [drm:radeon_cs_ioctl [radeon]] *ERROR* Failed to parse relocation -12! */ + subSize = maxSize / 2; + + printf("%s, Internal Format = %s, Largest Texture Size = %d\n", + piglit_get_gl_enum_name(target), + piglit_get_gl_enum_name(internalformat), + maxSize); + + /* Allocate and initialize texture data array */ + pixels = ((GLfloat *) calloc(subSize * subSize * COLOR_COMPONENTS, sizeof(float))); + + if (pixels == NULL) { + printf("Error allocating texture data array for target %s, size %d\n", + piglit_get_gl_enum_name(target), subSize); + result = PIGLIT_SKIP; + glDeleteTextures(1, &tex); + break; + } + + if (fence) + glClientWaitSync(fence, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); + + glTexImage2D(target, 0, internalformat, maxSize, + maxSize, 0, GL_RGBA, GL_FLOAT, NULL); + + glErr = glGetError(); + if (glErr != GL_NO_ERROR) { + if (glErr == GL_OUT_OF_MEMORY) { + printf("Out of memory: 0x%x\n", glErr); + result = PIGLIT_SKIP; + } else { + printf("Unexpected GL error: 0x%x\n", glErr); + result = PIGLIT_FAIL; + } + glDeleteTextures(1, &tex); + break; + } + + glTexSubImage2D(target, 0, 0, 0, subSize, subSize, + GL_RGBA, GL_FLOAT, pixels); + free(pixels); + pixels = NULL; + + glErr = glGetError(); + if (glErr != GL_NO_ERROR) { + printf("Unexpected GL error: 0x%x\n", glErr); + result = PIGLIT_FAIL; + glDeleteTextures(1, &tex); + break; + } + + glDeleteTextures(1, &tex); + free(pixels); + tex = 0; + glBindTexture(target, 0); + + if (fence) + glDeleteSync(fence); + if (use_fence) + fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + } + + + /* Catch here any potential gl error instead. Otherwise it will be + * silent when calling glXMakeCurrent(XOpenDisplay(NULL), 0, NULL); + * from the external glx wrapper lib. */ + glFlush(); + glErr = glGetError(); + if (glErr != GL_NO_ERROR) { + printf("Unexpected GL error: 0x%x\n", glErr); + result = PIGLIT_FAIL; + } + + piglit_report_subtest_result(result, "%s-%s", + piglit_get_gl_enum_name(target), + piglit_get_gl_enum_name(internalformat)); +} + +void +piglit_init(int argc, char **argv) +{ + test_large_texture(); + printf("exit\n"); + exit(0); +} + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} -- 2.7.4