From patchwork Fri Jan 18 20:04:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom Gall X-Patchwork-Id: 14116 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4681A24229 for ; Fri, 18 Jan 2013 20:05:44 +0000 (UTC) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by fiordland.canonical.com (Postfix) with ESMTP id DB969A18EED for ; Fri, 18 Jan 2013 20:05:43 +0000 (UTC) Received: by mail-vc0-f171.google.com with SMTP id fk10so2525563vcb.16 for ; Fri, 18 Jan 2013 12:05:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=FSEfOg5swPLWzbRgax7cEuiS5ux1OCUvmTv/iNBekqc=; b=eG6Z+7c2ezwdR60tc6Ks4Weh2701qTtat6gnpP7PzwP45tvEqBZthUoGDjoMGknTW1 s07Gp9oQLQrU3jMm3STJUg+qKNAm+Z1Byq5LaNVnRoGcsoy2CXExYAbwWG6/TThNigX3 d+Win7uN+gxHNEVfDyR+pUjP70QUK9ejXssQzeX4OeyERjfb63g9aRCvkXu0J1K9iigk ITau2gQboZN95qZG8v1SZQRvIsgRniIFiED6vT88clQQN0A1zNSgCxdTr9K4kSxw4PwF zTLw8ZbGgyurJ3SZ64TgRoK/wDDokspsSf5l6sAiwgZSYtCr9Z8/IazUYDQ5+qjQjzvq xDuw== X-Received: by 10.52.16.6 with SMTP id b6mr6831163vdd.40.1358539543385; Fri, 18 Jan 2013 12:05:43 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp102049veb; Fri, 18 Jan 2013 12:05:42 -0800 (PST) X-Received: by 10.42.57.11 with SMTP id b11mr6890298ich.15.1358539542584; Fri, 18 Jan 2013 12:05:42 -0800 (PST) Received: from mail-ie0-f181.google.com (mail-ie0-f181.google.com [209.85.223.181]) by mx.google.com with ESMTPS id xv10si3563281igb.8.2013.01.18.12.05.42 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Jan 2013 12:05:42 -0800 (PST) Received-SPF: neutral (google.com: 209.85.223.181 is neither permitted nor denied by best guess record for domain of tom.gall@linaro.org) client-ip=209.85.223.181; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.223.181 is neither permitted nor denied by best guess record for domain of tom.gall@linaro.org) smtp.mail=tom.gall@linaro.org Received: by mail-ie0-f181.google.com with SMTP id 16so6757064iea.26 for ; Fri, 18 Jan 2013 12:05:42 -0800 (PST) X-Received: by 10.50.217.129 with SMTP id oy1mr3105963igc.26.1358539542236; Fri, 18 Jan 2013 12:05:42 -0800 (PST) Received: from localhost.localdomain ([70.35.96.184]) by mx.google.com with ESMTPS id hi2sm2741910igc.16.2013.01.18.12.05.40 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Jan 2013 12:05:40 -0800 (PST) From: Tom Gall To: piglit@lists.freedesktop.org Cc: patches@linaro.org, Tom Gall Subject: =?UTF-8?q?=5BPATCH=201/2=5D=20port=20ttexrect=2Ecpp=20to=20piglit=20from=20glean?= Date: Fri, 18 Jan 2013 14:04:02 -0600 Message-Id: <1358539443-3382-1-git-send-email-tom.gall@linaro.org> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkHTk5DDNu8HnyrBag2KrOW1EG4yALieC9Op2uxrmk7jAMU6KF4q9Pf0yjsPM4qFuMUMSBn This ported test goes into tests/spec/arb_texture_rectangle. It tests the ARB_texture_rectangle extension. Create a 255x127 texture of varying colors and bind it as a GL_ARB_texture_recangle target. Draw that rectangle to the window, and check that the texture was drawn correctly. The common failure to be caught with this test is not adjusting the non-normalized coordinates on hardware that expects normalized coordinates. Signed-off-by: Tom Gall Reviewed-by: Brian Paul --- tests/spec/CMakeLists.txt | 1 + tests/spec/arb_texture_rectangle/CMakeLists.gl.txt | 13 ++ tests/spec/arb_texture_rectangle/CMakeLists.txt | 1 + tests/spec/arb_texture_rectangle/texrect-simple.c | 132 ++++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 tests/spec/arb_texture_rectangle/CMakeLists.gl.txt create mode 100644 tests/spec/arb_texture_rectangle/CMakeLists.txt create mode 100644 tests/spec/arb_texture_rectangle/texrect-simple.c diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index a4342b7..8b06d5c 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -24,6 +24,7 @@ add_subdirectory (arb_texture_buffer_object) add_subdirectory (arb_texture_compression) add_subdirectory (arb_texture_cube_map_array) add_subdirectory (arb_texture_float) +add_subdirectory (arb_texture_rectangle) add_subdirectory (arb_texture_storage) add_subdirectory (arb_timer_query) add_subdirectory (arb_transform_feedback2) diff --git a/tests/spec/arb_texture_rectangle/CMakeLists.gl.txt b/tests/spec/arb_texture_rectangle/CMakeLists.gl.txt new file mode 100644 index 0000000..d84a850 --- /dev/null +++ b/tests/spec/arb_texture_rectangle/CMakeLists.gl.txt @@ -0,0 +1,13 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} + ${piglit_SOURCE_DIR}/tests/mesa/util +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} +) + +piglit_add_executable (texrect_simple_arb_texrect texrect-simple.c) diff --git a/tests/spec/arb_texture_rectangle/CMakeLists.txt b/tests/spec/arb_texture_rectangle/CMakeLists.txt new file mode 100644 index 0000000..144a306 --- /dev/null +++ b/tests/spec/arb_texture_rectangle/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/arb_texture_rectangle/texrect-simple.c b/tests/spec/arb_texture_rectangle/texrect-simple.c new file mode 100644 index 0000000..1a8f33f --- /dev/null +++ b/tests/spec/arb_texture_rectangle/texrect-simple.c @@ -0,0 +1,132 @@ +/* Copyright © 2013 Linaro Inc + * + * 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. + */ + +/** + * Ported from glean ttexrect.cpp into piglit. + * Test the ARB_texture_rectangle extension + * Create a 255x127 texture of varying colors and bind it as a + * GL_ARB_texture_recangle target. Draw that rectangle to the window, and + * check that the texture was drawn correctly. The common failure to be + * caught with this test is not adjusting the non-normalized coordinates on + * hardware that expects normalized coordinates. + * \author: Eric Anholt (original) + * \author: Tom Gall (port) + */ +#include "piglit-util-gl-common.h" + +#define TEXTURE_WIDTH 255 +#define TEXTURE_HEIGHT 127 +#define WINDOW_SIZE 256 + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_width = WINDOW_SIZE; + config.window_height = WINDOW_SIZE; + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DEPTH; + +PIGLIT_GL_TEST_CONFIG_END + + +enum piglit_result +piglit_display(void) +{ + int x,y,i; + enum piglit_result final_result = PIGLIT_PASS; + float image[TEXTURE_WIDTH * TEXTURE_HEIGHT * 3]; + + /* Set up a texture that is color ramps with red to black top to + * bottom and green to black left to right. + */ + for (y = 0; y < TEXTURE_HEIGHT; y++) { + for (x = 0; x < TEXTURE_WIDTH; x++) { + i = (y * TEXTURE_WIDTH + x) * 3; + + image[i + 0] = (float)x / (TEXTURE_WIDTH - 1); + image[i + 1] = 1.0 - ((float) y / (TEXTURE_HEIGHT - 1)); + image[i + 2] = 0.0; + } + } + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glShadeModel(GL_FLAT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, WINDOW_SIZE, 0, WINDOW_SIZE, -1, 1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glViewport(0, 0, WINDOW_SIZE, WINDOW_SIZE); + + glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, + TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL_RGB, GL_FLOAT, image); + glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, + GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, + GL_NEAREST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glEnable(GL_TEXTURE_RECTANGLE_ARB); + + glDrawBuffer(GL_BACK); + glReadBuffer(GL_BACK); + + /* Draw our texture to the window such that each texel should map + * to the corresponding pixel of the window. + */ + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); + glVertex2f(0, 0); + + glTexCoord2f(TEXTURE_WIDTH, 0); + glVertex2f(TEXTURE_WIDTH, 0); + + glTexCoord2f(TEXTURE_WIDTH, TEXTURE_HEIGHT); + glVertex2f(TEXTURE_WIDTH, TEXTURE_HEIGHT); + + glTexCoord2f(0, TEXTURE_HEIGHT); + glVertex2f(0, TEXTURE_HEIGHT); + glEnd(); + + piglit_swap_buffers(); + + /* Verify the output */ + for (y = 0; y < TEXTURE_HEIGHT; y++) { + for (x = 0; x < TEXTURE_WIDTH; x++) { + i = (y * TEXTURE_WIDTH + x) * 3; + + if (!piglit_probe_pixel_rgb(x,y, &image[i])) { + final_result = PIGLIT_FAIL; + } + } + } + + piglit_report_result(final_result); + return final_result; +} + + +void +piglit_init(int argc, char *argv[]) +{ +}