diff --git a/.editorconfig b/.editorconfig index 0220ac21..3a4c397f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/.env b/.env index e2773527..f2b97cd8 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023, The Khronos Group Inc. +# Copyright (c) 2022-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 9925f530..2caab1b9 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,4 +1,4 @@ -# Copyright 2021-2023, The Khronos Group Inc. Inc. +# Copyright 2021-2024, The Khronos Group Inc. Inc. # # SPDX-License-Identifier: CC-BY-4.0 diff --git a/.gitattributes b/.gitattributes index dcddd89a..fa2e3ac3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/.github/scripts/generate_windows_matrix_build.py b/.github/scripts/generate_windows_matrix_build.py index f8538b87..8b1cf83c 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-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 from itertools import product diff --git a/.github/scripts/install_vulkan.ps1 b/.github/scripts/install_vulkan.ps1 index 1f1c3d71..10f1d980 100644 --- a/.github/scripts/install_vulkan.ps1 +++ b/.github/scripts/install_vulkan.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023 The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 $ErrorActionPreference = 'Stop' diff --git a/.github/scripts/organize_windows_artifacts.py b/.github/scripts/organize_windows_artifacts.py index f40536ef..041c8b82 100644 --- a/.github/scripts/organize_windows_artifacts.py +++ b/.github/scripts/organize_windows_artifacts.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (c) 2019-2023 The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 from pathlib import Path diff --git a/.github/scripts/shared.py b/.github/scripts/shared.py index b9ab2e95..15b5899a 100644 --- a/.github/scripts/shared.py +++ b/.github/scripts/shared.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 import json diff --git a/.github/workflows/check_clang_format_and_codespell.yml b/.github/workflows/check_clang_format_and_codespell.yml index d807b660..d3f20353 100644 --- a/.github/workflows/check_clang_format_and_codespell.yml +++ b/.github/workflows/check_clang_format_and_codespell.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 name: Check code formatting and spelling diff --git a/.gitignore b/.gitignore index 3ea0a5d5..2e8bce12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/.mailmap b/.mailmap new file mode 100644 index 00000000..42a9016c --- /dev/null +++ b/.mailmap @@ -0,0 +1,24 @@ +# Copyright 2017-2024, The Khronos Group Inc. +# +# SPDX-License-Identifier: CC-BY-4.0 +# +# See mailmap docs: https://git-scm.com/docs/gitmailmap +# Please keep in sorted order. +# Generally, only add lines, unless you want to change the spelling +# of your name. +# Test by running git shortlog -s -e +# +# This mailmap is for **public repos** and should only be tested there. + +Blake Taylor +Bryce Hutchings +Bryce Hutchings <5100250+brycehutchings@users.noreply.github.com> +Bryce Hutchings +Khronos Group Web Services +Khronos Group Web Services +Rylie Pavlik +Rylie Pavlik +Rylie Pavlik +Yin Li +utzcoz +utzcoz <43091780+utzcoz@users.noreply.github.com> diff --git a/.proclamation.json.license b/.proclamation.json.license index 3b833d2d..e7fa4fbb 100644 --- a/.proclamation.json.license +++ b/.proclamation.json.license @@ -1,4 +1,4 @@ Copyright (c) 2020 Collabora, Ltd. and the Proclamation contributors -Copyright (c) 2020-2023, The Khronos Group Inc. +Copyright (c) 2020-2024, The Khronos Group Inc. SPDX-License-Identifier: CC0-1.0 diff --git a/.reuse/dep5 b/.reuse/dep5 index c905fc9a..02ee9cd1 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -1,6 +1,6 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: OpenXR -Upstream-Contact: Ryan Pavlik +Upstream-Contact: Rylie Pavlik Source: https://registry.khronos.org/OpenXR/ Files: changes/conformance/* @@ -10,11 +10,11 @@ Files: changes/conformance/* changes/README.md changes/template.md HOTFIX -Copyright: 2019-2023, The Khronos Group Inc. +Copyright: 2019-2024, The Khronos Group Inc. License: CC-BY-4.0 Files: specification/config/copyright-spec.adoc -Copyright: 2014-2023 The Khronos Group Inc +Copyright: 2014-2024, The Khronos Group Inc License: LicenseRef-KhronosSpecCopyright-WithNormativeWording-v10 Files: src/tests/hello_xr/android_resources/vulkan/mipmap-xxhdpi/ic_helloxr_launcher.png @@ -27,7 +27,7 @@ Files: src/tests/hello_xr/android_resources/vulkan/mipmap-xxhdpi/ic_helloxr_laun src/tests/hello_xr/android_resources/opengles/mipmap-xhdpi/ic_helloxr_launcher.png src/tests/hello_xr/android_resources/opengles/mipmap-hdpi/ic_helloxr_launcher.png src/tests/hello_xr/android_resources/opengles/mipmap-xxxhdpi/ic_helloxr_launcher.png -Copyright: Copyright (c) 2020-2023, The Khronos Group Inc. +Copyright: Copyright (c) 2020-2024, The Khronos Group Inc. Copyright (c) 2020, Google License: Apache-2.0 Comment: Based on a Material Icons asset ("emoji-people") with added text @@ -86,7 +86,7 @@ Comment: In-line license comments requested, https://gitlab.khronos.org/openxr/o 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. +Copyright: 2017-2024, The Khronos Group Inc. License: CC-BY-4.0 Comment: In-line license comments requested, https://gitlab.khronos.org/openxr/openxr/-/issues/1419 @@ -95,13 +95,13 @@ Files: src/conformance/platform_specific/android_resources/mipmap-hdpi/* src/conformance/platform_specific/android_resources/mipmap-xhdpi/* src/conformance/platform_specific/android_resources/mipmap-xxhdpi/* src/conformance/platform_specific/android_resources/mipmap-xxxhdpi/* -Copyright: 2020-2023, The Khronos Group Inc. +Copyright: 2020-2024, The Khronos Group Inc. 2020, Google License: Apache-2.0 Comment: Generated .png versions of an icon, created in Android Studio based on a Material Icons asset. Files: specification/scripts/vuidCounts.py -Copyright: 2022-2023, The Khronos Group Inc. +Copyright: 2022-2024, The Khronos Group Inc. License: Apache-2.0 Comment: File automatically rewritten by VUID assignment. diff --git a/BUILDING.md b/BUILDING.md index aa2a87c2..9e4335df 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,7 +1,7 @@ # How to Build and Run diff --git a/CHANGELOG.CTS.md b/CHANGELOG.CTS.md index a0c65b64..6ec26798 100644 --- a/CHANGELOG.CTS.md +++ b/CHANGELOG.CTS.md @@ -1,7 +1,7 @@ # Changelog for OpenXR-CTS Repo @@ -17,6 +17,55 @@ particular, since it is primarily software, pull requests may be integrated as they are accepted even between periodic updates. However, versions that are not signed tags on the `approved` branch are not valid for conformance submission. +## OpenXR CTS 1.0.33.0 (2024-01-18) + +- Conformance Tests + - Fix: Refactor Pbr::Model into an immutable Pbr::Model and Pbr::Instance that + holds the state for one drawn instance of the model. This corrects the known + issue in the self-tests mentioned in a previous changelog. + ([internal MR 3079](https://gitlab.khronos.org/openxr/openxr/merge_requests/3079), + [internal issue 2139](https://gitlab.khronos.org/openxr/openxr/issues/2139), + [internal MR 3141](https://gitlab.khronos.org/openxr/openxr/merge_requests/3141)) + - Fix: Avoid artificial error precedence requirement in test for + `XR_ERROR_GRAPHICS_DEVICE_INVALID`, by making sure to call the "check graphics + requirements" function if applicable. + ([internal MR 3093](https://gitlab.khronos.org/openxr/openxr/merge_requests/3093), + [internal issue 2155](https://gitlab.khronos.org/openxr/openxr/issues/2155)) + - Fix: Remove extra `xrSyncActions` call in `test_glTFRendering` to resolve + interaction issue. + ([internal MR 3107](https://gitlab.khronos.org/openxr/openxr/merge_requests/3107), + [internal issue 2163](https://gitlab.khronos.org/openxr/openxr/issues/2163)) + - Fix: Skip `XR_MSFT_controller_model` interactive test if extension is not + supported. + ([internal MR 3146](https://gitlab.khronos.org/openxr/openxr/merge_requests/3146), + [internal issue 2187](https://gitlab.khronos.org/openxr/openxr/issues/2187)) + - Improvement: Adjust `StringToPath` utility function to be easier to use. + ([internal MR 2076](https://gitlab.khronos.org/openxr/openxr/merge_requests/2076)) + - Improvement: Simplify how some tests refer to the main OpenXR handles. + ([internal MR 3023](https://gitlab.khronos.org/openxr/openxr/merge_requests/3023)) + - Improvement: Make `AutoBasicSession` use `EventReader` to support event + multiplexing. + ([internal MR 3023](https://gitlab.khronos.org/openxr/openxr/merge_requests/3023)) + - Improvement: Do not require system support for `XR_EXT_eye_gaze_interaction` + before running XrPath and interaction profile related tests. Paths are valid as + long as the extension is offered and enabled, regardless of whether there is + system support for eye tracking. + ([internal MR 3055](https://gitlab.khronos.org/openxr/openxr/merge_requests/3055)) + - Improvement: General code cleanup, warning fixes, clang-tidy fixes, and + refactoring to improve flexibility and maintainability. + ([internal MR 3082](https://gitlab.khronos.org/openxr/openxr/merge_requests/3082), + [internal MR 3023](https://gitlab.khronos.org/openxr/openxr/merge_requests/3023)) + - Improvement: On Android, log using the "FATAL" severity before triggering an + abort from the conformance layer. + ([internal MR 3087](https://gitlab.khronos.org/openxr/openxr/merge_requests/3087)) + - Improvement: Exclude loader negotiation functions (added to XML and ratified + spec in 1.0.33) from the list of functions automatically tested by the + conformance suite. + ([internal MR 3113](https://gitlab.khronos.org/openxr/openxr/merge_requests/3113)) + - New test: Check behavior for actions created without subaction paths, but + queried using subaction paths. + ([internal MR 3068](https://gitlab.khronos.org/openxr/openxr/merge_requests/3068)) + ## OpenXR CTS 1.0.32.1 (2023-12-14) A notable change in this release, is that the build system now checks for git diff --git a/CMakeLists.txt b/CMakeLists.txt index 50dbd254..28eabd1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 3742f93d..6365d162 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,6 +1,6 @@ diff --git a/COPYING.adoc b/COPYING.adoc index 473e7fdc..18c85fa6 100644 --- a/COPYING.adoc +++ b/COPYING.adoc @@ -1,6 +1,6 @@ = COPYING.adoc for the Khronos Group OpenXR projects -// Copyright (c) 2020-2023, The Khronos Group Inc. +// Copyright (c) 2020-2024, The Khronos Group Inc. // // SPDX-License-Identifier: CC-BY-4.0 diff --git a/HOTFIX b/HOTFIX deleted file mode 100644 index d00491fd..00000000 --- a/HOTFIX +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/LICENSES/LicenseRef-KhronosSpecCopyright-WithNormativeWording-v10.txt b/LICENSES/LicenseRef-KhronosSpecCopyright-WithNormativeWording-v10.txt index c0154fe3..9b7853b6 100644 --- a/LICENSES/LicenseRef-KhronosSpecCopyright-WithNormativeWording-v10.txt +++ b/LICENSES/LicenseRef-KhronosSpecCopyright-WithNormativeWording-v10.txt @@ -1,4 +1,4 @@ -Copyright (c) 2017-2023, The Khronos Group Inc. +Copyright (c) 2017-2024, The Khronos Group Inc. This Specification is protected by copyright laws and contains material proprietary to Khronos. diff --git a/README.md b/README.md index 1884334d..d4d45a1f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ OpenXR Conformance Test Suite ============================= diff --git a/checkCodespell b/checkCodespell index e5afb893..0a19e7c2 100755 --- a/checkCodespell +++ b/checkCodespell @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/external/include/CMakeLists.txt b/external/include/CMakeLists.txt index 83816147..e00abfbe 100644 --- a/external/include/CMakeLists.txt +++ b/external/include/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 0977a0bf..b983da5e 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/include/generated_header_list.txt b/include/generated_header_list.txt index 291d99b3..6ed8e33e 100644 --- a/include/generated_header_list.txt +++ b/include/generated_header_list.txt @@ -1,4 +1,5 @@ openxr.h +openxr_loader_negotiation.h openxr_platform.h openxr_reflection.h openxr_reflection_structs.h diff --git a/include/generated_header_list.txt.license b/include/generated_header_list.txt.license index f19e7160..35c53d8c 100644 --- a/include/generated_header_list.txt.license +++ b/include/generated_header_list.txt.license @@ -1,4 +1,4 @@ -Copyright (c) 2017-2023, The Khronos Group Inc. +Copyright (c) 2017-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/include/openxr/CMakeLists.txt b/include/openxr/CMakeLists.txt index c814df48..b95a60c3 100644 --- a/include/openxr/CMakeLists.txt +++ b/include/openxr/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/include/openxr/openxr_platform_defines.h b/include/openxr/openxr_platform_defines.h index 820b7b3e..cd07c913 100644 --- a/include/openxr/openxr_platform_defines.h +++ b/include/openxr/openxr_platform_defines.h @@ -1,5 +1,5 @@ /* -** Copyright (c) 2017-2023, The Khronos Group Inc. +** Copyright (c) 2017-2024, The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 OR MIT */ diff --git a/maintainer-scripts/archive-conformance.sh b/maintainer-scripts/archive-conformance.sh index 4c6ea4fa..d40e812c 100755 --- a/maintainer-scripts/archive-conformance.sh +++ b/maintainer-scripts/archive-conformance.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -39,6 +39,10 @@ TARNAME=OpenXR-CTS makeSubset "$TARNAME" $(getConformanceFilenames) ( cd github + + # Add the shared public .mailmap used in all GitHub projects derived from the internal openxr repo + add_to_tar "$TARNAME" .mailmap + # Add the shared COPYING.adoc used in all GitHub projects derived from the internal openxr repo add_to_tar "$TARNAME" COPYING.adoc diff --git a/maintainer-scripts/common.sh b/maintainer-scripts/common.sh index cce5a6f1..57761ac0 100644 --- a/maintainer-scripts/common.sh +++ b/maintainer-scripts/common.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/openxr-codespell.exclude b/openxr-codespell.exclude index 3e3e3645..fbc48b29 100644 --- a/openxr-codespell.exclude +++ b/openxr-codespell.exclude @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: CC-BY-4.0 # Lines that should be excluded from codespell - trailing newline required! diff --git a/runClangFormat.sh b/runClangFormat.sh index 2fb98a75..0a63c837 100755 --- a/runClangFormat.sh +++ b/runClangFormat.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/specification/.gitignore b/specification/.gitignore index 5b577284..49a2bf3c 100644 --- a/specification/.gitignore +++ b/specification/.gitignore @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 @@ -12,6 +12,7 @@ diffs/ # Artifacts from converting/checking RELAX-NG Compact schema. registry/registry.rng registry/regenerated.rnc +registry/regenerated.rnc.backup # Schematron-related files registry/schxslt-cli.jar diff --git a/specification/Makefile b/specification/Makefile index 136324f2..9bb35546 100644 --- a/specification/Makefile +++ b/specification/Makefile @@ -1,4 +1,4 @@ -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 @@ -32,7 +32,7 @@ ifneq (,$(strip $(VERY_STRICT))) ASCIIDOC := $(ASCIIDOC) --failure-level WARN endif -SPECREVISION = 1.0.32 +SPECREVISION = 1.0.33 REVISION_COMPONENTS = $(subst ., ,$(SPECREVISION)) MAJORMINORVER = $(word 1,$(REVISION_COMPONENTS)).$(word 2,$(REVISION_COMPONENTS)) @@ -133,10 +133,11 @@ config_stamp: HEADER_DIR := $(OUTDIR)/openxr HEADER := $(HEADER_DIR)/openxr.h PLATHEAD := $(HEADER_DIR)/openxr_platform.h +LOADERHEAD := $(HEADER_DIR)/openxr_loader_negotiation.h REFLECTHEADERS:= $(HEADER_DIR)/openxr_reflection.h \ $(HEADER_DIR)/openxr_reflection_structs.h \ $(HEADER_DIR)/openxr_reflection_parent_structs.h -GENHEADERS := $(HEADER) $(PLATHEAD) $(REFLECTHEADERS) +GENHEADERS := $(HEADER) $(PLATHEAD) $(LOADERHEAD) $(REFLECTHEADERS) DEFINESHEAD := $(HEADER_DIR)/openxr_platform_defines.h # Platform header (just copy) @@ -535,7 +536,7 @@ CHECK_MARKUP_SCRIPT = $(CURDIR)/checkMarkup # Edit the following line's "ignore_count" when the number of checkSpecLinks errors changes, # either by reducing (ensuring we keep the improvement) # or by increasing (if there's an error we can't resolve right now and don't want to break CI) -CHECK_SPEC_LINKS_SCRIPT = $(CURDIR)/scripts/check_spec_links.py --ignore_count=0 -Wall --include_warn +CHECK_SPEC_LINKS_SCRIPT = $(CURDIR)/scripts/check_spec_links.py --ignore_count=0 -Wall --include_warn -Werror # -Werror disabled for now because there are ~14 -Wrefpage_missing messages. # Would like those in the logs, but not in the count for build-breaking. @@ -631,7 +632,7 @@ clean_generated: # Clean generated targets as well as intermediates. clean clobber: clean_dirt clean_generated - $(RM) $(HEADER) $(PLATHEAD) $(REFLECTHEADERS) $(DEFINESHEAD) $(HTMLSPEC) $(PDFSPEC) $(PDFA4SPEC) $(STYLEGUIDE) $(LOADERGUIDE) $(CONFIG_STAMP_FN) + $(RM) $(HEADER) $(PLATHEAD) $(LOADERHEAD) $(REFLECTHEADERS) $(DEFINESHEAD) $(HTMLSPEC) $(PDFSPEC) $(PDFA4SPEC) $(STYLEGUIDE) $(LOADERGUIDE) $(CONFIG_STAMP_FN) # Clean up extracted code if [ -f $(EXAMPLES_MAKEFILE) ]; then $(MAKE) -f $(EXAMPLES_MAKEFILE) clean-examples; fi $(RM) $(EXAMPLES_MAKEFILE) diff --git a/specification/README.md b/specification/README.md index 45948c3b..bdab33d7 100644 --- a/specification/README.md +++ b/specification/README.md @@ -1,7 +1,7 @@ # Building the OpenXR Specification diff --git a/specification/registry/xr.xml b/specification/registry/xr.xml index 5b574cdd..a3520581 100644 --- a/specification/registry/xr.xml +++ b/specification/registry/xr.xml @@ -4,7 +4,7 @@ -Copyright (c) 2017-2023, The Khronos Group Inc. +Copyright (c) 2017-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 OR MIT @@ -31,12 +31,13 @@ maintained in the default branch of the Khronos OpenXR GitHub project. + - + - + @@ -49,7 +50,7 @@ maintained in the default branch of the Khronos OpenXR GitHub project. - + @@ -61,7 +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, 32) +#define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 33) + +#define XR_CURRENT_LOADER_API_LAYER_VERSION 1 + +#define XR_CURRENT_LOADER_RUNTIME_VERSION 1 + +#define XR_LOADER_INFO_STRUCT_VERSION 1 + +#define XR_API_LAYER_INFO_STRUCT_VERSION 1 + +#define XR_RUNTIME_INFO_STRUCT_VERSION 1 + +#define XR_API_LAYER_NEXT_INFO_STRUCT_VERSION 1 + +#define XR_API_LAYER_CREATE_INFO_STRUCT_VERSION 1 + +#define XR_API_LAYER_MAX_SETTINGS_PATH_SIZE 512 + #define XR_HAND_JOINT_COUNT_EXT 26 @@ -442,6 +461,7 @@ maintained in the default branch of the Khronos OpenXR GitHub project. XR_DEFINE_HANDLE(XrMarkerDetectorML) + @@ -697,6 +717,52 @@ maintained in the default branch of the Khronos OpenXR GitHub project. XrExtent2Di extent + + + XrLoaderInterfaceStructs structType + uint32_t structVersion + size_t structSize + uint32_t minInterfaceVersion + uint32_t maxInterfaceVersion + XrVersion minApiVersion + XrVersion maxApiVersion + + + XrLoaderInterfaceStructs structType + uint32_t structVersion + size_t structSize + uint32_t layerInterfaceVersion + XrVersion layerApiVersion + PFN_xrGetInstanceProcAddr getInstanceProcAddr + PFN_xrCreateApiLayerInstance createApiLayerInstance + + + XrLoaderInterfaceStructs structType + uint32_t structVersion + size_t structSize + uint32_t runtimeInterfaceVersion + XrVersion runtimeApiVersion + PFN_xrGetInstanceProcAddr getInstanceProcAddr + + + + XrLoaderInterfaceStructs structType + uint32_t structVersion + size_t structSize + char layerName[XR_MAX_API_LAYER_NAME_SIZE] + PFN_xrGetInstanceProcAddr nextGetInstanceProcAddr + PFN_xrCreateApiLayerInstance nextCreateApiLayerInstance + struct XrApiLayerNextInfo* next + + + XrLoaderInterfaceStructs structType + uint32_t structVersion + size_t structSize + void* loaderInstance + char settings_file_location[XR_API_LAYER_MAX_SETTINGS_PATH_SIZE] + XrApiLayerNextInfo* nextInfo + + XrBaseInStructure and XrBaseOutStructure use "struct" in their member definitions because they are recursive structures and this is easier than modifying the tooling @@ -1448,9 +1514,23 @@ maintained in the default branch of the Khronos OpenXR GitHub project. const void* next - + typedef void (XRAPI_PTR *PFN_xrVoidFunction)(void); + + typedef XrResult (XRAPI_PTR *PFN_xrGetInstanceProcAddr)(XrInstance instance, const char* name, PFN_xrVoidFunction* function); + + + + + + +typedef struct XrApiLayerCreateInfo XrApiLayerCreateInfo; +typedef XrResult (XRAPI_PTR *PFN_xrCreateApiLayerInstance)( + const XrInstanceCreateInfo* info, + const XrApiLayerCreateInfo* apiLayerInfo, + XrInstance* instance); + typedef XrBool32 (XRAPI_PTR *PFN_xrDebugUtilsMessengerCallbackEXT)( XrDebugUtilsMessageSeverityFlagsEXT messageSeverity, @@ -4049,6 +4129,16 @@ maintained in the default branch of the Khronos OpenXR GitHub project. + + + + + + + + + + @@ -4586,6 +4676,27 @@ maintained in the default branch of the Khronos OpenXR GitHub project. + + + + + XrResult xrNegotiateLoaderRuntimeInterface + const XrNegotiateLoaderInfo* loaderInfo + XrNegotiateRuntimeRequest* runtimeRequest + + + XrResult xrNegotiateLoaderApiLayerInterface + const XrNegotiateLoaderInfo* loaderInfo + const char* layerName + XrNegotiateApiLayerRequest* apiLayerRequest + + + XrResult xrCreateApiLayerInstance + const XrInstanceCreateInfo* info + const XrApiLayerCreateInfo* layerInfo + XrInstance* instance + + @@ -7054,12 +7165,30 @@ maintained in the default branch of the Khronos OpenXR GitHub project. + + + + + + + + + + + + + + + + + + - + @@ -7492,7 +7621,7 @@ maintained in the default branch of the Khronos OpenXR GitHub project. - + @@ -13617,6 +13746,166 @@ maintained in the default branch of the Khronos OpenXR GitHub project. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/specification/requirements.txt b/specification/requirements.txt index 59f5bdf8..b310979e 100644 --- a/specification/requirements.txt +++ b/specification/requirements.txt @@ -1,4 +1,4 @@ -# Copyright 2017-2023, The Khronos Group Inc. +# Copyright 2017-2024, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 # Optional but recommended for check spec links diff --git a/specification/scripts/__init__.py.docs b/specification/scripts/__init__.py.docs index 5ea88c80..ce7877b6 100644 --- a/specification/scripts/__init__.py.docs +++ b/specification/scripts/__init__.py.docs @@ -5,7 +5,7 @@ See also `src.scripts` for scripts that help build the loader and layers, many of which build on these scripts. """ -# Copyright (c) 2013-2023, The Khronos Group Inc. +# Copyright (c) 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/apiconventions.py b/specification/scripts/apiconventions.py index 75180217..33082040 100644 --- a/specification/scripts/apiconventions.py +++ b/specification/scripts/apiconventions.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2021-2023 The Khronos Group Inc. +# Copyright 2021-2024, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 # Generic alias for working group-specific API conventions interface. diff --git a/specification/scripts/cgenerator.py b/specification/scripts/cgenerator.py index 790579c8..316945e5 100644 --- a/specification/scripts/cgenerator.py +++ b/specification/scripts/cgenerator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 @@ -253,7 +253,7 @@ def endFeature(self): if self.genOpts.conventions is None: raise MissingGeneratorOptionsConventionsError() is_core = self.featureName and self.featureName.startswith(self.conventions.api_prefix + 'VERSION_') - if self.genOpts.conventions.writeFeature(self.featureExtraProtect, self.genOpts.filename): + if self.genOpts.conventions.writeFeature(self.featureName, self.featureExtraProtect, self.genOpts.filename): self.newline() if self.genOpts.protectFeature: write('#ifndef', self.featureName, file=self.outFile) diff --git a/specification/scripts/check_spec_links.py b/specification/scripts/check_spec_links.py index 5408affa..d4baa3ca 100755 --- a/specification/scripts/check_spec_links.py +++ b/specification/scripts/check_spec_links.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik # # Purpose: This file performs some basic checks of the custom macros # used in the AsciiDoctor source for the spec, especially diff --git a/specification/scripts/check_stamp.py b/specification/scripts/check_stamp.py index 3f13f8c5..32778dff 100755 --- a/specification/scripts/check_stamp.py +++ b/specification/scripts/check_stamp.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # -# Author: Ryan Pavlik +# Author: Rylie Pavlik """Pass a filename and any arguments. Will use those arguments to create a stamp file to monitor for changes.""" import sys from pathlib import Path diff --git a/specification/scripts/comment_convert.py b/specification/scripts/comment_convert.py index f1fa938c..518eb580 100755 --- a/specification/scripts/comment_convert.py +++ b/specification/scripts/comment_convert.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik # # Purpose: This script converts leading comments on some Python # classes and functions into docstrings. diff --git a/specification/scripts/creflectiongenerator.py b/specification/scripts/creflectiongenerator.py index 37087390..4fd5f27f 100644 --- a/specification/scripts/creflectiongenerator.py +++ b/specification/scripts/creflectiongenerator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2013-2023, The Khronos Group Inc. +# Copyright (c) 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/specification/scripts/docgenerator.py b/specification/scripts/docgenerator.py index 832498e1..c8ea1d3b 100644 --- a/specification/scripts/docgenerator.py +++ b/specification/scripts/docgenerator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/extdependency.py b/specification/scripts/extdependency.py index 5df72429..e2ad0109 100755 --- a/specification/scripts/extdependency.py +++ b/specification/scripts/extdependency.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2017-2023 The Khronos Group Inc. +# Copyright 2017-2024, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 """Generate a mapping of extension name -> all required extension names for diff --git a/specification/scripts/extensionmetadocgenerator.py b/specification/scripts/extensionmetadocgenerator.py index 593bf8a8..001cf864 100644 --- a/specification/scripts/extensionmetadocgenerator.py +++ b/specification/scripts/extensionmetadocgenerator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/extract_code.py b/specification/scripts/extract_code.py index a13ca087..e95f4fb7 100644 --- a/specification/scripts/extract_code.py +++ b/specification/scripts/extract_code.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik # # Purpose: This script searches for and extracts embedded source code # from specification chapters. diff --git a/specification/scripts/findBareNormatives.sh b/specification/scripts/findBareNormatives.sh index a5477b52..e06d5e0f 100755 --- a/specification/scripts/findBareNormatives.sh +++ b/specification/scripts/findBareNormatives.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2018-2023, The Khronos Group Inc. +# Copyright (c) 2018-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/genRef.py b/specification/scripts/genRef.py index 04184010..0f9b477b 100644 --- a/specification/scripts/genRef.py +++ b/specification/scripts/genRef.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright 2016-2023 The Khronos Group Inc. +# Copyright 2016-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 @@ -76,7 +76,7 @@ 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('// Copyright 2014-2024, 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) diff --git a/specification/scripts/genanchorlinks.py b/specification/scripts/genanchorlinks.py index e4296172..a5d7106f 100644 --- a/specification/scripts/genanchorlinks.py +++ b/specification/scripts/genanchorlinks.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright 2020-2023 The Khronos Group Inc. +# Copyright 2020-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/generator.py b/specification/scripts/generator.py index 4f5019ed..226fc7b7 100644 --- a/specification/scripts/generator.py +++ b/specification/scripts/generator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 """Base class for source/header/doc generators, as well as some utility functions.""" diff --git a/specification/scripts/genxr.py b/specification/scripts/genxr.py index 875de43a..74940eeb 100755 --- a/specification/scripts/genxr.py +++ b/specification/scripts/genxr.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 @@ -109,7 +109,7 @@ def makeGenOpts(args): # Copyright text prefixing all headers (list of strings). prefixStrings = [ '/*', - '** Copyright 2017-2023 The Khronos Group Inc.', + '** Copyright 2017-2024, The Khronos Group Inc.', '**', # The following split string is to avoid confusing the "REUSE" tool '** SPDX-License-Identifier' + ': Apache-2.0 OR MIT', @@ -255,6 +255,37 @@ def makeGenOpts(args): aliasMacro = 'XR_MAY_ALIAS') ] + genOpts['openxr_loader_negotiation.h'] = [ + COutputGenerator, + CGeneratorOptions( + conventions = conventions, + filename = 'openxr_loader_negotiation.h', + directory = directory, + apiname = 'openxr', + profile = None, + versions = featuresPat, + emitversions = featuresPat, + defaultExtensions = 'openxr', + addExtensions = None, + removeExtensions = None, + emitExtensions = emitExtensionsPat, + prefixText = prefixStrings + xrPrefixStrings + platformPrefixStrings, + genFuncPointers = True, + protectFile = protectFile, + protectFeature = False, + protectProto = '#ifndef', + protectProtoStr = 'XR_NO_PROTOTYPES', + protectExtensionProto = '#ifdef', + protectExtensionProtoStr = 'XR_EXTENSION_PROTOTYPES', + apicall = 'XRAPI_ATTR ', + apientry = 'XRAPI_CALL ', + apientryp = 'XRAPI_PTR *', + alignFuncParam = 48, + genAliasMacro = True, + genStructExtendsComment = True, + aliasMacro = 'XR_MAY_ALIAS') + ] + def make_reflection_options(fn): return CGeneratorOptions( conventions=conventions, diff --git a/specification/scripts/hostsyncgenerator.py b/specification/scripts/hostsyncgenerator.py index b9435677..57e592f1 100644 --- a/specification/scripts/hostsyncgenerator.py +++ b/specification/scripts/hostsyncgenerator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/indexgenerator.py b/specification/scripts/indexgenerator.py index ae93fa44..a70de7e3 100644 --- a/specification/scripts/indexgenerator.py +++ b/specification/scripts/indexgenerator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2013-2023, The Khronos Group Inc. +# Copyright (c) 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/jinja_helpers.py b/specification/scripts/jinja_helpers.py index dcc954ae..95495c10 100644 --- a/specification/scripts/jinja_helpers.py +++ b/specification/scripts/jinja_helpers.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # Copyright (c) 2019 Collabora, Ltd. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/pdf-index-customizer.rb b/specification/scripts/pdf-index-customizer.rb index 9feaad67..5628564e 100644 --- a/specification/scripts/pdf-index-customizer.rb +++ b/specification/scripts/pdf-index-customizer.rb @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023, The Khronos Group Inc. +# Copyright (c) 2020-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/pdf_chapter_diff.py b/specification/scripts/pdf_chapter_diff.py index b9431355..2cd8ba68 100755 --- a/specification/scripts/pdf_chapter_diff.py +++ b/specification/scripts/pdf_chapter_diff.py @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik # # Purpose: This script helps drive a per-section PDF diff. diff --git a/specification/scripts/pygenerator.py b/specification/scripts/pygenerator.py index 6e0e8f98..286ed6c5 100644 --- a/specification/scripts/pygenerator.py +++ b/specification/scripts/pygenerator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/realign.py b/specification/scripts/realign.py index 633fbf60..f2caf6c0 100755 --- a/specification/scripts/realign.py +++ b/specification/scripts/realign.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright (c) 2013-2023, The Khronos Group Inc. +# Copyright (c) 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/reflib.py b/specification/scripts/reflib.py index 4a0c2e1e..5543fcbc 100644 --- a/specification/scripts/reflib.py +++ b/specification/scripts/reflib.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright 2016-2023 The Khronos Group Inc. +# Copyright 2016-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/reflow.py b/specification/scripts/reflow.py index 8c842fc4..79e24849 100755 --- a/specification/scripts/reflow.py +++ b/specification/scripts/reflow.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright 2016-2023 The Khronos Group Inc. +# Copyright 2016-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/reg.py b/specification/scripts/reg.py index ebe7840c..90359b2a 100755 --- a/specification/scripts/reg.py +++ b/specification/scripts/reg.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/reserve_extensions.py b/specification/scripts/reserve_extensions.py index abe3dde2..6a0d302a 100755 --- a/specification/scripts/reserve_extensions.py +++ b/specification/scripts/reserve_extensions.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright 2020-2023 The Khronos Group Inc. +# Copyright 2020-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 """ diff --git a/specification/scripts/rubygenerator.py b/specification/scripts/rubygenerator.py index 283f09f7..2b11e0c6 100644 --- a/specification/scripts/rubygenerator.py +++ b/specification/scripts/rubygenerator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/scriptgenerator.py b/specification/scripts/scriptgenerator.py index bfddc64f..b96ea4e0 100644 --- a/specification/scripts/scriptgenerator.py +++ b/specification/scripts/scriptgenerator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/spec-macros.rb b/specification/scripts/spec-macros.rb index e1ab5808..211b089d 100644 --- a/specification/scripts/spec-macros.rb +++ b/specification/scripts/spec-macros.rb @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2023, The Khronos Group Inc. +# Copyright (c) 2016-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/spec-macros/extension.rb b/specification/scripts/spec-macros/extension.rb index fdf4dcc4..06b445ad 100644 --- a/specification/scripts/spec-macros/extension.rb +++ b/specification/scripts/spec-macros/extension.rb @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2023, The Khronos Group Inc. +# Copyright (c) 2016-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/spec_tools/__init__.py b/specification/scripts/spec_tools/__init__.py index 34c01f39..553ec1ab 100644 --- a/specification/scripts/spec_tools/__init__.py +++ b/specification/scripts/spec_tools/__init__.py @@ -4,4 +4,4 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik diff --git a/specification/scripts/spec_tools/algo.py b/specification/scripts/spec_tools/algo.py index cea9a98e..8af0f0ca 100644 --- a/specification/scripts/spec_tools/algo.py +++ b/specification/scripts/spec_tools/algo.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik """RecursiveMemoize serves as a base class for a function modeled as a dictionary computed on-the-fly.""" diff --git a/specification/scripts/spec_tools/attributes.py b/specification/scripts/spec_tools/attributes.py index 63b6cb1a..26338e8a 100644 --- a/specification/scripts/spec_tools/attributes.py +++ b/specification/scripts/spec_tools/attributes.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 """Utilities for working with attributes of the XML registry.""" diff --git a/specification/scripts/spec_tools/base_printer.py b/specification/scripts/spec_tools/base_printer.py index f48905ac..a3e0a4a4 100644 --- a/specification/scripts/spec_tools/base_printer.py +++ b/specification/scripts/spec_tools/base_printer.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik from abc import ABC, abstractmethod from pathlib import Path diff --git a/specification/scripts/spec_tools/consistency_tools.py b/specification/scripts/spec_tools/consistency_tools.py index cc123c4a..d45e92af 100644 --- a/specification/scripts/spec_tools/consistency_tools.py +++ b/specification/scripts/spec_tools/consistency_tools.py @@ -1,11 +1,11 @@ #!/usr/bin/python3 -i # # Copyright (c) 2019 Collabora, Ltd. -# Copyright (c) 2018-2023, The Khronos Group Inc. +# Copyright (c) 2018-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik """Provides utilities to write a script to verify XML registry consistency.""" import re diff --git a/specification/scripts/spec_tools/console_printer.py b/specification/scripts/spec_tools/console_printer.py index 7d69aac2..2b46a4f7 100644 --- a/specification/scripts/spec_tools/console_printer.py +++ b/specification/scripts/spec_tools/console_printer.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik from sys import stdout diff --git a/specification/scripts/spec_tools/conventions.py b/specification/scripts/spec_tools/conventions.py index bb862c80..48f08d2c 100644 --- a/specification/scripts/spec_tools/conventions.py +++ b/specification/scripts/spec_tools/conventions.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 @@ -282,7 +282,7 @@ def EXT_prefix(self): May override.""" return self.api_prefix + 'EXT_' - def writeFeature(self, featureExtraProtect, filename): + def writeFeature(self, featureName, featureExtraProtect, filename): """Return True if OutputGenerator.endFeature should write this feature. Defaults to always True. diff --git a/specification/scripts/spec_tools/data_structures.py b/specification/scripts/spec_tools/data_structures.py index f2808cf1..008d1405 100644 --- a/specification/scripts/spec_tools/data_structures.py +++ b/specification/scripts/spec_tools/data_structures.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik """Provides general-purpose data structures.""" diff --git a/specification/scripts/spec_tools/entity_db.py b/specification/scripts/spec_tools/entity_db.py index 128f87a6..4497a500 100644 --- a/specification/scripts/spec_tools/entity_db.py +++ b/specification/scripts/spec_tools/entity_db.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik from abc import ABC, abstractmethod diff --git a/specification/scripts/spec_tools/file_process.py b/specification/scripts/spec_tools/file_process.py index f0d4c608..bfc1e0c9 100644 --- a/specification/scripts/spec_tools/file_process.py +++ b/specification/scripts/spec_tools/file_process.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik "Utilities for processing files." from pathlib import Path diff --git a/specification/scripts/spec_tools/html_printer.py b/specification/scripts/spec_tools/html_printer.py index 3ec87afe..79b5a1cf 100644 --- a/specification/scripts/spec_tools/html_printer.py +++ b/specification/scripts/spec_tools/html_printer.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik import html import re diff --git a/specification/scripts/spec_tools/macro_checker.py b/specification/scripts/spec_tools/macro_checker.py index 17f42e2c..f85b0a2b 100644 --- a/specification/scripts/spec_tools/macro_checker.py +++ b/specification/scripts/spec_tools/macro_checker.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik from io import StringIO import re diff --git a/specification/scripts/spec_tools/macro_checker_file.py b/specification/scripts/spec_tools/macro_checker_file.py index 46c9c2ad..02c3923c 100644 --- a/specification/scripts/spec_tools/macro_checker_file.py +++ b/specification/scripts/spec_tools/macro_checker_file.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik import logging import re diff --git a/specification/scripts/spec_tools/main.py b/specification/scripts/spec_tools/main.py index 2cd4f69c..6fe4d663 100644 --- a/specification/scripts/spec_tools/main.py +++ b/specification/scripts/spec_tools/main.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik import argparse diff --git a/specification/scripts/spec_tools/shared.py b/specification/scripts/spec_tools/shared.py index 3bb6d773..8db1b9ac 100644 --- a/specification/scripts/spec_tools/shared.py +++ b/specification/scripts/spec_tools/shared.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik import platform from collections import namedtuple diff --git a/specification/scripts/spec_tools/util.py b/specification/scripts/spec_tools/util.py index bf258450..07e973fd 100644 --- a/specification/scripts/spec_tools/util.py +++ b/specification/scripts/spec_tools/util.py @@ -1,6 +1,6 @@ """Utility functions not closely tied to other spec_tools types.""" # Copyright (c) 2018-2019 Collabora, Ltd. -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/spec_tools/validity.py b/specification/scripts/spec_tools/validity.py index 18f9f979..5271159d 100644 --- a/specification/scripts/spec_tools/validity.py +++ b/specification/scripts/spec_tools/validity.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/template_openxr_reflection.h b/specification/scripts/template_openxr_reflection.h index 030d7a9b..664a5d1d 100644 --- a/specification/scripts/template_openxr_reflection.h +++ b/specification/scripts/template_openxr_reflection.h @@ -2,7 +2,7 @@ #define OPENXR_REFLECTION_H_ 1 /* -** Copyright (c) 2017-2023, The Khronos Group Inc. +** Copyright (c) 2017-2024, The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 OR MIT */ diff --git a/specification/scripts/template_openxr_reflection_parent_structs.h b/specification/scripts/template_openxr_reflection_parent_structs.h index 1ae31639..d0b7923f 100644 --- a/specification/scripts/template_openxr_reflection_parent_structs.h +++ b/specification/scripts/template_openxr_reflection_parent_structs.h @@ -2,7 +2,7 @@ #define OPENXR_REFLECTION_PARENT_STRUCTS_H_ 1 /* -** Copyright (c) 2017-2023, The Khronos Group Inc. +** Copyright (c) 2017-2024, The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 OR MIT */ diff --git a/specification/scripts/template_openxr_reflection_structs.h b/specification/scripts/template_openxr_reflection_structs.h index 04f26f23..f660dc94 100644 --- a/specification/scripts/template_openxr_reflection_structs.h +++ b/specification/scripts/template_openxr_reflection_structs.h @@ -2,7 +2,7 @@ #define OPENXR_REFLECTION_STRUCTS_H_ 1 /* -** Copyright (c) 2017-2023, The Khronos Group Inc. +** Copyright (c) 2017-2024, The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 OR MIT */ diff --git a/specification/scripts/test_check_spec_links.py b/specification/scripts/test_check_spec_links.py index b5426470..4cea508c 100644 --- a/specification/scripts/test_check_spec_links.py +++ b/specification/scripts/test_check_spec_links.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik # # Purpose: This file contains tests for check_spec_links.py diff --git a/specification/scripts/test_check_spec_links_api_specific.py b/specification/scripts/test_check_spec_links_api_specific.py index 4f44b606..16db1b89 100644 --- a/specification/scripts/test_check_spec_links_api_specific.py +++ b/specification/scripts/test_check_spec_links_api_specific.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik # # Purpose: This file contains tests for check_spec_links.py # that depend on the API being used. diff --git a/specification/scripts/test_entity_db.py b/specification/scripts/test_entity_db.py index 76ac5ae9..a8d6a564 100644 --- a/specification/scripts/test_entity_db.py +++ b/specification/scripts/test_entity_db.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik import pytest diff --git a/specification/scripts/update_version.py b/specification/scripts/update_version.py index 5f58e355..ac0603ac 100755 --- a/specification/scripts/update_version.py +++ b/specification/scripts/update_version.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright (c) 2018-2023, The Khronos Group Inc. +# Copyright (c) 2018-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/validitygenerator.py b/specification/scripts/validitygenerator.py index fee73641..3f0904c5 100644 --- a/specification/scripts/validitygenerator.py +++ b/specification/scripts/validitygenerator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2013-2023, The Khronos Group Inc. +# Copyright (c) 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/specification/scripts/xml_consistency.py b/specification/scripts/xml_consistency.py index 60e8f660..9d63a8e3 100755 --- a/specification/scripts/xml_consistency.py +++ b/specification/scripts/xml_consistency.py @@ -1,11 +1,11 @@ #!/usr/bin/python3 # # Copyright (c) 2019 Collabora, Ltd. -# Copyright (c) 2018-2023, The Khronos Group Inc. +# Copyright (c) 2018-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # -# Author(s): Ryan Pavlik +# Author(s): Rylie Pavlik # # Purpose: This script checks some "business logic" in the XML registry. @@ -181,6 +181,23 @@ def __init__(self): # Keys are entity names, values are tuples or lists of message text to suppress. suppressions: Dict[str, Union[Tuple[str, ...], List[str]]] = { + # xrCreateApiLayerInstance has a very constrained list of code specified in the spec + "xrCreateApiLayerInstance": ( + "Missing expected return code(s) XR_ERROR_LIMIT_REACHED,XR_ERROR_OUT_OF_MEMORY implied because of the name of this command", + "Missing expected return code(s) XR_ERROR_OUT_OF_MEMORY,XR_ERROR_LIMIT_REACHED implied because of the name of this command", + "Missing expected return code(s) XR_ERROR_HANDLE_INVALID,XR_ERROR_INSTANCE_LOST implied because of input of type XrInstance", + "Missing expected return code(s) XR_ERROR_INSTANCE_LOST,XR_ERROR_HANDLE_INVALID implied because of input of type XrInstance", + ), + # XrLoaderInterfaceStructs doesn't match the OpenXR pattern :( + "XrLoaderInterfaceStructs": ( + "Got an enum value whose name does not match the pattern: got XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO but expected something that started with XR_LOADER_INTERFACE_STRUCTS_ due to typename being XrLoaderInterfaceStructs", + "Got an enum value whose name does not match the pattern: got XR_LOADER_INTERFACE_STRUCT_UNINTIALIZED but expected something that started with XR_LOADER_INTERFACE_STRUCTS_ due to typename being XrLoaderInterfaceStructs", + "Got an enum value whose name does not match the pattern: got XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST but expected something that started with XR_LOADER_INTERFACE_STRUCTS_ due to typename being XrLoaderInterfaceStructs", + "Got an enum whose name does not match the pattern: the type is XrLoaderInterfaceStructs which would cause values to start with XR_LOADER_INTERFACE_STRUCTS_ but got a different longest common prefix XR_LOADER_INTERFACE_STRUCT_", + "Got an enum value whose name does not match the pattern: got XR_LOADER_INTERFACE_STRUCT_LOADER_INFO but expected something that started with XR_LOADER_INTERFACE_STRUCTS_ due to typename being XrLoaderInterfaceStructs", + "Got an enum value whose name does not match the pattern: got XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO but expected something that started with XR_LOADER_INTERFACE_STRUCTS_ due to typename being XrLoaderInterfaceStructs", + "Got an enum value whose name does not match the pattern: got XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST but expected something that started with XR_LOADER_INTERFACE_STRUCTS_ due to typename being XrLoaderInterfaceStructs", + ), # path to string can take any path "xrPathToString": ("Missing expected return code(s) XR_ERROR_PATH_UNSUPPORTED implied because of input of type XrPath",), # Just a case error, vendor declined to modify diff --git a/specification/scripts/xrconventions.py b/specification/scripts/xrconventions.py index 0c650699..705a8543 100644 --- a/specification/scripts/xrconventions.py +++ b/specification/scripts/xrconventions.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2013-2023, The Khronos Group Inc. +# Copyright (c) 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 @@ -144,7 +144,7 @@ def write_refpage_include(self): """Return whether refpage include should be written to extension appendices""" return True - def writeFeature(self, featureExtraProtect, filename): + def writeFeature(self, featureName, featureExtraProtect, filename): """Returns True if OutputGenerator.endFeature should write this feature. Used in COutputGenerator. @@ -155,9 +155,17 @@ def writeFeature(self, featureExtraProtect, filename): if filename == 'openxr_reflection.h': # Write all features to the reflection header return True + is_loader = featureName == 'XR_LOADER_VERSION_1_0' is_protected = featureExtraProtect is not None is_platform_header = (filename == 'openxr_platform.h') + # Only write loader spec to loader file. + if is_loader: + return filename == 'openxr_loader_negotiation.h' + + if filename == 'openxr_loader_negotiation.h': + return False + # non-protected goes in non-platform header, # protected goes in platform header. return is_protected == is_platform_header diff --git a/src/.clang-format b/src/.clang-format index cc6d80f7..97ad7fb0 100644 --- a/src/.clang-format +++ b/src/.clang-format @@ -1,5 +1,5 @@ --- -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # Use defaults from the Google style with the following exceptions: diff --git a/src/.gitignore b/src/.gitignore index 54f01d42..b50a8147 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d055b7a7..e618325f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/src/cmake/FindEGL.cmake b/src/cmake/FindEGL.cmake index c4f6c8b4..7bc836ff 100644 --- a/src/cmake/FindEGL.cmake +++ b/src/cmake/FindEGL.cmake @@ -40,7 +40,7 @@ #============================================================================= # Copyright 2014 Alex Merry # Copyright 2014 Martin Gräßlin -# Copyright 2019, 2021 Ryan Pavlik +# Copyright 2019, 2021 Rylie Pavlik # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/src/cmake/FindJsonCpp.cmake b/src/cmake/FindJsonCpp.cmake index e1010056..2a321122 100644 --- a/src/cmake/FindJsonCpp.cmake +++ b/src/cmake/FindJsonCpp.cmake @@ -22,7 +22,7 @@ # JSONCPP_FOUND - True if JsonCpp was found. # # Original Author: -# 2016 Ryan Pavlik +# 2016 Rylie Pavlik # Incorporates work from the module contributed to VRPN under the same license: # 2011 Philippe Crassous (ENSAM ParisTech / Institut Image) p.crassous _at_ free.fr # diff --git a/src/cmake/FindOpenGLES.cmake b/src/cmake/FindOpenGLES.cmake index e024df8f..bd630154 100644 --- a/src/cmake/FindOpenGLES.cmake +++ b/src/cmake/FindOpenGLES.cmake @@ -5,7 +5,7 @@ # http://www.boost.org/LICENSE_1_0.txt) # # Original Author: -# 2020-2021, Ryan Pavlik +# 2020-2021, Rylie Pavlik #[[.rst: FindOpenGLES diff --git a/src/cmake/GetGitRevisionDescription.cmake b/src/cmake/GetGitRevisionDescription.cmake index bee0fba5..5a6765f0 100644 --- a/src/cmake/GetGitRevisionDescription.cmake +++ b/src/cmake/GetGitRevisionDescription.cmake @@ -32,11 +32,11 @@ # Requires CMake 2.6 or newer (uses the 'function' command) # # Original Author: -# 2009-2020 Ryan Pavlik -# http://academic.cleardefinition.com +# 2009-2020 Rylie Pavlik +# https://ryliepavlik.com/ # # Copyright 2009-2013, Iowa State University. -# Copyright 2013-2020, Ryan Pavlik +# Copyright 2013-2020, Rylie Pavlik # Copyright 2013-2020, Contributors # SPDX-License-Identifier: BSL-1.0 # Distributed under the Boost Software License, Version 1.0. diff --git a/src/cmake/GetGitRevisionDescription.cmake.in b/src/cmake/GetGitRevisionDescription.cmake.in index 462edb68..06335665 100644 --- a/src/cmake/GetGitRevisionDescription.cmake.in +++ b/src/cmake/GetGitRevisionDescription.cmake.in @@ -4,8 +4,8 @@ # Requires CMake 2.6 or newer (uses the 'function' command) # # Original Author: -# 2009-2023 Ryan Pavlik -# http://academic.cleardefinition.com +# 2009-2023 Rylie Pavlik +# https://ryliepavlik.com/ # Iowa State University HCI Graduate Program/VRAC # # Copyright 2009-2012, Iowa State University diff --git a/src/cmake/fxc_shader.cmake b/src/cmake/fxc_shader.cmake index 5d4cfa66..d4e56868 100644 --- a/src/cmake/fxc_shader.cmake +++ b/src/cmake/fxc_shader.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/cmake/glsl_shader.cmake b/src/cmake/glsl_shader.cmake index 7fa56360..8886094e 100644 --- a/src/cmake/glsl_shader.cmake +++ b/src/cmake/glsl_shader.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/cmake/make_includable.cmake b/src/cmake/make_includable.cmake index 4002c3a2..faf2dc78 100644 --- a/src/cmake/make_includable.cmake +++ b/src/cmake/make_includable.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/cmake/metaconfig.cmake.in b/src/cmake/metaconfig.cmake.in index 0353e58a..e082ceb0 100644 --- a/src/cmake/metaconfig.cmake.in +++ b/src/cmake/metaconfig.cmake.in @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/src/cmake/presentation.cmake b/src/cmake/presentation.cmake index 26363856..c8e7969f 100644 --- a/src/cmake/presentation.cmake +++ b/src/cmake/presentation.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/common/extra_algorithms.h b/src/common/extra_algorithms.h index eec429e1..bdaa420e 100644 --- a/src/common/extra_algorithms.h +++ b/src/common/extra_algorithms.h @@ -1,11 +1,11 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 OR MIT // -// Initial Author: Ryan Pavlik +// Initial Author: Rylie Pavlik // /*! diff --git a/src/common/filesystem_utils.cpp b/src/common/filesystem_utils.cpp index 16e6ff32..063c4c4c 100644 --- a/src/common/filesystem_utils.cpp +++ b/src/common/filesystem_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017 Valve Corporation // Copyright (c) 2017 LunarG, Inc. // diff --git a/src/common/filesystem_utils.hpp b/src/common/filesystem_utils.hpp index 3dea1b2c..2a923fac 100644 --- a/src/common/filesystem_utils.hpp +++ b/src/common/filesystem_utils.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017 Valve Corporation // Copyright (c) 2017 LunarG, Inc. // diff --git a/src/common/gfxwrapper_opengl.c b/src/common/gfxwrapper_opengl.c index 1c9e0916..f7739415 100644 --- a/src/common/gfxwrapper_opengl.c +++ b/src/common/gfxwrapper_opengl.c @@ -1,5 +1,5 @@ /* -Copyright (c) 2017-2023, The Khronos Group Inc. +Copyright (c) 2017-2024, 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 a8aa7386..32d12ca1 100644 --- a/src/common/gfxwrapper_opengl.h +++ b/src/common/gfxwrapper_opengl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, 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/hex_and_handles.h b/src/common/hex_and_handles.h index 30066903..12bdb367 100644 --- a/src/common/hex_and_handles.h +++ b/src/common/hex_and_handles.h @@ -1,11 +1,11 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 OR MIT // -// Initial Author: Ryan Pavlik +// Initial Author: Rylie Pavlik // /*! diff --git a/src/common/loader_interfaces.h b/src/common/loader_interfaces.h deleted file mode 100644 index 020c3456..00000000 --- a/src/common/loader_interfaces.h +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. -// Copyright (c) 2017 Valve Corporation -// Copyright (c) 2017 LunarG, Inc. -// -// SPDX-License-Identifier: Apache-2.0 OR MIT -// -// Initial Author: Mark Young -// - -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// Forward declare. -typedef struct XrApiLayerCreateInfo XrApiLayerCreateInfo; - -// Function pointer prototype for the xrCreateApiLayerInstance function used in place of xrCreateInstance. -// This function allows us to pass special API layer information to each layer during the process of creating an Instance. -typedef XrResult(XRAPI_PTR *PFN_xrCreateApiLayerInstance)(const XrInstanceCreateInfo *info, - const XrApiLayerCreateInfo *apiLayerInfo, XrInstance *instance); - -// Loader/API Layer Interface versions -// 1 - First version, introduces negotiation structure and functions -#define XR_CURRENT_LOADER_API_LAYER_VERSION 1 - -// Loader/Runtime Interface versions -// 1 - First version, introduces negotiation structure and functions -#define XR_CURRENT_LOADER_RUNTIME_VERSION 1 - -// Version negotiation values -typedef enum XrLoaderInterfaceStructs { - XR_LOADER_INTERFACE_STRUCT_UNINTIALIZED = 0, - XR_LOADER_INTERFACE_STRUCT_LOADER_INFO, - XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST, - XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST, - XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO, - XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO, -} XrLoaderInterfaceStructs; - -#define XR_LOADER_INFO_STRUCT_VERSION 1 -typedef struct XrNegotiateLoaderInfo { - XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_LOADER_INFO - uint32_t structVersion; // XR_LOADER_INFO_STRUCT_VERSION - size_t structSize; // sizeof(XrNegotiateLoaderInfo) - uint32_t minInterfaceVersion; - uint32_t maxInterfaceVersion; - XrVersion minApiVersion; - XrVersion maxApiVersion; -} XrNegotiateLoaderInfo; - -#define XR_API_LAYER_INFO_STRUCT_VERSION 1 -typedef struct XrNegotiateApiLayerRequest { - XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST - uint32_t structVersion; // XR_API_LAYER_INFO_STRUCT_VERSION - size_t structSize; // sizeof(XrNegotiateApiLayerRequest) - uint32_t layerInterfaceVersion; // CURRENT_LOADER_API_LAYER_VERSION - XrVersion layerApiVersion; - PFN_xrGetInstanceProcAddr getInstanceProcAddr; - PFN_xrCreateApiLayerInstance createApiLayerInstance; -} XrNegotiateApiLayerRequest; - -#define XR_RUNTIME_INFO_STRUCT_VERSION 1 -typedef struct XrNegotiateRuntimeRequest { - XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST - uint32_t structVersion; // XR_RUNTIME_INFO_STRUCT_VERSION - size_t structSize; // sizeof(XrNegotiateRuntimeRequest) - uint32_t runtimeInterfaceVersion; // CURRENT_LOADER_RUNTIME_VERSION - XrVersion runtimeApiVersion; - PFN_xrGetInstanceProcAddr getInstanceProcAddr; -} XrNegotiateRuntimeRequest; - -// Function used to negotiate an interface betewen the loader and an API layer. Each library exposing one or -// more API layers needs to expose at least this function. -typedef XrResult(XRAPI_PTR *PFN_xrNegotiateLoaderApiLayerInterface)(const XrNegotiateLoaderInfo *loaderInfo, - const char *apiLayerName, - XrNegotiateApiLayerRequest *apiLayerRequest); - -// Function used to negotiate an interface betewen the loader and a runtime. Each runtime should expose -// at least this function. -typedef XrResult(XRAPI_PTR *PFN_xrNegotiateLoaderRuntimeInterface)(const XrNegotiateLoaderInfo *loaderInfo, - XrNegotiateRuntimeRequest *runtimeRequest); - -// Forward declare. -typedef struct XrApiLayerNextInfo XrApiLayerNextInfo; - -#define XR_API_LAYER_NEXT_INFO_STRUCT_VERSION 1 -struct XrApiLayerNextInfo { - XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO - uint32_t structVersion; // XR_API_LAYER_NEXT_INFO_STRUCT_VERSION - size_t structSize; // sizeof(XrApiLayerNextInfo) - char layerName[XR_MAX_API_LAYER_NAME_SIZE]; // Name of API layer which should receive this info - PFN_xrGetInstanceProcAddr nextGetInstanceProcAddr; // Pointer to next API layer's xrGetInstanceProcAddr - PFN_xrCreateApiLayerInstance nextCreateApiLayerInstance; // Pointer to next API layer's xrCreateApiLayerInstance - XrApiLayerNextInfo *next; // Pointer to the next API layer info in the sequence -}; - -#define XR_API_LAYER_MAX_SETTINGS_PATH_SIZE 512 -#define XR_API_LAYER_CREATE_INFO_STRUCT_VERSION 1 -typedef struct XrApiLayerCreateInfo { - XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO - uint32_t structVersion; // XR_API_LAYER_CREATE_INFO_STRUCT_VERSION - size_t structSize; // sizeof(XrApiLayerCreateInfo) - void *loaderInstance; // Pointer to the LoaderInstance class - char settings_file_location[XR_API_LAYER_MAX_SETTINGS_PATH_SIZE]; // Location to the found settings file (or empty '\0') - XrApiLayerNextInfo *nextInfo; // Pointer to the next API layer's Info -} XrApiLayerCreateInfo; - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/src/common/object_info.cpp b/src/common/object_info.cpp index 3f8f96bc..d45430a6 100644 --- a/src/common/object_info.cpp +++ b/src/common/object_info.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // Copyright (c) 2019 Collabora, Ltd. @@ -6,7 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT // // Initial Authors: Mark Young -// Ryan Pavlik +// Rylie Pavlik // Dave Houlton // diff --git a/src/common/object_info.h b/src/common/object_info.h index 247ede0d..572f06ab 100644 --- a/src/common/object_info.h +++ b/src/common/object_info.h @@ -1,11 +1,11 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 OR MIT // -// Initial Authors: Mark Young , Ryan Pavlik , Rylie Pavlik +#include #include ///////////////// diff --git a/src/conformance/conformance_layer/Negotiate.cpp b/src/conformance/conformance_layer/Negotiate.cpp index 431a8b8f..21ab0bb4 100644 --- a/src/conformance/conformance_layer/Negotiate.cpp +++ b/src/conformance/conformance_layer/Negotiate.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_layer/RuntimeFailure.cpp b/src/conformance/conformance_layer/RuntimeFailure.cpp index 60d19504..2974d5df 100644 --- a/src/conformance/conformance_layer/RuntimeFailure.cpp +++ b/src/conformance/conformance_layer/RuntimeFailure.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_layer/RuntimeFailure.h b/src/conformance/conformance_layer/RuntimeFailure.h index ba8c34f6..fda7a8e3 100644 --- a/src/conformance/conformance_layer/RuntimeFailure.h +++ b/src/conformance/conformance_layer/RuntimeFailure.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -43,14 +43,15 @@ void ValidateXrQuaternion(ConformanceHooksBase* conformanceHook, const XrQuatern void ValidateXrVector3f(ConformanceHooksBase* conformanceHook, const XrVector3f& v, const char* valueName, const char* xrFunctionName); // clang-format off -#define ENUM_CASE_BOOL(name, val) case name: return true; +#define ENUM_CASE_BOOL(name, val) case name: #define MAKE_IS_VALID_ENUM_VALUE(enumType, zeroIsValid) \ inline bool is_valid_enum_val(enumType e) { \ if (!zeroIsValid && e == 0) return false; \ - else if (e == 0x7FFFFFFF) return false; \ + if (e == 0x7FFFFFFF) return false; \ \ switch (e) { \ XR_LIST_ENUM_##enumType(ENUM_CASE_BOOL) \ + return true; \ default: return false; \ } \ } diff --git a/src/conformance/conformance_layer/Session.cpp b/src/conformance/conformance_layer/Session.cpp index 8326b9ab..9f7dae3e 100644 --- a/src/conformance/conformance_layer/Session.cpp +++ b/src/conformance/conformance_layer/Session.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_layer/Space.cpp b/src/conformance/conformance_layer/Space.cpp index ab57be1d..eb463fc0 100644 --- a/src/conformance/conformance_layer/Space.cpp +++ b/src/conformance/conformance_layer/Space.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_layer/Swapchain.cpp b/src/conformance/conformance_layer/Swapchain.cpp index 142cc7d8..abed58cf 100644 --- a/src/conformance/conformance_layer/Swapchain.cpp +++ b/src/conformance/conformance_layer/Swapchain.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_layer/XrApiLayer_conformance_layer.def b/src/conformance/conformance_layer/XrApiLayer_conformance_layer.def index 5ac07b3a..f2874f18 100644 --- a/src/conformance/conformance_layer/XrApiLayer_conformance_layer.def +++ b/src/conformance/conformance_layer/XrApiLayer_conformance_layer.def @@ -1,2 +1,6 @@ +; Copyright (c) 2019-2024, The Khronos Group Inc. +; +; SPDX-License-Identifier: Apache-2.0 + EXPORTS xrNegotiateLoaderApiLayerInterface \ No newline at end of file diff --git a/src/conformance/conformance_layer/XrApiLayer_conformance_layer.def.license b/src/conformance/conformance_layer/XrApiLayer_conformance_layer.def.license deleted file mode 100644 index bc07946a..00000000 --- a/src/conformance/conformance_layer/XrApiLayer_conformance_layer.def.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. - -SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_layer/XrApiLayer_conformance_layer.expsym b/src/conformance/conformance_layer/XrApiLayer_conformance_layer.expsym index ec596832..c7892e0c 100644 --- a/src/conformance/conformance_layer/XrApiLayer_conformance_layer.expsym +++ b/src/conformance/conformance_layer/XrApiLayer_conformance_layer.expsym @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_layer/XrApiLayer_conformance_layer.map b/src/conformance/conformance_layer/XrApiLayer_conformance_layer.map new file mode 100644 index 00000000..5fc8ab24 --- /dev/null +++ b/src/conformance/conformance_layer/XrApiLayer_conformance_layer.map @@ -0,0 +1,12 @@ +/* +Copyright (c) 2019-2024, The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0 +*/ + +{ + global: + xrNegotiateLoaderApiLayerInterface; + local: + *; +}; diff --git a/src/conformance/conformance_layer/conformance_layer.json.license b/src/conformance/conformance_layer/conformance_layer.json.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_layer/conformance_layer.json.license +++ b/src/conformance/conformance_layer/conformance_layer.json.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/CMakeLists.txt b/src/conformance/conformance_test/CMakeLists.txt index a230b48e..8a8cbabf 100644 --- a/src/conformance/conformance_test/CMakeLists.txt +++ b/src/conformance/conformance_test/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/src/conformance/conformance_test/android_assets/openxr/1/api_layers/explicit.d/XR_APILAYER_KHRONOS_runtime_conformance.json.license b/src/conformance/conformance_test/android_assets/openxr/1/api_layers/explicit.d/XR_APILAYER_KHRONOS_runtime_conformance.json.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/android_assets/openxr/1/api_layers/explicit.d/XR_APILAYER_KHRONOS_runtime_conformance.json.license +++ b/src/conformance/conformance_test/android_assets/openxr/1/api_layers/explicit.d/XR_APILAYER_KHRONOS_runtime_conformance.json.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/ext_plane_detection_contour.png.license b/src/conformance/conformance_test/composition_examples/ext_plane_detection_contour.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/ext_plane_detection_contour.png.license +++ b/src/conformance/conformance_test/composition_examples/ext_plane_detection_contour.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/eye_visibility.png.license b/src/conformance/conformance_test/composition_examples/eye_visibility.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/eye_visibility.png.license +++ b/src/conformance/conformance_test/composition_examples/eye_visibility.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/grip_and_aim_pose.png.license b/src/conformance/conformance_test/composition_examples/grip_and_aim_pose.png.license index 6d36aba0..62d2a928 100644 --- a/src/conformance/conformance_test/composition_examples/grip_and_aim_pose.png.license +++ b/src/conformance/conformance_test/composition_examples/grip_and_aim_pose.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2020-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2020-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/grip_axes_diagram.png.license b/src/conformance/conformance_test/composition_examples/grip_axes_diagram.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/grip_axes_diagram.png.license +++ b/src/conformance/conformance_test/composition_examples/grip_axes_diagram.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/palm_pose.png.license b/src/conformance/conformance_test/composition_examples/palm_pose.png.license index 6d36aba0..62d2a928 100644 --- a/src/conformance/conformance_test/composition_examples/palm_pose.png.license +++ b/src/conformance/conformance_test/composition_examples/palm_pose.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2020-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2020-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/projection_array.png.license b/src/conformance/conformance_test/composition_examples/projection_array.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/projection_array.png.license +++ b/src/conformance/conformance_test/composition_examples/projection_array.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/projection_mutable.png.license b/src/conformance/conformance_test/composition_examples/projection_mutable.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/projection_mutable.png.license +++ b/src/conformance/conformance_test/composition_examples/projection_mutable.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/projection_separate.png.license b/src/conformance/conformance_test/composition_examples/projection_separate.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/projection_separate.png.license +++ b/src/conformance/conformance_test/composition_examples/projection_separate.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/projection_wide.png.license b/src/conformance/conformance_test/composition_examples/projection_wide.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/projection_wide.png.license +++ b/src/conformance/conformance_test/composition_examples/projection_wide.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/quad_hands.png.license b/src/conformance/conformance_test/composition_examples/quad_hands.png.license index 6d36aba0..62d2a928 100644 --- a/src/conformance/conformance_test/composition_examples/quad_hands.png.license +++ b/src/conformance/conformance_test/composition_examples/quad_hands.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2020-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2020-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/quad_occlusion.png.license b/src/conformance/conformance_test/composition_examples/quad_occlusion.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/quad_occlusion.png.license +++ b/src/conformance/conformance_test/composition_examples/quad_occlusion.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/quad_poses.png.license b/src/conformance/conformance_test/composition_examples/quad_poses.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/quad_poses.png.license +++ b/src/conformance/conformance_test/composition_examples/quad_poses.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/source_alpha_blending.png.license b/src/conformance/conformance_test/composition_examples/source_alpha_blending.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/source_alpha_blending.png.license +++ b/src/conformance/conformance_test/composition_examples/source_alpha_blending.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/stale_swapchain.png.license b/src/conformance/conformance_test/composition_examples/stale_swapchain.png.license index 6d36aba0..62d2a928 100644 --- a/src/conformance/conformance_test/composition_examples/stale_swapchain.png.license +++ b/src/conformance/conformance_test/composition_examples/stale_swapchain.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2020-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2020-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/subimage.png.license b/src/conformance/conformance_test/composition_examples/subimage.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/subimage.png.license +++ b/src/conformance/conformance_test/composition_examples/subimage.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/composition_examples/visibility_mask_with_red.png.license b/src/conformance/conformance_test/composition_examples/visibility_mask_with_red.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/composition_examples/visibility_mask_with_red.png.license +++ b/src/conformance/conformance_test/composition_examples/visibility_mask_with_red.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/conformance_test.cpp b/src/conformance/conformance_test/conformance_test.cpp index 36781f99..ac79f66f 100644 --- a/src/conformance/conformance_test/conformance_test.cpp +++ b/src/conformance/conformance_test/conformance_test.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/conformance_test.h b/src/conformance/conformance_test/conformance_test.h index 85dcba60..595df0a7 100644 --- a/src/conformance/conformance_test/conformance_test.h +++ b/src/conformance/conformance_test/conformance_test.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/gltf_examples/AlphaBlendModeTest.png.license b/src/conformance/conformance_test/gltf_examples/AlphaBlendModeTest.png.license index f479a621..ac148188 100644 --- a/src/conformance/conformance_test/gltf_examples/AlphaBlendModeTest.png.license +++ b/src/conformance/conformance_test/gltf_examples/AlphaBlendModeTest.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2023-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/gltf_examples/MetalRoughSpheres.png.license b/src/conformance/conformance_test/gltf_examples/MetalRoughSpheres.png.license index f479a621..ac148188 100644 --- a/src/conformance/conformance_test/gltf_examples/MetalRoughSpheres.png.license +++ b/src/conformance/conformance_test/gltf_examples/MetalRoughSpheres.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2023-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/gltf_examples/MetalRoughSpheresNoTextures.png.license b/src/conformance/conformance_test/gltf_examples/MetalRoughSpheresNoTextures.png.license index f479a621..ac148188 100644 --- a/src/conformance/conformance_test/gltf_examples/MetalRoughSpheresNoTextures.png.license +++ b/src/conformance/conformance_test/gltf_examples/MetalRoughSpheresNoTextures.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2023-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/gltf_examples/NormalTangentMirrorTest.png.license b/src/conformance/conformance_test/gltf_examples/NormalTangentMirrorTest.png.license index f479a621..ac148188 100644 --- a/src/conformance/conformance_test/gltf_examples/NormalTangentMirrorTest.png.license +++ b/src/conformance/conformance_test/gltf_examples/NormalTangentMirrorTest.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2023-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/gltf_examples/NormalTangentTest.png.license b/src/conformance/conformance_test/gltf_examples/NormalTangentTest.png.license index f479a621..ac148188 100644 --- a/src/conformance/conformance_test/gltf_examples/NormalTangentTest.png.license +++ b/src/conformance/conformance_test/gltf_examples/NormalTangentTest.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2023-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/gltf_examples/TextureSettingsTest.png.license b/src/conformance/conformance_test/gltf_examples/TextureSettingsTest.png.license index f479a621..ac148188 100644 --- a/src/conformance/conformance_test/gltf_examples/TextureSettingsTest.png.license +++ b/src/conformance/conformance_test/gltf_examples/TextureSettingsTest.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2023-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/gltf_examples/VertexColorTest.png.license b/src/conformance/conformance_test/gltf_examples/VertexColorTest.png.license index f479a621..ac148188 100644 --- a/src/conformance/conformance_test/gltf_examples/VertexColorTest.png.license +++ b/src/conformance/conformance_test/gltf_examples/VertexColorTest.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2023-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/pbr_assets/brdf_lut.png.license b/src/conformance/conformance_test/pbr_assets/brdf_lut.png.license index bc07946a..cca73d04 100644 --- a/src/conformance/conformance_test/pbr_assets/brdf_lut.png.license +++ b/src/conformance/conformance_test/pbr_assets/brdf_lut.png.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2019-2023, The Khronos Group Inc. +SPDX-FileCopyrightText: 2019-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/readme.md b/src/conformance/conformance_test/readme.md index 1884334d..d4d45a1f 100644 --- a/src/conformance/conformance_test/readme.md +++ b/src/conformance/conformance_test/readme.md @@ -2,7 +2,7 @@ OpenXR Conformance Test Suite ============================= diff --git a/src/conformance/conformance_test/test_ActionPoses.cpp b/src/conformance/conformance_test/test_ActionPoses.cpp index 66e1bbd9..af356631 100644 --- a/src/conformance/conformance_test/test_ActionPoses.cpp +++ b/src/conformance/conformance_test/test_ActionPoses.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_FrameSubmission.cpp b/src/conformance/conformance_test/test_FrameSubmission.cpp index 1ae93f3e..51f54fcd 100644 --- a/src/conformance/conformance_test/test_FrameSubmission.cpp +++ b/src/conformance/conformance_test/test_FrameSubmission.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_HapticInterrupt.cpp b/src/conformance/conformance_test/test_HapticInterrupt.cpp index c5ad5d63..1adce26c 100644 --- a/src/conformance/conformance_test/test_HapticInterrupt.cpp +++ b/src/conformance/conformance_test/test_HapticInterrupt.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_InteractiveThrow.cpp b/src/conformance/conformance_test/test_InteractiveThrow.cpp index b70c86b2..4570eab9 100644 --- a/src/conformance/conformance_test/test_InteractiveThrow.cpp +++ b/src/conformance/conformance_test/test_InteractiveThrow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_LayerComposition.cpp b/src/conformance/conformance_test/test_LayerComposition.cpp index 1a9344ae..7996ee6b 100644 --- a/src/conformance/conformance_test/test_LayerComposition.cpp +++ b/src/conformance/conformance_test/test_LayerComposition.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -18,7 +18,8 @@ #include "composition_utils.h" #include "conformance_framework.h" #include "utilities/throw_helpers.h" -#include "utilities/utils.h" +#include "utilities/types_and_constants.h" +#include "utilities/xrduration_literals.h" #include #include @@ -41,7 +42,9 @@ namespace Conformance compositionHelper, "quad_occlusion.png", "This test includes a blue and green quad at Z=-2 with opposite rotations on Y axis forming X. The green quad should be" " fully visible due to painter's algorithm. A red quad is facing away and should not be visible."); - compositionHelper.GetInteractionManager().AttachActionSets(); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); const XrSwapchain greenSwapchain = compositionHelper.CreateStaticSwapchainSolidColor(Colors::Green); @@ -60,9 +63,7 @@ namespace Conformance const XrQuaternionf redRot = Quat::FromAxisAngle({0, 1, 0}, Math::DegToRad(180)); interactiveLayerManager.AddLayer(compositionHelper.CreateQuadLayer(redSwapchain, viewSpace, 1.0f, XrPosef{redRot, {0, 0, -1}})); - RenderLoop(compositionHelper.GetSession(), [&](const XrFrameState& frameState) { - return interactiveLayerManager.EndFrame(frameState); - }).Loop(); + RenderLoop(session, [&](const XrFrameState& frameState) { return interactiveLayerManager.EndFrame(frameState); }).Loop(); } // Purpose: Verify order of transforms by exercising the two ways poses can be specified: @@ -78,7 +79,9 @@ namespace Conformance " rotation around the Z axis on an XrSpace and then translate the quad out on the Z axis through the quad" " layer's pose. The purple/yellow quads apply the same translation on the XrSpace and the rotation on the" " quad layer's pose."); - compositionHelper.GetInteractionManager().AttachActionSets(); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); const XrSwapchain blueSwapchain = compositionHelper.CreateStaticSwapchainSolidColor(Colors::Blue); @@ -108,9 +111,7 @@ namespace Conformance interactiveLayerManager.AddLayer(quad2); } - RenderLoop(compositionHelper.GetSession(), [&](const XrFrameState& frameState) { - return interactiveLayerManager.EndFrame(frameState); - }).Loop(); + RenderLoop(session, [&](const XrFrameState& frameState) { return interactiveLayerManager.EndFrame(frameState); }).Loop(); } // Purpose: Validates alpha blending (both premultiplied and unpremultiplied). @@ -119,7 +120,9 @@ namespace Conformance CompositionHelper compositionHelper("Source Alpha Blending"); InteractiveLayerManager interactiveLayerManager(compositionHelper, "source_alpha_blending.png", "All three squares should have an identical blue-green gradient."); - compositionHelper.GetInteractionManager().AttachActionSets(); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); const XrSpace viewSpace = compositionHelper.CreateReferenceSpace(XR_REFERENCE_SPACE_TYPE_VIEW); @@ -195,9 +198,7 @@ namespace Conformance createGradientTest(true, -1.02f, 0); // Test premultiplied (left of center "answer") createGradientTest(false, 1.02f, 0); // Test unpremultiplied (right of center "answer") - RenderLoop(compositionHelper.GetSession(), [&](const XrFrameState& frameState) { - return interactiveLayerManager.EndFrame(frameState); - }).Loop(); + RenderLoop(session, [&](const XrFrameState& frameState) { return interactiveLayerManager.EndFrame(frameState); }).Loop(); } // Purpose: Validate eye visibility flags. @@ -206,7 +207,9 @@ namespace Conformance CompositionHelper compositionHelper("Eye Visibility"); InteractiveLayerManager interactiveLayerManager(compositionHelper, "eye_visibility.png", "A green quad is shown in the left eye and a blue quad is shown in the right eye."); - compositionHelper.GetInteractionManager().AttachActionSets(); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); @@ -224,9 +227,7 @@ namespace Conformance quad2->eyeVisibility = XR_EYE_VISIBILITY_RIGHT; interactiveLayerManager.AddLayer(quad2); - RenderLoop(compositionHelper.GetSession(), [&](const XrFrameState& frameState) { - return interactiveLayerManager.EndFrame(frameState); - }).Loop(); + RenderLoop(session, [&](const XrFrameState& frameState) { return interactiveLayerManager.EndFrame(frameState); }).Loop(); } TEST_CASE("Subimage", "[composition][interactive][no_auto]") @@ -235,7 +236,9 @@ namespace Conformance InteractiveLayerManager interactiveLayerManager( compositionHelper, "subimage.png", "Creates a 4x2 grid of quad layers testing subImage array index and imageRect. Red should not be visible except minor bleed in."); - compositionHelper.GetInteractionManager().AttachActionSets(); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); const XrSpace viewSpace = compositionHelper.CreateReferenceSpace(XR_REFERENCE_SPACE_TYPE_VIEW, XrPosef{Quat::Identity, {0, 0, -1}}); @@ -292,9 +295,7 @@ namespace Conformance } }); - RenderLoop(compositionHelper.GetSession(), [&](const XrFrameState& frameState) { - return interactiveLayerManager.EndFrame(frameState); - }).Loop(); + RenderLoop(session, [&](const XrFrameState& frameState) { return interactiveLayerManager.EndFrame(frameState); }).Loop(); } TEST_CASE("ProjectionArraySwapchain", "[composition][interactive][no_auto]") @@ -303,11 +304,12 @@ namespace Conformance InteractiveLayerManager interactiveLayerManager( compositionHelper, "projection_array.png", "Uses a single texture array for a projection layer (each view is a different slice and each slice has a unique color)."); - compositionHelper.GetInteractionManager().AttachActionSets(); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); - const XrSpace localSpace = - compositionHelper.CreateReferenceSpace(XR_REFERENCE_SPACE_TYPE_LOCAL, XrPosef{Quat::Identity, {0, 0, 0}}); + const XrSpace localSpace = compositionHelper.CreateReferenceSpace(XR_REFERENCE_SPACE_TYPE_LOCAL, XrPosefCPP()); const std::vector viewProperties = compositionHelper.EnumerateConfigurationViews(); @@ -366,7 +368,7 @@ namespace Conformance return interactiveLayerManager.EndFrame(frameState, layers); }; - RenderLoop(compositionHelper.GetSession(), updateLayers).Loop(); + RenderLoop(session, updateLayers).Loop(); } TEST_CASE("ProjectionWideSwapchain", "[composition][interactive][no_auto]") @@ -374,11 +376,12 @@ namespace Conformance CompositionHelper compositionHelper("Projection Wide Swapchain"); InteractiveLayerManager interactiveLayerManager(compositionHelper, "projection_wide.png", "Uses a single wide texture for a projection layer."); - compositionHelper.GetInteractionManager().AttachActionSets(); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); - const XrSpace localSpace = - compositionHelper.CreateReferenceSpace(XR_REFERENCE_SPACE_TYPE_LOCAL, XrPosef{Quat::Identity, {0, 0, 0}}); + const XrSpace localSpace = compositionHelper.CreateReferenceSpace(XR_REFERENCE_SPACE_TYPE_LOCAL, XrPosefCPP()); const std::vector viewProperties = compositionHelper.EnumerateConfigurationViews(); @@ -433,7 +436,7 @@ namespace Conformance return interactiveLayerManager.EndFrame(frameState, layers); }; - RenderLoop(compositionHelper.GetSession(), updateLayers).Loop(); + RenderLoop(session, updateLayers).Loop(); } TEST_CASE("ProjectionSeparateSwapchains", "[composition][interactive][no_auto]") @@ -441,7 +444,9 @@ namespace Conformance CompositionHelper compositionHelper("Projection Separate Swapchains"); InteractiveLayerManager interactiveLayerManager(compositionHelper, "projection_separate.png", "Uses separate textures for each projection layer view."); - compositionHelper.GetInteractionManager().AttachActionSets(); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); SimpleProjectionLayerHelper simpleProjectionLayerHelper(compositionHelper); @@ -454,7 +459,7 @@ namespace Conformance return interactiveLayerManager.EndFrame(frameState, layers); }; - RenderLoop(compositionHelper.GetSession(), updateLayers).Loop(); + RenderLoop(session, updateLayers).Loop(); } TEST_CASE("QuadHands", "[composition][interactive][no_auto]") @@ -462,6 +467,9 @@ namespace Conformance GlobalData& globalData = GetGlobalData(); CompositionHelper compositionHelper("Quad Hands"); + XrInstance instance = compositionHelper.GetInstance(); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); InteractiveLayerManager interactiveLayerManager(compositionHelper, "quad_hands.png", "10x10cm Quads labeled \'L\' and \'R\' should appear 10cm along the grip " "positive Z in front of the center of 10cm cubes rendered at the controller " @@ -472,8 +480,7 @@ namespace Conformance "that \'R\' is always rendered atop \'L\', " "and both are atop the cubes when visible."); - const std::vector subactionPaths{StringToPath(compositionHelper.GetInstance(), "/user/hand/left"), - StringToPath(compositionHelper.GetInstance(), "/user/hand/right")}; + const std::vector subactionPaths{StringToPath(instance, "/user/hand/left"), StringToPath(instance, "/user/hand/right")}; XrActionSet actionSet; XrAction gripPoseAction; @@ -481,7 +488,7 @@ namespace Conformance XrActionSetCreateInfo actionSetInfo{XR_TYPE_ACTION_SET_CREATE_INFO}; strcpy(actionSetInfo.actionSetName, "quad_hands"); strcpy(actionSetInfo.localizedActionSetName, "Quad Hands"); - XRC_CHECK_THROW_XRCMD(xrCreateActionSet(compositionHelper.GetInstance(), &actionSetInfo, &actionSet)); + XRC_CHECK_THROW_XRCMD(xrCreateActionSet(instance, &actionSetInfo, &actionSet)); XrActionCreateInfo actionInfo{XR_TYPE_ACTION_CREATE_INFO}; actionInfo.actionType = XR_ACTION_TYPE_POSE_INPUT; @@ -492,16 +499,15 @@ namespace Conformance XRC_CHECK_THROW_XRCMD(xrCreateAction(actionSet, &actionInfo, &gripPoseAction)); } - compositionHelper.GetInteractionManager().AddActionSet(actionSet); - XrPath simpleInteractionProfile = StringToPath(compositionHelper.GetInstance(), "/interaction_profiles/khr/simple_controller"); - compositionHelper.GetInteractionManager().AddActionBindings( - simpleInteractionProfile, - {{ - {gripPoseAction, StringToPath(compositionHelper.GetInstance(), "/user/hand/left/input/grip/pose")}, - {gripPoseAction, StringToPath(compositionHelper.GetInstance(), "/user/hand/right/input/grip/pose")}, - }}); + interactionManager.AddActionSet(actionSet); + XrPath simpleInteractionProfile = StringToPath(instance, "/interaction_profiles/khr/simple_controller"); + interactionManager.AddActionBindings(simpleInteractionProfile, + {{ + {gripPoseAction, StringToPath(instance, "/user/hand/left/input/grip/pose")}, + {gripPoseAction, StringToPath(instance, "/user/hand/right/input/grip/pose")}, + }}); - compositionHelper.GetInteractionManager().AttachActionSets(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); SimpleProjectionLayerHelper simpleProjectionLayerHelper(compositionHelper); @@ -516,13 +522,13 @@ namespace Conformance XrActionSpaceCreateInfo spaceCreateInfo{XR_TYPE_ACTION_SPACE_CREATE_INFO}; spaceCreateInfo.action = gripPoseAction; spaceCreateInfo.subactionPath = subactionPaths[i]; - spaceCreateInfo.poseInActionSpace = {{0, 0, 0, 1}, {0, 0, 0}}; - XRC_CHECK_THROW_XRCMD(xrCreateActionSpace(compositionHelper.GetSession(), &spaceCreateInfo, &space)); + spaceCreateInfo.poseInActionSpace = XrPosefCPP(); + XRC_CHECK_THROW_XRCMD(xrCreateActionSpace(session, &spaceCreateInfo, &space)); } else { XrReferenceSpaceCreateInfo spaceCreateInfo{XR_TYPE_REFERENCE_SPACE_CREATE_INFO, nullptr, XR_REFERENCE_SPACE_TYPE_LOCAL, XrPosefCPP()}; - XRC_CHECK_THROW_XRCMD(xrCreateReferenceSpace(compositionHelper.GetSession(), &spaceCreateInfo, &space)); + XRC_CHECK_THROW_XRCMD(xrCreateReferenceSpace(session, &spaceCreateInfo, &space)); } gripSpaces.push_back(std::move(space)); } @@ -559,19 +565,20 @@ namespace Conformance return interactiveLayerManager.EndFrame(frameState, layers); }; - RenderLoop(compositionHelper.GetSession(), updateLayers).Loop(); + RenderLoop(session, updateLayers).Loop(); } TEST_CASE("ProjectionMutableFieldOfView", "[composition][interactive][no_auto]") { CompositionHelper compositionHelper("Projection Mutable Field-of-View"); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); InteractiveLayerManager interactiveLayerManager(compositionHelper, "projection_mutable.png", "Uses mutable field-of-views for each projection layer view."); - compositionHelper.GetInteractionManager().AttachActionSets(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); - const XrSpace localSpace = - compositionHelper.CreateReferenceSpace(XR_REFERENCE_SPACE_TYPE_LOCAL, XrPosef{Quat::Identity, {0, 0, 0}}); + const XrSpace localSpace = compositionHelper.CreateReferenceSpace(XR_REFERENCE_SPACE_TYPE_LOCAL, XrPosefCPP{}); if (!compositionHelper.GetViewConfigurationProperties().fovMutable) { SKIP("View configuration does not support mutable FoV"); @@ -651,7 +658,7 @@ namespace Conformance return interactiveLayerManager.EndFrame(frameState, layers); }; - RenderLoop(compositionHelper.GetSession(), updateLayers).Loop(); + RenderLoop(session, updateLayers).Loop(); } TEST_CASE("StaleSwapchain", "[composition][interactive][no_auto]") diff --git a/src/conformance/conformance_test/test_SessionState.cpp b/src/conformance/conformance_test/test_SessionState.cpp index f59a14f6..cdc381ee 100644 --- a/src/conformance/conformance_test/test_SessionState.cpp +++ b/src/conformance/conformance_test/test_SessionState.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_Swapchains.cpp b/src/conformance/conformance_test/test_Swapchains.cpp index 90078fae..61c65c7a 100644 --- a/src/conformance/conformance_test/test_Swapchains.cpp +++ b/src/conformance/conformance_test/test_Swapchains.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_ViewConfigurations.cpp b/src/conformance/conformance_test/test_ViewConfigurations.cpp index e269a587..1cfa7336 100644 --- a/src/conformance/conformance_test/test_ViewConfigurations.cpp +++ b/src/conformance/conformance_test/test_ViewConfigurations.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_EXT_debug_utils.cpp b/src/conformance/conformance_test/test_XR_EXT_debug_utils.cpp index 828824b3..ba9e1e31 100644 --- a/src/conformance/conformance_test/test_XR_EXT_debug_utils.cpp +++ b/src/conformance/conformance_test/test_XR_EXT_debug_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/conformance/conformance_test/test_XR_EXT_dpad_binding.cpp b/src/conformance/conformance_test/test_XR_EXT_dpad_binding.cpp index 91abefa2..fb0a7b01 100644 --- a/src/conformance/conformance_test/test_XR_EXT_dpad_binding.cpp +++ b/src/conformance/conformance_test/test_XR_EXT_dpad_binding.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_EXT_eye_gaze_interaction.cpp b/src/conformance/conformance_test/test_XR_EXT_eye_gaze_interaction.cpp index 19b20bbf..04a662a5 100644 --- a/src/conformance/conformance_test/test_XR_EXT_eye_gaze_interaction.cpp +++ b/src/conformance/conformance_test/test_XR_EXT_eye_gaze_interaction.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -43,7 +43,7 @@ namespace Conformance MakeSystemPropertiesBoolChecker(XrSystemEyeGazeInteractionPropertiesEXT{XR_TYPE_SYSTEM_EYE_GAZE_INTERACTION_PROPERTIES_EXT}, &XrSystemEyeGazeInteractionPropertiesEXT::supportsEyeGazeInteraction); - TEST_CASE("XR_EXT_eye_gaze_interaction", "[scenario][interactive][no_auto][XR_EXT_eye_gaze_interaction]") + TEST_CASE("XR_EXT_eye_gaze_interaction-system_support_optional", "[XR_EXT_eye_gaze_interaction]") { GlobalData& globalData = GetGlobalData(); if (!globalData.IsInstanceExtensionSupported(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME)) { @@ -70,12 +70,7 @@ namespace Conformance SECTION("Extension enabled") { - AutoBasicInstance instance({XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME}, AutoBasicInstance::createSystemId); - XrSystemId systemId = instance.systemId; - if (!SystemSupportsEyeGazeInteraction(instance, systemId)) { - // This runtime does support eye gaze, but this headset does not which is fine. - SKIP("System does not support eye gaze interaction"); - } + AutoBasicInstance instance({XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME}); SECTION("Create and destroy eye gaze actions") { @@ -206,14 +201,7 @@ namespace Conformance // Verify that eye gaze interaction input can be combined with other input sources. // Use Simple Controller profile as opposed to vendor-specific inputs for broader coverage. - AutoBasicInstance instance({XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME}, AutoBasicInstance::createSystemId); - XrSystemId systemId = instance.systemId; - if (!SystemSupportsEyeGazeInteraction(instance, systemId)) { - // This runtime does support eye gaze, but this headset does not which is fine. - WARN("System does not support eye gaze interaction"); - return; - } - + AutoBasicInstance instance({XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME}); AutoBasicSession session(AutoBasicSession::beginSession, instance); // Create action set @@ -280,6 +268,14 @@ namespace Conformance XrSpace gazeActionSpace{XR_NULL_HANDLE}; REQUIRE_RESULT(xrCreateActionSpace(session, &createActionSpaceInfo, &gazeActionSpace), XR_SUCCESS); } + } + + TEST_CASE("XR_EXT_eye_gaze_interaction", "[scenario][interactive][no_auto][XR_EXT_eye_gaze_interaction]") + { + GlobalData& globalData = GetGlobalData(); + if (!globalData.IsInstanceExtensionSupported(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME)) { + SKIP(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME " not supported"); + } SECTION("Localize eye gaze paths") { diff --git a/src/conformance/conformance_test/test_XR_EXT_hand_tracking.cpp b/src/conformance/conformance_test/test_XR_EXT_hand_tracking.cpp index 282466cf..3b71da75 100644 --- a/src/conformance/conformance_test/test_XR_EXT_hand_tracking.cpp +++ b/src/conformance/conformance_test/test_XR_EXT_hand_tracking.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_EXT_local_floor.cpp b/src/conformance/conformance_test/test_XR_EXT_local_floor.cpp index 5914621d..74df02da 100644 --- a/src/conformance/conformance_test/test_XR_EXT_local_floor.cpp +++ b/src/conformance/conformance_test/test_XR_EXT_local_floor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_EXT_palm_pose.cpp b/src/conformance/conformance_test/test_XR_EXT_palm_pose.cpp index d76f21b5..23d5728e 100644 --- a/src/conformance/conformance_test/test_XR_EXT_palm_pose.cpp +++ b/src/conformance/conformance_test/test_XR_EXT_palm_pose.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -60,7 +60,7 @@ namespace Conformance "A hand in a pointing pose is rendered in the other hand using the palm action space. " "Press select to swap hands. Press menu to complete the validation."; - CompositionHelper compositionHelper(XR_EXT_PALM_POSE_EXTENSION_NAME, {XR_EXT_PALM_POSE_EXTENSION_NAME}); + CompositionHelper compositionHelper("Palm Pose", {XR_EXT_PALM_POSE_EXTENSION_NAME}); const XrSpace localSpace = compositionHelper.CreateReferenceSpace(XR_REFERENCE_SPACE_TYPE_LOCAL, XrPosefCPP{}); diff --git a/src/conformance/conformance_test/test_XR_EXT_plane_detection.cpp b/src/conformance/conformance_test/test_XR_EXT_plane_detection.cpp index 34c0448a..4a0027d0 100644 --- a/src/conformance/conformance_test/test_XR_EXT_plane_detection.cpp +++ b/src/conformance/conformance_test/test_XR_EXT_plane_detection.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_EXT_thermal_query.cpp b/src/conformance/conformance_test/test_XR_EXT_thermal_query.cpp index 4caf22b2..f2037772 100644 --- a/src/conformance/conformance_test/test_XR_EXT_thermal_query.cpp +++ b/src/conformance/conformance_test/test_XR_EXT_thermal_query.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_KHR_D3D11_enable.cpp b/src/conformance/conformance_test/test_XR_KHR_D3D11_enable.cpp index afe4f16e..e463959a 100644 --- a/src/conformance/conformance_test/test_XR_KHR_D3D11_enable.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_D3D11_enable.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_KHR_D3D12_enable.cpp b/src/conformance/conformance_test/test_XR_KHR_D3D12_enable.cpp index b815305c..92d555f1 100644 --- a/src/conformance/conformance_test/test_XR_KHR_D3D12_enable.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_D3D12_enable.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_KHR_OpenGL_ES_enable.cpp b/src/conformance/conformance_test/test_XR_KHR_OpenGL_ES_enable.cpp index 01624d96..38a8959c 100644 --- a/src/conformance/conformance_test/test_XR_KHR_OpenGL_ES_enable.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_OpenGL_ES_enable.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_KHR_OpenGL_enable.cpp b/src/conformance/conformance_test/test_XR_KHR_OpenGL_enable.cpp index 7be84beb..6f5368a7 100644 --- a/src/conformance/conformance_test/test_XR_KHR_OpenGL_enable.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_OpenGL_enable.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_KHR_composition_layer_cube.cpp b/src/conformance/conformance_test/test_XR_KHR_composition_layer_cube.cpp index 5cf450ae..bc8e839b 100644 --- a/src/conformance/conformance_test/test_XR_KHR_composition_layer_cube.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_composition_layer_cube.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -19,15 +19,13 @@ #include "utilities/generator.h" #include "utilities/bitmask_generator.h" #include "utilities/bitmask_to_string.h" +#include "utilities/xrduration_literals.h" #include #include #include -#include #include -#include -#include #include namespace Conformance diff --git a/src/conformance/conformance_test/test_XR_KHR_composition_layer_cylinder.cpp b/src/conformance/conformance_test/test_XR_KHR_composition_layer_cylinder.cpp index 4013bde9..9fd04593 100644 --- a/src/conformance/conformance_test/test_XR_KHR_composition_layer_cylinder.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_composition_layer_cylinder.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_KHR_composition_layer_depth.cpp b/src/conformance/conformance_test/test_XR_KHR_composition_layer_depth.cpp index 445f70b6..2fb6b576 100644 --- a/src/conformance/conformance_test/test_XR_KHR_composition_layer_depth.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_composition_layer_depth.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -17,6 +17,7 @@ #include "conformance_framework.h" #include "conformance_utils.h" #include "utilities/bitmask_generator.h" +#include "utilities/xrduration_literals.h" #include #include diff --git a/src/conformance/conformance_test/test_XR_KHR_composition_layer_equirect.cpp b/src/conformance/conformance_test/test_XR_KHR_composition_layer_equirect.cpp index 3c30ee33..3a38b4bb 100644 --- a/src/conformance/conformance_test/test_XR_KHR_composition_layer_equirect.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_composition_layer_equirect.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -19,15 +19,13 @@ #include "utilities/bitmask_generator.h" #include "utilities/bitmask_to_string.h" #include "utilities/generator.h" +#include "utilities/xrduration_literals.h" #include #include #include -#include #include -#include -#include #include namespace Conformance diff --git a/src/conformance/conformance_test/test_XR_KHR_convert_timespec_time.cpp b/src/conformance/conformance_test/test_XR_KHR_convert_timespec_time.cpp index b68c0c66..e0d17d01 100644 --- a/src/conformance/conformance_test/test_XR_KHR_convert_timespec_time.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_convert_timespec_time.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_KHR_visibility_mask.cpp b/src/conformance/conformance_test/test_XR_KHR_visibility_mask.cpp index 204a0339..9a10a02e 100644 --- a/src/conformance/conformance_test/test_XR_KHR_visibility_mask.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_visibility_mask.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_KHR_vulkan_enable.cpp b/src/conformance/conformance_test/test_XR_KHR_vulkan_enable.cpp index 2a8622e7..408e18d5 100644 --- a/src/conformance/conformance_test/test_XR_KHR_vulkan_enable.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_vulkan_enable.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_KHR_vulkan_enable2.cpp b/src/conformance/conformance_test/test_XR_KHR_vulkan_enable2.cpp index dfa1cbb8..ce5c23f2 100644 --- a/src/conformance/conformance_test/test_XR_KHR_vulkan_enable2.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_vulkan_enable2.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_KHR_win32_convert_performance_counter_time.cpp b/src/conformance/conformance_test/test_XR_KHR_win32_convert_performance_counter_time.cpp index 284cb2b9..b8283cd0 100644 --- a/src/conformance/conformance_test/test_XR_KHR_win32_convert_performance_counter_time.cpp +++ b/src/conformance/conformance_test/test_XR_KHR_win32_convert_performance_counter_time.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,6 +16,7 @@ #ifdef XR_USE_PLATFORM_WIN32 #include "utilities/utils.h" +#include "utilities/xrduration_literals.h" #include "conformance_utils.h" #include "conformance_framework.h" #include diff --git a/src/conformance/conformance_test/test_XR_META_headset_id.cpp b/src/conformance/conformance_test/test_XR_META_headset_id.cpp index f41885d5..4ffc3efa 100644 --- a/src/conformance/conformance_test/test_XR_META_headset_id.cpp +++ b/src/conformance/conformance_test/test_XR_META_headset_id.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) Meta Platforms, LLC and its affiliates. All rights reserved. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/test_XR_META_performance_metrics.cpp b/src/conformance/conformance_test/test_XR_META_performance_metrics.cpp index 585b95ff..c6db2d35 100644 --- a/src/conformance/conformance_test/test_XR_META_performance_metrics.cpp +++ b/src/conformance/conformance_test/test_XR_META_performance_metrics.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) Meta Platforms, LLC and its affiliates. All rights reserved. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/conformance_test/test_XR_MND_headless.cpp b/src/conformance/conformance_test/test_XR_MND_headless.cpp index 277a3879..0b940185 100644 --- a/src/conformance/conformance_test/test_XR_MND_headless.cpp +++ b/src/conformance/conformance_test/test_XR_MND_headless.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_XR_MSFT_controller_model.cpp b/src/conformance/conformance_test/test_XR_MSFT_controller_model.cpp index 8c9aef8c..afe38e0b 100644 --- a/src/conformance/conformance_test/test_XR_MSFT_controller_model.cpp +++ b/src/conformance/conformance_test/test_XR_MSFT_controller_model.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 @@ -7,7 +7,7 @@ #include "conformance_framework.h" #include "conformance_utils.h" #include "controller_animation_handler.h" -#include "gltf.h" +#include "cts_tinygltf.h" #include "graphics_plugin.h" #include "input_testinputdevice.h" #include "report.h" @@ -187,7 +187,7 @@ namespace Conformance syncInfo.countActiveActionSets = 1; XrActionSpaceCreateInfo actionSpaceCreateInfo{XR_TYPE_ACTION_SPACE_CREATE_INFO}; - actionSpaceCreateInfo.poseInActionSpace = XrPosef{Quat::Identity, {0, 0, 0}}; + actionSpaceCreateInfo.poseInActionSpace = XrPosefCPP(); std::vector gripSpaces; for (std::shared_ptr controller : {leftHandInputDevice, rightHandInputDevice}) { @@ -309,6 +309,13 @@ namespace Conformance TEST_CASE("XR_MSFT_controller_model_interactive", "[scenario][interactive][no_auto]") { + + GlobalData& globalData = GetGlobalData(); + + if (!globalData.IsInstanceExtensionSupported(XR_MSFT_CONTROLLER_MODEL_EXTENSION_NAME)) { + SKIP(XR_MSFT_CONTROLLER_MODEL_EXTENSION_NAME " not supported"); + } + const char* instructions = "Ensure the controller model is positioned in the same position as the physical controller. " "Press menu to complete the validation."; @@ -338,7 +345,8 @@ namespace Conformance XrPath subactionPath; XrSpace space; XrControllerModelKeyMSFT modelKey; - GLTFHandle controllerModel; + GLTFModelHandle controllerModel; + GLTFModelInstanceHandle controllerModelInstance; ControllerAnimationHandler animationHandler; }; @@ -394,6 +402,7 @@ namespace Conformance compositionHelper.BeginSession(); XrSession session = compositionHelper.GetSession(); + auto& graphicsPlugin = GetGlobalData().graphicsPlugin; // Create the instructional quad layer placed to the left. XrCompositionLayerQuad* const instructionsQuad = @@ -450,6 +459,7 @@ namespace Conformance ext.xrLoadControllerModelMSFT_(session, hand.modelKey, modelBufferSize, &modelBufferSize, modelBuffer.data())); hand.controllerModel = GetGlobalData().graphicsPlugin->LoadGLTF(modelBuffer); + hand.controllerModelInstance = GetGlobalData().graphicsPlugin->CreateGLTFModelInstance(hand.controllerModel); XrControllerModelPropertiesMSFT modelProperties{XR_TYPE_CONTROLLER_MODEL_PROPERTIES_MSFT}; REQUIRE_RESULT_UNQUALIFIED_SUCCESS(ext.xrGetControllerModelPropertiesMSFT_(session, hand.modelKey, &modelProperties)); @@ -458,8 +468,8 @@ namespace Conformance modelProperties.nodeProperties = nodePropertiesBuffer.data(); REQUIRE_RESULT_UNQUALIFIED_SUCCESS(ext.xrGetControllerModelPropertiesMSFT_(session, hand.modelKey, &modelProperties)); - hand.animationHandler = - ControllerAnimationHandler(GetGlobalData().graphicsPlugin->GetModel(hand.controllerModel), nodePropertiesBuffer); + hand.animationHandler = ControllerAnimationHandler{*GetGlobalData().graphicsPlugin->GetPbrModel(hand.controllerModel), + std::move(nodePropertiesBuffer)}; ReportF("Loaded model for key"); } @@ -481,9 +491,10 @@ namespace Conformance modelState.nodeStates = nodeStateBuffer.data(); REQUIRE_RESULT_UNQUALIFIED_SUCCESS(ext.xrGetControllerModelStateMSFT_(session, hand.modelKey, &modelState)); - hand.animationHandler.UpdateControllerParts(nodeStateBuffer); + hand.animationHandler.UpdateControllerParts(nodeStateBuffer, + graphicsPlugin->GetModelInstance(hand.controllerModelInstance)); - renderedGLTFs.push_back(GLTFDrawable{hand.controllerModel, spaceLocation.pose}); + renderedGLTFs.push_back(GLTFDrawable{hand.controllerModelInstance, spaceLocation.pose}); } } } diff --git a/src/conformance/conformance_test/test_XrCompositionLayerProjection.cpp b/src/conformance/conformance_test/test_XrCompositionLayerProjection.cpp index d0116b56..c1755d96 100644 --- a/src/conformance/conformance_test/test_XrCompositionLayerProjection.cpp +++ b/src/conformance/conformance_test/test_XrCompositionLayerProjection.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -19,6 +19,7 @@ #include "utilities/bitmask_generator.h" #include "utilities/bitmask_to_string.h" #include "utilities/generator.h" +#include "utilities/xrduration_literals.h" #include #include @@ -30,7 +31,6 @@ #include #include #include -#include #include namespace Conformance diff --git a/src/conformance/conformance_test/test_XrCompositionLayerQuad.cpp b/src/conformance/conformance_test/test_XrCompositionLayerQuad.cpp index 591f4956..b781f28b 100644 --- a/src/conformance/conformance_test/test_XrCompositionLayerQuad.cpp +++ b/src/conformance/conformance_test/test_XrCompositionLayerQuad.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -20,13 +20,13 @@ #include "utilities/generator.h" #include "utilities/throw_helpers.h" #include "utilities/types_and_constants.h" +#include "utilities/xrduration_literals.h" #include #include #include #include -#include #include #include #include diff --git a/src/conformance/conformance_test/test_actions.cpp b/src/conformance/conformance_test/test_actions.cpp index 294bda64..f66ad37f 100644 --- a/src/conformance/conformance_test/test_actions.cpp +++ b/src/conformance/conformance_test/test_actions.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -418,7 +418,7 @@ namespace Conformance SECTION("Unknown interaction profile") { for (const auto& invalidIP : invalidInteractionProfiles) { - bindings.interactionProfile = StringToPath(instance, invalidIP.c_str()); + bindings.interactionProfile = StringToPath(instance, invalidIP); REQUIRE_RESULT(xrSuggestInteractionProfileBindings(instance, &bindings), XR_ERROR_PATH_UNSUPPORTED); } @@ -428,7 +428,7 @@ namespace Conformance SECTION("Unknown binding path") { for (const auto& invalidBindingPath : invalidBindingPaths) { - XrActionSuggestedBinding invalidBindingPathBinding = {action, StringToPath(instance, invalidBindingPath.c_str())}; + XrActionSuggestedBinding invalidBindingPathBinding = {action, StringToPath(instance, invalidBindingPath)}; bindings.suggestedBindings = &invalidBindingPathBinding; REQUIRE_RESULT(xrSuggestInteractionProfileBindings(instance, &bindings), XR_ERROR_PATH_UNSUPPORTED); } @@ -471,7 +471,7 @@ namespace Conformance REQUIRE_RESULT(xrCreateAction(actionSet, &allIPActionCreateInfo, &hapticAction), XR_SUCCESS); CAPTURE(ipMetadata.InteractionProfilePathString); - bindings.interactionProfile = StringToPath(instance, ipMetadata.InteractionProfilePathString.c_str()); + bindings.interactionProfile = StringToPath(instance, ipMetadata.InteractionProfilePathString); bindings.countSuggestedBindings = 1; for (const auto& inputSourcePathData : ipMetadata.InputSourcePaths) { const std::string& bindingPath = inputSourcePathData.Path; @@ -498,7 +498,7 @@ namespace Conformance actionRef = &hapticAction; } - XrActionSuggestedBinding suggestedBindings{*actionRef, StringToPath(instance, bindingPath.c_str())}; + XrActionSuggestedBinding suggestedBindings{*actionRef, StringToPath(instance, bindingPath)}; bindings.suggestedBindings = &suggestedBindings; REQUIRE_RESULT(xrSuggestInteractionProfileBindings(instance, &bindings), XR_SUCCESS); } @@ -582,13 +582,13 @@ namespace Conformance std::shared_ptr inputDevice = CreateTestDevice( &actionLayerManager, &compositionHelper.GetInteractionManager(), compositionHelper.GetInstance(), compositionHelper.GetSession(), - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()), - path, cSimpleKHRInteractionProfileDefinition.InputSourcePaths); + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString), path, + cSimpleKHRInteractionProfileDefinition.InputSourcePaths); compositionHelper.GetInteractionManager().AddActionSet(actionSet); std::string selectPathStr = std::string(pathStr) + "/input/select/click"; - XrPath selectPath = StringToPath(compositionHelper.GetInstance(), selectPathStr.c_str()); + XrPath selectPath = StringToPath(compositionHelper.GetInstance(), selectPathStr); XrActionSuggestedBinding testBinding = {selectActionA, selectPath}; XrInteractionProfileSuggestedBinding bindings{XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING}; bindings.interactionProfile = StringToPath(compositionHelper.GetInstance(), "/interaction_profiles/khr/simple_controller"); @@ -598,7 +598,7 @@ namespace Conformance // Calling attach on the interaction manager will call xrSuggestInteractionProfileBindings with the bindings provided here, overwriting the previous bindings compositionHelper.GetInteractionManager().AddActionBindings( - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()), + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString), {{{selectActionB, selectPath}}}); compositionHelper.GetInteractionManager().AttachActionSets(); @@ -897,7 +897,7 @@ namespace Conformance std::vector interactionProfileOrder{}; auto suggestBindings = [&](const InteractionProfileMetadata& interactionProfile) { std::string interactionProfileName = interactionProfile.InteractionProfilePathString; - XrPath interactionProfilePath = StringToPath(compositionHelper.GetInstance(), interactionProfileName.c_str()); + XrPath interactionProfilePath = StringToPath(compositionHelper.GetInstance(), interactionProfileName); bool bindingSuggested = false; for (auto& bindings : interactionProfile.InputSourcePaths) { @@ -930,11 +930,11 @@ namespace Conformance } // Hardcoded path valid for simple controller - XrPath userHandLeftXrPath{StringToPath(compositionHelper.GetInstance(), topLevelPathString.c_str())}; + XrPath userHandLeftXrPath{StringToPath(compositionHelper.GetInstance(), topLevelPathString)}; std::shared_ptr inputDevice = CreateTestDevice( &actionLayerManager, &compositionHelper.GetInteractionManager(), compositionHelper.GetInstance(), compositionHelper.GetSession(), - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()), + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString), userHandLeftXrPath, cSimpleKHRInteractionProfileDefinition.InputSourcePaths); // This function calls xrSuggestInteractionProfileBindings() before attaching the actionsets @@ -944,10 +944,10 @@ namespace Conformance inputDevice->SetDeviceActive(/*state = */ true, /*skipInteraction = */ false, boolAction, actionSet); actionLayerManager.WaitForSessionFocusWithMessage(); XrInteractionProfileState interactionProfileState{XR_TYPE_INTERACTION_PROFILE_STATE}; - REQUIRE_RESULT(xrGetCurrentInteractionProfile(compositionHelper.GetSession(), - StringToPath(compositionHelper.GetInstance(), topLevelPathString.c_str()), - &interactionProfileState), - XR_SUCCESS); + REQUIRE_RESULT( + xrGetCurrentInteractionProfile(compositionHelper.GetSession(), + StringToPath(compositionHelper.GetInstance(), topLevelPathString), &interactionProfileState), + XR_SUCCESS); // Are we expecting the topLevelPath to have a active input? if (nullPathExpected) { @@ -994,7 +994,7 @@ namespace Conformance ActionLayerManager actionLayerManager(compositionHelper); XrPath simpleControllerInteractionProfile = - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()); + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString); XrActionSet actionSet{XR_NULL_HANDLE}; XrActionSetCreateInfo actionSetCreateInfo{XR_TYPE_ACTION_SET_CREATE_INFO}; @@ -1013,14 +1013,14 @@ namespace Conformance std::shared_ptr leftHandInputDevice = CreateTestDevice( &actionLayerManager, &compositionHelper.GetInteractionManager(), compositionHelper.GetInstance(), compositionHelper.GetSession(), - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()), + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString), leftHandPath, cSimpleKHRInteractionProfileDefinition.InputSourcePaths); XrPath rightHandPath{StringToPath(compositionHelper.GetInstance(), "/user/hand/right")}; std::shared_ptr rightHandInputDevice = CreateTestDevice( &actionLayerManager, &compositionHelper.GetInteractionManager(), compositionHelper.GetInstance(), compositionHelper.GetSession(), - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()), + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString), rightHandPath, cSimpleKHRInteractionProfileDefinition.InputSourcePaths); XrActionsSyncInfo syncInfo{XR_TYPE_ACTIONS_SYNC_INFO}; @@ -1036,7 +1036,7 @@ namespace Conformance compositionHelper.GetInteractionManager().AddActionSet(actionSet); compositionHelper.GetInteractionManager().AddActionBindings( - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()), + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString), {{{selectAction, StringToPath(compositionHelper.GetInstance(), "/user/hand/left/input/select/click")}, {selectAction, StringToPath(compositionHelper.GetInstance(), "/user/hand/right/input/select/click")}}}); compositionHelper.GetInteractionManager().AttachActionSets(); @@ -1136,7 +1136,7 @@ namespace Conformance ActionLayerManager actionLayerManager(compositionHelper); XrPath simpleControllerInteractionProfile = - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()); + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString); std::string leftHandPathString = "/user/hand/left"; XrPath leftHandPath{StringToPath(compositionHelper.GetInstance(), "/user/hand/left")}; @@ -1234,7 +1234,7 @@ namespace Conformance SECTION("Parameter validation") { std::string selectPathStr = defaultDevicePathStr + "/input/select/click"; - XrPath selectPath = StringToPath(compositionHelper.GetInstance(), selectPathStr.c_str()); + XrPath selectPath = StringToPath(compositionHelper.GetInstance(), selectPathStr); compositionHelper.GetInteractionManager().AddActionSet(actionSet); compositionHelper.GetInteractionManager().AddActionBindings(simpleControllerInteractionProfile, {{action, selectPath}}); compositionHelper.GetInteractionManager().AttachActionSets(); @@ -1851,7 +1851,7 @@ namespace Conformance actionLayerManager.WaitForSessionFocusWithMessage(); - XrPath interactionProfile = StringToPath(compositionHelper.GetInstance(), ipMetadata.InteractionProfilePathString.c_str()); + XrPath interactionProfile = StringToPath(compositionHelper.GetInstance(), ipMetadata.InteractionProfilePathString); XrPath inputDevicePath{StringToPath(compositionHelper.GetInstance(), topLevelPathString.data())}; std::shared_ptr inputDevice = CreateTestDevice(&actionLayerManager, &compositionHelper.GetInteractionManager(), compositionHelper.GetInstance(), @@ -1971,7 +1971,7 @@ namespace Conformance REQUIRE_RESULT(xrCreateAction(actionSet, &actionCreateInfo, &xAction), XR_SUCCESS); std::string xSubBindingPath = std::string(inputSourceData.Path) + "/x"; - bindingPath = StringToPath(compositionHelper.GetInstance(), xSubBindingPath.c_str()); + bindingPath = StringToPath(compositionHelper.GetInstance(), xSubBindingPath); compositionHelper.GetInteractionManager().AddActionBindings(interactionProfile, {{xAction, bindingPath}}); actionNames = GetActionNames(); @@ -1980,7 +1980,7 @@ namespace Conformance REQUIRE_RESULT(xrCreateAction(actionSet, &actionCreateInfo, &yAction), XR_SUCCESS); std::string ySubBindingPath = std::string(inputSourceData.Path) + "/y"; - bindingPath = StringToPath(compositionHelper.GetInstance(), ySubBindingPath.c_str()); + bindingPath = StringToPath(compositionHelper.GetInstance(), ySubBindingPath); compositionHelper.GetInteractionManager().AddActionBindings(interactionProfile, {{yAction, bindingPath}}); break; } @@ -2785,7 +2785,7 @@ namespace Conformance actionLayerManager.WaitForSessionFocusWithMessage(); XrPath simpleControllerInteractionProfile = - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()); + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString); XrPath leftHandSelectClickPath = StringToPath(compositionHelper.GetInstance(), "/user/hand/left/input/select/click"); XrPath rightHandSelectClickPath = StringToPath(compositionHelper.GetInstance(), "/user/hand/right/input/select/click"); @@ -2916,6 +2916,14 @@ namespace Conformance reinterpret_cast(&hapticPacket)), XR_ERROR_PATH_UNSUPPORTED); REQUIRE_RESULT(xrStopHapticFeedback(compositionHelper.GetSession(), &hapticActionInfo), XR_ERROR_PATH_UNSUPPORTED); + + { + INFO("Action created with no subaction paths, cannot be queried with any"); + getInfo.action = confirmAction; + getInfo.subactionPath = leftHandPath; + REQUIRE_RESULT(xrGetActionStateBoolean(compositionHelper.GetSession(), &getInfo, &booleanState), + XR_ERROR_PATH_UNSUPPORTED); + } } SECTION("Type mismatch") { @@ -2994,7 +3002,7 @@ namespace Conformance ActionLayerManager actionLayerManager(compositionHelper); XrPath simpleControllerInteractionProfile = - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()); + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString); XrActionSet actionSet{XR_NULL_HANDLE}; XrActionSetCreateInfo actionSetCreateInfo{XR_TYPE_ACTION_SET_CREATE_INFO}; @@ -3079,7 +3087,7 @@ namespace Conformance ActionLayerManager actionLayerManager(compositionHelper); XrPath simpleControllerInteractionProfile = - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()); + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString); XrPath leftHandPath{StringToPath(compositionHelper.GetInstance(), "/user/hand/left")}; XrPath rightHandPath{StringToPath(compositionHelper.GetInstance(), "/user/hand/right")}; const XrPath bothHands[2] = {leftHandPath, rightHandPath}; @@ -3565,8 +3573,8 @@ namespace Conformance std::shared_ptr inputDevice = CreateTestDevice( &actionLayerManager, &compositionHelper.GetInteractionManager(), compositionHelper.GetInstance(), compositionHelper.GetSession(), - StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString.c_str()), - path, cSimpleKHRInteractionProfileDefinition.InputSourcePaths); + StringToPath(compositionHelper.GetInstance(), cSimpleKHRInteractionProfileDefinition.InteractionProfilePathString), path, + cSimpleKHRInteractionProfileDefinition.InputSourcePaths); compositionHelper.GetInteractionManager().AddActionSet(actionSet); compositionHelper.GetInteractionManager().AddActionBindings( diff --git a/src/conformance/conformance_test/test_glTFRendering.cpp b/src/conformance/conformance_test/test_glTFRendering.cpp index 440d6f18..8c5b571e 100644 --- a/src/conformance/conformance_test/test_glTFRendering.cpp +++ b/src/conformance/conformance_test/test_glTFRendering.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,10 @@ namespace Conformance GlobalData& globalData = GetGlobalData(); CompositionHelper compositionHelper("glTF rendering"); + XrInstance instance = compositionHelper.GetInstance(); + XrSession session = compositionHelper.GetSession(); + InteractionManager& interactionManager = compositionHelper.GetInteractionManager(); + // Each test case will configure the layer manager with its own instructions and image InteractiveLayerManager interactiveLayerManager(compositionHelper, nullptr, "glTF rendering"); @@ -48,8 +53,7 @@ namespace Conformance } } - const std::vector subactionPaths{StringToPath(compositionHelper.GetInstance(), "/user/hand/left"), - StringToPath(compositionHelper.GetInstance(), "/user/hand/right")}; + const std::vector subactionPaths{StringToPath(instance, "/user/hand/left"), StringToPath(instance, "/user/hand/right")}; XrActionSet actionSet; XrAction gripPoseAction; @@ -57,7 +61,7 @@ namespace Conformance XrActionSetCreateInfo actionSetInfo{XR_TYPE_ACTION_SET_CREATE_INFO}; strcpy(actionSetInfo.actionSetName, "gltf_rendering"); strcpy(actionSetInfo.localizedActionSetName, "glTF rendering"); - XRC_CHECK_THROW_XRCMD(xrCreateActionSet(compositionHelper.GetInstance(), &actionSetInfo, &actionSet)); + XRC_CHECK_THROW_XRCMD(xrCreateActionSet(instance, &actionSetInfo, &actionSet)); XrActionCreateInfo actionInfo{XR_TYPE_ACTION_CREATE_INFO}; actionInfo.actionType = XR_ACTION_TYPE_POSE_INPUT; @@ -68,16 +72,15 @@ namespace Conformance XRC_CHECK_THROW_XRCMD(xrCreateAction(actionSet, &actionInfo, &gripPoseAction)); } - compositionHelper.GetInteractionManager().AddActionSet(actionSet); - XrPath simpleInteractionProfile = StringToPath(compositionHelper.GetInstance(), "/interaction_profiles/khr/simple_controller"); - compositionHelper.GetInteractionManager().AddActionBindings( - simpleInteractionProfile, - {{ - {gripPoseAction, StringToPath(compositionHelper.GetInstance(), "/user/hand/left/input/grip/pose")}, - {gripPoseAction, StringToPath(compositionHelper.GetInstance(), "/user/hand/right/input/grip/pose")}, - }}); + interactionManager.AddActionSet(actionSet); + XrPath simpleInteractionProfile = StringToPath(instance, "/interaction_profiles/khr/simple_controller"); + interactionManager.AddActionBindings(simpleInteractionProfile, + {{ + {gripPoseAction, StringToPath(instance, "/user/hand/left/input/grip/pose")}, + {gripPoseAction, StringToPath(instance, "/user/hand/right/input/grip/pose")}, + }}); - compositionHelper.GetInteractionManager().AttachActionSets(); + interactionManager.AttachActionSets(); compositionHelper.BeginSession(); // Spaces where we will draw the active gltf. Default to one on each controller. @@ -90,9 +93,9 @@ namespace Conformance XrActionSpaceCreateInfo spaceCreateInfo{XR_TYPE_ACTION_SPACE_CREATE_INFO}; spaceCreateInfo.action = gripPoseAction; spaceCreateInfo.subactionPath = subactionPaths[i]; - spaceCreateInfo.poseInActionSpace = {{0, 0, 0, 1}, {0, 0, 0}}; - XRC_CHECK_THROW_XRCMD(xrCreateActionSpace(compositionHelper.GetSession(), &spaceCreateInfo, &space)); - gripSpaces.push_back(std::move(space)); + spaceCreateInfo.poseInActionSpace = XrPosefCPP{}; + XRC_CHECK_THROW_XRCMD(xrCreateActionSpace(session, &spaceCreateInfo, &space)); + gripSpaces.emplace_back(std::move(space)); } } @@ -164,7 +167,9 @@ namespace Conformance auto testCase = testCases[testCaseIdx]; bool testCaseInitialized = false; - GLTFHandle gltfModel; + GLTFModelHandle gltfModel; + std::vector gltfModelInstances; + gltfModelInstances.reserve(gripSpaces.size()); auto setupTest = [&]() { // Load the model file into memory @@ -173,6 +178,12 @@ namespace Conformance // Load the model gltfModel = GetGlobalData().graphicsPlugin->LoadGLTF(modelData); + gltfModelInstances.clear(); + + for (const auto& space : gripSpaces) { + (void)space; + gltfModelInstances.push_back(GetGlobalData().graphicsPlugin->CreateGLTFModelInstance(gltfModel)); + } // Configure the interactive layer manager with the corresponding description and image std::ostringstream oss; oss << "Subtest " << (testCaseIdx + 1) << "/" << ArraySize(testCases) << ": " << testCase.name << std::endl; @@ -189,9 +200,6 @@ namespace Conformance auto viewData = compositionHelper.LocateViews(localSpace, frameState.predictedDisplayTime); const auto& viewState = std::get(viewData); - // want our standard action sets on all subaction paths - compositionHelper.GetInteractionManager().SyncActions(XR_NULL_PATH); - if (!testCaseInitialized) { testCase = testCases[testCaseIdx]; setupTest(); @@ -199,7 +207,8 @@ namespace Conformance std::vector renderedGLTFs; - for (const auto& space : gripSpaces) { + for (size_t i = 0; i < gripSpaces.size(); ++i) { + const auto& space = gripSpaces[i]; XrSpaceLocation location{XR_TYPE_SPACE_LOCATION}; if (XR_SUCCEEDED(xrLocateSpace(space, localSpace, frameState.predictedDisplayTime, &location))) { if ((location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) && @@ -207,7 +216,8 @@ namespace Conformance XrPosef adjustedPose; XrPosef_Multiply(&adjustedPose, &location.pose, &testCase.poseInGripSpace); - renderedGLTFs.push_back(GLTFDrawable{gltfModel, adjustedPose, {testCase.scale, testCase.scale, testCase.scale}}); + renderedGLTFs.push_back( + GLTFDrawable{gltfModelInstances[i], adjustedPose, {testCase.scale, testCase.scale, testCase.scale}}); } } } @@ -239,6 +249,6 @@ namespace Conformance } return true; }; - RenderLoop(compositionHelper.GetSession(), updateLayers).Loop(); + RenderLoop(session, updateLayers).Loop(); } } // namespace Conformance diff --git a/src/conformance/conformance_test/test_multithreading.cpp b/src/conformance/conformance_test/test_multithreading.cpp index de7156ef..1d51f686 100644 --- a/src/conformance/conformance_test/test_multithreading.cpp +++ b/src/conformance/conformance_test/test_multithreading.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrCreateInstance.cpp b/src/conformance/conformance_test/test_xrCreateInstance.cpp index 6af99a31..0fab8598 100644 --- a/src/conformance/conformance_test/test_xrCreateInstance.cpp +++ b/src/conformance/conformance_test/test_xrCreateInstance.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrCreateReferenceSpace.cpp b/src/conformance/conformance_test/test_xrCreateReferenceSpace.cpp index 21f534e7..307728c5 100644 --- a/src/conformance/conformance_test/test_xrCreateReferenceSpace.cpp +++ b/src/conformance/conformance_test/test_xrCreateReferenceSpace.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrCreateSession.cpp b/src/conformance/conformance_test/test_xrCreateSession.cpp index cb6f1314..43e3ef5d 100644 --- a/src/conformance/conformance_test/test_xrCreateSession.cpp +++ b/src/conformance/conformance_test/test_xrCreateSession.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -62,6 +62,9 @@ namespace Conformance SECTION("Missing graphics binding implies XR_ERROR_GRAPHICS_DEVICE_INVALID") { + if (graphicsPlugin) { + REQUIRE(graphicsPlugin->InitializeDevice(instance, systemId, true /* checkGraphicsRequirements */)); + } sessionCreateInfo.next = nullptr; XrResult result; CAPTURE(result = xrCreateSession(instance, &sessionCreateInfo, &session)); diff --git a/src/conformance/conformance_test/test_xrCreateSwapchain.cpp b/src/conformance/conformance_test/test_xrCreateSwapchain.cpp index ac179090..59297cc8 100644 --- a/src/conformance/conformance_test/test_xrCreateSwapchain.cpp +++ b/src/conformance/conformance_test/test_xrCreateSwapchain.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrEnumerateApiLayerProperties.cpp b/src/conformance/conformance_test/test_xrEnumerateApiLayerProperties.cpp index ac6e61b3..082b726e 100644 --- a/src/conformance/conformance_test/test_xrEnumerateApiLayerProperties.cpp +++ b/src/conformance/conformance_test/test_xrEnumerateApiLayerProperties.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrEnumerateEnvironmentBlendModes.cpp b/src/conformance/conformance_test/test_xrEnumerateEnvironmentBlendModes.cpp index 81b98126..79e53948 100644 --- a/src/conformance/conformance_test/test_xrEnumerateEnvironmentBlendModes.cpp +++ b/src/conformance/conformance_test/test_xrEnumerateEnvironmentBlendModes.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrEnumerateInstanceExtensionProperties.cpp b/src/conformance/conformance_test/test_xrEnumerateInstanceExtensionProperties.cpp index a0af3c21..2915fd27 100644 --- a/src/conformance/conformance_test/test_xrEnumerateInstanceExtensionProperties.cpp +++ b/src/conformance/conformance_test/test_xrEnumerateInstanceExtensionProperties.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrEnumerateReferenceSpaces.cpp b/src/conformance/conformance_test/test_xrEnumerateReferenceSpaces.cpp index df984a41..8285f196 100644 --- a/src/conformance/conformance_test/test_xrEnumerateReferenceSpaces.cpp +++ b/src/conformance/conformance_test/test_xrEnumerateReferenceSpaces.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrEnumerateSwapchainFormats.cpp b/src/conformance/conformance_test/test_xrEnumerateSwapchainFormats.cpp index 68008ecd..76aac34b 100644 --- a/src/conformance/conformance_test/test_xrEnumerateSwapchainFormats.cpp +++ b/src/conformance/conformance_test/test_xrEnumerateSwapchainFormats.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrGetInstanceProcAddr.cpp b/src/conformance/conformance_test/test_xrGetInstanceProcAddr.cpp index 3b11e3b5..0b6b4d17 100644 --- a/src/conformance/conformance_test/test_xrGetInstanceProcAddr.cpp +++ b/src/conformance/conformance_test/test_xrGetInstanceProcAddr.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrGetInstanceProperties.cpp b/src/conformance/conformance_test/test_xrGetInstanceProperties.cpp index 9e2deb32..904643f0 100644 --- a/src/conformance/conformance_test/test_xrGetInstanceProperties.cpp +++ b/src/conformance/conformance_test/test_xrGetInstanceProperties.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrGetReferenceSpaceBoundsRect.cpp b/src/conformance/conformance_test/test_xrGetReferenceSpaceBoundsRect.cpp index 56a6d4a5..07a4a771 100644 --- a/src/conformance/conformance_test/test_xrGetReferenceSpaceBoundsRect.cpp +++ b/src/conformance/conformance_test/test_xrGetReferenceSpaceBoundsRect.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrGetSystem.cpp b/src/conformance/conformance_test/test_xrGetSystem.cpp index def4e6db..e6376aad 100644 --- a/src/conformance/conformance_test/test_xrGetSystem.cpp +++ b/src/conformance/conformance_test/test_xrGetSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrGetSystemProperties.cpp b/src/conformance/conformance_test/test_xrGetSystemProperties.cpp index 0bc6fb1c..ab78bbe4 100644 --- a/src/conformance/conformance_test/test_xrGetSystemProperties.cpp +++ b/src/conformance/conformance_test/test_xrGetSystemProperties.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrLinear.cpp b/src/conformance/conformance_test/test_xrLinear.cpp index 43468d6d..ca59da0a 100644 --- a/src/conformance/conformance_test/test_xrLinear.cpp +++ b/src/conformance/conformance_test/test_xrLinear.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrLocateSpace.cpp b/src/conformance/conformance_test/test_xrLocateSpace.cpp index 96b54ffa..ab6f9482 100644 --- a/src/conformance/conformance_test/test_xrLocateSpace.cpp +++ b/src/conformance/conformance_test/test_xrLocateSpace.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,21 +14,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "composition_utils.h" #include "conformance_framework.h" #include "conformance_utils.h" #include "utilities/bitmask_to_string.h" #include "utilities/types_and_constants.h" +#include "utilities/xrduration_literals.h" #include #include #include -#include #include -#include -#include -#include -#include namespace Conformance { @@ -176,20 +173,17 @@ namespace Conformance CHECK(XR_SUCCESS == xrCreateReferenceSpace(sessionHandle, &spaceCreateInfo, &spaceB)); XrResult result = xrLocateSpace(spaceA, spaceB, time, &location); - CHECK(XR_SUCCESS == result); + { + INFO("xrLocateSpace"); + CHECK(XR_SUCCESS == result); + } // the main test: if (XR_SUCCESS == result) { // Capture the three poses and the result to generate useful error messages in case the result is not // identical to the expected values. - CAPTURE(poseSpaceA.orientation.x, poseSpaceA.orientation.y, poseSpaceA.orientation.z, poseSpaceA.orientation.w, - poseSpaceA.position.x, poseSpaceA.position.y, poseSpaceA.position.z, poseSpaceB.orientation.x, - poseSpaceB.orientation.y, poseSpaceB.orientation.z, poseSpaceB.orientation.w, poseSpaceB.position.x, - poseSpaceB.position.y, poseSpaceB.position.z, expectedResult.orientation.x, expectedResult.orientation.y, - expectedResult.orientation.z, expectedResult.orientation.w, expectedResult.position.x, - expectedResult.position.y, expectedResult.position.z, location.pose.orientation.x, location.pose.orientation.y, - location.pose.orientation.z, location.pose.orientation.w, location.pose.position.x, location.pose.position.y, - location.pose.position.z); + CAPTURE(poseSpaceA.orientation, poseSpaceA.position, poseSpaceB.orientation, poseSpaceB.position, + expectedResult.orientation, expectedResult.position, location.pose.orientation, location.pose.position); ValidateSpaceLocation(location, expectedResult); } @@ -205,7 +199,7 @@ namespace Conformance LocateAndTest(identity, identity, identity); // Exercise identical spaces which are not located at the origin of the reference space. - XrPosef space = {{0, 0, 0, 1}, {1, 2, 3}}; + XrPosef space = {Quat::Identity, {1, 2, 3}}; LocateAndTest(space, space, identity); // Exercise identical spaces which also have a rotation. @@ -213,10 +207,10 @@ namespace Conformance LocateAndTest(space, space, identity); // Exercise different spaces without a rotation. - LocateAndTest({{0, 0, 0, 1}, {1, 2, 3}}, {{0, 0, 0, 1}, {-1, -2, -3}}, {{0, 0, 0, 1}, {2, 4, 6}}); + LocateAndTest({Quat::Identity, {1, 2, 3}}, {Quat::Identity, {-1, -2, -3}}, {Quat::Identity, {2, 4, 6}}); // Another test with different spaces. - LocateAndTest({{0, 0, 0, 1}, {-1, -2, -3}}, {{0, 0, 0, 1}, {1, 2, 3}}, {{0, 0, 0, 1}, {-2, -4, -6}}); + LocateAndTest({Quat::Identity, {-1, -2, -3}}, {Quat::Identity, {1, 2, 3}}, {Quat::Identity, {-2, -4, -6}}); const float pi = std::acos(-1.0f); float deg90 = pi / 2.0f; diff --git a/src/conformance/conformance_test/test_xrLocateViews.cpp b/src/conformance/conformance_test/test_xrLocateViews.cpp index 583dc66e..ba0ec5cd 100644 --- a/src/conformance/conformance_test/test_xrLocateViews.cpp +++ b/src/conformance/conformance_test/test_xrLocateViews.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrPathToString.cpp b/src/conformance/conformance_test/test_xrPathToString.cpp index 5bb87546..c61774ce 100644 --- a/src/conformance/conformance_test/test_xrPathToString.cpp +++ b/src/conformance/conformance_test/test_xrPathToString.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrPollEvent.cpp b/src/conformance/conformance_test/test_xrPollEvent.cpp index 10d96278..21a5dfa6 100644 --- a/src/conformance/conformance_test/test_xrPollEvent.cpp +++ b/src/conformance/conformance_test/test_xrPollEvent.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrRequestExitSession.cpp b/src/conformance/conformance_test/test_xrRequestExitSession.cpp index d4456f36..a9e36175 100644 --- a/src/conformance/conformance_test/test_xrRequestExitSession.cpp +++ b/src/conformance/conformance_test/test_xrRequestExitSession.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrResultToString.cpp b/src/conformance/conformance_test/test_xrResultToString.cpp index 7e951cea..0d0dec29 100644 --- a/src/conformance/conformance_test/test_xrResultToString.cpp +++ b/src/conformance/conformance_test/test_xrResultToString.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrStringToPath.cpp b/src/conformance/conformance_test/test_xrStringToPath.cpp index f1b66618..a7db6978 100644 --- a/src/conformance/conformance_test/test_xrStringToPath.cpp +++ b/src/conformance/conformance_test/test_xrStringToPath.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/conformance_test/test_xrStructureTypeToString.cpp b/src/conformance/conformance_test/test_xrStructureTypeToString.cpp index 3a4f9c03..142ccf36 100644 --- a/src/conformance/conformance_test/test_xrStructureTypeToString.cpp +++ b/src/conformance/conformance_test/test_xrStructureTypeToString.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/ctsxml.rnc b/src/conformance/ctsxml.rnc index 5bcb827f..adc0a250 100644 --- a/src/conformance/ctsxml.rnc +++ b/src/conformance/ctsxml.rnc @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2023, The Khronos Group Inc. +# Copyright (c) 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/CMakeLists.txt b/src/conformance/framework/CMakeLists.txt index d75b294b..e20759bd 100644 --- a/src/conformance/framework/CMakeLists.txt +++ b/src/conformance/framework/CMakeLists.txt @@ -1,10 +1,10 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # tinygltf -add_library(conformance_framework_tinygltf STATIC gltf.cpp) +add_library(conformance_framework_tinygltf STATIC cts_tinygltf.cpp) target_include_directories( conformance_framework_tinygltf @@ -59,6 +59,7 @@ add_library( conformance_utils.cpp controller_animation_handler.cpp environment.cpp + gltf_helpers.cpp graphics_plugin_d3d11.cpp graphics_plugin_d3d11_gltf.cpp graphics_plugin_d3d12.cpp diff --git a/src/conformance/framework/RGBAImage.cpp b/src/conformance/framework/RGBAImage.cpp index ce2f9e8d..db6c0c9f 100644 --- a/src/conformance/framework/RGBAImage.cpp +++ b/src/conformance/framework/RGBAImage.cpp @@ -1,10 +1,11 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 #include "RGBAImage.h" #include "conformance_framework.h" +#include "report.h" #ifdef XR_USE_PLATFORM_ANDROID #include "common/unique_asset.h" @@ -160,6 +161,7 @@ namespace Conformance uc = stbi_load_from_memory((const stbi_uc*)buf, length, &width, &height, nullptr, RequiredComponents); } #else + stbi_uc* const uc = stbi_load(path, &width, &height, nullptr, RequiredComponents); #endif if (uc == nullptr) { @@ -177,7 +179,7 @@ namespace Conformance return image; } - void RGBAImage::PutText(const XrRect2Di& rect, const char* text, int pixelHeight, XrColor4f color) + void RGBAImage::PutText(const XrRect2Di& rect, const char* text, int pixelHeight, XrColor4f color, WordWrap wordWrap) { const std::shared_ptr font = BakedFont::GetOrCreate(pixelHeight); if (!font) @@ -187,6 +189,8 @@ namespace Conformance int yadvance = rect.offset.y + (int)(pixelHeight * 0.8f); // Adjust down because glyphs are relative to the font baseline. This is hacky. + const char* const fullText = text; + // Loop through each character and copy over the chracters' glyphs. for (; *text; text++) { if (*text == '\n') { @@ -207,8 +211,14 @@ namespace Conformance if (xadvance + remainingWordWidth > rect.offset.x + rect.extent.width) { // But only if the word isn't longer than the destination. if (remainingWordWidth <= (rect.extent.width - rect.offset.x)) { - xadvance = (float)rect.offset.x; - yadvance += pixelHeight; + if (wordWrap == WordWrap::Enabled) { + xadvance = (float)rect.offset.x; + yadvance += pixelHeight; + } + else { + ReportConsoleOnlyF("CTS dev warning: Would have wrapped this text but told to disable word wrap! Text: %s", + fullText); + } } } } @@ -217,10 +227,16 @@ namespace Conformance const int characterWidth = (int)(bakedChar.x1 - bakedChar.x0); const int characterHeight = (int)(bakedChar.y1 - bakedChar.y0); - if (xadvance + characterWidth > rect.offset.x + rect.extent.width) { - // Wrap to new line if there isn't enough room for this char. - xadvance = (float)rect.offset.x; - yadvance += pixelHeight; + if ((xadvance + characterWidth) > (rect.offset.x + rect.extent.width)) { + if (wordWrap == WordWrap::Enabled) { + + // Wrap to new line if there isn't enough room for this char. + xadvance = (float)rect.offset.x; + yadvance += pixelHeight; + } + else { + ReportConsoleOnlyF("CTS dev warning: Would have wrapped this text but told to disable word wrap! Text: %s", fullText); + } } // For each row of the glyph bitmap @@ -330,6 +346,35 @@ namespace Conformance rowPitch); } + void RGBAImageCache::Init() + { + m_cacheMutex = std::make_unique(); + } + + std::shared_ptr RGBAImageCache::Load(const char* path) + { + if (!IsValid()) { + throw std::logic_error("RGBAImageCache accessed before initialization"); + } + + // Check cache to see if this image already exists. + { + std::lock_guard guard(*m_cacheMutex); + auto imageIt = m_imageCache.find(path); + if (imageIt != m_imageCache.end()) { + return imageIt->second; + } + } + + ReportConsoleOnlyF("Loading and caching image: %s", path); + + auto image = std::make_shared(RGBAImage::Load(path)); + + std::lock_guard guard(*m_cacheMutex); + // If the key already exists then the existing image will be returned. + return m_imageCache.emplace(path, image).first->second; + } + void CopyWithStride(const uint8_t* source, uint8_t* dest, uint32_t rowSize, uint32_t rows, uint32_t rowPitch) { for (size_t row = 0; row < rows; ++row) { diff --git a/src/conformance/framework/RGBAImage.h b/src/conformance/framework/RGBAImage.h index 654b7d5f..76b1f17f 100644 --- a/src/conformance/framework/RGBAImage.h +++ b/src/conformance/framework/RGBAImage.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 @@ -6,6 +6,9 @@ #include +#include +#include +#include #include namespace Conformance @@ -30,6 +33,12 @@ namespace Conformance static_assert(sizeof(RGBA8Color) == 4, "Incorrect RGBA8Color size"); + enum class WordWrap + { + Disabled, + Enabled, + }; + /// A 2D, 32 bit-per-pixel RGBA image struct RGBAImage { @@ -37,7 +46,7 @@ namespace Conformance static RGBAImage Load(const char* path); - void PutText(const XrRect2Di& rect, const char* text, int pixelHeight, XrColor4f color); + void PutText(const XrRect2Di& rect, const char* text, int pixelHeight, XrColor4f color, WordWrap wordWrap = WordWrap::Enabled); void DrawRect(int x, int y, int w, int h, XrColor4f color); void DrawRectBorder(int x, int y, int w, int h, int thickness, XrColor4f color); void ConvertToSRGB(); @@ -52,6 +61,30 @@ namespace Conformance int32_t height; }; + /// A 2D, 32 bit-per-pixel RGBA image + class RGBAImageCache + { + public: + RGBAImageCache() = default; + + RGBAImageCache(RGBAImageCache&&) = default; + RGBAImageCache& operator=(RGBAImageCache&&) = default; + + void Init(); + + bool IsValid() const noexcept + { + return m_cacheMutex != nullptr; + } + + std::shared_ptr Load(const char* path); + + private: + // in unique_ptr to make it moveable + std::unique_ptr m_cacheMutex; + std::map> m_imageCache; + }; + /// Copy a contiguous image into a buffer for GPU usage - with stride/pitch. /// /// @param source Source buffer, with all pixels contiguous diff --git a/src/conformance/framework/action_utils.cpp b/src/conformance/framework/action_utils.cpp index fddbb4d5..555b27ca 100644 --- a/src/conformance/framework/action_utils.cpp +++ b/src/conformance/framework/action_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/action_utils.h b/src/conformance/framework/action_utils.h index ac0a6e6b..6922083e 100644 --- a/src/conformance/framework/action_utils.h +++ b/src/conformance/framework/action_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/catch_reporter_cts.cpp b/src/conformance/framework/catch_reporter_cts.cpp index 4deba8f8..3a443cf7 100644 --- a/src/conformance/framework/catch_reporter_cts.cpp +++ b/src/conformance/framework/catch_reporter_cts.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright Catch2 Authors // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/src/conformance/framework/catch_reporter_cts.h b/src/conformance/framework/catch_reporter_cts.h index 24610d38..3e2742fc 100644 --- a/src/conformance/framework/catch_reporter_cts.h +++ b/src/conformance/framework/catch_reporter_cts.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright Catch2 Authors // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/src/conformance/framework/composition_utils.cpp b/src/conformance/framework/composition_utils.cpp index c0659991..d4050819 100644 --- a/src/conformance/framework/composition_utils.cpp +++ b/src/conformance/framework/composition_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,6 +16,7 @@ #include "composition_utils.h" +#include "RGBAImage.h" #include "conformance_framework.h" #include "swapchain_image_data.h" @@ -39,7 +40,7 @@ using namespace std::chrono_literals; namespace Conformance { - RGBAImage CreateTextImage(int32_t width, int32_t height, const char* text, int32_t fontHeight) + RGBAImage CreateTextImage(int32_t width, int32_t height, const char* text, int32_t fontHeight, WordWrap wordWrap) { constexpr int FontPaddingPixels = 4; constexpr int BorderPixels = 2; @@ -49,14 +50,14 @@ namespace Conformance image.DrawRect(0, 0, image.width, image.height, {0, 0, 0, 0.5f}); image.DrawRectBorder(0, 0, image.width, image.height, BorderPixels, {1, 1, 1, 1}); image.PutText(XrRect2Di{{InsetPixels, InsetPixels}, {image.width - InsetPixels * 2, image.height - InsetPixels * 2}}, text, - fontHeight, {1, 1, 1, 1}); + fontHeight, {1, 1, 1, 1}, wordWrap); return image; } - XrPath StringToPath(XrInstance instance, const char* pathStr) + XrPath StringToPath(XrInstance instance, const std::string& pathStr) { XrPath path; - XRC_CHECK_THROW_XRCMD(xrStringToPath(instance, pathStr, &path)); + XRC_CHECK_THROW_XRCMD(xrStringToPath(instance, pathStr.c_str(), &path)); return path; } @@ -137,15 +138,21 @@ namespace Conformance void InteractionManager::SyncActions(XrPath subactionPath) { - std::vector activeActionSet; - for (auto& actionSet : m_actionSets) { - XrActiveActionSet activeSet{actionSet, subactionPath}; - activeActionSet.emplace_back(activeSet); - } + SyncActions({subactionPath}); + } + void InteractionManager::SyncActions(const std::initializer_list& subactionPaths) + { + std::vector activeActionSets; + for (XrPath subactionPath : subactionPaths) { + for (auto& actionSet : m_actionSets) { + XrActiveActionSet activeSet{actionSet, subactionPath}; + activeActionSets.emplace_back(activeSet); + } + } XrActionsSyncInfo syncInfo{XR_TYPE_ACTIONS_SYNC_INFO}; - syncInfo.countActiveActionSets = uint32_t(m_actionSets.size()); - syncInfo.activeActionSets = activeActionSet.data(); + syncInfo.countActiveActionSets = uint32_t(activeActionSets.size()); + syncInfo.activeActionSets = activeActionSets.data(); XRC_CHECK_THROW_XRCMD(xrSyncActions(m_session, &syncInfo)); } @@ -190,7 +197,7 @@ namespace Conformance { constexpr int TitleFontHeightPixels = 32; - RGBAImage image = CreateTextImage(512, 44, testName, TitleFontHeightPixels); + RGBAImage image = CreateTextImage(512, 44, testName, TitleFontHeightPixels, WordWrap::Disabled); m_testNameQuad.layerFlags |= XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT; m_testNameQuad.size.width = 0.75f; @@ -331,6 +338,7 @@ namespace Conformance FAIL("Unexpected transition to session state " << sessionState->state); return false; // Stop running. } + m_sessionState = sessionState->state; } } diff --git a/src/conformance/framework/composition_utils.h b/src/conformance/framework/composition_utils.h index 78123d75..43582a2d 100644 --- a/src/conformance/framework/composition_utils.h +++ b/src/conformance/framework/composition_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -47,9 +48,9 @@ namespace Conformance class EventReader; class ISwapchainImageData; - RGBAImage CreateTextImage(int32_t width, int32_t height, const char* text, int32_t fontHeight); + RGBAImage CreateTextImage(int32_t width, int32_t height, const char* text, int32_t fontHeight, WordWrap wordWrap = WordWrap::Enabled); - XrPath StringToPath(XrInstance instance, const char* pathStr); + XrPath StringToPath(XrInstance instance, const std::string& pathStr); using UpdateLayers = std::function; using EndFrame = std::function; // Return false to stop the loop. @@ -84,6 +85,7 @@ namespace Conformance void AddActionSet(XrActionSet actionSet); void AttachActionSets(std::vector* assertInteractionProfilePath = nullptr); void SyncActions(XrPath subactionPath); + void SyncActions(const std::initializer_list& subactionPaths); private: XrInstance m_instance; @@ -94,9 +96,14 @@ namespace Conformance std::vector m_actionSets; }; - /// A helper for basic frame loop and rendering operations, wrapping an instance, session, and @ref InteractionManager + /// A helper for basic frame loop and rendering operations, wrapping an instance, session, and @ref InteractionManager. + /// + /// Displays the usual title box. struct CompositionHelper { + /// Constructor + /// + /// Note that "testName" is the title that will be shown on the device: it is limited in size and often cannot show the entire actual test name. CompositionHelper(const char* testName, const std::vector& additionalEnabledExtensions = std::vector()); ~CompositionHelper(); @@ -136,6 +143,7 @@ namespace Conformance EventQueue& GetEventQueue() const; + /// Call xrEndFrame submitting the given layers. void EndFrame(XrTime predictedDisplayTime, std::vector layers); /// Create a handle for a reference space of type @p type owned by this class. @@ -214,6 +222,12 @@ namespace Conformance /// Typically used with @ref MakeDefaultSubImage to finish populating the structure. XrCompositionLayerProjection* CreateProjectionLayer(XrSpace space); + /// Return the session state from the most recent session state changed event + XrSessionState GetSessionState() const + { + return m_sessionState; + } + private: std::mutex m_mutex; @@ -229,6 +243,7 @@ namespace Conformance int64_t m_defaultColorFormat; XrViewConfigurationType m_primaryViewType; uint32_t m_projectionViewCount{0}; + XrSessionState m_sessionState = XR_SESSION_STATE_UNKNOWN; std::list m_projections; std::list> m_projectionViews; @@ -471,6 +486,12 @@ namespace Conformance m_sceneLayers.push_back(reinterpret_cast(layer)); } + template + void AddBackgroundLayer(T* layer) + { + m_backgroundLayers.push_back(reinterpret_cast(layer)); + } + bool EndFrame(const XrFrameState& frameState, std::vector layers = {}) { bool keepRunning = AppendLayers(layers, frameState.predictedDisplayTime); @@ -489,6 +510,10 @@ namespace Conformance // Add layer(s) based on the interaction mode. switch (layerMode) { case LayerMode::Scene: + for (auto& backgroundLayer : m_backgroundLayers) { + layers.push_back(backgroundLayer); + } + m_actionsQuad->subImage = m_compositionHelper.MakeDefaultSubImage(m_sceneActionsSwapchain); layers.push_back(reinterpret_cast(m_actionsQuad)); @@ -579,5 +604,6 @@ namespace Conformance XrCompositionLayerQuad* m_exampleQuad{}; XrSpace m_exampleQuadSpace; std::vector m_sceneLayers; + std::vector m_backgroundLayers; }; } // namespace Conformance diff --git a/src/conformance/framework/conformance_framework.cpp b/src/conformance/framework/conformance_framework.cpp index 9a2fa3c7..d081dc73 100644 --- a/src/conformance/framework/conformance_framework.cpp +++ b/src/conformance/framework/conformance_framework.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -23,12 +23,14 @@ #include "two_call_util.h" #include "utilities/throw_helpers.h" #include "utilities/utils.h" +#include "utilities/uuid_utils.h" #include #include #include #include +#include #include #include #include @@ -508,3 +510,32 @@ namespace Conformance } } } // namespace Conformance + +std::string Catch::StringMaker::convert(XrUuidEXT const& value) +{ + return to_string(value); +} + +std::string Catch::StringMaker::convert(XrVector3f const& value) +{ + std::ostringstream oss; + oss << "(" << value.x; + oss << ", " << value.y; + oss << ", " << value.z; + oss << ")"; + return oss.str(); +} + +std::string Catch::StringMaker::convert(XrPosef const& value) +{ + std::ostringstream oss; + oss << "[pos = (" << value.position.x; + oss << ", " << value.position.y; + oss << ", " << value.position.z; + oss << ") ori = (w=" << value.orientation.w; + oss << ", xyz=(" << value.orientation.x; + oss << ", " << value.orientation.y; + oss << ", " << value.orientation.z; + oss << ")]"; + return oss.str(); +} diff --git a/src/conformance/framework/conformance_framework.h b/src/conformance/framework/conformance_framework.h index 53f0a0aa..02487db7 100644 --- a/src/conformance/framework/conformance_framework.h +++ b/src/conformance/framework/conformance_framework.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -607,31 +606,17 @@ namespace Catch template <> struct StringMaker { - static std::string convert(XrPosef const& value) - { - std::ostringstream oss; - oss << "[pos = (" << value.position.x; - oss << ", " << value.position.y; - oss << ", " << value.position.z; - oss << ") ori = (w=" << value.orientation.w; - oss << ", xyz=(" << value.orientation.x; - oss << ", " << value.orientation.y; - oss << ", " << value.orientation.z; - oss << ")]"; - return oss.str(); - } + static std::string convert(XrPosef const& value); }; template <> struct StringMaker { - static std::string convert(XrVector3f const& value) - { - std::ostringstream oss; - oss << "(" << value.x; - oss << ", " << value.y; - oss << ", " << value.z; - oss << ")"; - return oss.str(); - } + static std::string convert(XrVector3f const& value); + }; + + template <> + struct StringMaker + { + static std::string convert(XrUuidEXT const& value); }; } // namespace Catch diff --git a/src/conformance/framework/conformance_utils.cpp b/src/conformance/framework/conformance_utils.cpp index d796083b..3986c82f 100644 --- a/src/conformance/framework/conformance_utils.cpp +++ b/src/conformance/framework/conformance_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -21,6 +21,7 @@ #include "two_call_util.h" #include "utilities/throw_helpers.h" #include "utilities/utils.h" +#include "utilities/xrduration_literals.h" #include #include @@ -132,6 +133,13 @@ namespace Conformance } } + void InstanceDelete::operator()(XrInstance i) const + { + if (i != XR_NULL_HANDLE) { + xrDestroyInstance(i); + } + } + void SessionDeleteCHECK::operator()(XrSession s) const { if (s != XR_NULL_HANDLE) { @@ -148,6 +156,13 @@ namespace Conformance } } + void SessionDelete::operator()(XrSession s) const + { + if (s != XR_NULL_HANDLE) { + xrDestroySession(s); + } + } + void SpaceDeleteCHECK::operator()(XrSpace s) const { if (s != XR_NULL_HANDLE) { @@ -182,11 +197,11 @@ namespace Conformance void SwapchainDelete::operator()(XrSwapchain s) const { - if (s != XR_NULL_HANDLE) { xrDestroySwapchain(s); } } + } // namespace deleters static XrBaseInStructure unrecognizedExtension{XRC_UNRECOGNIZABLE_STRUCTURE_TYPE, nullptr}; @@ -455,11 +470,14 @@ namespace Conformance } if (instance_ == XR_NULL_HANDLE) { XRC_CHECK_THROW_XRCMD(CreateBasicInstance(&instance)); - instanceOwned = true; + instanceOwned.adopt(instance); } assert(instance != XR_NULL_HANDLE); + m_eventQueue = std::make_unique(instance); + m_privateEventReader = std::make_unique(*m_eventQueue); + if ((optionFlags & createSession) == 0) { // cannot proceed further without a session return; @@ -472,61 +490,7 @@ namespace Conformance assert(session != XR_NULL_HANDLE); if (optionFlags & beginSession) { - // The session starts in (or gets directly transitioned to) the - // XR_SESSION_STATE_IDLE state and will get transitioned to - // XR_SESSION_STATE_READY by the runtime. But before that has not happened, - // xrBeginSession() below can return XR_ERROR_SESSION_NOT_READY. - // So just calling xrBeginSession might fail without it being a conformance - // failure. The correct way is to wait until the runtime tells us via an event - // that the session is ready. - - // timeout in case the runtime will never transition to READY: 10s in release, no practical limit in debug - auto timeoutToTransitionToSessionState = (GetGlobalData().options.debugMode ? 3600s : 10s); - CountdownTimer countdownTimer(timeoutToTransitionToSessionState); - - while ((sessionState != XR_SESSION_STATE_READY) && (!countdownTimer.IsTimeUp())) { - XrEventDataBuffer eventData{XR_TYPE_EVENT_DATA_BUFFER}; - XrResult result = xrPollEvent(instance, &eventData); - XRC_CHECK_THROW_XRCMD(result); - - if (XR_UNQUALIFIED_SUCCESS(result)) { - switch (eventData.type) { - case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: - XrEventDataSessionStateChanged sessionStateChanged; - memcpy(&sessionStateChanged, &eventData, sizeof(sessionStateChanged)); - sessionState = sessionStateChanged.state; - break; - default: - break; // Ignored event type. - } - } - } - - if (sessionState != XR_SESSION_STATE_READY) { - // We have failed this check with the timeout. This is a pretty common place to fail - // so we will offer helpful hints for the most common errors - as well as a generic - // message. - - // https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#sessionstatechanged-description - // If the system supports a user engagement sensor and runtime is in XR_SESSION_STATE_IDLE state, - // the runtime should not transition to the XR_SESSION_STATE_READY state until the user starts - // engaging with the device. - - std::string extraInfo; - if (sessionState == XR_SESSION_STATE_IDLE) { - extraInfo = - " If this system supports a user engagement sensor, the runtime may not transition to XR_SESSION_STATE_READY state until the user starts engaging with the device."; - } - - CAPTURE(timeoutToTransitionToSessionState); - CAPTURE(sessionState); - FAIL("Time out waiting for XR_SESSION_STATE_READY session state change after creating a new session." << extraInfo); - } - - XrSessionBeginInfo sessionBeginInfo{XR_TYPE_SESSION_BEGIN_INFO, - globalData.GetPlatformPlugin()->PopulateNextFieldForStruct(XR_TYPE_SESSION_BEGIN_INFO), - globalData.options.viewConfigurationValue}; - XRC_CHECK_THROW_XRCMD(xrBeginSession(session, &sessionBeginInfo)); + BeginSession(); } // Set up the enumerated types @@ -581,6 +545,59 @@ namespace Conformance } } + void AutoBasicSession::BeginSession() + { + GlobalData& globalData = GetGlobalData(); + // The session starts in (or gets directly transitioned to) the + // XR_SESSION_STATE_IDLE state and will get transitioned to + // XR_SESSION_STATE_READY by the runtime. But before that has not happened, + // xrBeginSession() below can return XR_ERROR_SESSION_NOT_READY. + // So just calling xrBeginSession might fail without it being a conformance + // failure. The correct way is to wait until the runtime tells us via an event + // that the session is ready. + + // timeout in case the runtime will never transition to READY: 10s in release, no practical limit in debug + auto timeoutToTransitionToSessionState = (GetGlobalData().options.debugMode ? 3600s : 10s); + CountdownTimer countdownTimer(timeoutToTransitionToSessionState); + + while ((sessionState != XR_SESSION_STATE_READY) && (!countdownTimer.IsTimeUp())) { + XrEventDataBuffer eventBuffer; + while (m_privateEventReader->TryReadNext(eventBuffer)) { + if (eventBuffer.type == XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED) { + XrEventDataSessionStateChanged sessionStateChanged; + memcpy(&sessionStateChanged, &eventBuffer, sizeof(sessionStateChanged)); + sessionState = sessionStateChanged.state; + } + } + } + + if (sessionState != XR_SESSION_STATE_READY) { + // We have failed this check with the timeout. This is a pretty common place to fail + // so we will offer helpful hints for the most common errors - as well as a generic + // message. + + // https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#sessionstatechanged-description + // If the system supports a user engagement sensor and runtime is in XR_SESSION_STATE_IDLE state, + // the runtime should not transition to the XR_SESSION_STATE_READY state until the user starts + // engaging with the device. + + std::string extraInfo; + if (sessionState == XR_SESSION_STATE_IDLE) { + extraInfo = + " If this system supports a user engagement sensor, the runtime may not transition to XR_SESSION_STATE_READY state until the user starts engaging with the device."; + } + + CAPTURE(timeoutToTransitionToSessionState); + CAPTURE(sessionState); + FAIL("Time out waiting for XR_SESSION_STATE_READY session state change after creating a new session." << extraInfo); + } + + XrSessionBeginInfo sessionBeginInfo{XR_TYPE_SESSION_BEGIN_INFO, + globalData.GetPlatformPlugin()->PopulateNextFieldForStruct(XR_TYPE_SESSION_BEGIN_INFO), + globalData.options.viewConfigurationValue}; + XRC_CHECK_THROW_XRCMD(xrBeginSession(session, &sessionBeginInfo)); + } + AutoBasicSession::~AutoBasicSession() { Shutdown(); @@ -620,11 +637,10 @@ namespace Conformance } } - if (instanceOwned) { - if (instance != XR_NULL_HANDLE) // Should be true. - xrDestroyInstance(instance); - instanceOwned = false; - } + m_privateEventReader.reset(); + m_eventQueue.reset(); + + instanceOwned.reset(); instance = XR_NULL_HANDLE; } diff --git a/src/conformance/framework/conformance_utils.h b/src/conformance/framework/conformance_utils.h index bcb1386a..b2cf7c74 100644 --- a/src/conformance/framework/conformance_utils.h +++ b/src/conformance/framework/conformance_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 @@ -17,8 +17,8 @@ #pragma once +#include "utilities/event_reader.h" #include "utilities/types_and_constants.h" -#include "utilities/xrduration_literals.h" #include @@ -27,8 +27,8 @@ #include #include #include +#include #include -#include #include #include @@ -187,11 +187,6 @@ namespace Conformance namespace deleters { - struct SwapchainDelete - { - typedef XrSwapchain pointer; - void operator()(XrSwapchain s) const; - }; struct InstanceDeleteCHECK { typedef XrInstance pointer; @@ -202,6 +197,11 @@ namespace Conformance typedef XrInstance pointer; void operator()(XrInstance i) const; }; + struct InstanceDelete + { + typedef XrInstance pointer; + void operator()(XrInstance i) const; + }; struct SessionDeleteCHECK { typedef XrSession pointer; @@ -212,6 +212,11 @@ namespace Conformance typedef XrSession pointer; void operator()(XrSession s) const; }; + struct SessionDelete + { + typedef XrSession pointer; + void operator()(XrSession s) const; + }; struct SpaceDeleteCHECK { typedef XrSpace pointer; @@ -232,6 +237,11 @@ namespace Conformance typedef XrSwapchain pointer; void operator()(XrSwapchain s) const; }; + struct SwapchainDelete + { + typedef XrSwapchain pointer; + void operator()(XrSwapchain s) const; + }; } // namespace deleters /// Defines a type similar to std::unique_ptr for XrInstance which uses CHECK() on destruction to verify that the @@ -251,6 +261,10 @@ namespace Conformance /// using InstanceREQUIRE = ScopedHandle; + /// This is similar to InstanceCHECK except that it ignores the result of xrDestroyInstance. + /// + using InstanceScoped = ScopedHandle; + /// Defines a type similar to std::unique_ptr for XrSession which uses CHECK() on destruction to verify that the /// destroy function succeeded. /// (Unlike std::unique_ptr, this copes with 32-bit builds where the handles are not pointers but uint64_t typedefs.) @@ -269,6 +283,10 @@ namespace Conformance /// using SessionREQUIRE = ScopedHandle; + /// This is similar to SessionCHECK except that it ignores the result of xrDestroySession. + /// + using SessionScoped = ScopedHandle; + /// Defines a type similar to std::unique_ptr for XrSpace which uses CHECK() on destruction to verify that the /// destroy function succeeded. /// (Unlike std::unique_ptr, this copes with 32-bit builds where the handles are not pointers but uint64_t typedefs.) @@ -568,6 +586,9 @@ namespace Conformance /// If instance is valid then we inherit it instead of create one ourselves. void Init(int optionFlags, XrInstance instance = XR_NULL_HANDLE); + /// Begin the session. + void BeginSession(); + /// Restores the class instance to a pre-initialized state. void Shutdown(); @@ -601,6 +622,11 @@ namespace Conformance return environmentBlendModeVector; } + EventQueue& GetEventQueue() const + { + return *m_eventQueue; + } + bool operator==(NullHandleType const& /*unused*/) const; bool operator!=(NullHandleType const& /*unused*/) const; @@ -613,13 +639,15 @@ namespace Conformance int optionFlags{0}; //< Enum OptionFlags XrInstance instance{XR_NULL_HANDLE}; - bool instanceOwned{false}; //< True if we created it and not the caller of us. + InstanceScoped instanceOwned; XrSystemId systemId{XR_NULL_SYSTEM_ID}; XrSession session{XR_NULL_HANDLE}; XrResult sessionCreateResult{XR_SUCCESS}; XrSessionState sessionState{XR_SESSION_STATE_UNKNOWN}; + std::unique_ptr m_eventQueue; + std::unique_ptr m_privateEventReader; std::array handSubactionArray; // "/user/hand/left", "/user/hand/right" diff --git a/src/conformance/framework/controller_animation_handler.cpp b/src/conformance/framework/controller_animation_handler.cpp index 32fc6814..3c966632 100644 --- a/src/conformance/framework/controller_animation_handler.cpp +++ b/src/conformance/framework/controller_animation_handler.cpp @@ -1,5 +1,5 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -13,6 +13,7 @@ #include "common/xr_linear.h" #include "pbr/PbrCommon.h" #include "pbr/PbrModel.h" +#include "utilities/throw_helpers.h" #include @@ -25,28 +26,41 @@ using namespace std::literals::chrono_literals; namespace Conformance { - ControllerAnimationHandler::ControllerAnimationHandler(std::shared_ptr model, - std::vector properties) - : m_pbrModel(model), m_nodeProperties(properties) + ControllerAnimationHandler::ControllerAnimationHandler(const Pbr::Model& model, + std::vector&& properties) + { + Init(model, std::move(properties)); + } + void ControllerAnimationHandler::Init(const Pbr::Model& model, std::vector&& properties) { + m_nodeProperties = std::move(properties); // Compute the index of each node reported by runtime to be animated. // The order of m_nodeIndices exactly matches the order of the nodes properties and states. m_nodeIndices.resize(m_nodeProperties.size(), Pbr::NodeIndex_npos); for (size_t i = 0; i < m_nodeProperties.size(); ++i) { const auto& nodeProperty = m_nodeProperties[i]; - Pbr::NodeIndex_t parentNodeIndex; - if (m_pbrModel->FindFirstNode(&parentNodeIndex, nodeProperty.parentNodeName)) { - Pbr::NodeIndex_t targetNodeIndex; - if (m_pbrModel->FindFirstNode(&targetNodeIndex, nodeProperty.nodeName, &parentNodeIndex)) { - m_nodeIndices[i] = targetNodeIndex; - } - } + m_nodeIndices[i] = FindPbrNodeIndex(model, nodeProperty.parentNodeName, nodeProperty.nodeName); + } + } + + Pbr::NodeIndex_t ControllerAnimationHandler::FindPbrNodeIndex(const Pbr::Model& model, const char* parentNodeName, const char* nodeName) + { + + Pbr::NodeIndex_t parentNodeIndex; + if (!model.FindFirstNode(&parentNodeIndex, parentNodeName)) { + XRC_THROW("Could not find parent node by name"); + } + Pbr::NodeIndex_t targetNodeIndex; + if (!model.FindFirstNode(&targetNodeIndex, nodeName, &parentNodeIndex)) { + XRC_THROW("Could not find target node by name"); } + return targetNodeIndex; } // Update transforms of nodes for the animatable parts in the controller model - void ControllerAnimationHandler::UpdateControllerParts(std::vector nodeStates) + void ControllerAnimationHandler::UpdateControllerParts(const std::vector& nodeStates, + Pbr::ModelInstance& pbrModelInstance) { m_nodeStates = nodeStates; @@ -55,12 +69,11 @@ namespace Conformance for (size_t i = 0; i < end; i++) { const Pbr::NodeIndex_t nodeIndex = m_nodeIndices[i]; if (nodeIndex != Pbr::NodeIndex_npos) { - Pbr::Node& node = m_pbrModel->GetNode(nodeIndex); XrMatrix4x4f nodeTransform; XrVector3f unitScale = {1, 1, 1}; XrMatrix4x4f_CreateTranslationRotationScale(&nodeTransform, &m_nodeStates[i].nodePose.position, &m_nodeStates[i].nodePose.orientation, &unitScale); - node.SetTransform(nodeTransform); + pbrModelInstance.SetNodeTransform(nodeIndex, nodeTransform); } } } diff --git a/src/conformance/framework/controller_animation_handler.h b/src/conformance/framework/controller_animation_handler.h index dd2037ed..a1c4a4dc 100644 --- a/src/conformance/framework/controller_animation_handler.h +++ b/src/conformance/framework/controller_animation_handler.h @@ -1,5 +1,5 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -29,11 +29,13 @@ namespace Conformance { public: ControllerAnimationHandler() = default; - ControllerAnimationHandler(std::shared_ptr model, std::vector properties); - void UpdateControllerParts(std::vector nodeStates); + ControllerAnimationHandler(const Pbr::Model& model, std::vector&& properties); + + void Init(const Pbr::Model& model, std::vector&& properties); + void UpdateControllerParts(const std::vector& nodeStates, Pbr::ModelInstance& pbrModelInstance); private: - std::shared_ptr m_pbrModel; + static Pbr::NodeIndex_t FindPbrNodeIndex(const Pbr::Model& model, const char* parentNodeName, const char* nodeName); std::vector m_nodeIndices; std::vector m_nodeProperties; std::vector m_nodeStates; diff --git a/src/conformance/framework/gltf.cpp b/src/conformance/framework/cts_tinygltf.cpp similarity index 71% rename from src/conformance/framework/gltf.cpp rename to src/conformance/framework/cts_tinygltf.cpp index f34e5069..8663fc2b 100644 --- a/src/conformance/framework/gltf.cpp +++ b/src/conformance/framework/cts_tinygltf.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 @@ -9,4 +9,4 @@ #pragma warning(disable : 4189) #endif // defined(_MSC_VER) -#include "gltf.h" +#include "cts_tinygltf.h" diff --git a/src/conformance/framework/gltf.h b/src/conformance/framework/cts_tinygltf.h similarity index 68% rename from src/conformance/framework/gltf.h rename to src/conformance/framework/cts_tinygltf.h index ffbff1a4..2595ebad 100644 --- a/src/conformance/framework/gltf.h +++ b/src/conformance/framework/cts_tinygltf.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/environment.cpp b/src/conformance/framework/environment.cpp index 2f70cbd4..8504d532 100644 --- a/src/conformance/framework/environment.cpp +++ b/src/conformance/framework/environment.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/conformance/framework/environment.h b/src/conformance/framework/environment.h index 85a2a5cc..960deb01 100644 --- a/src/conformance/framework/environment.h +++ b/src/conformance/framework/environment.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/conformance/framework/gltf/CMakeLists.txt b/src/conformance/framework/gltf/CMakeLists.txt index ab81f486..9e9cc1e1 100644 --- a/src/conformance/framework/gltf/CMakeLists.txt +++ b/src/conformance/framework/gltf/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/gltf/GltfHelper.cpp b/src/conformance/framework/gltf/GltfHelper.cpp index c0da9296..8e74d434 100644 --- a/src/conformance/framework/gltf/GltfHelper.cpp +++ b/src/conformance/framework/gltf/GltfHelper.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/gltf/GltfHelper.h b/src/conformance/framework/gltf/GltfHelper.h index 99017179..0cf84b6c 100644 --- a/src/conformance/framework/gltf/GltfHelper.h +++ b/src/conformance/framework/gltf/GltfHelper.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/gltf_helpers.cpp b/src/conformance/framework/gltf_helpers.cpp new file mode 100644 index 00000000..d98fc2c2 --- /dev/null +++ b/src/conformance/framework/gltf_helpers.cpp @@ -0,0 +1,39 @@ +// Copyright (c) 2019-2024, The Khronos Group Inc. +// +// SPDX-License-Identifier: Apache-2.0 + +#include "gltf_helpers.h" + +#include "utilities/throw_helpers.h" +#include "cts_tinygltf.h" + +namespace Conformance +{ + + std::shared_ptr LoadGLTF(span data) + { + tinygltf::TinyGLTF loader; + + return LoadGLTF(data, loader); + } + + std::shared_ptr LoadGLTF(span data, tinygltf::TinyGLTF& loader) + { + std::shared_ptr model = std::make_shared(); + std::string err; + std::string warn; + bool loadedModel = loader.LoadBinaryFromMemory(model.get(), &err, &warn, data.data(), (unsigned int)data.size()); + if (!warn.empty()) { + // ReportF("glTF WARN: %s", &warn); + } + + if (!err.empty()) { + XRC_THROW("glTF ERR: " + err); + } + + if (!loadedModel) { + XRC_THROW("Failed to load glTF model provided."); + } + return model; + } +} // namespace Conformance diff --git a/src/conformance/framework/gltf_helpers.h b/src/conformance/framework/gltf_helpers.h new file mode 100644 index 00000000..c5fc2f4a --- /dev/null +++ b/src/conformance/framework/gltf_helpers.h @@ -0,0 +1,33 @@ +// Copyright (c) 2019-2024, The Khronos Group Inc. +// +// SPDX-License-Identifier: Apache-2.0 + +/// @file +/// Forward declare TinyGLTF types, and provide some helpers for loading a glTF file and asserting +/// that the load was successful. + +#pragma once + +#include + +#include + +namespace tinygltf +{ + class Model; + class TinyGLTF; +} // namespace tinygltf + +namespace Conformance +{ + // Import a backported implementation of std::span, or std::span itself if available. + + using nonstd::span; + + /// Load a glTF file from memory into a shared pointer, throwing on errors. + std::shared_ptr LoadGLTF(span data); + + /// Load a glTF file from memory into a shared pointer, throwing on errors, using the provided loader. + std::shared_ptr LoadGLTF(span data, tinygltf::TinyGLTF& loader); + +} // namespace Conformance diff --git a/src/conformance/framework/gltf_model.h b/src/conformance/framework/gltf_model.h index 6d9f9ad3..f24a40c9 100644 --- a/src/conformance/framework/gltf_model.h +++ b/src/conformance/framework/gltf_model.h @@ -1,9 +1,9 @@ -// Copyright (c) 2022-2023, The Khronos Group Inc. +// Copyright (c) 2022-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT #pragma once -#include "gltf.h" +#include "cts_tinygltf.h" #include "gltf/GltfHelper.h" #include "pbr/GltfLoader.h" @@ -15,26 +15,23 @@ namespace Conformance { /// Templated base class for API-specific model objects in the main CTS code. - template - class GltfModelBase + template + class RenderableGltfModelInstanceBase { public: - GltfModelBase(ResourcesType& pbrResources, std::shared_ptr gltf, std::shared_ptr pbrModel = nullptr, - Pbr::FillMode fillMode = Pbr::FillMode::Solid) - : m_gltf(gltf) - , m_pbrModel(pbrModel != nullptr ? std::move(pbrModel) : Gltf::FromGltfObject(pbrResources, *gltf)) - , m_fillMode(fillMode) + RenderableGltfModelInstanceBase(ModelInstanceType&& pbrModelInstance, Pbr::FillMode fillMode = Pbr::FillMode::Solid) + : m_pbrModelInstance(std::move(pbrModelInstance)), m_fillMode(fillMode) { } - void SetModel(std::shared_ptr&& model) + ModelInstanceType& GetModelInstance() noexcept { - m_pbrModel = std::move(model); + return m_pbrModelInstance; } - const std::shared_ptr& GetModel() const noexcept + const ModelInstanceType& GetModelInstance() const noexcept { - return m_pbrModel; + return m_pbrModelInstance; } void SetFillMode(const Pbr::FillMode& fillMode) @@ -49,15 +46,15 @@ namespace Conformance void SetBaseColorFactor(ResourcesType& pbrResources, Pbr::RGBAColor color) { - for (uint32_t k = 0; k < GetModel()->GetPrimitiveCount(); k++) { - auto& material = pbrResources.GetPrimitive(GetModel()->GetPrimitive(k)).GetMaterial(); + for (uint32_t k = 0; k < m_pbrModelInstance.GetPrimitiveCount(); k++) { + auto& material = pbrResources.GetPrimitive(m_pbrModelInstance.GetPrimitiveHandle(k)).GetMaterial(); material->Parameters().BaseColorFactor = color; } } private: std::shared_ptr m_gltf; - std::shared_ptr m_pbrModel; + ModelInstanceType m_pbrModelInstance; Pbr::FillMode m_fillMode; }; } // namespace Conformance diff --git a/src/conformance/framework/graphics_plugin.h b/src/conformance/framework/graphics_plugin.h index 669cba14..dd4c55e8 100644 --- a/src/conformance/framework/graphics_plugin.h +++ b/src/conformance/framework/graphics_plugin.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,12 +16,11 @@ #pragma once +#include "gltf_helpers.h" #include "platform_plugin.h" #include "conformance_utils.h" #include "conformance_framework.h" #include "utilities/Geometry.h" -#include "utilities/throw_helpers.h" -#include "gltf.h" #include "RGBAImage.h" #include "pbr/PbrModel.h" @@ -30,10 +29,8 @@ #include #include #include -#include #include #include -#include // We #include all the possible graphics system headers here because openxr_platform.h assumes that // they are all visible when it is compiled. @@ -77,6 +74,12 @@ #include #endif +namespace tinygltf +{ + class Model; + class TinyGLTF; +} // namespace tinygltf + namespace Conformance { // Import a backported implementation of std::span, or std::span itself if available. @@ -140,14 +143,25 @@ namespace Conformance } }; - /// Handle returned by a graphics plugin, used to reference plugin-internal data for a loaded GLTF model. + /// Handle returned by a graphics plugin, used to reference plugin-internal data for a loaded glTF (PBR) model. + /// + /// They expire at IGraphicsPlugin::Shutdown() and IGraphicsPlugin::ShutdownDevice() calls, + /// so must not be persisted past those calls. + /// + /// They are "null" by default, so may be tested for validity by comparison against a default-constructed instance. + using GLTFModelHandle = nonstd::equality; + + /// Handle returned by a graphics plugin, used to reference plugin-internal data for a renderable instance of a glTF (PBR) model. /// /// They expire at IGraphicsPlugin::Shutdown() and IGraphicsPlugin::ShutdownDevice() calls, /// so must not be persisted past those calls. /// /// They are "null" by default, so may be tested for validity by comparison against a default-constructed instance. - using GLTFHandle = nonstd::equality; + using GLTFModelInstanceHandle = nonstd::equality; + /// A handle referring to a node in a loaded PBR (glTF) model. + /// Only useful in the context of the GLTFModelHandle it came from: + /// it is internally just an index. using NodeHandle = nonstd::ordered; struct NodeParams @@ -156,38 +170,16 @@ namespace Conformance bool visible; }; - static inline std::shared_ptr LoadGLTF(span data) - { - tinygltf::Model model; - tinygltf::TinyGLTF loader; - std::string err; - std::string warn; - bool loadedModel = loader.LoadBinaryFromMemory(&model, &err, &warn, data.data(), (unsigned int)data.size()); - if (!warn.empty()) { - // ReportF("glTF WARN: %s", &warn); - } - - if (!err.empty()) { - XRC_THROW("glTF ERR: " + err); - } - - if (!loadedModel) { - XRC_THROW("Failed to load glTF model provided."); - } - - return std::make_shared(std::move(model)); - } - - /// A drawable GLTF model, consisting of a reference to plugin-specific data for a GLTF model, plus pose and scale. + /// A drawable GLTF model, consisting of a reference to plugin-specific data for a glTF (PBR) model instance, pose, scale, and node/parameter pairs. struct GLTFDrawable { - GLTFHandle handle; + GLTFModelInstanceHandle handle; DrawableParams params; // or unordered_map, probably not significant std::map nodesAndParams; - GLTFDrawable(GLTFHandle handle, XrPosef pose = XrPosefCPP{}, XrVector3f scale = {1.0, 1.0, 1.0}) + GLTFDrawable(GLTFModelInstanceHandle handle, XrPosef pose = XrPosefCPP{}, XrVector3f scale = {1.0, 1.0, 1.0}) : handle(handle), params(pose, scale) { } @@ -360,9 +352,23 @@ namespace Conformance /// Create internal data for a glTF model, returning a handle to refer to it. /// This handle expires when the internal data is cleared in Shutdown() and ShutdownDevice(). - virtual GLTFHandle LoadGLTF(span data) = 0; + GLTFModelHandle LoadGLTF(span data) + { + return LoadGLTF(Conformance::LoadGLTF(data)); + } + + /// Create internal data for a glTF model, returning a handle to refer to it. + /// This handle expires when the internal data is cleared in Shutdown() and ShutdownDevice(). + /// It retains a reference to the tinygltf model passed here. + virtual GLTFModelHandle LoadGLTF(std::shared_ptr tinygltfModel) = 0; - virtual std::shared_ptr GetModel(GLTFHandle handle) const = 0; + /// Get the underlying Pbr::Model associated with the supplied handle. + virtual std::shared_ptr GetPbrModel(GLTFModelHandle handle) const = 0; + + virtual GLTFModelInstanceHandle CreateGLTFModelInstance(GLTFModelHandle handle) = 0; + + /// Get a reference to the base interface for a given ModelInstance from its handle + virtual Pbr::ModelInstance& GetModelInstance(GLTFModelInstanceHandle handle) = 0; /// Convenience helper function to make a mesh that is our standard cube (with R, G, B faces along X, Y, Z, respectively) MeshHandle MakeCubeMesh() @@ -374,7 +380,7 @@ namespace Conformance MeshHandle MakeGnomonMesh() { return MakeSimpleMesh(Geometry::AxisIndicator::GetInstance().indices, Geometry::AxisIndicator::GetInstance().vertices); - }; + } virtual void RenderView(const XrCompositionLayerProjectionView& layerView, const XrSwapchainImageBaseHeader* colorSwapchainImage, const RenderParams& params) = 0; diff --git a/src/conformance/framework/graphics_plugin_d3d11.cpp b/src/conformance/framework/graphics_plugin_d3d11.cpp index deca352a..93faf286 100644 --- a/src/conformance/framework/graphics_plugin_d3d11.cpp +++ b/src/conformance/framework/graphics_plugin_d3d11.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -207,9 +207,10 @@ namespace Conformance MeshHandle MakeSimpleMesh(span idx, span vtx) override; - GLTFHandle LoadGLTF(span data) override; - - std::shared_ptr GetModel(GLTFHandle handle) const override; + GLTFModelHandle LoadGLTF(std::shared_ptr tinygltfModel) override; + std::shared_ptr GetPbrModel(GLTFModelHandle handle) const override; + GLTFModelInstanceHandle CreateGLTFModelInstance(GLTFModelHandle handle) override; + Pbr::ModelInstance& GetModelInstance(GLTFModelInstanceHandle handle) override; void RenderView(const XrCompositionLayerProjectionView& layerView, const XrSwapchainImageBaseHeader* colorSwapchainImage, const RenderParams& params) override; @@ -234,9 +235,11 @@ namespace Conformance MeshHandle m_cubeMesh; VectorWithGenerationCountedHandles m_meshes; - VectorWithGenerationCountedHandles m_gltfs; + // This is fine to be a shared_ptr because Model doesn't directly hold any graphics state. + VectorWithGenerationCountedHandles, GLTFModelHandle> m_gltfModels; + VectorWithGenerationCountedHandles m_gltfInstances; - std::unique_ptr pbrResources; + std::unique_ptr m_pbrResources; SwapchainImageDataMap m_swapchainImageDataMap; }; @@ -384,14 +387,14 @@ namespace Conformance m_cubeMesh = MakeCubeMesh(); - pbrResources = std::make_unique(d3d11Device.Get()); - pbrResources->SetLight({0.0f, 0.7071067811865475f, 0.7071067811865475f}, Pbr::RGB::White); + m_pbrResources = std::make_unique(d3d11Device.Get()); + m_pbrResources->SetLight({0.0f, 0.7071067811865475f, 0.7071067811865475f}, Pbr::RGB::White); // Read the BRDF Lookup Table used by the PBR system into a DirectX texture. std::vector brdfLutFileData = ReadFileBytes("brdf_lut.png"); Microsoft::WRL::ComPtr brdfLutResourceView = Pbr::D3D11Texture::LoadTextureImage(d3d11Device.Get(), brdfLutFileData.data(), (uint32_t)brdfLutFileData.size()); - pbrResources->SetBrdfLut(brdfLutResourceView.Get()); + m_pbrResources->SetBrdfLut(brdfLutResourceView.Get()); } return true; @@ -428,8 +431,9 @@ namespace Conformance m_cubeMesh = {}; m_meshes.clear(); - m_gltfs.clear(); - pbrResources.reset(); + m_gltfInstances.clear(); + m_gltfModels.clear(); + m_pbrResources.reset(); d3d11DeviceContext.Reset(); d3d11Device.Reset(); @@ -674,7 +678,6 @@ namespace Conformance // Clear color buffer. // Create RenderTargetView with original swapchain format (swapchain is typeless). ComPtr renderTargetView = CreateRenderTargetView(*swapchainData, imageIndex, imageArrayIndex); - // TODO: Do not clear to a color when using a pass-through view configuration. FLOAT bg[] = {color.r, color.g, color.b, color.a}; d3d11DeviceContext->ClearRenderTargetView(renderTargetView.Get(), bg); @@ -689,15 +692,28 @@ namespace Conformance return handle; } - inline GLTFHandle D3D11GraphicsPlugin::LoadGLTF(span data) + GLTFModelHandle D3D11GraphicsPlugin::LoadGLTF(std::shared_ptr tinygltfModel) { - auto handle = m_gltfs.emplace_back(*pbrResources, Conformance::LoadGLTF(data)); + std::shared_ptr pbrModel = Gltf::FromGltfObject(*m_pbrResources, *tinygltfModel); + auto handle = m_gltfModels.emplace_back(std::move(pbrModel)); return handle; } - inline std::shared_ptr D3D11GraphicsPlugin::GetModel(GLTFHandle handle) const + std::shared_ptr D3D11GraphicsPlugin::GetPbrModel(GLTFModelHandle handle) const + { + return m_gltfModels[handle]; + } + + GLTFModelInstanceHandle D3D11GraphicsPlugin::CreateGLTFModelInstance(GLTFModelHandle handle) + { + auto pbrModelInstance = Pbr::D3D11ModelInstance(*m_pbrResources, GetPbrModel(handle)); + auto instanceHandle = m_gltfInstances.emplace_back(std::move(pbrModelInstance)); + return instanceHandle; + } + + Pbr::ModelInstance& D3D11GraphicsPlugin::GetModelInstance(GLTFModelInstanceHandle handle) { - return m_gltfs[handle].GetModel(); + return m_gltfInstances[handle].GetModelInstance(); } void D3D11GraphicsPlugin::RenderView(const XrCompositionLayerProjectionView& layerView, @@ -776,21 +792,21 @@ namespace Conformance } // Render each gltf - for (const auto& gltfHandle : params.glTFs) { - D3D11GLTF& gltf = m_gltfs[gltfHandle.handle]; + for (const auto& gltfDrawable : params.glTFs) { + D3D11GLTF& gltf = m_gltfInstances[gltfDrawable.handle]; // Compute and update the model transform. XrMatrix4x4f modelToWorld; - XrMatrix4x4f_CreateTranslationRotationScale(&modelToWorld, &gltfHandle.params.pose.position, - &gltfHandle.params.pose.orientation, &gltfHandle.params.scale); + XrMatrix4x4f_CreateTranslationRotationScale(&modelToWorld, &gltfDrawable.params.pose.position, + &gltfDrawable.params.pose.orientation, &gltfDrawable.params.scale); XrMatrix4x4f viewMatrix; XrVector3f unitScale = {1, 1, 1}; XrMatrix4x4f_CreateTranslationRotationScale(&viewMatrix, &layerView.pose.position, &layerView.pose.orientation, &unitScale); XrMatrix4x4f viewMatrixInverse; XrMatrix4x4f_Invert(&viewMatrixInverse, &viewMatrix); - pbrResources->SetViewProjection(LoadXrMatrix(viewMatrixInverse), LoadXrMatrix(projectionMatrix)); + m_pbrResources->SetViewProjection(LoadXrMatrix(viewMatrixInverse), LoadXrMatrix(projectionMatrix)); - gltf.Render(d3d11DeviceContext, *pbrResources, modelToWorld); + gltf.Render(d3d11DeviceContext, *m_pbrResources, modelToWorld); } } diff --git a/src/conformance/framework/graphics_plugin_d3d11_gltf.cpp b/src/conformance/framework/graphics_plugin_d3d11_gltf.cpp index a3e9bacd..4c3158e1 100644 --- a/src/conformance/framework/graphics_plugin_d3d11_gltf.cpp +++ b/src/conformance/framework/graphics_plugin_d3d11_gltf.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2022-2023, The Khronos Group Inc. +// Copyright (c) 2022-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT #if defined(XR_USE_GRAPHICS_API_D3D11) && !defined(MISSING_DIRECTX_COLORS) @@ -21,16 +21,11 @@ using namespace DirectX; namespace Conformance { - void D3D11GLTF::Render(ComPtr deviceContext, Pbr::D3D11Resources& resources, XrMatrix4x4f& modelToWorld) const + void D3D11GLTF::Render(ComPtr deviceContext, Pbr::D3D11Resources& resources, XrMatrix4x4f& modelToWorld) { - if (!GetModel()) { - return; - } - resources.SetFillMode(GetFillMode()); - resources.SetModelToWorld(LoadXrMatrix(modelToWorld), deviceContext.Get()); resources.Bind(deviceContext.Get()); - GetModel()->Render(resources, deviceContext.Get()); + GetModelInstance().Render(resources, deviceContext.Get(), LoadXrMatrix(modelToWorld)); } } // namespace Conformance diff --git a/src/conformance/framework/graphics_plugin_d3d11_gltf.h b/src/conformance/framework/graphics_plugin_d3d11_gltf.h index c8a29ac2..36da9cc7 100644 --- a/src/conformance/framework/graphics_plugin_d3d11_gltf.h +++ b/src/conformance/framework/graphics_plugin_d3d11_gltf.h @@ -1,11 +1,10 @@ -// Copyright (c) 2022-2023, The Khronos Group Inc. +// Copyright (c) 2022-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT #pragma once #if defined(XR_USE_GRAPHICS_API_D3D11) && !defined(MISSING_DIRECTX_COLORS) -#include "gltf.h" #include "gltf_model.h" #include "gltf/GltfHelper.h" @@ -27,13 +26,14 @@ using Microsoft::WRL::ComPtr; namespace Conformance { + struct CmdBuffer; - class D3D11GLTF : public GltfModelBase + class D3D11GLTF : public RenderableGltfModelInstanceBase { public: - using GltfModelBase::GltfModelBase; + using RenderableGltfModelInstanceBase::RenderableGltfModelInstanceBase; - void Render(ComPtr deviceContext, Pbr::D3D11Resources& resources, XrMatrix4x4f& modelToWorld) const; + void Render(ComPtr deviceContext, Pbr::D3D11Resources& resources, XrMatrix4x4f& modelToWorld); }; } // namespace Conformance #endif diff --git a/src/conformance/framework/graphics_plugin_d3d12.cpp b/src/conformance/framework/graphics_plugin_d3d12.cpp index 9a722be6..b4e6fd4b 100644 --- a/src/conformance/framework/graphics_plugin_d3d12.cpp +++ b/src/conformance/framework/graphics_plugin_d3d12.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -17,7 +17,7 @@ #if defined(XR_USE_GRAPHICS_API_D3D12) #include "conformance_framework.h" -#include "gltf.h" +#include "gltf_helpers.h" #include "graphics_plugin.h" #include "graphics_plugin_d3d12_gltf.h" #include "graphics_plugin_impl_helpers.h" @@ -357,9 +357,10 @@ namespace Conformance MeshHandle MakeSimpleMesh(span idx, span vtx) override; - GLTFHandle LoadGLTF(span data) override; - - std::shared_ptr GetModel(GLTFHandle handle) const override; + GLTFModelHandle LoadGLTF(std::shared_ptr tinygltfModel) override; + std::shared_ptr GetPbrModel(GLTFModelHandle handle) const override; + GLTFModelInstanceHandle CreateGLTFModelInstance(GLTFModelHandle handle) override; + Pbr::ModelInstance& GetModelInstance(GLTFModelInstanceHandle handle) override; void RenderView(const XrCompositionLayerProjectionView& layerView, const XrSwapchainImageBaseHeader* colorSwapchainImage, const RenderParams& params) override; @@ -395,8 +396,10 @@ namespace Conformance MeshHandle m_cubeMesh; VectorWithGenerationCountedHandles m_meshes; - VectorWithGenerationCountedHandles m_gltfs; - std::unique_ptr pbrResources; + // This is fine to be a shared_ptr because Model doesn't directly hold any graphics state. + VectorWithGenerationCountedHandles, GLTFModelHandle> m_gltfModels; + VectorWithGenerationCountedHandles m_gltfInstances; + std::unique_ptr m_pbrResources; }; D3D12GraphicsPlugin::D3D12GraphicsPlugin(std::shared_ptr) @@ -553,14 +556,14 @@ namespace Conformance D3D12_GRAPHICS_PIPELINE_STATE_DESC pipelineStateDesc{}; SetupBasePipelineStateDesc(pipelineStateDesc); - pbrResources = std::make_unique(d3d12Device.Get(), pipelineStateDesc); - pbrResources->SetLight({0.0f, 0.7071067811865475f, 0.7071067811865475f}, Pbr::RGB::White); + m_pbrResources = std::make_unique(d3d12Device.Get(), pipelineStateDesc); + m_pbrResources->SetLight({0.0f, 0.7071067811865475f, 0.7071067811865475f}, Pbr::RGB::White); // Read the BRDF Lookup Table used by the PBR system into a DirectX texture. std::vector brdfLutFileData = ReadFileBytes("brdf_lut.png"); D3D12ResourceWithSRVDesc brdLutResourceView = - Pbr::D3D12Texture::LoadTextureImage(*pbrResources, brdfLutFileData.data(), (uint32_t)brdfLutFileData.size()); - pbrResources->SetBrdfLut(brdLutResourceView); + Pbr::D3D12Texture::LoadTextureImage(*m_pbrResources, brdfLutFileData.data(), (uint32_t)brdfLutFileData.size()); + m_pbrResources->SetBrdfLut(brdLutResourceView); graphicsBinding.device = d3d12Device.Get(); graphicsBinding.queue = m_queueWrapper->GetCommandQueue().Get(); @@ -589,12 +592,13 @@ namespace Conformance pipelineStates.clear(); m_cubeMesh = {}; m_meshes.clear(); - m_gltfs.clear(); + m_gltfInstances.clear(); + m_gltfModels.clear(); rtvHeap.Reset(); dsvHeap.Reset(); m_swapchainImageDataMap.Reset(); - pbrResources.reset(); + m_pbrResources.reset(); d3d12Device.Reset(); lastSwapchainImage = nullptr; } @@ -937,7 +941,6 @@ namespace Conformance // Clear color buffer. D3D12_CPU_DESCRIPTOR_HANDLE renderTargetView = CreateRenderTargetView(colorTexture, imageArrayIndex, swapchainData->GetCreateInfo().format); - // TODO: Do not clear to a color when using a pass-through view configuration. FLOAT bg[] = {color.r, color.g, color.b, color.a}; cmdList->ClearRenderTargetView(renderTargetView, bg, 0, nullptr); @@ -962,15 +965,28 @@ namespace Conformance return handle; } - inline GLTFHandle D3D12GraphicsPlugin::LoadGLTF(span data) + GLTFModelHandle D3D12GraphicsPlugin::LoadGLTF(std::shared_ptr tinygltfModel) { - auto handle = m_gltfs.emplace_back(*pbrResources, Conformance::LoadGLTF(data)); + std::shared_ptr pbrModel = Gltf::FromGltfObject(*m_pbrResources, *tinygltfModel); + auto handle = m_gltfModels.emplace_back(std::move(pbrModel)); return handle; } - inline std::shared_ptr D3D12GraphicsPlugin::GetModel(GLTFHandle handle) const + std::shared_ptr D3D12GraphicsPlugin::GetPbrModel(GLTFModelHandle handle) const + { + return m_gltfModels[handle]; + } + + GLTFModelInstanceHandle D3D12GraphicsPlugin::CreateGLTFModelInstance(GLTFModelHandle handle) + { + auto pbrModelInstance = Pbr::D3D12ModelInstance(*m_pbrResources, GetPbrModel(handle)); + auto instanceHandle = m_gltfInstances.emplace_back(std::move(pbrModelInstance)); + return instanceHandle; + } + + Pbr::ModelInstance& D3D12GraphicsPlugin::GetModelInstance(GLTFModelInstanceHandle handle) { - return m_gltfs[handle].GetModel(); + return m_gltfInstances[handle].GetModelInstance(); } void D3D12GraphicsPlugin::RenderView(const XrCompositionLayerProjectionView& layerView, @@ -1106,26 +1122,26 @@ namespace Conformance } // Render each gltf - for (const auto& gltfHandle : params.glTFs) { - D3D12GLTF& gltf = m_gltfs[gltfHandle.handle]; + for (const auto& gltfDrawable : params.glTFs) { + D3D12GLTF& gltf = m_gltfInstances[gltfDrawable.handle]; // Compute and update the model transform. XrMatrix4x4f modelToWorld; - XrMatrix4x4f_CreateTranslationRotationScale(&modelToWorld, &gltfHandle.params.pose.position, - &gltfHandle.params.pose.orientation, &gltfHandle.params.scale); + XrMatrix4x4f_CreateTranslationRotationScale(&modelToWorld, &gltfDrawable.params.pose.position, + &gltfDrawable.params.pose.orientation, &gltfDrawable.params.scale); XrMatrix4x4f viewMatrix; XrVector3f unitScale = {1, 1, 1}; XrMatrix4x4f_CreateTranslationRotationScale(&viewMatrix, &layerView.pose.position, &layerView.pose.orientation, &unitScale); XrMatrix4x4f viewMatrixInverse; XrMatrix4x4f_Invert(&viewMatrixInverse, &viewMatrix); - pbrResources->SetViewProjection(LoadXrMatrix(viewMatrixInverse), LoadXrMatrix(projectionMatrix)); + m_pbrResources->SetViewProjection(LoadXrMatrix(viewMatrixInverse), LoadXrMatrix(projectionMatrix)); DXGI_FORMAT depthSwapchainFormatDX = GetDepthStencilFormatOrDefault(depthCreateInfo); - gltf.Render(cmdList, *pbrResources, modelToWorld, (DXGI_FORMAT)swapchainData->GetCreateInfo().format, depthSwapchainFormatDX); + gltf.Render(cmdList, *m_pbrResources, modelToWorld, (DXGI_FORMAT)swapchainData->GetCreateInfo().format, depthSwapchainFormatDX); // wait in the direct queue for resources' internal copy queue to complete - m_queueWrapper->GPUWaitOnOtherFence(pbrResources->GetFenceAndValue()); + m_queueWrapper->GPUWaitOnOtherFence(m_pbrResources->GetFenceAndValue()); } XRC_CHECK_THROW_HRCMD(cmdList->Close()); diff --git a/src/conformance/framework/graphics_plugin_d3d12_gltf.cpp b/src/conformance/framework/graphics_plugin_d3d12_gltf.cpp index 008af3c3..d8dc88ab 100644 --- a/src/conformance/framework/graphics_plugin_d3d12_gltf.cpp +++ b/src/conformance/framework/graphics_plugin_d3d12_gltf.cpp @@ -1,19 +1,13 @@ -// Copyright (c) 2022-2023, The Khronos Group Inc. +// Copyright (c) 2022-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT #if defined(XR_USE_GRAPHICS_API_D3D12) && !defined(MISSING_DIRECTX_COLORS) #include "graphics_plugin_d3d12_gltf.h" -#include "conformance_framework.h" -#include "graphics_plugin_d3d12_gltf.h" -#include "report.h" - -#include "pbr/D3D12/D3D12Primitive.h" +#include "pbr/D3D12/D3D12Model.h" #include "pbr/D3D12/D3D12Resources.h" -#include "pbr/GltfLoader.h" #include "utilities/d3d_common.h" -#include "utilities/throw_helpers.h" #include #include @@ -25,17 +19,10 @@ namespace Conformance void D3D12GLTF::Render(ComPtr directCommandList, Pbr::D3D12Resources& resources, XrMatrix4x4f& modelToWorld, DXGI_FORMAT colorRenderTargetFormat, DXGI_FORMAT depthRenderTargetFormat) { - if (!GetModel()) { - return; - } - - // move these to a base class helper resources.SetFillMode(GetFillMode()); - // end move - - resources.SetModelToWorld(LoadXrMatrix(modelToWorld)); resources.Bind(directCommandList.Get()); - GetModel()->Render(resources, directCommandList.Get(), colorRenderTargetFormat, depthRenderTargetFormat); + GetModelInstance().Render(resources, directCommandList.Get(), colorRenderTargetFormat, depthRenderTargetFormat, + LoadXrMatrix(modelToWorld)); } } // namespace Conformance diff --git a/src/conformance/framework/graphics_plugin_d3d12_gltf.h b/src/conformance/framework/graphics_plugin_d3d12_gltf.h index f183f4e8..635236e0 100644 --- a/src/conformance/framework/graphics_plugin_d3d12_gltf.h +++ b/src/conformance/framework/graphics_plugin_d3d12_gltf.h @@ -1,11 +1,10 @@ -// Copyright (c) 2022-2023, The Khronos Group Inc. +// Copyright (c) 2022-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT #pragma once #if defined(XR_USE_GRAPHICS_API_D3D12) && !defined(MISSING_DIRECTX_COLORS) -#include "gltf.h" #include "gltf_model.h" #include "gltf/GltfHelper.h" @@ -28,10 +27,10 @@ using Microsoft::WRL::ComPtr; namespace Conformance { - class D3D12GLTF : public GltfModelBase + class D3D12GLTF : public RenderableGltfModelInstanceBase { public: - using GltfModelBase::GltfModelBase; + using RenderableGltfModelInstanceBase::RenderableGltfModelInstanceBase; void Render(ComPtr directCommandList, Pbr::D3D12Resources& resources, XrMatrix4x4f& modelToWorld, DXGI_FORMAT colorRenderTargetFormat, DXGI_FORMAT depthRenderTargetFormat); diff --git a/src/conformance/framework/graphics_plugin_factory.cpp b/src/conformance/framework/graphics_plugin_factory.cpp index 08e7dc06..24fe09b4 100644 --- a/src/conformance/framework/graphics_plugin_factory.cpp +++ b/src/conformance/framework/graphics_plugin_factory.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/graphics_plugin_impl_helpers.h b/src/conformance/framework/graphics_plugin_impl_helpers.h index 246aceab..521e5a2f 100644 --- a/src/conformance/framework/graphics_plugin_impl_helpers.h +++ b/src/conformance/framework/graphics_plugin_impl_helpers.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/graphics_plugin_opengl.cpp b/src/conformance/framework/graphics_plugin_opengl.cpp index 05c3e0ed..3a501faf 100644 --- a/src/conformance/framework/graphics_plugin_opengl.cpp +++ b/src/conformance/framework/graphics_plugin_opengl.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -19,7 +19,7 @@ #include "RGBAImage.h" #include "conformance_framework.h" #include "conformance_utils.h" -#include "gltf.h" +#include "gltf_helpers.h" #include "graphics_plugin.h" #include "graphics_plugin_impl_helpers.h" #include "graphics_plugin_opengl_gltf.h" @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -418,9 +417,10 @@ namespace Conformance MeshHandle MakeSimpleMesh(span idx, span vtx) override; - GLTFHandle LoadGLTF(span data) override; - - std::shared_ptr GetModel(GLTFHandle handle) const override; + GLTFModelHandle LoadGLTF(std::shared_ptr tinygltfModel) override; + std::shared_ptr GetPbrModel(GLTFModelHandle handle) const override; + GLTFModelInstanceHandle CreateGLTFModelInstance(GLTFModelHandle handle) override; + Pbr::ModelInstance& GetModelInstance(GLTFModelInstanceHandle handle) override; void RenderView(const XrCompositionLayerProjectionView& layerView, const XrSwapchainImageBaseHeader* colorSwapchainImage, const RenderParams& params) override; @@ -455,7 +455,9 @@ namespace Conformance GLint m_vertexAttribColor{0}; MeshHandle m_cubeMesh{}; VectorWithGenerationCountedHandles m_meshes; - VectorWithGenerationCountedHandles m_gltfs; + // This is fine to be a shared_ptr because Model doesn't directly hold any graphics state. + VectorWithGenerationCountedHandles, GLTFModelHandle> m_gltfModels; + VectorWithGenerationCountedHandles m_gltfInstances; std::unique_ptr m_pbrResources; }; @@ -805,7 +807,9 @@ namespace Conformance m_swapchainImageDataMap.Reset(); m_cubeMesh = {}; m_meshes.clear(); - m_gltfs.clear(); + m_gltfInstances.clear(); + m_gltfModels.clear(); + m_pbrResources.reset(); deleteGLContext(); } @@ -1038,15 +1042,28 @@ namespace Conformance return handle; } - inline GLTFHandle OpenGLGraphicsPlugin::LoadGLTF(span data) + GLTFModelHandle OpenGLGraphicsPlugin::LoadGLTF(std::shared_ptr tinygltfModel) { - auto handle = m_gltfs.emplace_back(*m_pbrResources, Conformance::LoadGLTF(data)); + std::shared_ptr pbrModel = Gltf::FromGltfObject(*m_pbrResources, *tinygltfModel); + auto handle = m_gltfModels.emplace_back(std::move(pbrModel)); return handle; } - inline std::shared_ptr OpenGLGraphicsPlugin::GetModel(GLTFHandle handle) const + std::shared_ptr OpenGLGraphicsPlugin::GetPbrModel(GLTFModelHandle handle) const + { + return m_gltfModels[handle]; + } + + GLTFModelInstanceHandle OpenGLGraphicsPlugin::CreateGLTFModelInstance(GLTFModelHandle handle) + { + auto pbrModelInstance = Pbr::GLModelInstance(*m_pbrResources, GetPbrModel(handle)); + auto instanceHandle = m_gltfInstances.emplace_back(std::move(pbrModelInstance)); + return instanceHandle; + } + + Pbr::ModelInstance& OpenGLGraphicsPlugin::GetModelInstance(GLTFModelInstanceHandle handle) { - return m_gltfs[handle].GetModel(); + return m_gltfInstances[handle].GetModelInstance(); } void OpenGLGraphicsPlugin::RenderView(const XrCompositionLayerProjectionView& layerView, @@ -1137,13 +1154,13 @@ namespace Conformance } // Render each gltf - for (const auto& gltfHandle : params.glTFs) { - GLGLTF& gltf = m_gltfs[gltfHandle.handle]; + for (const auto& gltfDrawable : params.glTFs) { + GLGLTF& gltf = m_gltfInstances[gltfDrawable.handle]; // Compute and update the model transform. XrMatrix4x4f modelToWorld; - XrMatrix4x4f_CreateTranslationRotationScale(&modelToWorld, &gltfHandle.params.pose.position, - &gltfHandle.params.pose.orientation, &gltfHandle.params.scale); + XrMatrix4x4f_CreateTranslationRotationScale(&modelToWorld, &gltfDrawable.params.pose.position, + &gltfDrawable.params.pose.orientation, &gltfDrawable.params.scale); m_pbrResources->SetViewProjection(view, proj); diff --git a/src/conformance/framework/graphics_plugin_opengl_gltf.cpp b/src/conformance/framework/graphics_plugin_opengl_gltf.cpp index 8339f80b..ba120000 100644 --- a/src/conformance/framework/graphics_plugin_opengl_gltf.cpp +++ b/src/conformance/framework/graphics_plugin_opengl_gltf.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2022-2023, The Khronos Group Inc. +// Copyright (c) 2022-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT @@ -6,30 +6,16 @@ #include "graphics_plugin_opengl_gltf.h" -#include "conformance_framework.h" -#include "graphics_plugin_opengl_gltf.h" -#include "report.h" - -#include "pbr/GltfLoader.h" #include "pbr/OpenGL/GLModel.h" -#include "pbr/OpenGL/GLPrimitive.h" #include "pbr/OpenGL/GLResources.h" -#include "utilities/throw_helpers.h" - -#include namespace Conformance { - void GLGLTF::Render(Pbr::GLResources& resources, XrMatrix4x4f& modelToWorld) const + void GLGLTF::Render(Pbr::GLResources& resources, XrMatrix4x4f& modelToWorld) { - if (!GetModel()) { - return; - } - resources.SetFillMode(GetFillMode()); - resources.SetModelToWorld(modelToWorld); resources.Bind(); - GetModel()->Render(resources); + GetModelInstance().Render(resources, modelToWorld); } } // namespace Conformance diff --git a/src/conformance/framework/graphics_plugin_opengl_gltf.h b/src/conformance/framework/graphics_plugin_opengl_gltf.h index cb3012a2..1f979496 100644 --- a/src/conformance/framework/graphics_plugin_opengl_gltf.h +++ b/src/conformance/framework/graphics_plugin_opengl_gltf.h @@ -1,11 +1,10 @@ -// Copyright (c) 2022-2023, The Khronos Group Inc. +// Copyright (c) 2022-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT #pragma once #if defined(XR_USE_GRAPHICS_API_OPENGL) || defined(XR_USE_GRAPHICS_API_OPENGL_ES) -#include "gltf.h" #include "gltf_model.h" #include "common/xr_linear.h" @@ -28,12 +27,12 @@ namespace Pbr namespace Conformance { - class GLGLTF : public GltfModelBase + class GLGLTF : public RenderableGltfModelInstanceBase { public: - using GltfModelBase::GltfModelBase; + using RenderableGltfModelInstanceBase::RenderableGltfModelInstanceBase; - void Render(Pbr::GLResources& resources, XrMatrix4x4f& modelToWorld) const; + void Render(Pbr::GLResources& resources, XrMatrix4x4f& modelToWorld); }; } // namespace Conformance #endif diff --git a/src/conformance/framework/graphics_plugin_opengl_loader.h b/src/conformance/framework/graphics_plugin_opengl_loader.h index a5c69d69..cdbadd67 100644 --- a/src/conformance/framework/graphics_plugin_opengl_loader.h +++ b/src/conformance/framework/graphics_plugin_opengl_loader.h @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2023, The Khronos Group Inc. +// Copyright (c) 2020-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/graphics_plugin_opengles.cpp b/src/conformance/framework/graphics_plugin_opengles.cpp index e74e427d..a12860f9 100644 --- a/src/conformance/framework/graphics_plugin_opengles.cpp +++ b/src/conformance/framework/graphics_plugin_opengles.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -299,9 +299,10 @@ namespace Conformance MeshHandle MakeSimpleMesh(span idx, span vtx) override; - GLTFHandle LoadGLTF(span data) override; - - std::shared_ptr GetModel(GLTFHandle handle) const override; + GLTFModelHandle LoadGLTF(std::shared_ptr tinygltfModel) override; + std::shared_ptr GetPbrModel(GLTFModelHandle handle) const override; + GLTFModelInstanceHandle CreateGLTFModelInstance(GLTFModelHandle handle) override; + Pbr::ModelInstance& GetModelInstance(GLTFModelInstanceHandle handle) override; void RenderView(const XrCompositionLayerProjectionView& layerView, const XrSwapchainImageBaseHeader* colorSwapchainImage, const RenderParams& params) override; @@ -326,7 +327,9 @@ namespace Conformance GLint m_vertexAttribColor{0}; MeshHandle m_cubeMesh{}; VectorWithGenerationCountedHandles m_meshes; - VectorWithGenerationCountedHandles m_gltfs; + // This is fine to be a shared_ptr because Model doesn't directly hold any graphics state. + VectorWithGenerationCountedHandles, GLTFModelHandle> m_gltfModels; + VectorWithGenerationCountedHandles m_gltfInstances; std::unique_ptr m_pbrResources; SwapchainImageDataMap m_swapchainImageDataMap; @@ -592,7 +595,9 @@ namespace Conformance m_cubeMesh = {}; m_meshes.clear(); - m_gltfs.clear(); + m_gltfInstances.clear(); + m_gltfModels.clear(); + m_pbrResources.reset(); ksGpuWindow_Destroy(&window); } @@ -1158,15 +1163,28 @@ namespace Conformance return handle; } - inline GLTFHandle OpenGLESGraphicsPlugin::LoadGLTF(span data) + GLTFModelHandle OpenGLESGraphicsPlugin::LoadGLTF(std::shared_ptr tinygltfModel) { - auto handle = m_gltfs.emplace_back(*m_pbrResources, Conformance::LoadGLTF(data)); + std::shared_ptr pbrModel = Gltf::FromGltfObject(*m_pbrResources, *tinygltfModel); + auto handle = m_gltfModels.emplace_back(std::move(pbrModel)); return handle; } - inline std::shared_ptr OpenGLESGraphicsPlugin::GetModel(GLTFHandle handle) const + std::shared_ptr OpenGLESGraphicsPlugin::GetPbrModel(GLTFModelHandle handle) const + { + return m_gltfModels[handle]; + } + + GLTFModelInstanceHandle OpenGLESGraphicsPlugin::CreateGLTFModelInstance(GLTFModelHandle handle) + { + auto pbrModelInstance = Pbr::GLModelInstance(*m_pbrResources, GetPbrModel(handle)); + auto instanceHandle = m_gltfInstances.emplace_back(std::move(pbrModelInstance)); + return instanceHandle; + } + + Pbr::ModelInstance& OpenGLESGraphicsPlugin::GetModelInstance(GLTFModelInstanceHandle handle) { - return m_gltfs[handle].GetModel(); + return m_gltfInstances[handle].GetModelInstance(); } void OpenGLESGraphicsPlugin::RenderView(const XrCompositionLayerProjectionView& layerView, @@ -1258,13 +1276,13 @@ namespace Conformance } // Render each gltf - for (const auto& gltfHandle : params.glTFs) { - GLGLTF& gltf = m_gltfs[gltfHandle.handle]; + for (const auto& gltfDrawable : params.glTFs) { + GLGLTF& gltf = m_gltfInstances[gltfDrawable.handle]; // Compute and update the model transform. XrMatrix4x4f modelToWorld; - XrMatrix4x4f_CreateTranslationRotationScale(&modelToWorld, &gltfHandle.params.pose.position, - &gltfHandle.params.pose.orientation, &gltfHandle.params.scale); + XrMatrix4x4f_CreateTranslationRotationScale(&modelToWorld, &gltfDrawable.params.pose.position, + &gltfDrawable.params.pose.orientation, &gltfDrawable.params.scale); m_pbrResources->SetViewProjection(view, proj); diff --git a/src/conformance/framework/graphics_plugin_vulkan.cpp b/src/conformance/framework/graphics_plugin_vulkan.cpp index 4c132ce3..13bb6345 100644 --- a/src/conformance/framework/graphics_plugin_vulkan.cpp +++ b/src/conformance/framework/graphics_plugin_vulkan.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -17,7 +17,7 @@ #ifdef XR_USE_GRAPHICS_API_VULKAN #include "RGBAImage.h" #include "conformance_utils.h" -#include "gltf.h" +#include "gltf_helpers.h" #include "graphics_plugin.h" #include "graphics_plugin_impl_helpers.h" #include "graphics_plugin_vulkan_gltf.h" @@ -32,6 +32,7 @@ #include "pbr/Vulkan/VkCommon.h" #include "pbr/Vulkan/VkResources.h" #include "pbr/Vulkan/VkTexture.h" +#include "pbr/Vulkan/VkModel.h" #include "utilities/Geometry.h" #include "utilities/swapchain_format_data.h" #include "utilities/swapchain_parameters.h" @@ -653,9 +654,10 @@ namespace Conformance MeshHandle MakeSimpleMesh(span idx, span vtx) override; - GLTFHandle LoadGLTF(span data) override; - - std::shared_ptr GetModel(GLTFHandle handle) const override; + GLTFModelHandle LoadGLTF(std::shared_ptr tinygltfModel) override; + std::shared_ptr GetPbrModel(GLTFModelHandle handle) const override; + GLTFModelInstanceHandle CreateGLTFModelInstance(GLTFModelHandle handle) override; + Pbr::ModelInstance& GetModelInstance(GLTFModelInstanceHandle handle) override; void RenderView(const XrCompositionLayerProjectionView& layerView, const XrSwapchainImageBaseHeader* colorSwapchainImage, const RenderParams& params) override; @@ -710,7 +712,9 @@ namespace Conformance PipelineLayout m_pipelineLayout{}; MeshHandle m_cubeMesh{}; VectorWithGenerationCountedHandles m_meshes; - VectorWithGenerationCountedHandles m_gltfs; + // This is fine to be a shared_ptr because Model doesn't directly hold any graphics state. + VectorWithGenerationCountedHandles, GLTFModelHandle> m_gltfModels; + VectorWithGenerationCountedHandles m_gltfInstances; std::unique_ptr m_pbrResources; #if defined(USE_MIRROR_WINDOW) @@ -1373,7 +1377,9 @@ namespace Conformance m_swapchainImageDataMap.Reset(); m_cubeMesh = {}; m_meshes.clear(); - m_gltfs.clear(); + m_gltfInstances.clear(); + m_gltfModels.clear(); + m_pbrResources.reset(); m_queueFamilyIndex = 0; m_vkQueue = VK_NULL_HANDLE; @@ -1950,15 +1956,28 @@ namespace Conformance return handle; } - inline GLTFHandle VulkanGraphicsPlugin::LoadGLTF(span data) + GLTFModelHandle VulkanGraphicsPlugin::LoadGLTF(std::shared_ptr tinygltfModel) { - auto handle = m_gltfs.emplace_back(*m_pbrResources, Conformance::LoadGLTF(data)); + std::shared_ptr pbrModel = Gltf::FromGltfObject(*m_pbrResources, *tinygltfModel); + auto handle = m_gltfModels.emplace_back(std::move(pbrModel)); return handle; } - inline std::shared_ptr VulkanGraphicsPlugin::GetModel(GLTFHandle handle) const + std::shared_ptr VulkanGraphicsPlugin::GetPbrModel(GLTFModelHandle handle) const + { + return m_gltfModels[handle]; + } + + GLTFModelInstanceHandle VulkanGraphicsPlugin::CreateGLTFModelInstance(GLTFModelHandle handle) + { + auto pbrModelInstance = Pbr::VulkanModelInstance(*m_pbrResources, GetPbrModel(handle)); + auto instanceHandle = m_gltfInstances.emplace_back(std::move(pbrModelInstance)); + return instanceHandle; + } + + Pbr::ModelInstance& VulkanGraphicsPlugin::GetModelInstance(GLTFModelInstanceHandle handle) { - return m_gltfs[handle].GetModel(); + return m_gltfInstances[handle].GetModelInstance(); } void VulkanGraphicsPlugin::RenderView(const XrCompositionLayerProjectionView& layerView, @@ -2056,13 +2075,13 @@ namespace Conformance } // Render each gltf - for (const auto& gltfHandle : params.glTFs) { - VulkanGLTF& gltf = m_gltfs[gltfHandle.handle]; + for (const auto& gltfDrawable : params.glTFs) { + VulkanGLTF& gltf = m_gltfInstances[gltfDrawable.handle]; // Compute and update the model transform. XrMatrix4x4f modelToWorld; - XrMatrix4x4f_CreateTranslationRotationScale(&modelToWorld, &gltfHandle.params.pose.position, - &gltfHandle.params.pose.orientation, &gltfHandle.params.scale); + XrMatrix4x4f_CreateTranslationRotationScale(&modelToWorld, &gltfDrawable.params.pose.position, + &gltfDrawable.params.pose.orientation, &gltfDrawable.params.scale); // XrMatrix4x4f viewMatrix; // XrVector3f unitScale = {1, 1, 1}; // XrMatrix4x4f_CreateTranslationRotationScale(&viewMatrix, &layerView.pose.position, &layerView.pose.orientation, &unitScale); diff --git a/src/conformance/framework/graphics_plugin_vulkan_gltf.cpp b/src/conformance/framework/graphics_plugin_vulkan_gltf.cpp index ee34cc16..af966b09 100644 --- a/src/conformance/framework/graphics_plugin_vulkan_gltf.cpp +++ b/src/conformance/framework/graphics_plugin_vulkan_gltf.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2022-2023, The Khronos Group Inc. +// Copyright (c) 2022-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT @@ -6,33 +6,19 @@ #include "graphics_plugin_vulkan_gltf.h" -#include "conformance_framework.h" -#include "graphics_plugin_vulkan_gltf.h" -#include "report.h" - -#include "pbr/GltfLoader.h" #include "pbr/Vulkan/VkModel.h" #include "pbr/Vulkan/VkPrimitive.h" #include "pbr/Vulkan/VkResources.h" -#include "utilities/throw_helpers.h" - -#include namespace Conformance { struct CmdBuffer; - void VulkanGLTF::Render(CmdBuffer& directCommandBuffer, Pbr::VulkanResources& resources, XrMatrix4x4f& modelToWorld, - VkRenderPass renderPass, VkSampleCountFlagBits sampleCount) const + void VulkanGLTF::Render(CmdBuffer& directCommandBuffer, Pbr::VulkanResources& resources, const XrMatrix4x4f& modelToWorld, + VkRenderPass renderPass, VkSampleCountFlagBits sampleCount) { - if (!GetModel()) { - return; - } - resources.SetFillMode(GetFillMode()); - resources.SetModelToWorld(modelToWorld); - // resources.Bind(directCommandBuffer); - GetModel()->Render(resources, directCommandBuffer, renderPass, sampleCount); + GetModelInstance().Render(resources, directCommandBuffer, renderPass, sampleCount, modelToWorld); } } // namespace Conformance diff --git a/src/conformance/framework/graphics_plugin_vulkan_gltf.h b/src/conformance/framework/graphics_plugin_vulkan_gltf.h index 5a039a66..1c773854 100644 --- a/src/conformance/framework/graphics_plugin_vulkan_gltf.h +++ b/src/conformance/framework/graphics_plugin_vulkan_gltf.h @@ -1,10 +1,9 @@ -// Copyright (c) 2022-2023, The Khronos Group Inc. +// Copyright (c) 2022-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT #pragma once #ifdef XR_USE_GRAPHICS_API_VULKAN -#include "gltf.h" #include "gltf_model.h" #include "common/xr_linear.h" @@ -22,7 +21,7 @@ namespace Pbr { - class VulkanModel; + class Model; struct VulkanResources; } // namespace Pbr @@ -30,13 +29,13 @@ namespace Conformance { struct CmdBuffer; - class VulkanGLTF : public GltfModelBase + class VulkanGLTF : public RenderableGltfModelInstanceBase { public: - using GltfModelBase::GltfModelBase; + using RenderableGltfModelInstanceBase::RenderableGltfModelInstanceBase; - void Render(CmdBuffer& directCommandBuffer, Pbr::VulkanResources& resources, XrMatrix4x4f& modelToWorld, VkRenderPass renderPass, - VkSampleCountFlagBits sampleCount) const; + void Render(CmdBuffer& directCommandBuffer, Pbr::VulkanResources& resources, const XrMatrix4x4f& modelToWorld, + VkRenderPass renderPass, VkSampleCountFlagBits sampleCount); }; } // namespace Conformance #endif diff --git a/src/conformance/framework/input_testinputdevice.cpp b/src/conformance/framework/input_testinputdevice.cpp index 85084ab5..1852a6a8 100644 --- a/src/conformance/framework/input_testinputdevice.cpp +++ b/src/conformance/framework/input_testinputdevice.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/input_testinputdevice.h b/src/conformance/framework/input_testinputdevice.h index c7ad1378..9132ba64 100644 --- a/src/conformance/framework/input_testinputdevice.h +++ b/src/conformance/framework/input_testinputdevice.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/matchers.h b/src/conformance/framework/matchers.h index 33aa2f1d..f6f3038d 100644 --- a/src/conformance/framework/matchers.h +++ b/src/conformance/framework/matchers.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/mesh_projection_layer.cpp b/src/conformance/framework/mesh_projection_layer.cpp index 231fa454..46ea4130 100644 --- a/src/conformance/framework/mesh_projection_layer.cpp +++ b/src/conformance/framework/mesh_projection_layer.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/mesh_projection_layer.h b/src/conformance/framework/mesh_projection_layer.h index 68812140..6ff4aa31 100644 --- a/src/conformance/framework/mesh_projection_layer.h +++ b/src/conformance/framework/mesh_projection_layer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/pbr/CMakeLists.txt b/src/conformance/framework/pbr/CMakeLists.txt index 9217d352..f5c6be31 100644 --- a/src/conformance/framework/pbr/CMakeLists.txt +++ b/src/conformance/framework/pbr/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 @@ -198,6 +198,16 @@ if(XR_USE_GRAPHICS_API_VULKAN) Vulkan/VkModel.cpp Vulkan/VkPrimitive.cpp ) + if(GLSLANG_VALIDATOR) + # If we can, run this check of shader structure offsets in the unit test suite. + add_test( + NAME pbr_glsl_offsets + COMMAND + "${PYTHON_EXECUTABLE}" + "${CMAKE_CURRENT_SOURCE_DIR}/check-offsets.py" + "${GLSLANG_VALIDATOR}" + ) + endif() endif() target_include_directories( diff --git a/src/conformance/framework/pbr/D3D11/D3D11Material.cpp b/src/conformance/framework/pbr/D3D11/D3D11Material.cpp index bb840804..51779e19 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11Material.cpp +++ b/src/conformance/framework/pbr/D3D11/D3D11Material.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/D3D11/D3D11Material.h b/src/conformance/framework/pbr/D3D11/D3D11Material.h index 2b2c2a88..5af101a7 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11Material.h +++ b/src/conformance/framework/pbr/D3D11/D3D11Material.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -17,34 +17,30 @@ #include #include // For Microsoft::WRL::ComPtr -#include -#include #include -#include namespace Pbr { - // A D3D11Material contains the metallic roughness parameters and textures. - // Primitives specify which D3D11Material to use when being rendered. + /// A D3D11Material contains the metallic roughness parameters and textures. + /// Primitives specify which D3D11Material to use when being rendered. struct D3D11Material final : public Material { - // Create a uninitialized material. Textures and shader coefficients must be set. + /// Create a uninitialized material. Textures and shader coefficients must be set. D3D11Material(Pbr::D3D11Resources const& pbrResources); - // Create a clone of this material. + /// Create a clone of this material. std::shared_ptr Clone(Pbr::D3D11Resources const& pbrResources) const; - // Create a flat (no texture) material. + /// Create a flat (no texture) material. static std::shared_ptr CreateFlat(const D3D11Resources& pbrResources, RGBAColor baseColorFactor, float roughnessFactor = 1.0f, float metallicFactor = 0.0f, RGBColor emissiveFactor = RGB::Black); - // Set a Metallic-Roughness texture. + /// Set a Metallic-Roughness texture. void SetTexture(ShaderSlots::PSMaterial slot, _In_ ID3D11ShaderResourceView* textureView, _In_opt_ ID3D11SamplerState* sampler = nullptr); - // void SetTexture(ShaderSlots::PSMaterial slot, ITexture& texture) override; - // Bind this material to current context. + /// Bind this material to current context. void Bind(_In_ ID3D11DeviceContext* context, const D3D11Resources& pbrResources) const; std::string Name; diff --git a/src/conformance/framework/pbr/D3D11/D3D11Model.cpp b/src/conformance/framework/pbr/D3D11/D3D11Model.cpp index f39dc652..1e7b5896 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11Model.cpp +++ b/src/conformance/framework/pbr/D3D11/D3D11Model.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -10,6 +10,7 @@ #include "D3D11Model.h" +#include "D3D11Material.h" #include "D3D11Primitive.h" #include "D3D11Resources.h" @@ -22,15 +23,19 @@ namespace Pbr { - - void D3D11Model::Render(Pbr::D3D11Resources const& pbrResources, _In_ ID3D11DeviceContext* context) + void D3D11ModelInstance::Render(Pbr::D3D11Resources const& pbrResources, _In_ ID3D11DeviceContext* context, + DirectX::FXMMATRIX modelToWorld) { + XMStoreFloat4x4(&m_modelBuffer.ModelToWorld, XMMatrixTranspose(modelToWorld)); + context->UpdateSubresource(m_modelConstantBuffer.Get(), 0, nullptr, &m_modelBuffer, 0, 0); + pbrResources.BindConstantBuffers(context, m_modelConstantBuffer.Get()); + UpdateTransforms(pbrResources, context); ID3D11ShaderResourceView* vsShaderResources[] = {m_modelTransformsResourceView.Get()}; context->VSSetShaderResources(Pbr::ShaderSlots::Transforms, _countof(vsShaderResources), vsShaderResources); - for (PrimitiveHandle primitiveHandle : GetPrimitives()) { + for (PrimitiveHandle primitiveHandle : GetModel().GetPrimitiveHandles()) { const Pbr::D3D11Primitive& primitive = pbrResources.GetPrimitive(primitiveHandle); if (primitive.GetMaterial()->Hidden) continue; @@ -38,66 +43,51 @@ namespace Pbr primitive.GetMaterial()->Bind(context, pbrResources); primitive.Render(context); } - - // Expect the caller to reset other state, but the geometry shader is cleared specially. - //context->GSSetShader(nullptr, nullptr, 0); } - void D3D11Model::UpdateTransforms(Pbr::D3D11Resources const& pbrResources, _In_ ID3D11DeviceContext* context) + D3D11ModelInstance::D3D11ModelInstance(Pbr::D3D11Resources& pbrResources, std::shared_ptr model) + : ModelInstance(std::move(model)) { - const auto& nodes = GetNodes(); - const uint32_t newTotalModifyCount = std::accumulate(nodes.begin(), nodes.end(), 0, [](uint32_t sumChangeCount, const Node& node) { - return sumChangeCount + node.GetModifyCount(); - }); + // Set up the model constant buffer. + const CD3D11_BUFFER_DESC modelConstantBufferDesc(sizeof(ModelConstantBuffer), D3D11_BIND_CONSTANT_BUFFER); + XRC_CHECK_THROW_HRCMD( + pbrResources.GetDevice()->CreateBuffer(&modelConstantBufferDesc, nullptr, m_modelConstantBuffer.ReleaseAndGetAddressOf())); + + // Set up the transforms buffer. + XrMatrix4x4f identityMatrix; + XrMatrix4x4f_CreateIdentity(&identityMatrix); // or better yet poison it + size_t nodeCount = GetModel().GetNodes().size(); + + // Create/recreate the structured buffer and SRV which holds the node transforms. + // Use Usage=D3D11_USAGE_DYNAMIC and CPUAccessFlags=D3D11_CPU_ACCESS_WRITE with Map/Unmap instead? + D3D11_BUFFER_DESC desc{}; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; + desc.StructureByteStride = sizeof(XrMatrix4x4f); + desc.ByteWidth = (UINT)(nodeCount * desc.StructureByteStride); + XRC_CHECK_THROW_HRCMD( + pbrResources.GetDevice()->CreateBuffer(&desc, nullptr, m_modelTransformsStructuredBuffer.ReleaseAndGetAddressOf())); + + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc{}; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; + // TODO this looks weird + srvDesc.Buffer.NumElements = (UINT)nodeCount; + srvDesc.Buffer.ElementWidth = (UINT)nodeCount; + m_modelTransformsResourceView = nullptr; + XRC_CHECK_THROW_HRCMD(pbrResources.GetDevice()->CreateShaderResourceView(m_modelTransformsStructuredBuffer.Get(), &srvDesc, + m_modelTransformsResourceView.ReleaseAndGetAddressOf())); + } + void D3D11ModelInstance::UpdateTransforms(Pbr::D3D11Resources const& /*pbrResources*/, _In_ ID3D11DeviceContext* context) + { // If none of the node transforms have changed, no need to recompute/update the model transform structured buffer. - if (newTotalModifyCount != TotalModifyCount || m_modelTransformsStructuredBufferInvalid) { - if (m_modelTransformsStructuredBufferInvalid) // The structured buffer is reset when a Node is added. - { - XrMatrix4x4f identityMatrix; - XrMatrix4x4f_CreateIdentity(&identityMatrix); // or better yet poison it - m_modelTransforms.resize(nodes.size(), identityMatrix); - - // Create/recreate the structured buffer and SRV which holds the node transforms. - // Use Usage=D3D11_USAGE_DYNAMIC and CPUAccessFlags=D3D11_CPU_ACCESS_WRITE with Map/Unmap instead? - D3D11_BUFFER_DESC desc{}; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; - desc.StructureByteStride = sizeof(decltype(m_modelTransforms)::value_type); - desc.ByteWidth = (UINT)(m_modelTransforms.size() * desc.StructureByteStride); - XRC_CHECK_THROW_HRCMD( - pbrResources.GetDevice()->CreateBuffer(&desc, nullptr, m_modelTransformsStructuredBuffer.ReleaseAndGetAddressOf())); - - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc{}; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; - // TODO this looks weird - srvDesc.Buffer.NumElements = (UINT)m_modelTransforms.size(); - srvDesc.Buffer.ElementWidth = (UINT)m_modelTransforms.size(); - m_modelTransformsResourceView = nullptr; - XRC_CHECK_THROW_HRCMD(pbrResources.GetDevice()->CreateShaderResourceView( - m_modelTransformsStructuredBuffer.Get(), &srvDesc, m_modelTransformsResourceView.ReleaseAndGetAddressOf())); - - m_modelTransformsStructuredBufferInvalid = false; - } - - // Nodes are guaranteed to come after their parents, so each node transform can be multiplied by its parent transform in a single pass. - assert(nodes.size() == m_modelTransforms.size()); - XrMatrix4x4f identityMatrix; - XrMatrix4x4f_CreateIdentity(&identityMatrix); - for (const auto& node : nodes) { - assert(node.ParentNodeIndex == RootParentNodeIndex || node.ParentNodeIndex < node.Index); - const XrMatrix4x4f& parentTransform = - (node.ParentNodeIndex == RootParentNodeIndex) ? identityMatrix : m_modelTransforms[node.ParentNodeIndex]; - XrMatrix4x4f nodeTransform = node.GetTransform(); - XrMatrix4x4f nodeTransformTranspose; - XrMatrix4x4f_Transpose(&nodeTransformTranspose, &nodeTransform); - XrMatrix4x4f_Multiply(&m_modelTransforms[node.Index], &nodeTransformTranspose, &parentTransform); - } + if (WereNodeLocalTransformsUpdated()) { + ResolveTransforms(true); // Update node transform structured buffer. - context->UpdateSubresource(m_modelTransformsStructuredBuffer.Get(), 0, nullptr, this->m_modelTransforms.data(), 0, 0); - TotalModifyCount = newTotalModifyCount; + context->UpdateSubresource(m_modelTransformsStructuredBuffer.Get(), 0, nullptr, GetResolvedTransforms().data(), 0, 0); + ClearTransformsUpdatedFlag(); } } } // namespace Pbr diff --git a/src/conformance/framework/pbr/D3D11/D3D11Model.h b/src/conformance/framework/pbr/D3D11/D3D11Model.h index 171eac05..bde687e0 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11Model.h +++ b/src/conformance/framework/pbr/D3D11/D3D11Model.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -14,24 +14,33 @@ namespace Pbr { - struct D3D11Primitive; + struct D3D11Resources; + + struct ModelConstantBuffer + { + DirectX::XMFLOAT4X4 ModelToWorld; + }; + + static_assert((sizeof(ModelConstantBuffer) % 16) == 0, "Constant Buffer must be divisible by 16 bytes"); - class D3D11Model final : public Model + class D3D11ModelInstance final : public ModelInstance { public: - // Render the model. - void Render(Pbr::D3D11Resources const& pbrResources, _In_ ID3D11DeviceContext* context); + D3D11ModelInstance(Pbr::D3D11Resources& pbrResources, std::shared_ptr model); + + /// Render the model. + void Render(Pbr::D3D11Resources const& pbrResources, _In_ ID3D11DeviceContext* context, DirectX::FXMMATRIX modelToWorld); private: - // Updated the transforms used to render the model. This needs to be called any time a node transform is changed. + void AllocateDescriptorSets(Pbr::D3D11Resources& pbrResources, uint32_t numSets); + /// Update the transforms used to render the model. This needs to be called any time a node transform is changed. void UpdateTransforms(Pbr::D3D11Resources const& pbrResources, _In_ ID3D11DeviceContext* context); - // Temporary buffer holds the world transforms, computed from the node's local transforms. - mutable std::vector m_modelTransforms; - mutable Microsoft::WRL::ComPtr m_modelTransformsStructuredBuffer; - mutable Microsoft::WRL::ComPtr m_modelTransformsResourceView; + ModelConstantBuffer m_modelBuffer; + Microsoft::WRL::ComPtr m_modelConstantBuffer; - mutable uint32_t TotalModifyCount{0}; + Microsoft::WRL::ComPtr m_modelTransformsStructuredBuffer; + Microsoft::WRL::ComPtr m_modelTransformsResourceView; }; } // namespace Pbr diff --git a/src/conformance/framework/pbr/D3D11/D3D11Primitive.cpp b/src/conformance/framework/pbr/D3D11/D3D11Primitive.cpp index 9854fe31..b769e667 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11Primitive.cpp +++ b/src/conformance/framework/pbr/D3D11/D3D11Primitive.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/D3D11/D3D11Primitive.h b/src/conformance/framework/pbr/D3D11/D3D11Primitive.h index 0a762491..92f709bb 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11Primitive.h +++ b/src/conformance/framework/pbr/D3D11/D3D11Primitive.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -14,11 +14,12 @@ #include #include // For Microsoft::WRL::ComPtr +#include #include namespace Pbr { - // A primitive holds a vertex buffer, index buffer, and a pointer to a PBR material. + /// A primitive holds a vertex buffer, index buffer, and a pointer to a PBR material. struct D3D11Primitive final { using Collection = std::vector; @@ -31,25 +32,20 @@ namespace Pbr void UpdateBuffers(_In_ ID3D11Device* device, _In_ ID3D11DeviceContext* context, const Pbr::PrimitiveBuilder& primitiveBuilder); - // Get the material for the primitive. - std::shared_ptr& GetMaterial() - { - return m_material; - } + /// Get the material for the primitive. const std::shared_ptr& GetMaterial() const { return m_material; } - // Replace the material for the primitive + /// Replace the material for the primitive void SetMaterial(std::shared_ptr material) { m_material = std::move(material); } protected: - // friend class Model; - friend class D3D11Model; + friend class D3D11ModelInstance; void Render(_In_ ID3D11DeviceContext* context) const; D3D11Primitive Clone(Pbr::D3D11Resources const& pbrResources) const; diff --git a/src/conformance/framework/pbr/D3D11/D3D11Resources.cpp b/src/conformance/framework/pbr/D3D11/D3D11Resources.cpp index 73be98cd..e18e7902 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11Resources.cpp +++ b/src/conformance/framework/pbr/D3D11/D3D11Resources.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -52,13 +52,6 @@ namespace static_assert(offsetof(SceneConstantBuffer, LightDiffuseColor) == 96, "Offsets must match shader"); static_assert(offsetof(SceneConstantBuffer, NumSpecularMipLevels) == 112, "Offsets must match shader"); - struct ModelConstantBuffer - { - DirectX::XMFLOAT4X4 ModelToWorld; - }; - - static_assert((sizeof(ModelConstantBuffer) % 16) == 0, "Constant Buffer must be divisible by 16 bytes"); - const D3D11_INPUT_ELEMENT_DESC s_vertexDesc[6] = { {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, @@ -87,15 +80,11 @@ namespace Pbr XRC_CHECK_THROW_HRCMD(device->CreateVertexShader(g_PbrVertexShader, sizeof(g_PbrVertexShader), nullptr, Resources.PbrVertexShader.ReleaseAndGetAddressOf())); - // Set up the constant buffers. + // Set up the scene constant buffer. const CD3D11_BUFFER_DESC pbrConstantBufferDesc(sizeof(SceneConstantBuffer), D3D11_BIND_CONSTANT_BUFFER); XRC_CHECK_THROW_HRCMD( device->CreateBuffer(&pbrConstantBufferDesc, nullptr, Resources.SceneConstantBuffer.ReleaseAndGetAddressOf())); - const CD3D11_BUFFER_DESC modelConstantBufferDesc(sizeof(ModelConstantBuffer), D3D11_BIND_CONSTANT_BUFFER); - XRC_CHECK_THROW_HRCMD( - device->CreateBuffer(&modelConstantBufferDesc, nullptr, Resources.ModelConstantBuffer.ReleaseAndGetAddressOf())); - // Samplers for environment map and BRDF. Resources.EnvironmentMapSampler = D3D11Texture::CreateSampler(device); Resources.BrdfSampler = D3D11Texture::CreateSampler(device); @@ -152,7 +141,6 @@ namespace Pbr Microsoft::WRL::ComPtr PbrVertexShader; Microsoft::WRL::ComPtr PbrPixelShader; Microsoft::WRL::ComPtr SceneConstantBuffer; - Microsoft::WRL::ComPtr ModelConstantBuffer; Microsoft::WRL::ComPtr BrdfLut; Microsoft::WRL::ComPtr SpecularEnvironmentMap; Microsoft::WRL::ComPtr DiffuseEnvironmentMap; @@ -167,7 +155,6 @@ namespace Pbr DeviceResources Resources; SceneConstantBuffer SceneBuffer; - ModelConstantBuffer ModelBuffer; struct LoaderResources { @@ -348,12 +335,6 @@ namespace Pbr m_impl->SceneBuffer.LightDiffuseColor = {diffuseColor.x, diffuseColor.y, diffuseColor.z}; } - void XM_CALLCONV D3D11Resources::SetModelToWorld(DirectX::FXMMATRIX modelToWorld, _In_ ID3D11DeviceContext* context) const - { - XMStoreFloat4x4(&m_impl->ModelBuffer.ModelToWorld, XMMatrixTranspose(modelToWorld)); - context->UpdateSubresource(m_impl->Resources.ModelConstantBuffer.Get(), 0, nullptr, &m_impl->ModelBuffer, 0, 0); - } - void XM_CALLCONV D3D11Resources::SetViewProjection(DirectX::FXMMATRIX view, DirectX::CXMMATRIX projection) { XMStoreFloat4x4(&m_impl->SceneBuffer.ViewProjection, XMMatrixTranspose(XMMatrixMultiply(view, projection))); @@ -391,10 +372,9 @@ namespace Pbr context->VSSetShader(m_impl->Resources.PbrVertexShader.Get(), nullptr, 0); context->PSSetShader(m_impl->Resources.PbrPixelShader.Get(), nullptr, 0); - ID3D11Buffer* vsBuffers[] = {m_impl->Resources.SceneConstantBuffer.Get(), m_impl->Resources.ModelConstantBuffer.Get()}; - context->VSSetConstantBuffers(Pbr::ShaderSlots::ConstantBuffers::Scene, _countof(vsBuffers), vsBuffers); ID3D11Buffer* psBuffers[] = {m_impl->Resources.SceneConstantBuffer.Get()}; context->PSSetConstantBuffers(Pbr::ShaderSlots::ConstantBuffers::Scene, _countof(psBuffers), psBuffers); + context->IASetInputLayout(m_impl->Resources.InputLayout.Get()); static_assert(ShaderSlots::DiffuseTexture == ShaderSlots::SpecularTexture + 1, "Diffuse must follow Specular slot"); @@ -406,6 +386,13 @@ namespace Pbr context->PSSetSamplers(ShaderSlots::Brdf, _countof(samplers), samplers); } + void D3D11Resources::BindConstantBuffers(_In_ ID3D11DeviceContext* context, ID3D11Buffer* modelConstantBuffer) const + { + ID3D11Buffer* vsBuffers[] = {m_impl->Resources.SceneConstantBuffer.Get(), modelConstantBuffer}; + context->VSSetConstantBuffers(Pbr::ShaderSlots::ConstantBuffers::Scene, _countof(vsBuffers), vsBuffers); + // PSSetConstantBuffers is done in Bind because it is not model-dependent + } + PrimitiveHandle D3D11Resources::MakePrimitive(const Pbr::PrimitiveBuilder& primitiveBuilder, const std::shared_ptr& material) { diff --git a/src/conformance/framework/pbr/D3D11/D3D11Resources.h b/src/conformance/framework/pbr/D3D11/D3D11Resources.h index e09f5a96..af314227 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11Resources.h +++ b/src/conformance/framework/pbr/D3D11/D3D11Resources.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -58,39 +58,39 @@ namespace Pbr const std::shared_ptr& material) override; void DropLoaderCaches() override; - // Sets the Bidirectional Reflectance Distribution Function Lookup Table texture, required by the shader to compute surface - // reflectance from the IBL. + /// Sets the Bidirectional Reflectance Distribution Function Lookup Table texture, required by the shader to compute surface + /// reflectance from the IBL. void SetBrdfLut(_In_ ID3D11ShaderResourceView* brdfLut); - // Create device-dependent resources. + /// Create device-dependent resources. void CreateDeviceDependentResources(_In_ ID3D11Device* device); - // Release device-dependent resources. + /// Release device-dependent resources. void ReleaseDeviceDependentResources(); - // Get the D3D11Device that the PBR resources are associated with. + /// Get the D3D11Device that the PBR resources are associated with. Microsoft::WRL::ComPtr GetDevice() const; - // Set the directional light. + /// Set the directional light. void SetLight(DirectX::XMFLOAT3 direction, RGBColor diffuseColor); - // Set the specular and diffuse image-based lighting (IBL) maps. ShaderResourceViews must be TextureCubes. + /// Set the specular and diffuse image-based lighting (IBL) maps. ShaderResourceViews must be TextureCubes. void SetEnvironmentMap(_In_ ID3D11ShaderResourceView* specularEnvironmentMap, _In_ ID3D11ShaderResourceView* diffuseEnvironmentMap); - // Set the current view and projection matrices. + /// Set the current view and projection matrices. void XM_CALLCONV SetViewProjection(DirectX::FXMMATRIX view, DirectX::CXMMATRIX projection); - // Many 1x1 pixel colored textures are used in the PBR system. This is used to create textures backed by a cache to reduce the - // number of textures created. + /// Many 1x1 pixel colored textures are used in the PBR system. This is used to create textures backed by a cache to reduce the + /// number of textures created. Microsoft::WRL::ComPtr CreateTypedSolidColorTexture(RGBAColor color) const; - // Bind the the PBR resources to the current context. + /// Bind the the PBR resources to the current context. void Bind(_In_ ID3D11DeviceContext* context) const; - // Set and update the model to world constant buffer value. - void XM_CALLCONV SetModelToWorld(DirectX::FXMMATRIX modelToWorld, _In_ ID3D11DeviceContext* context) const; - + /// Get the D3D11Primitive from a primitive handle. D3D11Primitive& GetPrimitive(PrimitiveHandle p); + + /// Get the D3D11Primitive from a primitive handle, const overload. const D3D11Primitive& GetPrimitive(PrimitiveHandle p) const; // Set or get the shading and fill modes. @@ -105,6 +105,10 @@ namespace Pbr void SetRasterizerState(_In_ ID3D11DeviceContext* context, bool doubleSided) const; void SetDepthStencilState(_In_ ID3D11DeviceContext* context, bool disableDepthWrite) const; + // Bind the scene constant buffer as well as a provided model constant buffer. + void BindConstantBuffers(_In_ ID3D11DeviceContext* context, ID3D11Buffer* modelConstantBuffer) const; + + friend class D3D11ModelInstance; friend struct D3D11Material; struct Impl; diff --git a/src/conformance/framework/pbr/D3D11/D3D11Texture.cpp b/src/conformance/framework/pbr/D3D11/D3D11Texture.cpp index 8f93616a..92b52c15 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11Texture.cpp +++ b/src/conformance/framework/pbr/D3D11/D3D11Texture.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/D3D11/D3D11Texture.h b/src/conformance/framework/pbr/D3D11/D3D11Texture.h index a33932ae..a302d638 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11Texture.h +++ b/src/conformance/framework/pbr/D3D11/D3D11Texture.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -21,7 +21,6 @@ #include // For Microsoft::WRL::ComPtr #include -#include namespace Pbr { diff --git a/src/conformance/framework/pbr/D3D11/D3D11TextureCache.cpp b/src/conformance/framework/pbr/D3D11/D3D11TextureCache.cpp index 4c80bc8d..d49cafcd 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11TextureCache.cpp +++ b/src/conformance/framework/pbr/D3D11/D3D11TextureCache.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -18,6 +18,7 @@ #include #include #include +#include namespace Pbr { diff --git a/src/conformance/framework/pbr/D3D11/D3D11TextureCache.h b/src/conformance/framework/pbr/D3D11/D3D11TextureCache.h index 26f81f39..aa723561 100644 --- a/src/conformance/framework/pbr/D3D11/D3D11TextureCache.h +++ b/src/conformance/framework/pbr/D3D11/D3D11TextureCache.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -21,7 +21,6 @@ namespace Pbr { template using ComPtr = Microsoft::WRL::ComPtr; - // using Microsoft::WRL::ComPtr; /// Cache of single-color textures. /// diff --git a/src/conformance/framework/pbr/D3D12/D3D12Material.cpp b/src/conformance/framework/pbr/D3D12/D3D12Material.cpp index 7518c38e..cfb68f28 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12Material.cpp +++ b/src/conformance/framework/pbr/D3D12/D3D12Material.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/D3D12/D3D12Material.h b/src/conformance/framework/pbr/D3D12/D3D12Material.h index 2ec3f1cc..7d16707f 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12Material.h +++ b/src/conformance/framework/pbr/D3D12/D3D12Material.h @@ -1,10 +1,11 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved // Licensed under the MIT License. See License.txt in the project root for license information. // // SPDX-License-Identifier: MIT AND Apache-2.0 + #pragma once #include "D3D12Resources.h" @@ -15,38 +16,34 @@ #include #include // For Microsoft::WRL::ComPtr -#include -#include #include -#include namespace Pbr { - // A D3D12Material contains the metallic roughness parameters and textures. - // Primitives specify which D3D12Material to use when being rendered. + /// A D3D12Material contains the metallic roughness parameters and textures. + /// Primitives specify which D3D12Material to use when being rendered. struct D3D12Material final : public Material { - // Create a uninitialized material. Textures and shader coefficients must be set. + /// Create a uninitialized material. Textures and shader coefficients must be set. D3D12Material(Pbr::D3D12Resources const& pbrResources); - // Create a clone of this material. Shares the texture and sampler heap with this material. + /// Create a clone of this material. Shares the texture and sampler heap with this material. std::shared_ptr Clone(Pbr::D3D12Resources const& pbrResources) const; - // Create a flat (no texture) material. + /// Create a flat (no texture) material. static std::shared_ptr CreateFlat(D3D12Resources& pbrResources, RGBAColor baseColorFactor, float roughnessFactor = 1.0f, float metallicFactor = 0.0f, RGBColor emissiveFactor = RGB::Black); - // Set a Metallic-Roughness texture. + /// Set a Metallic-Roughness texture. void SetTexture(_In_ ID3D12Device* device, ShaderSlots::PSMaterial slot, Conformance::D3D12ResourceWithSRVDesc& texture, _In_opt_ D3D12_SAMPLER_DESC* sampler); - // void SetTexture(ShaderSlots::PSMaterial slot, ITexture& texture) override; - // Write the descriptors of this material to a texture and sampler heap + /// Write the descriptors of this material to a texture and sampler heap void GetDescriptors(_In_ ID3D12Device* device, D3D12_CPU_DESCRIPTOR_HANDLE destTextureDescriptors, D3D12_CPU_DESCRIPTOR_HANDLE destSamplerDescriptors); - // Bind this material to current context. + /// Bind this material to current context. void Bind(_In_ ID3D12GraphicsCommandList* directCommandList, D3D12Resources& pbrResources); std::string Name; diff --git a/src/conformance/framework/pbr/D3D12/D3D12Model.cpp b/src/conformance/framework/pbr/D3D12/D3D12Model.cpp index d4639ffa..e0f96c1a 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12Model.cpp +++ b/src/conformance/framework/pbr/D3D12/D3D12Model.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -26,91 +26,83 @@ namespace Pbr { - void D3D12Model::Render(Pbr::D3D12Resources& pbrResources, _In_ ID3D12GraphicsCommandList* directCommandList, - DXGI_FORMAT colorRenderTargetFormat, DXGI_FORMAT depthRenderTargetFormat) + void D3D12ModelInstance::Render(Pbr::D3D12Resources& pbrResources, _In_ ID3D12GraphicsCommandList* directCommandList, + DXGI_FORMAT colorRenderTargetFormat, DXGI_FORMAT depthRenderTargetFormat, + DirectX::FXMMATRIX modelToWorld) { + XMStoreFloat4x4(&m_modelBuffer.ModelToWorld, XMMatrixTranspose(modelToWorld)); + pbrResources.WithCopyCommandList( + [&](ID3D12GraphicsCommandList* cmdList) { m_modelConstantBuffer.AsyncUpload(cmdList, &m_modelBuffer); }); + // xxx: why do we copy the transform descriptor to a separate heap, again? is that relevant here? + pbrResources.BindConstantBufferViews(directCommandList, m_modelConstantBuffer.GetResource()->GetGPUVirtualAddress()); + UpdateTransforms(pbrResources); pbrResources.SetTransforms(m_modelTransformsResourceViewHeap->GetCPUDescriptorHandleForHeapStart()); - for (PrimitiveHandle primitiveHandle : GetPrimitives()) { + for (PrimitiveHandle primitiveHandle : GetModel().GetPrimitiveHandles()) { const Pbr::D3D12Primitive& primitive = pbrResources.GetPrimitive(primitiveHandle); if (primitive.GetMaterial()->Hidden) continue; primitive.Render(directCommandList, pbrResources, colorRenderTargetFormat, depthRenderTargetFormat); } - - // Expect the caller to reset other state, but the geometry shader is cleared specially. - //context->GSSetShader(nullptr, nullptr, 0); } - void D3D12Model::UpdateTransforms(Pbr::D3D12Resources& pbrResources) + D3D12ModelInstance::D3D12ModelInstance(Pbr::D3D12Resources& pbrResources, std::shared_ptr model) + : ModelInstance(std::move(model)) { - const auto& nodes = GetNodes(); - const uint32_t newTotalModifyCount = std::accumulate(nodes.begin(), nodes.end(), 0, [](uint32_t sumChangeCount, const Node& node) { - return sumChangeCount + node.GetModifyCount(); - }); + // Set up the model constant buffer. + static_assert((sizeof(ModelConstantBuffer) % 16) == 0, "Constant Buffer must be divisible by 16 bytes"); + m_modelConstantBuffer.Allocate(pbrResources.GetDevice().Get()); + + // Set up the transforms buffer. + XrMatrix4x4f identityMatrix; + XrMatrix4x4f_CreateIdentity(&identityMatrix); // or better yet poison it + size_t nodeCount = GetModel().GetNodes().size(); + + // Create/recreate the structured buffer and SRV which holds the node transforms. + UINT elemSize = sizeof(XrMatrix4x4f); + UINT count = (UINT)(nodeCount); + UINT size = (UINT)(count * elemSize); + + m_modelTransformsStructuredBuffer = Conformance::D3D12BufferWithUpload(pbrResources.GetDevice().Get(), size); + + D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc{}; + srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + srvDesc.Format = DXGI_FORMAT_UNKNOWN; + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; + srvDesc.Buffer.NumElements = count; + srvDesc.Buffer.StructureByteStride = elemSize; + + if (m_modelTransformsResourceViewHeap == nullptr) { + D3D12_DESCRIPTOR_HEAP_DESC transformHeapDesc; + transformHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + transformHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + transformHeapDesc.NumDescriptors = ShaderSlots::NumTextures; + transformHeapDesc.NodeMask = 1; + + XRC_CHECK_THROW_HRCMD( + pbrResources.GetDevice()->CreateDescriptorHeap(&transformHeapDesc, IID_PPV_ARGS(&m_modelTransformsResourceViewHeap))); + } + pbrResources.GetDevice()->CreateShaderResourceView( + m_modelTransformsStructuredBuffer.GetResource(), &srvDesc, + CD3DX12_CPU_DESCRIPTOR_HANDLE(m_modelTransformsResourceViewHeap->GetCPUDescriptorHandleForHeapStart())); + } + + void D3D12ModelInstance::UpdateTransforms(Pbr::D3D12Resources& pbrResources) + { // If none of the node transforms have changed, no need to recompute/update the model transform structured buffer. - if (newTotalModifyCount != TotalModifyCount || m_modelTransformsStructuredBufferInvalid) { - if (m_modelTransformsStructuredBufferInvalid) // The structured buffer is reset when a Node is added. - { - XrMatrix4x4f identityMatrix; - XrMatrix4x4f_CreateIdentity(&identityMatrix); // or better yet poison it - m_modelTransforms.resize(nodes.size(), identityMatrix); - - // Create/recreate the structured buffer and SRV which holds the node transforms. - UINT elemSize = sizeof(decltype(m_modelTransforms)::value_type); - UINT count = (UINT)(m_modelTransforms.size()); - UINT size = (UINT)(count * elemSize); - - m_modelTransformsStructuredBuffer = Conformance::D3D12BufferWithUpload(pbrResources.GetDevice().Get(), size); - - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc{}; - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - srvDesc.Format = DXGI_FORMAT_UNKNOWN; - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - srvDesc.Buffer.NumElements = count; - srvDesc.Buffer.StructureByteStride = elemSize; - - if (m_modelTransformsResourceViewHeap == nullptr) { - D3D12_DESCRIPTOR_HEAP_DESC transformHeapDesc; - transformHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; - transformHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - transformHeapDesc.NumDescriptors = ShaderSlots::NumTextures; - transformHeapDesc.NodeMask = 1; - - XRC_CHECK_THROW_HRCMD(pbrResources.GetDevice()->CreateDescriptorHeap(&transformHeapDesc, - IID_PPV_ARGS(&m_modelTransformsResourceViewHeap))); - } - - pbrResources.GetDevice()->CreateShaderResourceView( - m_modelTransformsStructuredBuffer.GetResource(), &srvDesc, - CD3DX12_CPU_DESCRIPTOR_HANDLE(m_modelTransformsResourceViewHeap->GetCPUDescriptorHandleForHeapStart())); - - m_modelTransformsStructuredBufferInvalid = false; - } - - // Nodes are guaranteed to come after their parents, so each node transform can be multiplied by its parent transform in a single pass. - assert(nodes.size() == m_modelTransforms.size()); - XrMatrix4x4f identityMatrix; - XrMatrix4x4f_CreateIdentity(&identityMatrix); - for (const auto& node : nodes) { - assert(node.ParentNodeIndex == RootParentNodeIndex || node.ParentNodeIndex < node.Index); - const XrMatrix4x4f& parentTransform = - (node.ParentNodeIndex == RootParentNodeIndex) ? identityMatrix : m_modelTransforms[node.ParentNodeIndex]; - XrMatrix4x4f nodeTransform = node.GetTransform(); - XrMatrix4x4f nodeTransformTranspose; - XrMatrix4x4f_Transpose(&nodeTransformTranspose, &nodeTransform); - XrMatrix4x4f_Multiply(&m_modelTransforms[node.Index], &nodeTransformTranspose, &parentTransform); - } + if (WereNodeLocalTransformsUpdated()) { + ResolveTransforms(true); // Update node transform structured buffer. + auto& resolvedTransforms = GetResolvedTransforms(); pbrResources.WithCopyCommandList([&](ID3D12GraphicsCommandList* cmdList) { - m_modelTransformsStructuredBuffer.AsyncUpload(cmdList, this->m_modelTransforms.data(), this->m_modelTransforms.size()); + m_modelTransformsStructuredBuffer.AsyncUpload(cmdList, resolvedTransforms.data(), resolvedTransforms.size()); }); - TotalModifyCount = newTotalModifyCount; + ClearTransformsUpdatedFlag(); } } } // namespace Pbr diff --git a/src/conformance/framework/pbr/D3D12/D3D12Model.h b/src/conformance/framework/pbr/D3D12/D3D12Model.h index 39f0e765..caaa6bce 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12Model.h +++ b/src/conformance/framework/pbr/D3D12/D3D12Model.h @@ -1,10 +1,11 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved // Licensed under the MIT License. See License.txt in the project root for license information. // // SPDX-License-Identifier: MIT AND Apache-2.0 + #pragma once #include "D3D12Resources.h" @@ -16,22 +17,30 @@ namespace Pbr struct D3D12Primitive; - class D3D12Model final : public Model + struct ModelConstantBuffer + { + DirectX::XMFLOAT4X4 ModelToWorld; + }; + + static_assert((sizeof(ModelConstantBuffer) % 16) == 0, "Constant Buffer must be divisible by 16 bytes"); + + class D3D12ModelInstance final : public ModelInstance { public: - // Render the model. + D3D12ModelInstance(Pbr::D3D12Resources& pbrResources, std::shared_ptr model); + + /// Render the model. void Render(Pbr::D3D12Resources& pbrResources, _In_ ID3D12GraphicsCommandList* directCommandList, - DXGI_FORMAT colorRenderTargetFormat, DXGI_FORMAT depthRenderTargetFormat); + DXGI_FORMAT colorRenderTargetFormat, DXGI_FORMAT depthRenderTargetFormat, DirectX::FXMMATRIX modelToWorld); private: - // Updated the transforms used to render the model. This needs to be called any time a node transform is changed. + /// Update the transforms used to render the model. This needs to be called any time a node transform is changed. void UpdateTransforms(Pbr::D3D12Resources& pbrResources); - // Temporary buffer holds the world transforms, computed from the node's local transforms. - mutable std::vector m_modelTransforms; - mutable Conformance::D3D12BufferWithUpload m_modelTransformsStructuredBuffer; - mutable Microsoft::WRL::ComPtr m_modelTransformsResourceViewHeap; + ModelConstantBuffer m_modelBuffer; + Conformance::D3D12BufferWithUpload m_modelConstantBuffer; - mutable uint32_t TotalModifyCount{0}; + Conformance::D3D12BufferWithUpload m_modelTransformsStructuredBuffer; + Microsoft::WRL::ComPtr m_modelTransformsResourceViewHeap; }; } // namespace Pbr diff --git a/src/conformance/framework/pbr/D3D12/D3D12PipelineStates.cpp b/src/conformance/framework/pbr/D3D12/D3D12PipelineStates.cpp index 6a26ac6f..c5264e9e 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12PipelineStates.cpp +++ b/src/conformance/framework/pbr/D3D12/D3D12PipelineStates.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // diff --git a/src/conformance/framework/pbr/D3D12/D3D12PipelineStates.h b/src/conformance/framework/pbr/D3D12/D3D12PipelineStates.h index c59b3eaf..1138cfba 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12PipelineStates.h +++ b/src/conformance/framework/pbr/D3D12/D3D12PipelineStates.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -8,6 +8,7 @@ // SPDX-License-Identifier: MIT AND Apache-2.0 #pragma once + #include "../PbrSharedState.h" #include @@ -49,17 +50,6 @@ namespace Pbr BlendState blendState, DoubleSided doubleSided, DepthDirection depthDirection); - // void DropStates() - // { - // m_pipelineStates.clear(); - // } - // void Reset(Microsoft::WRL::ComPtr rootSignature = nullptr) - // { - // DropStates(); - // m_rootSignature = std::move(rootSignature); - // m_basePipelineStateDesc.pRootSignature = m_rootSignature.Get(); - // } - private: using PipelineStateKey = std::tuple; diff --git a/src/conformance/framework/pbr/D3D12/D3D12Primitive.cpp b/src/conformance/framework/pbr/D3D12/D3D12Primitive.cpp index ad80f334..186a6272 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12Primitive.cpp +++ b/src/conformance/framework/pbr/D3D12/D3D12Primitive.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/D3D12/D3D12Primitive.h b/src/conformance/framework/pbr/D3D12/D3D12Primitive.h index 769babdd..26b6f383 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12Primitive.h +++ b/src/conformance/framework/pbr/D3D12/D3D12Primitive.h @@ -1,10 +1,11 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved // Licensed under the MIT License. See License.txt in the project root for license information. // // SPDX-License-Identifier: MIT AND Apache-2.0 + #pragma once #include "D3D12Material.h" @@ -12,11 +13,12 @@ #include #include // For Microsoft::WRL::ComPtr +#include #include namespace Pbr { - // A primitive holds a vertex buffer, index buffer, and a pointer to a PBR material. + /// A primitive holds a vertex buffer, index buffer, and a pointer to a PBR material. struct D3D12Primitive final { using Collection = std::vector; @@ -29,25 +31,20 @@ namespace Pbr void UpdateBuffers(Pbr::D3D12Resources& pbrResources, const Pbr::PrimitiveBuilder& primitiveBuilder); - // Get the material for the primitive. - std::shared_ptr& GetMaterial() - { - return m_material; - } + /// Get the material for the primitive. const std::shared_ptr& GetMaterial() const { return m_material; } - // Replace the material for the primitive + /// Replace the material for the primitive void SetMaterial(std::shared_ptr material) { m_material = std::move(material); } protected: - // friend class Model; - friend class D3D12Model; + friend class D3D12ModelInstance; void Render(_In_ ID3D12GraphicsCommandList* directCommandList, D3D12Resources& pbrResources, DXGI_FORMAT colorRenderTargetFormat, DXGI_FORMAT depthRenderTargetFormat) const; diff --git a/src/conformance/framework/pbr/D3D12/D3D12Resources.cpp b/src/conformance/framework/pbr/D3D12/D3D12Resources.cpp index e2cd5150..5dc50e8f 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12Resources.cpp +++ b/src/conformance/framework/pbr/D3D12/D3D12Resources.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -58,13 +58,6 @@ namespace static_assert(offsetof(SceneConstantBuffer, LightDiffuseColor) == 96, "Offsets must match shader"); static_assert(offsetof(SceneConstantBuffer, NumSpecularMipLevels) == 112, "Offsets must match shader"); - struct ModelConstantBuffer - { - DirectX::XMFLOAT4X4 ModelToWorld; - }; - - static_assert((sizeof(ModelConstantBuffer) % 16) == 0, "Constant Buffer must be divisible by 16 bytes"); - const D3D12_INPUT_ELEMENT_DESC s_vertexDesc[6] = { {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, @@ -158,13 +151,10 @@ namespace Pbr Resources.PipelineStates = std::make_unique(Resources.RootSignature, basePipelineStateDesc, s_vertexDesc, g_PbrVertexShader, g_PbrPixelShader); - // Set up the constant buffers. + // Set up the scene constant buffer. static_assert((sizeof(SceneConstantBuffer) % 16) == 0, "Constant Buffer must be divisible by 16 bytes"); Resources.SceneConstantBuffer.Allocate(device); - static_assert((sizeof(ModelConstantBuffer) % 16) == 0, "Constant Buffer must be divisible by 16 bytes"); - Resources.ModelConstantBuffer.Allocate(device); - D3D12_DESCRIPTOR_HEAP_DESC transformHeapDesc; transformHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; transformHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; @@ -176,32 +166,32 @@ namespace Pbr D3D12_DESCRIPTOR_HEAP_DESC textureHeapDesc; textureHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; textureHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - textureHeapDesc.NumDescriptors = ShaderSlots::NumTextures - ShaderSlots::NumMaterialSlots; + textureHeapDesc.NumDescriptors = (int)ShaderSlots::NumTextures - (int)ShaderSlots::NumMaterialSlots; textureHeapDesc.NodeMask = 1; XRC_CHECK_THROW_HRCMD(device->CreateDescriptorHeap(&textureHeapDesc, IID_PPV_ARGS(&Resources.TextureHeap))); UINT textureDescriptorSize = device->GetDescriptorHandleIncrementSize(textureHeapDesc.Type); CD3DX12_CPU_DESCRIPTOR_HANDLE textureBaseHandle(Resources.TextureHeap->GetCPUDescriptorHandleForHeapStart()); Resources.BrdfLutTextureDescriptor = CD3DX12_CPU_DESCRIPTOR_HANDLE( // - textureBaseHandle, ShaderSlots::Brdf - ShaderSlots::NumMaterialSlots, textureDescriptorSize); + textureBaseHandle, (int)ShaderSlots::Brdf - (int)ShaderSlots::NumMaterialSlots, textureDescriptorSize); Resources.SpecularEnvMapTextureDescriptor = CD3DX12_CPU_DESCRIPTOR_HANDLE( // - textureBaseHandle, ShaderSlots::SpecularTexture - ShaderSlots::NumMaterialSlots, textureDescriptorSize); + textureBaseHandle, (int)ShaderSlots::SpecularTexture - (int)ShaderSlots::NumMaterialSlots, textureDescriptorSize); Resources.DiffuseEnvMapTextureDescriptor = CD3DX12_CPU_DESCRIPTOR_HANDLE( // - textureBaseHandle, ShaderSlots::DiffuseTexture - ShaderSlots::NumMaterialSlots, textureDescriptorSize); + textureBaseHandle, (int)ShaderSlots::DiffuseTexture - (int)ShaderSlots::NumMaterialSlots, textureDescriptorSize); D3D12_DESCRIPTOR_HEAP_DESC samplerHeapDesc; samplerHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER; samplerHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - samplerHeapDesc.NumDescriptors = ShaderSlots::NumSamplers - ShaderSlots::NumMaterialSlots; + samplerHeapDesc.NumDescriptors = (int)ShaderSlots::NumSamplers - (int)ShaderSlots::NumMaterialSlots; samplerHeapDesc.NodeMask = 1; XRC_CHECK_THROW_HRCMD(device->CreateDescriptorHeap(&samplerHeapDesc, IID_PPV_ARGS(&Resources.SamplerHeap))); UINT samplerDescriptorSize = device->GetDescriptorHandleIncrementSize(samplerHeapDesc.Type); CD3DX12_CPU_DESCRIPTOR_HANDLE samplerBaseHandle(Resources.SamplerHeap->GetCPUDescriptorHandleForHeapStart()); Resources.BrdfSamplerDescriptor = CD3DX12_CPU_DESCRIPTOR_HANDLE( // - samplerBaseHandle, ShaderSlots::Brdf - ShaderSlots::NumMaterialSlots, samplerDescriptorSize); + samplerBaseHandle, (int)ShaderSlots::Brdf - (int)ShaderSlots::NumMaterialSlots, samplerDescriptorSize); Resources.EnvironmentMapSamplerDescriptor = CD3DX12_CPU_DESCRIPTOR_HANDLE( // - samplerBaseHandle, ShaderSlots::EnvironmentMapSampler - ShaderSlots::NumMaterialSlots, samplerDescriptorSize); + samplerBaseHandle, (int)ShaderSlots::EnvironmentMapSampler - (int)ShaderSlots::NumMaterialSlots, samplerDescriptorSize); D3D12Texture::CreateSampler(device, Resources.BrdfSamplerDescriptor); D3D12Texture::CreateSampler(device, Resources.EnvironmentMapSamplerDescriptor); @@ -241,7 +231,6 @@ namespace Pbr D3D12_CPU_DESCRIPTOR_HANDLE EnvironmentMapSamplerDescriptor; Microsoft::WRL::ComPtr RootSignature; Conformance::D3D12BufferWithUpload SceneConstantBuffer; - Conformance::D3D12BufferWithUpload ModelConstantBuffer; std::unique_ptr PipelineStates{}; mutable D3D12TextureCache SolidColorTextureCache; }; @@ -250,7 +239,6 @@ namespace Pbr D3D12_GRAPHICS_PIPELINE_STATE_DESC BasePipelineStateDesc; DeviceResources Resources; SceneConstantBuffer SceneBuffer; - ModelConstantBuffer ModelBuffer; struct LoaderResources { @@ -338,7 +326,7 @@ namespace Pbr return filter; } - // Create a DirectX sampler state from a tinygltf Sampler. + /// Create a DirectX sampler state from a tinygltf Sampler. static D3D12_SAMPLER_DESC CreateGLTFSampler(_In_ ID3D12Device* /*device*/, const tinygltf::Sampler& sampler) { D3D12_SAMPLER_DESC samplerDesc{}; @@ -392,6 +380,7 @@ namespace Pbr pbrMaterial->SetTexture(GetDevice().Get(), slot, *textureView, samplerState.get()); } + void D3D12Resources::DropLoaderCaches() { m_impl->loaderResources = {}; @@ -455,10 +444,10 @@ namespace Pbr void D3D12Resources::GetGlobalTexturesAndSamplers(D3D12_CPU_DESCRIPTOR_HANDLE destTextureDescriptors, D3D12_CPU_DESCRIPTOR_HANDLE destSamplerDescriptors) { - GetDevice()->CopyDescriptorsSimple(ShaderSlots::NumTextures - ShaderSlots::NumMaterialSlots, destTextureDescriptors, + GetDevice()->CopyDescriptorsSimple((int)ShaderSlots::NumTextures - (int)ShaderSlots::NumMaterialSlots, destTextureDescriptors, m_impl->Resources.TextureHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - GetDevice()->CopyDescriptorsSimple(ShaderSlots::NumSamplers - ShaderSlots::NumMaterialSlots, destSamplerDescriptors, + GetDevice()->CopyDescriptorsSimple((int)ShaderSlots::NumSamplers - (int)ShaderSlots::NumMaterialSlots, destSamplerDescriptors, m_impl->Resources.SamplerHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); } @@ -478,13 +467,6 @@ namespace Pbr m_impl->SceneBuffer.LightDiffuseColor = {diffuseColor.x, diffuseColor.y, diffuseColor.z}; } - void XM_CALLCONV D3D12Resources::SetModelToWorld(DirectX::FXMMATRIX modelToWorld) const - { - XMStoreFloat4x4(&m_impl->ModelBuffer.ModelToWorld, XMMatrixTranspose(modelToWorld)); - WithCopyCommandList( - [&](ID3D12GraphicsCommandList* cmdList) { m_impl->Resources.ModelConstantBuffer.AsyncUpload(cmdList, &m_impl->ModelBuffer); }); - } - void XM_CALLCONV D3D12Resources::SetViewProjection(DirectX::FXMMATRIX view, DirectX::CXMMATRIX projection) const { XMStoreFloat4x4(&m_impl->SceneBuffer.ViewProjection, XMMatrixTranspose(XMMatrixMultiply(view, projection))); @@ -523,11 +505,14 @@ namespace Pbr WithCopyCommandList( [&](ID3D12GraphicsCommandList* cmdList) { m_impl->Resources.SceneConstantBuffer.AsyncUpload(cmdList, &m_impl->SceneBuffer); }); + } + void D3D12Resources::BindConstantBufferViews(_In_ ID3D12GraphicsCommandList* directCommandList, + D3D12_GPU_VIRTUAL_ADDRESS modelConstantBufferAddress) const + { directCommandList->SetGraphicsRootConstantBufferView(ShaderSlots::ConstantBuffers::Scene, m_impl->Resources.SceneConstantBuffer.GetResource()->GetGPUVirtualAddress()); - directCommandList->SetGraphicsRootConstantBufferView(ShaderSlots::ConstantBuffers::Model, - m_impl->Resources.ModelConstantBuffer.GetResource()->GetGPUVirtualAddress()); + directCommandList->SetGraphicsRootConstantBufferView(ShaderSlots::ConstantBuffers::Model, modelConstantBufferAddress); } void D3D12Resources::BindDescriptorHeaps(_In_ ID3D12GraphicsCommandList* directCommandList, ID3D12DescriptorHeap* srvDescriptorHeap, diff --git a/src/conformance/framework/pbr/D3D12/D3D12Resources.h b/src/conformance/framework/pbr/D3D12/D3D12Resources.h index 791a4fc5..7ea37271 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12Resources.h +++ b/src/conformance/framework/pbr/D3D12/D3D12Resources.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -42,7 +42,7 @@ namespace Pbr bool samplerSet; }; - // Global PBR resources required for rendering a scene. + /// Global PBR resources required for rendering a scene. struct D3D12Resources final : public IResources { D3D12Resources(_In_ ID3D12Device* device, const D3D12_GRAPHICS_PIPELINE_STATE_DESC& basePipelineStateDesc); @@ -61,23 +61,23 @@ namespace Pbr const std::shared_ptr& material) override; void DropLoaderCaches() override; - // Sets the Bidirectional Reflectance Distribution Function Lookup Table texture, required by the shader to compute surface - // reflectance from the IBL. + /// Sets the Bidirectional Reflectance Distribution Function Lookup Table texture, required by the shader to compute surface + /// reflectance from the IBL. void SetBrdfLut(_In_ Conformance::D3D12ResourceWithSRVDesc brdfLut); - // Create device-dependent resources. + /// Create device-dependent resources. void CreateDeviceDependentResources(_In_ ID3D12Device* device); - // Release device-dependent resources. + /// Release device-dependent resources. void ReleaseDeviceDependentResources(); - // Get the D3D12Device that the PBR resources are associated with. + /// Get the D3D12Device that the PBR resources are associated with. Microsoft::WRL::ComPtr GetDevice() const; - // Create a new copy command list, which can later be executed with ExecuteCopyCommandList + /// Create a new copy command list, which can later be executed with ExecuteCopyCommandList Microsoft::WRL::ComPtr CreateCopyCommandList() const; - // Execute a copy command list on the internal copy queue, which can be waited on using GetFenceAndValue + /// Execute a copy command list on the internal copy queue, which can be waited on using GetFenceAndValue void ExecuteCopyCommandList(ID3D12GraphicsCommandList* cmdList, std::vector> destroyAfterCopy = {}) const; @@ -94,35 +94,35 @@ namespace Pbr ExecuteCopyCommandList(cmdList.Get()); } - // Get a pipeline state matching some parameters as well as the current settings inside D3D12Resources. + /// Get a pipeline state matching some parameters as well as the current settings inside D3D12Resources. Microsoft::WRL::ComPtr GetOrCreatePipelineState(DXGI_FORMAT colorRenderTargetFormat, DXGI_FORMAT depthRenderTargetFormat, BlendState blendState, DoubleSided doubleSided); - // Set the directional light. + /// Set the directional light. void SetLight(DirectX::XMFLOAT3 direction, RGBColor diffuseColor); - // Set the specular and diffuse image-based lighting (IBL) maps. ShaderResourceViews must be TextureCubes. + /// Set the specular and diffuse image-based lighting (IBL) maps. ShaderResourceViews must be TextureCubes. void SetEnvironmentMap(_In_ Conformance::D3D12ResourceWithSRVDesc specularEnvironmentMap, _In_ Conformance::D3D12ResourceWithSRVDesc diffuseEnvironmentMap); - // Set the current view and projection matrices. + /// Set the current view and projection matrices. void XM_CALLCONV SetViewProjection(DirectX::FXMMATRIX view, DirectX::CXMMATRIX projection) const; - // Many 1x1 pixel colored textures are used in the PBR system. This is used to create textures backed by a cache to reduce the - // number of textures created. + /// Many 1x1 pixel colored textures are used in the PBR system. This is used to create textures backed by a cache to reduce the + /// number of textures created. Conformance::D3D12ResourceWithSRVDesc CreateTypedSolidColorTexture(RGBAColor color); - // Bind the the PBR resources to the current context. + /// Bind the the PBR resources to the current context. void Bind(_In_ ID3D12GraphicsCommandList* directCommandList) const; - // Get the fence to wait on before executing any command list built on this Resources. + /// Get the fence to wait on before executing any command list built on this Resources. std::pair GetFenceAndValue() const; - // Set and update the model to world constant buffer value. - void XM_CALLCONV SetModelToWorld(DirectX::FXMMATRIX modelToWorld) const; - + /// Get the D3D12Primitive from a primitive handle. D3D12Primitive& GetPrimitive(PrimitiveHandle p); + + /// Get the D3D12Primitive from a primitive handle, const overload. const D3D12Primitive& GetPrimitive(PrimitiveHandle p) const; // Set or get the shading and fill modes. @@ -137,12 +137,15 @@ namespace Pbr void GetTransforms(D3D12_CPU_DESCRIPTOR_HANDLE destTransformDescriptor); void GetGlobalTexturesAndSamplers(D3D12_CPU_DESCRIPTOR_HANDLE destTextureDescriptors, D3D12_CPU_DESCRIPTOR_HANDLE destSamplerDescriptors); - // Bind a material's descriptors according to the root signature. + // Bind the scene constant buffer as well as a provided model constant buffer. + void BindConstantBufferViews(_In_ ID3D12GraphicsCommandList* directCommandList, + D3D12_GPU_VIRTUAL_ADDRESS modelConstantBufferAddress) const; + /// Bind a material's descriptors according to the root signature. void BindDescriptorHeaps(_In_ ID3D12GraphicsCommandList* directCommandList, ID3D12DescriptorHeap* srvDescriptorHeap, ID3D12DescriptorHeap* samplerDescriptorHeap) const; friend struct D3D12Material; - friend class D3D12Model; + friend class D3D12ModelInstance; friend struct D3D12Primitive; struct Impl; diff --git a/src/conformance/framework/pbr/D3D12/D3D12Texture.cpp b/src/conformance/framework/pbr/D3D12/D3D12Texture.cpp index de17b3fc..5a0b4af2 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12Texture.cpp +++ b/src/conformance/framework/pbr/D3D12/D3D12Texture.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/D3D12/D3D12Texture.h b/src/conformance/framework/pbr/D3D12/D3D12Texture.h index b907257a..3a96198d 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12Texture.h +++ b/src/conformance/framework/pbr/D3D12/D3D12Texture.h @@ -1,13 +1,11 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: +// // Copyright (C) Microsoft Corporation. All Rights Reserved // Licensed under the MIT License. See License.txt in the project root for license information. // // SPDX-License-Identifier: MIT AND Apache-2.0 -// -// Shared data types and functions used throughout the Pbr rendering library. -// #pragma once @@ -22,7 +20,6 @@ #include // For Microsoft::WRL::ComPtr #include -#include namespace Pbr { diff --git a/src/conformance/framework/pbr/D3D12/D3D12TextureCache.cpp b/src/conformance/framework/pbr/D3D12/D3D12TextureCache.cpp index a2624ba0..48bce765 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12TextureCache.cpp +++ b/src/conformance/framework/pbr/D3D12/D3D12TextureCache.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // diff --git a/src/conformance/framework/pbr/D3D12/D3D12TextureCache.h b/src/conformance/framework/pbr/D3D12/D3D12TextureCache.h index 1bcbb4ba..37783cc5 100644 --- a/src/conformance/framework/pbr/D3D12/D3D12TextureCache.h +++ b/src/conformance/framework/pbr/D3D12/D3D12TextureCache.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -23,7 +23,6 @@ namespace Pbr { template using ComPtr = Microsoft::WRL::ComPtr; - // using Microsoft::WRL::ComPtr; /// Cache of single-color textures. /// @@ -34,9 +33,6 @@ namespace Pbr /// Default constructor makes an invalid cache. D3D12TextureCache() = default; - // D3D12TextureCache(const D3D12TextureCache&) = default; - // D3D12TextureCache& operator=(const D3D12TextureCache&) = default; - D3D12TextureCache(D3D12TextureCache&&) = default; D3D12TextureCache& operator=(D3D12TextureCache&&) = default; diff --git a/src/conformance/framework/pbr/GlslBuffers.h b/src/conformance/framework/pbr/GlslBuffers.h index 32cb1708..21a0c3fe 100644 --- a/src/conformance/framework/pbr/GlslBuffers.h +++ b/src/conformance/framework/pbr/GlslBuffers.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/GltfLoader.cpp b/src/conformance/framework/pbr/GltfLoader.cpp index 9ba77080..70049669 100644 --- a/src/conformance/framework/pbr/GltfLoader.cpp +++ b/src/conformance/framework/pbr/GltfLoader.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -101,9 +101,6 @@ namespace Gltf { void PopulateFromGltfObject(Pbr::Model& model, Pbr::IResources& pbrResources, const tinygltf::Model& gltfModel) { - // Empty the model to ensure we're starting from scratch - model.Clear(); - // Read and transform mesh/node data. Primitives with the same material are merged to reduce draw calls. PrimitiveBuilderMap primitiveBuilderMap; GltfHelper::PrimitiveCache primitiveCache{gltfModel}; diff --git a/src/conformance/framework/pbr/GltfLoader.h b/src/conformance/framework/pbr/GltfLoader.h index 5fedadf8..24fb638f 100644 --- a/src/conformance/framework/pbr/GltfLoader.h +++ b/src/conformance/framework/pbr/GltfLoader.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -37,31 +37,25 @@ namespace Gltf void PopulateFromGltfBinary(Pbr::Model& model, Pbr::IResources& pbrResources, const uint8_t* buffer, uint32_t bufferBytes); // Creates a Pbr Model from tinygltf model. - template - std::shared_ptr FromGltfObject(Pbr::IResources& pbrResources, const tinygltf::Model& gltfModel) + inline std::shared_ptr FromGltfObject(Pbr::IResources& pbrResources, const tinygltf::Model& gltfModel) { - static_assert(std::is_base_of::value, "DerivedModel not derived from Pbr::Model"); - // Start off with an empty Model. - auto model = std::make_shared(); + auto model = std::make_shared(); PopulateFromGltfObject(*model, pbrResources, gltfModel); return model; } // Creates a Pbr Model from glTF 2.0 GLB file content. - template - std::shared_ptr FromGltfBinary(Pbr::IResources& pbrResources, const uint8_t* buffer, uint32_t bufferBytes) + inline std::shared_ptr FromGltfBinary(Pbr::IResources& pbrResources, const uint8_t* buffer, uint32_t bufferBytes) { - static_assert(std::is_base_of::value, "DerivedModel not derived from Pbr::Model"); - // Start off with an empty Model. - auto model = std::make_shared(); + auto model = std::make_shared(); PopulateFromGltfBinary(*model, pbrResources, buffer, bufferBytes); return model; } - template - std::shared_ptr FromGltfBinary(Pbr::IResources& pbrResources, const Container& buffer) + template + std::shared_ptr FromGltfBinary(Pbr::IResources& pbrResources, const Container& buffer) { return FromGltfBinary(pbrResources, buffer.data(), static_cast(buffer.size())); } diff --git a/src/conformance/framework/pbr/IResources.h b/src/conformance/framework/pbr/IResources.h index 7def6115..e37e3b3c 100644 --- a/src/conformance/framework/pbr/IResources.h +++ b/src/conformance/framework/pbr/IResources.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/OpenGL/GLCommon.h b/src/conformance/framework/pbr/OpenGL/GLCommon.h index c4bcb906..4524e8f1 100644 --- a/src/conformance/framework/pbr/OpenGL/GLCommon.h +++ b/src/conformance/framework/pbr/OpenGL/GLCommon.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // diff --git a/src/conformance/framework/pbr/OpenGL/GLMaterial.cpp b/src/conformance/framework/pbr/OpenGL/GLMaterial.cpp index f8771fad..3fed9f6e 100644 --- a/src/conformance/framework/pbr/OpenGL/GLMaterial.cpp +++ b/src/conformance/framework/pbr/OpenGL/GLMaterial.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/OpenGL/GLMaterial.h b/src/conformance/framework/pbr/OpenGL/GLMaterial.h index 8b7b6e0a..193ed6b3 100644 --- a/src/conformance/framework/pbr/OpenGL/GLMaterial.h +++ b/src/conformance/framework/pbr/OpenGL/GLMaterial.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -17,37 +17,34 @@ #include "common/gfxwrapper_opengl.h" #include -#include #include #include #include -#include namespace Pbr { struct GLResources; - // A GLMaterial contains the metallic roughness parameters and textures. - // Primitives specify which GLMaterial to use when being rendered. + /// A GLMaterial contains the metallic roughness parameters and textures. + /// Primitives specify which GLMaterial to use when being rendered. struct GLMaterial final : public Material { - // Create a uninitialized material. Textures and shader coefficients must be set. + /// Create a uninitialized material. Textures and shader coefficients must be set. GLMaterial(Pbr::GLResources const& pbrResources); - // Create a clone of this material. + /// Create a clone of this material. std::shared_ptr Clone(Pbr::GLResources const& pbrResources) const; - // Create a flat (no texture) material. + /// Create a flat (no texture) material. static std::shared_ptr CreateFlat(const GLResources& pbrResources, RGBAColor baseColorFactor, float roughnessFactor = 1.0f, float metallicFactor = 0.0f, RGBColor emissiveFactor = RGB::Black); - // Set a Metallic-Roughness texture. + /// Set a Metallic-Roughness texture. void SetTexture(ShaderSlots::PSMaterial slot, std::shared_ptr textureView, std::shared_ptr sampler = nullptr); - // void SetTexture(ShaderSlots::PSMaterial slot, ITexture& texture) override; - // Bind this material to current context. + /// Bind this material to current context. void Bind(const GLResources& pbrResources) const; std::string Name; diff --git a/src/conformance/framework/pbr/OpenGL/GLModel.cpp b/src/conformance/framework/pbr/OpenGL/GLModel.cpp index f21c6509..9e80598f 100644 --- a/src/conformance/framework/pbr/OpenGL/GLModel.cpp +++ b/src/conformance/framework/pbr/OpenGL/GLModel.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -15,6 +15,7 @@ #include "GLPrimitive.h" #include "GLResources.h" +#include "../GlslBuffers.h" #include "../PbrHandles.h" #include "../PbrModel.h" #include "../PbrSharedState.h" @@ -22,22 +23,27 @@ #include "common/gfxwrapper_opengl.h" #include "utilities/opengl_utils.h" -#include -#include -#include #include namespace Pbr { - void GLModel::Render(Pbr::GLResources const& pbrResources) + void GLModelInstance::Render(Pbr::GLResources const& pbrResources, XrMatrix4x4f modelToWorld) { + // Update model buffer + m_modelBuffer.ModelToWorld = modelToWorld; + XRC_CHECK_THROW_GLCMD(glBindBuffer(GL_UNIFORM_BUFFER, m_modelConstantBuffer.get())); + XRC_CHECK_THROW_GLCMD(glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(Glsl::ModelConstantBuffer), &m_modelBuffer)); + // Bind model buffer + XRC_CHECK_THROW_GLCMD(glBindBufferBase(GL_UNIFORM_BUFFER, ShaderSlots::ConstantBuffers::Model, m_modelConstantBuffer.get())); + UpdateTransforms(pbrResources); - XRC_CHECK_THROW_GLCMD(glBindBufferBase(GL_SHADER_STORAGE_BUFFER, ShaderSlots::GLSL::VSResourceViewsOffset + ShaderSlots::Transforms, + XRC_CHECK_THROW_GLCMD(glBindBufferBase(GL_SHADER_STORAGE_BUFFER, + (int)ShaderSlots::GLSL::VSResourceViewsOffset + (int)ShaderSlots::Transforms, m_modelTransformsStructuredBuffer.get())); - for (PrimitiveHandle primitiveHandle : GetPrimitives()) { + for (PrimitiveHandle primitiveHandle : GetModel().GetPrimitiveHandles()) { const Pbr::GLPrimitive& primitive = pbrResources.GetPrimitive(primitiveHandle); if (primitive.GetMaterial()->Hidden) continue; @@ -45,55 +51,44 @@ namespace Pbr primitive.GetMaterial()->Bind(pbrResources); primitive.Render(pbrResources.GetFillMode()); } - - // Expect the caller to reset other state, but the geometry shader is cleared specially. - //context->GSSetShader(nullptr, nullptr, 0); } - void GLModel::UpdateTransforms(Pbr::GLResources const& /* pbrResources */) + GLModelInstance::GLModelInstance(Pbr::GLResources& /* pbrResources */, std::shared_ptr model) + : ModelInstance(std::move(model)) { - const auto& nodes = GetNodes(); - const uint32_t newTotalModifyCount = std::accumulate(nodes.begin(), nodes.end(), 0, [](uint32_t sumChangeCount, const Node& node) { - return sumChangeCount + node.GetModifyCount(); - }); + // Set up the model constant buffer. + XRC_CHECK_THROW_GLCMD(glGenBuffers(1, m_modelConstantBuffer.resetAndPut())); + XRC_CHECK_THROW_GLCMD(glBindBuffer(GL_UNIFORM_BUFFER, m_modelConstantBuffer.get())); + XRC_CHECK_THROW_GLCMD(glBufferData(GL_UNIFORM_BUFFER, sizeof(Glsl::ModelConstantBuffer), nullptr, GL_DYNAMIC_DRAW)); + + // Set up the transforms buffer. + XrMatrix4x4f identityMatrix; + XrMatrix4x4f_CreateIdentity(&identityMatrix); // or better yet poison it + size_t nodeCount = GetModel().GetNodes().size(); + + size_t elemSize = sizeof(XrMatrix4x4f); + size_t count = nodeCount; + size_t size = count * elemSize; + + XRC_CHECK_THROW_GLCMD(glGenBuffers(1, m_modelTransformsStructuredBuffer.resetAndPut())); + XRC_CHECK_THROW_GLCMD(glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_modelTransformsStructuredBuffer.get())); + XRC_CHECK_THROW_GLCMD(glBufferData(GL_SHADER_STORAGE_BUFFER, size, nullptr, GL_DYNAMIC_DRAW)); + } + void GLModelInstance::UpdateTransforms(Pbr::GLResources const& /* pbrResources */) + { // If none of the node transforms have changed, no need to recompute/update the model transform structured buffer. - if (newTotalModifyCount != TotalModifyCount || m_modelTransformsStructuredBufferInvalid) { - if (m_modelTransformsStructuredBufferInvalid) // The structured buffer is reset when a Node is added. - { - XrMatrix4x4f identityMatrix; - XrMatrix4x4f_CreateIdentity(&identityMatrix); // or better yet poison it - m_modelTransforms.resize(nodes.size(), identityMatrix); - - size_t elemSize = sizeof(decltype(m_modelTransforms)::value_type); - XRC_CHECK_THROW_GLCMD(glGenBuffers(1, m_modelTransformsStructuredBuffer.resetAndPut())); - XRC_CHECK_THROW_GLCMD(glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_modelTransformsStructuredBuffer.get())); - XRC_CHECK_THROW_GLCMD( - glBufferData(GL_SHADER_STORAGE_BUFFER, elemSize * m_modelTransforms.size(), m_modelTransforms.data(), GL_DYNAMIC_DRAW)); - - m_modelTransformsStructuredBufferInvalid = false; - } - - // Nodes are guaranteed to come after their parents, so each node transform can be multiplied by its parent transform in a single pass. - assert(nodes.size() == m_modelTransforms.size()); - XrMatrix4x4f identityMatrix; - XrMatrix4x4f_CreateIdentity(&identityMatrix); - for (const auto& node : nodes) { - assert(node.ParentNodeIndex == RootParentNodeIndex || node.ParentNodeIndex < node.Index); - const XrMatrix4x4f& parentTransform = - (node.ParentNodeIndex == RootParentNodeIndex) ? identityMatrix : m_modelTransforms[node.ParentNodeIndex]; - XrMatrix4x4f nodeTransform = node.GetTransform(); - XrMatrix4x4f_Multiply(&m_modelTransforms[node.Index], &parentTransform, &nodeTransform); - } + if (WereNodeLocalTransformsUpdated()) { + ResolveTransforms(false); // Update node transform structured buffer. + auto& resolvedTransforms = GetResolvedTransforms(); XRC_CHECK_THROW_GLCMD(glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_modelTransformsStructuredBuffer.get())); - XRC_CHECK_THROW_GLCMD(glBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, - sizeof(decltype(m_modelTransforms)::value_type) * m_modelTransforms.size(), - this->m_modelTransforms.data())); - TotalModifyCount = newTotalModifyCount; + XRC_CHECK_THROW_GLCMD( + glBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, sizeof(XrMatrix4x4f) * resolvedTransforms.size(), resolvedTransforms.data())); + ClearTransformsUpdatedFlag(); } } } // namespace Pbr -#endif +#endif // defined(XR_USE_GRAPHICS_API_OPENGL) || defined(XR_USE_GRAPHICS_API_OPENGL_ES) diff --git a/src/conformance/framework/pbr/OpenGL/GLModel.h b/src/conformance/framework/pbr/OpenGL/GLModel.h index 6c5f7341..d377b2b0 100644 --- a/src/conformance/framework/pbr/OpenGL/GLModel.h +++ b/src/conformance/framework/pbr/OpenGL/GLModel.h @@ -1,42 +1,40 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved // Licensed under the MIT License. See License.txt in the project root for license information. // // SPDX-License-Identifier: MIT AND Apache-2.0 + #pragma once #include "GLCommon.h" #include "GLResources.h" +#include "../GlslBuffers.h" #include "../PbrHandles.h" #include "../PbrModel.h" -#include "common/xr_linear.h" - -#include -#include - namespace Pbr { struct GLPrimitive; struct GLResources; - class GLModel final : public Model + class GLModelInstance final : public ModelInstance { public: - // Render the model. - void Render(Pbr::GLResources const& pbrResources); + GLModelInstance(Pbr::GLResources& pbrResources, std::shared_ptr model); + + /// Render the model. + void Render(Pbr::GLResources const& pbrResources, XrMatrix4x4f modelToWorld); private: - // Updated the transforms used to render the model. This needs to be called any time a node transform is changed. + /// Update the transforms used to render the model. This needs to be called any time a node transform is changed. void UpdateTransforms(Pbr::GLResources const& pbrResources); - // Temporary buffer holds the world transforms, computed from the node's local transforms. - mutable std::vector m_modelTransforms; - mutable ScopedGLBuffer m_modelTransformsStructuredBuffer; + Glsl::ModelConstantBuffer m_modelBuffer; + ScopedGLBuffer m_modelConstantBuffer; - mutable uint32_t TotalModifyCount{0}; + ScopedGLBuffer m_modelTransformsStructuredBuffer; }; } // namespace Pbr diff --git a/src/conformance/framework/pbr/OpenGL/GLPrimitive.cpp b/src/conformance/framework/pbr/OpenGL/GLPrimitive.cpp index 7c97335e..813e9782 100644 --- a/src/conformance/framework/pbr/OpenGL/GLPrimitive.cpp +++ b/src/conformance/framework/pbr/OpenGL/GLPrimitive.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -176,4 +176,4 @@ namespace Pbr } } // namespace Pbr -#endif \ No newline at end of file +#endif // defined(XR_USE_GRAPHICS_API_OPENGL) || defined(XR_USE_GRAPHICS_API_OPENGL_ES) diff --git a/src/conformance/framework/pbr/OpenGL/GLPrimitive.h b/src/conformance/framework/pbr/OpenGL/GLPrimitive.h index b716ed77..5d948470 100644 --- a/src/conformance/framework/pbr/OpenGL/GLPrimitive.h +++ b/src/conformance/framework/pbr/OpenGL/GLPrimitive.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -23,7 +23,7 @@ namespace Pbr struct GLMaterial; struct PrimitiveBuilder; - // A primitive holds a vertex buffer, index buffer, and a pointer to a PBR material. + /// A primitive holds a vertex buffer, index buffer, and a pointer to a PBR material. struct GLPrimitive final { using Collection = std::vector; @@ -35,25 +35,20 @@ namespace Pbr void UpdateBuffers(const Pbr::PrimitiveBuilder& primitiveBuilder); - // Get the material for the primitive. - std::shared_ptr& GetMaterial() - { - return m_material; - } + /// Get the material for the primitive. const std::shared_ptr& GetMaterial() const { return m_material; } - // Replace the material for the primitive + /// Replace the material for the primitive void SetMaterial(std::shared_ptr material) { m_material = std::move(material); } protected: - // friend class Model; - friend class GLModel; + friend class GLModelInstance; void Render(FillMode fillMode) const; private: diff --git a/src/conformance/framework/pbr/OpenGL/GLResources.cpp b/src/conformance/framework/pbr/OpenGL/GLResources.cpp index a088bfed..acfbfafd 100644 --- a/src/conformance/framework/pbr/OpenGL/GLResources.cpp +++ b/src/conformance/framework/pbr/OpenGL/GLResources.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -15,7 +15,7 @@ #include "GLPrimitive.h" #include "GLTexture.h" #include "GLTextureCache.h" -#include "GlslBuffers.h" +#include "../GlslBuffers.h" #include "../../gltf/GltfHelper.h" #include "../PbrCommon.h" @@ -24,17 +24,14 @@ #include "common/gfxwrapper_opengl.h" #include "utilities/opengl_utils.h" -#include "utilities/throw_helpers.h" #include #include -#include #include #include #include #include -#include #include #include @@ -111,10 +108,6 @@ namespace Pbr XRC_CHECK_THROW_GLCMD(glBindBuffer(GL_UNIFORM_BUFFER, Resources.SceneConstantBuffer.get())); XRC_CHECK_THROW_GLCMD(glBufferData(GL_UNIFORM_BUFFER, sizeof(Glsl::SceneConstantBuffer), nullptr, GL_DYNAMIC_DRAW)); - XRC_CHECK_THROW_GLCMD(glGenBuffers(1, Resources.ModelConstantBuffer.resetAndPut())); - XRC_CHECK_THROW_GLCMD(glBindBuffer(GL_UNIFORM_BUFFER, Resources.ModelConstantBuffer.get())); - XRC_CHECK_THROW_GLCMD(glBufferData(GL_UNIFORM_BUFFER, sizeof(Glsl::ModelConstantBuffer), nullptr, GL_DYNAMIC_DRAW)); - // Samplers for environment map and BRDF. Resources.BrdfSampler = GLTexture::CreateSampler(); Resources.EnvironmentMapSampler = GLTexture::CreateSampler(); @@ -128,7 +121,6 @@ namespace Pbr ScopedGLSampler BrdfSampler; ScopedGLSampler EnvironmentMapSampler; ScopedGLBuffer SceneConstantBuffer; - ScopedGLBuffer ModelConstantBuffer; std::shared_ptr BrdfLut; std::shared_ptr SpecularEnvironmentMap; std::shared_ptr DiffuseEnvironmentMap; @@ -138,7 +130,6 @@ namespace Pbr DeviceResources Resources; Glsl::SceneConstantBuffer SceneBuffer; - Glsl::ModelConstantBuffer ModelBuffer; struct LoaderResources { @@ -283,13 +274,6 @@ namespace Pbr m_impl->SceneBuffer.LightDiffuseColor = diffuseColor; } - void GLResources::SetModelToWorld(XrMatrix4x4f modelToWorld) const - { - m_impl->ModelBuffer.ModelToWorld = modelToWorld; - XRC_CHECK_THROW_GLCMD(glBindBuffer(GL_UNIFORM_BUFFER, m_impl->Resources.ModelConstantBuffer.get())); - XRC_CHECK_THROW_GLCMD(glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(Glsl::ModelConstantBuffer), &m_impl->ModelBuffer)); - } - void GLResources::SetViewProjection(XrMatrix4x4f view, XrMatrix4x4f projection) const { XrMatrix4x4f_Multiply(&m_impl->SceneBuffer.ViewProjection, &projection, &view); @@ -316,7 +300,6 @@ namespace Pbr void GLResources::Bind() const { - // SetModelToWorld must always be called before this, populating the ModelConstantBuffer. XRC_CHECK_THROW_GLCMD(glBindBuffer(GL_UNIFORM_BUFFER, m_impl->Resources.SceneConstantBuffer.get())); XRC_CHECK_THROW_GLCMD(glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(Glsl::SceneConstantBuffer), &m_impl->SceneBuffer)); @@ -324,8 +307,7 @@ namespace Pbr XRC_CHECK_THROW_GLCMD( glBindBufferBase(GL_UNIFORM_BUFFER, ShaderSlots::ConstantBuffers::Scene, m_impl->Resources.SceneConstantBuffer.get())); - XRC_CHECK_THROW_GLCMD( - glBindBufferBase(GL_UNIFORM_BUFFER, ShaderSlots::ConstantBuffers::Model, m_impl->Resources.ModelConstantBuffer.get())); + // ModelConstantBuffer is bound in GLModelInstance::Render XRC_CHECK_THROW_GLCMD( // glActiveTexture(GL_TEXTURE0 + ShaderSlots::GLSL::MaterialTexturesOffset + ShaderSlots::Brdf)); @@ -425,4 +407,4 @@ namespace Pbr } } // namespace Pbr -#endif +#endif // defined(XR_USE_GRAPHICS_API_OPENGL) || defined(XR_USE_GRAPHICS_API_OPENGL_ES) diff --git a/src/conformance/framework/pbr/OpenGL/GLResources.h b/src/conformance/framework/pbr/OpenGL/GLResources.h index f6b05802..3535bec1 100644 --- a/src/conformance/framework/pbr/OpenGL/GLResources.h +++ b/src/conformance/framework/pbr/OpenGL/GLResources.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -19,18 +19,15 @@ #include +#include +#include + namespace tinygltf { struct Image; struct Sampler; } // namespace tinygltf -#include -#include -#include -#include -#include - namespace Pbr { struct Primitive; @@ -50,7 +47,7 @@ namespace Pbr std::shared_ptr sampler; }; - // Global PBR resources required for rendering a scene. + /// Global PBR resources required for rendering a scene. struct GLResources final : public IResources { explicit GLResources(); @@ -62,37 +59,38 @@ namespace Pbr RGBColor emissiveFactor = RGB::Black) override; std::shared_ptr CreateMaterial() override; std::shared_ptr CreateSolidColorTexture(RGBAColor color); + void LoadTexture(const std::shared_ptr& pbrMaterial, Pbr::ShaderSlots::PSMaterial slot, const tinygltf::Image* image, const tinygltf::Sampler* sampler, bool sRGB, Pbr::RGBAColor defaultRGBA) override; PrimitiveHandle MakePrimitive(const Pbr::PrimitiveBuilder& primitiveBuilder, const std::shared_ptr& material) override; void DropLoaderCaches() override; - // Sets the Bidirectional Reflectance Distribution Function Lookup Table texture, required by the shader to compute surface - // reflectance from the IBL. + /// Sets the Bidirectional Reflectance Distribution Function Lookup Table texture, required by the shader to compute surface + /// reflectance from the IBL. void SetBrdfLut(std::shared_ptr brdfLut); - // Set the directional light. + /// Set the directional light. void SetLight(XrVector3f direction, RGBColor diffuseColor); - // Set the specular and diffuse image-based lighting (IBL) maps. ShaderResourceViews must be TextureCubes. + /// Set the specular and diffuse image-based lighting (IBL) maps. ShaderResourceViews must be TextureCubes. void SetEnvironmentMap(std::shared_ptr specularEnvironmentMap, std::shared_ptr diffuseEnvironmentMap); - // Set the current view and projection matrices. + /// Set the current view and projection matrices. void SetViewProjection(XrMatrix4x4f view, XrMatrix4x4f projection) const; - // Many 1x1 pixel colored textures are used in the PBR system. This is used to create textures backed by a cache to reduce the - // number of textures created. + /// Many 1x1 pixel colored textures are used in the PBR system. This is used to create textures backed by a cache to reduce the + /// number of textures created. std::shared_ptr CreateTypedSolidColorTexture(RGBAColor color) const; - // Bind the the PBR resources to the current context. + /// Bind the the PBR resources to the current context. void Bind() const; - // Set and update the model to world constant buffer value. - void SetModelToWorld(XrMatrix4x4f modelToWorld) const; - + /// Get the GLPrimitive from a primitive handle. GLPrimitive& GetPrimitive(PrimitiveHandle p); + + /// Get the GLPrimitive from a primitive handle, const overload const GLPrimitive& GetPrimitive(PrimitiveHandle p) const; // Set or get the shading and fill modes. @@ -110,7 +108,6 @@ namespace Pbr friend struct GLMaterial; struct Impl; - std::unique_ptr m_impl; SharedState m_sharedState; diff --git a/src/conformance/framework/pbr/OpenGL/GLTexture.cpp b/src/conformance/framework/pbr/OpenGL/GLTexture.cpp index c76da494..f4fb7c4f 100644 --- a/src/conformance/framework/pbr/OpenGL/GLTexture.cpp +++ b/src/conformance/framework/pbr/OpenGL/GLTexture.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/OpenGL/GLTexture.h b/src/conformance/framework/pbr/OpenGL/GLTexture.h index 3f88789f..91babf06 100644 --- a/src/conformance/framework/pbr/OpenGL/GLTexture.h +++ b/src/conformance/framework/pbr/OpenGL/GLTexture.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/OpenGL/GLTextureCache.cpp b/src/conformance/framework/pbr/OpenGL/GLTextureCache.cpp index 75b2c83a..1005f237 100644 --- a/src/conformance/framework/pbr/OpenGL/GLTextureCache.cpp +++ b/src/conformance/framework/pbr/OpenGL/GLTextureCache.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -23,7 +23,6 @@ #include #include #include -#include namespace Pbr { diff --git a/src/conformance/framework/pbr/OpenGL/GLTextureCache.h b/src/conformance/framework/pbr/OpenGL/GLTextureCache.h index 8e55b0f7..7a174ebf 100644 --- a/src/conformance/framework/pbr/OpenGL/GLTextureCache.h +++ b/src/conformance/framework/pbr/OpenGL/GLTextureCache.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // diff --git a/src/conformance/framework/pbr/PbrCommon.cpp b/src/conformance/framework/pbr/PbrCommon.cpp index 96a7f00a..9cd626ef 100644 --- a/src/conformance/framework/pbr/PbrCommon.cpp +++ b/src/conformance/framework/pbr/PbrCommon.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/PbrCommon.h b/src/conformance/framework/pbr/PbrCommon.h index d0b416a3..11c0329a 100644 --- a/src/conformance/framework/pbr/PbrCommon.h +++ b/src/conformance/framework/pbr/PbrCommon.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/PbrHandles.h b/src/conformance/framework/pbr/PbrHandles.h index 91ce9548..789e7697 100644 --- a/src/conformance/framework/pbr/PbrHandles.h +++ b/src/conformance/framework/pbr/PbrHandles.h @@ -1,4 +1,4 @@ -// Copyright 2019-2023, The Khronos Group, Inc. +// Copyright 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/pbr/PbrMaterial.cpp b/src/conformance/framework/pbr/PbrMaterial.cpp index 3aae2974..a1e9afbc 100644 --- a/src/conformance/framework/pbr/PbrMaterial.cpp +++ b/src/conformance/framework/pbr/PbrMaterial.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/PbrMaterial.h b/src/conformance/framework/pbr/PbrMaterial.h index e5796b8b..d6223f7a 100644 --- a/src/conformance/framework/pbr/PbrMaterial.h +++ b/src/conformance/framework/pbr/PbrMaterial.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved diff --git a/src/conformance/framework/pbr/PbrModel.cpp b/src/conformance/framework/pbr/PbrModel.cpp index 26487209..10eff3d3 100644 --- a/src/conformance/framework/pbr/PbrModel.cpp +++ b/src/conformance/framework/pbr/PbrModel.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -11,19 +11,15 @@ #include "common/xr_linear.h" -#include -#include #include namespace Pbr { - Model::Model(bool createRootNode /*= true*/) + Model::Model() { - if (createRootNode) { - XrMatrix4x4f identityMatrix; - XrMatrix4x4f_CreateIdentity(&identityMatrix); - AddNode(identityMatrix, RootParentNodeIndex, "root"); - } + XrMatrix4x4f identityMatrix; + XrMatrix4x4f_CreateIdentity(&identityMatrix); + AddNode(identityMatrix, RootParentNodeIndex, "root"); } NodeIndex_t Model::AddNode(const XrMatrix4x4f& transform, Pbr::NodeIndex_t parentIndex, std::string name) @@ -34,14 +30,7 @@ namespace Pbr } m_nodes.emplace_back(transform, std::move(name), newNodeIndex, parentIndex); - // m_modelTransformsStructuredBuffer = nullptr; // Structured buffer will need to be recreated. - InvalidateBuffer(); // Structured buffer will need to be recreated. - return m_nodes.back().Index; - } - - void Model::Clear() - { - m_primitives.clear(); + return m_nodes.back().GetNodeIndex(); } bool Model::FindFirstNode(NodeIndex_t* outNodeIndex, const char* name, const NodeIndex_t* parentNodeIndex) const @@ -50,42 +39,22 @@ namespace Pbr const NodeIndex_t startIndex = parentNodeIndex ? *parentNodeIndex + 1 : Pbr::RootNodeIndex; for (NodeIndex_t i = startIndex; i < m_nodes.size(); ++i) { const Pbr::Node& node = m_nodes[i]; - if ((!parentNodeIndex || node.ParentNodeIndex == *parentNodeIndex) && (node.Name.compare(name) == 0)) { - *outNodeIndex = node.Index; + if ((!parentNodeIndex || node.GetParentNodeIndex() == *parentNodeIndex) && (node.CompareName(name) == 0)) { + *outNodeIndex = node.GetNodeIndex(); return true; } } return false; } - XrMatrix4x4f Model::GetNodeToModelRootTransform(NodeIndex_t nodeIndex) const - { - const Pbr::Node& node = GetNode(nodeIndex); - - // Compute the transform recursively. - XrMatrix4x4f identityMatrix; - XrMatrix4x4f_CreateIdentity(&identityMatrix); - const XrMatrix4x4f parentTransform = - node.ParentNodeIndex == Pbr::RootNodeIndex ? identityMatrix : GetNodeToModelRootTransform(node.ParentNodeIndex); - XrMatrix4x4f nodeTransform = node.GetTransform(); - XrMatrix4x4f result; - XrMatrix4x4f_Multiply(&result, &nodeTransform, &parentTransform); - return result; - } - void Model::AddPrimitive(PrimitiveHandle primitive) { - m_primitives.push_back(primitive); + m_primitiveHandles.push_back(primitive); } Node::Node(Node&& other) noexcept { - using std::swap; - swap(Name, other.Name); - swap(Index, other.Index); - swap(ParentNodeIndex, other.ParentNodeIndex); - m_modifyCount.store(other.m_modifyCount); - swap(m_localTransform, other.m_localTransform); + *this = std::move(other); } Node& Node::operator=(Node&& other) noexcept @@ -97,7 +66,6 @@ namespace Pbr swap(Name, other.Name); swap(Index, other.Index); swap(ParentNodeIndex, other.ParentNodeIndex); - m_modifyCount.store(other.m_modifyCount); swap(m_localTransform, other.m_localTransform); return *this; } diff --git a/src/conformance/framework/pbr/PbrModel.h b/src/conformance/framework/pbr/PbrModel.h index 9cd42892..3e0f8d5b 100644 --- a/src/conformance/framework/pbr/PbrModel.h +++ b/src/conformance/framework/pbr/PbrModel.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -12,9 +12,6 @@ #include "common/xr_linear.h" -#include -#include -#include #include #include #include @@ -29,39 +26,42 @@ namespace Pbr using Collection = std::vector; Node(const XrMatrix4x4f& localTransform, std::string name, NodeIndex_t index, NodeIndex_t parentNodeIndex) - : Name(std::move(name)), Index(index), ParentNodeIndex(parentNodeIndex) + : Name(std::move(name)), Index(index), ParentNodeIndex(parentNodeIndex), m_localTransform(localTransform) { - SetTransform(localTransform); } Node(Node&& other) noexcept; Node& operator=(Node&& other) noexcept; - // Set the local transform for this node. - void SetTransform(const XrMatrix4x4f& transform) + // Compare this node's name to a given name. + int CompareName(const char* value) const { - m_localTransform = transform; - ++m_modifyCount; + return Name.compare(value); } // Get the local transform for this node. - XrMatrix4x4f GetTransform() const + const XrMatrix4x4f& GetLocalTransform() const { return m_localTransform; } - uint32_t GetModifyCount() const + + // Get the index of this node. + NodeIndex_t GetNodeIndex() const + { + return Index; + } + + // Get the index of the parent node of this node. + NodeIndex_t GetParentNodeIndex() const { - return m_modifyCount; + return ParentNodeIndex; } + private: + // All immutable, but we need copy-assign for vector std::string Name; NodeIndex_t Index; NodeIndex_t ParentNodeIndex; - - private: - friend class Model; - // TODO std::atomic_uint32_t - std::atomic_uint32_t m_modifyCount{0}; XrMatrix4x4f m_localTransform; }; @@ -69,9 +69,7 @@ namespace Pbr class Model { public: - std::string Name; - - Model(bool createRootNode = true); + Model(); /// Add a node to the model. NodeIndex_t AddNode(const XrMatrix4x4f& transform, NodeIndex_t parentIndex, std::string name = ""); @@ -79,9 +77,6 @@ namespace Pbr /// Add a primitive to the model. void AddPrimitive(PrimitiveHandle primitive); - // Remove all primitives. - void Clear(); - NodeIndex_t GetNodeCount() const { return (NodeIndex_t)m_nodes.size(); @@ -95,29 +90,24 @@ namespace Pbr return m_nodes[nodeIndex]; } + /// Get the number of primitives used in this model uint32_t GetPrimitiveCount() const { - return (uint32_t)m_primitives.size(); + return (uint32_t)m_primitiveHandles.size(); } - PrimitiveHandle GetPrimitive(uint32_t index) const + + /// Get a primitive handle by index of primitives used in this model. + PrimitiveHandle GetPrimitiveHandle(uint32_t index) const { - return m_primitives[index]; + return m_primitiveHandles[index]; } /// Find the first node (after an optional parent node) which matches a given name. bool FindFirstNode(NodeIndex_t* outNodeIndex, const char* name, const NodeIndex_t* parentNodeIndex = nullptr) const; - protected: - // Invalidate buffers associated with model transforms - bool m_modelTransformsStructuredBufferInvalid{true}; - void InvalidateBuffer() - { - m_modelTransformsStructuredBufferInvalid = true; - } - - const std::vector& GetPrimitives() const + const std::vector& GetPrimitiveHandles() const { - return m_primitives; + return m_primitiveHandles; } const Node::Collection& GetNodes() const @@ -126,20 +116,106 @@ namespace Pbr } static constexpr Pbr::NodeIndex_t RootParentNodeIndex = (Pbr::NodeIndex_t)-1; - private: - // Compute the transform relative to the root of the model for a given node. - XrMatrix4x4f GetNodeToModelRootTransform(NodeIndex_t nodeIndex) const; - - // Updated the transforms used to render the model. This needs to be called any time a node transform is changed. - // void UpdateTransforms(Pbr::D3D11Resources const& pbrResources, std::runtime_error ID3D11DeviceContext* context) const; - private: // A model is made up of one or more Primitives. Each Primitive has a unique material. // Ideally primitives with the same material should be merged to reduce draw calls. - std::vector m_primitives; + std::vector m_primitiveHandles; // A model contains one or more nodes. Each vertex of a primitive references a node to have the // node's transform applied. Node::Collection m_nodes; }; + + /// A model instance is a collection of node transforms for an instance of a model. + /// A model instance can only have its transforms updated once per command queue. + /// A model instance holds a strong shared reference to its corresponding model. + class ModelInstance + { + protected: + ModelInstance(std::shared_ptr model) : m_model(std::move(model)) + { + const auto nodeCount = m_model->GetNodeCount(); + + m_nodeLocalTransforms.reserve(m_model->GetNodeCount()); + for (const Node& node : m_model->GetNodes()) { + m_nodeLocalTransforms.push_back(node.GetLocalTransform()); + } + XrMatrix4x4f identityMatrix; + XrMatrix4x4f_CreateIdentity(&identityMatrix); // or better yet poison it + m_resolvedTransforms.resize(nodeCount, identityMatrix); + } + + public: + /// Overrides the local transform of a node + void SetNodeTransform(NodeIndex_t nodeIndex, const XrMatrix4x4f& transform) + { + m_nodeLocalTransforms[nodeIndex] = transform; + m_nodeLocalTransformsUpdated = true; + } + + /// Combine a transform with the original transform from the asset + void SetAdditionalNodeTransform(NodeIndex_t nodeIndex, const XrMatrix4x4f& transform) + { + XrMatrix4x4f compositeTransform; + // Node transform is the immutable original transform + const XrMatrix4x4f& originalNodeTransform = m_model->GetNode(nodeIndex).GetLocalTransform(); + XrMatrix4x4f_Multiply(&compositeTransform, &originalNodeTransform, &transform); + SetNodeTransform(nodeIndex, compositeTransform); + } + + protected: + bool WereNodeLocalTransformsUpdated() const noexcept + { + return m_nodeLocalTransformsUpdated; + } + void ClearTransformsUpdatedFlag() noexcept + { + m_nodeLocalTransformsUpdated = false; + } + void ResolveTransforms(bool transpose) + { + const auto& nodes = m_model->GetNodes(); + + // Nodes are guaranteed to come after their parents, so each node transform can be multiplied by its parent transform in a single pass. + assert(nodes.size() == m_nodeLocalTransforms.size()); + assert(nodes.size() == m_resolvedTransforms.size()); + XrMatrix4x4f identityMatrix; + XrMatrix4x4f_CreateIdentity(&identityMatrix); + for (const auto& node : nodes) { + assert(node.GetParentNodeIndex() == Model::RootParentNodeIndex || node.GetParentNodeIndex() < node.GetNodeIndex()); + const XrMatrix4x4f& parentTransform = (node.GetParentNodeIndex() == Model::RootParentNodeIndex) + ? identityMatrix + : m_resolvedTransforms[node.GetParentNodeIndex()]; + const XrMatrix4x4f& nodeTransform = m_nodeLocalTransforms[node.GetNodeIndex()]; + if (transpose) { + XrMatrix4x4f nodeTransformTranspose; + XrMatrix4x4f_Transpose(&nodeTransformTranspose, &nodeTransform); + XrMatrix4x4f_Multiply(&m_resolvedTransforms[node.GetNodeIndex()], &nodeTransformTranspose, &parentTransform); + } + else { + XrMatrix4x4f_Multiply(&m_resolvedTransforms[node.GetNodeIndex()], &parentTransform, &nodeTransform); + } + } + } + + const Model& GetModel() const + { + return *m_model; + } + + const std::vector& GetResolvedTransforms() const noexcept + { + return m_resolvedTransforms; + } + + private: + bool m_nodeLocalTransformsUpdated{true}; + + // Derived classes may depend on this being immutable. + std::shared_ptr m_model; + // This is initialized to the local transform of every node, + // but can be updated for this instance. + std::vector m_nodeLocalTransforms; + std::vector m_resolvedTransforms; + }; } // namespace Pbr diff --git a/src/conformance/framework/pbr/PbrSharedState.cpp b/src/conformance/framework/pbr/PbrSharedState.cpp index f1ed0cc1..025f0dd3 100644 --- a/src/conformance/framework/pbr/PbrSharedState.cpp +++ b/src/conformance/framework/pbr/PbrSharedState.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // diff --git a/src/conformance/framework/pbr/PbrSharedState.h b/src/conformance/framework/pbr/PbrSharedState.h index c9908101..31941636 100644 --- a/src/conformance/framework/pbr/PbrSharedState.h +++ b/src/conformance/framework/pbr/PbrSharedState.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -72,8 +72,8 @@ namespace Pbr enum BindingOffsets { VSResourceViewsOffset = NumConstantBuffers, - MaterialTexturesOffset = VSResourceViewsOffset + NumVSResourceViews, - GlobalTexturesOffset = MaterialTexturesOffset + NumMaterialSlots, + MaterialTexturesOffset = (int)VSResourceViewsOffset + (int)NumVSResourceViews, + GlobalTexturesOffset = (int)MaterialTexturesOffset + (int)NumMaterialSlots, }; } } // namespace ShaderSlots diff --git a/src/conformance/framework/pbr/Shaders/PbrPixelShader_glsl.frag b/src/conformance/framework/pbr/Shaders/PbrPixelShader_glsl.frag index 3e2ae34a..51c0e207 100644 --- a/src/conformance/framework/pbr/Shaders/PbrPixelShader_glsl.frag +++ b/src/conformance/framework/pbr/Shaders/PbrPixelShader_glsl.frag @@ -3,7 +3,7 @@ precision mediump float; precision highp int; // Copyright (c) 2016 - 2017 Mohamad Moneimne and Contributors // Copyright (C) Microsoft Corporation. All Rights Reserved -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT diff --git a/src/conformance/framework/pbr/Shaders/PbrPixelShader_glsl.spv.license b/src/conformance/framework/pbr/Shaders/PbrPixelShader_glsl.spv.license index 0721500c..c42456e2 100644 --- a/src/conformance/framework/pbr/Shaders/PbrPixelShader_glsl.spv.license +++ b/src/conformance/framework/pbr/Shaders/PbrPixelShader_glsl.spv.license @@ -1,5 +1,5 @@ Copyright (c) 2016 - 2017 Mohamad Moneimne and Contributors Copyright (C) Microsoft Corporation. All Rights Reserved -Copyright 2023, The Khronos Group, Inc. +Copyright 2023-2024, The Khronos Group Inc. SPDX-License-Identifier: MIT diff --git a/src/conformance/framework/pbr/Shaders/PbrVertexShader_glsl.spv.license b/src/conformance/framework/pbr/Shaders/PbrVertexShader_glsl.spv.license index 0721500c..c42456e2 100644 --- a/src/conformance/framework/pbr/Shaders/PbrVertexShader_glsl.spv.license +++ b/src/conformance/framework/pbr/Shaders/PbrVertexShader_glsl.spv.license @@ -1,5 +1,5 @@ Copyright (c) 2016 - 2017 Mohamad Moneimne and Contributors Copyright (C) Microsoft Corporation. All Rights Reserved -Copyright 2023, The Khronos Group, Inc. +Copyright 2023-2024, The Khronos Group Inc. SPDX-License-Identifier: MIT diff --git a/src/conformance/framework/pbr/Shaders/PbrVertexShader_glsl.vert b/src/conformance/framework/pbr/Shaders/PbrVertexShader_glsl.vert index c6171340..964aa4de 100644 --- a/src/conformance/framework/pbr/Shaders/PbrVertexShader_glsl.vert +++ b/src/conformance/framework/pbr/Shaders/PbrVertexShader_glsl.vert @@ -3,7 +3,7 @@ precision mediump float; precision highp int; // Copyright (c) 2016 - 2017 Mohamad Moneimne and Contributors // Copyright (C) Microsoft Corporation. All Rights Reserved -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // SPDX-License-Identifier: MIT diff --git a/src/conformance/framework/pbr/Vulkan/VkCommon.h b/src/conformance/framework/pbr/Vulkan/VkCommon.h index e766be90..d4f608a8 100644 --- a/src/conformance/framework/pbr/Vulkan/VkCommon.h +++ b/src/conformance/framework/pbr/Vulkan/VkCommon.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // diff --git a/src/conformance/framework/pbr/Vulkan/VkMaterial.cpp b/src/conformance/framework/pbr/Vulkan/VkMaterial.cpp index fe5b551a..1bec4b0d 100644 --- a/src/conformance/framework/pbr/Vulkan/VkMaterial.cpp +++ b/src/conformance/framework/pbr/Vulkan/VkMaterial.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -6,6 +6,9 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // // SPDX-License-Identifier: MIT AND Apache-2.0 + +#if defined(XR_USE_GRAPHICS_API_VULKAN) + #include "VkMaterial.h" #include "VkCommon.h" @@ -17,6 +20,8 @@ #include "utilities/vulkan_scoped_handle.h" #include "utilities/vulkan_utils.h" +#include + namespace Pbr { VulkanMaterial::VulkanMaterial(Pbr::VulkanResources const& pbrResources) @@ -72,20 +77,18 @@ namespace Pbr void VulkanMaterial::SetTexture(ShaderSlots::PSMaterial slot, std::shared_ptr textureView, std::shared_ptr sampler) { - m_textures[slot] = textureView; + m_textures[slot] = std::move(textureView); if (sampler) { - m_samplers[slot] = sampler; + m_samplers[slot] = std::move(sampler); } } - // Get the material constant buffer for binding VkDescriptorBufferInfo VulkanMaterial::GetMaterialConstantBuffer() { return m_constantBuffer.MakeDescriptor(); } - // Get the combined image sampler descriptors for binding std::vector VulkanMaterial::GetTextureDescriptors() { std::vector ret(TextureCount); @@ -108,3 +111,5 @@ namespace Pbr } } } // namespace Pbr + +#endif // defined(XR_USE_GRAPHICS_API_VULKAN) diff --git a/src/conformance/framework/pbr/Vulkan/VkMaterial.h b/src/conformance/framework/pbr/Vulkan/VkMaterial.h index ac7b83b8..e6a7e9e9 100644 --- a/src/conformance/framework/pbr/Vulkan/VkMaterial.h +++ b/src/conformance/framework/pbr/Vulkan/VkMaterial.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -6,6 +6,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // // SPDX-License-Identifier: MIT AND Apache-2.0 + #pragma once #include "VkResources.h" @@ -21,7 +22,6 @@ #include #include -#include #include #include #include @@ -32,32 +32,33 @@ namespace Pbr struct VulkanResources; struct VulkanTextureBundle; - // A VulkanMaterial contains the metallic roughness parameters and textures. - // Primitives specify which VulkanMaterial to use when being rendered. + /// A VulkanMaterial contains the metallic roughness parameters and textures. + /// Primitives specify which VulkanMaterial to use when being rendered. struct VulkanMaterial final : public Material { - // Create a uninitialized material. Textures and shader coefficients must be set. + /// Create a uninitialized material. Textures and shader coefficients must be set. VulkanMaterial(Pbr::VulkanResources const& pbrResources); ~VulkanMaterial() override = default; - // Create a clone of this material. Shares the texture and sampler heap with this material. + /// Create a clone of this material. Shares the texture and sampler heap with this material. std::shared_ptr Clone(Pbr::VulkanResources const& pbrResources) const; - // Create a flat (no texture) material. + /// Create a flat (no texture) material. static std::shared_ptr CreateFlat(VulkanResources& pbrResources, RGBAColor baseColorFactor, float roughnessFactor = 1.0f, float metallicFactor = 0.0f, RGBColor emissiveFactor = RGB::Black); - // Set a Metallic-Roughness texture. + /// Set a Metallic-Roughness texture. void SetTexture(ShaderSlots::PSMaterial slot, std::shared_ptr textureView, std::shared_ptr sampler); - // Get the material constant buffer for binding + /// Get the material constant buffer for binding VkDescriptorBufferInfo GetMaterialConstantBuffer(); - // Get the combined image sampler descriptors for binding + + /// Get the combined image sampler descriptors for binding std::vector GetTextureDescriptors(); - // Update the material constant buffer + /// Update the material constant buffer void UpdateBuffer(); std::string Name; diff --git a/src/conformance/framework/pbr/Vulkan/VkModel.cpp b/src/conformance/framework/pbr/Vulkan/VkModel.cpp index d92221e2..e1e2a307 100644 --- a/src/conformance/framework/pbr/Vulkan/VkModel.cpp +++ b/src/conformance/framework/pbr/Vulkan/VkModel.cpp @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -6,6 +6,8 @@ // // SPDX-License-Identifier: MIT AND Apache-2.0 +#if defined(XR_USE_GRAPHICS_API_VULKAN) + #include "VkModel.h" #include "VkMaterial.h" @@ -18,42 +20,38 @@ #include "utilities/vulkan_scoped_handle.h" #include "utilities/vulkan_utils.h" -#include -#include #include -#include #include namespace Pbr { - void VulkanModel::Render(Pbr::VulkanResources& pbrResources, Conformance::CmdBuffer& directCommandBuffer, VkRenderPass renderPass, - VkSampleCountFlagBits sampleCount) + void VulkanModelInstance::Render(Pbr::VulkanResources& pbrResources, Conformance::CmdBuffer& directCommandBuffer, + VkRenderPass renderPass, VkSampleCountFlagBits sampleCount, XrMatrix4x4f modelToWorld) { pbrResources.UpdateBuffer(); + m_modelBuffer.ModelToWorld = modelToWorld; + m_modelConstantBuffer.Update({&m_modelBuffer, 1}); UpdateTransforms(pbrResources); - auto primitives = GetPrimitives(); - if (m_descriptorSets.size() < primitives.size()) { - AllocateDescriptorSets(pbrResources, (uint32_t)primitives.size()); + auto& primitiveHandles = GetModel().GetPrimitiveHandles(); + if (m_descriptorSets.size() < primitiveHandles.size()) { + AllocateDescriptorSets(pbrResources, (uint32_t)primitiveHandles.size()); } - for (size_t i = 0; i < primitives.size(); i++) { - PrimitiveHandle primitiveHandle = primitives[i]; + for (size_t i = 0; i < primitiveHandles.size(); i++) { + PrimitiveHandle primitiveHandle = primitiveHandles[i]; VkDescriptorSet descriptorSet = m_descriptorSets[i]; const Pbr::VulkanPrimitive& primitive = pbrResources.GetPrimitive(primitiveHandle); if (primitive.GetMaterial()->Hidden) continue; primitive.Render(directCommandBuffer, pbrResources, descriptorSet, renderPass, sampleCount, - m_modelTransformsStructuredBuffer.MakeDescriptor()); + m_modelConstantBuffer.MakeDescriptor(), m_modelTransformsStructuredBuffer.MakeDescriptor()); } - - // Expect the caller to reset other state, but the geometry shader is cleared specially. - //context->GSSetShader(nullptr, nullptr, 0); } - void VulkanModel::AllocateDescriptorSets(Pbr::VulkanResources& pbrResources, uint32_t numSets) + void VulkanModelInstance::AllocateDescriptorSets(Pbr::VulkanResources& pbrResources, uint32_t numSets) { m_descriptorPool.adopt(pbrResources.MakeDescriptorPool(numSets), pbrResources.GetDevice()); @@ -69,48 +67,37 @@ namespace Pbr m_descriptorSets.resize(numSets); XRC_CHECK_THROW_VKCMD(vkAllocateDescriptorSets(pbrResources.GetDevice(), &allocInfo, m_descriptorSets.data())); } - - void VulkanModel::UpdateTransforms(Pbr::VulkanResources& pbrResources) + VulkanModelInstance::VulkanModelInstance(Pbr::VulkanResources& pbrResources, std::shared_ptr model) + : ModelInstance(std::move(model)) + { + // Set up the model constant buffer. + m_modelConstantBuffer.Init(pbrResources.GetDevice(), pbrResources.GetMemoryAllocator()); + m_modelConstantBuffer.Create(1, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT); + + // Set up the transforms buffer. + XrMatrix4x4f identityMatrix; + XrMatrix4x4f_CreateIdentity(&identityMatrix); // or better yet poison it + size_t nodeCount = GetModel().GetNodes().size(); + + // Create/recreate the structured buffer and SRV which holds the node transforms. + size_t elemSize = sizeof(XrMatrix4x4f); + uint32_t count = (uint32_t)(nodeCount); + uint32_t size = (uint32_t)(count * elemSize); + + m_modelTransformsStructuredBuffer.Init(pbrResources.GetDevice(), pbrResources.GetMemoryAllocator()); + m_modelTransformsStructuredBuffer.Create(size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT); + } + void VulkanModelInstance::UpdateTransforms(Pbr::VulkanResources& /* pbrResources */) { - const auto& nodes = GetNodes(); - const uint32_t newTotalModifyCount = std::accumulate(nodes.begin(), nodes.end(), 0, [](uint32_t sumChangeCount, const Node& node) { - return sumChangeCount + node.GetModifyCount(); - }); - // If none of the node transforms have changed, no need to recompute/update the model transform structured buffer. - if (newTotalModifyCount != TotalModifyCount || m_modelTransformsStructuredBufferInvalid) { - if (m_modelTransformsStructuredBufferInvalid) // The structured buffer is reset when a Node is added. - { - XrMatrix4x4f identityMatrix; - XrMatrix4x4f_CreateIdentity(&identityMatrix); // or better yet poison it - m_modelTransforms.resize(nodes.size(), identityMatrix); - - // Create/recreate the structured buffer and SRV which holds the node transforms. - size_t elemSize = sizeof(decltype(m_modelTransforms)::value_type); - uint32_t count = (uint32_t)(m_modelTransforms.size()); - uint32_t size = (uint32_t)(count * elemSize); - - m_modelTransformsStructuredBuffer.Init(pbrResources.GetDevice(), pbrResources.GetMemoryAllocator()); - m_modelTransformsStructuredBuffer.Create(size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT); - - m_modelTransformsStructuredBufferInvalid = false; - } - - // Nodes are guaranteed to come after their parents, so each node transform can be multiplied by its parent transform in a single pass. - assert(nodes.size() == m_modelTransforms.size()); - XrMatrix4x4f identityMatrix; - XrMatrix4x4f_CreateIdentity(&identityMatrix); - for (const auto& node : nodes) { - assert(node.ParentNodeIndex == RootParentNodeIndex || node.ParentNodeIndex < node.Index); - const XrMatrix4x4f& parentTransform = - (node.ParentNodeIndex == RootParentNodeIndex) ? identityMatrix : m_modelTransforms[node.ParentNodeIndex]; - XrMatrix4x4f nodeTransform = node.GetTransform(); - XrMatrix4x4f_Multiply(&m_modelTransforms[node.Index], &parentTransform, &nodeTransform); - } + if (WereNodeLocalTransformsUpdated()) { + ResolveTransforms(false); // Update node transform structured buffer. - m_modelTransformsStructuredBuffer.Update(this->m_modelTransforms); - TotalModifyCount = newTotalModifyCount; + m_modelTransformsStructuredBuffer.Update(GetResolvedTransforms()); + ClearTransformsUpdatedFlag(); } } } // namespace Pbr + +#endif // defined(XR_USE_GRAPHICS_API_VULKAN) diff --git a/src/conformance/framework/pbr/Vulkan/VkModel.h b/src/conformance/framework/pbr/Vulkan/VkModel.h index 33cc9128..9ed6925d 100644 --- a/src/conformance/framework/pbr/Vulkan/VkModel.h +++ b/src/conformance/framework/pbr/Vulkan/VkModel.h @@ -1,4 +1,4 @@ -// Copyright 2022-2023, The Khronos Group, Inc. +// Copyright 2022-2024, The Khronos Group Inc. // // Based in part on code that is: // Copyright (C) Microsoft Corporation. All Rights Reserved @@ -9,6 +9,7 @@ #pragma once #include "VkResources.h" +#include "../GlslBuffers.h" #include "../PbrHandles.h" #include "../PbrModel.h" @@ -23,29 +24,28 @@ namespace Pbr { - struct VulkanPrimitive; struct VulkanResources; - class VulkanModel final : public Model + class VulkanModelInstance final : public ModelInstance { public: - // Render the model. + VulkanModelInstance(Pbr::VulkanResources& pbrResources, std::shared_ptr model); + + /// Render the model. void Render(Pbr::VulkanResources& pbrResources, Conformance::CmdBuffer& directCommandBuffer, VkRenderPass renderPass, - VkSampleCountFlagBits sampleCount); + VkSampleCountFlagBits sampleCount, XrMatrix4x4f modelToWorld); private: void AllocateDescriptorSets(Pbr::VulkanResources& pbrResources, uint32_t numSets); - // Updated the transforms used to render the model. This needs to be called any time a node transform is changed. + /// Update the transforms used to render the model. This needs to be called any time a node transform is changed. void UpdateTransforms(Pbr::VulkanResources& pbrResources); - // Temporary buffer holds the world transforms, computed from the node's local transforms. - mutable std::vector m_modelTransforms; - mutable Conformance::StructuredBuffer m_modelTransformsStructuredBuffer; - // mutable Microsoft::WRL::ComPtr m_modelTransformsResourceViewHeap; + Glsl::ModelConstantBuffer m_modelBuffer; + Conformance::StructuredBuffer m_modelConstantBuffer; + + Conformance::StructuredBuffer m_modelTransformsStructuredBuffer; Conformance::ScopedVkDescriptorPool m_descriptorPool; std::vector m_descriptorSets; - - mutable uint32_t TotalModifyCount{0}; }; } // namespace Pbr diff --git a/src/conformance/framework/pbr/Vulkan/VkPipelineStates.cpp b/src/conformance/framework/pbr/Vulkan/VkPipelineStates.cpp index a9867319..b7870dc6 100644 --- a/src/conformance/framework/pbr/Vulkan/VkPipelineStates.cpp +++ b/src/conformance/framework/pbr/Vulkan/VkPipelineStates.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -7,6 +7,8 @@ // // SPDX-License-Identifier: MIT AND Apache-2.0 +#if defined(XR_USE_GRAPHICS_API_VULKAN) + #include "VkPipelineStates.h" #include "../PbrSharedState.h" @@ -150,3 +152,5 @@ namespace Pbr return pipeline; } } // namespace Pbr + +#endif // defined(XR_USE_GRAPHICS_API_VULKAN) diff --git a/src/conformance/framework/pbr/Vulkan/VkPipelineStates.h b/src/conformance/framework/pbr/Vulkan/VkPipelineStates.h index c87b925a..1443d11d 100644 --- a/src/conformance/framework/pbr/Vulkan/VkPipelineStates.h +++ b/src/conformance/framework/pbr/Vulkan/VkPipelineStates.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // diff --git a/src/conformance/framework/pbr/Vulkan/VkPrimitive.cpp b/src/conformance/framework/pbr/Vulkan/VkPrimitive.cpp index 35fa1729..03d0f569 100644 --- a/src/conformance/framework/pbr/Vulkan/VkPrimitive.cpp +++ b/src/conformance/framework/pbr/Vulkan/VkPrimitive.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -7,6 +7,8 @@ // // SPDX-License-Identifier: MIT AND Apache-2.0 +#if defined(XR_USE_GRAPHICS_API_VULKAN) + #include "VkPrimitive.h" #include "VkMaterial.h" @@ -53,14 +55,15 @@ namespace Pbr } void VulkanPrimitive::Render(Conformance::CmdBuffer& directCommandBuffer, VulkanResources& pbrResources, VkDescriptorSet descriptorSet, - VkRenderPass renderPass, VkSampleCountFlagBits sampleCount, VkDescriptorBufferInfo transformBuffer) const + VkRenderPass renderPass, VkSampleCountFlagBits sampleCount, VkDescriptorBufferInfo modelConstantBuffer, + VkDescriptorBufferInfo transformBuffer) const { GetMaterial()->UpdateBuffer(); auto materialConstantBuffer = GetMaterial()->GetMaterialConstantBuffer(); auto materialTextures = GetMaterial()->GetTextureDescriptors(); - std::unique_ptr wds = - pbrResources.BuildWriteDescriptorSets(materialConstantBuffer, transformBuffer, materialTextures, descriptorSet); + std::unique_ptr wds = pbrResources.BuildWriteDescriptorSets( + modelConstantBuffer, materialConstantBuffer, transformBuffer, materialTextures, descriptorSet); vkUpdateDescriptorSets(pbrResources.GetDevice(), static_cast(wds->writeDescriptorSets.size()), wds->writeDescriptorSets.data(), 0, NULL); @@ -91,3 +94,5 @@ namespace Pbr CHECKPOINT(); } } // namespace Pbr + +#endif // defined(XR_USE_GRAPHICS_API_VULKAN) diff --git a/src/conformance/framework/pbr/Vulkan/VkPrimitive.h b/src/conformance/framework/pbr/Vulkan/VkPrimitive.h index 93338e75..520f60c7 100644 --- a/src/conformance/framework/pbr/Vulkan/VkPrimitive.h +++ b/src/conformance/framework/pbr/Vulkan/VkPrimitive.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -29,7 +29,7 @@ namespace Pbr struct VulkanMaterial; struct VulkanResources; - // A primitive holds a vertex buffer, index buffer, and a pointer to a PBR material. + /// A primitive holds a vertex buffer, index buffer, and a pointer to a PBR material. struct VulkanPrimitive final { using Collection = std::vector; @@ -39,13 +39,7 @@ namespace Pbr VulkanPrimitive(Pbr::VulkanResources const& pbrResources, const Pbr::PrimitiveBuilder& primitiveBuilder, const std::shared_ptr& material); - // void UpdateBuffers(Pbr::VulkanResources& pbrResources, const Pbr::PrimitiveBuilder& primitiveBuilder); - /// Get the material for the primitive. - std::shared_ptr& GetMaterial() - { - return m_material; - } const std::shared_ptr& GetMaterial() const { return m_material; @@ -58,10 +52,10 @@ namespace Pbr } protected: - // friend class Model; - friend class VulkanModel; + friend class VulkanModelInstance; void Render(Conformance::CmdBuffer& directCommandBuffer, VulkanResources& pbrResources, VkDescriptorSet descriptorSet, - VkRenderPass renderPass, VkSampleCountFlagBits sampleCount, VkDescriptorBufferInfo transformBuffer) const; + VkRenderPass renderPass, VkSampleCountFlagBits sampleCount, VkDescriptorBufferInfo modelConstantBuffer, + VkDescriptorBufferInfo transformBuffer) const; /// The clone shares the vertex and index buffers - they are not cloned VulkanPrimitive Clone(Pbr::VulkanResources const& pbrResources) const; diff --git a/src/conformance/framework/pbr/Vulkan/VkResources.cpp b/src/conformance/framework/pbr/Vulkan/VkResources.cpp index adbf0da0..17a6e267 100644 --- a/src/conformance/framework/pbr/Vulkan/VkResources.cpp +++ b/src/conformance/framework/pbr/Vulkan/VkResources.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -7,9 +7,10 @@ // // SPDX-License-Identifier: MIT AND Apache-2.0 +#if defined(XR_USE_GRAPHICS_API_VULKAN) + #include "VkResources.h" -#include "GlslBuffers.h" #include "VkCommon.h" #include "VkMaterial.h" #include "VkPipelineStates.h" @@ -18,6 +19,7 @@ #include "VkTextureCache.h" #include "../../gltf/GltfHelper.h" +#include "../GlslBuffers.h" #include "../PbrCommon.h" #include "../PbrHandles.h" #include "../PbrSharedState.h" @@ -30,7 +32,6 @@ #include #include -#include #include #include #include @@ -255,7 +256,7 @@ namespace Pbr VK_SHADER_STAGE_FRAGMENT_BIT); // transform buffer - layoutBuilder.SetBindings(TransformsBuffer, ShaderSlots::GLSL::VSResourceViewsOffset + ShaderSlots::Transforms, + layoutBuilder.SetBindings(TransformsBuffer, (int)ShaderSlots::GLSL::VSResourceViewsOffset + (int)ShaderSlots::Transforms, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_VERTEX_BIT, // ShaderSlots::NumVSResourceViews); @@ -265,7 +266,7 @@ namespace Pbr ShaderSlots::NumMaterialSlots); layoutBuilder.SetBindings(GlobalTextures, ShaderSlots::GLSL::GlobalTexturesOffset, // VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, // - ShaderSlots::NumTextures - ShaderSlots::NumMaterialSlots); + (int)ShaderSlots::NumTextures - (int)ShaderSlots::NumMaterialSlots); } // very basic for now, can grow if needed @@ -304,14 +305,10 @@ namespace Pbr Resources.Pipelines = std::make_unique(device, Resources.PipelineLayout, c_attrDesc, c_bindingDesc, g_PbrVertexShader, g_PbrPixelShader); - // Set up the constant buffers. - + // Set up the scene constant buffer. Resources.SceneBuffer.Init(device, allocator); Resources.SceneBuffer.Create(1, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT); - Resources.ModelBuffer.Init(device, allocator); - Resources.ModelBuffer.Create(1, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT); - Resources.BrdfSampler.adopt(VulkanTexture::CreateSampler(device), device); Resources.EnvironmentMapSampler.adopt(VulkanTexture::CreateSampler(device), device); @@ -338,7 +335,6 @@ namespace Pbr mutable VulkanTextureCache SolidColorTextureCache; Conformance::StructuredBuffer SceneBuffer; - Conformance::StructuredBuffer ModelBuffer; Conformance::ScopedVkSampler BrdfSampler; Conformance::ScopedVkSampler EnvironmentMapSampler; std::shared_ptr DescriptorSetLayout; @@ -357,7 +353,6 @@ namespace Pbr DeviceResources Resources; Glsl::SceneConstantBuffer SceneBuffer; - Glsl::ModelConstantBuffer ModelBuffer; PipelineLayout::VulkanDescriptorSetLayout VulkanLayout{}; struct LoaderResources @@ -442,7 +437,7 @@ namespace Pbr : glMagFilter == TINYGLTF_TEXTURE_FILTER_LINEAR ? VK_FILTER_LINEAR : VK_FILTER_NEAREST; } - // Create a Vulkan sampler from a tinygltf Sampler. + /// Create a Vulkan sampler from a tinygltf Sampler. static VkSampler CreateGLTFSampler(VkDevice device, const tinygltf::Sampler& sampler) { VkSamplerCreateInfo info{VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO}; @@ -512,9 +507,9 @@ namespace Pbr m_impl->Resources.BrdfLut = std::move(brdfLut); } - std::unique_ptr - VulkanResources::BuildWriteDescriptorSets(VkDescriptorBufferInfo materialConstantBuffer, VkDescriptorBufferInfo transformBuffer, - nonstd::span materialCombinedImageSamplers, VkDescriptorSet dstSet) + std::unique_ptr VulkanResources::BuildWriteDescriptorSets( + VkDescriptorBufferInfo modelConstantBuffer, VkDescriptorBufferInfo materialConstantBuffer, VkDescriptorBufferInfo transformBuffer, + nonstd::span materialCombinedImageSamplers, VkDescriptorSet dstSet) { PipelineLayout::VulkanWriteDescriptorSetsBuilder builder(m_impl->VulkanLayout, dstSet); @@ -525,10 +520,7 @@ namespace Pbr builder.BindBuffers(PipelineLayout::SceneConstantBuffer, sceneConstantBuffer); // ModelConstantBuffer - VkDescriptorBufferInfo modelConstantBuffer[] = { - m_impl->Resources.ModelBuffer.MakeDescriptor(), - }; - builder.BindBuffers(PipelineLayout::ModelConstantBuffer, modelConstantBuffer); + builder.BindBuffers(PipelineLayout::ModelConstantBuffer, {&modelConstantBuffer, 1}); // MaterialConstantBuffer builder.BindBuffers(PipelineLayout::MaterialConstantBuffer, {&materialConstantBuffer, 1}); @@ -567,12 +559,6 @@ namespace Pbr m_impl->SceneBuffer.LightDiffuseColor = diffuseColor; } - void VulkanResources::SetModelToWorld(XrMatrix4x4f modelToWorld) const - { - m_impl->ModelBuffer.ModelToWorld = modelToWorld; - m_impl->Resources.ModelBuffer.Update({&m_impl->ModelBuffer, 1}); - } - void VulkanResources::SetViewProjection(XrMatrix4x4f view, XrMatrix4x4f projection) const { XrMatrix4x4f_Multiply(&m_impl->SceneBuffer.ViewProjection, &projection, &view); @@ -704,3 +690,5 @@ namespace Pbr } } // namespace Pbr + +#endif // defined(XR_USE_GRAPHICS_API_VULKAN) diff --git a/src/conformance/framework/pbr/Vulkan/VkResources.h b/src/conformance/framework/pbr/Vulkan/VkResources.h index 4391d2d8..d0b6ba43 100644 --- a/src/conformance/framework/pbr/Vulkan/VkResources.h +++ b/src/conformance/framework/pbr/Vulkan/VkResources.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -22,15 +22,12 @@ #include #include #include -#include #include #include -#include #include #include #include -#include class VulkanDebugObjectNamer; @@ -47,10 +44,6 @@ namespace tinygltf struct Sampler; } // namespace tinygltf -// namespace Conformance -// { -// struct MemoryAllocator; -// } namespace Pbr { struct Primitive; @@ -64,15 +57,12 @@ namespace Pbr struct VulkanTextureAndSampler : public ITexture { ~VulkanTextureAndSampler() override = default; - /// Required - // Microsoft::WRL::ComPtr texture; - /// Optional - // Vulkan_SAMPLER_DESC sampler; bool samplerSet; }; static constexpr size_t BindingCount = ShaderSlots::NumConstantBuffers + ShaderSlots::NumVSResourceViews + ShaderSlots::NumTextures; + class VulkanWriteDescriptorSets { public: @@ -103,7 +93,7 @@ namespace Pbr VulkanWriteDescriptorSets& operator=(VulkanWriteDescriptorSets&&) = delete; }; - // Global PBR resources required for rendering a scene. + /// Global PBR resources required for rendering a scene. struct VulkanResources final : public IResources { VulkanResources(const VulkanDebugObjectNamer& namer, VkPhysicalDevice physicalDevice, VkDevice device, uint32_t queueFamilyIndex); @@ -122,38 +112,35 @@ namespace Pbr const std::shared_ptr& material) override; void DropLoaderCaches() override; - // Sets the Bidirectional Reflectance Distribution Function Lookup Table texture, required by the shader to compute surface - // reflectance from the IBL. + /// Sets the Bidirectional Reflectance Distribution Function Lookup Table texture, required by the shader to compute surface + /// reflectance from the IBL. void SetBrdfLut(std::shared_ptr brdfLut); - // Get a pipeline state matching some parameters as well as the current settings inside VkResources + /// Get a pipeline state matching some parameters as well as the current settings inside VkResources Conformance::Pipeline& GetOrCreatePipeline(VkRenderPass renderPass, VkSampleCountFlagBits sampleCount, BlendState blendState, DoubleSided doubleSided); - // Set the directional light. + /// Set the directional light. void SetLight(XrVector3f direction, RGBColor diffuseColor); - // Set the specular and diffuse image-based lighting (IBL) maps. ShaderResourceViews must be TextureCubes. + /// Set the specular and diffuse image-based lighting (IBL) maps. ShaderResourceViews must be TextureCubes. void SetEnvironmentMap(std::shared_ptr specularEnvironmentMap, std::shared_ptr diffuseEnvironmentMap); - // Set the current view and projection matrices. + /// Set the current view and projection matrices. void SetViewProjection(XrMatrix4x4f view, XrMatrix4x4f projection) const; - // Many 1x1 pixel colored textures are used in the PBR system. This is used to create textures backed by a cache to reduce the - // number of textures created. + /// Many 1x1 pixel colored textures are used in the PBR system. This is used to create textures backed by a cache to reduce the + /// number of textures created. std::shared_ptr CreateTypedSolidColorTexture(RGBAColor color); - // Update the scene buffer in GPU memory. + /// Update the scene buffer in GPU memory. void UpdateBuffer() const; - // Get the fence to wait on before executing any command list built on this Resources. - // std::pair GetFenceAndValue() const; - - // Set and update the model to world constant buffer value. - void SetModelToWorld(XrMatrix4x4f modelToWorld) const; - + /// Get the VulkanPrimitive from a primitive handle. VulkanPrimitive& GetPrimitive(PrimitiveHandle p); + + /// Get the VulkanPrimitive from a primitive handle, const overload. const VulkanPrimitive& GetPrimitive(PrimitiveHandle p) const; // Set or get the shading and fill modes. @@ -176,13 +163,13 @@ namespace Pbr private: std::unique_ptr - BuildWriteDescriptorSets(VkDescriptorBufferInfo materialConstantBuffer, VkDescriptorBufferInfo transformBuffer, - nonstd::span materialCombinedImageSamplers, VkDescriptorSet dstSet); + BuildWriteDescriptorSets(VkDescriptorBufferInfo modelConstantBuffer, VkDescriptorBufferInfo materialConstantBuffer, + VkDescriptorBufferInfo transformBuffer, nonstd::span materialCombinedImageSamplers, + VkDescriptorSet dstSet); friend struct VulkanMaterial; friend struct VulkanPrimitive; struct Impl; - std::unique_ptr m_impl; SharedState m_sharedState; diff --git a/src/conformance/framework/pbr/Vulkan/VkTexture.cpp b/src/conformance/framework/pbr/Vulkan/VkTexture.cpp index bc334f07..531e7b14 100644 --- a/src/conformance/framework/pbr/Vulkan/VkTexture.cpp +++ b/src/conformance/framework/pbr/Vulkan/VkTexture.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -7,6 +7,8 @@ // // SPDX-License-Identifier: MIT AND Apache-2.0 +#if defined(XR_USE_GRAPHICS_API_VULKAN) + #include "VkTexture.h" #include "VkCommon.h" @@ -21,6 +23,7 @@ #include "utilities/vulkan_utils.h" #include +#include #include #include #include @@ -58,53 +61,6 @@ namespace Pbr const uint8_t* rgba, uint32_t elemSize, uint32_t width, uint32_t height, bool cubemap, VkFormat format) { - // Microsoft::WRL::ComPtr device = pbrResources.GetDevice(); - - // Microsoft::WRL::ComPtr cmdList = pbrResources.CreateCopyCommandList(); - - // std::vector> imageUploadBuffers; - // Microsoft::WRL::ComPtr image = - // Conformance::VulkanCreateImage(device.get(), width, height, arraySize, format, Vulkan_HEAP_TYPE_DEFAULT); - - // Vulkan_RESOURCE_DESC imageDesc = image->GetDesc(); - // assert(imageDesc.DepthOrArraySize == arraySize); - // imageUploadBuffers.reserve(arraySize); - // // TODO: maybe call GetCopyableFootprints only once, as all out fields accept arrays - // // TODO: put the upload buffer in a staging resources vector and make async - // for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { - // UINT subresourceIndex = VulkanCalcSubresource(0, arrayIndex, 0, imageDesc.MipLevels, arraySize); - - // Vulkan_PLACED_SUBRESOURCE_FOOTPRINT footprint; - // UINT rowCount; - // UINT64 rowSize; - // UINT64 uploadBufferSize; - // device->GetCopyableFootprints(&imageDesc, subresourceIndex, 1, 0, &footprint, &rowCount, &rowSize, &uploadBufferSize); - - // assert( - // rowCount == - // height); // doesn't hold for compressed textures, see: https://www.gamedev.net/forums/topic/677932-getcopyablefootprints-question/ - // assert(rowSize == width * elemSize); // assert this for now, probably doesn't hold for e.g. compressed textures - - // Microsoft::WRL::ComPtr imageUpload = - // Conformance::VulkanCreateBuffer(device.get(), (uint32_t)uploadBufferSize, Vulkan_HEAP_TYPE_UPLOAD); - // imageUploadBuffers.push_back(imageUpload); - - // Vulkan_SUBRESOURCE_DATA initData{}; - // initData.pData = rgba; - // initData.RowPitch = elemSize * width; - // initData.SlicePitch = elemSize * width * height; - - // // this does a row-by-row memcpy internally or we would have used our own CopyWithStride - // Internal::ThrowIf(!UpdateSubresources(cmdList.get(), image.get(), imageUpload.get(), 0, 1, uploadBufferSize, &footprint, - // &rowCount, &rowSize, &initData), - // "Call to UpdateSubresources helper failed"); - // } - - // XRC_CHECK_THROW_HRCMD(cmdList->Close()); - // pbrResources.ExecuteCopyCommandList(cmdList.get(), std::move(imageUploadBuffers)); - - // return image; - VkDevice device = pbrResources.GetDevice(); const Conformance::MemoryAllocator& memAllocator = pbrResources.GetMemoryAllocator(); const Conformance::CmdBuffer& copyCmdBuffer = pbrResources.GetCopyCommandBuffer(); @@ -121,11 +77,11 @@ namespace Pbr // Create a staging buffer VkBufferCreateInfo bufferCreateInfo{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; - bufferCreateInfo.size = width * height * elemSize; + bufferCreateInfo.size = static_cast(width) * height * elemSize; Conformance::BufferAndMemory stagingBuffer; stagingBuffer.Create(device, memAllocator, bufferCreateInfo); - stagingBuffer.Update(device, {rgba, width * height * elemSize}, 0); + stagingBuffer.Update(device, {rgba, static_cast(bufferCreateInfo.size)}, 0); // create image VkImage image{VK_NULL_HANDLE}; @@ -157,24 +113,6 @@ namespace Pbr bundle.deviceMemory = Conformance::ScopedVkDeviceMemory(imageMemory, device); - // // Switch the source buffer to TRANSFER_DST_OPTIMAL - // VkBufferMemoryBarrier bufferBarrier{VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER}; - // // VkAccessFlags srcAccessMask; - // // VkAccessFlags dstAccessMask; - // // uint32_t srcQueueFamilyIndex; - // // uint32_t dstQueueFamilyIndex; - // // VkBuffer buffer; - // // VkDeviceSize offset; - // // VkDeviceSize size; - // bufferBarrier.srcAccessMask = 0; - // bufferBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; - // bufferBarrier.oldLayout = VK_BUFFER_; - // bufferBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - // bufferBarrier.= stagingBuffer.buf; - // bufferBarrier.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, layerCount}; - // vkCmdPipelineBarrier(copyCmdBuffer.buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, - // nullptr, 1, &bufferBarrier); - // Switch the destination image to TRANSFER_DST_OPTIMAL VkImageMemoryBarrier imgBarrier{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; imgBarrier.srcAccessMask = 0; @@ -313,3 +251,5 @@ namespace Pbr } } // namespace VulkanTexture } // namespace Pbr + +#endif // defined(XR_USE_GRAPHICS_API_VULKAN) diff --git a/src/conformance/framework/pbr/Vulkan/VkTexture.h b/src/conformance/framework/pbr/Vulkan/VkTexture.h index e03fda93..129bbc75 100644 --- a/src/conformance/framework/pbr/Vulkan/VkTexture.h +++ b/src/conformance/framework/pbr/Vulkan/VkTexture.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // diff --git a/src/conformance/framework/pbr/Vulkan/VkTextureCache.cpp b/src/conformance/framework/pbr/Vulkan/VkTextureCache.cpp index 40ccf2b5..7f8c3f0d 100644 --- a/src/conformance/framework/pbr/Vulkan/VkTextureCache.cpp +++ b/src/conformance/framework/pbr/Vulkan/VkTextureCache.cpp @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -7,6 +7,8 @@ // // SPDX-License-Identifier: MIT AND Apache-2.0 +#if defined(XR_USE_GRAPHICS_API_VULKAN) + #include "VkTextureCache.h" #include "VkCommon.h" @@ -56,3 +58,5 @@ namespace Pbr return m_solidColorTextureCache.emplace(colorKey, texture).first->second; } } // namespace Pbr + +#endif // defined(XR_USE_GRAPHICS_API_VULKAN) diff --git a/src/conformance/framework/pbr/Vulkan/VkTextureCache.h b/src/conformance/framework/pbr/Vulkan/VkTextureCache.h index dce69665..a1a80f47 100644 --- a/src/conformance/framework/pbr/Vulkan/VkTextureCache.h +++ b/src/conformance/framework/pbr/Vulkan/VkTextureCache.h @@ -1,4 +1,4 @@ -// Copyright 2023, The Khronos Group, Inc. +// Copyright 2023-2024, The Khronos Group Inc. // // Based in part on code that is: // @@ -34,9 +34,6 @@ namespace Pbr /// Default constructor makes an invalid cache. VulkanTextureCache() = default; - // VulkanTextureCache(const VulkanTextureCache&) = default; - // VulkanTextureCache& operator=(const VulkanTextureCache&) = default; - VulkanTextureCache(VulkanTextureCache&&) = default; VulkanTextureCache& operator=(VulkanTextureCache&&) = default; diff --git a/src/conformance/framework/pbr/check-offsets.py b/src/conformance/framework/pbr/check-offsets.py new file mode 100755 index 00000000..7c6aea95 --- /dev/null +++ b/src/conformance/framework/pbr/check-offsets.py @@ -0,0 +1,260 @@ +#!/usr/bin/env python3 +# Copyright 2023-2024, The Khronos Group, Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +import os +import subprocess +from pathlib import Path +from dataclasses import dataclass, field +import re +import sys +from typing import Dict, List, Optional, Tuple + +_PBR_DIR = Path(__file__).parent.resolve() + +_SHADER = "PbrPixelShader_glsl.frag" + +_GL_TYPES = { + 0x8B51: "GL_FLOAT_VEC3", + 0x1405: "GL_UNSIGNED_INT", # 32 bit (4 bytes) + 0x1406: "GL_FLOAT", # 32 bit (4 bytes) +} + + +@dataclass +class GlslObjectReflectionData: + name: str + offset: int + data_type: int # typically shown in hex + size: int + index: int + binding: int + stages: int + counter: Optional[int] = None + num_members: Optional[int] = None + array_stride: Optional[int] = None + top_level_array_stride: Optional[int] = None + + +def parse_reflection_line(line: str) -> GlslObjectReflectionData: + """ + Process a single object reflection dump line from glslangValidator. + + Parses the output of TObjectReflection::dump(), effectively. + + See: + https://github.com/KhronosGroup/glslang/blob/db4d6f85afb8cf6aa404a141855f556d172c1ed2/glslang/MachineIndependent/reflection.cpp#L1092 + """ + name, _, all_fields = line.strip().partition(": ") + if all_fields is None: + raise RuntimeError( + f"Could not parse line as a reflection data line: {all_fields}" + ) + # field_list = [] + # fields = {name: val for name, val in field_list} + fields = dict(field.split(" ") for field in all_fields.split(", ")) + + # These fields are always printed - see TObjectReflection::dump + # So, let's parse them. + + offset = int(fields["offset"]) + + # parse hex + data_type = int(fields["type"], 16) + + size = int(fields["size"]) + + index = int(fields["index"]) + + binding = int(fields["binding"]) + + stages = int(fields["stages"]) + data = GlslObjectReflectionData( + name=name, + offset=offset, + data_type=data_type, + size=size, + index=index, + binding=binding, + stages=stages, + ) + + # These are not always printed + counter = fields.get("counter") + if counter is not None: + data.counter = int(counter) + + num_members = fields.get("numMembers") + if num_members is not None: + data.num_members = int(num_members) + + array_stride = fields.get("arrayStride") + if array_stride is not None: + data.array_stride = int(array_stride) + + top_level_array_stride = fields.get("topLevelArrayStride") + if top_level_array_stride is not None: + data.top_level_array_stride = int(top_level_array_stride) + + return data + + +def process_reflection_data_section( + reflection_lines: List[str], heading: str +) -> Dict[str, GlslObjectReflectionData]: + """ + Process a section of reflection data from glslangValidator. + + Effectively handles a single section (loop) from TReflection::dump() + + See: + https://github.com/KhronosGroup/glslang/blob/db4d6f85afb8cf6aa404a141855f556d172c1ed2/glslang/MachineIndependent/reflection.cpp#L1222 + """ + start_idx = reflection_lines.index(heading) + end_idx = None + try: + end_idx = reflection_lines.index("", start_idx + 1) + except ValueError: + # don't care, last section + pass + if end_idx is None: + section_lines = reflection_lines[start_idx + 1 :] + else: + section_lines = reflection_lines[start_idx + 1 : end_idx - 1] + ret = {} + for line in section_lines: + data = parse_reflection_line(line) + ret[data.name] = data + return ret + + +@dataclass +class ReflectionData: + uniforms: Dict[str, GlslObjectReflectionData] = field(default_factory=dict) + + +def compile_and_get_reflection_data( + shader_source: Path, glslangvalidator_cmd: str = "glslangValidator" +) -> ReflectionData: + output = subprocess.check_output( + [glslangvalidator_cmd, "-V", str(shader_source), "-q"] + ) + + ret = ReflectionData() + + lines = [line.strip().decode(encoding="utf-8") for line in output.splitlines()] + start_uniform = lines.index("Uniform reflection:") + end_uniform = lines.index("", start_uniform + 1) + uniform_lines = lines[start_uniform + 1 : end_uniform - 1] + for line in uniform_lines: + data = parse_reflection_line(line) + ret.uniforms[data.name] = data + + return ret + + +@dataclass +class COffsetData: + structure_type: str + member_name: str + offset: int + + +_RE_OFFSET_ASSERTS = re.compile( + r"offsetof\((?P[A-Za-z]+), (?P[A-Za-z]+)\) == (?P[0-9]+)," +) + + +def parse_c_offsets(source: Path) -> Dict[Tuple[str, str], COffsetData]: + ret = {} + with open(source, "r", encoding="utf-8") as fp: + for line in fp: + m = _RE_OFFSET_ASSERTS.search(line) + if m: + structure_type = m.group("structure_type") + member_name = m.group("member_name") + offset = int(m.group("offset")) + ret[(structure_type, member_name)] = COffsetData( + structure_type=structure_type, + member_name=member_name, + offset=offset, + ) + return ret + + +def compare_glsl_and_c( + shader_data: ReflectionData, + source_data: Dict[Tuple[str, str], COffsetData], + glsl_qualified_member: str, + c_structure: str, + c_member: str, +): + uniform_data = shader_data.uniforms.get(glsl_qualified_member) + if uniform_data is None: + raise RuntimeError( + f"Could not find qualified GLSL name {glsl_qualified_member} in reflection data!" + ) + c_data = source_data.get((c_structure, c_member)) + if c_data is None: + raise RuntimeError( + f"Could not find parsed source code offset assertion for type {c_structure}, member name {c_member}" + ) + + glsl_offset = shader_data.uniforms[glsl_qualified_member].offset + c_offset = c_data.offset + gl_type_enum = shader_data.uniforms[glsl_qualified_member].data_type + # print(f"GLSL: datatype: {gl_type_enum:04x}") + gl_type_name = _GL_TYPES[gl_type_enum] + + print( + f"GLSL: offset {glsl_offset:03d} {glsl_qualified_member} (datatype: {gl_type_name})" + ) + print(f"C: offset {c_offset:03d} {c_structure}.{c_member}") + if glsl_offset != c_offset: + raise RuntimeError("Mismatch!") + + +if __name__ == "__main__": + shader = _PBR_DIR / "Shaders" / _SHADER + + if len(sys.argv) > 1: + glslangValidator = sys.argv[1] + else: + + # glslangValidator = os.getenv("GLSLANGVALIDATOR") + # if not glslangValidator: + glslangValidator = "glslangValidator" + + shader_data = compile_and_get_reflection_data(shader, glslangValidator) + + source_data = parse_c_offsets(_PBR_DIR / "GlslBuffers.h") + + compare_glsl_and_c( + shader_data, + source_data, + "type_SceneBuffer.EyePosition", + "SceneConstantBuffer", + "EyePosition", + ) + compare_glsl_and_c( + shader_data, + source_data, + "type_SceneBuffer.LightDirection", + "SceneConstantBuffer", + "LightDirection", + ) + compare_glsl_and_c( + shader_data, + source_data, + "type_SceneBuffer.LightColor", + "SceneConstantBuffer", + "LightDiffuseColor", + ) + compare_glsl_and_c( + shader_data, + source_data, + "type_SceneBuffer.NumSpecularMipLevels", + "SceneConstantBuffer", + "NumSpecularMipLevels", + ) diff --git a/src/conformance/framework/platform_plugin.h b/src/conformance/framework/platform_plugin.h index 827f24f2..d0103f6f 100644 --- a/src/conformance/framework/platform_plugin.h +++ b/src/conformance/framework/platform_plugin.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/platform_plugin_android.cpp b/src/conformance/framework/platform_plugin_android.cpp index 614463a0..849be94d 100644 --- a/src/conformance/framework/platform_plugin_android.cpp +++ b/src/conformance/framework/platform_plugin_android.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/platform_plugin_posix.cpp b/src/conformance/framework/platform_plugin_posix.cpp index 776768b9..84ce9d19 100644 --- a/src/conformance/framework/platform_plugin_posix.cpp +++ b/src/conformance/framework/platform_plugin_posix.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/platform_plugin_win32.cpp b/src/conformance/framework/platform_plugin_win32.cpp index e5e050fb..506cd676 100644 --- a/src/conformance/framework/platform_plugin_win32.cpp +++ b/src/conformance/framework/platform_plugin_win32.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/report.cpp b/src/conformance/framework/report.cpp index ea0c0b4e..47ab7708 100644 --- a/src/conformance/framework/report.cpp +++ b/src/conformance/framework/report.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/report.h b/src/conformance/framework/report.h index e8daf086..df01bf53 100644 --- a/src/conformance/framework/report.h +++ b/src/conformance/framework/report.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/framework/swapchain_image_data.cpp b/src/conformance/framework/swapchain_image_data.cpp index d7d8eff9..f8a78264 100644 --- a/src/conformance/framework/swapchain_image_data.cpp +++ b/src/conformance/framework/swapchain_image_data.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/swapchain_image_data.h b/src/conformance/framework/swapchain_image_data.h index 0211a5b2..8ab379df 100644 --- a/src/conformance/framework/swapchain_image_data.h +++ b/src/conformance/framework/swapchain_image_data.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/two_call.h b/src/conformance/framework/two_call.h index d3c41f1d..ada3089f 100644 --- a/src/conformance/framework/two_call.h +++ b/src/conformance/framework/two_call.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/two_call_struct.h b/src/conformance/framework/two_call_struct.h index 5ae1d9db..ef0fdaa5 100644 --- a/src/conformance/framework/two_call_struct.h +++ b/src/conformance/framework/two_call_struct.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/two_call_struct_metadata.h b/src/conformance/framework/two_call_struct_metadata.h index f256ebf4..2fd24181 100644 --- a/src/conformance/framework/two_call_struct_metadata.h +++ b/src/conformance/framework/two_call_struct_metadata.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/two_call_struct_tests.h b/src/conformance/framework/two_call_struct_tests.h index 8f214560..d44bdc46 100644 --- a/src/conformance/framework/two_call_struct_tests.h +++ b/src/conformance/framework/two_call_struct_tests.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/two_call_util.h b/src/conformance/framework/two_call_util.h index 73cbef96..27e9d49e 100644 --- a/src/conformance/framework/two_call_util.h +++ b/src/conformance/framework/two_call_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2018-2019 Collabora, Ltd. // SPDX-License-Identifier: Apache-2.0 // @@ -24,7 +24,7 @@ * Based in part on xrtraits/TwoCall.h from https://gitlab.freedesktop.org/monado/utilities/xrtraits * (More complete functionality is available there under BSL-1.0) * - * @author Ryan Pavlik + * @author Rylie Pavlik */ #pragma once diff --git a/src/conformance/framework/type_utils.h b/src/conformance/framework/type_utils.h index 07548112..f28bf32c 100644 --- a/src/conformance/framework/type_utils.h +++ b/src/conformance/framework/type_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/vulkan_shaders/frag.glsl b/src/conformance/framework/vulkan_shaders/frag.glsl index dd397ce5..c010c05b 100644 --- a/src/conformance/framework/vulkan_shaders/frag.glsl +++ b/src/conformance/framework/vulkan_shaders/frag.glsl @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/vulkan_shaders/frag.spv.license b/src/conformance/framework/vulkan_shaders/frag.spv.license index 1811d391..3caf3ed8 100644 --- a/src/conformance/framework/vulkan_shaders/frag.spv.license +++ b/src/conformance/framework/vulkan_shaders/frag.spv.license @@ -1,3 +1,3 @@ -Copyright (c) 2017-2023, The Khronos Group Inc. +Copyright (c) 2017-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/vulkan_shaders/vert.glsl b/src/conformance/framework/vulkan_shaders/vert.glsl index 2b959395..54e54272 100644 --- a/src/conformance/framework/vulkan_shaders/vert.glsl +++ b/src/conformance/framework/vulkan_shaders/vert.glsl @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/vulkan_shaders/vert.spv.license b/src/conformance/framework/vulkan_shaders/vert.spv.license index 1811d391..3caf3ed8 100644 --- a/src/conformance/framework/vulkan_shaders/vert.spv.license +++ b/src/conformance/framework/vulkan_shaders/vert.spv.license @@ -1,3 +1,3 @@ -Copyright (c) 2017-2023, The Khronos Group Inc. +Copyright (c) 2017-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/xml_test_environment.cpp b/src/conformance/framework/xml_test_environment.cpp index ff48f858..aad0cf67 100644 --- a/src/conformance/framework/xml_test_environment.cpp +++ b/src/conformance/framework/xml_test_environment.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/framework/xml_test_environment.h b/src/conformance/framework/xml_test_environment.h index 8049d1f8..ff969eb5 100644 --- a/src/conformance/framework/xml_test_environment.h +++ b/src/conformance/framework/xml_test_environment.h @@ -1,4 +1,4 @@ -// Copyright (c) 2023, The Khronos Group Inc. +// Copyright (c) 2023-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/gradle.properties b/src/conformance/gradle.properties index f4e35f07..17834714 100644 --- a/src/conformance/gradle.properties +++ b/src/conformance/gradle.properties @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 The Khronos Group Inc. +# Copyright (c) 2020-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/platform_specific/AndroidManifest.xml b/src/conformance/platform_specific/AndroidManifest.xml index 94cb24b1..165a8cbe 100644 --- a/src/conformance/platform_specific/AndroidManifest.xml +++ b/src/conformance/platform_specific/AndroidManifest.xml @@ -5,7 +5,7 @@ android:versionCode="1" android:versionName="1.0"> diff --git a/src/conformance/platform_specific/android_intent_extras.cpp b/src/conformance/platform_specific/android_intent_extras.cpp index 57bd9699..a55432d5 100644 --- a/src/conformance/platform_specific/android_intent_extras.cpp +++ b/src/conformance/platform_specific/android_intent_extras.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 #include "android_intent_extras.h" diff --git a/src/conformance/platform_specific/android_intent_extras.h b/src/conformance/platform_specific/android_intent_extras.h index 1e799df8..3d287ab3 100644 --- a/src/conformance/platform_specific/android_intent_extras.h +++ b/src/conformance/platform_specific/android_intent_extras.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/platform_specific/android_main.cpp b/src/conformance/platform_specific/android_main.cpp index 734ac48b..472535c6 100644 --- a/src/conformance/platform_specific/android_main.cpp +++ b/src/conformance/platform_specific/android_main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/platform_specific/android_resources/drawable/ic_launcher_foreground.xml b/src/conformance/platform_specific/android_resources/drawable/ic_launcher_foreground.xml index ea4d6e26..ff2b6bb3 100644 --- a/src/conformance/platform_specific/android_resources/drawable/ic_launcher_foreground.xml +++ b/src/conformance/platform_specific/android_resources/drawable/ic_launcher_foreground.xml @@ -5,7 +5,7 @@ android:viewportHeight="108" android:tint="#FFFFFF"> diff --git a/src/conformance/settings.gradle b/src/conformance/settings.gradle index ee7baa55..cd1c8f20 100644 --- a/src/conformance/settings.gradle +++ b/src/conformance/settings.gradle @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2023, The Khronos Group Inc. +// Copyright (c) 2020-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/CMakeLists.txt b/src/conformance/utilities/CMakeLists.txt index f8b4e075..119b37a3 100644 --- a/src/conformance/utilities/CMakeLists.txt +++ b/src/conformance/utilities/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 @@ -57,6 +57,7 @@ add_library( throw_helpers.cpp types_and_constants.cpp utils.cpp + uuid_utils.cpp "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" ) diff --git a/src/conformance/utilities/Geometry.cpp b/src/conformance/utilities/Geometry.cpp index 7eaf0309..178b0749 100644 --- a/src/conformance/utilities/Geometry.cpp +++ b/src/conformance/utilities/Geometry.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/Geometry.h b/src/conformance/utilities/Geometry.h index 4bd3b85a..de687270 100644 --- a/src/conformance/utilities/Geometry.h +++ b/src/conformance/utilities/Geometry.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/align_to.h b/src/conformance/utilities/align_to.h index c737f806..06e425c5 100644 --- a/src/conformance/utilities/align_to.h +++ b/src/conformance/utilities/align_to.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/android_declarations.h b/src/conformance/utilities/android_declarations.h index 31017913..743d064c 100644 --- a/src/conformance/utilities/android_declarations.h +++ b/src/conformance/utilities/android_declarations.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/array_size.h b/src/conformance/utilities/array_size.h index e1c1351f..02e3e99d 100644 --- a/src/conformance/utilities/array_size.h +++ b/src/conformance/utilities/array_size.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/bitmask_generator.cpp b/src/conformance/utilities/bitmask_generator.cpp index 6bd4c6a5..cfec382b 100644 --- a/src/conformance/utilities/bitmask_generator.cpp +++ b/src/conformance/utilities/bitmask_generator.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 @@ -17,7 +17,7 @@ /*! * @file * @brief Implementation - * @author Ryan Pavlik + * @author Rylie Pavlik */ #include "bitmask_generator.h" diff --git a/src/conformance/utilities/bitmask_generator.h b/src/conformance/utilities/bitmask_generator.h index 31d9b1d3..08780ac0 100644 --- a/src/conformance/utilities/bitmask_generator.h +++ b/src/conformance/utilities/bitmask_generator.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 @@ -22,7 +22,7 @@ * * See the xrCreateSwapchain test for examples of usage. * - * @author Ryan Pavlik + * @author Rylie Pavlik */ #pragma once diff --git a/src/conformance/utilities/bitmask_to_string.cpp b/src/conformance/utilities/bitmask_to_string.cpp index 50fdb9a9..5f414570 100644 --- a/src/conformance/utilities/bitmask_to_string.cpp +++ b/src/conformance/utilities/bitmask_to_string.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/bitmask_to_string.h b/src/conformance/utilities/bitmask_to_string.h index eb31b963..06dec935 100644 --- a/src/conformance/utilities/bitmask_to_string.h +++ b/src/conformance/utilities/bitmask_to_string.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/colors.h b/src/conformance/utilities/colors.h index a363171f..546689e5 100644 --- a/src/conformance/utilities/colors.h +++ b/src/conformance/utilities/colors.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/d3d12_queue_wrapper.cpp b/src/conformance/utilities/d3d12_queue_wrapper.cpp index b1e8cb98..f3ceb33e 100644 --- a/src/conformance/utilities/d3d12_queue_wrapper.cpp +++ b/src/conformance/utilities/d3d12_queue_wrapper.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/d3d12_queue_wrapper.h b/src/conformance/utilities/d3d12_queue_wrapper.h index 6a30b96c..87ffebae 100644 --- a/src/conformance/utilities/d3d12_queue_wrapper.h +++ b/src/conformance/utilities/d3d12_queue_wrapper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/d3d12_utils.cpp b/src/conformance/utilities/d3d12_utils.cpp index 904a9ad5..abb740c2 100644 --- a/src/conformance/utilities/d3d12_utils.cpp +++ b/src/conformance/utilities/d3d12_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/d3d12_utils.h b/src/conformance/utilities/d3d12_utils.h index 1d67756f..4badb800 100644 --- a/src/conformance/utilities/d3d12_utils.h +++ b/src/conformance/utilities/d3d12_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/d3d_common.cpp b/src/conformance/utilities/d3d_common.cpp index 8a82a881..e4268e5d 100644 --- a/src/conformance/utilities/d3d_common.cpp +++ b/src/conformance/utilities/d3d_common.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/d3d_common.h b/src/conformance/utilities/d3d_common.h index 2fa3ccad..4ea7831c 100644 --- a/src/conformance/utilities/d3d_common.h +++ b/src/conformance/utilities/d3d_common.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 #pragma once diff --git a/src/conformance/utilities/destruction_queue.h b/src/conformance/utilities/destruction_queue.h index 222c8d2f..d85ab529 100644 --- a/src/conformance/utilities/destruction_queue.h +++ b/src/conformance/utilities/destruction_queue.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/event_reader.cpp b/src/conformance/utilities/event_reader.cpp index 80e8ff85..32576978 100644 --- a/src/conformance/utilities/event_reader.cpp +++ b/src/conformance/utilities/event_reader.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/event_reader.h b/src/conformance/utilities/event_reader.h index 1637f61c..7fe2245e 100644 --- a/src/conformance/utilities/event_reader.h +++ b/src/conformance/utilities/event_reader.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/generator.h b/src/conformance/utilities/generator.h index 85a2c7ca..cea201b6 100644 --- a/src/conformance/utilities/generator.h +++ b/src/conformance/utilities/generator.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 @@ -17,7 +17,7 @@ /*! * @file * @brief Header for functionality similar to the Catch2 generators, but customized for our needs. - * @author Ryan Pavlik + * @author Rylie Pavlik */ #pragma once diff --git a/src/conformance/utilities/git_revision.cpp.in b/src/conformance/utilities/git_revision.cpp.in index 6cd51fa6..3737ad7a 100644 --- a/src/conformance/utilities/git_revision.cpp.in +++ b/src/conformance/utilities/git_revision.cpp.in @@ -1,4 +1,4 @@ -// Copyright (c) 2023, The Khronos Group Inc. +// Copyright (c) 2023-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/git_revision.h b/src/conformance/utilities/git_revision.h index 1d40bd11..beb2bfe4 100644 --- a/src/conformance/utilities/git_revision.h +++ b/src/conformance/utilities/git_revision.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/opengl_utils.cpp b/src/conformance/utilities/opengl_utils.cpp index 38225fbf..0455e45f 100644 --- a/src/conformance/utilities/opengl_utils.cpp +++ b/src/conformance/utilities/opengl_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/opengl_utils.h b/src/conformance/utilities/opengl_utils.h index c50004ac..f5e208c3 100644 --- a/src/conformance/utilities/opengl_utils.h +++ b/src/conformance/utilities/opengl_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 #pragma once diff --git a/src/conformance/utilities/stringification.cpp b/src/conformance/utilities/stringification.cpp index b19ec833..24fe5edf 100644 --- a/src/conformance/utilities/stringification.cpp +++ b/src/conformance/utilities/stringification.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/stringification.h b/src/conformance/utilities/stringification.h index 616d8073..3999e873 100644 --- a/src/conformance/utilities/stringification.h +++ b/src/conformance/utilities/stringification.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/swapchain_format_data.cpp b/src/conformance/utilities/swapchain_format_data.cpp index 83507f49..49ffcb8f 100644 --- a/src/conformance/utilities/swapchain_format_data.cpp +++ b/src/conformance/utilities/swapchain_format_data.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/swapchain_format_data.h b/src/conformance/utilities/swapchain_format_data.h index 2a2baf28..46bac4a0 100644 --- a/src/conformance/utilities/swapchain_format_data.h +++ b/src/conformance/utilities/swapchain_format_data.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/swapchain_parameters.h b/src/conformance/utilities/swapchain_parameters.h index 72390906..a16db1c7 100644 --- a/src/conformance/utilities/swapchain_parameters.h +++ b/src/conformance/utilities/swapchain_parameters.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/system_properties_helper.h b/src/conformance/utilities/system_properties_helper.h index bdbfbd40..7b0d8bed 100644 --- a/src/conformance/utilities/system_properties_helper.h +++ b/src/conformance/utilities/system_properties_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/throw_helpers.cpp b/src/conformance/utilities/throw_helpers.cpp index b9a0227a..7d465284 100644 --- a/src/conformance/utilities/throw_helpers.cpp +++ b/src/conformance/utilities/throw_helpers.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/throw_helpers.h b/src/conformance/utilities/throw_helpers.h index 3378114a..29a0f423 100644 --- a/src/conformance/utilities/throw_helpers.h +++ b/src/conformance/utilities/throw_helpers.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/types_and_constants.cpp b/src/conformance/utilities/types_and_constants.cpp index a63b7243..a74eceee 100644 --- a/src/conformance/utilities/types_and_constants.cpp +++ b/src/conformance/utilities/types_and_constants.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/types_and_constants.h b/src/conformance/utilities/types_and_constants.h index 2a927882..de2b00e5 100644 --- a/src/conformance/utilities/types_and_constants.h +++ b/src/conformance/utilities/types_and_constants.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // Copyright (c) 2019 Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 @@ -110,6 +110,26 @@ namespace Conformance MAKE_CONVERSION_FUNCTION(XrSwapchain) MAKE_CONVERSION_FUNCTION(XrActionSet) MAKE_CONVERSION_FUNCTION(XrDebugUtilsMessengerEXT) + MAKE_CONVERSION_FUNCTION(XrSpatialAnchorMSFT) + MAKE_CONVERSION_FUNCTION(XrSpatialGraphNodeBindingMSFT) + MAKE_CONVERSION_FUNCTION(XrHandTrackerEXT) + MAKE_CONVERSION_FUNCTION(XrBodyTrackerFB) + MAKE_CONVERSION_FUNCTION(XrSceneObserverMSFT) + MAKE_CONVERSION_FUNCTION(XrSceneMSFT) + MAKE_CONVERSION_FUNCTION(XrFacialTrackerHTC) + MAKE_CONVERSION_FUNCTION(XrFoveationProfileFB) + MAKE_CONVERSION_FUNCTION(XrTriangleMeshFB) + MAKE_CONVERSION_FUNCTION(XrPassthroughFB) + MAKE_CONVERSION_FUNCTION(XrPassthroughLayerFB) + MAKE_CONVERSION_FUNCTION(XrGeometryInstanceFB) + MAKE_CONVERSION_FUNCTION(XrSpatialAnchorStoreConnectionMSFT) + MAKE_CONVERSION_FUNCTION(XrSpaceUserFB) + MAKE_CONVERSION_FUNCTION(XrFaceTrackerFB) + MAKE_CONVERSION_FUNCTION(XrEyeTrackerFB) + MAKE_CONVERSION_FUNCTION(XrVirtualKeyboardMETA) + MAKE_CONVERSION_FUNCTION(XrPassthroughColorLutMETA) + MAKE_CONVERSION_FUNCTION(XrPassthroughHTC) + MAKE_CONVERSION_FUNCTION(XrPlaneDetectorEXT) #else // 32-bit, just a uint64_t operator uint64_t() const diff --git a/src/conformance/utilities/utils.cpp b/src/conformance/utilities/utils.cpp index 51ecacae..0a6dff10 100644 --- a/src/conformance/utilities/utils.cpp +++ b/src/conformance/utilities/utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/utils.h b/src/conformance/utilities/utils.h index ef572faa..02263535 100644 --- a/src/conformance/utilities/utils.h +++ b/src/conformance/utilities/utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/src/conformance/utilities/uuid_utils.cpp b/src/conformance/utilities/uuid_utils.cpp new file mode 100644 index 00000000..78dc81a6 --- /dev/null +++ b/src/conformance/utilities/uuid_utils.cpp @@ -0,0 +1,50 @@ +// Copyright (c) 2019-2024, The Khronos Group Inc. +// +// SPDX-License-Identifier: Apache-2.0 + +#include "uuid_utils.h" + +#include +#include +#include + +bool operator==(const XrUuidEXT& lhs, const XrUuidEXT& rhs) +{ + return lhs.data[0] == rhs.data[0] && lhs.data[1] == rhs.data[1] && lhs.data[2] == rhs.data[2] && lhs.data[3] == rhs.data[3] && + lhs.data[4] == rhs.data[4] && lhs.data[5] == rhs.data[5] && lhs.data[6] == rhs.data[6] && lhs.data[7] == rhs.data[7] && + lhs.data[8] == rhs.data[8] && lhs.data[9] == rhs.data[9] && lhs.data[10] == rhs.data[10] && lhs.data[11] == rhs.data[11] && + lhs.data[12] == rhs.data[12] && lhs.data[13] == rhs.data[13] && lhs.data[14] == rhs.data[14] && lhs.data[15] == rhs.data[15]; +} + +bool operator!=(const XrUuidEXT& lhs, const XrUuidEXT& rhs) +{ + return !(lhs == rhs); +} + +std::string to_string(const XrUuidEXT& uuid) +{ + std::ostringstream oss; + // 8-4-4-4-12 format + // each byte is two digits + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[0]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[1]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[2]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[3]; + oss << '-'; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[4]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[5]; + oss << '-'; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[6]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[7]; + oss << '-'; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[8]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[9]; + oss << '-'; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[10]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[11]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[12]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[13]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[14]; + oss << std::hex << std::setw(2) << std::setfill('0') << uuid.data[15]; + return oss.str(); +} diff --git a/src/conformance/utilities/uuid_utils.h b/src/conformance/utilities/uuid_utils.h new file mode 100644 index 00000000..44cc8e69 --- /dev/null +++ b/src/conformance/utilities/uuid_utils.h @@ -0,0 +1,18 @@ +// Copyright (c) 2019-2024, The Khronos Group Inc. +// +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include + +/// Equality comparison for UUIDs +bool operator==(const XrUuidEXT& lhs, const XrUuidEXT& rhs); + +/// Inequality comparison for UUIDs +bool operator!=(const XrUuidEXT& lhs, const XrUuidEXT& rhs); + +/// Convert UUIDs to strings +std::string to_string(const XrUuidEXT& uuid); diff --git a/src/conformance/utilities/vulkan_scoped_handle.h b/src/conformance/utilities/vulkan_scoped_handle.h index ba40c074..2bf6a2f1 100644 --- a/src/conformance/utilities/vulkan_scoped_handle.h +++ b/src/conformance/utilities/vulkan_scoped_handle.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/vulkan_utils.h b/src/conformance/utilities/vulkan_utils.h index 5128519b..64b6be82 100644 --- a/src/conformance/utilities/vulkan_utils.h +++ b/src/conformance/utilities/vulkan_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/conformance/utilities/xrduration_literals.h b/src/conformance/utilities/xrduration_literals.h index fa335491..49c9c59b 100644 --- a/src/conformance/utilities/xrduration_literals.h +++ b/src/conformance/utilities/xrduration_literals.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/external/android-jni-wrappers/wrap/ObjectWrapperBase.h b/src/external/android-jni-wrappers/wrap/ObjectWrapperBase.h index fe76c4f4..5aff7664 100644 --- a/src/external/android-jni-wrappers/wrap/ObjectWrapperBase.h +++ b/src/external/android-jni-wrappers/wrap/ObjectWrapperBase.h @@ -1,6 +1,6 @@ // Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik +// Author: Rylie Pavlik #pragma once #include diff --git a/src/external/android-jni-wrappers/wrap/android.content.cpp b/src/external/android-jni-wrappers/wrap/android.content.cpp index b68274e9..5926a72f 100644 --- a/src/external/android-jni-wrappers/wrap/android.content.cpp +++ b/src/external/android-jni-wrappers/wrap/android.content.cpp @@ -1,6 +1,6 @@ // Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik +// Author: Rylie Pavlik #include "android.content.h" diff --git a/src/external/android-jni-wrappers/wrap/android.content.h b/src/external/android-jni-wrappers/wrap/android.content.h index e815e6cf..ba685e5e 100644 --- a/src/external/android-jni-wrappers/wrap/android.content.h +++ b/src/external/android-jni-wrappers/wrap/android.content.h @@ -1,6 +1,6 @@ // Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik +// Author: Rylie Pavlik #pragma once diff --git a/src/external/android-jni-wrappers/wrap/android.content.impl.h b/src/external/android-jni-wrappers/wrap/android.content.impl.h index 39956103..d16f504c 100644 --- a/src/external/android-jni-wrappers/wrap/android.content.impl.h +++ b/src/external/android-jni-wrappers/wrap/android.content.impl.h @@ -1,6 +1,6 @@ // Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik +// Author: Rylie Pavlik // Inline implementations: do not include on its own! #pragma once diff --git a/src/external/android-jni-wrappers/wrap/android.database.cpp b/src/external/android-jni-wrappers/wrap/android.database.cpp index f03e5730..05a0884e 100644 --- a/src/external/android-jni-wrappers/wrap/android.database.cpp +++ b/src/external/android-jni-wrappers/wrap/android.database.cpp @@ -1,6 +1,6 @@ // Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik +// Author: Rylie Pavlik #include "android.database.h" diff --git a/src/external/android-jni-wrappers/wrap/android.database.h b/src/external/android-jni-wrappers/wrap/android.database.h index 308fa2e0..be384f62 100644 --- a/src/external/android-jni-wrappers/wrap/android.database.h +++ b/src/external/android-jni-wrappers/wrap/android.database.h @@ -1,6 +1,6 @@ // Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik +// Author: Rylie Pavlik #pragma once diff --git a/src/external/android-jni-wrappers/wrap/android.database.impl.h b/src/external/android-jni-wrappers/wrap/android.database.impl.h index b48931ef..0c0d8446 100644 --- a/src/external/android-jni-wrappers/wrap/android.database.impl.h +++ b/src/external/android-jni-wrappers/wrap/android.database.impl.h @@ -1,6 +1,6 @@ // Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik +// Author: Rylie Pavlik // Inline implementations: do not include on its own! #pragma once diff --git a/src/external/android-jni-wrappers/wrap/android.net.cpp b/src/external/android-jni-wrappers/wrap/android.net.cpp index 5058d904..f46d5f5f 100644 --- a/src/external/android-jni-wrappers/wrap/android.net.cpp +++ b/src/external/android-jni-wrappers/wrap/android.net.cpp @@ -1,6 +1,6 @@ // Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik +// Author: Rylie Pavlik #include "android.net.h" diff --git a/src/external/android-jni-wrappers/wrap/android.net.h b/src/external/android-jni-wrappers/wrap/android.net.h index 7a77864a..94851652 100644 --- a/src/external/android-jni-wrappers/wrap/android.net.h +++ b/src/external/android-jni-wrappers/wrap/android.net.h @@ -1,6 +1,6 @@ // Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik +// Author: Rylie Pavlik #pragma once diff --git a/src/external/android-jni-wrappers/wrap/android.net.impl.h b/src/external/android-jni-wrappers/wrap/android.net.impl.h index a8a927d9..f570c47b 100644 --- a/src/external/android-jni-wrappers/wrap/android.net.impl.h +++ b/src/external/android-jni-wrappers/wrap/android.net.impl.h @@ -1,6 +1,6 @@ // Copyright 2020-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 -// Author: Ryan Pavlik +// Author: Rylie Pavlik // Inline implementations: do not include on its own! #pragma once diff --git a/src/loader/.gitignore b/src/loader/.gitignore index be1be1af..335efdb8 100644 --- a/src/loader/.gitignore +++ b/src/loader/.gitignore @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023, The Khronos Group Inc. +# Copyright (c) 2020-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 diff --git a/src/loader/AndroidManifest.xml.in b/src/loader/AndroidManifest.xml.in index 33a45153..0a81c753 100644 --- a/src/loader/AndroidManifest.xml.in +++ b/src/loader/AndroidManifest.xml.in @@ -3,7 +3,7 @@ android:versionCode="1" android:versionName="${OPENXR_FULL_VERSION}${OPENXR_ANDROID_VERSION_SUFFIX}"> diff --git a/src/loader/CMakeLists.txt b/src/loader/CMakeLists.txt index 89c9f2ca..326f74ed 100644 --- a/src/loader/CMakeLists.txt +++ b/src/loader/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/src/loader/OpenXRConfig.cmake.in b/src/loader/OpenXRConfig.cmake.in index edf34ee4..81b12e75 100644 --- a/src/loader/OpenXRConfig.cmake.in +++ b/src/loader/OpenXRConfig.cmake.in @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 OR MIT diff --git a/src/loader/abi.json.license b/src/loader/abi.json.license index 924b9735..d8a41d20 100644 --- a/src/loader/abi.json.license +++ b/src/loader/abi.json.license @@ -1,3 +1,3 @@ -Copyright (c) 2020-2023, The Khronos Group Inc. +Copyright (c) 2020-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 OR MIT diff --git a/src/loader/additional_manifest.mf.in.license b/src/loader/additional_manifest.mf.in.license index 4f133824..16dcae7e 100644 --- a/src/loader/additional_manifest.mf.in.license +++ b/src/loader/additional_manifest.mf.in.license @@ -1,2 +1,2 @@ -Copyright (c) 2023, The Khronos Group Inc. +Copyright (c) 2023-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 OR MIT diff --git a/src/loader/android_utilities.cpp b/src/loader/android_utilities.cpp index 68512d4a..5c9b846b 100644 --- a/src/loader/android_utilities.cpp +++ b/src/loader/android_utilities.cpp @@ -1,9 +1,9 @@ -// Copyright (c) 2020-2023, The Khronos Group Inc. +// Copyright (c) 2020-2024, The Khronos Group Inc. // Copyright (c) 2020-2021, Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 OR MIT // -// Initial Author: Ryan Pavlik +// Initial Author: Rylie Pavlik #include "android_utilities.h" diff --git a/src/loader/android_utilities.h b/src/loader/android_utilities.h index f66c9bf1..582a6505 100644 --- a/src/loader/android_utilities.h +++ b/src/loader/android_utilities.h @@ -1,9 +1,9 @@ -// Copyright (c) 2020-2023, The Khronos Group Inc. +// Copyright (c) 2020-2024, The Khronos Group Inc. // Copyright (c) 2020-2021, Collabora, Ltd. // // SPDX-License-Identifier: Apache-2.0 OR MIT // -// Initial Author: Ryan Pavlik +// Initial Author: Rylie Pavlik #pragma once #ifdef __ANDROID__ diff --git a/src/loader/api_layer_interface.cpp b/src/loader/api_layer_interface.cpp index e8f6a401..fb509de2 100644 --- a/src/loader/api_layer_interface.cpp +++ b/src/loader/api_layer_interface.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // @@ -9,7 +9,6 @@ #include "api_layer_interface.hpp" -#include "loader_interfaces.h" #include "loader_init_data.hpp" #include "loader_logger.hpp" #include "loader_platform.hpp" @@ -17,6 +16,7 @@ #include "platform_utils.hpp" #include +#include #include #include diff --git a/src/loader/api_layer_interface.hpp b/src/loader/api_layer_interface.hpp index 98685b0c..43758b31 100644 --- a/src/loader/api_layer_interface.hpp +++ b/src/loader/api_layer_interface.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // @@ -14,9 +14,9 @@ #include #include +#include #include "loader_platform.hpp" -#include "loader_interfaces.h" struct XrGeneratedDispatchTable; diff --git a/src/loader/exception_handling.hpp b/src/loader/exception_handling.hpp index bc0d9b65..62395fdf 100644 --- a/src/loader/exception_handling.hpp +++ b/src/loader/exception_handling.hpp @@ -1,8 +1,8 @@ -// Copyright (c) 2019-2023, The Khronos Group Inc. +// Copyright (c) 2019-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 OR MIT // -// Initial Author: Ryan Pavlik +// Initial Author: Rylie Pavlik // // Provides protection for C ABI functions if standard library functions may throw. diff --git a/src/loader/loader.rc b/src/loader/loader.rc index fd646580..5b376c0c 100644 --- a/src/loader/loader.rc +++ b/src/loader/loader.rc @@ -1,5 +1,5 @@ // -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017 Valve Corporation // Copyright (c) 2017 LunarG, Inc. // @@ -9,7 +9,7 @@ // // The years here should always match the Khronos line above! -#define COPYRIGHT_NOTICE "2017-2023, The Khronos Group Inc. and others" +#define COPYRIGHT_NOTICE "2017-2024, The Khronos Group Inc. and others" // REUSE-IgnoreStart diff --git a/src/loader/loader_core.cpp b/src/loader/loader_core.cpp index f173142c..8bf2609a 100644 --- a/src/loader/loader_core.cpp +++ b/src/loader/loader_core.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/loader/loader_init_data.cpp b/src/loader/loader_init_data.cpp index 16b75304..11d3c4e7 100644 --- a/src/loader/loader_init_data.cpp +++ b/src/loader/loader_init_data.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/loader/loader_init_data.hpp b/src/loader/loader_init_data.hpp index 7c6579cc..fe6bc134 100644 --- a/src/loader/loader_init_data.hpp +++ b/src/loader/loader_init_data.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/loader/loader_instance.cpp b/src/loader/loader_instance.cpp index ce5c2055..f1823008 100644 --- a/src/loader/loader_instance.cpp +++ b/src/loader/loader_instance.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // @@ -15,13 +15,13 @@ #include "api_layer_interface.hpp" #include "hex_and_handles.h" -#include "loader_interfaces.h" #include "loader_logger.hpp" #include "runtime_interface.hpp" #include "xr_generated_dispatch_table_core.h" #include "xr_generated_loader.hpp" #include +#include #include #include @@ -60,7 +60,7 @@ XrResult Get(LoaderInstance** loader_instance, const char* log_function_name) { bool IsAvailable() { return GetSetCurrentLoaderInstance() != nullptr; } -void Remove() { GetSetCurrentLoaderInstance().release(); } +void Remove() { GetSetCurrentLoaderInstance().reset(nullptr); } } // namespace ActiveLoaderInstance // Extensions that are supported by the loader, but may not be supported diff --git a/src/loader/loader_instance.hpp b/src/loader/loader_instance.hpp index a0268a85..b99e6b04 100644 --- a/src/loader/loader_instance.hpp +++ b/src/loader/loader_instance.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // @@ -10,9 +10,9 @@ #pragma once #include "extra_algorithms.h" -#include "loader_interfaces.h" #include +#include #include #include diff --git a/src/loader/loader_logger.cpp b/src/loader/loader_logger.cpp index 1c8d64f3..593e19a3 100644 --- a/src/loader/loader_logger.cpp +++ b/src/loader/loader_logger.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/loader/loader_logger.hpp b/src/loader/loader_logger.hpp index d31fac09..964aa479 100644 --- a/src/loader/loader_logger.hpp +++ b/src/loader/loader_logger.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/loader/loader_logger_recorders.cpp b/src/loader/loader_logger_recorders.cpp index 32e4687b..00392c27 100644 --- a/src/loader/loader_logger_recorders.cpp +++ b/src/loader/loader_logger_recorders.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/loader/loader_logger_recorders.hpp b/src/loader/loader_logger_recorders.hpp index 7b934202..b676c37e 100644 --- a/src/loader/loader_logger_recorders.hpp +++ b/src/loader/loader_logger_recorders.hpp @@ -1,10 +1,10 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // // SPDX-License-Identifier: Apache-2.0 OR MIT // -// Initial Author: Ryan Pavlik +// Initial Author: Rylie Pavlik // #pragma once diff --git a/src/loader/loader_platform.hpp b/src/loader/loader_platform.hpp index 0ea80c05..964116ca 100644 --- a/src/loader/loader_platform.hpp +++ b/src/loader/loader_platform.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/loader/manifest_file.cpp b/src/loader/manifest_file.cpp index da96845e..ae0842f3 100644 --- a/src/loader/manifest_file.cpp +++ b/src/loader/manifest_file.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // @@ -600,14 +600,8 @@ void RuntimeManifestFile::CreateIfValid(const Json::Value &root_node, const std: // If the library_path variable has no directory symbol, it's just a file name and should be accessible on the // global library path. if (lib_path.find('\\') != std::string::npos || lib_path.find('/') != std::string::npos) { - // If the library_path is an absolute path, just use that if it exists - if (FileSysUtilsIsAbsolutePath(lib_path)) { - if (!FileSysUtilsPathExists(lib_path)) { - error_ss << filename << " library " << lib_path << " does not appear to exist"; - LoaderLogger::LogErrorMessage("", error_ss.str()); - return; - } - } else { + // If the library_path is an absolute path, just use that as-is. + if (!FileSysUtilsIsAbsolutePath(lib_path)) { // Otherwise, treat the library path as a relative path based on the JSON file. std::string canonical_path; std::string combined_path; @@ -618,8 +612,8 @@ void RuntimeManifestFile::CreateIfValid(const Json::Value &root_node, const std: canonical_path = filename; } if (!FileSysUtilsGetParentPath(canonical_path, file_parent) || - !FileSysUtilsCombinePaths(file_parent, lib_path, combined_path) || !FileSysUtilsPathExists(combined_path)) { - error_ss << filename << " library " << combined_path << " does not appear to exist"; + !FileSysUtilsCombinePaths(file_parent, lib_path, combined_path)) { + error_ss << filename << " filesystem operations failed for path " << canonical_path; LoaderLogger::LogErrorMessage("", error_ss.str()); return; } diff --git a/src/loader/manifest_file.hpp b/src/loader/manifest_file.hpp index 46b842c6..52fe3134 100644 --- a/src/loader/manifest_file.hpp +++ b/src/loader/manifest_file.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017 Valve Corporation // Copyright (c) 2017 LunarG, Inc. // diff --git a/src/loader/module.json.license b/src/loader/module.json.license index 924b9735..d8a41d20 100644 --- a/src/loader/module.json.license +++ b/src/loader/module.json.license @@ -1,3 +1,3 @@ -Copyright (c) 2020-2023, The Khronos Group Inc. +Copyright (c) 2020-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 OR MIT diff --git a/src/loader/openxr-loader.def b/src/loader/openxr-loader.def index 46622360..3c1c455e 100644 --- a/src/loader/openxr-loader.def +++ b/src/loader/openxr-loader.def @@ -1,4 +1,4 @@ -; Copyright (c) 2019-2023, The Khronos Group Inc. +; Copyright (c) 2019-2024, The Khronos Group Inc. ; ; SPDX-License-Identifier: Apache-2.0 OR MIT diff --git a/src/loader/openxr-loader.expsym b/src/loader/openxr-loader.expsym index 98a14921..20b6e56b 100644 --- a/src/loader/openxr-loader.expsym +++ b/src/loader/openxr-loader.expsym @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, The Khronos Group Inc. +# Copyright (c) 2019-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 OR MIT diff --git a/src/loader/openxr-loader.map b/src/loader/openxr-loader.map index 982f63d1..7ac55701 100644 --- a/src/loader/openxr-loader.map +++ b/src/loader/openxr-loader.map @@ -1,3 +1,9 @@ +/* +Copyright (c) 2019-2024, The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0 OR MIT +*/ + { global: xrCreateInstance; diff --git a/src/loader/openxr-loader.map.license b/src/loader/openxr-loader.map.license deleted file mode 100644 index 1eda462d..00000000 --- a/src/loader/openxr-loader.map.license +++ /dev/null @@ -1,3 +0,0 @@ -Copyright (c) 2019-2023, The Khronos Group Inc. - -SPDX-License-Identifier: Apache-2.0 OR MIT diff --git a/src/loader/openxr.pc.in b/src/loader/openxr.pc.in index dc96995c..9772bf1c 100644 --- a/src/loader/openxr.pc.in +++ b/src/loader/openxr.pc.in @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 OR MIT diff --git a/src/loader/openxr_loader_for_android.pom b/src/loader/openxr_loader_for_android.pom index 1b696ecc..af93f710 100644 --- a/src/loader/openxr_loader_for_android.pom +++ b/src/loader/openxr_loader_for_android.pom @@ -3,7 +3,7 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> org.khronos.openxr diff --git a/src/loader/prefab.json.license b/src/loader/prefab.json.license index 924b9735..d8a41d20 100644 --- a/src/loader/prefab.json.license +++ b/src/loader/prefab.json.license @@ -1,3 +1,3 @@ -Copyright (c) 2020-2023, The Khronos Group Inc. +Copyright (c) 2020-2024, The Khronos Group Inc. SPDX-License-Identifier: Apache-2.0 OR MIT diff --git a/src/loader/runtime_interface.cpp b/src/loader/runtime_interface.cpp index df190cc2..7812aca9 100644 --- a/src/loader/runtime_interface.cpp +++ b/src/loader/runtime_interface.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // @@ -9,15 +9,15 @@ #include "runtime_interface.hpp" +#include +#include + #include "manifest_file.hpp" -#include "loader_interfaces.h" #include "loader_init_data.hpp" #include "loader_logger.hpp" #include "loader_platform.hpp" #include "xr_generated_dispatch_table_core.h" -#include - #include #include #include diff --git a/src/loader/runtime_interface.hpp b/src/loader/runtime_interface.hpp index 8f8278f5..093f8ba7 100644 --- a/src/loader/runtime_interface.hpp +++ b/src/loader/runtime_interface.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // Copyright (c) 2017-2019 Valve Corporation // Copyright (c) 2017-2019 LunarG, Inc. // diff --git a/src/loader/settings.gradle b/src/loader/settings.gradle index 9b51150d..6d9d267f 100644 --- a/src/loader/settings.gradle +++ b/src/loader/settings.gradle @@ -1,3 +1,3 @@ -// Copyright (c) 2020-2023, The Khronos Group Inc. +// Copyright (c) 2020-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/src/scripts/api_dump_generator.py b/src/scripts/api_dump_generator.py index d396560d..e2f02c2a 100755 --- a/src/scripts/api_dump_generator.py +++ b/src/scripts/api_dump_generator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # Copyright (c) 2017-2019 Valve Corporation # Copyright (c) 2017-2019 LunarG, Inc. # @@ -32,10 +32,22 @@ # The following commands should not be generated for the layer MANUALLY_DEFINED_IN_LAYER = set(( + 'xrNegotiateLoaderRuntimeInterface', + 'xrNegotiateLoaderApiLayerInterface', + 'xrCreateApiLayerInstance', + 'xrCreateInstance', 'xrDestroyInstance', )) +LOADER_STRUCTS = [ + 'XrApiLayerNextInfo', + 'XrApiLayerCreateInfo', + 'XrNegotiateLoaderInfo', + 'XrNegotiateRuntimeRequest', + 'XrNegotiateApiLayerRequest', +] + # ApiDumpOutputGenerator - subclass of AutomaticSourceOutputGenerator. @@ -143,6 +155,9 @@ def outputLayerHeaderPrototypes(self): if xr_union.protect_value: generated_prototypes += '#endif // %s\n' % xr_union.protect_string for xr_struct in self.api_structures: + if xr_struct.name in LOADER_STRUCTS: + continue + if xr_struct.protect_value: generated_prototypes += '#if %s\n' % xr_struct.protect_string generated_prototypes += 'bool ApiDumpOutputXrStruct(XrGeneratedDispatchTable* gen_dispatch_table, const %s* value,\n' % xr_struct.name @@ -888,6 +903,9 @@ def writeApiDumpUnionStructFuncs(self): if xr_union.protect_value: struct_union_check += '#endif // %s\n' % xr_union.protect_string for xr_struct in self.api_structures: + if xr_struct.name in LOADER_STRUCTS: + continue + if xr_struct.protect_value: struct_union_check += '#if %s\n' % xr_struct.protect_string struct_union_check += 'bool ApiDumpOutputXrStruct(XrGeneratedDispatchTable* gen_dispatch_table, const %s* value,\n' % xr_struct.name @@ -1037,8 +1055,17 @@ def outputLayerCommands(self): if cur_cmd.name == 'xrGetInstanceProcAddr': continue - # xrInitializeLoaderKHR is special - if cur_cmd.name == 'xrInitializeLoaderKHR': + if cur_cmd.name == 'xrCreateApiLayerInstance': + continue + + LOADER_FUNCTIONS = [ + 'xrInitializeLoaderKHR', + 'xrNegotiateLoaderRuntimeInterface', + 'xrNegotiateLoaderApiLayerInterface', + ] + + # functions implemented by or for the loader are different + if cur_cmd.name in LOADER_FUNCTIONS: continue is_create = False diff --git a/src/scripts/automatic_source_generator.py b/src/scripts/automatic_source_generator.py index b470bb43..6d9620fa 100755 --- a/src/scripts/automatic_source_generator.py +++ b/src/scripts/automatic_source_generator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # Copyright (c) 2017-2019 Valve Corporation # Copyright (c) 2017-2019 LunarG, Inc. # @@ -498,6 +498,9 @@ def __init__(self, *args, **kwargs): self.no_trampoline_or_terminator = [ 'xrEnumerateApiLayerProperties', 'xrEnumerateInstanceExtensionProperties', + 'xrNegotiateLoaderRuntimeInterface', + 'xrCreateApiLayerInstance', + 'xrNegotiateLoaderApiLayerInterface', 'xrInitializeLoaderKHR' ] @@ -580,7 +583,7 @@ def outputErrorIfNeeded(self): # overridden by a derived class. # self the AutomaticSourceOutputGenerator object def outputCopywriteHeader(self): - notice = '// Copyright (c) 2017-2023, The Khronos Group Inc.\n' + notice = '// Copyright (c) 2017-2024, The Khronos Group Inc.\n' notice += '// Copyright (c) 2017-2019 Valve Corporation\n' notice += '// Copyright (c) 2017-2019 LunarG, Inc.\n' notice += '//\n' @@ -1600,6 +1603,8 @@ def paramArrayDimension(self, param_cdecl, param_type, param_name): def isCoreExtensionName(self, ext_name): if "XR_VERSION_" in ext_name: return True + if "XR_LOADER_VERSION_" in ext_name: + return True return False # Determine if all the characters in a string are upper-case diff --git a/src/scripts/conformance_generator.py b/src/scripts/conformance_generator.py index 8de7fe26..1509b4f3 100644 --- a/src/scripts/conformance_generator.py +++ b/src/scripts/conformance_generator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # Copyright (c) 2017-2019 Valve Corporation # Copyright (c) 2017-2019 LunarG, Inc. # diff --git a/src/scripts/conformance_layer_generator.py b/src/scripts/conformance_layer_generator.py index 72ab685b..e34c80e9 100644 --- a/src/scripts/conformance_layer_generator.py +++ b/src/scripts/conformance_layer_generator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # Copyright (c) 2017-2019 Valve Corporation # Copyright (c) 2017-2019 LunarG, Inc. # diff --git a/src/scripts/generate_api_layer_manifest.py b/src/scripts/generate_api_layer_manifest.py index 570e9ffa..f07733c5 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-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/src/scripts/generate_runtime_manifest.py b/src/scripts/generate_runtime_manifest.py index 985108fb..6e151ae8 100755 --- a/src/scripts/generate_runtime_manifest.py +++ b/src/scripts/generate_runtime_manifest.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, 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 83f26e73..b9280a12 100755 --- a/src/scripts/loader_source_generator.py +++ b/src/scripts/loader_source_generator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # Copyright (c) 2017-2019 Valve Corporation # Copyright (c) 2017-2019 LunarG, Inc. # @@ -24,6 +24,10 @@ # The following commands are manually implemented in the loader. MANUAL_LOADER_FUNCS = set(( + 'xrNegotiateLoaderRuntimeInterface', + 'xrNegotiateLoaderApiLayerInterface', + 'xrCreateApiLayerInstance', + 'xrGetInstanceProcAddr', 'xrEnumerateApiLayerProperties', 'xrEnumerateInstanceExtensionProperties', @@ -85,7 +89,7 @@ def getProto(self, cur_cmd): def outputGeneratedHeaderWarning(self): # REUSE-IgnoreStart generated_warning = '' - generated_warning += '// Copyright (c) 2017-2023, The Khronos Group Inc.\n' + generated_warning += '// Copyright (c) 2017-2024, The Khronos Group Inc.\n' generated_warning += '// Copyright (c) 2017-2019 Valve Corporation\n' generated_warning += '// Copyright (c) 2017-2019 LunarG, Inc.\n' # Broken string is to avoid confusing the REUSE tool here. @@ -111,8 +115,8 @@ def beginFile(self, genOpts): preamble += '#include \n\n' preamble += '#include "xr_dependencies.h"\n' preamble += '#include "openxr/openxr.h"\n' + preamble += '#include "openxr/openxr_loader_negotiation.h"\n' preamble += '#include "openxr/openxr_platform.h"\n\n' - preamble += '#include "loader_interfaces.h"\n\n' preamble += '#include "loader_instance.hpp"\n\n' preamble += '#include "loader_platform.hpp"\n\n' diff --git a/src/scripts/src_genxr.py b/src/scripts/src_genxr.py index b90248f9..ad13bdf0 100755 --- a/src/scripts/src_genxr.py +++ b/src/scripts/src_genxr.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright 2013-2023 The Khronos Group Inc. +# Copyright 2013-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -100,7 +100,7 @@ def makeGenOpts(args): # Copyright text prefixing all headers (list of strings). prefixStrings = [ '/*', - '** Copyright (c) 2017-2023, The Khronos Group Inc.', + '** Copyright (c) 2017-2024, The Khronos Group Inc.', '**', '** Licensed under the Apache License, Version 2.0 (the "License");', '** you may not use this file except in compliance with the License.', diff --git a/src/scripts/template_function_info.cpp b/src/scripts/template_function_info.cpp index 99abeafb..bb02e710 100644 --- a/src/scripts/template_function_info.cpp +++ b/src/scripts/template_function_info.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -11,6 +11,7 @@ namespace Conformance { // This is a generated list of information about functions. static const FunctionInfoMap functionInfoMapInternal{ //# for cur_cmd in sorted_cmds +//# if cur_cmd.ext_name != "XR_LOADER_VERSION_1_0" {/*{ cur_cmd.name | quote_string }*/, FunctionInfo(PFN_xrVoidFunction(nullptr), //# if cur_cmd.name in null_instance_ok @@ -24,6 +25,7 @@ static const FunctionInfoMap functionInfoMapInternal{ nullptr, //# endif {/*{ gen.allReturnCodesForCommand(cur_cmd) | join(', ') }*/})}, +//# endif //# endfor }; diff --git a/src/scripts/template_gen_dispatch.cpp b/src/scripts/template_gen_dispatch.cpp index 91a8049c..c69bf0ea 100644 --- a/src/scripts/template_gen_dispatch.cpp +++ b/src/scripts/template_gen_dispatch.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -8,23 +8,23 @@ #if defined(ANDROID) #include -#define LOG(...) __android_log_print(ANDROID_LOG_ERROR, "XrApiLayer_runtime_conformance", __VA_ARGS__) +#define LOG_FATAL(...) __android_log_print(ANDROID_LOG_FATAL, "XrApiLayer_runtime_conformance", __VA_ARGS__) #else #include -#define LOG(...) fprintf(stderr, __VA_ARGS__) +#define LOG_FATAL(...) fprintf(stderr, __VA_ARGS__) #endif #include // Unhandled exception at ABI is a catastrophic error in the layer (a bug). -#define ABI_CATCH \ - catch (const std::exception& e) { \ - LOG("Conformance Layer Bug: caught exception at ABI level with message = %s\n", e.what()); \ - abort(); /* Something went wrong in the layer. */ \ - } \ - catch (...) { \ - LOG("Conformance Layer Bug: caught exception at ABI level\n"); \ - abort(); /* Something went wrong in the layer. */ \ +#define ABI_CATCH \ + catch (const std::exception& e) { \ + LOG_FATAL("FATAL: Conformance Layer Bug: caught exception at ABI level with message = %s\n", e.what()); \ + abort(); /* Something went wrong in the layer. */ \ + } \ + catch (...) { \ + LOG_FATAL("FATAL: Conformance Layer Bug: caught exception at ABI level\n"); \ + abort(); /* Something went wrong in the layer. */ \ } /*% macro checkExtCode(ext_code) %*/(handleState->enabledExtensions->/*{make_ext_variable_name(ext_code.extension)}*/ && result == /*{ ext_code.value }*/)/*% endmacro %*/ diff --git a/src/scripts/template_gen_dispatch.h b/src/scripts/template_gen_dispatch.h index a967d84c..d2a08181 100644 --- a/src/scripts/template_gen_dispatch.h +++ b/src/scripts/template_gen_dispatch.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, The Khronos Group Inc. +// Copyright (c) 2017-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -15,9 +15,9 @@ #include #include "xr_dependencies.h" #include +#include #include #include "xr_generated_dispatch_table.h" -#include // HandleState.h contains non-generated code. #include "HandleState.h" diff --git a/src/scripts/utility_source_generator.py b/src/scripts/utility_source_generator.py index 836e6d65..48172b6c 100755 --- a/src/scripts/utility_source_generator.py +++ b/src/scripts/utility_source_generator.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -i # -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # Copyright (c) 2017-2019 Valve Corporation # Copyright (c) 2017-2019 LunarG, Inc. # @@ -31,7 +31,7 @@ class UtilitySourceOutputGenerator(AutomaticSourceOutputGenerator): def outputGeneratedHeaderWarning(self): # REUSE-IgnoreStart generated_warning = '' - generated_warning += '// Copyright (c) 2017-2023, The Khronos Group Inc.\n' + generated_warning += '// Copyright (c) 2017-2024, The Khronos Group 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. @@ -131,6 +131,12 @@ def outputDispatchTable(self): table += '// Generated dispatch table\n' table += 'struct XrGeneratedDispatchTable {\n' + # functions implemented for the loader are different + LOADER_FUNCTIONS = [ + 'xrCreateApiLayerInstance', + 'xrNegotiateLoaderRuntimeInterface', + 'xrNegotiateLoaderApiLayerInterface', + ] # Loop through both core commands, and extension commands # Outputting the core commands first, and then the extension commands. for x in range(0, 2): @@ -150,6 +156,10 @@ def outputDispatchTable(self): # Skip anything that is not core or XR_EXT_debug_utils in the loader dispatch table continue + # Skip loader-use-only functions in dispatch tables. + if cur_cmd.name in LOADER_FUNCTIONS: + 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 8f683241..4cc72064 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-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # Copyright (c) 2017 Valve Corporation # Copyright (c) 2017 LunarG, Inc. # @@ -42,6 +42,18 @@ 'xrSessionInsertDebugUtilsLabelEXT', )) +LOADER_STRUCTS = [ + 'XrApiLayerNextInfo', + 'XrApiLayerCreateInfo', + 'XrNegotiateLoaderInfo', + 'XrNegotiateRuntimeRequest', + 'XrNegotiateApiLayerRequest', +] + +LOADER_ENUMS = [ + 'XrLoaderInterfaceStructs', +] + _CHAR_RE = re.compile(r"\bchar\b") @@ -261,6 +273,9 @@ def outputValidationSourceFlagBitValues(self): def outputValidationSourceEnumValues(self): enum_value_validate = '' for enum_tuple in self.api_enums: + if enum_tuple.name in LOADER_ENUMS: + continue + if enum_tuple.protect_value: enum_value_validate += '#if %s\n' % enum_tuple.protect_string enum_value_validate += '// Function to validate %s enum\n' % enum_tuple.name @@ -415,6 +430,9 @@ def outputValidationInternalProtos(self): validation_internal_protos += 'bool ExtensionEnabled(const std::vector &extensions, const char* const check_extension_name);\n' validation_internal_protos += '\n// Functions to validate structures\n' for xr_struct in self.api_structures: + if xr_struct.name in LOADER_STRUCTS: + continue + if xr_struct.protect_value: validation_internal_protos += '#if %s\n' % xr_struct.protect_string validation_internal_protos += 'XrResult ValidateXrStruct(GenValidUsageXrInstanceInfo *instance_info, const std::string &command_name,\n' @@ -1870,6 +1888,9 @@ def writeValidateStructFuncs(self): struct_check = '' # Now write out the actual functions for xr_struct in self.api_structures: + if xr_struct.name in LOADER_STRUCTS: + continue + if xr_struct.name in self.structs_with_no_type: continue diff --git a/src/version.cmake b/src/version.cmake index 3a6e0398..794946e9 100644 --- a/src/version.cmake +++ b/src/version.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/src/version.gradle b/src/version.gradle index bd2aa658..0d16974e 100644 --- a/src/version.gradle +++ b/src/version.gradle @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2023, The Khronos Group Inc. +// Copyright (c) 2020-2024, The Khronos Group Inc. // // SPDX-License-Identifier: Apache-2.0 diff --git a/tox.ini b/tox.ini index f3511891..8053e320 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2023, The Khronos Group Inc. +# Copyright (c) 2017-2024, The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 # tox (https://tox.readthedocs.io/) is a tool for running tests