diff options
author | Lucas Stach <dev@lynxeye.de> | 2023-10-18 13:53:32 +0200 |
---|---|---|
committer | Lucas Stach <l.stach@pengutronix.de> | 2024-03-26 09:56:11 +0100 |
commit | f9e26b98b1fa03a0fe25084ede56b2fabe057098 (patch) | |
tree | d50717ce8deb074ec2f2d9106492a5adcd3bec8f | |
parent | b24c834d967a9d8793edc60552cd9112f49d09fb (diff) |
tests: add a test for GL_APPLE_sync
Tests from desktop GL ARB_sync adapted to GLES extension APPLE_sync.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/844>
-rw-r--r-- | tests/opengl.py | 13 | ||||
-rw-r--r-- | tests/spec/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/spec/apple_sync/CMakeLists.gles2.txt | 13 | ||||
-rw-r--r-- | tests/spec/apple_sync/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/spec/apple_sync/ClientWaitSync-errors.c | 79 | ||||
-rw-r--r-- | tests/spec/apple_sync/DeleteSync.c | 64 | ||||
-rw-r--r-- | tests/spec/apple_sync/FenceSync-errors.c | 55 | ||||
-rw-r--r-- | tests/spec/apple_sync/GetSynciv-errors.c | 74 | ||||
-rw-r--r-- | tests/spec/apple_sync/IsSync.c | 67 | ||||
-rw-r--r-- | tests/spec/apple_sync/WaitSync-errors.c | 62 | ||||
-rw-r--r-- | tests/spec/apple_sync/repeat-wait.c | 73 | ||||
-rw-r--r-- | tests/spec/apple_sync/sync-initialize.c | 116 | ||||
-rw-r--r-- | tests/spec/apple_sync/timeout-zero.c | 96 |
13 files changed, 714 insertions, 0 deletions
diff --git a/tests/opengl.py b/tests/opengl.py index d584b1458..2ce58bb90 100644 --- a/tests/opengl.py +++ b/tests/opengl.py @@ -1709,6 +1709,19 @@ with profile.test_list.group_manager( g(['arb_sync-ClientWaitSync-timeout'], 'ClientWaitSync-timeout') g(['sync_api']) +# Group APPLE_sync +with profile.test_list.group_manager( + PiglitGLTest, grouptools.join('spec', 'APPLE_sync')) as g: + g(['apple_sync-client-wait-errors'], 'ClientWaitSync-errors') + g(['apple_sync-delete'], 'DeleteSync') + g(['apple_sync-fence-sync-errors'], 'FenceSync-errors') + g(['apple_sync-get-sync-errors'], 'GetSynciv-errors') + g(['apple_sync-is-sync'], 'IsSync') + g(['apple_sync-repeat-wait'], 'repeat-wait') + g(['apple_sync-sync-initialize'], 'sync-initialize') + g(['apple_sync-timeout-zero'], 'timeout-zero') + g(['apple_sync-WaitSync-errors'], 'WaitSync-errors') + # Group ARB_ES2_compatibility with profile.test_list.group_manager( PiglitGLTest, grouptools.join('spec', 'ARB_ES2_compatibility')) as g: diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index 8aea8d974..544d7da54 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -4,6 +4,7 @@ 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) 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); +} |