From b529d2255d892e1edf6e31b55ac9945a4c3b9be3 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 | 139 ++++++++++++++++++++++++++++++++++++ 2 files changed, 140 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..c03bf6d --- /dev/null +++ b/tests/texturing/max-texture-size2.c @@ -0,0 +1,139 @@ +/* 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, maxSide; + GLfloat *pixels = NULL; + GLenum target = GL_TEXTURE_2D; + GLenum internalformat = GL_RGBA8; + GLenum gl_err = GL_NO_ERROR; + GLsync fence = 0; + GLboolean use_fence = getenv("USE_FENCE") ? GL_TRUE : GL_FALSE;; + enum piglit_result result = PIGLIT_PASS; + int i; + + for (i = 0; i < 2; 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, &maxSide); + + /* Notes: + * With subSize = maxSide it succeeds. + * + * With subSize = 3 * maxSide / 4; then "radeon: Failed to allocate a buffer" + * [drm:radeon_cs_ioctl [radeon]] *ERROR* Failed to parse relocation -12! + * + * With subSize = maxSide / 2; then "radeon: Not enough memory for command submission" + * [drm:radeon_cs_ioctl [radeon]] *ERROR* Failed to parse relocation -12! */ + subSize = maxSide / 2; + + printf("%s, Internal Format = %s, Largest Texture Size = %d\n", + piglit_get_gl_enum_name(target), + piglit_get_gl_enum_name(internalformat), + maxSide); + + /* 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; + break; + } + + if (fence) + glClientWaitSync(fence, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); + + glTexImage2D(target, 0, internalformat, maxSide, + maxSide, 0, GL_RGBA, GL_FLOAT, NULL); + glTexSubImage2D(target, 0, 0, 0, subSize, subSize, + GL_RGBA, GL_FLOAT, pixels); + gl_err = glGetError(); + if (gl_err != GL_NO_ERROR) { + printf("Unexpected GL error: 0x%x\n", gl_err); + } + glDeleteTextures(1, &tex); + + if (fence) + glDeleteSync(fence); + if (use_fence) + fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + + free(pixels); + tex = 0; + pixels = NULL; + } + + + /* 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(); + gl_err = glGetError(); + if (gl_err != GL_NO_ERROR) { + printf("Unexpected GL error: 0x%x\n", gl_err); + } + + 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