Skip to content
This repository was archived by the owner on Dec 14, 2025. It is now read-only.

Commit 38e57df

Browse files
committed
Remove the call overhead when the API layer cannot load configuration. Improve setup process and instructions.
1 parent 6fb0afe commit 38e57df

8 files changed

+27
-20
lines changed

Install-Layer.ps1

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$JsonPath = Join-Path "$PSScriptRoot" "XR_APILAYER_NOVENDOR_fov_modifier.json"
2+
Start-Process -FilePath reg.exe -Verb RunAs -Wait -ArgumentList "ADD HKLM\Software\Khronos\OpenXR\1\ApiLayers\Implicit /v `"$JsonPath`" /f /t REG_DWORD /d 0"

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
## Download
44

5-
A ZIP file containing the necessary files to install and use the layer can be found on the release page: https://github.com/mbucchia/XR_APILAYER_NOVENDOR_fov_modifier/releases.
5+
A ZIP file containing the necessary files to install and use the layer can be found on the release page: https://github.com/mbucchia/XR_APILAYER_NOVENDOR_fov_modifier/releases. Check under *Assets*.
66

77
## Setup
88

99
1. Create a folder in `%ProgramFiles%`. It's important to make it in `%ProgramFiles%` so that UWP applications can access it! For example: `C:\Program Files\OpenXR-API-Layers`.
1010

11-
2. Place `XR_APILAYER_NOVENDOR_fov_modifier.json`, `XR_APILAYER_NOVENDOR_fov_modifier.dll`, `Install-Layer.ps1` and `Uninstall-Layer.ps1` in the folder created above.
11+
2. Place `XR_APILAYER_NOVENDOR_fov_modifier.json`, `XR_APILAYER_NOVENDOR_fov_modifier.dll`, `Install-XR_APILAYER_NOVENDOR_fov_modifier.ps1` and `Uninstall-XR_APILAYER_NOVENDOR_fov_modifier.ps1` in the folder created above.
1212

13-
3. Run the script `Install-Layer.ps1` **as Administrator**.
13+
3. Run the script `Install-XR_APILAYER_NOVENDOR_fov_modifier.ps1`. You will be prompted for elevation (running as Administrator).
1414

1515
4. Start the OpenXR Developer Tools for Windows Mixed Reality, under the *System Status* tab, scroll down to *API Layers*. A layer named `XR_APILAYER_NOVENDOR_fov_modifier` should be listed.
1616

1717
## Removal
1818

1919
1. Go to the folder where the API layer is installed. For example: `C:\Program Files\OpenXR-API-Layers`.
2020

21-
2. Run the script `Uninstall-Layer.ps1` **as Administrator**.
21+
2. Run the script `Uninstall-XR_APILAYER_NOVENDOR_fov_modifier.ps1` You will be prompted for elevation (running as Administrator).
2222

2323
3. Start the OpenXR Developer Tools for Windows Mixed Reality, under the *System Status* tab, scroll down to *API Layers*. There should be no layer named `XR_APILAYER_NOVENDOR_fov_modifier`.
2424

@@ -35,7 +35,6 @@ dllHome is "C:\Program Files\OpenXR-API-Layers"
3535
XR_APILAYER_NOVENDOR_fov_modifier layer is active
3636
Could not load config for "FS2020"
3737
Could not load config for "Zouna"
38-
Using FOV for left 1.000 1.000 1.000 1.000 and right 1.000 1.000 1.000
3938
```
4039

4140
4. In the same folder where `XR_APILAYER_NOVENDOR_fov_modifier.json` was copied during setup, create a file named after the application, and with the extension `.cfg`. For example `C:\Program Files\OpenXR-API-Layers\FS2020.cfg`.

Uninstall-Layer.ps1

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$JsonPath = Join-Path "$PSScriptRoot" "XR_APILAYER_NOVENDOR_fov_modifier.json"
2+
Start-Process -FilePath reg.exe -Verb RunAs -Wait -ArgumentList "DELETE HKLM\Software\Khronos\OpenXR\1\ApiLayers\Implicit /v `"$JsonPath`" /f"

XR_APILAYER_NOVENDOR_fov_modifier.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@
100100
</ItemGroup>
101101
<ItemGroup>
102102
<None Include=".gitignore" />
103-
<None Include="Install-Layer.ps1" />
103+
<None Include="Install-XR_APILAYER_NOVENDOR_fov_multiplier.ps1" />
104104
<None Include="packages.config" />
105105
<None Include="README.md" />
106-
<None Include="Uninstall-Layer.ps1" />
106+
<None Include="Uninstall-XR_APILAYER_NOVENDOR_fov_multiplier.ps1" />
107107
<None Include="XR_APILAYER_NOVENDOR_fov_modifier.json" />
108108
</ItemGroup>
109109
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

XR_APILAYER_NOVENDOR_fov_modifier.vcxproj.filters

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<None Include="XR_APILAYER_NOVENDOR_fov_modifier.json" />
2929
<None Include=".gitignore" />
3030
<None Include="README.md" />
31-
<None Include="Install-Layer.ps1" />
32-
<None Include="Uninstall-Layer.ps1" />
31+
<None Include="Install-XR_APILAYER_NOVENDOR_fov_multiplier.ps1" />
32+
<None Include="Uninstall-XR_APILAYER_NOVENDOR_fov_multiplier.ps1" />
3333
</ItemGroup>
3434
</Project>

dllmain.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ namespace {
3232
void Log(const char* fmt, ...);
3333

3434
struct {
35+
bool loaded;
36+
3537
float leftAngleUp;
3638
float leftAngleDown;
3739
float leftAngleLeft;
@@ -43,13 +45,17 @@ namespace {
4345

4446
void Dump()
4547
{
46-
Log("Using FOV for left %.3f %.3f %.3f %.3f and right %.3f %.3f %.3f %.3f\n",
47-
leftAngleUp, leftAngleDown, leftAngleLeft, leftAngleRight,
48-
rightAngleUp, rightAngleDown, rightAngleLeft, rightAngleRight);
48+
if (loaded)
49+
{
50+
Log("Using FOV for left %.3f %.3f %.3f %.3f and right %.3f %.3f %.3f %.3f\n",
51+
leftAngleUp, leftAngleDown, leftAngleLeft, leftAngleRight,
52+
rightAngleUp, rightAngleDown, rightAngleLeft, rightAngleRight);
53+
}
4954
}
5055

5156
void Reset()
5257
{
58+
loaded = false;
5359
leftAngleUp = 1.0f;
5460
leftAngleDown = 1.0f;
5561
leftAngleLeft = 1.0f;
@@ -162,6 +168,8 @@ namespace {
162168
}
163169
configFile.close();
164170

171+
config.loaded = true;
172+
165173
return true;
166174
}
167175

@@ -214,7 +222,7 @@ namespace {
214222

215223
// Call the chain to resolve the next function pointer.
216224
const XrResult result = nextXrGetInstanceProcAddr(instance, name, function);
217-
if (result == XR_SUCCESS)
225+
if (config.loaded && result == XR_SUCCESS)
218226
{
219227
const std::string apiName(name);
220228

@@ -256,13 +264,13 @@ namespace {
256264
return XR_ERROR_INITIALIZATION_FAILED;
257265
}
258266

267+
// Store the next xrGetInstanceProcAddr to resolve the functions no handled by our layer.
268+
nextXrGetInstanceProcAddr = apiLayerInfo->nextInfo->nextGetInstanceProcAddr;
269+
259270
// Call the chain to create the instance.
260271
const XrResult result = apiLayerInfo->nextInfo->nextCreateApiLayerInstance(instanceCreateInfo, apiLayerInfo, instance);
261272
if (result == XR_SUCCESS)
262273
{
263-
// Store the next xrGetInstanceProcAddr to resolve the functions no handled by our layer.
264-
nextXrGetInstanceProcAddr = apiLayerInfo->nextInfo->nextGetInstanceProcAddr;
265-
266274
// Identify the application and load our configuration. Try by application first, then fallback to engines otherwise.
267275
config.Reset();
268276
if (!LoadConfiguration(instanceCreateInfo->applicationInfo.applicationName)) {

0 commit comments

Comments
 (0)