From f66902f299e6f50cd8f6ff55c2d591963655ad08 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 25 Aug 2023 17:00:44 -0500 Subject: [PATCH] OpenXR SDK 1.0.29 (2023-08-25) This release contains several fixes to the specification registry, improvements to the loader, layers, and loader test, as well as enhancements to the loader documentation/specification to support architecture and ABI specific active runtime manifest names on Linux and Android. - Registry - Change PFNEGLGETPROCADDRESSPROC (for eglGetProcAddress) to a locally defined type to avoid compiler errors. (internal MR 2468) - Extension reservation: Register author ID and reserve vendor extensions for YVR. (internal MR 2832) - New vendor extension: XR_META_passthrough_preferences (internal MR 2694) - XR_HTCX_vive_tracker_interaction: Added new role paths for wrists and ankles. (internal MR 2728) - SDK - Changes also included in 1.0.28.1 SDK hotfix release - layers: Build with /bigobj or equivalent on Windows due to increased number of generated functions with spec growth. (internal MR 2837, internal issue 2051, OpenXR-SDK-Source PR 414) - Changes also included in 1.0.28.2 SDK hotfix release - Android AAR artifacts (loader) and hello_xr: Fix element contents. (internal MR 2840, internal issue 2053) - Android AAR artifacts: Fix C++ standard library selection for Android artifacts in build-aar.sh (internal MR 2836, internal issue 2052) - Android AAR artifacts: Use jar instead of 7-zip to perform archiving, and document requirements in build-aar.sh (internal MR 2836, OpenXR-SDK-Source issue 303, internal issue 1711) - build system: Support SDK hotfix versions (fourth version component). (internal MR 2836) - Add XrVector2f length function to xr_linear.h (internal MR 2876) - Add build.gradle files for list_json, c_compile_test. (internal MR 2908) - Change PFNEGLGETPROCADDRESSPROC (for eglGetProcAddress) to a locally defined type to avoid compiler errors. (internal MR 2468) - Enable loader_test tests which require a valid extension (internal MR 2790) - Fix building hello_xr with mingw compiler. (internal MR 2850) - Improvement: Reduce size of dispatch table in OpenXR loader. (Full size table still shipped in OpenXR-SDK even though it is not used by the loader anymore.) (internal MR 2810, internal MR 2842) - Maintenance script updates. (internal MR 2900) - loader: Add support for architecture-specific active runtime manifests for Linux, macOS, and Android. (internal MR 2450, internal issue 2066, internal MR 2871) - loader: refactor to use jnipp on Android (internal MR 2812) - loader: disable loader_test if api layer building is disabled (internal MR 2843) - loader_test: Replace session test with action test to make test more maintainable. (internal MR 2786) - validation layer: Fix deadlock when calling XR_EXT_debug_utils functions. (internal MR 2865) GitOrigin-RevId: 07acb644ae0a5a42f891120d3172004cb5605ad7 --- .appveyor.yml | 2 +- .../build/native/OpenXR.Loader.props | 2 +- .../build/native/OpenXR.Loader.targets | 2 +- .azure-pipelines/nuget/stage_nuget.ps1 | 2 +- .../shared/generate_windows_matrix_build.py | 2 +- .azure-pipelines/shared/install_vulkan.ps1 | 2 +- .../shared/organize_windows_artifacts.py | 2 +- .../shared/print_windows_artifact_names.py | 2 +- .azure-pipelines/shared/shared.py | 2 +- .git-blame-ignore-revs | 5 +- .../scripts/generate_windows_matrix_build.py | 2 +- .github/scripts/shared.py | 2 +- .github/workflows/android.yml | 100 +- .gitignore | 1 + .reuse/dep5 | 27 +- CHANGELOG.SDK.md | 72 + HOTFIX | 1 - README.md | 2 + changes/sdk/mr.2836.gl.1.md | 4 - changes/sdk/mr.2836.gl.2.md | 5 - changes/sdk/mr.2836.gl.md | 1 - changes/sdk/mr.2840.gl.md | 4 - changes/sdk/mr.414.gh.OpenXR-SDK-Source.md | 1 - github/sdk/README.md | 2 + maintainer-scripts/archive-sdk.sh | 2 + maintainer-scripts/common.sh | 2 +- specification/Makefile | 18 +- specification/loader/api_layer.adoc | 24 +- specification/loader/design.adoc | 7 +- specification/loader/loader.adoc | 12 +- specification/loader/overview.adoc | 2 +- specification/loader/runtime.adoc | 205 ++- specification/registry/xr.xml | 235 ++- specification/scripts/genRef.py | 2 + specification/scripts/genxr.py | 2 + .../scripts/spec-macros/extension.rb | 15 +- specification/scripts/validitygenerator.py | 2 + specification/scripts/xrconventions.py | 2 +- src/CMakeLists.txt | 34 +- src/api_layers/CMakeLists.txt | 16 +- src/api_layers/core_validation.cpp | 36 +- src/common/gfxwrapper_opengl.c | 1 + src/common/gfxwrapper_opengl.h | 56 +- src/common/platform_utils.hpp | 84 +- src/common/xr_dependencies.h | 6 +- src/common/xr_linear.h | 20 +- src/loader/.gitignore | 2 +- src/loader/AndroidManifest.xml | 2 +- src/loader/AndroidManifest.xml.in | 2 +- src/loader/CMakeLists.txt | 4 +- src/loader/abi.json.license | 5 +- src/loader/loader.rc | 9 +- src/loader/loader_core.cpp | 2 +- src/loader/loader_instance.cpp | 2 +- src/loader/manifest_file.cpp | 77 +- src/loader/module.json.license | 5 +- src/loader/openxr-loader.def | 5 - src/loader/openxr.pc.in | 4 + src/loader/openxr.pc.in.license | 3 - src/loader/prefab.json.license | 5 +- src/loader/runtime_interface.cpp | 45 +- src/scripts/generate_api_layer_manifest.py | 2 +- src/scripts/loader_source_generator.py | 4 +- src/scripts/src_genxr.py | 54 +- src/scripts/utility_source_generator.py | 54 +- src/scripts/validation_layer_generator.py | 2 +- src/tests/CMakeLists.txt | 5 +- src/tests/c_compile_test/AndroidManifest.xml | 74 + src/tests/c_compile_test/CMakeLists.txt | 19 +- src/tests/c_compile_test/build.gradle | 72 + src/tests/c_compile_test/main.c | 27 + src/tests/hello_xr/CMakeLists.txt | 5 +- .../values/ic_helloxr_launcher_background.xml | 2 +- src/tests/hello_xr/build.gradle | 21 + src/tests/hello_xr/d3d_common.cpp | 2 +- src/tests/hello_xr/gradle.properties | 2 +- src/tests/hello_xr/graphicsplugin_d3d11.cpp | 2 +- src/tests/hello_xr/graphicsplugin_d3d12.cpp | 2 +- src/tests/hello_xr/graphicsplugin_factory.cpp | 8 +- src/tests/hello_xr/graphicsplugin_vulkan.cpp | 14 +- src/tests/hello_xr/pch.h | 4 + src/tests/hello_xr/settings.gradle | 2 +- src/tests/list_json/AndroidManifest.xml | 21 +- src/tests/list_json/CMakeLists.txt | 7 +- src/tests/list_json/build.gradle | 72 + src/tests/loader_test/loader_test.cpp | 1372 +---------------- src/tests/loader_test/loader_test_utils.cpp | 4 - .../test_layers/XrApiLayer_test.def | 5 - .../test_runtimes/test_runtime.def | 5 - 89 files changed, 1237 insertions(+), 1828 deletions(-) delete mode 100644 HOTFIX delete mode 100644 changes/sdk/mr.2836.gl.1.md delete mode 100644 changes/sdk/mr.2836.gl.2.md delete mode 100644 changes/sdk/mr.2836.gl.md delete mode 100644 changes/sdk/mr.2840.gl.md delete mode 100644 changes/sdk/mr.414.gh.OpenXR-SDK-Source.md delete mode 100644 src/loader/openxr.pc.in.license create mode 100644 src/tests/c_compile_test/AndroidManifest.xml create mode 100644 src/tests/c_compile_test/build.gradle create mode 100644 src/tests/list_json/build.gradle diff --git a/.appveyor.yml b/.appveyor.yml index 36bd4b276..b17f46f82 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -version: 1.0.28.{build} +version: 1.0.29.{build} image: Visual Studio 2017 diff --git a/.azure-pipelines/nuget/NugetTemplate/build/native/OpenXR.Loader.props b/.azure-pipelines/nuget/NugetTemplate/build/native/OpenXR.Loader.props index 40cd777c5..0c45ebb27 100644 --- a/.azure-pipelines/nuget/NugetTemplate/build/native/OpenXR.Loader.props +++ b/.azure-pipelines/nuget/NugetTemplate/build/native/OpenXR.Loader.props @@ -1,6 +1,6 @@ diff --git a/.azure-pipelines/nuget/NugetTemplate/build/native/OpenXR.Loader.targets b/.azure-pipelines/nuget/NugetTemplate/build/native/OpenXR.Loader.targets index 216ba7d91..87476d338 100644 --- a/.azure-pipelines/nuget/NugetTemplate/build/native/OpenXR.Loader.targets +++ b/.azure-pipelines/nuget/NugetTemplate/build/native/OpenXR.Loader.targets @@ -1,7 +1,7 @@ diff --git a/.azure-pipelines/nuget/stage_nuget.ps1 b/.azure-pipelines/nuget/stage_nuget.ps1 index c4760328c..0ce897dbc 100644 --- a/.azure-pipelines/nuget/stage_nuget.ps1 +++ b/.azure-pipelines/nuget/stage_nuget.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020 The Khronos Group Inc. +# Copyright (c) 2019-2023, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 param( [Parameter(Mandatory = $true, HelpMessage = "Path to unzipped openxr_loader_windows OpenXR-SDK release asset")] diff --git a/.azure-pipelines/shared/generate_windows_matrix_build.py b/.azure-pipelines/shared/generate_windows_matrix_build.py index b74409b76..0f4622014 100644 --- a/.azure-pipelines/shared/generate_windows_matrix_build.py +++ b/.azure-pipelines/shared/generate_windows_matrix_build.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (c) 2019 The Khronos Group Inc. +# Copyright (c) 2019-2023, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 from itertools import product diff --git a/.azure-pipelines/shared/install_vulkan.ps1 b/.azure-pipelines/shared/install_vulkan.ps1 index aee09e94c..c1f2ab599 100644 --- a/.azure-pipelines/shared/install_vulkan.ps1 +++ b/.azure-pipelines/shared/install_vulkan.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) 2019 The Khronos Group Inc. +# Copyright (c) 2019-2023, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 if (-not $env:VULKAN_SDK_VERSION) { diff --git a/.azure-pipelines/shared/organize_windows_artifacts.py b/.azure-pipelines/shared/organize_windows_artifacts.py index fc80354d1..d59c53be5 100644 --- a/.azure-pipelines/shared/organize_windows_artifacts.py +++ b/.azure-pipelines/shared/organize_windows_artifacts.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (c) 2019 The Khronos Group Inc. +# Copyright (c) 2019-2023, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 from itertools import product diff --git a/.azure-pipelines/shared/print_windows_artifact_names.py b/.azure-pipelines/shared/print_windows_artifact_names.py index f7ab0da6c..d58bfdfcb 100644 --- a/.azure-pipelines/shared/print_windows_artifact_names.py +++ b/.azure-pipelines/shared/print_windows_artifact_names.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (c) 2019 The Khronos Group Inc. +# Copyright (c) 2019-2023, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 from itertools import product diff --git a/.azure-pipelines/shared/shared.py b/.azure-pipelines/shared/shared.py index aae8cb704..4276880cb 100644 --- a/.azure-pipelines/shared/shared.py +++ b/.azure-pipelines/shared/shared.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 The Khronos Group Inc. +# Copyright (c) 2019-2023, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 import json diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 5519b09d8..9925f5301 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -9,8 +9,11 @@ # and do try to make sure that the bulk change is made # **separate from a release commit** on all repos. # See -# for how to use this. +# for how to use this, probably something like: +# git config blame.ignoreRevsFile .git-blame-ignore-revs +## Old changes +767537d9523253de1615b01450a8b22c8e2cc6a2 ## 1.0.17 - Fix XML indentation diff --git a/.github/scripts/generate_windows_matrix_build.py b/.github/scripts/generate_windows_matrix_build.py index ef2d153b6..f8538b871 100644 --- a/.github/scripts/generate_windows_matrix_build.py +++ b/.github/scripts/generate_windows_matrix_build.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (c) 2019 The Khronos Group Inc. +# Copyright (c) 2019-2023, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 from itertools import product diff --git a/.github/scripts/shared.py b/.github/scripts/shared.py index c93035156..b9ab2e959 100644 --- a/.github/scripts/shared.py +++ b/.github/scripts/shared.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 The Khronos Group Inc. +# Copyright (c) 2019-2023, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 import json diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 2df431c54..c6a7a4c96 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,4 +1,4 @@ -# Copyright 2021, Collabora, Ltd. +# Copyright 2021-2023, Collabora, Ltd. # SPDX-License-Identifier: CC0-1.0 name: Android @@ -48,38 +48,6 @@ jobs: name: AAR and POM path: openxr_loader_for_android* - - name: Add to release - if: inputs.release && startsWith(github.ref, 'refs/tags/release-') - uses: softprops/action-gh-release@v1 - with: - files: openxr_loader_for_android* - - - name: Publish release to mavencentral - if: inputs.release - uses: gradle/gradle-build-action@v2 - with: - arguments: publishMavenPublicationToBuildDirRepository publishMavenPublicationToOSSRHRepository - build-root-directory: ./maintainer-scripts/publish-aar - env: - ORG_GRADLE_PROJECT_signingKey: ${{secrets.ORG_GRADLE_PROJECT_signingKey}} - ORG_GRADLE_PROJECT_signingKeyId: ${{secrets.ORG_GRADLE_PROJECT_signingKeyId}} - ORG_GRADLE_PROJECT_signingPassword: ${{secrets.ORG_GRADLE_PROJECT_signingPassword}} - OSSRH_USER: ${{secrets.OSSRH_USER}} - OSSRH_PASSWORD: ${{secrets.OSSRH_PASSWORD}} - - - name: Publish snapshot to mavencentral - if: inputs.snapshot - uses: gradle/gradle-build-action@v2 - with: - arguments: publishMavenPublicationToBuildDirRepository publishMavenPublicationToOSSRH-SnapshotsRepository - build-root-directory: ./maintainer-scripts/publish-aar - env: - ORG_GRADLE_PROJECT_signingKey: ${{secrets.ORG_GRADLE_PROJECT_signingKey}} - ORG_GRADLE_PROJECT_signingKeyId: ${{secrets.ORG_GRADLE_PROJECT_signingKeyId}} - ORG_GRADLE_PROJECT_signingPassword: ${{secrets.ORG_GRADLE_PROJECT_signingPassword}} - OSSRH_USER: ${{secrets.OSSRH_USER}} - OSSRH_PASSWORD: ${{secrets.OSSRH_PASSWORD}} - - name: Upload Maven repo if: inputs.release || inputs.snapshot uses: actions/upload-artifact@v3 @@ -114,69 +82,3 @@ jobs: with: name: HelloXR OpenGLES Android path: src/tests/hello_xr/build/outputs/apk/OpenGLES/debug/*.apk - - - name: Sign HelloXR OpenGLES Android release - if: inputs.release - uses: r0adkll/sign-android-release@349ebdef58775b1e0d8099458af0816dc79b6407 - id: sign_gles - with: - releaseDirectory: src/tests/hello_xr/build/outputs/apk/OpenGLES/release - signingKeyBase64: ${{ secrets.APK_SIGNING_KEY }} - alias: ${{ secrets.APK_ALIAS }} - keyStorePassword: ${{ secrets.APK_KEY_STORE_PASSWORD }} - keyPassword: ${{ secrets.APK_KEY_PASSWORD }} - env: - BUILD_TOOLS_VERSION: "30.0.3" - - - name: Rename APK - if: inputs.release - env: - SIGNED_FILE: ${{ steps.sign_gles.outputs.signedReleaseFile }} - run: mv $SIGNED_FILE HelloXR_OpenGLES.apk - - - name: Upload signed HelloXR OpenGLES Android - if: inputs.release - uses: actions/upload-artifact@v3 - with: - name: HelloXR OpenGLES Android - path: HelloXR_OpenGLES.apk - - # HelloXR Vulkan version - - name: Build HelloXR Vulkan for Android - if: inputs.release - uses: gradle/gradle-build-action@v2 - with: - arguments: assembleVulkanRelease - build-root-directory: src/tests/hello_xr - - - name: Sign HelloXR Vulkan Android release - if: inputs.release - uses: r0adkll/sign-android-release@349ebdef58775b1e0d8099458af0816dc79b6407 - id: sign_vulkan - with: - releaseDirectory: src/tests/hello_xr/build/outputs/apk/Vulkan/release - signingKeyBase64: ${{ secrets.APK_SIGNING_KEY }} - alias: ${{ secrets.APK_ALIAS }} - keyStorePassword: ${{ secrets.APK_KEY_STORE_PASSWORD }} - keyPassword: ${{ secrets.APK_KEY_PASSWORD }} - env: - BUILD_TOOLS_VERSION: "30.0.3" - - - name: Rename APK - if: inputs.release - env: - SIGNED_FILE: ${{ steps.sign_vulkan.outputs.signedReleaseFile }} - run: mv $SIGNED_FILE HelloXR_Vulkan.apk - - - name: Upload HelloXR Vulkan Android - if: inputs.release - uses: actions/upload-artifact@v3 - with: - name: HelloXR Vulkan Android - path: HelloXR_Vulkan.apk - - - name: Release - if: startsWith(github.ref, 'refs/tags/release-') - uses: softprops/action-gh-release@v1 - with: - files: HelloXR_*.apk diff --git a/.gitignore b/.gitignore index 13a23f162..fbafc27fa 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,7 @@ local.properties # Don't ignore these things !.*.license +!.artifact-bot.md !.appveyor.yml !.azure-pipelines/ !.azure-pipelines/nuget/NugetTemplate/build diff --git a/.reuse/dep5 b/.reuse/dep5 index cefd07650..3df6553ac 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -3,7 +3,12 @@ Upstream-Name: OpenXR Upstream-Contact: Ryan Pavlik Source: https://khronos.org/registry/OpenXR/ -Files: changes/* +Files: changes/conformance/* + changes/registry/* + changes/sdk/* + changes/specification/* + changes/README.md + changes/template.md HOTFIX Copyright: 2019-2023, The Khronos Group Inc. License: CC-BY-4.0 @@ -30,25 +35,22 @@ Comment: Based on a Material Icons asset ("emoji-people") with added text Rasterized with Android Studio. Files: src/external/catch2/* -Copyright: Copyright (c) 2022 Two Blue Cubes Ltd. +Copyright: Copyright (c) 2023 Two Blue Cubes Ltd. License: BSL-1.0 -Comment: Unmodified, vendored copy of Catch2 3.1.1 +Comment: Unmodified, vendored copy of Catch2 v3.3.2 Files: src/external/jsoncpp/* Copyright: 2007-2010 Baptiste Lepilleur and The JsonCpp Authors License: MIT OR LicenseRef-jsoncpp-public-domain Comment: Unmodified, vendored copy of jsoncpp 1.9.5 -Files: src/external/tinygltf/* -Copyright: 2017 Syoyo Fujita, Aurélien Chatelain and many contributors +Files: src/external/tinygltf/README.md + src/external/tinygltf/tiny_gltf.cc + src/external/tinygltf/tiny_gltf.h +Copyright: 2015-Present, Syoyo Fujita, Aurélien Chatelain and many contributors License: MIT Comment: Unmodified, vendored copy of a subset of the tiny-gltf repo v2.8.9 -Files: src/external/tinygltf/json.hpp -Copyright: 2013-2017 Niels Lohmann -License: MIT -Comment: Unmodified, included in tiny-gltf repo. - Files: src/external/d3dx12/* Copyright: Copyright (c) Microsoft Corporation. License: MIT @@ -82,11 +84,6 @@ Copyright: 2020, Epic Games, Inc. License: CC-BY-4.0 Comment: In-line license comments requested, https://gitlab.khronos.org/openxr/openxr/-/issues/1422 -Files: specification/sources/chapters/extensions/oculus/oculus_android_session_state_enable.adoc -Copyright: 2019, Oculus VR, LLC. -License: CC-BY-4.0 -Comment: In-line license comments requested, https://gitlab.khronos.org/openxr/openxr/-/issues/1418 - Files: specification/sources/chapters/extensions/ext/ext_performance_settings.adoc specification/sources/chapters/extensions/ext/ext_thermal_query.adoc Copyright: 2017-2023, The Khronos Group Inc. diff --git a/CHANGELOG.SDK.md b/CHANGELOG.SDK.md index babc1ca1a..af900f4d8 100644 --- a/CHANGELOG.SDK.md +++ b/CHANGELOG.SDK.md @@ -19,6 +19,78 @@ along with any public pull requests that have been accepted. In this repository in particular, since it is primarily software, pull requests may be integrated as they are accepted even between periodic updates. +## OpenXR SDK 1.0.29 (2023-08-25) + +This release contains several fixes to the specification registry, improvements +to the loader, layers, and loader test, as well as enhancements to the loader +documentation/specification to support architecture and ABI specific active +runtime manifest names on Linux and Android. + +- Registry + - Change `PFNEGLGETPROCADDRESSPROC` (for `eglGetProcAddress`) to a locally + defined type to avoid compiler errors. + ([internal MR 2468](https://gitlab.khronos.org/openxr/openxr/merge_requests/2468)) + - Extension reservation: Register author ID and reserve vendor extensions for + YVR. + ([internal MR 2832](https://gitlab.khronos.org/openxr/openxr/merge_requests/2832)) + - New vendor extension: `XR_META_passthrough_preferences` + ([internal MR 2694](https://gitlab.khronos.org/openxr/openxr/merge_requests/2694)) + - `XR_HTCX_vive_tracker_interaction`: Added new role paths for wrists and ankles. + ([internal MR 2728](https://gitlab.khronos.org/openxr/openxr/merge_requests/2728)) +- SDK + - Changes also included in 1.0.28.1 SDK hotfix release + - layers: Build with `/bigobj` or equivalent on Windows due to increased number + of generated functions with spec growth. + ([internal MR 2837](https://gitlab.khronos.org/openxr/openxr/merge_requests/2837), + [internal issue 2051](https://gitlab.khronos.org/openxr/openxr/issues/2051), + [OpenXR-SDK-Source PR 414](https://github.com/KhronosGroup/OpenXR-SDK-Source/pull/414)) + - Changes also included in 1.0.28.2 SDK hotfix release + - Android AAR artifacts (loader) and hello_xr: Fix `` element contents. + ([internal MR 2840](https://gitlab.khronos.org/openxr/openxr/merge_requests/2840), + [internal issue 2053](https://gitlab.khronos.org/openxr/openxr/issues/2053)) + - Android AAR artifacts: Fix C++ standard library selection for Android artifacts + in `build-aar.sh` + ([internal MR 2836](https://gitlab.khronos.org/openxr/openxr/merge_requests/2836), + [internal issue 2052](https://gitlab.khronos.org/openxr/openxr/issues/2052)) + - Android AAR artifacts: Use `jar` instead of 7-zip to perform archiving, and + document requirements in `build-aar.sh` + ([internal MR 2836](https://gitlab.khronos.org/openxr/openxr/merge_requests/2836), + [OpenXR-SDK-Source issue 303](https://github.com/KhronosGroup/OpenXR-SDK-Source/issues/303), + [internal issue 1711](https://gitlab.khronos.org/openxr/openxr/issues/1711)) + - build system: Support SDK hotfix versions (fourth version component). + ([internal MR 2836](https://gitlab.khronos.org/openxr/openxr/merge_requests/2836)) + - Add XrVector2f length function to `xr_linear.h` + ([internal MR 2876](https://gitlab.khronos.org/openxr/openxr/merge_requests/2876)) + - Add build.gradle files for list_json, c_compile_test. + ([internal MR 2908](https://gitlab.khronos.org/openxr/openxr/merge_requests/2908)) + - Change `PFNEGLGETPROCADDRESSPROC` (for `eglGetProcAddress`) to a locally + defined type to avoid compiler errors. + ([internal MR 2468](https://gitlab.khronos.org/openxr/openxr/merge_requests/2468)) + - Enable `loader_test` tests which require a valid extension + ([internal MR 2790](https://gitlab.khronos.org/openxr/openxr/merge_requests/2790)) + - Fix building hello_xr with mingw compiler. + ([internal MR 2850](https://gitlab.khronos.org/openxr/openxr/merge_requests/2850)) + - Improvement: Reduce size of dispatch table in OpenXR loader. (Full size table + still shipped in OpenXR-SDK even though it is not used by the loader anymore.) + ([internal MR 2810](https://gitlab.khronos.org/openxr/openxr/merge_requests/2810), + [internal MR 2842](https://gitlab.khronos.org/openxr/openxr/merge_requests/2842)) + - Maintenance script updates. + ([internal MR 2900](https://gitlab.khronos.org/openxr/openxr/merge_requests/2900)) + - loader: Add support for architecture-specific active runtime manifests for + Linux, macOS, and Android. + ([internal MR 2450](https://gitlab.khronos.org/openxr/openxr/merge_requests/2450), + [internal issue 2066](https://gitlab.khronos.org/openxr/openxr/issues/2066), + [internal MR 2871](https://gitlab.khronos.org/openxr/openxr/merge_requests/2871)) + - loader: refactor to use jnipp on Android + ([internal MR 2812](https://gitlab.khronos.org/openxr/openxr/merge_requests/2812)) + - loader: disable `loader_test` if api layer building is disabled + ([internal MR 2843](https://gitlab.khronos.org/openxr/openxr/merge_requests/2843)) + - loader_test: Replace session test with action test to make test more + maintainable. + ([internal MR 2786](https://gitlab.khronos.org/openxr/openxr/merge_requests/2786)) + - validation layer: Fix deadlock when calling `XR_EXT_debug_utils` functions. + ([internal MR 2865](https://gitlab.khronos.org/openxr/openxr/merge_requests/2865)) + ## OpenXR SDK 1.0.28 (2023-07-10) This release contains improved compatibility and code quality fixes for the diff --git a/HOTFIX b/HOTFIX deleted file mode 100644 index 0cfbf0888..000000000 --- a/HOTFIX +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/README.md b/README.md index a09af6a8c..09dc4dad5 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ and omits the samples, tests, and API layers, as they are not typically built as ## Directory Structure + - `BUILDING.md` - Instructions for building the projects - `README.md` - This file - `COPYING.md` - Copyright and licensing information @@ -34,6 +35,7 @@ and omits the samples, tests, and API layers, as they are not typically built as - `src/api_layer` - Sample code for developing API layers - `src/loader` - OpenXR loader code - `src/tests` - various test code (if looking for sample code start with `hello_xr/`) + Currently the best sample code is in [src/tests/hello_xr/](src/tests/hello_xr). More will be added in the future. diff --git a/changes/sdk/mr.2836.gl.1.md b/changes/sdk/mr.2836.gl.1.md deleted file mode 100644 index 67e6433b6..000000000 --- a/changes/sdk/mr.2836.gl.1.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -- issue.2052.gl ---- -Android AAR artifacts: Fix C++ standard library selection for Android artifacts in `build-aar.sh` diff --git a/changes/sdk/mr.2836.gl.2.md b/changes/sdk/mr.2836.gl.2.md deleted file mode 100644 index 143a7d19b..000000000 --- a/changes/sdk/mr.2836.gl.2.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -- issue.303.gh.OpenXR-SDK-Source -- issue.1711.gl ---- -- Android AAR artifacts: Use `jar` instead of 7-zip to perform archiving, and document requirements in `build-aar.sh` diff --git a/changes/sdk/mr.2836.gl.md b/changes/sdk/mr.2836.gl.md deleted file mode 100644 index c87e8a882..000000000 --- a/changes/sdk/mr.2836.gl.md +++ /dev/null @@ -1 +0,0 @@ -- build system: Support SDK hotfix versions (fourth version component). diff --git a/changes/sdk/mr.2840.gl.md b/changes/sdk/mr.2840.gl.md deleted file mode 100644 index 6b00c228b..000000000 --- a/changes/sdk/mr.2840.gl.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -- issue.2053.gl ---- -- Android AAR artifacts (loader) and hello_xr: Fix `` element contents. diff --git a/changes/sdk/mr.414.gh.OpenXR-SDK-Source.md b/changes/sdk/mr.414.gh.OpenXR-SDK-Source.md deleted file mode 100644 index 32614d817..000000000 --- a/changes/sdk/mr.414.gh.OpenXR-SDK-Source.md +++ /dev/null @@ -1 +0,0 @@ -API dump layer: Fix build on Windows on ARM64. diff --git a/github/sdk/README.md b/github/sdk/README.md index c3cd2289b..f66000946 100644 --- a/github/sdk/README.md +++ b/github/sdk/README.md @@ -24,6 +24,7 @@ That repository is also where sample code (hello_xr) and API layer source can be ## Directory Structure + - `BUILDING.md` - Instructions for building the projects - `README.md` - This file - `COPYING.md` - Copyright and licensing information @@ -32,6 +33,7 @@ That repository is also where sample code (hello_xr) and API layer source can be - `include/` - OpenXR header files - `src/external/jsoncpp` - The jsoncpp project source code, an included dependency of the loader. - `src/loader` - OpenXR loader code, **including generated code** + ## Building diff --git a/maintainer-scripts/archive-sdk.sh b/maintainer-scripts/archive-sdk.sh index 82fdda4f1..ba8524746 100755 --- a/maintainer-scripts/archive-sdk.sh +++ b/maintainer-scripts/archive-sdk.sh @@ -63,6 +63,8 @@ while read -r header; do done < include/generated_header_list.txt # These go just in SDK +generate_src src xr_generated_dispatch_table_core.c "$TARNAME" +generate_src src xr_generated_dispatch_table_core.h "$TARNAME" generate_src src xr_generated_dispatch_table.c "$TARNAME" generate_src src xr_generated_dispatch_table.h "$TARNAME" generate_src src/loader xr_generated_loader.cpp "$TARNAME" diff --git a/maintainer-scripts/common.sh b/maintainer-scripts/common.sh index 370432238..065300c24 100644 --- a/maintainer-scripts/common.sh +++ b/maintainer-scripts/common.sh @@ -34,7 +34,7 @@ makeSubset() { } -COMMON_FILES=".gitignore .gitattributes .git-blame-ignore-revs CODE_OF_CONDUCT.md LICENSES .reuse .editorconfig" +COMMON_FILES=".gitignore .gitattributes .git-blame-ignore-revs CODE_OF_CONDUCT.md LICENSES .reuse .editorconfig HOTFIX" export COMMON_FILES COMMON_EXCLUDE_PATTERN="KhronosExperimental" export COMMON_EXCLUDE_PATTERN diff --git a/specification/Makefile b/specification/Makefile index 5b69343df..fcf693386 100644 --- a/specification/Makefile +++ b/specification/Makefile @@ -32,7 +32,7 @@ ifneq (,$(strip $(VERY_STRICT))) ASCIIDOC := $(ASCIIDOC) --failure-level WARN endif -SPECREVISION = 1.0.28 +SPECREVISION = 1.0.29 REVISION_COMPONENTS = $(subst ., ,$(SPECREVISION)) MAJORMINORVER = $(word 1,$(REVISION_COMPONENTS)).$(word 2,$(REVISION_COMPONENTS)) @@ -384,26 +384,14 @@ BACKEND_ARGS=--backend html5 $(ASCIIDOCTOR_TARGETS): $(ECHO) "[asciidoctor] $(SPECSRC) -> $(call MAKE_RELATIVE,$@)" $(QUIET)$(MKDIR) "$(@D)" - $(QUIET)if [ $$(uname -s | cut -c 1-6) == "CYGWIN" ]; then \ - OUTSPEC_DOS=$$(cygpath -w $@) ;\ - SPECSRC_DOS=$$(cygpath -w $(SPECSRC)) ;\ - ATTRIBOPTS_DOS='$(ATTRIBOPTS)' ;\ - ADOCOPTS_DOS="--doctype book -a data-uri -r $$(cygpath -w $(CURDIR)/scripts/spec-macros.rb) $$ATTRIBOPTS_DOS" ;\ - BATCH_FILE=$$(cygpath -w $$(mktemp)).bat ;\ - echo $(ASCIIDOC) $$ADOCOPTS_DOS $(BACKEND_ARGS) --out-file $$OUTSPEC_DOS $$SPECSRC_DOS > $$BATCH_FILE ;\ - CMD /C $$BATCH_FILE ;\ - rm -f $$BATCH_FILE ;\ - else \ - $(ASCIIDOC) $(ADOCOPTS) $(BACKEND_ARGS) --out-file $@ $(SPECSRC) 2>&1 | tee $(LOGFILE) ;\ - if [ -s $(LOGFILE) ]; then \ + $(QUIET)$(ASCIIDOC) $(ADOCOPTS) $(BACKEND_ARGS) --out-file $@ $(SPECSRC) 2>&1 | tee $(LOGFILE) + $(QUIET)if [ -s $(LOGFILE) ]; then \ echo "Failure: $(LOGFILE) exists and is not empty!"; \ false; \ else \ rm $(LOGFILE); \ - fi; \ fi $(POSTPROCESS) -# TODO: Postprocess step(s) may have broken the Cygwin build. Not sure this matters anymore with WSL, though. ################################################ diff --git a/specification/loader/api_layer.adoc b/specification/loader/api_layer.adoc index 2a27f39b2..9f1d986dc 100644 --- a/specification/loader/api_layer.adoc +++ b/specification/loader/api_layer.adoc @@ -382,8 +382,8 @@ On Android the loader finds API layers by reading all and implicit layers: ---- -openxr/1/api_layers/implicit.d -openxr/1/api_layers/explicit.d +openxr/__major_ver__/api_layers/implicit.d +openxr/__major_ver__/api_layers/explicit.d ---- [Note] @@ -399,19 +399,19 @@ order for implicit and explicit API layers: ===== Implicit API Layers -. `/product/etc/openxr/1/api_layers/implicit.d` -. `/odm/etc/openxr/1/api_layers/implicit.d` -. `/oem/etc/openxr/1/api_layers/implicit.d` -. `/system/etc/openxr/1/api_layers/implicit.d` -. `/vendor/etc/openxr/1/api_layers/implicit.d` +1. `/product/etc/openxr/__major_ver__/api_layers/implicit.d` +2. `/odm/etc/openxr/__major_ver__/api_layers/implicit.d` +3. `/oem/etc/openxr/__major_ver__/api_layers/implicit.d` +4. `/system/etc/openxr/__major_ver__/api_layers/implicit.d` +5. `/vendor/etc/openxr/__major_ver__/api_layers/implicit.d` ===== Explicit API Layers -. `/product/etc/openxr/1/api_layers/explicit.d` -. `/oem/etc/openxr/1/api_layers/explicit.d` -. `/vendor/etc/openxr/1/api_layers/explicit.d` -. `/system/etc/openxr/1/api_layers/explicit.d` -. `/odm/etc/openxr/1/api_layers/explicit.d` +1. `/product/etc/openxr/__major_ver__/api_layers/explicit.d` +2. `/oem/etc/openxr/__major_ver__/api_layers/explicit.d` +3. `/vendor/etc/openxr/__major_ver__/api_layers/explicit.d` +4. `/system/etc/openxr/__major_ver__/api_layers/explicit.d` +5. `/odm/etc/openxr/__major_ver__/api_layers/explicit.d` [[api-layer-manifest-file-format]] ==== API Layer Manifest File Format ==== diff --git a/specification/loader/design.adoc b/specification/loader/design.adoc index 1ae080252..434899e92 100644 --- a/specification/loader/design.adoc +++ b/specification/loader/design.adoc @@ -525,6 +525,8 @@ process: .2+| /src folder l| xr_generated_dispatch_table.h l| xr_generated_dispatch_table.c + l| xr_generated_dispatch_table_core.h + l| xr_generated_dispatch_table_core.c .2+| /src/loader folder l| xr_loader_generated.hpp l| xr_loader_generated.cpp @@ -537,8 +539,9 @@ sname:XrGeneratedDispatchTable structure. This structure can be used to store function pointers for any OpenXR commands defined in the xr.xml at the time the loader was built. It includes slots for both core and extension function pointers. -Currently, the loader uses this structure as well as the provided API -Layers. +Currently, the provided API Layers use this structure and the loader +uses a structure which has a subset of the function pointers (defined +in `xr_generated_dispatch_table_core.h`). A partial listing from the generated table follows: diff --git a/specification/loader/loader.adoc b/specification/loader/loader.adoc index 048e9e9c4..a9d92c4c1 100644 --- a/specification/loader/loader.adoc +++ b/specification/loader/loader.adoc @@ -3,7 +3,7 @@ // // SPDX-License-Identifier: CC-BY-4.0 -= OpenXR^(R)^ Loader - Design and Operation {apititle} += OpenXR(TM) Loader - Design and Operation Copyright (c) 2017-2023, The Khronos Group Inc. :data-uri: :icons: font @@ -29,9 +29,17 @@ Intended use of this document is as a detailed design document and a tool for learning general OpenXR loader behavior. In the event of any discrepancies between this document and the -(https://www.khronos.org/registry/OpenXR[OpenXR specification]), that +https://www.khronos.org/registry/OpenXR[OpenXR specification], that document is authoritative. +OpenXR(TM) and the OpenXR logo are trademarks owned by The Khronos Group +Inc. +and are registered as a trademark in China, the European Union, Japan, and +the United Kingdom. +OpenGL and OpenGL ES are registered trademarks of Hewlett Packard +Enterprise, all used under license by Khronos. +All other product names, trademarks, and/or company names are used solely +for identification and belong to their respective owners. [[introduction-terminology]] == Terminology == diff --git a/specification/loader/overview.adoc b/specification/loader/overview.adoc index 945913b5d..a3cfc3d69 100644 --- a/specification/loader/overview.adoc +++ b/specification/loader/overview.adoc @@ -135,7 +135,7 @@ enabled API layers and into the appropriate runtime. [NOTE] .Note ==== -Some OpenXR commands don't actually take an object, such as +Some OpenXR commands do not take an object, such as `xrEnumerateApiLayerProperties` and `xrEnumerateInstanceExtensionProperties`. These commands typically only provide information for other commands which diff --git a/specification/loader/runtime.adoc b/specification/loader/runtime.adoc index b6e74d66a..d2c0da885 100644 --- a/specification/loader/runtime.adoc +++ b/specification/loader/runtime.adoc @@ -29,6 +29,7 @@ sub-sections below. This information is also important if the active runtime needs to be changed by an external entity (on those platforms that support updating). +[[linux-active-runtime-location]] ===== Linux Active Runtime Location On Linux, the active runtime information is contained inside a @@ -41,43 +42,57 @@ directory (typically `/etc`), under the relative path: openxr/ ``` - should be replaced with the integer value for the +`____` should be replaced with the integer value for the corresponding OpenXR API version. -The JSON file is named "active_runtime.json" and contains the necessary -information on how OpenXR components can load the appropriate runtime -library. +Two JSON file names are checked in each directory. +First, the loader looks for `active_runtime.____.json`, where +`____` is an architecture and ABI specifier from the +<> table. +If no such file is found, `active_runtime.json` is then checked. +The JSON file contains the necessary information on how OpenXR components +can load the appropriate runtime library. -For example, a globally-configured OpenXR 1.x active runtime file might be -at: +For example, a globally-configured OpenXR 1.x active runtime file on an +x86_64 PC might be at: ``` -/etc/xdg/openxr/1/active_runtime.json +/etc/xdg/openxr/1/active_runtime.x86_64.json ``` When multiple such files exist, `XDG_CONFIG_HOME` is preferred, followed by the elements of `XDG_CONFIG_DIRS` in order, followed by the system's global configuration directory. +Both filenames are tested in a given directory before moving on. This allows the user's preference to easily override a global default. +[NOTE] +.NOTE +==== +`active_runtime` filenames may be a symbolic link to a file with a +runtime-specific name, for ease of runtime switching and enumeration by the +user or system tools. +See <> for more information. +==== + +[[windows-active-runtime-location]] ===== Windows Active Runtime Location -The Windows OpenXR active runtime information is actually located in the -Windows Registry (not to be confused with the OpenXR registry) under the -key: +The Windows OpenXR active runtime information is located in the Windows +Registry (not to be confused with the OpenXR registry) under the key: ``` HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenXR\ ``` -Where should be replaced with the integer value for the -corresponding OpenXR API major version. +Where `____` should be replaced with the integer value +for the corresponding OpenXR API version. [NOTE] .Important ==== If using a 32-bit application on a 64-bit Windows install, "WOW6432Node" is -added before "SOFTWARE", in the above path like so: +added before "SOFTWARE" in the preceding path as follows: ``` HKEY_LOCAL_MACHINE\WOW6432Node\SOFTWARE\Khronos\OpenXR\ @@ -170,12 +185,19 @@ construct an object corresponding to an equivalent JSON runtime manifest file as used on other platforms. If no runtime is found this way, as a fall-back, a similar process as on -Linux takes place, searching for `active_runtime.json` files in: +Linux takes place, searching for `active_runtime.____.json` and +`active_runtime.json` files in the following locations in priority order: -* `/oem/etc/openxr/1` -* `/vendor/etc/openxr/1` -* `/system/etc/openxr/1` +1. `/product/etc/openxr/__major_ver__` +2. `/odm/etc/openxr/__major_ver__` +3. `/oem/etc/openxr/__major_ver__` +4. `/vendor/etc/openxr/__major_ver__` +5. `/system/etc/openxr/__major_ver__` +`____` should be replaced with the integer value for the +corresponding OpenXR API version, and `____` is an architecture and +ABI specifier from the <> table. +Both filenames are checked in each directory before moving on to the next. [[android-ipc]] ====== Android IPC and Runtime Access @@ -254,15 +276,114 @@ It is harmless to leave it in place, but the broker no longer requires it. ``` ==== -If no runtime is found this way, as a fall-back, a similar process as on -Linux takes place, searching for `active_runtime.json` files in the -following priority order: - -. `/product/etc/openxr/1` -. `/odm/etc/openxr/1` -. `/oem/etc/openxr/1` -. `/vendor/etc/openxr/1` -. `/system/etc/openxr/1` +[[architecture-identifiers]] +===== Architecture/ABI Identifiers + +On platforms such as <> and +<> where the active runtime +manifest may be found by filename, the following table of known +architectures and ABIs is used. + +:url-android-ndk-abis: https://developer.android.com/ndk/guides/abis +:url-debian-ports: https://www.debian.org/ports/ + +[cols="1,1,1,4"] +|=== +|Architecture/ABI Identifier |{url-android-ndk-abis}[Android NDK ABI] Name | {url-debian-ports}[Debian Port] Name |Description + +|`x32` + | + | `x32` + | 64-bit x86 instructions, using an ILP32 model (32-bit pointers) + +|`x86_64` + | `x86_64` + | `x86_64` + | 64-bit x86 + +|`i686` + | `x86` + | `i386` + | 32-bit x86 + +|`aarch64` + | `arm64-v8a` + | `aarch64` + | 64-bit ARM architecture, little endian + +|`armv7a-vfp` + | `armeabi-v7a` (See <>.) + | `armhf` + | 32-bit ARMv7-A architecture, little endian, with hardware floating point and VFP PCS ABI + +|`armv5te` + | + | `armel` + | 32-bit ARMv5TE architecture or compatible, little endian + +|`mips64` + | + | `mips64el` + | 64-bit MIPS architecture, little endian + +|`mips` + | + | `mipsel` + | 32-bit MIPS architecture, little endian + +|`ppc64` + | + | `ppc64` + | 64-bit PowerPC architecture, big endian + +|`ppc64el` + | + | `ppc64el` + | 64-bit POWER8/POWER9 architecture, little endian (OpenPOWER ELF ABI v2) + +|`s390x` + | + | `s390x` + | 64-bit S390/z-Series architecture, big endian + +|`hppa` + | + | `hppa` + | 32-bit HP PA-RISC architecture, big endian + +|`alpha` + | + | `alpha` + | 64-bit Alpha architecture + +|`ia64` + | + | `ia64` + | 64-bit IA-64 architecture + +|`m68k` + | + | `m68k` + | 32-bit Motorola 68000-based architecture, big endian + +|`riscv64` + | + | `riscv64` + | 64-bit RISC-V architecture, little endian + +|`sparc64` + | + | `sparc64` + | 64-bit SPARC architecture + +|=== + +[[android-arm32-note]] +Note: The preceding table defines `armv7a-vfp` as the architecture/ABI +identifier for 32-bit ARM in Android. +While the Android ABI called `armeabi-v7a` does not use VFP PCS as the +__system__ ABI, a definition in `openxr_platform_defines.h` enables the VFP +PCS calling convention for all OpenXR API calls and function pointers. [[runtime-enumeration]] ==== Runtime Enumeration @@ -307,8 +428,8 @@ the registry, as described in <>: enumeration (for example, if hardware configuration, or first time setup hasn't been run by the user yet). -For instance, the OpenXR 1.x runtime used as an example in section <> would add a `DWORD` value in: +For instance, the OpenXR 1.x runtime used as an example in section +<> would add a `DWORD` value in: ``` HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenXR\1\AvailableRuntimes @@ -322,13 +443,14 @@ C:\Windows\system32\my_system_runtime.json And set it to `0`. -All considerations for 32 bit platforms mentioned in section <> still apply. +All considerations for 32 bit platforms mentioned in section +<> still apply. Tools that want to change the currently `ActiveRuntime` should not modify -the list of `AvailableRuntimes`, and just copy the path to the correct +the list of `AvailableRuntimes`, but rather copy the path to the correct location. +[[linux-installed-runtimes-enumeration]] ===== Linux Installed Runtimes Enumeration As previously defined, the OpenXR configuration on Linux is either stored in @@ -337,15 +459,15 @@ directory. Aside from the currently active runtime, installed runtimes that make themselves available for enumeration should install their runtime manifest -into this directory, using any name suitable. +into one of these directories, using any name suitable. Rules about precedence in different directories for runtime enumeration -follow the same rules as in section <> for -selecting the folder containing an `active_runtime.json`. +follow the same rules as in section <> for +selecting the folder containing the active runtime manifest. -Tools that want to change the current `active_runtime.json` should only -update the symlink to the active runtime, and not move, copy or delete any -other files. +Tools that want to change the current active runtime should only update the +`active_runtime.____.json` and/or `active_runtime.json` symlink to the +active runtime, and not move, copy, or delete any other files. [[runtime-manifest-file-format]] ==== Runtime Manifest File Format @@ -768,15 +890,6 @@ The following sections detail the differences between the various versions. ** Requires runtimes to export `xrNegotiateLoaderRuntimeInterface` function. -[[android-runtime-negotiation]] -==== Android Runtime Negotiation ==== - -The Android loader uses the same protocol for initializing the dispatch -table as described above. -The only difference is that the Android loader queries API layer and -extension information directly from the respective libraries and does not -use the json manifest files used by the Windows and Linux loaders. - [[additional-loader-requirements]] === Additional Loader Requirements === diff --git a/specification/registry/xr.xml b/specification/registry/xr.xml index 0fccc5198..add5a2c79 100644 --- a/specification/registry/xr.xml +++ b/specification/registry/xr.xml @@ -62,6 +62,7 @@ maintained in the default branch of the Khronos OpenXR GitHub project. + @@ -131,7 +132,7 @@ maintained in the default branch of the Khronos OpenXR GitHub project. updates them automatically by processing a line at a time. --> // OpenXR current version number. -#define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 28) +#define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 29) typedef XrFlags64 XrPerformanceMetricsCounterFlagsMETA; + + typedef XrFlags64 XrPassthroughPreferenceFlagsMETA; + typedef XrFlags64 XrFoveationDynamicFlagsHTC; @@ -544,6 +548,9 @@ maintained in the default branch of the Khronos OpenXR GitHub project. + + + @@ -1465,11 +1472,14 @@ maintained in the default branch of the Khronos OpenXR GitHub project. XrBlendFactorFB dstFactorAlpha + + typedef void *(*PFN_xrEglGetProcAddressMNDX)(const char *name); + XrStructureType type const void* next - PFNEGLGETPROCADDRESSPROC getProcAddress + PFN_xrEglGetProcAddressMNDX getProcAddress EGLDisplay display EGLConfig config EGLContext context @@ -2859,6 +2869,13 @@ maintained in the default branch of the Khronos OpenXR GitHub project. float floatValue + + + XrStructureType type + const void* next + XrPassthroughPreferenceFlagsMETA flags + + XrStructureType type @@ -4104,6 +4121,11 @@ maintained in the default branch of the Khronos OpenXR GitHub project. + + + + + @@ -5589,6 +5611,13 @@ maintained in the default branch of the Khronos OpenXR GitHub project. XrPerformanceMetricsCounterMETA* counter + + + XrResult xrGetPassthroughPreferencesMETA + XrSession session + XrPassthroughPreferencesMETA* preferences + + XrResult xrApplyFoveationHTC @@ -6063,6 +6092,10 @@ maintained in the default branch of the Khronos OpenXR GitHub project. + + + + @@ -7720,7 +7753,7 @@ maintained in the default branch of the Khronos OpenXR GitHub project. - + @@ -9116,10 +9149,18 @@ maintained in the default branch of the Khronos OpenXR GitHub project. - + - - + + + + + + + + + + @@ -11343,6 +11384,188 @@ maintained in the default branch of the Khronos OpenXR GitHub project. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/specification/scripts/genRef.py b/specification/scripts/genRef.py index b5dfa189a..5a72a6aca 100644 --- a/specification/scripts/genRef.py +++ b/specification/scripts/genRef.py @@ -75,10 +75,12 @@ def printCopyrightSourceComments(fp): Writes an asciidoc comment block, which copyrights the source file.""" + # REUSE-IgnoreStart print('// Copyright 2014-2023 The Khronos Group Inc.', file=fp) print('//', file=fp) # This works around constraints of the 'reuse' tool print('// SPDX' + '-License-Identifier: CC-BY-4.0', file=fp) + # REUSE-IgnoreEnd print('', file=fp) diff --git a/specification/scripts/genxr.py b/specification/scripts/genxr.py index 2ddbda1ef..875de43a0 100755 --- a/specification/scripts/genxr.py +++ b/specification/scripts/genxr.py @@ -105,6 +105,7 @@ def makeGenOpts(args): emitExtensionsPat = makeREstring(emitExtensions, allExtensions) featuresPat = makeREstring(features, allFeatures) + # REUSE-IgnoreStart # Copyright text prefixing all headers (list of strings). prefixStrings = [ '/*', @@ -115,6 +116,7 @@ def makeGenOpts(args): '*/', '' ] + # REUSE-IgnoreEnd # Text specific to OpenXR headers xrPrefixStrings = [ diff --git a/specification/scripts/spec-macros/extension.rb b/specification/scripts/spec-macros/extension.rb index 08f953cac..be76084c3 100644 --- a/specification/scripts/spec-macros/extension.rb +++ b/specification/scripts/spec-macros/extension.rb @@ -270,13 +270,14 @@ class BasetypeInlineMacro < LinkInlineMacroBase named :basetype match /basetype:(\w+)/ - # def process parent, target, attributes - # if parent.document.attributes['cross-file-links'] - # return Inline.new(parent, :anchor, target, :type => :link, :target => (target + '.html')) - # else - # return Inline.new(parent, :anchor, '' + target + '', :type => :xref, :target => ('#' + target), :attributes => {'fragment' => target, 'refid' => target}) - # end - # end + def process parent, target, attributes + node = super parent, target, attributes + if parent.document.attributes['cross-file-links'] + node + else + create_inline parent, :quoted, %(#{node.convert}) + end + end def exists? target $apiNames.basetypes.has_key? target diff --git a/specification/scripts/validitygenerator.py b/specification/scripts/validitygenerator.py index 495ae026d..b121f705e 100644 --- a/specification/scripts/validitygenerator.py +++ b/specification/scripts/validitygenerator.py @@ -1024,6 +1024,8 @@ def makeStructureTypeValidity(self, structname): child_structs = self.keepOnlyRequired(self.struct_children.get(structname, []), self.registry.typedict) if child_structs: + if values: + print('The struct: {} has children, it may not have a "values" attribute itself.'.format(structname)) assert(not values) if len(child_structs) > 1: entry += 'one of the following XrStructureType values: ' diff --git a/specification/scripts/xrconventions.py b/specification/scripts/xrconventions.py index 6fe3d307b..2d59c0c50 100644 --- a/specification/scripts/xrconventions.py +++ b/specification/scripts/xrconventions.py @@ -22,7 +22,7 @@ (?POpenGL(ES)?)| # OpenGL and OpenGLES as words (?P[0-9]D)| # Things like 2D are words (?P # Normal-ish words, which are.... - ([A-Z]([a-z]+([0-9](?!D))*)+)| # Capital letter followed by at least one lowercase letter, possibly ending in some digits as long as the digits aren't followed by "D" + ([A-Z]([a-z]+([0-9](?!D[A-Z]{1}))*)+)| # Capital letter followed by at least one lowercase letter, possibly ending in some digits as long as the digits aren't followed by a "D" then another word ([A-Z][A-Z0-9]+(?![a-z])) # Or, all-caps letter and digit mix starting with a letter, excluding the last capital before some lowercase )''', re.VERBOSE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f8af1a0df..b952079a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -305,12 +305,10 @@ function(compile_glsl run_target_name) endfunction() -if(WIN32) +# Not available in MinGW +if(MSVC) add_definitions(-DXR_USE_GRAPHICS_API_D3D11) - if(MSVC) - # Not available in MinGW right now - add_definitions(-DXR_USE_GRAPHICS_API_D3D12) - endif() + add_definitions(-DXR_USE_GRAPHICS_API_D3D12) endif() # Check for the existence of the secure_getenv or __secure_getenv commands @@ -408,16 +406,34 @@ set(GENERATED_OUTPUT) set(GENERATED_DEPENDS) run_xr_xml_generate(utility_source_generator.py xr_generated_dispatch_table.h) run_xr_xml_generate(utility_source_generator.py xr_generated_dispatch_table.c) -if(GENERATED_DEPENDS) - add_custom_target(xr_global_generated_files DEPENDS ${GENERATED_DEPENDS}) +set(COMMON_GENERATED_OUTPUT ${GENERATED_OUTPUT}) +set(COMMON_GENERATED_DEPENDS ${GENERATED_DEPENDS}) +unset(GENERATED_OUTPUT) +unset(GENERATED_DEPENDS) + +run_xr_xml_generate(utility_source_generator.py xr_generated_dispatch_table_core.h) +run_xr_xml_generate(utility_source_generator.py xr_generated_dispatch_table_core.c) +set(LOADER_GENERATED_OUTPUT ${GENERATED_OUTPUT}) +set(LOADER_GENERATED_DEPENDS ${GENERATED_DEPENDS}) +unset(GENERATED_OUTPUT) +unset(GENERATED_DEPENDS) + +if(LOADER_GENERATED_DEPENDS) + add_custom_target(xr_global_generated_files DEPENDS ${LOADER_GENERATED_DEPENDS}) else() add_custom_target(xr_global_generated_files) endif() set_target_properties(xr_global_generated_files PROPERTIES FOLDER ${CODEGEN_FOLDER}) -set(COMMON_GENERATED_OUTPUT ${GENERATED_OUTPUT}) -set(COMMON_GENERATED_DEPENDS ${GENERATED_DEPENDS}) +if(COMMON_GENERATED_DEPENDS) + add_custom_target(xr_common_generated_files DEPENDS ${COMMON_GENERATED_DEPENDS}) +else() + add_custom_target(xr_common_generated_files) +endif() + +set_target_properties(xr_common_generated_files PROPERTIES FOLDER ${CODEGEN_FOLDER}) + if(NOT MSVC) include(CheckCXXCompilerFlag) include(CheckCCompilerFlag) diff --git a/src/api_layers/CMakeLists.txt b/src/api_layers/CMakeLists.txt index 348b6d978..9bd00b132 100644 --- a/src/api_layers/CMakeLists.txt +++ b/src/api_layers/CMakeLists.txt @@ -67,6 +67,10 @@ run_xr_xml_generate(api_dump_generator.py xr_generated_api_dump.hpp ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/automatic_source_generator.py) run_xr_xml_generate(api_dump_generator.py xr_generated_api_dump.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/automatic_source_generator.py) +set(API_DUMP_GENERATED_OUTPUT ${GENERATED_OUTPUT}) +set(API_DUMP_GENERATED_DEPENDS ${GENERATED_DEPENDS}) +unset(GENERATED_OUTPUT) +unset(GENERATED_DEPENDS) add_library(XrApiLayer_api_dump SHARED api_dump.cpp @@ -74,7 +78,7 @@ add_library(XrApiLayer_api_dump SHARED ${PROJECT_SOURCE_DIR}/src/common/hex_and_handles.h # target-specific generated files - ${GENERATED_OUTPUT} + ${API_DUMP_GENERATED_OUTPUT} # Dispatch table ${COMMON_GENERATED_OUTPUT} @@ -88,7 +92,7 @@ target_link_libraries(XrApiLayer_api_dump PRIVATE Threads::Threads OpenXR::heade target_compile_definitions(XrApiLayer_api_dump PRIVATE ${OPENXR_ALL_SUPPORTED_DEFINES}) add_dependencies(XrApiLayer_api_dump generate_openxr_header - xr_global_generated_files + xr_common_generated_files ) target_include_directories(XrApiLayer_api_dump @@ -131,6 +135,10 @@ run_xr_xml_generate(validation_layer_generator.py xr_generated_core_validation.h ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/automatic_source_generator.py) run_xr_xml_generate(validation_layer_generator.py xr_generated_core_validation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/automatic_source_generator.py) +set(CORE_VALIDATION_GENERATED_OUTPUT ${GENERATED_OUTPUT}) +set(CORE_VALIDATION_GENERATED_DEPENDS ${GENERATED_DEPENDS}) +unset(GENERATED_OUTPUT) +unset(GENERATED_DEPENDS) add_library(XrApiLayer_core_validation SHARED core_validation.cpp @@ -141,7 +149,7 @@ add_library(XrApiLayer_core_validation SHARED ${PROJECT_SOURCE_DIR}/src/common/object_info.h # target-specific generated files - ${GENERATED_OUTPUT} + ${CORE_VALIDATION_GENERATED_OUTPUT} # Dispatch table ${COMMON_GENERATED_OUTPUT} @@ -155,7 +163,7 @@ target_link_libraries(XrApiLayer_core_validation PRIVATE Threads::Threads OpenXR target_compile_definitions(XrApiLayer_core_validation PRIVATE ${OPENXR_ALL_SUPPORTED_DEFINES}) add_dependencies(XrApiLayer_core_validation generate_openxr_header - xr_global_generated_files + xr_common_generated_files ) target_include_directories(XrApiLayer_core_validation PRIVATE diff --git a/src/api_layers/core_validation.cpp b/src/api_layers/core_validation.cpp index c81f50c4a..11116e14f 100644 --- a/src/api_layers/core_validation.cpp +++ b/src/api_layers/core_validation.cpp @@ -792,11 +792,13 @@ XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSessionBeginDebugUtilsLabelRegion if (XR_SUCCESS != test_result) { return test_result; } - auto info_with_lock = g_session_info.getWithLock(session); - if (info_with_lock.second != nullptr) { - GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second->instance_info; - if (nullptr != gen_instance_info) { - gen_instance_info->debug_data.BeginLabelRegion(session, *labelInfo); + { + auto info_with_lock = g_session_info.getWithLock(session); + if (info_with_lock.second != nullptr) { + GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second->instance_info; + if (nullptr != gen_instance_info) { + gen_instance_info->debug_data.BeginLabelRegion(session, *labelInfo); + } } } return GenValidUsageNextXrSessionBeginDebugUtilsLabelRegionEXT(session, labelInfo); @@ -807,11 +809,13 @@ XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSessionEndDebugUtilsLabelRegionEX if (XR_SUCCESS != test_result) { return test_result; } - auto info_with_lock = g_session_info.getWithLock(session); - if (info_with_lock.second != nullptr) { - GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second->instance_info; - if (nullptr != gen_instance_info) { - gen_instance_info->debug_data.EndLabelRegion(session); + { + auto info_with_lock = g_session_info.getWithLock(session); + if (info_with_lock.second != nullptr) { + GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second->instance_info; + if (nullptr != gen_instance_info) { + gen_instance_info->debug_data.EndLabelRegion(session); + } } } return GenValidUsageNextXrSessionEndDebugUtilsLabelRegionEXT(session); @@ -823,11 +827,13 @@ XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrSessionInsertDebugUtilsLabelEXT(X if (XR_SUCCESS != test_result) { return test_result; } - auto info_with_lock = g_session_info.getWithLock(session); - if (info_with_lock.second != nullptr) { - GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second->instance_info; - if (nullptr != gen_instance_info) { - gen_instance_info->debug_data.InsertLabel(session, *labelInfo); + { + auto info_with_lock = g_session_info.getWithLock(session); + if (info_with_lock.second != nullptr) { + GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second->instance_info; + if (nullptr != gen_instance_info) { + gen_instance_info->debug_data.InsertLabel(session, *labelInfo); + } } } return GenValidUsageNextXrSessionInsertDebugUtilsLabelEXT(session, labelInfo); diff --git a/src/common/gfxwrapper_opengl.c b/src/common/gfxwrapper_opengl.c index 8b5c08990..413dc5143 100644 --- a/src/common/gfxwrapper_opengl.c +++ b/src/common/gfxwrapper_opengl.c @@ -1,4 +1,5 @@ /* +Copyright (c) 2017-2023, The Khronos Group Inc. Copyright (c) 2016 Oculus VR, LLC. Portions of macOS, iOS, functionality copyright (c) 2016 The Brenwill Workshop Ltd. diff --git a/src/common/gfxwrapper_opengl.h b/src/common/gfxwrapper_opengl.h index a4c245d31..6d8e1518e 100644 --- a/src/common/gfxwrapper_opengl.h +++ b/src/common/gfxwrapper_opengl.h @@ -1,35 +1,33 @@ +// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2016, Oculus VR, LLC. +// Portions of macOS, iOS, functionality copyright (c) 2016, The Brenwill Workshop Ltd. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* REUSE-IgnoreStart */ +/* The following has copyright notices that duplicate the header above */ + /* ================================================================================================ -Description : Convenient wrapper for the OpenGL API. -Author : J.M.P. van Waveren -Date : 12/21/2014 -Language : C99 -Format : Real tabs with the tab size equal to 4 spaces. -Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved. - : Portions copyright (c) 2016 The Brenwill Workshop Ltd. All Rights reserved. - - -LICENSE -======= - -Copyright (c) 2016 Oculus VR, LLC. -Portions of macOS, iOS, functionality copyright (c) 2016 The Brenwill Workshop Ltd. - -SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - +Description : Convenient wrapper for the OpenGL API. +Orig. Author : J.M.P. van Waveren +Orig. Date : 12/21/2014 +Language : C99 +Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved. + : Portions copyright (c) 2016 The Brenwill Workshop Ltd. All Rights reserved. IMPLEMENTATION ============== diff --git a/src/common/platform_utils.hpp b/src/common/platform_utils.hpp index 219d19789..883baef82 100644 --- a/src/common/platform_utils.hpp +++ b/src/common/platform_utils.hpp @@ -37,6 +37,44 @@ #include "common_config.h" #endif // OPENXR_HAVE_COMMON_CONFIG +#if defined(__x86_64__) && defined(__ILP32__) +#define XR_ARCH_ABI "x32" +#elif defined(_M_X64) || defined(__x86_64__) +#define XR_ARCH_ABI "x86_64" +#elif defined(_M_IX86) || defined(__i386__) || defined(_X86_) +#define XR_ARCH_ABI "i686" +#elif (defined(__aarch64__) && defined(__LP64__)) || defined(_M_ARM64) +#define XR_ARCH_ABI "aarch64" +#elif (defined(__ARM_ARCH) && __ARM_ARCH >= 7 && (defined(__ARM_PCS_VFP) || defined(__ANDROID__))) || defined(_M_ARM) +#define XR_ARCH_ABI "armv7a-vfp" +#elif defined(__ARM_ARCH_5TE__) +#define XR_ARCH_ABI "armv5te" +#elif defined(__mips64) +#define XR_ARCH_ABI "mips64" +#elif defined(__mips) +#define XR_ARCH_ABI "mips" +#elif defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define XR_ARCH_ABI "ppc64" +#elif defined(__powerpc__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define XR_ARCH_ABI "ppc64el" +#elif defined(__s390x__) || defined(__zarch__) +#define XR_ARCH_ABI "s390x" +#elif defined(__hppa__) +#define XR_ARCH_ABI "hppa" +#elif defined(__alpha__) +#define XR_ARCH_ABI "alpha" +#elif defined(__ia64__) || defined(_M_IA64) +#define XR_ARCH_ABI "ia64" +#elif defined(__m68k__) +#define XR_ARCH_ABI "m68k" +#elif defined(__riscv_xlen) && (__riscv_xlen == 64) +#define XR_ARCH_ABI "riscv64" +#elif defined(__sparc__) && defined(__arch64__) +#define XR_ARCH_ABI "sparc64" +#else +#error "No architecture string known!" +#endif + // Consumers of this file must ensure this function is implemented. For example, the loader will implement this function so that it // can route messages through the loader's logging system. void LogPlatformUtilsError(const std::string& message); @@ -47,6 +85,7 @@ void LogPlatformUtilsError(const std::string& message); #include #include #include +#include namespace detail { @@ -72,6 +111,31 @@ static inline char* ImplGetSecureEnv(const char* name) { } // namespace detail #endif // defined(XR_OS_LINUX) || defined(XR_OS_APPLE) + +#if defined(XR_OS_ANDROID) || defined(XR_OS_APPLE) + +#include + +namespace detail { + +static inline bool ImplTryRuntimeFilename(const char* rt_dir_prefix, uint16_t major_version, std::string& file_name) { + auto decorated_path = rt_dir_prefix + std::to_string(major_version) + "/active_runtime." XR_ARCH_ABI ".json"; + auto undecorated_path = rt_dir_prefix + std::to_string(major_version) + "/active_runtime.json"; + + struct stat buf {}; + if (0 == stat(decorated_path.c_str(), &buf)) { + file_name = decorated_path; + return true; + } + if (0 == stat(undecorated_path.c_str(), &buf)) { + file_name = undecorated_path; + return true; + } + return false; +} + +} // namespace detail +#endif // defined(XR_OS_ANDROID) || defined(XR_OS_APPLE) #if defined(XR_OS_LINUX) static inline std::string PlatformUtilsGetEnv(const char* name) { @@ -130,15 +194,8 @@ static inline bool PlatformUtilsSetEnv(const char* name, const char* value) { return (result == 0); } -// Prefix for the Apple global runtime JSON file name -static const std::string rt_dir_prefix = "/usr/local/share/openxr/"; -static const std::string rt_filename = "/active_runtime.json"; - static inline bool PlatformGetGlobalRuntimeFileName(uint16_t major_version, std::string& file_name) { - file_name = rt_dir_prefix; - file_name += std::to_string(major_version); - file_name += rt_filename; - return true; + return detail::ImplTryRuntimeFilename("/usr/local/share/openxr/", major_version, file_name); } #elif defined(XR_OS_WINDOWS) @@ -311,22 +368,19 @@ static inline bool PlatformUtilsSetEnv(const char* /* name */, const char* /* va return false; } -#include - // Intended to be only used as a fallback on Android, with a more open, "native" technique used in most cases static inline bool PlatformGetGlobalRuntimeFileName(uint16_t major_version, std::string& file_name) { // Prefix for the runtime JSON file name static const char* rt_dir_prefixes[] = {"/product", "/odm", "/oem", "/vendor", "/system"}; - static const std::string rt_filename = "/active_runtime.json"; + static const std::string subdir = "/etc/openxr/"; for (const auto prefix : rt_dir_prefixes) { - auto path = prefix + subdir + std::to_string(major_version) + rt_filename; - struct stat buf; - if (0 == stat(path.c_str(), &buf)) { - file_name = path; + const std::string rt_dir_prefix = prefix + subdir; + if (detail::ImplTryRuntimeFilename(rt_dir_prefix.c_str(), major_version, file_name)) { return true; } } + return false; } #else // Not Linux, Apple, nor Windows diff --git a/src/common/xr_dependencies.h b/src/common/xr_dependencies.h index 5c7bd0477..6c9cf2d05 100644 --- a/src/common/xr_dependencies.h +++ b/src/common/xr_dependencies.h @@ -76,7 +76,10 @@ #include "wayland-client.h" #endif // XR_USE_PLATFORM_WAYLAND -#ifdef XR_USE_GRAPHICS_API_OPENGL +#ifdef XR_USE_PLATFORM_EGL +#include +#endif // XR_USE_PLATFORM_EGL + #if defined(XR_USE_PLATFORM_XLIB) || defined(XR_USE_PLATFORM_XCB) #ifdef Success #undef Success @@ -90,4 +93,3 @@ #undef None #endif // None #endif // defined(XR_USE_PLATFORM_XLIB) || defined(XR_USE_PLATFORM_XCB) -#endif // XR_USE_GRAPHICS_API_OPENGL diff --git a/src/common/xr_linear.h b/src/common/xr_linear.h index 5b0da645a..ce65f8ddf 100644 --- a/src/common/xr_linear.h +++ b/src/common/xr_linear.h @@ -1,5 +1,5 @@ -// Copyright (c) 2017 The Khronos Group Inc. -// Copyright (c) 2016 Oculus VR, LLC. +// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2016, Oculus VR, LLC. // // SPDX-License-Identifier: Apache-2.0 // @@ -23,15 +23,17 @@ #include +/* REUSE-IgnoreStart */ +/* The following has copyright notices that duplicate the header above */ + /* ================================================================================================ -Description : Vector, matrix and quaternion math. -Author : J.M.P. van Waveren -Date : 12/10/2016 -Language : C99 -Format : Indent 4 spaces - no tabs. -Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved. +Description : Vector, matrix and quaternion math. +Orig. Author : J.M.P. van Waveren +Orig. Date : 12/10/2016 +Language : C99 +Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved. DESCRIPTION @@ -145,6 +147,8 @@ inline static float XrRcpSqrt(const float x) { return rcp; } +inline static float XrVector2f_Length(const XrVector2f* v) { return sqrtf(v->x * v->x + v->y * v->y); } + inline static void XrVector3f_Set(XrVector3f* v, const float value) { v->x = value; v->y = value; diff --git a/src/loader/.gitignore b/src/loader/.gitignore index 5e8e0ba3a..be1be1af1 100644 --- a/src/loader/.gitignore +++ b/src/loader/.gitignore @@ -1,4 +1,4 @@ -# Copyright (c) 2020 The Khronos Group Inc. +# Copyright (c) 2020-2023, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/loader/AndroidManifest.xml b/src/loader/AndroidManifest.xml index 2817b34ad..0c151c63b 100644 --- a/src/loader/AndroidManifest.xml +++ b/src/loader/AndroidManifest.xml @@ -2,7 +2,7 @@ package="org.khronos.openxr.openxr_loader_for_android"> diff --git a/src/loader/AndroidManifest.xml.in b/src/loader/AndroidManifest.xml.in index 9bd8a4602..291a1e2d5 100644 --- a/src/loader/AndroidManifest.xml.in +++ b/src/loader/AndroidManifest.xml.in @@ -4,7 +4,7 @@ android:versionName="${OPENXR_FULL_VERSION}${OPENXR_ANDROID_VERSION_SUFFIX}"> diff --git a/src/loader/CMakeLists.txt b/src/loader/CMakeLists.txt index 22047fbc7..a98d38087 100644 --- a/src/loader/CMakeLists.txt +++ b/src/loader/CMakeLists.txt @@ -31,8 +31,8 @@ include(GNUInstallDirs) # List of all files externally generated outside of the loader that the loader # needs to build with. -set(LOADER_EXTERNAL_GEN_FILES ${COMMON_GENERATED_OUTPUT}) -set(LOADER_EXTERNAL_GEN_DEPENDS ${COMMON_GENERATED_DEPENDS}) +set(LOADER_EXTERNAL_GEN_FILES ${LOADER_GENERATED_OUTPUT}) +set(LOADER_EXTERNAL_GEN_DEPENDS ${LOADER_GENERATED_DEPENDS}) run_xr_xml_generate(loader_source_generator.py xr_generated_loader.hpp) run_xr_xml_generate(loader_source_generator.py xr_generated_loader.cpp) diff --git a/src/loader/abi.json.license b/src/loader/abi.json.license index ae931a242..924b9735f 100644 --- a/src/loader/abi.json.license +++ b/src/loader/abi.json.license @@ -1,2 +1,3 @@ -Copyright (c) 2020 The Khronos Group Inc. -SPDX-License-Identifier: Apache-2.0 +Copyright (c) 2020-2023, The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0 OR MIT diff --git a/src/loader/loader.rc b/src/loader/loader.rc index 8f36b13bb..fd6465807 100644 --- a/src/loader/loader.rc +++ b/src/loader/loader.rc @@ -8,10 +8,17 @@ // Initial Author: Mark Young // +// The years here should always match the Khronos line above! +#define COPYRIGHT_NOTICE "2017-2023, The Khronos Group Inc. and others" + +// REUSE-IgnoreStart + /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // Start customize section // Edit this section for your build +// The normal OpenXR CMake build will define the XR_CURRENT_API_*_VERSION +// symbols automatically so no manual changes are needed in that case. /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// @@ -63,7 +70,7 @@ BEGIN BEGIN VALUE "FileDescription", "OpenXR Loader" VALUE "FileVersion", VER_FILE_VERSION_STR - VALUE "LegalCopyright", "Copyright (C) 2015-2020" + VALUE "LegalCopyright", "Copyright (C) " COPYRIGHT_NOTICE VALUE "ProductName", "OpenXR Loader" VALUE "ProductVersion", VER_FILE_VERSION_STR END diff --git a/src/loader/loader_core.cpp b/src/loader/loader_core.cpp index 98d3fa971..06e687005 100644 --- a/src/loader/loader_core.cpp +++ b/src/loader/loader_core.cpp @@ -19,7 +19,7 @@ #include "loader_logger.hpp" #include "loader_platform.hpp" #include "runtime_interface.hpp" -#include "xr_generated_dispatch_table.h" +#include "xr_generated_dispatch_table_core.h" #include "xr_generated_loader.hpp" #include diff --git a/src/loader/loader_instance.cpp b/src/loader/loader_instance.cpp index badd39193..ce5c20550 100644 --- a/src/loader/loader_instance.cpp +++ b/src/loader/loader_instance.cpp @@ -18,7 +18,7 @@ #include "loader_interfaces.h" #include "loader_logger.hpp" #include "runtime_interface.hpp" -#include "xr_generated_dispatch_table.h" +#include "xr_generated_dispatch_table_core.h" #include "xr_generated_loader.hpp" #include diff --git a/src/loader/manifest_file.cpp b/src/loader/manifest_file.cpp index 99f4e8410..0683bc166 100644 --- a/src/loader/manifest_file.cpp +++ b/src/loader/manifest_file.cpp @@ -274,16 +274,45 @@ static std::string GetXDGEnvAbsolute(const char *name, const char *fallback_path return fallback_paths; } +/// @param rt_dir_prefix Directory prefix with a trailing slash +static bool FindEitherActiveRuntimeFilename(const char *prefix_desc, const std::string &rt_dir_prefix, uint16_t major_version, + std::string &out) { + { + std::ostringstream oss; + oss << "Looking for active_runtime." XR_ARCH_ABI ".json or active_runtime.json in "; + oss << prefix_desc; + oss << ": "; + oss << rt_dir_prefix; + + LoaderLogger::LogInfoMessage("", oss.str()); + } + { + auto decorated_path = rt_dir_prefix + std::to_string(major_version) + "/active_runtime." XR_ARCH_ABI ".json"; + + if (FileSysUtilsPathExists(decorated_path)) { + out = decorated_path; + return true; + } + } + { + auto undecorated_path = rt_dir_prefix + std::to_string(major_version) + "/active_runtime.json"; + + if (FileSysUtilsPathExists(undecorated_path)) { + out = undecorated_path; + return true; + } + } + return false; +} // Return the first instance of relative_path occurring in an XDG config dir according to standard // precedence order. -static bool FindXDGConfigFile(const std::string &relative_path, std::string &out) { - out = GetXDGEnvHome("XDG_CONFIG_HOME", ".config"); - if (!out.empty()) { - out += "/"; - out += relative_path; - - LoaderLogger::LogInfoMessage("", "Looking for " + relative_path + " in XDG_CONFIG_HOME: " + out); - if (FileSysUtilsPathExists(out)) { +static bool FindXDGConfigFile(const char *relative_dir, uint16_t major_version, std::string &out) { + const std::string message{"Looking for active_runtime." XR_ARCH_ABI ".json or active_runtime.json"}; + std::string dir_prefix = GetXDGEnvHome("XDG_CONFIG_HOME", ".config"); + if (!dir_prefix.empty()) { + dir_prefix += "/"; + dir_prefix += relative_dir; + if (FindEitherActiveRuntimeFilename("XDG_CONFIG_HOME", dir_prefix, major_version, out)) { return true; } } @@ -294,29 +323,26 @@ static bool FindXDGConfigFile(const std::string &relative_path, std::string &out if (path.empty()) { continue; } - out = path; - out += "/"; - out += relative_path; - LoaderLogger::LogInfoMessage("", "Looking for " + relative_path + " in an entry of XDG_CONFIG_DIRS: " + out); - if (FileSysUtilsPathExists(out)) { + dir_prefix = std::move(path); + dir_prefix += "/"; + dir_prefix += relative_dir; + if (FindEitherActiveRuntimeFilename("an entry of XDG_CONFIG_DIRS", dir_prefix, major_version, out)) { return true; } } - out = SYSCONFDIR; - out += "/"; - out += relative_path; - LoaderLogger::LogInfoMessage("", "Looking for " + relative_path + " in compiled-in SYSCONFDIR: " + out); - if (FileSysUtilsPathExists(out)) { + dir_prefix = SYSCONFDIR; + dir_prefix += "/"; + dir_prefix += relative_dir; + if (FindEitherActiveRuntimeFilename("compiled-in SYSCONFDIR", dir_prefix, major_version, out)) { return true; } #if defined(EXTRASYSCONFDIR) - out = EXTRASYSCONFDIR; - out += "/"; - out += relative_path; - LoaderLogger::LogInfoMessage("", "Looking for " + relative_path + " in compiled-in EXTRASYSCONFDIR: " + out); - if (FileSysUtilsPathExists(out)) { + dir_prefix = EXTRASYSCONFDIR; + dir_prefix += "/"; + dir_prefix += relative_dir; + if (FindEitherActiveRuntimeFilename("compiled-in EXTRASYSCONFDIR", dir_prefix, major_version, out)) { return true; } #endif @@ -632,9 +658,8 @@ XrResult RuntimeManifestFile::FindManifestFiles(std::vector @@ -29,6 +29,10 @@ #include "android_utilities.h" #include #include + +// Needed for the loader init struct +#include +#include #endif // XR_USE_PLATFORM_ANDROID #ifdef XR_KHR_LOADER_INIT_SUPPORT @@ -105,33 +109,22 @@ XrResult LoaderInitData::initialize(const XrLoaderInitInfoBaseHeaderKHR* info) { if (cast_info->applicationContext == nullptr) { return XR_ERROR_VALIDATION_FAILURE; } + + // Copy and store the JVM pointer and Android Context, ensuring the JVM is initialised. _data = *cast_info; - jni::init((jni::JavaVM*)_data.applicationVM); _data.next = nullptr; - JNIEnv* Env; - ((jni::JavaVM*)(cast_info->applicationVM))->AttachCurrentThread(&Env, nullptr); - const jclass contextClass = Env->GetObjectClass((jobject)_data.applicationContext); - - const jmethodID getAssetsMethod = Env->GetMethodID(contextClass, "getAssets", "()Landroid/content/res/AssetManager;"); - const jobject AssetManagerObject = Env->CallObjectMethod((jobject)_data.applicationContext, getAssetsMethod); - _android_asset_manager = AAssetManager_fromJava(Env, AssetManagerObject); - - const jmethodID getApplicationContextMethod = - Env->GetMethodID(contextClass, "getApplicationContext", "()Landroid/content/Context;"); - const jobject contextObject = Env->CallObjectMethod((jobject)_data.applicationContext, getApplicationContextMethod); - const jmethodID getApplicationInfoMethod = - Env->GetMethodID(contextClass, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;"); - const jobject applicationInfoObject = Env->CallObjectMethod(contextObject, getApplicationInfoMethod); - const jfieldID nativeLibraryDirField = - Env->GetFieldID(Env->GetObjectClass(applicationInfoObject), "nativeLibraryDir", "Ljava/lang/String;"); - const jobject nativeLibraryDirObject = Env->GetObjectField(applicationInfoObject, nativeLibraryDirField); - const jmethodID getBytesMethod = - Env->GetMethodID(Env->GetObjectClass(nativeLibraryDirObject), "getBytes", "(Ljava/lang/String;)[B"); - const auto bytesObject = - static_cast(Env->CallObjectMethod(nativeLibraryDirObject, getBytesMethod, Env->NewStringUTF("UTF-8"))); - const size_t length = Env->GetArrayLength(bytesObject); - const jbyte* const bytes = Env->GetByteArrayElements(bytesObject, nullptr); - _native_library_path = std::string(reinterpret_cast(bytes), length); + jni::init(static_cast(_data.applicationVM)); + const jni::Object context = jni::Object{static_cast(_data.applicationContext)}; + + // Retrieve a reference to the Android AssetManager. + const auto assetManager = context.call("getAssets()Landroid/content/res/AssetManager;"); + _android_asset_manager = AAssetManager_fromJava(jni::env(), assetManager.getHandle()); + + // Retrieve the path to the native libraries. + const auto applicationContext = context.call("getApplicationContext()Landroid/content/Context;"); + const auto applicationInfo = context.call("getApplicationInfo()Landroid/content/pm/ApplicationInfo;"); + _native_library_path = applicationInfo.get("nativeLibraryDir"); + _initialized = true; return XR_SUCCESS; } diff --git a/src/scripts/generate_api_layer_manifest.py b/src/scripts/generate_api_layer_manifest.py index 04013fdd6..fc843f3cf 100755 --- a/src/scripts/generate_api_layer_manifest.py +++ b/src/scripts/generate_api_layer_manifest.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright (c) 2017 The Khronos Group Inc. +# Copyright (c) 2017-2023, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/src/scripts/loader_source_generator.py b/src/scripts/loader_source_generator.py index 29eef0302..188865c03 100755 --- a/src/scripts/loader_source_generator.py +++ b/src/scripts/loader_source_generator.py @@ -81,6 +81,7 @@ def getProto(self, cur_cmd): # self the LoaderSourceOutputGenerator object def outputGeneratedHeaderWarning(self): + # REUSE-IgnoreStart generated_warning = '' generated_warning += '// Copyright (c) 2017-2023, The Khronos Group Inc.\n' generated_warning += '// Copyright (c) 2017-2019 Valve Corporation\n' @@ -90,6 +91,7 @@ def outputGeneratedHeaderWarning(self): generated_warning += '// *********** THIS FILE IS GENERATED - DO NOT EDIT ***********\n' generated_warning += '// See loader_source_generator.py for modifications\n' generated_warning += '// ************************************************************\n' + # REUSE-IgnoreEnd write(generated_warning, file=self.outFile) # Call the base class to properly begin the file, and then add @@ -121,7 +123,7 @@ def beginFile(self, genOpts): preamble += '#include "loader_logger.hpp"\n' preamble += '#include "loader_platform.hpp"\n' preamble += '#include "runtime_interface.hpp"\n' - preamble += '#include "xr_generated_dispatch_table.h"\n\n' + preamble += '#include "xr_generated_dispatch_table_core.h"\n\n' preamble += '#include "xr_dependencies.h"\n' preamble += '#include \n' diff --git a/src/scripts/src_genxr.py b/src/scripts/src_genxr.py index 6bab4654d..922e9d90c 100755 --- a/src/scripts/src_genxr.py +++ b/src/scripts/src_genxr.py @@ -96,6 +96,7 @@ def makeGenOpts(args): emitExtensionsPat = makeREstring(emitExtensions, allExtensions) featuresPat = makeREstring(features, allFeatures) + # REUSE-IgnoreStart # Copyright text prefixing all headers (list of strings). prefixStrings = [ '/*', @@ -115,6 +116,7 @@ def makeGenOpts(args): '*/', '' ] + # REUSE-IgnoreEnd # Text specific to OpenXR headers xrPrefixStrings = [ @@ -191,37 +193,29 @@ def makeGenOpts(args): apientryp = 'XRAPI_PTR *',) ] - genOpts['xr_generated_dispatch_table.h'] = [ - UtilitySourceOutputGenerator, - AutomaticSourceGeneratorOptions( - conventions = conventions, - filename = 'xr_generated_dispatch_table.h', - directory = directory, - apiname = 'openxr', - profile = None, - versions = featuresPat, - emitversions = featuresPat, - defaultExtensions = 'openxr', - addExtensions = None, - removeExtensions = None, - emitExtensions = emitExtensionsPat) - ] + DISPATCH_TABLE_FILES = [ + 'xr_generated_dispatch_table.h', + 'xr_generated_dispatch_table.c', + 'xr_generated_dispatch_table_core.h', + 'xr_generated_dispatch_table_core.c', + ] - genOpts['xr_generated_dispatch_table.c'] = [ - UtilitySourceOutputGenerator, - AutomaticSourceGeneratorOptions( - conventions = conventions, - filename = 'xr_generated_dispatch_table.c', - directory = directory, - apiname = 'openxr', - profile = None, - versions = featuresPat, - emitversions = featuresPat, - defaultExtensions = 'openxr', - addExtensions = None, - removeExtensions = None, - emitExtensions = emitExtensionsPat) - ] + for filename in DISPATCH_TABLE_FILES: + genOpts[filename] = [ + UtilitySourceOutputGenerator, + AutomaticSourceGeneratorOptions( + conventions = conventions, + filename = filename, + directory = directory, + apiname = 'openxr', + profile = None, + versions = featuresPat, + emitversions = featuresPat, + defaultExtensions = 'openxr', + addExtensions = None, + removeExtensions = None, + emitExtensions = emitExtensionsPat) + ] genOpts['xr_generated_loader.hpp'] = [ LoaderSourceOutputGenerator, diff --git a/src/scripts/utility_source_generator.py b/src/scripts/utility_source_generator.py index c57286970..9ecb0c6b6 100755 --- a/src/scripts/utility_source_generator.py +++ b/src/scripts/utility_source_generator.py @@ -29,15 +29,17 @@ class UtilitySourceOutputGenerator(AutomaticSourceOutputGenerator): # Override the base class header warning so the comment indicates this file. # self the UtilitySourceOutputGenerator object def outputGeneratedHeaderWarning(self): + # REUSE-IgnoreStart generated_warning = '' generated_warning += '// Copyright (c) 2017-2023, The Khronos Group Inc.\n' - generated_warning += '// Copyright (c) 2017-2019 Valve Corporation\n' - generated_warning += '// Copyright (c) 2017-2019 LunarG, Inc.\n' + generated_warning += '// Copyright (c) 2017-2019, Valve Corporation\n' + generated_warning += '// Copyright (c) 2017-2019, LunarG, Inc.\n\n' # Broken string is to avoid confusing the REUSE tool here. - generated_warning += '// SPDX-License-' + 'Identifier: Apache-2.0 OR MIT\n' + generated_warning += '// SPDX-License-' + 'Identifier: Apache-2.0 OR MIT\n\n' generated_warning += '// *********** THIS FILE IS GENERATED - DO NOT EDIT ***********\n' generated_warning += '// See utility_source_generator.py for modifications\n' generated_warning += '// ************************************************************\n' + # REUSE-IgnoreEnd write(generated_warning, file=self.outFile) # Call the base class to properly begin the file, and then add @@ -47,15 +49,24 @@ def outputGeneratedHeaderWarning(self): def beginFile(self, genOpts): AutomaticSourceOutputGenerator.beginFile(self, genOpts) preamble = '' - if self.genOpts.filename == 'xr_generated_dispatch_table.h': - preamble += '#pragma once\n' + if self.genOpts.filename == 'xr_generated_dispatch_table_core.h': + preamble += '#pragma once\n\n' + preamble += '#include \n' + elif self.genOpts.filename == 'xr_generated_dispatch_table.h': + preamble += '#pragma once\n\n' + preamble += '#include "xr_dependencies.h"\n' + preamble += '#include \n' + preamble += '#include \n' + elif self.genOpts.filename == 'xr_generated_dispatch_table_core.c': + preamble += '#include "xr_generated_dispatch_table_core.h"\n' elif self.genOpts.filename == 'xr_generated_dispatch_table.c': preamble += '#include \n' preamble += '#include "xr_generated_dispatch_table.h"\n' + else: + raise RuntimeError("Unknown filename! " + self.genOpts.filename) + + preamble += '\n' - preamble += '#include "xr_dependencies.h"\n' - preamble += '#include \n' - preamble += '#include \n\n' write(preamble, file=self.outFile) # Write out all the information for the appropriate file, @@ -68,9 +79,14 @@ def endFile(self): file_data += 'extern "C" { \n' file_data += '#endif\n' - if self.genOpts.filename == 'xr_generated_dispatch_table.h': + if self.genOpts.filename == 'xr_generated_dispatch_table_core.h': file_data += self.outputDispatchTable() file_data += self.outputDispatchPrototypes() + elif self.genOpts.filename == 'xr_generated_dispatch_table.h': + file_data += self.outputDispatchTable() + file_data += self.outputDispatchPrototypes() + elif self.genOpts.filename == 'xr_generated_dispatch_table_core.c': + file_data += self.outputDispatchTableHelper() elif self.genOpts.filename == 'xr_generated_dispatch_table.c': file_data += self.outputDispatchTableHelper() else: @@ -115,6 +131,16 @@ def outputDispatchTable(self): commands = self.ext_commands for cur_cmd in commands: + if self.genOpts.filename == 'xr_generated_dispatch_table_core.h': + if self.isCoreExtensionName(cur_cmd.ext_name): + pass + # Loader implements XR_EXT_debug_utils + elif cur_cmd.ext_name == 'XR_EXT_debug_utils': + pass + else: + # Skip anything that is not core or XR_EXT_debug_utils in the loader dispatch table + continue + # If we've switched to a new "feature" print out a comment on what it is. Usually, # this is a group of core commands or a group of commands in an extension. if cur_cmd.ext_name != cur_extension_name: @@ -168,6 +194,16 @@ def outputDispatchTableHelper(self): if cur_cmd.name in self.no_trampoline_or_terminator: continue + if self.genOpts.filename == 'xr_generated_dispatch_table_core.c': + if self.isCoreExtensionName(cur_cmd.ext_name): + pass + # Loader implements XR_EXT_debug_utils + elif cur_cmd.ext_name == 'XR_EXT_debug_utils': + pass + else: + # Skip anything that is not core or XR_EXT_debug_utils in the loader dispatch table + continue + # If we've switched to a new "feature" print out a comment on what it is. Usually, # this is a group of core commands or a group of commands in an extension. if cur_cmd.ext_name != cur_extension_name: diff --git a/src/scripts/validation_layer_generator.py b/src/scripts/validation_layer_generator.py index c928838d6..c037afcc7 100644 --- a/src/scripts/validation_layer_generator.py +++ b/src/scripts/validation_layer_generator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2017 The Khronos Group Inc. +# Copyright (c) 2017-2023, The Khronos Group Inc. # Copyright (c) 2017 Valve Corporation # Copyright (c) 2017 LunarG, Inc. # diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index d4b367966..9fb27a5f8 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -17,12 +17,13 @@ # Author: # +add_subdirectory(c_compile_test) add_subdirectory(hello_xr) add_subdirectory(list_json) + if(NOT ANDROID) - add_subdirectory(c_compile_test) add_subdirectory(list) - if(BUILD_LOADER) + if(BUILD_LOADER AND BUILD_API_LAYERS) add_subdirectory(loader_test) endif() endif() diff --git a/src/tests/c_compile_test/AndroidManifest.xml b/src/tests/c_compile_test/AndroidManifest.xml new file mode 100644 index 000000000..5785d0849 --- /dev/null +++ b/src/tests/c_compile_test/AndroidManifest.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/tests/c_compile_test/CMakeLists.txt b/src/tests/c_compile_test/CMakeLists.txt index 0c9ed69a3..b9e55d9ac 100644 --- a/src/tests/c_compile_test/CMakeLists.txt +++ b/src/tests/c_compile_test/CMakeLists.txt @@ -15,9 +15,20 @@ # limitations under the License. # -add_executable(openxr_c_compile_test - main.c -) +if(ANDROID) + add_library(openxr_c_compile_test MODULE + main.c + $ + ) + target_link_libraries(openxr_c_compile_test ${ANDROID_LIBRARY} ${ANDROID_LOG_LIBRARY}) + target_include_directories(openxr_c_compile_test PRIVATE ${ANDROID_NATIVE_APP_GLUE}) +else() + add_executable(openxr_c_compile_test + main.c + ) +endif() +set_target_properties(openxr_c_compile_test PROPERTIES FOLDER ${TESTS_FOLDER}) + add_dependencies(openxr_c_compile_test generate_openxr_header ) @@ -37,5 +48,3 @@ target_link_libraries(openxr_c_compile_test OpenXR::openxr_loader) if(MSVC) target_compile_options(openxr_c_compile_test PRIVATE /Zc:wchar_t /Zc:forScope /W4 /WX) endif() - -set_target_properties(openxr_c_compile_test PROPERTIES FOLDER ${TESTS_FOLDER}) diff --git a/src/tests/c_compile_test/build.gradle b/src/tests/c_compile_test/build.gradle new file mode 100644 index 000000000..102a7462c --- /dev/null +++ b/src/tests/c_compile_test/build.gradle @@ -0,0 +1,72 @@ +// Copyright (c) 2020-2023, The Khronos Group Inc. +// +// SPDX-License-Identifier: Apache-2.0 + +// Open this directory in Android Studio, or build with Gradle, +// to build the "c_compile_test" sample application +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:7.4.2' + } +} + +repositories { + google() + mavenCentral() +} + +apply plugin: 'com.android.application' + +// These next few lines are just to make the version match the OpenXR release. +project.ext.repoRoot = file('../../../') +apply from: file('../../version.gradle') + +android { + compileSdk 29 + ndkVersion "21.4.7075529" + buildToolsVersion = "30.0.3" + + defaultConfig { + applicationId "org.khronos.openxr.c_compile_test" + // for Vulkan, need at least 24 + minSdkVersion 24 + + versionName = project.versionOpenXR.toString() + project.versionQualifier + versionCode = project.versionOpenXR.getVersionCode() + + externalNativeBuild { + cmake { + arguments '-DANDROID_STL=c++_shared', + '-DBUILD_API_LAYERS=OFF', + '-DBUILD_TESTS=ON', + '-DBUILD_LOADER=ON', + '-DBUILD_CONFORMANCE_TESTS=OFF', + '-DBUILD_ALL_EXTENSIONS=ON' + targets "openxr_loader", "openxr_c_compile_test" + } + } + } + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + } + } + + buildTypes { + release { + minifyEnabled false + } + } + + externalNativeBuild { + cmake { + path "${project.repoRoot}/CMakeLists.txt" + } + } + +} + diff --git a/src/tests/c_compile_test/main.c b/src/tests/c_compile_test/main.c index 56ab373d1..920b2b0f5 100644 --- a/src/tests/c_compile_test/main.c +++ b/src/tests/c_compile_test/main.c @@ -76,6 +76,10 @@ #include #endif +#ifdef XR_USE_PLATFORM_EGL +#include +#endif // XR_USE_PLATFORM_EGL + #ifdef XR_USE_TIMESPEC #include #endif @@ -86,6 +90,7 @@ #include #include +#if !defined(ANDROID) // this is just a test that our SDK headers compile with the C compiler int main(int argc, const char** argv) { (void)argc; @@ -93,3 +98,25 @@ int main(int argc, const char** argv) { return 0; } +#else // defined(ANDROID) +static void app_handle_cmd(struct android_app* app, int32_t cmd) { + (void)app; + (void)cmd; +} + +void android_main(struct android_app* app) { + JNIEnv* Env; + + JavaVM* java_vm = app->activity->vm; + + (*java_vm)->AttachCurrentThread(java_vm, &Env, NULL); + + app->userData = NULL; + app->onAppCmd = app_handle_cmd; + + // empty implementation + + ANativeActivity_finish(app->activity); + (*java_vm)->DetachCurrentThread(java_vm); +} +#endif // !defined(ANDROID) diff --git a/src/tests/hello_xr/CMakeLists.txt b/src/tests/hello_xr/CMakeLists.txt index 006db5312..42782ef79 100644 --- a/src/tests/hello_xr/CMakeLists.txt +++ b/src/tests/hello_xr/CMakeLists.txt @@ -51,6 +51,7 @@ target_include_directories(hello_xr PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/common + ${PROJECT_SOURCE_DIR}/src/tests/hello_xr/vulkan_shaders # for helper headers ${PROJECT_SOURCE_DIR}/external/include @@ -78,10 +79,8 @@ if(WIN32) endif() target_link_libraries(hello_xr ole32) if(MSVC) - # Right now can't build this on MinGW because of directxcolors, etc. + # Right now can't build this on MinGW because of directxcolors, directxmath, etc. target_link_libraries(hello_xr d3d11 d3d12 d3dcompiler dxgi) - else() - target_compile_definitions(hello_xr PRIVATE MISSING_DIRECTX_COLORS) endif() endif() diff --git a/src/tests/hello_xr/android_resources/values/ic_helloxr_launcher_background.xml b/src/tests/hello_xr/android_resources/values/ic_helloxr_launcher_background.xml index 27747f637..2ae91b695 100644 --- a/src/tests/hello_xr/android_resources/values/ic_helloxr_launcher_background.xml +++ b/src/tests/hello_xr/android_resources/values/ic_helloxr_launcher_background.xml @@ -1,6 +1,6 @@ diff --git a/src/tests/hello_xr/build.gradle b/src/tests/hello_xr/build.gradle index 843f6e9c0..69f2b4d70 100644 --- a/src/tests/hello_xr/build.gradle +++ b/src/tests/hello_xr/build.gradle @@ -95,3 +95,24 @@ android { } } +// For signing of release binaries - env var must contain an absolute path +// CI always does this. +def keystorePropertiesFilename = System.getenv("KEYSTORE_PROPERTIES") +if (keystorePropertiesFilename) { + def keystorePropertiesFile = file("${keystorePropertiesFilename}") + if (keystorePropertiesFile.exists()) { + println("Signing release artifacts for hello_xr") + def keystoreProperties = new Properties() + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) + android.signingConfigs { + release { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile file("${project.repoRoot}/" + keystoreProperties['storeFile']) + storePassword keystoreProperties['storePassword'] + } + } + android.buildTypes.release.signingConfig android.signingConfigs.release + } +} + diff --git a/src/tests/hello_xr/d3d_common.cpp b/src/tests/hello_xr/d3d_common.cpp index e990c1262..abe385ca0 100644 --- a/src/tests/hello_xr/d3d_common.cpp +++ b/src/tests/hello_xr/d3d_common.cpp @@ -5,7 +5,7 @@ #include "pch.h" #include "common.h" -#if (defined(XR_USE_GRAPHICS_API_D3D11) || defined(XR_USE_GRAPHICS_API_D3D12)) && !defined(MISSING_DIRECTX_COLORS) +#if defined(XR_USE_GRAPHICS_API_D3D11) || defined(XR_USE_GRAPHICS_API_D3D12) #include #include diff --git a/src/tests/hello_xr/gradle.properties b/src/tests/hello_xr/gradle.properties index 45cb34341..71d051014 100644 --- a/src/tests/hello_xr/gradle.properties +++ b/src/tests/hello_xr/gradle.properties @@ -1,4 +1,4 @@ -# Copyright (c) 2020 The Khronos Group Inc. +# Copyright (c) 2020-2023, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/tests/hello_xr/graphicsplugin_d3d11.cpp b/src/tests/hello_xr/graphicsplugin_d3d11.cpp index dd5f3efef..c27600bae 100644 --- a/src/tests/hello_xr/graphicsplugin_d3d11.cpp +++ b/src/tests/hello_xr/graphicsplugin_d3d11.cpp @@ -8,7 +8,7 @@ #include "graphicsplugin.h" #include "options.h" -#if defined(XR_USE_GRAPHICS_API_D3D11) && !defined(MISSING_DIRECTX_COLORS) +#if defined(XR_USE_GRAPHICS_API_D3D11) #include #include diff --git a/src/tests/hello_xr/graphicsplugin_d3d12.cpp b/src/tests/hello_xr/graphicsplugin_d3d12.cpp index ddaff421d..0152b0cf8 100644 --- a/src/tests/hello_xr/graphicsplugin_d3d12.cpp +++ b/src/tests/hello_xr/graphicsplugin_d3d12.cpp @@ -8,7 +8,7 @@ #include "graphicsplugin.h" #include "options.h" -#if defined(XR_USE_GRAPHICS_API_D3D12) && !defined(MISSING_DIRECTX_COLORS) +#if defined(XR_USE_GRAPHICS_API_D3D12) #include #include diff --git a/src/tests/hello_xr/graphicsplugin_factory.cpp b/src/tests/hello_xr/graphicsplugin_factory.cpp index 806dbdbd4..63139aa41 100644 --- a/src/tests/hello_xr/graphicsplugin_factory.cpp +++ b/src/tests/hello_xr/graphicsplugin_factory.cpp @@ -26,11 +26,11 @@ std::shared_ptr CreateGraphicsPlugin_VulkanLegacy(const std::sh std::shared_ptr CreateGraphicsPlugin_Vulkan(const std::shared_ptr& options, std::shared_ptr platformPlugin); #endif -#if defined(XR_USE_GRAPHICS_API_D3D11) && !defined(MISSING_DIRECTX_COLORS) +#ifdef XR_USE_GRAPHICS_API_D3D11 std::shared_ptr CreateGraphicsPlugin_D3D11(const std::shared_ptr& options, std::shared_ptr platformPlugin); #endif -#if defined(XR_USE_GRAPHICS_API_D3D12) && !defined(MISSING_DIRECTX_COLORS) +#ifdef XR_USE_GRAPHICS_API_D3D12 std::shared_ptr CreateGraphicsPlugin_D3D12(const std::shared_ptr& options, std::shared_ptr platformPlugin); #endif @@ -62,13 +62,13 @@ std::map graphicsPlugi return CreateGraphicsPlugin_Vulkan(options, std::move(platformPlugin)); }}, #endif -#if defined(XR_USE_GRAPHICS_API_D3D11) && !defined(MISSING_DIRECTX_COLORS) +#ifdef XR_USE_GRAPHICS_API_D3D11 {"D3D11", [](const std::shared_ptr& options, std::shared_ptr platformPlugin) { return CreateGraphicsPlugin_D3D11(options, std::move(platformPlugin)); }}, #endif -#if defined(XR_USE_GRAPHICS_API_D3D12) && !defined(MISSING_DIRECTX_COLORS) +#ifdef XR_USE_GRAPHICS_API_D3D12 {"D3D12", [](const std::shared_ptr& options, std::shared_ptr platformPlugin) { return CreateGraphicsPlugin_D3D12(options, std::move(platformPlugin)); diff --git a/src/tests/hello_xr/graphicsplugin_vulkan.cpp b/src/tests/hello_xr/graphicsplugin_vulkan.cpp index 46f718777..9841784a3 100644 --- a/src/tests/hello_xr/graphicsplugin_vulkan.cpp +++ b/src/tests/hello_xr/graphicsplugin_vulkan.cpp @@ -1089,6 +1089,10 @@ struct Swapchain { hWnd = nullptr; UnregisterClassW(L"hello_xr", hInst); } + if (hUser32Dll != NULL) { + ::FreeLibrary(hUser32Dll); + hUser32Dll = NULL; + } #endif m_vkDevice = nullptr; @@ -1102,6 +1106,7 @@ struct Swapchain { #if defined(VK_USE_PLATFORM_WIN32_KHR) HINSTANCE hInst{NULL}; HWND hWnd{NULL}; + HINSTANCE hUser32Dll{NULL}; #endif const VkExtent2D size{640, 480}; VkInstance m_vkInstance{VK_NULL_HANDLE}; @@ -1130,8 +1135,13 @@ void Swapchain::Create(VkInstance instance, VkPhysicalDevice physDevice, VkDevic // adjust the window size and show at InitDevice time #if defined(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) - // Make sure we're 1:1 for HMD pixels - SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + typedef DPI_AWARENESS_CONTEXT(WINAPI * PFN_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); + hUser32Dll = ::LoadLibraryA("user32.dll"); + if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = + reinterpret_cast(::GetProcAddress(hUser32Dll, "SetThreadDpiAwarenessContext"))) { + // Make sure we're 1:1 for HMD pixels + SetThreadDpiAwarenessContextFn(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + } #endif RECT rect{0, 0, (LONG)size.width, (LONG)size.height}; AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, false); diff --git a/src/tests/hello_xr/pch.h b/src/tests/hello_xr/pch.h index 8fb94a2ee..8c26ce4bc 100644 --- a/src/tests/hello_xr/pch.h +++ b/src/tests/hello_xr/pch.h @@ -94,6 +94,10 @@ #include #endif +#ifdef XR_USE_PLATFORM_EGL +#include +#endif // XR_USE_PLATFORM_EGL + #ifdef XR_USE_GRAPHICS_API_VULKAN #ifdef XR_USE_PLATFORM_WIN32 #define VK_USE_PLATFORM_WIN32_KHR diff --git a/src/tests/hello_xr/settings.gradle b/src/tests/hello_xr/settings.gradle index b1ec2710f..6c347217e 100644 --- a/src/tests/hello_xr/settings.gradle +++ b/src/tests/hello_xr/settings.gradle @@ -1,4 +1,4 @@ -// Copyright (c) 2020 The Khronos Group Inc. +// Copyright (c) 2020-2023, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/tests/list_json/AndroidManifest.xml b/src/tests/list_json/AndroidManifest.xml index 0807cdaca..3accaeb16 100644 --- a/src/tests/list_json/AndroidManifest.xml +++ b/src/tests/list_json/AndroidManifest.xml @@ -20,11 +20,28 @@ android:required="false" android:version="1" /> - + + + + + + + + + + + + + + + + + + @@ -63,7 +80,7 @@ + android:value="openxr_runtime_list_json" /> diff --git a/src/tests/list_json/CMakeLists.txt b/src/tests/list_json/CMakeLists.txt index b4bed34f7..a9c45cb4a 100644 --- a/src/tests/list_json/CMakeLists.txt +++ b/src/tests/list_json/CMakeLists.txt @@ -18,9 +18,6 @@ file(GLOB LOCAL_HEADERS "*.h") file(GLOB LOCAL_SOURCE "*.cpp") -# For including compiled shaders -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - if(ANDROID) add_library(openxr_runtime_list_json MODULE ${LOCAL_SOURCE} @@ -59,10 +56,8 @@ if(WIN32) endif() target_link_libraries(openxr_runtime_list_json ole32) if(MSVC) - # Right now can't build this on MinGW because of directxcolors, etc. + # Right now can't build this on MinGW because of directxcolors, directxmath, etc. target_link_libraries(openxr_runtime_list_json d3d11 d3d12 d3dcompiler dxgi) - else() - target_compile_definitions(openxr_runtime_list_json PRIVATE MISSING_DIRECTX_COLORS) endif() endif() diff --git a/src/tests/list_json/build.gradle b/src/tests/list_json/build.gradle new file mode 100644 index 000000000..049be2a76 --- /dev/null +++ b/src/tests/list_json/build.gradle @@ -0,0 +1,72 @@ +// Copyright (c) 2020-2023, The Khronos Group Inc. +// +// SPDX-License-Identifier: Apache-2.0 + +// Open this directory in Android Studio, or build with Gradle, +// to build the "list_json" sample application +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:7.4.2' + } +} + +repositories { + google() + mavenCentral() +} + +apply plugin: 'com.android.application' + +// These next few lines are just to make the version match the OpenXR release. +project.ext.repoRoot = file('../../../') +apply from: file('../../version.gradle') + +android { + compileSdk 29 + ndkVersion "21.4.7075529" + buildToolsVersion = "30.0.3" + + defaultConfig { + applicationId "org.khronos.openxr.list_json" + // for Vulkan, need at least 24 + minSdkVersion 24 + + versionName = project.versionOpenXR.toString() + project.versionQualifier + versionCode = project.versionOpenXR.getVersionCode() + + externalNativeBuild { + cmake { + arguments '-DANDROID_STL=c++_shared', + '-DBUILD_API_LAYERS=OFF', + '-DBUILD_TESTS=ON', + '-DBUILD_LOADER=ON', + '-DBUILD_CONFORMANCE_TESTS=OFF', + '-DBUILD_ALL_EXTENSIONS=ON' + targets "openxr_loader", "openxr_runtime_list_json" + } + } + } + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + } + } + + buildTypes { + release { + minifyEnabled false + } + } + + externalNativeBuild { + cmake { + path "${project.repoRoot}/CMakeLists.txt" + } + } + +} + diff --git a/src/tests/loader_test/loader_test.cpp b/src/tests/loader_test/loader_test.cpp index 29956ae6d..4f3e2866f 100644 --- a/src/tests/loader_test/loader_test.cpp +++ b/src/tests/loader_test/loader_test.cpp @@ -28,16 +28,10 @@ #include "filesystem_utils.hpp" #include "loader_test_utils.hpp" -#include "hex_and_handles.h" - #include "xr_dependencies.h" #include #include -#ifdef XR_USE_GRAPHICS_API_D3D11 -#include "d3d11.h" -#endif - #include static_assert(sizeof(XrStructureType) == 4, "This should be a 32-bit enum"); @@ -49,9 +43,6 @@ using std::endl; // clean output for the test. #define FILTER_OUT_LOADER_ERRORS 1 -enum LoaderTestGraphicsApiToUse { GRAPHICS_API_UNKONWN = 0, GRAPHICS_API_OPENGL, GRAPHICS_API_VULKAN, GRAPHICS_API_D3D }; -LoaderTestGraphicsApiToUse g_graphics_api_to_use = GRAPHICS_API_UNKONWN; -bool g_debug_utils_exists = false; bool g_has_installed_runtime = false; void CleanupEnvironmentVariables() { @@ -87,51 +78,6 @@ bool DetectInstalledRuntime() { // Successful enumeration implies an active runtime is installed (regardless of ext count) runtime_found = XR_SUCCEEDED(ret); - // See which display extension (if any) to use - // If multiple are supported, pick the first one found - if (runtime_found && (0 < ext_count)) { - std::vector properties; - properties.resize(ext_count); - for (uint32_t prop = 0; prop < ext_count; ++prop) { - properties[prop] = {XR_TYPE_EXTENSION_PROPERTIES, nullptr, {0, 0}}; - } - ret = xrEnumerateInstanceExtensionProperties(nullptr, ext_count, &ext_count, properties.data()); - if (XR_FAILED(ret)) { - return runtime_found; - } - - for (uint32_t ext = 0; ext < ext_count; ext++) { -#ifdef XR_USE_GRAPHICS_API_D3D11 - if (!strcmp(properties[ext].extensionName, XR_KHR_D3D11_ENABLE_EXTENSION_NAME)) { - g_graphics_api_to_use = GRAPHICS_API_D3D; - break; - } -#endif // XR_USE_GRAPHICS_API_D3D11 - -#ifdef XR_USE_GRAPHICS_API_VULKAN - if (strcmp(properties[ext].extensionName, XR_KHR_VULKAN_ENABLE_EXTENSION_NAME) == 0) { - g_graphics_api_to_use = GRAPHICS_API_VULKAN; - break; - } -#endif // XR_USE_GRAPHICS_API_VULKAN - -#ifdef XR_USE_GRAPHICS_API_OPENGL - if (strcmp(properties[ext].extensionName, XR_KHR_OPENGL_ENABLE_EXTENSION_NAME) == 0) { - g_graphics_api_to_use = GRAPHICS_API_OPENGL; - break; - } -#endif // XR_USE_GRAPHICS_API_OPENGL - } - - // While we're here, also check for debug utils support - for (uint32_t ext = 0; ext < ext_count; ext++) { - if (strcmp(properties[ext].extensionName, XR_EXT_DEBUG_UTILS_EXTENSION_NAME) == 0) { - g_debug_utils_exists = true; - break; - } - } - } - return runtime_found; } @@ -574,10 +520,11 @@ DEFINE_TEST(TestCreateDestroyInstance) { XrResult expected_result = XR_SUCCESS; char valid_layer_to_enable[] = "XR_APILAYER_LUNARG_api_dump"; char invalid_layer_to_enable[] = "XrApiLayer_invalid_layer_test"; + char valid_extension_to_enable[] = "XR_EXT_debug_utils"; char invalid_extension_to_enable[] = "XR_KHR_fake_ext1"; const char* const valid_layer_name_array[1] = {valid_layer_to_enable}; const char* const invalid_layer_name_array[1] = {invalid_layer_to_enable}; - const char* valid_extension_name_array[1]; + const char* valid_extension_name_array[1] = {valid_extension_to_enable}; const char* const invalid_extension_name_array[1] = {invalid_extension_to_enable}; XrApplicationInfo application_info = {}; strcpy(application_info.applicationName, "Loader Test"); @@ -598,9 +545,6 @@ DEFINE_TEST(TestCreateDestroyInstance) { layer_path + TEST_DIRECTORY_SYMBOL + ".." + TEST_DIRECTORY_SYMBOL + ".." + TEST_DIRECTORY_SYMBOL + "api_layers"; LoaderTestSetEnvironmentVariable("XR_API_LAYER_PATH", layer_path); - // Look to see if the runtime supports any extensions, if it does, use the first one in this test. - bool missing_extensions = true; - // Make API dump write to a file, when loaded LoaderTestSetEnvironmentVariable("XR_API_DUMP_FILE_NAME", "api_dump_out.txt"); @@ -633,9 +577,6 @@ DEFINE_TEST(TestCreateDestroyInstance) { break; // Test 3 - xrCreateInstance with a valid extension case 3: - if (missing_extensions) { - continue; - } current_test_string = "xrCreateInstance with a single valid extension"; expected_result = XR_SUCCESS; instance_create_info.enabledExtensionCount = 1; @@ -643,9 +584,6 @@ DEFINE_TEST(TestCreateDestroyInstance) { break; // Test 4 - xrCreateInstance with an invalid extension case 4: - if (missing_extensions) { - continue; - } current_test_string = "xrCreateInstance with a single invalid extension"; expected_result = XR_ERROR_EXTENSION_NOT_PRESENT; instance_create_info.enabledExtensionCount = 1; @@ -653,9 +591,6 @@ DEFINE_TEST(TestCreateDestroyInstance) { break; // Test 5 - xrCreateInstance with everything case 5: - if (missing_extensions) { - continue; - } current_test_string = "xrCreateInstance with app info, valid layer, and a valid extension"; expected_result = XR_SUCCESS; instance_create_info.enabledApiLayerCount = 1; @@ -720,7 +655,7 @@ DEFINE_TEST(TestGetSystem) { XrSystemGetInfo system_get_info = {XR_TYPE_SYSTEM_GET_INFO}; system_get_info.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY; - XrSystemId systemId; + XrSystemId systemId = XR_NULL_SYSTEM_ID; TEST_EQUAL(xrGetSystem(instance, &system_get_info, &systemId), XR_SUCCESS, "xrGetSystem"); TEST_EQUAL(xrDestroyInstance(instance), XR_SUCCESS, "Destroying instance") @@ -736,8 +671,8 @@ DEFINE_TEST(TestGetSystem) { } // Test at least one non-XrInstance function to make sure that the automatic non-instance functions work. -DEFINE_TEST(TestCreateDestroySession) { - INIT_TEST(TestCreateDestroySession) +DEFINE_TEST(TestCreateDestroyAction) { + INIT_TEST(TestCreateDestroyAction) try { std::string current_path; @@ -761,1285 +696,24 @@ DEFINE_TEST(TestCreateDestroySession) { XrInstanceCreateInfo instance_ci = {XR_TYPE_INSTANCE_CREATE_INFO}; instance_ci.applicationInfo = app_info; - - std::string ext_name; - const char* ext_name_array[2]; - switch (g_graphics_api_to_use) { - case GRAPHICS_API_D3D: - ext_name = "XR_KHR_D3D11_enable"; - break; - case GRAPHICS_API_VULKAN: - ext_name = "XR_KHR_vulkan_enable"; - break; - case GRAPHICS_API_OPENGL: - ext_name = "XR_KHR_opengl_enable"; - break; - default: - TEST_FAIL("Unable to continue - no graphics binding extension found") - TEST_REPORT(TestCreateDestroySession) - return; - } - ext_name_array[0] = ext_name.c_str(); - instance_ci.enabledExtensionNames = ext_name_array; - instance_ci.enabledExtensionCount = 1; - cout << " Display binding extension: " << ext_name << endl; - TEST_EQUAL(xrCreateInstance(&instance_ci, &instance), XR_SUCCESS, "Creating instance") - XrSystemGetInfo system_get_info = {XR_TYPE_SYSTEM_GET_INFO}; - system_get_info.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY; - - XrSystemId systemId; - TEST_EQUAL(xrGetSystem(instance, &system_get_info, &systemId), XR_SUCCESS, "xrGetSystem"); - - if (systemId != XR_NULL_SYSTEM_ID) { - void* graphics_binding = nullptr; - -#ifdef XR_USE_GRAPHICS_API_VULKAN - XrGraphicsBindingVulkanKHR vulkan_graphics_binding = {}; - if (g_graphics_api_to_use == GRAPHICS_API_VULKAN) { - PFN_xrGetVulkanInstanceExtensionsKHR pfn_get_vulkan_instance_extensions_khr; - PFN_xrGetVulkanDeviceExtensionsKHR pfn_get_vulkan_device_extensions_khr; - PFN_xrGetVulkanGraphicsDeviceKHR pfn_get_vulkan_graphics_device_khr; - PFN_xrGetVulkanGraphicsRequirementsKHR pfn_get_vulkan_graphics_requirements_khr; - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetVulkanInstanceExtensionsKHR", - reinterpret_cast(&pfn_get_vulkan_instance_extensions_khr)), - XR_SUCCESS, "TestCreateDestroySession get xrGetVulkanInstanceExtensionsKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_vulkan_instance_extensions_khr, nullptr, - "TestCreateDestroySession invalid xrGetVulkanInstanceExtensionsKHR function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetVulkanDeviceExtensionsKHR", - reinterpret_cast(&pfn_get_vulkan_device_extensions_khr)), - XR_SUCCESS, "TestCreateDestroySession get xrGetVulkanDeviceExtensionsKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_vulkan_device_extensions_khr, nullptr, - "TestCreateDestroySession invalid xrGetVulkanDeviceExtensionsKHR function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetVulkanGraphicsDeviceKHR", - reinterpret_cast(&pfn_get_vulkan_graphics_device_khr)), - XR_SUCCESS, "TestCreateDestroySession get xrGetVulkanGraphicsDeviceKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_vulkan_graphics_device_khr, nullptr, - "TestCreateDestroySession invalid xrGetVulkanGraphicsDeviceKHR function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetVulkanGraphicsRequirementsKHR", - reinterpret_cast(&pfn_get_vulkan_graphics_requirements_khr)), - XR_SUCCESS, "TestCreateDestroySession get xrGetVulkanGraphicsRequirementsKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_vulkan_graphics_requirements_khr, nullptr, - "TestCreateDestroySession invalid xrGetVulkanGraphicsRequirementsKHR function pointer"); - - XrGraphicsRequirementsVulkanKHR vulkan_graphics_requirements = {XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR}; - TEST_EQUAL(pfn_get_vulkan_graphics_requirements_khr(instance, systemId, &vulkan_graphics_requirements), XR_SUCCESS, - "TestCreateDestroySession calling xrGetVulkanGraphicsRequirementsKHR"); - - // TODO: Just need something other than NULL here for now (for validation). Eventually need - // to correctly put in a valid pointer to an Display - vulkan_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR}; - vulkan_graphics_binding.instance = VK_NULL_HANDLE; - vulkan_graphics_binding.physicalDevice = VK_NULL_HANDLE; - vulkan_graphics_binding.device = VK_NULL_HANDLE; - vulkan_graphics_binding.queueFamilyIndex = 0; - vulkan_graphics_binding.queueIndex = 0; - graphics_binding = reinterpret_cast(&vulkan_graphics_binding); - } -#endif // XR_USE_GRAPHICS_API_VULKAN - -#ifdef XR_USE_GRAPHICS_API_OPENGL -#ifdef _WIN32 - XrGraphicsBindingOpenGLWin32KHR win32_gl_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR}; -#elif defined(OS_LINUX_XLIB) - XrGraphicsBindingOpenGLXlibKHR glx_gl_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR}; -#elif defined(OS_LINUX_XCB) || defined(OS_LINUX_XCB_GLX) - XrGraphicsBindingOpenGLXcbKHR xcb_gl_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_OPENGL_XCB_KHR}; -#elif defined(OS_LINUX_WAYLAND) - XrGraphicsBindingOpenGLWaylandKHR wayland_gl_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR}; -#endif - if (g_graphics_api_to_use == GRAPHICS_API_OPENGL) { - PFN_xrGetOpenGLGraphicsRequirementsKHR pfn_get_opengl_graphics_requirements_khr; - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetOpenGLGraphicsRequirementsKHR", - reinterpret_cast(&pfn_get_opengl_graphics_requirements_khr)), - XR_SUCCESS, "TestCreateDestroySession get xrGetOpenGLGraphicsRequirementsKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_opengl_graphics_requirements_khr, nullptr, - "TestCreateDestroySession invalid xrGetOpenGLGraphicsRequirementsKHR function pointer"); - XrGraphicsRequirementsOpenGLKHR opengl_graphics_requirements = {XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_KHR}; - TEST_EQUAL(pfn_get_opengl_graphics_requirements_khr(instance, systemId, &opengl_graphics_requirements), XR_SUCCESS, - "TestCreateDestroySession calling xrGetOpenGLGraphicsRequirementsKHR"); -#ifdef _WIN32 - graphics_binding = reinterpret_cast(&win32_gl_graphics_binding); -#elif defined(OS_LINUX_XLIB) - // TODO: Just need something other than NULL here for now (for validation). Eventually need - // to correctly put in a valid pointer to an Display - glx_gl_graphics_binding.xDisplay = reinterpret_cast(0xFFFFFFFF); - graphics_binding = reinterpret_cast(&glx_gl_graphics_binding); -#elif defined(OS_LINUX_XCB) || defined(OS_LINUX_XCB_GLX) - // TODO: Just need something other than NULL here for now (for validation). Eventually need - // to correctly put in a valid pointer to an xcb_connection_t - xcb_gl_graphics_binding.connection = reinterpret_cast(0xFFFFFFFF); - graphics_binding = reinterpret_cast(&xcb_gl_graphics_binding); -#elif defined(OS_LINUX_WAYLAND) - // TODO: Just need something other than NULL here for now (for validation). Eventually need - // to correctly put in a valid pointer to an wl_display - wayland_gl_graphics_binding.display = reinterpret_cast(0xFFFFFFFF); - graphics_binding = reinterpret_cast(&wayland_gl_graphics_binding); -#endif - } -#endif // XR_USE_GRAPHICS_API_OPENGL - -#ifdef XR_USE_GRAPHICS_API_D3D11 - XrGraphicsBindingD3D11KHR d3d11_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_D3D11_KHR}; - ID3D11Device* d3d_device = NULL; - if (g_graphics_api_to_use == GRAPHICS_API_D3D) { - PFN_xrGetD3D11GraphicsRequirementsKHR pfn_get_d3d11_reqs; - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetD3D11GraphicsRequirementsKHR", - reinterpret_cast(&pfn_get_d3d11_reqs)), - XR_SUCCESS, "TestCreateDestroySession get xrGetD3D11GraphicsRequirementsKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_d3d11_reqs, nullptr, - "TestCreateDestroySession invalid xrGetD3D11GraphicsRequirementsKHR function pointer"); - XrGraphicsRequirementsD3D11KHR d3d_reqs = {XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR}; - TEST_EQUAL(pfn_get_d3d11_reqs(instance, systemId, &d3d_reqs), XR_SUCCESS, - "TestCreateDestroySession calling xrGetD3D11GraphicsRequirementsKHR"); - HRESULT res = - D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, &d3d_device, NULL, NULL); - TEST_EQUAL(res, S_OK, "TestCreateDestroySession creating D3D11 reference device") - - d3d11_graphics_binding.device = d3d_device; - graphics_binding = reinterpret_cast(&d3d11_graphics_binding); - } -#endif // XR_USE_GRAPHICS_API_D3D11 - - if (graphics_binding != nullptr) { - // Create a session for us to begin - XrSession session; - XrSessionCreateInfo session_create_info = {XR_TYPE_SESSION_CREATE_INFO}; - session_create_info.systemId = systemId; - session_create_info.next = graphics_binding; - TEST_EQUAL(xrCreateSession(instance, &session_create_info, &session), XR_SUCCESS, "xrCreateSession") - TEST_EQUAL(xrDestroySession(session), XR_SUCCESS, "Destroying session") - } else { - TEST_FAIL("No graphics binding available for CreateSession test") - } -#ifdef XR_USE_GRAPHICS_API_D3D11 - if (d3d_device) d3d_device->Release(); -#endif - } - TEST_EQUAL(xrDestroyInstance(instance), XR_SUCCESS, "Destroying instance") - } catch (...) { - TEST_FAIL("Exception triggered during test, automatic failure") - } - - // Cleanup - CleanupEnvironmentVariables(); - - // Output results for this test - TEST_REPORT(TestCreateDestroySession) -} - -const char test_function_name[] = "MyTestFunctionName"; -static char message_id[64]; -static uint64_t object_handle; -static char object_name[64]; -static uint32_t num_objects = 0; -const char test_message[] = "This is a test message - 1 . 2! 3"; -static void* expected_user_value = nullptr; -static bool captured_error = false; -static bool captured_warning = false; -static bool captured_info = false; -static bool captured_verbose = false; -static bool captured_general_message = false; -static bool captured_validation_message = false; -static bool captured_performance_message = false; -static bool user_data_correct = false; -static bool encountered_bad_type = false; -static bool encountered_bad_severity = false; -static bool function_matches = false; -static bool message_matches = false; -static bool message_id_matches = false; -static bool num_objects_matches = false; -static bool object_contents_match = false; -const char g_first_individual_label_name[] = "First individual label"; -const char g_second_individual_label_name[] = "Second individual label"; -const char g_third_individual_label_name[] = "Third individual label"; -const char g_first_label_region_name[] = "First Label Region"; -const char g_second_label_region_name[] = "Second Label Region"; -uint32_t g_in_region_num = 0; -uint32_t g_individual_label_num = 0; -static bool g_expecting_labels = false; -static bool g_captured_labels = false; -static bool g_captured_only_expected_labels = false; - -XrBool32 XRAPI_PTR TestDebugUtilsCallback(XrDebugUtilsMessageSeverityFlagsEXT messageSeverity, - XrDebugUtilsMessageTypeFlagsEXT messageType, - const XrDebugUtilsMessengerCallbackDataEXT* callbackData, void* userData) { - user_data_correct = (expected_user_value == userData); - - if (strcmp(callbackData->functionName, test_function_name) == 0) { - function_matches = true; - } - - if (strcmp(callbackData->messageId, message_id) == 0) { - message_id_matches = true; - } - - if (strcmp(callbackData->message, test_message) == 0) { - message_matches = true; - } - - switch (messageType) { - case XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT: - captured_general_message = true; - break; - case XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT: - captured_validation_message = true; - break; - case XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: - captured_performance_message = true; - break; - default: - encountered_bad_type = true; - break; - } - - switch (messageSeverity) { - case XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: - captured_error = true; - break; - case XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: - captured_warning = true; - break; - case XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: - captured_info = true; - break; - case XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: - captured_verbose = true; - break; - default: - encountered_bad_severity = true; - break; - } - - if (callbackData->objectCount == num_objects) { - num_objects_matches = true; - if (callbackData->objectCount == 3) { - if (callbackData->objects[0].type == XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT && - callbackData->objects[0].next == nullptr && callbackData->objects[0].objectType == XR_OBJECT_TYPE_INSTANCE && - callbackData->objects[0].objectHandle == static_cast(0xFEED0001) && - callbackData->objects[0].objectName == nullptr && - callbackData->objects[1].type == XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT && - callbackData->objects[1].next == nullptr && callbackData->objects[1].objectType == XR_OBJECT_TYPE_SESSION && - callbackData->objects[1].objectHandle == static_cast(0xFEED0002) && - callbackData->objects[1].objectName == nullptr && - callbackData->objects[2].type == XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT && - callbackData->objects[2].next == nullptr && callbackData->objects[2].objectType == XR_OBJECT_TYPE_ACTION_SET && - callbackData->objects[2].objectHandle == static_cast(0xFEED0003) && - callbackData->objects[2].objectName == nullptr) { - object_contents_match = true; - } - } else if (callbackData->objectCount == 1) { - // This should have an actual object and name - if (callbackData->objects[0].type == XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT && - callbackData->objects[0].next == nullptr && callbackData->objects[0].objectType == XR_OBJECT_TYPE_INSTANCE && - callbackData->objects[0].objectHandle == object_handle && - (strcmp(callbackData->objects[0].objectName, object_name) == 0)) { - object_contents_match = true; - } - } - } - - if (callbackData->sessionLabelCount > 0) { - g_captured_labels = true; - g_captured_only_expected_labels = false; - if (g_expecting_labels) { - if (g_in_region_num == 0) { - // Should not have any label region in list - bool found_invalid = false; - for (uint32_t label_index = 0; label_index < callbackData->sessionLabelCount; ++label_index) { - if ((strcmp(callbackData->sessionLabels[label_index].labelName, g_second_label_region_name) == 0) || - (strcmp(callbackData->sessionLabels[label_index].labelName, g_first_label_region_name) == 0)) { - found_invalid = true; - } - } - if (!found_invalid) { - g_captured_only_expected_labels = true; - } - } else if (g_in_region_num == 2) { - // Should have g_second_label_region_name in list - // Should have g_first_label_region_name in list - if (callbackData->sessionLabelCount >= 2 && - ((strcmp(callbackData->sessionLabels[0].labelName, g_second_label_region_name) == 0) && - (strcmp(callbackData->sessionLabels[1].labelName, g_first_label_region_name) == 0))) { - g_captured_only_expected_labels = true; - } - } else if (g_in_region_num == 1) { - // Should not have g_second_label_region_name in list - // Should have g_first_label_region_name in list - if (callbackData->sessionLabelCount >= 2 && - (strcmp(callbackData->sessionLabels[0].labelName, g_second_label_region_name) != 0) && - (strcmp(callbackData->sessionLabels[1].labelName, g_first_label_region_name) == 0)) { - g_captured_only_expected_labels = true; - } else if (callbackData->sessionLabelCount >= 1 && - (strcmp(callbackData->sessionLabels[0].labelName, g_first_label_region_name) == 0)) { - g_captured_only_expected_labels = true; - } - } - - if (g_individual_label_num == 0) { - // Should not have any individual label in list - bool found_invalid = false; - for (uint32_t label_index = 0; label_index < callbackData->sessionLabelCount; ++label_index) { - if ((strcmp(callbackData->sessionLabels[label_index].labelName, g_first_individual_label_name) == 0) || - (strcmp(callbackData->sessionLabels[label_index].labelName, g_second_individual_label_name) == 0) || - (strcmp(callbackData->sessionLabels[label_index].labelName, g_third_individual_label_name) == 0)) { - found_invalid = true; - } - } - if (found_invalid) { - g_captured_only_expected_labels = false; - } - } - if (g_individual_label_num == 1) { - // Should have g_first_individual_label_name in list - // Should not have g_second_individual_label_name in list - // Should not have g_third_individual_label_name in list - bool found_invalid = false; - bool found_valid = false; - for (uint32_t label_index = 0; label_index < callbackData->sessionLabelCount; ++label_index) { - if ((strcmp(callbackData->sessionLabels[label_index].labelName, g_second_individual_label_name) == 0) || - (strcmp(callbackData->sessionLabels[label_index].labelName, g_third_individual_label_name) == 0)) { - found_invalid = true; - } - if (strcmp(callbackData->sessionLabels[label_index].labelName, g_first_individual_label_name) == 0) { - found_valid = true; - } - } - if (found_invalid || !found_valid) { - g_captured_only_expected_labels = false; - } - } else if (g_individual_label_num == 2) { - // Should not have g_first_individual_label_name in list - // Should have g_second_individual_label_name in list - // Should not have g_third_individual_label_name in list - bool found_invalid = false; - bool found_valid = false; - for (uint32_t label_index = 0; label_index < callbackData->sessionLabelCount; ++label_index) { - if ((strcmp(callbackData->sessionLabels[label_index].labelName, g_first_individual_label_name) == 0) || - (strcmp(callbackData->sessionLabels[label_index].labelName, g_third_individual_label_name) == 0)) { - found_invalid = true; - } - if (strcmp(callbackData->sessionLabels[label_index].labelName, g_second_individual_label_name) == 0) { - found_valid = true; - } - } - if (found_invalid || !found_valid) { - g_captured_only_expected_labels = false; - } - } else if (g_individual_label_num == 3) { - // Should not have g_first_individual_label_name in list - // Should not have g_second_individual_label_name in list - // Should have g_third_individual_label_name in list - bool found_invalid = false; - bool found_valid = false; - for (uint32_t label_index = 0; label_index < callbackData->sessionLabelCount; ++label_index) { - if ((strcmp(callbackData->sessionLabels[label_index].labelName, g_first_individual_label_name) == 0) || - (strcmp(callbackData->sessionLabels[label_index].labelName, g_second_individual_label_name) == 0)) { - found_invalid = true; - } - if (strcmp(callbackData->sessionLabels[label_index].labelName, g_third_individual_label_name) == 0) { - found_valid = true; - } - } - if (found_invalid || !found_valid) { - g_captured_only_expected_labels = false; - } - } - } - } - - return XR_FALSE; -} - -// Test the EXT_debug_utils extension. Just to make sure it properly triggers at least one callback item -DEFINE_TEST(TestDebugUtils) { - INIT_TEST(TestDebugUtils) - - try { - std::string current_path; - std::string sample_impl_runtime_path; - std::string layer_path; - - if (!FileSysUtilsGetCurrentPath(current_path) || !FileSysUtilsCombinePaths(current_path, "../../api_layers", layer_path)) { - TEST_FAIL("Unable to set API layer path") - TEST_REPORT(TestDebugUtils) - return; + if (instance != XR_NULL_HANDLE) { + XrActionSetCreateInfo actionSetInfo{XR_TYPE_ACTION_SET_CREATE_INFO}; + strcpy(actionSetInfo.actionSetName, "test"); + strcpy(actionSetInfo.localizedActionSetName, "test"); + XrActionSet actionSet{XR_NULL_HANDLE}; + TEST_EQUAL(xrCreateActionSet(instance, &actionSetInfo, &actionSet), XR_SUCCESS, "Calling xrCreateActionSet"); + + XrActionCreateInfo actionInfo{XR_TYPE_ACTION_CREATE_INFO}; + actionInfo.actionType = XR_ACTION_TYPE_BOOLEAN_INPUT; + strcpy(actionInfo.actionName, "action_test"); + strcpy(actionInfo.localizedActionName, "Action test"); + XrAction completeAction{XR_NULL_HANDLE}; + TEST_EQUAL(xrCreateAction(actionSet, &actionInfo, &completeAction), XR_SUCCESS, "Calling xrCreateAction"); } - LoaderTestUnsetEnvironmentVariable("XR_RUNTIME_JSON"); - LoaderTestSetEnvironmentVariable("XR_API_LAYER_PATH", layer_path); - - XrInstance instance = XR_NULL_HANDLE; - - XrApplicationInfo app_info = {}; - strcpy(app_info.applicationName, "Loader Test"); - app_info.applicationVersion = 688; - strcpy(app_info.engineName, "Infinite Improbability Drive"); - app_info.engineVersion = 42; - app_info.apiVersion = XR_CURRENT_API_VERSION; - - XrInstanceCreateInfo instance_ci = {XR_TYPE_INSTANCE_CREATE_INFO}; - instance_ci.applicationInfo = app_info; - - char dbg_ext_name[] = XR_EXT_DEBUG_UTILS_EXTENSION_NAME; - std::string gfx_name("None"); - const char* ext_array[2]; - instance_ci.enabledExtensionCount = 2; - instance_ci.enabledExtensionNames = ext_array; - -#ifdef XR_USE_GRAPHICS_API_VULKAN - if (g_graphics_api_to_use == GRAPHICS_API_VULKAN) { - gfx_name = XR_KHR_VULKAN_ENABLE_EXTENSION_NAME; - } -#endif // XR_USE_GRAPHICS_API_VULKAN -#ifdef XR_USE_GRAPHICS_API_OPENGL - if (g_graphics_api_to_use == GRAPHICS_API_OPENGL) { - gfx_name = XR_KHR_OPENGL_ENABLE_EXTENSION_NAME; - } -#endif // XR_USE_GRAPHICS_API_OPENGL -#ifdef XR_USE_GRAPHICS_API_D3D11 - if (g_graphics_api_to_use == GRAPHICS_API_D3D) { - gfx_name = XR_KHR_D3D11_ENABLE_EXTENSION_NAME; - } -#endif // XR_USE_GRAPHICS_API_D3D11 - - ext_array[0] = dbg_ext_name; - ext_array[1] = gfx_name.c_str(); - instance_ci.enabledExtensionNames = ext_array; - - // Create an instance with the appropriate data for the debug utils messenger - XrDebugUtilsMessengerCreateInfoEXT dbg_msg_ci = {XR_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT}; - dbg_msg_ci.messageSeverities = - XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | - XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT; - dbg_msg_ci.messageTypes = XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | - XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; - dbg_msg_ci.userCallback = TestDebugUtilsCallback; - - // Create an instacne with the general information setup for a message - XrDebugUtilsMessengerCallbackDataEXT callback_data = {XR_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT}; - callback_data.messageId = &message_id[0]; - callback_data.functionName = &test_function_name[0]; - callback_data.message = &test_message[0]; - callback_data.objectCount = 0; - callback_data.objects = nullptr; - callback_data.sessionLabelCount = 0; - callback_data.sessionLabels = nullptr; - - // Path 1 - Create/Destroy with xrCreateInstance/xrDestroyInstance - - // Reset the capture values - intptr_t def_int_value = 0xBADDECAF; - expected_user_value = reinterpret_cast(def_int_value); - captured_error = false; - captured_warning = false; - captured_info = false; - captured_verbose = false; - user_data_correct = false; - captured_general_message = false; - captured_validation_message = false; - captured_performance_message = false; - function_matches = false; - message_matches = false; - message_id_matches = false; - num_objects_matches = false; - num_objects = 0; - dbg_msg_ci.userData = expected_user_value; - - instance_ci.next = reinterpret_cast(&dbg_msg_ci); - - TEST_EQUAL(xrCreateInstance(&instance_ci, &instance), XR_SUCCESS, "Creating instance with next messenger creation") - - // Get a function pointer to the submit function to test - PFN_xrSubmitDebugUtilsMessageEXT pfn_submit_dmsg; - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrSubmitDebugUtilsMessageEXT", - reinterpret_cast(&pfn_submit_dmsg)), - XR_SUCCESS, "TestDebugUtils get xrSubmitDebugUtilsMessageEXT function pointer"); - TEST_NOT_EQUAL(pfn_submit_dmsg, nullptr, "TestDebugUtils invalid xrSubmitDebugUtilsMessageEXT function pointer"); - - // Test the various items - strcpy(message_id, "General Error"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_error, true, "TestDebugUtils - General Error : Captured Error") - TEST_EQUAL(captured_general_message, true, "TestDebugUtils - General Error : Captured General") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - General Error : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - General Error : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - General Error : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - General Error : Message ID Matches") - strcpy(message_id, "Validation Warning"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_warning, true, "TestDebugUtils - Validation Warning : Captured Warning") - TEST_EQUAL(captured_validation_message, true, "TestDebugUtils - Validation Warning : Captured Validation") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - Validation Warning : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - Validation Warning : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - Validation Warning : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - Validation Warning : Message ID Matches") - strcpy(message_id, "Performance Info"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_info, true, "TestDebugUtils - Performance Info : Captured Info") - TEST_EQUAL(captured_performance_message, true, "TestDebugUtils - Performance Info : Captured Performance") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - Performance Info : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - Performance Info : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - Performance Info : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - Performance Info : Message ID Matches") - strcpy(message_id, "General Verbose"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_verbose, true, "TestDebugUtils - General Verbose : Captured Verbose") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - General Verbose : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - General Verbose : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - General Verbose : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - General Verbose : Message ID Matches") - - TEST_EQUAL(xrDestroyInstance(instance), XR_SUCCESS, "Destroying instance with next messenger creation") - - // Path 2 - Create/Destroy with explicit call (xrCreateDebugUtilsMessengerEXT/xrDestroyDebugUtilsMessengerEXT) - - // Reset the capture values - def_int_value = 0xDECAFBAD; - expected_user_value = reinterpret_cast(def_int_value); - captured_error = false; - captured_warning = false; - captured_info = false; - captured_verbose = false; - user_data_correct = false; - captured_general_message = false; - captured_validation_message = false; - captured_performance_message = false; - function_matches = false; - message_matches = false; - message_id_matches = false; - num_objects_matches = false; - num_objects = 0; - dbg_msg_ci.userData = expected_user_value; - instance_ci.next = nullptr; - - TEST_EQUAL(xrCreateInstance(&instance_ci, &instance), XR_SUCCESS, "Creating instance for separate create/destroy messenger") - - // Get a function pointer to the various debug utils functions to test - PFN_xrCreateDebugUtilsMessengerEXT pfn_create_debug_utils_messager_ext; - PFN_xrDestroyDebugUtilsMessengerEXT pfn_destroy_debug_utils_messager_ext; - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrCreateDebugUtilsMessengerEXT", - reinterpret_cast(&pfn_create_debug_utils_messager_ext)), - XR_SUCCESS, "TestDebugUtils get xrCreateDebugUtilsMessengerEXT function pointer"); - TEST_NOT_EQUAL(pfn_create_debug_utils_messager_ext, nullptr, - "TestDebugUtils invalid xrCreateDebugUtilsMessengerEXT function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrDestroyDebugUtilsMessengerEXT", - reinterpret_cast(&pfn_destroy_debug_utils_messager_ext)), - XR_SUCCESS, "TestDebugUtils get xrDestroyDebugUtilsMessengerEXT function pointer"); - TEST_NOT_EQUAL(pfn_destroy_debug_utils_messager_ext, nullptr, - "TestDebugUtils invalid xrDestroyDebugUtilsMessengerEXT function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrSubmitDebugUtilsMessageEXT", - reinterpret_cast(&pfn_submit_dmsg)), - XR_SUCCESS, "TestDebugUtils get xrSubmitDebugUtilsMessageEXT function pointer"); - TEST_NOT_EQUAL(pfn_submit_dmsg, nullptr, "TestDebugUtils invalid xrSubmitDebugUtilsMessageEXT function pointer"); - - // Create the debug utils messenger - XrDebugUtilsMessengerEXT debug_utils_messenger = XR_NULL_HANDLE; - TEST_EQUAL(pfn_create_debug_utils_messager_ext(instance, &dbg_msg_ci, &debug_utils_messenger), XR_SUCCESS, - "Creating the debug utils messenger") - - // Test the various items - strcpy(message_id, "General Error"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_error, true, "TestDebugUtils - General Error : Captured Error") - TEST_EQUAL(captured_general_message, true, "TestDebugUtils - General Error : Captured General") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - General Error : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - General Error : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - General Error : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - General Error : Message ID Matches") - TEST_EQUAL(num_objects_matches, true, "TestDebugUtils - General Error : Number of Objects Matches") - strcpy(message_id, "Validation Warning"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_warning, true, "TestDebugUtils - Validation Warning : Captured Warning") - TEST_EQUAL(captured_validation_message, true, "TestDebugUtils - Validation Warning : Captured Validation") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - Validation Warning : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - Validation Warning : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - Validation Warning : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - Validation Warning : Message ID Matches") - TEST_EQUAL(num_objects_matches, true, "TestDebugUtils - Validation Warning : Number of Objects Matches") - strcpy(message_id, "Performance Info"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_info, true, "TestDebugUtils - Performance Info : Captured Info") - TEST_EQUAL(captured_performance_message, true, "TestDebugUtils - Performance Info : Captured Performance") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - Performance Info : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - Performance Info : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - Performance Info : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - Performance Info : Message ID Matches") - TEST_EQUAL(num_objects_matches, true, "TestDebugUtils - Performance Info : Number of Objects Matches") - strcpy(message_id, "General Verbose"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_verbose, true, "TestDebugUtils - General Verbose : Captured Verbose") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - General Verbose : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - General Verbose : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - General Verbose : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - General Verbose : Message ID Matches") - TEST_EQUAL(num_objects_matches, true, "TestDebugUtils - General Verbose : Number of Objects Matches") - - // Destroy what we created - TEST_EQUAL(pfn_destroy_debug_utils_messager_ext(debug_utils_messenger), XR_SUCCESS, "Destroying the debug utils messenger") - - TEST_EQUAL(xrDestroyInstance(instance), XR_SUCCESS, "Destroying instance for separate create/destroy messenger") - - // Path 3 - Make sure appropriate messages only received when registered. - - // Reset the capture values - def_int_value = 0xDECAFBAD; - expected_user_value = reinterpret_cast(def_int_value); - captured_error = false; - captured_warning = false; - captured_info = false; - captured_verbose = false; - user_data_correct = false; - captured_general_message = false; - captured_validation_message = false; - captured_performance_message = false; - function_matches = false; - message_matches = false; - message_id_matches = false; - num_objects_matches = false; - num_objects = 0; - dbg_msg_ci.userData = expected_user_value; - instance_ci.next = nullptr; - - TEST_EQUAL(xrCreateInstance(&instance_ci, &instance), XR_SUCCESS, - "Creating instance for individual message type/severity testing") - - // Get a function pointer to the various debug utils functions to test - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrCreateDebugUtilsMessengerEXT", - reinterpret_cast(&pfn_create_debug_utils_messager_ext)), - XR_SUCCESS, "TestDebugUtils get xrCreateDebugUtilsMessengerEXT function pointer"); - TEST_NOT_EQUAL(pfn_create_debug_utils_messager_ext, nullptr, - "TestDebugUtils invalid xrCreateDebugUtilsMessengerEXT function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrDestroyDebugUtilsMessengerEXT", - reinterpret_cast(&pfn_destroy_debug_utils_messager_ext)), - XR_SUCCESS, "TestDebugUtils get xrDestroyDebugUtilsMessengerEXT function pointer"); - TEST_NOT_EQUAL(pfn_destroy_debug_utils_messager_ext, nullptr, - "TestDebugUtils invalid xrDestroyDebugUtilsMessengerEXT function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrSubmitDebugUtilsMessageEXT", - reinterpret_cast(&pfn_submit_dmsg)), - XR_SUCCESS, "TestDebugUtils get xrSubmitDebugUtilsMessageEXT function pointer"); - TEST_NOT_EQUAL(pfn_submit_dmsg, nullptr, "TestDebugUtils invalid xrSubmitDebugUtilsMessageEXT function pointer"); - - // Create the debug utils messenger, but only to receive general error messages - debug_utils_messenger = XR_NULL_HANDLE; - dbg_msg_ci.messageSeverities = XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT; - dbg_msg_ci.messageTypes = XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT; - - TEST_EQUAL(pfn_create_debug_utils_messager_ext(instance, &dbg_msg_ci, &debug_utils_messenger), XR_SUCCESS, - "Creating the debug utils messenger for general error testing") - - strcpy(message_id, "General Error"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - strcpy(message_id, "Validation Warning"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, - &callback_data); - strcpy(message_id, "Performance Info"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, - &callback_data); - strcpy(message_id, "General Verbose"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_error, true, "TestDebugUtils - Only General Error : Captured Error") - TEST_EQUAL(captured_warning, false, "TestDebugUtils - Only General Error : Captured Warning") - TEST_EQUAL(captured_info, false, "TestDebugUtils - Only General Error : Captured Info") - TEST_EQUAL(captured_verbose, false, "TestDebugUtils - Only General Error : Captured Verbose") - TEST_EQUAL(captured_general_message, true, "TestDebugUtils - Only General Error : Captured General") - TEST_EQUAL(captured_validation_message, false, "TestDebugUtils - Only General Error : Captured Validation") - TEST_EQUAL(captured_performance_message, false, "TestDebugUtils - Only General Error : Captured Performance") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - Only General Error : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - Only General Error : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - Only General Error : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - Only General Error : Message ID Matches") - TEST_EQUAL(num_objects_matches, true, "TestDebugUtils - Only General Error : Number of Objects Matches") - - // Destroy what we created - TEST_EQUAL(pfn_destroy_debug_utils_messager_ext(debug_utils_messenger), XR_SUCCESS, - "Destroying the debug utils messenger for general error testing") - - // Reset the items we tested above. - captured_error = false; - captured_general_message = false; - - // Create the debug utils messenger, but only to receive validation warning messages - debug_utils_messenger = XR_NULL_HANDLE; - dbg_msg_ci.messageSeverities = XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT; - dbg_msg_ci.messageTypes = XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT; - - TEST_EQUAL(pfn_create_debug_utils_messager_ext(instance, &dbg_msg_ci, &debug_utils_messenger), XR_SUCCESS, - "Creating the debug utils messenger for validation warning testing") - - strcpy(message_id, "General Error"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - strcpy(message_id, "Validation Warning"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, - &callback_data); - strcpy(message_id, "Performance Info"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, - &callback_data); - strcpy(message_id, "General Verbose"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_error, false, "TestDebugUtils - Only Validation Warning : Captured Error") - TEST_EQUAL(captured_warning, true, "TestDebugUtils - Only Validation Warning : Captured Warning") - TEST_EQUAL(captured_info, false, "TestDebugUtils - Only Validation Warning : Captured Info") - TEST_EQUAL(captured_verbose, false, "TestDebugUtils - Only Validation Warning : Captured Verbose") - TEST_EQUAL(captured_general_message, false, "TestDebugUtils - Only Validation Warning : Captured General") - TEST_EQUAL(captured_validation_message, true, "TestDebugUtils - Only Validation Warning : Captured Validation") - TEST_EQUAL(captured_performance_message, false, "TestDebugUtils - Only Validation Warning : Captured Performance") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - Only Validation Warning : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - Only Validation Warning : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - Only Validation Warning : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - Only Validation Warning : Message ID Matches") - TEST_EQUAL(num_objects_matches, true, "TestDebugUtils - Only Validation Warning : Number of Objects Matches") - - // Destroy what we created - TEST_EQUAL(pfn_destroy_debug_utils_messager_ext(debug_utils_messenger), XR_SUCCESS, - "Destroying the debug utils messenger for validation warning testing") - - // Reset the items we tested above. - captured_warning = false; - captured_validation_message = false; - - // Create the debug utils messenger, but only to receive validation warning messages - debug_utils_messenger = XR_NULL_HANDLE; - dbg_msg_ci.messageSeverities = XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT; - dbg_msg_ci.messageTypes = XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; - - TEST_EQUAL(pfn_create_debug_utils_messager_ext(instance, &dbg_msg_ci, &debug_utils_messenger), XR_SUCCESS, - "Creating the debug utils messenger for performance verbose testing") - - strcpy(message_id, "General Error"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - strcpy(message_id, "Validation Warning"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, - &callback_data); - strcpy(message_id, "Performance Info"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, - &callback_data); - strcpy(message_id, "General Verbose"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_error, false, "TestDebugUtils - Only Performance Verbose : Captured Error") - TEST_EQUAL(captured_warning, false, "TestDebugUtils - Only Performance Verbose : Captured Warning") - TEST_EQUAL(captured_info, false, "TestDebugUtils - Only Performance Verbose : Captured Info") - TEST_EQUAL(captured_verbose, false, "TestDebugUtils - Only Performance Verbose : Captured Verbose") - TEST_EQUAL(captured_general_message, false, "TestDebugUtils - Only Performance Verbose : Captured General") - TEST_EQUAL(captured_validation_message, false, "TestDebugUtils - Only Performance Verbose : Captured Validation") - TEST_EQUAL(captured_verbose, false, "TestDebugUtils - Only Performance Verbose : Captured Verbose") - TEST_EQUAL(captured_performance_message, false, "TestDebugUtils - Only Performance Verbose : Captured Performance") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - Only Performance Verbose : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - Only Performance Verbose : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - Only Performance Verbose : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - Only Performance Verbose : Message ID Matches") - TEST_EQUAL(num_objects_matches, true, "TestDebugUtils - Only Performance Verbose : Number of Objects Matches") - strcpy(message_id, "Performance Verbose"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_verbose, true, "TestDebugUtils - Only Performance Verbose : Captured Verbose") - TEST_EQUAL(captured_performance_message, true, "TestDebugUtils - Only Performance Verbose : Captured Performance") - - // Destroy what we created - TEST_EQUAL(pfn_destroy_debug_utils_messager_ext(debug_utils_messenger), XR_SUCCESS, - "Destroying the debug utils messenger for performance verbose testing") - - // Reset the items we tested above. - captured_verbose = false; - captured_performance_message = false; - - // Create the debug utils messenger, but only to receive validation warning messages - debug_utils_messenger = XR_NULL_HANDLE; - dbg_msg_ci.messageSeverities = XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT; - dbg_msg_ci.messageTypes = XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT; - - TEST_EQUAL(pfn_create_debug_utils_messager_ext(instance, &dbg_msg_ci, &debug_utils_messenger), XR_SUCCESS, - "Creating the debug utils messenger for validation info testing") - - strcpy(message_id, "General Error"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - strcpy(message_id, "Validation Warning"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, - &callback_data); - strcpy(message_id, "Performance Info"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, - &callback_data); - strcpy(message_id, "General Verbose"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_error, false, "TestDebugUtils - Only Validation Info : Captured Error") - TEST_EQUAL(captured_warning, false, "TestDebugUtils - Only Validation Info : Captured Warning") - TEST_EQUAL(captured_info, false, "TestDebugUtils - Only Validation Info : Captured Info") - TEST_EQUAL(captured_verbose, false, "TestDebugUtils - Only Validation Info : Captured Verbose") - TEST_EQUAL(captured_general_message, false, "TestDebugUtils - Only Validation Info : Captured General") - TEST_EQUAL(captured_validation_message, false, "TestDebugUtils - Only Validation Info : Captured Validation") - TEST_EQUAL(captured_performance_message, false, "TestDebugUtils - Only Validation Info : Captured Performance") - TEST_EQUAL(user_data_correct, true, "TestDebugUtils - Only Validation Info : User Data Correct") - TEST_EQUAL(function_matches, true, "TestDebugUtils - Only Validation Info : Function Matches") - TEST_EQUAL(message_matches, true, "TestDebugUtils - Only Validation Info : Message Matches") - TEST_EQUAL(message_id_matches, true, "TestDebugUtils - Only Validation Info : Message ID Matches") - TEST_EQUAL(num_objects_matches, true, "TestDebugUtils - Only Validation Info : Number of Objects Matches") - strcpy(message_id, "Validation Info"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, - &callback_data); - TEST_EQUAL(captured_info, true, "TestDebugUtils - Only Validation Info : Captured Info") - TEST_EQUAL(captured_validation_message, true, "TestDebugUtils - Only Validation Info : Captured Validation") - - // Destroy what we created - TEST_EQUAL(pfn_destroy_debug_utils_messager_ext(debug_utils_messenger), XR_SUCCESS, - "Destroying the debug utils messenger for validation info testing") - - // Reset the items we tested above. - captured_info = false; - captured_validation_message = false; - - // Path 4 - Test objects - - // Create the debug utils messenger, but only to receive validation warning messages - debug_utils_messenger = XR_NULL_HANDLE; - dbg_msg_ci.messageSeverities = XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT; - dbg_msg_ci.messageTypes = XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; - - TEST_EQUAL(pfn_create_debug_utils_messager_ext(instance, &dbg_msg_ci, &debug_utils_messenger), XR_SUCCESS, - "Creating the debug utils messenger for number of objects testing") - - num_objects_matches = false; - object_contents_match = false; - - num_objects = 3; - callback_data.objectCount = static_cast(num_objects); - XrDebugUtilsObjectNameInfoEXT objects[3]; - objects[0].type = XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; - objects[0].next = nullptr; - objects[0].objectType = XR_OBJECT_TYPE_INSTANCE; - objects[0].objectHandle = static_cast(0xFEED0001); - objects[0].objectName = nullptr; - objects[1].type = XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; - objects[1].next = nullptr; - objects[1].objectType = XR_OBJECT_TYPE_SESSION; - objects[1].objectHandle = static_cast(0xFEED0002); - objects[1].objectName = nullptr; - objects[2].type = XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; - objects[2].next = nullptr; - objects[2].objectType = XR_OBJECT_TYPE_ACTION_SET; - objects[2].objectHandle = static_cast(0xFEED0003); - objects[2].objectName = nullptr; - callback_data.objects = &objects[0]; - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, - &callback_data); - TEST_EQUAL(num_objects_matches, true, "TestDebugUtils - Number of Objects Matches") - TEST_EQUAL(object_contents_match, true, "TestDebugUtils - Object Content Matches") - num_objects_matches = false; - object_contents_match = false; - - // Destroy what we created - TEST_EQUAL(pfn_destroy_debug_utils_messager_ext(debug_utils_messenger), XR_SUCCESS, - "Destroying the debug utils messenger for number of objects testing") - xrDestroyInstance(instance); - - // Path 5 - Test object names - - // Need a graphics binding for these tests - std::string gfx_bind_name; - const char* ext_name_array[2]; - switch (g_graphics_api_to_use) { - case GRAPHICS_API_D3D: - gfx_name = "XR_KHR_D3D11_enable"; - break; - case GRAPHICS_API_VULKAN: - gfx_name = "XR_KHR_vulkan_enable"; - break; - case GRAPHICS_API_OPENGL: - gfx_name = "XR_KHR_opengl_enable"; - break; - default: - TEST_FAIL("Unable to continue - no graphics binding extension found") - TEST_REPORT(TestDebugUtils) - return; - } - - ext_name_array[0] = gfx_name.c_str(); - ext_name_array[1] = dbg_ext_name; - - instance_ci.enabledExtensionNames = ext_name_array; - instance_ci.enabledExtensionCount = 2; - - TEST_EQUAL(xrCreateInstance(&instance_ci, &instance), XR_SUCCESS, "Creating instance for number of objects testing") - - // Get a function pointer to the various debug utils functions to test - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrCreateDebugUtilsMessengerEXT", - reinterpret_cast(&pfn_create_debug_utils_messager_ext)), - XR_SUCCESS, "TestDebugUtils get xrCreateDebugUtilsMessengerEXT function pointer"); - TEST_NOT_EQUAL(pfn_create_debug_utils_messager_ext, nullptr, - "TestDebugUtils invalid xrCreateDebugUtilsMessengerEXT function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrDestroyDebugUtilsMessengerEXT", - reinterpret_cast(&pfn_destroy_debug_utils_messager_ext)), - XR_SUCCESS, "TestDebugUtils get xrDestroyDebugUtilsMessengerEXT function pointer"); - TEST_NOT_EQUAL(pfn_destroy_debug_utils_messager_ext, nullptr, - "TestDebugUtils invalid xrDestroyDebugUtilsMessengerEXT function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrSubmitDebugUtilsMessageEXT", - reinterpret_cast(&pfn_submit_dmsg)), - XR_SUCCESS, "TestDebugUtils get xrSubmitDebugUtilsMessageEXT function pointer"); - TEST_NOT_EQUAL(pfn_submit_dmsg, nullptr, "TestDebugUtils invalid xrSubmitDebugUtilsMessageEXT function pointer"); - - // Create the debug utils messenger, but only to receive validation warning messages - debug_utils_messenger = XR_NULL_HANDLE; - dbg_msg_ci.messageSeverities = XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT; - dbg_msg_ci.messageTypes = XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; - TEST_EQUAL(pfn_create_debug_utils_messager_ext(instance, &dbg_msg_ci, &debug_utils_messenger), XR_SUCCESS, - "Creating the debug utils messenger for session labels testing") - - num_objects_matches = false; - object_contents_match = false; - - PFN_xrSetDebugUtilsObjectNameEXT pfn_set_obj_name; - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrSetDebugUtilsObjectNameEXT", - reinterpret_cast(&pfn_set_obj_name)), - XR_SUCCESS, "TestDebugUtils get xrSetDebugUtilsObjectNameEXT function pointer"); - TEST_NOT_EQUAL(pfn_set_obj_name, nullptr, "TestDebugUtils invalid xrSetDebugUtilsObjectNameEXT function pointer"); - strcpy(object_name, "My Instance Obj"); - object_handle = MakeHandleGeneric(instance); - objects[0].type = XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; - objects[0].next = nullptr; - objects[0].objectType = XR_OBJECT_TYPE_INSTANCE; - objects[0].objectHandle = object_handle; - objects[0].objectName = &object_name[0]; - TEST_EQUAL(pfn_set_obj_name(instance, &objects[0]), XR_SUCCESS, "Setting object name") - num_objects = 1; - callback_data.objectCount = static_cast(num_objects); - - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, - &callback_data); - TEST_EQUAL(num_objects_matches, true, "TestDebugUtils - Name Set: Objects Matches") - TEST_EQUAL(object_contents_match, true, "TestDebugUtils - Name Set: Object Content Matches") - num_objects_matches = false; - object_contents_match = false; - - XrSystemGetInfo system_get_info = {XR_TYPE_SYSTEM_GET_INFO}; - system_get_info.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY; - XrSystemId systemId; - TEST_EQUAL(xrGetSystem(instance, &system_get_info, &systemId), XR_SUCCESS, "xrGetSystem"); - - if (systemId != XR_NULL_SYSTEM_ID) { - void* graphics_binding = nullptr; - -#ifdef XR_USE_GRAPHICS_API_VULKAN - XrGraphicsBindingVulkanKHR vulkan_graphics_binding = {}; - if (g_graphics_api_to_use == GRAPHICS_API_VULKAN) { - PFN_xrGetVulkanInstanceExtensionsKHR pfn_get_vulkan_instance_extensions_khr; - PFN_xrGetVulkanDeviceExtensionsKHR pfn_get_vulkan_device_extensions_khr; - PFN_xrGetVulkanGraphicsDeviceKHR pfn_get_vulkan_graphics_device_khr; - PFN_xrGetVulkanGraphicsRequirementsKHR pfn_get_vulkan_graphics_requirements_khr; - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetVulkanInstanceExtensionsKHR", - reinterpret_cast(&pfn_get_vulkan_instance_extensions_khr)), - XR_SUCCESS, "TestDebugUtils get xrGetVulkanInstanceExtensionsKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_vulkan_instance_extensions_khr, nullptr, - "TestDebugUtils invalid xrGetVulkanInstanceExtensionsKHR function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetVulkanDeviceExtensionsKHR", - reinterpret_cast(&pfn_get_vulkan_device_extensions_khr)), - XR_SUCCESS, "TestDebugUtils get xrGetVulkanDeviceExtensionsKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_vulkan_device_extensions_khr, nullptr, - "TestDebugUtils invalid xrGetVulkanDeviceExtensionsKHR function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetVulkanGraphicsDeviceKHR", - reinterpret_cast(&pfn_get_vulkan_graphics_device_khr)), - XR_SUCCESS, "TestDebugUtils get xrGetVulkanGraphicsDeviceKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_vulkan_graphics_device_khr, nullptr, - "TestDebugUtils invalid xrGetVulkanGraphicsDeviceKHR function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetVulkanGraphicsRequirementsKHR", - reinterpret_cast(&pfn_get_vulkan_graphics_requirements_khr)), - XR_SUCCESS, "TestDebugUtils get xrGetVulkanGraphicsRequirementsKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_vulkan_graphics_requirements_khr, nullptr, - "TestDebugUtils invalid xrGetVulkanGraphicsRequirementsKHR function pointer"); - - XrGraphicsRequirementsVulkanKHR vulkan_graphics_requirements = {XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR}; - TEST_EQUAL(pfn_get_vulkan_graphics_requirements_khr(instance, systemId, &vulkan_graphics_requirements), XR_SUCCESS, - "TestDebugUtils calling xrGetVulkanGraphicsRequirementsKHR"); - - // TODO: Just need something other than NULL here for now (for validation). Eventually need - // to correctly put in a valid pointer to an Display - vulkan_graphics_binding.instance = VK_NULL_HANDLE; - vulkan_graphics_binding.physicalDevice = VK_NULL_HANDLE; - vulkan_graphics_binding.device = VK_NULL_HANDLE; - vulkan_graphics_binding.queueFamilyIndex = 0; - vulkan_graphics_binding.queueIndex = 0; - graphics_binding = reinterpret_cast(&vulkan_graphics_binding); - } -#endif // XR_USE_GRAPHICS_API_VULKAN -#ifdef XR_USE_GRAPHICS_API_OPENGL -#ifdef _WIN32 - XrGraphicsBindingOpenGLWin32KHR win32_gl_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR}; -#elif defined(OS_LINUX_XLIB) - XrGraphicsBindingOpenGLXlibKHR glx_gl_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR}; -#elif defined(OS_LINUX_XCB) || defined(OS_LINUX_XCB_GLX) - XrGraphicsBindingOpenGLXcbKHR xcb_gl_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_OPENGL_XCB_KHR}; -#elif defined(OS_LINUX_WAYLAND) - XrGraphicsBindingOpenGLWaylandKHR wayland_gl_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR}; -#endif - if (g_graphics_api_to_use == GRAPHICS_API_OPENGL) { - PFN_xrGetOpenGLGraphicsRequirementsKHR pfn_get_opengl_graphics_requirements_khr; - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetOpenGLGraphicsRequirementsKHR", - reinterpret_cast(&pfn_get_opengl_graphics_requirements_khr)), - XR_SUCCESS, "TestDebugUtils get xrGetOpenGLGraphicsRequirementsKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_opengl_graphics_requirements_khr, nullptr, - "TestDebugUtils invalid xrGetOpenGLGraphicsRequirementsKHR function pointer"); - XrGraphicsRequirementsOpenGLKHR opengl_graphics_requirements = {}; - TEST_EQUAL(pfn_get_opengl_graphics_requirements_khr(instance, systemId, &opengl_graphics_requirements), XR_SUCCESS, - "TestDebugUtils calling xrGetOpenGLGraphicsRequirementsKHR"); -#ifdef _WIN32 - graphics_binding = reinterpret_cast(&win32_gl_graphics_binding); -#elif defined(OS_LINUX_XLIB) - // TODO: Just need something other than NULL here for now (for validation). Eventually need - // to correctly put in a valid pointer to an Display - glx_gl_graphics_binding.xDisplay = reinterpret_cast(0xFFFFFFFF); - graphics_binding = reinterpret_cast(&glx_gl_graphics_binding); -#elif defined(OS_LINUX_XCB) || defined(OS_LINUX_XCB_GLX) - // TODO: Just need something other than NULL here for now (for validation). Eventually need - // to correctly put in a valid pointer to an xcb_connection_t - xcb_gl_graphics_binding.connection = reinterpret_cast(0xFFFFFFFF); - graphics_binding = reinterpret_cast(&xcb_gl_graphics_binding); -#elif defined(OS_LINUX_WAYLAND) - // TODO: Just need something other than NULL here for now (for validation). Eventually need - // to correctly put in a valid pointer to an wl_display - wayland_gl_graphics_binding.display = reinterpret_cast(0xFFFFFFFF); - graphics_binding = reinterpret_cast(&wayland_gl_graphics_binding); -#endif - } -#endif // XR_USE_GRAPHICS_API_OPENGL -#ifdef XR_USE_GRAPHICS_API_D3D11 - XrGraphicsBindingD3D11KHR d3d11_graphics_binding = {XR_TYPE_GRAPHICS_BINDING_D3D11_KHR}; - if (g_graphics_api_to_use == GRAPHICS_API_D3D) { - PFN_xrGetD3D11GraphicsRequirementsKHR pfn_get_d3d11_graphics_requirements_khr; - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrGetD3D11GraphicsRequirementsKHR", - reinterpret_cast(&pfn_get_d3d11_graphics_requirements_khr)), - XR_SUCCESS, "TestDebugUtils get xrGetD3D11GraphicsRequirementsKHR function pointer"); - TEST_NOT_EQUAL(pfn_get_d3d11_graphics_requirements_khr, nullptr, - "TestDebugUtils invalid xrGetD3D11GraphicsRequirementsKHR function pointer"); - XrGraphicsRequirementsD3D11KHR d3d11_graphics_requirements = {XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR}; - TEST_EQUAL(pfn_get_d3d11_graphics_requirements_khr(instance, systemId, &d3d11_graphics_requirements), XR_SUCCESS, - "TestDebugUtils calling xrGetD3D11GraphicsRequirementsKHR"); - - ID3D11Device* d3d_device; - HRESULT res = - D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, &d3d_device, NULL, NULL); - TEST_EQUAL(res, S_OK, "TestDebugUtils creating D3D11 reference device") - - d3d11_graphics_binding.device = d3d_device; - graphics_binding = reinterpret_cast(&d3d11_graphics_binding); - } -#endif // XR_USE_GRAPHICS_API_D3D11 - - // Get a function pointer to the various debug utils functions to test - PFN_xrSessionBeginDebugUtilsLabelRegionEXT pfn_begin_debug_utils_label_region_ext; - PFN_xrSessionEndDebugUtilsLabelRegionEXT pfn_end_debug_utils_label_region_ext; - PFN_xrSessionInsertDebugUtilsLabelEXT pfn_insert_debug_utils_label_ext; - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrSessionBeginDebugUtilsLabelRegionEXT", - reinterpret_cast(&pfn_begin_debug_utils_label_region_ext)), - XR_SUCCESS, "TestDebugUtils get xrSessionBeginDebugUtilsLabelRegionEXT function pointer"); - TEST_NOT_EQUAL(pfn_begin_debug_utils_label_region_ext, nullptr, - "TestDebugUtils invalid xrSessionBeginDebugUtilsLabelRegionEXT function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrSessionEndDebugUtilsLabelRegionEXT", - reinterpret_cast(&pfn_end_debug_utils_label_region_ext)), - XR_SUCCESS, "TestDebugUtils get xrSessionEndDebugUtilsLabelRegionEXT function pointer"); - TEST_NOT_EQUAL(pfn_end_debug_utils_label_region_ext, nullptr, - "TestDebugUtils invalid xrSessionEndDebugUtilsLabelRegionEXT function pointer"); - TEST_EQUAL(xrGetInstanceProcAddr(instance, "xrSessionInsertDebugUtilsLabelEXT", - reinterpret_cast(&pfn_insert_debug_utils_label_ext)), - XR_SUCCESS, "TestDebugUtils get xrSessionInsertDebugUtilsLabelEXT function pointer"); - TEST_NOT_EQUAL(pfn_insert_debug_utils_label_ext, nullptr, - "TestDebugUtils invalid xrSessionInsertDebugUtilsLabelEXT function pointer"); - - g_expecting_labels = true; - - // Create a label struct for initial testing - XrDebugUtilsLabelEXT first_label = {XR_TYPE_DEBUG_UTILS_LABEL_EXT}; - first_label.labelName = g_first_individual_label_name; - - // Create a session for us to begin - XrSession session; - XrSessionCreateInfo session_create_info = {XR_TYPE_SESSION_CREATE_INFO}; - session_create_info.systemId = systemId; - session_create_info.next = graphics_binding; - - TEST_EQUAL(xrCreateSession(instance, &session_create_info, &session), XR_SUCCESS, "xrCreateSession") - - // Set it up to put in the session and instance to any debug utils messages - num_objects = 2; - callback_data.objectCount = static_cast(num_objects); - objects[0].type = XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; - objects[0].next = nullptr; - objects[0].objectType = XR_OBJECT_TYPE_INSTANCE; - objects[0].objectHandle = MakeHandleGeneric(instance); - objects[0].objectName = nullptr; - objects[1].type = XR_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; - objects[1].next = nullptr; - objects[1].objectType = XR_OBJECT_TYPE_SESSION; - objects[1].objectHandle = MakeHandleGeneric(session); - objects[1].objectName = nullptr; - callback_data.objects = &objects[0]; - - // Try invalid session on each of the label functions - TEST_EQUAL(pfn_begin_debug_utils_label_region_ext(XR_NULL_HANDLE, &first_label), XR_ERROR_HANDLE_INVALID, - "TestDebugUtils calling xrSessionBeginDebugUtilsLabelRegionEXT with invalid session"); - TEST_EQUAL(pfn_end_debug_utils_label_region_ext(XR_NULL_HANDLE), XR_ERROR_HANDLE_INVALID, - "TestDebugUtils calling xrSessionEndDebugUtilsLabelRegionEXT with invalid session"); - TEST_EQUAL(pfn_insert_debug_utils_label_ext(XR_NULL_HANDLE, &first_label), XR_ERROR_HANDLE_INVALID, - "TestDebugUtils calling xrSessionInsertDebugUtilsLabelEXT with invalid session"); - - // Try with nullptr for the label - TEST_EQUAL(pfn_begin_debug_utils_label_region_ext(session, nullptr), XR_ERROR_VALIDATION_FAILURE, - "TestDebugUtils calling xrSessionBeginDebugUtilsLabelRegionEXT with NULL label"); - TEST_EQUAL(pfn_insert_debug_utils_label_ext(session, nullptr), XR_ERROR_VALIDATION_FAILURE, - "TestDebugUtils calling xrSessionInsertDebugUtilsLabelEXT with NULL label"); - - // Start an individual label - TEST_EQUAL(pfn_insert_debug_utils_label_ext(session, &first_label), XR_SUCCESS, - "TestDebugUtils calling xrSessionInsertDebugUtilsLabelEXT"); - - // Trigger a message and make sure we see "First individual label" - g_in_region_num = 0; - g_individual_label_num = 1; - g_captured_labels = false; - g_captured_only_expected_labels = false; - strcpy(message_id, "First Individual Label"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, - XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, &callback_data); - TEST_EQUAL(g_captured_labels, true, "TestDebugUtils - First Individual Label : Captured Labels") - TEST_EQUAL(g_captured_only_expected_labels, true, "TestDebugUtils - First Individual Label : Captured Correct Labels") - - // Begin a label region - first_label.labelName = g_first_label_region_name; - TEST_EQUAL(pfn_begin_debug_utils_label_region_ext(session, &first_label), XR_SUCCESS, - "TestDebugUtils calling xrSessionBeginDebugUtilsLabelRegionEXT"); - - // Trigger a message and make sure we see "Label Region" and not "First individual label" - g_in_region_num = 1; - g_individual_label_num = 0; - g_captured_labels = false; - g_captured_only_expected_labels = false; - strcpy(message_id, "First Label Region"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, - XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, &callback_data); - TEST_EQUAL(g_captured_labels, true, "TestDebugUtils - First Label Region : Captured Labels") - TEST_EQUAL(g_captured_only_expected_labels, true, "TestDebugUtils - First Label Region : Captured Correct Labels") - - // Begin the session now. - XrSessionBeginInfo session_begin_info = {XR_TYPE_SESSION_BEGIN_INFO}; - session_begin_info.primaryViewConfigurationType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO; - - TEST_EQUAL(xrBeginSession(session, &session_begin_info), XR_SUCCESS, "xrBeginSession") - - XrDebugUtilsLabelEXT individual_label = {XR_TYPE_DEBUG_UTILS_LABEL_EXT}; - individual_label.labelName = g_second_individual_label_name; - TEST_EQUAL(pfn_insert_debug_utils_label_ext(session, &individual_label), XR_SUCCESS, - "TestDebugUtils calling xrSessionInsertDebugUtilsLabelEXT"); - - // TODO: Trigger a message and make sure we see "Second individual" and "First Label Region" and not "First - // individual label" - g_in_region_num = 1; - g_individual_label_num = 2; - g_captured_labels = false; - g_captured_only_expected_labels = false; - strcpy(message_id, "Second Individual and First Region"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, - XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, &callback_data); - TEST_EQUAL(g_captured_labels, true, "TestDebugUtils - Second Individual and First Region : Captured Labels") - TEST_EQUAL(g_captured_only_expected_labels, true, - "TestDebugUtils - Second Individual and First Region : Captured Correct Labels") - - individual_label.labelName = g_third_individual_label_name; - TEST_EQUAL(pfn_insert_debug_utils_label_ext(session, &individual_label), XR_SUCCESS, - "TestDebugUtils calling xrSessionInsertDebugUtilsLabelEXT"); - - // TODO: Trigger a message and make sure we see "Third individual" and "First Label Region" and not "First - // individual label" or "Second individual label" - g_in_region_num = 1; - g_individual_label_num = 3; - g_captured_labels = false; - g_captured_only_expected_labels = false; - strcpy(message_id, "Third Individual and First Region"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, - XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, &callback_data); - TEST_EQUAL(g_captured_labels, true, "TestDebugUtils - Third Individual and First Region : Captured Labels") - TEST_EQUAL(g_captured_only_expected_labels, true, - "TestDebugUtils - Third Individual and First Region : Captured Correct Labels") - - // Begin a label region - XrDebugUtilsLabelEXT second_label_region = {XR_TYPE_DEBUG_UTILS_LABEL_EXT}; - second_label_region.labelName = g_second_label_region_name; - TEST_EQUAL(pfn_begin_debug_utils_label_region_ext(session, &second_label_region), XR_SUCCESS, - "TestDebugUtils calling xrSessionBeginDebugUtilsLabelRegionEXT"); - - // TODO: Trigger a message and make sure we see "Second Label Region" and "First Label Region" - g_in_region_num = 2; - g_individual_label_num = 0; - g_captured_labels = false; - g_captured_only_expected_labels = false; - strcpy(message_id, "Second and First Label Regions"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, - XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, &callback_data); - TEST_EQUAL(g_captured_labels, true, "TestDebugUtils - Second and First Label Regions : Captured Labels") - TEST_EQUAL(g_captured_only_expected_labels, true, - "TestDebugUtils - Second and First Label Regions : Captured Correct Labels") - - // End the last label region - TEST_EQUAL(pfn_end_debug_utils_label_region_ext(session), XR_SUCCESS, - "TestDebugUtils calling xrSessionEndDebugUtilsLabelRegionEXT"); - - // TODO: Trigger a message and make sure we see "First Label Region" - g_in_region_num = 1; - g_individual_label_num = 0; - g_captured_labels = false; - g_captured_only_expected_labels = false; - strcpy(message_id, "First Label Region 2"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, - XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, &callback_data); - TEST_EQUAL(g_captured_labels, true, "TestDebugUtils - First Label Region 2 : Captured Labels") - TEST_EQUAL(g_captured_only_expected_labels, true, "TestDebugUtils - First Label Region 2 : Captured Correct Labels") - - // Now clean-up - XrResult res = xrRequestExitSession(session); - TEST_EQUAL(res, XR_SUCCESS, "Exiting session") - res = xrEndSession(session); - TEST_EQUAL(res, XR_SUCCESS, "Ending session") - - // End the last label region - TEST_EQUAL(pfn_end_debug_utils_label_region_ext(session), XR_SUCCESS, - "TestDebugUtils calling xrSessionEndDebugUtilsLabelRegionEXT"); - - // TODO: Trigger a message and make sure we see no labels - g_expecting_labels = false; - g_in_region_num = 0; - g_individual_label_num = 0; - g_captured_labels = false; - g_captured_only_expected_labels = false; - strcpy(message_id, "No Labels"); - pfn_submit_dmsg(instance, XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, - XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, &callback_data); - TEST_EQUAL(g_captured_labels, false, "TestDebugUtils - No Labels : Captured Labels") - - TEST_EQUAL(xrDestroySession(session), XR_SUCCESS, "Destroying session") - -#ifdef XR_USE_GRAPHICS_API_D3D11 - if (d3d11_graphics_binding.device) d3d11_graphics_binding.device->Release(); -#endif - } - - // Destroy what we created - TEST_EQUAL(pfn_destroy_debug_utils_messager_ext(debug_utils_messenger), XR_SUCCESS, - "Destroying the debug utils messenger for number of objects testing") - - TEST_EQUAL(xrDestroyInstance(instance), XR_SUCCESS, "Destroying instance for individual message type/severity testing") + TEST_EQUAL(xrDestroyInstance(instance), XR_SUCCESS, "Destroying instance") } catch (...) { TEST_FAIL("Exception triggered during test, automatic failure") } @@ -2048,7 +722,7 @@ DEFINE_TEST(TestDebugUtils) { CleanupEnvironmentVariables(); // Output results for this test - TEST_REPORT(TestDebugUtils) + TEST_REPORT(TestCreateDestroyAction) } int main(int argc, char* argv[]) { @@ -2081,15 +755,11 @@ int main(int argc, char* argv[]) { cout << "----------------------------------------------------------" << endl; TestCreateDestroyInstance(total_tests, total_passed, total_skipped, total_failed); TestGetSystem(total_tests, total_passed, total_skipped, total_failed); - TestCreateDestroySession(total_tests, total_passed, total_skipped, total_failed); + TestCreateDestroyAction(total_tests, total_passed, total_skipped, total_failed); } else { cout << "No installed XR runtime detected - active runtime tests skipped(!)" << endl; } - if (g_debug_utils_exists) { - TestDebugUtils(total_tests, total_passed, total_skipped, total_failed); - } - #if FILTER_OUT_LOADER_ERRORS == 1 // Restore std::cerr to the original buffer std::cerr.rdbuf(original_cerr); diff --git a/src/tests/loader_test/loader_test_utils.cpp b/src/tests/loader_test/loader_test_utils.cpp index 583cc4b79..98a39f759 100644 --- a/src/tests/loader_test/loader_test_utils.cpp +++ b/src/tests/loader_test/loader_test_utils.cpp @@ -20,10 +20,6 @@ // Author: Dave Houlton // -#ifdef XR_USE_GRAPHICS_API_OPENGL -#include "gfxwrapper_opengl.h" // for GL Extensions -#endif - #include "loader_test_utils.hpp" #include "xr_dependencies.h" #include diff --git a/src/tests/loader_test/test_layers/XrApiLayer_test.def b/src/tests/loader_test/test_layers/XrApiLayer_test.def index 16cfc9fb1..81ad201ed 100644 --- a/src/tests/loader_test/test_layers/XrApiLayer_test.def +++ b/src/tests/loader_test/test_layers/XrApiLayer_test.def @@ -1,6 +1,3 @@ - -;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; ; Copyright (c) 2017-2023, The Khronos Group Inc. ; Copyright (c) 2017 Valve Corporation ; Copyright (c) 2017 LunarG, Inc. @@ -20,8 +17,6 @@ ; limitations under the License. ; ; Author: Mark Young -; -;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LIBRARY XrApiLayer_test EXPORTS diff --git a/src/tests/loader_test/test_runtimes/test_runtime.def b/src/tests/loader_test/test_runtimes/test_runtime.def index 099a07464..a8e2a6953 100644 --- a/src/tests/loader_test/test_runtimes/test_runtime.def +++ b/src/tests/loader_test/test_runtimes/test_runtime.def @@ -1,6 +1,3 @@ - -;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; ; Copyright (c) 2017-2023, The Khronos Group Inc. ; Copyright (c) 2017 Valve Corporation ; Copyright (c) 2017 LunarG, Inc. @@ -20,8 +17,6 @@ ; limitations under the License. ; ; Author: Mark Young -; -;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LIBRARY test_runtime EXPORTS