├── installer
├── .gitignore
├── comodo.pfx
├── signtool.exe
├── selfsigncert.pfx
├── README.rtf
└── EULA.rtf
├── .gitattributes
├── .github
├── FUNDING.yml
└── workflows
│ └── msbuild.yml
├── openxr-api-layer
├── pch.cpp
├── framework
│ ├── .gitignore
│ ├── dispatch.h
│ ├── layer_apis.py
│ ├── log.h
│ ├── util.h
│ ├── log.cpp
│ ├── entry.cpp
│ ├── dispatch.cpp
│ └── dispatch_generator.py
├── module.def
├── version.h
├── packages.config
├── resource.h
├── openxr-api-layer.json
├── openxr-api-layer-32.json
├── ProjectionVS.hlsl
├── layer.h
├── resource.rc
├── utils
│ ├── general.h
│ ├── inputs.h
│ ├── general.cpp
│ ├── graphics.h
│ ├── d3d11.cpp
│ └── d3d12.cpp
├── pch.h
├── ProjectionPS.hlsl
├── SharpeningCS.hlsl
├── views.h
└── openxr-api-layer.vcxproj.filters
├── version.info
├── scripts
├── sed.exe
├── msys-2.0.dll
├── msys-iconv-2.dll
├── msys-intl-8.dll
├── Capture-ETL.bat
├── Uninstall-Layer.ps1
├── Uninstall-Layer32.ps1
├── Install-Layer.ps1
├── Install-Layer32.ps1
└── Tracing.wprp
├── .gitignore
├── .gitmodules
├── .clang-format
├── LICENSE
├── settings.cfg
├── CustomSetup
├── Properties
│ └── AssemblyInfo.cs
├── CustomSetup.csproj
└── CustomSetupActions.cs
├── README.md
├── XR_APILAYER_MBUCCHIA_quad_views_foveated.sln
└── THIRD_PARTY
/installer/.gitignore:
--------------------------------------------------------------------------------
1 | Output/
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.gen.* text eol=lf
2 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: mbucchia
2 |
--------------------------------------------------------------------------------
/openxr-api-layer/pch.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 |
--------------------------------------------------------------------------------
/version.info:
--------------------------------------------------------------------------------
1 | major=1
2 | minor=1
3 | patch=4
4 |
--------------------------------------------------------------------------------
/openxr-api-layer/framework/.gitignore:
--------------------------------------------------------------------------------
1 | dispatch.gen.cpp
2 | dispatch.gen.h
3 |
--------------------------------------------------------------------------------
/openxr-api-layer/module.def:
--------------------------------------------------------------------------------
1 | LIBRARY
2 | EXPORTS
3 | xrNegotiateLoaderApiLayerInterface
4 |
--------------------------------------------------------------------------------
/scripts/sed.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mbucchia/Quad-Views-Foveated/HEAD/scripts/sed.exe
--------------------------------------------------------------------------------
/installer/comodo.pfx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mbucchia/Quad-Views-Foveated/HEAD/installer/comodo.pfx
--------------------------------------------------------------------------------
/installer/signtool.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mbucchia/Quad-Views-Foveated/HEAD/installer/signtool.exe
--------------------------------------------------------------------------------
/scripts/msys-2.0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mbucchia/Quad-Views-Foveated/HEAD/scripts/msys-2.0.dll
--------------------------------------------------------------------------------
/scripts/msys-iconv-2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mbucchia/Quad-Views-Foveated/HEAD/scripts/msys-iconv-2.dll
--------------------------------------------------------------------------------
/scripts/msys-intl-8.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mbucchia/Quad-Views-Foveated/HEAD/scripts/msys-intl-8.dll
--------------------------------------------------------------------------------
/installer/selfsigncert.pfx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mbucchia/Quad-Views-Foveated/HEAD/installer/selfsigncert.pfx
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vs/
2 | packages/
3 | bin/
4 | **/x64/
5 | **/obj/
6 | **/__pycache__/
7 | *.pyc
8 | *.vcxproj.user
9 | *.csproj.user
10 |
--------------------------------------------------------------------------------
/openxr-api-layer/version.h:
--------------------------------------------------------------------------------
1 | const unsigned int LayerVersionMajor = 1;
2 | const unsigned int LayerVersionMinor = 1;
3 | const unsigned int LayerVersionPatch = 4;
4 |
--------------------------------------------------------------------------------
/scripts/Capture-ETL.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | pushd %~dp0
3 | wpr -start Tracing.wprp -filemode
4 |
5 | echo Reproduce your issue now, then
6 | pause
7 |
8 | wpr -stop QVFR.etl
9 | popd
10 |
--------------------------------------------------------------------------------
/openxr-api-layer/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/scripts/Uninstall-Layer.ps1:
--------------------------------------------------------------------------------
1 | $JsonPath = Join-Path "$PSScriptRoot" "openxr-api-layer.json"
2 | Start-Process -FilePath powershell.exe -Verb RunAs -Wait -ArgumentList @"
3 | & {
4 | Remove-ItemProperty -Path HKLM:\Software\Khronos\OpenXR\1\ApiLayers\Implicit -Name '$jsonPath' -Force | Out-Null
5 | }
6 | "@
7 |
--------------------------------------------------------------------------------
/scripts/Uninstall-Layer32.ps1:
--------------------------------------------------------------------------------
1 | $JsonPath = Join-Path "$PSScriptRoot" "openxr-api-layer-32.json"
2 | Start-Process -FilePath powershell.exe -Verb RunAs -Wait -ArgumentList @"
3 | & {
4 | Remove-ItemProperty -Path HKLM:\Software\WOW6432Node\Khronos\OpenXR\1\ApiLayers\Implicit -Name '$jsonPath' -Force | Out-Null
5 | }
6 | "@
7 |
--------------------------------------------------------------------------------
/openxr-api-layer/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by resource.rc
4 |
5 | // Next default values for new objects
6 | //
7 | #ifdef APSTUDIO_INVOKED
8 | #ifndef APSTUDIO_READONLY_SYMBOLS
9 | #define _APS_NEXT_RESOURCE_VALUE 101
10 | #define _APS_NEXT_COMMAND_VALUE 40001
11 | #define _APS_NEXT_CONTROL_VALUE 1001
12 | #define _APS_NEXT_SYMED_VALUE 101
13 | #endif
14 | #endif
15 |
--------------------------------------------------------------------------------
/scripts/Install-Layer.ps1:
--------------------------------------------------------------------------------
1 | $RegistryPath = "HKLM:\Software\Khronos\OpenXR\1\ApiLayers\Implicit"
2 | $JsonPath = Join-Path "$PSScriptRoot" "openxr-api-layer.json"
3 | Start-Process -FilePath powershell.exe -Verb RunAs -Wait -ArgumentList @"
4 | & {
5 | If (-not (Test-Path $RegistryPath)) {
6 | New-Item -Path $RegistryPath -Force | Out-Null
7 | }
8 | New-ItemProperty -Path $RegistryPath -Name '$jsonPath' -PropertyType DWord -Value 0 -Force | Out-Null
9 | }
10 | "@
11 |
--------------------------------------------------------------------------------
/scripts/Install-Layer32.ps1:
--------------------------------------------------------------------------------
1 | $RegistryPath = "HKLM:\Software\WOW6432Node\Khronos\OpenXR\1\ApiLayers\Implicit"
2 | $JsonPath = Join-Path "$PSScriptRoot" "openxr-api-layer-32.json"
3 | Start-Process -FilePath powershell.exe -Verb RunAs -Wait -ArgumentList @"
4 | & {
5 | If (-not (Test-Path $RegistryPath)) {
6 | New-Item -Path $RegistryPath -Force | Out-Null
7 | }
8 | New-ItemProperty -Path $RegistryPath -Name '$jsonPath' -PropertyType DWord -Value 0 -Force | Out-Null
9 | }
10 | "@
11 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "external/OpenXR-SDK-Source"]
2 | path = external/OpenXR-SDK-Source
3 | url = https://github.com/KhronosGroup/OpenXR-SDK-Source.git
4 | [submodule "external/OpenXR-SDK"]
5 | path = external/OpenXR-SDK
6 | url = https://github.com/KhronosGroup/OpenXR-SDK.git
7 | [submodule "external/OpenXR-MixedReality"]
8 | path = external/OpenXR-MixedReality
9 | url = https://github.com/microsoft/OpenXR-MixedReality.git
10 | [submodule "external/FidelityFX-CAS"]
11 | path = external/FidelityFX-CAS
12 | url = https://github.com/GPUOpen-Effects/FidelityFX-CAS.git
13 | [submodule "external/fmt"]
14 | path = external/fmt
15 | url = https://github.com/fmtlib/fmt.git
16 |
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | Language: Cpp
2 | IndentWidth: 4
3 | ColumnLimit: 120
4 | AllowShortBlocksOnASingleLine: false
5 | AllowShortFunctionsOnASingleLine: false
6 | AlwaysBreakTemplateDeclarations: true
7 | BinPackParameters: false
8 | BinPackArguments: false
9 | IndentWrappedFunctionNames: false
10 | KeepEmptyLinesAtTheStartOfBlocks: false
11 | MaxEmptyLinesToKeep: 1
12 | NamespaceIndentation: All
13 | PenaltyReturnTypeOnItsOwnLine: 100
14 | PointerAlignment: Left
15 | SortIncludes: false
16 | SpaceAfterCStyleCast: false
17 | SpaceBeforeAssignmentOperators: true
18 | SpaceBeforeParens: ControlStatements
19 | SpaceInEmptyParentheses: false
20 | SpacesInAngles: false
21 | SpacesInCStyleCastParentheses: false
22 | SpacesInContainerLiterals: false
23 | SpacesInParentheses: false
24 | SpacesInSquareBrackets: false
25 | UseTab: Never
26 |
--------------------------------------------------------------------------------
/openxr-api-layer/openxr-api-layer.json:
--------------------------------------------------------------------------------
1 | {
2 | "file_format_version" : "1.0.0",
3 | "api_layer": {
4 | "name": "XR_APILAYER_name",
5 | "library_path": ".\\XR_APILAYER_name.dll",
6 | "api_version": "1.0",
7 | "implementation_version": "1",
8 | "description": "Emulate quad views foveation support",
9 | "instance_extensions": [
10 | {
11 | "name": "XR_VARJO_quad_views",
12 | "extension_version": 1,
13 | "entrypoints": []
14 | },
15 | {
16 | "name": "XR_VARJO_foveated_rendering",
17 | "extension_version": 3,
18 | "entrypoints": []
19 | }
20 | ],
21 | "functions": {
22 | "xrNegotiateLoaderApiLayerInterface": "xrNegotiateLoaderApiLayerInterface"
23 | },
24 | "disable_environment": "DISABLE_XR_APILAYER_name"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/openxr-api-layer/openxr-api-layer-32.json:
--------------------------------------------------------------------------------
1 | {
2 | "file_format_version" : "1.0.0",
3 | "api_layer": {
4 | "name": "XR_APILAYER_name",
5 | "library_path": ".\\XR_APILAYER_name-32.dll",
6 | "api_version": "1.0",
7 | "implementation_version": "1",
8 | "description": "Emulate quad views foveation support",
9 | "instance_extensions": [
10 | {
11 | "name": "XR_VARJO_quad_views",
12 | "extension_version": 1,
13 | "entrypoints": []
14 | },
15 | {
16 | "name": "XR_VARJO_foveated_rendering",
17 | "extension_version": 3,
18 | "entrypoints": []
19 | }
20 | ],
21 | "functions": {
22 | "xrNegotiateLoaderApiLayerInterface": "xrNegotiateLoaderApiLayerInterface"
23 | },
24 | "disable_environment": "DISABLE_XR_APILAYER_name"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/installer/README.rtf:
--------------------------------------------------------------------------------
1 | {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
2 | {\colortbl ;\red43\green145\blue175;\red163\green21\blue21;\red0\green0\blue0;\red0\green0\blue255;}
3 | {\*\generator Riched20 10.0.19041}\viewkind4\uc1
4 | \pard\sa200\sl240\slmult1\qj\cf1\f0\fs22\lang9 OpenXR Foveated Rendering with Quad Views - \cf0\fs16 v1.1.4\cf2\fs22\par
5 | \cf3\fs19 This software enables the use of foveated rendering (with or without eye tracking) with applications using OpenXR and the Varjo quad views rendering technique. Two examples of such applications are DCS World and Pavlov VR.\par
6 | Please visit the official page at {\cf0{\field{\*\fldinst{HYPERLINK https://github.com/mbucchia/Quad-Views-Foveated/wiki }}{\fldrslt{https://github.com/mbucchia/Quad-Views-Foveated/wiki\ul0\cf0}}}}\f0\fs19 for detailed instructions on how to download,\lang1033 \lang9 install, and use this software.\par
7 | \b DISCLAIMER: This software is distributed as-is, without any warranties or conditions of any kind. Use at your own risks.\par
8 | \b0 This software was created by Matthieu Bucchianeri.\par
9 | }
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022-2023 Matthieu Bucchianeri
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/settings.cfg:
--------------------------------------------------------------------------------
1 | #
2 | # DO NOT EDIT THIS FILE!
3 | # INSTEAD, CREATE A NEW FILE `settings.cfg` UNDER `%LocalAppData%\Quad-Views-Foveated`
4 | # DO NOT COPY THIS FILE, START FROM A BLANK FILE!
5 | #
6 |
7 | # Common settings for all headsets (unless overriden below).
8 | smoothen_focus_view_edges=0.2
9 | sharpen_focus_view=0.7
10 | # Turbo mode is an unsafe feature that should not be enabled by default.
11 | turbo_mode=0
12 |
13 | # Fixed Foveated rendering settings for fallback when eye tracker is not available.
14 | horizontal_fixed_section=0.5
15 | vertical_fixed_section=0.45
16 |
17 | [Oculus]
18 | peripheral_multiplier=0.4
19 | focus_multiplier=1.1
20 | horizontal_focus_section=0.5
21 | vertical_focus_section=0.5
22 |
23 | [Varjo]
24 | horizontal_focus_section=0.29
25 | vertical_focus_section=0.33
26 | # Turbo mode is incompatible with Varjo's deferred swapchain release. Use OpenXR Toolkit Turbo instead.
27 | turbo_mode=0
28 |
29 | [PimaxXR]
30 | # Dynamic Foveated Rendering settings (for Crystal)
31 | horizontal_focus_section=0.33
32 | vertical_focus_section=0.31
33 |
34 | [Windows Mixed Reality]
35 | peripheral_multiplier=0.4
36 | focus_multiplier=1.1
37 | # Dynamic Foveated Rendering settings (for G2 Omnicept Edition)
38 | horizontal_focus_section=0.3
39 | vertical_focus_section=0.3
40 | vertical_focus_offset=0.04
41 |
42 | [SteamVR]
43 | # Turbo Mode causes unexplained errors with SteamVR.
44 | turbo_mode=0
45 |
46 |
47 | # Un-advertise in incompatible apps.
48 | [exe:Contractors]
49 | unadvertise=1
50 | [app:WanderingSpace]
51 | unadvertise=1
52 |
--------------------------------------------------------------------------------
/CustomSetup/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CustomSetup")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("CustomSetup")]
13 | [assembly: AssemblyCopyright("Copyright © 2023")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b6c07936-a1d2-4a80-b559-b55e3f15cc97")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.1.4.0")]
36 | [assembly: AssemblyFileVersion("1.1.4.0")]
37 |
--------------------------------------------------------------------------------
/openxr-api-layer/framework/dispatch.h:
--------------------------------------------------------------------------------
1 | // MIT License
2 | //
3 | // Copyright(c) 2022-2023 Matthieu Bucchianeri
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this softwareand associated documentation files(the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions :
11 | //
12 | // The above copyright noticeand this permission notice shall be included in all
13 | // copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | // SOFTWARE.
22 |
23 | #pragma once
24 |
25 | namespace openxr_api_layer {
26 |
27 | XrResult XRAPI_CALL xrCreateApiLayerInstance(const XrInstanceCreateInfo* instanceCreateInfo,
28 | const struct XrApiLayerCreateInfo* apiLayerInfo,
29 | XrInstance* instance);
30 | XrResult XRAPI_CALL xrGetInstanceProcAddr(XrInstance instance, const char* name, PFN_xrVoidFunction* function);
31 |
32 | } // namespace openxr_api_layer
33 |
--------------------------------------------------------------------------------
/openxr-api-layer/ProjectionVS.hlsl:
--------------------------------------------------------------------------------
1 | // MIT License
2 | //
3 | // Copyright(c) 2023 Matthieu Bucchianeri
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this softwareand associated documentation files(the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions :
11 | //
12 | // The above copyright noticeand this permission notice shall be included in all
13 | // copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | // SOFTWARE.
22 |
23 | // A Vertex Shader that draws a full-screen quad and projects the coordinates of two layers.
24 |
25 | cbuffer ConstantBuffer : register(b0) {
26 | float4x4 focusProjection;
27 | };
28 |
29 | void main(in uint id : SV_VertexID, out float4 position : SV_POSITION, out float2 texcoord : PROJ_COORD0, out float3 projectedFocusCoord : PROJ_COORD1) {
30 | texcoord = float2((id == 1) ? 2.0 : 0.0, (id == 2) ? 2.0 : 0.0);
31 | position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
32 | projectedFocusCoord = mul(position, focusProjection).xyw;
33 | }
34 |
--------------------------------------------------------------------------------
/openxr-api-layer/framework/layer_apis.py:
--------------------------------------------------------------------------------
1 | # The list of OpenXR functions our layer will override.
2 | override_functions = [
3 | "xrGetSystem",
4 | "xrGetSystemProperties",
5 | "xrEnumerateViewConfigurations",
6 | "xrGetViewConfigurationProperties",
7 | "xrEnumerateViewConfigurationViews",
8 | "xrEnumerateEnvironmentBlendModes",
9 | "xrCreateReferenceSpace",
10 | "xrDestroySpace",
11 | "xrCreateSession",
12 | "xrDestroySession",
13 | "xrBeginSession",
14 | "xrAttachSessionActionSets",
15 | "xrCreateSwapchain",
16 | "xrDestroySwapchain",
17 | "xrAcquireSwapchainImage",
18 | "xrReleaseSwapchainImage",
19 | "xrLocateViews",
20 | "xrLocateSpace",
21 | "xrWaitFrame",
22 | "xrBeginFrame",
23 | "xrEndFrame",
24 | "xrPollEvent",
25 | "xrSyncActions",
26 | "xrGetVisibilityMaskKHR",
27 | ]
28 |
29 | # The list of OpenXR functions our layer will use from the runtime.
30 | # Might repeat entries from override_functions above.
31 | requested_functions = [
32 | "xrGetInstanceProperties",
33 | "xrGetSystem",
34 | "xrGetSystemProperties",
35 | "xrCreateReferenceSpace",
36 | "xrDestroySpace",
37 | "xrCreateSwapchain",
38 | "xrDestroySwapchain",
39 | "xrEnumerateSwapchainImages",
40 | "xrAcquireSwapchainImage",
41 | "xrWaitSwapchainImage",
42 | "xrReleaseSwapchainImage",
43 | "xrPathToString",
44 | "xrStringToPath",
45 | "xrCreateActionSet",
46 | "xrCreateAction",
47 | "xrSuggestInteractionProfileBindings",
48 | "xrCreateActionSpace",
49 | "xrLocateViews",
50 | "xrWaitFrame",
51 | "xrBeginFrame",
52 | "xrGetActionStatePose",
53 | "xrSyncActions",
54 | "xrCreateEyeTrackerFB",
55 | "xrGetEyeGazesFB",
56 | ]
57 |
58 | # The list of OpenXR extensions our layer will either override or use.
59 | extensions = ["XR_KHR_visibility_mask", "XR_FB_eye_tracking_social"]
60 |
--------------------------------------------------------------------------------
/openxr-api-layer/layer.h:
--------------------------------------------------------------------------------
1 | // MIT License
2 | //
3 | // Copyright(c) 2022-2023 Matthieu Bucchianeri
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this softwareand associated documentation files(the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions :
11 | //
12 | // The above copyright noticeand this permission notice shall be included in all
13 | // copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | // SOFTWARE.
22 |
23 | #pragma once
24 |
25 | #include "framework/dispatch.gen.h"
26 |
27 | namespace openxr_api_layer {
28 |
29 | const std::string LayerName = LAYER_NAME;
30 | const std::string LayerPrettyName = "Quad-Views-Foveated";
31 | extern const std::string VersionString;
32 |
33 | // Singleton accessor.
34 | OpenXrApi* GetInstance();
35 |
36 | // The path where the DLL is loaded from (eg: to load data files).
37 | extern std::filesystem::path dllHome;
38 |
39 | // The path that is writable (eg: to store logs).
40 | extern std::filesystem::path localAppData;
41 |
42 | extern const std::vector> advertisedExtensions;
43 | extern const std::vector blockedExtensions;
44 | extern const std::vector implicitExtensions;
45 |
46 | } // namespace openxr_api_layer
47 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Foveated Rendering via Quad Views
2 |
3 | In layperson's terms:
4 |
5 | This software lets you use Eye-Tracked Foveated Rendering (sometimes referred to as Dynamic Foveated Rendering) with your Pimax Crystal, Meta Quest Pro, and other headsets supporting eye tracking via OpenXR in games using the [quad views rendering](https://github.com/mbucchia/Quad-Views-Foveated/wiki/What-is-Quad-Views-rendering%3F) technique like Digital Combat Simulation (DCS) and Pavlov VR.
6 |
7 | In technical terms:
8 |
9 | This software enables OpenXR apps developed with [`XR_VARJO_quad_views`](https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_VARJO_quad_views) and optionally [`XR_VARJO_foveated_rendering`](https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_VARJO_foveated_rendering) to be used on platforms that do not typically support those extensions. It composes each quad view projection layer into a stereo projection layer, and uses the eye tracking support on the device to make the inner projection views follow the eye gaze.
10 |
11 | DISCLAIMER: This software is distributed as-is, without any warranties or conditions of any kind. Use at your own risks.
12 |
13 | # Details and instructions on the [the wiki](https://github.com/mbucchia/Quad-Views-Foveated/wiki)!
14 |
15 | ## Setup
16 |
17 | Download the latest version from the [Releases page](https://github.com/mbucchia/Quad-Views-Foveated/releases). Find the installer program under **Assets**, file `Quad-Views-Foveated-.msi`.
18 |
19 | More information on the [the wiki](https://github.com/mbucchia/Quad-Views-Foveated/wiki)!
20 |
21 | For troubleshooting, the log file can be found at `%LocalAppData%\Quad-Views-Foveated\Quad-Views-Foveated.log`.
22 |
23 | ## Donate
24 |
25 | Donations are welcome and totally optional. Please use [my GitHub sponsorship page](https://github.com/sponsors/mbucchia) to make one-time or recurring donations!
26 |
27 | Thank you!
28 |
29 | ## Special thanks
30 |
31 | Thanks to my beta testers for helping throughout development and release (in alphabetical order):
32 |
33 | - BARRACUDAS
34 | - edmuss
35 | - MastahFR
36 | - mfrisby
37 | - Omniwhatever
38 | - xMcCARYx
39 |
--------------------------------------------------------------------------------
/openxr-api-layer/framework/log.h:
--------------------------------------------------------------------------------
1 | // MIT License
2 | //
3 | // Copyright(c) 2022-2023 Matthieu Bucchianeri
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this softwareand associated documentation files(the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions :
11 | //
12 | // The above copyright noticeand this permission notice shall be included in all
13 | // copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | // SOFTWARE.
22 |
23 | #pragma once
24 |
25 | #include "pch.h"
26 |
27 | namespace openxr_api_layer::log {
28 |
29 | TRACELOGGING_DECLARE_PROVIDER(g_traceProvider);
30 |
31 | extern TraceLoggingActivity g_traceGlobal;
32 |
33 | #define IsTraceEnabled() TraceLoggingProviderEnabled(g_traceProvider, 0, 0)
34 |
35 | #define TraceLocalActivity(activity) TraceLoggingActivity activity;
36 |
37 | #define TLArg(var, ...) TraceLoggingValue(var, ##__VA_ARGS__)
38 | #define TLPArg(var, ...) TraceLoggingPointer(var, ##__VA_ARGS__)
39 | #ifdef _M_IX86
40 | #define TLXArg TLArg
41 | #else
42 | #define TLXArg TLPArg
43 | #endif
44 |
45 | // General logging function.
46 | void Log(const char* fmt, ...);
47 | static inline void Log(const std::string_view& str) {
48 | Log(str.data());
49 | }
50 |
51 | // Debug logging function. Can make things very slow (only enabled on Debug builds).
52 | void DebugLog(const char* fmt, ...);
53 | static inline void DebugLog(const std::string_view& str) {
54 | Log(str.data());
55 | }
56 |
57 | // Error logging function. Goes silent after too many errors.
58 | void ErrorLog(const char* fmt, ...);
59 | static inline void ErrorLog(const std::string_view& str) {
60 | Log(str.data());
61 | }
62 |
63 | } // namespace openxr_api_layer::log
64 |
--------------------------------------------------------------------------------
/openxr-api-layer/resource.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #include "resource.h"
4 |
5 | #define APSTUDIO_READONLY_SYMBOLS
6 | /////////////////////////////////////////////////////////////////////////////
7 | //
8 | // Generated from the TEXTINCLUDE 2 resource.
9 | //
10 | #include "winres.h"
11 |
12 | /////////////////////////////////////////////////////////////////////////////
13 | #undef APSTUDIO_READONLY_SYMBOLS
14 |
15 | /////////////////////////////////////////////////////////////////////////////
16 | // English (United States) resources
17 |
18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
19 | LANGUAGE 9, 1
20 |
21 | #ifdef APSTUDIO_INVOKED
22 | /////////////////////////////////////////////////////////////////////////////
23 | //
24 | // TEXTINCLUDE
25 | //
26 |
27 | 1 TEXTINCLUDE
28 | BEGIN
29 | "resource.h\0"
30 | END
31 |
32 | 2 TEXTINCLUDE
33 | BEGIN
34 | "#include ""winres.h""\r\n"
35 | "\0"
36 | END
37 |
38 | 3 TEXTINCLUDE
39 | BEGIN
40 | "\r\n"
41 | "\0"
42 | END
43 |
44 | #endif // APSTUDIO_INVOKED
45 |
46 |
47 | /////////////////////////////////////////////////////////////////////////////
48 | //
49 | // Version
50 | //
51 |
52 | VS_VERSION_INFO VERSIONINFO
53 | FILEVERSION 1,1,4,0
54 | PRODUCTVERSION 1,1,4,0
55 | FILEFLAGSMASK 0x3fL
56 | #ifdef _DEBUG
57 | FILEFLAGS 0x1L
58 | #else
59 | FILEFLAGS 0x0L
60 | #endif
61 | FILEOS 0x40004L
62 | FILETYPE 0x2L
63 | FILESUBTYPE 0x0L
64 | BEGIN
65 | BLOCK "StringFileInfo"
66 | BEGIN
67 | BLOCK "040904b0"
68 | BEGIN
69 | VALUE "FileVersion", "1.1.4.0"
70 | VALUE "InternalName", "XR_APILAYER_MBUCCHIA_quad_views_foveated.dll"
71 | VALUE "LegalCopyright", "Copyright (c) 2023 Matthieu Bucchianeri"
72 | VALUE "OriginalFilename", "XR_APILAYER_MBUCCHIA_quad_views_foveated.dll"
73 | VALUE "ProductName", "Quad-Views-Foveated"
74 | VALUE "ProductVersion", "1.1.4.0"
75 | END
76 | END
77 | BLOCK "VarFileInfo"
78 | BEGIN
79 | VALUE "Translation", 0x409, 1200
80 | END
81 | END
82 |
83 | #endif // English (United States) resources
84 | /////////////////////////////////////////////////////////////////////////////
85 |
86 |
87 |
88 | #ifndef APSTUDIO_INVOKED
89 | /////////////////////////////////////////////////////////////////////////////
90 | //
91 | // Generated from the TEXTINCLUDE 3 resource.
92 | //
93 |
94 |
95 | /////////////////////////////////////////////////////////////////////////////
96 | #endif // not APSTUDIO_INVOKED
97 |
--------------------------------------------------------------------------------
/scripts/Tracing.wprp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/.github/workflows/msbuild.yml:
--------------------------------------------------------------------------------
1 | name: MSBuild
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | - release/*
8 | tags:
9 | - '[0-9]+.[0-9]+.[0-9]+'
10 | pull_request:
11 | branches:
12 | - main
13 | - release/*
14 | workflow_dispatch:
15 |
16 | env:
17 | SOLUTION_FILE_PATH: XR_APILAYER_MBUCCHIA_quad_views_foveated.sln
18 | BUILD_CONFIGURATION: Release
19 |
20 | jobs:
21 | build:
22 | runs-on: windows-latest
23 | environment: build-and-sign
24 |
25 | steps:
26 | - name: Checkout project
27 | uses: actions/checkout@v2
28 |
29 | - name: Checkout submodules
30 | working-directory: ${{env.GITHUB_WORKSPACE}}
31 | run: git submodule update --init
32 |
33 | - name: Setup DevEnv
34 | uses: seanmiddleditch/gha-setup-vsdevenv@v4
35 |
36 | - name: Setup Python
37 | uses: actions/setup-python@v2.3.1
38 | with:
39 | python-version: 3.8
40 |
41 | - name: Restore NuGet packages
42 | working-directory: ${{env.GITHUB_WORKSPACE}}
43 | run: nuget restore ${{env.SOLUTION_FILE_PATH}}
44 |
45 | - name: Build
46 | env:
47 | PFX_PASSWORD: ${{ secrets.PFX_PASSWORD }}
48 | PFX_NAME: ${{env.PFX_NAME}}
49 | working-directory: ${{env.GITHUB_WORKSPACE}}
50 | run: |
51 | # Need to build vdproj. We must invoke this tool from inside its own folder.
52 | $DisableOutOfProcBuild=$(vswhere -latest -find **\DisableOutOfProcBuild.exe)
53 | Push-Location $(Split-Path $DisableOutOfProcBuild)
54 | & $DisableOutOfProcBuild
55 | Pop-Location
56 |
57 | # Finally, we may build the project.
58 | devenv.com ${{env.SOLUTION_FILE_PATH}} /Build "${{env.BUILD_CONFIGURATION}}|x64"
59 |
60 | - name: Signing
61 | env:
62 | PFX_PASSWORD: ${{ secrets.PFX_PASSWORD }}
63 | PFX_NAME: ${{env.PFX_NAME}}
64 | working-directory: ${{env.GITHUB_WORKSPACE}}
65 | run: |
66 | $pfxName = if ($env:PFX_NAME) { $env:PFX_NAME } else { "selfsigncert" };
67 | installer/signtool.exe sign /d "OpenXR Quad Views Foveated" /du "https://github.com/mbucchia/Quad-Views-Foveated" /f installer/$pfxName.pfx /p "$env:PFX_PASSWORD" /v installer/output/Quad-Views-Foveated.msi
68 |
69 | - name: Publish
70 | uses: actions/upload-artifact@v2
71 | with:
72 | name: Setup
73 | path: |
74 | installer/output/Quad-Views-Foveated.msi
75 |
76 | - name: Publish
77 | uses: actions/upload-artifact@v2
78 | with:
79 | name: Symbols
80 | path: |
81 | bin/x64/Release/XR_APILAYER_MBUCCHIA_quad_views_foveated.pdb
82 |
--------------------------------------------------------------------------------
/openxr-api-layer/framework/util.h:
--------------------------------------------------------------------------------
1 | // MIT License
2 | //
3 | // Copyright(c) 2022-2023 Matthieu Bucchianeri
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this softwareand associated documentation files(the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions :
11 | //
12 | // The above copyright noticeand this permission notice shall be included in all
13 | // copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | // SOFTWARE.
22 |
23 | #pragma once
24 |
25 | #include "pch.h"
26 |
27 | namespace xr {
28 |
29 | static inline std::string ToString(XrVersion version) {
30 | return fmt::format("{}.{}.{}", XR_VERSION_MAJOR(version), XR_VERSION_MINOR(version), XR_VERSION_PATCH(version));
31 | }
32 |
33 | static inline std::string ToString(const XrPosef& pose) {
34 | return fmt::format("p: ({:.3f}, {:.3f}, {:.3f}), o:({:.3f}, {:.3f}, {:.3f}, {:.3f})",
35 | pose.position.x,
36 | pose.position.y,
37 | pose.position.z,
38 | pose.orientation.x,
39 | pose.orientation.y,
40 | pose.orientation.z,
41 | pose.orientation.w);
42 | }
43 |
44 | static inline std::string ToString(const XrFovf& fov) {
45 | return fmt::format(
46 | "(l:{:.3f}, r:{:.3f}, u:{:.3f}, d:{:.3f})", fov.angleLeft, fov.angleRight, fov.angleUp, fov.angleDown);
47 | }
48 |
49 | static inline std::string ToString(const XrVector2f& vec) {
50 | return fmt::format("({:.3f}, {:.3f})", vec.x, vec.y);
51 | }
52 |
53 | static inline std::string ToString(const XrVector3f& vec) {
54 | return fmt::format("({:.3f}, {:.3f}, {:.3f})", vec.x, vec.y, vec.z);
55 | }
56 |
57 | static inline std::string ToString(const XrRect2Di& rect) {
58 | return fmt::format(
59 | "x:{}, y:{}, w:{}, h:{}", rect.offset.x, rect.offset.y, rect.extent.width, rect.extent.height);
60 | }
61 |
62 | static inline std::string ToString(const XrRect2Df& rect) {
63 | return fmt::format(
64 | "x:{}, y:{}, w:{}, h:{}", rect.offset.x, rect.offset.y, rect.extent.width, rect.extent.height);
65 | }
66 |
67 | } // namespace xr
--------------------------------------------------------------------------------
/openxr-api-layer/utils/general.h:
--------------------------------------------------------------------------------
1 | // MIT License
2 | //
3 | // Copyright(c) 2022-2023 Matthieu Bucchianeri
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this softwareand associated documentation files(the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions :
11 | //
12 | // The above copyright notice and this permission notice shall be included in all
13 | // copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | // SOFTWARE.
22 |
23 | #pragma once
24 |
25 | namespace xr::math {
26 |
27 | static inline XrVector3f Cross(const XrVector3f& a, const XrVector3f& b) {
28 | return {
29 | a.y * b.z - a.z * b.y,
30 | a.z * b.x - a.x * b.z,
31 | a.x * b.y - a.y * b.x,
32 | };
33 | }
34 |
35 | } // namespace xr::math
36 |
37 | namespace openxr_api_layer::utils::general {
38 |
39 | struct ITimer {
40 | virtual ~ITimer() = default;
41 |
42 | virtual void start() = 0;
43 | virtual void stop() = 0;
44 |
45 | virtual uint64_t query() const = 0;
46 | };
47 |
48 | std::shared_ptr createTimer();
49 |
50 | static inline bool startsWith(const std::string& str, const std::string& substr) {
51 | return str.find(substr) == 0;
52 | }
53 |
54 | static inline bool endsWith(const std::string& str, const std::string& substr) {
55 | const auto pos = str.find(substr);
56 | return pos != std::string::npos && pos == str.size() - substr.size();
57 | }
58 |
59 | // Both ray and quadCenter poses must be located using the same base space.
60 | bool hitTest(const XrPosef& ray, const XrPosef& quadCenter, const XrExtent2Df& quadSize, XrPosef& hitPose);
61 |
62 | // Get UV coordinates for a point on quad.
63 | XrVector2f getUVCoordinates(const XrVector3f& point, const XrPosef& quadCenter, const XrExtent2Df& quadSize);
64 | static inline POINT getUVCoordinates(const XrVector3f& point,
65 | const XrPosef& quadCenter,
66 | const XrExtent2Df& quadSize,
67 | const XrExtent2Di& quadPixelSize) {
68 | const XrVector2f uv = getUVCoordinates(point, quadCenter, quadSize);
69 | return {static_cast(uv.x * quadPixelSize.width), static_cast(uv.y * quadPixelSize.height)};
70 | }
71 |
72 | } // namespace openxr_api_layer::utils::general
73 |
--------------------------------------------------------------------------------
/openxr-api-layer/framework/log.cpp:
--------------------------------------------------------------------------------
1 | // MIT License
2 | //
3 | // Copyright(c) 2022-2023 Matthieu Bucchianeri
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this softwareand associated documentation files(the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions :
11 | //
12 | // The above copyright noticeand this permission notice shall be included in all
13 | // copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | // SOFTWARE.
22 |
23 | #include "pch.h"
24 |
25 | namespace {
26 | constexpr uint32_t k_maxLoggedErrors = 100;
27 | uint32_t g_globalErrorCount = 0;
28 | } // namespace
29 |
30 | namespace openxr_api_layer::log {
31 | extern std::ofstream logStream;
32 |
33 | // {cbf3adcd-42b1-4c38-830c-91980af201f8}
34 | TRACELOGGING_DEFINE_PROVIDER(g_traceProvider,
35 | "QuadViewsFoveated",
36 | (0xcbf3adcd, 0x42b1, 0x4c38, 0x83, 0x0c, 0x98, 0x98, 0x0a, 0xf2, 0x01, 0xf8));
37 |
38 | TraceLoggingActivity g_traceActivity;
39 |
40 | namespace {
41 |
42 | // Utility logging function.
43 | void InternalLog(const char* fmt, va_list va) {
44 | const std::time_t now = std::time(nullptr);
45 |
46 | char buf[1024];
47 | size_t offset = std::strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %z: ", std::localtime(&now));
48 | vsnprintf_s(buf + offset, sizeof(buf) - offset, _TRUNCATE, fmt, va);
49 | OutputDebugStringA(buf);
50 | if (logStream.is_open()) {
51 | logStream << buf;
52 | logStream.flush();
53 | }
54 | }
55 | } // namespace
56 |
57 | void Log(const char* fmt, ...) {
58 | va_list va;
59 | va_start(va, fmt);
60 | InternalLog(fmt, va);
61 | va_end(va);
62 | }
63 |
64 | void ErrorLog(const char* fmt, ...) {
65 | if (g_globalErrorCount++ < k_maxLoggedErrors) {
66 | va_list va;
67 | va_start(va, fmt);
68 | InternalLog(fmt, va);
69 | va_end(va);
70 | if (g_globalErrorCount == k_maxLoggedErrors) {
71 | Log("Maximum number of errors logged. Going silent.");
72 | }
73 | }
74 | }
75 |
76 | void DebugLog(const char* fmt, ...) {
77 | #ifdef _DEBUG
78 | va_list va;
79 | va_start(va, fmt);
80 | InternalLog(fmt, va);
81 | va_end(va);
82 | #endif
83 | }
84 |
85 | } // namespace openxr_api_layer::log
86 |
--------------------------------------------------------------------------------
/openxr-api-layer/pch.h:
--------------------------------------------------------------------------------
1 | // MIT License
2 | //
3 | // Copyright(c) 2022-2023 Matthieu Bucchianeri
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this softwareand associated documentation files(the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions :
11 | //
12 | // The above copyright noticeand this permission notice shall be included in all
13 | // copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | // SOFTWARE.
22 |
23 | #pragma once
24 |
25 | // Uncomment below the graphics frameworks used by the layer.
26 |
27 | #define XR_USE_GRAPHICS_API_D3D11
28 | #define XR_USE_GRAPHICS_API_D3D12
29 |
30 | // Standard library.
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include