diff options
Diffstat (limited to 'tests/spec')
351 files changed, 6237 insertions, 1217 deletions
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index 035f43f74..544d7da54 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -1,8 +1,10 @@ add_subdirectory (amd_compressed_atc_texture) add_subdirectory (amd_framebuffer_multisample_advanced) add_subdirectory (amd_depth_clamp_separate) +add_subdirectory (amd_gpu_shader_half_float) add_subdirectory (amd_performance_monitor) add_subdirectory (amd_pinned_memory) +add_subdirectory (apple_sync) add_subdirectory (arb_arrays_of_arrays) add_subdirectory (arb_base_instance) add_subdirectory (arb_bindless_texture) @@ -194,6 +196,7 @@ add_subdirectory (ext_render_snorm) add_subdirectory (ext_texture_compression_bptc) add_subdirectory (ext_texture_compression_rgtc) add_subdirectory (ext_color_buffer_float) +add_subdirectory (ext_debug_label) add_subdirectory (khr_parallel_shader_compile) add_subdirectory (ext_direct_state_access) add_subdirectory (arb_gpu_shader_int64) @@ -204,3 +207,5 @@ add_subdirectory (nv_viewport_swizzle) add_subdirectory (nv_alpha_to_coverage_dither_control) add_subdirectory (nv_copy_depth_to_color) add_subdirectory (arm_shader_framebuffer_fetch_depth_stencil) +add_subdirectory (ext_instanced_arrays) +add_subdirectory (ext_texture_storage) diff --git a/tests/spec/amd_gpu_shader_half_float/CMakeLists.gl.txt b/tests/spec/amd_gpu_shader_half_float/CMakeLists.gl.txt new file mode 100644 index 000000000..0301f4de1 --- /dev/null +++ b/tests/spec/amd_gpu_shader_half_float/CMakeLists.gl.txt @@ -0,0 +1,14 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} + ${piglit_SOURCE_DIR}/tests/util +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} +) + +piglit_add_executable (amd_gpu_shader_half_float-explicit-offset-bufferstorage half-float-explicit-offset-bufferstorage.c half_float_util.c) + +# vim: ft=cmake: diff --git a/tests/spec/amd_gpu_shader_half_float/CMakeLists.txt b/tests/spec/amd_gpu_shader_half_float/CMakeLists.txt new file mode 100644 index 000000000..144a306f4 --- /dev/null +++ b/tests/spec/amd_gpu_shader_half_float/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec2.vert b/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec2.vert index 0394adc9c..0e17769fb 100644 --- a/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec2.vert +++ b/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec2.vert @@ -12,7 +12,7 @@ f16vec2 test() { float16_t x = 0.999HF; - float16_t i = 0.567HF; + f16vec2 i = f16vec2(0.567HF); - return modf(f16vec2(x), f16vec2(i)); + return modf(f16vec2(x), i); } diff --git a/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec3.vert b/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec3.vert index d0df92fa4..f9d08e91b 100644 --- a/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec3.vert +++ b/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec3.vert @@ -12,7 +12,7 @@ f16vec3 test() { float16_t x = 0.999HF; - float16_t i = 0.567HF; + f16vec3 i = f16vec3(0.567HF); - return modf(f16vec3(x), f16vec3(i)); + return modf(f16vec3(x), i); } diff --git a/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec4.vert b/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec4.vert index b33bc219a..f97f07f69 100644 --- a/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec4.vert +++ b/tests/spec/amd_gpu_shader_half_float/compiler/builtin-functions/common/modf-f16vec4.vert @@ -12,7 +12,7 @@ f16vec4 test() { float16_t x = 0.999HF; - float16_t i = 0.567HF; + f16vec4 i = f16vec4(0.567HF); - return modf(f16vec4(x), f16vec4(i)); + return modf(f16vec4(x), i); } diff --git a/tests/spec/amd_gpu_shader_half_float/compiler/varying_error.vert b/tests/spec/amd_gpu_shader_half_float/compiler/varying_error.vert new file mode 100644 index 000000000..c5b6bf71b --- /dev/null +++ b/tests/spec/amd_gpu_shader_half_float/compiler/varying_error.vert @@ -0,0 +1,10 @@ +// [config] +// expect_result: fail +// glsl_version: 1.10 +// [end config] +// +// Tests an error is thrown when using half float varying without enabling + +#version 110 + +varying float16_t x; diff --git a/tests/spec/amd_gpu_shader_half_float/half-float-explicit-offset-bufferstorage.c b/tests/spec/amd_gpu_shader_half_float/half-float-explicit-offset-bufferstorage.c new file mode 100644 index 000000000..3b8aedcc1 --- /dev/null +++ b/tests/spec/amd_gpu_shader_half_float/half-float-explicit-offset-bufferstorage.c @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2014 VMware, 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. + */ + +/** @file half-float-explicit-offset-bufferstorage.c + * + * This is a copy of the arb_uniform_buffer_object bufferstorage test updated + * to make use of explicit offsets and half floats. + * + * Test rendering with UBOs. We draw four squares with different + * positions, sizes, rotations and colors where those parameters come + * from UBOs. Same as rendering.c, except that the UBOs are + * persistently mapped. + */ + +#include "piglit-util-gl.h" + +#include "half_float_util.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 40; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +static const char vert_shader_text[] = + "#version 400\n" + "#extension GL_ARB_enhanced_layouts : require\n" + "#extension GL_AMD_gpu_shader_half_float : require\n" + "\n" + "in vec4 piglit_vertex;\n" + "\n" + "layout(std140) uniform;\n" + "layout(std140) uniform ub_pos_size {\n" + " layout(offset = 0) float16_t size;\n" + " layout(offset = 2) float16_t pos1;\n" + " layout(offset = 6) float16_t pos2;\n" + "};\n" + "uniform ub_rot {float rotation; };\n" + "\n" + "void main()\n" + "{\n" + " mat2 m;\n" + " m[0][0] = m[1][1] = cos(rotation); \n" + " m[0][1] = sin(rotation); \n" + " m[1][0] = -m[0][1]; \n" + " gl_Position.xy = m * piglit_vertex.xy * vec2(size) + vec2(pos1, pos2);\n" + " gl_Position.zw = vec2(0, 1);\n" + "}\n"; + +static const char frag_shader_text[] = + "#version 400\n" + "#extension GL_ARB_enhanced_layouts : require\n" + "#extension GL_AMD_gpu_shader_half_float : require\n" + "\n" + "layout(std140) uniform;\n" + "layout(std140) uniform ub_color {\n" + " layout(offset = 0) vec4 color;\n" + " layout(offset = 22) float16_t color_scale;\n" + "} named_ub;\n" + "\n" + "void main()\n" + "{\n" + " gl_FragColor = named_ub.color * float(named_ub.color_scale);\n" + "}\n"; + +#define NUM_SQUARES 4 +#define NUM_UBOS 3 + +/* Square positions and sizes */ +static const float pos_size[NUM_SQUARES][3] = { + { 0.1, -0.5, -0.5 }, + { 0.2, 0.5, -0.5 }, + { 0.3, -0.5, 0.5 }, + { 0.4, 0.5, 0.5 } +}; + +/* Square color and color_scales */ +static const float color[NUM_SQUARES][4] = { + { 2.0, 0.0, 0.0, 1.0 }, + { 0.0, 4.0, 0.0, 1.0 }, + { 0.0, 0.0, 5.0, 1.0 }, + { 0.2, 0.2, 0.2, 0.2 } +}; + +static const float color_scale[NUM_SQUARES] = { + 0.50, + 0.25, + 0.20, + 5.00 +}; + +/* Square rotations */ +static const float rotation[NUM_SQUARES] = { + 0.0, + 0.1, + 0.2, + 0.3 +}; + +static GLuint prog; +static GLuint buffers[NUM_UBOS]; +static void *ubos[NUM_UBOS]; + +static void +setup_ubos(void) +{ + static const char *names[NUM_UBOS] = { + "ub_pos_size", + "ub_color", + "ub_rot" + }; + int i; + + glGenBuffers(NUM_UBOS, buffers); + + for (i = 0; i < NUM_UBOS; i++) { + GLint index, size; + + /* query UBO index */ + index = glGetUniformBlockIndex(prog, names[i]); + + /* query UBO size */ + glGetActiveUniformBlockiv(prog, index, + GL_UNIFORM_BLOCK_DATA_SIZE, &size); + + printf("UBO %s: index = %d, size = %d\n", + names[i], index, size); + + /* Allocate UBO */ + glBindBuffer(GL_UNIFORM_BUFFER, buffers[i]); + glBufferStorage(GL_UNIFORM_BUFFER, size, NULL, + GL_MAP_WRITE_BIT | + GL_MAP_PERSISTENT_BIT | + GL_MAP_COHERENT_BIT | + GL_DYNAMIC_STORAGE_BIT); + + piglit_check_gl_error(GL_NO_ERROR); + + ubos[i] = glMapBufferRange(GL_UNIFORM_BUFFER, 0, size, + GL_MAP_WRITE_BIT | + GL_MAP_PERSISTENT_BIT | + GL_MAP_COHERENT_BIT); + + piglit_check_gl_error(GL_NO_ERROR); + + if (!ubos[i]) + piglit_report_result(PIGLIT_FAIL); + + /* Attach UBO */ + glBindBufferBase(GL_UNIFORM_BUFFER, i, buffers[i]); + glUniformBlockBinding(prog, index, i); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + } +} + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_ARB_enhanced_layouts"); + piglit_require_extension("GL_AMD_gpu_shader_half_float"); + + prog = piglit_build_simple_program(vert_shader_text, frag_shader_text); + assert(prog); + glUseProgram(prog); + + setup_ubos(); + + glClearColor(0.2, 0.2, 0.2, 0.2); +} + +static bool +probe(int x, int y, int color_index) +{ + float expected[4]; + + /* mul color by color_scale */ + expected[0] = color[color_index][0] * color_scale[color_index]; + expected[1] = color[color_index][1] * color_scale[color_index]; + expected[2] = color[color_index][2] * color_scale[color_index]; + expected[3] = color[color_index][3] * color_scale[color_index]; + + return piglit_probe_pixel_rgba(x, y, expected); +} + + +enum piglit_result +piglit_display(void) +{ + GLsync fence; + bool pass = true; + int x0 = piglit_width / 4; + int x1 = piglit_width * 3 / 4; + int y0 = piglit_height / 4; + int y1 = piglit_height * 3 / 4; + int i; + + glViewport(0, 0, piglit_width, piglit_height); + + glClear(GL_COLOR_BUFFER_BIT); + + for (i = 0; i < NUM_SQUARES; i++) { + /* Wait for any previous rendering to finish before + * updating the UBOs + */ + fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glClientWaitSync(fence, GL_SYNC_FLUSH_COMMANDS_BIT, + GL_TIMEOUT_IGNORED); + + /* Load UBO data */ + uint16_t half_float_val = _mesa_float_to_half_slow(pos_size[i][0]); + memcpy(ubos[0], &half_float_val, 2); + + half_float_val = _mesa_float_to_half_slow(pos_size[i][1]); + memcpy((uint8_t *)ubos[0] + 2, &half_float_val, 2); + + half_float_val = _mesa_float_to_half_slow(pos_size[i][2]); + memcpy((uint8_t *)ubos[0] + 6, &half_float_val, 2); + + memcpy(ubos[1], color[i], sizeof(color[0])); + + half_float_val = _mesa_float_to_half_slow(color_scale[i]); + memcpy(((uint8_t *)ubos[1]) + 22, &half_float_val, 2); + + memcpy(ubos[2], &rotation[i], sizeof(rotation[0])); + + piglit_draw_rect(-1, -1, 2, 2); + } + + pass = probe(x0, y0, 0) && pass; + pass = probe(x1, y0, 1) && pass; + pass = probe(x0, y1, 2) && pass; + pass = probe(x1, y1, 3) && pass; + + piglit_present_results(); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} diff --git a/tests/spec/amd_gpu_shader_half_float/half_float_util.c b/tests/spec/amd_gpu_shader_half_float/half_float_util.c new file mode 100644 index 000000000..a4b5ffd8a --- /dev/null +++ b/tests/spec/amd_gpu_shader_half_float/half_float_util.c @@ -0,0 +1,167 @@ +/* + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright 2015 Philip Taylor <philip@zaynar.co.uk> + * Copyright 2018 Advanced Micro Devices, Inc. + * Copyright (C) 2018-2019 Intel Corporation + * + * 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 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. + */ + + /* These functions were copied from Mesas util library. The only difference + * is the custom optimised _mesa_roundevenf() calls were replaced with + * lrintf() + */ + +#include <assert.h> +#include <math.h> +#include <stdint.h> + +#include "half_float_util.h" + +typedef union { float f; int32_t i; uint32_t u; } fi_type; + +/** + * Convert a 4-byte float to a 2-byte half float. + * + * Not all float32 values can be represented exactly as a float16 value. We + * round such intermediate float32 values to the nearest float16. When the + * float32 lies exactly between to float16 values, we round to the one with + * an even mantissa. + * + * This rounding behavior has several benefits: + * - It has no sign bias. + * + * - It reproduces the behavior of real hardware: opcode F32TO16 in Intel's + * GPU ISA. + * + * - By reproducing the behavior of the GPU (at least on Intel hardware), + * compile-time evaluation of constant packHalf2x16 GLSL expressions will + * result in the same value as if the expression were executed on the GPU. + */ +uint16_t +_mesa_float_to_half_slow(float val) +{ + const fi_type fi = {val}; + const int flt_m = fi.i & 0x7fffff; + const int flt_e = (fi.i >> 23) & 0xff; + const int flt_s = (fi.i >> 31) & 0x1; + int s, e, m = 0; + uint16_t result; + + /* sign bit */ + s = flt_s; + + /* handle special cases */ + if ((flt_e == 0) && (flt_m == 0)) { + /* zero */ + /* m = 0; - already set */ + e = 0; + } + else if ((flt_e == 0) && (flt_m != 0)) { + /* denorm -- denorm float maps to 0 half */ + /* m = 0; - already set */ + e = 0; + } + else if ((flt_e == 0xff) && (flt_m == 0)) { + /* infinity */ + /* m = 0; - already set */ + e = 31; + } + else if ((flt_e == 0xff) && (flt_m != 0)) { + /* Retain the top bits of a NaN to make sure that the quiet/signaling + * status stays the same. + */ + m = flt_m >> 13; + if (!m) + m = 1; + e = 31; + } + else { + /* regular number */ + const int new_exp = flt_e - 127; + if (new_exp < -14) { + /* The float32 lies in the range (0.0, min_normal16) and is rounded + * to a nearby float16 value. The result will be either zero, subnormal, + * or normal. + */ + e = 0; + m = lrintf((1 << 24) * fabsf(fi.f)); + } + else if (new_exp > 15) { + /* map this value to infinity */ + /* m = 0; - already set */ + e = 31; + } + else { + /* The float32 lies in the range + * [min_normal16, max_normal16 + max_step16) + * and is rounded to a nearby float16 value. The result will be + * either normal or infinite. + */ + e = new_exp + 15; + m = lrintf(flt_m / (float) (1 << 13)); + } + } + + assert(0 <= m && m <= 1024); + if (m == 1024) { + /* The float32 was rounded upwards into the range of the next exponent, + * so bump the exponent. This correctly handles the case where f32 + * should be rounded up to float16 infinity. + */ + ++e; + m = 0; + } + + result = (s << 15) | (e << 10) | m; + return result; +} + +/** + * Convert a 2-byte half float to a 4-byte float. + * Based on code from: + * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html + */ +float +_mesa_half_to_float_slow(uint16_t val) +{ + fi_type infnan; + fi_type magic; + fi_type f32; + + infnan.u = 0x8f << 23; + infnan.f = 65536.0f; + magic.u = 0xef << 23; + + /* Exponent / Mantissa */ + f32.u = (val & 0x7fff) << 13; + + /* Adjust */ + f32.f *= magic.f; + /* XXX: The magic mul relies on denorms being available */ + + /* Inf / NaN */ + if (f32.f >= infnan.f) + f32.u |= 0xff << 23; + + /* Sign */ + f32.u |= (uint32_t)(val & 0x8000) << 16; + + return f32.f; +}
\ No newline at end of file diff --git a/tests/spec/amd_gpu_shader_half_float/half_float_util.h b/tests/spec/amd_gpu_shader_half_float/half_float_util.h new file mode 100644 index 000000000..f0f50fd22 --- /dev/null +++ b/tests/spec/amd_gpu_shader_half_float/half_float_util.h @@ -0,0 +1,33 @@ +/* + * Copyright © 2015 Intel Corporation + * + * 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. + */ + +#ifndef _HALF_FLOAT_H_ +#define _HALF_FLOAT_H_ + +#define FP16_ONE ((uint16_t) 0x3c00) +#define FP16_ZERO ((uint16_t) 0) + +uint16_t _mesa_float_to_half_slow(float val); +float _mesa_half_to_float_slow(uint16_t val); + +#endif /* _HALF_FLOAT_H_ */ diff --git a/tests/spec/apple_sync/CMakeLists.gles2.txt b/tests/spec/apple_sync/CMakeLists.gles2.txt new file mode 100644 index 000000000..39e90fb4b --- /dev/null +++ b/tests/spec/apple_sync/CMakeLists.gles2.txt @@ -0,0 +1,13 @@ +link_libraries ( + piglitutil_${piglit_target_api} +) + +piglit_add_executable (apple_sync-client-wait-errors ClientWaitSync-errors.c) +piglit_add_executable (apple_sync-delete DeleteSync.c) +piglit_add_executable (apple_sync-fence-sync-errors FenceSync-errors.c) +piglit_add_executable (apple_sync-get-sync-errors GetSynciv-errors.c) +piglit_add_executable (apple_sync-is-sync IsSync.c) +piglit_add_executable (apple_sync-repeat-wait repeat-wait.c) +piglit_add_executable (apple_sync-sync-initialize sync-initialize.c) +piglit_add_executable (apple_sync-timeout-zero timeout-zero.c) +piglit_add_executable (apple_sync-WaitSync-errors WaitSync-errors.c) diff --git a/tests/spec/apple_sync/CMakeLists.txt b/tests/spec/apple_sync/CMakeLists.txt new file mode 100644 index 000000000..144a306f4 --- /dev/null +++ b/tests/spec/apple_sync/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/apple_sync/ClientWaitSync-errors.c b/tests/spec/apple_sync/ClientWaitSync-errors.c new file mode 100644 index 000000000..1129d0e3c --- /dev/null +++ b/tests/spec/apple_sync/ClientWaitSync-errors.c @@ -0,0 +1,79 @@ +/* + * Copyright © 2013 Intel Corporation + * Copyright © 2023 Lucas Stach (adapted to GL ES) + * + * SPDX-License-Identifier: MIT + */ + +/** + * \file + * Test ClientWaitSyncAPPLE() returns correct error messages for invalid input + * + * + * Section 5.2.1 (Waiting for Sync Objects) of the extension spec says: + * + * "If <sync> is not the name of a sync object, an INVALID_VALUE error + * is generated. If <flags> contains any bits other than + * SYNC_FLUSH_COMMANDS_BIT_APPLE, an INVALID_VALUE error is generated." + * + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + config.khr_no_error_support = PIGLIT_HAS_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + GLsync a = (GLsync)0xDEADBEEF; + GLenum status; + int i; + + piglit_require_extension("GL_APPLE_sync"); + + /* sync not set up yet so this should fail with both GL error and + * respond GL_WAIT_FAILED + */ + status = glClientWaitSyncAPPLE(a, GL_SYNC_FLUSH_COMMANDS_BIT_APPLE, 0); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + if (status != GL_WAIT_FAILED_APPLE) { + printf("Expected GL_WAIT_FAILED but returned: %s\n", + piglit_get_gl_enum_name(status)); + pass = false; + } + + a = glFenceSyncAPPLE(GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE, 0); + + /* test that valid sync results in NO_ERROR */ + status = glClientWaitSyncAPPLE(a, GL_SYNC_FLUSH_COMMANDS_BIT_APPLE, 0); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* test that invalid flag value results in INVALID_VALUE */ + for (i = 0; i < sizeof(GLbitfield) * 8; i++) { + GLbitfield mask = 1 << i; + /* Skip over the valid bit */ + if (mask == GL_SYNC_FLUSH_COMMANDS_BIT_APPLE) { + continue; + } + status = glClientWaitSyncAPPLE(a, mask, 0); + pass = (status == GL_WAIT_FAILED_APPLE) && pass; + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + } + + glDeleteSyncAPPLE(a); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/apple_sync/DeleteSync.c b/tests/spec/apple_sync/DeleteSync.c new file mode 100644 index 000000000..ca8e7f562 --- /dev/null +++ b/tests/spec/apple_sync/DeleteSync.c @@ -0,0 +1,64 @@ +/* + * Copyright © 2013 Intel Corporation + * Copyright © 2023 Lucas Stach (adapted to GL ES) + * + * SPDX-License-Identifier: MIT + */ + +/** + * \file + * Test DeleteSyncAPPLE() returns correct error messages + * + * Section 5.2 (Sync Objects and Fences) of the extension spec says: + * + * "DeleteSyncAPPLE will silently ignore a <sync> value of zero. An + * INVALID_VALUE error is generated if <sync> is neither zero nor the + * name of a sync object." + * + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + GLsync sync; + GLsync invalid = (GLsync) GL_FRONT; + + piglit_require_extension("GL_APPLE_sync"); + + /* Test for successful function calls + * DeleteSync will silently ignore a sync value of zero + */ + glDeleteSync(0); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + sync = glFenceSyncAPPLE(GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE, 0); + glDeleteSyncAPPLE(sync); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + /* Check if sync was deleted */ + pass = !glIsSyncAPPLE(sync) && pass; + + if (!piglit_khr_no_error) { + /* Test for unsuccessful function calls */ + glDeleteSyncAPPLE(invalid); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + } + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/apple_sync/FenceSync-errors.c b/tests/spec/apple_sync/FenceSync-errors.c new file mode 100644 index 000000000..28bd799bf --- /dev/null +++ b/tests/spec/apple_sync/FenceSync-errors.c @@ -0,0 +1,55 @@ +/* + * Copyright © 2013 Intel Corporation + * Copyright © 2023 Lucas Stach (adapted to GL ES) + * + * SPDX-License-Identifier: MIT + */ + +/** + * \file + * Test FenceSyncAPPLE() returns correct error messages for invalid input + * + * Section 5.2 (Sync Objects and Fences) of the extension spec says: + * + * "An INVALID_ENUM error is generated if <condition> is not + * SYNC_GPU_COMMANDS_COMPLETE_APPLE. If <flags> is not zero, + * an INVALID_VALUE error is generated." + * + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + config.khr_no_error_support = PIGLIT_HAS_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + GLsync a, b; + + piglit_require_extension("GL_APPLE_sync"); + + /* test that an invalid condition results in INVALID_ENUM */ + a = glFenceSyncAPPLE(GL_NONE, 0); + pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass; + glDeleteSyncAPPLE(a); + + /* test that invalid flag value results in INVALID_VALUE */ + b = glFenceSyncAPPLE(GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE, 1); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + glDeleteSyncAPPLE(b); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/apple_sync/GetSynciv-errors.c b/tests/spec/apple_sync/GetSynciv-errors.c new file mode 100644 index 000000000..0dc7cdb80 --- /dev/null +++ b/tests/spec/apple_sync/GetSynciv-errors.c @@ -0,0 +1,74 @@ +/* + * Copyright © 2013 Intel Corporation + * Copyright © 2023 Lucas Stach (adapted to GL ES) + * + * SPDX-License-Identifier: MIT + */ + +/** + * \file + * Test GetSyncivAPPLE() sets correct error codes + * + * Section 6.1.6 (Sync Object Queries) of the extension spec says: + * + * "If <sync> is not the name of a sync object, an INVALID_VALUE error + * is generated. If <pname> is not one of the values described above, + * an INVALID_ENUM error is generated." + * + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + config.khr_no_error_support = PIGLIT_HAS_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + GLsync valid_fence; + GLsync invalid_fence = (GLsync) 0x1373; + + GLsizei len; + GLint val; + + piglit_require_extension("GL_APPLE_sync"); + + valid_fence = glFenceSyncAPPLE(GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE, 0); + + /* test that invalid sync results in INVALID_VALUE */ + glGetSyncivAPPLE(invalid_fence, GL_SYNC_STATUS_APPLE, 1, &len, &val); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + + /* test valid pname values result in NO_ERROR */ + glGetSyncivAPPLE(valid_fence, GL_OBJECT_TYPE_APPLE, 1, &len, &val); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + glGetSyncivAPPLE(valid_fence, GL_SYNC_STATUS_APPLE, 1, &len, &val); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + glGetSyncivAPPLE(valid_fence, GL_SYNC_CONDITION_APPLE, 1, &len, &val); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + glGetSyncivAPPLE(valid_fence, GL_SYNC_FLAGS_APPLE, 1, &len, &val); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* test that invalid pname results in INVALID_ENUM */ + glGetSyncivAPPLE(valid_fence, GL_INVALID_VALUE, 1, &len, &val); + pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass; + + glDeleteSyncAPPLE(valid_fence); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/apple_sync/IsSync.c b/tests/spec/apple_sync/IsSync.c new file mode 100644 index 000000000..9269fbf9a --- /dev/null +++ b/tests/spec/apple_sync/IsSync.c @@ -0,0 +1,67 @@ +/* + * Copyright © 2013 Intel Corporation + * Copyright © 2023 Lucas Stach (adapted to GL ES) + * + * SPDX-License-Identifier: MIT + */ + +/** + * \file + * Test IsSyncAPPLE() + * + * Section 6.1.6 (Sync Object Queries) of the extension spec says: + * + * "The command + * boolean IsSyncAPPLE(sync sync); + * returns TRUE if <sync> is the name of a sync object. If <sync> is + * not the name of a sync object, or if an error condition occurs, + * IsSyncAPPLE returns FALSE (note that zero is not the name of a + * sync object). + * + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + GLsync valid_sync; + GLsync invalid_sync = (GLsync)GL_BACK; + + piglit_require_extension("GL_APPLE_sync"); + + /* Create valid sync object */ + valid_sync = glFenceSyncAPPLE(GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE, 0); + + /* Check if a valid name returns true */ + pass = glIsSyncAPPLE(valid_sync) && pass; + + /* Check if invalid names return false. + * From the extension specification: + * "If <sync> is not the name of a sync object, or if an error + * condition occurs, IsSyncAPPLE returns FALSE (note that zero + * is not the name of a sync object)." + */ + pass = !glIsSyncAPPLE(invalid_sync) && pass; + + pass = !glIsSyncAPPLE(0) && pass; + + glDeleteSyncAPPLE(valid_sync); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/apple_sync/WaitSync-errors.c b/tests/spec/apple_sync/WaitSync-errors.c new file mode 100644 index 000000000..0133b5368 --- /dev/null +++ b/tests/spec/apple_sync/WaitSync-errors.c @@ -0,0 +1,62 @@ +/* + * Copyright © 2013 Intel Corporation + * Copyright © 2023 Lucas Stach (adapted to GL ES) + * + * SPDX-License-Identifier: MIT + */ + +/** + * \file + * Test WaitSyncAPPLE() returns correct error codes + * + * Section 5.2.1 (Waiting for Sync Objects) of the extension spec says: + * + * "If <sync> is not the name of a sync object, an INVALID_VALUE error + * is generated. If <flags> contains any bits other than + * SYNC_FLUSH_COMMANDS_BIT_APPLE, an INVALID_VALUE error is generated." + * + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + config.khr_no_error_support = PIGLIT_HAS_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + GLsync valid_sync; + GLsync invalid_sync = (GLsync)20; + + piglit_require_extension("GL_APPLE_sync"); + + valid_sync = glFenceSyncAPPLE(GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE, 0); + + /* test that valid parameters passed results in NO_ERROR */ + glWaitSyncAPPLE(valid_sync, 0, GL_TIMEOUT_IGNORED_APPLE); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* test that invalid sync results in INVALID_VALUE */ + glWaitSyncAPPLE(invalid_sync, 0, GL_TIMEOUT_IGNORED_APPLE); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + + /* test that invalid flag value results in INVALID_VALUE */ + glWaitSyncAPPLE(valid_sync, 3, GL_TIMEOUT_IGNORED_APPLE); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + + glDeleteSyncAPPLE(valid_sync); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/apple_sync/repeat-wait.c b/tests/spec/apple_sync/repeat-wait.c new file mode 100644 index 000000000..e905706e4 --- /dev/null +++ b/tests/spec/apple_sync/repeat-wait.c @@ -0,0 +1,73 @@ +/* + * Copyright © 2012 Intel Corporation + * Copyright © 2023 Lucas Stach (adapted to GL ES) + * + * SPDX-License-Identifier: MIT + */ + +/** @file repeat-wait.c + * + * From the GL_APPLE_sync spec: + * + * "A return value of ALREADY_SIGNALED_APPLE indicates that <sync> + * was signaled at the time ClientWaitSyncAPPLE was called. + * ALREADY_SIGNALED_APPLE will always be returned if <sync> was + * signaled, even if the value of <timeout> is zero." + * + * There was concern that the implementation of the kernel API on i965 + * might violate this for the specific case of back-to-back + * ClientWaitSyncs, but Mesa core doesn't end up calling into the + * driver on a later ClientWaitSync. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + + config.window_width = 10; + config.window_height = 10; + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +#define ONE_SECOND 1000000000 + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + GLsync sync; + GLenum ret1, ret2; + + piglit_require_extension("GL_APPLE_sync"); + + glClear(GL_COLOR_BUFFER_BIT); + + sync = glFenceSyncAPPLE(GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE, 0); + + ret1 = glClientWaitSyncAPPLE(sync, GL_SYNC_FLUSH_COMMANDS_BIT_APPLE, ONE_SECOND); + ret2 = glClientWaitSyncAPPLE(sync, 0, ONE_SECOND); + + if (ret1 == GL_TIMEOUT_EXPIRED_APPLE) { + printf("timeout expired on the first wait\n"); + piglit_report_result(PIGLIT_SKIP); + } + + if (ret2 != GL_ALREADY_SIGNALED_APPLE) { + fprintf(stderr, + "Expected GL_ALREADY_SIGNALED_APPLE on second wait, got %s", + piglit_get_gl_enum_name(ret2)); + piglit_report_result(PIGLIT_FAIL); + } + + piglit_report_result(PIGLIT_PASS); +} diff --git a/tests/spec/apple_sync/sync-initialize.c b/tests/spec/apple_sync/sync-initialize.c new file mode 100644 index 000000000..2aed5ac23 --- /dev/null +++ b/tests/spec/apple_sync/sync-initialize.c @@ -0,0 +1,116 @@ +/* + * Copyright © 2013 Intel Corporation + * Copyright © 2023 Lucas Stach (adapted to GL ES) + * + * SPDX-License-Identifier: MIT + */ + +/** + * \file + * Test that a sync is initialized correctly with FenceSyncAPPLE + * + * Section 5.2 (Sync Objects and Fences) of the extension spec says: + * "Table 5.props: Initial properties of a sync object + * created with FenceSyncAPPLE." + * + * Property Name Property Value + * -------------------------------------- + * OBJECT_TYPE_APPLE SYNC_FENCE_APPLE + * SYNC_CONDITION_APPLE <condition> + * SYNC_STATUS_APPLE UNSIGNALED_APPLE + * SYNC_FLAGS_APPLE <flags> + * + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + GLsizei length = -5; + GLint value; + GLsync sync; + + piglit_require_extension("GL_APPLE_sync"); + + /* Create a new fence sync */ + sync = glFenceSyncAPPLE(GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE, 0); + + /* Test initialized as fence type */ + glGetSyncivAPPLE(sync, GL_OBJECT_TYPE_APPLE, 1, &length, &value); + if (length != 1) { + printf("length should be 1 but incorrectly returned: %d\n", + length); + pass = false; + } + if (value != GL_SYNC_FENCE_APPLE) { + printf("Expected GL_SYNC_FENCE_APPLE but returned: %s\n", + piglit_get_gl_enum_name(value)); + pass = false; + } + + /* Test initialized to given condition */ + length = -5; + glGetSyncivAPPLE(sync, GL_SYNC_CONDITION_APPLE, 1, &length, &value); + if (length != 1) { + printf("length should be 1 but incorrectly returned: %d\n", + length); + pass = false; + } + if (value != GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE) { + printf("Expected GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE but returned: %s\n", + piglit_get_gl_enum_name(value)); + pass = false; + } + + /* Test initialized to unsignaled */ + length = -5; + glGetSyncivAPPLE(sync, GL_SYNC_STATUS_APPLE, 1, &length, &value); + if (length != 1) { + printf("length should be 1 but incorrectly returned: %d\n", + length); + pass = false; + } + /* We can't test for just GL_UNSIGNALED_APPLE here, since the + * driver may have actually completed any previous rendering + * (or, in our case, no rendering at all) already. + */ + if (value != GL_UNSIGNALED_APPLE && value != GL_SIGNALED_APPLE) { + printf("Expected GL_UNSIGNALED_APPLE or GL_SIGNALED_APPLE but returned: %s\n", + piglit_get_gl_enum_name(value)); + pass = false; + } + + /* Test initialized with given flag */ + length = -5; + glGetSyncivAPPLE(sync, GL_SYNC_FLAGS_APPLE, 1, &length, &value); + if (length != 1) { + printf("length should be 1 but incorrectly returned: %d\n", + length); + pass = false; + } + if (value != 0) { + printf("Expected GL_SYNC_FLAGS_APPLE == 0 but returned: %d\n", + value); + pass = false; + } + + glDeleteSyncAPPLE(sync); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/apple_sync/timeout-zero.c b/tests/spec/apple_sync/timeout-zero.c new file mode 100644 index 000000000..5a7aa3a94 --- /dev/null +++ b/tests/spec/apple_sync/timeout-zero.c @@ -0,0 +1,96 @@ +/* + * Copyright © 2012 Intel Corporation + * Copyright © 2023 Lucas Stach (adapted to GL ES) + * + * SPDX-License-Identifier: MIT + */ + +/** @file repeat-wait.c + * + * From the GL_APPLE_sync spec: + * + * "ALREADY_SIGNALED_APPLE will always be returned if <sync> was + * signaled, even if the value of <timeout> is zero. + * + * ... + * + * If the value of <timeout> is zero, then ClientWaitSyncAPPLE + * does not block, but simply tests the current state of <sync>. + * TIMEOUT_EXPIRED_APPLE will be returned in this case if <sync> + * is not signaled, even though no actual wait was performed." + * + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + + config.window_width = 10; + config.window_height = 10; + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + GLsync sync; + GLenum ret1, ret2; + bool pass = true; + + + piglit_require_extension("GL_APPLE_sync"); + + glClear(GL_COLOR_BUFFER_BIT); + sync = glFenceSyncAPPLE(GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE, 0); + ret1 = glClientWaitSyncAPPLE(sync, GL_SYNC_FLUSH_COMMANDS_BIT_APPLE, 0); + glFinish(); + ret2 = glClientWaitSyncAPPLE(sync, 0, 0); + + glDeleteSyncAPPLE(sync); + + if (ret1 != GL_TIMEOUT_EXPIRED_APPLE && + ret1 != GL_ALREADY_SIGNALED_APPLE) { + fprintf(stderr, + "On first wait:\n" + " Expected GL_ALREADY_SIGNALED_APPLE or GL_TIMEOUT_EXPIRED_APPLE\n" + " Got %s\n", + piglit_get_gl_enum_name(ret1)); + pass = false; + } + + if (ret2 != GL_ALREADY_SIGNALED_APPLE) { + fprintf(stderr, + "On repeated wait:\n" + " Expected GL_ALREADY_SIGNALED_APPLE\n" + " Got %s\n", + piglit_get_gl_enum_name(ret2)); + pass = false; + } + + glClear(GL_COLOR_BUFFER_BIT); + sync = glFenceSyncAPPLE(GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE, 0); + glFinish(); + ret1 = glClientWaitSyncAPPLE(sync, GL_SYNC_FLUSH_COMMANDS_BIT_APPLE, 0); + + if (ret1 != GL_ALREADY_SIGNALED_APPLE) { + fprintf(stderr, + "On wait after a finish:\n" + " Expected GL_ALREADY_SIGNALED_APPLE\n" + " Got %s\n", + piglit_get_gl_enum_name(ret1)); + pass = false; + } + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-indirect-index.shader_test b/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-indirect-index.shader_test index 39dc268df..27e85fd3b 100644 --- a/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-indirect-index.shader_test +++ b/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-indirect-index.shader_test @@ -1,4 +1,4 @@ -# Simple test of accessing an atomic counter with dynamic indicies. +# Simple test of accessing an atomic counter with dynamic indexes. # [require] @@ -26,7 +26,7 @@ void main() uint v0[12]; uint v1[12]; - /* Get all initail values of a0 */ + /* Get all initial values of a0 */ v0[0] = atomicCounter(a0[0][0]); v0[1] = atomicCounter(a0[0][1]); v0[2] = atomicCounter(a0[0][2]); diff --git a/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-simple-inc-dec-read.shader_test b/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-simple-inc-dec-read.shader_test index 9949df843..dd2c3b734 100644 --- a/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-simple-inc-dec-read.shader_test +++ b/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-simple-inc-dec-read.shader_test @@ -25,7 +25,7 @@ void main() uint v0[12]; uint v1[12]; - /* Get all initail values of a0 */ + /* Get all initial values of a0 */ v0[0] = atomicCounter(a0[0][0]); v0[1] = atomicCounter(a0[0][1]); v0[2] = atomicCounter(a0[0][2]); @@ -59,7 +59,7 @@ void main() atomicCounterDecrement(a1[0][1][1]); atomicCounterDecrement(a1[2][0][1]); - /* Get all initail values of a1 */ + /* Get all initial values of a1 */ v0[0] = atomicCounter(a1[0][0][0]); v0[1] = atomicCounter(a1[0][0][1]); v0[2] = atomicCounter(a1[0][1][0]); diff --git a/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/vs-indirect-index.shader_test b/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/vs-indirect-index.shader_test index d58b07691..f6d72751e 100644 --- a/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/vs-indirect-index.shader_test +++ b/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/vs-indirect-index.shader_test @@ -1,4 +1,4 @@ -# Simple test of accessing an atomic counter with dynamic indicies. +# Simple test of accessing an atomic counter with dynamic indices. # [require] @@ -26,7 +26,7 @@ void main() uint v0[12]; uint v1[12]; - /* Get all initail values of a0 */ + /* Get all initial values of a0 */ v0[0] = atomicCounter(a0[0][0]); v0[1] = atomicCounter(a0[0][1]); v0[2] = atomicCounter(a0[0][2]); diff --git a/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/vs-simple-inc-dec-read.shader_test b/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/vs-simple-inc-dec-read.shader_test index c5c3015dc..fd9344394 100644 --- a/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/vs-simple-inc-dec-read.shader_test +++ b/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/vs-simple-inc-dec-read.shader_test @@ -25,7 +25,7 @@ void main() uint v0[12]; uint v1[12]; - /* Get all initail values of a0 */ + /* Get all initial values of a0 */ v0[0] = atomicCounter(a0[0][0]); v0[1] = atomicCounter(a0[0][1]); v0[2] = atomicCounter(a0[0][2]); @@ -59,7 +59,7 @@ void main() atomicCounterDecrement(a1[0][1][1]); atomicCounterDecrement(a1[2][0][1]); - /* Get all initail values of a1 */ + /* Get all initial values of a1 */ v0[0] = atomicCounter(a1[0][0][0]); v0[1] = atomicCounter(a1[0][0][1]); v0[2] = atomicCounter(a1[0][1][0]); diff --git a/tests/spec/arb_arrays_of_arrays/execution/glsl-arrays-copy-size-mismatch.shader_test b/tests/spec/arb_arrays_of_arrays/execution/glsl-arrays-copy-size-mismatch.shader_test index b7256b39b..04ac3ea38 100644 --- a/tests/spec/arb_arrays_of_arrays/execution/glsl-arrays-copy-size-mismatch.shader_test +++ b/tests/spec/arb_arrays_of_arrays/execution/glsl-arrays-copy-size-mismatch.shader_test @@ -1,5 +1,6 @@ [require] GLSL >= 1.20 +GL_ARB_arrays_of_arrays [vertex shader] #version 120 diff --git a/tests/spec/arb_arrays_of_arrays/execution/sampler/vs-struct-nonconst-non-opaque-members.shader_test b/tests/spec/arb_arrays_of_arrays/execution/sampler/vs-struct-nonconst-non-opaque-members.shader_test index dbc9c40e4..8eae15c5b 100644 --- a/tests/spec/arb_arrays_of_arrays/execution/sampler/vs-struct-nonconst-non-opaque-members.shader_test +++ b/tests/spec/arb_arrays_of_arrays/execution/sampler/vs-struct-nonconst-non-opaque-members.shader_test @@ -1,5 +1,5 @@ # This test verifies that dynamically uniform indexing of sampler arrays -# in the vertex shader behaves correctly, and the offests for the +# in the vertex shader behaves correctly, and the offsets for the # non-opaque members are calculated correctly. [require] diff --git a/tests/spec/arb_arrays_of_arrays/linker/vs-to-fs-interface-field-unsized2.shader_test b/tests/spec/arb_arrays_of_arrays/linker/vs-to-fs-interface-field-unsized2.shader_test index 269690462..da8ed8661 100644 --- a/tests/spec/arb_arrays_of_arrays/linker/vs-to-fs-interface-field-unsized2.shader_test +++ b/tests/spec/arb_arrays_of_arrays/linker/vs-to-fs-interface-field-unsized2.shader_test @@ -4,7 +4,7 @@ # # Note: The size of the arrays also means this tests the # max boundary of GL_MAX_VERTEX_ATTRIBS when it's set -# to 64 (the mininum allowed for an implementation). +# to 64 (the minimum allowed for an implementation). [require] GLSL >= 1.50 diff --git a/tests/spec/arb_arrays_of_arrays/max-binding.c b/tests/spec/arb_arrays_of_arrays/max-binding.c index 9d9bd2d47..4622f1d53 100644 --- a/tests/spec/arb_arrays_of_arrays/max-binding.c +++ b/tests/spec/arb_arrays_of_arrays/max-binding.c @@ -23,7 +23,7 @@ /** @file max-binding.c * - * Test that using more than the maximum number of suported interface block, + * Test that using more than the maximum number of supported interface block, * sampler, or atomic bindings fails with a compile error. */ @@ -49,7 +49,7 @@ generate_and_compile_shader(GLuint stage, const char *src_template, ret = asprintf(&src, src_template, binding); assert(ret); - ret = piglit_compile_shader_text_nothrow(stage, src, true); + ret = piglit_compile_shader_text_nothrow(stage, src, false); free(src); return ret; @@ -172,7 +172,7 @@ piglit_init(int argc, char **argv) /* test max boundary */ if(!run_test_sampler_max_bindings(max_samp_binding-array_elements)) subtest_fail(&status, "Test sampler binding on boundary " - "of maximum number of texure " + "of maximum number of texture " "unit bindings"); if (piglit_is_extension_supported("GL_ARB_shader_atomic_counters")) { diff --git a/tests/spec/arb_bindless_texture/errors.c b/tests/spec/arb_bindless_texture/errors.c index fa66c9f2c..eaeab6b9b 100644 --- a/tests/spec/arb_bindless_texture/errors.c +++ b/tests/spec/arb_bindless_texture/errors.c @@ -299,7 +299,7 @@ check_MakeImageHandleResident_invalid_enum(void *data) * <access> specifies whether the texture bound to the image handle * will be treated as READ_ONLY, WRITE_ONLY, or READ_WRITE." * - * NOTE: The spec doesn't explicitely say that INVALID_ENUM should + * NOTE: The spec doesn't explicitly say that INVALID_ENUM should * be returned, but I think it makes sense (like NVIDIA). */ tex = piglit_rgbw_texture(GL_RGBA32F, 16, 16, GL_FALSE, GL_FALSE, diff --git a/tests/spec/arb_bindless_texture/execution/images/uniform-struct.shader_test b/tests/spec/arb_bindless_texture/execution/images/uniform-struct.shader_test new file mode 100644 index 000000000..d2c538569 --- /dev/null +++ b/tests/spec/arb_bindless_texture/execution/images/uniform-struct.shader_test @@ -0,0 +1,49 @@ +# Test access to a uniform where it has a structure which contains a bindless +# image. +[require] +GL >= 3.3 +GLSL >= 3.30 +GL_ARB_bindless_texture +GL_ARB_shader_image_load_store + +[vertex shader passthrough] + +[fragment shader] +#version 330 +#extension GL_ARB_bindless_texture: require +#extension GL_ARB_shader_image_load_store: enable +#extension GL_ARB_uniform_buffer_object: enable + +struct Struct { + vec4 color; + writeonly image2D img; +}; + +uniform Struct s; + +out vec4 outcolor; + +void main() +{ + imageStore(s.img, ivec2(gl_FragCoord.xy), s.color); + outcolor = vec4(0.0, 0.0, 0.0, 1.0); +} + +[test] +# Texture 0 is the imageStore output. +texture rgbw 0 (16, 16) GL_RGBA8 +resident image texture 0 GL_RGBA8 +uniform handle s.img 0 + +# Texture 1 is the rendering output. We don't care about this. +texture rgbw 1 (16, 16) GL_RGBA8 + +# Store red using imageStore +uniform vec4 s.color 1.0 0.0 0.0 1.0 +fb tex 2d 1 +draw rect -1 -1 2 2 + +# Test the result of imageStore +memory barrier GL_FRAMEBUFFER_BARRIER_BIT +fb tex 2d 0 +probe all rgba 1.0 0.0 0.0 1.0 diff --git a/tests/spec/arb_blend_func_extended/api/builtins.c b/tests/spec/arb_blend_func_extended/api/builtins.c index a71608373..4752b170a 100644 --- a/tests/spec/arb_blend_func_extended/api/builtins.c +++ b/tests/spec/arb_blend_func_extended/api/builtins.c @@ -31,7 +31,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN PIGLIT_GL_TEST_CONFIG_END -bool compile_simple_program(const char* vs_text, const char* fs_text) +bool compile_simple_program(const char* vs_text, const char* fs_text, bool err_to_stderr) { GLuint vs; GLuint fs; @@ -40,8 +40,8 @@ bool compile_simple_program(const char* vs_text, const char* fs_text) prog = glCreateProgram(); - vs = piglit_compile_shader_text_nothrow(GL_VERTEX_SHADER, vs_text, true); - fs = piglit_compile_shader_text_nothrow(GL_FRAGMENT_SHADER, fs_text, true); + vs = piglit_compile_shader_text_nothrow(GL_VERTEX_SHADER, vs_text, err_to_stderr); + fs = piglit_compile_shader_text_nothrow(GL_FRAGMENT_SHADER, fs_text, err_to_stderr); if (!vs || !fs) return false; @@ -89,26 +89,26 @@ void piglit_init(int argc, char **argv) snprintf(fs_text, 256, fs_template, "gl_FragColor", "gl_SecondaryFragColorEXT"); - pass = compile_simple_program(vs_text, fs_text) && pass; + pass = compile_simple_program(vs_text, fs_text, true) && pass; // Regular FragData snprintf(fs_text, 256, fs_template, "gl_FragData[0]", "gl_SecondaryFragDataEXT[0]"); - pass = compile_simple_program(vs_text, fs_text) && pass; + pass = compile_simple_program(vs_text, fs_text, true) && pass; // Tests that should fail // FragColor & SecondaryFragData snprintf(fs_text, 256, fs_template, "gl_FragColor", "gl_SecondaryFragDataEXT[0]"); - pass = !compile_simple_program(vs_text, fs_text) && pass; + pass = !compile_simple_program(vs_text, fs_text, false) && pass; // FragData & SecondaryFragColor snprintf(fs_text, 256, fs_template, "gl_FragData[0]", "gl_SecondaryFragColorEXT"); - pass = !compile_simple_program(vs_text, fs_text) && pass; + pass = !compile_simple_program(vs_text, fs_text, false) && pass; piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); diff --git a/tests/spec/arb_blend_func_extended/api/error-at-begin.c b/tests/spec/arb_blend_func_extended/api/error-at-begin.c index 7acf33396..9627068a2 100644 --- a/tests/spec/arb_blend_func_extended/api/error-at-begin.c +++ b/tests/spec/arb_blend_func_extended/api/error-at-begin.c @@ -30,7 +30,7 @@ * implicitly calls Begin if any draw buffer has a blend function requiring the * second color input (SRC1_COLOR, ONE_MINUS_SRC1_COLOR, SRC1_ALPHA or * ONE_MINUS_SRC1_ALPHA), and a framebuffer is bound that has more than - * the value of MAX_DUAL_SOURCE_DRAW_BUFFERS-1 active color attachements." + * the value of MAX_DUAL_SOURCE_DRAW_BUFFERS-1 active color attachments." */ #include "piglit-util-gl.h" diff --git a/tests/spec/arb_blend_func_extended/api/output-location.c b/tests/spec/arb_blend_func_extended/api/output-location.c index dbda66f7d..21aeaf80b 100644 --- a/tests/spec/arb_blend_func_extended/api/output-location.c +++ b/tests/spec/arb_blend_func_extended/api/output-location.c @@ -114,7 +114,7 @@ void piglit_init(int argc, char **argv) /* Linking should fail as the location set is too big. */ glLinkProgram(prog); - if (piglit_link_check_status(prog)) + if (piglit_link_check_status_quiet(prog)) piglit_report_result(PIGLIT_FAIL); piglit_report_result(PIGLIT_PASS); diff --git a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-pattern.c b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-pattern.c index 94c779175..19b190805 100644 --- a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-pattern.c +++ b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-pattern.c @@ -28,10 +28,10 @@ * On Intel hardware at least, SIMD16 dual source rendering requires handling * pixel data in two sets of 8 pixels each. Incorrect implementations may fail * to map correct colors for each pixel group (for example by using the color - * for the first group as the color for the second group or viceversa). However, - * tests that render using solid colors across the entire polygon won't catch - * these cases (since in that case the color is the same for boths groups of - * pixels). + * for the first group as the color for the second group or vice-versa). + * However, tests that render using solid colors across the entire polygon + * won't catch these cases (since in that case the color is the same for both + * groups of pixels). * * This test blends using a checker board pattern where each cell is * 10px wide and 10px tall. This makes it so that the two sets of 8 pixels diff --git a/tests/spec/arb_clear_texture/CMakeLists.gl.txt b/tests/spec/arb_clear_texture/CMakeLists.gl.txt index 98dfd6576..fe07688a9 100644 --- a/tests/spec/arb_clear_texture/CMakeLists.gl.txt +++ b/tests/spec/arb_clear_texture/CMakeLists.gl.txt @@ -24,5 +24,6 @@ piglit_add_executable (arb_clear_texture-srgb srgb.c common.c) piglit_add_executable (arb_clear_texture-stencil stencil.c common.c) piglit_add_executable (arb_clear_texture-texview texview.c) piglit_add_executable (arb_clear_texture-depth depth.c common.c) +piglit_add_executable (arb_clear_texture-supported-formats supported-formats.c common.c) # vim: ft=cmake: diff --git a/tests/spec/arb_clear_texture/depth.c b/tests/spec/arb_clear_texture/depth.c index 93c5b1be0..096885ee9 100644 --- a/tests/spec/arb_clear_texture/depth.c +++ b/tests/spec/arb_clear_texture/depth.c @@ -40,10 +40,14 @@ PIGLIT_GL_TEST_CONFIG_BEGIN PIGLIT_GL_TEST_CONFIG_END static const struct format -formats[] = { +base_formats[] = { { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 4 }, { GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 4 }, { GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 4 }, +}; + +static const struct format +float_formats[] = { { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 4 }, }; @@ -54,7 +58,11 @@ piglit_init(int argc, char **argv) piglit_require_extension("GL_ARB_depth_texture"); - pass = test_formats(formats, ARRAY_SIZE(formats)); + pass = test_formats(base_formats, ARRAY_SIZE(base_formats)); + + if (piglit_is_extension_supported("GL_ARB_depth_buffer_float")) { + pass &= test_formats(float_formats, ARRAY_SIZE(float_formats)); + } piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); } diff --git a/tests/spec/arb_clear_texture/integer.c b/tests/spec/arb_clear_texture/integer.c index 03ea16ef6..1e2632e66 100644 --- a/tests/spec/arb_clear_texture/integer.c +++ b/tests/spec/arb_clear_texture/integer.c @@ -28,7 +28,7 @@ * texture where the first four texels are cleared to known values * using separate calls to glClearTexSubImage. The values are chosen * to potentially trigger problems with signed conversions. The rest - * of the texture is initalised to zeroes. The textures are then read + * of the texture is initialised to zeroes. The textures are then read * back with glGetTexImage and compared with the expected values. */ diff --git a/tests/spec/arb_clear_texture/supported-formats.c b/tests/spec/arb_clear_texture/supported-formats.c new file mode 100644 index 000000000..e2eca537b --- /dev/null +++ b/tests/spec/arb_clear_texture/supported-formats.c @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2023 Intel Corporation + * + * 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 supported-formats.c + * + * Test using GL_CLEAR_COLOR with a range of formats. + */ + +#include "common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_RGB; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +static const GLenum valid_targets[] = { + GL_TEXTURE_1D, + GL_TEXTURE_1D_ARRAY, + GL_TEXTURE_2D, + GL_TEXTURE_2D_ARRAY, + GL_TEXTURE_2D_MULTISAMPLE, + GL_TEXTURE_2D_MULTISAMPLE_ARRAY, + GL_TEXTURE_3D, + GL_TEXTURE_CUBE_MAP, + GL_TEXTURE_CUBE_MAP_ARRAY, + GL_TEXTURE_RECTANGLE, +}; + +static const GLenum invalid_targets[] = { + GL_RENDERBUFFER, + GL_TEXTURE_BUFFER, + GL_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3, + GL_COLOR_ATTACHMENT4, + GL_COLOR_ATTACHMENT5, + GL_COLOR_ATTACHMENT6, + GL_COLOR_ATTACHMENT7, + GL_COLOR_ATTACHMENT8, + GL_COLOR_ATTACHMENT9, + GL_COLOR_ATTACHMENT10, + GL_COLOR_ATTACHMENT11, + GL_COLOR_ATTACHMENT12, + GL_COLOR_ATTACHMENT13, + GL_COLOR_ATTACHMENT14, + GL_COLOR_ATTACHMENT15, + GL_DEPTH_ATTACHMENT, + GL_STENCIL_ATTACHMENT, + GL_TEXTURE_4D_SGIS, + GL_TEXTURE_RENDERBUFFER_NV, +}; + +static const GLenum valid_internal_formats[] = { + /* Base/unsized internal format (from Table 8.11) */ + GL_DEPTH_COMPONENT, + GL_DEPTH_STENCIL, + GL_RED, + GL_RG, + GL_RGB, + GL_RGBA, + GL_STENCIL_INDEX, + /* Table 8.12 */ + GL_R8, + GL_R8_SNORM, + GL_R16, + GL_R16_SNORM, + GL_RG8, + GL_RG8_SNORM, + GL_RG16, + GL_RG16_SNORM, + GL_R3_G3_B2, + GL_RGB4, + GL_RGB5, + GL_RGB8, + GL_RGB8_SNORM, + GL_RGB10, + GL_RGB12, + GL_RGB16, + GL_RGB16_SNORM, + GL_RGBA2, + GL_RGBA4, + GL_RGB5_A1, + GL_RGBA8, + GL_RGBA8_SNORM, + GL_RGB10_A2, + GL_RGB10_A2UI, + GL_RGBA12, + GL_RGBA16, + GL_RGBA16_SNORM, + GL_SRGB8, + GL_SRGB8_ALPHA8, + GL_R16F, + GL_RG16F, + GL_RGB16F, + GL_RGBA16F, + GL_R32F, + GL_RG32F, + GL_RGB32F, + GL_RGBA32F, + GL_R11F_G11F_B10F, + GL_RGB9_E5, + GL_R8I, + GL_R8UI, + GL_R16I, + GL_R16UI, + GL_R32I, + GL_R32UI, + GL_RG8I, + GL_RG16I, + GL_RG16UI, + GL_RG32I, + GL_RG32UI, + GL_RGB8I, + GL_RGB8UI, + GL_RGB16I, + GL_RGB16UI, + GL_RGB32I, + GL_RGB32UI, + GL_RGBA8I, + GL_RGBA8UI, + GL_RGBA16I, + GL_RGBA16UI, + GL_RGBA32I, + GL_RGBA32UI, + /* Table 8.13 */ + GL_DEPTH_COMPONENT16, + GL_DEPTH_COMPONENT24, + GL_DEPTH_COMPONENT32, + GL_DEPTH_COMPONENT32F, + GL_DEPTH24_STENCIL8, + GL_DEPTH32F_STENCIL8, + GL_STENCIL_INDEX1, + GL_STENCIL_INDEX4, + GL_STENCIL_INDEX8, + GL_STENCIL_INDEX16 +}; + +static const GLenum invalid_internal_formats[] = { + /* Table 8.14 */ + GL_COMPRESSED_RED, + GL_COMPRESSED_RG, + GL_COMPRESSED_RGB, + GL_COMPRESSED_RGBA, + GL_COMPRESSED_SRGB, + GL_COMPRESSED_SRGB_ALPHA, + GL_COMPRESSED_RED_RGTC1, + GL_COMPRESSED_SIGNED_RED_RGTC1, + GL_COMPRESSED_RG_RGTC2, + GL_COMPRESSED_SIGNED_RG_RGTC2, + GL_COMPRESSED_RGBA_BPTC_UNORM, + GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, + GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, + GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, + GL_COMPRESSED_RGB8_ETC2, + GL_COMPRESSED_SRGB8_ETC2, + GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, + GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, + GL_COMPRESSED_RGBA8_ETC2_EAC, + GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, + GL_COMPRESSED_R11_EAC, + GL_COMPRESSED_SIGNED_R11_EAC, + GL_COMPRESSED_RG11_EAC, + GL_COMPRESSED_SIGNED_RG11_EAC +}; + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} + +static bool +try(const GLenum *targets, unsigned num_targets, + const GLenum *pinternal_formats, unsigned num_formats, + GLenum expected_result) +{ + bool pass = true; + + for (unsigned i = 0; i < num_targets; i++) { + for (unsigned j = 0; j < num_formats; j++) { + GLint param; + GLint64 param64; + + glGetInternalformativ(targets[i], + pinternal_formats[j], + GL_CLEAR_TEXTURE, + 1, + ¶m); + + glGetInternalformati64v(targets[i], + pinternal_formats[j], + GL_CLEAR_TEXTURE, + 1, + ¶m64); + + bool test = (expected_result == param); + bool test64 = (expected_result == param64); + + if (test && test64) + continue; + + fprintf(stderr, + " Failing case was " + "Result: %s NOT %s\n" + "target = %s, internal format = %s. \n", + piglit_get_gl_enum_name(param), + piglit_get_gl_enum_name(expected_result), + piglit_get_gl_enum_name(targets[i]), + piglit_get_gl_enum_name(pinternal_formats[j])); + + if (!test) + fprintf(stderr, + " Calling glGetInternalformativ\n"); + + if (!test64) + fprintf(stderr, + " Calling glGetInternalformati64v\n"); + + pass = false; + } + } + + return pass; +} + +static bool +check_supported_formats() +{ + bool pass = true; + + pass = try(valid_targets, ARRAY_SIZE(valid_targets), valid_internal_formats, + ARRAY_SIZE(valid_internal_formats), GL_FULL_SUPPORT) + && pass; + pass = try(invalid_targets, ARRAY_SIZE(invalid_targets), + valid_internal_formats, ARRAY_SIZE(valid_internal_formats), GL_NONE) + && pass; + pass = try(valid_targets, ARRAY_SIZE(valid_targets), + invalid_internal_formats, ARRAY_SIZE(invalid_internal_formats), GL_NONE) + && pass; + + return pass; +} + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_ARB_clear_texture"); + piglit_require_extension("GL_ARB_internalformat_query2"); + + piglit_report_result(check_supported_formats() ? + PIGLIT_PASS : + PIGLIT_FAIL); +}
\ No newline at end of file diff --git a/tests/spec/arb_clip_control/clip-control-depth-precision.c b/tests/spec/arb_clip_control/clip-control-depth-precision.c index 61282a0ad..1a5433e8e 100644 --- a/tests/spec/arb_clip_control/clip-control-depth-precision.c +++ b/tests/spec/arb_clip_control/clip-control-depth-precision.c @@ -40,7 +40,7 @@ * This extension avoids adding a constant number even in an intermediate * step which would destroy the effective depth precision possible with * the floating point depth buffers. - * Roughtly in numbers: + * Roughly in numbers: * Two fragments at 5000001 and 5000000 \about 5000001*(1 - eps) distance * from the eye point should yield to different values in the depth buffer. * The same goes for about any fragment distance x that you should be able diff --git a/tests/spec/arb_clip_control/clip-control.c b/tests/spec/arb_clip_control/clip-control.c index 020ea0aa2..5a9466a73 100644 --- a/tests/spec/arb_clip_control/clip-control.c +++ b/tests/spec/arb_clip_control/clip-control.c @@ -225,7 +225,7 @@ draw_test(void) pass = piglit_probe_pixel_depth(5, 5, 1.0) && pass; - /* Defaut depth rage all clip control combinations */ + /* Default depth rage all clip control combinations */ pass = test_patches(GL_LOWER_LEFT, GL_NEGATIVE_ONE_TO_ONE, near, far, 10) && pass; pass = test_patches(GL_LOWER_LEFT, GL_ZERO_TO_ONE, diff --git a/tests/spec/arb_color_buffer_float/mrt.c b/tests/spec/arb_color_buffer_float/mrt.c index 73166f728..ee72f0c63 100644 --- a/tests/spec/arb_color_buffer_float/mrt.c +++ b/tests/spec/arb_color_buffer_float/mrt.c @@ -132,17 +132,10 @@ test() unsigned init() { - GLint num; - piglit_require_extension("GL_ARB_vertex_program"); piglit_require_extension("GL_ARB_fragment_program"); piglit_require_extension("GL_ARB_draw_buffers"); - - glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &num); - if (num < 2) { - printf("Test requires 2 draw buffers, found %d\n", num); - piglit_report_result(PIGLIT_SKIP); - } + piglit_require_minimum_getinteger(GL_MAX_DRAW_BUFFERS_ARB, 2); mrt_vp = piglit_compile_program(GL_VERTEX_PROGRAM_ARB, mrt_vp_string); mrt_fp = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, mrt_fp_string); diff --git a/tests/spec/arb_compute_shader/compute-and-render-bug-109630.c b/tests/spec/arb_compute_shader/compute-and-render-bug-109630.c index e6ae51570..de3914fb9 100644 --- a/tests/spec/arb_compute_shader/compute-and-render-bug-109630.c +++ b/tests/spec/arb_compute_shader/compute-and-render-bug-109630.c @@ -27,7 +27,7 @@ * Test verifies that after compute workload geometry renders fine. * This exercises hardware issue in Intel's GEN9 GPU which resulted * in geometry flickering see https://bugs.freedesktop.org/show_bug.cgi?id=109630 - * There is no guarantied way to reproduce the issue but to run the + * There is no guaranteed way to reproduce the issue but to run the * core part of the test many times. * * \author Andrii Kryvytskyi <andrii.o.kryvytskyi@globallogic.com> @@ -157,7 +157,7 @@ piglit_display(void) { glFinish(); if (!piglit_probe_pixel_rgba(0, 0, expected)) { - printf("Failed on interation #%d \n", i); + printf("Failed on iteration #%d \n", i); pass = false; break; } diff --git a/tests/spec/arb_copy_image/CMakeLists.gl.txt b/tests/spec/arb_copy_image/CMakeLists.gl.txt index 304148c95..cd6b5264a 100644 --- a/tests/spec/arb_copy_image/CMakeLists.gl.txt +++ b/tests/spec/arb_copy_image/CMakeLists.gl.txt @@ -11,6 +11,7 @@ link_libraries ( piglit_add_executable (arb_copy_image-api_errors api_errors.c) piglit_add_executable (arb_copy_image-format-swizzle format-swizzle.c) piglit_add_executable (arb_copy_image-formats formats.c) +piglit_add_executable (arb_copy_image-levels-copy levels-copy.c) piglit_add_executable (arb_copy_image-simple simple.c) piglit_add_executable (arb_copy_image-srgb-copy srgb-copy.c) piglit_add_executable (arb_copy_image-targets targets.c) diff --git a/tests/spec/arb_copy_image/api_errors.c b/tests/spec/arb_copy_image/api_errors.c index 75cd27439..b144d60c1 100644 --- a/tests/spec/arb_copy_image/api_errors.c +++ b/tests/spec/arb_copy_image/api_errors.c @@ -241,7 +241,7 @@ test_compressed_alignment_errors() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); - /* Check for alignment constaints */ + /* Check for alignment constraints */ /* bad width = 21 */ glCopyImageSubData(tex[0], GL_TEXTURE_2D, 0, 0, 0, 0, tex[1], GL_TEXTURE_2D, 0, 0, 0, 0, 21, 24, 1); diff --git a/tests/spec/arb_copy_image/formats.c b/tests/spec/arb_copy_image/formats.c index 95bbd04d7..6de6e7780 100644 --- a/tests/spec/arb_copy_image/formats.c +++ b/tests/spec/arb_copy_image/formats.c @@ -327,7 +327,7 @@ piglit_init(int argc, char **argv) if (src_format_arg) { /* Since we know the source format, we know the number of - * bits per texel, so we can restrict the ammount of random + * bits per texel, so we can restrict the amount of random * data we generate. */ Bpp = src_format_arg->bytes; @@ -455,7 +455,7 @@ setup_test_data(const struct texture_format *src_format, for (j = 0; j < samples; ++j) { src_image = src_data + (j * image_size); res_image = res_data + (j * image_size); - /* Copy the center TEX_SIZE/2 x TEX_SIZE/2 pixels froms + /* Copy the center TEX_SIZE/2 x TEX_SIZE/2 pixels forms * src_data to res_data */ memcpy_rect(src_image, stride, TEX_SIZE/4, TEX_SIZE/4, @@ -563,7 +563,7 @@ load_compare_program(const struct texture_format *format) } else if (compare == &icomp) { gtype = "i"; } else { - assert(!"Invalid comparison fucntion"); + assert(!"Invalid comparison function"); gtype = ""; } diff --git a/tests/spec/arb_copy_image/levels-copy.c b/tests/spec/arb_copy_image/levels-copy.c new file mode 100644 index 000000000..9df1461c8 --- /dev/null +++ b/tests/spec/arb_copy_image/levels-copy.c @@ -0,0 +1,290 @@ +/* Copyright © 2020 Intel Corporation + * + * 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 layers-copy.c + * + * Tests that glCopyImageSubData correctly copies all levels of a texture. + * Also tests that the order in which levels are initialized doesn't affect + * the copying (some drivers, e.g. gallium drivers, may be sensitive to the + * initialization order). + */ + +#include "piglit-util-gl.h" +#include <math.h> + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 13; + + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} + +static const int tex_default_width = 32; +static const int tex_default_height = 32; +static const int tex_default_depth = 8; +static const int tex_default_levels = 6; + +static int illegal_levels_amount = 0; + +struct image { + GLuint texture; + GLenum target; + int levels; + int width, height, depth; +}; + +static void +get_img_dims(struct image *img, int level, + int *width, int *height, int *depth) +{ + *width = MAX2(img->width >> level, 1); + *height = MAX2(img->height >> level, 1); + *depth = MAX2(img->depth >> level, 1); + + switch (img->target) { + case GL_TEXTURE_1D: + case GL_TEXTURE_1D_ARRAY: + *height = 1; + *depth = 1; + break; + + case GL_TEXTURE_CUBE_MAP: + *depth = 6; + break; + + case GL_TEXTURE_2D: + case GL_TEXTURE_2D_ARRAY: + *depth = 1; + break; + } +} + +static void +init_image(struct image *img, GLenum texture_type, + int width, int height, int depth, int levels) +{ + img->target = texture_type; + + img->width = width; + img->height = height; + img->depth = depth; + img->levels = levels; + + get_img_dims(img, 0, &img->width, &img->height, &img->depth); + + glGenTextures(1, &img->texture); + glBindTexture(img->target, img->texture); + glTexParameteri(img->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(img->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); +} + +static void +tex_image(struct image *img, int level, bool upload_data) +{ + glBindTexture(img->target, img->texture); + + int width, height, depth; + get_img_dims(img, level, &width, &height, &depth); + + GLuint *data = NULL; + if (upload_data) { + data = malloc(width * height * depth * sizeof(GLuint)); + for (int i = 0; i < width * height * depth; i++) { + data[i] = 0xFF / (level + 1); + } + } + + switch (img->target) { + case GL_TEXTURE_1D: + glTexImage1D(img->target, level, + GL_RGBA8, width, 0, + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data); + break; + + case GL_TEXTURE_CUBE_MAP: + for (int k = 0; k < 6; ++k) { + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + k, level, + GL_RGBA8, width, height, 0, + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, + data); + } + break; + + case GL_TEXTURE_2D: + case GL_TEXTURE_1D_ARRAY: + glTexImage2D(img->target, level, + GL_RGBA8, width, height, 0, + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data); + break; + + case GL_TEXTURE_3D: + case GL_TEXTURE_2D_ARRAY: + glTexImage3D(img->target, level, + GL_RGBA8, width, height, depth, 0, + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data); + break; + default: + assert(!"Invalid target"); + } + + free(data); +} + +static bool +check_image(GLenum target_type, int level, int data_size) +{ + bool pass = true; + GLuint expected = 0xFF / (level + 1); + + GLuint *data = malloc(data_size * sizeof(GLuint)); + glGetTexImage(target_type, level, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data); + + if(level < tex_default_levels) /*Skip illegal levels*/ + { + for (int i = 0; i < data_size; i++) { + if (data[i] != expected) { + pass = false; + fprintf(stderr, "%s: level %d, texel idx %d (%d total) " + "comparison failed (%d != %d)\n", + piglit_get_gl_enum_name(target_type), + level, i, data_size, data[i], expected); + break; + } + } + } + + free(data); + + return pass; +} + +enum tex_init_order { + TEX_ORDER_FORWARD, + TEX_ORDER_BACKWARD, + + TEX_ORDER_END, +}; + +static bool +run_test(GLenum target_type, enum tex_init_order init_order) +{ + struct image srcImg, dstImg; + bool pass = true; + + init_image(&srcImg, target_type, tex_default_width, tex_default_height, + tex_default_depth, tex_default_levels + illegal_levels_amount); + init_image(&dstImg, target_type, tex_default_width, tex_default_height, + tex_default_depth, tex_default_levels + illegal_levels_amount); + + if (init_order == TEX_ORDER_FORWARD) { + for(int level = 0; level < srcImg.levels; level++) { + tex_image(&srcImg, level, true); + tex_image(&dstImg, level, false); + } + } else { + for(int level = srcImg.levels - 1; level >= 0; level--) { + tex_image(&srcImg, level, true); + tex_image(&dstImg, level, false); + } + } + + for(int level = 0; level < srcImg.levels; level++) { + int width, height, depth; + get_img_dims(&srcImg, level, &width, &height, &depth); + + glCopyImageSubData(srcImg.texture, target_type, level, 0, 0, 0, dstImg.texture, + target_type, level, 0, 0, 0, width, height, depth); + } + + for(int level = 0; level < srcImg.levels; level++) { + int width, height, depth; + get_img_dims(&srcImg, level, &width, &height, &depth); + + glBindTexture(target_type, dstImg.texture); + + if (target_type == GL_TEXTURE_CUBE_MAP) { + for (int k = 0; k < 6; ++k) { + pass = check_image(GL_TEXTURE_CUBE_MAP_POSITIVE_X + k, + level, width * height) && pass; + } + } else { + pass = check_image(target_type, level, width * height * depth) && pass; + } + } + + glDeleteTextures(1, &srcImg.texture); + glDeleteTextures(1, &dstImg.texture); + + piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL, + "Target type: %s, width: %d, height: %d, depth: %d, levels: %d, init order: %s", + piglit_get_gl_enum_name(target_type), srcImg.width, srcImg.height, + srcImg.depth, srcImg.levels, + init_order == TEX_ORDER_FORWARD ? "'forward'" : "'backward'"); + + return pass; +} + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_ARB_copy_image"); + + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "add-illegal-levels") == 0) { + illegal_levels_amount = 2; + break; + } + } + /* When ran with 'add-illegal-levels' argument, + * we generate 2 more mipmap levels than allowed by texture size. + * Which can possibly corrupt data of existing layers. + * We don't check the data correctness of illegal levels, since + * spec doesn't say what should be in them. + */ + + bool pass = true; + + for (enum tex_init_order order = TEX_ORDER_FORWARD; order < TEX_ORDER_END; order++) { + pass = run_test(GL_TEXTURE_1D, order) && pass; + pass = run_test(GL_TEXTURE_2D, order) && pass; + pass = run_test(GL_TEXTURE_3D, order) && pass; + + if (piglit_is_extension_supported("GL_EXT_texture_array")) { + pass = run_test(GL_TEXTURE_1D_ARRAY, order) && pass; + pass = run_test(GL_TEXTURE_2D_ARRAY, order) && pass; + } + + if (piglit_is_extension_supported("GL_ARB_texture_cube_map")) { + pass = run_test(GL_TEXTURE_CUBE_MAP, order) && pass; + } + } + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/arb_cull_distance/exceed-limits.c b/tests/spec/arb_cull_distance/exceed-limits.c index d7704d552..561d59e62 100644 --- a/tests/spec/arb_cull_distance/exceed-limits.c +++ b/tests/spec/arb_cull_distance/exceed-limits.c @@ -95,7 +95,7 @@ piglit_init(int argc, char **argv) piglit_require_gl_version(30); piglit_require_extension("GL_ARB_cull_distance"); - vs = piglit_compile_shader_text_nothrow(GL_VERTEX_SHADER, vert, true); + vs = piglit_compile_shader_text_nothrow(GL_VERTEX_SHADER, vert, false); if (vs == 0) piglit_report_result(PIGLIT_PASS); diff --git a/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-different.shader_test b/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-different.shader_test index 27fff6ff3..24468f3bf 100644 --- a/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-different.shader_test +++ b/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-different.shader_test @@ -5,7 +5,7 @@ # stage, as described in section 13.5. # # This test checks that the arrays gl_ClipDistance and gl_CullDistance only -# interfer by gl_MaxCombinedClipAndCullDistances and not by its entrys. +# interfere by gl_MaxCombinedClipAndCullDistances and not by its entries. [require] GLSL >= 1.30 diff --git a/tests/spec/arb_direct_state_access/compressedtextureimage.c b/tests/spec/arb_direct_state_access/compressedtextureimage.c index 7b93fda8f..872340c4a 100644 --- a/tests/spec/arb_direct_state_access/compressedtextureimage.c +++ b/tests/spec/arb_direct_state_access/compressedtextureimage.c @@ -121,7 +121,7 @@ display_mipmaps(int x, int y) glEnable(GL_TEXTURE_2D); - /* Disply all the mipmap levels */ + /* Display all the mipmap levels */ for (i = SIZE; i > 0; i /= 2) { piglit_draw_rect_tex(x, y, i, i, 0, 0, 1, 1); diff --git a/tests/spec/arb_direct_state_access/getcompressedtextureimage.c b/tests/spec/arb_direct_state_access/getcompressedtextureimage.c index 4206a4714..a28d9f83a 100644 --- a/tests/spec/arb_direct_state_access/getcompressedtextureimage.c +++ b/tests/spec/arb_direct_state_access/getcompressedtextureimage.c @@ -223,7 +223,7 @@ getTexImage(bool doPBO, GLenum target, GLubyte *data, */ if (target == GL_TEXTURE_CUBE_MAP) comp_size *= num_faces; - printf("\tThe size of the texture in bytes is %d.\n", comp_size); + printf("\the size of the texture in bytes is %d.\n", comp_size); /* Show the uncompressed data. */ show_image(data, num_layers * num_faces, "Data Before Compression"); diff --git a/tests/spec/arb_direct_state_access/gettextureimage-targets.c b/tests/spec/arb_direct_state_access/gettextureimage-targets.c index 4ebb73f59..05ffc7609 100644 --- a/tests/spec/arb_direct_state_access/gettextureimage-targets.c +++ b/tests/spec/arb_direct_state_access/gettextureimage-targets.c @@ -58,7 +58,7 @@ init_layer_data(GLubyte *layer_data, int num_layers) int b = (z + 1) * 255 / (num_layers - 1); int a = x ^ y ^ z; - /* each 4x4 block constains only one color (for S3TC) */ + /* each 4x4 block contains only one color (for S3TC) */ for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { data[((y + j) * IMAGE_WIDTH + x diff --git a/tests/spec/arb_draw_buffers/state_change.c b/tests/spec/arb_draw_buffers/state_change.c index e067d77a9..e9cf67899 100644 --- a/tests/spec/arb_draw_buffers/state_change.c +++ b/tests/spec/arb_draw_buffers/state_change.c @@ -131,13 +131,7 @@ piglit_display(void) void piglit_init(int argc, char **argv) { - GLint i; - piglit_require_extension("GL_EXT_framebuffer_object"); piglit_require_extension("GL_ARB_draw_buffers"); - glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &i); - if (i < 2) { - printf("2 draw buffers required, %d reported.\n", i); - piglit_report_result(PIGLIT_SKIP); - } + piglit_require_minimum_getinteger(GL_MAX_DRAW_BUFFERS_ARB, 2); } diff --git a/tests/spec/arb_draw_buffers_blend/state_set_get.c b/tests/spec/arb_draw_buffers_blend/state_set_get.c index a8e2f2630..280994e80 100644 --- a/tests/spec/arb_draw_buffers_blend/state_set_get.c +++ b/tests/spec/arb_draw_buffers_blend/state_set_get.c @@ -88,7 +88,7 @@ set_state(int buffer, } if (test_dlist) { - glEndList(list); + glEndList(); glCallList(list); glDeleteLists(list, 1); } @@ -133,7 +133,7 @@ set_state_all_buffers(GLenum srcRGB, GLenum srcA, } if (test_dlist) { - glEndList(list); + glEndList(); glCallList(list); glDeleteLists(list, 1); } diff --git a/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-10.frag b/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-10.frag index ba7ca4e7f..3cfe18859 100644 --- a/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-10.frag +++ b/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-10.frag @@ -20,7 +20,7 @@ // * if more than one varying out variable is bound to the same // number and index; or // -// * if the explicit binding assigments do not leave enough space +// * if the explicit binding assignments do not leave enough space // for the linker to automatically assign a location for a varying // out array, which requires multiple contiguous locations." diff --git a/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-11.frag b/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-11.frag index e9a1f3878..3e6238c35 100644 --- a/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-11.frag +++ b/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-11.frag @@ -20,7 +20,7 @@ // * if more than one varying out variable is bound to the same // number and index; or // -// * if the explicit binding assigments do not leave enough space +// * if the explicit binding assignments do not leave enough space // for the linker to automatically assign a location for a varying // out array, which requires multiple contiguous locations." // diff --git a/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-13.frag b/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-13.frag index 413778a3d..9f1799347 100644 --- a/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-13.frag +++ b/tests/spec/arb_explicit_attrib_location/1.10/compiler/layout-13.frag @@ -20,7 +20,7 @@ // * if more than one varying out variable is bound to the same // number and index; or // -// * if the explicit binding assigments do not leave enough space +// * if the explicit binding assignments do not leave enough space // for the linker to automatically assign a location for a varying // out array, which requires multiple contiguous locations." diff --git a/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-10.frag b/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-10.frag index 610976b13..6231e303b 100644 --- a/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-10.frag +++ b/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-10.frag @@ -20,7 +20,7 @@ // * if more than one varying out variable is bound to the same // number and index; or // -// * if the explicit binding assigments do not leave enough space +// * if the explicit binding assignments do not leave enough space // for the linker to automatically assign a location for a varying // out array, which requires multiple contiguous locations." diff --git a/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-11.frag b/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-11.frag index 1720d6635..342b01fa2 100644 --- a/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-11.frag +++ b/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-11.frag @@ -20,7 +20,7 @@ // * if more than one varying out variable is bound to the same // number and index; or // -// * if the explicit binding assigments do not leave enough space +// * if the explicit binding assignments do not leave enough space // for the linker to automatically assign a location for a varying // out array, which requires multiple contiguous locations." // diff --git a/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-13.frag b/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-13.frag index c6e6d049a..8a4c55a19 100644 --- a/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-13.frag +++ b/tests/spec/arb_explicit_attrib_location/1.20/compiler/layout-13.frag @@ -20,7 +20,7 @@ // * if more than one varying out variable is bound to the same // number and index; or // -// * if the explicit binding assigments do not leave enough space +// * if the explicit binding assignments do not leave enough space // for the linker to automatically assign a location for a varying // out array, which requires multiple contiguous locations." diff --git a/tests/spec/arb_explicit_attrib_location/overlapping-locations-input-attribs.c b/tests/spec/arb_explicit_attrib_location/overlapping-locations-input-attribs.c index ec6df3b17..f107d80c0 100644 --- a/tests/spec/arb_explicit_attrib_location/overlapping-locations-input-attribs.c +++ b/tests/spec/arb_explicit_attrib_location/overlapping-locations-input-attribs.c @@ -36,7 +36,7 @@ * in this case." * * Aliasing of vertex input variables is allowed in: OpenGL - * 2.0 (and above) and OpenGL ES 2.0. This test varifies + * 2.0 (and above) and OpenGL ES 2.0. This test verifies * that aliasing can be used successfully in a vertex shader * under the constraints defined in OpenGL spec. */ diff --git a/tests/spec/arb_explicit_uniform_location/linker/set-location-to-sampler.shader_test b/tests/spec/arb_explicit_uniform_location/linker/set-location-to-sampler.shader_test index 31c0c693e..965f809cd 100644 --- a/tests/spec/arb_explicit_uniform_location/linker/set-location-to-sampler.shader_test +++ b/tests/spec/arb_explicit_uniform_location/linker/set-location-to-sampler.shader_test @@ -1,5 +1,5 @@ # -# Tests that an opaque type (sampler) gets a location succesfully +# Tests that an opaque type (sampler) gets a location successfully # [require] GLSL >= 1.30 diff --git a/tests/spec/arb_fragment_layer_viewport/layer-gs-write-simple.shader_test b/tests/spec/arb_fragment_layer_viewport/layer-gs-write-simple.shader_test index bfafcb1f2..a43293581 100644 --- a/tests/spec/arb_fragment_layer_viewport/layer-gs-write-simple.shader_test +++ b/tests/spec/arb_fragment_layer_viewport/layer-gs-write-simple.shader_test @@ -39,15 +39,9 @@ clear color 0.0 0.0 0.0 0.0 clear uniform int layer 0 -draw rect -1 -1 1 1 +draw rect -1 -1 1 2 uniform int layer 1 -draw rect 0 -1 1 1 - -uniform int layer 10000 -draw rect -1 0 1 1 - -uniform int layer -10000 -draw rect 0 0 1 1 +draw rect 0 -1 1 2 probe all rgb 0.0 1.0 0.0 diff --git a/tests/spec/arb_fragment_layer_viewport/layer-gs-writes-out-of-range.shader_test b/tests/spec/arb_fragment_layer_viewport/layer-gs-writes-out-of-range.shader_test deleted file mode 100644 index 06a859b64..000000000 --- a/tests/spec/arb_fragment_layer_viewport/layer-gs-writes-out-of-range.shader_test +++ /dev/null @@ -1,72 +0,0 @@ -[require] -GLSL >= 1.50 -GL_ARB_fragment_layer_viewport -GL_ARB_shader_atomic_counters - -# -# Ensure that the fragment stage reads the same value for gl_Layer as was -# written by the geometry stage. -# -# This test covers the case where the value written is out of range. -# - -[vertex shader] -#version 150 -in vec4 piglit_vertex; - -void main() -{ - gl_Position = piglit_vertex; -} - -[geometry shader] -#version 150 - -layout(triangles) in; -layout(triangle_strip, max_vertices=9) out; - -const int layers[] = int[]( -1, 4, 2048 ); -flat out int layer_written; - -void main() -{ - for (int layer = 0; layer < layers.length(); layer++) { - - for (int i = 0; i < 3; i++) { - gl_Position = gl_in[i].gl_Position; - layer_written = layers[layer]; - gl_Layer = layers[layer]; - EmitVertex(); - } - - EndPrimitive(); - } -} - -[fragment shader] -#version 150 -#extension GL_ARB_fragment_layer_viewport: require -#extension GL_ARB_shader_atomic_counters: require - -flat in int layer_written; - -layout(binding = 0) uniform atomic_uint mismatches; - -void main() -{ - if (layer_written != gl_Layer) - atomicCounterIncrement(mismatches); - - gl_FragColor = vec4(0); -} - -[test] -texture junk 2DArray 0 ( 64 , 64 , 4 ) -fb tex layered 0 - -atomic counters 1 - - -draw rect -1 -1 2 2 - -probe atomic counter 0 == 0 diff --git a/tests/spec/arb_fragment_layer_viewport/layer-vs-gs-write-simple.shader_test b/tests/spec/arb_fragment_layer_viewport/layer-vs-gs-write-simple.shader_test index aab8a5b6e..2b7210eab 100644 --- a/tests/spec/arb_fragment_layer_viewport/layer-vs-gs-write-simple.shader_test +++ b/tests/spec/arb_fragment_layer_viewport/layer-vs-gs-write-simple.shader_test @@ -50,15 +50,9 @@ clear color 0.0 0.0 0.0 0.0 clear uniform int layer 0 -draw rect -1 -1 1 1 +draw rect -1 -1 1 2 uniform int layer 1 -draw rect 0 -1 1 1 - -uniform int layer 10000 -draw rect -1 0 1 1 - -uniform int layer -10000 -draw rect 0 0 1 1 +draw rect 0 -1 1 2 probe all rgb 0.0 1.0 0.0 diff --git a/tests/spec/arb_fragment_layer_viewport/layer-vs-write-gs-no-write-simple.shader_test b/tests/spec/arb_fragment_layer_viewport/layer-vs-write-gs-no-write-simple.shader_test index 3dfc2c447..30a229730 100644 --- a/tests/spec/arb_fragment_layer_viewport/layer-vs-write-gs-no-write-simple.shader_test +++ b/tests/spec/arb_fragment_layer_viewport/layer-vs-write-gs-no-write-simple.shader_test @@ -2,6 +2,7 @@ GLSL >= 1.50 GL_ARB_fragment_layer_viewport GL_AMD_vertex_shader_layer +ignore_missing_uniforms [vertex shader] #version 140 diff --git a/tests/spec/arb_fragment_layer_viewport/layer-vs-write-simple.shader_test b/tests/spec/arb_fragment_layer_viewport/layer-vs-write-simple.shader_test index fe453fb17..d9f002aa3 100644 --- a/tests/spec/arb_fragment_layer_viewport/layer-vs-write-simple.shader_test +++ b/tests/spec/arb_fragment_layer_viewport/layer-vs-write-simple.shader_test @@ -34,15 +34,9 @@ clear color 0.0 0.0 0.0 0.0 clear uniform int layer 0 -draw rect -1 -1 1 1 +draw rect -1 -1 1 2 uniform int layer 1 -draw rect 0 -1 1 1 - -uniform int layer 10000 -draw rect -1 0 1 1 - -uniform int layer -10000 -draw rect 0 0 1 1 +draw rect 0 -1 1 2 probe all rgb 0.0 1.0 0.0 diff --git a/tests/spec/arb_fragment_layer_viewport/viewport-gs-writes-out-of-range.shader_test b/tests/spec/arb_fragment_layer_viewport/viewport-gs-writes-out-of-range.shader_test deleted file mode 100644 index 9418e161b..000000000 --- a/tests/spec/arb_fragment_layer_viewport/viewport-gs-writes-out-of-range.shader_test +++ /dev/null @@ -1,73 +0,0 @@ -[require] -GLSL >= 1.50 -GL_ARB_fragment_layer_viewport -GL_ARB_shader_atomic_counters - -# -# Ensure that the fragment stage reads the same value for gl_ViewportIndex as was -# written by the geometry stage. -# -# This test covers the case where the value written is out of range. -# - -[vertex shader] -#version 150 -in vec4 piglit_vertex; - -void main() -{ - gl_Position = piglit_vertex; -} - -[geometry shader] -#version 150 -#extension GL_ARB_viewport_array: require - -layout(triangles) in; -layout(triangle_strip, max_vertices=9) out; - -const int vps[] = int[]( -1, 16, 2048 ); -flat out int vp_written; - -void main() -{ - for (int vp = 0; vp < vps.length(); vp++) { - - for (int i = 0; i < 3; i++) { - gl_Position = gl_in[i].gl_Position; - vp_written = vps[vp]; - gl_ViewportIndex = vps[vp]; - EmitVertex(); - } - - EndPrimitive(); - } -} - -[fragment shader] -#version 150 -#extension GL_ARB_fragment_layer_viewport: require -#extension GL_ARB_shader_atomic_counters: require - -flat in int vp_written; - -layout(binding = 0) uniform atomic_uint mismatches; - -void main() -{ - if (vp_written != gl_ViewportIndex) - atomicCounterIncrement(mismatches); - - gl_FragColor = vec4(0); -} - -[test] -texture junk 2DArray 0 ( 64 , 64 , 1 ) -fb tex layered 0 - -atomic counters 1 - - -draw rect -1 -1 2 2 - -probe atomic counter 0 == 0 diff --git a/tests/spec/arb_fragment_layer_viewport/viewport-vs-write-gs-no-write-simple.shader_test b/tests/spec/arb_fragment_layer_viewport/viewport-vs-write-gs-no-write-simple.shader_test index faec9f07a..81d947a44 100644 --- a/tests/spec/arb_fragment_layer_viewport/viewport-vs-write-gs-no-write-simple.shader_test +++ b/tests/spec/arb_fragment_layer_viewport/viewport-vs-write-gs-no-write-simple.shader_test @@ -2,6 +2,7 @@ GLSL >= 1.50 GL_ARB_fragment_layer_viewport GL_AMD_vertex_shader_viewport_index +ignore_missing_uniforms [vertex shader] #version 140 diff --git a/tests/spec/arb_fragment_program_shadow/tex-shadow2dnotdepth.shader_test b/tests/spec/arb_fragment_program_shadow/tex-shadow2dnotdepth.shader_test new file mode 100644 index 000000000..d46a16358 --- /dev/null +++ b/tests/spec/arb_fragment_program_shadow/tex-shadow2dnotdepth.shader_test @@ -0,0 +1,41 @@ +[require] +GL_ARB_texture_rectangle +GL_ARB_fragment_program_shadow + +[vertex program] +!!ARBvp1.0 +TEMP texcoord; + +ADD texcoord.xyz, vertex.position.xyyy, {1}.x; +MUL texcoord.xyz, texcoord, {0.5}.x; +MOV texcoord.w, {0}.x; + +MOV result.position, vertex.position; +MOV result.texcoord[0], texcoord; +END + +[fragment program] +!!ARBfp1.0 +OPTION ARB_fragment_program_shadow; +TEX result.color, fragment.texcoord[0], texture[0], SHADOW2D; +END + +[test] +texture rgbw 0 (8, 8) +draw rect -1 -1 2 2 + +# Test fallback to a not shadow sampler for a not depth texture +# It is how AMD and NVIDIA work on Windows, and games might abuse this: +# https://gitlab.freedesktop.org/mesa/mesa/-/issues/8425 + +relative probe rgba (0.0, 0.0) (1.0, 0.0, 0.0, 1.0) +relative probe rgba (0.4, 0.4) (1.0, 0.0, 0.0, 1.0) + +relative probe rgba (1.0, 0.0) (0.0, 1.0, 0.0, 1.0) +relative probe rgba (0.6, 0.4) (0.0, 1.0, 0.0, 1.0) + +relative probe rgba (0.0, 1.0) (0.0, 0.0, 1.0, 1.0) +relative probe rgba (0.4, 0.6) (0.0, 0.0, 1.0, 1.0) + +relative probe rgba (1.0, 1.0) (1.0, 1.0, 1.0, 1.0) +relative probe rgba (0.6, 0.6) (1.0, 1.0, 1.0, 1.0)
\ No newline at end of file diff --git a/tests/spec/arb_framebuffer_object/GenerateMipmap-versus-READ_FRAMEBUFFER.c b/tests/spec/arb_framebuffer_object/GenerateMipmap-versus-READ_FRAMEBUFFER.c index cc24d17af..6d23c0ff3 100644 --- a/tests/spec/arb_framebuffer_object/GenerateMipmap-versus-READ_FRAMEBUFFER.c +++ b/tests/spec/arb_framebuffer_object/GenerateMipmap-versus-READ_FRAMEBUFFER.c @@ -70,7 +70,7 @@ piglit_init(int argc, char **argv) fprintf(stderr, "Either OpenGL 3.0, or GL_ARB_framebuffer_object, or " "GL_EXT_framebuffer_object and GL_EXT_framebuffer_blit " - "is requred.\n"); + "is required.\n"); piglit_report_result(PIGLIT_SKIP); } diff --git a/tests/spec/arb_framebuffer_object/fbo-drawbuffers-none.c b/tests/spec/arb_framebuffer_object/fbo-drawbuffers-none.c index f6a8a2044..ec3395f81 100644 --- a/tests/spec/arb_framebuffer_object/fbo-drawbuffers-none.c +++ b/tests/spec/arb_framebuffer_object/fbo-drawbuffers-none.c @@ -121,6 +121,7 @@ static const char *fs_template_write_different = static char *fs_write_different; static char *test_name, *prog_name; static GLuint fb, prog_write_all_red, prog_write_all_different; +bool (*run_test)(const GLenum drawbuffers[4]); static void @@ -422,8 +423,6 @@ print_usage_and_exit(void) void piglit_init(int argc, char **argv) { - int max_draw_bufs; - prog_name = malloc((strlen(argv[0]) + 1)); assert(prog_name); strcpy(prog_name, argv[0]); @@ -437,11 +436,42 @@ piglit_init(int argc, char **argv) piglit_require_gl_version(21); piglit_require_extension("GL_ARB_framebuffer_object"); + piglit_require_minimum_getinteger(GL_MAX_DRAW_BUFFERS_ARB, 4); - glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &max_draw_bufs); - if (max_draw_bufs < 4) { - puts("At least 4 draw buffers are required."); - piglit_report_result(PIGLIT_SKIP); + if (streq(test_name, "glClear")) { + run_test = &test_glClear; + } + else if (streq(test_name, "glClearBuffer")) { + piglit_require_gl_version(30); + run_test = &test_glClearBuffer; + } + else if (streq(test_name, "gl_FragColor")) { + run_test = &test_fragcolor; + } + else if (streq(test_name, "gl_FragData")) { + run_test = &test_fragdata; + } + else if (streq(test_name, "use_frag_out")) { + piglit_require_GLSL_version(130); + run_test = &test_fragout; + } + else if (streq(test_name, "glColorMaskIndexed")) { + piglit_require_extension("GL_EXT_draw_buffers2"); + run_test = &test_glColorMaskIndexed; + } + else if (streq(test_name, "glBlendFunci")) { + piglit_require_extension("GL_ARB_draw_buffers_blend"); + run_test = &test_glBlendFunci; + } + else if (streq(test_name, "glDrawPixels")) { + run_test = &test_glDrawPixels; + } + else if (streq(test_name, "glBlitFramebuffer")) { + run_test = &test_glBlitFramebuffer; + } + else { + printf("Unknown subtest: %s\n", test_name); + print_usage_and_exit(); } create_shaders(); @@ -460,41 +490,7 @@ piglit_display(void) glDrawBuffers(4, drawbuf_config[i]); - if (streq(test_name, "glClear")) { - pass = test_glClear(drawbuf_config[i]) && pass; - } - else if (streq(test_name, "glClearBuffer")) { - piglit_require_gl_version(30); - pass = test_glClearBuffer(drawbuf_config[i]) && pass; - } - else if (streq(test_name, "gl_FragColor")) { - pass = test_fragcolor(drawbuf_config[i]) && pass; - } - else if (streq(test_name, "gl_FragData")) { - pass = test_fragdata(drawbuf_config[i]) && pass; - } - else if (streq(test_name, "use_frag_out")) { - piglit_require_GLSL_version(130); - pass = test_fragout(drawbuf_config[i]) && pass; - } - else if (streq(test_name, "glColorMaskIndexed")) { - piglit_require_extension("GL_EXT_draw_buffers2"); - pass = test_glColorMaskIndexed(drawbuf_config[i]) && pass; - } - else if (streq(test_name, "glBlendFunci")) { - piglit_require_extension("GL_ARB_draw_buffers_blend"); - pass = test_glBlendFunci(drawbuf_config[i]) && pass; - } - else if (streq(test_name, "glDrawPixels")) { - pass = test_glDrawPixels(drawbuf_config[i]) && pass; - } - else if (streq(test_name, "glBlitFramebuffer")) { - pass = test_glBlitFramebuffer(drawbuf_config[i]) && pass; - } - else { - printf("Unknown subtest: %s\n", test_name); - print_usage_and_exit(); - } + pass = run_test(drawbuf_config[i]) && pass; } pass = piglit_check_gl_error(GL_NO_ERROR) && pass; diff --git a/tests/spec/arb_geometry_shader4/execution/program-parameter/vertices-out.c b/tests/spec/arb_geometry_shader4/execution/program-parameter/vertices-out.c index 4d23526a4..b4b7488c1 100644 --- a/tests/spec/arb_geometry_shader4/execution/program-parameter/vertices-out.c +++ b/tests/spec/arb_geometry_shader4/execution/program-parameter/vertices-out.c @@ -28,7 +28,7 @@ * variable number of output components. * * The value of GEOMETRY_VERTICES_OUT is limited by the implementation - * dependend constants MAX_GEOMETRY_OUTPUT_VERTICES and + * dependent constants MAX_GEOMETRY_OUTPUT_VERTICES and * MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS. * * From the ARB_geometry_shader4 spec (section Errors): @@ -126,7 +126,7 @@ test_geometry_vertices_out(const GLuint prog) * > MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS, the spec requires * ProgramParameter to throw an INVALID_VALUE and subsequent linking to * fail. - * But the number of output components can only be infered from the + * But the number of output components can only be inferred from the * geometry shader source (and a geometry shader might not even be * attached to the program object when ProgramParameter is called). * So, ignore any errors generated from ProgramParameter and only check diff --git a/tests/spec/arb_geometry_shader4/linker/2darray-vertex-index-oob.shader_test b/tests/spec/arb_geometry_shader4/linker/2darray-vertex-index-oob.shader_test index 60db7e918..05d0587e9 100644 --- a/tests/spec/arb_geometry_shader4/linker/2darray-vertex-index-oob.shader_test +++ b/tests/spec/arb_geometry_shader4/linker/2darray-vertex-index-oob.shader_test @@ -29,7 +29,7 @@ varying out float gs_out; void main() { - /* This sould fail at link time once the size of the outer dimension of + /* This should fail at link time once the size of the outer dimension of * gs_input (3) is known. */ float s = gs_input[3][0]; diff --git a/tests/spec/arb_get_program_binary/api-errors.c b/tests/spec/arb_get_program_binary/api-errors.c index 5b104bb43..9b1356502 100644 --- a/tests/spec/arb_get_program_binary/api-errors.c +++ b/tests/spec/arb_get_program_binary/api-errors.c @@ -23,7 +23,7 @@ /** * \file coverage.c - * Attempt quering every enum in the spec. Sanity check initial values. + * Attempt querying every enum in the spec. Sanity check initial values. * * GL_NUM_PROGRAM_BINARY_FORMATS and GL_PROGRAM_BINARY_FORMATS are not * covered by this test because they are heavily covered by the diff --git a/tests/spec/arb_get_program_binary/gpb-common.c b/tests/spec/arb_get_program_binary/gpb-common.c index 438e4992d..224173d5d 100644 --- a/tests/spec/arb_get_program_binary/gpb-common.c +++ b/tests/spec/arb_get_program_binary/gpb-common.c @@ -76,7 +76,7 @@ gpb_restore_program(GLuint prog, void *binary, GLsizei length, GLenum format) glProgramBinary(prog, format, binary, length); if (!piglit_check_gl_error(GL_NO_ERROR)) { fprintf(stderr, "glProgramBinary error " - "(should not happend according to spec.)\n"); + "(should not happen according to spec.)\n"); piglit_report_result(PIGLIT_FAIL); } diff --git a/tests/spec/arb_get_program_binary/retrievable_hint.c b/tests/spec/arb_get_program_binary/retrievable_hint.c index a81a9f63b..9d6e2c651 100644 --- a/tests/spec/arb_get_program_binary/retrievable_hint.c +++ b/tests/spec/arb_get_program_binary/retrievable_hint.c @@ -23,7 +23,7 @@ /** * \file coverage.c - * Attempt quering every enum in the spec. Sanity check initial values. + * Attempt querying every enum in the spec. Sanity check initial values. * * GL_NUM_PROGRAM_BINARY_FORMATS and GL_PROGRAM_BINARY_FORMATS are not * covered by this test because they are heavily covered by the diff --git a/tests/spec/arb_get_texture_sub_image/errors.c b/tests/spec/arb_get_texture_sub_image/errors.c index 4b99d1cc2..a733d6c20 100644 --- a/tests/spec/arb_get_texture_sub_image/errors.c +++ b/tests/spec/arb_get_texture_sub_image/errors.c @@ -125,7 +125,7 @@ test_buffer_size(void) if (!piglit_check_gl_error(GL_INVALID_OPERATION)) pass = false; - /* Test getting a quadrant, sufficent buffer size */ + /* Test getting a quadrant, sufficient buffer size */ glPixelStorei(GL_PACK_SKIP_ROWS, 0); glPixelStorei(GL_PACK_SKIP_PIXELS, 0); glPixelStorei(GL_PACK_ROW_LENGTH, 0); @@ -137,7 +137,7 @@ test_buffer_size(void) if (!piglit_check_gl_error(GL_NO_ERROR)) pass = false; - /* Test getting a quadrant, insufficent buffer size */ + /* Test getting a quadrant, insufficient buffer size */ glPixelStorei(GL_PACK_SKIP_ROWS, 0); glPixelStorei(GL_PACK_SKIP_PIXELS, 0); glPixelStorei(GL_PACK_ROW_LENGTH, 0); @@ -194,7 +194,7 @@ test_invalid_values(void) if (!piglit_check_gl_error(GL_INVALID_VALUE)) pass = false; - /* Test non-existant level */ + /* Test non-existent level */ glGetTextureSubImage(tex, 4, 0, 0, 0, /* offset */ 8, 8, 1, /* size */ diff --git a/tests/spec/arb_get_texture_sub_image/get.c b/tests/spec/arb_get_texture_sub_image/get.c index 4abf3a596..a0ba906f7 100644 --- a/tests/spec/arb_get_texture_sub_image/get.c +++ b/tests/spec/arb_get_texture_sub_image/get.c @@ -194,7 +194,7 @@ test_getsubimage(GLenum target, y1 = MAX2(1, mip_height / 3); z1 = MAX2(1, mip_depth / 3); if (intFormat == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) { - /* x1, y1 must be a multipe of 4 */ + /* x1, y1 must be a multiple of 4 */ x1 &= ~0x3; y1 &= ~0x3; } diff --git a/tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-bitfieldInsert-pow2-and-zero.shader_test b/tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-bitfieldInsert-pow2-and-zero.shader_test new file mode 100644 index 000000000..daf968d55 --- /dev/null +++ b/tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-bitfieldInsert-pow2-and-zero.shader_test @@ -0,0 +1,46 @@ +# Verify an optimization pattern that was added in mesa!19968 + +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader5 + +[vertex shader passthrough] + +[fragment shader] +#extension GL_ARB_gpu_shader5 : enable + +out vec4 color; + +uniform vec2 expected[4] = vec2[](vec2(0.0, 0.0), + vec2(16384.0, 0.0), + vec2(0.0, 4096.0), + vec2(16384.0, 4096.0)); + +void main() +{ + vec4 c = vec4(0.0, 1.0, 0.0, 1.0); + uint i = (uint(gl_FragCoord.x) & 1) + ((uint(gl_FragCoord.y) & 1) << 1); + + /* Result of bitfieldInsert(0, X, Y, 1) is either 0 or (1 << Y) + * depending on whether X is even or odd, respectively. + */ + + if (float(bitfieldInsert(0, uint(gl_FragCoord.x), 14, 1)) != + expected[i].x) { + c.x = 1.0; + c.y = 0.0; + } + + if (float(bitfieldInsert(0, uint(gl_FragCoord.y), 12, 1)) != + expected[i].y) { + c.y = 0.0; + c.z = 1.0; + } + + color = c; +} + +[test] +clear +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-ldexp.shader_test b/tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-ldexp.shader_test index 763e8bbf8..ea855c943 100644 --- a/tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-ldexp.shader_test +++ b/tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-ldexp.shader_test @@ -63,11 +63,6 @@ uniform ivec4 given_exponent 125 125 -128 -128 draw rect -1 -1 2 2 probe all rgba 0.0 1.0 0.0 1.0 -# Test underflow generates zero with sign of x. -uniform vec4 expected_float 0.0 -0.0 0.0 -0.0 -uniform vec4 given_float 0.0 -0.0 0.5 -0.5 -uniform ivec4 given_exponent -127 -127 -127 -127 -draw rect -1 -1 2 2 -probe all rgba 0.0 1.0 0.0 1.0 +# Underflow may flush to zero or not, so can't test that with this shader. # Overflow is undefined according to the GLSL spec, so nothing to test. diff --git a/tests/spec/arb_gpu_shader5/execution/built-in-functions/vs-ldexp.shader_test b/tests/spec/arb_gpu_shader5/execution/built-in-functions/vs-ldexp.shader_test index b819f8a10..9ad954a18 100644 --- a/tests/spec/arb_gpu_shader5/execution/built-in-functions/vs-ldexp.shader_test +++ b/tests/spec/arb_gpu_shader5/execution/built-in-functions/vs-ldexp.shader_test @@ -73,11 +73,6 @@ uniform ivec4 given_exponent 125 125 -128 -128 draw rect -1 -1 2 2 probe all rgba 0.0 1.0 0.0 1.0 -# Test underflow generates zero with sign of x. -uniform vec4 expected_float 0.0 -0.0 0.0 -0.0 -uniform vec4 given_float 0.0 -0.0 0.5 -0.5 -uniform ivec4 given_exponent -127 -127 -127 -127 -draw rect -1 -1 2 2 -probe all rgba 0.0 1.0 0.0 1.0 +# Underflow may flush to zero or not, so can't test that with this shader. # Overflow is undefined according to the GLSL spec, so nothing to test. diff --git a/tests/spec/arb_gpu_shader5/execution/instanced-inputs-built-in-variable.shader_test b/tests/spec/arb_gpu_shader5/execution/instanced-inputs-built-in-variable.shader_test index 8021ba03b..22181d1b3 100644 --- a/tests/spec/arb_gpu_shader5/execution/instanced-inputs-built-in-variable.shader_test +++ b/tests/spec/arb_gpu_shader5/execution/instanced-inputs-built-in-variable.shader_test @@ -1,5 +1,5 @@ # This test is essentially the same as the "instanced-inputs.shader_test" test -# except that it makes use of gl_Position between the vertx and geometry +# except that it makes use of gl_Position between the vertex and geometry # shader. Using gl_Position allows us to reproduce Mesa bug #96354. [require] diff --git a/tests/spec/arb_gpu_shader5/execution/sampler_array_indexing/fs-struct-nonconst-multiple-samplers.shader_test b/tests/spec/arb_gpu_shader5/execution/sampler_array_indexing/fs-struct-nonconst-multiple-samplers.shader_test index b717196d2..8e53c62db 100644 --- a/tests/spec/arb_gpu_shader5/execution/sampler_array_indexing/fs-struct-nonconst-multiple-samplers.shader_test +++ b/tests/spec/arb_gpu_shader5/execution/sampler_array_indexing/fs-struct-nonconst-multiple-samplers.shader_test @@ -1,5 +1,5 @@ # This test verifies that dynamic uniform indexing of samplers inside -# a stuct array in the fragment shader behaves correctly. +# a struct array in the fragment shader behaves correctly. [require] GLSL >= 1.50 diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-ldexp-dvec4.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-ldexp-dvec4.shader_test index 38214dee6..72040cdd8 100644 --- a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-ldexp-dvec4.shader_test +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-ldexp-dvec4.shader_test @@ -89,12 +89,7 @@ uniform ivec4 given_exponent 1021 1021 -1024 -1024 draw arrays GL_TRIANGLE_FAN 0 4 probe rgba 5 0 0.0 0.0 0.0 0.0 -# Test underflow generates zero with sign of x. -uniform dvec4 expected_double 0.0 -0.0 0.0 -0.0 -uniform dvec4 given_double 0.0 -0.0 0.5 -0.5 -uniform ivec4 given_exponent -1028 -1028 -1078 -1078 -draw arrays GL_TRIANGLE_FAN 0 4 -probe rgba 6 0 0.0 0.0 0.0 0.0 +# Underflow may flush to zero or not, so can't test that with this shader. uniform dvec4 expected_double 0.0 -0.0 0.0 -0.0 uniform dvec4 given_double 2.2250738585072014E-308 -2.2250738585072014E-308 1.7976931348623157E+308 -1.7976931348623157E+308 diff --git a/tests/spec/arb_gpu_shader_fp64/execution/uniform-invalid-operation.c b/tests/spec/arb_gpu_shader_fp64/execution/uniform-invalid-operation.c index aa61afdcc..1bd051200 100644 --- a/tests/spec/arb_gpu_shader_fp64/execution/uniform-invalid-operation.c +++ b/tests/spec/arb_gpu_shader_fp64/execution/uniform-invalid-operation.c @@ -25,7 +25,7 @@ * \file uniform-invalid-operation.c * * From the GL_ARB_gpu_shader_fp64 spec: - * "regarding INVALID_OPERATION errors in Uniform* comamnds, if the type of + * "regarding INVALID_OPERATION errors in Uniform* commands, if the type of * the uniform declared in the shader does not match the component type and * count indicated in the Uniform* command name (where a boolean uniform * component type is considered to match any of the Uniform*i{v}, diff --git a/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std140-fp64-mixed-shader.c b/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std140-fp64-mixed-shader.c index 043581b01..58f17b61f 100644 --- a/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std140-fp64-mixed-shader.c +++ b/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std140-fp64-mixed-shader.c @@ -259,6 +259,8 @@ piglit_init(int argc, char **argv) piglit_draw_rect(-1, -1, 2, 2); + glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT); + glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer); map_f = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY); diff --git a/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std140-fp64-shader.c b/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std140-fp64-shader.c index 0fe636e42..122187638 100644 --- a/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std140-fp64-shader.c +++ b/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std140-fp64-shader.c @@ -217,6 +217,8 @@ piglit_init(int argc, char **argv) piglit_draw_rect(-1, -1, 2, 2); + glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT); + glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer); map = (double *) glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY); diff --git a/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std430-fp64-mixed-shader.c b/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std430-fp64-mixed-shader.c index b994b39ed..d6ed63762 100644 --- a/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std430-fp64-mixed-shader.c +++ b/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std430-fp64-mixed-shader.c @@ -291,6 +291,8 @@ piglit_init(int argc, char **argv) piglit_draw_rect(-1, -1, 2, 2); + glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT); + glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer); map_f = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY); diff --git a/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std430-fp64-shader.c b/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std430-fp64-shader.c index 314c510e3..156645040 100644 --- a/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std430-fp64-shader.c +++ b/tests/spec/arb_gpu_shader_fp64/shader_storage/layout-std430-fp64-shader.c @@ -251,6 +251,8 @@ piglit_init(int argc, char **argv) piglit_draw_rect(-1, -1, 2, 2); + glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT); + glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer); map = (double *) glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY); diff --git a/tests/spec/arb_gpu_shader_int64/execution/fs-ishl-then-ishr.shader_test b/tests/spec/arb_gpu_shader_int64/execution/fs-ishl-then-ishr.shader_test index f6a6ba542..49be888a4 100644 --- a/tests/spec/arb_gpu_shader_int64/execution/fs-ishl-then-ishr.shader_test +++ b/tests/spec/arb_gpu_shader_int64/execution/fs-ishl-then-ishr.shader_test @@ -38,7 +38,7 @@ void main() /* This is INTENTIONALLY not a loop. Putting it in a loop causes the * optimization that generates the extract instructions to trigger * before the shift count is known to be a constant. The effectively - * prevents the bad code generation in the i965 driver from occuring. + * prevents the bad code generation in the i965 driver from occurring. */ i = 0; result = (ival[i] << (56u - (i * 8u))) >> 56u; diff --git a/tests/spec/arb_gpu_shader_int64/execution/fs-ishl-then-ushr.shader_test b/tests/spec/arb_gpu_shader_int64/execution/fs-ishl-then-ushr.shader_test index 30844ea0b..bbad7ddd9 100644 --- a/tests/spec/arb_gpu_shader_int64/execution/fs-ishl-then-ushr.shader_test +++ b/tests/spec/arb_gpu_shader_int64/execution/fs-ishl-then-ushr.shader_test @@ -38,7 +38,7 @@ void main() /* This is INTENTIONALLY not a loop. Putting it in a loop causes the * optimization that generates the extract instructions to trigger * before the shift count is known to be a constant. The effectively - * prevents the bad code generation in the i965 driver from occuring. + * prevents the bad code generation in the i965 driver from occurring. */ i = 0; result = (ival[i] << (56u - (i * 8u))) >> 56u; diff --git a/tests/spec/arb_gpu_shader_int64/execution/fs-ishr-and-mask.shader_test b/tests/spec/arb_gpu_shader_int64/execution/fs-ishr-and-mask.shader_test index fa1509dfa..897d97f0e 100644 --- a/tests/spec/arb_gpu_shader_int64/execution/fs-ishr-and-mask.shader_test +++ b/tests/spec/arb_gpu_shader_int64/execution/fs-ishr-and-mask.shader_test @@ -38,7 +38,7 @@ void main() /* This is INTENTIONALLY not a loop. Putting it in a loop causes the * optimization that generates the extract instructions to trigger * before the shift count is known to be a constant. The effectively - * prevents the bad code generation in the i965 driver from occuring. + * prevents the bad code generation in the i965 driver from occurring. */ i = 0; result = (ival[i] >> (i * 8u)) & 0x0FFl; diff --git a/tests/spec/arb_gpu_shader_int64/execution/fs-ushr-and-mask.shader_test b/tests/spec/arb_gpu_shader_int64/execution/fs-ushr-and-mask.shader_test index 96519624b..36b577c2b 100644 --- a/tests/spec/arb_gpu_shader_int64/execution/fs-ushr-and-mask.shader_test +++ b/tests/spec/arb_gpu_shader_int64/execution/fs-ushr-and-mask.shader_test @@ -38,7 +38,7 @@ void main() /* This is INTENTIONALLY not a loop. Putting it in a loop causes the * optimization that generates the extract instructions to trigger * before the shift count is known to be a constant. The effectively - * prevents the bad code generation in the i965 driver from occuring. + * prevents the bad code generation in the i965 driver from occurring. */ i = 0; result = (ival[i] >> (i * 8u)) & 0x0FFul; diff --git a/tests/spec/arb_instanced_arrays/vertex-attrib-divisor-index-error.c b/tests/spec/arb_instanced_arrays/vertex-attrib-divisor-index-error.c index 4e4bc542c..4e95774e9 100644 --- a/tests/spec/arb_instanced_arrays/vertex-attrib-divisor-index-error.c +++ b/tests/spec/arb_instanced_arrays/vertex-attrib-divisor-index-error.c @@ -45,11 +45,13 @@ void piglit_init(int argc, char **argv) { bool pass = true; + GLint maxAttribCount = 0; if(piglit_get_gl_version() < 33) piglit_require_extension("GL_ARB_instanced_arrays"); - glVertexAttribDivisor(GL_MAX_VERTEX_ATTRIBS, 0); + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribCount); + glVertexAttribDivisor(maxAttribCount, 0); pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); diff --git a/tests/spec/arb_internalformat_query2/common.c b/tests/spec/arb_internalformat_query2/common.c index 67f04b133..ba27fac48 100644 --- a/tests/spec/arb_internalformat_query2/common.c +++ b/tests/spec/arb_internalformat_query2/common.c @@ -151,7 +151,7 @@ test_data_value_at_index(test_data *data, { if (index > data->params_size || index < 0) { fprintf(stderr, "ERROR: invalid index while retrieving" - " data from auxiliar test data\n"); + " data from auxiliary test data\n"); return -1; } @@ -329,7 +329,7 @@ void print_failing_case_full(const GLenum target, const GLenum internalformat, * the cases where the set of returned values is not specified in * detail by the spec (like INTERNALFORMAT_PREFERRED). On that case, * it is not tested the returned value, and just tested that if not - * suppported, the returned value is the usupported value defined by + * supported, the returned value is the unsupported value defined by * the spec. * */ @@ -875,7 +875,7 @@ check_query2_target_dependencies(const GLenum target) return true; } -/* Returns is @pname and @target dependencies are fullfilled */ +/* Returns is @pname and @target dependencies are fulfilled */ bool check_query2_dependencies(const GLenum pname, const GLenum target) @@ -1010,7 +1010,7 @@ test_data_set_value_at_index(test_data *data, { if (index > data->params_size || index < 0) { fprintf(stderr, "ERROR: invalid index while setting" - " auxiliar test data\n"); + " auxiliary test data\n"); return; } @@ -1027,18 +1027,18 @@ test_data_equal_at_index(test_data *data, unsigned index) { if (data->testing64 != data_copy->testing64) { - fprintf(stderr, "ERROR: trying to compare imcompatible" - " auxiliar test data structures\n"); + fprintf(stderr, "ERROR: trying to compare incompatible" + " auxiliary test data structures\n"); return false; } if (data->params_size != data_copy->params_size) { - fprintf(stderr, "ERROR: trying to compare imcompatible" - " auxiliar test data structures\n"); + fprintf(stderr, "ERROR: trying to compare incompatible" + " auxiliary test data structures\n"); return false; } if (index > data->params_size) { fprintf(stderr, "ERROR: invalid index while setting" - " auxiliar test data\n"); + " auxiliary test data\n"); return false; } diff --git a/tests/spec/arb_internalformat_query2/generic-pname-checks.c b/tests/spec/arb_internalformat_query2/generic-pname-checks.c index bd44da038..bbb922920 100644 --- a/tests/spec/arb_internalformat_query2/generic-pname-checks.c +++ b/tests/spec/arb_internalformat_query2/generic-pname-checks.c @@ -244,7 +244,7 @@ piglit_display(void) /* * Executes try_basic on a list of pnames/possible values. * - * check_basic and try_basic are splitted because for some pnames, we + * check_basic and try_basic are split because for some pnames, we * would need to check more than just try_basic. */ static bool diff --git a/tests/spec/arb_internalformat_query2/max-dimensions.c b/tests/spec/arb_internalformat_query2/max-dimensions.c index 50190d56d..2f82c1ec4 100644 --- a/tests/spec/arb_internalformat_query2/max-dimensions.c +++ b/tests/spec/arb_internalformat_query2/max-dimensions.c @@ -316,7 +316,7 @@ try(const GLenum *targets, unsigned num_targets, value_test = test_data_is_unsupported_response(data, pname); } else { /* - * If suppported and enough dimensions, we compare against the values + * If supported and enough dimensions, we compare against the values * returned by GetInteger */ value_test = check_params_against_get_integer(data, @@ -478,7 +478,7 @@ try_max_layers(const GLenum *targets, unsigned num_targets, value_test = check_params_against_dimension(data, targets[i], - internalformats[i]); + internalformats[j]); /* We check that is the returned value by GetInteger */ value_test = value_test && check_params_against_get_integer(data, @@ -607,7 +607,7 @@ check_against_combined_dimensions(test_data *data, * * This method compares against zero if unsupported. If supported it * computes the value using MAX_WIDTH, MAX_HEIGHT, MAX_DEPTH, - * MAX_LAYERS and SAMPLES, and compare it agains the returned value. + * MAX_LAYERS and SAMPLES, and compare it against the returned value. */ static bool try_max_combined_dimensions(const GLenum *targets, unsigned num_targets, diff --git a/tests/spec/arb_map_buffer_range/map_buffer_range_error_check.c b/tests/spec/arb_map_buffer_range/map_buffer_range_error_check.c index bcb759d26..7cf18d89a 100644 --- a/tests/spec/arb_map_buffer_range/map_buffer_range_error_check.c +++ b/tests/spec/arb_map_buffer_range/map_buffer_range_error_check.c @@ -80,7 +80,7 @@ piglit_init(int argc, char *argv[]) if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); - /* offset + lenght > GL_BUFFER_SIZE */ + /* offset + length > GL_BUFFER_SIZE */ glMapBufferRange(target, 1, GL_BUFFER_SIZE, access); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); diff --git a/tests/spec/arb_map_buffer_range/map_buffer_range_test.c b/tests/spec/arb_map_buffer_range/map_buffer_range_test.c index 493924cbe..f0a793e7a 100644 --- a/tests/spec/arb_map_buffer_range/map_buffer_range_test.c +++ b/tests/spec/arb_map_buffer_range/map_buffer_range_test.c @@ -60,14 +60,14 @@ clear_buffer(GLenum target) { if (piglit_is_extension_supported("GL_ARB_clear_buffer_object")) { /* Clear the buffer just to make the device busy, so that - * the driver can't optimize MapBufferRange to unsychronized + * the driver can't optimize MapBufferRange to unsynchronized * without explicit_flush. */ glClearBufferData(target, GL_R32I, GL_RED_INTEGER, GL_INT, NULL); } } -/* This test relies on simple patterns, so using offets which are multiples of +/* This test relies on simple patterns, so using offsets which are multiples of * 0x100 is bad */ void diff --git a/tests/spec/arb_multisample/pushpop.c b/tests/spec/arb_multisample/pushpop.c index e6d8cf34d..1e6365341 100644 --- a/tests/spec/arb_multisample/pushpop.c +++ b/tests/spec/arb_multisample/pushpop.c @@ -141,7 +141,7 @@ test_coverage(bool mode) static bool test_state(bool enable_on, bool coverage_mode) { - return test_enable_bits(enable_on) & test_coverage(coverage_mode); + return test_enable_bits(enable_on) && test_coverage(coverage_mode); } static void diff --git a/tests/spec/arb_occlusion_query/occlusion_query.c b/tests/spec/arb_occlusion_query/occlusion_query.c index d28699813..66da0cdec 100644 --- a/tests/spec/arb_occlusion_query/occlusion_query.c +++ b/tests/spec/arb_occlusion_query/occlusion_query.c @@ -107,6 +107,14 @@ static int do_test(float x, int all_at_once) glColor3ub(0xff, 0x00, 0x00); draw_box(x + 20.0f, 20.0f, 0.0f, 55.0f, 55.0f); + /* It is legal for a driver to support the query API but not have + * any query bits. However, drivers must still allow calling the API + * entrypoints, so let's test that but ignore the result. + */ + GLint query_bits; + glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, + & query_bits); + for (i = 0; i < MAX_QUERIES; i++) { glBeginQuery(GL_SAMPLES_PASSED, occ_queries[i]); glColor3ubv(tests[i].color); @@ -117,7 +125,8 @@ static int do_test(float x, int all_at_once) if (! all_at_once) { glGetQueryObjectiv(occ_queries[i], GL_QUERY_RESULT, &passed); - test_pass &= check_result(passed, tests[i].expected); + if (query_bits > 0) + test_pass &= check_result(passed, tests[i].expected); } } @@ -126,7 +135,8 @@ static int do_test(float x, int all_at_once) for (i = 0; i < MAX_QUERIES; i++) { glGetQueryObjectiv(occ_queries[i], GL_QUERY_RESULT, &passed); - test_pass &= check_result(passed, tests[i].expected); + if (query_bits > 0) + test_pass &= check_result(passed, tests[i].expected); } } @@ -153,8 +163,6 @@ piglit_display(void) void piglit_init(int argc, char **argv) { - GLint query_bits; - glClearColor(0.0, 0.2, 0.3, 0.0); glClearDepth(1.0); @@ -163,16 +171,5 @@ piglit_init(int argc, char **argv) piglit_require_extension("GL_ARB_occlusion_query"); - /* It is legal for a driver to support the query API but not have - * any query bits. I wonder how many applications actually check for - * this case... - */ - glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, - & query_bits); - if (query_bits == 0) { - piglit_report_result(PIGLIT_SKIP); - } - - glGenQueries(MAX_QUERIES, occ_queries); } diff --git a/tests/spec/arb_occlusion_query/occlusion_query_conform.c b/tests/spec/arb_occlusion_query/occlusion_query_conform.c index df82a35fc..1d22b413c 100644 --- a/tests/spec/arb_occlusion_query/occlusion_query_conform.c +++ b/tests/spec/arb_occlusion_query/occlusion_query_conform.c @@ -104,7 +104,7 @@ conformOQ_GetObjivAval_multi1(void *data) piglit_draw_rect(-0.51, 0.51, 0.51, -0.51); glEndQueryARB(GL_SAMPLES_PASSED_ARB); - /* draw the 2nd box (blue) which is occluded by the occluder throughly */ + /* draw the 2nd box (blue) which is occluded by the occluder thoroughly */ glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id); glColor3f(0, 0, 1); piglit_draw_rect(-0.4, 0.4, 0.4, -0.4); @@ -126,7 +126,7 @@ conformOQ_GetObjivAval_multi1(void *data) return passed > 0 ? PIGLIT_FAIL : PIGLIT_PASS; } -/* If mutiple queries are issued on the same target and diff ids prior +/* If multiple queries are issued on the same target and diff ids prior * to calling GetQueryObject[u]iVARB, the results should be * corresponding to those queries (ids) respectively. */ diff --git a/tests/spec/arb_point_parameters/point-attenuation.c b/tests/spec/arb_point_parameters/point-attenuation.c index ed77064bd..178a240b5 100644 --- a/tests/spec/arb_point_parameters/point-attenuation.c +++ b/tests/spec/arb_point_parameters/point-attenuation.c @@ -87,25 +87,20 @@ expectedSize(GLfloat initSize, /* measure size of rendered point at yPos (in model coords) */ static GLfloat -measureSize(GLfloat yPos) +measureSize(float *pixels, GLfloat yPos) { assert(yPos >= -10.0); assert(yPos <= 10.0); float yNdc = (yPos + 10.0) / 20.0; /* See glOrtho above */ - int x = 0; int y = (int) (yNdc * windowHeight); int w = windowWidth; - int h = 3; - GLfloat image[3 * windowWidth * 3]; /* three rows of RGB values */ - /* Read three row of pixels and add up colors in each row. - * Use the row with the greatest sum. This helps gives us a bit - * of leeway in vertical point positioning. + /* Add up colors in 3 rows, and use the row with the greatest sum. + * This helps gives us a bit of leeway in vertical point positioning. * Colors should be white or shades of gray if smoothing is enabled. - */ - glReadPixels(x, y - 1, w, h, GL_RGB, GL_FLOAT, image); - - float sum[3] = { 0.0, 0.0, 0.0 }; + */ + float *image = pixels + (y - 1) * windowWidth * 3; + float sum[3] = {0.0, 0.0, 0.0}; for (int j = 0; j < 3; j++) { for (int i = 0; i < w; i++) { int k = j * 3 * w + i * 3; @@ -142,6 +137,8 @@ testPointRendering(bool smooth) glDisable(GL_BLEND); } + float *pixels = malloc(piglit_width * piglit_height * 3 * sizeof(float)); + for (int a = 0; a < 3; a++) { atten[0] = pow(10.0, -a); for (int b = -2; b < 3; b++) { @@ -164,12 +161,14 @@ testPointRendering(bool smooth) } glEnd(); + glReadPixels(0, 0, piglit_width, piglit_height, GL_RGB, GL_FLOAT, pixels); + /* test the column of points */ for (float z = -6.0; z <= 6.0; z += 1.0) { float expected = expectedSize(size, atten, min, max, z, smooth); - float actual = measureSize(z); + float actual = measureSize(pixels, z); if (fabs(expected - actual) > epsilon) { reportFailure(size, atten, min, max, z, expected, actual); @@ -187,6 +186,8 @@ testPointRendering(bool smooth) } } + free(pixels); + if (!piglit_check_gl_error(0)) return false; diff --git a/tests/spec/arb_post_depth_coverage/basic.c b/tests/spec/arb_post_depth_coverage/basic.c index 07f6ab1af..9f41859b8 100644 --- a/tests/spec/arb_post_depth_coverage/basic.c +++ b/tests/spec/arb_post_depth_coverage/basic.c @@ -209,6 +209,8 @@ piglit_display(void) glUniform1i(2, piglit_width); glDrawArrays(GL_TRIANGLES, 6, 6); + glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT); + glGetBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, sizeof(GLint) * piglit_width * piglit_height, &sample_mask[0]); diff --git a/tests/spec/arb_program_interface_query/getprogramresourceindex.c b/tests/spec/arb_program_interface_query/getprogramresourceindex.c index 16b38e2d5..f3491f491 100755 --- a/tests/spec/arb_program_interface_query/getprogramresourceindex.c +++ b/tests/spec/arb_program_interface_query/getprogramresourceindex.c @@ -146,7 +146,7 @@ struct subtest_index_t { GLenum programInterface; const char *name; bool valid_index; - GLint expect_value; /* -1, means don't check for an epected value */ + GLint expect_value; /* -1, means don't check for an expected value */ GLenum expected_error; }; diff --git a/tests/spec/arb_program_interface_query/getprogramresourceiv.c b/tests/spec/arb_program_interface_query/getprogramresourceiv.c index e55cf96ac..571ae7f2e 100755 --- a/tests/spec/arb_program_interface_query/getprogramresourceiv.c +++ b/tests/spec/arb_program_interface_query/getprogramresourceiv.c @@ -820,7 +820,7 @@ check_prop(GLuint prog, GLenum programInterface, int index, const char *name, break; } - /* harcode the index test for GL_ATOMIC_COUNTER_BUFFER */ + /* hardcode the index test for GL_ATOMIC_COUNTER_BUFFER */ if (programInterface == GL_ATOMIC_COUNTER_BUFFER) { if (values[0] != 0) { diff --git a/tests/spec/arb_program_interface_query/resource-query.c b/tests/spec/arb_program_interface_query/resource-query.c index b94a50bc8..1ea96d970 100755 --- a/tests/spec/arb_program_interface_query/resource-query.c +++ b/tests/spec/arb_program_interface_query/resource-query.c @@ -303,8 +303,8 @@ static const char *st_r_tes_sub_uni[] = {"TESS_EVALUATION", NULL}; * include all active variables for the interface, including any active * built-in variables. * - * For PROGRAM_INPUT and PROGRAM_OUTPUT interfaces for shaders that recieve - * or produce patch primitves, the active resource list will include both + * For PROGRAM_INPUT and PROGRAM_OUTPUT interfaces for shaders that receive + * or produce patch primitives, the active resource list will include both * per-vertex and per-patch inputs and outputs. * * For the TRANSFORM_FEEDBACK_VARYING interface, the active resource list diff --git a/tests/spec/arb_provoking_vertex/provoking-vertex-initial.c b/tests/spec/arb_provoking_vertex/provoking-vertex-initial.c index d4031a8c9..72eab9719 100644 --- a/tests/spec/arb_provoking_vertex/provoking-vertex-initial.c +++ b/tests/spec/arb_provoking_vertex/provoking-vertex-initial.c @@ -22,7 +22,7 @@ */ /** - * Test that the intitial value of PROVOKING_VERTEX is LAST_VERTEX_CONVENTION + * Test that the initial value of PROVOKING_VERTEX is LAST_VERTEX_CONVENTION * * Section 2.18(Flatshading) of OpenGL 3.2 Core says: * "The initial value of the provoking vertex mode is LAST_VERTEX_CONVENTION." diff --git a/tests/spec/arb_query_buffer_object/qbo.c b/tests/spec/arb_query_buffer_object/qbo.c index 3ba11ee26..05be962a8 100644 --- a/tests/spec/arb_query_buffer_object/qbo.c +++ b/tests/spec/arb_query_buffer_object/qbo.c @@ -27,10 +27,11 @@ * \file qbo.c * Tests ARB_query_buffer_object * - synchronous wait for result - * - asynchrounous result, default value is left intact if result unavailable - * - asynchrounous result, retrieve result to client memory before & after + * - asynchronous result, default value is left intact if result unavailable + * - asynchronous result, retrieve result to client memory before & after */ +#include <inttypes.h> #include "common.h" PIGLIT_GL_TEST_CONFIG_BEGIN @@ -96,6 +97,23 @@ cpu_gather_query(bool exact, uint32_t expected, uint64_t *cpu_result) ? PIGLIT_PASS : PIGLIT_FAIL; } +static bool +is_gs_valid(const struct query_type_desc *desc, uint32_t expected, uint64_t cpu_result) +{ + switch (desc->type) { + case GL_GEOMETRY_SHADER_INVOCATIONS: + case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB: + if (!expected && cpu_result) { + fprintf(stderr, "WARNING: GEOMETRY_SHADER statistics query returned nonzero when no GS bound\n"); + return true; + } + return false; + default: + break; + } + return true; +} + enum piglit_result run_subtest(void) { @@ -119,7 +137,7 @@ run_subtest(void) if (sync_mode == QBO_ASYNC_CPU_READ_BEFORE) { if (cpu_gather_query(exact, expected, &cpu_result)) - return PIGLIT_FAIL; + return is_gs_valid(query_desc, expected, cpu_result) ? PIGLIT_WARN : PIGLIT_FAIL; have_cpu_result = true; } @@ -155,7 +173,7 @@ run_subtest(void) if (sync_mode == QBO_SYNC_CPU_READ_AFTER_CACHE_TEST || sync_mode == QBO_ASYNC_CPU_READ_AFTER) { if (cpu_gather_query(exact, expected, &cpu_result)) - return PIGLIT_FAIL; + return is_gs_valid(query_desc, expected, cpu_result) ? PIGLIT_WARN : PIGLIT_FAIL; have_cpu_result = true; } @@ -182,11 +200,11 @@ run_subtest(void) printf("Expected: %u\n", expected); if (have_cpu_result) - printf("CPU result: %lu\n", cpu_result); + printf("CPU result: %"PRIu64"\n", cpu_result); printf("QBO: %u %u %u %u\n", ptr[0], ptr[1], ptr[2], ptr[3]); glUnmapBuffer(GL_QUERY_BUFFER); - return PIGLIT_FAIL; + return is_gs_valid(query_desc, expected, cpu_result) ? PIGLIT_WARN : PIGLIT_FAIL; } return PIGLIT_PASS; diff --git a/tests/spec/arb_sample_shading/execution/ignore-centroid-qualifier.cpp b/tests/spec/arb_sample_shading/execution/ignore-centroid-qualifier.cpp index 105f8377e..cea1f88e8 100644 --- a/tests/spec/arb_sample_shading/execution/ignore-centroid-qualifier.cpp +++ b/tests/spec/arb_sample_shading/execution/ignore-centroid-qualifier.cpp @@ -132,7 +132,7 @@ piglit_init(int argc, char**argv) msConfig.num_tex_attachments = 1; multisampled_fbo.setup(msConfig); - /* Reduced tolerence for stricter color matching */ + /* Reduced tolerance for stricter color matching */ piglit_set_tolerance_for_bits(16, 16, 16, 16); draw_prog_left = piglit_build_simple_program( "#version 130\n" diff --git a/tests/spec/arb_sample_shading/execution/interpolate-at-sample-position.cpp b/tests/spec/arb_sample_shading/execution/interpolate-at-sample-position.cpp index 36ede0d7e..9216964da 100644 --- a/tests/spec/arb_sample_shading/execution/interpolate-at-sample-position.cpp +++ b/tests/spec/arb_sample_shading/execution/interpolate-at-sample-position.cpp @@ -144,7 +144,7 @@ piglit_init(int argc, char**argv) msConfig.tex_attachment[1] = GL_COLOR_ATTACHMENT1; multisampled_fbo.setup(msConfig); - /* Reduced tolerence for stricter color matching */ + /* Reduced tolerance for stricter color matching */ piglit_set_tolerance_for_bits(16, 16, 16, 16); draw_prog_left = piglit_build_simple_program( "#version 130\n" diff --git a/tests/spec/arb_sample_shading/execution/samplemask.cpp b/tests/spec/arb_sample_shading/execution/samplemask.cpp index 4be7e3a52..5f16d7f1a 100644 --- a/tests/spec/arb_sample_shading/execution/samplemask.cpp +++ b/tests/spec/arb_sample_shading/execution/samplemask.cpp @@ -309,6 +309,9 @@ test_fix(enum rate_mode mode, float sample_rate) static enum piglit_result test_mask_in_one(enum rate_mode mode, float sample_rate) { + if (!mask_in_one_supported) + return PIGLIT_SKIP; + glClearColor(0.0, 0.0, 0.0, 0.0); /* 1. Draw everything outputting gl_SampleMaskIn, with msaa disabled; */ diff --git a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt index ce257ca2e..37d19e3c3 100644 --- a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt +++ b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt @@ -31,3 +31,4 @@ piglit_add_executable (arb_separate_shader_object-UseProgramStages-non-separable piglit_add_executable (arb_separate_shader_object-ValidateProgramPipeline ValidateProgramPipeline.c) piglit_add_executable (arb_separate_shader_object-atomic-counter atomic-counter.c) piglit_add_executable (arb_separate_shader_object-xfb-rendezvous_by_location xfb-rendezvous_by_location.c sso-common.c) +piglit_add_executable (arb_separate_shader_object-xfb-explicit-location-array xfb-explicit-location-array.c) diff --git a/tests/spec/arb_separate_shader_objects/ProgramUniform-coverage.c b/tests/spec/arb_separate_shader_objects/ProgramUniform-coverage.c index 5763d155d..95ef98a64 100644 --- a/tests/spec/arb_separate_shader_objects/ProgramUniform-coverage.c +++ b/tests/spec/arb_separate_shader_objects/ProgramUniform-coverage.c @@ -219,7 +219,7 @@ random_uints(unsigned int *v, unsigned count) * \name Data checking functions. * * Each of these functions verifies that one set of data matches another set - * of data. If a discrepency is found, the failing location is logged. + * of data. If a discrepancy is found, the failing location is logged. */ /*@{*/ static bool diff --git a/tests/spec/arb_separate_shader_objects/api-errors.c b/tests/spec/arb_separate_shader_objects/api-errors.c index 1d6069e11..fd36ce951 100644 --- a/tests/spec/arb_separate_shader_objects/api-errors.c +++ b/tests/spec/arb_separate_shader_objects/api-errors.c @@ -24,7 +24,7 @@ /** * \file api-errors.c - * Verify miscelaneous API error conditions from the specification. + * Verify miscellaneous API error conditions from the specification. */ #include "piglit-util-gl.h" #include "sso-common.h" diff --git a/tests/spec/arb_separate_shader_objects/atomic-counter.c b/tests/spec/arb_separate_shader_objects/atomic-counter.c index a773b64c9..a1df46fa9 100644 --- a/tests/spec/arb_separate_shader_objects/atomic-counter.c +++ b/tests/spec/arb_separate_shader_objects/atomic-counter.c @@ -104,6 +104,7 @@ piglit_init(int argc, char **argv) bool pass = true; uint32_t counter = 0; + piglit_require_GLSL_version(150); piglit_require_extension("GL_ARB_shader_atomic_counters"); piglit_require_extension("GL_ARB_separate_shader_objects"); diff --git a/tests/spec/arb_separate_shader_objects/rendezvous_by_location-5-stages.c b/tests/spec/arb_separate_shader_objects/rendezvous_by_location-5-stages.c index 9d72cb4e6..4e81cac26 100644 --- a/tests/spec/arb_separate_shader_objects/rendezvous_by_location-5-stages.c +++ b/tests/spec/arb_separate_shader_objects/rendezvous_by_location-5-stages.c @@ -179,6 +179,7 @@ piglit_display(void) void piglit_init(int argc, char **argv) { GLuint vs_prog, tcs_prog, tes_prog, gs_prog, fs_prog; + bool pass = true; piglit_require_gl_version(32); piglit_require_extension("GL_ARB_separate_shader_objects"); @@ -187,23 +188,23 @@ void piglit_init(int argc, char **argv) vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, (const GLchar *const*)&vs_code); - piglit_link_check_status(vs_prog); + pass = piglit_link_check_status(vs_prog) && pass; tcs_prog = glCreateShaderProgramv(GL_TESS_CONTROL_SHADER, 1, (const GLchar *const *)&tcs_code); - piglit_link_check_status(tcs_prog); + pass = piglit_link_check_status(tcs_prog) && pass; tes_prog = glCreateShaderProgramv(GL_TESS_EVALUATION_SHADER, 1, (const GLchar *const *)&tes_code); - piglit_link_check_status(tes_prog); + pass = piglit_link_check_status(tes_prog) && pass; gs_prog = glCreateShaderProgramv(GL_GEOMETRY_SHADER, 1, (const GLchar *const *)&gs_code); - piglit_link_check_status(gs_prog); + pass = piglit_link_check_status(gs_prog) && pass; fs_prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, (const GLchar *const *)&fs_code); - piglit_link_check_status(fs_prog); + pass = piglit_link_check_status(fs_prog) && pass; glGenProgramPipelines(1, &pipeline); glUseProgramStages(pipeline, GL_VERTEX_SHADER_BIT, vs_prog); @@ -211,8 +212,10 @@ void piglit_init(int argc, char **argv) glUseProgramStages(pipeline, GL_TESS_EVALUATION_SHADER_BIT, tes_prog); glUseProgramStages(pipeline, GL_GEOMETRY_SHADER_BIT, gs_prog); glUseProgramStages(pipeline, GL_FRAGMENT_SHADER_BIT, fs_prog); - piglit_program_pipeline_check_status(pipeline); + pass = piglit_program_pipeline_check_status(pipeline) && pass; - if (!piglit_check_gl_error(0)) + pass = piglit_check_gl_error(0) && pass; + + if (!pass) piglit_report_result(PIGLIT_FAIL); } diff --git a/tests/spec/arb_separate_shader_objects/rendezvous_by_location.c b/tests/spec/arb_separate_shader_objects/rendezvous_by_location.c index c9c673a54..4e2ffeccd 100644 --- a/tests/spec/arb_separate_shader_objects/rendezvous_by_location.c +++ b/tests/spec/arb_separate_shader_objects/rendezvous_by_location.c @@ -26,13 +26,13 @@ * Simple test for separate shader objects that use rendezvous-by-location. * * There are two ways one might expect rendezvous-by-location to fail. One - * predicatble failure mode is for variables between two program objects to be - * linked in the order they appear in the shader text. Another predicatble + * predictable failure mode is for variables between two program objects to be + * linked in the order they appear in the shader text. Another predictable * failure mode is for variables between two program objects to be linked by * name. * - * This test tries both modes using a single fragement shader program. This - * program outputs two varibles, a and b, with locations specified. Two + * This test tries both modes using a single fragment shader program. This + * program outputs two variables, a and b, with locations specified. Two * fragment shader programs are created, each having input variables a and b, * with locations specified. In the first case, a and b are listed in the * same order as in the vertex shader, but the locations are reversed (vertex diff --git a/tests/spec/arb_separate_shader_objects/xfb-explicit-location-array.c b/tests/spec/arb_separate_shader_objects/xfb-explicit-location-array.c new file mode 100644 index 000000000..e76207653 --- /dev/null +++ b/tests/spec/arb_separate_shader_objects/xfb-explicit-location-array.c @@ -0,0 +1,298 @@ +/* + * Copyright © 2016 Intel Corporation + * + * 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. + */ + +/* Tests xfb with explicit locations. Specifically this was written to test + * a mesa bug with the handling of xfb output arrays that have an explicit + * location. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 32; + config.supports_gl_core_version = 32; + +PIGLIT_GL_TEST_CONFIG_END + +static const char vs_pass_thru_text[] = + "#version 150\n" + "void main() {\n" + " gl_Position = vec4(0.0);\n" + "}\n"; + +static const char vs_shader_text[] = + "#version 150\n" + "#extension GL_ARB_separate_shader_objects: require\n" + "\n" + "out float x1_out;\n" + "layout(location = 4) out float x2_out[2];\n" + "layout(location = 6) out vec3 x3_out;\n" + "layout(location = 2) out float y1_out;\n" + "layout(location = 3) out vec4 y2_out;\n" + "void main() {\n" + " gl_Position = vec4(0.0);\n" + " x1_out = 1.0;\n" + " x2_out[0] = 2.0;\n" + " x2_out[1] = 3.0;\n" + " x3_out = vec3(4.0, 5.0, 6.0);\n" + " y1_out = 7.0;\n" + " y2_out = vec4(8.0, 9.0, 10.0, 11.0);\n" + "}"; + +static const char gs_text_tmpl[] = + "#version 150\n" + "#extension GL_ARB_separate_shader_objects: require\n" + "#extension GL_ARB_gpu_shader5 : enable\n" + "#define INVOCATION_MAX_N %u\n" + "layout(points, invocations = INVOCATION_MAX_N) in;\n" + "layout(points, max_vertices = 1) out;\n" + "\n" + "out float x1_out;\n" + "layout(location = 4) out float x2_out[2];\n" + "layout(location = 6) out vec3 x3_out;\n" + "out vec3 not_captured1;\n" + "layout(location = 2) out float y1_out;\n" + "layout(location = 1) out vec4 y2_out;\n" + "out vec3 not_captured2;\n" + "void main() {\n" + " gl_Position = gl_in[0].gl_Position;\n" + " x1_out = 1.0 + gl_InvocationID;\n" + " x2_out[0] = 2.0 + gl_InvocationID;\n" + " x2_out[1] = 3.0 + gl_InvocationID;\n" + " x3_out = vec3(4.0 + gl_InvocationID, 5.0 + gl_InvocationID,\n" + " 6.0 + gl_InvocationID);\n" + " y1_out = 7.0 + gl_InvocationID;\n" + " y2_out = vec4(8.0 + gl_InvocationID, 9.0 + gl_InvocationID,\n" + " 10.0 + gl_InvocationID, 11.0 + gl_InvocationID);\n" + " not_captured1 = vec3(1.0);" + " not_captured2 = vec3(1.0);" + " EmitVertex();\n" + " EndPrimitive();\n" + "}"; + +#define BUF_1_FLOAT_N 6 +#define BUF_2_FLOAT_N 5 + +static void +print_usage_and_exit(const char *prog_name) +{ + printf("Usage: %s <subtest>\n" + " where <subtest> is one of the following:\n" + " vs (vertex shader only)\n" + " gs (with geometry shader invoked once per stage)\n" + " gs_max (with geometry shader invoked max times per " + "stage)\n", prog_name); + piglit_report_result(PIGLIT_FAIL); +} + +static void +build_and_use_program(unsigned gs_invocation_n, const char *vs_text) +{ + GLuint prog; + + if (gs_invocation_n == 0) { + prog = piglit_build_simple_program_multiple_shaders( + GL_VERTEX_SHADER, vs_text, 0); + } else { + char *gs_text; + + (void)!asprintf(&gs_text, gs_text_tmpl, gs_invocation_n); + prog = piglit_build_simple_program_multiple_shaders( + GL_VERTEX_SHADER, vs_pass_thru_text, + GL_GEOMETRY_SHADER, gs_text, 0); + free(gs_text); + } + + const char *varyings[] = { + "x1_out", "x2_out[0]", "x2_out[1]", "x3_out", "gl_NextBuffer", "gl_NextBuffer","y1_out", "y2_out" + }; + + glTransformFeedbackVaryings(prog, 8, varyings, GL_INTERLEAVED_ATTRIBS); + + glLinkProgram(prog); + if (!piglit_link_check_status(prog)) + piglit_report_result(PIGLIT_FAIL); + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + glUseProgram(prog); +} + +static bool +probe_buffers(const GLuint *xfb, const GLuint *queries, unsigned primitive_n) +{ + bool pass; + unsigned i; + GLuint query_result; + float *first; + float *second; + + const unsigned first_n = primitive_n * BUF_1_FLOAT_N; + const unsigned second_n = primitive_n * BUF_2_FLOAT_N; + + glGetQueryObjectuiv(queries[0], GL_QUERY_RESULT, &query_result); + if (query_result != primitive_n) { + printf("Expected %u primitives written, got %u\n", + primitive_n, query_result); + piglit_report_result(PIGLIT_FAIL); + } + + glGetQueryObjectuiv(queries[1], GL_QUERY_RESULT, &query_result); + if (query_result != primitive_n) { + printf("Expected %u primitives generated, got %u\n", + primitive_n, query_result); + piglit_report_result(PIGLIT_FAIL); + } + + first = malloc(first_n * sizeof(float)); + second = malloc(second_n * sizeof(float)); + + for (i = 0; i < primitive_n; ++i) { + first[i * BUF_1_FLOAT_N + 0] = i + 1.0; /* x1 */ + first[i * BUF_1_FLOAT_N + 1] = i + 2.0; /* x2[0] */ + first[i * BUF_1_FLOAT_N + 2] = i + 3.0; /* x2[1] */ + first[i * BUF_1_FLOAT_N + 3] = i + 4.0; /* x3[0] */ + first[i * BUF_1_FLOAT_N + 4] = i + 5.0; /* x3[1] */ + first[i * BUF_1_FLOAT_N + 5] = i + 6.0; /* x3[2] */ + + second[i * BUF_2_FLOAT_N + 0] = i + 7.0; /* y1 */ + second[i * BUF_2_FLOAT_N + 1] = i + 8.0; /* y2[0] */ + second[i * BUF_2_FLOAT_N + 2] = i + 9.0; /* y2[1] */ + second[i * BUF_2_FLOAT_N + 3] = i + 10.0; /* y2[2] */ + second[i * BUF_2_FLOAT_N + 4] = i + 11.0; /* y2u3] */ + } + + pass = piglit_probe_buffer(xfb[0], GL_TRANSFORM_FEEDBACK_BUFFER, + "first", 1, first_n, first); + pass = piglit_probe_buffer(xfb[1], GL_TRANSFORM_FEEDBACK_BUFFER, + "second", 1, second_n, second) && + pass; + + free(first); + free(second); + + return pass; +} + +static unsigned +parse_args(int argc, char **argv, const char **vs_text) +{ + GLint gs_invocation_n; + + if (argc != 2) + print_usage_and_exit(argv[0]); + + if (strcmp(argv[1], "vs") == 0) { + *vs_text = vs_shader_text; + return 0; + } + + piglit_require_extension("GL_ARB_gpu_shader5"); + if (strcmp(argv[1], "gs") == 0) + return 1; + + if (strcmp(argv[1], "gs_max") != 0) + print_usage_and_exit(argv[0]); + + glGetIntegerv(GL_MAX_GEOMETRY_SHADER_INVOCATIONS, &gs_invocation_n); + if (gs_invocation_n <= 0) { + printf("Maximum amount of geometry shader invocations " + "needs to be positive (%u).\n", gs_invocation_n); + piglit_report_result(PIGLIT_FAIL); + } + + return gs_invocation_n; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass; + unsigned primitive_n, gs_invocation_n; + const char *vs_text; + GLuint queries[2]; + GLuint xfb[2]; + GLuint vao; + + piglit_require_extension("GL_ARB_transform_feedback3"); + piglit_require_extension("GL_ARB_separate_shader_objects"); + + + gs_invocation_n = parse_args(argc, argv, &vs_text); + + /* Zero invocations means the feedback is produced by vertex shader */ + primitive_n = gs_invocation_n ? gs_invocation_n : 1; + + build_and_use_program(gs_invocation_n, vs_text); + + /* Set up the transform feedback buffers. */ + glGenBuffers(ARRAY_SIZE(xfb), xfb); + glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, xfb[0]); + glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, + primitive_n * BUF_1_FLOAT_N * sizeof(float), NULL, + GL_STREAM_READ); + glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, xfb[1]); + glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, + primitive_n * BUF_2_FLOAT_N * sizeof(float), NULL, + GL_STREAM_READ); + + /* Test only records using transform feedback. */ + glEnable(GL_RASTERIZER_DISCARD); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + glGenQueries(2, queries); + glBeginQuery(GL_PRIMITIVES_GENERATED, queries[0]); + glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queries[1]); + + /* Test is run under desktop OpenGL 3.2 -> use of VAOs is required */ + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + /* Draw and record */ + glBeginTransformFeedback(GL_POINTS); + glDrawArrays(GL_POINTS, 0, 1); + glEndQuery(GL_PRIMITIVES_GENERATED); + glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); + glEndTransformFeedback(); + glDeleteVertexArrays(1, &vao); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + pass = probe_buffers(xfb, queries, primitive_n); + + glDeleteBuffers(2, xfb); + glDeleteQueries(2, queries); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} + +enum piglit_result +piglit_display(void) +{ + /* Should never be reached */ + return PIGLIT_FAIL; +} diff --git a/tests/spec/arb_shader_atomic_counters/max-counters.c b/tests/spec/arb_shader_atomic_counters/max-counters.c index f3df5f8ba..19b0444d5 100644 --- a/tests/spec/arb_shader_atomic_counters/max-counters.c +++ b/tests/spec/arb_shader_atomic_counters/max-counters.c @@ -23,7 +23,7 @@ /** @file max-counters.c * - * Test that using more than the maximum number of suported atomic + * Test that using more than the maximum number of supported atomic * counters, buffers or bindings fails with a linking error. */ diff --git a/tests/spec/arb_shader_atomic_counters/semantics.c b/tests/spec/arb_shader_atomic_counters/semantics.c index 7da358399..633ff7349 100644 --- a/tests/spec/arb_shader_atomic_counters/semantics.c +++ b/tests/spec/arb_shader_atomic_counters/semantics.c @@ -164,14 +164,14 @@ run_test_fragment(GLint max_bindings) const char *fs_template = "#version 140\n" "#extension GL_ARB_shader_atomic_counters : enable\n" "\n" - "out ivec4 fcolor;\n" + "out uvec4 fcolor;\n" "layout(binding = %i, offset = 0) uniform atomic_uint x;\n" "\n" "void main() {\n" - " fcolor.x = int(atomicCounterDecrement(x));\n" - " fcolor.y = int(atomicCounterIncrement(x));\n" - " fcolor.z = int(atomicCounterIncrement(x));\n" - " fcolor.w = int(atomicCounter(x));\n" + " fcolor.x = atomicCounterDecrement(x);\n" + " fcolor.y = atomicCounterIncrement(x);\n" + " fcolor.z = atomicCounterIncrement(x);\n" + " fcolor.w = atomicCounter(x);\n" "}\n"; const char *vs_source = "#version 140\n" "#extension GL_ARB_shader_atomic_counters : enable\n" diff --git a/tests/spec/arb_shader_image_load_store/execution/disable_early_z.shader_test b/tests/spec/arb_shader_image_load_store/execution/disable_early_z.shader_test index e970757bd..2dc94f686 100644 --- a/tests/spec/arb_shader_image_load_store/execution/disable_early_z.shader_test +++ b/tests/spec/arb_shader_image_load_store/execution/disable_early_z.shader_test @@ -1,4 +1,4 @@ -# Test that Z runs lates when the fragment shader contains stores. +# Test that Z runs later when the fragment shader contains stores. # [require] GL >= 3.3 diff --git a/tests/spec/arb_shader_image_load_store/grid.c b/tests/spec/arb_shader_image_load_store/grid.c index 7454e52f2..9e7e2c17f 100644 --- a/tests/spec/arb_shader_image_load_store/grid.c +++ b/tests/spec/arb_shader_image_load_store/grid.c @@ -261,7 +261,7 @@ generate_program_v(const struct grid_info grid, const char **sources) GL_GEOMETRY_SHADER_BIT); const unsigned stages = (grid.stages | - /* Make a full pipeline if a tesselation shader was + /* Make a full pipeline if a tessellation shader was * requested. */ (grid.stages & tess_stages ? graphic_stages : 0) | /* Make sure there is always a vertex and fragment diff --git a/tests/spec/arb_shader_texture_lod/execution/glsl-fs-texturelod-01.shader_test b/tests/spec/arb_shader_texture_lod/execution/glsl-fs-texturelod-01.shader_test index f5ea392c0..77f324c08 100644 --- a/tests/spec/arb_shader_texture_lod/execution/glsl-fs-texturelod-01.shader_test +++ b/tests/spec/arb_shader_texture_lod/execution/glsl-fs-texturelod-01.shader_test @@ -1,6 +1,6 @@ [require] GLSL >= 1.20 -require GL_ARB_shader_texture_lod +GL_ARB_shader_texture_lod [vertex shader] #version 120 diff --git a/tests/spec/arb_tessellation_shader/execution/compatibility/vs-tcs-tes-clip-vertex-enables.shader_test b/tests/spec/arb_tessellation_shader/execution/compatibility/vs-tcs-tes-clip-vertex-enables.shader_test index 546d785a6..20b3a0224 100644 --- a/tests/spec/arb_tessellation_shader/execution/compatibility/vs-tcs-tes-clip-vertex-enables.shader_test +++ b/tests/spec/arb_tessellation_shader/execution/compatibility/vs-tcs-tes-clip-vertex-enables.shader_test @@ -5,7 +5,7 @@ # # To verify that each enable works, the combinations of enables were # chosen such that: -# - Every plane is enabled at least once and disbled at least once. +# - Every plane is enabled at least once and disabled at least once. # - Every plane is enabled and disabled in a different pattern. # # Note: Some implementations have bugs related to improper coordinate diff --git a/tests/spec/arb_tessellation_shader/execution/tesslevels-indirect.shader_test b/tests/spec/arb_tessellation_shader/execution/tesslevels-indirect.shader_test new file mode 100644 index 000000000..a05610a6e --- /dev/null +++ b/tests/spec/arb_tessellation_shader/execution/tesslevels-indirect.shader_test @@ -0,0 +1,52 @@ +# Test a set of simple pass-through tessellation shaders + +[require] +GLSL >= 1.50 +GL_ARB_tessellation_shader + +[vertex shader] +#version 150 + +void main() +{ +} + +[tessellation control shader] +#version 150 +#extension GL_ARB_tessellation_shader : require + +layout(vertices = 4) out; + +void main() +{ + float tessOuter = 1.0; + gl_TessLevelInner[0] = 1.0; + gl_TessLevelInner[1] = 1.0; + gl_TessLevelOuter[gl_InvocationID] = tessOuter; +} + +[tessellation evaluation shader] +#version 150 +#extension GL_ARB_tessellation_shader : require + +layout(quads, equal_spacing) in; + +void main() +{ + gl_Position = vec4(gl_TessCoord.x * 2 - 1, gl_TessCoord.y * 2 - 1, 0, 1); +} + +[fragment shader] +#version 150 + +void main() +{ + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); +} + +[test] +clear color 0.1 0.1 0.1 0.1 +clear +patch parameter vertices 4 +draw arrays GL_PATCHES 0 4 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_tessellation_shader/large-uniforms.c b/tests/spec/arb_tessellation_shader/large-uniforms.c index 91bd30fc5..4e7adf809 100644 --- a/tests/spec/arb_tessellation_shader/large-uniforms.c +++ b/tests/spec/arb_tessellation_shader/large-uniforms.c @@ -154,7 +154,7 @@ test_uniform_array(const GLenum shader, const int n, const bool expect_fail) if (link_status && expect_fail) { fprintf(stderr, "Program with %d uniform components in %s " - "linked succesfully\n", n, + "linked successfully\n", n, piglit_get_gl_enum_name(shader)); free(source_uniforms); return false; @@ -199,7 +199,7 @@ test_uniform_block(const GLenum shader, const int num_blocks, const int size, sum = malloc((strlen(summand_template) + 8) * num_blocks); sum[0] = '\0'; for(i = 0; i < num_blocks; ++i) { - char summand[40]; + char summand[44]; sprintf(summand, summand_template, i); strcat(sum, summand); } diff --git a/tests/spec/arb_tessellation_shader/layout-mismatch.c b/tests/spec/arb_tessellation_shader/layout-mismatch.c index 988d26cfc..f752b3499 100644 --- a/tests/spec/arb_tessellation_shader/layout-mismatch.c +++ b/tests/spec/arb_tessellation_shader/layout-mismatch.c @@ -127,7 +127,7 @@ test_tcs_layout(const int i, const int j) if (link_status && (i != j)) { fprintf(stderr, "Program with different vertices " - "specifications linked succesfully\n"); + "specifications linked successfully\n"); return false; } if (!link_status && (i == j)) { @@ -164,7 +164,7 @@ test_tes_layout(const char *const layout1, const char *const layout2, if (link_status && (layout1 != layout2)) { fprintf(stderr, "Program with different %s " - "specifications linked succesfully\n", layout_name); + "specifications linked successfully\n", layout_name); return false; } if (!link_status && (layout1 == layout2)) { diff --git a/tests/spec/arb_tessellation_shader/tes-gs-max-output.cpp b/tests/spec/arb_tessellation_shader/tes-gs-max-output.cpp index acfb5e714..23744e129 100644 --- a/tests/spec/arb_tessellation_shader/tes-gs-max-output.cpp +++ b/tests/spec/arb_tessellation_shader/tes-gs-max-output.cpp @@ -67,7 +67,7 @@ struct testcase { unsigned tessfactor_u; unsigned tessfactor_v; unsigned num_invocations; /* GS invocations / instances */ - unsigned num_outputs; /* # vertex ouput per GS invocation */ + unsigned num_outputs; /* # vertex output per GS invocation */ unsigned num_extra_components; /* # extra components per GS output vertex */ bool operator<(const testcase &o) const { diff --git a/tests/spec/arb_texture_barrier/blending-in-shader-arb.c b/tests/spec/arb_texture_barrier/blending-in-shader-arb.c index ce19c2951..d61d5a214 100644 --- a/tests/spec/arb_texture_barrier/blending-in-shader-arb.c +++ b/tests/spec/arb_texture_barrier/blending-in-shader-arb.c @@ -177,7 +177,8 @@ initialize_data() glActiveTexture(GL_TEXTURE0 + t); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RED_INTEGER, GL_UNSIGNED_INT, tex_data[t]); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + t, tex[t], 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + t, + GL_TEXTURE_2D, tex[t], 0); } assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); } @@ -207,7 +208,7 @@ interpolate_square(const Vertex square[4], /* * Tesselates @square_pos, returning a set of vertex information and * indices compatible to draw with glDrawElements at (@tesselated_pos, - * @indices). @granularity is the number of vertexes per side. So the + * @indices). @granularity is the number of vertices per side. So the * minimum should be 2. * * Is assumed that the vertex at @square_pos are in the order @@ -231,7 +232,7 @@ util_tesselate_square(const Vertex square_pos[4], if (granularity < 2) { fprintf(stderr, "Granularity should be equal or greater to 2" - " in order to tesselate a square. Setting it to 2.\n"); + " in order to tessellate a square. Setting it to 2.\n"); granularity = 2; } diff --git a/tests/spec/arb_texture_barrier/texture-halves-ping-pong-operation-chain.c b/tests/spec/arb_texture_barrier/texture-halves-ping-pong-operation-chain.c index 41a840148..23b03531b 100644 --- a/tests/spec/arb_texture_barrier/texture-halves-ping-pong-operation-chain.c +++ b/tests/spec/arb_texture_barrier/texture-halves-ping-pong-operation-chain.c @@ -163,7 +163,8 @@ initialize_fbo() unsigned fbo; glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, tex, 0); assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); } diff --git a/tests/spec/arb_texture_buffer_object/texture-buffer-size-clamp.c b/tests/spec/arb_texture_buffer_object/texture-buffer-size-clamp.c index 5696da5f1..93ef5a4fd 100644 --- a/tests/spec/arb_texture_buffer_object/texture-buffer-size-clamp.c +++ b/tests/spec/arb_texture_buffer_object/texture-buffer-size-clamp.c @@ -249,7 +249,7 @@ piglit_init(int argc, char **argv) "void main() {gl_Position = piglit_vertex;}"; static const char frag[] = "#version 140\n" - "uniform samplerBuffer s;\n" + "uniform usamplerBuffer s;\n" "uniform int size, maxSize;\n" "void main()\n" "{\n" @@ -264,7 +264,7 @@ piglit_init(int argc, char **argv) "#extension GL_ARB_shader_storage_buffer_object: require\n" "#extension GL_ARB_shader_image_size: require\n" "layout(local_size_x = 1) in;\n" - "writeonly readonly uniform imageBuffer s;\n" + "writeonly readonly uniform uimageBuffer s;\n" "layout(std430, binding=0) writeonly buffer SZ\n" "{\n" " int size;\n" @@ -277,7 +277,11 @@ piglit_init(int argc, char **argv) GLuint prog_sampler = piglit_build_simple_program(vert, frag); GLuint prog_image = 0; - if (piglit_is_extension_supported("GL_ARB_compute_shader")) { + + bool es; + int major, minor; + piglit_get_glsl_version(&es, &major, &minor); + if (piglit_is_extension_supported("GL_ARB_compute_shader") && major * 100 + minor >= 420) { GLuint shader = piglit_compile_shader_text(GL_COMPUTE_SHADER, comp); diff --git a/tests/spec/arb_texture_cube_map_array/sampler-cube-array-shadow.c b/tests/spec/arb_texture_cube_map_array/sampler-cube-array-shadow.c index 95eeb04df..a16455112 100644 --- a/tests/spec/arb_texture_cube_map_array/sampler-cube-array-shadow.c +++ b/tests/spec/arb_texture_cube_map_array/sampler-cube-array-shadow.c @@ -63,7 +63,7 @@ static GLfloat compvals[6][4] = { { -0.50, 0.00, 0.50, 0.00 }, #define STRIDE (9 * sizeof(GLfloat)) /* Setup interleaved vertex attributes for 6 * 4 vertices: * 4 float vertex coordinates for drawing 6 quads aligned in a 3x2 grid with - * some space inbetween. + * some space in between. * 4 float texture coordinates for sampling one cube map face per quad. * 1 float compare value for shadow texture fetch. */ diff --git a/tests/spec/arb_texture_multisample/large-float-texture.c b/tests/spec/arb_texture_multisample/large-float-texture.c index 3c18ee25e..78953bfb7 100644 --- a/tests/spec/arb_texture_multisample/large-float-texture.c +++ b/tests/spec/arb_texture_multisample/large-float-texture.c @@ -351,7 +351,7 @@ extract_texture_image(GLuint readbackProg, static bool nearly_equal(const GLfloat x[4], const GLfloat y[4]) { - /* XXX this tolerance was chosen emperically */ + /* XXX this tolerance was chosen empirically */ const float maxRelDiff = 0.0005; int i; for (i = 0; i < 4; i++) { diff --git a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test index edae0319f..8f44d9ce1 100644 --- a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test +++ b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test @@ -55,11 +55,12 @@ void main() { vec4 frag1 = texture(tex, gl_TexCoord[0].st); vec4 frag2 = textureLod(tex, gl_TexCoord[0].st, lod); + vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st); + if (!equal_v4(frag1, frag2)) { discard; } - vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st); if (!equal(queried_lod.x, queried_lod.y)) { discard; } diff --git a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test index 5fa9c9cf2..d34e5c121 100644 --- a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test +++ b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test @@ -68,11 +68,12 @@ void main() vec4 frag1 = texture(tex, gl_TexCoord[0].st); vec4 frag2 = textureLod(tex, gl_TexCoord[0].st, nearest_lod); + vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st); + if (frag1 != frag2) { discard; } - vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st); if (!equal(queried_lod.x, min(queried_lod.y, MAX_MIPMAP_LEVEL))) { discard; } diff --git a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test index 9782abba3..ae6a26b78 100644 --- a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test +++ b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test @@ -63,11 +63,12 @@ void main() vec4 frag1 = texture(tex, gl_TexCoord[0].st); vec4 frag2 = textureLod(tex, gl_TexCoord[0].st, nearest_lod); + vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st); + if (frag1 != frag2) { discard; } - vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st); if (!equal(queried_lod.x, queried_lod.y)) { discard; } diff --git a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-no-mipmap.shader_test b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-no-mipmap.shader_test index 205a0871e..f81765af1 100644 --- a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-no-mipmap.shader_test +++ b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-no-mipmap.shader_test @@ -57,11 +57,13 @@ uniform float lambda_prime; void main() { + vec4 color = texture(tex, gl_TexCoord[0].st); + if (!equal_v2(textureQueryLOD(tex, gl_TexCoord[0].st), vec2(0.0f, lambda_prime))) { discard; } - gl_FragColor = texture(tex, gl_TexCoord[0].st); + gl_FragColor = color; } [vertex shader] diff --git a/tests/spec/arb_texture_storage_multisample/tex-param.c b/tests/spec/arb_texture_storage_multisample/tex-param.c index bc40ecc82..531e71779 100644 --- a/tests/spec/arb_texture_storage_multisample/tex-param.c +++ b/tests/spec/arb_texture_storage_multisample/tex-param.c @@ -119,7 +119,7 @@ check_subtest(struct subtest *t) return PIGLIT_FAIL; } - /* verify that the new value stuck (or didnt, if we expected failure) */ + /* verify that the new value stuck (or didn't, if we expected failure) */ glGetTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, t->param, &val); expected_val = t->expected_error == GL_NO_ERROR ? t->value : t->initial_value; diff --git a/tests/spec/arb_texture_view/queries.c b/tests/spec/arb_texture_view/queries.c index 026d97ece..b603791a1 100644 --- a/tests/spec/arb_texture_view/queries.c +++ b/tests/spec/arb_texture_view/queries.c @@ -42,7 +42,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN PIGLIT_GL_TEST_CONFIG_END /** - * make sure default intial state is correct for textureView + * make sure default initial state is correct for textureView * In OpenGL Core 4.3 spec see table 23.15 for default values. */ static bool diff --git a/tests/spec/arb_timer_query/timestamp-get.c b/tests/spec/arb_timer_query/timestamp-get.c index fc48d85b0..3fdf3813b 100644 --- a/tests/spec/arb_timer_query/timestamp-get.c +++ b/tests/spec/arb_timer_query/timestamp-get.c @@ -80,7 +80,7 @@ validate_times(GLint64 t1, GLint64 t2, GLint64 tolerance) piglit_report_result(PIGLIT_FAIL); } - /* the tolerance of 1 milisecond seems to be sufficient */ + /* the tolerance of 1 millisecond seems to be sufficient */ if (t2 - t1 > tolerance) { printf("time 1 = %" PRIu64 " us\n", (uint64_t) t1 / 1000); printf("time 2 = %" PRIu64 " us\n", (uint64_t) t2 / 1000); diff --git a/tests/spec/arb_transform_feedback2/api-queries.c b/tests/spec/arb_transform_feedback2/api-queries.c index 03b39e124..d074d29ca 100644 --- a/tests/spec/arb_transform_feedback2/api-queries.c +++ b/tests/spec/arb_transform_feedback2/api-queries.c @@ -129,7 +129,7 @@ void piglit_init(int argc, char **argv) glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id); glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); - /* Verify the initial state of transform feedback object queires. + /* Verify the initial state of transform feedback object queries. */ pass = check_int(GL_TRANSFORM_FEEDBACK_BINDING, id) && pass; diff --git a/tests/spec/arb_transform_feedback2/change-objects-while-paused.c b/tests/spec/arb_transform_feedback2/change-objects-while-paused.c index b81fbd87a..e110e7c65 100644 --- a/tests/spec/arb_transform_feedback2/change-objects-while-paused.c +++ b/tests/spec/arb_transform_feedback2/change-objects-while-paused.c @@ -29,7 +29,7 @@ * * - Bind an XFB object, start XFB, draw something, pause XFB. * - * - Bind a different XFB object, start XFB, draw someting, pause XFB. + * - Bind a different XFB object, start XFB, draw something, pause XFB. * * - Rebind the first XFB object, resume XFB, draw something, end XFB. * diff --git a/tests/spec/arb_transform_feedback3/begin_end.c b/tests/spec/arb_transform_feedback3/begin_end.c index e95c6e657..104cb1f79 100644 --- a/tests/spec/arb_transform_feedback3/begin_end.c +++ b/tests/spec/arb_transform_feedback3/begin_end.c @@ -53,7 +53,7 @@ piglit_init(int argc, char **argv) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &max_attrib_n); if (!max_attrib_n) { - printf("Maximum number of separete attributes is zero\n"); + printf("Maximum number of separate attributes is zero\n"); piglit_report_result(PIGLIT_FAIL); } diff --git a/tests/spec/arb_transform_feedback3/set_invalid_varyings.c b/tests/spec/arb_transform_feedback3/set_invalid_varyings.c index ee4b596a6..80124ed60 100644 --- a/tests/spec/arb_transform_feedback3/set_invalid_varyings.c +++ b/tests/spec/arb_transform_feedback3/set_invalid_varyings.c @@ -160,7 +160,7 @@ piglit_init(int argc, char **argv) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &max_attrib_n); if (!max_attrib_n) { - printf("Maximum number of separete attributes is zero\n"); + printf("Maximum number of separate attributes is zero\n"); piglit_report_result(PIGLIT_FAIL); } diff --git a/tests/spec/arb_transform_feedback3/set_varyings_with_invalid_args.c b/tests/spec/arb_transform_feedback3/set_varyings_with_invalid_args.c index a9efccb19..96262f07a 100644 --- a/tests/spec/arb_transform_feedback3/set_varyings_with_invalid_args.c +++ b/tests/spec/arb_transform_feedback3/set_varyings_with_invalid_args.c @@ -97,7 +97,7 @@ piglit_init(int argc, char **argv) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &max_attrib_n); if (!max_attrib_n) { - printf("Maximum number of separete attributes is zero\n"); + printf("Maximum number of separate attributes is zero\n"); piglit_report_result(PIGLIT_FAIL); } diff --git a/tests/spec/arb_transform_feedback_overflow_query/basic.c b/tests/spec/arb_transform_feedback_overflow_query/basic.c index 017335c98..6ccc0e850 100644 --- a/tests/spec/arb_transform_feedback_overflow_query/basic.c +++ b/tests/spec/arb_transform_feedback_overflow_query/basic.c @@ -326,7 +326,7 @@ run_subtest(int n_streams, int array_sizes[], int stream, GLuint query_type, } else if (!strcmp(test_type, "buffer_object")) { pass = overflow_buffer_object(query, expected); } else { - printf("Unkown test.\n"); + printf("Unknown test.\n"); pass = PIGLIT_FAIL; } diff --git a/tests/spec/arb_uniform_buffer_object/referenced-by-shader.c b/tests/spec/arb_uniform_buffer_object/referenced-by-shader.c index a1d7b93e8..a4229f97a 100644 --- a/tests/spec/arb_uniform_buffer_object/referenced-by-shader.c +++ b/tests/spec/arb_uniform_buffer_object/referenced-by-shader.c @@ -71,7 +71,7 @@ piglit_init(int argc, char **argv) "uniform vsgsfs { float vgf; };\n" "void main() {\n" " for(int i = 0; i < 3; i++) {\n" - " gl_Position = vec4(g + vg + gf + vgf);\n" + " gl_Position = vec4(g + vg + gf + vgf) + gl_in[i].gl_Position;\n" " EmitVertex();\n" " }\n" "}\n"; diff --git a/tests/spec/arb_vertex_attrib_64bit/execution/unused-sub-dvec4-01.shader_test b/tests/spec/arb_vertex_attrib_64bit/execution/unused-sub-dvec4-01.shader_test new file mode 100644 index 000000000..2a467fa39 --- /dev/null +++ b/tests/spec/arb_vertex_attrib_64bit/execution/unused-sub-dvec4-01.shader_test @@ -0,0 +1,57 @@ +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader_fp64 +GL_ARB_vertex_attrib_64bit +GL_ARB_explicit_attrib_location + +[vertex shader] +#version 150 +#extension GL_ARB_gpu_shader_fp64 : require +#extension GL_ARB_vertex_attrib_64bit : require +#extension GL_ARB_explicit_attrib_location : require + +layout(location = 0) in dvec4 position; +layout(location = 1) in dvec4 color0; +layout(location = 2) in dvec4 color1; +layout(location = 3) in dvec4 color2; + +flat out dvec4 fscolor0; +flat out dvec4 fscolor1; +flat out dvec4 fscolor2; + +void main() +{ + gl_Position = vec4(position); + fscolor0 = color0; + fscolor1 = color1; + fscolor2 = color2; +} + +[fragment shader] +#version 150 +#extension GL_ARB_gpu_shader_fp64 : require + +flat in dvec4 fscolor0; +flat in dvec4 fscolor1; +flat in dvec4 fscolor2; + +out vec4 color; + +void main() +{ + // NOTE: fscolor1.zw is unused + color = vec4((fscolor0 + fscolor1.xyyx + fscolor2) / 3.0); +} + +[vertex data] +position/double/4 color0/double/4 color1/double/4 color2/double/4 +-1.0 -1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 + 1.0 -1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 + 1.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 +-1.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 + +[test] +clear color 0.0 0.0 1.0 0.0 +clear +draw arrays GL_TRIANGLE_FAN 0 4 +probe rgba 0 0 0.333333 0.333333 0.333333 1.0 diff --git a/tests/spec/arb_vertex_attrib_64bit/execution/unused-sub-dvec4-02.shader_test b/tests/spec/arb_vertex_attrib_64bit/execution/unused-sub-dvec4-02.shader_test new file mode 100644 index 000000000..a31b29be5 --- /dev/null +++ b/tests/spec/arb_vertex_attrib_64bit/execution/unused-sub-dvec4-02.shader_test @@ -0,0 +1,57 @@ +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader_fp64 +GL_ARB_vertex_attrib_64bit +GL_ARB_explicit_attrib_location + +[vertex shader] +#version 150 +#extension GL_ARB_gpu_shader_fp64 : require +#extension GL_ARB_vertex_attrib_64bit : require +#extension GL_ARB_explicit_attrib_location : require + +layout(location = 0) in dvec4 position; +layout(location = 1) in dvec4 color0; +layout(location = 2) in dvec4 color1; +layout(location = 3) in dvec4 color2; + +flat out dvec4 fscolor0; +flat out dvec4 fscolor1; +flat out dvec4 fscolor2; + +void main() +{ + gl_Position = vec4(position); + fscolor0 = color0; + fscolor1 = color1; + fscolor2 = color2; +} + +[fragment shader] +#version 150 +#extension GL_ARB_gpu_shader_fp64 : require + +flat in dvec4 fscolor0; +flat in dvec4 fscolor1; +flat in dvec4 fscolor2; + +out vec4 color; + +void main() +{ + // NOTE: fscolor1.xy is unused + color = vec4((fscolor0 + fscolor1.wzzw + fscolor2) / 3.0); +} + +[vertex data] +position/double/4 color0/double/4 color1/double/4 color2/double/4 +-1.0 -1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 + 1.0 -1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 + 1.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 +-1.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 + +[test] +clear color 0.0 0.0 1.0 0.0 +clear +draw arrays GL_TRIANGLE_FAN 0 4 +probe rgba 0 0 0.333333 0.333333 0.333333 1.0 diff --git a/tests/spec/arb_vertex_program/get-limits-without-fp.c b/tests/spec/arb_vertex_program/get-limits-without-fp.c index d4f2b3eab..6c2bedc61 100644 --- a/tests/spec/arb_vertex_program/get-limits-without-fp.c +++ b/tests/spec/arb_vertex_program/get-limits-without-fp.c @@ -29,7 +29,7 @@ * \file get-vp-limit-without-fp.c * * Test for the crash reported in bugs.freedesktop.org bug #24066. - * This occured when the native limits of a vertex program are queried + * This occurred when the native limits of a vertex program are queried * before a fragment program has been setup. */ diff --git a/tests/spec/arb_vertex_program/property-bindings.c b/tests/spec/arb_vertex_program/property-bindings.c index 381ecab2f..f9d0c947e 100644 --- a/tests/spec/arb_vertex_program/property-bindings.c +++ b/tests/spec/arb_vertex_program/property-bindings.c @@ -361,11 +361,19 @@ piglit_display(void) glFogfv(GL_FOG_COLOR, val); pass = check_prg_param(val, "state.fog.color") && pass; - random_vec4(val); + /* Don't test infinity because shader comparisons with infinity are + * undefined. + */ + float fog_scale; + do { + random_vec4(val); + fog_scale = 1 / (val[2] - val[1]); + } while (isinf(fog_scale)); + glFogf(GL_FOG_DENSITY, val[0]); glFogf(GL_FOG_START, val[1]); glFogf(GL_FOG_END, val[2]); - val[3] = 1 / (val[2] - val[1]); + val[3] = fog_scale; pass = check_prg_param(val, "state.fog.params") && pass; /* Clip Plane Property Bindings */ diff --git a/tests/spec/arb_viewport_array/bounds.c b/tests/spec/arb_viewport_array/bounds.c index 8d43e9f97..e3717c5db 100644 --- a/tests/spec/arb_viewport_array/bounds.c +++ b/tests/spec/arb_viewport_array/bounds.c @@ -74,7 +74,7 @@ viewport_bounds(GLint maxVP) bool pass = true; int i; - /* intial values for x,y,w,h */ + /* initial values for x,y,w,h */ for (i = 0; i < maxVP; i++) { glGetFloati_v(GL_VIEWPORT, i, vp); if (vp[0] != 0.0 || vp[1] != 0.0 || @@ -154,7 +154,7 @@ depth_range_bounds(GLint maxVP) #endif int i; - /* intial values for near, far are 0.0, 1.0 repsectively */ + /* initial values for near, far are 0.0, 1.0 respectively */ for (i = 0; i < maxVP; i++) { #ifdef PIGLIT_USE_OPENGL glGetDoublei_v(GL_DEPTH_RANGE, i, dr); @@ -219,7 +219,7 @@ scissor_bounds(GLint maxVP) bool pass = true; int i; - /* intial values for left, bottom, width, height */ + /* initial values for left, bottom, width, height */ for (i = 0; i < maxVP; i++) { glGetIntegeri_v(GL_SCISSOR_BOX, i, sc); if (sc[0] != 0 || sc[1] != 0 || sc[2] != piglit_width || diff --git a/tests/spec/arb_viewport_array/queries.c b/tests/spec/arb_viewport_array/queries.c index efd280b30..af9c20537 100644 --- a/tests/spec/arb_viewport_array/queries.c +++ b/tests/spec/arb_viewport_array/queries.c @@ -84,7 +84,7 @@ piglit_init(int argc, char **argv) * depthrange-indices and viewport-indices tests. * OpenGL 4.3 Core section 22.1 ref: * "An INVALID_ENUM error is generated if target is not - * indexed state queriable with these commands." + * indexed state queryable with these commands." */ for (i = 0; i < ARRAY_SIZE(tokens); i++) { glGetFloati_v(tokens[i], 1, valf); diff --git a/tests/spec/arb_viewport_array/render_scissor.c b/tests/spec/arb_viewport_array/render_scissor.c index 93f07754a..b6e5b6374 100644 --- a/tests/spec/arb_viewport_array/render_scissor.c +++ b/tests/spec/arb_viewport_array/render_scissor.c @@ -52,7 +52,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN PIGLIT_GL_TEST_CONFIG_END -/* number of viewport/scissor rectangle divisons in x and y */ +/* number of viewport/scissor rectangle divisions in x and y */ static const int divX=2, divY=3; /** @@ -128,7 +128,7 @@ draw_multi_scissor_rect(void) * Draws a single quad full window size, with different scissor rectangles * and different scissor test enables for each viewport index. * Scissor rectangles or viewport restrict drawing to sub-area of full - * window surface. Geometry shader is responsible for exapnding primitves + * window surface. Geometry shader is responsible for exapnding primitives * to cover all divX * divY viewport/scissor indices. The function reads * back the expected color to test if the scissored drawing was correct. */ diff --git a/tests/spec/arb_viewport_array/viewport_indices.c b/tests/spec/arb_viewport_array/viewport_indices.c index 567f83d36..8f8aa0590 100644 --- a/tests/spec/arb_viewport_array/viewport_indices.c +++ b/tests/spec/arb_viewport_array/viewport_indices.c @@ -161,7 +161,7 @@ test_preserve_invalid_index(GLint maxVP) GLboolean scEnabled; int i; - /* intialize all indices to know values */ + /* initialize all indices to know values */ for (i = 0; i < maxVP; i++) { glViewportIndexedfv(i, vp); #ifdef PIGLIT_USE_OPENGL diff --git a/tests/spec/ati_draw_buffers/arbfp-no-index.c b/tests/spec/ati_draw_buffers/arbfp-no-index.c index b928cab63..cb86203f1 100644 --- a/tests/spec/ati_draw_buffers/arbfp-no-index.c +++ b/tests/spec/ati_draw_buffers/arbfp-no-index.c @@ -152,18 +152,13 @@ piglit_display(void) void piglit_init(int argc, char **argv) { - GLint num; - piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); piglit_require_extension("GL_EXT_framebuffer_object"); piglit_require_extension("GL_ATI_draw_buffers"); piglit_require_extension("GL_ARB_fragment_program"); piglit_require_extension("GL_ARB_vertex_program"); - - glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &num); - if (num < 2) - piglit_report_result(PIGLIT_SKIP); + piglit_require_minimum_getinteger(GL_MAX_DRAW_BUFFERS_ARB, 2); piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, mrt_fp_string); } diff --git a/tests/spec/ati_draw_buffers/arbfp-no-option.c b/tests/spec/ati_draw_buffers/arbfp-no-option.c index ae062cca0..00e03245f 100644 --- a/tests/spec/ati_draw_buffers/arbfp-no-option.c +++ b/tests/spec/ati_draw_buffers/arbfp-no-option.c @@ -138,16 +138,11 @@ piglit_display(void) void piglit_init(int argc, char **argv) { - GLint num; - piglit_require_extension("GL_EXT_framebuffer_object"); piglit_require_extension("GL_ATI_draw_buffers"); piglit_require_extension("GL_ARB_fragment_program"); piglit_require_extension("GL_ARB_vertex_program"); - - glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &num); - if (num < 2) - piglit_report_result(PIGLIT_SKIP); + piglit_require_minimum_getinteger(GL_MAX_DRAW_BUFFERS_ARB, 2); piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, mrt_fp_string); } diff --git a/tests/spec/ati_draw_buffers/arbfp.c b/tests/spec/ati_draw_buffers/arbfp.c index 34805c3aa..5d4c3a5bb 100644 --- a/tests/spec/ati_draw_buffers/arbfp.c +++ b/tests/spec/ati_draw_buffers/arbfp.c @@ -144,18 +144,13 @@ piglit_display(void) void piglit_init(int argc, char **argv) { - GLint num; - piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); piglit_require_extension("GL_EXT_framebuffer_object"); piglit_require_extension("GL_ATI_draw_buffers"); piglit_require_extension("GL_ARB_fragment_program"); piglit_require_extension("GL_ARB_vertex_program"); - - glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &num); - if (num < 2) - piglit_report_result(PIGLIT_SKIP); + piglit_require_minimum_getinteger(GL_MAX_DRAW_BUFFERS_ARB, 2); piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, mrt_fp_string); } diff --git a/tests/spec/ext_clear_texture/base-formats.c b/tests/spec/ext_clear_texture/base-formats.c index edf8738fa..7eb5eb670 100644 --- a/tests/spec/ext_clear_texture/base-formats.c +++ b/tests/spec/ext_clear_texture/base-formats.c @@ -29,7 +29,7 @@ * texture where the first four texels are cleared to known values * using separate calls to glClearTexSubImage. The values are chosen * to potentially trigger problems with signed conversions for integer - * textures. The restof the texture is initalised to zeroes. The textures + * textures. The restof the texture is initialised to zeroes. The textures * are then read back by attaching them to a fbo and calling glReadPixels * or glReadnPixelsKHR if robustness is supported. */ diff --git a/tests/spec/ext_debug_label/CMakeLists.gl.txt b/tests/spec/ext_debug_label/CMakeLists.gl.txt new file mode 100644 index 000000000..b08a2e547 --- /dev/null +++ b/tests/spec/ext_debug_label/CMakeLists.gl.txt @@ -0,0 +1,13 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} +) + +piglit_add_executable (ext_debug_label-object-label_${piglit_target_api} debug-object-label.c) + +# vim: ft=cmake: diff --git a/tests/spec/ext_debug_label/CMakeLists.gles2.txt b/tests/spec/ext_debug_label/CMakeLists.gles2.txt new file mode 100644 index 000000000..413dc3cd2 --- /dev/null +++ b/tests/spec/ext_debug_label/CMakeLists.gles2.txt @@ -0,0 +1,13 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${EGL_LDFLAGS} +) + +piglit_add_executable (ext_debug_label-object-label_${piglit_target_api} debug-object-label.c) + +# vim: ft=cmake: diff --git a/tests/spec/ext_debug_label/CMakeLists.gles3.txt b/tests/spec/ext_debug_label/CMakeLists.gles3.txt new file mode 100644 index 000000000..413dc3cd2 --- /dev/null +++ b/tests/spec/ext_debug_label/CMakeLists.gles3.txt @@ -0,0 +1,13 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${EGL_LDFLAGS} +) + +piglit_add_executable (ext_debug_label-object-label_${piglit_target_api} debug-object-label.c) + +# vim: ft=cmake: diff --git a/tests/spec/ext_debug_label/CMakeLists.txt b/tests/spec/ext_debug_label/CMakeLists.txt new file mode 100644 index 000000000..144a306f4 --- /dev/null +++ b/tests/spec/ext_debug_label/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/ext_debug_label/debug-object-label.c b/tests/spec/ext_debug_label/debug-object-label.c new file mode 100644 index 000000000..715dc1955 --- /dev/null +++ b/tests/spec/ext_debug_label/debug-object-label.c @@ -0,0 +1,436 @@ +/* + * Copyright (c) 2013 Timothy Arceri <t_arceri@yahoo.com.au> + * + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 + * NON-INFRINGEMENT. IN NO EVENT SHALL AUTHORS AND/OR THEIR SUPPLIERS + * 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. + */ + +#include "piglit-util-gl.h" + +static const char *TestLabel = "Test Label"; +#define TestLabelLen 10 + +PIGLIT_GL_TEST_CONFIG_BEGIN + +#ifdef PIGLIT_USE_OPENGL + config.supports_gl_compat_version = 11; +#else /* using GLES */ + config.supports_gl_es_version = 11; +#endif + + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE; + config.khr_no_error_support = PIGLIT_HAS_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_PASS; +} + +/* <label> will be null-terminated. The actual number of + * characters written into <label>, + * excluding the null terminator, is returned in <length>. + */ +static bool +check_label_and_length(char *label, int length, GLenum object) +{ + bool pass = true; + const char *name = piglit_get_gl_enum_name(object); + + printf("Checking label and length of %s object\n", name); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + pass = false; + + if (length != TestLabelLen || (strcmp(TestLabel, label) != 0)) { + fprintf(stderr, "Label or length does not match in %s object\n", name); + printf(" actual label: %s actual length: %i\n", label, length); + printf(" expected label: %s expected length: %i\n", TestLabel, TestLabelLen); + pass = false; + } + + return pass; +} + +/* trivial tests to get/set labels on all the different types of objects */ +static bool +test_object_label_types() +{ + #define numObjects 12 + GLsizei length[numObjects]; /* create a fresh variable for each object to test */ + GLchar label[numObjects][TestLabelLen + 1]; + bool pass = true; + + enum test_object_indices { + BUFFER_IDX, SHADER_IDX, PROGRAM_IDX, VERTEX_ARRAY_IDX, RENDERBUFFER_IDX, + FRAMEBUFFER_IDX, QUERY_IDX, PROGRAM_PIPELINE_IDX, TRANSFORM_FEEDBACK_IDX, + SAMPLER_IDX, TEXTURE_IDX, DISPLAY_LIST_IDX + }; + + GLuint buffer; + GLuint shader; + GLuint program; + GLuint vertexArray; + GLuint query; +#ifdef PIGLIT_USE_OPENGL + GLuint programPipeline; +#endif + GLuint transformFeedback; + GLuint sampler; + GLuint texture; + GLuint renderbuffer; + GLuint framebuffer; + + /* Test BUFFER */ + glGenBuffers(1, &buffer); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glLabelObjectEXT(GL_BUFFER_OBJECT_EXT, buffer, 0, TestLabel); + glGetObjectLabelEXT(GL_BUFFER_OBJECT_EXT, buffer, TestLabelLen + 1, &length[BUFFER_IDX], label[BUFFER_IDX]); + + pass = check_label_and_length(label[BUFFER_IDX], length[BUFFER_IDX], + GL_BUFFER) && pass; + + glDeleteBuffers(1, &buffer); + + if (piglit_get_gl_version() >= 20) { + /* Test SHADER */ + shader = glCreateShader(GL_FRAGMENT_SHADER); + glLabelObjectEXT(GL_SHADER_OBJECT_EXT, shader, 0, TestLabel); + glGetObjectLabelEXT(GL_SHADER_OBJECT_EXT, shader, TestLabelLen + 1, + &length[SHADER_IDX], label[SHADER_IDX]); + + pass = check_label_and_length(label[SHADER_IDX], length[SHADER_IDX], + GL_SHADER) && pass; + + glDeleteShader(shader); + + /* Test PROGRAM */ + program = glCreateProgram(); + glLabelObjectEXT(GL_PROGRAM_OBJECT_EXT, program, 0, TestLabel); + glGetObjectLabelEXT(GL_PROGRAM_OBJECT_EXT, program, TestLabelLen + 1, + &length[PROGRAM_IDX], label[PROGRAM_IDX]); + + pass = check_label_and_length(label[PROGRAM_IDX], length[PROGRAM_IDX], + GL_PROGRAM) && pass; + + glDeleteProgram(program); + } + + /* GL or GLES >= 3.0 supports vertex arrays*/ + if (piglit_get_gl_version() >= 30) { + /* Test VERTEX_ARRAY */ + glGenVertexArrays(1, &vertexArray); + glBindVertexArray(vertexArray); + glLabelObjectEXT(GL_VERTEX_ARRAY_OBJECT_EXT, vertexArray, 0, TestLabel); + glGetObjectLabelEXT(GL_VERTEX_ARRAY_OBJECT_EXT, vertexArray, TestLabelLen + 1, + &length[VERTEX_ARRAY_IDX], label[VERTEX_ARRAY_IDX]); + + pass = check_label_and_length(label[VERTEX_ARRAY_IDX], length[VERTEX_ARRAY_IDX], + GL_VERTEX_ARRAY) && pass; + + glDeleteVertexArrays(1, &vertexArray); + } + + /* GLES supports render buffer and frame buffer since 2.0 */ + if (piglit_is_gles() || piglit_get_gl_version() >= 30) { + /* Test RENDERBUFFER */ + glGenRenderbuffers(1, &renderbuffer); + glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); + glLabelObjectEXT(GL_RENDERBUFFER, renderbuffer, 0, TestLabel); + glGetObjectLabelEXT(GL_RENDERBUFFER, renderbuffer, TestLabelLen + 1, + &length[RENDERBUFFER_IDX], label[RENDERBUFFER_IDX]); + + pass = check_label_and_length(label[RENDERBUFFER_IDX], length[RENDERBUFFER_IDX], + GL_RENDERBUFFER) && pass; + + glDeleteRenderbuffers(1, &renderbuffer); + + /* Test FRAMEBUFFER */ + glGenFramebuffers(1, &framebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); + glLabelObjectEXT(GL_FRAMEBUFFER, framebuffer, 0, TestLabel); + glGetObjectLabelEXT(GL_FRAMEBUFFER, framebuffer, TestLabelLen + 1, + &length[FRAMEBUFFER_IDX], label[FRAMEBUFFER_IDX]); + + pass = check_label_and_length(label[FRAMEBUFFER_IDX], length[FRAMEBUFFER_IDX], + GL_FRAMEBUFFER) && pass; + + glDeleteFramebuffers(1, &framebuffer); + } + + /* GLES >= 3.0 or GL compat */ + if (piglit_is_extension_supported("GL_ARB_occlusion_query") || + piglit_get_gl_version() >= 30) { + /* Test QUERY */ + glGenQueries(1, &query); + if (piglit_is_gles()) { + glBeginQuery(GL_ANY_SAMPLES_PASSED, query); + glEndQuery(GL_ANY_SAMPLES_PASSED); + } else { + glBeginQuery(GL_SAMPLES_PASSED, query); + glEndQuery(GL_SAMPLES_PASSED); + } + glLabelObjectEXT(GL_QUERY_OBJECT_EXT, query, 0, TestLabel); + glGetObjectLabelEXT(GL_QUERY_OBJECT_EXT, query, TestLabelLen + 1, &length[QUERY_IDX], label[QUERY_IDX]); + + pass = check_label_and_length(label[QUERY_IDX], length[QUERY_IDX], + GL_QUERY) && pass; + + glDeleteQueries(1, &query); + } + +#ifdef PIGLIT_USE_OPENGL + /* Test PROGRAM_PIPELINE */ + if (piglit_is_extension_supported("GL_ARB_separate_shader_objects")) { + glGenProgramPipelines(1, &programPipeline); + glBindProgramPipeline(programPipeline); + glLabelObjectEXT(GL_PROGRAM_PIPELINE_OBJECT_EXT, programPipeline, 0, TestLabel); + glGetObjectLabelEXT(GL_PROGRAM_PIPELINE_OBJECT_EXT, programPipeline, TestLabelLen + 1, + &length[PROGRAM_PIPELINE_IDX], label[PROGRAM_PIPELINE_IDX]); + + pass = check_label_and_length(label[PROGRAM_PIPELINE_IDX], length[PROGRAM_PIPELINE_IDX], + GL_PROGRAM_PIPELINE) && pass; + + glDeleteProgramPipelines(1, &programPipeline); + } +#endif /* PIGLIT_USE_OPENGL */ + + /* Test TRANSFORM_FEEDBACK */ + if ((piglit_is_gles() && piglit_get_gl_version() >= 30) || + piglit_is_extension_supported("GL_ARB_transform_feedback2")) { + glGenTransformFeedbacks(1, &transformFeedback); + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformFeedback); + glLabelObjectEXT(GL_TRANSFORM_FEEDBACK, transformFeedback, 0, TestLabel); + glGetObjectLabelEXT(GL_TRANSFORM_FEEDBACK, transformFeedback, TestLabelLen + 1, + &length[TRANSFORM_FEEDBACK_IDX], label[TRANSFORM_FEEDBACK_IDX]); + + pass = check_label_and_length(label[TRANSFORM_FEEDBACK_IDX], length[TRANSFORM_FEEDBACK_IDX], + GL_TRANSFORM_FEEDBACK) && pass; + + glDeleteTransformFeedbacks(1, &transformFeedback); + } + + /* Test SAMPLER */ + if ((piglit_is_gles() && piglit_get_gl_version() >= 30) || + piglit_is_extension_supported("GL_ARB_sampler_objects")) { + glGenSamplers(1, &sampler); + glBindSampler(0, sampler); + glLabelObjectEXT(GL_SAMPLER, sampler, 0, TestLabel); + glGetObjectLabelEXT(GL_SAMPLER, sampler, TestLabelLen + 1, &length[SAMPLER_IDX], label[SAMPLER_IDX]); + + pass = check_label_and_length(label[SAMPLER_IDX], length[SAMPLER_IDX], + GL_SAMPLER) && pass; + + glDeleteSamplers(1, &sampler); + } + + /* Test TEXTURE */ + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glLabelObjectEXT(GL_TEXTURE, texture, 0, TestLabel); + glGetObjectLabelEXT(GL_TEXTURE, texture, TestLabelLen + 1, &length[TEXTURE_IDX], label[TEXTURE_IDX]); + + pass = check_label_and_length(label[TEXTURE_IDX], length[TEXTURE_IDX], + GL_TEXTURE) && pass; + + glDeleteTextures(1, &texture); + + return pass; +} + +static bool +test_object_label() +{ + GLsizei length; + GLuint buffer; + GLuint invalidBufferName; + GLchar label[TestLabelLen + 1]; + bool pass = true; + + puts("Test LabelObject"); + + glGenBuffers(1, &buffer); + + /* If <label> is NULL, any debug label is effectively removed from the object. + */ + glLabelObjectEXT(GL_BUFFER, buffer, 0, TestLabel); + glLabelObjectEXT(GL_BUFFER, buffer, 0, NULL); + glGetObjectLabelEXT(GL_BUFFER, buffer, TestLabelLen + 1, &length, label); + + if (length != 0 || (strcmp("", label) != 0)) { + fprintf(stderr, "Setting label to NULL should remove the label\n"); + printf(" actual label: %s actual length: %i\n", label, length); + pass = false; + } + + /* An INVALID_ENUM error is generated by ObjectLabel if <identifier> is not + * one of the object types. + */ + glLabelObjectEXT(GL_ARRAY_BUFFER, buffer, 0, TestLabel); + + if (!piglit_check_gl_error(GL_INVALID_ENUM)) { + fprintf(stderr, "GL_INVALID_ENUM should be generated when the LabelObject identifier is invalid\n"); + pass = false; + } + + /* INVALID_VALUE is generated by LabelObjectEXT if <length> is less than zero. */ + glLabelObjectEXT(GL_BUFFER, buffer, -1, TestLabel); + + if (!piglit_check_gl_error(GL_INVALID_VALUE)) { + fprintf(stderr, "GL_INVALID_VALUE should be generated when the LabelObject length is less than 0\n"); + pass = false; + } + + /* INVALID_OPERATION is generated by LabelObjectEXT + * if the type of <object> does not match <type>. + */ + invalidBufferName = buffer; + glDeleteBuffers(1, &buffer); + glLabelObjectEXT(GL_BUFFER, invalidBufferName, 0, TestLabel); + + if (!piglit_check_gl_error(GL_INVALID_OPERATION)) { + fprintf(stderr, "GL_INVALID_OPERATION should be generated when the LabelObject name is invalid\n"); + pass = false; + } + + return pass; +} + +static bool +test_get_object_label() +{ + #define numBuffers 4 + GLsizei length; + GLuint buffers[numBuffers]; + GLuint invalidBufferName; + GLchar label[TestLabelLen + 1]; + bool pass = true; + + enum test_object_indices { + TEST_BUFSIZE_IDX, TEST_NO_LABEL_IDX, TEST_NULL_LABEL_IDX, TEST_NULL_LENGTH_IDX + }; + + puts("Test GetObjectLabel"); + + glGenBuffers(numBuffers, buffers); + + /* The maximum number of characters that may + * be written into <label>, including the null terminator, is specified by + * <bufSize>. + */ + glBindBuffer(GL_ARRAY_BUFFER, buffers[TEST_BUFSIZE_IDX]); + glLabelObjectEXT(GL_BUFFER, buffers[TEST_BUFSIZE_IDX], 0, TestLabel); + glGetObjectLabelEXT(GL_BUFFER, buffers[TEST_BUFSIZE_IDX], TestLabelLen, &length, label); + + if (length != 9 || (strcmp("Test Labe", label) != 0)) { + fprintf(stderr, "BufSize should limit the maximum label length to 9\n"); + printf(" actual label: %s actual length: %i\n", label, length); + pass = false; + } + + /* If no debug label was specified for the object then <label> + * will contain a null-terminated empty string, and zero will be returned + * in <length>. + */ + glBindBuffer(GL_ARRAY_BUFFER, buffers[TEST_NO_LABEL_IDX]); + glGetObjectLabelEXT(GL_BUFFER, buffers[TEST_NO_LABEL_IDX], TestLabelLen + 1, &length, label); + + if (length != 0 || (strcmp("", label) != 0)) { + fprintf(stderr, "Label should be empty and length 0\n"); + printf(" actual label: %s actual length: %i\n", label, length); + pass = false; + } + + /* If <label> is NULL and <length> is non-NULL then no string + * will be returned and the length of the label will be returned in + * <length>. + */ + glBindBuffer(GL_ARRAY_BUFFER, buffers[TEST_NULL_LABEL_IDX]); + glLabelObjectEXT(GL_BUFFER, buffers[TEST_NULL_LABEL_IDX], 0, TestLabel); + glGetObjectLabelEXT(GL_BUFFER, buffers[TEST_NULL_LABEL_IDX], TestLabelLen + 1, &length, NULL); + + if (length != TestLabelLen) { + fprintf(stderr, "Label length should be %i\n", TestLabelLen); + printf(" actual length: %i\n", length); + pass = false; + } + + /* If <length> is NULL, no length is returned. + */ + glBindBuffer(GL_ARRAY_BUFFER, buffers[TEST_NULL_LENGTH_IDX]); + glLabelObjectEXT(GL_BUFFER, buffers[TEST_NULL_LENGTH_IDX], 0, TestLabel); + glGetObjectLabelEXT(GL_BUFFER, buffers[TEST_NULL_LENGTH_IDX], TestLabelLen + 1, NULL, label); + + if (strcmp(TestLabel, label) != 0) { + fprintf(stderr, "Label doent match expected string when length NULL\n"); + printf(" label: %s expected: %s\n", label, TestLabel); + pass = false; + } + + /* An INVALID_ENUM error is generated by GetObjectLabel if identifier is not + * one of the valid object types + */ + glGetObjectLabelEXT(GL_ARRAY_BUFFER, buffers[TEST_NULL_LENGTH_IDX], TestLabelLen + 1, &length, label); + + if (!piglit_check_gl_error(GL_INVALID_ENUM)) { + fprintf(stderr, "GL_INVALID_ENUM should be generated when GetObjectLabel identifier is invalid\n"); + pass = false; + } + + /* INVALID_VALUE is generated by GetObjectLabelEXT if <bufSize> is less than zero. */ + glGetObjectLabelEXT(GL_BUFFER, buffers[TEST_NULL_LENGTH_IDX], -1, &length, label); + + if (!piglit_check_gl_error(GL_INVALID_VALUE)) { + fprintf(stderr, "GL_INVALID_VALUE should be generated when GetObjectLabel bufSize is less than 0\n"); + pass = false; + } + + /* INVALID_OPERATION is generated by GetObjectLabelEXT + * if the type of <object> does not match <type>. + */ + invalidBufferName = buffers[TEST_NULL_LENGTH_IDX]; + glDeleteBuffers(numBuffers, buffers); + glGetObjectLabelEXT(GL_BUFFER, invalidBufferName, TestLabelLen + 1, &length, label); + + if (!piglit_check_gl_error(GL_INVALID_OPERATION)) { + fprintf(stderr, "GL_INVALID_OPERATION should be generated when GetObjectLabel name is invalid\n"); + pass = false; + } + + return pass; +} + +void piglit_init(int argc, char **argv) +{ + bool pass = true; + +#ifdef PIGLIT_USE_OPENGL + piglit_require_gl_version(11); +#endif + piglit_require_extension("GL_EXT_debug_label"); + + pass = test_object_label_types() && pass; + pass = test_object_label() && pass; + pass = test_get_object_label() && pass; + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} diff --git a/tests/spec/ext_disjoint_timer_query/simple-query.c b/tests/spec/ext_disjoint_timer_query/simple-query.c index 17d054ce9..b7e4bb31e 100644 --- a/tests/spec/ext_disjoint_timer_query/simple-query.c +++ b/tests/spec/ext_disjoint_timer_query/simple-query.c @@ -24,7 +24,7 @@ /** * @file * Tests GL_EXT_disjoint_timer_query extension. Test does not to cover - * the whole API as that is tested throughly by existing query tests for + * the whole API as that is tested thoroughly by existing query tests for * desktop GL. Main objective is to test that timer queries work on OpenGL * ES 2.0 and we can get GL_GPU_DISJOINT_EXT value from the driver. */ @@ -132,7 +132,7 @@ piglit_display(void) glGetQueryObjectui64vEXT(query, GL_QUERY_RESULT_EXT, &time); - /* Check if disjoint operation occured. */ + /* Check if disjoint operation occurred. */ glGetInteger64vEXT(GL_GPU_DISJOINT_EXT, &disjoint); if (!piglit_check_gl_error(GL_NO_ERROR)) piglit_report_result(PIGLIT_FAIL); diff --git a/tests/spec/ext_external_objects/helpers.c b/tests/spec/ext_external_objects/helpers.c index 661da8d2f..897cb8a09 100644 --- a/tests/spec/ext_external_objects/helpers.c +++ b/tests/spec/ext_external_objects/helpers.c @@ -55,22 +55,7 @@ check_bound_fbo_status(void) { GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { - switch(status) { - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - fprintf(stderr, "GL FBO status: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT\n"); - break; - case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: - fprintf(stderr, "GL FBO status: GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS\n"); - break; - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: - fprintf(stderr, "GL FBO status: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT\n"); - break; - case GL_FRAMEBUFFER_UNSUPPORTED: - fprintf(stderr, "GL FBO status: GL_FRAMEBUFFER_UNSUPPORTED\n"); - break; - default: - fprintf(stderr, "GL FBO status: Unknown\n"); - } + fprintf(stderr, "GL FBO status: %s\n", piglit_get_gl_enum_name(status)); return false; } return true; diff --git a/tests/spec/ext_external_objects/params.h b/tests/spec/ext_external_objects/params.h index 87f75059e..ca9ff8c3c 100644 --- a/tests/spec/ext_external_objects/params.h +++ b/tests/spec/ext_external_objects/params.h @@ -29,9 +29,6 @@ #include "interop.h" -uint32_t w; -uint32_t h; -uint32_t d = 1; uint32_t num_samples = 1; uint32_t num_levels = 1; uint32_t num_layers = 1; diff --git a/tests/spec/ext_external_objects/semaphore-api-errors.c b/tests/spec/ext_external_objects/semaphore-api-errors.c index e20276a5f..cf8fa3d3d 100644 --- a/tests/spec/ext_external_objects/semaphore-api-errors.c +++ b/tests/spec/ext_external_objects/semaphore-api-errors.c @@ -51,7 +51,7 @@ test_gen_semaphores_value_errors() static bool test_delete_semaphores_value_errors() { - GLuint sem; + GLuint sem = 0; glDeleteSemaphoresEXT(-1, &sem); diff --git a/tests/spec/ext_external_objects/vk.c b/tests/spec/ext_external_objects/vk.c index 7c7bf619c..d5ff36097 100644 --- a/tests/spec/ext_external_objects/vk.c +++ b/tests/spec/ext_external_objects/vk.c @@ -235,7 +235,7 @@ create_renderpass(struct vk_ctx *ctx, struct vk_image_props *color_img_props, struct vk_image_props *depth_img_props) { - uint32_t num_attachments = 2; + uint32_t num_attachments = depth_img_props ? 2 : 1; VkAttachmentDescription att_dsc[2]; VkAttachmentReference att_rfc[2]; VkSubpassDescription subpass_dsc[1]; @@ -253,21 +253,24 @@ create_renderpass(struct vk_ctx *ctx, att_dsc[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; att_dsc[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - att_dsc[1].samples = get_num_samples(depth_img_props->num_samples); - /* We might want to reuse a depth buffer */ - if (depth_img_props->in_layout != VK_IMAGE_LAYOUT_UNDEFINED) { - att_dsc[1].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; - att_dsc[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; - } - else { - att_dsc[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - att_dsc[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + if (depth_img_props) { + + att_dsc[1].samples = get_num_samples(depth_img_props->num_samples); + /* We might want to reuse a depth buffer */ + if (depth_img_props->in_layout != VK_IMAGE_LAYOUT_UNDEFINED) { + att_dsc[1].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + att_dsc[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + } + else { + att_dsc[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + att_dsc[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + } + att_dsc[1].storeOp = VK_ATTACHMENT_STORE_OP_STORE; + att_dsc[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; + att_dsc[1].initialLayout = depth_img_props->in_layout; + att_dsc[1].finalLayout = depth_img_props->end_layout; + att_dsc[1].format = depth_img_props->format; } - att_dsc[1].storeOp = VK_ATTACHMENT_STORE_OP_STORE; - att_dsc[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; - att_dsc[1].initialLayout = depth_img_props->in_layout; - att_dsc[1].finalLayout = depth_img_props->end_layout; - att_dsc[1].format = depth_img_props->format; /* VkAttachmentReference */ memset(att_rfc, 0, num_attachments * sizeof att_rfc[0]); @@ -275,15 +278,20 @@ create_renderpass(struct vk_ctx *ctx, att_rfc[0].layout = color_img_props->tiling == VK_IMAGE_TILING_OPTIMAL ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL; att_rfc[0].attachment = 0; - att_rfc[1].layout = depth_img_props->tiling == VK_IMAGE_TILING_OPTIMAL ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL; - att_rfc[1].attachment = 1; + if (depth_img_props) { + att_rfc[1].layout = depth_img_props->tiling == VK_IMAGE_TILING_OPTIMAL ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL; + att_rfc[1].attachment = 1; + } /* VkSubpassDescription */ memset(&subpass_dsc, 0, sizeof subpass_dsc); subpass_dsc[0].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; subpass_dsc[0].colorAttachmentCount = 1; subpass_dsc[0].pColorAttachments = &att_rfc[0]; - subpass_dsc[0].pDepthStencilAttachment = &att_rfc[1]; + + if (depth_img_props) { + subpass_dsc[0].pDepthStencilAttachment = &att_rfc[1]; + } /* VkRenderPassCreateInfo */ memset(&rpass_info, 0, sizeof rpass_info); @@ -405,7 +413,7 @@ create_framebuffer(struct vk_ctx *ctx, VkImageViewType view_type = get_image_view_type(&color_att->props); VkImageView atts[2]; - if (!color_att->obj.img || !depth_att->obj.img) { + if (!color_att->obj.img || (depth_att && !depth_att->obj.img)) { fprintf(stderr, "Invalid framebuffer attachment image.\n"); goto fail; } @@ -443,30 +451,34 @@ create_framebuffer(struct vk_ctx *ctx, goto fail; } - /* depth view */ - memset(&sr, 0, sizeof sr); - sr.aspectMask = get_aspect_from_depth_format(depth_att->props.format); - sr.baseMipLevel = 0; - sr.levelCount = depth_att->props.num_levels ? depth_att->props.num_levels : 1; - sr.baseArrayLayer = 0; - sr.layerCount = depth_att->props.num_layers ? depth_att->props.num_layers : 1; - - memset(&depth_info, 0, sizeof depth_info); - depth_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - depth_info.image = depth_att->obj.img; - depth_info.viewType = depth_att->props.num_layers > 1 ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D; - depth_info.viewType = VK_IMAGE_VIEW_TYPE_2D; - depth_info.format = depth_att->props.format; - depth_info.subresourceRange = sr; - - if (vkCreateImageView(ctx->dev, &depth_info, 0, &depth_att->obj.img_view) != VK_SUCCESS) { - fprintf(stderr, "Failed to create depth image view for framebuffer.\n"); - vk_destroy_ext_image(ctx, &depth_att->obj); - goto fail; + if (depth_att) { + /* depth view */ + memset(&sr, 0, sizeof sr); + sr.aspectMask = get_aspect_from_depth_format(depth_att->props.format); + sr.baseMipLevel = 0; + sr.levelCount = depth_att->props.num_levels ? depth_att->props.num_levels : 1; + sr.baseArrayLayer = 0; + sr.layerCount = depth_att->props.num_layers ? depth_att->props.num_layers : 1; + + memset(&depth_info, 0, sizeof depth_info); + depth_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; + depth_info.image = depth_att->obj.img; + depth_info.viewType = depth_att->props.num_layers > 1 ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D; + depth_info.viewType = VK_IMAGE_VIEW_TYPE_2D; + depth_info.format = depth_att->props.format; + depth_info.subresourceRange = sr; + + if (vkCreateImageView(ctx->dev, &depth_info, 0, &depth_att->obj.img_view) != VK_SUCCESS) { + fprintf(stderr, "Failed to create depth image view for framebuffer.\n"); + vk_destroy_ext_image(ctx, &depth_att->obj); + goto fail; + } } atts[0] = color_att->obj.img_view; - atts[1] = depth_att->obj.img_view; + + if (depth_att) + atts[1] = depth_att->obj.img_view; memset(&fb_info, 0, sizeof fb_info); fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; @@ -474,7 +486,7 @@ create_framebuffer(struct vk_ctx *ctx, fb_info.width = color_att->props.w; fb_info.height = color_att->props.h; fb_info.layers = color_att->props.num_layers ? color_att->props.num_layers : 1; - fb_info.attachmentCount = 2; + fb_info.attachmentCount = depth_att ? 2 : 1; fb_info.pAttachments = atts; if (vkCreateFramebuffer(ctx->dev, &fb_info, 0, &renderer->fb) != VK_SUCCESS) @@ -1221,7 +1233,7 @@ vk_create_renderer(struct vk_ctx *ctx, if (vert_info) renderer->vertex_info = *vert_info; - renderer->renderpass = create_renderpass(ctx, &color_att->props, &depth_att->props); + renderer->renderpass = create_renderpass(ctx, &color_att->props, depth_att ? &depth_att->props : NULL); if (renderer->renderpass == VK_NULL_HANDLE) goto fail; @@ -1669,7 +1681,7 @@ vk_clear_color(struct vk_ctx *ctx, barrier->sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; bool is_depth = - get_aspect_from_depth_format(att->props.format) != VK_NULL_HANDLE; + get_aspect_from_depth_format(att->props.format) != (uintptr_t)VK_NULL_HANDLE; barrier->oldLayout = is_depth ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : diff --git a/tests/spec/ext_external_objects/vk_buf_exchange.c b/tests/spec/ext_external_objects/vk_buf_exchange.c index f564c68d0..9034d1eca 100644 --- a/tests/spec/ext_external_objects/vk_buf_exchange.c +++ b/tests/spec/ext_external_objects/vk_buf_exchange.c @@ -83,9 +83,6 @@ vk_cleanup(void); static bool gl_init(); -static void -gl_cleanup(void); - static struct vk_ctx vk_core; static struct vk_image_att vk_color_att; static struct vk_image_att vk_depth_att; @@ -112,10 +109,7 @@ piglit_init(int argc, char **argv) atexit(cleanup); - w = piglit_width; - h = piglit_height; - - if (!vk_init(w, h, d, num_samples, num_levels, num_layers, + if (!vk_init(piglit_width, piglit_height, 1, num_samples, num_levels, num_layers, color_format, depth_format, color_tiling, depth_tiling, color_in_layout, depth_in_layout, @@ -135,9 +129,9 @@ piglit_init(int argc, char **argv) } vk_draw(&vk_core, 0, &vk_rnd, vk_fb_color, 4, 0, - false, false, NULL, 0, 0, 0, w, h); + false, false, NULL, 0, 0, 0, piglit_width, piglit_height); - vk_copy_image_to_buffer(&vk_core, &vk_color_att, &vk_bo, w, h); + vk_copy_image_to_buffer(&vk_core, &vk_color_att, &vk_bo, piglit_width, piglit_height); if (!gl_init()) { fprintf(stderr, "Failed to initialize OpenGL.\n"); @@ -294,7 +288,7 @@ gl_init() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_bo); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, w, h, 0, GL_RGBA, GL_FLOAT, 0); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, piglit_width, piglit_height, 0, GL_RGBA, GL_FLOAT, 0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); glBindTexture(GL_TEXTURE_2D, 0); @@ -304,7 +298,6 @@ gl_init() static void cleanup(void) { - gl_cleanup(); vk_cleanup(); } @@ -317,11 +310,3 @@ vk_cleanup(void) vk_destroy_buffer(&vk_core, &vk_bo); vk_cleanup_ctx(&vk_core); } - -static void -gl_cleanup(void) -{ - glDeleteProgram(gl_prog); - glDeleteMemoryObjectsEXT(1, &gl_memobj); - glDeleteBuffers(1, &gl_bo); -} diff --git a/tests/spec/ext_external_objects/vk_depth_display.c b/tests/spec/ext_external_objects/vk_depth_display.c index dea5f1287..ecfd5e16f 100644 --- a/tests/spec/ext_external_objects/vk_depth_display.c +++ b/tests/spec/ext_external_objects/vk_depth_display.c @@ -56,9 +56,6 @@ static void vk_subtest_cleanup(void); static void -gl_cleanup(void); - -static void gl_subtest_cleanup(void); static void @@ -136,9 +133,6 @@ piglit_init(int argc, char **argv) atexit(cleanup); - w = piglit_width; - h = piglit_height; - if (!vk_init()) { fprintf(stderr, "Failed to initialize Vulkan, skipping the test.\n"); piglit_report_result(PIGLIT_SKIP); @@ -187,7 +181,7 @@ run_subtest(int case_num) vk_draw(&vk_core, 0, &vk_rnd, vk_fb_color, - 4, 0, false, false, &vk_depth_att, 1, 0, 0, w, h); + 4, 0, false, false, &vk_depth_att, 1, 0, 0, piglit_width, piglit_height); /* interoperability */ if (!gl_create_mem_obj_from_vk_mem(&vk_core, &vk_depth_att.obj.mobj, @@ -223,7 +217,7 @@ run_subtest(int case_num) /* the result must be: a blue quad that has the green framebuffer * color in the middle */ - if (!piglit_probe_pixel_rgb(w / 2, h / 2, green)) + if (!piglit_probe_pixel_rgb(piglit_width / 2, piglit_height / 2, green)) goto fail; if (!piglit_probe_pixel_rgb(0, 0, blue) || @@ -281,7 +275,7 @@ static bool vk_subtest_init(int case_num) { if (!vk_fill_ext_image_props(&vk_core, - w, h, d, + piglit_width, piglit_height, 1, num_samples, num_levels, num_layers, @@ -300,7 +294,7 @@ vk_subtest_init(int case_num) } if (!vk_fill_ext_image_props(&vk_core, - w, h, d, + piglit_width, piglit_height, 1, num_samples, num_levels, num_layers, @@ -411,21 +405,7 @@ vk_cleanup(void) } static void -gl_cleanup(void) -{ - glBindTexture(GL_TEXTURE_2D, 0); - glUseProgram(0); - - glDeleteTextures(1, &gl_color_tex); - glDeleteFramebuffers(1, &gl_fbo); - - glDeleteProgram(gl_prog); - glDeleteProgram(gl_rnd2fbo_prog); -} - -static void cleanup(void) { - gl_cleanup(); vk_cleanup(); } diff --git a/tests/spec/ext_external_objects/vk_image_display.c b/tests/spec/ext_external_objects/vk_image_display.c index 03543109b..869fdb028 100644 --- a/tests/spec/ext_external_objects/vk_image_display.c +++ b/tests/spec/ext_external_objects/vk_image_display.c @@ -83,12 +83,8 @@ vk_cleanup(void); static bool gl_init(); -static void -gl_cleanup(void); - static struct vk_ctx vk_core; static struct vk_image_att vk_color_att; -static struct vk_image_att vk_depth_att; static struct vk_renderer vk_rnd; static GLenum gl_target = GL_TEXTURE_2D; @@ -112,10 +108,7 @@ void piglit_init(int argc, char **argv) atexit(cleanup); - w = piglit_width; - h = piglit_height; - - if (!vk_init(w, h, d, num_samples, num_levels, num_layers, + if (!vk_init(piglit_width, piglit_height, 1, num_samples, num_levels, num_layers, color_format, depth_format, color_tiling, depth_tiling, color_in_layout, depth_in_layout, @@ -171,10 +164,10 @@ piglit_display(void) glFlush(); } - struct vk_image_att images[] = { vk_color_att, vk_depth_att }; + struct vk_image_att images[] = { vk_color_att }; vk_draw(&vk_core, 0, &vk_rnd, vk_fb_color, 4, &vk_sem, - vk_sem_has_wait, vk_sem_has_signal, images, ARRAY_SIZE(images), 0, 0, w, h); + vk_sem_has_wait, vk_sem_has_signal, images, ARRAY_SIZE(images), 0, 0, piglit_width, piglit_height); layout = gl_get_layout_from_vk(color_end_layout); if (vk_sem_has_signal) { @@ -256,27 +249,6 @@ vk_init(uint32_t w, return false; } - /* depth image */ - if (!vk_fill_ext_image_props(&vk_core, - w, h, d, - num_samples, - num_levels, - num_layers, - depth_format, - depth_tiling, - depth_in_layout, - depth_end_layout, - false, - &vk_depth_att.props)) { - fprintf(stderr, "Unsupported depth image properties.\n"); - return false; - } - - if (!vk_create_ext_image(&vk_core, &vk_depth_att.props, &vk_depth_att.obj)) { - fprintf(stderr, "Failed to create depth image.\n"); - goto fail; - } - /* load shaders */ if (!(vs_src = load_shader(VK_BANDS_VERT, &vs_sz))) goto fail; @@ -287,7 +259,7 @@ vk_init(uint32_t w, /* create Vulkan renderer */ if (!vk_create_renderer(&vk_core, vs_src, vs_sz, fs_src, fs_sz, false, false, - &vk_color_att, &vk_depth_att, 0, &vk_rnd)) { + &vk_color_att, NULL, 0, &vk_rnd)) { fprintf(stderr, "Failed to create Vulkan renderer.\n"); goto fail; } @@ -313,7 +285,6 @@ static void vk_cleanup(void) { vk_destroy_ext_image(&vk_core, &vk_color_att.obj); - vk_destroy_ext_image(&vk_core, &vk_depth_att.obj); vk_destroy_renderer(&vk_core, &vk_rnd); vk_destroy_semaphores(&vk_core, &vk_sem); @@ -324,7 +295,6 @@ vk_cleanup(void) static void cleanup(void) { - gl_cleanup(); vk_cleanup(); } @@ -337,17 +307,3 @@ gl_init() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); return glGetError() == GL_NO_ERROR; } - -static void -gl_cleanup(void) -{ - glBindTexture(gl_target, 0); - - glDeleteTextures(1, &gl_tex); - glDeleteProgram(gl_prog); - - glDeleteSemaphoresEXT(1, &gl_sem.gl_frame_ready); - glDeleteSemaphoresEXT(1, &gl_sem.vk_frame_done); - - glDeleteMemoryObjectsEXT(1, &gl_mem_obj); -} diff --git a/tests/spec/ext_external_objects/vk_image_display_multiple_textures.c b/tests/spec/ext_external_objects/vk_image_display_multiple_textures.c index 3916b009d..00ff26f17 100644 --- a/tests/spec/ext_external_objects/vk_image_display_multiple_textures.c +++ b/tests/spec/ext_external_objects/vk_image_display_multiple_textures.c @@ -83,9 +83,6 @@ vk_cleanup(void); static bool gl_init(); -static void -gl_cleanup(void); - static struct vk_ctx vk_core; static struct vk_image_att vk_color_att; static struct vk_image_att vk_depth_att; @@ -115,10 +112,7 @@ void piglit_init(int argc, char **argv) atexit(cleanup); - w = piglit_width; - h = piglit_height; - - if (!vk_init(w, h, d, num_samples, num_levels, num_layers, + if (!vk_init(piglit_width, piglit_height, 1, num_samples, num_levels, num_layers, color_format, depth_format, color_tiling, depth_tiling, color_in_layout, depth_in_layout, @@ -136,7 +130,7 @@ void piglit_init(int argc, char **argv) struct vk_image_att images[] = { vk_color_att, vk_depth_att }; vk_draw(&vk_core, 0, &vk_rnd, vk_fb_color, 4, 0, - false, false, images, ARRAY_SIZE(images), 0, 0, w, h); + false, false, images, ARRAY_SIZE(images), 0, 0, piglit_width, piglit_height); /* generate NUM_TEX textures */ for (i = 0; i < NUM_TEX; i++) { @@ -318,7 +312,6 @@ vk_cleanup(void) static void cleanup(void) { - gl_cleanup(); vk_cleanup(); } @@ -332,14 +325,3 @@ gl_init() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); return glGetError() == GL_NO_ERROR; } - -static void -gl_cleanup(void) -{ - glBindTexture(gl_target, 0); - - glDeleteTextures(NUM_TEX, gl_textures); - glDeleteProgram(gl_prog); - - glDeleteMemoryObjectsEXT(1, &gl_mem_obj); -} diff --git a/tests/spec/ext_external_objects/vk_image_display_overwrite.c b/tests/spec/ext_external_objects/vk_image_display_overwrite.c index 192bf85e3..09ba7f0db 100644 --- a/tests/spec/ext_external_objects/vk_image_display_overwrite.c +++ b/tests/spec/ext_external_objects/vk_image_display_overwrite.c @@ -107,9 +107,6 @@ vk_cleanup(void); static bool gl_init(); -static void -gl_cleanup(void); - static struct vk_ctx vk_core; static struct vk_image_att vk_color_att; static struct vk_image_att vk_depth_att; @@ -142,10 +139,7 @@ void piglit_init(int argc, char **argv) atexit(cleanup); - w = piglit_width; - h = piglit_height; - - if (!vk_init(w, h, d, num_samples, num_levels, num_layers, + if (!vk_init(piglit_width, piglit_height, 1, num_samples, num_levels, num_layers, color_format, depth_format, color_tiling, depth_tiling, color_in_layout, depth_in_layout, @@ -205,7 +199,7 @@ piglit_display(void) vk_draw(&vk_core, 0, &vk_rnd, vk_fb_color, 4, &vk_sem, vk_sem_has_wait, vk_sem_has_signal, images, ARRAY_SIZE(images), - 0, 0, w, h); + 0, 0, piglit_width, piglit_height); layout = gl_get_layout_from_vk(color_end_layout); if (vk_sem_has_signal) { @@ -221,7 +215,7 @@ piglit_display(void) glBindFramebuffer(GL_FRAMEBUFFER, 0); glFinish(); - vk_copy_image_to_buffer(&vk_core, &vk_color_att, &vk_bo, w, h); + vk_copy_image_to_buffer(&vk_core, &vk_color_att, &vk_bo, piglit_width, piglit_height); if (vkMapMemory(vk_core.dev, vk_bo.mobj.mem, 0, vk_bo.mobj.mem_sz, 0, &pixels) != VK_SUCCESS) { fprintf(stderr, "Failed to map Vulkan image memory.\n"); @@ -232,7 +226,7 @@ piglit_display(void) * pixels we've just read from Vulkan memory as texture data * in a new OpenGL texture */ glBindTexture(gl_target, gl_disp_tex); - glTexSubImage2D(gl_target, 0, 0, 0, w, h, GL_RGBA, GL_FLOAT, pixels); + glTexSubImage2D(gl_target, 0, 0, 0, piglit_width, piglit_height, GL_RGBA, GL_FLOAT, pixels); glFinish(); vkUnmapMemory(vk_core.dev, vk_bo.mobj.mem); @@ -387,7 +381,6 @@ vk_cleanup(void) static void cleanup(void) { - gl_cleanup(); vk_cleanup(); } @@ -419,26 +412,10 @@ gl_init() glBindTexture(gl_target, gl_disp_tex); glTexParameteri(gl_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(gl_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(gl_target, 0, gl_tex_storage_format, w, h, 0, GL_RGBA, GL_FLOAT, 0); + glTexImage2D(gl_target, 0, gl_tex_storage_format, piglit_width, piglit_height, 0, GL_RGBA, GL_FLOAT, 0); glBindTexture(gl_target, 0); glClearColor(0.1, 0.1, 0.1, 1.0); glClear(GL_COLOR_BUFFER_BIT); return glGetError() == GL_NO_ERROR; } - -static void -gl_cleanup(void) -{ - glBindTexture(gl_target, 0); - - glDeleteTextures(1, &gl_tex); - glDeleteProgram(gl_prog); - - glDeleteSemaphoresEXT(1, &gl_sem.gl_frame_ready); - glDeleteSemaphoresEXT(1, &gl_sem.vk_frame_done); - - glDeleteFramebuffers(1, &gl_fbo); - - glDeleteMemoryObjectsEXT(1, &gl_mem_obj); -} diff --git a/tests/spec/ext_external_objects/vk_image_overwrite.c b/tests/spec/ext_external_objects/vk_image_overwrite.c index d5fe3a0d8..a4aefc217 100644 --- a/tests/spec/ext_external_objects/vk_image_overwrite.c +++ b/tests/spec/ext_external_objects/vk_image_overwrite.c @@ -116,9 +116,6 @@ static bool gl_draw_texture(enum fragment_type fs_type, uint32_t w, uint32_t h); static void -gl_cleanup(void); - -static void cleanup(void); void @@ -167,7 +164,7 @@ run_subtest(int case_num) const float color_prb[] = { 0.0, 1.0, 0.0, 1.0 }; GLint loc = -1; - if (!vk_set_image_props(piglit_width, piglit_height, d, + if (!vk_set_image_props(piglit_width, piglit_height, 1, num_samples, num_levels, vk_gl_format[case_num].vkformat, vk_gl_format[case_num].tiling)) { @@ -201,7 +198,6 @@ run_subtest(int case_num) "%s: Failed to create texture from GL memory object.", vk_gl_format[case_num].name); vk_destroy_ext_image(&vk_core, &vk_img_obj); - gl_cleanup(); return PIGLIT_FAIL; } @@ -210,7 +206,6 @@ run_subtest(int case_num) "%s: Failed to initialize OpenGL FBO/RBO", vk_gl_format[case_num].name); vk_destroy_ext_image(&vk_core, &vk_img_obj); - gl_cleanup(); return PIGLIT_FAIL; } @@ -269,7 +264,6 @@ run_subtest(int case_num) default: fprintf(stderr, "Invalid format. Shouldn't reach.\n"); vk_destroy_ext_image(&vk_core, &vk_img_obj); - gl_cleanup(); return PIGLIT_FAIL; }; @@ -290,7 +284,6 @@ run_subtest(int case_num) piglit_present_results(); vk_destroy_ext_image(&vk_core, &vk_img_obj); - gl_cleanup(); return subtest_result; } @@ -353,21 +346,9 @@ gl_draw_texture(enum fragment_type fs_type, uint32_t w, uint32_t h) } static void -gl_cleanup(void) -{ - glBindTexture(gl_get_target(&vk_img_props), 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glUseProgram(0); - - glDeleteTextures(1, &gl_tex); - glDeleteMemoryObjectsEXT(1, &gl_mem_obj); -} - -static void cleanup(void) { vk_cleanup_ctx(&vk_core); - gl_cleanup(); glDeleteFramebuffers(1, &gl_fbo); diff --git a/tests/spec/ext_external_objects/vk_pix_buf_update_errors.c b/tests/spec/ext_external_objects/vk_pix_buf_update_errors.c index 4ae1c9a7b..3570d8829 100644 --- a/tests/spec/ext_external_objects/vk_pix_buf_update_errors.c +++ b/tests/spec/ext_external_objects/vk_pix_buf_update_errors.c @@ -82,9 +82,6 @@ vk_cleanup(void); static bool gl_init(); -static void -gl_cleanup(void); - static struct vk_ctx vk_core; static struct vk_image_att vk_color_att; static struct vk_image_att vk_depth_att; @@ -342,7 +339,6 @@ gl_init() static void cleanup(void) { - gl_cleanup(); vk_cleanup(); } @@ -355,11 +351,3 @@ vk_cleanup(void) vk_destroy_buffer(&vk_core, &vk_bo); vk_cleanup_ctx(&vk_core); } - -static void -gl_cleanup(void) -{ - glDeleteProgram(gl_prog); - glDeleteMemoryObjectsEXT(1, &gl_memobj); - glDeleteBuffers(1, &gl_bo); -} diff --git a/tests/spec/ext_external_objects/vk_semaphores.c b/tests/spec/ext_external_objects/vk_semaphores.c index 8b2a89be3..c7610611b 100644 --- a/tests/spec/ext_external_objects/vk_semaphores.c +++ b/tests/spec/ext_external_objects/vk_semaphores.c @@ -82,9 +82,6 @@ vk_cleanup(void); static bool gl_init(); -static void -gl_cleanup(void); - static struct vk_ctx vk_core; static struct vk_image_att vk_color_att; static struct vk_image_att vk_depth_att; @@ -113,10 +110,7 @@ void piglit_init(int argc, char **argv) atexit(cleanup); - w = piglit_width; - h = piglit_height; - - if (!vk_init(w, h, d, num_samples, num_levels, num_layers, + if (!vk_init(piglit_width, piglit_height, 1, num_samples, num_levels, num_layers, color_format, depth_format, color_tiling, depth_tiling, color_in_layout, depth_in_layout, @@ -158,7 +152,8 @@ void piglit_init(int argc, char **argv) struct vk_image_att images[] = { vk_color_att, vk_depth_att }; vk_draw(&vk_core, 0, &vk_rnd, vk_fb_color, 4, &vk_sem, - vk_sem_has_wait, vk_sem_has_signal, images, ARRAY_SIZE(images), 0, 0, w, h); + vk_sem_has_wait, vk_sem_has_signal, images, ARRAY_SIZE(images), 0, 0, + piglit_width, piglit_height); layout = gl_get_layout_from_vk(color_end_layout); if (vk_sem_has_signal) { @@ -194,7 +189,7 @@ piglit_display(void) struct vk_image_att images[] = { vk_color_att, vk_depth_att }; vk_clear_color(&vk_core, 0, &vk_rnd, vk_fb_color, 4, &vk_sem, vk_sem_has_wait, vk_sem_has_signal, images, - ARRAY_SIZE(images), 0, 0, w, h); + ARRAY_SIZE(images), 0, 0, piglit_width, piglit_height); layout = gl_get_layout_from_vk(color_end_layout); if (vk_sem_has_signal) { glWaitSemaphoreEXT(gl_sem.vk_frame_done, 0, 0, 1, @@ -341,7 +336,6 @@ vk_cleanup(void) static void cleanup(void) { - gl_cleanup(); vk_cleanup(); } @@ -354,17 +348,3 @@ gl_init() glClear(GL_COLOR_BUFFER_BIT); return glGetError() == GL_NO_ERROR; } - -static void -gl_cleanup(void) -{ - glBindTexture(gl_target, 0); - - glDeleteTextures(1, &gl_tex); - glDeleteProgram(gl_prog); - - glDeleteSemaphoresEXT(1, &gl_sem.gl_frame_ready); - glDeleteSemaphoresEXT(1, &gl_sem.vk_frame_done); - - glDeleteMemoryObjectsEXT(1, &gl_mem_obj); -} diff --git a/tests/spec/ext_external_objects/vk_semaphores2.c b/tests/spec/ext_external_objects/vk_semaphores2.c index b868951a3..44c921251 100644 --- a/tests/spec/ext_external_objects/vk_semaphores2.c +++ b/tests/spec/ext_external_objects/vk_semaphores2.c @@ -112,9 +112,6 @@ vk_cleanup(void); static bool gl_init(); -static void -gl_cleanup(void); - static struct vk_ctx vk_core; static struct vk_image_att vk_color_att; static struct vk_image_att vk_depth_att; @@ -144,10 +141,7 @@ void piglit_init(int argc, char **argv) atexit(cleanup); - w = piglit_width; - h = piglit_height; - - if (!vk_init(w, h, d, num_samples, num_levels, num_layers, + if (!vk_init(piglit_width, piglit_height, 1, num_samples, num_levels, num_layers, color_format, depth_format, color_tiling, depth_tiling, color_in_layout, depth_in_layout, @@ -215,7 +209,7 @@ piglit_display(void) struct vk_image_att images[] = { vk_color_att, vk_depth_att }; vk_draw(&vk_core, 0, &vk_rnd, vk_fb_color, 4, &vk_sem, vk_sem_has_wait, vk_sem_has_signal, images, ARRAY_SIZE(images), - 0, 0, w, h); + 0, 0, piglit_width, piglit_height); layout = gl_get_layout_from_vk(color_end_layout); if (vk_sem_has_signal) { @@ -360,7 +354,6 @@ vk_cleanup(void) static void cleanup(void) { - gl_cleanup(); vk_cleanup(); } @@ -392,19 +385,3 @@ gl_init() glClear(GL_COLOR_BUFFER_BIT); return glGetError() == GL_NO_ERROR; } - -static void -gl_cleanup(void) -{ - glBindTexture(gl_target, 0); - - glDeleteTextures(1, &gl_tex); - glDeleteProgram(gl_prog); - - glDeleteSemaphoresEXT(1, &gl_sem.gl_frame_ready); - glDeleteSemaphoresEXT(1, &gl_sem.vk_frame_done); - - glDeleteFramebuffers(1, &gl_fbo); - - glDeleteMemoryObjectsEXT(1, &gl_mem_obj); -} diff --git a/tests/spec/ext_external_objects/vk_stencil_display.c b/tests/spec/ext_external_objects/vk_stencil_display.c index 7418592ba..6d579e3e8 100644 --- a/tests/spec/ext_external_objects/vk_stencil_display.c +++ b/tests/spec/ext_external_objects/vk_stencil_display.c @@ -56,9 +56,6 @@ static void vk_subtest_cleanup(void); static void -gl_cleanup(void); - -static void gl_subtest_cleanup(void); static void @@ -75,7 +72,6 @@ static struct vk_renderer vk_rnd; static GLuint gl_mem_obj; static float vk_fb_color[4] = { 1.0, 0.0, 1.0, 1.0 }; -static GLenum gl_target = GL_TEXTURE_2D; static GLuint vkgl_stencil_tex; static GLuint gl_fbo; static GLuint gl_color_tex; @@ -136,9 +132,6 @@ piglit_init(int argc, char **argv) atexit(cleanup); - w = piglit_width; - h = piglit_height; - if (!vk_init()) { fprintf(stderr, "Failed to initialize Vulkan, skipping the test.\n"); piglit_report_result(PIGLIT_SKIP); @@ -186,7 +179,7 @@ run_subtest(int case_num) vk_draw(&vk_core, 0, &vk_rnd, vk_fb_color, - 4, 0, false, false, &vk_depth_att, 1, 0, 0, w, h); + 4, 0, false, false, &vk_depth_att, 1, 0, 0, piglit_width, piglit_height); if (!gl_create_mem_obj_from_vk_mem(&vk_core, &vk_depth_att.obj.mobj, &gl_mem_obj)) { @@ -219,7 +212,7 @@ run_subtest(int case_num) 0, 0, 1, 1); assert(glGetError() == GL_NO_ERROR); - if (!piglit_probe_pixel_rgb(w / 2, h / 2, blue)) + if (!piglit_probe_pixel_rgb(piglit_width / 2, piglit_height / 2, blue)) goto fail; if (!piglit_probe_pixel_rgb(0, 0, green) || @@ -277,7 +270,7 @@ static bool vk_subtest_init(int case_num) { if (!vk_fill_ext_image_props(&vk_core, - w, h, d, + piglit_width, piglit_height, 1, num_samples, num_levels, num_layers, @@ -296,7 +289,7 @@ vk_subtest_init(int case_num) } if (!vk_fill_ext_image_props(&vk_core, - w, h, d, + piglit_width, piglit_height, 1, num_samples, num_levels, num_layers, @@ -410,22 +403,8 @@ vk_cleanup(void) } static void -gl_cleanup(void) -{ - glBindTexture(gl_target, 0); - glUseProgram(0); - - glDeleteTextures(1, &gl_color_tex); - glDeleteFramebuffers(1, &gl_fbo); - - glDeleteProgram(gl_prog); - glDeleteProgram(gl_rnd2fbo_prog); -} - -static void cleanup(void) { - gl_cleanup(); vk_cleanup(); } diff --git a/tests/spec/ext_external_objects/vk_vert_buf_reuse.c b/tests/spec/ext_external_objects/vk_vert_buf_reuse.c index 59879b22f..30129a972 100644 --- a/tests/spec/ext_external_objects/vk_vert_buf_reuse.c +++ b/tests/spec/ext_external_objects/vk_vert_buf_reuse.c @@ -60,7 +60,6 @@ static GLuint gl_disp_vk_prog; static void cleanup(); static void vk_cleanup(); -static void gl_cleanup(); static bool vk_init(); static bool gl_init(); @@ -239,18 +238,9 @@ vk_cleanup() } static void -gl_cleanup() -{ - glDeleteProgram(gl_prog); - glDeleteMemoryObjectsEXT(1, &gl_memobj); - glDeleteBuffers(1, &gl_vk_vb); -} - -static void cleanup() { vk_cleanup(); - gl_cleanup(); } static bool diff --git a/tests/spec/ext_external_objects/vk_vert_buf_update_errors.c b/tests/spec/ext_external_objects/vk_vert_buf_update_errors.c index f0af16854..ab6b9aa9b 100644 --- a/tests/spec/ext_external_objects/vk_vert_buf_update_errors.c +++ b/tests/spec/ext_external_objects/vk_vert_buf_update_errors.c @@ -37,7 +37,6 @@ PIGLIT_GL_TEST_CONFIG_END static void cleanup(); static void vk_cleanup(); -static void gl_cleanup(); static bool vk_init(); static bool gl_init(); @@ -165,7 +164,7 @@ piglit_display(void) piglit_present_results(); - /* Checking that calling glBufferSubData updates buffer succesfully. */ + /* Checking that calling glBufferSubData updates buffer successfully. */ glBindBuffer(GL_ARRAY_BUFFER, gl_vk_vb); glBufferSubData(GL_ARRAY_BUFFER, 0, vk_vb.mobj.mem_sz, checkerboard); if (glGetError() != GL_NO_ERROR) { @@ -195,18 +194,9 @@ vk_cleanup() } static void -gl_cleanup() -{ - glDeleteProgram(gl_prog); - glDeleteMemoryObjectsEXT(1, &gl_memobj); - glDeleteBuffers(1, &gl_vk_vb); -} - -static void cleanup() { vk_cleanup(); - gl_cleanup(); } static bool diff --git a/tests/spec/ext_framebuffer_multisample/accuracy.cpp b/tests/spec/ext_framebuffer_multisample/accuracy.cpp index 76cb9e2ee..17667631f 100644 --- a/tests/spec/ext_framebuffer_multisample/accuracy.cpp +++ b/tests/spec/ext_framebuffer_multisample/accuracy.cpp @@ -27,12 +27,12 @@ * * Verify the accuracy of multisample antialiasing. * - * This test utilizes the functions defined in common.cpp to verfify the + * This test utilizes the functions defined in common.cpp to verify the * accuracy of MSAA. * * The test also accepts the following flags: * - * - "small": Causes the MSAA image to be renedered in extremely tiny + * - "small": Causes the MSAA image to be rendered in extremely tiny * (16x16) tiles that are then stitched together. This verifies * that MSAA works properly on very small buffers (a critical corner * case on i965). diff --git a/tests/spec/ext_framebuffer_multisample/blit-multiple-render-targets.cpp b/tests/spec/ext_framebuffer_multisample/blit-multiple-render-targets.cpp index 2f5a37fba..ac25653fd 100644 --- a/tests/spec/ext_framebuffer_multisample/blit-multiple-render-targets.cpp +++ b/tests/spec/ext_framebuffer_multisample/blit-multiple-render-targets.cpp @@ -119,7 +119,7 @@ piglit_display() glClearColor(0.0, 1.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); - /* Clear all color attachements of multisample_fbo to blue color */ + /* Clear all color attachments of multisample_fbo to blue color */ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, multisample_fbo.handle); glDrawBuffers(6, bufs); glClearColor(0.0, 0.0, 1.0, 1.0); diff --git a/tests/spec/ext_framebuffer_multisample/clear.cpp b/tests/spec/ext_framebuffer_multisample/clear.cpp index c639e160d..b958a80e3 100644 --- a/tests/spec/ext_framebuffer_multisample/clear.cpp +++ b/tests/spec/ext_framebuffer_multisample/clear.cpp @@ -264,7 +264,7 @@ piglit_display() pass = test_clear(1.0, 1.0, 1.0, 0.5, false) && pass; /* Test with color values compatible with Intel's i965 driver's - * 'fast clear' constraints. It varifies the 'fast clear' path + * 'fast clear' constraints. It verifies the 'fast clear' path * if supported by the implementation. */ pass = test_clear(1.0, 1.0, 1.0, 0.0, true) && pass; diff --git a/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp b/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp index 2e6ca4413..48e1ad4a5 100644 --- a/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp +++ b/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp @@ -227,7 +227,7 @@ shader_compile(bool sample_alpha_to_coverage, glBindAttribLocation(prog, 0, "pos"); glEnableVertexAttribArray(0); - /* Linking is rquired after glBindFragDataLocation */ + /* Linking is required after glBindFragDataLocation */ glLinkProgram(prog); /* Set up uniforms */ @@ -902,7 +902,7 @@ ms_fbo_and_draw_buffers_setup(int samples, ms_config.color_internalformat = color_buffer_zero_format; ms_fbo.setup(ms_config); - /* Create resolve_fbo with dimensions large enough to accomodate + /* Create resolve_fbo with dimensions large enough to accommodate * all the draw buffers */ FboConfig resolve_config(0, pattern_width, diff --git a/tests/spec/ext_framebuffer_multisample/fast-clear.c b/tests/spec/ext_framebuffer_multisample/fast-clear.c index c0b249fb9..c5c4fbb64 100644 --- a/tests/spec/ext_framebuffer_multisample/fast-clear.c +++ b/tests/spec/ext_framebuffer_multisample/fast-clear.c @@ -27,7 +27,7 @@ * Clears a multisample texture with various formats to various * different colors and then samples from it in a shader to ensure * that the expected color is returned. This includes verifying that - * when there are components missing they are overriden to the right + * when there are components missing they are overridden to the right * value (such as GL_RED should report 0 for green and blue and 1 for * the alpha). The main reason to do this is that the i965 driver has * various different code paths to implement a fast clear optimisation diff --git a/tests/spec/ext_framebuffer_multisample/interpolation.cpp b/tests/spec/ext_framebuffer_multisample/interpolation.cpp index e57113ea5..32b19b9fd 100644 --- a/tests/spec/ext_framebuffer_multisample/interpolation.cpp +++ b/tests/spec/ext_framebuffer_multisample/interpolation.cpp @@ -306,7 +306,7 @@ print_usage_and_exit(char *prog_name) " where <test_type> is one of:\n" " non-centroid-disabled: non-centroid varying, MSAA off\n" " centroid-disabled: centroid varying, MSAA off\n" - " centroid-edges: centroid behaviour at trinagle edges\n" + " centroid-edges: centroid behaviour at triangle edges\n" " non-centroid-deriv: dFdx/dFdy on non-centroid varying\n" " non-centroid-deriv-disabled: As above, with MSAA off\n" " centroid-deriv: dFdx/dFdy on centroid varying\n" diff --git a/tests/spec/ext_framebuffer_multisample/negative-mismatched-samples.c b/tests/spec/ext_framebuffer_multisample/negative-mismatched-samples.c index e4851100e..8c546b234 100644 --- a/tests/spec/ext_framebuffer_multisample/negative-mismatched-samples.c +++ b/tests/spec/ext_framebuffer_multisample/negative-mismatched-samples.c @@ -90,7 +90,7 @@ test_buffers(GLuint rb0, GLuint samples0, void piglit_init(int argc, char **argv) { - GLint max_samples, max_draw_buffers; + GLint max_samples; GLuint *rb, fb; GLint *rb_samples; bool pass = true; @@ -102,12 +102,7 @@ piglit_init(int argc, char **argv) piglit_require_extension("GL_EXT_framebuffer_multisample"); piglit_require_extension("GL_ARB_draw_buffers"); - - glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers); - if (max_draw_buffers < 2) { - printf("test requires 2 draw buffers.\n"); - piglit_report_result(PIGLIT_SKIP); - } + piglit_require_minimum_getinteger(GL_MAX_DRAW_BUFFERS, 2); glGetIntegerv(GL_MAX_SAMPLES, &max_samples); diff --git a/tests/spec/ext_framebuffer_multisample/sample-coverage.cpp b/tests/spec/ext_framebuffer_multisample/sample-coverage.cpp index 8cda26d7e..d535a7f9f 100644 --- a/tests/spec/ext_framebuffer_multisample/sample-coverage.cpp +++ b/tests/spec/ext_framebuffer_multisample/sample-coverage.cpp @@ -221,7 +221,7 @@ compute_expected(void) for (i = 0; i < num_rects; i++) { float samples_used = coverage[i] * num_samples; - /* Exepected color values are computed only for integer + /* Expected color values are computed only for integer * number of samples_used */ if(samples_used == (int)samples_used) { diff --git a/tests/spec/ext_framebuffer_multisample/turn-on-off.cpp b/tests/spec/ext_framebuffer_multisample/turn-on-off.cpp index bfc791cb5..2abc216ba 100644 --- a/tests/spec/ext_framebuffer_multisample/turn-on-off.cpp +++ b/tests/spec/ext_framebuffer_multisample/turn-on-off.cpp @@ -24,7 +24,7 @@ #include "common.h" /** * @file turn-on-off.c - * This test varifies turning multisampling on/off by setting up FBO with + * This test verifies turning multisampling on/off by setting up FBO with * appropriate sample count. * Test algorithm: * 1. Render the geometry to left half of default framebuffer and read color @@ -34,7 +34,7 @@ * buffer in Step 1. It is expected to match. * * 3. Turn ON MSAA in FBO. Render the scene, draw reference image and measure - * the accuracy of MSAA. This varifies if MSAA is turned ON. + * the accuracy of MSAA. This verifies if MSAA is turned ON. * * 4. Turn OFF MSAA in FBO. Render the scene and compare to the buffer in * step 1. It is expected to match. @@ -98,7 +98,7 @@ piglit_display(void) test->draw_reference_image(); /* Measure the accuracy of MSAA in multisample FBO by comparing the - * test image to reference image. This varifies if MSAA is actually + * test image to reference image. This verifies if MSAA is actually * switched on. */ pass = test->measure_accuracy() && pass; diff --git a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt index d33abd37b..8857cf6cd 100644 --- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt +++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt @@ -22,7 +22,10 @@ if(PIGLIT_BUILD_DMA_BUF_TESTS) piglit_add_executable(ext_image_dma_buf_import-transcode-nv12-as-r8-gr88 transcode-nv12-as-r8-gr88.c image_common.c) piglit_add_executable(ext_image_dma_buf_import-export export.c sample_common.c image_common.c) piglit_add_executable(ext_image_dma_buf_import-export-tex export-tex.c sample_common.c image_common.c) + piglit_add_executable(ext_image_dma_buf_import-modifiers modifiers.c sample_common.c image_common.c) piglit_add_executable(ext_image_dma_buf_import-reimport-bug reimport-bug.c sample_common.c image_common.c) + piglit_add_executable(ext_image_dma_buf_import-refcount-multithread refcount-multithread.c sample_common.c image_common.c) + target_link_libraries(ext_image_dma_buf_import-refcount-multithread pthread) endif() # vim: ft=cmake: diff --git a/tests/spec/ext_image_dma_buf_import/export-tex.c b/tests/spec/ext_image_dma_buf_import/export-tex.c index ecf26e105..485ee0433 100644 --- a/tests/spec/ext_image_dma_buf_import/export-tex.c +++ b/tests/spec/ext_image_dma_buf_import/export-tex.c @@ -207,8 +207,8 @@ test(EGLDisplay egl_dpy, bool glfinish_after_dmabuf_export) /* Draw EGLImage contents */ GLuint imported_tex; - texture_for_egl_image(imported_img, &imported_tex); - sample_tex(imported_tex, 0, 0, 1, piglit_height); + texture_for_egl_image(imported_img, &imported_tex, true); + sample_tex(imported_tex, 0, 0, 1, piglit_height, true); /* Verify the contents */ const float ones[] = { CLEAR_VALUE }; @@ -224,12 +224,13 @@ piglit_init(int argc, char **argv) piglit_require_egl_extension(egl_dpy, "EGL_EXT_image_dma_buf_import"); piglit_require_egl_extension(egl_dpy, "EGL_KHR_gl_texture_2D_image"); piglit_require_extension("GL_OES_EGL_image_external"); + piglit_require_extension("GL_EXT_EGL_image_storage"); - fprintf(stderr, "Testing glFinish before dmabuf export\n"); + printf("Testing glFinish before dmabuf export\n"); if (!test(egl_dpy, false)) piglit_report_result(PIGLIT_FAIL); - fprintf(stderr, "Testing glFinish after dmabuf export\n"); + printf("Testing glFinish after dmabuf export\n"); if (!test(egl_dpy, true)) piglit_report_result(PIGLIT_FAIL); diff --git a/tests/spec/ext_image_dma_buf_import/export.c b/tests/spec/ext_image_dma_buf_import/export.c index 0380ef9a6..fe47a5218 100644 --- a/tests/spec/ext_image_dma_buf_import/export.c +++ b/tests/spec/ext_image_dma_buf_import/export.c @@ -27,7 +27,7 @@ /** * @file export.c * - * Test verifies that we can succesfully export imported dmabuf. + * Test verifies that we can successfully export imported dmabuf. */ PIGLIT_GL_TEST_CONFIG_BEGIN @@ -42,6 +42,7 @@ static const int format_table[] = { DRM_FORMAT_P012, DRM_FORMAT_P016, DRM_FORMAT_NV12, + DRM_FORMAT_NV21, DRM_FORMAT_XRGB8888, DRM_FORMAT_ARGB8888, DRM_FORMAT_YUV420, @@ -61,6 +62,7 @@ fourcc_num_planes(int fourcc) case DRM_FORMAT_P012: case DRM_FORMAT_P016: case DRM_FORMAT_NV12: + case DRM_FORMAT_NV21: return 2; case DRM_FORMAT_XRGB8888: case DRM_FORMAT_ARGB8888: diff --git a/tests/spec/ext_image_dma_buf_import/image_common.h b/tests/spec/ext_image_dma_buf_import/image_common.h index f9845c7cb..0d3a30c58 100644 --- a/tests/spec/ext_image_dma_buf_import/image_common.h +++ b/tests/spec/ext_image_dma_buf_import/image_common.h @@ -32,7 +32,7 @@ */ #include <unistd.h> -#include <drm_fourcc.h> +#include "drm-uapi/drm_fourcc.h" #include "piglit-util-egl.h" #include "piglit-util-gl.h" diff --git a/tests/spec/ext_image_dma_buf_import/modifiers.c b/tests/spec/ext_image_dma_buf_import/modifiers.c new file mode 100644 index 000000000..28c3dccb9 --- /dev/null +++ b/tests/spec/ext_image_dma_buf_import/modifiers.c @@ -0,0 +1,874 @@ +/* + * Copyright © 2020 Intel Corporation + * + * 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. + */ + +#include "piglit-util-compressed-grays.h" +#include "sample_common.h" +#include "image_common.h" +#include "drm-uapi/drm_fourcc.h" + +#include <inttypes.h> + +#define PRIMARY_REFERENCE_MOD DRM_FORMAT_MOD_LINEAR + +#define W 257 +#define H 257 +#define MAX_PLANES 4 + +/** + * @file modifiers.c + * + * Test various operations on imported dmabufs with supported modifiers. + */ + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + config.window_visual = PIGLIT_GL_VISUAL_RGBA; + config.window_height = 240; + config.window_width = 960; + +PIGLIT_GL_TEST_CONFIG_END + +PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC dmabuf_query; +PFNEGLEXPORTDMABUFIMAGEMESAPROC dmabuf_export; +PFNEGLQUERYDMABUFFORMATSEXTPROC dmabuf_query_formats; +PFNEGLQUERYDMABUFMODIFIERSEXTPROC dmabuf_query_modifiers; + +struct dma_buf_info { + int fd; + uint32_t w; + uint32_t h; + uint32_t n_planes; + uint32_t stride[4]; /* pitch for each plane */ + uint32_t offset[4]; /* offset of each plane */ +}; + +static void +delete_tex(GLuint *tex) +{ + if (*tex != 0) { + glDeleteTextures(1, tex); + *tex = 0; + } +} + +static void +destroy_img(EGLImageKHR *img) +{ + if (*img != EGL_NO_IMAGE_KHR) { + eglDestroyImageKHR(eglGetCurrentDisplay(), *img); + *img = EGL_NO_IMAGE_KHR; + } +} + +static int +cpp_for_fourcc(uint32_t format) +{ + switch (format) { + case DRM_FORMAT_R8: + return 1; + case DRM_FORMAT_R16: + return 2; + case DRM_FORMAT_XBGR8888: + case DRM_FORMAT_XRGB8888: + case DRM_FORMAT_ABGR8888: + case DRM_FORMAT_ARGB8888: + return 4; + default: + fprintf(stderr, "invalid fourcc: %.4s\n", (char *)&format); + return 0; + } +} + +struct modifier_name { + uint64_t mod; + const char *name; +}; + +#define CASE(mod) { mod, #mod } + +static const struct modifier_name known_modifiers[] = { + CASE(DRM_FORMAT_MOD_LINEAR), + CASE(I915_FORMAT_MOD_X_TILED), + CASE(I915_FORMAT_MOD_Y_TILED), + CASE(I915_FORMAT_MOD_Yf_TILED), + CASE(I915_FORMAT_MOD_Y_TILED_CCS), + CASE(I915_FORMAT_MOD_Yf_TILED_CCS), + CASE(I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS), + CASE(I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS), + CASE(I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC), + CASE(DRM_FORMAT_MOD_SAMSUNG_64_32_TILE), + CASE(DRM_FORMAT_MOD_SAMSUNG_16_16_TILE), + CASE(DRM_FORMAT_MOD_QCOM_COMPRESSED), + CASE(DRM_FORMAT_MOD_QCOM_TILED3), + CASE(DRM_FORMAT_MOD_VIVANTE_TILED), + CASE(DRM_FORMAT_MOD_VIVANTE_SUPER_TILED), + CASE(DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED), + CASE(DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED), + CASE(DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED), + CASE(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB), + CASE(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB), + CASE(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB), + CASE(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB), + CASE(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB), + CASE(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB), + CASE(DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED), + CASE(DRM_FORMAT_MOD_BROADCOM_SAND32), + CASE(DRM_FORMAT_MOD_BROADCOM_SAND64), + CASE(DRM_FORMAT_MOD_BROADCOM_SAND128), + CASE(DRM_FORMAT_MOD_BROADCOM_SAND256), + CASE(DRM_FORMAT_MOD_ALLWINNER_TILED), +}; +#undef CASE + +const char * +modifier_str(EGLuint64KHR mod) +{ + for (int i = 0; i < ARRAY_SIZE(known_modifiers); i++) { + if (known_modifiers[i].mod == mod) + return known_modifiers[i].name; + } + return NULL; +} + +static EGLuint64KHR +str_to_modifier(const char *mod) +{ + for (int i = 0; i < ARRAY_SIZE(known_modifiers); i++) { + if (strcmp(known_modifiers[i].name, mod) == 0) + return known_modifiers[i].mod; + } + return DRM_FORMAT_MOD_INVALID; +} + +/* Shorten fourcc "strings" (e.g., "R8 " -> "R8") */ +static int +format_no_space(int fmt) +{ + int fmt_no_space = fmt; + char *fmt_str = (char *)&fmt_no_space; + for (int i = 0; i < 4; i++) + if (fmt_str[i] == ' ') + fmt_str[i] = '\0'; + + return fmt_no_space; +} + +static void +report_result(enum piglit_result res, int fmt, EGLuint64KHR mod, bool autogen, + const char *fn) +{ + const char *mod_str = modifier_str(mod); + const int fmt_no_space = format_no_space(fmt); + const char *gen_str = autogen ? "autogen" : "pregen"; + + if (mod_str) + piglit_report_subtest_result(res, "%s-%.4s-%s-%s", + gen_str, (char*)&fmt_no_space, + mod_str, fn); + else + piglit_report_subtest_result(res, "%s-%.4s-0x%"PRIx64"-%s", + gen_str, (char*)&fmt_no_space, + mod, fn); +} + +static enum piglit_result +egl_image_for_dma_buf_fd_mod(struct dma_buf_info *buf, int fourcc, + EGLImageKHR *out_img, EGLuint64KHR modifier) +{ +#define DMA_BUF_ATTRS \ + EGL_IMAGE_PRESERVED, EGL_TRUE, \ + EGL_WIDTH, buf->w, \ + EGL_HEIGHT, buf->h, \ + EGL_LINUX_DRM_FOURCC_EXT, fourcc +#define PLANE_ATTRS \ + EGL_NONE, EGL_NONE, \ + EGL_NONE, EGL_NONE, \ + EGL_NONE, EGL_NONE, \ + EGL_NONE, EGL_NONE, \ + EGL_NONE, EGL_NONE +#define LIST_SIZE(type, list) ARRAY_SIZE(((type []) { list })) +#define DMA_BUF_ATTRS_LEN LIST_SIZE(EGLint, DMA_BUF_ATTRS) +#define PLANE_ATTRS_LEN LIST_SIZE(EGLint, PLANE_ATTRS) +#define FILL_PLANE(attr, buf, fourcc, mod, p) \ + if (p < buf->n_planes) { \ + const EGLint plane_attr[PLANE_ATTRS_LEN] = { \ + EGL_DMA_BUF_PLANE ## p ## _FD_EXT, \ + buf->fd, \ + EGL_DMA_BUF_PLANE ## p ## _OFFSET_EXT, \ + buf->offset[p], \ + EGL_DMA_BUF_PLANE ## p ## _PITCH_EXT, \ + buf->stride[p], \ + EGL_DMA_BUF_PLANE ## p ## _MODIFIER_LO_EXT, \ + mod, \ + EGL_DMA_BUF_PLANE ## p ## _MODIFIER_HI_EXT, \ + mod >> 32, \ + }; \ + const unsigned plane_attr_offset = \ + DMA_BUF_ATTRS_LEN + PLANE_ATTRS_LEN * p; \ + assert(plane_attr_offset + PLANE_ATTRS_LEN < \ + ARRAY_SIZE(attr)); \ + memcpy(attr + plane_attr_offset, plane_attr, \ + sizeof(plane_attr)); \ + } + + EGLint attr[] = { + DMA_BUF_ATTRS, + PLANE_ATTRS, + PLANE_ATTRS, + PLANE_ATTRS, + PLANE_ATTRS, + EGL_NONE, + }; + FILL_PLANE(attr, buf, fourcc, modifier, 0) + FILL_PLANE(attr, buf, fourcc, modifier, 1) + FILL_PLANE(attr, buf, fourcc, modifier, 2) + FILL_PLANE(attr, buf, fourcc, modifier, 3) + +#undef FILL_PLANE +#undef PLANE_ATTRS_LEN +#undef DMA_BUF_ATTRS_LEN +#undef LIST_SIZE +#undef PLANE_ATTRS +#undef DMA_BUF_ATTRS + + EGLImageKHR img = eglCreateImageKHR(eglGetCurrentDisplay(), + EGL_NO_CONTEXT, + EGL_LINUX_DMA_BUF_EXT, + (EGLClientBuffer)0, attr); + EGLint error = eglGetError(); + + /* EGL may not support the format, this is not an error. */ + if (!img && error == EGL_BAD_MATCH) + return PIGLIT_SKIP; + + if (error != EGL_SUCCESS) { + printf("eglCreateImageKHR() failed: %s 0x%x\n", + piglit_get_egl_error_name(error), error); + return PIGLIT_FAIL; + } + + *out_img = img; + return PIGLIT_PASS; +} + +/* This function can be implemented locally to make this test load files + * that contain or point to dmabuf data. It's intended to be left + * unimplemented by default. + */ +static bool +load_dma_buf_from_file(uint32_t format, EGLuint64KHR modifier, + struct dma_buf_info *buf) +{ + return false; +} + +static bool +create_dma_buf(uint32_t format, EGLuint64KHR modifier, + struct dma_buf_info *buf) +{ + /* Use 4KB worth of interesting data to initialize the dmabuf. */ + assert(sizeof(piglit_fxt1_grayscale_blocks) == 4 * 1024); + const char *src_data = (const char*)piglit_fxt1_grayscale_blocks; + const int num_pixels = sizeof(piglit_fxt1_grayscale_blocks) / + cpp_for_fourcc(format); + const int dim = sqrt((double)num_pixels); + + struct piglit_dma_buf *drm_buf = NULL; + enum piglit_result result = + piglit_drm_create_dma_buf_modifiers(dim, dim, format, + modifier, src_data, + &drm_buf); + + if (result != PIGLIT_PASS) { + piglit_drm_destroy_dma_buf(drm_buf); + return false; + } + + buf->n_planes = drm_buf->n_planes; + assert(buf->n_planes <= ARRAY_SIZE(drm_buf->offset)); + for (int i = 0; i < buf->n_planes; i++) { + buf->offset[i] = drm_buf->offset[i]; + buf->stride[i] = drm_buf->stride[i]; + } + buf->fd = drm_buf->fd; + buf->w = drm_buf->w; + buf->h = drm_buf->h; + + piglit_drm_destroy_dma_buf(drm_buf); + return true; +} + +static bool +get_dma_buf(uint32_t format, EGLuint64KHR modifier, bool external_only, + struct dma_buf_info *buf, bool autogen) +{ + if (autogen) { + /* GL drivers are generally unable to create external-only + * images. We can load them from external sources, however. + */ + if (external_only) + return false; + + return create_dma_buf(format, modifier, buf); + } else { + return load_dma_buf_from_file(format, modifier, buf); + } +} + +static void +clear_buffer(GLenum type) +{ + GLuint color_uint[] = {1, 1, 1, 1}; + GLint color_int[] = {1, 1, 1, 1}; + GLfloat color_float[] = {0.25 , 0.125, 0.0675, 0.25}; + switch (type) { + case GL_INT: + glClearBufferiv(GL_COLOR, 0, color_int); + return; + case GL_UNSIGNED_INT: + glClearBufferuiv(GL_COLOR, 0, color_uint); + return; + case GL_FLOAT: + glClearBufferfv(GL_COLOR, 0, color_float); + return; + default: + assert(!"unhandled clear type"); + } +} + +static bool +sample_compare(GLuint tex, GLuint tex_ref, bool external_only) +{ + const int piglit_width_half = piglit_width / 2; + sample_tex(tex, 0, 0, piglit_width_half, piglit_height, + external_only); + sample_tex(tex_ref, piglit_width_half, 0, piglit_width_half, + piglit_height, external_only); + return piglit_probe_rects_equal(0, 0, piglit_width_half, 0, + piglit_width_half, piglit_height, + GL_RGBA); +} + +static bool +clear_textures(GLuint tex, GLuint tex_ref, GLenum type) +{ + GLuint fbo; + glGenFramebuffers(1, &fbo); + glViewport(0, 0, piglit_width, piglit_height); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + + GLuint textures[] = {tex, tex_ref}; + for (int i = 0; i < ARRAY_SIZE(textures); i++) { + glBindTexture(GL_TEXTURE_2D, textures[i]); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, textures[i], 0); + clear_buffer(type); + glBindTexture(GL_TEXTURE_2D, 0); + } + + glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo); + glDeleteFramebuffers(1, &fbo); + return sample_compare(tex, tex_ref, false); +} + +static enum piglit_result +test_export(EGLImageKHR img, struct dma_buf_info *buf, + int format, EGLuint64KHR modifier) +{ + /* Export the buffer and query properties. */ + int prop_fourcc = -1; + int num_planes = -1; + + /* Query the image properties, verify fourcc and num planes. */ + EGLDisplay egl_dpy = eglGetCurrentDisplay(); + if (!dmabuf_query(egl_dpy, img, &prop_fourcc, &num_planes, NULL)) { + fprintf(stderr, "export dmabuf image query failed!\n"); + return PIGLIT_FAIL; + } + + if (!piglit_check_egl_error(EGL_SUCCESS)) { + fprintf(stderr, "image export failed!\n"); + return PIGLIT_FAIL; + } + + if (prop_fourcc != format) { + fprintf(stderr, + "fourcc mismatch, got %.4s expected %.4s\n", + (char *)&prop_fourcc, (char *)&format); + return PIGLIT_FAIL; + } + + if (num_planes != buf->n_planes) { + fprintf(stderr, "planes mismatch, got %d expected %d\n", + num_planes, buf->n_planes); + return PIGLIT_FAIL; + } + + + /* Export the image, verify success. */ + EGLint strides[MAX_PLANES] = {0,}; + EGLint offsets[MAX_PLANES] = {0,}; + if (!dmabuf_export(egl_dpy, img, NULL, strides, offsets)) { + fprintf(stderr, "image export failed!\n"); + return PIGLIT_FAIL; + } + + if (!piglit_check_egl_error(EGL_SUCCESS)) { + fprintf(stderr, "image export failed!\n"); + return PIGLIT_FAIL; + } + + /* Check if we got an expected stride and offset for each plane. + * The export spec doesn't require that the output stride and offset + * match the input, so don't fail if they're different. At this time + * though, drivers are expected to return the same values. + */ + for (uint32_t i = 0; i < num_planes; i++) { + if (strides[i] != buf->stride[i] || + offsets[i] != buf->offset[i]) { + fprintf(stderr, "suspect data from driver: " + "stride %d (expected %d) " + "offset %d (expected %d)\n", + strides[i], buf->stride[i], offsets[i], + buf->offset[i]); + + /* TODO - propagate this warning up the stack (?) */ + + return PIGLIT_WARN; + } + } + + return PIGLIT_PASS; +} + +static bool +test_gl_advanced(GLuint tex, GLuint tex_ref, int fourcc) +{ + /* DRI formats are non-integer, clear with floating point values. */ + piglit_logd("Testing clears"); + if (!clear_textures(tex, tex_ref, GL_FLOAT)) + return false; + + return true; +} + +static enum piglit_result +clear_reimport(uint32_t format, EGLuint64KHR reference_modifier, + EGLuint64KHR modifier, EGLBoolean external_only, bool autogen) +{ + GLuint tex = 0; + GLuint tex_ref = 0; + EGLImageKHR img = EGL_NO_IMAGE_KHR; + EGLImageKHR img_ref = EGL_NO_IMAGE_KHR; + struct dma_buf_info buf = { .fd = -1 }; + struct dma_buf_info buf_ref = { .fd = -1 }; + enum piglit_result res = PIGLIT_SKIP; + + if (external_only) { + piglit_logd("External only format + modifier"); + return PIGLIT_SKIP; + } + + /* Create dma_buf_info. */ + if (!get_dma_buf(format, modifier, external_only, &buf, autogen)) { + piglit_logd("No data found"); + return PIGLIT_SKIP; + } + + /* Create reference dma_buf_info. */ + if (!get_dma_buf(format, reference_modifier, external_only, + &buf_ref, autogen)) { + piglit_logd("No data found"); + goto destroy; + } + + /* Perform EGL testing */ + piglit_logd("Testing import"); + res = egl_image_for_dma_buf_fd_mod(&buf, format, &img, modifier); + if (res != PIGLIT_PASS) + goto destroy; + + res = egl_image_for_dma_buf_fd_mod(&buf_ref, format, &img_ref, + reference_modifier); + if (res != PIGLIT_PASS) + goto destroy; + + /* Create textures */ + res = texture_for_egl_image(img, &tex, external_only); + if (res != PIGLIT_PASS) + goto destroy; + + res = texture_for_egl_image(img_ref, &tex_ref, external_only); + if (res != PIGLIT_PASS) + goto destroy; + + piglit_logd("Testing clear, reimport, sample"); + if (!clear_textures(tex, tex_ref, GL_FLOAT)) { + res = PIGLIT_FAIL; + goto destroy; + } + + glFinish(); + delete_tex(&tex); + delete_tex(&tex_ref); + destroy_img(&img); + destroy_img(&img_ref); + + res = egl_image_for_dma_buf_fd_mod(&buf, format, &img, modifier); + if (res != PIGLIT_PASS) + goto destroy; + + res = egl_image_for_dma_buf_fd_mod(&buf_ref, format, &img_ref, + reference_modifier); + if (res != PIGLIT_PASS) + goto destroy; + + res = texture_for_egl_image(img, &tex, external_only); + if (res != PIGLIT_PASS) + goto destroy; + + res = texture_for_egl_image(img_ref, &tex_ref, external_only); + if (res != PIGLIT_PASS) + goto destroy; + + if (!sample_compare(tex, tex_ref, external_only)) { + res = PIGLIT_FAIL; + goto destroy; + } + +destroy: + delete_tex(&tex); + delete_tex(&tex_ref); + destroy_img(&img); + destroy_img(&img_ref); + close(buf.fd); + close(buf_ref.fd); + + if (res == PIGLIT_FAIL) + piglit_present_results(); + + return res; +} + +static enum piglit_result +stress_test(uint32_t format, EGLuint64KHR reference_modifier, + EGLuint64KHR modifier, EGLBoolean external_only, bool autogen) +{ + GLuint tex = 0; + GLuint tex_ref = 0; + EGLImageKHR img = EGL_NO_IMAGE_KHR; + EGLImageKHR img_ref = EGL_NO_IMAGE_KHR; + struct dma_buf_info buf = { .fd = -1 }; + struct dma_buf_info buf_ref = { .fd = -1 }; + enum piglit_result res = PIGLIT_SKIP; + + /* Create dma_buf_info structs. */ + if (!get_dma_buf(format, modifier, external_only, &buf, autogen)) { + piglit_logd("No data found"); + return PIGLIT_SKIP; + } + + if (!get_dma_buf(format, reference_modifier, external_only, + &buf_ref, autogen)) { + piglit_logd("No data found"); + goto destroy; + } + + /* Perform EGL testing */ + piglit_logd("Testing import"); + res = egl_image_for_dma_buf_fd_mod(&buf, format, &img, modifier); + if (res != PIGLIT_PASS) + goto destroy; + + res = egl_image_for_dma_buf_fd_mod(&buf_ref, format, &img_ref, + reference_modifier); + if (res != PIGLIT_PASS) + goto destroy; + + piglit_logd("Testing export"); + res = test_export(img, &buf, format, modifier); + if (res == PIGLIT_FAIL) + goto destroy; + + /* Create textures */ + res = texture_for_egl_image(img, &tex, external_only); + if (res != PIGLIT_PASS) + goto destroy; + + res = texture_for_egl_image(img_ref, &tex_ref, external_only); + if (res != PIGLIT_PASS) + goto destroy; + + /* Perform GL testing */ + piglit_logd("Testing sampling"); + if (!sample_compare(tex, tex_ref, external_only)) { + res = PIGLIT_FAIL; + goto destroy; + } + + /* Display the result of sampling the test and reference textures. */ + piglit_present_results(); + + if (!external_only && !test_gl_advanced(tex, tex_ref, format)) { + res = PIGLIT_FAIL; + goto destroy; + } + +destroy: + delete_tex(&tex); + delete_tex(&tex_ref); + destroy_img(&img); + destroy_img(&img_ref); + close(buf.fd); + close(buf_ref.fd); + + if (res == PIGLIT_FAIL) + piglit_present_results(); + + return res; +} + +static enum piglit_result +modifier_test(uint32_t format, EGLuint64KHR modifier, bool external_only, + bool autogen) +{ + GLuint tex = 0; + EGLImageKHR img = EGL_NO_IMAGE_KHR; + struct dma_buf_info buf = { .fd = -1 }; + enum piglit_result res = PIGLIT_SKIP; + + /* Create dma_buf_info. */ + if (!get_dma_buf(format, modifier, external_only, &buf, autogen)) { + piglit_logd("No data found"); + return PIGLIT_SKIP; + } + + /* Create EGLImage. */ + res = egl_image_for_dma_buf_fd_mod(&buf, format, &img, modifier); + + if (!img) { + /* Close the descriptor also, EGL does not have ownership */ + close(buf.fd); + } + + if (res != PIGLIT_PASS) { + piglit_logd("Failed EGL import"); + goto destroy; + } + + res = texture_for_egl_image(img, &tex, true); + if (res != PIGLIT_PASS) { + piglit_logd("Failed GL import"); + goto destroy; + } + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + /* TODO - verify results (?) */ + + sample_tex(tex, 0, 0, W, H, true); + +destroy: + delete_tex(&tex); + destroy_img(&img); + close(buf.fd); + return res; +} + +static int arg_fmt = DRM_FORMAT_INVALID; +static EGLuint64KHR arg_mod = DRM_FORMAT_MOD_INVALID; + +static bool +skip_format(uint32_t format) +{ + if (arg_fmt != DRM_FORMAT_INVALID && arg_fmt != format) + return true; + + switch (format) { + case DRM_FORMAT_R8: + case DRM_FORMAT_R16: + case DRM_FORMAT_XRGB8888: + case DRM_FORMAT_XBGR8888: + case DRM_FORMAT_ARGB8888: + case DRM_FORMAT_ABGR8888: + case DRM_FORMAT_YUYV: + case DRM_FORMAT_UYVY: + case DRM_FORMAT_P010: + case DRM_FORMAT_P012: + case DRM_FORMAT_P016: + case DRM_FORMAT_NV12: + return false; + default: + return true; + } +} + +static bool +skip_modifier(EGLuint64KHR mod) +{ + if (arg_mod != DRM_FORMAT_MOD_INVALID && arg_mod != mod) + return true; + + return false; +} + +enum piglit_result +piglit_display(void) +{ + EGLDisplay egl_dpy = eglGetCurrentDisplay(); + +#define MAX_FORMATS 256 +#define MAX_MODIFIERS 256 + + /* First query all available formats. */ + EGLint formats[MAX_FORMATS]; + EGLuint64KHR modifiers[MAX_MODIFIERS]; + EGLBoolean external_only[MAX_MODIFIERS]; + EGLint num_formats = 0; + EGLint num_modifiers = 0; + + dmabuf_query_formats(egl_dpy, MAX_FORMATS, formats, &num_formats); + + printf("found %d supported formats\n", num_formats); + + enum piglit_result result = PIGLIT_SKIP; + + bool autogen[] = { false, true }; + + for (unsigned g = 0; g < ARRAY_SIZE(autogen); g++) { + printf(autogen[g] ? + "\n\nTesting with autogenerated dmabufs\n\n" : + "\n\nTesting with pregenerated binaries\n\n"); + for (unsigned i = 0; i < num_formats; i++) { + if (skip_format(formats[i])) + continue; + + int32_t fmt = formats[i]; + + dmabuf_query_modifiers(egl_dpy, fmt, MAX_MODIFIERS, + modifiers, external_only, + &num_modifiers); + + printf("format %.4s has %d supported modifiers\n", + (char *)&fmt, num_modifiers); + + for (unsigned j = 0; j < num_modifiers; j++) { + if (skip_modifier(modifiers[j])) + continue; + + enum piglit_result r; + r = modifier_test(fmt, modifiers[j], + external_only[j], + autogen[g]); + report_result(r, fmt, modifiers[j], + autogen[g], "modifiers_test"); + piglit_merge_result(&result, r); + + r = stress_test(fmt, PRIMARY_REFERENCE_MOD, + modifiers[j], + external_only[j], + autogen[g]); + report_result(r, fmt, modifiers[j], + autogen[g], "stress_test"); + piglit_merge_result(&result, r); + + r = clear_reimport(fmt, PRIMARY_REFERENCE_MOD, + modifiers[j], + external_only[j], + autogen[g]); + report_result(r, fmt, modifiers[j], + autogen[g], "clear_reimport"); + piglit_merge_result(&result, r); + } + } + } + + return result; +} + +void +piglit_init(int argc, char **argv) +{ + for (int i = 1; i < argc; i++) { + + /* Init with spaces for codes with less than four chars. */ + int tmp_fmt = fourcc_code(' ',' ',' ',' '); + if (sscanf(argv[i], "-fmt=%4c", (char *)&tmp_fmt) > 0) { + + arg_fmt = tmp_fmt; + + /* The invalid format is reserved for this test */ + assert(arg_fmt != DRM_FORMAT_INVALID); + continue; + } + + char mod_str[4096] = {0}; + if (sscanf(argv[i], "-mod=%4096s", mod_str) > 0) { + arg_mod = str_to_modifier(mod_str); + + /* The invalid modifier is reserved for this test */ + assert(arg_mod != DRM_FORMAT_MOD_INVALID); + continue; + } + + fprintf(stderr,"e.g., %s [-fmt=AR24] " + "[-mod=DRM_FORMAT_MOD_LINEAR]\n", argv[0]); + piglit_report_result(PIGLIT_FAIL); + } + + EGLDisplay egl_dpy = eglGetCurrentDisplay(); + + piglit_require_egl_extension( + egl_dpy, "EGL_EXT_image_dma_buf_import_modifiers"); + piglit_require_egl_extension( + egl_dpy, "EGL_MESA_image_dma_buf_export"); + piglit_require_extension("GL_EXT_EGL_image_storage"); + piglit_require_extension("GL_OES_texture_view"); + + dmabuf_query = + (PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC) eglGetProcAddress( + "eglExportDMABUFImageQueryMESA"); + + dmabuf_export = + (PFNEGLEXPORTDMABUFIMAGEMESAPROC) eglGetProcAddress( + "eglExportDMABUFImageMESA"); + + if (!dmabuf_query || !dmabuf_export) { + fprintf(stderr, "could not find extension entrypoints\n"); + piglit_report_result(PIGLIT_FAIL); + } + + dmabuf_query_formats = + (PFNEGLQUERYDMABUFFORMATSEXTPROC) eglGetProcAddress( + "eglQueryDmaBufFormatsEXT"); + + dmabuf_query_modifiers = + (PFNEGLQUERYDMABUFMODIFIERSEXTPROC) eglGetProcAddress( + "eglQueryDmaBufModifiersEXT"); + + if (!dmabuf_query_formats || !dmabuf_query_modifiers) { + fprintf(stderr, "could not find extension entrypoints\n"); + piglit_report_result(PIGLIT_FAIL); + } +} diff --git a/tests/spec/ext_image_dma_buf_import/refcount-multithread.c b/tests/spec/ext_image_dma_buf_import/refcount-multithread.c new file mode 100644 index 000000000..91a4736d5 --- /dev/null +++ b/tests/spec/ext_image_dma_buf_import/refcount-multithread.c @@ -0,0 +1,190 @@ +/* + * Copyright 2023 Google LLC + * + * 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 refcount-multithread.c + * + * Mesa drivers normally use a hash table to make sure there is a 1:1 mapping + * between gem bo handles and userspace bo handles. When a gem bo handle is + * imported, and if a userspace bo handle for the gem bo handle already + * exists, mesa drivers simply increase the reference count of the userspace + * bo handle. + * + * It occurred to multiple drivers in the past where the bo destroy function + * raced with the bo import function and led to use-after-free. This test + * attempts to catch such a driver bug. + */ + +#include <pthread.h> + +#include "image_common.h" +#include "sample_common.h" + +#define THREAD_COUNT 2 +#define THREAD_ITER 100000 + +struct thread_data { + pthread_t thread; + + struct piglit_dma_buf *buf; + int fourcc; + + EGLDisplay dpy; + EGLContext ctx; + enum piglit_result result; +}; + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + config.window_visual = PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +static enum piglit_result +create_and_destroy_texture(struct piglit_dma_buf *buf, int fourcc) +{ + enum piglit_result res; + EGLImageKHR img; + GLuint tex; + + res = egl_image_for_dma_buf_fd(buf, buf->fd, fourcc, &img); + if (res != PIGLIT_PASS) + return res; + + res = texture_for_egl_image(img, &tex, true); + eglDestroyImageKHR(eglGetCurrentDisplay(), img); + if (res != PIGLIT_PASS) + return res; + + glDeleteTextures(1, &tex); + glFinish(); + + return res; +} + +static void +thread_cleanup(struct thread_data *data) +{ + eglDestroyContext(data->dpy, data->ctx); +} + +static enum piglit_result +thread_init(struct thread_data *data) +{ + const EGLint attrs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE, + }; + data->ctx = eglCreateContext(data->dpy, EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT, attrs); + if (data->ctx == EGL_NO_CONTEXT) + return PIGLIT_FAIL; + + if (!eglMakeCurrent(data->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, data->ctx)) { + eglDestroyContext(data->dpy, data->ctx); + return PIGLIT_FAIL; + } + + return PIGLIT_PASS; +} + +static void * +thread_main(void *arg) +{ + struct thread_data *data = arg; + + data->result = thread_init(data); + if (data->result != PIGLIT_PASS) + return NULL; + + for (int i = 0; i < THREAD_ITER; i++) { + data->result = create_and_destroy_texture(data->buf, data->fourcc); + if (data->result != PIGLIT_PASS) + break; + } + + thread_cleanup(data); + + return NULL; +} + +/* dummy */ +enum piglit_result +piglit_display(void) +{ + return PIGLIT_PASS; +} + +void +piglit_init(int argc, char **argv) +{ + EGLDisplay egl_dpy = eglGetCurrentDisplay(); + + piglit_require_egl_extension(egl_dpy, "EGL_KHR_image_base"); + piglit_require_egl_extension(egl_dpy, "EGL_EXT_image_dma_buf_import"); + piglit_require_egl_extension(egl_dpy, "EGL_KHR_no_config_context"); + piglit_require_egl_extension(egl_dpy, "EGL_KHR_surfaceless_context"); + + enum piglit_result res; + + /* Create a DMABUF */ + const uint32_t src_data[2][2] = { 0 }; + const int fourcc = DRM_FORMAT_ABGR8888; + struct piglit_dma_buf *buf; + res = piglit_create_dma_buf(2, 2, fourcc, src_data, &buf); + if (res != PIGLIT_PASS) + piglit_report_result(PIGLIT_SKIP); + + /* Make image_common.c resolve the entrypoints */ + res = create_and_destroy_texture(buf, fourcc); + if (res != PIGLIT_PASS) + piglit_report_result(PIGLIT_SKIP); + + /* Dissociate the DMABUF from the underlying driver */ + struct piglit_dma_buf local_buf = *buf; + local_buf.fd = dup(buf->fd); + piglit_destroy_dma_buf(buf); + + if (local_buf.fd < 0) + piglit_report_result(PIGLIT_FAIL); + + struct thread_data data[THREAD_COUNT]; + for (int i = 0; i < THREAD_COUNT; i++) { + data[i].buf = &local_buf; + data[i].fourcc = fourcc; + data[i].dpy = egl_dpy; + data[i].result = PIGLIT_PASS; + + if (pthread_create(&data[i].thread, NULL, thread_main, + &data[i])) + piglit_report_result(PIGLIT_FAIL); + } + + for (int i = 0; i < THREAD_COUNT; i++) { + pthread_join(data[i].thread, NULL); + if (data[i].result != PIGLIT_PASS) + piglit_report_result(data[i].result); + } + + piglit_report_result(PIGLIT_PASS); +} diff --git a/tests/spec/ext_image_dma_buf_import/refcount.c b/tests/spec/ext_image_dma_buf_import/refcount.c index 7ea200edd..6b6ac54b8 100644 --- a/tests/spec/ext_image_dma_buf_import/refcount.c +++ b/tests/spec/ext_image_dma_buf_import/refcount.c @@ -80,27 +80,27 @@ piglit_display(void) close(buf->fd); - res = texture_for_egl_image(img1, &tex1); + res = texture_for_egl_image(img1, &tex1, true); if (res != PIGLIT_PASS) return res; - res = texture_for_egl_image(img2, &tex2); + res = texture_for_egl_image(img2, &tex2, true); if (res != PIGLIT_PASS) return res; sample_tex(tex1, 0, y_spacing * 0, - w * scale, h * scale); + w * scale, h * scale, true); sample_tex(tex2, 0, y_spacing * 1, - w * scale, h * scale); + w * scale, h * scale, true); glDeleteTextures(1, &tex2); eglDestroyImageKHR(eglGetCurrentDisplay(), img2); sample_tex(tex1, 0, y_spacing * 2, - w * scale, h * scale); + w * scale, h * scale, true); expected = piglit_rgbw_image_ubyte(w * scale, h * scale, false); @@ -127,4 +127,5 @@ piglit_init(int argc, char **argv) piglit_require_egl_extension(egl_dpy, "EGL_EXT_image_dma_buf_import"); piglit_require_extension("GL_OES_EGL_image_external"); + piglit_require_extension("GL_EXT_EGL_image_storage"); } diff --git a/tests/spec/ext_image_dma_buf_import/reimport-bug.c b/tests/spec/ext_image_dma_buf_import/reimport-bug.c index 185604d29..807e2e1ab 100644 --- a/tests/spec/ext_image_dma_buf_import/reimport-bug.c +++ b/tests/spec/ext_image_dma_buf_import/reimport-bug.c @@ -27,7 +27,7 @@ /** * @file reimport-bug.c * - * Test verifies that we can succesfully reimport and map a DMABUF. This + * Test verifies that we can successfully reimport and map a DMABUF. This * specifically checks that drivers, which may map a DMABUF, invalidates any * such mappings (as needed) when it is reimported. This test has been tuned * specifically for the iris driver. diff --git a/tests/spec/ext_image_dma_buf_import/sample_common.c b/tests/spec/ext_image_dma_buf_import/sample_common.c index b94cfd55e..7f3ac767d 100644 --- a/tests/spec/ext_image_dma_buf_import/sample_common.c +++ b/tests/spec/ext_image_dma_buf_import/sample_common.c @@ -28,7 +28,7 @@ #include "image_common.h" #include "sample_common.h" -static const char fs_src[] = +static const char fs_src_external[] = "#extension GL_OES_EGL_image_external : require\n" "precision mediump float;\n" "uniform samplerExternalOES sampler;\n" @@ -38,6 +38,15 @@ static const char fs_src[] = "{\n" "gl_FragColor = texture2D(sampler, texcoords);\n" "}\n"; +static const char fs_src[] = + "precision mediump float;\n" + "uniform sampler2D sampler;\n" + "varying vec2 texcoords;\n" + "\n" + "void main()\n" + "{\n" + "gl_FragColor = texture2D(sampler, texcoords);\n" + "}\n"; static const char vs_src[] = "attribute vec4 piglit_vertex;\n" "attribute vec4 piglit_texcoords;\n" @@ -50,17 +59,17 @@ static const char vs_src[] = "}\n"; enum piglit_result -texture_for_egl_image(EGLImageKHR img, GLuint *out_tex) +texture_for_egl_image(EGLImageKHR img, GLuint *out_tex, bool external) { GLuint tex; GLenum error; + GLenum target = external ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; glGenTextures(1, &tex); - glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex); + glBindTexture(target, tex); /* Set the image as level zero */ - glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, - (GLeglImageOES)img); + glEGLImageTargetTexStorageEXT(target, (GLeglImageOES)img, NULL); error = glGetError(); /** @@ -71,15 +80,13 @@ texture_for_egl_image(EGLImageKHR img, GLuint *out_tex) return PIGLIT_SKIP; if (error != GL_NO_ERROR) { - printf("glEGLImageTargetTexture2DOES() failed: %s 0x%x\n", + printf("glEGLImageTargetTexStorageEXT() failed: %s 0x%x\n", piglit_get_gl_error_name(error), error); return PIGLIT_FAIL; } - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, - GL_NEAREST); - glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, - GL_NEAREST); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); *out_tex = tex; @@ -87,15 +94,17 @@ texture_for_egl_image(EGLImageKHR img, GLuint *out_tex) } void -sample_tex(GLuint tex, unsigned x, unsigned y, unsigned w, unsigned h) +sample_tex(GLuint tex, unsigned x, unsigned y, unsigned w, unsigned h, + bool external) { GLuint prog; - prog = piglit_build_simple_program(vs_src, fs_src); + prog = piglit_build_simple_program(vs_src, external ? + fs_src_external : fs_src); glUseProgram(prog); - glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex); + glBindTexture(external ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D, tex); glUniform1i(glGetUniformLocation(prog, "sampler"), 0); glViewport(x, y, w, h); @@ -153,6 +162,7 @@ egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImag EGLint *attr; switch (fourcc) { case DRM_FORMAT_NV12: + case DRM_FORMAT_NV21: case DRM_FORMAT_P010: case DRM_FORMAT_P012: case DRM_FORMAT_P016: @@ -170,7 +180,6 @@ egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImag img = eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer)0, attr); - *out_img = img; error = eglGetError(); @@ -216,11 +225,11 @@ sample_buffer(struct piglit_dma_buf *buf, int fourcc) if (res != PIGLIT_PASS) return res; - res = texture_for_egl_image(img, &tex); + res = texture_for_egl_image(img, &tex, true); if (res != PIGLIT_PASS) goto destroy; - sample_tex(tex, 0, 0, w, h); + sample_tex(tex, 0, 0, w, h, true); destroy: glDeleteTextures(1, &tex); diff --git a/tests/spec/ext_image_dma_buf_import/sample_common.h b/tests/spec/ext_image_dma_buf_import/sample_common.h index f02e1e0e3..c12686dc7 100644 --- a/tests/spec/ext_image_dma_buf_import/sample_common.h +++ b/tests/spec/ext_image_dma_buf_import/sample_common.h @@ -40,10 +40,11 @@ enum piglit_result egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImageKHR *out_img); enum piglit_result -texture_for_egl_image(EGLImageKHR img, GLuint *out_tex); +texture_for_egl_image(EGLImageKHR img, GLuint *out_tex, bool external); void -sample_tex(GLuint tex, unsigned x, unsigned y, unsigned w, unsigned h); +sample_tex(GLuint tex, unsigned x, unsigned y, unsigned w, unsigned h, + bool external); void usage(const char *name, const char *color_space); diff --git a/tests/spec/ext_image_dma_buf_import/sample_yuv.c b/tests/spec/ext_image_dma_buf_import/sample_yuv.c index ff5da0b3e..9283baad2 100644 --- a/tests/spec/ext_image_dma_buf_import/sample_yuv.c +++ b/tests/spec/ext_image_dma_buf_import/sample_yuv.c @@ -169,6 +169,15 @@ piglit_display(void) /* UV */ 120, 130, 140, 130, 120, 160, 140, 160, + }, nv21[] = { + /* Y */ + 50, 70, 90, 110, + 50, 70, 90, 110, + 50, 70, 90, 110, + 50, 70, 90, 110, + /* VU */ + 130, 120, 130, 140, + 160, 120, 160, 140, }, yuv420[] = { /* Y */ 50, 70, 90, 110, @@ -224,6 +233,26 @@ piglit_display(void) 90, 140, 110, 160, 50, 121, 70, 161, 90, 140, 110, 160, + }, yvyu[] = { + /* YVYU */ + 50, 130, 70, 120, + 89, 130, 110, 140, + 50, 130, 70, 120, + 89, 130, 110, 140, + 50, 161, 70, 121, + 90, 160, 110, 140, + 50, 161, 70, 121, + 90, 160, 110, 140, + }, vyuy[] = { + /* VYUY */ + 130, 50, 120, 70, + 130, 89, 140, 110, + 130, 50, 120, 70, + 130, 89, 140, 110, + 161, 50, 121, 70, + 160, 90, 140, 110, + 161, 50, 121, 70, + 160, 90, 140, 110, }, uyvy[] = { /* UYVY */ 120, 50, 130, 70, @@ -311,6 +340,9 @@ piglit_display(void) case DRM_FORMAT_NV12: t = nv12; break; + case DRM_FORMAT_NV21: + t = nv21; + break; case DRM_FORMAT_YUV420: t = yuv420; break; @@ -324,9 +356,15 @@ piglit_display(void) case DRM_FORMAT_YUYV: t = yuyv; break; + case DRM_FORMAT_YVYU: + t = yvyu; + break; case DRM_FORMAT_UYVY: t = uyvy; break; + case DRM_FORMAT_VYUY: + t = vyuy; + break; default: fprintf(stderr, "invalid fourcc: %.4s\n", (char *)&fourcc); return PIGLIT_SKIP; diff --git a/tests/spec/ext_instanced_arrays/CMakeLists.gles2.txt b/tests/spec/ext_instanced_arrays/CMakeLists.gles2.txt new file mode 100644 index 000000000..e755cf402 --- /dev/null +++ b/tests/spec/ext_instanced_arrays/CMakeLists.gles2.txt @@ -0,0 +1,12 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} +) + +piglit_add_executable (ext_instanced_arrays-instanced_arrays instanced_arrays.c) +piglit_add_executable (ext_instanced_arrays-vertex-attrib-divisor-index-error vertex-attrib-divisor-index-error.c)
\ No newline at end of file diff --git a/tests/spec/ext_instanced_arrays/CMakeLists.txt b/tests/spec/ext_instanced_arrays/CMakeLists.txt new file mode 100644 index 000000000..4a012b958 --- /dev/null +++ b/tests/spec/ext_instanced_arrays/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api()
\ No newline at end of file diff --git a/tests/spec/ext_instanced_arrays/instanced_arrays.c b/tests/spec/ext_instanced_arrays/instanced_arrays.c new file mode 100644 index 000000000..8b032af33 --- /dev/null +++ b/tests/spec/ext_instanced_arrays/instanced_arrays.c @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Collabora, Ltd. + * + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 + * NON-INFRINGEMENT. IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS + * 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 + * Tests GL_EXT_instanced_arrays + */ + +#include "piglit-util-gl.h" +#include "piglit-matrix.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + + config.window_width = 500; + config.window_height = 500; + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +#define NUM_TRIANGLES 10 + +static const char *VertShaderText = + "attribute vec3 Vertex; \n" + "attribute mat4 Matrix; \n" + "void main() \n" + "{ \n" + " gl_Position = Matrix*vec4(Vertex, 1.0); \n" + "} \n"; + +static const char *FragShaderText = + "void main() \n" + "{ \n" + " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); \n" + "} \n"; + + +static GLuint Program; +static GLuint vbo, mbo; +static GLint VertexAttrib, MatrixAttrib; + +enum piglit_result +piglit_display(void) +{ + float white[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + float transparent[] = { 0.0f, 0.0f, 0.0f, 0.0f }; + float vertices[9] = {-0.1f, -0.1f , 0.0f, + 0.1f, -0.1f , 0.0f, + 0.0f, 0.15f, 0.0f}; + glGenBuffers(1, &vbo); + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glBufferData(GL_ARRAY_BUFFER, 9*sizeof(float), vertices, GL_STATIC_DRAW); + glVertexAttribPointer(VertexAttrib, 3, GL_FLOAT, GL_FALSE, (GLsizei)3*sizeof(float), NULL); + glEnableVertexAttribArray(VertexAttrib); + + float mat[NUM_TRIANGLES * 16]; + for (int matrix_id=0; matrix_id < NUM_TRIANGLES; matrix_id++) { + float pos_x = cos(2*M_PI*matrix_id / NUM_TRIANGLES); + float pos_y = sin(2*M_PI*matrix_id / NUM_TRIANGLES); + int i = 16 * matrix_id; + piglit_identity_matrix (&mat[i]); + mat[i+12] = pos_x; + mat[i+13] = pos_y; + } + glGenBuffers(1, &mbo); + glBindBuffer(GL_ARRAY_BUFFER, mbo); + glBufferData(GL_ARRAY_BUFFER, NUM_TRIANGLES * 16 * sizeof(float), + mat, GL_DYNAMIC_DRAW); + for (unsigned int i = 0; i < 4; i++) { + glEnableVertexAttribArray(MatrixAttrib + i); + glVertexAttribPointer(MatrixAttrib + i, 4, GL_FLOAT, GL_FALSE, + 16 * sizeof(float), + (const GLvoid *)(sizeof(GLfloat) * i * 4)); + glVertexAttribDivisorEXT(MatrixAttrib + i, 1); + if (!piglit_check_gl_error(GL_NO_ERROR)) { + piglit_present_results(); + return PIGLIT_FAIL; + } + } + + glClear(GL_COLOR_BUFFER_BIT); + + glDrawArraysInstancedEXT(GL_TRIANGLES, 0, 3, (GLsizei)NUM_TRIANGLES); + if (!piglit_check_gl_error(GL_NO_ERROR)) { + piglit_present_results(); + return PIGLIT_FAIL; + } + + if (!piglit_probe_pixel_rgba(piglit_width - 1, piglit_height/2, white)) { + piglit_present_results(); + return PIGLIT_FAIL; + } + + if (!piglit_probe_pixel_rgba(0, 0, transparent)) { + piglit_present_results(); + return PIGLIT_FAIL; + } + + piglit_present_results(); + + return PIGLIT_PASS; +} + + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_EXT_instanced_arrays"); + + Program = piglit_build_simple_program(VertShaderText, FragShaderText); + + glUseProgram(Program); + + VertexAttrib = glGetAttribLocation(Program, "Vertex"); + MatrixAttrib = glGetAttribLocation(Program, "Matrix"); +} diff --git a/tests/spec/ext_instanced_arrays/vertex-attrib-divisor-index-error.c b/tests/spec/ext_instanced_arrays/vertex-attrib-divisor-index-error.c new file mode 100644 index 000000000..02ffb6321 --- /dev/null +++ b/tests/spec/ext_instanced_arrays/vertex-attrib-divisor-index-error.c @@ -0,0 +1,64 @@ +/** + * Copyright © 2013 Intel Corporation + * + * 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 + * Test that VertexAttribDivisor() generates INVALID_VALUE if index is greater + * than or equal to MAX_VERTEX_ATTRIBS. + * + * GL 3.3 core spec, section 2.8 (Vertex Arrays) says: + * "An INVALID_VALUE error is generated if index is greater than or equal to the + * value of MAX_VERTEX_ATTRIBS." + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + config.khr_no_error_support = PIGLIT_HAS_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + GLint maxAttribCount = 0; + + if(piglit_get_gl_version() < 30) + piglit_require_extension("GL_EXT_instanced_arrays"); + + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribCount); + glVertexAttribDivisor(maxAttribCount, 0); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} + +enum piglit_result +piglit_display(void) +{ + /* UNREACHED */ + return PIGLIT_FAIL; +} diff --git a/tests/spec/ext_occlusion_query_boolean/any-samples.c b/tests/spec/ext_occlusion_query_boolean/any-samples.c index 4963346d4..d10e24cd6 100644 --- a/tests/spec/ext_occlusion_query_boolean/any-samples.c +++ b/tests/spec/ext_occlusion_query_boolean/any-samples.c @@ -24,7 +24,7 @@ /** * @file * Tests GL_EXT_occlusion_query_boolean extension. Test does not to cover - * the whole API as that is tested throughly by existing arb_occlusion_query + * the whole API as that is tested thoroughly by existing arb_occlusion_query * and arb_occlusion_query2 tests. Main objective is to test that boolean * query works on OpenGL ES 2.0. */ diff --git a/tests/spec/ext_packed_depth_stencil/errors.c b/tests/spec/ext_packed_depth_stencil/errors.c index d2c1c4df4..6393a1f59 100644 --- a/tests/spec/ext_packed_depth_stencil/errors.c +++ b/tests/spec/ext_packed_depth_stencil/errors.c @@ -40,7 +40,7 @@ PIGLIT_GL_TEST_CONFIG_END static bool test_drawpixels(void) { - GLuint p[1]; + GLuint p[1] = {0}; glDrawPixels(1, 1, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT, p); if (!piglit_check_gl_error(GL_INVALID_ENUM)) diff --git a/tests/spec/ext_render_snorm/render.c b/tests/spec/ext_render_snorm/render.c index 1d4a69c2d..be4adbe20 100644 --- a/tests/spec/ext_render_snorm/render.c +++ b/tests/spec/ext_render_snorm/render.c @@ -38,14 +38,14 @@ #include "piglit-util-gl.h" PIGLIT_GL_TEST_CONFIG_BEGIN - config.supports_gl_es_version = 31; + config.supports_gl_es_version = 30; config.window_visual = PIGLIT_GL_VISUAL_RGBA; PIGLIT_GL_TEST_CONFIG_END #define PIGLIT_RESULT(x) x ? PIGLIT_PASS : PIGLIT_FAIL static const char vs_source[] = - "#version 310 es\n" + "#version 300 es\n" "layout(location = 0) in highp vec4 vertex;\n" "layout(location = 1) in highp vec4 uv;\n" "out highp vec2 tex_coord;\n" @@ -57,8 +57,8 @@ static const char vs_source[] = "}\n"; static const char fs_source[] = - "#version 310 es\n" - "layout(location = 0) uniform sampler2D texture;\n" + "#version 300 es\n" + "uniform sampler2D texture;\n" "in highp vec2 tex_coord;\n" "out highp vec4 color;\n" "void main()\n" @@ -107,18 +107,18 @@ value_for_format(const struct fmt_test *test, void *value) char *v = value; /* red */ - v[0] = val; + v[0] = -val; /* green */ if (test->bpp > 1) { v[0] = 0; - v[1] = val; + v[1] = -val; } /* blue */ if (test->bpp > 2) { - v[0] = 0; + v[0] = -val; v[1] = 0; v[2] = val; - v[3] = val; + v[3] = -val; } } @@ -174,7 +174,7 @@ static GLuint create_and_bind_fbo(const struct fmt_test *test, GLuint *tex) { GLuint fbo; - GLuint fbo_tex = create_and_bind_empty_texture(test); + GLuint fbo_tex = create_and_bind_empty_texture(); upload(test, NULL); *tex = fbo_tex; @@ -235,7 +235,7 @@ test_format(const struct fmt_test *test) bool pass = true; glUseProgram(prog); - glUniform1i(0 /* explicit loc */, 0); + glUniform1i(glGetUniformLocation(prog, "texture"), 0); /* Test glRenderbufferStorage. */ GLuint rbo = create_and_bind_rbo(test); diff --git a/tests/spec/ext_texture_env_combine/combine.c b/tests/spec/ext_texture_env_combine/combine.c index 0b6486357..0254d94fd 100644 --- a/tests/spec/ext_texture_env_combine/combine.c +++ b/tests/spec/ext_texture_env_combine/combine.c @@ -1123,7 +1123,7 @@ run_multi_texture_test(void) } /* We do a really short, simple test for GL_ARB_texture_env_crossbar since the - * preceeding tests are pretty comprehensive and the crossbar feature is just + * preceding tests are pretty comprehensive and the crossbar feature is just * an incremental addition. Basically, if we have N texture units we run N * tests. For test [i] we set texture unit [i] to fetch the texture color * from unit [num_units - i - 1]. For units != i we use the constant color @@ -1258,7 +1258,7 @@ piglit_init(int argc, char **argv) { piglit_require_extension("GL_EXT_texture_env_combine"); - /* Test the availability of the DOT3 extenstion */ + /* Test the availability of the DOT3 extension */ have_dot3 = piglit_is_extension_supported("GL_EXT_texture_env_dot3"); have_crossbar = diff --git a/tests/spec/ext_texture_format_bgra8888/api-errors.c b/tests/spec/ext_texture_format_bgra8888/api-errors.c index a432ded5e..ea164ee57 100644 --- a/tests/spec/ext_texture_format_bgra8888/api-errors.c +++ b/tests/spec/ext_texture_format_bgra8888/api-errors.c @@ -41,11 +41,13 @@ PIGLIT_GL_TEST_CONFIG_END static bool run_test(void) { - GLuint tex; + GLuint tex, rb; bool pass = true; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); + glGenRenderbuffers(1, &rb); + glBindRenderbuffer(GL_RENDERBUFFER, tex); if (!piglit_check_gl_error(GL_NO_ERROR)) return false; @@ -110,7 +112,13 @@ run_test(void) if (!piglit_check_gl_error(GL_INVALID_OPERATION)) pass = false; + /* glRenderbufferStorage */ + glRenderbufferStorage(GL_RENDERBUFFER, GL_BGRA_EXT, 2, 2); + if (!piglit_check_gl_error(GL_NO_ERROR)) + pass = false; + glDeleteTextures(1, &tex); + glDeleteRenderbuffers(1, &rb); return pass; } diff --git a/tests/spec/ext_texture_storage/CMakeLists.gles2.txt b/tests/spec/ext_texture_storage/CMakeLists.gles2.txt new file mode 100644 index 000000000..26d2b4ab5 --- /dev/null +++ b/tests/spec/ext_texture_storage/CMakeLists.gles2.txt @@ -0,0 +1,7 @@ +link_libraries ( + piglitutil_${piglit_target_api} +) + +piglit_add_executable (ext_texture_storage-formats formats.c) + +# vim: ft=cmake: diff --git a/tests/spec/ext_texture_storage/CMakeLists.txt b/tests/spec/ext_texture_storage/CMakeLists.txt new file mode 100644 index 000000000..144a306f4 --- /dev/null +++ b/tests/spec/ext_texture_storage/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/ext_texture_storage/formats.c b/tests/spec/ext_texture_storage/formats.c new file mode 100644 index 000000000..95972ef8a --- /dev/null +++ b/tests/spec/ext_texture_storage/formats.c @@ -0,0 +1,211 @@ +/* + * Copyright © 2024 Collabora, Ltd. + * + * 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 + * Tests glTexStorage2DEXT interactions with formats defined in other + * extensions, which is not covered by the CTS. + */ + +#include "piglit-util-gl.h" + +static struct piglit_gl_test_config *piglit_config; + +PIGLIT_GL_TEST_CONFIG_BEGIN + + piglit_config = &config; + config.supports_gl_es_version = 20; + config.window_visual = PIGLIT_GL_VISUAL_RGBA; + config.khr_no_error_support = PIGLIT_HAS_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +struct format_test { + const char *ext_names[2]; + const GLenum formats[5]; +}; + +static enum piglit_result +check_formats(void *data_) +{ + const struct format_test *data = data_; + bool failed = false; + + for (int i = 0; i < ARRAY_SIZE(data->ext_names); i++) { + if (data->ext_names[i] && + !piglit_is_extension_supported(data->ext_names[i])) { + return PIGLIT_SKIP; + } + } + + piglit_reset_gl_error(); + + for (int i = 0; i < ARRAY_SIZE(data->formats); i++) { + GLuint tex; + GLint param; + + if (data->formats[i] == GL_NONE) + continue; + + piglit_logi("checking %s", + piglit_get_gl_enum_name(data->formats[i])); + + glActiveTexture(GL_TEXTURE0); + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + glTexStorage2DEXT(GL_TEXTURE_2D, 1, data->formats[i], 128, 128); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + failed = true; + + glGetTexParameteriv(GL_TEXTURE_2D, + GL_TEXTURE_IMMUTABLE_FORMAT_EXT, + ¶m); + if (param != GL_TRUE) + failed = true; + + glDeleteTextures(1, &tex); + } + + return failed ? PIGLIT_FAIL : PIGLIT_PASS; +} + +static const struct format_test format_tests[] = { + { + { }, + { GL_ALPHA8_EXT, GL_LUMINANCE8_EXT, GL_LUMINANCE8_ALPHA8_EXT, }, + }, + { + { "GL_OES_texture_float", }, + { + GL_RGBA32F_EXT, GL_RGB32F_EXT, + GL_ALPHA32F_EXT, GL_LUMINANCE32F_EXT, + GL_LUMINANCE_ALPHA32F_EXT, + }, + }, + { + { "GL_OES_texture_half_float", }, + { + GL_RGBA16F_EXT, GL_RGB16F_EXT, + GL_ALPHA16F_EXT, GL_LUMINANCE16F_EXT, + GL_LUMINANCE_ALPHA16F_EXT, + }, + }, + { + { "GL_EXT_texture_type_2_10_10_10_REV", }, + { GL_RGB10_A2_EXT, GL_RGB10_EXT, }, + }, + { + { "GL_EXT_texture_format_BGRA8888", }, + { GL_BGRA8_EXT, }, + }, + { + { "GL_EXT_texture_rg", }, + { GL_R8_EXT, GL_RG8_EXT, }, + }, + { + { "GL_EXT_texture_rg", "GL_OES_texture_float", }, + { GL_R32F_EXT, GL_RG32F_EXT, }, + }, + { + { "GL_EXT_texture_rg", "GL_OES_texture_half_float", }, + { GL_R16F_EXT, GL_RG16F_EXT, }, + }, + { + { "GL_APPLE_rgb_422", }, + { GL_RGB_RAW_422_APPLE, }, + }, +}; + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + enum piglit_result result; + struct piglit_subtest subtests[ARRAY_SIZE(format_tests) + 1]; + + piglit_require_extension("GL_EXT_texture_storage"); + + subtests[0].name = strdup("Check core extension"); + subtests[0].option = strdup("core"); + subtests[0].subtest_func = check_formats; + subtests[0].data = (void *) &format_tests[0]; + + for (int i = 1; i < ARRAY_SIZE(format_tests); i++) { + const char *lead = "Check interactions with "; + char *name, *opt; + int ext_len = 0; + + for (int j = 0; j < ARRAY_SIZE(format_tests[i].ext_names); j++) { + if (!format_tests[i].ext_names[j]) + continue; + ext_len += strlen(format_tests[i].ext_names[j]) + 1; + } + + name = calloc(strlen(lead) + ext_len + 1, 1); + opt = calloc(ext_len + 1, 1); + if (!name || !opt) { + free(name); + free(opt); + return; + } + + strcat(name, lead); + + for (int j = 0; j < ARRAY_SIZE(format_tests[i].ext_names); j++) { + if (!format_tests[i].ext_names[j]) + continue; + + if (j > 0) { + strcat(name, " "); + strcat(opt, "-"); + } + strcat(name, format_tests[i].ext_names[j]); + strcat(opt, format_tests[i].ext_names[j]); + } + + subtests[i].name = name; + subtests[i].option = opt; + subtests[i].subtest_func = check_formats; + subtests[i].data = (void *) &format_tests[i]; + } + + memset(&subtests[ARRAY_SIZE(format_tests)], 0, sizeof(*subtests)); + + result = piglit_run_selected_subtests(subtests, + piglit_config->selected_subtests, + piglit_config->num_selected_subtests, + PIGLIT_SKIP); + + piglit_report_result(result); + + for (int i = 0; i < ARRAY_SIZE(subtests); i++) { + free((char *) subtests[i].name); + free((char *) subtests[i].option); + } +} diff --git a/tests/spec/ext_texture_swizzle/depth_texture_mode_and_swizzle.c b/tests/spec/ext_texture_swizzle/depth_texture_mode_and_swizzle.c index 6f9d7f38c..cb87fad1e 100644 --- a/tests/spec/ext_texture_swizzle/depth_texture_mode_and_swizzle.c +++ b/tests/spec/ext_texture_swizzle/depth_texture_mode_and_swizzle.c @@ -26,7 +26,7 @@ * * Tests the interactions between EXT_texture_swizzle and DEPTH_TEXTURE_MODE. * - * From the EXT_texture_swizzle specfication: + * From the EXT_texture_swizzle specification: * "4) How does this interact with depth component textures? * * RESOLVED: The swizzle is applied after the DEPTH_TEXTURE_MODE. This diff --git a/tests/spec/ext_transform_feedback/api-errors.c b/tests/spec/ext_transform_feedback/api-errors.c index b5437776c..d74943712 100644 --- a/tests/spec/ext_transform_feedback/api-errors.c +++ b/tests/spec/ext_transform_feedback/api-errors.c @@ -411,6 +411,7 @@ do_test(const struct test_desc *test) break; } + glEndTransformFeedback(); return pass; } diff --git a/tests/spec/ext_transform_feedback/builtin-varyings.c b/tests/spec/ext_transform_feedback/builtin-varyings.c index 29d84fe96..aeee87057 100644 --- a/tests/spec/ext_transform_feedback/builtin-varyings.c +++ b/tests/spec/ext_transform_feedback/builtin-varyings.c @@ -433,6 +433,32 @@ struct test_desc { GL_FLOAT, /* expected_type */ 1, /* expected_size */ }, + { + "gl_CullDistance", /* name */ + 130, /* version */ + + "#version 130\n" /* vs */ + "#extension GL_ARB_cull_distance : enable\n" /* vs */ + "in vec4 vertex_pos;\n" + "in float vertex_num;\n" + "out float gl_CullDistance[8];\n" + "void main() {\n" + " gl_Position = vertex_pos;\n" + " float scale = 1.0/256.0;\n" + " for(int i = 0; i < 8; ++i)\n" + " gl_CullDistance[i] = (float(i) + 8.0 * vertex_num) * scale;\n" + "}\n", + + 8, /* num_varyings */ + {"gl_CullDistance[0]", "gl_CullDistance[1]", /* varyings */ + "gl_CullDistance[2]", "gl_CullDistance[3]", + "gl_CullDistance[4]", "gl_CullDistance[5]", + "gl_CullDistance[6]", "gl_CullDistance[7]"}, + + 8, /* expected_num_output_components */ + GL_FLOAT, /* expected_type */ + 1, /* expected_size */ + }, }; const struct test_desc *test_to_run; @@ -480,6 +506,9 @@ piglit_init(int argc, char **argv) /* Set up test */ piglit_require_vertex_shader(); piglit_require_GLSL_version(test_to_run->version); + if (strcmp("gl_CullDistance", test_to_run->name) == 0) { + piglit_require_extension("GL_ARB_cull_distance"); + } piglit_require_transform_feedback(); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, test_to_run->vs); prog = glCreateProgram(); diff --git a/tests/spec/ext_transform_feedback/discard-bitmap.c b/tests/spec/ext_transform_feedback/discard-bitmap.c index 0f5db5018..428c87e06 100644 --- a/tests/spec/ext_transform_feedback/discard-bitmap.c +++ b/tests/spec/ext_transform_feedback/discard-bitmap.c @@ -32,7 +32,7 @@ * * "Primitives can be optionally discarded before rasterization by * calling Enable and Disable with RASTERIZER_DISCARD_EXT. When - * enabled, primitives are discared right before the + * enabled, primitives are discarded right before the * rasterization stage, but after the optional transform feedback * stage. When disabled, primitives are passed through to the * rasterization stage to be processed diff --git a/tests/spec/ext_transform_feedback/discard-clear.c b/tests/spec/ext_transform_feedback/discard-clear.c index d67aad5f2..9db26a9d5 100644 --- a/tests/spec/ext_transform_feedback/discard-clear.c +++ b/tests/spec/ext_transform_feedback/discard-clear.c @@ -32,7 +32,7 @@ * * "Primitives can be optionally discarded before rasterization by * calling Enable and Disable with RASTERIZER_DISCARD_EXT. When - * enabled, primitives are discared right before the + * enabled, primitives are discarded right before the * rasterization stage, but after the optional transform feedback * stage. When disabled, primitives are passed through to the * rasterization stage to be processed diff --git a/tests/spec/ext_transform_feedback/discard-copypixels.c b/tests/spec/ext_transform_feedback/discard-copypixels.c index cfd796b4e..b3c2f5fe9 100644 --- a/tests/spec/ext_transform_feedback/discard-copypixels.c +++ b/tests/spec/ext_transform_feedback/discard-copypixels.c @@ -32,7 +32,7 @@ * * "Primitives can be optionally discarded before rasterization by * calling Enable and Disable with RASTERIZER_DISCARD_EXT. When - * enabled, primitives are discared right before the + * enabled, primitives are discarded right before the * rasterization stage, but after the optional transform feedback * stage. When disabled, primitives are passed through to the * rasterization stage to be processed diff --git a/tests/spec/ext_transform_feedback/discard-drawarrays.c b/tests/spec/ext_transform_feedback/discard-drawarrays.c index ec47dd03d..f32807b72 100644 --- a/tests/spec/ext_transform_feedback/discard-drawarrays.c +++ b/tests/spec/ext_transform_feedback/discard-drawarrays.c @@ -33,7 +33,7 @@ * * "Primitives can be optionally discarded before rasterization by * calling Enable and Disable with RASTERIZER_DISCARD_EXT. When - * enabled, primitives are discared right before the + * enabled, primitives are discarded right before the * rasterization stage, but after the optional transform feedback * stage. When disabled, primitives are passed through to the * rasterization stage to be processed diff --git a/tests/spec/ext_transform_feedback/discard-drawpixels.c b/tests/spec/ext_transform_feedback/discard-drawpixels.c index a7958c9e4..94a643412 100644 --- a/tests/spec/ext_transform_feedback/discard-drawpixels.c +++ b/tests/spec/ext_transform_feedback/discard-drawpixels.c @@ -32,7 +32,7 @@ * * "Primitives can be optionally discarded before rasterization by * calling Enable and Disable with RASTERIZER_DISCARD_EXT. When - * enabled, primitives are discared right before the + * enabled, primitives are discarded right before the * rasterization stage, but after the optional transform feedback * stage. When disabled, primitives are passed through to the * rasterization stage to be processed diff --git a/tests/spec/ext_transform_feedback/geometry-shaders-basic.c b/tests/spec/ext_transform_feedback/geometry-shaders-basic.c index 213c80441..140de9b74 100644 --- a/tests/spec/ext_transform_feedback/geometry-shaders-basic.c +++ b/tests/spec/ext_transform_feedback/geometry-shaders-basic.c @@ -41,6 +41,7 @@ #include "piglit-util-gl.h" #define GEOM_OUT_VERTS 10 +#define DRAW_COUNT 10 PIGLIT_GL_TEST_CONFIG_BEGIN config.supports_gl_compat_version = 32; @@ -114,9 +115,9 @@ piglit_init(int argc, char **argv) glGenBuffers(1, &xfb_buf); glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf); glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, - GEOM_OUT_VERTS * sizeof(GLint), NULL, GL_STREAM_READ); + DRAW_COUNT * GEOM_OUT_VERTS * sizeof(GLint), NULL, GL_STREAM_READ); glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, xfb_buf, 0, - GEOM_OUT_VERTS * sizeof(GLint)); + DRAW_COUNT * GEOM_OUT_VERTS * sizeof(GLint)); /* Setup queries */ glGenQueries(1, &generated_query); @@ -126,21 +127,25 @@ piglit_init(int argc, char **argv) /* Do drawing */ glBeginTransformFeedback(GL_POINTS); - glDrawArrays(GL_POINTS, 0, 1); + for (i = 0; i < DRAW_COUNT; i++) { + glDrawArrays(GL_POINTS, 0, 1); + glPauseTransformFeedback(); + glResumeTransformFeedback(); + } glEndTransformFeedback(); /* Check query results */ glEndQuery(GL_PRIMITIVES_GENERATED); glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); glGetQueryObjectuiv(generated_query, GL_QUERY_RESULT, &query_result); - if (query_result != GEOM_OUT_VERTS) { + if (query_result != DRAW_COUNT * GEOM_OUT_VERTS) { printf("GL_PRIMITIVES_GENERATED query failed." " Expected %d, got %d.\n", GEOM_OUT_VERTS, query_result); pass = false; } glGetQueryObjectuiv(written_query, GL_QUERY_RESULT, &query_result); - if (query_result != GEOM_OUT_VERTS) { + if (query_result != DRAW_COUNT * GEOM_OUT_VERTS) { printf("GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN query failed." " Expected %d, got %d.\n", GEOM_OUT_VERTS, query_result); @@ -149,10 +154,12 @@ piglit_init(int argc, char **argv) /* Check transform feedback data */ readback = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, GL_READ_ONLY); - for (i = 0; i < GEOM_OUT_VERTS; i++) { - if (readback[i] != i) { + for (i = 0; i < DRAW_COUNT * GEOM_OUT_VERTS; i++) { + GLint expected = i % DRAW_COUNT; + GLint got = readback[i]; + if (got != expected) { printf("Incorrect data for vertex %d." - " Expected %d, got %d.", i, i, readback[i]); + " Expected %d, got %d.", i, expected, got); pass = false; } } diff --git a/tests/spec/ext_transform_feedback/max-varyings.c b/tests/spec/ext_transform_feedback/max-varyings.c index bbce09cce..dfe4b66bc 100644 --- a/tests/spec/ext_transform_feedback/max-varyings.c +++ b/tests/spec/ext_transform_feedback/max-varyings.c @@ -204,7 +204,7 @@ init_xfb_varyings(int max_varyings) /* Initialise arrays of arrays */ for (i = 0; i < AOA_OUTER_DIM; ++i) { for (j = 0; j < inner_dim; ++j) { - char *buf = malloc(16); + char *buf = malloc(17); sprintf(buf, "v[%d][%d]", i, j); xfb_varying_aoa[count++] = buf; } diff --git a/tests/spec/ext_transform_feedback/negative-prims.c b/tests/spec/ext_transform_feedback/negative-prims.c index 7716f61d4..c5b6a5319 100644 --- a/tests/spec/ext_transform_feedback/negative-prims.c +++ b/tests/spec/ext_transform_feedback/negative-prims.c @@ -88,7 +88,7 @@ test_one_prim(GLenum tf_prim, int i) } } else { if (error != 0) { - printf("Unxpected GL error 0x%x when " + printf("Unexpected GL error 0x%x when " "rendering %s during %s transform feedback\n", error, prim_name, tf_name); diff --git a/tests/spec/ext_transform_feedback/order.c b/tests/spec/ext_transform_feedback/order.c index 62f83b212..647c9b111 100644 --- a/tests/spec/ext_transform_feedback/order.c +++ b/tests/spec/ext_transform_feedback/order.c @@ -38,7 +38,7 @@ * correct order by using a vertex shader whose execution time is * dramatically different for different vertices. * - * The test requries two command line arguments: + * The test requires two command line arguments: * * - drawcall indicates which drawing function should be called. A * value of "arrays" causes DrawArrays() to be used. A value of diff --git a/tests/spec/ext_transform_feedback/structs.c b/tests/spec/ext_transform_feedback/structs.c index d67c3f307..d6a175abf 100644 --- a/tests/spec/ext_transform_feedback/structs.c +++ b/tests/spec/ext_transform_feedback/structs.c @@ -38,7 +38,7 @@ * passed to glTransformFeedbackVaryings(). * * - The intention is for the transform feedback API to behave - * similary to glGetUniformLocation() and + * similarly to glGetUniformLocation() and * glGetProgramResourceLocation(). * * This test verifies proper operation of transform feedback varyings diff --git a/tests/spec/ext_transform_feedback/tessellation.c b/tests/spec/ext_transform_feedback/tessellation.c index 7200ef917..4a437b954 100644 --- a/tests/spec/ext_transform_feedback/tessellation.c +++ b/tests/spec/ext_transform_feedback/tessellation.c @@ -62,7 +62,7 @@ * * The images are rendered using a fragment shader that attenuates the * color of back-facing primitives, so that the test will verify that - * tesellation preserves winding order properly. + * tessellation preserves winding order properly. * * The test can be run in four different coloring modes: * @@ -432,7 +432,7 @@ draw(GLuint prog, bool use_xfb, float y_offset, GLenum mode, if (use_xfb) { glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf); /* Initialize the buffer with 0 so that we will be - * able to identify membory that was not overwitten by + * able to identify membory that was not overwritten by * the transform feedback. */ memset(buffer, 0, sizeof(buffer)); @@ -473,7 +473,8 @@ print_usage_and_exit(char *prog_name) " monochrome\n" " smooth\n" " flat_first\n" - " flat_last\n", prog_name); + " flat_last\n" + " wireframe\n", prog_name); exit(1); } diff --git a/tests/spec/gl-1.0/dlist-beginend.c b/tests/spec/gl-1.0/dlist-beginend.c index eca32c1f3..5f11f98a5 100644 --- a/tests/spec/gl-1.0/dlist-beginend.c +++ b/tests/spec/gl-1.0/dlist-beginend.c @@ -312,6 +312,42 @@ test_illegal_begin_mode(void * unused) return pass ? PIGLIT_PASS : PIGLIT_FAIL; } +static enum piglit_result +test_reproducer_7335(void * unused) +{ + GLuint list; + bool pass; + + list = glGenLists(1); + glNewList(list, GL_COMPILE_AND_EXECUTE); + glBegin(GL_QUADS); + glColor4fv(green); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + /* In mesa bug 7335 _mesa_End() incorrectly restores the wrong GL dispatch table. + * This causes only the first command (glPushMatrix) of the following commands to + * be dispatched (the others are dropped). + */ + glPushMatrix(); + glPopMatrix(); + glEndList(); + + glCallList(list); + + /* This should cause a GL_STACK_UNDERFLOW, unless the glPopMatrix + * was dropped from the display list. + */ + glPopMatrix(); + pass = piglit_check_gl_error(GL_STACK_UNDERFLOW); + + glDeleteLists(list, 1); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + static const struct piglit_subtest tests[] = { { @@ -356,6 +392,12 @@ static const struct piglit_subtest tests[] = { test_illegal_begin_mode, NULL }, + { + "incorrect dlist with glthread (bug 7335)", + "incorrect-dlist-glthread", + test_reproducer_7335, + NULL + }, { 0 }, }; diff --git a/tests/spec/gl-1.0/logicop.c b/tests/spec/gl-1.0/logicop.c index 85587596f..8bf927a44 100644 --- a/tests/spec/gl-1.0/logicop.c +++ b/tests/spec/gl-1.0/logicop.c @@ -53,7 +53,7 @@ struct test_data { bool msaa; }; -static struct test_data datas[] = { +static struct test_data data[] = { { GL_CLEAR, false }, { GL_SET, false }, { GL_COPY, false }, @@ -88,20 +88,20 @@ static struct test_data datas[] = { { GL_OR_INVERTED, true }, }; -static struct piglit_subtest tests[ARRAY_SIZE(datas) + 1]; +static struct piglit_subtest tests[ARRAY_SIZE(data) + 1]; PIGLIT_GL_TEST_CONFIG_BEGIN piglit_config = &config; - for (int i = 0; i < ARRAY_SIZE(datas); i++) { + for (int i = 0; i < ARRAY_SIZE(data); i++) { char *name; - asprintf(&name, "%s%s", piglit_get_gl_enum_name(datas[i].mode), - datas[i].msaa ? "_MSAA" : ""); + asprintf(&name, "%s%s", piglit_get_gl_enum_name(data[i].mode), + data[i].msaa ? "_MSAA" : ""); tests[i].name = name; tests[i].option = name; tests[i].subtest_func = test_logicop; - tests[i].data = &datas[i]; + tests[i].data = &data[i]; } config.subtests = tests; diff --git a/tests/spec/gl-1.0/no-op-paths.c b/tests/spec/gl-1.0/no-op-paths.c index 7c86b7c30..257a696ed 100644 --- a/tests/spec/gl-1.0/no-op-paths.c +++ b/tests/spec/gl-1.0/no-op-paths.c @@ -30,7 +30,7 @@ * * * Based on the original Glean tpaths.cpp test, this test verifies - * that basic, trival OpenGL paths work as expected. For example, + * that basic, trivial OpenGL paths work as expected. For example, * glAlphaFunc(GL_GEQUAL, 0.0) should always pass and * glAlphaFunc(GL_LESS, 0.0) should always fail. We setup trivial * pass and fail conditions for each of alpha test, blending, color mask, diff --git a/tests/spec/gl-1.0/rendermode-feedback.c b/tests/spec/gl-1.0/rendermode-feedback.c index 0f64881f2..2e7325ccf 100644 --- a/tests/spec/gl-1.0/rendermode-feedback.c +++ b/tests/spec/gl-1.0/rendermode-feedback.c @@ -94,6 +94,8 @@ struct type { ARRAY_SIZE(gl_4d_color_texture_values) }, }; +static struct piglit_subtest tests[ARRAY_SIZE(types) + 1]; + static enum piglit_result run_subtest(void * data); static const struct piglit_gl_test_config * piglit_config; @@ -101,13 +103,15 @@ PIGLIT_GL_TEST_CONFIG_BEGIN piglit_config = &config; - struct piglit_subtest tests[ARRAY_SIZE(types) + 1] = { 0 }; for (unsigned i = 0; i < ARRAY_SIZE(types); ++i) { tests[i].name = piglit_get_gl_enum_name(types[i].type); tests[i].option = tests[i].name; tests[i].subtest_func = run_subtest; tests[i].data = (void *)&types[i]; } + + tests[ARRAY_SIZE(types)].name = NULL; + config.subtests = tests; config.supports_gl_compat_version = 10; @@ -122,7 +126,7 @@ report_failure(struct type *type, float *buffer, int count) { int i; - fprintf(stderr, "Feeback failed for %s:\n", + fprintf(stderr, "Feedback failed for %s:\n", piglit_get_gl_enum_name(type->type)); fprintf(stderr, " Expected: Observed: (%d/%d)\n", diff --git a/tests/spec/gl-1.0/scissor-bitmap.c b/tests/spec/gl-1.0/scissor-bitmap.c index 463d40ea4..88a9cffba 100644 --- a/tests/spec/gl-1.0/scissor-bitmap.c +++ b/tests/spec/gl-1.0/scissor-bitmap.c @@ -84,7 +84,7 @@ get_bitmap_bit(int x, int y) } static GLboolean -verify_bitmap_pixel(struct probes *probes, int i, int x, int y) +verify_bitmap_pixel(float *pixels, struct probes *probes, int i, int x, int y) { const GLfloat black[4] = {0.0, 0.0, 0.0, 0.0}; int x1 = probes->probes[i].x; @@ -111,7 +111,9 @@ verify_bitmap_pixel(struct probes *probes, int i, int x, int y) } /* Make sure the region is black */ - pass = piglit_probe_pixel_rgb(x, y, expected); + pass = piglit_compare_pixels(x, y, expected, + pixels + (y * piglit_width + x) * 3, + piglit_tolerance, 3); if (!pass) printf("glBitmap error in %s (test offset %d,%d)\n", probes->probes[i].name, @@ -121,7 +123,7 @@ verify_bitmap_pixel(struct probes *probes, int i, int x, int y) } static GLboolean -verify_bitmap_contents(struct probes *probes, int i) +verify_bitmap_contents(float *pixels, struct probes *probes, int i) { int x, y; int x1 = probes->probes[i].x; @@ -137,7 +139,7 @@ verify_bitmap_contents(struct probes *probes, int i) if (x < 0 || x >= piglit_width) continue; - pass &= verify_bitmap_pixel(probes, i, x, y); + pass &= verify_bitmap_pixel(pixels, probes, i, x, y); if (!pass) return pass; } @@ -145,7 +147,6 @@ verify_bitmap_contents(struct probes *probes, int i) return pass; } - enum piglit_result piglit_display() { @@ -291,9 +292,12 @@ piglit_display() fdo_bitmap_width, fdo_bitmap_height * 3 / 4, 0, 0); + float *pixels = malloc(piglit_width * piglit_height * 3 * sizeof(float)); + glReadPixels(0, 0, piglit_width, piglit_height, GL_RGB, GL_FLOAT, pixels); for (i = 0; i < probes.n_probes; i++) { - pass = pass && verify_bitmap_contents(&probes, i); + pass = pass && verify_bitmap_contents(pixels, &probes, i); } + free(pixels); piglit_present_results(); diff --git a/tests/spec/gl-1.1/drawarrays-vertex-count.c b/tests/spec/gl-1.1/drawarrays-vertex-count.c index f307bcdd7..49cf8c437 100644 --- a/tests/spec/gl-1.1/drawarrays-vertex-count.c +++ b/tests/spec/gl-1.1/drawarrays-vertex-count.c @@ -92,7 +92,7 @@ probe_line_rect(int x1, int y1, int x2, int y2) black)); } -/* Sets a range of the color array to a spefific color. */ +/* Sets a range of the color array to a specific color. */ static void set_colors(float *colors, unsigned int start, unsigned int count, const float *color) diff --git a/tests/spec/gl-1.5/get-array-attribs.c b/tests/spec/gl-1.5/get-array-attribs.c index 6aa3c7832..22a7cbf5a 100644 --- a/tests/spec/gl-1.5/get-array-attribs.c +++ b/tests/spec/gl-1.5/get-array-attribs.c @@ -93,7 +93,7 @@ void piglit_init(int argc, char **argv) { bool pass = true; - GLubyte dummy[100]; + GLubyte dummy[100] = {0}; glVertexPointer(2, GL_FLOAT, 12, dummy); glNormalPointer(GL_FLOAT, 0, dummy); diff --git a/tests/spec/gl-2.0/glsl-link-empty-prog.c b/tests/spec/gl-2.0/glsl-link-empty-prog.c index 6e57a4345..5cd15b3c7 100644 --- a/tests/spec/gl-2.0/glsl-link-empty-prog.c +++ b/tests/spec/gl-2.0/glsl-link-empty-prog.c @@ -25,7 +25,7 @@ * * Verify behavior when a program object with no shaders attached is used. * Neither the OpenGL spec nor the GLSL spec are explicit about what happens - * in this case. However, the correct behavior can be infered from a few bits + * in this case. However, the correct behavior can be inferred from a few bits * in the spec. Section 2.15 of the GL 2.1 spec says: * * "When the program object currently in use includes a vertex shader, its diff --git a/tests/spec/gl-2.0/large-point-fs.c b/tests/spec/gl-2.0/large-point-fs.c index 27e9c55ab..8903645a3 100644 --- a/tests/spec/gl-2.0/large-point-fs.c +++ b/tests/spec/gl-2.0/large-point-fs.c @@ -94,7 +94,7 @@ piglit_display(void) } size = MIN2(30, size); - probeSize = size - 2; /* to accomodate small rasterization errors */ + probeSize = size - 2; /* to accommodate small rasterization errors */ glUniform4fv(color_scale_uniform, 1, scale); glUniform4fv(color_bias_uniform, 1, bias); diff --git a/tests/spec/gl-2.1/pbo.c b/tests/spec/gl-2.1/pbo.c index 59792cc5f..53be162ff 100644 --- a/tests/spec/gl-2.1/pbo.c +++ b/tests/spec/gl-2.1/pbo.c @@ -1071,7 +1071,7 @@ piglit_display(void) { "test_tex_sub_image", "", test_tex_sub_image, NULL }, { "test_polygon_stip", "", test_polygon_stip, NULL }, { "test_error_handling", "", test_error_handling, NULL }, - { NULL, NULL, NULL, NULL } /* End of list sentinal */ + { NULL, NULL, NULL, NULL } /* End of list sentinel */ }; result = piglit_run_selected_subtests(funcs, NULL, 0, result); diff --git a/tests/spec/gl-3.0/api/bindfragdata-link-error.c b/tests/spec/gl-3.0/api/bindfragdata-link-error.c index 63dbbf237..172b05867 100644 --- a/tests/spec/gl-3.0/api/bindfragdata-link-error.c +++ b/tests/spec/gl-3.0/api/bindfragdata-link-error.c @@ -104,7 +104,7 @@ void piglit_init(int argc, char **argv) /* Page 237 (page 253 of the PDF) of the OpenGL 3.0 spec says: * * "LinkProgram will fail if the assigned binding of a varying out - * variable would cause the GL to reference a non-existant + * variable would cause the GL to reference a non-existent * fragment color number (one greater than or equal to MAX DRAW * BUFFERS)." * @@ -140,7 +140,7 @@ void piglit_init(int argc, char **argv) * variable is bound to the same number. This type of aliasing is * not allowed." * - * Try this by assiging 'a[0]' and 'v' to the same slot, and also try + * Try this by assigning 'a[0]' and 'v' to the same slot, and also try * assigning 'a[1]' and 'v' to the same slot. * * This should not generate a GL error. It should only cause linking diff --git a/tests/spec/gl-3.0/api/clearbuffer-mixed-format.c b/tests/spec/gl-3.0/api/clearbuffer-mixed-format.c index 8f5febe3c..2c3966e80 100644 --- a/tests/spec/gl-3.0/api/clearbuffer-mixed-format.c +++ b/tests/spec/gl-3.0/api/clearbuffer-mixed-format.c @@ -70,7 +70,7 @@ GLenum type; const GLvoid *clear_color; } test_vectors[] = { - /* GL_RGBA8, GL_RGBA16 clamps the color vaues to [0, 1] */ + /* GL_RGBA8, GL_RGBA16 clamps the color values to [0, 1] */ { GL_RGBA8, GL_FLOAT, (const GLvoid *)fcolor[0] }, { GL_RGBA16, GL_FLOAT, (const GLvoid *)fcolor[1] }, diff --git a/tests/spec/gl-3.0/bound-resource-limits.c b/tests/spec/gl-3.0/bound-resource-limits.c index 19cc21aa6..f42367020 100644 --- a/tests/spec/gl-3.0/bound-resource-limits.c +++ b/tests/spec/gl-3.0/bound-resource-limits.c @@ -462,7 +462,7 @@ setup_vertex_element_buffers(void) * Setup the vertex buffer objects. */ for (i = 0; i < g_maxVertexAttribs - 1; i++) { - char strTemp[16]; + char strTemp[17]; if ((i + 1) * MAX_COMPONENTS < NUM_PRIMES) { attrib[0].x = attrib[1].x = @@ -845,7 +845,7 @@ piglit_display(void) for (i = 0; i < g_maxCombinedTextureImageUnits; i++) { GLuint tex; GLuint uniformLoc; - char strTemp[16]; + char strTemp[19]; glGenTextures(1, &tex); glActiveTexture(GL_TEXTURE0 + i); @@ -925,7 +925,7 @@ piglit_display(void) * Enable the rest of the attributes. */ for (i = 0; i < g_maxVertexAttribs - 1; i++) { - char strTemp[16]; + char strTemp[18]; snprintf(strTemp, sizeof(strTemp), "InValue%u", i); attribLoc = glGetAttribLocation(g_program, strTemp); @@ -1168,14 +1168,12 @@ piglit_init(int argc, char **argv) */ if ((g_debugMask & DEBUG_DONT_CLAMP_MAX_VARYINGS) == 0) { g_maxVaryingFloats = MIN2(g_maxVaryingFloats, 32); - fprintf(stderr, "Clamped max varying floats to %u.\n", - g_maxVaryingFloats); + printf("Clamped max varying floats to %u.\n", g_maxVaryingFloats); } if (g_drawMode == DRAW_IMMEDIATE) { g_maxVertexAttribs = 1; - fprintf(stderr, - "Immediate mode selected, using only one vertex attrib.\n"); + printf("Immediate mode selected, using only one vertex attrib.\n"); } /* diff --git a/tests/spec/gl-3.0/texture-integer.c b/tests/spec/gl-3.0/texture-integer.c index 587fd00b0..5d34db0a2 100644 --- a/tests/spec/gl-3.0/texture-integer.c +++ b/tests/spec/gl-3.0/texture-integer.c @@ -40,6 +40,7 @@ PIGLIT_GL_TEST_CONFIG_END static const char *TestName = "texture-integer"; static GLint TexWidth = 16, TexHeight = 16; static GLint BiasUniform = -1, TexUniform = -1; +static GLuint iProgram, uProgram; struct format_info { @@ -105,10 +106,10 @@ static const struct format_info Formats[] = { static const char *FragShaderText = "#version 130 \n" "uniform vec4 bias; \n" - "uniform isampler2D tex; \n" + "uniform %csampler2D tex; \n" "void main() \n" "{ \n" - " ivec4 t = texture(tex, gl_TexCoord[0].xy); \n" + " %cvec4 t = texture(tex, gl_TexCoord[0].xy); \n" " gl_FragColor = vec4(t) + bias; \n" "} \n"; @@ -314,6 +315,19 @@ test_format(const struct format_info *info) ; } + if (info->Signed) { + glUseProgram(iProgram); + BiasUniform = glGetUniformLocation(iProgram, "bias"); + TexUniform = glGetUniformLocation(iProgram, "tex"); + } else { + glUseProgram(uProgram); + BiasUniform = glGetUniformLocation(uProgram, "bias"); + TexUniform = glGetUniformLocation(uProgram, "tex"); + } + + + /* tex unit zero */ + glUniform1i(TexUniform, 0); /* compute, set test bias */ bias[0] = expected[0] - value[0]; bias[1] = expected[1] - value[1]; @@ -349,6 +363,8 @@ test_format(const struct format_info *info) return false; } + glUseProgram(0); + piglit_present_results(); free(buf); @@ -376,18 +392,16 @@ piglit_display(void) void piglit_init(int argc, char **argv) { - GLuint program; static GLuint tex; + char shaderText[1024]; piglit_require_gl_version(30); - program = piglit_build_simple_program(NULL, FragShaderText); - glUseProgram(program); - - BiasUniform = glGetUniformLocation(program, "bias"); - TexUniform = glGetUniformLocation(program, "tex"); + sprintf(shaderText, FragShaderText, 'i', 'i'); + iProgram = piglit_build_simple_program(NULL, shaderText); - glUniform1i(TexUniform, 0); /* tex unit zero */ + sprintf(shaderText, FragShaderText, 'u', 'u'); + uProgram = piglit_build_simple_program(NULL, shaderText); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); diff --git a/tests/spec/gl-3.2/adj-prims.c b/tests/spec/gl-3.2/adj-prims.c index b8c653425..ddeb09f6f 100644 --- a/tests/spec/gl-3.2/adj-prims.c +++ b/tests/spec/gl-3.2/adj-prims.c @@ -611,7 +611,7 @@ draw_lines_adj(GLuint vao, unsigned n) provoking_vertex, 1 + i/4); set_color(gray); - // draw preceeding "wing" line + // draw preceding "wing" line glDrawArrays(GL_LINES, i, 2); // draw trailing "wing" line glDrawArrays(GL_LINES, i+2, 2); diff --git a/tests/spec/gl-3.2/layered-rendering/blit.c b/tests/spec/gl-3.2/layered-rendering/blit.c index db171243c..bde65d497 100644 --- a/tests/spec/gl-3.2/layered-rendering/blit.c +++ b/tests/spec/gl-3.2/layered-rendering/blit.c @@ -251,7 +251,7 @@ testFramebufferBlitLayered(int x, int y, bool srcLayered, bool dstLayered) return false; } - /* Check for if any errors have occured */ + /* Check for if any errors have occurred */ if (!piglit_check_gl_error(GL_NO_ERROR)) { printf("Error setting up framebuffers for test.\n"); return false; @@ -286,7 +286,7 @@ testFramebufferBlitLayered(int x, int y, bool srcLayered, bool dstLayered) glDeleteTextures(1, &srcTex); glDeleteTextures(1, &dstTex); - /* Check for if any errors have occured */ + /* Check for if any errors have occurred */ if (!piglit_check_gl_error(GL_NO_ERROR)) { printf("Error setting up framebuffers for test.\n"); return false; @@ -324,7 +324,7 @@ piglit_display(void) pass = testFramebufferBlitLayered(2 * texWidth, texDepth * texHeight, false, false) && pass; - /* Check for if any errors have occured */ + /* Check for if any errors have occurred */ pass = piglit_check_gl_error(GL_NO_ERROR) && pass; piglit_present_results(); diff --git a/tests/spec/gl-3.2/layered-rendering/clear-color.c b/tests/spec/gl-3.2/layered-rendering/clear-color.c index 32572b09c..0071aa5c6 100644 --- a/tests/spec/gl-3.2/layered-rendering/clear-color.c +++ b/tests/spec/gl-3.2/layered-rendering/clear-color.c @@ -166,7 +166,7 @@ piglit_display(void) bool pass = true; const float clearColor[3] = { 1, 1, 0 }; - /* Clear Defualt Framebuffer */ + /* Clear Default Framebuffer */ glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo); glClearColor(1,1,0,1); glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/spec/gl-3.2/layered-rendering/clear-depth.c b/tests/spec/gl-3.2/layered-rendering/clear-depth.c index b58fccec9..9f509656b 100644 --- a/tests/spec/gl-3.2/layered-rendering/clear-depth.c +++ b/tests/spec/gl-3.2/layered-rendering/clear-depth.c @@ -180,7 +180,7 @@ piglit_init(int argc, char **argv) if(!probe_texture_layered_depth(texture[0], 0, 0, 0, 10, 10, 4, expected)) { - printf("Incorrect depth values recieved with glClear()\n"); + printf("Incorrect depth values received with glClear()\n"); pass = false; } @@ -190,7 +190,7 @@ piglit_init(int argc, char **argv) if(!probe_texture_layered_depth(texture[1], 0, 0, 0, 10, 10, 4, expected)) { - printf("Incorrect depth values recieved with glClearBuffer()\n"); + printf("Incorrect depth values received with glClearBuffer()\n"); pass = false; } diff --git a/tests/spec/gl-3.2/layered-rendering/framebuffertexture-defaults.c b/tests/spec/gl-3.2/layered-rendering/framebuffertexture-defaults.c index 4c9e47b77..486ef8ce3 100644 --- a/tests/spec/gl-3.2/layered-rendering/framebuffertexture-defaults.c +++ b/tests/spec/gl-3.2/layered-rendering/framebuffertexture-defaults.c @@ -77,7 +77,7 @@ check_texture_parameters(GLenum objType, int objName, int level, int layer, int } if(!piglit_check_gl_error(GL_NO_ERROR)) { - printf("Error has occured in check_texture_parameters()\n"); + printf("Error has occurred in check_texture_parameters()\n"); return false; } @@ -119,7 +119,7 @@ check_texture_parameters(GLenum objType, int objName, int level, int layer, int } if(!piglit_check_gl_error(GL_NO_ERROR)) { - printf("Error has occured in check_texture_parameters()\n"); + printf("Error has occurred in check_texture_parameters()\n"); return false; } } diff --git a/tests/spec/gl-3.2/layered-rendering/gl-layer-cube-map.c b/tests/spec/gl-3.2/layered-rendering/gl-layer-cube-map.c index bd3134a67..12c25c77d 100644 --- a/tests/spec/gl-3.2/layered-rendering/gl-layer-cube-map.c +++ b/tests/spec/gl-3.2/layered-rendering/gl-layer-cube-map.c @@ -140,7 +140,7 @@ piglit_init(int argc, char **argv) /* Check for errors during setup */ if(!check_framebuffer_status(GL_FRAMEBUFFER, GL_FRAMEBUFFER_COMPLETE) || !piglit_check_gl_error(GL_NO_ERROR)) { - printf("Error occured during setup.\n"); + printf("Error occurred during setup.\n"); piglit_report_result(PIGLIT_FAIL); } @@ -165,7 +165,7 @@ piglit_init(int argc, char **argv) if(!check_framebuffer_status(GL_FRAMEBUFFER, GL_FRAMEBUFFER_COMPLETE)) { - printf("Error occured while probing texture\n"); + printf("Error occurred while probing texture\n"); piglit_report_result(PIGLIT_FAIL); } diff --git a/tests/spec/gl-3.3/fb-null-attachment.shader_test b/tests/spec/gl-3.3/fb-null-attachment.shader_test new file mode 100644 index 000000000..c0edae516 --- /dev/null +++ b/tests/spec/gl-3.3/fb-null-attachment.shader_test @@ -0,0 +1,33 @@ +# Verify that a null framebuffer attachment doesn't affect framebuffer size +# +# This verifies that drivers aren't clamping framebuffers to a smaller size in the +# presence of null framebuffer attachments + +[require] +GL >= 3.3 +GLSL >= 3.30 +SIZE 1920 1080 + +[vertex shader passthrough] + +[fragment shader] +#version 330 + +out vec4 outcolor; + +void main() +{ + outcolor = vec4(0.0, 1.0, 0.0, 1.0); +} + +[test] +texture rgbw 0 (1920, 1080) GL_RGBA8 +texture rgbw 1 (1920, 1080) GL_RGBA8 + +fb tex 2d 0 -1 1 + +clear color 0.2 0.2 0.2 0.2 +clear +draw rect -1 -1 2 2 + +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/gl-4.5/compare-framebuffer-parameter-with-get.c b/tests/spec/gl-4.5/compare-framebuffer-parameter-with-get.c index 10c9eb907..0151042bb 100644 --- a/tests/spec/gl-4.5/compare-framebuffer-parameter-with-get.c +++ b/tests/spec/gl-4.5/compare-framebuffer-parameter-with-get.c @@ -211,7 +211,7 @@ get_framebuffer_name(int index) } /* - * Gets a framebuffer and attachs to it renderbuffer and other stuff, + * Gets a framebuffer and attaches to it renderbuffer and other stuff, * in order to ensure that it is a complete framebuffer. * * returns if it was successful. diff --git a/tests/spec/gles-3.0/CMakeLists.gles3.txt b/tests/spec/gles-3.0/CMakeLists.gles3.txt index 9f7ffe8ce..b6d6a83c3 100644 --- a/tests/spec/gles-3.0/CMakeLists.gles3.txt +++ b/tests/spec/gles-3.0/CMakeLists.gles3.txt @@ -3,10 +3,12 @@ link_libraries( ) piglit_add_executable (gles-3.0-drawarrays-vertexid drawarrays-vertexid.c) +piglit_add_executable(clear_stencil_gles3 clear-stencil.c) piglit_add_executable(minmax_${piglit_target_api} minmax.c) piglit_add_executable(oes_compressed_etc2_texture-miptree_gles3 oes_compressed_etc2_texture-miptree.c) piglit_add_executable(texture-immutable-levels_gles3 texture-immutable-levels.c) piglit_add_executable(read_depth_gles3 read-depth.c) +piglit_add_executable(read_depth_offset_gles3 read-depth-offset.c) piglit_add_executable(gles-3.0-transform-feedback-uniform-buffer-object transform-feedback-uniform-buffer-object.c) piglit_add_executable(gles-3.0-attribute-aliasing attribute-aliasing.c) diff --git a/tests/spec/gles-3.0/clear-stencil.c b/tests/spec/gles-3.0/clear-stencil.c new file mode 100644 index 000000000..1379e2220 --- /dev/null +++ b/tests/spec/gles-3.0/clear-stencil.c @@ -0,0 +1,231 @@ +/* + * Copyright © 2024 Collabora Ltd + * + * Based on read-depth, which has + * Copyright © 2015 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/** @file clear-stencil.c + * + * Tests clearing stencil data. Some drivers, particularly for tile + * based renderers, may try to keep track of stencil data to optimize + * clears. This test will fail if they do it wrong (as the panfrost + * driver did at one point). + */ + +#include "piglit-util-gl.h" + +#define TEX_WIDTH 4 +#define TEX_HEIGHT 4 +#define TEX_LAYERS 2 + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 31; + config.window_visual = PIGLIT_GL_VISUAL_DEPTH; + +PIGLIT_GL_TEST_CONFIG_END + +static GLint prog; + +const char *vs_source = + "#version 310 es\n" + "vec4 vertcoord(uint i) {\n" + " vec2 base[3] = vec2[3](vec2(-1.0f, -3.0f), vec2(3.0f, 1.0f), vec2(-1.0f, 1.0f));\n" + " return vec4(base[i], 0.0f, 1.0f);\n" + "}\n" + + "void main()\n" + "{\n" + " gl_Position = vertcoord(uint(gl_VertexID));\n" + " gl_Position.y = -(gl_Position.y);\n" + " gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);\n" + "}\n"; + +const char *fs_source = + "#version 310 es\n" + "precision highp float;\n" + "layout(location = 0) out float value;\n" + + "void main()\n" + "{\n" + " value = 1.0f;\n" + "}\n"; + +/* fill the depth and stencil buffers with some arbitrary (non-zero) data */ +static void +fill_layer(GLuint tex, int layer) +{ + GLuint fb; + GLenum zero = GL_ZERO; + + glGenFramebuffers(1, &fb); + glBindFramebuffer(GL_FRAMEBUFFER, fb); + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, tex, 0, layer); + glDrawBuffers(1, &zero); + + glDisable(GL_SCISSOR_TEST); + glDepthMask(GL_TRUE); + glStencilMask(255); + glClearBufferfi(GL_DEPTH_STENCIL, 0, 0.8, 42); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &fb); +} + +/* create a multiple layer depth/stencil texture that is cleared to 0 initially */ +static GLuint +create_depth_stencil_tex(GLenum depth_type) +{ + GLuint fbo, tex; + int i; + + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + + glDepthMask(GL_TRUE); + glDisable(GL_STENCIL_TEST); + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D_ARRAY, tex); + /* create a 2x2x7 texture */ + glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, depth_type, TEX_WIDTH, TEX_HEIGHT, TEX_LAYERS); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + /* clear all the layers */ + for (i = 0; i < TEX_LAYERS; i++) { + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, tex, 0, i); + glDepthMask(GL_TRUE); + glStencilMask(255); + glClearBufferfi(GL_DEPTH_STENCIL, 0, 0, 0); + } + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + fill_layer(tex, 0); + return tex; +} + +/* create the target texture for rendering, and fill it with 0's */ +static GLuint +create_target_tex() +{ + static GLubyte byte_zeros[TEX_WIDTH*TEX_HEIGHT] = { 0 }; + static GLfloat float_zeros[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + GLuint tex, fbo; + + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + glTexStorage2D(GL_TEXTURE_2D, 1, GL_R8, TEX_WIDTH, TEX_HEIGHT); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEX_WIDTH, TEX_HEIGHT, GL_RED, GL_UNSIGNED_BYTE, byte_zeros); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glColorMaskiEXT(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0); + glClearBufferfv(GL_COLOR, 0, float_zeros); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &fbo); + return tex; +} + +static bool +check_pixels(GLuint tex) +{ + GLuint fbo; + GLubyte pixels[TEX_WIDTH*TEX_HEIGHT]; + int i; + + memset(pixels, 0xcc, sizeof(pixels)); + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0); + glReadBuffer(GL_COLOR_ATTACHMENT0); + glReadPixels(0, 0, TEX_WIDTH, TEX_HEIGHT, GL_RED, GL_UNSIGNED_BYTE, pixels); + for (i = 0; i < TEX_WIDTH; i++) { + if (pixels[i] != 0xff) + return false; + } + return true; +} + +static bool +test_format(GLenum depth_format) +{ + GLuint fbo; + GLuint depth_tex; + GLuint out_tex; + static GLenum drawto[] = { GL_COLOR_ATTACHMENT0 }; + bool result; + + glViewport(0, 0, TEX_WIDTH, TEX_HEIGHT); + glScissor(0, 0, TEX_WIDTH, TEX_HEIGHT); + + depth_tex = create_depth_stencil_tex(depth_format); + + out_tex = create_target_tex(); + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, out_tex, 0); + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, depth_tex, 0, TEX_LAYERS-1); + glDrawBuffers(1, drawto); + glUseProgram(prog); + + glStencilFuncSeparate(GL_BACK, GL_EQUAL, 0, 255); + glStencilFuncSeparate(GL_FRONT, GL_EQUAL, 0, 255); + glStencilOpSeparate(GL_BACK, GL_KEEP, GL_KEEP, GL_KEEP); + glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP); + + GLuint vert_array; + glGenVertexArrays(1, &vert_array); + glBindVertexArray(vert_array); + glDisable(GL_SCISSOR_TEST); + glDepthMask(GL_FALSE); + glEnable(GL_STENCIL_TEST); + glEnable(GL_SCISSOR_TEST); + glDrawArraysInstanced(GL_TRIANGLES, 0, 3, 1); + glDisable(GL_SCISSOR_TEST); + glBindVertexArray(0); + glDeleteVertexArrays(1, &vert_array); + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &fbo); + result = check_pixels(out_tex); + + glDeleteTextures(1, &out_tex); + glDeleteTextures(1, &depth_tex); + return result; +} + +const GLenum tests[] = { + GL_DEPTH24_STENCIL8, + GL_DEPTH32F_STENCIL8, +}; + +enum piglit_result +piglit_display(void) +{ + unsigned j; + + /* Loop through formats listed in 'tests'. */ + for (j = 0; j < ARRAY_SIZE(tests); j++) { + if (!test_format(tests[j])) + return PIGLIT_FAIL; + } + return PIGLIT_PASS; +} + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_NV_read_depth"); + prog = piglit_build_simple_program(vs_source, fs_source); + glUseProgram(prog); +} diff --git a/tests/spec/gles-3.0/read-depth-offset.c b/tests/spec/gles-3.0/read-depth-offset.c new file mode 100644 index 000000000..970db8d1e --- /dev/null +++ b/tests/spec/gles-3.0/read-depth-offset.c @@ -0,0 +1,252 @@ +/* + * Copyright © 2024 Collabora Ltd + * + * Based on read-depth, which has + * Copyright © 2015 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/** @file read-depth-offset.c + * + * Tests glPolygonOffset calculations + * + * Test iterates over table of depth buffer formats and expected types to + * read values back from each format. For each format it renders a rectangle at + * different depth levels, reads back a pixel and verifies expected depth value. + * + * The spec is fairly clear on the calculations for floating point depth + * buffers, but for fixed point it merely specifies that the value r + * used for the minimum resolvable difference is "implementation defined". + * But it must be the same for all depth values, so we can at least + * check that. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 30; + config.window_visual = PIGLIT_GL_VISUAL_DEPTH; + +PIGLIT_GL_TEST_CONFIG_END + +static GLint prog; + +const char *vs_source = + "attribute vec4 vertex;\n" + "uniform float depth;\n" + "void main()\n" + "{\n" + " gl_Position = vec4(vertex.xy, depth, 1.0);\n" + "}\n"; + +const char *fs_source = + "void main()\n" + "{\n" + "}\n"; + +/* this is a fairly arbitrary test for floats being "close" together. + we don't want to make too many assumptions about how the GPU hardware + does floating point calculations, so we don't even assume IEEE binary + compliance +*/ +static bool +equals(float a, float b) +{ + return fabs(a - b) < 0.00001; +} + +#define DEPTH_BIAS_UNITS 256.0 + +/* + * Calculate the expected depth after offset applied. + * We assume the polygon is facing the screen and + * that glPolygonOffsetClamp factor is 0.0. + * For fixed point formats, the minimum resolvable + * difference in depth values is passed as a + * pointer; if this value is 0, we do no + * offsetting and instead return the raw value read + * (so that the caller can calculate what mrd is + * being used by the fixed point hardware). + */ + +static GLfloat +offset_depth(GLenum type, GLfloat inputZ, double mrd) +{ + GLfloat near = -1.0; + GLfloat far = 1.0; + GLfloat zw, offset; + double work; + int exp; + + zw = inputZ * (far-near)/2.0 + (far+near)/2.0; + + /* for floats, find the minimum resolvable difference near inputZ */ + if (type == GL_FLOAT) { + double mant; + work = (double) zw; + mant = frexp(work, &exp); + if (mant == 0) + mrd = 0; /* 0 has no exponent, really */ + else { + mrd = exp2(exp-24); + } + } + offset = (GLfloat)(mrd * DEPTH_BIAS_UNITS); + + zw += offset; + + if (zw < near) zw = near; + if (zw > far) zw = far; + return zw; +} + +static GLuint +create_depth_fbo(GLenum depth_type) +{ + GLuint fbo, buffer; + GLenum status; + + glGenRenderbuffers(1, &buffer); + glBindRenderbuffer(GL_RENDERBUFFER, buffer); + glRenderbufferStorage(GL_RENDERBUFFER, + depth_type, piglit_width, piglit_height); + + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + + glFramebufferRenderbuffer(GL_FRAMEBUFFER, + GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, buffer); + + status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if (status != GL_FRAMEBUFFER_COMPLETE) { + fprintf(stderr, "error creating framebuffer, status 0x%x\n", + status); + return 0; + } + return fbo; +} + +static bool +check_depth(GLenum type, float source_depth, double *mrd_ptr) +{ + float expect; + GLfloat data; + GLuint uint_pixel; + double mrd; + + if (type == GL_FLOAT) { + glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, type, + (void *) &data); + } else { + glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, type, + (void *) &uint_pixel); + uint_pixel = uint_pixel >> 8; + data = (1.0 * ((float) uint_pixel)) / 16777215.0; + } + + if (!piglit_check_gl_error(GL_NO_ERROR)) + return false; + + mrd = *mrd_ptr; + expect = offset_depth(type, source_depth, mrd); + /* if we haven't computed the minimum resolvable difference yet, + then figure it out here */ + if (type != GL_FLOAT && mrd == 0.0) { + double delta = fabs(data - source_depth); + mrd = delta / DEPTH_BIAS_UNITS; +#if 0 + /* useful for debugging failures, but #if'd out for normal usage */ + printf("orig: %a read: %a delta: %a mrd: %a\n", source_depth, data, delta, mrd); +#endif + *mrd_ptr = mrd; + expect = data; /* no failure on first time through */ + } + + if (!equals(data, expect)) { + if (type == GL_FLOAT && source_depth == 0.0 && fabs(data - source_depth)/DEPTH_BIAS_UNITS < 0.000001 ) { + /* floating point 0.0 upsets some hardware, just accept + whatever it gave us */ + } else { + fprintf(stderr, "%s Z source: %f expected: %f actual: %f\n", + (type == GL_FLOAT) ? "float" : "fixed", source_depth, expect, data); + return false; + } + } + return true; +} + +const GLenum tests[] = { + GL_DEPTH_COMPONENT16, GL_UNSIGNED_INT_24_8_OES, + GL_DEPTH_COMPONENT24, GL_UNSIGNED_INT_24_8_OES, + GL_DEPTH_COMPONENT32F, GL_FLOAT, +}; + +static bool +test_format(GLenum depth_format, GLenum read_type) +{ + const float step = 0.1; + int steps = (int)round(1.0 / step); + double mrd = 0.0; /* minimum resolvable difference */ + float expect = 0.0; + int i; + bool test_ok; + + GLuint fbo = create_depth_fbo(depth_format); + if (!fbo) + return PIGLIT_FAIL; + + /* Step from -1.0 to 1.0, linear depth. Render a rectangle at + * depth i, read pixel and verify expected depth value. + */ + for (i = -steps; i <= steps; i++) { + GLfloat depth = (GLfloat)i / steps; + glDepthRangef(-1.0, 1.0); + glPolygonOffset(0, DEPTH_BIAS_UNITS); + glEnable(GL_POLYGON_OFFSET_FILL); + + glClear(GL_DEPTH_BUFFER_BIT); + glUniform1f(glGetUniformLocation(prog, "depth"), depth); + + piglit_draw_rect(-1, -1, 2, 2); + + test_ok = check_depth(read_type, expect, &mrd); + + glPolygonOffset(0, 0); + glDisable(GL_POLYGON_OFFSET_FILL); + glDepthRangef(0.0, 1.0); + + if (!test_ok) + return false; + + expect += step / 2.0; + } + glDeleteFramebuffers(1, &fbo); + return true; +} + +enum piglit_result +piglit_display(void) +{ + unsigned j; + + glEnable(GL_DEPTH_TEST); + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + + /* Loop through formats listed in 'tests'. */ + for (j = 0; j < ARRAY_SIZE(tests); j += 2) { + + if (!test_format(tests[j], tests[j+1])) + return PIGLIT_FAIL; + } + return PIGLIT_PASS; +} + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_NV_read_depth"); + prog = piglit_build_simple_program(vs_source, fs_source); + glUseProgram(prog); +} diff --git a/tests/spec/gles-3.0/transform-feedback-uniform-buffer-object.c b/tests/spec/gles-3.0/transform-feedback-uniform-buffer-object.c index e4a6a00e0..03373d3ed 100644 --- a/tests/spec/gles-3.0/transform-feedback-uniform-buffer-object.c +++ b/tests/spec/gles-3.0/transform-feedback-uniform-buffer-object.c @@ -80,8 +80,8 @@ static const char *vs_ubo_src = "#version 300 es\n" "uniform int ubo_pass;\n" "uniform int tile;\n" - "uniform ubo {\n" - " int tf_pass[8 * 8 * 6];\n" + "layout (std140) uniform ubo {\n" + " ivec4 tf_pass[(8 * 8 * 6) / 4];\n" "};\n" "in vec4 piglit_vertex;\n" "flat out vec4 color;\n" @@ -89,7 +89,10 @@ static const char *vs_ubo_src = "{\n" " color = vec4(0.0);\n" " for (int i = 0; i < tf_pass.length(); ++i)\n" - " if (ubo_pass != tf_pass[i])\n" + " if (ubo_pass != tf_pass[i].x ||\n" + " ubo_pass != tf_pass[i].y ||\n" + " ubo_pass != tf_pass[i].z ||\n" + " ubo_pass != tf_pass[i].w)\n" " color[ubo_pass] = 1.0;\n" " gl_Position = piglit_vertex;\n" "}\n"; diff --git a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-global.frag b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-global.frag index 5d61434c2..7560afcc5 100644 --- a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-global.frag +++ b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-global.frag @@ -3,7 +3,7 @@ // glsl_version: 1.10 // [end config] // -// Compilation should fail becuase the type 'B' is unknown. +// Compilation should fail because the type 'B' is unknown. // // Reproduces Mesa bugzilla #33313. diff --git a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-global.vert b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-global.vert index b17d381e3..563dff269 100644 --- a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-global.vert +++ b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-global.vert @@ -3,7 +3,7 @@ // glsl_version: 1.10 // [end config] // -// Compilation should fail becuase the type 'B' is unknown. +// Compilation should fail because the type 'B' is unknown. // // Reproduces Mesa bugzilla #33313. diff --git a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-parameter.frag b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-parameter.frag index 4014880dc..086b98b02 100644 --- a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-parameter.frag +++ b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-parameter.frag @@ -3,7 +3,7 @@ // glsl_version: 1.10 // [end config] // -// Compilation should fail becuase the type 'B' is unknown. +// Compilation should fail because the type 'B' is unknown. // // Reproduces Mesa bugzilla #33313. diff --git a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-parameter.vert b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-parameter.vert index 1c1148b21..cfdd56661 100644 --- a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-parameter.vert +++ b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-parameter.vert @@ -3,7 +3,7 @@ // glsl_version: 1.10 // [end config] // -// Compilation should fail becuase the type 'B' is unknown. +// Compilation should fail because the type 'B' is unknown. // // Reproduces Mesa bugzilla #33313. diff --git a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-struct-member.frag b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-struct-member.frag index 4eb111986..b5c681e99 100644 --- a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-struct-member.frag +++ b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-struct-member.frag @@ -3,7 +3,7 @@ // glsl_version: 1.10 // [end config] // -// Compilation should fail becuase the type 'B' is unknown. +// Compilation should fail because the type 'B' is unknown. // // Reproduces Mesa bugzilla #33313. diff --git a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-struct-member.vert b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-struct-member.vert index effec473b..a6fd78d92 100644 --- a/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-struct-member.vert +++ b/tests/spec/glsl-1.10/compiler/declarations/bad-array-type-struct-member.vert @@ -3,7 +3,7 @@ // glsl_version: 1.10 // [end config] // -// Compilation should fail becuase the type 'B' is unknown. +// Compilation should fail because the type 'B' is unknown. // // Reproduces Mesa bugzilla #33313. diff --git a/tests/spec/glsl-1.10/execution/built-in-matrix-state.c b/tests/spec/glsl-1.10/execution/built-in-matrix-state.c index 83d9b0622..ba5c2a839 100644 --- a/tests/spec/glsl-1.10/execution/built-in-matrix-state.c +++ b/tests/spec/glsl-1.10/execution/built-in-matrix-state.c @@ -24,7 +24,7 @@ /** * @file built-in-matrix-state.c: Access uniform matrix derived state in GLSL * - * Set coordiante transformation matrices with the OpenGL API and access them + * Set coordinate transformation matrices with the OpenGL API and access them * and their derived uniforms in a GLSL shader. */ diff --git a/tests/spec/glsl-1.10/execution/built-in-uniform-state.c b/tests/spec/glsl-1.10/execution/built-in-uniform-state.c index 5ab5ee893..7eb4f9911 100644 --- a/tests/spec/glsl-1.10/execution/built-in-uniform-state.c +++ b/tests/spec/glsl-1.10/execution/built-in-uniform-state.c @@ -458,19 +458,27 @@ piglit_display(void) pass; val[0] = DRAND(); + + /* Don't test infinity because shader comparisons with infinity are + * undefined. + */ + float fog_scale; + do { + val[1] = DRAND(); + val[2] = DRAND(); + fog_scale = 1 / (val[2] - val[1]); + } while (isinf(fog_scale)); + glFogf(GL_FOG_DENSITY, val[0]); pass = check_shader_builtin(GL_FLOAT, val, "gl_Fog.density") && pass; - val[1] = DRAND(); glFogf(GL_FOG_START, val[1]); pass = check_shader_builtin(GL_FLOAT, &val[1], "gl_Fog.start") && pass; - val[2] = DRAND(); glFogf(GL_FOG_END, val[2]); pass = check_shader_builtin(GL_FLOAT, &val[2], "gl_Fog.end") && pass; - const float fog_scale = 1 / (val[2] - val[1]); pass = check_shader_builtin(GL_FLOAT, &fog_scale, "gl_Fog.scale") && pass; diff --git a/tests/spec/glsl-1.10/execution/builtins/glsl-fs-clamp-abs.shader_test b/tests/spec/glsl-1.10/execution/builtins/glsl-fs-clamp-abs.shader_test new file mode 100644 index 000000000..1288a99b3 --- /dev/null +++ b/tests/spec/glsl-1.10/execution/builtins/glsl-fs-clamp-abs.shader_test @@ -0,0 +1,17 @@ +[require] +GLSL >= 1.10 + +[vertex shader passthrough] + +[fragment shader] +uniform vec4 color; + +void main() +{ + gl_FragColor = clamp(abs(color), 0.0, 1.0); +} + +[test] +uniform vec4 color -2.5 -1.5 0.4 0.5 +draw rect -1 -1 2 2 +probe all rgba 1.0 1.0 0.4 0.5 diff --git a/tests/spec/glsl-1.10/execution/builtins/glsl-fs-clamp-neg.shader_test b/tests/spec/glsl-1.10/execution/builtins/glsl-fs-clamp-neg.shader_test new file mode 100644 index 000000000..50bd4b2f4 --- /dev/null +++ b/tests/spec/glsl-1.10/execution/builtins/glsl-fs-clamp-neg.shader_test @@ -0,0 +1,17 @@ +[require] +GLSL >= 1.10 + +[vertex shader passthrough] + +[fragment shader] +uniform vec4 color; + +void main() +{ + gl_FragColor = clamp(-color, 0.0, 1.0); +} + +[test] +uniform vec4 color -2.5 -1.5 0.4 -0.5 +draw rect -1 -1 2 2 +probe all rgba 1.0 1.0 0.0 0.5 diff --git a/tests/spec/glsl-1.10/execution/color-interp-smooth-shademodel-flat.shader_test b/tests/spec/glsl-1.10/execution/color-interp-smooth-shademodel-flat.shader_test new file mode 100644 index 000000000..2db4ad542 --- /dev/null +++ b/tests/spec/glsl-1.10/execution/color-interp-smooth-shademodel-flat.shader_test @@ -0,0 +1,44 @@ +# A color varying qualified with smooth shouldn't be affected by +# glShadeModel(GL_FLAT). If compiler optimizations are applied that perform +# color deduplication and compaction, they should not merge color varyings +# with different qualifiers. + +[require] +GLSL >= 1.30 + +[vertex shader] +#version 130 +smooth out vec4 gl_FrontSecondaryColor; + +void main() +{ + gl_Position = gl_Vertex; + vec4 color = vec4(float(gl_VertexID) / 3.0); + gl_FrontColor = color; + gl_FrontSecondaryColor = color; +} + +[fragment shader] +#version 130 +uniform int b; +smooth in vec4 gl_SecondaryColor; + +void main() +{ + gl_FragColor = b != 0 ? gl_SecondaryColor : gl_Color; +} + +[test] +shade model flat + +uniform int b 0 +draw rect -1 -1 1 1 + +uniform int b 1 +draw rect 0 -1 1 1 + +probe rgb 50 50 0.666667 0.666667 0.666667 +probe rgb 100 100 1 1 1 + +probe rgb 175 50 0.403922 0.403922 0.403922 +probe rgb 225 100 0.803922 0.803922 0.803922 diff --git a/tests/spec/glsl-1.10/execution/copy-propagation/glsl-copy-propagation-loop-2.shader_test b/tests/spec/glsl-1.10/execution/copy-propagation/glsl-copy-propagation-loop-2.shader_test index cf63d2e2a..6e01e97dd 100644 --- a/tests/spec/glsl-1.10/execution/copy-propagation/glsl-copy-propagation-loop-2.shader_test +++ b/tests/spec/glsl-1.10/execution/copy-propagation/glsl-copy-propagation-loop-2.shader_test @@ -11,7 +11,7 @@ void main() } [fragment shader] -/* Tests for what was a crasher bug in glsl_copy_propagation_elements */ +/* Tests for what was a crash bug in glsl_copy_propagation_elements */ varying vec4 color; void main() diff --git a/tests/spec/glsl-1.10/execution/copy-propagation/glsl-vs-copy-propagation-1.shader_test b/tests/spec/glsl-1.10/execution/copy-propagation/glsl-vs-copy-propagation-1.shader_test index 226128737..15633c4e7 100644 --- a/tests/spec/glsl-1.10/execution/copy-propagation/glsl-vs-copy-propagation-1.shader_test +++ b/tests/spec/glsl-1.10/execution/copy-propagation/glsl-vs-copy-propagation-1.shader_test @@ -42,3 +42,8 @@ uniform vec4 u 0 1 0 0 uniform int j 1 draw rect -1 -1 2 2 probe all rgba 0 1 1 0 + +uniform vec4 u 0 1 0 0 +uniform int j 2 +draw rect -1 -1 2 2 +probe all rgba 0 1 0 0 diff --git a/tests/spec/glsl-1.10/execution/discard/glsl-fs-discard-mrt.c b/tests/spec/glsl-1.10/execution/discard/glsl-fs-discard-mrt.c index a15216523..64861d43e 100644 --- a/tests/spec/glsl-1.10/execution/discard/glsl-fs-discard-mrt.c +++ b/tests/spec/glsl-1.10/execution/discard/glsl-fs-discard-mrt.c @@ -180,16 +180,9 @@ piglit_display(void) void piglit_init(int argc, char **argv) { - GLint max_buffers; - piglit_require_GLSL(); piglit_require_extension("GL_ARB_explicit_attrib_location"); piglit_require_extension("GL_EXT_framebuffer_object"); - - glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_buffers); - if (max_buffers == 1) { - fprintf(stderr, "Test requires 2 draw buffers\n"); - piglit_report_result(PIGLIT_SKIP); - } + piglit_require_minimum_getinteger(GL_MAX_DRAW_BUFFERS, 2); } diff --git a/tests/spec/glsl-1.10/execution/fs-nested-loop-unrolled-with-return.shader_test b/tests/spec/glsl-1.10/execution/fs-nested-loop-unrolled-with-return.shader_test index 1f02e2f95..280ef77fc 100644 --- a/tests/spec/glsl-1.10/execution/fs-nested-loop-unrolled-with-return.shader_test +++ b/tests/spec/glsl-1.10/execution/fs-nested-loop-unrolled-with-return.shader_test @@ -17,7 +17,7 @@ void main(void) uniform int a; vec4 getColour() { - /* We use a uniform in the outer loop comparision so it's not immediately + /* We use a uniform in the outer loop comparison so it's not immediately * unrolled. */ for(int v124 = 0; v124 != a; v124++) { diff --git a/tests/spec/glsl-1.10/execution/fs-nested-return-in-loop-nested_in_if.shader_test b/tests/spec/glsl-1.10/execution/fs-nested-return-in-loop-nested_in_if.shader_test index 5486ca9f4..0718650df 100644 --- a/tests/spec/glsl-1.10/execution/fs-nested-return-in-loop-nested_in_if.shader_test +++ b/tests/spec/glsl-1.10/execution/fs-nested-return-in-loop-nested_in_if.shader_test @@ -1,4 +1,4 @@ -# Test return lowering when nested in a loop thats nested in an if. +# Test return lowering when nested in a loop that's nested in an if. # # Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100303 [require] diff --git a/tests/spec/glsl-1.10/execution/fs-texture-select.shader_test b/tests/spec/glsl-1.10/execution/fs-texture-select.shader_test index bedd36586..a0ad4dc2d 100644 --- a/tests/spec/glsl-1.10/execution/fs-texture-select.shader_test +++ b/tests/spec/glsl-1.10/execution/fs-texture-select.shader_test @@ -1,5 +1,5 @@ # Even columns fetch from tex0 (black), while odd columns fetch from tex1 (white). -# The shader inverts the color of even collumns to get make them white, +# The shader inverts the color of even columns to get make them white, # so the final image should be completely white. # # At the moment, radeonsi miscompiles this shader and only fetches from tex0 diff --git a/tests/spec/glsl-1.10/execution/glsl-override-builtin-2.shader_test b/tests/spec/glsl-1.10/execution/glsl-override-builtin-2.shader_test index 2a8001ad0..97a4bbdac 100644 --- a/tests/spec/glsl-1.10/execution/glsl-override-builtin-2.shader_test +++ b/tests/spec/glsl-1.10/execution/glsl-override-builtin-2.shader_test @@ -1,7 +1,7 @@ [require] GLSL >= 1.10 -/* built-in function could be overriden, but should not impact +/* built-in function could be overridden, but should not impact another shader. */ diff --git a/tests/spec/glsl-1.10/execution/variable-indexing/vs-output-array-vec2-index-wr-no-unroll.shader_test b/tests/spec/glsl-1.10/execution/variable-indexing/vs-output-array-vec2-index-wr-no-unroll.shader_test new file mode 100644 index 000000000..c32debb19 --- /dev/null +++ b/tests/spec/glsl-1.10/execution/variable-indexing/vs-output-array-vec2-index-wr-no-unroll.shader_test @@ -0,0 +1,84 @@ +[require] +GLSL >= 1.10 + +[vertex shader] +uniform int index; +varying vec2 m1[4]; +varying vec2 m2[4]; + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + m1[0] = vec2(1.0, 1.1); + m1[1] = vec2(2.0, 2.1); + m1[2] = vec2(3.0, 3.1); + m1[3] = vec2(4.0, 4.1); + m2[0] = vec2(5.0, 5.1); + m2[1] = vec2(6.0, 6.1); + m2[2] = vec2(7.0, 7.1); + m2[3] = vec2(8.0, 8.1); + + if (index >= 4) + m2[index-4] = vec2(0.0, 0.1); + else + m1[index] = vec2(0.0, 0.1); +} + +[fragment shader] +uniform int index; +uniform int start_value; +varying vec2 m1[4]; +varying vec2 m2[4]; + +void main() +{ + bool pass = true; + + for (int i = start_value; i < 4; i++) + pass = pass && m1[i] == (index == i ? vec2(0.0, 0.1) : vec2(1.0, 1.1) + vec2(i)); + + for (int i = start_value; i < 4; i++) + pass = pass && m2[i] == (index == 4+i ? vec2(0.0, 0.1) : vec2(5.0, 5.1) + vec2(i)); + + gl_FragColor = pass ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0); +} + +[test] +clear color 0.5 0.5 0.5 0.5 +clear +ortho + +uniform int start_value 0 + +uniform int index 0 +draw rect 5 5 10 10 +probe rgb 10 10 0.0 1.0 0.0 + +uniform int index 1 +draw rect 30 5 10 10 +probe rgb 35 10 0.0 1.0 0.0 + +uniform int index 2 +draw rect 55 5 10 10 +probe rgb 60 10 0.0 1.0 0.0 + +uniform int index 3 +draw rect 80 5 10 10 +probe rgb 85 10 0.0 1.0 0.0 + +uniform int index 4 +draw rect 105 5 10 10 +probe rgb 110 10 0.0 1.0 0.0 + +uniform int index 5 +draw rect 130 5 10 10 +probe rgb 135 10 0.0 1.0 0.0 + +uniform int index 6 +draw rect 155 5 10 10 +probe rgb 160 10 0.0 1.0 0.0 + +uniform int index 7 +draw rect 180 5 10 10 +probe rgb 185 10 0.0 1.0 0.0 diff --git a/tests/spec/glsl-1.10/execution/vs-loop-complex-no-unroll.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-complex-no-unroll.shader_test new file mode 100644 index 000000000..247579af8 --- /dev/null +++ b/tests/spec/glsl-1.10/execution/vs-loop-complex-no-unroll.shader_test @@ -0,0 +1,68 @@ +# This tests unrolling of a loop with two exit point where the trip count +# of one of the exits is known and the other unknown (loop_count uniform). +# +# Here we test all possible outcomes for the loop and also add some +# unreachable code to make sure it is not accessible after unrolling. +[require] +GLSL >= 1.10 + +[vertex shader] +uniform int loop_count; +uniform int start_value; + +void main() +{ + gl_Position = gl_Vertex; + + vec4 colour = vec4(1.0, 1.0, 1.0, 1.0); + vec4 colour2 = vec4(0.0, 0.0, 0.0, 1.0); + for (int i = start_value; i < loop_count; i++) { + + if (i > 1) { + colour = vec4(1.0, 0.0, 0.0, 1.0); + } + + if (i > 1) { + break; + } + + colour = vec4(0.0, 1.0, 0.0, 1.0); + + /* This should be unreachable */ + if (i >= 2) { + colour2 = vec4(0.0, 1.0, 0.0, 1.0); + } + } + + gl_FrontColor = colour + colour2; +} + +[fragment shader] +void main() +{ + gl_FragColor = gl_Color; +} + +[test] +clear color 0.5 0.5 0.5 0.5 +uniform int start_value 0 + +uniform int loop_count 4 +draw rect -1 -1 2 2 +probe all rgba 1.0 0.0 0.0 1.0 + +uniform int loop_count 3 +draw rect -1 -1 2 2 +probe all rgba 1.0 0.0 0.0 1.0 + +uniform int loop_count 2 +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 + +uniform int loop_count 1 +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 + +uniform int loop_count 0 +draw rect -1 -1 2 2 +probe all rgba 1.0 1.0 1.0 1.0 diff --git a/tests/spec/glsl-1.10/execution/vs-loop-complex-with-else-break.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-complex-with-else-break.shader_test index 43430071b..ca056a388 100644 --- a/tests/spec/glsl-1.10/execution/vs-loop-complex-with-else-break.shader_test +++ b/tests/spec/glsl-1.10/execution/vs-loop-complex-with-else-break.shader_test @@ -1,4 +1,4 @@ -# This tests a bug in the r300 compiler where it was too aggresive +# This tests a bug in the r300 compiler where it was too aggressive # with optimizations (copy propagation) of movs in loops. # # See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6467 diff --git a/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll4.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll4.shader_test index 38fdda4ca..d54f55efc 100644 --- a/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll4.shader_test +++ b/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll4.shader_test @@ -21,7 +21,7 @@ void main() int x = 0; /* Here we add a second && and put the known limit i < 4 in parentheses in - * order to trigger a Mesa bug seen in a Assasins Creed Odyssey shader + * order to trigger a Mesa bug seen in a Assassins Creed Odyssey shader */ while (x < loop_count && (i < 4 && j < loop_count2)) { if (x == 0 && i == 0) diff --git a/tests/spec/glsl-1.10/execution/vs-multiple-shader-fragments-with-global.shader_test b/tests/spec/glsl-1.10/execution/vs-multiple-shader-fragments-with-global.shader_test new file mode 100644 index 000000000..0a2853a54 --- /dev/null +++ b/tests/spec/glsl-1.10/execution/vs-multiple-shader-fragments-with-global.shader_test @@ -0,0 +1,43 @@ +# This test verifies that the compiler properly handles globals used across +# multiple shaders of the same stage. This test exposes a bug in mesa where it +# incorrectly assumed w = y; was the only time y was dereferenced and so +# just set w directly leaving y unassigned. + +[require] +GLSL >= 1.10 + +[vertex shader] +uniform float i; + +float y; +float w; + +void set_y_and_w() +{ + y = i; + w = y; +} + +[vertex shader] +float y; +float w; + +void set_y_and_w(); + +void main() +{ + set_y_and_w(); + gl_Position = gl_Vertex; + gl_FrontColor = vec4(0.0, y, 0.0, w); +} + +[fragment shader] +void main() +{ + gl_FragColor = gl_Color; +} + +[test] +uniform float i 1.0 +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/glsl-1.10/preprocessor/bogus-extension-test.frag b/tests/spec/glsl-1.10/preprocessor/bogus-extension-test.frag index b4fce4573..3cfe245a3 100644 --- a/tests/spec/glsl-1.10/preprocessor/bogus-extension-test.frag +++ b/tests/spec/glsl-1.10/preprocessor/bogus-extension-test.frag @@ -4,7 +4,7 @@ * [end config] */ -// Test using a non-existant function. Should not compile. +// Test using a non-existent function. Should not compile. #extension GL_FOO_bar: require void main() { diff --git a/tests/spec/glsl-1.10/preprocessor/unary-op-minus-define.shader_test b/tests/spec/glsl-1.10/preprocessor/unary-op-minus-define.shader_test new file mode 100644 index 000000000..966e55626 --- /dev/null +++ b/tests/spec/glsl-1.10/preprocessor/unary-op-minus-define.shader_test @@ -0,0 +1,19 @@ +[require] +GLSL >= 1.10 + +[vertex shader passthrough] + +[fragment shader] +#version 110 + +#define VALUE -1.0 +const float x = -VALUE; + +void main() +{ + gl_FragColor = vec4(0.0, x, 0.0, 1.0); +} + +[test] +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-sequence-in-parenthesis.vert b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-sequence-in-parenthesis.vert index 8f3d42f4c..c072f49fa 100644 --- a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-sequence-in-parenthesis.vert +++ b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-sequence-in-parenthesis.vert @@ -3,7 +3,7 @@ * glsl_version: 1.20 * [end config] * - * The body of the GLSL spec is slient on this issue, but the grammar says: + * The body of the GLSL spec is silent on this issue, but the grammar says: * * expression: * assignment_expression diff --git a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-sequence.vert b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-sequence.vert index 9d7e21442..0638084e8 100644 --- a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-sequence.vert +++ b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-sequence.vert @@ -3,7 +3,7 @@ * glsl_version: 1.20 * [end config] * - * The body of the GLSL spec is slient on this issue, but the grammar says: + * The body of the GLSL spec is silent on this issue, but the grammar says: * * expression: * assignment_expression diff --git a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-01.shader_test b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-01.shader_test index 2e7c7620c..1ce194d56 100644 --- a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-01.shader_test +++ b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-01.shader_test @@ -32,4 +32,3 @@ clear color 0.0 0.0 0.0 0.0 clear ortho draw rect 10 10 10 10 -probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-02.shader_test b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-02.shader_test index f9c8202cb..cf0ec01da 100644 --- a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-02.shader_test +++ b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-02.shader_test @@ -32,4 +32,3 @@ clear color 0.0 0.0 0.0 0.0 clear ortho draw rect 10 10 10 10 -probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-03.shader_test b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-03.shader_test index 1d7908464..f8f33235f 100644 --- a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-03.shader_test +++ b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-03.shader_test @@ -34,4 +34,3 @@ clear color 0.0 0.0 0.0 0.0 clear ortho draw rect 10 10 10 10 -probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-04.shader_test b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-04.shader_test index 8e21e7ab8..6f58c6721 100644 --- a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-04.shader_test +++ b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-04.shader_test @@ -34,4 +34,3 @@ clear color 0.0 0.0 0.0 0.0 clear ortho draw rect 10 10 10 10 -probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-05.shader_test b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-05.shader_test index b2ec3011c..bb0998b51 100644 --- a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-05.shader_test +++ b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-05.shader_test @@ -32,4 +32,3 @@ clear color 0.0 0.0 0.0 0.0 clear ortho draw rect 10 10 10 10 -probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-06.shader_test b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-06.shader_test index c540ff18a..944e1156a 100644 --- a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-06.shader_test +++ b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-06.shader_test @@ -32,4 +32,3 @@ clear color 0.0 0.0 0.0 0.0 clear ortho draw rect 10 10 10 10 -probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-07.shader_test b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-07.shader_test index 7bc3a0516..ef1d9b720 100644 --- a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-07.shader_test +++ b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-07.shader_test @@ -34,4 +34,3 @@ clear color 0.0 0.0 0.0 0.0 clear ortho draw rect 10 10 10 10 -probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-08.shader_test b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-08.shader_test index 5fddc1062..c08fb1c75 100644 --- a/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-08.shader_test +++ b/tests/spec/glsl-1.20/execution/array_bounds/glsl-array-bounds-08.shader_test @@ -34,4 +34,3 @@ clear color 0.0 0.0 0.0 0.0 clear ortho draw rect 10 10 10 10 -probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/spec/glsl-1.20/execution/clipping/fixed-clip-enables.shader_test b/tests/spec/glsl-1.20/execution/clipping/fixed-clip-enables.shader_test index 93995a5c1..b9740616a 100644 --- a/tests/spec/glsl-1.20/execution/clipping/fixed-clip-enables.shader_test +++ b/tests/spec/glsl-1.20/execution/clipping/fixed-clip-enables.shader_test @@ -8,7 +8,7 @@ # # To verify that each enable works, the combinations of enables were # chosen such that: -# - Every plane is enabled at least once and disbled at least once. +# - Every plane is enabled at least once and disabled at least once. # - Every plane is enabled and disabled in a different pattern. # # Note: Some implementations have bugs related to improper coordinate diff --git a/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-enables.shader_test b/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-enables.shader_test index b93d16f34..ca645b67b 100644 --- a/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-enables.shader_test +++ b/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-enables.shader_test @@ -5,7 +5,7 @@ # # To verify that each enable works, the combinations of enables were # chosen such that: -# - Every plane is enabled at least once and disbled at least once. +# - Every plane is enabled at least once and disabled at least once. # - Every plane is enabled and disabled in a different pattern. # # Note: Some implementations have bugs related to improper coordinate diff --git a/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test index c7d0e3a54..5ff0626b8 100644 --- a/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test +++ b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test @@ -15,7 +15,7 @@ void main() struct Foo { int value; - /* A second member of a differnt size helps ensures we calculate member + /* A second member of a different size helps ensures we calculate member * offsets correctly. */ ivec2 value2; diff --git a/tests/spec/glsl-1.20/recursion/recursion.c b/tests/spec/glsl-1.20/recursion/recursion.c index 7c3c4dc32..214f565ab 100644 --- a/tests/spec/glsl-1.20/recursion/recursion.c +++ b/tests/spec/glsl-1.20/recursion/recursion.c @@ -31,7 +31,7 @@ * present if the static function call graph of the program contains * cycles." * - * This langauge leaves a lot of questions unanswered. + * This language leaves a lot of questions unanswered. * * - Is the error generated at compile-time or link-time? * diff --git a/tests/spec/glsl-1.30/compiler/interpolation-qualifiers/local-smooth-01.frag b/tests/spec/glsl-1.30/compiler/interpolation-qualifiers/local-smooth-01.frag index 12cf0add7..84a33f397 100644 --- a/tests/spec/glsl-1.30/compiler/interpolation-qualifiers/local-smooth-01.frag +++ b/tests/spec/glsl-1.30/compiler/interpolation-qualifiers/local-smooth-01.frag @@ -3,7 +3,7 @@ // glsl_version: 1.30 // [end config] // -// Attempt to declare a local varaible with 'smooth'. +// Attempt to declare a local variable with 'smooth'. #version 130 diff --git a/tests/spec/glsl-1.30/compiler/storage-qualifiers/function-param-centroid-in-01.frag b/tests/spec/glsl-1.30/compiler/storage-qualifiers/function-param-centroid-in-01.frag index 7bbab7a68..236d8be25 100644 --- a/tests/spec/glsl-1.30/compiler/storage-qualifiers/function-param-centroid-in-01.frag +++ b/tests/spec/glsl-1.30/compiler/storage-qualifiers/function-param-centroid-in-01.frag @@ -3,7 +3,7 @@ // glsl_version: 1.30 // [end config] // -// Check that 'centroid in' cannot be used a parameter qualifer. +// Check that 'centroid in' cannot be used a parameter qualifier. #version 130 diff --git a/tests/spec/glsl-1.30/compiler/storage-qualifiers/local-centroid-in-01.frag b/tests/spec/glsl-1.30/compiler/storage-qualifiers/local-centroid-in-01.frag index b860cdd47..7bb2c3a5b 100644 --- a/tests/spec/glsl-1.30/compiler/storage-qualifiers/local-centroid-in-01.frag +++ b/tests/spec/glsl-1.30/compiler/storage-qualifiers/local-centroid-in-01.frag @@ -3,7 +3,7 @@ // glsl_version: 1.30 // [end config] // -// Check that 'centroid in' cannot be used a local variable qualifer. +// Check that 'centroid in' cannot be used a local variable qualifier. #version 130 diff --git a/tests/spec/glsl-1.30/compiler/storage-qualifiers/local-in-01.frag b/tests/spec/glsl-1.30/compiler/storage-qualifiers/local-in-01.frag index 74c82ef4a..24a0a8679 100644 --- a/tests/spec/glsl-1.30/compiler/storage-qualifiers/local-in-01.frag +++ b/tests/spec/glsl-1.30/compiler/storage-qualifiers/local-in-01.frag @@ -3,7 +3,7 @@ // glsl_version: 1.30 // [end config] // -// Declare a local varaible with 'in'. +// Declare a local variable with 'in'. // // From section 4.3.4 of the GLSL 1.30 spec: // Input variables must be declared at global scope. diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-all-planes-enabled.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-all-planes-enabled.shader_test index 37a8216f8..3a9abcc1f 100644 --- a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-all-planes-enabled.shader_test +++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-all-planes-enabled.shader_test @@ -16,7 +16,7 @@ void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - // Compute 2D cordinates relative to a center point of (0.5, + // Compute 2D coordinates relative to a center point of (0.5, // 0.5). vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5); diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-bulk-assign.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-bulk-assign.shader_test index 7c921d5bc..542bf6dad 100644 --- a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-bulk-assign.shader_test +++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-bulk-assign.shader_test @@ -28,7 +28,7 @@ void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - // Compute 2D cordinates relative to a center point of (0.5, + // Compute 2D coordinates relative to a center point of (0.5, // 0.5). vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5); diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-enables.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-enables.shader_test index 2cb0105b1..c6e63e8af 100644 --- a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-enables.shader_test +++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-enables.shader_test @@ -11,7 +11,7 @@ # # To verify that each enable works, the combinations of enables were # chosen such that: -# - Every plane is enabled at least once and disbled at least once. +# - Every plane is enabled at least once and disabled at least once. # - Every plane is enabled and disabled in a different pattern. [require] diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-in-param.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-in-param.shader_test index bbafc296a..561433f01 100644 --- a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-in-param.shader_test +++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-in-param.shader_test @@ -37,7 +37,7 @@ void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - // Compute 2D cordinates relative to a center point of (0.5, + // Compute 2D coordinates relative to a center point of (0.5, // 0.5). vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5); diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-inout-param.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-inout-param.shader_test index 075069db1..9be843fa4 100644 --- a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-inout-param.shader_test +++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-inout-param.shader_test @@ -35,7 +35,7 @@ void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - // Compute 2D cordinates relative to a center point of (0.5, + // Compute 2D coordinates relative to a center point of (0.5, // 0.5). vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5); diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-out-param.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-out-param.shader_test index fcc4737f0..07e623cad 100644 --- a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-out-param.shader_test +++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-out-param.shader_test @@ -35,7 +35,7 @@ void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - // Compute 2D cordinates relative to a center point of (0.5, + // Compute 2D coordinates relative to a center point of (0.5, // 0.5). vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5); diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-primitives.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-primitives.shader_test index 8191b8d9d..46d647200 100644 --- a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-primitives.shader_test +++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-primitives.shader_test @@ -44,7 +44,7 @@ uniform vec2 u_offset 0.5 0.5 draw arrays GL_POINTS 0 1 probe rect rgba ( 0, 0, 20, 20) (0, 0, 0, 0) -uniform vec2 u_offset 20 0.5 +uniform vec2 u_offset 20.5 0.5 draw arrays GL_LINES 0 2 probe rect rgba (20, 0, 20, 20) (0, 0, 0, 0) @@ -59,7 +59,7 @@ uniform vec2 u_offset 0.5 20.5 draw arrays GL_POINTS 0 1 probe rect rgba ( 0, 20, 1, 1) (1, 0, 0, 1) -uniform vec2 u_offset 20 20.5 +uniform vec2 u_offset 20.5 20.5 draw arrays GL_LINES 0 2 probe rect rgba (20, 20, 10, 1) (1, 0, 0, 1) diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-retval.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-retval.shader_test index 3dc8dc0c6..8aaf750ca 100644 --- a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-retval.shader_test +++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-retval.shader_test @@ -55,7 +55,7 @@ void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - // Compute 2D cordinates relative to a center point of (0.5, + // Compute 2D coordinates relative to a center point of (0.5, // 0.5). vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5); diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-uint-index.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-uint-index.shader_test index 93f0fc2cc..b3da1f85f 100644 --- a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-uint-index.shader_test +++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-uint-index.shader_test @@ -20,7 +20,7 @@ void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - // Compute 2D cordinates relative to a center point of (0.5, + // Compute 2D coordinates relative to a center point of (0.5, // 0.5). vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5); diff --git a/tests/spec/glsl-1.30/execution/interpolation/fs-int-interpolation.shader_test b/tests/spec/glsl-1.30/execution/interpolation/fs-int-interpolation.shader_test index 076346495..290d1f73d 100644 --- a/tests/spec/glsl-1.30/execution/interpolation/fs-int-interpolation.shader_test +++ b/tests/spec/glsl-1.30/execution/interpolation/fs-int-interpolation.shader_test @@ -16,14 +16,15 @@ GLSL >= 1.30 [vertex shader] #version 130 uniform int test_value; -/* To prevent linker optimize out test_value. */ -uniform int dummy; flat out int flat_int; void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - flat_int = test_value + dummy; + + // introduce a fake dependency on inputs to prevent the compiler from + // moving the uniform to the next shader + flat_int = gl_Position.x < -10.0 ? 0 : test_value; } [fragment shader] @@ -38,7 +39,6 @@ void main() } [test] -uniform int dummy 0 uniform int test_value 0 draw rect -1 -1 2 2 probe rgba 0 0 0.0 1.0 0.0 1.0 diff --git a/tests/spec/glsl-1.30/execution/interpolation/fs-uint-interpolation.shader_test b/tests/spec/glsl-1.30/execution/interpolation/fs-uint-interpolation.shader_test index b1f605026..da34d3100 100644 --- a/tests/spec/glsl-1.30/execution/interpolation/fs-uint-interpolation.shader_test +++ b/tests/spec/glsl-1.30/execution/interpolation/fs-uint-interpolation.shader_test @@ -16,14 +16,15 @@ GLSL >= 1.30 [vertex shader] #version 130 uniform uint test_value; -/* To prevent linker optimize out test_value. */ -uniform uint dummy; flat out uint flat_uint; void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - flat_uint = test_value + dummy; + + // introduce a fake dependency on inputs to prevent the compiler from + // moving the uniform to the next shader + flat_uint = gl_Position.x < -10.0 ? 0u : test_value; } [fragment shader] @@ -38,7 +39,6 @@ void main() } [test] -uniform uint dummy 0 uniform uint test_value 0 draw rect -1 -1 2 2 probe rgba 0 0 0.0 1.0 0.0 1.0 diff --git a/tests/spec/glsl-1.30/execution/range_analysis_fsat_of_nan.shader_test b/tests/spec/glsl-1.30/execution/range_analysis_fsat_of_nan.shader_test index 56fbcb645..14de330ff 100644 --- a/tests/spec/glsl-1.30/execution/range_analysis_fsat_of_nan.shader_test +++ b/tests/spec/glsl-1.30/execution/range_analysis_fsat_of_nan.shader_test @@ -13,7 +13,7 @@ out vec4 piglit_fragcolor; void main() { /* Create a value that, if it were a number, would have to be > 0. Due to - * possilbe flush-to-zero semantics, pretty much anything involving + * possible flush-to-zero semantics, pretty much anything involving * multiplication or division can be zero. However, gt_zero + ge_zero is * gt_zero. */ diff --git a/tests/spec/glsl-1.30/execution/varying-packing-mixed-types.shader_test b/tests/spec/glsl-1.30/execution/varying-packing-mixed-types.shader_test index a002fb491..f37e21bda 100644 --- a/tests/spec/glsl-1.30/execution/varying-packing-mixed-types.shader_test +++ b/tests/spec/glsl-1.30/execution/varying-packing-mixed-types.shader_test @@ -24,10 +24,13 @@ flat out int ia[gl_MaxVaryingComponents - 2]; void main() { gl_Position = gl_Vertex; - f = f_ref + f_dummy; - u = u_ref + u_dummy; + + // introduce a fake dependency on inputs to prevent the compiler from + // moving ref to the next shader + f = gl_Vertex.x < -10.0 ? 0.0 : f_ref; + u = gl_Vertex.x < -10.0 ? 0u : u_ref; for (int i = 0; i < gl_MaxVaryingComponents - 2; i++) - ia[i] = i_ref + i; + ia[i] = gl_Vertex.x < -10.0 ? 0 : i_ref + i; } [fragment shader] @@ -59,7 +62,5 @@ void main() uniform int i_ref -1000 uniform uint u_ref 0xfedcba98 uniform float f_ref 3.1415926 -uniform float f_dummy 0 -uniform uint u_dummy 0 draw rect -1 -1 2 2 probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/glsl-1.40/uniform_buffer/two-stages.shader_test b/tests/spec/glsl-1.40/uniform_buffer/two-stages.shader_test new file mode 100644 index 000000000..d0cd41838 --- /dev/null +++ b/tests/spec/glsl-1.40/uniform_buffer/two-stages.shader_test @@ -0,0 +1,79 @@ +# Simple UBO test with two stages using the same UBO. + +[require] +GL >= 3.1 +GLSL >= 1.40 +GL_ARB_program_interface_query + +[vertex shader] + +#version 450 + +layout (location = 0) in vec4 piglit_vertex; +layout (location = 1) out vec4 vertexColor; + + +layout (std140, binding = 5) uniform ComponentsBlock + { + vec4 c1; + vec2 c2; + } components; + +void main() +{ + vec4 fail_color = vec4(1.0, 0.0, 0.0, 1.0); + vertexColor = vec4(0.0, 1.0, 0.0, 1.0); + + if (components.c1 != vec4(4575.7996643, 14191.6120546, -30199.3084764, -31303.4210269)) + vertexColor = fail_color; + + if (components.c2 != vec2(-10231.1810483, 11729.6478218)) + vertexColor = fail_color; + + gl_Position = piglit_vertex; +} + +[fragment shader] + +#version 450 + +layout (location = 0) out vec4 color; +layout (location = 1) in vec4 vertexColor; +layout (std140, binding = 5) uniform ComponentsBlock + { + vec4 c1; + vec2 c2; + } components; + +void main() +{ + vec4 fail_color = vec4(1.0, 0.0, 0.0, 1.0); + color = vec4(0.0, 1.0, 0.0, 1.0); + + if (components.c1 != vec4(4575.7996643, 14191.6120546, -30199.3084764, -31303.4210269)) + color = fail_color; + + if (components.c2 != vec2(-10231.1810483, 11729.6478218)) + color = fail_color; + + if (vertexColor != vec4(0.0, 1.0, 0.0, 1.0)) + color = fail_color; +} + +[test] +clear color 1.0 0.0 0.0 0.0 +clear + +block binding 5 +block offset 0 +uniform vec4 ComponentsBlock.c1 4575.7996643 14191.6120546 -30199.3084764 -31303.4210269 +block offset 16 +uniform vec2 ComponentsBlock.c2 -10231.1810483 11729.6478218 + +verify program_interface_query GL_UNIFORM_BLOCK ComponentsBlock GL_NUM_ACTIVE_VARIABLES 2 +verify program_interface_query GL_UNIFORM_BLOCK ComponentsBlock GL_BUFFER_DATA_SIZE 32 + +verify program_query GL_ACTIVE_UNIFORMS 2 + +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/glsl-1.50/execution/compatibility/clipping/gs-clip-vertex-enables.shader_test b/tests/spec/glsl-1.50/execution/compatibility/clipping/gs-clip-vertex-enables.shader_test index d5ef9cd98..ba7e63712 100644 --- a/tests/spec/glsl-1.50/execution/compatibility/clipping/gs-clip-vertex-enables.shader_test +++ b/tests/spec/glsl-1.50/execution/compatibility/clipping/gs-clip-vertex-enables.shader_test @@ -5,7 +5,7 @@ # # To verify that each enable works, the combinations of enables were # chosen such that: -# - Every plane is enabled at least once and disbled at least once. +# - Every plane is enabled at least once and disabled at least once. # - Every plane is enabled and disabled in a different pattern. # # Note: Some implementations have bugs related to improper coordinate diff --git a/tests/spec/glsl-1.50/execution/compatibility/clipping/vs-gs-clip-vertex-enables.shader_test b/tests/spec/glsl-1.50/execution/compatibility/clipping/vs-gs-clip-vertex-enables.shader_test index 4231e8b26..c427b4461 100644 --- a/tests/spec/glsl-1.50/execution/compatibility/clipping/vs-gs-clip-vertex-enables.shader_test +++ b/tests/spec/glsl-1.50/execution/compatibility/clipping/vs-gs-clip-vertex-enables.shader_test @@ -5,7 +5,7 @@ # # To verify that each enable works, the combinations of enables were # chosen such that: -# - Every plane is enabled at least once and disbled at least once. +# - Every plane is enabled at least once and disabled at least once. # - Every plane is enabled and disabled in a different pattern. # # Note: Some implementations have bugs related to improper coordinate diff --git a/tests/spec/glsl-1.50/execution/compatibility/vs-gs-texcoord-array.shader_test b/tests/spec/glsl-1.50/execution/compatibility/vs-gs-texcoord-array.shader_test index fae6cff63..0ff1fe2a9 100644 --- a/tests/spec/glsl-1.50/execution/compatibility/vs-gs-texcoord-array.shader_test +++ b/tests/spec/glsl-1.50/execution/compatibility/vs-gs-texcoord-array.shader_test @@ -14,9 +14,11 @@ out gl_PerVertex { void main() { - for (int i = 0; i < n; i++) { + int i; + for (i = 0; i < n; i++) gl_TexCoord[i] = vec4(0.5, 0.5, 0.5, 0.5) * float(i); - } + for (; i < gl_TexCoord.length(); i++) + gl_TexCoord[i] = vec4(1.0, 1.0, 1.0, 1.0) * float(i); gl_Position = gl_Vertex; } diff --git a/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-conflicting-case-2.shader_test b/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-conflicting-case-2.shader_test index 3350e0fb4..3b3f9e16f 100644 --- a/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-conflicting-case-2.shader_test +++ b/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-conflicting-case-2.shader_test @@ -17,7 +17,7 @@ * the same set of qualifiers." * * Tests the case when all the fragment shaders which use gl_FragCoord, - * redeclare it with conflicting layout qualifiers. It varifies that + * redeclare it with conflicting layout qualifiers. It verifies that * link error is not effected by the presence of a fragment shader which * doesn't use gl_FragCoord. */ diff --git a/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-conflicting-case-3.shader_test b/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-conflicting-case-3.shader_test index a21f918d5..f7506845d 100644 --- a/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-conflicting-case-3.shader_test +++ b/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-conflicting-case-3.shader_test @@ -17,7 +17,7 @@ * the same set of qualifiers." * * Tests the case when all the fragment shaders which use gl_FragCoord, - * redeclare it with conflicting layout qualifiers. It varifies that + * redeclare it with conflicting layout qualifiers. It verifies that * link error is generated even if gl_FragCoord is redeclared by the * last fragment shader attached. */ diff --git a/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-matching-case-2.shader_test b/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-matching-case-2.shader_test index f78ec3f15..250c025dc 100644 --- a/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-matching-case-2.shader_test +++ b/tests/spec/glsl-1.50/execution/fragcoord-layout-qualifiers-matching-case-2.shader_test @@ -18,7 +18,7 @@ * * * Tests the case when all the fragment shaders which use gl_FragCoord, - * redeclare it with matching layout qualifiers. The specfic order of + * redeclare it with matching layout qualifiers. The specific order of * attached fragment shaders is important here. */ [require] diff --git a/tests/spec/glsl-1.50/execution/geometry/gs-max-output.cpp b/tests/spec/glsl-1.50/execution/geometry/gs-max-output.cpp index 6d71b9fe7..96585946e 100644 --- a/tests/spec/glsl-1.50/execution/geometry/gs-max-output.cpp +++ b/tests/spec/glsl-1.50/execution/geometry/gs-max-output.cpp @@ -59,7 +59,7 @@ struct testcase { unsigned num_instances; /* draw instances */ unsigned num_points; /* draw size / count */ unsigned num_invocations; /* GS invocations / instances */ - unsigned num_outputs; /* # vertex ouput per GS invocation */ + unsigned num_outputs; /* # vertex output per GS invocation */ unsigned num_components; /* # extra components per GS output vertex */ diff --git a/tests/spec/glsl-1.50/execution/geometry/tri-strip-ordering-with-prim-restart.c b/tests/spec/glsl-1.50/execution/geometry/tri-strip-ordering-with-prim-restart.c index 61bd73e81..a59f17b39 100644 --- a/tests/spec/glsl-1.50/execution/geometry/tri-strip-ordering-with-prim-restart.c +++ b/tests/spec/glsl-1.50/execution/geometry/tri-strip-ordering-with-prim-restart.c @@ -39,7 +39,7 @@ * restart to split it into a pair of 3-triangle strips (this ensures * that triangles in the first strip have the same parity in relation * to the strip as they have when measured by gl_PrimitiveIDIn; - * triangles in the second strip hav opposite parity in relation to + * triangles in the second strip have opposite parity in relation to * the strip from what they have when measured by gl_PrimitiveIDIn). * The vertex IDs of all vertices are collected using transform * feedback, and checked in C to make sure it matches the expected diff --git a/tests/spec/glsl-1.50/execution/interface-block-copy-vs-gs-fs.shader_test b/tests/spec/glsl-1.50/execution/interface-block-copy-vs-gs-fs.shader_test new file mode 100644 index 000000000..1ce537ece --- /dev/null +++ b/tests/spec/glsl-1.50/execution/interface-block-copy-vs-gs-fs.shader_test @@ -0,0 +1,77 @@ +# Test the direct copy of an entire named block + +[require] +GLSL >= 1.50 + +[vertex shader] +#version 150 + +out Data +{ + vec3 a; + float b; +} outData; + +out vec4 vertex_to_gs; + +in vec4 piglit_vertex; + +void main() +{ + outData.a = vec3(0.0, 0.75, 1.0); + outData.b = 0.5; + + vertex_to_gs = piglit_vertex; +} + +[geometry shader] +#version 150 + +layout(triangles) in; +layout(triangle_strip, max_vertices = 3) out; + +in vec4 vertex_to_gs[3]; + +in Data +{ + vec3 a; + float b; +} inData[]; + +out Data +{ + vec3 a; + float b; +} outData; + +void main() +{ + for (int i = 0; i < 3; i++) { + gl_Position = vertex_to_gs[i]; + outData = inData[i]; + EmitVertex(); + } +} + +[fragment shader] +#version 150 + +out vec4 color; + +in Data +{ + vec3 a; + float b; +} inData; + +void main() +{ + color = vec4(inData.b, inData.a); +} + +[test] +clear color 0.1 0.1 0.1 0.1 +clear + +draw rect -1 -1 2 2 +probe all rgb 0.5 0 0.75 diff --git a/tests/spec/glsl-1.50/execution/primitive-id-no-gs-line.shader_test b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-line.shader_test index b98880d7d..aa5b07f65 100644 --- a/tests/spec/glsl-1.50/execution/primitive-id-no-gs-line.shader_test +++ b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-line.shader_test @@ -61,7 +61,7 @@ piglit_vertex/float/2 # shader will draw a different color for failing pixels, and "probe all" will # detect the problem. # -# This won't catch cases where the test doesn't draw anything. Hopefullly +# This won't catch cases where the test doesn't draw anything. Hopefully # problems of that nature will have already been caught by other tests. clear color 0.0 1.0 0.0 1.0 diff --git a/tests/spec/glsl-1.50/execution/primitive-id-no-gs-point.shader_test b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-point.shader_test index d5ce5de25..5c99d1f7b 100644 --- a/tests/spec/glsl-1.50/execution/primitive-id-no-gs-point.shader_test +++ b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-point.shader_test @@ -61,7 +61,7 @@ piglit_vertex/float/2 # shader will draw a different color for failing pixels, and "probe all" will # detect the problem. # -# This won't catch cases where the test doesn't draw anything. Hopefullly +# This won't catch cases where the test doesn't draw anything. Hopefully # problems of that nature will have already been caught by other tests. clear color 0.0 1.0 0.0 1.0 diff --git a/tests/spec/glsl-1.50/execution/varying-struct-basic-gs-fs.shader_test b/tests/spec/glsl-1.50/execution/varying-struct-basic-gs-fs.shader_test index 5529ff381..358ce9bde 100644 --- a/tests/spec/glsl-1.50/execution/varying-struct-basic-gs-fs.shader_test +++ b/tests/spec/glsl-1.50/execution/varying-struct-basic-gs-fs.shader_test @@ -57,24 +57,28 @@ out Foo foo; void main() { + // introduce a fake dependency on inputs to prevent the compiler from + // moving ref to the next shader + float refx = pos[0].x < -10.0 ? 0.0 : ref; + for(int i = 0; i < 3; i++) { gl_Position = pos[i]; - foo.a = mat4(ref, ref + 1.0, ref + 2.0, ref + 3.0, - ref + 4.0, ref + 5.0, ref + 6.0, ref + 7.0, - ref + 8.0, ref + 9.0, ref + 10.0, ref + 11.0, - ref + 12.0, ref + 13.0, ref + 14.0, ref + 15.0); - - foo.b = mat3(ref + 16.0, ref + 17.0, ref + 18.0, - ref + 19.0, ref + 20.0, ref + 21.0, - ref + 22.0, ref + 23.0, ref + 24.0); - - foo.c = mat2(ref + 25.0, ref + 26.0, - ref + 27.0, ref + 28.0); - - foo.d = vec4(ref + 29.0, ref + 30.0, ref + 31.0, ref + 32.0); - foo.e = vec3(ref + 33.0, ref + 34.0, ref + 35.0); - foo.f = vec2(ref + 36.0, ref + 37.0); - foo.g = ref + 38.0; + foo.a = mat4(refx, refx + 1.0, refx + 2.0, refx + 3.0, + refx + 4.0, refx + 5.0, refx + 6.0, refx + 7.0, + refx + 8.0, refx + 9.0, refx + 10.0, refx + 11.0, + refx + 12.0, refx + 13.0, refx + 14.0, refx + 15.0); + + foo.b = mat3(refx + 16.0, refx + 17.0, refx + 18.0, + refx + 19.0, refx + 20.0, refx + 21.0, + refx + 22.0, refx + 23.0, refx + 24.0); + + foo.c = mat2(refx + 25.0, refx + 26.0, + refx + 27.0, refx + 28.0); + + foo.d = vec4(refx + 29.0, refx + 30.0, refx + 31.0, refx + 32.0); + foo.e = vec3(refx + 33.0, refx + 34.0, refx + 35.0); + foo.f = vec2(refx + 36.0, refx + 37.0); + foo.g = refx + 38.0; EmitVertex(); } } diff --git a/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-fs.shader_test b/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-fs.shader_test index a80595417..fd470917b 100644 --- a/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-fs.shader_test +++ b/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-fs.shader_test @@ -41,22 +41,26 @@ void main() { gl_Position = piglit_vertex; - foo.a = mat4(ref, ref + 1.0, ref + 2.0, ref + 3.0, - ref + 4.0, ref + 5.0, ref + 6.0, ref + 7.0, - ref + 8.0, ref + 9.0, ref + 10.0, ref + 11.0, - ref + 12.0, ref + 13.0, ref + 14.0, ref + 15.0); - - foo.b = mat3(ref + 16.0, ref + 17.0, ref + 18.0, - ref + 19.0, ref + 20.0, ref + 21.0, - ref + 22.0, ref + 23.0, ref + 24.0); - - foo.c = mat2(ref + 25.0, ref + 26.0, - ref + 27.0, ref + 28.0); - - foo.d = vec4(ref + 29.0, ref + 30.0, ref + 31.0, ref + 32.0); - foo.e = vec3(ref + 33.0, ref + 34.0, ref + 35.0); - foo.f = vec2(ref + 36.0, ref + 37.0); - foo.g = ref + 38.0; + // introduce a fake dependency on inputs to prevent the compiler from + // moving ref to the next shader + float refx = piglit_vertex.x < -10.0 ? 0.0 : ref; + + foo.a = mat4(refx, refx + 1.0, refx + 2.0, refx + 3.0, + refx + 4.0, refx + 5.0, refx + 6.0, refx + 7.0, + refx + 8.0, refx + 9.0, refx + 10.0, refx + 11.0, + refx + 12.0, refx + 13.0, refx + 14.0, refx + 15.0); + + foo.b = mat3(refx + 16.0, refx + 17.0, refx + 18.0, + refx + 19.0, refx + 20.0, refx + 21.0, + refx + 22.0, refx + 23.0, refx + 24.0); + + foo.c = mat2(refx + 25.0, refx + 26.0, + refx + 27.0, refx + 28.0); + + foo.d = vec4(refx + 29.0, refx + 30.0, refx + 31.0, refx + 32.0); + foo.e = vec3(refx + 33.0, refx + 34.0, refx + 35.0); + foo.f = vec2(refx + 36.0, refx + 37.0); + foo.g = refx + 38.0; } [fragment shader] diff --git a/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-gs.shader_test b/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-gs.shader_test index 0a5b9b211..4dbeefcfd 100644 --- a/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-gs.shader_test +++ b/tests/spec/glsl-1.50/execution/varying-struct-basic-vs-gs.shader_test @@ -44,22 +44,27 @@ void main() { gl_Position = vertex; pos = vertex; - foo.a = mat4(ref, ref + 1.0, ref + 2.0, ref + 3.0, - ref + 4.0, ref + 5.0, ref + 6.0, ref + 7.0, - ref + 8.0, ref + 9.0, ref + 10.0, ref + 11.0, - ref + 12.0, ref + 13.0, ref + 14.0, ref + 15.0); - - foo.b = mat3(ref + 16.0, ref + 17.0, ref + 18.0, - ref + 19.0, ref + 20.0, ref + 21.0, - ref + 22.0, ref + 23.0, ref + 24.0); - - foo.c = mat2(ref + 25.0, ref + 26.0, - ref + 27.0, ref + 28.0); - - foo.d = vec4(ref + 29.0, ref + 30.0, ref + 31.0, ref + 32.0); - foo.e = vec3(ref + 33.0, ref + 34.0, ref + 35.0); - foo.f = vec2(ref + 36.0, ref + 37.0); - foo.g = ref + 38.0; + + // introduce a fake dependency on inputs to prevent the compiler from + // moving ref to the next shader + float refx = vertex.x < -10.0 ? 0.0 : ref; + + foo.a = mat4(refx, refx + 1.0, refx + 2.0, refx + 3.0, + refx + 4.0, refx + 5.0, refx + 6.0, refx + 7.0, + refx + 8.0, refx + 9.0, refx + 10.0, refx + 11.0, + refx + 12.0, refx + 13.0, refx + 14.0, refx + 15.0); + + foo.b = mat3(refx + 16.0, refx + 17.0, refx + 18.0, + refx + 19.0, refx + 20.0, refx + 21.0, + refx + 22.0, refx + 23.0, refx + 24.0); + + foo.c = mat2(refx + 25.0, refx + 26.0, + refx + 27.0, refx + 28.0); + + foo.d = vec4(refx + 29.0, refx + 30.0, refx + 31.0, refx + 32.0); + foo.e = vec3(refx + 33.0, refx + 34.0, refx + 35.0); + foo.f = vec2(refx + 36.0, refx + 37.0); + foo.g = refx + 38.0; } [geometry shader] diff --git a/tests/spec/glsl-1.50/execution/vs-input-arrays.c b/tests/spec/glsl-1.50/execution/vs-input-arrays.c index d94d0c5f2..07a3b3ab1 100644 --- a/tests/spec/glsl-1.50/execution/vs-input-arrays.c +++ b/tests/spec/glsl-1.50/execution/vs-input-arrays.c @@ -40,7 +40,7 @@ * gl_VertexID). VS emits a float, 0 for pass, 1 for fail. This is done because * bool cannot be sent as a varying, and using flat shading for sending an int * results in additional vertex info being discarded. FS draws GREEN if it - * received the expeced 0 from the VS, RED if !0. + * received the expected 0 from the VS, RED if !0. */ #include "piglit-util-gl.h" diff --git a/tests/spec/glsl-1.50/execution/vs-named-block-no-modify.c b/tests/spec/glsl-1.50/execution/vs-named-block-no-modify.c index ed3d21372..38737a251 100644 --- a/tests/spec/glsl-1.50/execution/vs-named-block-no-modify.c +++ b/tests/spec/glsl-1.50/execution/vs-named-block-no-modify.c @@ -25,7 +25,7 @@ /** * \file named-block-no-modify.c * - * Test that uniform variables containted within a named uniform block cannot be + * Test that uniform variables contained within a named uniform block cannot be * accessed by the glUniform* commands. * * Section 2.11.4 (Uniform Variables) of the GL 3.2 spec says: diff --git a/tests/spec/glsl-es-1.00/execution/glsl-no-vertex-attribs.shader_test b/tests/spec/glsl-es-1.00/execution/glsl-no-vertex-attribs.shader_test index 36a6b4c2a..ddcc48a3b 100644 --- a/tests/spec/glsl-es-1.00/execution/glsl-no-vertex-attribs.shader_test +++ b/tests/spec/glsl-es-1.00/execution/glsl-no-vertex-attribs.shader_test @@ -1,5 +1,5 @@ # -# Tests that we can succesfully render a point with OpenGL ES 2.0 +# Tests that we can successfully render a point with OpenGL ES 2.0 # without having any vertex attributes enabled. # [require] diff --git a/tests/spec/glsl-es-1.00/linker/fface-invariant.c b/tests/spec/glsl-es-1.00/linker/fface-invariant.c index 35ce51549..3759bcd3b 100644 --- a/tests/spec/glsl-es-1.00/linker/fface-invariant.c +++ b/tests/spec/glsl-es-1.00/linker/fface-invariant.c @@ -60,16 +60,19 @@ piglit_init(int argc, char **argv) vs_shader = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source); fs_shader = piglit_compile_shader_text_nothrow(GL_FRAGMENT_SHADER, - fs_source, true); + fs_source, false); /* A compile error is allowed. */ if (!fs_shader) piglit_report_result(PIGLIT_PASS); - prog = piglit_link_simple_program(vs_shader, fs_shader); + prog = glCreateProgram(); + glAttachShader(prog, vs_shader); + glAttachShader(prog, fs_shader); + glLinkProgram(prog); - /* A link error is allowed. */ - if (!prog) + /* A link error is allowed, and must be present if a compile error wasn't thrown. */ + if (!piglit_link_check_status_quiet(prog)) piglit_report_result(PIGLIT_PASS); piglit_report_result(PIGLIT_FAIL); diff --git a/tests/spec/glsl-es-3.00/execution/varying-struct-basic.shader_test b/tests/spec/glsl-es-3.00/execution/varying-struct-basic.shader_test index 00f1e05eb..b96915c12 100644 --- a/tests/spec/glsl-es-3.00/execution/varying-struct-basic.shader_test +++ b/tests/spec/glsl-es-3.00/execution/varying-struct-basic.shader_test @@ -41,22 +41,26 @@ void main() { gl_Position = vertex; - foo.a = mat4(ref, ref + 1.0, ref + 2.0, ref + 3.0, - ref + 4.0, ref + 5.0, ref + 6.0, ref + 7.0, - ref + 8.0, ref + 9.0, ref + 10.0, ref + 11.0, - ref + 12.0, ref + 13.0, ref + 14.0, ref + 15.0); - - foo.b = mat3(ref + 16.0, ref + 17.0, ref + 18.0, - ref + 19.0, ref + 20.0, ref + 21.0, - ref + 22.0, ref + 23.0, ref + 24.0); - - foo.c = mat2(ref + 25.0, ref + 26.0, - ref + 27.0, ref + 28.0); - - foo.d = vec4(ref + 29.0, ref + 30.0, ref + 31.0, ref + 32.0); - foo.e = vec3(ref + 33.0, ref + 34.0, ref + 35.0); - foo.f = vec2(ref + 36.0, ref + 37.0); - foo.g = ref + 38.0; + // introduce a fake dependency on inputs to prevent the compiler from + // moving ref to the next shader + float refx = vertex.x < -10.0 ? 0.0 : ref; + + foo.a = mat4(refx, refx + 1.0, refx + 2.0, refx + 3.0, + refx + 4.0, refx + 5.0, refx + 6.0, refx + 7.0, + refx + 8.0, refx + 9.0, refx + 10.0, refx + 11.0, + refx + 12.0, refx + 13.0, refx + 14.0, refx + 15.0); + + foo.b = mat3(refx + 16.0, refx + 17.0, refx + 18.0, + refx + 19.0, refx + 20.0, refx + 21.0, + refx + 22.0, refx + 23.0, refx + 24.0); + + foo.c = mat2(refx + 25.0, refx + 26.0, + refx + 27.0, refx + 28.0); + + foo.d = vec4(refx + 29.0, refx + 30.0, refx + 31.0, refx + 32.0); + foo.e = vec3(refx + 33.0, refx + 34.0, refx + 35.0); + foo.f = vec2(refx + 36.0, refx + 37.0); + foo.g = refx + 38.0; } [fragment shader] diff --git a/tests/spec/glx_arb_create_context/invalid-attribute.c b/tests/spec/glx_arb_create_context/invalid-attribute.c index 4e1884c49..27e800402 100644 --- a/tests/spec/glx_arb_create_context/invalid-attribute.c +++ b/tests/spec/glx_arb_create_context/invalid-attribute.c @@ -43,7 +43,7 @@ static bool try_attribute(int attribute) if (ctx != NULL) { fprintf(stderr, - "Created OpenGL context with invalud attribute " + "Created OpenGL context with invalid attribute " "0x%08x, but this should have failed.\n", attribute); glXDestroyContext(dpy, ctx); diff --git a/tests/spec/glx_arb_create_context/invalid-gl-version.c b/tests/spec/glx_arb_create_context/invalid-gl-version.c index 12c253b2c..565fc9bef 100644 --- a/tests/spec/glx_arb_create_context/invalid-gl-version.c +++ b/tests/spec/glx_arb_create_context/invalid-gl-version.c @@ -101,7 +101,7 @@ int main(int argc, char **argv) /* Since the writing of the GLX_ARB_create_context_spec, versions 3.3, * 4.0, 4.1, and 4.2 have been released. There is no expectation that - * 3.4 will ever exist becuase it would have to include functionality + * 3.4 will ever exist because it would have to include functionality * not in 4.0, and that would be weird. */ pass = try_version(3, 4) && pass; diff --git a/tests/spec/glx_arb_create_context/invalid-reset-strategy.c b/tests/spec/glx_arb_create_context/invalid-reset-strategy.c index eed0a8d7f..0a4df9421 100644 --- a/tests/spec/glx_arb_create_context/invalid-reset-strategy.c +++ b/tests/spec/glx_arb_create_context/invalid-reset-strategy.c @@ -39,7 +39,7 @@ static bool try_reset_strategy(int reset_strategy) if (ctx != NULL) { fprintf(stderr, "Created OpenGL context with invalid reset " - "notifiction strategy\n" + "notification strategy\n" "0x%08x, but this should have failed.\n", reset_strategy); glXDestroyContext(dpy, ctx); diff --git a/tests/spec/glx_ext_import_context/common.c b/tests/spec/glx_ext_import_context/common.c index 8b0be4fcc..35fe95551 100644 --- a/tests/spec/glx_ext_import_context/common.c +++ b/tests/spec/glx_ext_import_context/common.c @@ -98,8 +98,7 @@ void GLX_EXT_import_context_setup(void) if (!piglit_is_extension_in_string(client_extensions, "GLX_EXT_import_context")) { - fprintf(stderr, - "Test requires GLX_EXT_import_context.\n"); + printf("Test requires GLX_EXT_import_context.\n"); piglit_report_result(PIGLIT_SKIP); } } else { diff --git a/tests/spec/glx_ext_import_context/query-context-info.c b/tests/spec/glx_ext_import_context/query-context-info.c index 6e187a1fb..dbc1ce259 100644 --- a/tests/spec/glx_ext_import_context/query-context-info.c +++ b/tests/spec/glx_ext_import_context/query-context-info.c @@ -105,7 +105,7 @@ int main(int argc, char **argv) && pass; /* Create a second indirect-rendering context, and have it share the - * first indirect-rendering context. The XID of the share conext for + * first indirect-rendering context. The XID of the share context for * the original context should be unchanged. */ ctx = glXCreateContext(dpy, visinfo, indirectCtx, False); diff --git a/tests/spec/intel_performance_query/issue_2235.c b/tests/spec/intel_performance_query/issue_2235.c index 71ae568e0..0cb88ee58 100644 --- a/tests/spec/intel_performance_query/issue_2235.c +++ b/tests/spec/intel_performance_query/issue_2235.c @@ -41,7 +41,7 @@ int main(int argc, char **argv) EGLContext ctx1; EGLint attr[] = { EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 2, + EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL_NONE }; GLuint query, query_handle; diff --git a/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicCompSwap-float-NaN.shader_test b/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicCompSwap-float-NaN.shader_test index 0ad13b742..6cdffdb2d 100644 --- a/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicCompSwap-float-NaN.shader_test +++ b/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicCompSwap-float-NaN.shader_test @@ -17,7 +17,7 @@ layout(binding = 0, std430) buffer bufblock { #define POS_NAN(x) (0x7f800000u | (0x007fffffu & uint(x))) #define NEG_NAN(x) (0xff800000u | (0x007fffffu & uint(x))) -uniform uint comparitors[] = uint[](POS_NAN(0x00ffffff), +uniform uint comparators[] = uint[](POS_NAN(0x00ffffff), NEG_NAN(0x00ffffff), POS_NAN(0x00555555), NEG_NAN(0x00555555), @@ -38,7 +38,7 @@ void main() * element will forever be set to float(idx). */ atomicCompSwap(value[idx], - uintBitsToFloat(comparitors[idx]), + uintBitsToFloat(comparators[idx]), 42.0); color = value[idx] == 42.0 diff --git a/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicMax-float-NaN.shader_test b/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicMax-float-NaN.shader_test index 527de10eb..5eda03ae4 100644 --- a/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicMax-float-NaN.shader_test +++ b/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicMax-float-NaN.shader_test @@ -85,21 +85,21 @@ void main() uint idx = (y * width) + x; - uint comparitor; + uint comparator; uint j = y & 7u; if (j <= 3u) - comparitor = floatBitsToUint(float(idx)); + comparator = floatBitsToUint(float(idx)); else if (j == 4u) - comparitor = make_qnan(idx * 101701u, false); + comparator = make_qnan(idx * 101701u, false); else if (j == 5u) - comparitor = make_qnan(idx * 89137u, true); + comparator = make_qnan(idx * 89137u, true); else if (j == 6u) - comparitor = make_snan(idx * 2399u, false); + comparator = make_snan(idx * 2399u, false); else - comparitor = make_snan(idx * 337u, true); + comparator = make_snan(idx * 337u, true); - float result = atomicMax(value[idx], uintBitsToFloat(comparitor)); + float result = atomicMax(value[idx], uintBitsToFloat(comparator)); uint k = idx & 7u; if (k <= 3u) @@ -128,7 +128,7 @@ void main() * does not explicitly state * which. */ - if (is_snan(comparitor)) + if (is_snan(comparator)) expect(is_snan(after)); else expect(floatBitsToUint(after) == floatBitsToUint(result)); @@ -141,9 +141,9 @@ void main() * does not explicitly state * which. */ - if (is_snan(comparitor)) - expect(floatBitsToUint(after) == comparitor); - else if (is_qnan(comparitor)) + if (is_snan(comparator)) + expect(floatBitsToUint(after) == comparator); + else if (is_qnan(comparator)) expect(is_qnan(after)); else expect(after == float(idx)); @@ -153,9 +153,9 @@ void main() * fmax(x, sNaN) => sNaN * fmax(x, qNaN) => x */ - if (is_snan(comparitor)) - expect(floatBitsToUint(after) == comparitor); - else if (is_qnan(comparitor)) + if (is_snan(comparator)) + expect(floatBitsToUint(after) == comparator); + else if (is_qnan(comparator)) expect(after == float(idx) - 0.5); else expect(after == float(idx)); diff --git a/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicMin-float-NaN.shader_test b/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicMin-float-NaN.shader_test index f34753610..63249c489 100644 --- a/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicMin-float-NaN.shader_test +++ b/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicMin-float-NaN.shader_test @@ -85,21 +85,21 @@ void main() uint idx = (y * width) + x; - uint comparitor; + uint comparator; uint j = y & 7u; if (j <= 3u) - comparitor = floatBitsToUint(float(idx)); + comparator = floatBitsToUint(float(idx)); else if (j == 4u) - comparitor = make_qnan(idx * 16871u, false); + comparator = make_qnan(idx * 16871u, false); else if (j == 5u) - comparitor = make_qnan(idx * 9929u, true); + comparator = make_qnan(idx * 9929u, true); else if (j == 6u) - comparitor = make_snan(idx * 8243u, false); + comparator = make_snan(idx * 8243u, false); else - comparitor = make_snan(idx * 4621u, true); + comparator = make_snan(idx * 4621u, true); - float result = atomicMin(value[idx], uintBitsToFloat(comparitor)); + float result = atomicMin(value[idx], uintBitsToFloat(comparator)); uint k = idx & 7u; if (k <= 3u) @@ -128,7 +128,7 @@ void main() * does not explicitly state * which. */ - if (is_snan(comparitor)) + if (is_snan(comparator)) expect(is_snan(after)); else expect(floatBitsToUint(after) == floatBitsToUint(result)); @@ -141,9 +141,9 @@ void main() * does not explicitly state * which. */ - if (is_snan(comparitor)) - expect(floatBitsToUint(after) == comparitor); - else if (is_qnan(comparitor)) + if (is_snan(comparator)) + expect(floatBitsToUint(after) == comparator); + else if (is_qnan(comparator)) expect(is_qnan(after)); else expect(after == float(idx)); @@ -153,9 +153,9 @@ void main() * fmin(x, sNaN) => sNaN * fmin(x, qNaN) => x */ - if (is_snan(comparitor)) - expect(floatBitsToUint(after) == comparitor); - else if (is_qnan(comparitor)) + if (is_snan(comparator)) + expect(floatBitsToUint(after) == comparator); + else if (is_qnan(comparator)) expect(after == float(idx) + 0.5); else expect(after == float(idx)); diff --git a/tests/spec/khr_debug/debug-push-pop-group.c b/tests/spec/khr_debug/debug-push-pop-group.c index d4c08cd09..1ac4ef48a 100644 --- a/tests/spec/khr_debug/debug-push-pop-group.c +++ b/tests/spec/khr_debug/debug-push-pop-group.c @@ -287,7 +287,7 @@ static bool test_push_pop_debug_group() pass = false; } - /* double check that TestMessage3 didnt sneak into the log */ + /* double check that TestMessage3 didn't sneak into the log */ nextMessage = 0; for (i = 0; i < count; i++) { if (strstr(messageLog+nextMessage, TestMessage3) != NULL) { diff --git a/tests/spec/khr_texture_compression_astc/khr_compressed_astc-miptree.c b/tests/spec/khr_texture_compression_astc/khr_compressed_astc-miptree.c index 2fdfb28ca..a5d61ac3f 100644 --- a/tests/spec/khr_texture_compression_astc/khr_compressed_astc-miptree.c +++ b/tests/spec/khr_texture_compression_astc/khr_compressed_astc-miptree.c @@ -277,7 +277,7 @@ test_miptrees(void* input_type) int block_dims; if (is_srgb_test) - /* Loosen up the tolerence for sRGB tests. This will allow testing + /* Loosen up the tolerance for sRGB tests. This will allow testing * sRGB formats which have known precision issues in void extent * blocks. See khronos bug#11294 for details. */ diff --git a/tests/spec/khr_texture_compression_astc/khr_compressed_astc-sliced-3d-miptree.c b/tests/spec/khr_texture_compression_astc/khr_compressed_astc-sliced-3d-miptree.c index 3926db785..d8f7caec7 100644 --- a/tests/spec/khr_texture_compression_astc/khr_compressed_astc-sliced-3d-miptree.c +++ b/tests/spec/khr_texture_compression_astc/khr_compressed_astc-sliced-3d-miptree.c @@ -266,7 +266,7 @@ test_miptrees(void* input_type) "GL_KHR_texture_compression_astc_sliced_3d"); if (is_srgb_test) - /* Loosen up the tolerence for sRGB tests. This will allow testing + /* Loosen up the tolerance for sRGB tests. This will allow testing * sRGB formats which have known precision issues in void extent * blocks. See khronos bug#11294 for details. */ diff --git a/tests/spec/mesa_shader_integer_functions/execution/built-in-functions/fs-ldexp.shader_test b/tests/spec/mesa_shader_integer_functions/execution/built-in-functions/fs-ldexp.shader_test index 3e6e69260..dededed5c 100644 --- a/tests/spec/mesa_shader_integer_functions/execution/built-in-functions/fs-ldexp.shader_test +++ b/tests/spec/mesa_shader_integer_functions/execution/built-in-functions/fs-ldexp.shader_test @@ -65,11 +65,6 @@ uniform ivec4 given_exponent 125 125 -128 -128 draw rect -1 -1 2 2 probe all rgba 0.0 1.0 0.0 1.0 -# Test underflow generates zero with sign of x. -uniform vec4 expected_float 0.0 -0.0 0.0 -0.0 -uniform vec4 given_float 0.0 -0.0 0.5 -0.5 -uniform ivec4 given_exponent -127 -127 -127 -127 -draw rect -1 -1 2 2 -probe all rgba 0.0 1.0 0.0 1.0 +# Underflow may flush to zero or not, so can't test that with this shader. # Overflow is undefined according to the GLSL spec, so nothing to test. diff --git a/tests/spec/mesa_shader_integer_functions/execution/built-in-functions/vs-ldexp.shader_test b/tests/spec/mesa_shader_integer_functions/execution/built-in-functions/vs-ldexp.shader_test index c01891cb7..c010ffb75 100644 --- a/tests/spec/mesa_shader_integer_functions/execution/built-in-functions/vs-ldexp.shader_test +++ b/tests/spec/mesa_shader_integer_functions/execution/built-in-functions/vs-ldexp.shader_test @@ -75,11 +75,6 @@ uniform ivec4 given_exponent 125 125 -128 -128 draw rect -1 -1 2 2 probe all rgba 0.0 1.0 0.0 1.0 -# Test underflow generates zero with sign of x. -uniform vec4 expected_float 0.0 -0.0 0.0 -0.0 -uniform vec4 given_float 0.0 -0.0 0.5 -0.5 -uniform ivec4 given_exponent -127 -127 -127 -127 -draw rect -1 -1 2 2 -probe all rgba 0.0 1.0 0.0 1.0 +# Underflow may flush to zero or not, so can't test that with this shader. # Overflow is undefined according to the GLSL spec, so nothing to test. diff --git a/tests/spec/nv_conditional_render/begin-while-active.c b/tests/spec/nv_conditional_render/begin-while-active.c index f80409a5d..6644dc9d7 100644 --- a/tests/spec/nv_conditional_render/begin-while-active.c +++ b/tests/spec/nv_conditional_render/begin-while-active.c @@ -36,7 +36,7 @@ * an <id> of zero, if the active query object name for <target> * is non-zero, if <id> is the active query object name for any * query type, or if <id> is the active query object for - * condtional rendering (Section 2.X), the error INVALID + * conditional rendering (Section 2.X), the error INVALID * OPERATION is generated." */ diff --git a/tests/spec/nv_copy_image/formats.c b/tests/spec/nv_copy_image/formats.c index dbee0d9f4..351083c14 100644 --- a/tests/spec/nv_copy_image/formats.c +++ b/tests/spec/nv_copy_image/formats.c @@ -328,7 +328,7 @@ piglit_init(int argc, char **argv) if (src_format_arg) { /* Since we know the source format, we know the number of - * bits per texel, so we can restrict the ammount of random + * bits per texel, so we can restrict the amount of random * data we generate. */ Bpp = src_format_arg->bytes; @@ -456,7 +456,7 @@ setup_test_data(const struct texture_format *src_format, for (j = 0; j < samples; ++j) { src_image = src_data + (j * image_size); res_image = res_data + (j * image_size); - /* Copy the center TEX_SIZE/2 x TEX_SIZE/2 pixels froms + /* Copy the center TEX_SIZE/2 x TEX_SIZE/2 pixels forms * src_data to res_data */ memcpy_rect(src_image, stride, TEX_SIZE/4, TEX_SIZE/4, diff --git a/tests/spec/nv_copy_image/simple.c b/tests/spec/nv_copy_image/simple.c index c5ca72968..7afd191b2 100644 --- a/tests/spec/nv_copy_image/simple.c +++ b/tests/spec/nv_copy_image/simple.c @@ -41,7 +41,10 @@ PIGLIT_GL_TEST_CONFIG_BEGIN PIGLIT_GL_TEST_CONFIG_END -static const float green[3] = {0.0, 1.0, 0.0}; +/* Note that the act of clearing and copying with the red and reddish colors + * helps to demonstrate bugs on some drivers. + */ +static const float red[3] = {1.0, 0.0, 0.0}; static const float reddish[3] = {0.5, 0.0, 0.0}; static const float blue[3] = {0.0, 0.0, 1.0}; @@ -157,7 +160,7 @@ piglit_display(void) image_init(&images[0], images[0].target, GL_RGB); image_init(&images[1], images[1].target, GL_RGB); - image_fill(&images[0], green); + image_fill(&images[0], red); image_fill(&images[1], reddish); glCopyImageSubDataNV(images[0].name, images[0].target, 0, 0, 0, 0, @@ -165,9 +168,9 @@ piglit_display(void) 32, 32, 1); pass &= piglit_check_gl_error(GL_NO_ERROR); - /* We should now have a green square on red */ + /* We should now have a bright red square on a darker one */ glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, images[1].fbo); - pass &= piglit_probe_rect_rgb(17, 11, 32, 32, green); + pass &= piglit_probe_rect_rgb(17, 11, 32, 32, red); pass &= piglit_probe_rect_rgb(0, 0, 64, 11, reddish); pass &= piglit_probe_rect_rgb(0, 11, 17, 32, reddish); pass &= piglit_probe_rect_rgb(49, 11, 15, 32, reddish); @@ -182,9 +185,9 @@ piglit_display(void) 32, 32, 1); pass &= piglit_check_gl_error(GL_NO_ERROR); - /* This should be a green square on blue (no red!) */ + /* This should be a red square on blue */ glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, images[0].fbo); - pass &= piglit_probe_rect_rgb(0, 32, 32, 32, green); + pass &= piglit_probe_rect_rgb(0, 32, 32, 32, red); pass &= piglit_probe_rect_rgb(0, 0, 64, 32, blue); pass &= piglit_probe_rect_rgb(32, 32, 32, 32, blue); @@ -193,11 +196,11 @@ piglit_display(void) 32, 32, 1); pass &= piglit_check_gl_error(GL_NO_ERROR); - /* This should be a blue/green checkerboard */ + /* This should be a blue/red checkerboard */ glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, images[0].fbo); pass &= piglit_probe_rect_rgb(0, 0, 32, 32, blue); - pass &= piglit_probe_rect_rgb(0, 32, 32, 32, green); - pass &= piglit_probe_rect_rgb(32, 0, 32, 32, green); + pass &= piglit_probe_rect_rgb(0, 32, 32, 32, red); + pass &= piglit_probe_rect_rgb(32, 0, 32, 32, red); pass &= piglit_probe_rect_rgb(32, 32, 32, 32, blue); if (!piglit_automatic) { diff --git a/tests/spec/nv_texture_env_combine4/combine.c b/tests/spec/nv_texture_env_combine4/combine.c index 0f2fdbd0c..9a5c03fc7 100644 --- a/tests/spec/nv_texture_env_combine4/combine.c +++ b/tests/spec/nv_texture_env_combine4/combine.c @@ -27,7 +27,7 @@ /** * @file combine.c: Test GL_NV_texture_env_combine4 - * Author: Brian Paul (brianp@valinux.com) Januar 2009 + * Author: Brian Paul (brianp@valinux.com) January 2009 * * Generate some random combiner state and colors, compute the expected * color, then render with the combiner state and compare the results. diff --git a/tests/spec/oes_texture_compression_astc/oes_compressed_astc-miptree-3d.c b/tests/spec/oes_texture_compression_astc/oes_compressed_astc-miptree-3d.c index 84e661135..8b3750918 100644 --- a/tests/spec/oes_texture_compression_astc/oes_compressed_astc-miptree-3d.c +++ b/tests/spec/oes_texture_compression_astc/oes_compressed_astc-miptree-3d.c @@ -248,7 +248,7 @@ test_miptrees(void* input_type) int block_dims = 0, slice;; if (is_srgb_test) - /* Loosen up the tolerence for sRGB tests. This will allow testing + /* Loosen up the tolerance for sRGB tests. This will allow testing * sRGB formats which have known precision issues in void extent * blocks. See khronos bug#11294 for details. */ diff --git a/tests/spec/oes_viewport_array/viewport-gs-writes-out-of-range.shader_test b/tests/spec/oes_viewport_array/viewport-gs-writes-out-of-range.shader_test deleted file mode 100644 index ea00b3f94..000000000 --- a/tests/spec/oes_viewport_array/viewport-gs-writes-out-of-range.shader_test +++ /dev/null @@ -1,71 +0,0 @@ -[require] -GL ES >= 3.1 -GLSL ES >= 3.10 -GL_OES_geometry_shader -GL_OES_viewport_array - -# -# Ensure that the fragment stage reads the same value for gl_ViewportIndex as was -# written by the geometry stage. -# -# This test covers the case where the value written is out of range. -# - -[vertex shader passthrough] - -[geometry shader] -#version 310 es -#extension GL_OES_geometry_shader: require -#extension GL_OES_viewport_array: require - -layout(triangles) in; -layout(triangle_strip, max_vertices=9) out; - -const int vps[] = int[]( -1, 16, 2048 ); -flat out int vp_written; - -void main() -{ - for (int vp = 0; vp < vps.length(); vp++) { - - for (int i = 0; i < 3; i++) { - gl_Position = gl_in[i].gl_Position; - vp_written = vps[vp]; - gl_ViewportIndex = vps[vp]; - EmitVertex(); - } - - EndPrimitive(); - } -} - -[fragment shader] -#version 310 es -#extension GL_OES_viewport_array: require -precision highp int; -precision highp float; - -flat in int vp_written; - -layout(binding = 0) uniform atomic_uint mismatches; - -out vec4 color; - -void main() -{ - if (vp_written != gl_ViewportIndex) - atomicCounterIncrement(mismatches); - - color = vec4(0); -} - -[test] -texture junk 2DArray 0 ( 64 , 64 , 1 ) -fb tex layered 0 - -atomic counters 1 - - -draw rect -1 -1 2 2 - -probe atomic counter 0 == 0 |