diff --git a/.gitmodules b/.gitmodules index 40411be..5c196ff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,7 +5,6 @@ [submodule "thirdparty/tinygltf"] path = thirdparty/tinygltf url = https://github.com/syoyo/tinygltf.git - branch = master [submodule "thirdparty/imgui"] path = thirdparty/imgui url = https://github.com/ocornut/imgui.git diff --git a/ChangeLog.md b/ChangeLog.md index 731dbe9..c2766d7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,39 @@ # RTXGI SDK Change Log +## 1.3.5 + +### SDK +- **Improvements** + - Adds the new **Probe Variability** feature to the ```DDGIVolume``` + - This is an optional feature that tracks the [coefficient of variation](https://en.wikipedia.org/wiki/Coefficient_of_variation) of a ```DDGIVolume``` + - This can be used to estimate of how converged the probes of the volume are. When the coefficient settles around a small value, it is likely the probes contain representative irradiance values and ray tracing and probe updates can be disabled until an event occurs that invalidates the light field + - See [Probe Variability](docs/DDGIVolume.md#probe-variability) in the documentation for more details + - Adds changes to ```DDGIVolume``` D3D12 resource transitions based on feedback from GitHub Issue #68 (thanks!) + - ```UpdateDDGIVolumes()``` can now be safely used on direct *and* compute command lists + - Irradiance, Distance, and Probe Data resources are now expected to be in the ```D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE``` state by default + - These resources can be transitioned to the required states for each workload using the new ```DDGIVolume::TransitionResources(...)``` function where appropriate (also see ```EDDGIExecutionStage```) + +### Test Harness +- **Improvements** + - Adds support for the SDK's new [Probe Variability](docs/DDGIVolume.md#probe-variability) feature, including buffer visualization, UI toggles, and checks to disable/enable probe traces based on volume variability + - Adds support for Shader Execution Reordering in DDGI probe ray tracing and the reference Path Tracer (D3D12 only). Requires an RTX 4000 series (Ada) GPU. + - Adds NVAPI as a new dependency (Test Harness only) + - Improves acceleration structure organization + - Reorganizes how BLAS are created from GLTF2 Mesh and MeshPrimitives + - MeshPrimitives are now geometries of the same BLAS (instead of individual BLAS) + - This prevents bad traversal characteristics when MeshPrimitives create substantially overlapping BLAS and increases trace performance up to 2x + - Adds the GeometryData and MeshOffsets indirection buffers for looking up MeshPrimitive information + - Updates RGS and Hit Shaders to look up MeshPrimitive information using DXR 1.1 GeometryIndex() and the new indirection buffers + - Updates Closest Hit shaders to conform with the [GLTF 2.0 specification](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#metallic-roughness-material) for how albedo values sampled from texture should be combined with ```baseColorFactor```. Fixes GitHub Issue #67. + - Updates scene cache serialization/deserialization + - Stores new information and now stores a scene cache file for .glb scenes too +- **Bug Fixes** + - Updates DXC binaries to v1.7.2207 (on Windows) to fix a shader compilation issue + - Fixes issues with ```DDGIVolume``` name strings not being handled properly + - Fixes D3D12 resource state problems caught by the debug layer + - Fixes a handful of other minor issues + + ## 1.3.0 ### SDK diff --git a/docs/DDGIVolume.md b/docs/DDGIVolume.md index 6c8b928..7830c23 100644 --- a/docs/DDGIVolume.md +++ b/docs/DDGIVolume.md @@ -138,6 +138,10 @@ struct DDGIVolumeResourceIndices uint probeDistanceSRVIndex; uint probeDataUAVIndex; uint probeDataSRVIndex; + uint probeVariabilityUAVIndex; + uint probeVariabilitySRVIndex; + uint probeVariabilityAverageUAVIndex; + uint probeVariabilityAverageSRVIndex; }; ``` @@ -222,6 +226,7 @@ The main workloads executed by a ```DDGIVolume``` are implemented in three shade * ProbeBlendingCS.hlsl * ProbeRelocationCS.hlsl * ProbeClassificationCS.hlsl + * ReductionCS.hlsl To make it possible to directly use the SDK's shader files in your codebase (with or without the RTXGI SDK), shader functionality is configured through shader compiler defines. All shaders support both traditionally bound and bindless resource access methods. @@ -334,6 +339,10 @@ The following defines provide SDK shaders with the information necessary to unde * *D3D12:* the UAV shader register ```X``` and space ```Y``` of the DDGIVolume probe data texture array. * *Vulkan:* the binding slot ```X``` and descriptor set index ```Y``` of the DDGIVolume probe data texture array. +```PROBE_VARIABILITY_REGISTER [uX|X]```
```PROBE_VARIABILITY_SPACE [spaceY|Y]``` + * *D3D12:* the UAV shader register ```X``` and space ```Y``` of the DDGIVolume probe variability texture array. + * *Vulkan:* the binding slot ```X``` and descriptor set index ```Y``` of the DDGIVolume probe variability texture array. + --- ### [```ProbeBlendingCS.hlsl```](../rtxgi-sdk/shaders/ddgi/ProbeBlendingCS.hlsl) @@ -438,14 +447,40 @@ struct ProbeRelocationBytecode --- +### [```ReductionCS.hlsl```](../rtxgi-sdk/shaders/ddgi/ReductionCS.hlsl) + +This file contains compute shader code that reduces the probe variability texture down to a single value. See [Probe Variability](#probe-variability) for more information. + +This shader is used by the ```rtxgi::[d3d12|vulkan]::CalculateDDGIVolumeVariability(...)``` function. + +**Compilation Instructions** + +This shader file provides two entry points: + - ```DDGIReductionCS()``` - performs initial reduction pass on per-probe-texel variability data. + - ```DDGIExtraReductionCS()``` - if the probe variability texture is too large to reduce down to one value in a single pass, this shader will perform additional reductions and can be run repeatedly until the output reaches a single value. + +Pass compiled shader bytecode or pipeline state objects to the `ProbeVariabilityBytecode` or `ProbeVariability[PSO|Pipeline]` structs that corresponds to the entry points in the shader file (see below). + +```C++ +struct ProbeVariabilityBytecode +{ + ShaderBytecode reductionCS; // DDGIReductionCS() entry point + ShaderBytecode extraReductionCS; // DDGIExtraReductionCS() entry point +}; +``` + +--- + ## Texture Layout -The ```DDGIVolume``` uses four texture arrays to store its data: +The ```DDGIVolume``` uses six texture arrays to store its data: 1. Probe Ray Data 2. Probe Irradiance 3. Probe Distance 4. Probe Data + 5. Probe Variability + 6. Probe Variability Average ### Probe Ray Data @@ -514,6 +549,32 @@ Within a texel:
Figure 7: A visualization of the Probe Data texture (zoomed) for the Crytek Sponza scene
+### Probe Variability + +This texture array stores the [coefficient of variation](https://en.wikipedia.org/wiki/Coefficient_of_variation) for all probe irradiance texels in a volume used by [Probe Variability](#probe-variability). The texture dimensions and layout are the same as the irradiance texture array ***with probe border texels omitted***. This texture array has a single channel that stores the scalar coefficient of variation value. + +Below is a visualization of the texture array. The visualization defines a threshold value, then marks inactive probes in blue, below-threshold values in red, and above-threshold values in green. + +
+ +
Figure 8: A visualization of the Probe Variability texture array for the Cornell Box scene
+
+ +### Probe Variability Average + +[Probe Variability](#probe-variability) averages the coefficient of variation of all probes in a volume to generate a single variability value. This texture array stores the intermediate values used in the averaging process. The final average variability value is stored in texel (0, 0) when the reduction passes complete. + +This texture array has two channels: + - The averaged coefficient of variation is stored in the R channel + - A weight the reduction shader uses to average contributions from all probes is stored in the G channel + +Below is a visualization of the texture array. The visualization defines a threshold value, then marks inactive probes in blue, below-threshold values in red, and above-threshold values in green. + +
+ +
Figure 9: A visualization of the Probe Variability Average texture for the Cornell Box scene
+
+ ### Probe Count Limits In addition to the available memory of the physical device, the number of probes a volume can contain is bounded by the graphics API's limits on texture (array) resources. @@ -636,7 +697,7 @@ Critically, instead of adjusting the position of all probes when the active area
-
Figure 8: Infinite Scrolling Volume Movement
+
Figure 10: Infinite Scrolling Volume Movement
ISVs are also useful when dynamic indirect lighting is desired around the camera view or a player character. Anchor the infinite scrolling volume to the camera view or a player character and use the camera or player's movement to drive the volume's scrolling of the active area. @@ -661,7 +722,7 @@ Any regular grid of sampling points will struggle to robustly handle all content
-
Figure 9: (Left) Probes falling inside wall geometry without probe relocation. (Right) Probes adjusted to a more useful locations with probe relocation enabled.
+
Figure 11: (Left) Probes falling inside wall geometry without probe relocation. (Right) Probes adjusted to a more useful locations with probe relocation enabled.
To use Probe Relocation: @@ -692,7 +753,7 @@ Classification is executed in two phases:
-
Figure 10: Disabled probes are highlighted with red outlines. Probes inside of geometry or with no surrounding geometry are disabled.
+
Figure 12: Disabled probes are highlighted with red outlines. Probes inside of geometry or with no surrounding geometry are disabled.
@@ -707,9 +768,19 @@ The number of fixed rays is specified by the ```RTXGI_DDGI_NUM_FIXED_RAYS``` def
-
Figure 11: The default fixed rays distribution used in probe relocation and classification.
+
Figure 13: The default fixed rays distribution used in probe relocation and classification.
+# Probe Variability + +It is often the case that the irradiance estimates stored in ```DDGIVolume``` probes contain a non-zero level of variance (per octahedral texel), even after a substantial quantity of samples have been accumulated. In fact, it is possible that **some (or even all) texels of a given probe may never fully converge**. This results in a continuous amount of low frequency noise in indirect lighting estimates computed from a ```DDGIVolume```. While this is not a problem (visually) in a single frame (i.e. the estimate is still reasonable), the low frequency noise *changes randomly* each frame. This produces objectionable temporal artifacts. + +To address this problem, ```DDGIVolume``` are now able to track probe variability. Probe Variability measures an average [coefficient of variation](https://en.wikipedia.org/wiki/Coefficient_of_variation) across the volume's probes. This serves as an estimate of how voliatile the volume's estimate of the light field is from one update to the next. As more samples are blended in and probe irradiance estimates improve, the measured variability will decrease towards zero. + +Importantly, the **variability value may not ever reach zero**. Instead, probe irradiance estimates eventually settle in a state where the variability stays within a given range. At this point, probes are converged 'enough' and the objectionable low frequency noise can be avoided by pausing probe ray tracing and blending updates for the ```DDGIVolume```. When an event that triggers a change to the volume's light field occurs (e.g. a light or object moves, an explosion occurs, weather changes, etc) ray tracing and blending updates should be re-enabled until the variability measure settles again. + +The range and stability of probe variability values depends on several factors including: the extent of the ```DDGIVolume```, the distribution of probes, the number of rays traced per probe, and the light transport characteristics of the scene. As a result, the SDK exposes the measured variability and expects the application to make decisions to handle variability ranges and updates. + # Rules of Thumb Below are rules of thumb related to ```DDGIVolume``` configuration and how a volume's settings affect the lighting results and content creation. diff --git a/docs/Integration.md b/docs/Integration.md index e1afb26..647dbde 100644 --- a/docs/Integration.md +++ b/docs/Integration.md @@ -33,7 +33,9 @@ At Render-Time - *Tip:* use the SDK's ```RelocateDDGIVolumeProbes()``` function 5. [**Classify Probes (optional)**](DDGIVolume.md#probe-classification) within relevant, active ```DDGIVolume```s to deactivate tracing and blending operations for probes that do not contribute to the final result - *Tip:* use the SDK's ```ClassifyDDGIVolumeProbes()``` function -6. [**Query Irradiance**](#querying-irradiance-with-a-ddgivolume) from relevant, active ```DDGIVolume```s to gather indirect lighting in screen-space +6. [**Calculate Variability (optional)**](DDGIVolume.md#probe-variability) within relevant, active ```DDGIVolume```s to generate variability measurements for the current update, then use these values to determine if the volume should remain active or not + - *Tip:* use the SDK's ```CalculateDDGIVolumeVariability()``` and ```ReadbackDDGIVolumeVariability()``` functions +7. [**Query Irradiance**](#querying-irradiance-with-a-ddgivolume) from relevant, active ```DDGIVolume```s to gather indirect lighting in screen-space ### Implementation Details diff --git a/docs/images/ddgivolume-textures-probevariability-avg.jpg b/docs/images/ddgivolume-textures-probevariability-avg.jpg new file mode 100644 index 0000000..9a06c4d Binary files /dev/null and b/docs/images/ddgivolume-textures-probevariability-avg.jpg differ diff --git a/docs/images/ddgivolume-textures-probevariability.jpg b/docs/images/ddgivolume-textures-probevariability.jpg new file mode 100644 index 0000000..03f9796 Binary files /dev/null and b/docs/images/ddgivolume-textures-probevariability.jpg differ diff --git a/docs/images/integration-ddgi-flow.svg b/docs/images/integration-ddgi-flow.svg index ee6ea78..376fbb5 100644 --- a/docs/images/integration-ddgi-flow.svg +++ b/docs/images/integration-ddgi-flow.svg @@ -2,11 +2,11 @@ + id="defs1148"> + id="E" /> + id="F" /> + id="G" /> + id="H" /> + id="I" /> + id="J" /> + id="K" /> + id="L" /> + id="M" /> + id="N" /> + id="O" /> + id="P" /> + id="Q" /> + id="R" /> + id="S" /> + id="T" /> + id="U" /> + id="b"> + id="V" /> + id="W" /> + id="X" /> + id="Y" /> + id="Z" /> + id="aa" /> + id="ab" /> + id="ac" /> + id="ad" /> + id="ae" /> + id="af" /> + id="ag" /> + id="ah" /> + id="ai" /> + id="c"> + id="aj" /> + id="d"> + id="ak" /> + id="al" /> + id="e"> + id="am" /> + id="an" /> + id="f"> + id="g"> + id="h"> + id="ao" /> + id="i"> + id="ap" /> + id="j"> + id="l"> + id="m"> + id="aq" /> + id="ar" /> + id="n"> + id="o"> + id="p"> + id="as" /> + id="q"> + id="r"> + id="s"> + id="t"> + id="u"> + id="v"> + id="at" /> + id="w"> + id="x"> - - - - + id="y"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id="defs2551"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + d="M 114,-163 C 36,-179 61,-72 57,0 H 25 l -1,-190 h 30 c 1,12 -1,29 2,39 6,-27 23,-49 58,-41 v 29" + id="path3370" /> + d="M 141,0 90,-78 38,0 H 4 L 72,-98 7,-190 h 35 l 48,74 47,-74 h 35 l -64,92 68,98 h -35" + id="path3372" /> + d="M 177,-190 C 167,-65 218,103 67,71 44,65 29,51 23,28 L 55,23 C 70,70 155,55 144,-5 V -35 C 133,-14 115,1 83,1 29,1 15,-40 15,-95 c 0,-56 16,-97 71,-98 29,-1 48,16 59,35 1,-10 0,-23 2,-32 z M 94,-22 c 36,0 50,-32 50,-73 0,-42 -14,-75 -50,-75 -39,0 -46,34 -46,75 0,41 6,73 46,73" + id="path3374" /> + d="m 24,-231 v -30 h 32 v 30 z M 24,0 V -190 H 56 V 0 H 24" + id="path3376" /> + d="m 126,-127 c 33,6 58,20 58,59 0,88 -139,92 -164,29 -3,-8 -5,-16 -6,-25 l 32,-3 c 6,27 21,44 54,44 32,0 52,-15 52,-46 0,-38 -36,-46 -79,-43 v -28 c 39,1 72,-4 72,-42 0,-27 -17,-43 -46,-43 -28,0 -47,15 -49,41 l -32,-3 c 6,-42 35,-63 81,-64 48,-1 79,21 79,65 0,36 -21,52 -52,59" + id="path3378" /> + d="m 27,0 v -27 h 64 v -190 l -56,39 v -29 l 58,-41 h 29 v 221 h 61 V 0 H 27" + id="path3380" /> + d="m 101,-251 c 82,-7 93,87 43,132 L 82,-64 C 71,-53 59,-42 53,-27 H 182 V 0 H 18 c 2,-99 128,-94 128,-182 0,-28 -16,-43 -45,-43 -29,0 -46,15 -49,41 l -32,-3 c 6,-41 34,-60 81,-64" + id="path3382" /> + d="m 212,-179 c -10,-28 -35,-45 -73,-45 -59,0 -87,40 -87,99 0,60 29,101 89,101 43,0 62,-24 78,-52 l 27,14 C 228,-24 195,4 139,4 59,4 22,-46 18,-125 c -6,-104 99,-153 187,-111 19,9 31,26 39,46" + id="path3384" /> + d="m 117,-194 c 89,-4 53,116 60,194 h -32 v -121 c 0,-31 -8,-49 -39,-48 C 34,-167 62,-67 57,0 H 25 l -1,-190 h 30 c 1,10 -1,24 2,32 11,-22 29,-35 61,-36" + id="path3386" /> + d="m 135,-143 c -3,-34 -86,-38 -87,0 15,53 115,12 119,90 4,78 -150,74 -157,8 l 28,-5 c 4,36 97,45 98,0 -10,-56 -113,-15 -118,-90 -4,-57 82,-63 122,-42 12,7 21,19 24,35" + id="path3388" /> + d="M 106,-169 C 34,-169 62,-67 57,0 H 25 v -261 h 32 l -1,103 c 12,-21 28,-36 61,-36 89,0 53,116 60,194 h -32 v -121 c 2,-32 -8,-49 -39,-48" + id="path3390" /> + d="m 96,-169 c -40,0 -48,33 -48,73 0,40 9,75 48,75 24,0 41,-14 43,-38 l 32,2 C 165,-20 140,4 97,4 38,4 21,-37 15,-95 c -10,-93 101,-131 147,-64 4,7 5,14 7,22 l -32,3 c -4,-21 -16,-35 -41,-35" + id="path3392" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + d="m 68,-38 c 1,34 0,65 -14,84 H 32 C 41,33 49,20 49,0 H 33 v -38 h 35" + id="path3532" /> + + + + + + + + + + + d="M 190,0 58,-211 59,0 H 30 v -248 h 39 l 133,213 -2,-213 h 31 V 0 h -41" + id="path3552" /> + d="M 127,-220 V 0 H 93 V -220 H 8 v -28 h 204 v 28 h -85" + id="path3554" /> + + + + + + + d="m 115,-194 c 53,0 69,39 70,98 C 185,-30 162,4 115,4 84,3 66,-7 56,-30 L 54,0 H 23 l 1,-261 h 32 v 101 c 10,-23 28,-34 59,-34 z m -8,174 c 40,0 45,-34 45,-75 0,-40 -5,-75 -45,-74 -42,0 -51,32 -51,76 0,43 10,73 51,73" + id="path3566" /> + d="m 101,-234 c -31,-9 -42,10 -38,44 h 38 v 23 H 63 V 0 H 32 V -167 H 5 v -23 h 27 c -7,-52 17,-82 69,-68 v 24" + id="path3568" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id="g3650"> + + + - - - - - - - - - - - - - + d="m 30,-248 c 87,1 191,-15 191,75 0,78 -77,80 -158,76 V 0 H 30 Z m 33,125 c 57,0 124,11 124,-50 0,-59 -68,-47 -124,-48 v 98" + id="path3672" /> + id="g3800"> - - - - - - - - - - - - - + + - - - - - - + id="g3824"> + + + + + + + - - - - - - - - - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + id="g4366"> - - - - - - + + - - - - - - - - - - - - - + + + + + + + + + + > 20) & 0x00000007); output.probeRelocationEnabled = (bool)((input.packed4 >> 23) & 0x00000001); output.probeClassificationEnabled = (bool)((input.packed4 >> 24) & 0x00000001); - output.probeScrollClear[0] = (bool)((input.packed4 >> 25) & 0x00000001); - output.probeScrollClear[1] = (bool)((input.packed4 >> 26) & 0x00000001); - output.probeScrollClear[2] = (bool)((input.packed4 >> 27) & 0x00000001); - output.probeScrollDirections[0] = (bool)((input.packed4 >> 28) & 0x00000001); - output.probeScrollDirections[1] = (bool)((input.packed4 >> 29) & 0x00000001); - output.probeScrollDirections[2] = (bool)((input.packed4 >> 30) & 0x00000001); + output.probeVariabilityEnabled = (bool)((input.packed4 >> 25) & 0x00000001); + output.probeScrollClear[0] = (bool)((input.packed4 >> 26) & 0x00000001); + output.probeScrollClear[1] = (bool)((input.packed4 >> 27) & 0x00000001); + output.probeScrollClear[2] = (bool)((input.packed4 >> 28) & 0x00000001); + output.probeScrollDirections[0] = (bool)((input.packed4 >> 29) & 0x00000001); + output.probeScrollDirections[1] = (bool)((input.packed4 >> 30) & 0x00000001); + output.probeScrollDirections[2] = (bool)((input.packed4 >> 31) & 0x00000001); return output; } diff --git a/rtxgi-sdk/include/rtxgi/ddgi/gfx/DDGIVolume_D3D12.h b/rtxgi-sdk/include/rtxgi/ddgi/gfx/DDGIVolume_D3D12.h index 83665bf..a98e71b 100644 --- a/rtxgi-sdk/include/rtxgi/ddgi/gfx/DDGIVolume_D3D12.h +++ b/rtxgi-sdk/include/rtxgi/ddgi/gfx/DDGIVolume_D3D12.h @@ -33,6 +33,14 @@ namespace rtxgi COUNT }; + enum class EDDGIExecutionStage + { + POST_PROBE_TRACE = 0, + PRE_GATHER_CS, + PRE_GATHER_PS, + POST_GATHER_PS, + }; + //------------------------------------------------------------------------ // Managed Resource Mode (SDK manages volume resources) //------------------------------------------------------------------------ @@ -49,6 +57,12 @@ namespace rtxgi ShaderBytecode resetCS; // Probe classification reset compute shader bytecode }; + struct ProbeVariabilityByteCode + { + ShaderBytecode reductionCS; // Probe variability reduction compute shader bytecode + ShaderBytecode extraReductionCS; // Probe variability reduction extra passes compute shader bytecode + }; + struct DDGIVolumeManagedResourcesDesc { bool enabled = false; // Enable or disable managed resources mode @@ -58,8 +72,10 @@ namespace rtxgi // Shader bytecode ShaderBytecode probeBlendingIrradianceCS; // Probe blending (irradiance) compute shader bytecode ShaderBytecode probeBlendingDistanceCS; // Probe blending (distance) compute shader bytecode - ProbeRelocationBytecode probeRelocation; // [Optional] Probe Relocation bytecode - ProbeClassificationBytecode probeClassification; // [Optional] Probe Classification bytecode + + ProbeRelocationBytecode probeRelocation; // Probe Relocation bytecode + ProbeClassificationBytecode probeClassification; // Probe Classification bytecode + ProbeVariabilityByteCode probeVariability; // Probe Classification bytecode }; //------------------------------------------------------------------------ @@ -78,6 +94,12 @@ namespace rtxgi ID3D12PipelineState* resetPSO = nullptr; // Probe classification reset compute PSO }; + struct ProbeVariabilityPSO + { + ID3D12PipelineState* reductionPSO = nullptr; // Probe variability averaging PSO + ID3D12PipelineState* extraReductionPSO = nullptr; // Probe variability extra reduction PSO + }; + struct DDGIVolumeUnmanagedResourcesDesc { bool enabled = false; // Enable or disable unmanaged resources mode @@ -96,12 +118,17 @@ namespace rtxgi ID3D12Resource* probeIrradiance = nullptr; // Probe irradiance texture array - RGB irradiance, encoded with a high gamma curve ID3D12Resource* probeDistance = nullptr; // Probe distance texture array - R: mean distance | G: mean distance^2 ID3D12Resource* probeData = nullptr; // Probe data texture array - XYZ: world-space relocation offsets | W: classification state + ID3D12Resource* probeVariability = nullptr; // Probe variability texture array + ID3D12Resource* probeVariabilityAverage = nullptr; // Average of Probe variability for whole volume + ID3D12Resource* probeVariabilityReadback = nullptr; // CPU-readable resource containing final Probe variability average // Pipeline State Objects ID3D12PipelineState* probeBlendingIrradiancePSO = nullptr; // Probe blending (irradiance) compute PSO ID3D12PipelineState* probeBlendingDistancePSO = nullptr; // Probe blending (distance) compute PSO - ProbeRelocationPSO probeRelocation; // [Optional] Probe Relocation PSOs - ProbeClassificationPSO probeClassification; // [Optional] Probe Classification PSOs + + ProbeRelocationPSO probeRelocation; // Probe Relocation PSOs + ProbeClassificationPSO probeClassification; // Probe Classification PSOs + ProbeVariabilityPSO probeVariabilityPSOs; // Probe Variability PSOs }; //------------------------------------------------------------------------ @@ -193,6 +220,11 @@ namespace rtxgi */ ERTXGIStatus ClearProbes(ID3D12GraphicsCommandList* cmdList); + /** + * Transitions volume resources to the appropriate state(s) for the given execution stage + */ + void TransitionResources(ID3D12GraphicsCommandList* cmdList, EDDGIExecutionStage stage) const; + /** * Releases resources owned by the volume */ @@ -210,7 +242,7 @@ namespace rtxgi UINT GetRootParamSlotRootConstants() const { return m_rootParamSlotRootConstants; }; UINT GetRootParamSlotResourceDescriptorTable() const { return m_rootParamSlotResourceDescriptorTable; } UINT GetRootParamSlotSamplerDescriptorTable() const { return m_rootParamSlotSamplerDescriptorTable; } - DDGIRootConstants GetRootConstants() const { return { m_desc.index, m_descriptorHeapDesc.constantsIndex, m_descriptorHeapDesc.resourceIndicesIndex, 0 }; }; + DDGIRootConstants GetRootConstants() const { return { m_desc.index, m_descriptorHeapDesc.constantsIndex, m_descriptorHeapDesc.resourceIndicesIndex, 0, 0, 0, 0 }; }; bool GetBindlessEnabled() const { return m_bindlessResources.enabled; } EBindlessType GetBindlessType() const { return m_bindlessResources.type; } @@ -237,12 +269,16 @@ namespace rtxgi EDDGIVolumeTextureFormat GetIrradianceFormat() const { return m_desc.probeIrradianceFormat; } EDDGIVolumeTextureFormat GetDistanceFormat() const { return m_desc.probeDistanceFormat; } EDDGIVolumeTextureFormat GetProbeDataFormat() const { return m_desc.probeDataFormat; } + EDDGIVolumeTextureFormat GetProbeVariabilityFormat() const { return m_desc.probeVariabilityFormat; } // Texture Arrays ID3D12Resource* GetProbeRayData() const { return m_probeRayData; } ID3D12Resource* GetProbeIrradiance() const { return m_probeIrradiance; } ID3D12Resource* GetProbeDistance() const { return m_probeDistance; } ID3D12Resource* GetProbeData() const { return m_probeData; } + ID3D12Resource* GetProbeVariability() const { return m_probeVariability; } + ID3D12Resource* GetProbeVariabilityAverage() const { return m_probeVariabilityAverage; } + ID3D12Resource* GetProbeVariabilityReadback() const { return m_probeVariabilityReadback; } // Pipeline State Objects ID3D12PipelineState* GetProbeBlendingIrradiancePSO() const { return m_probeBlendingIrradiancePSO; } @@ -251,6 +287,8 @@ namespace rtxgi ID3D12PipelineState* GetProbeRelocationResetPSO() const { return m_probeRelocationResetPSO; } ID3D12PipelineState* GetProbeClassificationPSO() const { return m_probeClassificationPSO; } ID3D12PipelineState* GetProbeClassificationResetPSO() const { return m_probeClassificationResetPSO; } + ID3D12PipelineState* GetProbeVariabilityReductionPSO() const { return m_probeVariabilityReductionPSO; } + ID3D12PipelineState* GetProbeVariabilityExtraReductionPSO() const { return m_probeVariabilityExtraReductionPSO; } //------------------------------------------------------------------------ // Resource Setters @@ -286,12 +324,15 @@ namespace rtxgi void SetIrradianceFormat(EDDGIVolumeTextureFormat format) { m_desc.probeIrradianceFormat = format; } void SetDistanceFormat(EDDGIVolumeTextureFormat format) { m_desc.probeDistanceFormat = format; } void SetProbeDataFormat(EDDGIVolumeTextureFormat format) { m_desc.probeDataFormat = format; } + void SetProbeVariabilityFormat(EDDGIVolumeTextureFormat format) { m_desc.probeVariabilityFormat = format; } #if !RTXGI_DDGI_RESOURCE_MANAGEMENT void SetProbeRayData(ID3D12Resource* ptr) { m_probeRayData = ptr; } void SetProbeIrradiance(ID3D12Resource* ptr) { m_probeIrradiance = ptr; } void SetProbeDistance(ID3D12Resource* ptr) { m_probeDistance = ptr; } void SetProbeData(ID3D12Resource* ptr) { m_probeData = ptr; } + void SetProbeVariability(ID3D12Resource* ptr) { m_probeVariability = ptr; } + void SetProbeVariabilityAverage(ID3D12Resource* ptr) { m_probeVariabilityAverage = ptr; } #endif private: @@ -310,6 +351,9 @@ namespace rtxgi ID3D12Resource* m_probeIrradiance = nullptr; // Probe irradiance texture array - RGB: irradiance, encoded with a high gamma curve ID3D12Resource* m_probeDistance = nullptr; // Probe distance texture array - R: mean distance | G: mean distance^2 ID3D12Resource* m_probeData = nullptr; // Probe data texture array - XYZ: world-space relocation offsets | W: classification state + ID3D12Resource* m_probeVariability = nullptr; // Probe luminance difference from previous update + ID3D12Resource* m_probeVariabilityAverage = nullptr; // Average Probe variability for whole volume + ID3D12Resource* m_probeVariabilityReadback = nullptr; // CPU-readable buffer with average Probe variability // Render Target Views D3D12_CPU_DESCRIPTOR_HANDLE m_probeIrradianceRTV = { 0 }; // Probe irradiance render target view @@ -334,6 +378,8 @@ namespace rtxgi ID3D12PipelineState* m_probeRelocationResetPSO = nullptr; // Probe relocation reset compute shader pipeline state object ID3D12PipelineState* m_probeClassificationPSO = nullptr; // Probe classification compute shader pipeline state object ID3D12PipelineState* m_probeClassificationResetPSO = nullptr; // Probe classification reset compute shader pipeline state object + ID3D12PipelineState* m_probeVariabilityReductionPSO = nullptr; // Probe variability reduction + ID3D12PipelineState* m_probeVariabilityExtraReductionPSO = nullptr; // Probe variability extra reduction pass #if RTXGI_DDGI_RESOURCE_MANAGEMENT ID3D12DescriptorHeap* m_rtvDescriptorHeap = nullptr; // Descriptor heap for render target views @@ -349,6 +395,8 @@ namespace rtxgi bool CreateProbeIrradiance(const DDGIVolumeDesc& desc); bool CreateProbeDistance(const DDGIVolumeDesc& desc); bool CreateProbeData(const DDGIVolumeDesc& desc); + bool CreateProbeVariability(const DDGIVolumeDesc& desc); + bool CreateProbeVariabilityAverage(const DDGIVolumeDesc& desc); bool IsDeviceChanged(const DDGIVolumeManagedResourcesDesc& desc) { @@ -380,20 +428,32 @@ namespace rtxgi /** * Updates one or more volume's probes using data in the volume's radiance texture. * Probe blending and border update workloads are batched together for better performance. + * Volume resources are expected to be in the D3D12_RESOURCE_STATE_UNORDERED_ACCESS state. */ RTXGI_API ERTXGIStatus UpdateDDGIVolumeProbes(ID3D12GraphicsCommandList* cmdList, UINT numVolumes, DDGIVolume** volumes); /** * Adjusts one or more volume's world-space probe positions to avoid them being too close to or inside of geometry. * If a volume has the reset flag set, all probe relocation offsets are set to zero before relocation occurs. + * Volume resources are expected to be in the D3D12_RESOURCE_STATE_UNORDERED_ACCESS state. */ RTXGI_API ERTXGIStatus RelocateDDGIVolumeProbes(ID3D12GraphicsCommandList* cmdList, UINT numVolumes, DDGIVolume** volumes); /** * Classifies one or more volume's probes as active or inactive based on the hit distance data in the ray data texture. * If a volume has the reset flag set, all probes are set to active before classification occurs. + * Volume resources are expected to be in the D3D12_RESOURCE_STATE_UNORDERED_ACCESS state. */ RTXGI_API ERTXGIStatus ClassifyDDGIVolumeProbes(ID3D12GraphicsCommandList* cmdList, UINT numVolumes, DDGIVolume** volumes); + /** + * Calculates average variability for all probes in each provided volume + */ + RTXGI_API ERTXGIStatus CalculateDDGIVolumeVariability(ID3D12GraphicsCommandList* cmdList, UINT numVolumes, DDGIVolume** volumes); + + /** + * Reads back average variability for each provided volume, at the time of the call + */ + RTXGI_API ERTXGIStatus ReadbackDDGIVolumeVariability(UINT numVolumes, DDGIVolume** volumes); } // namespace d3d12 } // namespace rtxgi diff --git a/rtxgi-sdk/include/rtxgi/ddgi/gfx/DDGIVolume_VK.h b/rtxgi-sdk/include/rtxgi/ddgi/gfx/DDGIVolume_VK.h index 51626be..beac895 100644 --- a/rtxgi-sdk/include/rtxgi/ddgi/gfx/DDGIVolume_VK.h +++ b/rtxgi-sdk/include/rtxgi/ddgi/gfx/DDGIVolume_VK.h @@ -33,6 +33,8 @@ namespace rtxgi ProbeIrradiance, ProbeDistance, ProbeData, + ProbeVariability, + ProbeVariabilityAverage }; //------------------------------------------------------------------------ @@ -51,6 +53,12 @@ namespace rtxgi ShaderBytecode resetCS; // Probe classification reset compute shader bytecode }; + struct ProbeVariabilityByteCode + { + ShaderBytecode reductionCS; // Probe variability reduction compute shader bytecode + ShaderBytecode extraReductionCS; // Probe variability reduction extra passes compute shader bytecode + }; + struct DDGIVolumeManagedResourcesDesc { bool enabled = false; // Enable or disable managed resources mode @@ -62,8 +70,10 @@ namespace rtxgi // Shader bytecode ShaderBytecode probeBlendingIrradianceCS; // Probe blending (irradiance) compute shader bytecode ShaderBytecode probeBlendingDistanceCS; // Probe blending (distance) compute shader bytecode - ProbeRelocationBytecode probeRelocation; // [Optional] Probe Relocation bytecode - ProbeClassificationBytecode probeClassification; // [Optional] Probe Classification bytecode + + ProbeRelocationBytecode probeRelocation; // Probe Relocation bytecode + ProbeClassificationBytecode probeClassification; // Probe Classification bytecode + ProbeVariabilityByteCode probeVariability; // Probe Classification bytecode }; //------------------------------------------------------------------------ @@ -88,6 +98,15 @@ namespace rtxgi VkPipeline resetPipeline = nullptr; // Probe classification reset compute pipeline }; + struct ProbeVariabilityPipeline + { + VkShaderModule reductionModule = nullptr; // Probe variability reduction shader module + VkShaderModule extraReductionModule = nullptr; // Probe variability reduction extra passes shader module + + VkPipeline reductionPipeline = nullptr; // Probe variability reduction compute pipeline + VkPipeline extraReductionPipeline = nullptr; // Probe variability extra reduction compute pipeline + }; + struct DDGIVolumeUnmanagedResourcesDesc { bool enabled = false; // Enable or disable unmanaged resources mode @@ -100,18 +119,26 @@ namespace rtxgi VkImage probeIrradiance = nullptr; // Probe irradiance texture array - RGB: irradiance, encoded with a high gamma curve VkImage probeDistance = nullptr; // Probe distance texture array - R: mean distance | G: mean distance^2 VkImage probeData = nullptr; // Probe data texture array - XYZ: world-space relocation offsets | W: classification state + VkImage probeVariability = nullptr; // Probe variability texture array + VkImage probeVariabilityAverage = nullptr; // Average of Probe variability for whole volume + VkBuffer probeVariabilityReadback = nullptr; // CPU-readable resource containing final Probe variability average // Texture Memory VkDeviceMemory probeRayDataMemory = nullptr; // Probe ray data texture array device memory VkDeviceMemory probeIrradianceMemory = nullptr; // Probe irradiance texture array device memory VkDeviceMemory probeDistanceMemory = nullptr; // Probe distance texture array device memory VkDeviceMemory probeDataMemory = nullptr; // Probe data texture array device memory + VkDeviceMemory probeVariabilityMemory = nullptr; // Probe variability texture array device memory + VkDeviceMemory probeVariabilityAverageMemory = nullptr; // Probe variability average texture device memory + VkDeviceMemory probeVariabilityReadbackMemory = nullptr; // Probe variability readback texture device memory // Texture Views VkImageView probeRayDataView = nullptr; // Probe ray data texture array view VkImageView probeIrradianceView = nullptr; // Probe irradiance texture array view VkImageView probeDistanceView = nullptr; // Probe distance texture array view VkImageView probeDataView = nullptr; // Probe data texture array view + VkImageView probeVariabilityView = nullptr; // Probe variability texture array view + VkImageView probeVariabilityAverageView = nullptr; // Probe variability average texture view // Shader Modules VkShaderModule probeBlendingIrradianceModule = nullptr; // Probe blending (irradiance) shader module @@ -120,8 +147,10 @@ namespace rtxgi // Pipelines VkPipeline probeBlendingIrradiancePipeline = nullptr; // Probe blending (irradiance) compute pipeline VkPipeline probeBlendingDistancePipeline = nullptr; // Probe blending (distance) compute pipeline - ProbeRelocationPipeline probeRelocation; // [Optional] Probe Relocation pipelines - ProbeClassificationPipeline probeClassification; // [Optional] Probe Classification pipelines + + ProbeRelocationPipeline probeRelocation; // Probe Relocation pipelines + ProbeClassificationPipeline probeClassification; // Probe Classification pipelines + ProbeVariabilityPipeline probeVariabilityPipelines; // Probe Variability pipelines }; //------------------------------------------------------------------------ @@ -238,7 +267,7 @@ namespace rtxgi // Push Constants uint32_t GetPushConstantsOffset() const { return m_pushConstantsOffset; } - DDGIRootConstants GetPushConstants() const { return { m_desc.index, 0, 0 }; } + DDGIRootConstants GetPushConstants() const { return { m_desc.index, 0, 0, 0, 0, 0 }; } // Resource Indices (Bindless) DDGIVolumeResourceIndices GetResourceIndices() const { return m_bindlessResources.resourceIndices; } @@ -258,24 +287,33 @@ namespace rtxgi EDDGIVolumeTextureFormat GetIrradianceFormat() const { return m_desc.probeIrradianceFormat; } EDDGIVolumeTextureFormat GetDistanceFormat() const { return m_desc.probeDistanceFormat; } EDDGIVolumeTextureFormat GetProbeDataFormat() const { return m_desc.probeDataFormat; } + EDDGIVolumeTextureFormat GetProbeVariabilityFormat() const { return m_desc.probeVariabilityFormat; } // Texture Arrays VkImage GetProbeRayData() const { return m_probeRayData; } VkImage GetProbeIrradiance() const { return m_probeIrradiance; } VkImage GetProbeDistance() const { return m_probeDistance; } VkImage GetProbeData() const { return m_probeData; } + VkImage GetProbeVariability() const { return m_probeVariability; } + VkImage GetProbeVariabilityAverage() const { return m_probeVariabilityAverage; } + VkBuffer GetProbeVariabilityReadback() const { return m_probeVariabilityReadback; } // Texture Array Memory VkDeviceMemory GetProbeRayDataMemory() const { return m_probeRayDataMemory; } VkDeviceMemory GetProbeIrradianceMemory() const { return m_probeIrradianceMemory; } VkDeviceMemory GetProbeDistanceMemory() const { return m_probeDistanceMemory; } VkDeviceMemory GetProbeDataMemory() const { return m_probeDataMemory; } + VkDeviceMemory GetProbeVariabilityMemory() const { return m_probeVariabilityMemory; } + VkDeviceMemory GetProbeVariabilityAverageMemory() const { return m_probeVariabilityAverageMemory; } + VkDeviceMemory GetProbeVariabilityReadbackMemory() const { return m_probeVariabilityReadbackMemory; } // Texture Array Views VkImageView GetProbeRayDataView() const { return m_probeRayDataView; } VkImageView GetProbeIrradianceView() const { return m_probeIrradianceView; } VkImageView GetProbeDistanceView() const { return m_probeDistanceView; } VkImageView GetProbeDataView() const { return m_probeDataView; } + VkImageView GetProbeVariabilityView() const { return m_probeVariabilityView; } + VkImageView GetProbeVariabilityAverageView() const { return m_probeVariabilityAverageView; } // Shader Modules VkShaderModule GetProbeBlendingIrradianceModule() const { return m_probeBlendingIrradianceModule; } @@ -284,6 +322,8 @@ namespace rtxgi VkShaderModule GetProbeRelocationResetModule() const { return m_probeRelocationResetModule; } VkShaderModule GetProbeClassificationModule() const { return m_probeClassificationModule; } VkShaderModule GetProbeClassificationResetModule() const { return m_probeClassificationResetModule; } + VkShaderModule GetProbeVariabilityReductionModule() const { return m_probeVariabilityReductionModule; } + VkShaderModule GetProbeVariabilityExtraReductionModule() const { return m_probeVariabilityExtraReductionModule; } // Pipelines VkPipeline GetProbeBlendingIrradiancePipeline() const { return m_probeBlendingIrradiancePipeline; } @@ -292,6 +332,8 @@ namespace rtxgi VkPipeline GetProbeRelocationResetPipeline() const { return m_probeRelocationResetPipeline; } VkPipeline GetProbeClassificationPipeline() const { return m_probeClassificationPipeline; } VkPipeline GetProbeClassificationResetPipeline() const { return m_probeClassificationResetPipeline; } + VkPipeline GetProbeVariabilityReductionPipeline() const { return m_probeVariabilityReductionPipeline; } + VkPipeline GetProbeVariabilityExtraReductionPipeline() const { return m_probeVariabilityExtraReductionPipeline; } //------------------------------------------------------------------------ // Resource Setters @@ -318,12 +360,16 @@ namespace rtxgi void SetIrradianceFormat(EDDGIVolumeTextureFormat format) { m_desc.probeIrradianceFormat = format; } void SetDistanceFormat(EDDGIVolumeTextureFormat format) { m_desc.probeDistanceFormat = format; } void SetProbeDataFormat(EDDGIVolumeTextureFormat format) { m_desc.probeDataFormat = format; } + void SetProbeVariabilityFromat(EDDGIVolumeTextureFormat format) { m_desc.probeVariabilityFormat = format; } #if !RTXGI_DDGI_RESOURCE_MANAGEMENT void SetProbeRayData(VkImage ptr, VkDeviceMemory memoryPtr, VkImageView viewPtr) { m_probeRayData = ptr; m_probeRayDataMemory = memoryPtr; m_probeRayDataView = viewPtr; } void SetProbeIrradiance(VkImage ptr, VkDeviceMemory memoryPtr, VkImageView viewPtr) { m_probeIrradiance = ptr; m_probeIrradianceMemory = memoryPtr; m_probeIrradianceView = viewPtr; } void SetProbeDistance(VkImage ptr, VkDeviceMemory memoryPtr, VkImageView viewPtr) { m_probeDistance = ptr; m_probeDistanceMemory = memoryPtr; m_probeDistanceView = viewPtr; } void SetProbeData(VkImage ptr, VkDeviceMemory memoryPtr, VkImageView viewPtr) { m_probeData = ptr; m_probeDataMemory = memoryPtr; m_probeDataView = viewPtr; } + void SetProbeVariability(VkImage ptr, VkDeviceMemory memoryPtr, VkImageView viewPtr) { m_probeVariability = ptr; m_probeVariabilityMemory = memoryPtr; m_probeVariabilityView = viewPtr; } + void SetProbeVariabilityAverage(VkImage ptr, VkDeviceMemory memoryPtr, VkImageView viewPtr) { m_probeVariabilityAverage = ptr; m_probeVariabilityAverageMemory = memoryPtr; m_probeVariabilityAverageView = viewPtr; } + void SetProbeVariabilityReadback(VkBuffer ptr, VkDeviceMemory memoryPtr) { m_probeVariabilityReadback = ptr; m_probeVariabilityReadbackMemory = memoryPtr; } #endif private: @@ -345,18 +391,26 @@ namespace rtxgi VkImage m_probeIrradiance = nullptr; // Probe irradiance texture array - RGB: irradiance, encoded with a high gamma curve VkImage m_probeDistance = nullptr; // Probe distance texture array - R: mean distance | G: mean distance^2 VkImage m_probeData = nullptr; // Probe data texture array - XYZ: world-space relocation offsets | W: classification state + VkImage m_probeVariability = nullptr; // Probe variability texture + VkImage m_probeVariabilityAverage = nullptr; // Probe variability average texture + VkBuffer m_probeVariabilityReadback = nullptr; // Probe variability readback texture // Texture Array Memory VkDeviceMemory m_probeRayDataMemory = nullptr; // Probe ray data memory VkDeviceMemory m_probeIrradianceMemory = nullptr; // Probe irradiance memory VkDeviceMemory m_probeDistanceMemory = nullptr; // Probe distance memory VkDeviceMemory m_probeDataMemory = nullptr; // Probe data memory + VkDeviceMemory m_probeVariabilityMemory = nullptr; // Probe variability memory + VkDeviceMemory m_probeVariabilityAverageMemory = nullptr; // Probe variability average memory + VkDeviceMemory m_probeVariabilityReadbackMemory = nullptr; // Probe variability readback memory // Texture Array Views VkImageView m_probeRayDataView = nullptr; // Probe ray data view VkImageView m_probeIrradianceView = nullptr; // Probe irradiance view VkImageView m_probeDistanceView = nullptr; // Probe distance view VkImageView m_probeDataView = nullptr; // Probe data view + VkImageView m_probeVariabilityView = nullptr; // Probe variability view + VkImageView m_probeVariabilityAverageView = nullptr; // Probe variability average view // Pipeline Layout VkPipelineLayout m_pipelineLayout = nullptr; // Pipeline layout, used for all update compute shaders @@ -378,6 +432,8 @@ namespace rtxgi VkShaderModule m_probeRelocationResetModule = nullptr; // Probe relocation reset shader module VkShaderModule m_probeClassificationModule = nullptr; // Probe classification shader module VkShaderModule m_probeClassificationResetModule = nullptr; // Probe classification reset shader module + VkShaderModule m_probeVariabilityReductionModule = nullptr; // Probe variability reduction shader module + VkShaderModule m_probeVariabilityExtraReductionModule = nullptr; // Probe variability reduction extra passes shader module // Pipelines VkPipeline m_probeBlendingIrradiancePipeline = nullptr; // Probe blending (irradiance) compute shader pipeline @@ -386,6 +442,8 @@ namespace rtxgi VkPipeline m_probeRelocationResetPipeline = nullptr; // Probe relocation reset compute shader pipeline VkPipeline m_probeClassificationPipeline = nullptr; // Probe classification compute shader pipeline VkPipeline m_probeClassificationResetPipeline = nullptr; // Probe classification reset compute shader pipeline + VkPipeline m_probeVariabilityReductionPipeline = nullptr; // Probe variability reduction compute shader pipeline + VkPipeline m_probeVariabilityExtraReductionPipeline = nullptr; // Probe variability reduction extra passes compute shader pipeline #if RTXGI_DDGI_RESOURCE_MANAGEMENT ERTXGIStatus CreateManagedResources(const DDGIVolumeDesc& desc, const DDGIVolumeManagedResourcesDesc& managed); @@ -402,6 +460,8 @@ namespace rtxgi bool CreateProbeIrradiance(const DDGIVolumeDesc& desc); bool CreateProbeDistance(const DDGIVolumeDesc& desc); bool CreateProbeData(const DDGIVolumeDesc& desc); + bool CreateProbeVariability(const DDGIVolumeDesc& desc); + bool CreateProbeVariabilityAverage(const DDGIVolumeDesc& desc); bool IsDeviceChanged(const DDGIVolumeManagedResourcesDesc& desc) { @@ -448,5 +508,14 @@ namespace rtxgi */ RTXGI_API ERTXGIStatus ClassifyDDGIVolumeProbes(VkCommandBuffer cmdBuffer, uint32_t numVolumes, DDGIVolume** volumes); + /** + * Calculates average variability for all probes in each provided volume + */ + RTXGI_API ERTXGIStatus CalculateDDGIVolumeVariability(VkCommandBuffer cmdBuffer, uint32_t numVolumes, DDGIVolume** volumes); + + /** + * Reads back average variability for each provided volume, at the time of the call + */ + RTXGI_API ERTXGIStatus ReadbackDDGIVolumeVariability(VkDevice device, uint32_t numVolumes, DDGIVolume** volumes); } // namespace vulkan } // namespace rtxgi diff --git a/rtxgi-sdk/shaders/Common.hlsl b/rtxgi-sdk/shaders/Common.hlsl index 26623ad..82d4f02 100644 --- a/rtxgi-sdk/shaders/Common.hlsl +++ b/rtxgi-sdk/shaders/Common.hlsl @@ -121,4 +121,17 @@ float4 RTXGIQuaternionConjugate(float4 q) return float4(-q.xyz, q.w); } +//------------------------------------------------------------------------ +// Luminance Helper +//------------------------------------------------------------------------ + +/** + * Convert Linear RGB value to Luminance + */ +float RTXGILinearRGBToLuminance(float3 rgb) +{ + const float3 LuminanceWeights = float3(0.2126, 0.7152, 0.0722); + return dot(rgb, LuminanceWeights); +} + #endif // RTXGI_COMMON_HLSL diff --git a/rtxgi-sdk/shaders/ddgi/ProbeBlendingCS.hlsl b/rtxgi-sdk/shaders/ddgi/ProbeBlendingCS.hlsl index 064159b..92c6bde 100644 --- a/rtxgi-sdk/shaders/ddgi/ProbeBlendingCS.hlsl +++ b/rtxgi-sdk/shaders/ddgi/ProbeBlendingCS.hlsl @@ -32,7 +32,10 @@ #else #define RAY_DATA_REG_DECL #define OUTPUT_REG_DECL - #define PROBE_DATA_REG_DECL + #define PROBE_DATA_REG_DECL + #if RTXGI_DDGI_BLEND_RADIANCE + #define PROBE_VARIABILITY_REG_DECL + #endif #endif #else @@ -48,6 +51,9 @@ #define RAY_DATA_REG_DECL : register(RAY_DATA_REGISTER, RAY_DATA_SPACE) #define OUTPUT_REG_DECL : register(OUTPUT_REGISTER, OUTPUT_SPACE) #define PROBE_DATA_REG_DECL : register(PROBE_DATA_REGISTER, PROBE_DATA_SPACE) + #if RTXGI_DDGI_BLEND_RADIANCE + #define PROBE_VARIABILITY_REG_DECL : register(PROBE_VARIABILITY_REGISTER, PROBE_VARIABILITY_SPACE) + #endif #endif // RTXGI_DDGI_BINDLESS_RESOURCES #endif // RTXGI_DDGI_SHADER_REFLECTION || SPIRV @@ -95,6 +101,12 @@ RTXGI_VK_BINDING(PROBE_DATA_REGISTER, PROBE_DATA_SPACE) RWTexture2DArray ProbeData PROBE_DATA_REG_DECL; +#if RTXGI_DDGI_BLEND_RADIANCE + // Probe variability + RTXGI_VK_BINDING(PROBE_VARIABILITY_REGISTER, PROBE_VARIABILITY_SPACE) + RWTexture2DArray ProbeVariability PROBE_VARIABILITY_REG_DECL; +#endif + #endif // RTXGI_DDGI_BINDLESS_RESOURCES // -------- SHARED MEMORY DECLARATIONS ------------------------------------------------------------ @@ -291,6 +303,7 @@ void DDGIProbeBlendingCS( RWTexture2DArray RayData = ResourceDescriptorHeap[resourceIndices.rayDataUAVIndex]; #if RTXGI_DDGI_BLEND_RADIANCE RWTexture2DArray Output = ResourceDescriptorHeap[resourceIndices.probeIrradianceUAVIndex]; + RWTexture2DArray ProbeVariability = ResourceDescriptorHeap[resourceIndices.probeVariabilityUAVIndex]; #else RWTexture2DArray Output = ResourceDescriptorHeap[resourceIndices.probeDistanceUAVIndex]; #endif @@ -305,6 +318,7 @@ void DDGIProbeBlendingCS( RWTexture2DArray RayData = RWTex2DArray[resourceIndices.rayDataUAVIndex]; #if RTXGI_DDGI_BLEND_RADIANCE RWTexture2DArray Output = RWTex2DArray[resourceIndices.probeIrradianceUAVIndex]; + RWTexture2DArray ProbeVariability = RWTex2DArray[resourceIndices.probeVariabilityUAVIndex]; #else RWTexture2DArray Output = RWTex2DArray[resourceIndices.probeDistanceUAVIndex]; #endif @@ -374,7 +388,13 @@ void DDGIProbeBlendingCS( // Early out: don't blend rays for probes that are inactive int probeState = DDGILoadProbeState(probeIndex, ProbeData, volume); - if (probeState == RTXGI_DDGI_PROBE_STATE_INACTIVE) return; + if (probeState == RTXGI_DDGI_PROBE_STATE_INACTIVE) + { + #if RTXGI_DDGI_BLEND_RADIANCE + ProbeVariability[DispatchThreadID].r = 0.f; + #endif + return; + } // Get the probe ray direction associated with this thread float2 probeOctantUV = DDGIGetNormalizedOctahedralCoordinates(int2(threadCoords.xy), RTXGI_DDGI_PROBE_NUM_INTERIOR_TEXELS); @@ -496,6 +516,9 @@ void DDGIProbeBlendingCS( float3 delta = (result.rgb - previous.rgb); + float3 previousIrradianceMean = previous.rgb; + float3 currentIrradianceSample = result.rgb; + if (RTXGIMaxComponent(previous.rgb - result.rgb) > volume.probeIrradianceThreshold) { // Lower the hysteresis when a large lighting change is detected @@ -524,6 +547,16 @@ void DDGIProbeBlendingCS( lerpDelta = min(max(c_threshold, abs(lerpDelta)), abs(delta)) * sign(lerpDelta); } result = float4(previous.rgb + lerpDelta, 1.f); + + if (volume.probeVariabilityEnabled) + { + float3 newIrradianceMean = result.rgb; + float3 newIrradianceSigma2 = (currentIrradianceSample - previousIrradianceMean) * (currentIrradianceSample - newIrradianceMean); + float newLuminanceSigma2 = RTXGILinearRGBToLuminance(newIrradianceSigma2); + float newLuminanceMean = RTXGILinearRGBToLuminance(newIrradianceMean); + float coefficientOfVariation = (newLuminanceMean <= c_threshold) ? 0.f : sqrt(newLuminanceSigma2) / newLuminanceMean; + ProbeVariability[threadCoords].r = coefficientOfVariation; + } #else // Interpolate the new filtered distance with the existing filtered distance in the probe. diff --git a/rtxgi-sdk/shaders/ddgi/ReductionCS.hlsl b/rtxgi-sdk/shaders/ddgi/ReductionCS.hlsl new file mode 100644 index 0000000..21c37e0 --- /dev/null +++ b/rtxgi-sdk/shaders/ddgi/ReductionCS.hlsl @@ -0,0 +1,411 @@ +/* +* Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +// For example usage, see DDGI_[D3D12|VK].cpp::CompileDDGIVolumeShaders() function. + +// -------- CONFIG FILE --------------------------------------------------------------------------- + +#if RTXGI_DDGI_USE_SHADER_CONFIG_FILE +#include +#endif + +// -------- DEFINE VALIDATION --------------------------------------------------------------------- + +#include "include/validation/ReductionDefines.hlsl" + +// -------- REGISTER DECLARATIONS ----------------------------------------------------------------- + +#if RTXGI_DDGI_SHADER_REFLECTION || defined(__spirv__) + + // Don't declare registers when using reflection or cross-compiling to SPIRV + #define VOLUME_CONSTS_REG_DECL + #if RTXGI_DDGI_BINDLESS_RESOURCES + #define VOLUME_RESOURCES_REG_DECL + #define RWTEX2DARRAY_REG_DECL + #else + #define RAY_DATA_REG_DECL + #define PROBE_DATA_REG_DECL + #define PROBE_VARIABILITY_REG_DECL + #define PROBE_VARIABILITY_AVERAGE_REG_DECL + #endif + +#else + + // Declare registers and spaces when using D3D without reflection + #define VOLUME_CONSTS_REG_DECL : register(VOLUME_CONSTS_REGISTER, VOLUME_CONSTS_SPACE) + #if RTXGI_DDGI_BINDLESS_RESOURCES + #if RTXGI_BINDLESS_TYPE == RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS + #define VOLUME_RESOURCES_REG_DECL : register(VOLUME_RESOURCES_REGISTER, VOLUME_RESOURCES_SPACE) + #define RWTEX2DARRAY_REG_DECL : register(RWTEX2DARRAY_REGISTER, RWTEX2DARRAY_SPACE) + #endif + #else + #define RAY_DATA_REG_DECL : register(RAY_DATA_REGISTER, RAY_DATA_SPACE) + #define OUTPUT_REG_DECL : register(OUTPUT_REGISTER, OUTPUT_SPACE) + #define PROBE_DATA_REG_DECL : register(PROBE_DATA_REGISTER, PROBE_DATA_SPACE) + #define PROBE_VARIABILITY_REG_DECL : register(PROBE_VARIABILITY_REGISTER, PROBE_VARIABILITY_SPACE) + #define PROBE_VARIABILITY_AVERAGE_REG_DECL : register(PROBE_VARIABILITY_AVERAGE_REGISTER, PROBE_VARIABILITY_SPACE) + #endif // RTXGI_DDGI_BINDLESS_RESOURCES + +#endif // RTXGI_DDGI_SHADER_REFLECTION || SPIRV + +// -------- ROOT / PUSH CONSTANT DECLARATIONS ----------------------------------------------------- + +#include "include/ProbeCommon.hlsl" +#include "include/DDGIRootConstants.hlsl" + +// -------- RESOURCE DECLARATIONS ----------------------------------------------------------------- + +#if RTXGI_DDGI_BINDLESS_RESOURCES + + #if RTXGI_BINDLESS_TYPE == RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS + + // DDGIVolume constants structured buffer + RTXGI_VK_BINDING(VOLUME_CONSTS_REGISTER, VOLUME_CONSTS_SPACE) + StructuredBuffer DDGIVolumes VOLUME_CONSTS_REG_DECL; + + // DDGIVolume resource indices structured buffer + RTXGI_VK_BINDING(VOLUME_RESOURCES_REGISTER, VOLUME_RESOURCES_SPACE) + StructuredBuffer DDGIVolumeBindless VOLUME_RESOURCES_REG_DECL; + + // DDGIVolume ray data, probe irradiance, probe distance, and probe data + RTXGI_VK_BINDING(RWTEX2DARRAY_REGISTER, RWTEX2DARRAY_SPACE) + RWTexture2DArray RWTex2DArray[] RWTEX2DARRAY_REG_DECL; + + #endif + +#else + + // DDGIVolume constants structured buffer + RTXGI_VK_BINDING(VOLUME_CONSTS_REGISTER, VOLUME_CONSTS_SPACE) + StructuredBuffer DDGIVolumes VOLUME_CONSTS_REG_DECL; + + // Probe data (world-space offsets and classification states) + RTXGI_VK_BINDING(PROBE_DATA_REGISTER, PROBE_DATA_SPACE) + RWTexture2DArray ProbeData PROBE_DATA_REG_DECL; + + // Probe variability + RTXGI_VK_BINDING(PROBE_VARIABILITY_REGISTER, PROBE_VARIABILITY_SPACE) + RWTexture2DArray ProbeVariability PROBE_VARIABILITY_REG_DECL; + + // Probe variability average + RTXGI_VK_BINDING(PROBE_VARIABILITY_AVERAGE_REGISTER, PROBE_VARIABILITY_SPACE) + RWTexture2DArray ProbeVariabilityAverage PROBE_VARIABILITY_AVERAGE_REG_DECL; + +#endif // RTXGI_DDGI_BINDLESS_RESOURCES + +// -------- SHARED MEMORY DECLARATIONS ------------------------------------------------------------ + +#define NUM_THREADS_X 4 +#define NUM_THREADS_Y 8 +#define NUM_THREADS_Z 4 +#define NUM_THREADS NUM_THREADS_X*NUM_THREADS_Y*NUM_THREADS_Z +#define NUM_WAVES NUM_THREADS / RTXGI_DDGI_WAVE_LANE_COUNT + +groupshared float ThreadGroupSum[NUM_WAVES]; +groupshared uint MaxSumEntry; +groupshared uint NumTotalSamples; + +// -------- HELPER FUNCTIONS ---------------------------------------------------------------------- + +// Sums values in the ThreadGroupSum shared memory array, from 0 to MaxSumEntry +// At the end of the function, ThreadGroupSum[0] should have the total of the whole array +void reduceSharedMemorySum(uint ThreadIndexInGroup, uint waveIndex, uint waveLaneCount) +{ + uint numSharedMemoryEntries = MaxSumEntry + 1; + uint activeThreads = numSharedMemoryEntries; + while (activeThreads > 1) + { + bool usefulThread = ThreadIndexInGroup < activeThreads; + if (usefulThread) + { + float value = ThreadGroupSum[ThreadIndexInGroup]; + GroupMemoryBarrierWithGroupSync(); + + float warpTotalValue = WaveActiveSum(value); + + if (WaveIsFirstLane()) + { + ThreadGroupSum[waveIndex] = warpTotalValue; + } + GroupMemoryBarrierWithGroupSync(); + } + // Divide by wave size, rounding up (ceil) + activeThreads = (activeThreads + waveLaneCount - 1) / waveLaneCount; + } +} + +// -------- ENTRY POINT --------------------------------------------------------------------------- + +[numthreads(NUM_THREADS_X, NUM_THREADS_Y, NUM_THREADS_Z)] +void DDGIReductionCS(uint3 GroupID : SV_GroupID, uint3 GroupThreadID : SV_GroupThreadID, uint ThreadIndexInGroup : SV_GroupIndex) +{ + if (ThreadIndexInGroup == 0) + { + MaxSumEntry = 0; + NumTotalSamples = 0; + } + GroupMemoryBarrierWithGroupSync(); + + // Doing 4x2 samples per thread + const uint3 ThreadSampleFootprint = uint3(4, 2, 1); + + uint3 groupCoordOffset = GroupID.xyz * uint3(NUM_THREADS_X, NUM_THREADS_Y, NUM_THREADS_Z) * ThreadSampleFootprint; + uint3 threadCoordInGroup = GroupThreadID.xyz; + uint3 threadCoordGlobal = groupCoordOffset + threadCoordInGroup * ThreadSampleFootprint; + + uint volumeIndex = GetDDGIVolumeIndex(); + +#if RTXGI_DDGI_BINDLESS_RESOURCES + #if RTXGI_BINDLESS_TYPE == RTXGI_BINDLESS_TYPE_DESCRIPTOR_HEAP + // Get the DDGIVolume constants structured buffer from the descriptor heap (SM6.6+ only) + StructuredBuffer DDGIVolumes = ResourceDescriptorHeap[GetDDGIVolumeConstantsIndex()]; + #endif +#endif + + // Get the volume's constants + DDGIVolumeDescGPU volume = UnpackDDGIVolumeDescGPU(DDGIVolumes[volumeIndex]); + + // Get the volume's resources +#if RTXGI_DDGI_BINDLESS_RESOURCES + #if RTXGI_BINDLESS_TYPE == RTXGI_BINDLESS_TYPE_DESCRIPTOR_HEAP + + // Get the volume's resource indices from the descriptor heap (SM6.6+ only) + StructuredBuffer DDGIVolumeBindless = ResourceDescriptorHeap[GetDDGIVolumeResourceIndicesIndex()]; + DDGIVolumeResourceIndices resourceIndices = DDGIVolumeBindless[volumeIndex]; + + // Get the volume's texture array UAVs from the descriptor heap (SM6.6+ only) + RWTexture2DArray ProbeVariability = ResourceDescriptorHeap[resourceIndices.probeVariabilityUAVIndex]; + RWTexture2DArray ProbeVariabilityAverage = ResourceDescriptorHeap[resourceIndices.probeVariabilityAverageUAVIndex]; + RWTexture2DArray ProbeData = ResourceDescriptorHeap[resourceIndices.probeDataUAVIndex]; + + #elif RTXGI_BINDLESS_TYPE == RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS + + // Get the volume's resource indices + DDGIVolumeResourceIndices resourceIndices = DDGIVolumeBindless[volumeIndex]; + + // Get the volume's texture array UAVs + RWTexture2DArray ProbeVariability = RWTex2DArray[resourceIndices.probeVariabilityUAVIndex]; + RWTexture2DArray ProbeVariabilityAverage = RWTex2DArray[resourceIndices.probeVariabilityAverageUAVIndex]; + RWTexture2DArray ProbeData = RWTex2DArray[resourceIndices.probeDataUAVIndex]; + + #endif +#endif + + uint waveLaneCount = WaveGetLaneCount(); + uint wavesPerThreadGroup = NUM_THREADS / waveLaneCount; + uint waveIndex = ThreadIndexInGroup / waveLaneCount; + + // Total size of the input variability texture + uint3 probeVariabilitySize = GetReductionInputSize(); + + float sampleSum = 0; + uint numSamples = 0; + for (uint i = 0; i < ThreadSampleFootprint.x; i++) + { + for (uint j = 0; j < ThreadSampleFootprint.y; j++) + { + uint3 sampleCoord = threadCoordGlobal + uint3(i, j, 0); + // Iterating over non-border samples of the irradiance texture + // Calling GetProbeIndex with NUM_INTERIOR_TEXELS (instead of NUM_TEXELS) to make + // sample coordinates line up with probe indices and avoid sampling border texels + int probeIndex = DDGIGetProbeIndex(sampleCoord, RTXGI_DDGI_PROBE_NUM_INTERIOR_TEXELS, volume); + bool sampleInBounds = all(sampleCoord < probeVariabilitySize); + if (sampleInBounds) + { + float value = ProbeVariability[sampleCoord].r; + + // Skip inactive probes + if (volume.probeClassificationEnabled) + { + uint3 probeDataCoords = DDGIGetProbeTexelCoords(probeIndex, volume); + int probeState = ProbeData[probeDataCoords].w; + if (probeState == RTXGI_DDGI_PROBE_STATE_INACTIVE) + { + value = 0.f; + continue; + } + } + + sampleSum += value; + numSamples++; + } + } + } + + // Sum up the warp + float waveTotalValue = WaveActiveSum(sampleSum); + // Sum up useful sample count + uint usefulSampleCount = WaveActiveSum(numSamples); + // Write sum and sample count for this wave + if (WaveIsFirstLane()) + { + ThreadGroupSum[waveIndex] = waveTotalValue; + InterlockedMax(MaxSumEntry, waveIndex); + InterlockedAdd(NumTotalSamples, usefulSampleCount); + } + GroupMemoryBarrierWithGroupSync(); + reduceSharedMemorySum(ThreadIndexInGroup, waveIndex, waveLaneCount); + + if (ThreadIndexInGroup == 0) + { + float TotalPossibleSamples = NUM_THREADS * ThreadSampleFootprint.x * ThreadSampleFootprint.y; + // Average value for the samples we took + ProbeVariabilityAverage[GroupID.xyz].r = NumTotalSamples > 0 ? ThreadGroupSum[0] / NumTotalSamples : 0; + // Normalizing "weight" factor for this thread group, to allow partial thread groups to average properly with full groups + ProbeVariabilityAverage[GroupID.xyz].g = NumTotalSamples / TotalPossibleSamples; + } +} + +// -------- SHARED MEMORY DECLARATIONS ------------------------------------------------------------ + +groupshared float ThreadGroupAverage[NUM_WAVES]; +groupshared uint MaxAverageEntry; +groupshared float ThreadGroupWeight[NUM_WAVES]; + +// -------- HELPER FUNCTIONS ---------------------------------------------------------------------- + +// Weighted average ThreadGroupAverage shared memory array, from 0 to MaxSumEntry +// At the end of the function, ThreadGroupAverage[0] should have the average of the whole array +// ThreadGroupWeight[0] will have the total weight of this thread group to be used when averaging with other groups +void reduceSharedMemoryAverage(uint ThreadIndexInGroup, uint waveIndex, uint waveLaneCount) +{ + uint numSharedMemoryEntries = MaxAverageEntry + 1; + uint activeThreads = numSharedMemoryEntries; + while (activeThreads > 1) + { + bool usefulThread = ThreadIndexInGroup < activeThreads; + if (usefulThread) + { + float value = ThreadGroupAverage[ThreadIndexInGroup]; + float weight = ThreadGroupWeight[ThreadIndexInGroup]; + GroupMemoryBarrierWithGroupSync(); + + float waveTotalValue = WaveActiveSum(weight*value); + float waveTotalWeight = WaveActiveSum(weight); + float TotalPossibleWeight = WaveActiveCountBits(true); + + if (WaveIsFirstLane()) + { + ThreadGroupAverage[waveIndex] = waveTotalValue / waveTotalWeight; + ThreadGroupWeight[waveIndex] = waveTotalWeight / TotalPossibleWeight; + } + GroupMemoryBarrierWithGroupSync(); + } + activeThreads = (activeThreads + waveLaneCount - 1) / waveLaneCount; + } +} + +// -------- ENTRY POINT --------------------------------------------------------------------------- + +[numthreads(NUM_THREADS_X, NUM_THREADS_Y, NUM_THREADS_Z)] +void DDGIExtraReductionCS(uint3 GroupID : SV_GroupID, uint3 GroupThreadID : SV_GroupThreadID, uint ThreadIndexInGroup : SV_GroupIndex) +{ + if (ThreadIndexInGroup == 0) + { + MaxAverageEntry = 0; + } + GroupMemoryBarrierWithGroupSync(); + + uint volumeIndex = GetDDGIVolumeIndex(); +#if RTXGI_DDGI_BINDLESS_RESOURCES + #if RTXGI_BINDLESS_TYPE == RTXGI_BINDLESS_TYPE_DESCRIPTOR_HEAP + // Get the DDGIVolume constants structured buffer from the descriptor heap (SM6.6+ only) + StructuredBuffer DDGIVolumes = ResourceDescriptorHeap[GetDDGIVolumeConstantsIndex()]; + #endif +#endif + + // Get the volume's constants + DDGIVolumeDescGPU volume = UnpackDDGIVolumeDescGPU(DDGIVolumes[volumeIndex]); + + // Get the volume's resources +#if RTXGI_DDGI_BINDLESS_RESOURCES + #if RTXGI_BINDLESS_TYPE == RTXGI_BINDLESS_TYPE_DESCRIPTOR_HEAP + + // Get the volume's resource indices from the descriptor heap (SM6.6+ only) + StructuredBuffer DDGIVolumeBindless = ResourceDescriptorHeap[GetDDGIVolumeResourceIndicesIndex()]; + DDGIVolumeResourceIndices resourceIndices = DDGIVolumeBindless[volumeIndex]; + + // Get the volume's texture array UAVs from the descriptor heap (SM6.6+ only) + RWTexture2DArray ProbeVariability = ResourceDescriptorHeap[resourceIndices.probeVariabilityUAVIndex]; + RWTexture2DArray ProbeVariabilityAverage = ResourceDescriptorHeap[resourceIndices.probeVariabilityAverageUAVIndex]; + RWTexture2DArray ProbeData = ResourceDescriptorHeap[resourceIndices.probeDataUAVIndex]; + + #elif RTXGI_BINDLESS_TYPE == RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS + + // Get the volume's resource indices + DDGIVolumeResourceIndices resourceIndices = DDGIVolumeBindless[volumeIndex]; + + // Get the volume's texture array UAVs + RWTexture2DArray ProbeVariability = RWTex2DArray[resourceIndices.probeVariabilityUAVIndex]; + RWTexture2DArray ProbeVariabilityAverage = RWTex2DArray[resourceIndices.probeVariabilityAverageUAVIndex]; + RWTexture2DArray ProbeData = RWTex2DArray[resourceIndices.probeDataUAVIndex]; + + #endif +#endif + + uint waveLaneCount = WaveGetLaneCount(); + uint wavesPerThreadGroup = NUM_THREADS / waveLaneCount; + uint waveIndex = ThreadIndexInGroup / waveLaneCount; + + // Doing 4x2 samples per thread + const uint3 ThreadSampleFootprint = uint3(4, 2, 1); + + uint3 groupCoordOffset = GroupID.xyz * uint3(NUM_THREADS_X, NUM_THREADS_Y, NUM_THREADS_Z) * ThreadSampleFootprint; + uint3 threadCoordInGroup = GroupThreadID.xyz; + uint3 threadCoordGlobal = groupCoordOffset + threadCoordInGroup * ThreadSampleFootprint; + uint3 inputSize = GetReductionInputSize(); + + bool footprintInBounds = all(threadCoordGlobal < inputSize); + float threadFootprintValueSum = 0; + float threadFootprintWeightSum = 0; + + if (footprintInBounds) + { + for (uint i = 0; i < ThreadSampleFootprint.x; i++) + { + for (uint j = 0; j < ThreadSampleFootprint.y; j++) + { + uint3 sampleCoord = threadCoordGlobal + uint3(i, j, 0); + bool sampleInBounds = all(sampleCoord < inputSize); + if (sampleInBounds) + { + float value = ProbeVariabilityAverage[sampleCoord].r; + float weight = ProbeVariabilityAverage[sampleCoord].g; + threadFootprintValueSum += weight * value; + threadFootprintWeightSum += weight; + } + } + } + } + float threadAverageValue = footprintInBounds ? threadFootprintValueSum / threadFootprintWeightSum : 0; + // Per-thread weight will be 1.0 if thread sampled all 4x2 pixels, 0.125 if it only sampled one + float ThreadTotalPossibleWeight = ThreadSampleFootprint.x * ThreadSampleFootprint.y; + float threadWeight = threadFootprintWeightSum / ThreadTotalPossibleWeight; + + // Sum up the warp + float waveTotalValue = WaveActiveSum(threadWeight * threadAverageValue); + float waveTotalWeight = WaveActiveSum(threadWeight); + float waveTotalPossibleWeight = waveLaneCount * ThreadTotalPossibleWeight; + + if (WaveIsFirstLane() && WaveActiveAnyTrue(footprintInBounds)) + { + ThreadGroupAverage[waveIndex] = waveTotalValue / waveTotalWeight; + ThreadGroupWeight[waveIndex] = waveTotalWeight / waveTotalPossibleWeight; + InterlockedMax(MaxSumEntry, waveIndex); + } + + GroupMemoryBarrierWithGroupSync(); + reduceSharedMemoryAverage(ThreadIndexInGroup, waveIndex, waveLaneCount); + if (ThreadIndexInGroup == 0) + { + ProbeVariabilityAverage[GroupID.xyz].r = ThreadGroupAverage[0]; + ProbeVariabilityAverage[GroupID.xyz].g = ThreadGroupWeight[0]; + } +} diff --git a/rtxgi-sdk/shaders/ddgi/include/Common.hlsl b/rtxgi-sdk/shaders/ddgi/include/Common.hlsl index d60d12e..6b71345 100644 --- a/rtxgi-sdk/shaders/ddgi/include/Common.hlsl +++ b/rtxgi-sdk/shaders/ddgi/include/Common.hlsl @@ -27,10 +27,12 @@ // Texture formats (matches EDDGIVolumeTextureFormat) #define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_U32 0 -#define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F16x2 1 -#define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F16x4 2 -#define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F32x2 3 -#define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F32x4 4 +#define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F16 1 +#define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F16x2 2 +#define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F16x4 3 +#define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F32 4 +#define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F32x2 5 +#define RTXGI_DDGI_VOLUME_TEXTURE_FORMAT_F32x4 6 // The number of fixed rays that are used by probe relocation and classification. // These rays directions are always the same to produce temporally stable results. diff --git a/rtxgi-sdk/shaders/ddgi/include/DDGIRootConstants.hlsl b/rtxgi-sdk/shaders/ddgi/include/DDGIRootConstants.hlsl index 36594bb..e08f174 100644 --- a/rtxgi-sdk/shaders/ddgi/include/DDGIRootConstants.hlsl +++ b/rtxgi-sdk/shaders/ddgi/include/DDGIRootConstants.hlsl @@ -37,6 +37,7 @@ uint GetDDGIVolumeIndex() { return DDGI.volumeIndex; } uint GetDDGIVolumeConstantsIndex() { return DDGI.volumeConstantsIndex; } uint GetDDGIVolumeResourceIndicesIndex() { return DDGI.volumeResourceIndicesIndex; } + uint3 GetReductionInputSize() { return uint3(DDGI.reductionInputSizeX, DDGI.reductionInputSizeY, DDGI.reductionInputSizeZ); } #else // VULKAN @@ -77,22 +78,33 @@ { // IMPORTANT: insert padding to match the layout of your push constants! // The padding below matches the size of the Test Harness' "GlobalConstants" struct - // with 44 float values before the DDGIRootConstants (see test-harness/include/graphics/Types.h) + // with 48 float values before the DDGIRootConstants (see test-harness/include/graphics/Types.h) float4x4 padding0; float4x4 padding1; - float4x3 padding2; + float4x4 padding2; uint RTXGI_PUSH_CONSTS_FIELD_DDGI_VOLUME_INDEX_NAME; - uint3 ddgi_pad; + uint2 ddgi_pad0; + uint RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_X_NAME; + uint RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Y_NAME; + uint RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Z_NAME; + uint2 ddgi_pad1; }; [[vk::push_constant]] RTXGI_PUSH_CONSTS_STRUCT_NAME RTXGI_PUSH_CONSTS_VARIABLE_NAME; #endif uint GetDDGIVolumeIndex() { return RTXGI_PUSH_CONSTS_VARIABLE_NAME.RTXGI_PUSH_CONSTS_FIELD_DDGI_VOLUME_INDEX_NAME; } + uint3 GetReductionInputSize() + { + return uint3(RTXGI_PUSH_CONSTS_VARIABLE_NAME.RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_X_NAME, + RTXGI_PUSH_CONSTS_VARIABLE_NAME.RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Y_NAME, + RTXGI_PUSH_CONSTS_VARIABLE_NAME.RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Z_NAME); + } #elif RTXGI_PUSH_CONSTS_TYPE == RTXGI_PUSH_CONSTS_TYPE_SDK [[vk::push_constant]] ConstantBuffer DDGI; uint GetDDGIVolumeIndex() { return DDGI.volumeIndex; } + uint3 GetReductionInputSize() { return uint3(DDGI.reductionInputSizeX, DDGI.reductionInputSizeY, DDGI.reductionInputSizeZ); } #endif // RTXGI_PUSH_CONSTS_TYPE diff --git a/rtxgi-sdk/shaders/ddgi/include/validation/ProbeBlendingDefines.hlsl b/rtxgi-sdk/shaders/ddgi/include/validation/ProbeBlendingDefines.hlsl index 63296bf..6c60164 100644 --- a/rtxgi-sdk/shaders/ddgi/include/validation/ProbeBlendingDefines.hlsl +++ b/rtxgi-sdk/shaders/ddgi/include/validation/ProbeBlendingDefines.hlsl @@ -36,6 +36,8 @@ #define RAY_DATA_SPACE 0 #if RTXGI_DDGI_BLEND_RADIANCE #define OUTPUT_REGISTER 2 + #define PROBE_VARIABILITY_REGISTER 5 + #define PROBE_VARIABILITY_SPACE 0 #else #define OUTPUT_REGISTER 3 #endif @@ -51,6 +53,8 @@ #define RAY_DATA_SPACE space1 #if RTXGI_DDGI_BLEND_RADIANCE #define OUTPUT_REGISTER u1 + #define PROBE_VARIABILITY_REGISTER u4 + #define PROBE_VARIABILITY_SPACE space1 #else #define OUTPUT_REGISTER u2 #endif @@ -160,6 +164,24 @@ #error Required define PROBE_DATA_SPACE is not defined for ProbeBlendingCS.hlsl! #endif + + #if RTXGI_DDGI_BLEND_RADIANCE + // PROBE_VARIABILITY_REGISTER and PROBE_VARIABILITY_SPACE must be passed in as defines at shader compilation time *when not using reflection* + // and when probe classification is enabled. + // These defines specify the shader register and space used for the DDGIVolume probe data texture. + // Ex: PROBE_VARIABILITY_REGISTER u2 + // Ex: PROBE_VARIABILITY_SPACE space1 + + #ifndef PROBE_VARIABILITY_REGISTER + #error Required define PROBE_VARIABILITY_REGISTER is not defined for ProbeBlendingCS.hlsl! + #endif + + #ifndef PROBE_VARIABILITY_SPACE + #error Required define PROBE_VARIABILITY_SPACE is not defined for ProbeBlendingCS.hlsl! + #endif + + #endif // RTXGI_DDGI_BLEND_RADIANCE + #endif // RTXGI_DDGI_BINDLESS_RESOURCES #endif // !RTXGI_DDGI_SHADER_REFLECTION #endif // RTXGI_DDGI_BINDLESS_RESOURCES diff --git a/rtxgi-sdk/shaders/ddgi/include/validation/ReductionDefines.hlsl b/rtxgi-sdk/shaders/ddgi/include/validation/ReductionDefines.hlsl new file mode 100644 index 0000000..9a4c27c --- /dev/null +++ b/rtxgi-sdk/shaders/ddgi/include/validation/ReductionDefines.hlsl @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +// RTXGI_DDGI_RESOURCE_MANAGEMENT must be passed in as a define at shader compilation time. +// This define specifies if the shader resources are managed by the SDK (and not the application). +// Ex: RTXGI_DDGI_RESOURCE_MANAGEMENT [0|1] +#ifndef RTXGI_DDGI_RESOURCE_MANAGEMENT + #error Required define RTXGI_DDGI_RESOURCE_MANAGEMENT is not defined for ReductionCS.hlsl! +#endif + +// -------- SHADER REFLECTION DEFINES ------------------------------------------------------------- + +// RTXGI_DDGI_SHADER_REFLECTION must be passed in as a define at shader compilation time. +// This define specifies if the shader resources will be determined using shader reflection. +// Ex: RTXGI_DDGI_SHADER_REFLECTION [0|1] +#ifndef RTXGI_DDGI_SHADER_REFLECTION + #error Required define RTXGI_DDGI_SHADER_REFLECTION is not defined for ReductionCS.hlsl! +#else + #if !RTXGI_DDGI_SHADER_REFLECTION + // REGISTERs AND SPACEs (SHADER REFLECTION DISABLED) + + // MANAGED RESOURCES DEFINES + #if RTXGI_DDGI_RESOURCE_MANAGEMENT + #ifdef __spirv__ + #define RTXGI_PUSH_CONSTS_TYPE 1 + #define VOLUME_CONSTS_REGISTER 0 + #define VOLUME_CONSTS_SPACE 0 + #define PROBE_VARIABILITY_REGISTER 5 + #define PROBE_VARIABILITY_AVERAGE_REGISTER 6 + #define PROBE_VARIABILITY_SPACE 0 + #define PROBE_DATA_REGISTER 4 + #define PROBE_DATA_SPACE 0 + #else + #define CONSTS_REGISTER b0 + #define CONSTS_SPACE space1 + #define VOLUME_CONSTS_REGISTER t0 + #define VOLUME_CONSTS_SPACE space1 + #define PROBE_VARIABILITY_REGISTER u4 + #define PROBE_VARIABILITY_AVERAGE_REGISTER u5 + #define PROBE_VARIABILITY_SPACE space1 + #define PROBE_DATA_REGISTER u3 + #define PROBE_DATA_SPACE space1 + #endif + #endif // RTXGI_DDGI_RESOURCE_MANAGEMENT + + // VOLUME_CONSTS_REGISTER and VOLUME_CONSTS_SPACE must be passed in as defines at shader compilation time *when not using reflection*. + // These defines specify the shader register and space used for the DDGIVolumeDescGPUPacked structured buffer. + // Ex: VOLUME_CONSTS_REGISTER t5 + // Ex: VOLUME_CONSTS_SPACE space0 + #ifndef VOLUME_CONSTS_REGISTER + #error Required define VOLUME_CONSTS_REGISTER is not defined for ReductionCS.hlsl! + #endif + #ifndef VOLUME_CONSTS_SPACE + #error Required define VOLUME_CONSTS_SPACE is not defined for ReductionCS.hlsl! + #endif + #endif // !RTXGI_DDGI_SHADER_REFLECTION +#endif // RTXGI_DDGI_SHADER_REFLECTION + +// -------- RESOURCE BINDING DEFINES -------------------------------------------------------------- + +// RTXGI_DDGI_BINDLESS_RESOURCES must be passed in as a define at shader compilation time. +// This define specifies whether resources will be accessed bindlessly or not. +// Ex: RTXGI_DDGI_BINDLESS_RESOURCES [0|1] +#ifndef RTXGI_DDGI_BINDLESS_RESOURCES + #error Required define RTXGI_DDGI_BINDLESS_RESOURCES is not defined for ReductionCS.hlsl! +#else + #if !RTXGI_DDGI_SHADER_REFLECTION + // Shader Reflection DISABLED + #if RTXGI_DDGI_BINDLESS_RESOURCES + // Bindless Resources ENABLED + + // RTXGI_BINDLESS_TYPE must be passed in as a define at shader compilation time when *bindless resources are used*. + // This define specifies whether bindless resources will be accessed through bindless resource arrays or the (D3D12) descriptor heap. + // Ex: RTXGI_BINDLESS_TYPE [RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS(0)|RTXGI_BINDLESS_TYPE_DESCRIPTOR_HEAP(1)] + #ifndef RTXGI_BINDLESS_TYPE + #error Required define RTXGI_BINDLESS_TYPE is not defined for ReductionCS.hlsl! + #endif + + #if RTXGI_BINDLESS_TYPE == RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS + // Bindless resources are accessed using SM6.5 and below style resource arrays + + // VOLUME_RESOURCES_REGISTER and VOLUME_RESOURCES_SPACE must be passed in as defines at shader compilation time + // *not* using reflection and using bindless resource arrays. + // These defines specify the shader register and space used for the DDGIVolumeResourceIndices structured buffer. + // Ex: VOLUME_RESOURCES_REGISTER t6 + // Ex: VOLUME_RESOURCES_SPACE space0 + #ifndef VOLUME_RESOURCES_REGISTER + #error Required define VOLUME_RESOURCES_REGISTER is not defined for ReductionCS.hlsl! + #endif + #ifndef VOLUME_RESOURCES_REGISTER + #error Required define VOLUME_RESOURCES_REGISTER is not defined for ReductionCS.hlsl! + #endif + + // RWTEX2DARRAY_REGISTER and RWTEX2DARRAY_SPACE must be passed in as defines at shader compilation time + // *not* using reflection and using bindless resource arrays. + // These defines specify the shader register and space of the RWTexture2DArray resource array that the DDGIVolume's + // ray data, irradiance, distance, and probe data texture arrays are retrieved from bindlessly. + // Ex: RWTEX2DARRAY_REGISTER u6 + // Ex: RWTEX2DARRAY_SPACE space1 + #ifndef RWTEX2DARRAY_REGISTER + #error Required bindless mode define RWTEX2DARRAY_REGISTER is not defined for ReductionCS.hlsl! + #endif + #ifndef RWTEX2DARRAY_SPACE + #error Required bindless mode define RWTEX2DARRAY_SPACE is not defined for ReductionCS.hlsl! + #endif + + #endif // RTXGI_BINDLESS_TYPE == RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS + + #else // RTXGI_DDGI_BINDLESS_RESOURCES + + // Bindless Resources DISABLED (BOUND RESOURCE DEFINES) + + // PROBE_DATA_REGISTER and PROBE_DATA_SPACE must be passed in as defines at shader compilation time *when not using reflection*. + // These defines specify the shader register and space used for the DDGIVolume probe data texture array. + // Ex: PROBE_DATA_REGISTER u2 + // Ex: PROBE_DATA_SPACE space1 + #ifndef PROBE_DATA_REGISTER + #error Required define PROBE_DATA_REGISTER is not defined for ReductionCS.hlsl! + #endif + #ifndef PROBE_DATA_SPACE + #error Required define PROBE_DATA_SPACE is not defined for ReductionCS.hlsl! + #endif + + // PROBE_VARIABILITY_REGISTER and PROBE_VARIABILITY_SPACE must be passed in as defines at shader compilation time *when not using reflection* + // and when probe classification is enabled. + // These defines specify the shader register and space used for the DDGIVolume probe variability texture. + // Ex: PROBE_VARIABILITY_REGISTER u2 + // Ex: PROBE_VARIABILITY_SPACE space1 + + #ifndef PROBE_VARIABILITY_REGISTER + #error Required define PROBE_VARIABILITY_REGISTER is not defined for ReductionCS.hlsl! + #endif + + #ifndef PROBE_VARIABILITY_AVERAGE_REGISTER + #error Required define PROBE_VARIABILITY_AVERAGE_REGISTER is not defined for ReductionCS.hlsl! + #endif + + #ifndef PROBE_VARIABILITY_SPACE + #error Required define PROBE_VARIABILITY_SPACE is not defined for ReductionCS.hlsl! + #endif + + #endif // RTXGI_DDGI_BINDLESS_RESOURCES + #endif // !RTXGI_DDGI_SHADER_REFLECTION +#endif // RTXGI_DDGI_BINDLESS_RESOURCES + +// -------- CONFIGURATION DEFINES ----------------------------------------------------------------- + +// RTXGI_DDGI_PROBE_NUM_INTERIOR_TEXELS must be passed in as a define at shader compilation time. +// This define specifies the number of texels in a single dimension of a probe *excluding* the 1-texel probe border. +// Ex: RTXGI_DDGI_PROBE_NUM_INTERIOR_TEXELS 6 => irradiance data is 6x6 texels (for a single probe) +// Ex: RTXGI_DDGI_PROBE_NUM_INTERIOR_TEXELS 14 => distance data is 14x14 texels (for a single probe) +#ifndef RTXGI_DDGI_PROBE_NUM_INTERIOR_TEXELS + #error Required define RTXGI_DDGI_PROBE_NUM_INTERIOR_TEXELS is not defined for ReductionCS.hlsl! +#endif + +// RTXGI_DDGI_WAVE_LANE_COUNT must be passed in as a define at shader compilation time. +// This define specifies the number of threads in a wave, needed to determine required shared memory +// Ex: RTXGI_DDGI_WAVE_LANE_COUNT 32 => 32 threads in a wave +#ifndef RTXGI_DDGI_WAVE_LANE_COUNT +#error Required define RTXGI_DDGI_WAVE_LANE_COUNT is not defined for ReductionCS.hlsl! +#endif + +// ------------------------------------------------------------------------------------------- diff --git a/rtxgi-sdk/src/ddgi/DDGIVolume.cpp b/rtxgi-sdk/src/ddgi/DDGIVolume.cpp index 4a3ceaa..2f83854 100644 --- a/rtxgi-sdk/src/ddgi/DDGIVolume.cpp +++ b/rtxgi-sdk/src/ddgi/DDGIVolume.cpp @@ -25,7 +25,7 @@ namespace rtxgi void SetInsertPerfMarkers(bool value) { bInsertPerfMarkers = value; } int GetDDGIVolumeNumRTVDescriptors() { return 2; } - int GetDDGIVolumeNumTex2DArrayDescriptors() { return 4; } + int GetDDGIVolumeNumTex2DArrayDescriptors() { return 6; } int GetDDGIVolumeNumResourceDescriptors() { return 2 * GetDDGIVolumeNumTex2DArrayDescriptors(); } // Multiplied by 2 to account for UAV *and* SRV descriptors bool ValidateShaderBytecode(const ShaderBytecode& bytecode) @@ -74,6 +74,25 @@ namespace rtxgi width *= (uint32_t)(desc.probeNumDistanceTexels); height *= (uint32_t)(desc.probeNumDistanceTexels); } + else if (type == EDDGIVolumeTextureType::Variability) + { + width *= (uint32_t)(desc.probeNumIrradianceInteriorTexels); + height *= (uint32_t)(desc.probeNumIrradianceInteriorTexels); + } + else if (type == EDDGIVolumeTextureType::VariabilityAverage) + { + // Start with Probe variability texture dimensions + width *= (uint32_t)(desc.probeNumIrradianceInteriorTexels); + height *= (uint32_t)(desc.probeNumIrradianceInteriorTexels); + // Divide into thread groups, should match NUM_THREADS_XYZ in ReductionCS.hlsl + const uint3 NumThreadsInGroup = { 4, 8, 4 }; + // Also divide by sample footprint per-thread, should match ThreadSampleFootprint in ReductionCS.hlsl + const uint3 DimensionScale = { NumThreadsInGroup.x * 4, NumThreadsInGroup.y * 2, NumThreadsInGroup.z }; + // Size of diff total texture is just diff divided by thread group dimensions, rounded up + width = (width + DimensionScale.x - 1) / DimensionScale.x; + height = (height + DimensionScale.y - 1) / DimensionScale.y; + arraySize = (arraySize + DimensionScale.z - 1) / DimensionScale.z; + } } } @@ -90,6 +109,7 @@ namespace rtxgi if(m_desc.movementType == EDDGIVolumeMovementType::Scrolling) ComputeScrolling(); } +#if _DEBUG void DDGIVolumeBase::ValidatePackedData(const DDGIVolumeDescGPUPacked packed) const { DDGIVolumeDescGPU l = UnpackDDGIVolumeDescGPU(packed); @@ -120,6 +140,7 @@ namespace rtxgi assert(l.probeIrradianceFormat == r.probeIrradianceFormat); assert(l.probeRelocationEnabled == r.probeRelocationEnabled); assert(l.probeClassificationEnabled == r.probeClassificationEnabled); + assert(l.probeVariabilityEnabled == r.probeVariabilityEnabled); assert(l.probeScrollClear[0] == r.probeScrollClear[0]); assert(l.probeScrollClear[1] == r.probeScrollClear[1]); assert(l.probeScrollClear[2] == r.probeScrollClear[2]); @@ -127,6 +148,7 @@ namespace rtxgi assert(l.probeScrollDirections[1] == r.probeScrollDirections[1]); assert(l.probeScrollDirections[2] == r.probeScrollDirections[2]); } +#endif //------------------------------------------------------------------------ // Getters @@ -168,6 +190,7 @@ namespace rtxgi descGPU.probeIrradianceFormat = static_cast(m_desc.probeIrradianceFormat); descGPU.probeRelocationEnabled = m_desc.probeRelocationEnabled; descGPU.probeClassificationEnabled = m_desc.probeClassificationEnabled; + descGPU.probeVariabilityEnabled = m_desc.probeVariabilityEnabled; descGPU.probeScrollClear[0] = m_probeScrollClear[0]; descGPU.probeScrollClear[1] = m_probeScrollClear[1]; descGPU.probeScrollClear[2] = m_probeScrollClear[2]; @@ -267,6 +290,8 @@ namespace rtxgi uint32_t numIrradianceBytesPerTexel = 0; uint32_t numDistanceBytesPerTexel = 0; uint32_t numProbeDataBytesPerTexel = 0; + uint32_t numProbeVariabilityBytesPerTexel = 0; + uint32_t numProbeVariabilityAverageBytesPerTexel = 0; // Compute the number of irradiance and distance texels uint32_t numIrradianceTexelsPerProbe = (m_desc.probeNumIrradianceTexels * m_desc.probeNumIrradianceTexels); @@ -289,12 +314,25 @@ namespace rtxgi if (m_desc.probeDataFormat == EDDGIVolumeTextureFormat::F16x4) numProbeDataBytesPerTexel = 8; else if (m_desc.probeDataFormat == EDDGIVolumeTextureFormat::F32x4) numProbeDataBytesPerTexel = 16; + // Get the number of bytes per probe variability texel + if (m_desc.probeVariabilityFormat == EDDGIVolumeTextureFormat::F16) numProbeVariabilityBytesPerTexel = 2; + else if (m_desc.probeVariabilityFormat == EDDGIVolumeTextureFormat::F32) numProbeVariabilityBytesPerTexel = 4; + + // Variability average is always F32x2 (8 bytes) + numProbeVariabilityAverageBytesPerTexel = 8; + // Compute the number of bytes per probe uint32_t bytesPerProbe = 0; bytesPerProbe += GetNumRaysPerProbe() * numRayDataBytesPerTexel; bytesPerProbe += (numIrradianceTexelsPerProbe * numIrradianceBytesPerTexel); bytesPerProbe += (numDistanceTexelsPerProbe * numDistanceBytesPerTexel); bytesPerProbe += numProbeDataBytesPerTexel; + bytesPerProbe += numProbeVariabilityBytesPerTexel; + + // Coefficient of variation average texture is different (smaller) dimensions from other textures + uint32_t width, height, arraySize; + GetDDGIVolumeTextureDimensions(m_desc, EDDGIVolumeTextureType::VariabilityAverage, width, height, arraySize); + bytesPerVolume += width * height * arraySize * numProbeVariabilityAverageBytesPerTexel; // Add the per probe memory use bytesPerVolume += GetNumProbes() * bytesPerProbe; diff --git a/rtxgi-sdk/src/ddgi/gfx/DDGIVolume_D3D12.cpp b/rtxgi-sdk/src/ddgi/gfx/DDGIVolume_D3D12.cpp index 29db639..bc601a8 100644 --- a/rtxgi-sdk/src/ddgi/gfx/DDGIVolume_D3D12.cpp +++ b/rtxgi-sdk/src/ddgi/gfx/DDGIVolume_D3D12.cpp @@ -38,6 +38,8 @@ namespace rtxgi if (!ValidateShaderBytecode(desc.probeRelocation.resetCS)) return ERTXGIStatus::ERROR_DDGI_INVALID_BYTECODE_PROBE_RELOCATION_RESET; if (!ValidateShaderBytecode(desc.probeClassification.updateCS)) return ERTXGIStatus::ERROR_DDGI_INVALID_BYTECODE_PROBE_CLASSIFICATION; if (!ValidateShaderBytecode(desc.probeClassification.resetCS)) return ERTXGIStatus::ERROR_DDGI_INVALID_BYTECODE_PROBE_CLASSIFICATION_RESET; + if (!ValidateShaderBytecode(desc.probeVariability.reductionCS)) return ERTXGIStatus::ERROR_DDGI_INVALID_BYTECODE_PROBE_VARIABILITY_REDUCTION; + if (!ValidateShaderBytecode(desc.probeVariability.extraReductionCS)) return ERTXGIStatus::ERROR_DDGI_INVALID_BYTECODE_PROBE_VARIABILITY_EXTRA_REDUCTION; return ERTXGIStatus::OK; } @@ -52,6 +54,9 @@ namespace rtxgi if (desc.probeIrradiance == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_IRRADIANCE; if (desc.probeDistance == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_DISTANCE; if (desc.probeData == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_DATA; + if (desc.probeVariability == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_VARIABILITY; + if (desc.probeVariabilityAverage == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_VARIABILITY_AVERAGE; + if (desc.probeVariabilityReadback == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_VARIABILITY_READBACK; // Render Target Views if (desc.probeIrradianceRTV.ptr == 0) return ERTXGIStatus::ERROR_DDGI_D3D12_INVALID_DESCRIPTOR; @@ -64,6 +69,8 @@ namespace rtxgi if (desc.probeRelocation.resetPSO == nullptr) return ERTXGIStatus::ERROR_DDGI_D3D12_INVALID_PSO_PROBE_RELOCATION_RESET; if (desc.probeClassification.updatePSO == nullptr) return ERTXGIStatus::ERROR_DDGI_D3D12_INVALID_PSO_PROBE_CLASSIFICATION; if (desc.probeClassification.resetPSO == nullptr) return ERTXGIStatus::ERROR_DDGI_D3D12_INVALID_PSO_PROBE_CLASSIFICATION_RESET; + if (desc.probeVariabilityPSOs.reductionPSO == nullptr) return ERTXGIStatus::ERROR_DDGI_D3D12_INVALID_PSO_PROBE_REDUCTION; + if (desc.probeVariabilityPSOs.extraReductionPSO == nullptr) return ERTXGIStatus::ERROR_DDGI_D3D12_INVALID_PSO_PROBE_EXTRA_REDUCTION; return ERTXGIStatus::OK; } @@ -95,6 +102,15 @@ namespace rtxgi if (format == EDDGIVolumeTextureFormat::F16x4) return DXGI_FORMAT_R16G16B16A16_FLOAT; else if (format == EDDGIVolumeTextureFormat::F32x4) return DXGI_FORMAT_R32G32B32A32_FLOAT; } + else if (type == EDDGIVolumeTextureType::Variability) + { + if (format == EDDGIVolumeTextureFormat::F16) return DXGI_FORMAT_R16_FLOAT; + else if(format == EDDGIVolumeTextureFormat::F32) return DXGI_FORMAT_R32_FLOAT; + } + else if (type == EDDGIVolumeTextureType::VariabilityAverage) + { + return DXGI_FORMAT_R32G32_FLOAT; + } return DXGI_FORMAT_UNKNOWN; } @@ -106,7 +122,9 @@ namespace rtxgi // 1 UAV for probe irradiance texture array (u1, space1) // 1 UAV for probe distance texture array (u2, space1) // 1 UAV for probe data texture array (u3, space1) - D3D12_DESCRIPTOR_RANGE ranges[5]; + // 1 UAV for probe variation array (u4, space1) + // 1 UAV for probe variation average array (u5, space1) + D3D12_DESCRIPTOR_RANGE ranges[7]; // Volume Constants Structured Buffer (t0, space1) ranges[0].NumDescriptors = 1; @@ -143,6 +161,20 @@ namespace rtxgi ranges[4].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; ranges[4].OffsetInDescriptorsFromTableStart = heapDesc.resourceIndices.probeDataUAVIndex; + // Probe Variability Texture Array UAV (u4, space1) + ranges[5].NumDescriptors = 1; + ranges[5].BaseShaderRegister = 4; + ranges[5].RegisterSpace = 1; + ranges[5].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; + ranges[5].OffsetInDescriptorsFromTableStart = heapDesc.resourceIndices.probeVariabilityUAVIndex; + + // Probe Variability Average Texture Array UAV (u5, space1) + ranges[6].NumDescriptors = 1; + ranges[6].BaseShaderRegister = 5; + ranges[6].RegisterSpace = 1; + ranges[6].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; + ranges[6].OffsetInDescriptorsFromTableStart = heapDesc.resourceIndices.probeVariabilityAverageUAVIndex; + // Root Parameters std::vector rootParameters; @@ -277,33 +309,6 @@ namespace rtxgi UINT volumeIndex; std::vector barriers; - // Transition volume textures to unordered access for read/write - D3D12_RESOURCE_BARRIER barrier = {}; - barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; - barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; - - // Transition(s) - for (volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) - { - const DDGIVolume* volume = volumes[volumeIndex]; - - // Transition the volume's irradiance and distance textures to unordered access - barrier.Transition.pResource = volume->GetProbeIrradiance(); - barriers.push_back(barrier); - - barrier.Transition.pResource = volume->GetProbeDistance(); - barriers.push_back(barrier); - } - - // Wait for the resource transitions to complete - if (!barriers.empty()) cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); - - barriers.clear(); - barrier = {}; - barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; - // Irradiance Blending if (bInsertPerfMarkers) PIXBeginEvent(cmdList, PIX_COLOR(RTXGI_PERF_MARKER_GREEN), "Probe Irradiance"); for (volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) @@ -358,8 +363,12 @@ namespace rtxgi } // Add a barrier + D3D12_RESOURCE_BARRIER barrier = {}; + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; barrier.UAV.pResource = volume->GetProbeIrradiance(); barriers.push_back(barrier); + barrier.UAV.pResource = volume->GetProbeVariability(); + barriers.push_back(barrier); } if (bInsertPerfMarkers) PIXEndEvent(cmdList); @@ -417,40 +426,15 @@ namespace rtxgi } // Add a barrier + D3D12_RESOURCE_BARRIER barrier = {}; + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; barrier.UAV.pResource = volume->GetProbeDistance(); barriers.push_back(barrier); } if (bInsertPerfMarkers) PIXEndEvent(cmdList); // Barrier(s) - // Wait for the irradiance and distance blending passes - // to complete before using the textures - if (!barriers.empty()) cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); - - // Remove previous barriers - barriers.clear(); - - // Transition volume textures back to pixel shader resources for read - barrier = {}; - barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; - barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; - - // Transition(s) - for (volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) - { - const DDGIVolume* volume = volumes[volumeIndex]; - - // Transition the volume's irradiance and distance texture arrays to unordered access - barrier.Transition.pResource = volume->GetProbeIrradiance(); - barriers.push_back(barrier); - - barrier.Transition.pResource = volume->GetProbeDistance(); - barriers.push_back(barrier); - } - - // Wait for the resource transitions to complete + // Wait for the irradiance and distance blending passes to complete before using the textures if (!barriers.empty()) cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); if (bInsertPerfMarkers) PIXEndEvent(cmdList); @@ -517,9 +501,11 @@ namespace rtxgi } // Probe Relocation Reset Barrier(s) - if(!barriers.empty()) cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); - - barriers.clear(); + if (!barriers.empty()) + { + cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); + barriers.clear(); + } // Probe Relocation for(volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) @@ -632,9 +618,11 @@ namespace rtxgi } // Probe Classification Reset Barrier(s) - if (!barriers.empty()) cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); - - barriers.clear(); + if (!barriers.empty()) + { + cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); + barriers.clear(); + } // Probe Classification for (volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) @@ -689,6 +677,223 @@ namespace rtxgi return ERTXGIStatus::OK; } + ERTXGIStatus CalculateDDGIVolumeVariability(ID3D12GraphicsCommandList* cmdList, UINT numVolumes, DDGIVolume** volumes) + { + if (bInsertPerfMarkers) PIXBeginEvent(cmdList, PIX_COLOR(RTXGI_PERF_MARKER_GREEN), "Probe Variability Calculation"); + + UINT volumeIndex; + + // Reduction + for (volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) + { + const DDGIVolume* volume = volumes[volumeIndex]; + if (!volume->GetProbeVariabilityEnabled()) continue; // Skip if the volume is not calculating variability + + // Set the descriptor heap(s) + std::vector heaps; + heaps.push_back(volume->GetResourceDescriptorHeap()); + if (volume->GetSamplerDescriptorHeap()) heaps.push_back(volume->GetSamplerDescriptorHeap()); + cmdList->SetDescriptorHeaps((UINT)heaps.size(), heaps.data()); + + // Set root signature and root constants + cmdList->SetComputeRootSignature(volume->GetRootSignature()); + cmdList->SetComputeRoot32BitConstants(volume->GetRootParamSlotRootConstants(), DDGIRootConstants::GetNum32BitValues(), volume->GetRootConstants().GetData(), 0); + + // Set the descriptor tables (when relevant) + if (volume->GetBindlessEnabled()) + { + // Bindless resources, using application's root signature + if (volume->GetBindlessType() == EBindlessType::RESOURCE_ARRAYS) + { + // Only need to set descriptor tables when using traditional resource array bindless + cmdList->SetComputeRootDescriptorTable(volume->GetRootParamSlotResourceDescriptorTable(), volume->GetResourceDescriptorHeap()->GetGPUDescriptorHandleForHeapStart()); + if (volume->GetSamplerDescriptorHeap()) cmdList->SetComputeRootDescriptorTable(volume->GetRootParamSlotSamplerDescriptorTable(), volume->GetSamplerDescriptorHeap()->GetGPUDescriptorHandleForHeapStart()); + } + } + else + { + // Bound resources, using the SDK's root signature + cmdList->SetComputeRootDescriptorTable(volume->GetRootParamSlotResourceDescriptorTable(), volume->GetResourceDescriptorHeap()->GetGPUDescriptorHandleForHeapStart()); + } + + // Get the number of probes on the XYZ dimensions of the texture + UINT probeCountX, probeCountY, probeCountZ; + GetDDGIVolumeProbeCounts(volume->GetDesc(), probeCountX, probeCountY, probeCountZ); + + // Initially, the reduction input is the full variability size (same as irradiance texture without border texels) + UINT inputTexelsX = probeCountX * volume->GetDesc().probeNumIrradianceInteriorTexels; + UINT inputTexelsY = probeCountY * volume->GetDesc().probeNumIrradianceInteriorTexels; + UINT inputTexelsZ = probeCountZ; + + const uint3 NumThreadsInGroup = { 4, 8, 4 }; // Each thread group will have 8x8x8 threads + constexpr uint2 ThreadSampleFootprint = { 4, 2 }; // Each thread will sample 4x2 texels + + DDGIRootConstants consts = volume->GetRootConstants(); + + // First pass reduction takes probe irradiance data and calculates variability, reduces as much as possible + { + if (bInsertPerfMarkers && volume->GetInsertPerfMarkers()) + { + std::string msg = "Reduction, DDGIVolume[" + std::to_string(volume->GetIndex()) + "] - \"" + volume->GetName() + "\""; + PIXBeginEvent(cmdList, PIX_COLOR(RTXGI_PERF_MARKER_GREEN), msg.c_str()); + } + + // Set the PSO and dispatch threads + cmdList->SetPipelineState(volume->GetProbeVariabilityReductionPSO()); + + // One thread group per output texel + UINT outputTexelsX = (UINT)ceil((float)inputTexelsX / (NumThreadsInGroup.x * ThreadSampleFootprint.x)); + UINT outputTexelsY = (UINT)ceil((float)inputTexelsY / (NumThreadsInGroup.y * ThreadSampleFootprint.y)); + UINT outputTexelsZ = (UINT)ceil((float)inputTexelsZ / NumThreadsInGroup.z); + + consts.reductionInputSizeX = inputTexelsX; + consts.reductionInputSizeY = inputTexelsY; + consts.reductionInputSizeZ = inputTexelsZ; + cmdList->SetComputeRoot32BitConstants(volume->GetRootParamSlotRootConstants(), DDGIRootConstants::GetNum32BitValues(), consts.GetData(), 0); + + cmdList->Dispatch(outputTexelsX, outputTexelsY, outputTexelsZ); + + if (bInsertPerfMarkers && volume->GetInsertPerfMarkers()) PIXEndEvent(cmdList); + + // Each thread group will write out a value to the averaging texture + // If there is more than one thread group, we will need to do extra averaging passes + inputTexelsX = outputTexelsX; + inputTexelsY = outputTexelsY; + inputTexelsZ = outputTexelsZ; + } + + // UAV barrier needed after each reduction pass + D3D12_RESOURCE_BARRIER reductionBarrier = {}; + reductionBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; + reductionBarrier.UAV.pResource = volume->GetProbeVariabilityAverage(); + cmdList->ResourceBarrier(1, &reductionBarrier); + + // Extra reduction passes average values in variability texture down to single value + while (inputTexelsX > 1 || inputTexelsY > 1 || inputTexelsZ > 1) + { + if (bInsertPerfMarkers && volume->GetInsertPerfMarkers()) + { + std::string msg = "Extra Reduction, DDGIVolume[" + std::to_string(volume->GetIndex()) + "] - \"" + volume->GetName() + "\""; + PIXBeginEvent(cmdList, PIX_COLOR(RTXGI_PERF_MARKER_GREEN), msg.c_str()); + } + + cmdList->SetPipelineState(volume->GetProbeVariabilityExtraReductionPSO()); + + // One thread group per output texel + UINT outputTexelsX = (UINT)ceil((float)inputTexelsX / (NumThreadsInGroup.x * ThreadSampleFootprint.x)); + UINT outputTexelsY = (UINT)ceil((float)inputTexelsY / (NumThreadsInGroup.y * ThreadSampleFootprint.y)); + UINT outputTexelsZ = (UINT)ceil((float)inputTexelsZ / NumThreadsInGroup.z); + + consts.reductionInputSizeX = inputTexelsX; + consts.reductionInputSizeY = inputTexelsY; + consts.reductionInputSizeZ = inputTexelsZ; + cmdList->SetComputeRoot32BitConstants(volume->GetRootParamSlotRootConstants(), DDGIRootConstants::GetNum32BitValues(), consts.GetData(), 0); + + cmdList->Dispatch(outputTexelsX, outputTexelsY, outputTexelsZ); + + if (bInsertPerfMarkers && volume->GetInsertPerfMarkers()) PIXEndEvent(cmdList); + + inputTexelsX = outputTexelsX; + inputTexelsY = outputTexelsY; + inputTexelsZ = outputTexelsZ; + + // Need a barrier in between each reduction pass + cmdList->ResourceBarrier(1, &reductionBarrier); + } + } + + if (bInsertPerfMarkers) PIXEndEvent(cmdList); + + // Copy readback buffer + std::vector barriers; + if (bInsertPerfMarkers) PIXBeginEvent(cmdList, PIX_COLOR(RTXGI_PERF_MARKER_GREEN), "Probe Variability Readback"); + + { + D3D12_RESOURCE_BARRIER beforeBarrier = {}; + beforeBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + beforeBarrier.Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; + beforeBarrier.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE; + beforeBarrier.Transition.Subresource = 0; + + D3D12_RESOURCE_BARRIER afterBarrier = beforeBarrier; + afterBarrier.Transition.StateBefore = beforeBarrier.Transition.StateAfter; + afterBarrier.Transition.StateAfter = beforeBarrier.Transition.StateBefore; + + for (volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) + { + const DDGIVolume* volume = volumes[volumeIndex]; + if (!volume->GetProbeVariabilityEnabled()) continue; // Skip if the volume is not calculating variability + + beforeBarrier.Transition.pResource = volume->GetProbeVariabilityAverage(); + barriers.push_back(beforeBarrier); + } + + if (!barriers.empty()) + { + cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); + barriers.clear(); + } + + for (volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) + { + const DDGIVolume* volume = volumes[volumeIndex]; + if (!volume->GetProbeVariabilityEnabled()) continue; // Skip if the volume is not calculating variability + + D3D12_TEXTURE_COPY_LOCATION copyLocSrc = {}; + copyLocSrc.pResource = volume->GetProbeVariabilityAverage(); + copyLocSrc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + copyLocSrc.SubresourceIndex = 0; + + D3D12_TEXTURE_COPY_LOCATION copyLocDst = {}; + copyLocDst.pResource = volume->GetProbeVariabilityReadback(); + copyLocDst.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + copyLocDst.PlacedFootprint.Offset = 0; + copyLocDst.PlacedFootprint.Footprint.Width = 1; + copyLocDst.PlacedFootprint.Footprint.Height = 1; + copyLocDst.PlacedFootprint.Footprint.Depth = 1; + copyLocDst.PlacedFootprint.Footprint.Format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::VariabilityAverage, volume->GetDesc().probeVariabilityFormat); + copyLocDst.PlacedFootprint.Footprint.RowPitch = D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; + + D3D12_BOX box = { 0, 0, 0, 1, 1, 1}; + cmdList->CopyTextureRegion(©LocDst, 0, 0, 0, ©LocSrc, &box); + + afterBarrier.Transition.pResource = volume->GetProbeVariabilityAverage(); + barriers.push_back(afterBarrier); + } + + if (!barriers.empty()) cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); + } + + if (bInsertPerfMarkers) PIXEndEvent(cmdList); + + return ERTXGIStatus::OK; + } + + ERTXGIStatus ReadbackDDGIVolumeVariability(UINT numVolumes, DDGIVolume** volumes) + { + for (UINT volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) + { + // Get the volume + DDGIVolume* volume = volumes[volumeIndex]; + if (!volume->GetProbeVariabilityEnabled()) continue; // Skip if the volume is not calculating variability + + // Get the probe variability readback buffer + ID3D12Resource* readback = volume->GetProbeVariabilityReadback(); + + // Read the first 32-bits of the readback buffer + float* pMappedMemory = nullptr; + D3D12_RANGE readRange = { 0, sizeof(float) }; + D3D12_RANGE writeRange = {}; + HRESULT hr = readback->Map(0, &readRange, (void**)&pMappedMemory); + if (FAILED(hr)) return ERTXGIStatus::ERROR_DDGI_MAP_FAILURE_VARIABILITY_READBACK_BUFFER; + float value = pMappedMemory[0]; + readback->Unmap(0, &writeRange); + + volume->SetVolumeAverageVariability(value); + } + return ERTXGIStatus::OK; + } + //------------------------------------------------------------------------ // Private DDGIVolume Functions //------------------------------------------------------------------------ @@ -707,6 +912,8 @@ namespace rtxgi RTXGI_SAFE_RELEASE(m_probeRelocationResetPSO); RTXGI_SAFE_RELEASE(m_probeClassificationPSO); RTXGI_SAFE_RELEASE(m_probeClassificationResetPSO); + RTXGI_SAFE_RELEASE(m_probeVariabilityReductionPSO); + RTXGI_SAFE_RELEASE(m_probeVariabilityExtraReductionPSO); } ERTXGIStatus DDGIVolume::CreateManagedResources(const DDGIVolumeDesc& desc, const DDGIVolumeManagedResourcesDesc& managed) @@ -755,17 +962,29 @@ namespace rtxgi managed.probeClassification.resetCS, &m_probeClassificationResetPSO, "Probe Classification Reset")) return ERTXGIStatus::ERROR_DDGI_D3D12_CREATE_FAILURE_PSO; + + if (!CreateComputePSO( + managed.probeVariability.reductionCS, + &m_probeVariabilityReductionPSO, + "Probe Variability Reduction")) return ERTXGIStatus::ERROR_DDGI_D3D12_CREATE_FAILURE_PSO; + + if (!CreateComputePSO( + managed.probeVariability.extraReductionCS, + &m_probeVariabilityExtraReductionPSO, + "Probe Variability Extra Reduction")) return ERTXGIStatus::ERROR_DDGI_D3D12_CREATE_FAILURE_PSO; } // Create the textures if (deviceChanged || m_desc.ShouldAllocateProbes(desc)) { // Probe counts have changed. The texture arrays are the wrong size or aren't allocated yet. - // (Re)allocate the probe ray data, irradiance, distance, and data textures. + // (Re)allocate the probe ray data, irradiance, distance, data, and variability textures. if (!CreateProbeRayData(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_RAY_DATA; if (!CreateProbeIrradiance(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_IRRADIANCE; if (!CreateProbeDistance(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_DISTANCE; if (!CreateProbeData(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_DATA; + if (!CreateProbeVariability(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_VARIABILITY; + if (!CreateProbeVariabilityAverage(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_VARIABILITY_AVERAGE; } else { @@ -806,6 +1025,9 @@ namespace rtxgi m_probeIrradiance = unmanaged.probeIrradiance; m_probeDistance = unmanaged.probeDistance; m_probeData = unmanaged.probeData; + m_probeVariability = unmanaged.probeVariability; + m_probeVariabilityAverage = unmanaged.probeVariabilityAverage; + m_probeVariabilityReadback = unmanaged.probeVariabilityReadback; // Render Target Views m_probeIrradianceRTV = unmanaged.probeIrradianceRTV; @@ -818,6 +1040,8 @@ namespace rtxgi m_probeRelocationResetPSO = unmanaged.probeRelocation.resetPSO; m_probeClassificationPSO = unmanaged.probeClassification.updatePSO; m_probeClassificationResetPSO = unmanaged.probeClassification.resetPSO; + m_probeVariabilityReductionPSO = unmanaged.probeVariabilityPSOs.reductionPSO; + m_probeVariabilityExtraReductionPSO = unmanaged.probeVariabilityPSOs.extraReductionPSO; } #endif @@ -910,12 +1134,12 @@ namespace rtxgi // Transition the probe textures render targets D3D12_RESOURCE_BARRIER barriers[2] = {}; barriers[0].Transition.pResource = m_probeIrradiance; - barriers[0].Transition.StateBefore = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + barriers[0].Transition.StateBefore = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; barriers[0].Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET; barriers[0].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; barriers[1].Transition.pResource = m_probeDistance; - barriers[1].Transition.StateBefore = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + barriers[1].Transition.StateBefore = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; barriers[1].Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET; barriers[1].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; @@ -930,10 +1154,10 @@ namespace rtxgi // Transition the probe textures back to unordered access barriers[0].Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET; - barriers[0].Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + barriers[0].Transition.StateAfter = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; barriers[1].Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET; - barriers[1].Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + barriers[1].Transition.StateAfter = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; // Wait for the transitions cmdList->ResourceBarrier(2, barriers); @@ -943,6 +1167,46 @@ namespace rtxgi return ERTXGIStatus::OK; } + void DDGIVolume::TransitionResources(ID3D12GraphicsCommandList* cmdList, EDDGIExecutionStage stage) const + { + std::vector barriers; + + D3D12_RESOURCE_BARRIER barrier = {}; + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; + + if (stage == EDDGIExecutionStage::POST_PROBE_TRACE) + { + barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; + barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; + } + else if (stage == EDDGIExecutionStage::PRE_GATHER_CS) + { + barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; + barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; + } + else if (stage == EDDGIExecutionStage::PRE_GATHER_PS) + { + barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; + barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + } + else if (stage == EDDGIExecutionStage::POST_GATHER_PS) + { + barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; + } + + // Add the volume texture array resources + barrier.Transition.pResource = m_probeIrradiance; + barriers.push_back(barrier); + barrier.Transition.pResource = m_probeDistance; + barriers.push_back(barrier); + barrier.Transition.pResource = m_probeData; + barriers.push_back(barrier); + + cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); + } + DDGIVolumeResourceIndices DDGIVolume::GetResourceIndices() const { if(m_bindlessResources.type == EBindlessType::DESCRIPTOR_HEAP) return m_descriptorHeapDesc.resourceIndices; @@ -972,6 +1236,16 @@ namespace rtxgi if (view == EResourceViewType::UAV) return m_descriptorHeapDesc.resourceIndices.probeDataUAVIndex; if (view == EResourceViewType::SRV) return m_descriptorHeapDesc.resourceIndices.probeDataSRVIndex; } + else if (type == EDDGIVolumeTextureType::Variability) + { + if (view == EResourceViewType::UAV) return m_descriptorHeapDesc.resourceIndices.probeVariabilityUAVIndex; + if (view == EResourceViewType::SRV) return m_descriptorHeapDesc.resourceIndices.probeVariabilitySRVIndex; + } + else if (type == EDDGIVolumeTextureType::VariabilityAverage) + { + if (view == EResourceViewType::UAV) return m_descriptorHeapDesc.resourceIndices.probeVariabilityAverageUAVIndex; + if (view == EResourceViewType::SRV) return m_descriptorHeapDesc.resourceIndices.probeVariabilityAverageSRVIndex; + } return 0; } @@ -998,6 +1272,16 @@ namespace rtxgi if (view == EResourceViewType::UAV) m_descriptorHeapDesc.resourceIndices.probeDataUAVIndex = index; if (view == EResourceViewType::SRV) m_descriptorHeapDesc.resourceIndices.probeDataSRVIndex = index; } + else if (type == EDDGIVolumeTextureType::Variability) + { + if (view == EResourceViewType::UAV) m_descriptorHeapDesc.resourceIndices.probeVariabilityUAVIndex = index; + if (view == EResourceViewType::SRV) m_descriptorHeapDesc.resourceIndices.probeVariabilitySRVIndex = index; + } + else if (type == EDDGIVolumeTextureType::VariabilityAverage) + { + if (view == EResourceViewType::UAV) m_descriptorHeapDesc.resourceIndices.probeVariabilityAverageUAVIndex = index; + if (view == EResourceViewType::SRV) m_descriptorHeapDesc.resourceIndices.probeVariabilityAverageSRVIndex = index; + } } void DDGIVolume::Destroy() @@ -1043,6 +1327,9 @@ namespace rtxgi RTXGI_SAFE_RELEASE(m_probeIrradiance); RTXGI_SAFE_RELEASE(m_probeDistance); RTXGI_SAFE_RELEASE(m_probeData); + RTXGI_SAFE_RELEASE(m_probeVariability); + RTXGI_SAFE_RELEASE(m_probeVariabilityAverage); + RTXGI_SAFE_RELEASE(m_probeVariabilityReadback); RTXGI_SAFE_RELEASE(m_probeBlendingIrradiancePSO); RTXGI_SAFE_RELEASE(m_probeBlendingDistancePSO); @@ -1050,6 +1337,8 @@ namespace rtxgi RTXGI_SAFE_RELEASE(m_probeRelocationResetPSO); RTXGI_SAFE_RELEASE(m_probeClassificationPSO); RTXGI_SAFE_RELEASE(m_probeClassificationResetPSO); + RTXGI_SAFE_RELEASE(m_probeVariabilityReductionPSO); + RTXGI_SAFE_RELEASE(m_probeVariabilityExtraReductionPSO); #else m_rootSignature = nullptr; @@ -1057,6 +1346,9 @@ namespace rtxgi m_probeIrradiance = nullptr; m_probeDistance = nullptr; m_probeData = nullptr; + m_probeVariability = nullptr; + m_probeVariabilityAverage = nullptr; + m_probeVariabilityReadback = nullptr; m_probeBlendingIrradiancePSO = nullptr; m_probeBlendingDistancePSO = nullptr; @@ -1064,6 +1356,8 @@ namespace rtxgi m_probeRelocationResetPSO = nullptr; m_probeClassificationPSO = nullptr; m_probeClassificationResetPSO = nullptr; + m_probeVariabilityReductionPSO = nullptr; + m_probeVariabilityExtraReductionPSO = nullptr; #endif; } @@ -1158,6 +1452,30 @@ namespace rtxgi m_device->CreateShaderResourceView(m_probeData, &srvDesc, srvHandle); } + // Probe variability texture descriptors + { + uavHandle.ptr = heapStart.ptr + (m_descriptorHeapDesc.resourceIndices.probeVariabilityUAVIndex * m_descriptorHeapDesc.entrySize); + srvHandle.ptr = heapStart.ptr + (m_descriptorHeapDesc.resourceIndices.probeVariabilitySRVIndex * m_descriptorHeapDesc.entrySize); + + srvDesc.Format = uavDesc.Format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Variability, m_desc.probeVariabilityFormat); + m_device->CreateUnorderedAccessView(m_probeVariability, nullptr, &uavDesc, uavHandle); + m_device->CreateShaderResourceView(m_probeVariability, &srvDesc, srvHandle); + } + + // Probe variability average texture descriptors + { + uavHandle.ptr = heapStart.ptr + (m_descriptorHeapDesc.resourceIndices.probeVariabilityAverageUAVIndex * m_descriptorHeapDesc.entrySize); + srvHandle.ptr = heapStart.ptr + (m_descriptorHeapDesc.resourceIndices.probeVariabilityAverageSRVIndex * m_descriptorHeapDesc.entrySize); + + UINT variabilityAverageArraySize; + GetDDGIVolumeTextureDimensions(m_desc, EDDGIVolumeTextureType::VariabilityAverage, width, height, variabilityAverageArraySize); + srvDesc.Format = uavDesc.Format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::VariabilityAverage, m_desc.probeVariabilityFormat); + uavDesc.Texture2DArray.ArraySize = variabilityAverageArraySize; + srvDesc.Texture2DArray.ArraySize = variabilityAverageArraySize; + m_device->CreateUnorderedAccessView(m_probeVariabilityAverage, nullptr, &uavDesc, uavHandle); + m_device->CreateShaderResourceView(m_probeVariabilityAverage, &srvDesc, srvHandle); + } + // Describe the RTV heap D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; heapDesc.NumDescriptors = GetDDGIVolumeNumRTVDescriptors(); @@ -1308,7 +1626,7 @@ namespace rtxgi // Create the texture resource D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; - bool result = CreateTexture(width, height, arraySize, format, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, flags, &m_probeIrradiance); + bool result = CreateTexture(width, height, arraySize, format, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, flags, &m_probeIrradiance); if (!result) return false; #ifdef RTXGI_GFX_NAME_OBJECTS std::wstring name = L"DDGIVolume[" + std::to_wstring(desc.index) + L"], Probe Irradiance"; @@ -1334,7 +1652,7 @@ namespace rtxgi // Create the texture resource D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; - bool result = CreateTexture(width, height, arraySize, format, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, flags, &m_probeDistance); + bool result = CreateTexture(width, height, arraySize, format, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, flags, &m_probeDistance); if (!result) return false; #ifdef RTXGI_GFX_NAME_OBJECTS std::wstring name = L"DDGIVolume[" + std::to_wstring(desc.index) + L"], Probe Distance"; @@ -1360,7 +1678,7 @@ namespace rtxgi if (width <= 0 || height <= 0 || arraySize <= 0) return false; // Create the texture resource - bool result = CreateTexture(width, height, arraySize, format, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, &m_probeData); + bool result = CreateTexture(width, height, arraySize, format, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, &m_probeData); if (!result) return false; #ifdef RTXGI_GFX_NAME_OBJECTS std::wstring name = L"DDGIVolume[" + std::to_wstring(desc.index) + L"], Probe Data"; @@ -1370,6 +1688,90 @@ namespace rtxgi return true; } + bool DDGIVolume::CreateProbeVariability(const DDGIVolumeDesc& desc) + { + RTXGI_SAFE_RELEASE(m_probeVariability); + + UINT width = 0; + UINT height = 0; + UINT arraySize = 0; + DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; + + // Get the texture dimensions and format + GetDDGIVolumeTextureDimensions(desc, EDDGIVolumeTextureType::Variability, width, height, arraySize); + format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Variability, desc.probeVariabilityFormat); + + // Check for problems + if (width <= 0 || height <= 0 || arraySize <= 0) return false; + + // Create the texture resource + bool result = CreateTexture(width, height, arraySize, format, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, &m_probeVariability); + if (!result) return false; + #ifdef RTXGI_GFX_NAME_OBJECTS + std::wstring name = L"DDGIVolume[" + std::to_wstring(desc.index) + L"], Probe Variability"; + m_probeVariability->SetName(name.c_str()); + #endif + + return true; + } + + bool DDGIVolume::CreateProbeVariabilityAverage(const DDGIVolumeDesc& desc) + { + RTXGI_SAFE_RELEASE(m_probeVariabilityAverage); + + UINT width = 0; + UINT height = 0; + UINT arraySize = 0; + DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; + + // Get the texture dimensions and format + GetDDGIVolumeTextureDimensions(desc, EDDGIVolumeTextureType::VariabilityAverage, width, height, arraySize); + format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::VariabilityAverage, desc.probeVariabilityFormat); + + // Check for problems + if (width <= 0 || height <= 0 || arraySize <= 0) return false; + + // Create the texture resource + bool result = CreateTexture(width, height, arraySize, format, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, &m_probeVariabilityAverage); + if (!result) return false; + #ifdef RTXGI_GFX_NAME_OBJECTS + std::wstring name = L"DDGIVolume[" + std::to_wstring(desc.index) + L"], Probe Variability Average"; + m_probeVariabilityAverage->SetName(name.c_str()); + #endif + + // Create the readback texture + RTXGI_SAFE_RELEASE(m_probeVariabilityReadback); + + // Readback texture is always in "full" format (R32G32F) + format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::VariabilityAverage, desc.probeVariabilityFormat); + { + D3D12_HEAP_PROPERTIES readbackHeapProperties = {}; + readbackHeapProperties.Type = D3D12_HEAP_TYPE_READBACK; + + D3D12_RESOURCE_DESC desc = {}; + desc.Format = DXGI_FORMAT_UNKNOWN; + desc.Width = sizeof(float) * 2; + desc.Height = 1; + desc.MipLevels = 1; + desc.DepthOrArraySize = 1; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + desc.Flags = D3D12_RESOURCE_FLAG_NONE; + + HRESULT hr = m_device->CreateCommittedResource(&readbackHeapProperties, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&m_probeVariabilityReadback)); + result = SUCCEEDED(hr); + } + if (!result) return false; + #ifdef RTXGI_GFX_NAME_OBJECTS + name = L"DDGIVolume[" + std::to_wstring(desc.index) + L"], Probe Variability Readback"; + m_probeVariabilityReadback->SetName(name.c_str()); + #endif + + return true; + } + #endif // RTXGI_DDGI_RESOURCE_MANAGEMENT } // namespace d3d12 diff --git a/rtxgi-sdk/src/ddgi/gfx/DDGIVolume_VK.cpp b/rtxgi-sdk/src/ddgi/gfx/DDGIVolume_VK.cpp index 14cfd4a..958a031 100644 --- a/rtxgi-sdk/src/ddgi/gfx/DDGIVolume_VK.cpp +++ b/rtxgi-sdk/src/ddgi/gfx/DDGIVolume_VK.cpp @@ -74,6 +74,8 @@ namespace rtxgi if (!ValidateShaderBytecode(desc.probeRelocation.resetCS)) return ERTXGIStatus::ERROR_DDGI_INVALID_BYTECODE_PROBE_RELOCATION_RESET; if (!ValidateShaderBytecode(desc.probeClassification.updateCS)) return ERTXGIStatus::ERROR_DDGI_INVALID_BYTECODE_PROBE_CLASSIFICATION; if (!ValidateShaderBytecode(desc.probeClassification.resetCS)) return ERTXGIStatus::ERROR_DDGI_INVALID_BYTECODE_PROBE_CLASSIFICATION_RESET; + if (!ValidateShaderBytecode(desc.probeVariability.reductionCS)) return ERTXGIStatus::ERROR_DDGI_INVALID_BYTECODE_PROBE_CLASSIFICATION_RESET; + if (!ValidateShaderBytecode(desc.probeVariability.extraReductionCS)) return ERTXGIStatus::ERROR_DDGI_INVALID_BYTECODE_PROBE_VARIABILITY_EXTRA_REDUCTION; return ERTXGIStatus::OK; } @@ -89,18 +91,26 @@ namespace rtxgi if (desc.probeIrradiance == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_IRRADIANCE; if (desc.probeDistance == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_DISTANCE; if (desc.probeData == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_DATA; + if (desc.probeVariability == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_VARIABILITY; + if (desc.probeVariabilityAverage == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_VARIABILITY_AVERAGE; + if (desc.probeVariabilityReadback == nullptr) return ERTXGIStatus::ERROR_DDGI_INVALID_TEXTURE_PROBE_VARIABILITY_READBACK; // Texture Array Memory if (desc.probeRayDataMemory == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_RAY_DATA; if (desc.probeIrradianceMemory == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_IRRADIANCE; if (desc.probeDistanceMemory == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_DISTANCE; if (desc.probeDataMemory == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_DATA; + if (desc.probeVariabilityMemory == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_VARIABILITY; + if (desc.probeVariabilityAverageMemory == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_VARIABILITY_AVERAGE; + if (desc.probeVariabilityReadbackMemory == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_VARIABILITY_READBACK; // Texture Array Views if (desc.probeRayDataView == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_RAY_DATA; if (desc.probeIrradianceView == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_IRRADIANCE; if (desc.probeDistanceView == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_DISTANCE; if (desc.probeDataView == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_DATA; + if (desc.probeVariabilityView == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_VARIABILITY; + if (desc.probeVariabilityAverageView == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_VARIABILITY_AVERAGE; // Shader Modules if (desc.probeBlendingIrradianceModule == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_BLENDING_IRRADIANCE; @@ -109,6 +119,8 @@ namespace rtxgi if (desc.probeRelocation.resetModule == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_RELOCATION_RESET; if (desc.probeClassification.updateModule == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_CLASSIFICATION; if (desc.probeClassification.resetModule == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_CLASSIFICATION_RESET; + if (desc.probeVariabilityPipelines.reductionModule == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_VARIABILITY_REDUCTION; + if (desc.probeVariabilityPipelines.extraReductionModule == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_VARIABILITY_EXTRA_REDUCTION; // Pipelines if (desc.probeBlendingIrradiancePipeline == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_BLENDING_IRRADIANCE; @@ -117,6 +129,8 @@ namespace rtxgi if (desc.probeRelocation.resetPipeline == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_RELOCATION_RESET; if (desc.probeClassification.updatePipeline == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_CLASSIFICATION; if (desc.probeClassification.resetPipeline == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_CLASSIFICATION_RESET; + if (desc.probeVariabilityPipelines.reductionPipeline == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_VARIABILITY_REDUCTION; + if (desc.probeVariabilityPipelines.extraReductionPipeline == nullptr) return ERTXGIStatus::ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_VARIABILITY_EXTRA_REDUCTION; return ERTXGIStatus::OK; } @@ -148,10 +162,19 @@ namespace rtxgi if (format == EDDGIVolumeTextureFormat::F16x4) return VK_FORMAT_R16G16B16A16_SFLOAT; else if (format == EDDGIVolumeTextureFormat::F32x4) return VK_FORMAT_R32G32B32A32_SFLOAT; } + else if (type == EDDGIVolumeTextureType::Variability) + { + if (format == EDDGIVolumeTextureFormat::F16) return VK_FORMAT_R16_SFLOAT; + else if (format == EDDGIVolumeTextureFormat::F32) return VK_FORMAT_R32_SFLOAT; + } + else if (type == EDDGIVolumeTextureType::VariabilityAverage) + { + return VK_FORMAT_R32G32_SFLOAT; + } return VK_FORMAT_UNDEFINED; } - uint32_t GetDDGIVolumeLayoutBindingCount() { return 5; } + uint32_t GetDDGIVolumeLayoutBindingCount() { return 7; } void GetDDGIVolumeLayoutDescs( VkDescriptorSetLayoutCreateInfo& descriptorSetLayoutCreateInfo, @@ -165,6 +188,8 @@ namespace rtxgi // 1 UAV probe irradiance texture array (2) // 1 UAV probe distance texture array (3) // 1 UAV probe data texture array (4) + // 1 UAV probe variation texture array (5) + // 1 UAV probe variation average array (6) // 0: Volume Constants Structured Buffer VkDescriptorSetLayoutBinding& bind0 = bindings[0]; @@ -201,6 +226,20 @@ namespace rtxgi bind4.descriptorCount = 1; bind4.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT; + // 5: Probe Variability + VkDescriptorSetLayoutBinding& bind5 = bindings[5]; + bind5.binding = static_cast(EDDGIVolumeBindings::ProbeVariability); + bind5.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; + bind5.descriptorCount = 1; + bind5.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT; + + // 6: Probe Variability + VkDescriptorSetLayoutBinding& bind6 = bindings[6]; + bind6.binding = static_cast(EDDGIVolumeBindings::ProbeVariabilityAverage); + bind6.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; + bind6.descriptorCount = 1; + bind6.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT; + // Describe the descriptor set layout descriptorSetLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; descriptorSetLayoutCreateInfo.bindingCount = GetDDGIVolumeLayoutBindingCount(); @@ -361,6 +400,8 @@ namespace rtxgi // Add a barrier barrier.image = volume->GetProbeIrradiance(); barriers.push_back(barrier); + barrier.image = volume->GetProbeVariability(); + barriers.push_back(barrier); } if (bInsertPerfMarkers) vkCmdEndDebugUtilsLabelEXT(cmdBuffer); @@ -402,9 +443,9 @@ namespace rtxgi } if (bInsertPerfMarkers) vkCmdEndDebugUtilsLabelEXT(cmdBuffer); - // Wait for the irradiance and distance blending passes - // to complete before updating the borders - if(!barriers.empty()) + // Irradiance pass must finish generating variability before possible reduction pass + // Also ensures that irradiance and distance complete before border update after reduction + if (!barriers.empty()) { vkCmdPipelineBarrier( cmdBuffer, @@ -624,6 +665,232 @@ namespace rtxgi return ERTXGIStatus::OK; } + ERTXGIStatus CalculateDDGIVolumeVariability(VkCommandBuffer cmdBuffer, uint32_t numVolumes, DDGIVolume** volumes) + { + if (bInsertPerfMarkers) AddPerfMarker(cmdBuffer, RTXGI_PERF_MARKER_GREEN, "Probe Variability Calculation"); + + uint32_t volumeIndex; + std::vector barriers; + + // Reduction + for (volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) + { + const DDGIVolume* volume = volumes[volumeIndex]; + if (!volume->GetProbeVariabilityEnabled()) continue; // Skip if the volume is not calculating variability + + // Bind the descriptor set and push constants + vkCmdBindDescriptorSets(cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, volume->GetPipelineLayout(), 0, 1, volume->GetDescriptorSetConstPtr(), 0, nullptr); + + // Get the number of probes on the XYZ dimensions of the texture + uint32_t probeCountX, probeCountY, probeCountZ; + GetDDGIVolumeProbeCounts(volume->GetDesc(), probeCountX, probeCountY, probeCountZ); + + // Initially, the reduction input is the full variability size (same as irradiance texture) + uint32_t inputTexelsX = probeCountX * volume->GetDesc().probeNumIrradianceInteriorTexels; + uint32_t inputTexelsY = probeCountY * volume->GetDesc().probeNumIrradianceInteriorTexels; + uint32_t inputTexelsZ = probeCountZ; + + const uint3 NumThreadsInGroup = { 4, 8, 4 }; // Each thread group will have 8x8x8 threads + constexpr uint2 ThreadSampleFootprint = { 4, 2 }; // Each thread will sample 4x2 texels + + // Set push constants + DDGIRootConstants consts = volume->GetPushConstants(); + + // First pass reduction takes probe irradiance data and calculates variability, reduces as much as possible + { + if (bInsertPerfMarkers && volume->GetInsertPerfMarkers()) + { + std::string msg = "Reduction, DDGIVolume[" + std::to_string(volume->GetIndex()) + "] - \"" + volume->GetName() + "\""; + AddPerfMarker(cmdBuffer, RTXGI_PERF_MARKER_GREEN, msg.c_str()); + } + + // Set the PSO and dispatch threads + vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, volume->GetProbeVariabilityReductionPipeline()); + + // One thread group per output texel + uint32_t outputTexelsX = (uint32_t)ceil((float)inputTexelsX / (float)(NumThreadsInGroup.x * ThreadSampleFootprint.x)); + uint32_t outputTexelsY = (uint32_t)ceil((float)inputTexelsY / (float)(NumThreadsInGroup.y * ThreadSampleFootprint.y)); + uint32_t outputTexelsZ = (uint32_t)ceil((float)inputTexelsZ / (float)NumThreadsInGroup.z); + + consts.reductionInputSizeX = inputTexelsX; + consts.reductionInputSizeY = inputTexelsY; + consts.reductionInputSizeZ = inputTexelsZ; + vkCmdPushConstants(cmdBuffer, volume->GetPipelineLayout(), VK_SHADER_STAGE_ALL, volume->GetPushConstantsOffset(), DDGIRootConstants::GetSizeInBytes(), consts.GetData()); + + vkCmdDispatch(cmdBuffer, outputTexelsX, outputTexelsY, outputTexelsZ); + + if (bInsertPerfMarkers && volume->GetInsertPerfMarkers()) vkCmdEndDebugUtilsLabelEXT(cmdBuffer); + + // Each thread group will write out a value to the averaging texture + // If there is more than one thread group, we will need to do extra averaging passes + inputTexelsX = outputTexelsX; + inputTexelsY = outputTexelsY; + inputTexelsZ = outputTexelsZ; + } + + // UAV barrier needed after each reduction pass + VkImageMemoryBarrier reductionBarrier = {}; + reductionBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + reductionBarrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + reductionBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + reductionBarrier.oldLayout = reductionBarrier.newLayout = VK_IMAGE_LAYOUT_GENERAL; + reductionBarrier.subresourceRange = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }; + reductionBarrier.image = volume->GetProbeVariabilityAverage(); + vkCmdPipelineBarrier( + cmdBuffer, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + 0, + 0, nullptr, + 0, nullptr, + 1, &reductionBarrier); + + // Future extra passes (if they run) will re-use the reductionBarrier struct, so update srcAcessMask to match + reductionBarrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + + // Extra reduction passes average values in variability texture down to single value + while (inputTexelsX > 1 || inputTexelsY > 1 || inputTexelsZ > 1) + { + if (bInsertPerfMarkers && volume->GetInsertPerfMarkers()) + { + std::string msg = "Extra Reduction, DDGIVolume[" + std::to_string(volume->GetIndex()) + "] - \"" + volume->GetName() + "\""; + AddPerfMarker(cmdBuffer, RTXGI_PERF_MARKER_GREEN, msg.c_str()); + } + + vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, volume->GetProbeVariabilityExtraReductionPipeline()); + + // One thread group per output texel + uint32_t outputTexelsX = (uint32_t)ceil((float)inputTexelsX / (float)(NumThreadsInGroup.x * ThreadSampleFootprint.x)); + uint32_t outputTexelsY = (uint32_t)ceil((float)inputTexelsY / (float)(NumThreadsInGroup.y * ThreadSampleFootprint.y)); + uint32_t outputTexelsZ = (uint32_t)ceil((float)inputTexelsZ / (float)NumThreadsInGroup.z); + + consts.reductionInputSizeX = inputTexelsX; + consts.reductionInputSizeY = inputTexelsY; + consts.reductionInputSizeZ = inputTexelsZ; + vkCmdPushConstants(cmdBuffer, volume->GetPipelineLayout(), VK_SHADER_STAGE_ALL, volume->GetPushConstantsOffset(), DDGIRootConstants::GetSizeInBytes(), consts.GetData()); + + vkCmdDispatch(cmdBuffer, outputTexelsX, outputTexelsY, outputTexelsZ); + + if (bInsertPerfMarkers && volume->GetInsertPerfMarkers()) vkCmdEndDebugUtilsLabelEXT(cmdBuffer); + + inputTexelsX = outputTexelsX; + inputTexelsY = outputTexelsY; + inputTexelsZ = outputTexelsZ; + + // Need a barrier in between each reduction pass + vkCmdPipelineBarrier( + cmdBuffer, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + 0, + 0, nullptr, + 0, nullptr, + 1, &reductionBarrier); + } + } + + if (bInsertPerfMarkers) vkCmdEndDebugUtilsLabelEXT(cmdBuffer); + + // Copy readback buffer + if (bInsertPerfMarkers) AddPerfMarker(cmdBuffer, RTXGI_PERF_MARKER_GREEN, "Probe Variability Readback"); + + { + VkImageMemoryBarrier beforeBarrier = {}; + beforeBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + beforeBarrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + beforeBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + beforeBarrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL; + beforeBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; + beforeBarrier.subresourceRange = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }; + + VkImageMemoryBarrier afterBarrier = beforeBarrier; + afterBarrier.srcAccessMask = beforeBarrier.dstAccessMask; + afterBarrier.dstAccessMask = beforeBarrier.srcAccessMask; + afterBarrier.oldLayout = beforeBarrier.newLayout; + afterBarrier.newLayout = beforeBarrier.oldLayout; + + for (volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) + { + const DDGIVolume* volume = volumes[volumeIndex]; + if (!volume->GetProbeVariabilityEnabled()) continue; // Skip if the volume is not calculating variability + + beforeBarrier.image = volume->GetProbeVariabilityAverage(); + barriers.push_back(beforeBarrier); + } + + if (!barriers.empty()) + { + vkCmdPipelineBarrier( + cmdBuffer, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, + 0, + 0, nullptr, + 0, nullptr, + static_cast(barriers.size()), barriers.data()); + + barriers.clear(); + } + + for (volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) + { + const DDGIVolume* volume = volumes[volumeIndex]; + if (!volume->GetProbeVariabilityEnabled()) continue; // Skip if the volume is not calculating variability + + VkBufferImageCopy copy = {}; + copy.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; + copy.imageExtent = { 1, 1, 1 }; + vkCmdCopyImageToBuffer(cmdBuffer, + volume->GetProbeVariabilityAverage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + volume->GetProbeVariabilityReadback(), + 1, ©); + + afterBarrier.image = volume->GetProbeVariabilityAverage(); + barriers.push_back(afterBarrier); + } + + if (!barriers.empty()) + { + vkCmdPipelineBarrier( + cmdBuffer, + VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + 0, + 0, nullptr, + 0, nullptr, + static_cast(barriers.size()), barriers.data()); + barriers.clear(); + } + } + + if (bInsertPerfMarkers) vkCmdEndDebugUtilsLabelEXT(cmdBuffer); + + return ERTXGIStatus::OK; + } + + ERTXGIStatus ReadbackDDGIVolumeVariability(VkDevice device, uint32_t numVolumes, DDGIVolume** volumes) + { + for (uint32_t volumeIndex = 0; volumeIndex < numVolumes; volumeIndex++) + { + // Get the volume + DDGIVolume* volume = volumes[volumeIndex]; + if (!volume->GetProbeVariabilityEnabled()) continue; // Skip if the volume is not calculating variability + + // Get the probe variability readback buffer + VkDeviceMemory readback = volume->GetProbeVariabilityReadbackMemory(); + + // Read the first 32-bits of the readback buffer + float* pMappedMemory = nullptr; + VkResult result = vkMapMemory(device, readback, 0, sizeof(float), 0, (void**)&pMappedMemory); + if (VKFAILED(result)) return ERTXGIStatus::ERROR_DDGI_MAP_FAILURE_VARIABILITY_READBACK_BUFFER; + float value = pMappedMemory[0]; + vkUnmapMemory(device, readback); + + volume->SetVolumeAverageVariability(value); + } + return ERTXGIStatus::OK; + } + //------------------------------------------------------------------------ // Private DDGIVolume Functions //------------------------------------------------------------------------ @@ -642,6 +909,8 @@ namespace rtxgi vkDestroyShaderModule(m_device, m_probeRelocationResetModule, nullptr); vkDestroyShaderModule(m_device, m_probeClassificationModule, nullptr); vkDestroyShaderModule(m_device, m_probeClassificationResetModule, nullptr); + vkDestroyShaderModule(m_device, m_probeVariabilityReductionModule, nullptr); + vkDestroyShaderModule(m_device, m_probeVariabilityExtraReductionModule, nullptr); // Release the existing compute pipelines vkDestroyPipeline(m_device, m_probeBlendingIrradiancePipeline, nullptr); @@ -650,6 +919,8 @@ namespace rtxgi vkDestroyPipeline(m_device, m_probeRelocationResetPipeline, nullptr); vkDestroyPipeline(m_device, m_probeClassificationPipeline, nullptr); vkDestroyPipeline(m_device, m_probeClassificationResetPipeline, nullptr); + vkDestroyPipeline(m_device, m_probeVariabilityReductionPipeline, nullptr); + vkDestroyPipeline(m_device, m_probeVariabilityExtraReductionPipeline, nullptr); } ERTXGIStatus DDGIVolume::CreateManagedResources(const DDGIVolumeDesc& desc, const DDGIVolumeManagedResourcesDesc& managed) @@ -712,6 +983,20 @@ namespace rtxgi &m_probeClassificationResetModule, &m_probeClassificationResetPipeline, "Probe Classification Reset")) return ERTXGIStatus::ERROR_DDGI_VK_CREATE_FAILURE_PIPELINE; + + if (!CreateComputePipeline( + managed.probeVariability.reductionCS, + "DDGIReductionCS", + &m_probeVariabilityReductionModule, + &m_probeVariabilityReductionPipeline, + "Probe Variability Reduction")) return ERTXGIStatus::ERROR_DDGI_VK_CREATE_FAILURE_PIPELINE; + + if (!CreateComputePipeline( + managed.probeVariability.extraReductionCS, + "DDGIExtraReductionCS", + &m_probeVariabilityExtraReductionModule, + &m_probeVariabilityExtraReductionPipeline, + "Probe Variability Extra Reduction")) return ERTXGIStatus::ERROR_DDGI_VK_CREATE_FAILURE_PIPELINE; } // Create the textures @@ -723,6 +1008,8 @@ namespace rtxgi if (!CreateProbeIrradiance(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_IRRADIANCE; if (!CreateProbeDistance(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_DISTANCE; if (!CreateProbeData(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_DATA; + if (!CreateProbeVariability(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_VARIABILITY; + if (!CreateProbeVariabilityAverage(desc)) return ERTXGIStatus::ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_VARIABILITY_AVERAGE; } else { @@ -759,18 +1046,26 @@ namespace rtxgi m_probeIrradiance = unmanaged.probeIrradiance; m_probeDistance = unmanaged.probeDistance; m_probeData = unmanaged.probeData; + m_probeVariability = unmanaged.probeVariability; + m_probeVariabilityAverage = unmanaged.probeVariabilityAverage; + m_probeVariabilityReadback = unmanaged.probeVariabilityReadback; // Texture Array Memory m_probeRayDataMemory = unmanaged.probeRayDataMemory; m_probeIrradianceMemory = unmanaged.probeIrradianceMemory; m_probeDistanceMemory = unmanaged.probeDistanceMemory; m_probeDataMemory = unmanaged.probeDataMemory; + m_probeVariabilityMemory = unmanaged.probeVariabilityMemory; + m_probeVariabilityAverageMemory = unmanaged.probeVariabilityAverageMemory; + m_probeVariabilityReadbackMemory = unmanaged.probeVariabilityReadbackMemory; // Texture Array Views m_probeRayDataView = unmanaged.probeRayDataView; m_probeIrradianceView = unmanaged.probeIrradianceView; m_probeDistanceView = unmanaged.probeDistanceView; m_probeDataView = unmanaged.probeDataView; + m_probeVariabilityView = unmanaged.probeVariabilityView; + m_probeVariabilityAverageView = unmanaged.probeVariabilityAverageView; // Shader Modules m_probeBlendingIrradianceModule = unmanaged.probeBlendingIrradianceModule; @@ -779,6 +1074,8 @@ namespace rtxgi m_probeRelocationResetModule = unmanaged.probeRelocation.resetModule; m_probeClassificationModule = unmanaged.probeClassification.updateModule; m_probeClassificationResetModule = unmanaged.probeClassification.resetModule; + m_probeVariabilityReductionModule = unmanaged.probeVariabilityPipelines.reductionModule; + m_probeVariabilityExtraReductionModule = unmanaged.probeVariabilityPipelines.extraReductionModule; // Pipelines m_probeBlendingIrradiancePipeline = unmanaged.probeBlendingIrradiancePipeline; @@ -787,6 +1084,8 @@ namespace rtxgi m_probeRelocationResetPipeline = unmanaged.probeRelocation.resetPipeline; m_probeClassificationPipeline = unmanaged.probeClassification.updatePipeline; m_probeClassificationResetPipeline = unmanaged.probeClassification.resetPipeline; + m_probeVariabilityReductionPipeline = unmanaged.probeVariabilityPipelines.reductionPipeline; + m_probeVariabilityExtraReductionPipeline = unmanaged.probeVariabilityPipelines.extraReductionPipeline; } #endif @@ -944,6 +1243,8 @@ namespace rtxgi vkDestroyShaderModule(m_device, m_probeRelocationResetModule, nullptr); vkDestroyShaderModule(m_device, m_probeClassificationModule, nullptr); vkDestroyShaderModule(m_device, m_probeClassificationResetModule, nullptr); + vkDestroyShaderModule(m_device, m_probeVariabilityReductionModule, nullptr); + vkDestroyShaderModule(m_device, m_probeVariabilityExtraReductionModule, nullptr); // Pipelines vkDestroyPipeline(m_device, m_probeBlendingIrradiancePipeline, nullptr); @@ -952,6 +1253,8 @@ namespace rtxgi vkDestroyPipeline(m_device, m_probeRelocationResetPipeline, nullptr); vkDestroyPipeline(m_device, m_probeClassificationPipeline, nullptr); vkDestroyPipeline(m_device, m_probeClassificationResetPipeline, nullptr); + vkDestroyPipeline(m_device, m_probeVariabilityReductionPipeline, nullptr); + vkDestroyPipeline(m_device, m_probeVariabilityExtraReductionPipeline, nullptr); // Texture Arrays vkDestroyImage(m_device, m_probeRayData, nullptr); @@ -970,6 +1273,17 @@ namespace rtxgi vkDestroyImageView(m_device, m_probeDataView, nullptr); vkFreeMemory(m_device, m_probeDataMemory, nullptr); + vkDestroyImage(m_device, m_probeVariability, nullptr); + vkDestroyImageView(m_device, m_probeVariabilityView, nullptr); + vkFreeMemory(m_device, m_probeVariabilityMemory, nullptr); + + vkDestroyImage(m_device, m_probeVariabilityAverage, nullptr); + vkDestroyImageView(m_device, m_probeVariabilityAverageView, nullptr); + vkFreeMemory(m_device, m_probeVariabilityAverageMemory, nullptr); + + vkDestroyBuffer(m_device, m_probeVariabilityReadback, nullptr); + vkFreeMemory(m_device, m_probeVariabilityReadbackMemory, nullptr); + m_descriptorSetLayout = nullptr; m_descriptorPool = nullptr; m_device = nullptr; @@ -992,6 +1306,14 @@ namespace rtxgi m_probeData = nullptr; m_probeDataMemory = nullptr; m_probeDataView = nullptr; + m_probeVariability = nullptr; + m_probeVariabilityMemory = nullptr; + m_probeVariabilityView = nullptr; + m_probeVariabilityAverage = nullptr; + m_probeVariabilityAverageMemory = nullptr; + m_probeVariabilityAverageView = nullptr; + m_probeVariabilityReadback = nullptr; + m_probeVariabilityReadbackMemory = nullptr; // Shader Modules m_probeBlendingIrradianceModule = nullptr; @@ -1000,6 +1322,8 @@ namespace rtxgi m_probeRelocationResetModule = nullptr; m_probeClassificationModule = nullptr; m_probeClassificationResetModule = nullptr; + m_probeVariabilityReductionModule = nullptr; + m_probeVariabilityExtraReductionModule = nullptr; // Pipelines m_probeBlendingIrradiancePipeline = nullptr; @@ -1008,6 +1332,8 @@ namespace rtxgi m_probeRelocationResetPipeline = nullptr; m_probeClassificationPipeline = nullptr; m_probeClassificationResetPipeline = nullptr; + m_probeVariabilityReductionPipeline = nullptr; + m_probeVariabilityExtraReductionPipeline = nullptr; } uint32_t DDGIVolume::GetGPUMemoryUsedInBytes() const @@ -1052,6 +1378,13 @@ namespace rtxgi barriers.push_back(barrier); barrier.image = m_probeData; barriers.push_back(barrier); + barrier.image = m_probeVariability; + barriers.push_back(barrier); + + GetDDGIVolumeTextureDimensions(m_desc, EDDGIVolumeTextureType::VariabilityAverage, width, height, arraySize); + barrier.image = m_probeVariabilityAverage; + barrier.subresourceRange.layerCount = arraySize; + barriers.push_back(barrier); vkCmdPipelineBarrier(cmdBuffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, static_cast(barriers.size()), barriers.data()); } @@ -1126,13 +1459,15 @@ namespace rtxgi descriptor->descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; descriptor->pBufferInfo = &volumeConstants; - // 1-4: Volume Texture Array UAVs + // 1-6: Volume Texture Array UAVs VkDescriptorImageInfo rwTex2D[] = { { VK_NULL_HANDLE, m_probeRayDataView, VK_IMAGE_LAYOUT_GENERAL }, { VK_NULL_HANDLE, m_probeIrradianceView, VK_IMAGE_LAYOUT_GENERAL }, { VK_NULL_HANDLE, m_probeDistanceView, VK_IMAGE_LAYOUT_GENERAL }, - { VK_NULL_HANDLE, m_probeDataView, VK_IMAGE_LAYOUT_GENERAL } + { VK_NULL_HANDLE, m_probeDataView, VK_IMAGE_LAYOUT_GENERAL }, + { VK_NULL_HANDLE, m_probeVariabilityView, VK_IMAGE_LAYOUT_GENERAL }, + { VK_NULL_HANDLE, m_probeVariabilityAverageView, VK_IMAGE_LAYOUT_GENERAL } }; descriptor = &descriptors.emplace_back(); @@ -1144,6 +1479,30 @@ namespace rtxgi descriptor->descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; descriptor->pImageInfo = rwTex2D; + VkDescriptorImageInfo variabilityInfo = { VK_NULL_HANDLE, m_probeVariabilityView, VK_IMAGE_LAYOUT_GENERAL }; + + // Probe Variability + descriptor = &descriptors.emplace_back(); + descriptor->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; + descriptor->dstSet = m_descriptorSet; + descriptor->dstBinding = static_cast(EDDGIVolumeBindings::ProbeVariability); + descriptor->dstArrayElement = 0; + descriptor->descriptorCount = 1; + descriptor->descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; + descriptor->pImageInfo = &variabilityInfo; + + VkDescriptorImageInfo variabilityAverageInfo = { VK_NULL_HANDLE, m_probeVariabilityAverageView, VK_IMAGE_LAYOUT_GENERAL }; + + // Probe Variability Average + descriptor = &descriptors.emplace_back(); + descriptor->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; + descriptor->dstSet = m_descriptorSet; + descriptor->dstBinding = static_cast(EDDGIVolumeBindings::ProbeVariabilityAverage); + descriptor->dstArrayElement = 0; + descriptor->descriptorCount = 1; + descriptor->descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; + descriptor->pImageInfo = &variabilityAverageInfo; + // Update the descriptor set vkUpdateDescriptorSets(m_device, static_cast(descriptors.size()), descriptors.data(), 0, nullptr); @@ -1399,6 +1758,102 @@ namespace rtxgi return true; } + bool DDGIVolume::CreateProbeVariability(const DDGIVolumeDesc& desc) + { + vkDestroyImage(m_device, m_probeVariability, nullptr); + vkDestroyImageView(m_device, m_probeVariabilityView, nullptr); + vkFreeMemory(m_device, m_probeVariabilityMemory, nullptr); + + uint32_t width = 0; + uint32_t height = 0; + uint32_t arraySize = 0; + GetDDGIVolumeTextureDimensions(desc, EDDGIVolumeTextureType::Variability, width, height, arraySize); + + // Check for problems + if (width <= 0 || height <= 0 || arraySize <= 0) return false; + + VkFormat format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Variability, desc.probeVariabilityFormat); + VkImageUsageFlags usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; + + // Create the texture, allocate memory, and bind the memory + bool result = CreateTexture(width, height, arraySize, format, usage, &m_probeVariability, &m_probeVariabilityMemory, &m_probeVariabilityView); + if (!result) return false; + #ifdef RTXGI_GFX_NAME_OBJECTS + std::string name = "DDGIVolume[" + std::to_string(desc.index) + "], Probe Variability"; + std::string memory = name + " Memory"; + std::string view = name + " View"; + SetObjectName(m_device, reinterpret_cast(m_probeVariability), name.c_str(), VK_OBJECT_TYPE_IMAGE); + SetObjectName(m_device, reinterpret_cast(m_probeVariabilityMemory), memory.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); + SetObjectName(m_device, reinterpret_cast(m_probeVariabilityView), view.c_str(), VK_OBJECT_TYPE_IMAGE_VIEW); + #endif + return true; + } + + bool DDGIVolume::CreateProbeVariabilityAverage(const DDGIVolumeDesc& desc) + { + vkDestroyImage(m_device, m_probeVariabilityAverage, nullptr); + vkDestroyImageView(m_device, m_probeVariabilityAverageView, nullptr); + vkFreeMemory(m_device, m_probeVariabilityAverageMemory, nullptr); + + uint32_t width = 0; + uint32_t height = 0; + uint32_t arraySize = 0; + GetDDGIVolumeTextureDimensions(desc, EDDGIVolumeTextureType::VariabilityAverage, width, height, arraySize); + + // Check for problems + if (width <= 0 || height <= 0 || arraySize <= 0) return false; + + VkFormat format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::VariabilityAverage, desc.probeVariabilityFormat); + VkImageUsageFlags usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; + + // Create the texture, allocate memory, and bind the memory + bool result = CreateTexture(width, height, arraySize, format, usage, &m_probeVariabilityAverage, &m_probeVariabilityAverageMemory, &m_probeVariabilityAverageView); + if (!result) return false; + #ifdef RTXGI_GFX_NAME_OBJECTS + std::string name = "DDGIVolume[" + std::to_string(desc.index) + "], Probe Variability Average"; + std::string memory = name + " Memory"; + std::string view = name + " View"; + SetObjectName(m_device, reinterpret_cast(m_probeVariabilityAverage), name.c_str(), VK_OBJECT_TYPE_IMAGE); + SetObjectName(m_device, reinterpret_cast(m_probeVariabilityAverageMemory), memory.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); + SetObjectName(m_device, reinterpret_cast(m_probeVariabilityAverageView), view.c_str(), VK_OBJECT_TYPE_IMAGE_VIEW); + #endif + + // Create the readback texture + vkDestroyBuffer(m_device, m_probeVariabilityReadback, nullptr); + + // Readback texture is always in "full" format (R32G32F) + format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::VariabilityAverage, desc.probeVariabilityFormat); + { + VkBufferCreateInfo bufferCreateInfo = {}; + bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + bufferCreateInfo.size = sizeof(float) * 2; + bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; + + // Create the buffer + VkResult result = vkCreateBuffer(m_device, &bufferCreateInfo, nullptr, &m_probeVariabilityReadback); + if (VKFAILED(result)) return false; + + // Get memory requirements + VkMemoryRequirements reqs; + vkGetBufferMemoryRequirements(m_device, m_probeVariabilityReadback, &reqs); + + // Allocate memory + VkMemoryAllocateFlags flags = 0; + VkMemoryPropertyFlags props = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + if (!AllocateMemory(reqs, props, flags, &m_probeVariabilityReadbackMemory)) return false; + + vkBindBufferMemory(m_device, m_probeVariabilityReadback, m_probeVariabilityReadbackMemory, 0); + } + #ifdef RTXGI_GFX_NAME_OBJECTS + name = "DDGIVolume[" + std::to_string(desc.index) + "], Probe Variability Readback"; + memory = name + " Memory"; + SetObjectName(m_device, reinterpret_cast(m_probeVariabilityReadback), name.c_str(), VK_OBJECT_TYPE_BUFFER); + SetObjectName(m_device, reinterpret_cast(m_probeVariabilityReadbackMemory), memory.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); + #endif + + return true; + } + #endif // RTXGI_MANAGED_RESOURCES } // namespace vulkan } // namespace rtxgi diff --git a/samples/test-harness/CMakeLists.txt b/samples/test-harness/CMakeLists.txt index 9eaeb5f..b713048 100644 --- a/samples/test-harness/CMakeLists.txt +++ b/samples/test-harness/CMakeLists.txt @@ -225,6 +225,7 @@ set_source_files_properties(${TEST_HARNESS_DDGIVIS_SHADER_SOURCE} PROPERTIES VS_ # Test Harness options option(RTXGISAMPLES_GFX_NAME_OBJECTS "Enable naming of graphics objects (for debugging)" ON) option(RTXGISAMPLES_GFX_PERF_MARKERS "Enable GPU performance markers" ON) +option(RTXGISAMPLES_GFX_NVAPI "Enable NVAPI" ON) # Test Harness bindless options set(RTXGISAMPLES_TEST_HARNESS_BINDLESS_TYPE "Resource Arrays" CACHE STRING "The bindless resource implementation to use") @@ -310,6 +311,7 @@ set(GLFW_INCLUDE_PATH "${ROOT_DIR}/thirdparty/glfw/include") set(IMGUI_INCLUDE_PATH "${ROOT_DIR}/thirdparty/imgui") set(IMGUI_BACKENDS_INCLUDE_PATH "${ROOT_DIR}/thirdparty/imgui/backends") set(TINYGLTF_INCLUDE_PATH "${ROOT_DIR}/thirdparty/tinygltf") +set(NVAPI_INCLUDE_PATH "${ROOT_DIR}/thirdparty/nvapi") # ---- WINDOWS / D3D12 -------------------------------------------------------------------------------------- @@ -355,11 +357,21 @@ if(RTXGI_API_D3D12_ENABLE) ${GLFW_INCLUDE_PATH} ${IMGUI_INCLUDE_PATH} ${IMGUI_BACKENDS_INCLUDE_PATH} + ${NVAPI_INCLUDE_PATH} ${TINYGLTF_INCLUDE_PATH} ) - # Add statically linked libs - target_link_libraries(${TARGET_EXE} RTXGI-D3D12 glfw d3d11 d3d12 dxgi) + if(RTXGISAMPLES_GFX_NVAPI) + target_compile_definitions(${TARGET_EXE} PRIVATE GFX_NVAPI=1) + + # Add statically linked libs + target_link_libraries(${TARGET_EXE} RTXGI-D3D12 glfw d3d11 d3d12 dxgi ${ROOT_DIR}/thirdparty/nvapi/amd64/nvapi64.lib) + else() + target_compile_definitions(${TARGET_EXE} PRIVATE GFX_NVAPI=0) + + # Add statically linked libs + target_link_libraries(${TARGET_EXE} RTXGI-D3D12 glfw d3d11 d3d12 dxgi) + endif() # Add common compiler definitions for exposed Test Harness options SetupOptions(${TARGET_EXE}) diff --git a/samples/test-harness/config/cornell.ini b/samples/test-harness/config/cornell.ini index c98d745..ea311da 100644 --- a/samples/test-harness/config/cornell.ini +++ b/samples/test-harness/config/cornell.ini @@ -13,7 +13,7 @@ app.rtxgiSDK=../../../rtxgi-sdk/ app.title=RTXGI Test Harness # scene -scene.name=Cornell Box +scene.name=Cornell-Box scene.path=data/gltf/cornell/ scene.file=cornell.glb scene.screenshotPath=cornell @@ -76,11 +76,14 @@ ddgi.volume.0.name=Cornell-Box ddgi.volume.0.probeRelocation.enabled=1 ddgi.volume.0.probeRelocation.minFrontfaceDistance=0.1 ddgi.volume.0.probeClassification.enabled=1 +ddgi.volume.0.probeVariability.enabled=0 +ddgi.volume.0.probeVariability.threshold=0.03 ddgi.volume.0.infiniteScrolling.enabled=1 -ddgi.volume.0.textures.rayData.format=3 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.0.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2 ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 -ddgi.volume.0.textures.distance.format=1 # EDDGIVolumeTextureFormat::F16x2 -ddgi.volume.0.textures.data.format=2 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.0.origin=0.0 1.0 0.0 ddgi.volume.0.probeCounts=9 9 9 ddgi.volume.0.probeSpacing=0.3 0.3 0.3 @@ -101,6 +104,7 @@ ddgi.volume.0.vis.texture.irradianceScale=2 ddgi.volume.0.vis.texture.distanceScale=1 ddgi.volume.0.vis.texture.probeDataScale=10 ddgi.volume.0.vis.texture.rayDataScale=0.56 +ddgi.volume.0.vis.texture.probeVariabilityScale=2.667 # ray traced ambient occlusion rtao.enable=1 diff --git a/samples/test-harness/config/furnace.ini b/samples/test-harness/config/furnace.ini index fde55c9..31e8f40 100644 --- a/samples/test-harness/config/furnace.ini +++ b/samples/test-harness/config/furnace.ini @@ -48,11 +48,14 @@ ddgi.volume.0.name=Scene Volume ddgi.volume.0.probeRelocation.enabled=0 ddgi.volume.0.probeRelocation.minFrontfaceDistance=0.1 ddgi.volume.0.probeClassification.enabled=0 +ddgi.volume.0.probeVariability.enabled=0 +ddgi.volume.0.probeVariability.threshold=0.01 ddgi.volume.0.infiniteScrolling.enabled=0 -ddgi.volume.0.textures.rayData.format=3 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.0.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2 ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 -ddgi.volume.0.textures.distance.format=1 # EDDGIVolumeTextureFormat::F16x2 -ddgi.volume.0.textures.data.format=2 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.0.origin=0.0 0.5 0.0 ddgi.volume.0.probeCounts=8 3 8 ddgi.volume.0.probeSpacing=2 1 2 @@ -73,6 +76,7 @@ ddgi.volume.0.vis.texture.irradianceScale=2.0 ddgi.volume.0.vis.texture.distanceScale=1.0 ddgi.volume.0.vis.texture.probeDataScale=16 ddgi.volume.0.vis.texture.rayDataScale=0.5 +ddgi.volume.0.vis.texture.probeVariabilityScale=2.667 # ray traced ambient occlusion rtao.enable=1 diff --git a/samples/test-harness/config/multi-cornell.ini b/samples/test-harness/config/multi-cornell.ini index eaeec58..c03561b 100644 --- a/samples/test-harness/config/multi-cornell.ini +++ b/samples/test-harness/config/multi-cornell.ini @@ -52,11 +52,14 @@ ddgi.volume.0.name=Cornell-Box-1 ddgi.volume.0.probeRelocation.enabled=1 ddgi.volume.0.probeRelocation.minFrontfaceDistance=0.1 ddgi.volume.0.probeClassification.enabled=1 +ddgi.volume.0.probeVariability.enabled=0 +ddgi.volume.0.probeVariability.threshold=0.04 ddgi.volume.0.infiniteScrolling.enabled=0 -ddgi.volume.0.textures.rayData.format=3 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.0.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2 ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 -ddgi.volume.0.textures.distance.format=1 # EDDGIVolumeTextureFormat::F16x2 -ddgi.volume.0.textures.data.format=2 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.0.origin=0.0 2.701 0.0 ddgi.volume.0.probeCounts=9 9 9 ddgi.volume.0.probeSpacing=0.75 0.75 0.75 @@ -77,16 +80,20 @@ ddgi.volume.0.vis.texture.irradianceScale=2.1 ddgi.volume.0.vis.texture.distanceScale=1.05 ddgi.volume.0.vis.texture.probeDataScale=16.81 ddgi.volume.0.vis.texture.rayDataScale=0.59 +ddgi.volume.0.vis.texture.probeVariabilityScale=2.799 ddgi.volume.1.name=Cornell-Box-2 ddgi.volume.1.probeRelocation.enabled=1 ddgi.volume.1.probeRelocation.minFrontfaceDistance=0.1 ddgi.volume.1.probeClassification.enabled=1 +ddgi.volume.1.probeVariability.enabled=0 +ddgi.volume.1.probeVariability.threshold=0.04 ddgi.volume.1.infiniteScrolling.enabled=0 -ddgi.volume.1.textures.rayData.format=3 -ddgi.volume.1.textures.irradiance.format=0 -ddgi.volume.1.textures.distance.format=1 -ddgi.volume.1.textures.data.format=2 +ddgi.volume.1.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.1.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 +ddgi.volume.1.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.1.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.1.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.1.origin=11.662 2.581 -6.0 ddgi.volume.1.rotation=0 43 0 ddgi.volume.1.probeCounts=9 9 9 @@ -108,16 +115,20 @@ ddgi.volume.1.vis.texture.irradianceScale=2.1 ddgi.volume.1.vis.texture.distanceScale=1.05 ddgi.volume.1.vis.texture.probeDataScale=16.81 ddgi.volume.1.vis.texture.rayDataScale=0.59 +ddgi.volume.1.vis.texture.probeVariabilityScale=2.799 ddgi.volume.2.name=Cornell-Box-3 ddgi.volume.2.probeRelocation.enabled=1 ddgi.volume.2.probeRelocation.minFrontfaceDistance=0.1 ddgi.volume.2.probeClassification.enabled=1 +ddgi.volume.2.probeVariability.enabled=0 +ddgi.volume.2.probeVariability.threshold=0.04 ddgi.volume.2.infiniteScrolling.enabled=0 -ddgi.volume.2.textures.rayData.format=3 -ddgi.volume.2.textures.irradiance.format=0 -ddgi.volume.2.textures.distance.format=1 -ddgi.volume.2.textures.data.format=2 +ddgi.volume.2.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.2.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 +ddgi.volume.2.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.2.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.2.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.2.origin=-10.379 2.701 -7.488 ddgi.volume.2.rotation=0 64 0 ddgi.volume.2.probeCounts=9 9 9 @@ -139,16 +150,20 @@ ddgi.volume.2.vis.texture.irradianceScale=2.1 ddgi.volume.2.vis.texture.distanceScale=1.05 ddgi.volume.2.vis.texture.probeDataScale=16.81 ddgi.volume.2.vis.texture.rayDataScale=0.59 +ddgi.volume.2.vis.texture.probeVariabilityScale=2.799 ddgi.volume.3.name=Cornell-Box-4 ddgi.volume.3.probeRelocation.enabled=1 ddgi.volume.3.probeRelocation.minFrontfaceDistance=0.1 ddgi.volume.3.probeClassification.enabled=1 +ddgi.volume.3.probeVariability.enabled=0 +ddgi.volume.3.probeVariability.threshold=0.04 ddgi.volume.3.infiniteScrolling.enabled=0 -ddgi.volume.3.textures.rayData.format=3 -ddgi.volume.3.textures.irradiance.format=0 -ddgi.volume.3.textures.distance.format=1 -ddgi.volume.3.textures.data.format=2 +ddgi.volume.3.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.3.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 +ddgi.volume.3.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.3.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.3.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.3.origin=0.565 2.629 -12.5 ddgi.volume.3.rotation=17 21 26 ddgi.volume.3.probeCounts=9 9 9 @@ -170,16 +185,20 @@ ddgi.volume.3.vis.texture.irradianceScale=2.1 ddgi.volume.3.vis.texture.distanceScale=1.05 ddgi.volume.3.vis.texture.probeDataScale=16.81 ddgi.volume.3.vis.texture.rayDataScale=0.59 +ddgi.volume.3.vis.texture.probeVariabilityScale=2.799 ddgi.volume.4.name=Cornell-Box-5 ddgi.volume.4.probeRelocation.enabled=1 ddgi.volume.4.probeRelocation.minFrontfaceDistance=0.1 ddgi.volume.4.probeClassification.enabled=1 +ddgi.volume.4.probeVariability.enabled=0 +ddgi.volume.4.probeVariability.threshold=0.04 ddgi.volume.4.infiniteScrolling.enabled=0 -ddgi.volume.4.textures.rayData.format=3 -ddgi.volume.4.textures.irradiance.format=0 -ddgi.volume.4.textures.distance.format=1 -ddgi.volume.4.textures.data.format=2 +ddgi.volume.4.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.4.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 +ddgi.volume.4.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.4.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.4.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.4.origin=-4.456 6.386 -19.6 ddgi.volume.4.rotation=-15 22 -22 ddgi.volume.4.probeCounts=9 9 9 @@ -201,16 +220,20 @@ ddgi.volume.4.vis.texture.irradianceScale=2.1 ddgi.volume.4.vis.texture.distanceScale=1.05 ddgi.volume.4.vis.texture.probeDataScale=16.81 ddgi.volume.4.vis.texture.rayDataScale=0.59 +ddgi.volume.4.vis.texture.probeVariabilityScale=2.799 ddgi.volume.5.name=Cornell-Box-6 ddgi.volume.5.probeRelocation.enabled=1 ddgi.volume.5.probeRelocation.minFrontfaceDistance=0.1 ddgi.volume.5.probeClassification.enabled=1 +ddgi.volume.5.probeVariability.enabled=0 +ddgi.volume.5.probeVariability.threshold=0.04 ddgi.volume.5.infiniteScrolling.enabled=0 -ddgi.volume.5.textures.rayData.format=3 -ddgi.volume.5.textures.irradiance.format=0 -ddgi.volume.5.textures.distance.format=1 -ddgi.volume.5.textures.data.format=2 +ddgi.volume.5.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.5.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 +ddgi.volume.5.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.5.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.5.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.5.origin=11.888 2.732 -19.5 ddgi.volume.5.rotation=33 36.5 -3 ddgi.volume.5.probeCounts=9 9 9 @@ -232,6 +255,7 @@ ddgi.volume.5.vis.texture.irradianceScale=2.1 ddgi.volume.5.vis.texture.distanceScale=1.05 ddgi.volume.5.vis.texture.probeDataScale=16.81 ddgi.volume.5.vis.texture.rayDataScale=0.59 +ddgi.volume.5.vis.texture.probeVariabilityScale=2.799 # ray traced ambient occlusion rtao.enable=1 diff --git a/samples/test-harness/config/sponza.ini b/samples/test-harness/config/sponza.ini index a535986..d1431f0 100644 --- a/samples/test-harness/config/sponza.ini +++ b/samples/test-harness/config/sponza.ini @@ -25,7 +25,7 @@ scene.lights.0.name=Sun scene.lights.0.type=0 scene.lights.0.direction=0.0 -1.0 0.3 scene.lights.0.color=1.0 1.0 1.0 -scene.lights.0.power=1.45 +scene.lights.0.power=3.14 # scene cameras scene.cameras.0.name=Upper Floor @@ -59,11 +59,14 @@ ddgi.volume.0.name=Scene-Volume ddgi.volume.0.probeRelocation.enabled=1 ddgi.volume.0.probeRelocation.minFrontfaceDistance=0.3 # should be at least as large as probeViewBias! ddgi.volume.0.probeClassification.enabled=1 +ddgi.volume.0.probeVariability.enabled=1 +ddgi.volume.0.probeVariability.threshold=0.4 ddgi.volume.0.infiniteScrolling.enabled=0 -ddgi.volume.0.textures.rayData.format=3 # EDDGIVolumeTextureFormat::F32x2 -ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 -ddgi.volume.0.textures.distance.format=1 # EDDGIVolumeTextureFormat::F16x2 -ddgi.volume.0.textures.data.format=2 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 +ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.0.origin=-0.4 5.4 -0.25 ddgi.volume.0.probeCounts=22 22 22 ddgi.volume.0.probeSpacing=1.02 0.5 0.45 @@ -84,6 +87,7 @@ ddgi.volume.0.vis.texture.irradianceScale=0.36 ddgi.volume.0.vis.texture.distanceScale=0.18 ddgi.volume.0.vis.texture.probeDataScale=2.88 ddgi.volume.0.vis.texture.rayDataScale=0.247 +ddgi.volume.0.vis.texture.probeVariabilityScale=0.479 # ray traced ambient occlusion rtao.enable=1 diff --git a/samples/test-harness/config/tunnel.ini b/samples/test-harness/config/tunnel.ini index e0b4b5c..dc71638 100644 --- a/samples/test-harness/config/tunnel.ini +++ b/samples/test-harness/config/tunnel.ini @@ -52,11 +52,14 @@ ddgi.volume.0.name=Infinite Scrolling Volume ddgi.volume.0.probeRelocation.enabled=1 ddgi.volume.0.probeRelocation.minFrontfaceDistance=2.2 ddgi.volume.0.probeClassification.enabled=1 +ddgi.volume.0.probeVariability.enabled=1 +ddgi.volume.0.probeVariability.threshold=0.02 ddgi.volume.0.infiniteScrolling.enabled=1 -ddgi.volume.0.textures.rayData.format=4 # EDDGIVolumeTextureFormat::F32x2 -ddgi.volume.0.textures.irradiance.format=4 # EDDGIVolumeTextureFormat::U32 -ddgi.volume.0.textures.distance.format=1 # EDDGIVolumeTextureFormat::F16x2 -ddgi.volume.0.textures.data.format=2 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.rayData.format=6 # EDDGIVolumeTextureFormat::F32x4 +ddgi.volume.0.textures.irradiance.format=6 # EDDGIVolumeTextureFormat::F32x4 +ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.0.origin=128.129 11.62 -13.673 ddgi.volume.0.probeCounts=24 9 12 ddgi.volume.0.probeSpacing=5 2.5 5 @@ -77,6 +80,7 @@ ddgi.volume.0.vis.texture.irradianceScale=0.8 ddgi.volume.0.vis.texture.distanceScale=0.4 ddgi.volume.0.vis.texture.probeDataScale=6.4 ddgi.volume.0.vis.texture.rayDataScale=0.2 +ddgi.volume.0.vis.texture.probeVariabilityScale=1.066 # ray traced ambient occlusion rtao.enable=1 diff --git a/samples/test-harness/config/two-rooms.ini b/samples/test-harness/config/two-rooms.ini index 027d90b..0a8cd52 100644 --- a/samples/test-harness/config/two-rooms.ini +++ b/samples/test-harness/config/two-rooms.ini @@ -66,11 +66,14 @@ ddgi.volume.0.name=Rooms Volume ddgi.volume.0.probeRelocation.enabled=1 ddgi.volume.0.probeRelocation.minFrontfaceDistance=0.1 ddgi.volume.0.probeClassification.enabled=1 +ddgi.volume.0.probeVariability.enabled=1 +ddgi.volume.0.probeVariability.threshold=0.035 ddgi.volume.0.infiniteScrolling.enabled=1 -ddgi.volume.0.textures.rayData.format=3 # EDDGIVolumeTextureFormat::F32x2 -ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 -ddgi.volume.0.textures.distance.format=1 # EDDGIVolumeTextureFormat::F16x2 -ddgi.volume.0.textures.data.format=2 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.rayData.format=5 # EDDGIVolumeTextureFormat::F32x2 +ddgi.volume.0.textures.irradiance.format=0 # EDDGIVolumeTextureFormat::U32 +ddgi.volume.0.textures.distance.format=2 # EDDGIVolumeTextureFormat::F16x2 +ddgi.volume.0.textures.data.format=3 # EDDGIVolumeTextureFormat::F16x4 +ddgi.volume.0.textures.variability.format=1 # EDDGIVolumeTextureFormat::F16 ddgi.volume.0.origin=0.0 24.0 0.0 ddgi.volume.0.probeCounts=32 6 32 ddgi.volume.0.probeSpacing=11 11 11 @@ -91,6 +94,7 @@ ddgi.volume.0.vis.texture.irradianceScale=0.7 ddgi.volume.0.vis.texture.distanceScale=0.35 ddgi.volume.0.vis.texture.probeDataScale=3 ddgi.volume.0.vis.texture.rayDataScale=0.49 +ddgi.volume.0.vis.texture.probeVariabilityScale=0.933 # ray traced ambient occlusion rtao.enable=1 diff --git a/samples/test-harness/include/Benchmark.h b/samples/test-harness/include/Benchmark.h index 3afe495..ea0f254 100644 --- a/samples/test-harness/include/Benchmark.h +++ b/samples/test-harness/include/Benchmark.h @@ -27,5 +27,5 @@ namespace Benchmark std::stringstream gpuTimingCsv; }; void StartBenchmark(BenchmarkRun& benchmarkRun, Instrumentation::Performance& perf, Configs::Config& config, Graphics::Globals& gfx); - void UpdateBenchmark(BenchmarkRun& benchmarkRun, Instrumentation::Performance& perf, Configs::Config& config, Graphics::Globals& gfx, std::ofstream& log); -} \ No newline at end of file + bool UpdateBenchmark(BenchmarkRun& benchmarkRun, Instrumentation::Performance& perf, Configs::Config& config, Graphics::Globals& gfx, std::ofstream& log); +} diff --git a/samples/test-harness/include/Configs.h b/samples/test-harness/include/Configs.h index 0bea16e..84f319a 100644 --- a/samples/test-harness/include/Configs.h +++ b/samples/test-harness/include/Configs.h @@ -28,6 +28,7 @@ namespace Configs rtxgi::EDDGIVolumeTextureFormat irradianceFormat; rtxgi::EDDGIVolumeTextureFormat distanceFormat; rtxgi::EDDGIVolumeTextureFormat dataFormat; + rtxgi::EDDGIVolumeTextureFormat variabilityFormat; }; struct DDGIVolume @@ -41,7 +42,9 @@ namespace Configs bool clearProbes = false; bool probeRelocationEnabled = false; bool probeClassificationEnabled = false; + bool probeVariabilityEnabled = false; bool infiniteScrollingEnabled = false; + bool clearProbeVariability = false; DirectX::XMFLOAT3 origin = { 0.f, 0.f, 0.f }; DirectX::XMFLOAT3 eulerAngles = { 0.f, 0.f, 0.f }; @@ -59,6 +62,7 @@ namespace Configs float probeViewBias = 0.f; float probeIrradianceThreshold = 0.f; float probeBrightnessThreshold = 0.f; + float probeVariabilityThreshold = 0.f; float probeMinFrontfaceDistance = 0.f; @@ -72,6 +76,7 @@ namespace Configs float probeIrradianceScale = 1.f; float probeDistanceScale = 1.f; float probeDataScale = 1.f; + float probeVariabilityScale = 1.f; rtxgi::EDDGIVolumeProbeVisType probeVisType = rtxgi::EDDGIVolumeProbeVisType::Default; }; @@ -84,6 +89,7 @@ namespace Configs bool showTextures = false; bool showIndirect = false; bool insertPerfMarkers = true; + bool shaderExecutionReordering = false; uint32_t selectedVolume = 0; std::vector volumes; }; @@ -138,6 +144,7 @@ namespace Configs { bool enabled = false; bool antialiasing = false; + bool shaderExecutionReordering = false; bool reload = false; float rayNormalBias = 0.001f; float rayViewBias = 0.001f; diff --git a/samples/test-harness/include/Direct3D12.h b/samples/test-harness/include/Direct3D12.h index 86d9774..32b10bf 100644 --- a/samples/test-harness/include/Direct3D12.h +++ b/samples/test-harness/include/Direct3D12.h @@ -89,6 +89,11 @@ namespace Graphics } }; + struct Features + { + UINT waveLaneCount; + }; + struct Globals { IDXGIFactory7* factory = nullptr; @@ -114,6 +119,8 @@ namespace Graphics Shaders::ShaderCompiler shaderCompiler; + Features features = {}; + // For Windowed->Fullscreen->Windowed transitions int x = 0; int y = 0; @@ -128,6 +135,7 @@ namespace Graphics bool fullscreenChanged = false; bool allowTearing = false; + bool supportsShaderExecutionReordering = false; }; struct RenderTargets @@ -179,9 +187,13 @@ namespace Graphics UINT8* materialsSTBPtr = nullptr; // ByteAddress Buffers - ID3D12Resource* materialIndicesRB = nullptr; - ID3D12Resource* materialIndicesRBUpload = nullptr; - UINT8* materialIndicesRBPtr = nullptr; + ID3D12Resource* meshOffsetsRB = nullptr; + ID3D12Resource* meshOffsetsRBUpload = nullptr; + UINT8* meshOffsetsRBPtr = nullptr; + + ID3D12Resource* geometryDataRB = nullptr; + ID3D12Resource* geometryDataRBUpload = nullptr; + UINT8* geometryDataRBPtr = nullptr; // Shared Render Targets RenderTargets rt; @@ -209,8 +221,8 @@ namespace Graphics ID3D12RootSignature* CreateRootSignature(Globals& d3d, const D3D12_ROOT_SIGNATURE_DESC& desc); bool CreateBuffer(Globals& d3d, const BufferDesc& info, ID3D12Resource** ppResource); - bool CreateVertexBuffer(Globals& d3d, const Scenes::MeshPrimitive& mesh, ID3D12Resource** device, ID3D12Resource** upload, D3D12_VERTEX_BUFFER_VIEW& view); - bool CreateIndexBuffer(Globals& d3d, const Scenes::MeshPrimitive& mesh, ID3D12Resource** device, ID3D12Resource** upload, D3D12_INDEX_BUFFER_VIEW& view); + bool CreateVertexBuffer(Globals& d3d, const Scenes::Mesh& mesh, ID3D12Resource** device, ID3D12Resource** upload, D3D12_VERTEX_BUFFER_VIEW& view); + bool CreateIndexBuffer(Globals& d3d, const Scenes::Mesh& mesh, ID3D12Resource** device, ID3D12Resource** upload, D3D12_INDEX_BUFFER_VIEW& view); bool CreateTexture(Globals& d3d, const TextureDesc& info, ID3D12Resource** resource); bool CreateRasterPSO( @@ -270,33 +282,34 @@ namespace Graphics // Texture2DArray UAV const int UAV_TEX2DARRAY_START = UAV_DDGI_OUTPUT + 1; // 16: RWTexture2DArray UAV Start - const int UAV_DDGI_VOLUME_TEX2DARRAY = UAV_TEX2DARRAY_START; // 16: 24 UAV, 4 for each DDGIVolume (RayData, Irradiance, Distance, Probe Data) + const int UAV_DDGI_VOLUME_TEX2DARRAY = UAV_TEX2DARRAY_START; // 16: 36 UAV, 6 for each DDGIVolume (RayData, Irradiance, Distance, Probe Data, Variability, VariabilityAverage) - // Shader Resource Views // 40: SRV Start + // Shader Resource Views // 52: SRV Start const int SRV_START = UAV_DDGI_VOLUME_TEX2DARRAY + (rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors() * MAX_DDGIVOLUMES); // RaytracingAccelerationStructure SRV - const int SRV_TLAS_START = SRV_START; // 40: TLAS SRV Start - const int SRV_SCENE_TLAS = SRV_TLAS_START; // 40: 1 SRV for the Scene TLAS - const int SRV_DDGI_PROBE_VIS_TLAS = SRV_SCENE_TLAS + 1; // 41: 1 SRV for the DDGI Probe Vis TLAS + const int SRV_TLAS_START = SRV_START; // 52: TLAS SRV Start + const int SRV_SCENE_TLAS = SRV_TLAS_START; // 52: 1 SRV for the Scene TLAS + const int SRV_DDGI_PROBE_VIS_TLAS = SRV_SCENE_TLAS + 1; // 53: 1 SRV for the DDGI Probe Vis TLAS // Texture2D SRV - const int SRV_TEX2D_START = SRV_TLAS_START + MAX_TLAS; // 42: Texture2D SRV Start - const int SRV_BLUE_NOISE = SRV_TEX2D_START; // 42: 1 SRV for the Blue Noise Texture - const int SRV_IMGUI_FONTS = SRV_BLUE_NOISE + 1; // 43: 1 SRV for the ImGui Font Texture - const int SRV_SCENE_TEXTURES = SRV_IMGUI_FONTS + 1; // 44: 300 SRV (max), 1 SRV for each Material Texture + const int SRV_TEX2D_START = SRV_TLAS_START + MAX_TLAS; // 54: Texture2D SRV Start + const int SRV_BLUE_NOISE = SRV_TEX2D_START; // 54: 1 SRV for the Blue Noise Texture + const int SRV_IMGUI_FONTS = SRV_BLUE_NOISE + 1; // 55: 1 SRV for the ImGui Font Texture + const int SRV_SCENE_TEXTURES = SRV_IMGUI_FONTS + 1; // 56: 300 SRV (max), 1 SRV for each Material Texture // Texture2DArray SRV - const int SRV_TEX2DARRAY_START = SRV_SCENE_TEXTURES + MAX_TEXTURES; // 344: Texture2DArray SRV Start - const int SRV_DDGI_VOLUME_TEX2DARRAY = SRV_TEX2DARRAY_START; // 344: 24 SRV, 4 for each DDGIVolume (RayData, Irradiance, Distance, Probe Data) + const int SRV_TEX2DARRAY_START = SRV_SCENE_TEXTURES + MAX_TEXTURES; // 356: Texture2DArray SRV Start + const int SRV_DDGI_VOLUME_TEX2DARRAY = SRV_TEX2DARRAY_START; // 356: 36 SRV, 6 for each DDGIVolume (RayData, Irradiance, Distance, Probe Data, Variability, Variability Average) - // ByteAddressBuffer SRV // 368: ByteAddressBuffer SRV Start + // ByteAddressBuffer SRV // 392: ByteAddressBuffer SRV Start const int SRV_BYTEADDRESS_START = SRV_TEX2DARRAY_START + (rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors() * MAX_DDGIVOLUMES); - const int SRV_SPHERE_INDICES = SRV_BYTEADDRESS_START; // 368: 1 SRV for DDGI Probe Vis Sphere Index Buffer - const int SRV_SPHERE_VERTICES = SRV_SPHERE_INDICES + 1; // 369: 1 SRV for DDGI Probe Vis Sphere Vertex Buffer - const int SRV_MATERIAL_INDICES = SRV_SPHERE_VERTICES + 1; // 370: 1 SRV for Mesh Primitive Material Indices - const int SRV_INDICES = SRV_MATERIAL_INDICES + 1; // 371: n SRV for Mesh Primitive Index Buffers - const int SRV_VERTICES = SRV_INDICES + 1; // 372: n SRV for Mesh Primitive Vertex Buffers + const int SRV_SPHERE_INDICES = SRV_BYTEADDRESS_START; // 392: 1 SRV for DDGI Probe Vis Sphere Index Buffer + const int SRV_SPHERE_VERTICES = SRV_SPHERE_INDICES + 1; // 393: 1 SRV for DDGI Probe Vis Sphere Vertex Buffer + const int SRV_MESH_OFFSETS = SRV_SPHERE_VERTICES + 1; // 394: 1 SRV for Mesh Offsets in the Geometry Data Buffer + const int SRV_GEOMETRY_DATA = SRV_MESH_OFFSETS + 1; // 395: 1 SRV for Geometry (Mesh Primitive) Data + const int SRV_INDICES = SRV_GEOMETRY_DATA + 1; // 396: n SRV for Mesh Index Buffers + const int SRV_VERTICES = SRV_INDICES + 1; // 397: n SRV for Mesh Vertex Buffers }; } diff --git a/samples/test-harness/include/Geometry.h b/samples/test-harness/include/Geometry.h index df03638..470aec4 100644 --- a/samples/test-harness/include/Geometry.h +++ b/samples/test-harness/include/Geometry.h @@ -13,6 +13,6 @@ namespace Geometry { - void CreateSphere(uint32_t latitudes, uint32_t longitudes, Scenes::MeshPrimitive& mesh); + void CreateSphere(uint32_t latitudes, uint32_t longitudes, Scenes::Mesh& mesh); } diff --git a/samples/test-harness/include/Scenes.h b/samples/test-harness/include/Scenes.h index ad2df33..4d80735 100644 --- a/samples/test-harness/include/Scenes.h +++ b/samples/test-harness/include/Scenes.h @@ -24,6 +24,8 @@ namespace Scenes int material = -1; bool opaque = true; bool doubleSided = false; + uint32_t vertexByteOffset = 0; + uint32_t indexByteOffset = 0; rtxgi::AABB boundingBox; // not instanced transformed std::vector vertices; std::vector indices; @@ -31,7 +33,10 @@ namespace Scenes struct Mesh { + int index = -1; std::string name = ""; + uint32_t numIndices = 0; + uint32_t numVertices = 0; rtxgi::AABB boundingBox; // not instance transformed std::vector primitives; }; diff --git a/samples/test-harness/include/Vulkan.h b/samples/test-harness/include/Vulkan.h index 9863266..f04c9a2 100644 --- a/samples/test-harness/include/Vulkan.h +++ b/samples/test-harness/include/Vulkan.h @@ -198,6 +198,11 @@ namespace Graphics } }; + struct Features + { + uint32_t waveLaneCount; + }; + struct Globals { VkInstance instance = nullptr; @@ -234,6 +239,8 @@ namespace Graphics Shaders::ShaderCompiler shaderCompiler; + Features features = {}; + // For Windowed->Fullscreen->Windowed transitions int x = 0; int y = 0; @@ -247,12 +254,15 @@ namespace Graphics int fullscreen = 0; bool fullscreenChanged = false; + bool supportsShaderExecutionReordering = false; + VkDebugUtilsMessengerEXT debugUtilsMessenger = nullptr; VkPhysicalDeviceFeatures deviceFeatures = {}; VkPhysicalDeviceProperties2 deviceProps = {}; VkPhysicalDeviceAccelerationStructurePropertiesKHR deviceASProps = {}; VkPhysicalDeviceRayTracingPipelinePropertiesKHR deviceRTPipelineProps = {}; + VkPhysicalDeviceSubgroupProperties deviceSubgroupProps = {}; }; struct RenderTargets @@ -315,11 +325,17 @@ namespace Graphics uint8_t* materialsSTBPtr = nullptr; // ByteAddress Buffers - VkBuffer materialIndicesRB = nullptr; - VkDeviceMemory materialIndicesRBMemory = nullptr; - VkBuffer materialIndicesRBUploadBuffer = nullptr; - VkDeviceMemory materialIndicesRBUploadMemory = nullptr; - uint8_t* materialIndicesRBPtr = nullptr; + VkBuffer meshOffsetsRB = nullptr; + VkDeviceMemory meshOffsetsRBMemory = nullptr; + VkBuffer meshOffsetsRBUploadBuffer = nullptr; + VkDeviceMemory meshOffsetsRBUploadMemory = nullptr; + uint8_t* meshOffsetsRBPtr = nullptr; + + VkBuffer geometryDataRB = nullptr; + VkDeviceMemory geometryDataRBMemory = nullptr; + VkBuffer geometryDataRBUploadBuffer = nullptr; + VkDeviceMemory geometryDataRBUploadMemory = nullptr; + uint8_t* geometryDataRBPtr = nullptr; // Shared Render Targets RenderTargets rt; @@ -363,8 +379,8 @@ namespace Graphics void SetImageLayoutBarrier(VkCommandBuffer cmdBuffer, VkImage image, const ImageBarrierDesc info); bool CreateBuffer(Globals& vk, const BufferDesc& info, VkBuffer* buffer, VkDeviceMemory* memory); - bool CreateIndexBuffer(Globals& vk, const Scenes::MeshPrimitive& primitive, VkBuffer* ib, VkDeviceMemory* ibMemory, VkBuffer* ibUpload, VkDeviceMemory* ibUploadMemory); - bool CreateVertexBuffer(Globals& vk, const Scenes::MeshPrimitive& primitive, VkBuffer* vb, VkDeviceMemory* vbMemory, VkBuffer* vbUpload, VkDeviceMemory* vbUploadMemory); + bool CreateIndexBuffer(Globals& vk, const Scenes::Mesh& mesh, VkBuffer* ib, VkDeviceMemory* ibMemory, VkBuffer* ibUpload, VkDeviceMemory* ibUploadMemory); + bool CreateVertexBuffer(Globals& vk, const Scenes::Mesh& mesh, VkBuffer* vb, VkDeviceMemory* vbMemory, VkBuffer* vbUpload, VkDeviceMemory* vbUploadMemory); bool CreateTexture(Globals& vk, const TextureDesc& info, VkImage* image, VkDeviceMemory* imageMemory, VkImageView* imageView); bool CreateShaderModule(VkDevice device, const Shaders::ShaderProgram& shader, VkShaderModule* module); diff --git a/samples/test-harness/include/graphics/DDGIShaderConfig.h b/samples/test-harness/include/graphics/DDGIShaderConfig.h index 104e365..9650d5a 100644 --- a/samples/test-harness/include/graphics/DDGIShaderConfig.h +++ b/samples/test-harness/include/graphics/DDGIShaderConfig.h @@ -59,6 +59,9 @@ #define RTXGI_PUSH_CONSTS_STRUCT_NAME GlobalConstants #define RTXGI_PUSH_CONSTS_VARIABLE_NAME GlobalConst #define RTXGI_PUSH_CONSTS_FIELD_DDGI_VOLUME_INDEX_NAME ddgi_volumeIndex + #define RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_X_NAME ddgi_reductionInputSizeX + #define RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Y_NAME ddgi_reductionInputSizeY + #define RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Z_NAME ddgi_reductionInputSizeZ #define VOLUME_CONSTS_REGISTER 5 #define VOLUME_CONSTS_SPACE 0 #define VOLUME_RESOURCES_REGISTER 6 @@ -79,6 +82,9 @@ #define OUTPUT_SPACE 0 #define PROBE_DATA_REGISTER 4 #define PROBE_DATA_SPACE 0 + #define PROBE_VARIABILITY_REGISTER 5 + #define PROBE_VARIABILITY_AVERAGE_REGISTER 6 + #define PROBE_VARIABILITY_SPACE 0 #endif #else #define CONSTS_REGISTER b0 @@ -103,6 +109,9 @@ #define OUTPUT_SPACE space1 #define PROBE_DATA_REGISTER u3 #define PROBE_DATA_SPACE space1 + #define PROBE_VARIABILITY_REGISTER u4 + #define PROBE_VARIABILITY_AVERAGE_REGISTER u5 + #define PROBE_VARIABILITY_SPACE space1 #endif #endif #endif diff --git a/samples/test-harness/include/graphics/DDGIVisualizations_D3D12.h b/samples/test-harness/include/graphics/DDGIVisualizations_D3D12.h index 2ce4e02..f141156 100644 --- a/samples/test-harness/include/graphics/DDGIVisualizations_D3D12.h +++ b/samples/test-harness/include/graphics/DDGIVisualizations_D3D12.h @@ -62,7 +62,7 @@ namespace Graphics ID3D12Resource* probeIBUpload = nullptr; D3D12_INDEX_BUFFER_VIEW probeIBView; - Scenes::MeshPrimitive probe; + Scenes::Mesh probe; AccelerationStructure blas; AccelerationStructure tlas; diff --git a/samples/test-harness/include/graphics/DDGIVisualizations_VK.h b/samples/test-harness/include/graphics/DDGIVisualizations_VK.h index 5382c9a..fa5403e 100644 --- a/samples/test-harness/include/graphics/DDGIVisualizations_VK.h +++ b/samples/test-harness/include/graphics/DDGIVisualizations_VK.h @@ -75,7 +75,7 @@ namespace Graphics VkBuffer probeIBUpload = nullptr; VkDeviceMemory probeIBUploadMemory = nullptr; - Scenes::MeshPrimitive probe; + Scenes::Mesh probe; AccelerationStructure blas; AccelerationStructure tlas; diff --git a/samples/test-harness/include/graphics/DDGI_D3D12.h b/samples/test-harness/include/graphics/DDGI_D3D12.h index 82a795f..94199a2 100644 --- a/samples/test-harness/include/graphics/DDGI_D3D12.h +++ b/samples/test-harness/include/graphics/DDGI_D3D12.h @@ -48,6 +48,7 @@ namespace Graphics D3D12_GPU_VIRTUAL_ADDRESS shaderTableHitGroupTableStartAddress = 0; // DDGI + std::vector volumeDescs; std::vector volumes; std::vector selectedVolumes; @@ -61,6 +62,9 @@ namespace Graphics ID3D12Resource* volumeConstantsSTBUpload = nullptr; UINT volumeConstantsSTBSizeInBytes = 0; + // Variability Tracking + std::vector numVolumeVariabilitySamples; + // Performance Stats Instrumentation::Stat* cpuStat = nullptr; Instrumentation::Stat* gpuStat = nullptr; @@ -70,6 +74,7 @@ namespace Graphics Instrumentation::Stat* blendStat = nullptr; Instrumentation::Stat* relocateStat = nullptr; Instrumentation::Stat* lightingStat = nullptr; + Instrumentation::Stat* variabilityStat = nullptr; bool enabled = false; }; diff --git a/samples/test-harness/include/graphics/DDGI_VK.h b/samples/test-harness/include/graphics/DDGI_VK.h index 527cef9..879fb28 100644 --- a/samples/test-harness/include/graphics/DDGI_VK.h +++ b/samples/test-harness/include/graphics/DDGI_VK.h @@ -54,6 +54,7 @@ namespace Graphics VkDeviceAddress shaderTableHitGroupTableStartAddress = 0; // DDGI + std::vector volumeDescs; std::vector volumes; std::vector selectedVolumes; @@ -75,6 +76,9 @@ namespace Graphics VkDeviceMemory volumeConstantsSTBUploadMemory = nullptr; uint64_t volumeConstantsSTBSizeInBytes = 0; + // Variability Tracking + std::vector numVolumeVariabilitySamples; + Instrumentation::Stat* cpuStat = nullptr; Instrumentation::Stat* gpuStat = nullptr; @@ -83,6 +87,7 @@ namespace Graphics Instrumentation::Stat* blendStat = nullptr; Instrumentation::Stat* relocateStat = nullptr; Instrumentation::Stat* lightingStat = nullptr; + Instrumentation::Stat* variabilityStat = nullptr; bool enabled = false; }; diff --git a/samples/test-harness/include/graphics/Types.h b/samples/test-harness/include/graphics/Types.h index c486764..03f6966 100644 --- a/samples/test-harness/include/graphics/Types.h +++ b/samples/test-harness/include/graphics/Types.h @@ -96,6 +96,13 @@ namespace Graphics float2 uv0; }; + struct GeometryData + { + uint materialIndex; + uint indexByteAddress; + uint vertexByteAddress; + }; + struct Camera { float3 position; @@ -183,9 +190,15 @@ namespace Graphics return data; } + // Pack the SER bool into the second-to-last bit of samplesPerPixel + void SetShaderExecutionReordering(bool value) + { + samplesPerPixel |= ((uint)value << 30); + } + + // Pack the AA bool into the last bit of samplesPerPixel void SetAntialiasing(bool value) { - // Pack bool into the last bit of samplesPerPixel samplesPerPixel |= ((uint)value << 31); } #endif @@ -318,12 +331,14 @@ namespace Graphics float irradianceTextureScale; float distanceTextureScale; float probeDataTextureScale; + float probeVariabilityTextureScale; + float probeVariabilityTextureThreshold; #ifndef HLSL - uint32_t data[8]; - static uint32_t GetNum32BitValues() { return 8; } + uint32_t data[10]; + static uint32_t GetNum32BitValues() { return 10; } static uint32_t GetSizeInBytes() { return GetNum32BitValues() * 4; } - static uint32_t GetAlignedNum32BitValues() { return 8; } + static uint32_t GetAlignedNum32BitValues() { return 12; } static uint32_t GetAlignedSizeInBytes() { return GetAlignedNum32BitValues() * 4; } uint32_t* GetData() { @@ -335,6 +350,9 @@ namespace Graphics data[5] = *(uint32_t*)&irradianceTextureScale; data[6] = *(uint32_t*)&distanceTextureScale; data[7] = *(uint32_t*)&probeDataTextureScale; + data[8] = *(uint32_t*)&probeVariabilityTextureScale; + data[9] = *(uint32_t*)&probeVariabilityTextureThreshold; + //data[10/11] = 0; // empty, alignment padding return data; } @@ -350,8 +368,8 @@ namespace Graphics RTAOConsts rtao; // 16 32-bit values, 64 bytes CompositeConsts composite; // 4 32-bit values, 16 bytes PostProcessConsts post; // 4 32-bit values, 16 bytes - DDGIVisConsts ddgivis; // 8 32-bit values, 32 bytes - // 44 32-bit values, 176 bytes + DDGIVisConsts ddgivis; // 12 32-bit values, 48 bytes + // 48 32-bit values, 192 bytes static uint32_t GetNum32BitValues() { @@ -453,11 +471,18 @@ namespace Graphics float ddgivis_irradianceTextureScale; float ddgivis_distanceTextureScale; float ddgivis_probeDataTextureScale; + float ddgivis_probeVariabilityTextureScale; + float ddgivis_probeVariabilityTextureThreshold; + uint2 ddgivis_pad; #ifdef __spirv__ // DDGIRootConstants uint ddgi_volumeIndex; - uint3 ddgi_pad; + uint2 ddgi_pad0; + uint ddgi_reductionInputSizeX; + uint ddgi_reductionInputSizeY; + uint ddgi_reductionInputSizeZ; + uint2 ddgi_pad1; #endif #endif // HLSL }; diff --git a/samples/test-harness/shaders/AHS.hlsl b/samples/test-harness/shaders/AHS.hlsl index d2e2116..5f9d9f6 100644 --- a/samples/test-harness/shaders/AHS.hlsl +++ b/samples/test-harness/shaders/AHS.hlsl @@ -14,18 +14,22 @@ [shader("anyhit")] void AHS_LOD0(inout PackedPayload packedPayload, BuiltInTriangleIntersectionAttributes attrib) { + // Load the intersected mesh geometry's data + GeometryData geometry; + GetGeometryData(InstanceID(), GeometryIndex(), geometry); + // Load the material - Material material = GetMaterial(GetMaterialIndex(InstanceID())); + Material material = GetMaterial(geometry); float alpha = material.opacity; if (material.alphaMode == 2) { // Load and interpolate the triangle's texture coordinates float3 barycentrics = float3((1.f - attrib.barycentrics.x - attrib.barycentrics.y), attrib.barycentrics.x, attrib.barycentrics.y); - float2 uv0 = LoadAndInterpolateUV0(InstanceID(), PrimitiveIndex(), barycentrics); + float2 uv0 = LoadAndInterpolateUV0(InstanceID(), PrimitiveIndex(), geometry, barycentrics); if (material.albedoTexIdx > -1) { - alpha = GetTex2D(material.albedoTexIdx).SampleLevel(GetBilinearWrapSampler(), uv0, 0).a; + alpha *= GetTex2D(material.albedoTexIdx).SampleLevel(GetBilinearWrapSampler(), uv0, 0).a; } } @@ -35,15 +39,19 @@ void AHS_LOD0(inout PackedPayload packedPayload, BuiltInTriangleIntersectionAttr [shader("anyhit")] void AHS_PRIMARY(inout PackedPayload payload, BuiltInTriangleIntersectionAttributes attrib) { + // Load the intersected mesh geometry's data + GeometryData geometry; + GetGeometryData(InstanceID(), GeometryIndex(), geometry); + // Load the material - Material material = GetMaterial(GetMaterialIndex(InstanceID())); + Material material = GetMaterial(geometry); float alpha = material.opacity; if (material.alphaMode == 2) { // Load the vertices Vertex vertices[3]; - LoadVerticesPosUV0(InstanceID(), PrimitiveIndex(), vertices); + LoadVerticesPosUV0(InstanceID(), PrimitiveIndex(), geometry, vertices); // Compute texture coordinate differentials float2 dUVdx, dUVdy; @@ -60,7 +68,7 @@ void AHS_PRIMARY(inout PackedPayload payload, BuiltInTriangleIntersectionAttribu // Sample the texture if (material.albedoTexIdx > -1) { - alpha = GetTex2D(material.albedoTexIdx).SampleGrad(GetAnisoWrapSampler(), v.uv0, dUVdx, dUVdy).a; + alpha *= GetTex2D(material.albedoTexIdx).SampleGrad(GetAnisoWrapSampler(), v.uv0, dUVdx, dUVdy).a; } } @@ -70,15 +78,19 @@ void AHS_PRIMARY(inout PackedPayload payload, BuiltInTriangleIntersectionAttribu [shader("anyhit")] void AHS_GI(inout PackedPayload payload, BuiltInTriangleIntersectionAttributes attrib) { + // Load the intersected mesh geometry's data + GeometryData geometry; + GetGeometryData(InstanceID(), GeometryIndex(), geometry); + // Load the surface material - Material material = GetMaterial(GetMaterialIndex(InstanceID())); + Material material = GetMaterial(geometry); float alpha = material.opacity; if (material.alphaMode == 2) { // Load the vertices Vertex vertices[3]; - LoadVerticesPosUV0(InstanceID(), PrimitiveIndex(), vertices); + LoadVerticesPosUV0(InstanceID(), PrimitiveIndex(), geometry, vertices); // Interpolate the triangle's texture coordinates float3 barycentrics = float3((1.f - attrib.barycentrics.x - attrib.barycentrics.y), attrib.barycentrics.x, attrib.barycentrics.y); @@ -92,7 +104,7 @@ void AHS_GI(inout PackedPayload payload, BuiltInTriangleIntersectionAttributes a GetTex2D(material.albedoTexIdx).GetDimensions(0, width, height, numLevels); // Sample the texture - alpha = GetTex2D(material.albedoTexIdx).SampleLevel(GetBilinearWrapSampler(), v.uv0, numLevels * 0.6667f).a; + alpha *= GetTex2D(material.albedoTexIdx).SampleLevel(GetBilinearWrapSampler(), v.uv0, numLevels * 0.6667f).a; } } diff --git a/samples/test-harness/shaders/CHS.hlsl b/samples/test-harness/shaders/CHS.hlsl index 0557fd8..b01faba 100644 --- a/samples/test-harness/shaders/CHS.hlsl +++ b/samples/test-harness/shaders/CHS.hlsl @@ -18,9 +18,13 @@ void CHS_LOD0(inout PackedPayload packedPayload, BuiltInTriangleIntersectionAttr payload.hitT = RayTCurrent(); payload.hitKind = HitKind(); + // Load the intersected mesh geometry's data + GeometryData geometry; + GetGeometryData(InstanceID(), GeometryIndex(), geometry); + // Load the triangle's vertices Vertex vertices[3]; - LoadVertices(InstanceID(), PrimitiveIndex(), vertices); + LoadVertices(InstanceID(), PrimitiveIndex(), geometry, vertices); // Interpolate the triangle's attributes for the hit location (position, normal, tangent, texture coordinates) float3 barycentrics = float3((1.f - attrib.barycentrics.x - attrib.barycentrics.y), attrib.barycentrics.x, attrib.barycentrics.y); @@ -36,15 +40,16 @@ void CHS_LOD0(inout PackedPayload packedPayload, BuiltInTriangleIntersectionAttr payload.shadingNormal = payload.normal; // Load the surface material - Material material = GetMaterial(GetMaterialIndex(InstanceID())); + Material material = GetMaterial(geometry); payload.albedo = material.albedo; + payload.opacity = material.opacity; // Albedo and Opacity if (material.albedoTexIdx > -1) { float4 bco = GetTex2D(material.albedoTexIdx).SampleLevel(GetBilinearWrapSampler(), v.uv0, 0); - payload.albedo = bco.rgb; - payload.opacity = bco.a; + payload.albedo *= bco.rgb; + payload.opacity *= bco.a; } // Shading normal @@ -83,9 +88,13 @@ void CHS_PRIMARY(inout PackedPayload packedPayload, BuiltInTriangleIntersectionA payload.hitT = RayTCurrent(); payload.hitKind = HitKind(); + // Load the intersected mesh geometry's data + GeometryData geometry; + GetGeometryData(InstanceID(), GeometryIndex(), geometry); + // Load the triangle's vertices Vertex vertices[3]; - LoadVertices(InstanceID(), PrimitiveIndex(), vertices); + LoadVertices(InstanceID(), PrimitiveIndex(), geometry, vertices); // Interpolate the triangle's attributes for the hit location (position, normal, tangent, texture coordinates) float3 barycentrics = float3((1.f - attrib.barycentrics.x - attrib.barycentrics.y), attrib.barycentrics.x, attrib.barycentrics.y); @@ -101,8 +110,9 @@ void CHS_PRIMARY(inout PackedPayload packedPayload, BuiltInTriangleIntersectionA payload.shadingNormal = payload.normal; // Load the surface material - Material material = GetMaterial(GetMaterialIndex(InstanceID())); + Material material = GetMaterial(geometry); payload.albedo = material.albedo; + payload.opacity = material.opacity; // Compute texture coordinate differentials float2 dUVdx, dUVdy; @@ -116,8 +126,8 @@ void CHS_PRIMARY(inout PackedPayload packedPayload, BuiltInTriangleIntersectionA if (material.albedoTexIdx > -1) { float4 bco = GetTex2D(material.albedoTexIdx).SampleGrad(GetAnisoWrapSampler(), v.uv0, dUVdx, dUVdy); - payload.albedo = bco.rgb; - payload.opacity = bco.a; + payload.albedo *= bco.rgb; + payload.opacity *= bco.a; } // Shading normal @@ -157,9 +167,13 @@ void CHS_GI(inout PackedPayload packedPayload, BuiltInTriangleIntersectionAttrib payload.hitT = RayTCurrent(); payload.hitKind = HitKind(); + // Load the intersected mesh geometry's data + GeometryData geometry; + GetGeometryData(InstanceID(), GeometryIndex(), geometry); + // Load the triangle's vertices Vertex vertices[3]; - LoadVertices(InstanceID(), PrimitiveIndex(), vertices); + LoadVertices(InstanceID(), PrimitiveIndex(), geometry, vertices); // Interpolate the triangle's attributes for the hit location (position, normal, tangent, texture coordinates) float3 barycentrics = float3((1.f - attrib.barycentrics.x - attrib.barycentrics.y), attrib.barycentrics.x, attrib.barycentrics.y); @@ -175,8 +189,9 @@ void CHS_GI(inout PackedPayload packedPayload, BuiltInTriangleIntersectionAttrib payload.shadingNormal = payload.normal; // Load the surface material - Material material = GetMaterial(GetMaterialIndex(InstanceID())); + Material material = GetMaterial(geometry); payload.albedo = material.albedo; + payload.opacity = material.opacity; // Albedo and Opacity if (material.albedoTexIdx > -1) @@ -187,8 +202,23 @@ void CHS_GI(inout PackedPayload packedPayload, BuiltInTriangleIntersectionAttrib // Sample the albedo texture float4 bco = GetTex2D(material.albedoTexIdx).SampleLevel(GetBilinearWrapSampler(), v.uv0, numLevels / 2.f); - payload.albedo = bco.rgb; - payload.opacity = bco.a; + payload.albedo *= bco.rgb; + payload.opacity *= bco.a; + } + + // Shading normal + if (material.normalTexIdx > -1) + { + // Get the number of mip levels + uint width, height, numLevels; + GetTex2D(material.normalTexIdx).GetDimensions(0, width, height, numLevels); + + float3 tangent = normalize(mul(ObjectToWorld3x4(), float4(v.tangent.xyz, 0.f)).xyz); + float3 bitangent = cross(payload.normal, tangent) * v.tangent.w; + float3x3 TBN = { tangent, bitangent, payload.normal }; + payload.shadingNormal = GetTex2D(material.normalTexIdx).SampleLevel(GetBilinearWrapSampler(), v.uv0, numLevels / 2.f).xyz; + payload.shadingNormal = (payload.shadingNormal * 2.f) - 1.f; // Transform to [-1, 1] + payload.shadingNormal = mul(payload.shadingNormal, TBN); // Transform tangent-space normal to world-space } // Pack the payload diff --git a/samples/test-harness/shaders/GBufferRGS.hlsl b/samples/test-harness/shaders/GBufferRGS.hlsl index 0b46a75..3f338ca 100644 --- a/samples/test-harness/shaders/GBufferRGS.hlsl +++ b/samples/test-harness/shaders/GBufferRGS.hlsl @@ -56,7 +56,7 @@ void RayGen() RAY_FLAG_CULL_BACK_FACING_TRIANGLES, 0xFF, 0, - 1, + 0, 0, ray, packedPayload); diff --git a/samples/test-harness/shaders/PathTraceRGS.hlsl b/samples/test-harness/shaders/PathTraceRGS.hlsl index 2acfdd6..0ec2cb7 100644 --- a/samples/test-harness/shaders/PathTraceRGS.hlsl +++ b/samples/test-harness/shaders/PathTraceRGS.hlsl @@ -30,15 +30,47 @@ float3 TracePath(RayDesc ray, uint seed) { // Trace the ray PackedPayload packedPayload = (PackedPayload)0; + + #if GFX_NVAPI + if (GetPTShaderExecutionReordering()) + { + NvHitObject hit; + NvTraceRayHitObject( + SceneTLAS, + RAY_FLAG_CULL_BACK_FACING_TRIANGLES, + 0xFF, + 0, + 0, + 0, + ray, + packedPayload, + hit); + NvReorderThread(hit, 0, 0); + NvInvokeHitObject(SceneTLAS, hit, packedPayload); + } + else + { + TraceRay( + SceneTLAS, + RAY_FLAG_CULL_BACK_FACING_TRIANGLES, + 0xFF, + 0, + 0, + 0, + ray, + packedPayload); + } + #else TraceRay( SceneTLAS, RAY_FLAG_CULL_BACK_FACING_TRIANGLES, 0xFF, 0, - 1, + 0, 0, ray, packedPayload); + #endif // Unpack the payload Payload payload = UnpackPayload(packedPayload); diff --git a/samples/test-harness/shaders/ProbeTraceRGS.hlsl b/samples/test-harness/shaders/ProbeTraceRGS.hlsl deleted file mode 100644 index 55730e1..0000000 --- a/samples/test-harness/shaders/ProbeTraceRGS.hlsl +++ /dev/null @@ -1,216 +0,0 @@ -/* -* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved. -* -* NVIDIA CORPORATION and its licensors retain all intellectual property -* and proprietary rights in and to this software, related documentation -* and any modifications thereto. Any use, reproduction, disclosure or -* distribution of this software and related documentation without an express -* license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -// -------- FEATURE DEFINES ----------------------------------------------------------------------- - -// RTXGI_DDGI_PROBE_RELOCATION must be passed in as a define at shader compilation time. -// This define specifies if probe relocation is enabled or disabled. -// Ex: RTXGI_DDGI_PROBE_RELOCATION [0|1] -#ifndef RTXGI_DDGI_PROBE_RELOCATION -#error Required define RTXGI_DDGI_PROBE_RELOCATION is not defined for ProbeTraceRGS.hlsl! -#endif - -// RTXGI_DDGI_PROBE_CLASSIFICATION must be passed in as a define at shader compilation time. -// This define specifies if probe classification is enabled or disabled. -// Ex: RTXGI_DDGI_PROBE_CLASSIFICATION [0|1] -#ifndef RTXGI_DDGI_PROBE_CLASSIFICATION -#error Required define RTXGI_DDGI_PROBE_CLASSIFICATION is not defined for ProbeTraceRGS.hlsl! -#endif - -// RTXGI_DDGI_VOLUME_INFINITE_SCROLLING must be passed in as a define at shader compilation time. -// This define specifies if infinite scrolling volume functionality is enabled or disabled. -// Ex: RTXGI_DDGI_VOLUME_INFINITE_SCROLLING [0|1] -#ifndef RTXGI_DDGI_VOLUME_INFINITE_SCROLLING -#error Required define RTXGI_DDGI_VOLUME_INFINITE_SCROLLING is not defined for ProbeTraceRGS.hlsl! -#endif - -// -------- CONFIGURATION DEFINES ----------------------------------------------------------------- - -// RTXGI_DDGI_FORMAT_PROBE_RAY_DATA must be passed in as a define at shader compilation time. -// This define specifies the format of the probe ray data texture. -// Ex: RTXGI_DDGI_FORMAT_PROBE_RAY_DATA 0 => R32G32_FLOAT -// Ex: RTXGI_DDGI_FORMAT_PROBE_RAY_DATA 1 => R32G32B32A32_FLOAT -#ifndef RTXGI_DDGI_FORMAT_PROBE_RAY_DATA -#error Required define RTXGI_DDGI_FORMAT_PROBE_RAY_DATA is not defined for ProbeTraceRGS.hlsl! -#endif - -// ------------------------------------------------------------------------------------------- - -#include "../../../rtxgi-sdk/shaders/ddgi/Irradiance.hlsl" - -#include "include/Descriptors.hlsl" -#include "include/Lighting.hlsl" -#include "include/RayTracing.hlsl" - -// ---[ Ray Generation Shader ]--- - -[shader("raygeneration")] -void RayGen() -{ - float4 result = 0.f; - - uint2 DispatchIndex = DispatchRaysIndex().xy; - int rayIndex = DispatchIndex.x; // index of the current probe ray - int probeIndex = DispatchIndex.y; // index of current probe - - // Get the DDGIVolume's constants - DDGIVolumeDescGPU DDGIVolume = UnpackDDGIVolumeDescGPU(DDGIVolumes[DDGI.volumeIndex]); - -#if RTXGI_DDGI_PROBE_RELOCATION || RTXGI_DDGI_PROBE_CLASSIFICATION - Texture2D ProbeData = GetDDGIVolumeProbeDataSRV(DDGI.volumeIndex); -#endif - -#if RTXGI_DDGI_PROBE_CLASSIFICATION - #if RTXGI_DDGI_VOLUME_INFINITE_SCROLLING - int storageProbeIndex = DDGIGetProbeIndexOffset(probeIndex, DDGIVolume.probeCounts, DDGIVolume.probeScrollOffsets); - #else - int storageProbeIndex = probeIndex; - #endif - - int2 texelPosition = DDGIGetProbeTexelPosition(storageProbeIndex, DDGIVolume.probeCounts); - float probeState = ProbeData.Load(int3(texelPosition, 0)).w; - if (probeState == RTXGI_DDGI_PROBE_STATE_INACTIVE && rayIndex >= RTXGI_DDGI_NUM_FIXED_RAYS) - { - // Do not shoot rays when the probe is inactive *unless* it is one of the "fixed" rays used by probe classification - return; - } -#endif - -#if RTXGI_DDGI_PROBE_RELOCATION - #if RTXGI_DDGI_VOLUME_INFINITE_SCROLLING - float3 probeWorldPosition = DDGIGetProbeWorldPositionWithOffset(probeIndex, DDGIVolume.origin, DDGIVolume.probeCounts, DDGIVolume.probeSpacing, DDGIVolume.probeScrollOffsets, ProbeData); - #else - float3 probeWorldPosition = DDGIGetProbeWorldPositionWithOffset(probeIndex, DDGIVolume.origin, DDGIVolume.probeCounts, DDGIVolume.probeSpacing, ProbeData); - #endif -#else - float3 probeWorldPosition = DDGIGetProbeWorldPosition(probeIndex, DDGIVolume.origin, DDGIVolume.probeCounts, DDGIVolume.probeSpacing); -#endif - - float3 probeRayDirection = DDGIGetProbeRayDirection(rayIndex, DDGIVolume.probeNumRays, DDGIVolume.probeRayRotation); - - // Setup the probe ray - RayDesc ray; - ray.Origin = probeWorldPosition; - ray.Direction = probeRayDirection; - ray.TMin = 0.f; - ray.TMax = DDGIVolume.probeMaxRayDistance; - - // Trace the Probe Ray - PackedPayload packedPayload = (PackedPayload)0; - -#if RTXGI_DDGI_PROBE_CLASSIFICATION - // Pass the probe's state flag to hit shaders through the payload - packedPayload.packed0.x = probeState; -#endif - - TraceRay( - SceneBVH, - RAY_FLAG_NONE, - 0xFF, - 0, - 1, - 0, - ray, - packedPayload); - - // Get a reference to the ray data texture - RWTexture2D RayData = GetDDGIVolumeRayDataUAV(DDGI.volumeIndex); - - // The ray missed. Set hit distance to a large value and exit early. - if (packedPayload.hitT < 0.f) - { - #if (RTXGI_DDGI_FORMAT_PROBE_RAY_DATA == 1) - RayData[DispatchIndex.xy] = float4(GetGlobalConst(app, skyRadiance), 1e27f); - #else // RTXGI_DDGI_FORMAT_PROBE_RAY_DATA == 0 - RayData[DispatchIndex.xy] = float4(asfloat(RTXGIFloat3ToUint(GetGlobalConst(app, skyRadiance))), 1e27f, 0.f, 0.f); - #endif - return; - } - - // Unpack the payload - Payload payload = UnpackPayload(packedPayload); - - // Hit a surface backface. - if (payload.hitKind == HIT_KIND_TRIANGLE_BACK_FACE) - { - // Make hit distance negative to mark a backface hit for blending, probe relocation, and probe classification. - // Shorten the hit distance on a backface hit by 80% to decrease the influence of the probe during irradiance sampling. - #if (RTXGI_DDGI_FORMAT_PROBE_RAY_DATA == 1) - RayData[DispatchIndex.xy].w = -payload.hitT * 0.2f; - #else // RTXGI_DDGI_FORMAT_PROBE_RAY_DATA == 0 - RayData[DispatchIndex.xy].g = -payload.hitT * 0.2f; - #endif - return; - } - -#if RTXGI_DDGI_PROBE_CLASSIFICATION - if (probeState == RTXGI_DDGI_PROBE_STATE_INACTIVE) - { - // Hit a front face, but the probe is inactive. This ray is only used for classification, so don't need to do lighting. - #if (RTXGI_DDGI_FORMAT_PROBE_RAY_DATA == 1) - RayData[DispatchIndex.xy].w = payload.hitT; - #else // RTXGI_DDGI_FORMAT_PROBE_RAY_DATA == 0 - RayData[DispatchIndex.xy].g = payload.hitT; - #endif - return; - } -#endif - - // Direct Lighting and Shadowing - float3 diffuse = DirectDiffuseLighting(payload, GetGlobalConst(pt, rayNormalBias), GetGlobalConst(pt, rayViewBias), SceneBVH); - - // Indirect Lighting (recursive) - float3 irradiance = 0.f; - float3 surfaceBias = DDGIGetSurfaceBias(payload.normal, ray.Direction, DDGIVolume); - - DDGIVolumeResources resources; - resources.probeIrradiance = GetDDGIVolumeIrradianceSRV(DDGI.volumeIndex); - resources.probeDistance = GetDDGIVolumeDistanceSRV(DDGI.volumeIndex); -#if RTXGI_DDGI_PROBE_RELOCATION || RTXGI_DDGI_PROBE_CLASSIFICATION - resources.probeData = ProbeData; -#endif - resources.bilinearSampler = GetBilinearWrapSampler(); - - // Compute volume blending weight - float volumeBlendWeight = DDGIGetVolumeBlendWeight(payload.worldPosition, DDGIVolume); - - // Avoid evaluating irradiance when the surface is outside the volume - if (volumeBlendWeight > 0) - { - // Get irradiance from the DDGIVolume - irradiance = DDGIGetVolumeIrradiance( - payload.worldPosition, - surfaceBias, - payload.normal, - DDGIVolume, - resources); - - // Attenuate irradiance by the blend weight - irradiance *= volumeBlendWeight; - } - - // Perfectly diffuse reflectors don't exist in the real world. Limit the BRDF - // albedo to a maximum value to account for the energy loss at each bounce. - float maxAlbedo = 0.9f; - - // Compute final color - result = float4(diffuse + ((min(payload.albedo, maxAlbedo) / PI) * irradiance), payload.hitT); - -#if (RTXGI_DDGI_FORMAT_PROBE_RAY_DATA == 1) - // Use R32G32B32A32_FLOAT format. Store color components and hit distance as 32-bit float values. - RayData[DispatchIndex.xy] = result; -#else // RTXGI_DDGI_FORMAT_PROBE_RAY_DATA == 0 - // Use R32G32_FLOAT format (don't use R32G32_UINT since hit distance needs to be negative sometimes). - // Pack color as R10G10B10 in R32 and store hit distance in G32. - static const float c_threshold = 1.f / 255.f; - if (RTXGIMaxComponent(result.rgb) <= c_threshold) result.rgb = float3(0.f, 0.f, 0.f); - RayData[DispatchIndex.xy] = float4(asfloat(RTXGIFloat3ToUint(result.rgb)), payload.hitT, 0.f, 0.f); -#endif -} diff --git a/samples/test-harness/shaders/RTAOTraceRGS.hlsl b/samples/test-harness/shaders/RTAOTraceRGS.hlsl index a65482c..e351f4a 100644 --- a/samples/test-harness/shaders/RTAOTraceRGS.hlsl +++ b/samples/test-harness/shaders/RTAOTraceRGS.hlsl @@ -59,7 +59,7 @@ float GetOcclusion(int2 screenPos, float3 worldPos, float3 normal) RAY_FLAG_CULL_BACK_FACING_TRIANGLES, 0xFF, 0, - 1, + 0, 0, ray, packedPayload); diff --git a/samples/test-harness/shaders/ddgi/ProbeTraceRGS.hlsl b/samples/test-harness/shaders/ddgi/ProbeTraceRGS.hlsl index f7f50c3..9088675 100644 --- a/samples/test-harness/shaders/ddgi/ProbeTraceRGS.hlsl +++ b/samples/test-harness/shaders/ddgi/ProbeTraceRGS.hlsl @@ -83,16 +83,47 @@ void RayGen() // Get the acceleration structure RaytracingAccelerationStructure SceneTLAS = GetAccelerationStructure(SCENE_TLAS_INDEX); +#if GFX_NVAPI + if (GetPTShaderExecutionReordering()) + { + NvHitObject hit; + NvTraceRayHitObject( + SceneTLAS, + RAY_FLAG_CULL_BACK_FACING_TRIANGLES, + 0xFF, + 0, + 0, + 0, + ray, + packedPayload, + hit); + NvReorderThread(hit, 0, 0); + NvInvokeHitObject(SceneTLAS, hit, packedPayload); + } + else + { + TraceRay( + SceneTLAS, + RAY_FLAG_CULL_BACK_FACING_TRIANGLES, + 0xFF, + 0, + 0, + 0, + ray, + packedPayload); + } +#else // Trace the Probe Ray TraceRay( SceneTLAS, RAY_FLAG_NONE, 0xFF, 0, - 1, + 0, 0, ray, packedPayload); +#endif // Get the ray data texture array RWTexture2DArray RayData = GetRWTex2DArray(resourceIndices.rayDataUAVIndex); diff --git a/samples/test-harness/shaders/ddgi/visualizations/VolumeTexturesCS.hlsl b/samples/test-harness/shaders/ddgi/visualizations/VolumeTexturesCS.hlsl index e22ca7d..059feb0 100644 --- a/samples/test-harness/shaders/ddgi/visualizations/VolumeTexturesCS.hlsl +++ b/samples/test-harness/shaders/ddgi/visualizations/VolumeTexturesCS.hlsl @@ -53,6 +53,8 @@ void CS(uint3 DispatchThreadID : SV_DispatchThreadID) Texture2DArray ProbeIrradiance = GetTex2DArray(resourceIndices.probeIrradianceSRVIndex); Texture2DArray ProbeDistance = GetTex2DArray(resourceIndices.probeDistanceSRVIndex); Texture2DArray ProbeData = GetTex2DArray(resourceIndices.probeDataSRVIndex); + Texture2DArray ProbeVariability = GetTex2DArray(resourceIndices.probeVariabilitySRVIndex); + Texture2DArray ProbeVariabilityAverage = GetTex2DArray(resourceIndices.probeVariabilityAverageSRVIndex); // Load and unpack the DDGIVolume's constants DDGIVolumeDescGPU volume = UnpackDDGIVolumeDescGPU(DDGIVolumes[volumeIndex]); @@ -83,7 +85,7 @@ void CS(uint3 DispatchThreadID : SV_DispatchThreadID) if(DispatchThreadID.x < irradianceRect.x && DispatchThreadID.y < irradianceRect.y) { // Compute the sampling coordinates - uint2 numScaledTexelsPerSlice = numTexelsPerSlice * irradianceScale; + uint2 numScaledTexelsPerSlice = numTexelsPerSlice * irradianceScale; float2 sliceUV = (float2(0.5f, 0.5f) + float2(DispatchThreadID.xy % numScaledTexelsPerSlice)) / float2(numScaledTexelsPerSlice); float sliceIndex = float(DispatchThreadID.x / numScaledTexelsPerSlice.x); float3 coords = float3(sliceUV, sliceIndex); @@ -126,7 +128,7 @@ void CS(uint3 DispatchThreadID : SV_DispatchThreadID) if (DispatchThreadID.x < xmax && DispatchThreadID.y >= ymin && DispatchThreadID.y < ymax) { // Compute the sampling coordinates - uint2 numScaledTexelsPerSlice = numTexelsPerSlice * distanceScale; + uint2 numScaledTexelsPerSlice = numTexelsPerSlice * distanceScale; float2 sliceUV = (float2(0.5f, 0.5f) + float2(uint2(DispatchThreadID.x, DispatchThreadID.y - ymin) % numScaledTexelsPerSlice)) / float2(numScaledTexelsPerSlice); float sliceIndex = float(DispatchThreadID.x / numScaledTexelsPerSlice.x); float3 coords = float3(sliceUV, sliceIndex); @@ -142,12 +144,79 @@ void CS(uint3 DispatchThreadID : SV_DispatchThreadID) return; } + // Variability + float variabilityScale = GetGlobalConst(ddgivis, probeVariabilityTextureScale); + numTexelsPerSlice = numProbesPerSlice * volume.probeNumIrradianceInteriorTexels; + uint2 variabilityRect = uint2(numTexelsPerSlice.x * numSlices, numTexelsPerSlice.y) * variabilityScale; + xmax = variabilityRect.x; + ymin += distanceRect.y + 5; + ymax = (ymin + variabilityRect.y); + if (DispatchThreadID.x < xmax.x && DispatchThreadID.y >= ymin && DispatchThreadID.y < ymax) + { + // Compute the sampling coordinates + uint2 numScaledTexelsPerSlice = numTexelsPerSlice * variabilityScale; + float2 sliceUV = (float2(0.5f, 0.5f) + float2(uint2(DispatchThreadID.x, DispatchThreadID.y - ymin) % numScaledTexelsPerSlice)) / float2(numScaledTexelsPerSlice); + float sliceIndex = float(DispatchThreadID.x / numScaledTexelsPerSlice.x); + float3 coords = float3(sliceUV, sliceIndex); + + // Sample the variability texture + float diff = ProbeVariability.SampleLevel(GetPointClampSampler(), coords, 0).r; + + // Sample the probe data texture + bool active = true; + if (volume.probeClassificationEnabled) + { + // Sample the probe data texture + uint state = ProbeData.SampleLevel(GetPointClampSampler(), coords, 0).a; + active = (state == RTXGI_DDGI_PROBE_STATE_ACTIVE); + } + + // Disabled = blue, above threshold = green, below = red, nan = yellow + if (!active) color = float3(0.f, 0.f, 1.f); + else if (isnan(diff)) color = float3(1.f, 1.f, 0.f); + else if (diff > GetGlobalConst(ddgivis, probeVariabilityTextureThreshold)) color = float3(0.f, 1.0, 0.f); + else color = float3(1.f, 0.f, 0.f); + + // Overwrite GBufferA's albedo and mark the pixel to not be lit + GBufferA[DispatchThreadID.xy] = float4(color, 0.f); + + return; + } + + // Variability average + // 1/4 number of slices (rounded up) after reduction + uint2 variabilityAvgRect = uint2(numTexelsPerSlice.x * ((numSlices + 3)/4), numTexelsPerSlice.y) * variabilityScale; + xmax = variabilityAvgRect.x; + ymin += variabilityRect.y + 5; + ymax = (ymin + variabilityAvgRect.y); + if (DispatchThreadID.x < xmax.x && DispatchThreadID.y >= ymin && DispatchThreadID.y < ymax) + { + // Compute the sampling coordinates + uint2 numScaledTexelsPerSlice = numTexelsPerSlice * variabilityScale; + float2 sliceUV = (float2(0.5f, 0.5f) + float2(uint2(DispatchThreadID.x, DispatchThreadID.y - ymin) % numScaledTexelsPerSlice)) / float2(numScaledTexelsPerSlice); + float sliceIndex = float(DispatchThreadID.x / numScaledTexelsPerSlice.x); + float3 coords = float3(sliceUV, sliceIndex); + + // Sample the variability average texture + float diff = ProbeVariabilityAverage.SampleLevel(GetPointClampSampler(), coords, 0).r; + + // Above threshold = green, below = red, nan = yellow + if (isnan(diff)) color = float3(1.f, 1.f, 0.f); + else if (diff > GetGlobalConst(ddgivis, probeVariabilityTextureThreshold)) color = float3(0.f, 1.f, 0.f); + else color = float3(1.f, 0.f, 0.f); + + // Overwrite GBufferA's albedo and mark the pixel to not be lit + GBufferA[DispatchThreadID.xy] = float4(color, 0.f); + + return; + } + // Get the texture scale factor for probe data float probeDataScale = GetGlobalConst(ddgivis, probeDataTextureScale); // Relocation Offsets uint2 offsetRect = 0; - ymin += distanceRect.y + 5; + ymin += variabilityAvgRect.y + 5; if (volume.probeRelocationEnabled) { offsetRect = uint2(numProbesPerSlice.x * numSlices, numProbesPerSlice.y) * probeDataScale; @@ -157,7 +226,7 @@ void CS(uint3 DispatchThreadID : SV_DispatchThreadID) if (DispatchThreadID.x < xmax && DispatchThreadID.y >= ymin && DispatchThreadID.y < ymax) { // Compute the sampling coordinates - uint2 numScaledTexelsPerSlice = numProbesPerSlice * probeDataScale; + uint2 numScaledTexelsPerSlice = numProbesPerSlice * probeDataScale; float2 sliceUV = (float2(0.5f, 0.5f) + float2(uint2(DispatchThreadID.x, DispatchThreadID.y - ymin) % numScaledTexelsPerSlice)) / float2(numScaledTexelsPerSlice); float sliceIndex = float(DispatchThreadID.x / numScaledTexelsPerSlice.x); float3 coords = float3(sliceUV, sliceIndex); @@ -184,7 +253,7 @@ void CS(uint3 DispatchThreadID : SV_DispatchThreadID) if (DispatchThreadID.x < xmax && DispatchThreadID.y >= ymin && DispatchThreadID.y < ymax) { // Compute the sampling coordinates - uint2 numScaledTexelsPerSlice = numProbesPerSlice * probeDataScale; + uint2 numScaledTexelsPerSlice = numProbesPerSlice * probeDataScale; float2 sliceUV = (float2(0.5f, 0.5f) + float2(uint2(DispatchThreadID.x, DispatchThreadID.y - ymin) % numScaledTexelsPerSlice)) / float2(numScaledTexelsPerSlice); float sliceIndex = float(DispatchThreadID.x / numScaledTexelsPerSlice.x); float3 coords = float3(sliceUV, sliceIndex); @@ -212,8 +281,7 @@ void CS(uint3 DispatchThreadID : SV_DispatchThreadID) if (DispatchThreadID.x <= xmax && DispatchThreadID.y > ymin && DispatchThreadID.y <= ymax) { // Compute the sampling coordinates - uint2 numScaledTexelsPerSlice = numTexelsPerSlice * rayDataScale; - + uint2 numScaledTexelsPerSlice = numTexelsPerSlice * rayDataScale; float2 sliceUV = (float2(0.5f, 0.5f) + float2(uint2(DispatchThreadID.x, DispatchThreadID.y - ymin) % numScaledTexelsPerSlice)) / float2(numScaledTexelsPerSlice); float sliceIndex = float(DispatchThreadID.x / numScaledTexelsPerSlice.x); float3 coords = float3(sliceUV, sliceIndex); diff --git a/samples/test-harness/shaders/include/Descriptors.hlsl b/samples/test-harness/shaders/include/Descriptors.hlsl index 424474e..f1156e4 100644 --- a/samples/test-harness/shaders/include/Descriptors.hlsl +++ b/samples/test-harness/shaders/include/Descriptors.hlsl @@ -38,8 +38,9 @@ VK_PUSH_CONST ConstantBuffer GlobalConst : register(b0, space0) #define GetGlobalConst(x, y) (GlobalConst.x##_##y) -uint GetPTSamplesPerPixel() { return (GetGlobalConst(pt, samplesPerPixel) & 0x7FFFFFFF); } +uint GetPTSamplesPerPixel() { return (GetGlobalConst(pt, samplesPerPixel) & 0x3FFFFFFF); } uint GetPTAntialiasing() { return (GetGlobalConst(pt, samplesPerPixel) & 0x80000000); } +uint GetPTShaderExecutionReordering() { return GetGlobalConst(pt, samplesPerPixel) & 0x40000000; } uint HasDirectionalLight() { return GetGlobalConst(lighting, hasDirectionalLight); } uint GetNumPointLights() { return GetGlobalConst(lighting, numPointLights); } @@ -97,8 +98,9 @@ VK_BINDING(13, 0) ByteAddressBuffer ByteAddrBuffer[] #define SPHERE_INDEX_BUFFER_INDEX 0 #define SPHERE_VERTEX_BUFFER_INDEX 1 -#define MATERIAL_INDICES_INDEX 2 -#define GEOMETRY_BUFFERS_INDEX 3 +#define MESH_OFFSETS_INDEX 2 +#define GEOMETRY_DATA_INDEX 3 +#define GEOMETRY_BUFFERS_INDEX 4 // Sampler Accessor Functions ------------------------------------------------------------------------------ @@ -112,8 +114,16 @@ SamplerState GetAnisoWrapSampler() { return Samplers[2]; } StructuredBuffer GetLights() { return Lights; } -Material GetMaterial(uint index) { return Materials[index]; } -uint GetMaterialIndex(uint meshIndex) { return ByteAddrBuffer[MATERIAL_INDICES_INDEX].Load(meshIndex * 4); } +void GetGeometryData(uint meshIndex, uint geometryIndex, out GeometryData geometry) +{ + uint address = ByteAddrBuffer[MESH_OFFSETS_INDEX].Load(meshIndex * 4); // address of the Mesh in the GeometryData buffer + address += geometryIndex * 12; // offset to mesh primitive geometry, GeometryData stride is 12 bytes + + geometry.materialIndex = ByteAddrBuffer[GEOMETRY_DATA_INDEX].Load(address); + geometry.indexByteAddress = ByteAddrBuffer[GEOMETRY_DATA_INDEX].Load(address + 4); + geometry.vertexByteAddress = ByteAddrBuffer[GEOMETRY_DATA_INDEX].Load(address + 8); +} +Material GetMaterial(GeometryData geometry) { return Materials[geometry.materialIndex]; } StructuredBuffer GetDDGIVolumeConstants(uint index) { return DDGIVolumes; } StructuredBuffer GetDDGIVolumeResourceIndices(uint index) { return DDGIVolumeBindless; } @@ -156,15 +166,16 @@ Texture2DArray GetTex2DArray(uint index) { return Tex2DArray[index]; } #define RTAO_RAW_INDEX 14 #define DDGI_OUTPUT_INDEX 15 -#define SCENE_TLAS_INDEX 40 -#define DDGIPROBEVIS_TLAS_INDEX 41 +#define SCENE_TLAS_INDEX 52 +#define DDGIPROBEVIS_TLAS_INDEX 53 -#define BLUE_NOISE_INDEX 42 +#define BLUE_NOISE_INDEX 54 -#define SPHERE_INDEX_BUFFER_INDEX 368 -#define SPHERE_VERTEX_BUFFER_INDEX 369 -#define MATERIAL_INDICES_INDEX 370 -#define GEOMETRY_BUFFERS_INDEX 371 +#define SPHERE_INDEX_BUFFER_INDEX 392 +#define SPHERE_VERTEX_BUFFER_INDEX 393 +#define MESH_OFFSETS_INDEX 394 +#define GEOMETRY_DATA_INDEX 395 +#define GEOMETRY_BUFFERS_INDEX 396 // Sampler Accessor Functions ------------------------------------------------------------------------------ @@ -178,8 +189,17 @@ SamplerState GetAnisoWrapSampler() { return SamplerDescriptorHeap[2]; } StructuredBuffer GetLights() { return StructuredBuffer(ResourceDescriptorHeap[LIGHTS_INDEX]); } -Material GetMaterial(uint index) { return StructuredBuffer(ResourceDescriptorHeap[MATERIALS_INDEX]).Load(index); } -uint GetMaterialIndex(uint meshIndex) { return ByteAddressBuffer(ResourceDescriptorHeap[MATERIAL_INDICES_INDEX]).Load(meshIndex * 4); } +void GetGeometryData(uint meshIndex, uint geometryIndex, out GeometryData geometry) +{ + uint address = ByteAddressBuffer(ResourceDescriptorHeap[MESH_OFFSETS_INDEX]).Load(meshIndex * 4) * 12; // offset to start of mesh, GeometryData is 12 bytes + address += geometryIndex * 12; // offset to mesh primitive geometry + + ByteAddressBuffer geometryData = ByteAddressBuffer(ResourceDescriptorHeap[GEOMETRY_DATA_INDEX]); + geometry.materialIndex = geometryData.Load(address); + geometry.indexByteAddress = geometryData.Load(address + 4); + geometry.vertexByteAddress = geometryData.Load(address + 8); +} +Material GetMaterial(GeometryData geometry) { return StructuredBuffer(ResourceDescriptorHeap[MATERIALS_INDEX]).Load(geometry.materialIndex); } StructuredBuffer GetDDGIVolumeConstants(uint index) { return ResourceDescriptorHeap[index]; } StructuredBuffer GetDDGIVolumeResourceIndices(uint index) { return ResourceDescriptorHeap[index]; } diff --git a/samples/test-harness/shaders/include/Lighting.hlsl b/samples/test-harness/shaders/include/Lighting.hlsl index b7a8984..55f7f15 100644 --- a/samples/test-harness/shaders/include/Lighting.hlsl +++ b/samples/test-harness/shaders/include/Lighting.hlsl @@ -57,7 +57,7 @@ float LightVisibility( RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH | RAY_FLAG_SKIP_CLOSEST_HIT_SHADER, 0xFF, 0, - 1, + 0, 0, ray, packedPayload); diff --git a/samples/test-harness/shaders/include/Platform.hlsl b/samples/test-harness/shaders/include/Platform.hlsl index 010e876..09c5eda 100644 --- a/samples/test-harness/shaders/include/Platform.hlsl +++ b/samples/test-harness/shaders/include/Platform.hlsl @@ -11,6 +11,13 @@ #ifndef PLATFORM_HLSL #define PLATFORM_HLSL +#if GFX_NVAPI +#define NV_SHADER_EXTN_SLOT u999999 +#define NV_SHADER_EXTN_REGISTER_SPACE space999999 +#define NV_HITOBJECT_USE_MACRO_API +#include "nvapi/nvHLSLExtns.h" +#endif + #ifdef __spirv__ #define VK_BINDING(x, y) [[vk::binding(x, y)]] #define VK_PUSH_CONST [[vk::push_constant]] diff --git a/samples/test-harness/shaders/include/RayTracing.hlsl b/samples/test-harness/shaders/include/RayTracing.hlsl index 3837e75..65f0f12 100644 --- a/samples/test-harness/shaders/include/RayTracing.hlsl +++ b/samples/test-harness/shaders/include/RayTracing.hlsl @@ -37,7 +37,6 @@ PackedPayload PackPayload(Payload input) output.packed1.y = f32tof16(input.shadingNormal.z); output.packed1.y |= f32tof16(input.opacity) << 16; output.packed1.z = f32tof16(input.hitKind); - //output.packed1.z = unused return output; } @@ -73,26 +72,26 @@ Payload UnpackPayload(PackedPayload input) /** * Load a triangle's indices. */ -uint3 LoadIndices(uint meshIndex, uint primitiveIndex) +uint3 LoadIndices(uint meshIndex, uint primitiveIndex, GeometryData geometry) { - uint address = (primitiveIndex * 3) * 4; // 3 indices per primitive, 4 bytes for each index - return GetIndexBuffer(meshIndex).Load3(address); // Mesh index buffers start at index 3 and alternate with vertex buffer pointers + uint address = geometry.indexByteAddress + (primitiveIndex * 3) * 4; // 3 indices per primitive, 4 bytes for each index + return GetIndexBuffer(meshIndex).Load3(address); // Mesh index buffers start at index 4 and alternate with vertex buffer pointers } /** * Load a triangle's vertex data (all: position, normal, tangent, uv0). */ -void LoadVertices(uint meshIndex, uint primitiveIndex, out Vertex vertices[3]) +void LoadVertices(uint meshIndex, uint primitiveIndex, GeometryData geometry, out Vertex vertices[3]) { // Get the indices - uint3 indices = LoadIndices(meshIndex, primitiveIndex); + uint3 indices = LoadIndices(meshIndex, primitiveIndex, geometry); // Load the vertices uint address; for (uint i = 0; i < 3; i++) { - vertices[i] = (Vertex)0; // Initialize the vertex - address = (indices[i] * 12) * 4; // Vertices contain 12 floats / 48 bytes + vertices[i] = (Vertex)0; + address = geometry.vertexByteAddress + (indices[i] * 12) * 4; // Vertices contain 12 floats / 48 bytes // Load the position vertices[i].position = asfloat(GetVertexBuffer(meshIndex).Load3(address)); @@ -114,17 +113,17 @@ void LoadVertices(uint meshIndex, uint primitiveIndex, out Vertex vertices[3]) /** * Load a triangle's vertex data (only position and uv0). */ -void LoadVerticesPosUV0(uint meshIndex, uint primitiveIndex, out Vertex vertices[3]) +void LoadVerticesPosUV0(uint meshIndex, uint primitiveIndex, GeometryData geometry, out Vertex vertices[3]) { // Get the indices - uint3 indices = LoadIndices(meshIndex, primitiveIndex); + uint3 indices = LoadIndices(meshIndex, primitiveIndex, geometry); // Load the vertices uint address; for (uint i = 0; i < 3; i++) { - vertices[i] = (Vertex)0; // Initialize the vertex - address = (indices[i] * 12) * 4; // Vertices contain 12 floats / 48 bytes + vertices[i] = (Vertex)0; + address = geometry.vertexByteAddress + (indices[i] * 12) * 4; // Vertices contain 12 floats / 48 bytes // Load the position vertices[i].position = asfloat(GetVertexBuffer(meshIndex).Load3(address)); @@ -138,18 +137,18 @@ void LoadVerticesPosUV0(uint meshIndex, uint primitiveIndex, out Vertex vertices /** * Load (only) a triangle's texture coordinates and return the barycentric interpolated texture coordinates. */ -float2 LoadAndInterpolateUV0(uint meshIndex, uint primitiveIndex, float3 barycentrics) +float2 LoadAndInterpolateUV0(uint meshIndex, uint primitiveIndex, GeometryData geometry, float3 barycentrics) { // Get the triangle indices - uint3 indices = LoadIndices(meshIndex, primitiveIndex); + uint3 indices = LoadIndices(meshIndex, primitiveIndex, geometry); // Interpolate the texture coordinates int address; float2 uv0 = float2(0.f, 0.f); for (uint i = 0; i < 3; i++) { - address = (indices[i] * 12) * 4; // 12 floats (3: pos, 3: normals, 4:tangent, 2:uv0) - address += 40; // 40 bytes (10 * 4): skip position, normal, and tangent + address = geometry.vertexByteAddress + (indices[i] * 12) * 4; // 12 floats (3: pos, 3: normals, 4:tangent, 2:uv0) + address += 40; // 40 bytes (10 * 4): skip position, normal, and tangent uv0 += asfloat(GetVertexBuffer(meshIndex).Load2(address)) * barycentrics[i]; } diff --git a/samples/test-harness/shaders/include/nvapi/nvHLSLExtns.h b/samples/test-harness/shaders/include/nvapi/nvHLSLExtns.h new file mode 100644 index 0000000..9394036 --- /dev/null +++ b/samples/test-harness/shaders/include/nvapi/nvHLSLExtns.h @@ -0,0 +1,2206 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + +////////////////////////// NVIDIA SHADER EXTENSIONS ///////////////// + +// this file is to be #included in the app HLSL shader code to make +// use of nvidia shader extensions + + +#include "nvHLSLExtnsInternal.h" + +//----------------------------------------------------------------------------// +//------------------------- Warp Shuffle Functions ---------------------------// +//----------------------------------------------------------------------------// + +// all functions have variants with width parameter which permits sub-division +// of the warp into segments - for example to exchange data between 4 groups of +// 8 lanes in a SIMD manner. If width is less than warpSize then each subsection +// of the warp behaves as a separate entity with a starting logical lane ID of 0. +// A thread may only exchange data with others in its own subsection. Width must +// have a value which is a power of 2 so that the warp can be subdivided equally; +// results are undefined if width is not a power of 2, or is a number greater +// than warpSize. + +// +// simple variant of SHFL instruction +// returns val from the specified lane +// optional width parameter must be a power of two and width <= 32 +// +int NvShfl(int val, uint srcLane, int width = NV_WARP_SIZE) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = val; // variable to be shuffled + g_NvidiaExt[index].src0u.y = srcLane; // source lane + g_NvidiaExt[index].src0u.z = __NvGetShflMaskFromWidth(width); + g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL; + + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +int2 NvShfl(int2 val, uint srcLane, int width = NV_WARP_SIZE) +{ + int x = NvShfl(val.x, srcLane, width); + int y = NvShfl(val.y, srcLane, width); + return int2(x, y); +} + +int4 NvShfl(int4 val, uint srcLane, int width = NV_WARP_SIZE) +{ + int x = NvShfl(val.x, srcLane, width); + int y = NvShfl(val.y, srcLane, width); + int z = NvShfl(val.z, srcLane, width); + int w = NvShfl(val.w, srcLane, width); + return int4(x, y, z, w); +} + +// +// Copy from a lane with lower ID relative to caller +// +int NvShflUp(int val, uint delta, int width = NV_WARP_SIZE) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = val; // variable to be shuffled + g_NvidiaExt[index].src0u.y = delta; // relative lane offset + g_NvidiaExt[index].src0u.z = (NV_WARP_SIZE - width) << 8; // minIndex = maxIndex for shfl_up (src2[4:0] is expected to be 0) + g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_UP; + return g_NvidiaExt.IncrementCounter(); +} + +// +// Copy from a lane with higher ID relative to caller +// +int NvShflDown(int val, uint delta, int width = NV_WARP_SIZE) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = val; // variable to be shuffled + g_NvidiaExt[index].src0u.y = delta; // relative lane offset + g_NvidiaExt[index].src0u.z = __NvGetShflMaskFromWidth(width); + g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_DOWN; + return g_NvidiaExt.IncrementCounter(); +} + +// +// Copy from a lane based on bitwise XOR of own lane ID +// +int NvShflXor(int val, uint laneMask, int width = NV_WARP_SIZE) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = val; // variable to be shuffled + g_NvidiaExt[index].src0u.y = laneMask; // laneMask to be XOR'ed with current laneId to get the source lane id + g_NvidiaExt[index].src0u.z = __NvGetShflMaskFromWidth(width); + g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_XOR; + return g_NvidiaExt.IncrementCounter(); +} + + +//----------------------------------------------------------------------------// +//----------------------------- Warp Vote Functions---------------------------// +//----------------------------------------------------------------------------// + +// returns 0xFFFFFFFF if the predicate is true for any thread in the warp, returns 0 otherwise +uint NvAny(int predicate) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = predicate; + g_NvidiaExt[index].opcode = NV_EXTN_OP_VOTE_ANY; + return g_NvidiaExt.IncrementCounter(); +} + +// returns 0xFFFFFFFF if the predicate is true for ALL threads in the warp, returns 0 otherwise +uint NvAll(int predicate) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = predicate; + g_NvidiaExt[index].opcode = NV_EXTN_OP_VOTE_ALL; + return g_NvidiaExt.IncrementCounter(); +} + +// returns a mask of all threads in the warp with bits set for threads that have predicate true +uint NvBallot(int predicate) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = predicate; + g_NvidiaExt[index].opcode = NV_EXTN_OP_VOTE_BALLOT; + return g_NvidiaExt.IncrementCounter(); +} + + +//----------------------------------------------------------------------------// +//----------------------------- Utility Functions ----------------------------// +//----------------------------------------------------------------------------// + +// returns the lane index of the current thread (thread index in warp) +int NvGetLaneId() +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_GET_LANE_ID; + return g_NvidiaExt.IncrementCounter(); +} + +// returns value of special register - specify subopcode from any of NV_SPECIALOP_* specified in nvShaderExtnEnums.h - other opcodes undefined behavior +uint NvGetSpecial(uint subOpCode) +{ + return __NvGetSpecial(subOpCode); +} + +//----------------------------------------------------------------------------// +//----------------------------- FP16 Atmoic Functions-------------------------// +//----------------------------------------------------------------------------// + +// The functions below performs atomic operations on two consecutive fp16 +// values in the given raw UAV. +// The uint paramater 'fp16x2Val' is treated as two fp16 values byteAddress must be multiple of 4 +// The returned value are the two fp16 values packed into a single uint + +uint NvInterlockedAddFp16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, fp16x2Val, NV_EXTN_ATOM_MAX); +} + + +// versions of the above functions taking two fp32 values (internally converted to fp16 values) +uint NvInterlockedAddFp16x2(RWByteAddressBuffer uav, uint byteAddress, float2 val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWByteAddressBuffer uav, uint byteAddress, float2 val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWByteAddressBuffer uav, uint byteAddress, float2 val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX); +} + + +//----------------------------------------------------------------------------// + +// The functions below perform atomic operation on a R16G16_FLOAT UAV at the given address +// the uint paramater 'fp16x2Val' is treated as two fp16 values +// the returned value are the two fp16 values (.x and .y components) packed into a single uint +// Warning: Behaviour of these set of functions is undefined if the UAV is not +// of R16G16_FLOAT format (might result in app crash or TDR) + +uint NvInterlockedAddFp16x2(RWTexture1D uav, uint address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture1D uav, uint address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture1D uav, uint address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + +uint NvInterlockedAddFp16x2(RWTexture2D uav, uint2 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture2D uav, uint2 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture2D uav, uint2 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + +uint NvInterlockedAddFp16x2(RWTexture3D uav, uint3 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture3D uav, uint3 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture3D uav, uint3 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + + +// versions taking two fp32 values (internally converted to fp16) +uint NvInterlockedAddFp16x2(RWTexture1D uav, uint address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture1D uav, uint address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture1D uav, uint address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX); +} + +uint NvInterlockedAddFp16x2(RWTexture2D uav, uint2 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture2D uav, uint2 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture2D uav, uint2 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX); +} + +uint NvInterlockedAddFp16x2(RWTexture3D uav, uint3 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture3D uav, uint3 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture3D uav, uint3 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX); +} + + +//----------------------------------------------------------------------------// + +// The functions below perform Atomic operation on a R16G16B16A16_FLOAT UAV at the given address +// the uint2 paramater 'fp16x2Val' is treated as four fp16 values +// i.e, fp16x2Val.x = uav.xy and fp16x2Val.y = uav.yz +// The returned value are the four fp16 values (.xyzw components) packed into uint2 +// Warning: Behaviour of these set of functions is undefined if the UAV is not +// of R16G16B16A16_FLOAT format (might result in app crash or TDR) + +uint2 NvInterlockedAddFp16x4(RWTexture1D uav, uint address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture1D uav, uint address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture1D uav, uint address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedAddFp16x4(RWTexture2D uav, uint2 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture2D uav, uint2 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture2D uav, uint2 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedAddFp16x4(RWTexture3D uav, uint3 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture3D uav, uint3 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture3D uav, uint3 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + +// versions taking four fp32 values (internally converted to fp16) +uint2 NvInterlockedAddFp16x4(RWTexture1D uav, uint address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture1D uav, uint address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture1D uav, uint address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedAddFp16x4(RWTexture2D uav, uint2 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture2D uav, uint2 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture2D uav, uint2 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedAddFp16x4(RWTexture3D uav, uint3 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture3D uav, uint3 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture3D uav, uint3 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MAX); +} + + +//----------------------------------------------------------------------------// +//----------------------------- FP32 Atmoic Functions-------------------------// +//----------------------------------------------------------------------------// + +// The functions below performs atomic add on the given UAV treating the value as float +// byteAddress must be multiple of 4 +// The returned value is the value present in memory location before the atomic add + +float NvInterlockedAddFp32(RWByteAddressBuffer uav, uint byteAddress, float val) +{ + return __NvAtomicAddFP32(uav, byteAddress, val); +} + +//----------------------------------------------------------------------------// + +// The functions below perform atomic add on a R32_FLOAT UAV at the given address +// the returned value is the value before performing the atomic add +// Warning: Behaviour of these set of functions is undefined if the UAV is not +// of R32_FLOAT format (might result in app crash or TDR) + +float NvInterlockedAddFp32(RWTexture1D uav, uint address, float val) +{ + return __NvAtomicAddFP32(uav, address, val); +} + +float NvInterlockedAddFp32(RWTexture2D uav, uint2 address, float val) +{ + return __NvAtomicAddFP32(uav, address, val); +} + +float NvInterlockedAddFp32(RWTexture3D uav, uint3 address, float val) +{ + return __NvAtomicAddFP32(uav, address, val); +} + + +//----------------------------------------------------------------------------// +//--------------------------- UINT64 Atmoic Functions-------------------------// +//----------------------------------------------------------------------------// + +// The functions below performs atomic operation on the given UAV treating the value as uint64 +// byteAddress must be multiple of 8 +// The returned value is the value present in memory location before the atomic operation +// uint2 vector type is used to represent a single uint64 value with the x component containing the low 32 bits and y component the high 32 bits. + +uint2 NvInterlockedAddUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMaxUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedMinUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedAndUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_AND); +} + +uint2 NvInterlockedOrUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_OR); +} + +uint2 NvInterlockedXorUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_XOR); +} + +uint2 NvInterlockedCompareExchangeUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 compare_value, uint2 value) +{ + return __NvAtomicCompareExchangeUINT64(uav, byteAddress, compare_value, value); +} + +uint2 NvInterlockedExchangeUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_SWAP); +} + +//----------------------------------------------------------------------------// + +// The functions below perform atomic operation on a R32G32_UINT UAV at the given address treating the value as uint64 +// the returned value is the value before performing the atomic operation +// uint2 vector type is used to represent a single uint64 value with the x component containing the low 32 bits and y component the high 32 bits. +// Warning: Behaviour of these set of functions is undefined if the UAV is not of R32G32_UINT format (might result in app crash or TDR) + +uint2 NvInterlockedAddUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMaxUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedMinUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedAndUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_AND); +} + +uint2 NvInterlockedOrUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_OR); +} + +uint2 NvInterlockedXorUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_XOR); +} + +uint2 NvInterlockedCompareExchangeUint64(RWTexture1D uav, uint address, uint2 compare_value, uint2 value) +{ + return __NvAtomicCompareExchangeUINT64(uav, address, compare_value, value); +} + +uint2 NvInterlockedExchangeUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_SWAP); +} + +uint2 NvInterlockedAddUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMaxUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedMinUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedAndUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_AND); +} + +uint2 NvInterlockedOrUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_OR); +} + +uint2 NvInterlockedXorUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_XOR); +} + +uint2 NvInterlockedCompareExchangeUint64(RWTexture2D uav, uint2 address, uint2 compare_value, uint2 value) +{ + return __NvAtomicCompareExchangeUINT64(uav, address, compare_value, value); +} + +uint2 NvInterlockedExchangeUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_SWAP); +} + +uint2 NvInterlockedAddUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMaxUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedMinUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedAndUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_AND); +} + +uint2 NvInterlockedOrUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_OR); +} + +uint2 NvInterlockedXorUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_XOR); +} + +uint2 NvInterlockedCompareExchangeUint64(RWTexture3D uav, uint3 address, uint2 compare_value, uint2 value) +{ + return __NvAtomicCompareExchangeUINT64(uav, address, compare_value, value); +} + +uint2 NvInterlockedExchangeUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_SWAP); +} + +//----------------------------------------------------------------------------// +//--------------------------- VPRS functions ---------------------------------// +//----------------------------------------------------------------------------// + +// Returns the shading rate and the number of per-pixel shading passes for current VPRS pixel +uint3 NvGetShadingRate() +{ + uint3 shadingRate = (uint3)0; + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_GET_SHADING_RATE; + g_NvidiaExt[index].numOutputsForIncCounter = 3; + shadingRate.x = g_NvidiaExt.IncrementCounter(); + shadingRate.y = g_NvidiaExt.IncrementCounter(); + shadingRate.z = g_NvidiaExt.IncrementCounter(); + return shadingRate; +} + +float NvEvaluateAttributeAtSampleForVPRS(float attrib, uint sampleIndex, int2 pixelOffset) +{ + float value = (float)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float2 NvEvaluateAttributeAtSampleForVPRS(float2 attrib, uint sampleIndex, int2 pixelOffset) +{ + float2 value = (float2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float3 NvEvaluateAttributeAtSampleForVPRS(float3 attrib, uint sampleIndex, int2 pixelOffset) +{ + float3 value = (float3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + value.z = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float4 NvEvaluateAttributeAtSampleForVPRS(float4 attrib, uint sampleIndex, int2 pixelOffset) +{ + float4 value = (float4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + value.z = asfloat(g_NvidiaExt.IncrementCounter()); + value.w = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +int NvEvaluateAttributeAtSampleForVPRS(int attrib, uint sampleIndex, int2 pixelOffset) +{ + int value = (int)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int2 NvEvaluateAttributeAtSampleForVPRS(int2 attrib, uint sampleIndex, int2 pixelOffset) +{ + int2 value = (int2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int3 NvEvaluateAttributeAtSampleForVPRS(int3 attrib, uint sampleIndex, int2 pixelOffset) +{ + int3 value = (int3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + value.z = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int4 NvEvaluateAttributeAtSampleForVPRS(int4 attrib, uint sampleIndex, int2 pixelOffset) +{ + int4 value = (int4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + value.z = asint(g_NvidiaExt.IncrementCounter()); + value.w = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint NvEvaluateAttributeAtSampleForVPRS(uint attrib, uint sampleIndex, int2 pixelOffset) +{ + uint value = (uint)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint2 NvEvaluateAttributeAtSampleForVPRS(uint2 attrib, uint sampleIndex, int2 pixelOffset) +{ + uint2 value = (uint2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint3 NvEvaluateAttributeAtSampleForVPRS(uint3 attrib, uint sampleIndex, int2 pixelOffset) +{ + uint3 value = (uint3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + value.z = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint4 NvEvaluateAttributeAtSampleForVPRS(uint4 attrib, uint sampleIndex, int2 pixelOffset) +{ + uint4 value = (uint4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + value.z = asuint(g_NvidiaExt.IncrementCounter()); + value.w = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + + +float NvEvaluateAttributeSnappedForVPRS(float attrib, uint2 offset) +{ + float value = (float)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float2 NvEvaluateAttributeSnappedForVPRS(float2 attrib, uint2 offset) +{ + float2 value = (float2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float3 NvEvaluateAttributeSnappedForVPRS(float3 attrib, uint2 offset) +{ + float3 value = (float3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + value.z = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float4 NvEvaluateAttributeSnappedForVPRS(float4 attrib, uint2 offset) +{ + float4 value = (float4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + value.z = asfloat(g_NvidiaExt.IncrementCounter()); + value.w = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +int NvEvaluateAttributeSnappedForVPRS(int attrib, uint2 offset) +{ + int value = (int)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int2 NvEvaluateAttributeSnappedForVPRS(int2 attrib, uint2 offset) +{ + int2 value = (int2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int3 NvEvaluateAttributeSnappedForVPRS(int3 attrib, uint2 offset) +{ + int3 value = (int3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + value.z = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int4 NvEvaluateAttributeSnappedForVPRS(int4 attrib, uint2 offset) +{ + int4 value = (int4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + value.z = asint(g_NvidiaExt.IncrementCounter()); + value.w = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint NvEvaluateAttributeSnappedForVPRS(uint attrib, uint2 offset) +{ + uint value = (uint)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint2 NvEvaluateAttributeSnappedForVPRS(uint2 attrib, uint2 offset) +{ + uint2 value = (uint2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint3 NvEvaluateAttributeSnappedForVPRS(uint3 attrib, uint2 offset) +{ + uint3 value = (uint3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + value.z = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint4 NvEvaluateAttributeSnappedForVPRS(uint4 attrib, uint2 offset) +{ + uint4 value = (uint4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + value.z = asuint(g_NvidiaExt.IncrementCounter()); + value.w = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +// MATCH instruction variants +uint NvWaveMatch(uint value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = value; + g_NvidiaExt[index].src1u.x = 1; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +uint NvWaveMatch(uint2 value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = value.xy; + g_NvidiaExt[index].src1u.x = 2; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +uint NvWaveMatch(uint4 value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u = value; + g_NvidiaExt[index].src1u.x = 4; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +uint NvWaveMatch(float value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = asuint(value); + g_NvidiaExt[index].src1u.x = 1; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +uint NvWaveMatch(float2 value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = asuint(value); + g_NvidiaExt[index].src1u.x = 2; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +uint NvWaveMatch(float4 value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u = asuint(value); + g_NvidiaExt[index].src1u.x = 4; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + + +//----------------------------------------------------------------------------// +//------------------------------ Footprint functions -------------------------// +//----------------------------------------------------------------------------// +// texSpace and smpSpace must be immediates, texIndex and smpIndex can be variable +// offset must be immediate +// the required components of location and offset fields can be filled depending on the dimension/type of the texture +// texType should be one of 2D or 3D as defined in nvShaderExtnEnums.h and and should be an immediate literal +// if the above restrictions are not met, the behaviour of this instruction is undefined + +uint4 NvFootprintFine(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprint(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, offset); +} + +uint4 NvFootprintCoarse(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprint(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, offset); +} + + + +uint4 NvFootprintFineBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float bias, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintBias(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, bias, offset); +} + +uint4 NvFootprintCoarseBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float bias, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintBias(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, bias, offset); +} + + + +uint4 NvFootprintFineLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float lodLevel, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintLevel(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, lodLevel, offset); +} + +uint4 NvFootprintCoarseLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float lodLevel, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintLevel(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, lodLevel, offset); +} + + + +uint4 NvFootprintFineGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float3 ddx, float3 ddy, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintGrad(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, ddx, ddy, offset); +} + +uint4 NvFootprintCoarseGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float3 ddx, float3 ddy, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintGrad(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, ddx, ddy, offset); +} + +uint NvFootprintExtractLOD(uint4 blob) +{ + return ((blob.w & 0xF000) >> 12); +} + +uint NvFootprintExtractReturnGran(uint4 blob) +{ + return ((blob.z & 0xF000000) >> 24); +} + +uint2 NvFootprintExtractAnchorTileLoc2D(uint4 blob) +{ + uint2 loc; + loc.x = (blob.w & 0xFFF); + loc.y = (blob.z & 0xFFF); + return loc; +} + +uint3 NvFootprintExtractAnchorTileLoc3D(uint4 blob) +{ + uint3 loc; + loc.x = (blob.w & 0xFFF); + loc.y = ((blob.w & 0xFFF0000) >> 16); + loc.z = (blob.z & 0x1FFF); + return loc; +} + +uint2 NvFootprintExtractOffset2D(uint4 blob) +{ + uint2 loc; + loc.x = ((blob.z & 0x070000) >> 16); + loc.y = ((blob.z & 0x380000) >> 19); + return loc; +} + +uint3 NvFootprintExtractOffset3D(uint4 blob) +{ + uint3 loc; + loc.x = ((blob.z & 0x030000) >> 16); + loc.y = ((blob.z & 0x0C0000) >> 18); + loc.z = ((blob.z & 0x300000) >> 20); + return loc; +} + +uint2 NvFootprintExtractBitmask(uint4 blob) +{ + return blob.xy; +} + + +// Variant of Footprint extensions which returns isSingleLod (out parameter) +// isSingleLod = true -> This footprint request touched the texels from only single LOD. +uint4 NvFootprintFine(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprint(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + +uint4 NvFootprintCoarse(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprint(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + + + +uint4 NvFootprintFineBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float bias, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintBias(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, bias, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + +uint4 NvFootprintCoarseBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float bias, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintBias(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, bias, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + + + +uint4 NvFootprintFineLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float lodLevel, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintLevel(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, lodLevel, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + +uint4 NvFootprintCoarseLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float lodLevel, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintLevel(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, lodLevel, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + + + +uint4 NvFootprintFineGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float3 ddx, float3 ddy, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintGrad(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, ddx, ddy, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + +uint4 NvFootprintCoarseGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float3 ddx, float3 ddy, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintGrad(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, ddx, ddy, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + + +uint NvActiveThreads() +{ + return NvBallot(1); +} + + +//----------------------------------------------------------------------------// +//------------------------------ WaveMultiPrefix functions -------------------// +//----------------------------------------------------------------------------// + +// Following are the WaveMultiPrefix functions for different operations (Add, Bitand, BitOr, BitXOr) for different datatypes (uint, uint2, uint4) +// This is a set of functions which implement multi-prefix operations among the set of active lanes in the current wave (WARP). +// A multi-prefix operation comprises a set of prefix operations, executed in parallel within subsets of lanes identified with the provided bitmasks. +// These bitmasks represent partitioning of the set of active lanes in the current wave into N groups (where N is the number of unique masks across all lanes in the wave). +// N prefix operations are then performed each within its corresponding group. +// The groups are assumed to be non-intersecting (that is, a given lane can be a member of one and only one group), +// and bitmasks in all lanes belonging to the same group are required to be the same. +// There are 2 type of functions - Exclusive and Inclusive prefix operations. +// e.g. For NvWaveMultiPrefixInclusiveAdd(val, mask) operation - For each of the groups (for which mask input is same) following is the expected output : +// i^th thread in a group has value = sum(values of threads 0 to i) +// For Exclusive version of same opeartion - +// i^th thread in a group has value = sum(values of threads 0 to i-1) and 0th thread in a the Group has value 0 + +// Extensions for Add +uint NvWaveMultiPrefixInclusiveAdd(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + // As remainingThreads only has threads in group with smaller thread ids than its own thread-id nextLane can never be 31 for any thread in the group except the smallest one + // For smallest thread in the group, remainingThreads is 0 --> nextLane is ~0 (i.e. considering last 5 bits its 31) + // So passing maskClampValue=30 to __NvShflGeneric, it will return laneValid=false for the smallest thread in the group. So update val and nextLane based on laneValid. + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val + temp; + nextLane = newLane; + } + } + return val; +} + +uint NvWaveMultiPrefixExclusiveAdd(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : 0; + return NvWaveMultiPrefixInclusiveAdd(val, mask); +} + +uint2 NvWaveMultiPrefixInclusiveAdd(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val + temp; + nextLane = newLane; + } + } + return val; +} + +uint2 NvWaveMultiPrefixExclusiveAdd(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint2(0, 0); + return NvWaveMultiPrefixInclusiveAdd(val, mask); +} + +uint4 NvWaveMultiPrefixInclusiveAdd(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val + temp; + nextLane = newLane; + } + } + return val; +} + +uint4 NvWaveMultiPrefixExclusiveAdd(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint4(0, 0, 0, 0); + return NvWaveMultiPrefixInclusiveAdd(val, mask); +} + +// MultiPrefix extensions for Bitand +uint NvWaveMultiPrefixInclusiveAnd(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val & temp; + nextLane = newLane; + } + } + return val; +} + +uint NvWaveMultiPrefixExclusiveAnd(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : ~0; + return NvWaveMultiPrefixInclusiveAnd(val, mask); +} + +uint2 NvWaveMultiPrefixInclusiveAnd(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val & temp; + nextLane = newLane; + } + } + return val; +} + +uint2 NvWaveMultiPrefixExclusiveAnd(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint2(~0, ~0); + return NvWaveMultiPrefixInclusiveAnd(val, mask); +} + + +uint4 NvWaveMultiPrefixInclusiveAnd(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val & temp; + nextLane = newLane; + } + } + return val; +} + +uint4 NvWaveMultiPrefixExclusiveAnd(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint4(~0, ~0, ~0, ~0); + return NvWaveMultiPrefixInclusiveAnd(val, mask); +} + + +// MultiPrefix extensions for BitOr +uint NvWaveMultiPrefixInclusiveOr(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val | temp; + nextLane = newLane; + } + } + return val; +} + +uint NvWaveMultiPrefixExclusiveOr(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : 0; + return NvWaveMultiPrefixInclusiveOr(val, mask); +} + +uint2 NvWaveMultiPrefixInclusiveOr(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val | temp; + nextLane = newLane; + } + } + return val; +} + +uint2 NvWaveMultiPrefixExclusiveOr(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint2(0, 0); + return NvWaveMultiPrefixInclusiveOr(val, mask); +} + + +uint4 NvWaveMultiPrefixInclusiveOr(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val | temp; + nextLane = newLane; + } + } + return val; +} + +uint4 NvWaveMultiPrefixExclusiveOr(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint4(0, 0, 0, 0); + return NvWaveMultiPrefixInclusiveOr(val, mask); +} + + +// MultiPrefix extensions for BitXOr +uint NvWaveMultiPrefixInclusiveXOr(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val ^ temp; + nextLane = newLane; + } + } + return val; +} + +uint NvWaveMultiPrefixExclusiveXOr(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : 0; + return NvWaveMultiPrefixInclusiveXOr(val, mask); +} + +uint2 NvWaveMultiPrefixInclusiveXOr(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val ^ temp; + nextLane = newLane; + } + } + return val; +} + +uint2 NvWaveMultiPrefixExclusiveXOr(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint2(0, 0); + return NvWaveMultiPrefixInclusiveXOr(val, mask); +} + + +uint4 NvWaveMultiPrefixInclusiveXOr(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val ^ temp; + nextLane = newLane; + } + } + return val; +} + +uint4 NvWaveMultiPrefixExclusiveXOr(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint4(0, 0, 0, 0); + return NvWaveMultiPrefixInclusiveXOr(val, mask); +} + +//----------------------------------------------------------------------------// +//------------------------- DXR HitObject Extension --------------------------// +//----------------------------------------------------------------------------// + +// Support for templates in HLSL requires HLSL 2021+. When using dxc, +// use the -HV 2021 command line argument to enable these versions. +#if defined(__HLSL_VERSION) && (__HLSL_VERSION >= 2021) && !defined(NV_HITOBJECT_USE_MACRO_API) + +struct NvHitObject { + uint _handle; + + bool IsMiss() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_MISS; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + bool IsHit() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_HIT; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + bool IsNop() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_NOP; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + uint GetInstanceID() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_ID; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetInstanceIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetPrimitiveIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_PRIMITIVE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetGeometryIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_GEOMETRY_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetHitKind() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_HIT_KIND; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + RayDesc GetRayDesc() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_RAY_DESC; + g_NvidiaExt[index].src0u.x = _handle; + + uint tmin = g_NvidiaExt.IncrementCounter(); + uint tmax = g_NvidiaExt.IncrementCounter(); + uint rayOrgX = g_NvidiaExt.IncrementCounter(); + uint rayOrgY = g_NvidiaExt.IncrementCounter(); + uint rayOrgZ = g_NvidiaExt.IncrementCounter(); + uint rayDirX = g_NvidiaExt.IncrementCounter(); + uint rayDirY = g_NvidiaExt.IncrementCounter(); + uint rayDirZ = g_NvidiaExt.IncrementCounter(); + + RayDesc ray; + ray.TMin = asfloat(tmin); + ray.TMax = asfloat(tmax); + ray.Origin.x = asfloat(rayOrgX); + ray.Origin.y = asfloat(rayOrgY); + ray.Origin.z = asfloat(rayOrgZ); + ray.Direction.x = asfloat(rayDirX); + ray.Direction.y = asfloat(rayDirY); + ray.Direction.z = asfloat(rayDirZ); + + return ray; + } + + template + T GetAttributes() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_ATTRIBUTES; + g_NvidiaExt[index].src0u.x = _handle; + uint callHandle = g_NvidiaExt.IncrementCounter(); + + T attrs; + CallShader(callHandle, attrs); + return attrs; + } + + uint GetShaderTableIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_SHADER_TABLE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint LoadLocalRootTableConstant(uint RootConstantOffsetInBytes) + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_LOAD_LOCAL_ROOT_TABLE_CONSTANT; + g_NvidiaExt[index].src0u.x = _handle; + g_NvidiaExt[index].src0u.y = RootConstantOffsetInBytes; + return g_NvidiaExt.IncrementCounter(); + } +}; + +template +NvHitObject NvTraceRayHitObject( + RaytracingAccelerationStructure AccelerationStructure, + uint RayFlags, + uint InstanceInclusionMask, + uint RayContributionToHitGroupIndex, + uint MultiplierForGeometryContributionToHitGroupIndex, + uint MissShaderIndex, + RayDesc Ray, + inout T Payload) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_TRACE_RAY; + g_NvidiaExt[index].numOutputsForIncCounter = 2; + g_NvidiaExt[index].src0u.x = MissShaderIndex; + uint hitHandle = g_NvidiaExt.IncrementCounter(); + uint traceHandle = g_NvidiaExt.IncrementCounter(); + + TraceRay(AccelerationStructure, RayFlags, InstanceInclusionMask, RayContributionToHitGroupIndex, MultiplierForGeometryContributionToHitGroupIndex, traceHandle, Ray, Payload); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +template +NvHitObject NvMakeHit( + RaytracingAccelerationStructure AccelerationStructure, + uint InstanceIndex, + uint GeometryIndex, + uint PrimitiveIndex, + uint HitKind, + uint RayContributionToHitGroupIndex, + uint MultiplierForGeometryContributionToHitGroupIndex, + RayDesc Ray, + T Attributes) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_HIT; + g_NvidiaExt[index].numOutputsForIncCounter = 2; + g_NvidiaExt[index].src0u.x = InstanceIndex; + g_NvidiaExt[index].src0u.y = GeometryIndex; + g_NvidiaExt[index].src0u.z = PrimitiveIndex; + g_NvidiaExt[index].src0u.w = HitKind; + g_NvidiaExt[index].src1u.x = RayContributionToHitGroupIndex; + g_NvidiaExt[index].src1u.y = MultiplierForGeometryContributionToHitGroupIndex; + uint hitHandle = g_NvidiaExt.IncrementCounter(); + uint traceHandle = g_NvidiaExt.IncrementCounter(); + + struct AttrWrapper { T Attrs; }; + AttrWrapper wrapper; + wrapper.Attrs = Attributes; + CallShader(traceHandle, wrapper); + + struct DummyPayload { int a; }; + DummyPayload payload; + TraceRay(AccelerationStructure, 0, 0, 0, 0, traceHandle, Ray, payload); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +template +NvHitObject NvMakeHitWithRecordIndex( + uint HitGroupRecordIndex, + RaytracingAccelerationStructure AccelerationStructure, + uint InstanceIndex, + uint GeometryIndex, + uint PrimitiveIndex, + uint HitKind, + RayDesc Ray, + T Attributes) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_HIT_WITH_RECORD_INDEX; + g_NvidiaExt[index].numOutputsForIncCounter = 2; + g_NvidiaExt[index].src0u.x = InstanceIndex; + g_NvidiaExt[index].src0u.y = GeometryIndex; + g_NvidiaExt[index].src0u.z = PrimitiveIndex; + g_NvidiaExt[index].src0u.w = HitKind; + g_NvidiaExt[index].src1u.x = HitGroupRecordIndex; + uint hitHandle = g_NvidiaExt.IncrementCounter(); + uint traceHandle = g_NvidiaExt.IncrementCounter(); + + struct AttrWrapper { T Attrs; }; + AttrWrapper wrapper; + wrapper.Attrs = Attributes; + CallShader(traceHandle, wrapper); + + struct DummyPayload { int a; }; + DummyPayload payload; + TraceRay(AccelerationStructure, 0, 0, 0, 0, traceHandle, Ray, payload); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +NvHitObject NvMakeMiss( + uint MissShaderIndex, + RayDesc Ray) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_MISS; + g_NvidiaExt[index].src0u.x = MissShaderIndex; + g_NvidiaExt[index].src0u.y = asuint(Ray.TMin); + g_NvidiaExt[index].src0u.z = asuint(Ray.TMax); + g_NvidiaExt[index].src1u.x = asuint(Ray.Origin.x); + g_NvidiaExt[index].src1u.y = asuint(Ray.Origin.y); + g_NvidiaExt[index].src1u.z = asuint(Ray.Origin.z); + g_NvidiaExt[index].src2u.x = asuint(Ray.Direction.x); + g_NvidiaExt[index].src2u.y = asuint(Ray.Direction.y); + g_NvidiaExt[index].src2u.z = asuint(Ray.Direction.z); + uint hitHandle = g_NvidiaExt.IncrementCounter(); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +NvHitObject NvMakeNop() +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_NOP; + uint hitHandle = g_NvidiaExt.IncrementCounter(); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +void NvReorderThread(uint CoherenceHint, uint NumCoherenceHintBits) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD; + g_NvidiaExt[index].src0u.x = 0; + g_NvidiaExt[index].src0u.y = 0; + g_NvidiaExt[index].src0u.z = CoherenceHint; + g_NvidiaExt[index].src0u.w = NumCoherenceHintBits; + g_NvidiaExt.IncrementCounter(); +} + +void NvReorderThread(NvHitObject HitObj, uint CoherenceHint, uint NumCoherenceHintBits) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD; + g_NvidiaExt[index].src0u.x = 1; + g_NvidiaExt[index].src0u.y = HitObj._handle; + g_NvidiaExt[index].src0u.z = CoherenceHint; + g_NvidiaExt[index].src0u.w = NumCoherenceHintBits; + g_NvidiaExt.IncrementCounter(); +} + +void NvReorderThread(NvHitObject HitObj) +{ + NvReorderThread(HitObj, 0, 0); +} + +template +void NvInvokeHitObject( + RaytracingAccelerationStructure AccelerationStructure, + NvHitObject HitObj, + inout T Payload) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_INVOKE; + g_NvidiaExt[index].src0u.x = HitObj._handle; + uint handle = g_NvidiaExt.IncrementCounter(); + + TraceRay(AccelerationStructure, 0, 0, 0, 0, handle, (RayDesc)0, Payload); +} + +// Macro-based version of the HitObject API. Use this when HLSL 2021 is not available. +// Enable by specifying #define NV_HITOBJECT_USE_MACRO_API before including this header. +#elif defined(NV_HITOBJECT_USE_MACRO_API) + +struct NvHitObject { + uint _handle; + + bool IsMiss() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_MISS; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + bool IsHit() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_HIT; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + bool IsNop() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_NOP; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + uint GetInstanceID() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_ID; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetInstanceIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetPrimitiveIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_PRIMITIVE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetGeometryIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_GEOMETRY_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetHitKind() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_HIT_KIND; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + RayDesc GetRayDesc() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_RAY_DESC; + g_NvidiaExt[index].src0u.x = _handle; + + uint tmin = g_NvidiaExt.IncrementCounter(); + uint tmax = g_NvidiaExt.IncrementCounter(); + uint rayOrgX = g_NvidiaExt.IncrementCounter(); + uint rayOrgY = g_NvidiaExt.IncrementCounter(); + uint rayOrgZ = g_NvidiaExt.IncrementCounter(); + uint rayDirX = g_NvidiaExt.IncrementCounter(); + uint rayDirY = g_NvidiaExt.IncrementCounter(); + uint rayDirZ = g_NvidiaExt.IncrementCounter(); + + RayDesc ray; + ray.TMin = asfloat(tmin); + ray.TMax = asfloat(tmax); + ray.Origin.x = asfloat(rayOrgX); + ray.Origin.y = asfloat(rayOrgY); + ray.Origin.z = asfloat(rayOrgZ); + ray.Direction.x = asfloat(rayDirX); + ray.Direction.y = asfloat(rayDirY); + ray.Direction.z = asfloat(rayDirZ); + + return ray; + } + + uint GetShaderTableIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_SHADER_TABLE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint LoadLocalRootTableConstant(uint RootConstantOffsetInBytes) + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_LOAD_LOCAL_ROOT_TABLE_CONSTANT; + g_NvidiaExt[index].src0u.x = _handle; + g_NvidiaExt[index].src0u.y = RootConstantOffsetInBytes; + return g_NvidiaExt.IncrementCounter(); + } +}; + +#define NvTraceRayHitObject(AccelerationStructure,RayFlags,InstanceInclusionMask,RayContributionToHitGroupIndex,MultiplierForGeometryContributionToHitGroupIndex,MissShaderIndex,Ray,Payload,ResultHitObj) \ +do { \ + uint _rayFlags = RayFlags; \ + uint _instanceInclusionMask = InstanceInclusionMask; \ + uint _rayContributionToHitGroupIndex = RayContributionToHitGroupIndex; \ + uint _multiplierForGeometryContributionToHitGroupIndex = MultiplierForGeometryContributionToHitGroupIndex; \ + uint _missShaderIndex = MissShaderIndex; \ + RayDesc _ray = Ray; \ + uint _index = g_NvidiaExt.IncrementCounter(); \ + g_NvidiaExt[_index].opcode = NV_EXTN_OP_HIT_OBJECT_TRACE_RAY; \ + g_NvidiaExt[_index].numOutputsForIncCounter = 2; \ + g_NvidiaExt[_index].src0u.x = _missShaderIndex; \ + uint _hitHandle = g_NvidiaExt.IncrementCounter(); \ + uint _traceHandle = g_NvidiaExt.IncrementCounter(); \ + TraceRay(AccelerationStructure, _rayFlags, _instanceInclusionMask, _rayContributionToHitGroupIndex, _multiplierForGeometryContributionToHitGroupIndex, _traceHandle, _ray, Payload); \ + ResultHitObj._handle = _hitHandle; \ +} while(0) + +struct NvHitObjectMacroDummyPayloadType { int a; }; + +#define NvMakeHit(AccelerationStructure,InstanceIndex,GeometryIndex,PrimitiveIndex,HitKind,RayContributionToHitGroupIndex,MultiplierForGeometryContributionToHitGroupIndex,Ray,Attributes,ResultHitObj) \ +do { \ + uint _instanceIndex = InstanceIndex; \ + uint _geometryIndex = GeometryIndex; \ + uint _primitiveIndex = PrimitiveIndex; \ + uint _hitKind = HitKind; \ + uint _rayContributionToHitGroupIndex = RayContributionToHitGroupIndex; \ + uint _multiplierForGeometryContributionToHitGroupIndex = MultiplierForGeometryContributionToHitGroupIndex; \ + RayDesc _ray = Ray; \ + uint _index = g_NvidiaExt.IncrementCounter(); \ + g_NvidiaExt[_index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_HIT; \ + g_NvidiaExt[_index].numOutputsForIncCounter = 2; \ + g_NvidiaExt[_index].src0u.x = _instanceIndex; \ + g_NvidiaExt[_index].src0u.y = _geometryIndex; \ + g_NvidiaExt[_index].src0u.z = _primitiveIndex; \ + g_NvidiaExt[_index].src0u.w = _hitKind; \ + g_NvidiaExt[_index].src1u.x = _rayContributionToHitGroupIndex; \ + g_NvidiaExt[_index].src1u.y = _multiplierForGeometryContributionToHitGroupIndex; \ + uint _hitHandle = g_NvidiaExt.IncrementCounter(); \ + uint _traceHandle = g_NvidiaExt.IncrementCounter(); \ + CallShader(_traceHandle, Attributes); \ + NvHitObjectMacroDummyPayloadType _payload; \ + TraceRay(AccelerationStructure, 0, 0, 0, 0, _traceHandle, _ray, _payload); \ + ResultHitObj._handle = _hitHandle; \ +} while(0) + +#define NvMakeHitWithRecordIndex(HitGroupRecordIndex,AccelerationStructure,InstanceIndex,GeometryIndex,PrimitiveIndex,HitKind,Ray,Attributes,ResultHitObj) \ +do { \ + uint _hitGroupRecordIndex = HitGroupRecordIndex; \ + uint _instanceIndex = InstanceIndex; \ + uint _geometryIndex = GeometryIndex; \ + uint _primitiveIndex = PrimitiveIndex; \ + uint _hitKind = HitKind; \ + RayDesc _ray = Ray; \ + uint _index = g_NvidiaExt.IncrementCounter(); \ + g_NvidiaExt[_index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_HIT_WITH_RECORD_INDEX; \ + g_NvidiaExt[_index].numOutputsForIncCounter = 2; \ + g_NvidiaExt[_index].src0u.x = _instanceIndex; \ + g_NvidiaExt[_index].src0u.y = _geometryIndex; \ + g_NvidiaExt[_index].src0u.z = _primitiveIndex; \ + g_NvidiaExt[_index].src0u.w = _hitKind; \ + g_NvidiaExt[_index].src1u.x = _hitGroupRecordIndex; \ + uint _hitHandle = g_NvidiaExt.IncrementCounter(); \ + uint _traceHandle = g_NvidiaExt.IncrementCounter(); \ + CallShader(_traceHandle, Attributes); \ + NvHitObjectMacroDummyPayloadType _payload; \ + TraceRay(AccelerationStructure, 0, 0, 0, 0, _traceHandle, _ray, _payload); \ + ResultHitObj._handle = _hitHandle; \ +} while(0) + +NvHitObject NvMakeMiss( + uint MissShaderIndex, + RayDesc Ray) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_MISS; + g_NvidiaExt[index].src0u.x = MissShaderIndex; + g_NvidiaExt[index].src0u.y = asuint(Ray.TMin); + g_NvidiaExt[index].src0u.z = asuint(Ray.TMax); + g_NvidiaExt[index].src1u.x = asuint(Ray.Origin.x); + g_NvidiaExt[index].src1u.y = asuint(Ray.Origin.y); + g_NvidiaExt[index].src1u.z = asuint(Ray.Origin.z); + g_NvidiaExt[index].src2u.x = asuint(Ray.Direction.x); + g_NvidiaExt[index].src2u.y = asuint(Ray.Direction.y); + g_NvidiaExt[index].src2u.z = asuint(Ray.Direction.z); + uint hitHandle = g_NvidiaExt.IncrementCounter(); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +NvHitObject NvMakeNop() +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_NOP; + uint hitHandle = g_NvidiaExt.IncrementCounter(); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +#define NvGetAttributesFromHitObject(HitObj,ResultAttributes) \ +do { \ + uint _index = g_NvidiaExt.IncrementCounter(); \ + g_NvidiaExt[_index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_ATTRIBUTES; \ + g_NvidiaExt[_index].src0u.x = HitObj._handle; \ + uint _callHandle = g_NvidiaExt.IncrementCounter(); \ + CallShader(_callHandle, ResultAttributes); \ +} while(0) + +void NvReorderThread(uint CoherenceHint, uint NumCoherenceHintBits) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD; + g_NvidiaExt[index].src0u.x = 0; + g_NvidiaExt[index].src0u.y = 0; + g_NvidiaExt[index].src0u.z = CoherenceHint; + g_NvidiaExt[index].src0u.w = NumCoherenceHintBits; + g_NvidiaExt.IncrementCounter(); +} + +void NvReorderThread(NvHitObject HitObj, uint CoherenceHint, uint NumCoherenceHintBits) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD; + g_NvidiaExt[index].src0u.x = 1; + g_NvidiaExt[index].src0u.y = HitObj._handle; + g_NvidiaExt[index].src0u.z = CoherenceHint; + g_NvidiaExt[index].src0u.w = NumCoherenceHintBits; + g_NvidiaExt.IncrementCounter(); +} + +void NvReorderThread(NvHitObject HitObj) +{ + NvReorderThread(HitObj, 0, 0); +} + +#define NvInvokeHitObject(AccelerationStructure,HitObj,Payload) \ +do { \ + uint _index = g_NvidiaExt.IncrementCounter(); \ + g_NvidiaExt[_index].opcode = NV_EXTN_OP_HIT_OBJECT_INVOKE; \ + g_NvidiaExt[_index].src0u.x = HitObj._handle; \ + uint _handle = g_NvidiaExt.IncrementCounter(); \ + TraceRay(AccelerationStructure, 0, 0, 0, 0, _handle, (RayDesc)0, Payload); \ +} while(0) + +#endif diff --git a/samples/test-harness/shaders/include/nvapi/nvHLSLExtnsInternal.h b/samples/test-harness/shaders/include/nvapi/nvHLSLExtnsInternal.h new file mode 100644 index 0000000..c5936a5 --- /dev/null +++ b/samples/test-harness/shaders/include/nvapi/nvHLSLExtnsInternal.h @@ -0,0 +1,767 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + +////////////////////////// NVIDIA SHADER EXTENSIONS ///////////////// +// internal functions +// Functions in this file are not expected to be called by apps directly + +#include "nvShaderExtnEnums.h" + +struct NvShaderExtnStruct +{ + uint opcode; // opcode + uint rid; // resource ID + uint sid; // sampler ID + + uint4 dst1u; // destination operand 1 (for instructions that need extra destination operands) + uint4 src3u; // source operand 3 + uint4 src4u; // source operand 4 + uint4 src5u; // source operand 5 + + uint4 src0u; // uint source operand 0 + uint4 src1u; // uint source operand 0 + uint4 src2u; // uint source operand 0 + uint4 dst0u; // uint destination operand + + uint markUavRef; // the next store to UAV is fake and is used only to identify the uav slot + uint numOutputsForIncCounter; // Used for output to IncrementCounter + float padding1[27]; // struct size: 256 bytes +}; + +// RW structured buffer for Nvidia shader extensions + +// Application needs to define NV_SHADER_EXTN_SLOT as a unused slot, which should be +// set using NvAPI_D3D11_SetNvShaderExtnSlot() call before creating the first shader that +// uses nvidia shader extensions. E.g before including this file in shader define it as: +// #define NV_SHADER_EXTN_SLOT u7 + +// For SM5.1, application needs to define NV_SHADER_EXTN_REGISTER_SPACE as register space +// E.g. before including this file in shader define it as: +// #define NV_SHADER_EXTN_REGISTER_SPACE space2 + +// Note that other operations to this UAV will be ignored so application +// should bind a null resource + +#ifdef NV_SHADER_EXTN_REGISTER_SPACE +RWStructuredBuffer g_NvidiaExt : register( NV_SHADER_EXTN_SLOT, NV_SHADER_EXTN_REGISTER_SPACE ); +#else +RWStructuredBuffer g_NvidiaExt : register( NV_SHADER_EXTN_SLOT ); +#endif + +//----------------------------------------------------------------------------// +// the exposed SHFL instructions accept a mask parameter in src2 +// To compute lane mask from width of segment: +// minLaneID : currentLaneId & src2[12:8] +// maxLaneID : minLaneId | (src2[4:0] & ~src2[12:8]) +// where [minLaneId, maxLaneId] defines the segment where currentLaneId belongs +// we always set src2[4:0] to 11111 (0x1F), and set src2[12:8] as (32 - width) +int __NvGetShflMaskFromWidth(uint width) +{ + return ((NV_WARP_SIZE - width) << 8) | 0x1F; +} + +//----------------------------------------------------------------------------// + +void __NvReferenceUAVForOp(RWByteAddressBuffer uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav.Store(index, 0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = float2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = float2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = float2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = float4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = float4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = float4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = 0.0f; +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = 0.0f; +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = 0.0f; +} + + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = uint2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = uint2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = uint2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = uint4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = uint4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = uint4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = 0; +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = 0; +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = 0; +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = int2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = int2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = int2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = int4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = int4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = int4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = 0; +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = 0; +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = 0; +} + +//----------------------------------------------------------------------------// +// ATOMIC op sub-opcodes +#define NV_EXTN_ATOM_AND 0 +#define NV_EXTN_ATOM_OR 1 +#define NV_EXTN_ATOM_XOR 2 + +#define NV_EXTN_ATOM_ADD 3 +#define NV_EXTN_ATOM_MAX 6 +#define NV_EXTN_ATOM_MIN 7 + +#define NV_EXTN_ATOM_SWAP 8 +#define NV_EXTN_ATOM_CAS 9 + +//----------------------------------------------------------------------------// + +// performs Atomic operation on two consecutive fp16 values in the given UAV +// the uint paramater 'fp16x2Val' is treated as two fp16 values +// the passed sub-opcode 'op' should be an immediate constant +// byteAddress must be multiple of 4 +// the returned value are the two fp16 values packed into a single uint +uint __NvAtomicOpFP16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = byteAddress; + g_NvidiaExt[index].src1u.x = fp16x2Val; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + + return g_NvidiaExt[index].dst0u.x; +} + +//----------------------------------------------------------------------------// + +// performs Atomic operation on a R16G16_FLOAT UAV at the given address +// the uint paramater 'fp16x2Val' is treated as two fp16 values +// the passed sub-opcode 'op' should be an immediate constant +// the returned value are the two fp16 values (.x and .y components) packed into a single uint +// Warning: Behaviour of these set of functions is undefined if the UAV is not +// of R16G16_FLOAT format (might result in app crash or TDR) + +uint __NvAtomicOpFP16x2(RWTexture1D uav, uint address, uint fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address; + g_NvidiaExt[index].src1u.x = fp16x2Val; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + + return g_NvidiaExt[index].dst0u.x; +} + +uint __NvAtomicOpFP16x2(RWTexture2D uav, uint2 address, uint fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = address; + g_NvidiaExt[index].src1u.x = fp16x2Val; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + + return g_NvidiaExt[index].dst0u.x; +} + +uint __NvAtomicOpFP16x2(RWTexture3D uav, uint3 address, uint fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = address; + g_NvidiaExt[index].src1u.x = fp16x2Val; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + + return g_NvidiaExt[index].dst0u.x; +} + +//----------------------------------------------------------------------------// + +// performs Atomic operation on a R16G16B16A16_FLOAT UAV at the given address +// the uint2 paramater 'fp16x2Val' is treated as four fp16 values +// i.e, fp16x2Val.x = uav.xy and fp16x2Val.y = uav.yz +// the passed sub-opcode 'op' should be an immediate constant +// the returned value are the four fp16 values (.xyzw components) packed into uint2 +// Warning: Behaviour of these set of functions is undefined if the UAV is not +// of R16G16B16A16_FLOAT format (might result in app crash or TDR) + +uint2 __NvAtomicOpFP16x2(RWTexture1D uav, uint address, uint2 fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + // break it down into two fp16x2 atomic ops + uint2 retVal; + + // first op has x-coordinate = x * 2 + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address * 2; + g_NvidiaExt[index].src1u.x = fp16x2Val.x; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.x = g_NvidiaExt[index].dst0u.x; + + // second op has x-coordinate = x * 2 + 1 + index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address * 2 + 1; + g_NvidiaExt[index].src1u.x = fp16x2Val.y; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.y = g_NvidiaExt[index].dst0u.x; + + return retVal; +} + +uint2 __NvAtomicOpFP16x2(RWTexture2D uav, uint2 address, uint2 fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + // break it down into two fp16x2 atomic ops + uint2 retVal; + + // first op has x-coordinate = x * 2 + uint2 addressTemp = uint2(address.x * 2, address.y); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = addressTemp; + g_NvidiaExt[index].src1u.x = fp16x2Val.x; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.x = g_NvidiaExt[index].dst0u.x; + + // second op has x-coordinate = x * 2 + 1 + addressTemp.x++; + index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = addressTemp; + g_NvidiaExt[index].src1u.x = fp16x2Val.y; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.y = g_NvidiaExt[index].dst0u.x; + + return retVal; +} + +uint2 __NvAtomicOpFP16x2(RWTexture3D uav, uint3 address, uint2 fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + // break it down into two fp16x2 atomic ops + uint2 retVal; + + // first op has x-coordinate = x * 2 + uint3 addressTemp = uint3(address.x * 2, address.y, address.z); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = addressTemp; + g_NvidiaExt[index].src1u.x = fp16x2Val.x; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.x = g_NvidiaExt[index].dst0u.x; + + // second op has x-coordinate = x * 2 + 1 + addressTemp.x++; + index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = addressTemp; + g_NvidiaExt[index].src1u.x = fp16x2Val.y; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.y = g_NvidiaExt[index].dst0u.x; + + return retVal; +} + +uint __fp32x2Tofp16x2(float2 val) +{ + return (f32tof16(val.y)<<16) | f32tof16(val.x) ; +} + +uint2 __fp32x4Tofp16x4(float4 val) +{ + return uint2( (f32tof16(val.y)<<16) | f32tof16(val.x), (f32tof16(val.w)<<16) | f32tof16(val.z) ) ; +} + +//----------------------------------------------------------------------------// + +// FP32 Atomic functions +// performs Atomic operation treating the uav as float (fp32) values +// the passed sub-opcode 'op' should be an immediate constant +// byteAddress must be multiple of 4 +float __NvAtomicAddFP32(RWByteAddressBuffer uav, uint byteAddress, float val) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = byteAddress; + g_NvidiaExt[index].src1u.x = asuint(val); // passing as uint to make it more convinient for the driver to translate + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC; + + return asfloat(g_NvidiaExt[index].dst0u.x); +} + +float __NvAtomicAddFP32(RWTexture1D uav, uint address, float val) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address; + g_NvidiaExt[index].src1u.x = asuint(val); + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC; + + return asfloat(g_NvidiaExt[index].dst0u.x); +} + +float __NvAtomicAddFP32(RWTexture2D uav, uint2 address, float val) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = address; + g_NvidiaExt[index].src1u.x = asuint(val); + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC; + + return asfloat(g_NvidiaExt[index].dst0u.x); +} + +float __NvAtomicAddFP32(RWTexture3D uav, uint3 address, float val) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = address; + g_NvidiaExt[index].src1u.x = asuint(val); + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC; + + return asfloat(g_NvidiaExt[index].dst0u.x); +} + +//----------------------------------------------------------------------------// + +// UINT64 Atmoic Functions +// The functions below performs atomic operation on the given UAV treating the value as uint64 +// byteAddress must be multiple of 8 +// The returned value is the value present in memory location before the atomic operation +// uint2 vector type is used to represent a single uint64 value with the x component containing the low 32 bits and y component the high 32 bits. + +uint2 __NvAtomicCompareExchangeUINT64(RWByteAddressBuffer uav, uint byteAddress, uint2 compareValue, uint2 value) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = byteAddress; + g_NvidiaExt[index].src1u.xy = compareValue; + g_NvidiaExt[index].src1u.zw = value; + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicOpUINT64(RWByteAddressBuffer uav, uint byteAddress, uint2 value, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = byteAddress; + g_NvidiaExt[index].src1u.xy = value; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicCompareExchangeUINT64(RWTexture1D uav, uint address, uint2 compareValue, uint2 value) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address; + g_NvidiaExt[index].src1u.xy = compareValue; + g_NvidiaExt[index].src1u.zw = value; + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicOpUINT64(RWTexture1D uav, uint address, uint2 value, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address; + g_NvidiaExt[index].src1u.xy = value; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicCompareExchangeUINT64(RWTexture2D uav, uint2 address, uint2 compareValue, uint2 value) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = address; + g_NvidiaExt[index].src1u.xy = compareValue; + g_NvidiaExt[index].src1u.zw = value; + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicOpUINT64(RWTexture2D uav, uint2 address, uint2 value, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = address; + g_NvidiaExt[index].src1u.xy = value; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicCompareExchangeUINT64(RWTexture3D uav, uint3 address, uint2 compareValue, uint2 value) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = address; + g_NvidiaExt[index].src1u.xy = compareValue; + g_NvidiaExt[index].src1u.zw = value; + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicOpUINT64(RWTexture3D uav, uint3 address, uint2 value, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = address; + g_NvidiaExt[index].src1u.xy = value; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + + +uint4 __NvFootprint(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, int3 offset = int3(0, 0, 0)) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = texIndex; + g_NvidiaExt[index].src0u.y = smpIndex; + g_NvidiaExt[index].src1u.xyz = asuint(location); + g_NvidiaExt[index].src1u.w = gran; + g_NvidiaExt[index].src3u.x = texSpace; + g_NvidiaExt[index].src3u.y = smpSpace; + g_NvidiaExt[index].src3u.z = texType; + g_NvidiaExt[index].src3u.w = footprintmode; + g_NvidiaExt[index].src4u.xyz = asuint(offset); + + g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT; + g_NvidiaExt[index].numOutputsForIncCounter = 4; + + // result is returned as the return value of IncrementCounter on fake UAV slot + uint4 op; + op.x = g_NvidiaExt.IncrementCounter(); + op.y = g_NvidiaExt.IncrementCounter(); + op.z = g_NvidiaExt.IncrementCounter(); + op.w = g_NvidiaExt.IncrementCounter(); + return op; +} + +uint4 __NvFootprintBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, float bias, int3 offset = int3(0, 0, 0)) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = texIndex; + g_NvidiaExt[index].src0u.y = smpIndex; + g_NvidiaExt[index].src1u.xyz = asuint(location); + g_NvidiaExt[index].src1u.w = gran; + g_NvidiaExt[index].src2u.x = asuint(bias); + g_NvidiaExt[index].src3u.x = texSpace; + g_NvidiaExt[index].src3u.y = smpSpace; + g_NvidiaExt[index].src3u.z = texType; + g_NvidiaExt[index].src3u.w = footprintmode; + g_NvidiaExt[index].src4u.xyz = asuint(offset); + + g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT_BIAS; + g_NvidiaExt[index].numOutputsForIncCounter = 4; + + // result is returned as the return value of IncrementCounter on fake UAV slot + uint4 op; + op.x = g_NvidiaExt.IncrementCounter(); + op.y = g_NvidiaExt.IncrementCounter(); + op.z = g_NvidiaExt.IncrementCounter(); + op.w = g_NvidiaExt.IncrementCounter(); + return op; +} + +uint4 __NvFootprintLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, float lodLevel, int3 offset = int3(0, 0, 0)) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = texIndex; + g_NvidiaExt[index].src0u.y = smpIndex; + g_NvidiaExt[index].src1u.xyz = asuint(location); + g_NvidiaExt[index].src1u.w = gran; + g_NvidiaExt[index].src2u.x = asuint(lodLevel); + g_NvidiaExt[index].src3u.x = texSpace; + g_NvidiaExt[index].src3u.y = smpSpace; + g_NvidiaExt[index].src3u.z = texType; + g_NvidiaExt[index].src3u.w = footprintmode; + g_NvidiaExt[index].src4u.xyz = asuint(offset); + + g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT_LEVEL; + g_NvidiaExt[index].numOutputsForIncCounter = 4; + + // result is returned as the return value of IncrementCounter on fake UAV slot + uint4 op; + op.x = g_NvidiaExt.IncrementCounter(); + op.y = g_NvidiaExt.IncrementCounter(); + op.z = g_NvidiaExt.IncrementCounter(); + op.w = g_NvidiaExt.IncrementCounter(); + return op; +} + +uint4 __NvFootprintGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, float3 ddx, float3 ddy, int3 offset = int3(0, 0, 0)) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = texIndex; + g_NvidiaExt[index].src0u.y = smpIndex; + g_NvidiaExt[index].src1u.xyz = asuint(location); + g_NvidiaExt[index].src1u.w = gran; + g_NvidiaExt[index].src2u.xyz = asuint(ddx); + g_NvidiaExt[index].src5u.xyz = asuint(ddy); + g_NvidiaExt[index].src3u.x = texSpace; + g_NvidiaExt[index].src3u.y = smpSpace; + g_NvidiaExt[index].src3u.z = texType; + g_NvidiaExt[index].src3u.w = footprintmode; + g_NvidiaExt[index].src4u.xyz = asuint(offset); + g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT_GRAD; + g_NvidiaExt[index].numOutputsForIncCounter = 4; + + // result is returned as the return value of IncrementCounter on fake UAV slot + uint4 op; + op.x = g_NvidiaExt.IncrementCounter(); + op.y = g_NvidiaExt.IncrementCounter(); + op.z = g_NvidiaExt.IncrementCounter(); + op.w = g_NvidiaExt.IncrementCounter(); + return op; +} + +// returns value of special register - specify subopcode from any of NV_SPECIALOP_* specified in nvShaderExtnEnums.h - other opcodes undefined behavior +uint __NvGetSpecial(uint subOpCode) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_GET_SPECIAL; + g_NvidiaExt[index].src0u.x = subOpCode; + return g_NvidiaExt.IncrementCounter(); +} + +// predicate is returned in laneValid indicating if srcLane is in range and val from specified lane is returned. +int __NvShflGeneric(int val, uint srcLane, uint maskClampVal, out uint laneValid) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = val; // variable to be shuffled + g_NvidiaExt[index].src0u.y = srcLane; // source lane + g_NvidiaExt[index].src0u.z = maskClampVal; + g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_GENERIC; + g_NvidiaExt[index].numOutputsForIncCounter = 2; + + laneValid = asuint(g_NvidiaExt.IncrementCounter()); + return g_NvidiaExt.IncrementCounter(); +} \ No newline at end of file diff --git a/samples/test-harness/shaders/include/nvapi/nvShaderExtnEnums.h b/samples/test-harness/shaders/include/nvapi/nvShaderExtnEnums.h new file mode 100644 index 0000000..cfa918b --- /dev/null +++ b/samples/test-harness/shaders/include/nvapi/nvShaderExtnEnums.h @@ -0,0 +1,141 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + +//////////////////////////////////////////////////////////////////////////////// +////////////////////////// NVIDIA SHADER EXTENSIONS //////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +// This file can be included both from HLSL shader code as well as C++ code. +// The app should call NvAPI_D3D11_IsNvShaderExtnOpCodeSupported() / NvAPI_D3D12_IsNvShaderExtnOpCodeSupported() +// to check for support for every nv shader extension opcode it plans to use + + + +//----------------------------------------------------------------------------// +//---------------------------- NV Shader Extn Version -----------------------// +//----------------------------------------------------------------------------// +#define NV_SHADER_EXTN_VERSION 1 + +//----------------------------------------------------------------------------// +//---------------------------- Misc constants --------------------------------// +//----------------------------------------------------------------------------// +#define NV_WARP_SIZE 32 +#define NV_WARP_SIZE_LOG2 5 + +//----------------------------------------------------------------------------// +//---------------------------- opCode constants ------------------------------// +//----------------------------------------------------------------------------// + + +#define NV_EXTN_OP_SHFL 1 +#define NV_EXTN_OP_SHFL_UP 2 +#define NV_EXTN_OP_SHFL_DOWN 3 +#define NV_EXTN_OP_SHFL_XOR 4 + +#define NV_EXTN_OP_VOTE_ALL 5 +#define NV_EXTN_OP_VOTE_ANY 6 +#define NV_EXTN_OP_VOTE_BALLOT 7 + +#define NV_EXTN_OP_GET_LANE_ID 8 +#define NV_EXTN_OP_FP16_ATOMIC 12 +#define NV_EXTN_OP_FP32_ATOMIC 13 + +#define NV_EXTN_OP_GET_SPECIAL 19 + +#define NV_EXTN_OP_UINT64_ATOMIC 20 + +#define NV_EXTN_OP_MATCH_ANY 21 + +// FOOTPRINT - For Sample and SampleBias +#define NV_EXTN_OP_FOOTPRINT 28 +#define NV_EXTN_OP_FOOTPRINT_BIAS 29 + +#define NV_EXTN_OP_GET_SHADING_RATE 30 + +// FOOTPRINT - For SampleLevel and SampleGrad +#define NV_EXTN_OP_FOOTPRINT_LEVEL 31 +#define NV_EXTN_OP_FOOTPRINT_GRAD 32 + +// SHFL Generic +#define NV_EXTN_OP_SHFL_GENERIC 33 + +#define NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE 51 +#define NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED 52 + +// HitObject API +#define NV_EXTN_OP_HIT_OBJECT_TRACE_RAY 67 +#define NV_EXTN_OP_HIT_OBJECT_MAKE_HIT 68 +#define NV_EXTN_OP_HIT_OBJECT_MAKE_HIT_WITH_RECORD_INDEX 69 +#define NV_EXTN_OP_HIT_OBJECT_MAKE_MISS 70 +#define NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD 71 +#define NV_EXTN_OP_HIT_OBJECT_INVOKE 72 +#define NV_EXTN_OP_HIT_OBJECT_IS_MISS 73 +#define NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_ID 74 +#define NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_INDEX 75 +#define NV_EXTN_OP_HIT_OBJECT_GET_PRIMITIVE_INDEX 76 +#define NV_EXTN_OP_HIT_OBJECT_GET_GEOMETRY_INDEX 77 +#define NV_EXTN_OP_HIT_OBJECT_GET_HIT_KIND 78 +#define NV_EXTN_OP_HIT_OBJECT_GET_RAY_DESC 79 +#define NV_EXTN_OP_HIT_OBJECT_GET_ATTRIBUTES 80 +#define NV_EXTN_OP_HIT_OBJECT_GET_SHADER_TABLE_INDEX 81 +#define NV_EXTN_OP_HIT_OBJECT_LOAD_LOCAL_ROOT_TABLE_CONSTANT 82 +#define NV_EXTN_OP_HIT_OBJECT_IS_HIT 83 +#define NV_EXTN_OP_HIT_OBJECT_IS_NOP 84 +#define NV_EXTN_OP_HIT_OBJECT_MAKE_NOP 85 + +//----------------------------------------------------------------------------// +//-------------------- GET_SPECIAL subOpCode constants -----------------------// +//----------------------------------------------------------------------------// +#define NV_SPECIALOP_THREADLTMASK 4 +#define NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED 5 +#define NV_SPECIALOP_GLOBAL_TIMER_LO 9 +#define NV_SPECIALOP_GLOBAL_TIMER_HI 10 + +//----------------------------------------------------------------------------// +//----------------------------- Texture Types -------------------------------// +//----------------------------------------------------------------------------// +#define NV_EXTN_TEXTURE_1D 2 +#define NV_EXTN_TEXTURE_1D_ARRAY 3 +#define NV_EXTN_TEXTURE_2D 4 +#define NV_EXTN_TEXTURE_2D_ARRAY 5 +#define NV_EXTN_TEXTURE_3D 6 +#define NV_EXTN_TEXTURE_CUBE 7 +#define NV_EXTN_TEXTURE_CUBE_ARRAY 8 + + +//---------------------------------------------------------------------------// +//----------------FOOTPRINT Enums for NvFootprint* extns---------------------// +//---------------------------------------------------------------------------// +#define NV_EXTN_FOOTPRINT_MODE_FINE 0 +#define NV_EXTN_FOOTPRINT_MODE_COARSE 1 diff --git a/samples/test-harness/src/Benchmark.cpp b/samples/test-harness/src/Benchmark.cpp index e6919ae..02a08ae 100644 --- a/samples/test-harness/src/Benchmark.cpp +++ b/samples/test-harness/src/Benchmark.cpp @@ -33,7 +33,7 @@ namespace Benchmark config.app.benchmarkRunning = true; } - void UpdateBenchmark(BenchmarkRun& benchmarkRun, Instrumentation::Performance& perf, Configs::Config& config, Graphics::Globals& gfx, std::ofstream& log) + bool UpdateBenchmark(BenchmarkRun& benchmarkRun, Instrumentation::Performance& perf, Configs::Config& config, Graphics::Globals& gfx, std::ofstream& log) { config.app.benchmarkProgress = (uint32_t)(((float)benchmarkRun.numFramesBenched / (float)NumBenchmarkFrames) * 100.f); @@ -119,8 +119,10 @@ namespace Benchmark } config.app.benchmarkRunning = false; + return true; } benchmarkRun.numFramesBenched++; + return false; } -} \ No newline at end of file +} diff --git a/samples/test-harness/src/Caches.cpp b/samples/test-harness/src/Caches.cpp index 800f1ed..f3d425c 100644 --- a/samples/test-harness/src/Caches.cpp +++ b/samples/test-harness/src/Caches.cpp @@ -12,7 +12,7 @@ using namespace DirectX; -#define SCENE_CACHE_VERSION 3 +#define SCENE_CACHE_VERSION 4 namespace Caches { @@ -95,6 +95,10 @@ namespace Caches mesh.name = std::string(buffer); delete[] buffer; + Read(in, &mesh.index, sizeof(uint32_t)); + Read(in, &mesh.numIndices, sizeof(uint32_t)); + Read(in, &mesh.numVertices, sizeof(uint32_t)); + // Read mesh bounding box Read(in, &mesh.boundingBox, sizeof(rtxgi::AABB)); @@ -114,6 +118,8 @@ namespace Caches Read(in, &mp.material, sizeof(int)); Read(in, &mp.opaque, sizeof(bool)); Read(in, &mp.doubleSided, sizeof(bool)); + Read(in, &mp.indexByteOffset, sizeof(uint32_t)); + Read(in, &mp.vertexByteOffset, sizeof(uint32_t)); Read(in, &mp.boundingBox, sizeof(rtxgi::AABB)); // post-transform bounding box Read(in, &numVertices); @@ -245,6 +251,10 @@ namespace Caches out.write(mesh.name.c_str(), numChars); out.seekp(out.tellp()); + Write(out, &mesh.index, sizeof(uint32_t)); + Write(out, &mesh.numIndices, sizeof(uint32_t)); + Write(out, &mesh.numVertices, sizeof(uint32_t)); + // Mesh bounding box Write(out, &mesh.boundingBox, sizeof(rtxgi::AABB)); @@ -260,6 +270,8 @@ namespace Caches Write(out, &primitive.material, sizeof(int)); Write(out, &primitive.opaque, sizeof(bool)); Write(out, &primitive.doubleSided, sizeof(bool)); + Write(out, &primitive.indexByteOffset, sizeof(uint32_t)); + Write(out, &primitive.vertexByteOffset, sizeof(uint32_t)); Write(out, &primitive.boundingBox, sizeof(rtxgi::AABB)); Write(out, &numVertices); Write(out, primitive.vertices.data(), sizeof(Graphics::Vertex) * numVertices); @@ -436,7 +448,7 @@ namespace Caches Read(in, &cacheVersion, sizeof(uint32_t)); if(cacheVersion != SCENE_CACHE_VERSION) { - log << "\n\tWarning: scene cache version '" << cacheVersion << "' does not match expected version '" << SCENE_CACHE_VERSION << "'\n"; + log << "\n\tWarning: scene cache version '" << cacheVersion << "' does not match expected version '" << SCENE_CACHE_VERSION << "'"; log << "\n\tRebuilding scene cache..."; return false; } diff --git a/samples/test-harness/src/Configs.cpp b/samples/test-harness/src/Configs.cpp index 55a34de..5d841be 100644 --- a/samples/test-harness/src/Configs.cpp +++ b/samples/test-harness/src/Configs.cpp @@ -156,9 +156,9 @@ namespace Configs destination = (rtxgi::EDDGIVolumeProbeVisType)stoi(source); } - /* - * Parse a post process configuration entry. - */ + /** + * Parse a post process configuration entry. + */ bool ParseConfigPostProcessEntry(const std::vector& tokens, const std::string& rhs, Config& config, uint32_t lineNumber, std::ofstream& log) { // Post process entries have no more than 3 tokens @@ -199,9 +199,9 @@ namespace Configs return false; } - /* - * Parse a DDGI configuration entry. - */ + /** + * Parse a DDGI configuration entry. + */ bool ParseConfigDDGIEntry(const std::vector& tokens, const std::string& rhs, Config& config, uint32_t lineNumber, std::ofstream& log) { // DDGI entries have no more than 6 tokens @@ -257,7 +257,19 @@ namespace Configs Store(data, config.ddgi.volumes[volumeIndex].probeClassificationEnabled); return true; } } - + + if (tokens[3].compare("probeVariability") == 0) + { + if (tokens.size() == 5 && tokens[4].compare("enabled") == 0) + { + Store(data, config.ddgi.volumes[volumeIndex].probeVariabilityEnabled); return true; + } + else if (tokens.size() == 5 && tokens[4].compare("threshold") == 0) + { + Store(data, config.ddgi.volumes[volumeIndex].probeVariabilityThreshold); return true; + } + } + if (tokens[3].compare("infiniteScrolling") == 0) { if (tokens.size() == 5 && tokens[4].compare("enabled") == 0) @@ -289,6 +301,11 @@ namespace Configs Store(data, config.ddgi.volumes[volumeIndex].textureFormats.dataFormat); return true; } + else if (tokens[4].compare("variability") == 0 && tokens[5].compare("format") == 0) + { + Store(data, config.ddgi.volumes[volumeIndex].textureFormats.variabilityFormat); + return true; + } } if (tokens[3].compare("vis") == 0) @@ -342,6 +359,12 @@ namespace Configs Store(data, config.ddgi.volumes[volumeIndex].probeDataScale); return true; } + + if (tokens[5].compare("probeVariabilityScale") == 0) + { + Store(data, config.ddgi.volumes[volumeIndex].probeVariabilityScale); + return true; + } } } } diff --git a/samples/test-harness/src/Direct3D12.cpp b/samples/test-harness/src/Direct3D12.cpp index 5b685a3..8f1a7cd 100644 --- a/samples/test-harness/src/Direct3D12.cpp +++ b/samples/test-harness/src/Direct3D12.cpp @@ -12,6 +12,14 @@ #include "UI.h" #include "ImageCapture.h" +#if GFX_NVAPI +#include "nvapi.h" +#include "nvShaderExtnEnums.h" + +#define NV_SHADER_EXTN_SLOT 999999 +#define NV_SHADER_EXTN_REGISTER_SPACE 999999 +#endif + namespace Graphics { using namespace DirectX; @@ -45,6 +53,9 @@ namespace Graphics return true; } + /** + * Convert wide strings to narrow strings. + */ void ConvertWideStringToNarrow(std::wstring& wide, std::string& narrow) { narrow.resize(wide.size()); @@ -59,11 +70,11 @@ namespace Graphics /** * Device creation helper. */ - bool CreateDeviceInternal(ID3D12Device6*& device, IDXGIFactory7*& factory, Configs::Config& config) + bool CreateDeviceInternal(Globals& d3d, Configs::Config& config) { // Create the device IDXGIAdapter1* adapter = nullptr; - for (UINT adapterIndex = 0; DXGI_ERROR_NOT_FOUND != factory->EnumAdapters1(adapterIndex, &adapter); ++adapterIndex) + for (UINT adapterIndex = 0; DXGI_ERROR_NOT_FOUND != d3d.factory->EnumAdapters1(adapterIndex, &adapter); ++adapterIndex) { DXGI_ADAPTER_DESC1 adapterDesc; adapter->GetDesc1(&adapterDesc); @@ -72,39 +83,70 @@ namespace Graphics continue; // Don't select the Basic Render Driver adapter } - if (SUCCEEDED(D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_12_0, _uuidof(ID3D12Device6), (void**)&device))) + if (SUCCEEDED(D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_12_0, _uuidof(ID3D12Device6), (void**)&d3d.device))) { // Check if the device supports ray tracing - D3D12_FEATURE_DATA_D3D12_OPTIONS5 features5; - HRESULT hr = device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &features5, sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS5)); + D3D12_FEATURE_DATA_D3D12_OPTIONS5 features5 = {}; + HRESULT hr = d3d.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &features5, sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS5)); if (FAILED(hr) || features5.RaytracingTier < D3D12_RAYTRACING_TIER_1_0) { - SAFE_RELEASE(device); - device = nullptr; + SAFE_RELEASE(d3d.device); + d3d.device = nullptr; continue; } // Check if the device supports SM6.6 - D3D12_FEATURE_DATA_SHADER_MODEL shaderModel; + D3D12_FEATURE_DATA_SHADER_MODEL shaderModel = {}; shaderModel.HighestShaderModel = D3D_SHADER_MODEL_6_6; - hr = device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &shaderModel, sizeof(D3D12_FEATURE_DATA_SHADER_MODEL)); + hr = d3d.device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &shaderModel, sizeof(D3D12_FEATURE_DATA_SHADER_MODEL)); if (FAILED(hr)) { - SAFE_RELEASE(device); - device = nullptr; + SAFE_RELEASE(d3d.device); + d3d.device = nullptr; continue; } // Resource binding tier 3 is required for SM6.6 dynamic resources - D3D12_FEATURE_DATA_D3D12_OPTIONS features; - hr = device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &features, sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS)); + D3D12_FEATURE_DATA_D3D12_OPTIONS features = {}; + hr = d3d.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &features, sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS)); if (FAILED(hr) || features.ResourceBindingTier < D3D12_RESOURCE_BINDING_TIER_3) { - SAFE_RELEASE(device); - device = nullptr; + SAFE_RELEASE(d3d.device); + d3d.device = nullptr; continue; } + #if GFX_NVAPI + // Check for SER HLSL extension support + NvAPI_Status status = NvAPI_D3D12_IsNvShaderExtnOpCodeSupported( + d3d.device, + NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD, + &d3d.supportsShaderExecutionReordering); + + if (status == NVAPI_OK && d3d.supportsShaderExecutionReordering) + { + // Check for SER device support + NVAPI_D3D12_RAYTRACING_THREAD_REORDERING_CAPS ReorderCaps = NVAPI_D3D12_RAYTRACING_THREAD_REORDERING_CAP_NONE; + status = NvAPI_D3D12_GetRaytracingCaps( + d3d.device, + NVAPI_D3D12_RAYTRACING_CAPS_TYPE_THREAD_REORDERING, + &ReorderCaps, + sizeof(ReorderCaps)); + + if (status != NVAPI_OK || ReorderCaps == NVAPI_D3D12_RAYTRACING_THREAD_REORDERING_CAP_NONE) + { + d3d.supportsShaderExecutionReordering = false; + } + } + #endif + + D3D12_FEATURE_DATA_D3D12_OPTIONS1 waveFeatures = {}; + hr = d3d.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1, &waveFeatures, sizeof(waveFeatures)); + if (SUCCEEDED(hr)) + { + d3d.features.waveLaneCount = waveFeatures.WaveLaneCountMin; + } + // Set the graphics API name config.app.api = "Direct3D 12"; @@ -112,12 +154,12 @@ namespace Graphics std::wstring name(adapterDesc.Description); ConvertWideStringToNarrow(name, config.app.gpuName); #ifdef GFX_NAME_OBJECTS - device->SetName(name.c_str()); + d3d.device->SetName(name.c_str()); #endif break; } - if (device == nullptr) + if (d3d.device == nullptr) { return false; // Didn't find a device that supports ray tracing } @@ -426,33 +468,42 @@ namespace Graphics } /** - * Create the index buffer for a mesh primitive. + * Create the index buffer for a mesh. + * Copy the index data to the upload buffer and schedule a copy to the device buffer. */ - bool CreateIndexBuffer(Globals& d3d, const Scenes::MeshPrimitive& primitive, ID3D12Resource** device, ID3D12Resource** upload, D3D12_INDEX_BUFFER_VIEW& view) + bool CreateIndexBuffer(Globals& d3d, const Scenes::Mesh& mesh, ID3D12Resource** device, ID3D12Resource** upload, D3D12_INDEX_BUFFER_VIEW& view) { // Create the index buffer upload resource - UINT size = static_cast(primitive.indices.size()) * sizeof(UINT); - BufferDesc desc = { size, 0, EHeapType::UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_FLAG_NONE }; + UINT sizeInBytes = mesh.numIndices * sizeof(UINT); + BufferDesc desc = { sizeInBytes, 0, EHeapType::UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_FLAG_NONE }; if (!CreateBuffer(d3d, desc, upload)) return false; // Create the index buffer device resource - desc = { size, 0, EHeapType::DEFAULT, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_FLAG_NONE }; + desc = { sizeInBytes, 0, EHeapType::DEFAULT, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_FLAG_NONE }; if (!CreateBuffer(d3d, desc, device)) return false; // Initialize the index buffer view view.Format = DXGI_FORMAT_R32_UINT; - view.SizeInBytes = size; + view.SizeInBytes = sizeInBytes; view.BufferLocation = (*device)->GetGPUVirtualAddress(); - // Copy the index data to the upload buffer + // Copy the index data of each mesh primitive to the upload buffer UINT8* pData = nullptr; D3D12_RANGE readRange = {}; D3DCHECK((*upload)->Map(0, &readRange, reinterpret_cast(&pData))); - memcpy(pData, primitive.indices.data(), size); + + for (UINT primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) + { + // Get the mesh primitive and copy its indices to the upload buffer + const Scenes::MeshPrimitive& primitive = mesh.primitives[primitiveIndex]; + + UINT size = static_cast(primitive.indices.size()) * sizeof(UINT); + memcpy(pData + primitive.indexByteOffset, primitive.indices.data(), size); + } (*upload)->Unmap(0, nullptr); // Schedule a copy of the upload buffer to the device buffer - d3d.cmdList->CopyBufferRegion(*device, 0, *upload, 0, size); + d3d.cmdList->CopyBufferRegion(*device, 0, *upload, 0, sizeInBytes); // Transition the default heap resource to generic read after the copy is complete D3D12_RESOURCE_BARRIER barrier = {}; @@ -468,34 +519,43 @@ namespace Graphics } /** - * Create the vertex buffer for a mesh primitive. + * Create the vertex buffer for a mesh. + * Copy the vertex data to the upload buffer and schedule a copy to the device buffer. */ - bool CreateVertexBuffer(Globals& d3d, const Scenes::MeshPrimitive& primitive, ID3D12Resource** device, ID3D12Resource** upload, D3D12_VERTEX_BUFFER_VIEW& view) + bool CreateVertexBuffer(Globals& d3d, const Scenes::Mesh& mesh, ID3D12Resource** device, ID3D12Resource** upload, D3D12_VERTEX_BUFFER_VIEW& view) { - // Create the vertex buffer resource + // Create the vertex buffer upload resource UINT stride = sizeof(Vertex); - UINT size = static_cast(primitive.vertices.size()) * stride; - BufferDesc desc = { size, 0, EHeapType::UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_FLAG_NONE }; + UINT sizeInBytes = mesh.numVertices * stride; + BufferDesc desc = { sizeInBytes, 0, EHeapType::UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_FLAG_NONE }; if (!CreateBuffer(d3d, desc, upload)) return false; // Create the vertex buffer device resource - desc = { size, 0, EHeapType::DEFAULT, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_FLAG_NONE }; + desc = { sizeInBytes, 0, EHeapType::DEFAULT, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_FLAG_NONE }; if (!CreateBuffer(d3d, desc, device)) return false; // Initialize the vertex buffer view view.StrideInBytes = stride; - view.SizeInBytes = size; + view.SizeInBytes = sizeInBytes; view.BufferLocation = (*device)->GetGPUVirtualAddress(); - // Copy the vertex data to the upload buffer + // Copy the vertex data of each mesh primitive to the upload buffer UINT8* pData = nullptr; D3D12_RANGE readRange = {}; D3DCHECK((*upload)->Map(0, &readRange, reinterpret_cast(&pData))); - memcpy(pData, primitive.vertices.data(), size); + + for (UINT primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) + { + // Get the mesh primitive and copy its vertices to the upload buffer + const Scenes::MeshPrimitive& primitive = mesh.primitives[primitiveIndex]; + + UINT size = static_cast(primitive.vertices.size()) * stride; + memcpy(pData + primitive.vertexByteOffset, primitive.vertices.data(), size); + } (*upload)->Unmap(0, nullptr); // Schedule a copy of the upload buffer to the device buffer - d3d.cmdList->CopyBufferRegion(*device, 0, *upload, 0, size); + d3d.cmdList->CopyBufferRegion(*device, 0, *upload, 0, sizeInBytes); // Transition the default heap resource to generic read after the copy is complete D3D12_RESOURCE_BARRIER barrier = {}; @@ -511,30 +571,40 @@ namespace Graphics } /** - * Create a bottom level acceleration structure for a mesh primitive. + * Create a bottom level acceleration structure for a mesh. */ - bool CreateBLAS(Globals& d3d, Resources& resources, const Scenes::MeshPrimitive& primitive, const std::string debugName = "") + bool CreateBLAS(Globals& d3d, Resources& resources, const Scenes::Mesh& mesh) { - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS buildFlags = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_TRACE; + // Describe the mesh primitives + std::vector primitives; - // Describe the mesh primitive geometry D3D12_RAYTRACING_GEOMETRY_DESC desc = {}; desc.Type = D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES; - desc.Triangles.VertexBuffer.StartAddress = resources.sceneVBs[primitive.index]->GetGPUVirtualAddress(); - desc.Triangles.VertexBuffer.StrideInBytes = resources.sceneVBViews[primitive.index].StrideInBytes; - desc.Triangles.VertexCount = static_cast(primitive.vertices.size()); - desc.Triangles.VertexFormat = DXGI_FORMAT_R32G32B32_FLOAT; - desc.Triangles.IndexBuffer = resources.sceneIBs[primitive.index]->GetGPUVirtualAddress(); - desc.Triangles.IndexFormat = resources.sceneIBViews[primitive.index].Format; - desc.Triangles.IndexCount = static_cast(primitive.indices.size()); - desc.Flags = primitive.opaque ? D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE : D3D12_RAYTRACING_GEOMETRY_FLAG_NONE; + for (UINT primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) + { + // Get the mesh primitive + const Scenes::MeshPrimitive& primitive = mesh.primitives[primitiveIndex]; + + desc.Triangles.VertexBuffer.StartAddress = resources.sceneVBs[mesh.index]->GetGPUVirtualAddress() + primitive.vertexByteOffset; + desc.Triangles.VertexBuffer.StrideInBytes = resources.sceneVBViews[mesh.index].StrideInBytes; + desc.Triangles.VertexCount = static_cast(primitive.vertices.size()); + desc.Triangles.VertexFormat = DXGI_FORMAT_R32G32B32_FLOAT; + desc.Triangles.IndexBuffer = resources.sceneIBs[mesh.index]->GetGPUVirtualAddress() + primitive.indexByteOffset; + desc.Triangles.IndexFormat = resources.sceneIBViews[mesh.index].Format; + desc.Triangles.IndexCount = static_cast(primitive.indices.size()); + desc.Flags = primitive.opaque ? D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE : D3D12_RAYTRACING_GEOMETRY_FLAG_NONE; + + primitives.push_back(desc); + } + + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS buildFlags = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_TRACE; // Describe the bottom level acceleration structure inputs D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS asInputs = {}; asInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL; asInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY; - asInputs.NumDescs = 1; - asInputs.pGeometryDescs = &desc; + asInputs.NumDescs = static_cast(primitives.size()); + asInputs.pGeometryDescs = primitives.data(); asInputs.Flags = buildFlags; // Get the size requirements for the BLAS buffer @@ -552,11 +622,10 @@ namespace Graphics D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, }; - if (!CreateBuffer(d3d, blasScratchDesc, &resources.blas[primitive.index].scratch)) return false; + if (!CreateBuffer(d3d, blasScratchDesc, &resources.blas[mesh.index].scratch)) return false; #ifdef GFX_NAME_OBJECTS - std::wstring name = std::wstring(debugName.begin(), debugName.end()); - name.append(L" (scratch)"); - resources.blas[primitive.index].scratch->SetName(name.c_str()); + std::wstring name = L"BLAS: " + std::wstring(mesh.name.begin(), mesh.name.end()) + L" (scratch)"; + resources.blas[mesh.index].scratch->SetName(name.c_str()); #endif // Create the BLAS buffer @@ -568,17 +637,17 @@ namespace Graphics D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, }; - if (!CreateBuffer(d3d, blasDesc, &resources.blas[primitive.index].as)) return false; + if (!CreateBuffer(d3d, blasDesc, &resources.blas[mesh.index].as)) return false; #ifdef GFX_NAME_OBJECTS - name = std::wstring(debugName.begin(), debugName.end()); - resources.blas[primitive.index].as->SetName(name.c_str()); + name = L"BLAS: " + std::wstring(mesh.name.begin(), mesh.name.end()); + resources.blas[mesh.index].as->SetName(name.c_str()); #endif // Describe and build the BLAS D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC buildDesc = {}; buildDesc.Inputs = asInputs; - buildDesc.ScratchAccelerationStructureData = resources.blas[primitive.index].scratch->GetGPUVirtualAddress(); - buildDesc.DestAccelerationStructureData = resources.blas[primitive.index].as->GetGPUVirtualAddress(); + buildDesc.ScratchAccelerationStructureData = resources.blas[mesh.index].scratch->GetGPUVirtualAddress(); + buildDesc.DestAccelerationStructureData = resources.blas[mesh.index].as->GetGPUVirtualAddress(); d3d.cmdList->BuildRaytracingAccelerationStructure(&buildDesc, 0, nullptr); @@ -999,6 +1068,24 @@ namespace Graphics } #endif + #if GFX_NVAPI + // Fake UAV for NVAPI + D3D12_DESCRIPTOR_RANGE nvapiRange = {}; + nvapiRange.BaseShaderRegister = NV_SHADER_EXTN_SLOT; + nvapiRange.NumDescriptors = 1; + nvapiRange.RegisterSpace = NV_SHADER_EXTN_REGISTER_SPACE; + nvapiRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; + nvapiRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; + + // Root Parameter 2 (or 4): NVAPI + D3D12_ROOT_PARAMETER param = {}; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + param.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + param.DescriptorTable.NumDescriptorRanges = 1; + param.DescriptorTable.pDescriptorRanges = &nvapiRange; + rootParameters.push_back(param); + #endif + // Describe the root signature D3D12_ROOT_SIGNATURE_DESC desc = {}; desc.NumParameters = static_cast(rootParameters.size()); @@ -1105,11 +1192,13 @@ namespace Graphics SAFE_RELEASE(resources.lightsSTB); SAFE_RELEASE(resources.lightsSTBUpload); SAFE_RELEASE(resources.materialsSTB); - SAFE_RELEASE(resources.materialIndicesRB); + SAFE_RELEASE(resources.meshOffsetsRB); + SAFE_RELEASE(resources.geometryDataRB); resources.cameraCBPtr = nullptr; resources.lightsSTBPtr = nullptr; resources.materialsSTBPtr = nullptr; - resources.materialIndicesRBPtr = nullptr; + resources.meshOffsetsRBPtr = nullptr; + resources.geometryDataRBPtr = nullptr; // Render Targets SAFE_RELEASE(resources.rt.GBufferA); @@ -1172,6 +1261,10 @@ namespace Graphics SAFE_RELEASE(d3d.cmdQueue); SAFE_RELEASE(d3d.device); SAFE_RELEASE(d3d.factory); + + #if GFX_NVAPI + NvAPI_Unload(); + #endif } //---------------------------------------------------------------------------------------------------------- @@ -1212,7 +1305,7 @@ namespace Graphics */ bool CreateSceneLightsBuffer(Globals& d3d, Resources& resources, const Scenes::Scene& scene) { - UINT size = ALIGN(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT, Scenes::Light::GetGPUDataSize() * static_cast(scene.lights.size())); + UINT size = ALIGN(D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT, Scenes::Light::GetGPUDataSize() * static_cast(scene.lights.size())); if (size == 0) return true; // scenes with no lights are valid // Create the lights upload buffer resource @@ -1269,12 +1362,12 @@ namespace Graphics } /** - * Create the scene materials buffers. + * Create the scene materials buffer. */ - bool CreateSceneMaterialsBuffers(Globals& d3d, Resources& resources, const Scenes::Scene& scene) + bool CreateSceneMaterialsBuffer(Globals& d3d, Resources& resources, const Scenes::Scene& scene) { // Create the materials buffer upload resource - UINT size = ALIGN(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT, Scenes::Material::GetGPUDataSize() * static_cast(scene.materials.size())); + UINT size = ALIGN(D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT, Scenes::Material::GetGPUDataSize() * static_cast(scene.materials.size())); BufferDesc desc = { size, 0, EHeapType::UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_FLAG_NONE }; if (!CreateBuffer(d3d, desc, &resources.materialsSTBUpload)) return false; #ifdef GFX_NAME_OBJECTS @@ -1343,56 +1436,120 @@ namespace Graphics handle.ptr = resources.srvDescHeapStart.ptr + (DescriptorHeapOffsets::STB_MATERIALS * resources.srvDescHeapEntrySize); d3d.device->CreateShaderResourceView(resources.materialsSTB, &srvDesc, handle); - // Material Indices + return true; + } + + /** + * Create the scene material indexing buffers. + */ + bool CreateSceneMaterialIndexingBuffers(Globals& d3d, Resources& resources, const Scenes::Scene& scene) + { + // Mesh Offsets - // Create the material indices upload buffer resource - size = ALIGN(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT, sizeof(UINT) * scene.numMeshPrimitives); - desc = { size, 0, EHeapType::UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_FLAG_NONE }; - if (!CreateBuffer(d3d, desc, &resources.materialIndicesRBUpload)) return false; + // Create the mesh offsets upload buffer resource + UINT meshOffsetsSize = ALIGN(D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT, sizeof(UINT) * static_cast(scene.meshes.size()) ); + BufferDesc desc = { meshOffsetsSize, 0, EHeapType::UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_FLAG_NONE }; + if (!CreateBuffer(d3d, desc, &resources.meshOffsetsRBUpload)) return false; #ifdef GFX_NAME_OBJECTS - resources.materialIndicesRBUpload->SetName(L"Material Indices Upload Raw Buffer"); + resources.meshOffsetsRBUpload->SetName(L"Mesh Offsets Upload ByteAddressBuffer"); #endif - // Create the material indices device buffer resource - desc = { size, 0, EHeapType::DEFAULT, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_FLAG_NONE }; - if (!CreateBuffer(d3d, desc, &resources.materialIndicesRB)) return false; + // Create the mesh offsets device buffer resource + desc = { meshOffsetsSize, 0, EHeapType::DEFAULT, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_FLAG_NONE }; + if (!CreateBuffer(d3d, desc, &resources.meshOffsetsRB)) return false; + #ifdef GFX_NAME_OBJECTS + resources.meshOffsetsRB->SetName(L"Mesh Offsets ByteAddressBuffer"); + #endif + + // Geometry Data + + // Create the geometry (mesh primitive) data upload buffer resource + UINT geometryDataSize = ALIGN(D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT, sizeof(GeometryData) * scene.numMeshPrimitives); + desc = { geometryDataSize, 0, EHeapType::UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_FLAG_NONE }; + if (!CreateBuffer(d3d, desc, &resources.geometryDataRBUpload)) return false; + #ifdef GFX_NAME_OBJECTS + resources.geometryDataRBUpload->SetName(L"Geometry Data Upload ByteAddressBuffer"); + #endif + + // Create the geometry (mesh primitive) data device buffer resource + desc = { geometryDataSize, 0, EHeapType::DEFAULT, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_FLAG_NONE }; + if (!CreateBuffer(d3d, desc, &resources.geometryDataRB)) return false; #ifdef GFX_NAME_OBJECTS - resources.materialIndicesRB->SetName(L"Material Indices Raw Buffer"); + resources.geometryDataRB->SetName(L"Geometry Data ByteAddressBuffer"); #endif - // Copy the material indices to the upload buffer - offset = 0; - D3DCHECK(resources.materialIndicesRBUpload->Map(0, &readRange, reinterpret_cast(&resources.materialIndicesRBPtr))); + // Copy the mesh offsets and geometry data to the upload buffers + UINT primitiveOffset = 0; + D3D12_RANGE readRange = {}; + D3DCHECK(resources.meshOffsetsRBUpload->Map(0, &readRange, reinterpret_cast(&resources.meshOffsetsRBPtr))); + D3DCHECK(resources.geometryDataRBUpload->Map(0, &readRange, reinterpret_cast(&resources.geometryDataRBPtr))); + + UINT8* meshOffsetsAddress = resources.meshOffsetsRBPtr; + UINT8* geometryDataAddress = resources.geometryDataRBPtr; for (UINT meshIndex = 0; meshIndex < static_cast(scene.meshes.size()); meshIndex++) { - const Scenes::Mesh mesh = scene.meshes[meshIndex]; - for (UINT primitiveIndex = 0; primitiveIndex < static_cast(scene.meshes[meshIndex].primitives.size()); primitiveIndex++) + // Get the mesh + const Scenes::Mesh& mesh = scene.meshes[meshIndex]; + + // Copy the mesh offset to the upload buffer + UINT meshOffset = primitiveOffset * sizeof(GeometryData); + memcpy(meshOffsetsAddress, &meshOffset, sizeof(UINT)); + meshOffsetsAddress += sizeof(UINT); + + for (UINT primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) { - const Scenes::MeshPrimitive& primitive = scene.meshes[meshIndex].primitives[primitiveIndex]; - memcpy(resources.materialIndicesRBPtr + offset, &primitive.material, sizeof(UINT)); - offset += sizeof(UINT); + // Get the mesh primitive and copy its material index to the upload buffer + const Scenes::MeshPrimitive& primitive = mesh.primitives[primitiveIndex]; + + GeometryData data; + data.materialIndex = primitive.material; + data.indexByteAddress = primitive.indexByteOffset; + data.vertexByteAddress = primitive.vertexByteOffset; + memcpy(geometryDataAddress, &data, sizeof(GeometryData)); + + geometryDataAddress += sizeof(GeometryData); + primitiveOffset++; } } - resources.materialIndicesRBUpload->Unmap(0, nullptr); + resources.meshOffsetsRBUpload->Unmap(0, nullptr); + resources.geometryDataRBUpload->Unmap(0, nullptr); - // Schedule a copy of the upload buffer to the device buffer - d3d.cmdList->CopyBufferRegion(resources.materialIndicesRB, 0, resources.materialIndicesRBUpload, 0, size); + // Schedule a copy of the upload buffers to the device buffers + d3d.cmdList->CopyBufferRegion(resources.meshOffsetsRB, 0, resources.meshOffsetsRBUpload, 0, meshOffsetsSize); + d3d.cmdList->CopyBufferRegion(resources.geometryDataRB, 0, resources.geometryDataRBUpload, 0, geometryDataSize); - // Transition the default heap resource to generic read after the copy is complete - barrier.Transition.pResource = resources.materialIndicesRB; + // Transition the default heap resources to generic read after the copies are complete + std::vector barriers; - d3d.cmdList->ResourceBarrier(1, &barrier); + D3D12_RESOURCE_BARRIER barrier = {}; + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST; + barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_GENERIC_READ; + barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; + + barrier.Transition.pResource = resources.meshOffsetsRB; + barriers.push_back(barrier); + barrier.Transition.pResource = resources.geometryDataRB; + barriers.push_back(barrier); + + d3d.cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); - // Add the material indices ByteAddressBuffer SRV to the descriptor heap - srvDesc = {}; + // Add the mesh offsets ByteAddressBuffer SRV to the descriptor heap + D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; srvDesc.Format = DXGI_FORMAT_R32_TYPELESS; srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - srvDesc.Buffer.NumElements = scene.numMeshPrimitives; srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - handle.ptr = resources.srvDescHeapStart.ptr + (DescriptorHeapOffsets::SRV_MATERIAL_INDICES * resources.srvDescHeapEntrySize); - d3d.device->CreateShaderResourceView(resources.materialIndicesRB, &srvDesc, handle); + D3D12_CPU_DESCRIPTOR_HANDLE handle; + srvDesc.Buffer.NumElements = static_cast(scene.meshes.size()); + handle.ptr = resources.srvDescHeapStart.ptr + (DescriptorHeapOffsets::SRV_MESH_OFFSETS * resources.srvDescHeapEntrySize); + d3d.device->CreateShaderResourceView(resources.meshOffsetsRB, &srvDesc, handle); + + // Add the geometry (mesh primitive) data ByteAddressBuffer SRV to the descriptor heap + srvDesc.Buffer.NumElements = scene.numMeshPrimitives * (sizeof(GeometryData) / sizeof(UINT)); + handle.ptr = resources.srvDescHeapStart.ptr + (DescriptorHeapOffsets::SRV_GEOMETRY_DATA * resources.srvDescHeapEntrySize); + d3d.device->CreateShaderResourceView(resources.geometryDataRB, &srvDesc, handle); return true; } @@ -1403,7 +1560,7 @@ namespace Graphics bool CreateSceneInstancesBuffer(Globals& d3d, Resources& resources, const std::vector& instances) { // Create the TLAS instance upload buffer resource - UINT size = static_cast(instances.size()) * sizeof(D3D12_RAYTRACING_INSTANCE_DESC); + UINT size = ALIGN(D3D12_RAYTRACING_INSTANCE_DESCS_BYTE_ALIGNMENT, static_cast(instances.size()) * sizeof(D3D12_RAYTRACING_INSTANCE_DESC)); BufferDesc desc = { size, 0, EHeapType::UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_FLAG_NONE }; if (!CreateBuffer(d3d, desc, &resources.tlas.instancesUpload)) return false; #ifdef GFX_NAME_OBJECTS @@ -1453,124 +1610,99 @@ namespace Graphics } /** - * Create the scene geometry index buffers. + * Create the scene mesh index buffers. */ bool CreateSceneIndexBuffers(Globals& d3d, Resources& resources, const Scenes::Scene& scene) { - resources.sceneIBs.resize(scene.numMeshPrimitives); - resources.sceneIBUploadBuffers.resize(scene.numMeshPrimitives); - resources.sceneIBViews.resize(scene.numMeshPrimitives); - for (UINT meshIndex = 0; meshIndex < static_cast(scene.meshes.size()); meshIndex++) + UINT numMeshes = static_cast(scene.meshes.size()); + + resources.sceneIBs.resize(numMeshes); + resources.sceneIBUploadBuffers.resize(numMeshes); + resources.sceneIBViews.resize(numMeshes); + for (UINT meshIndex = 0; meshIndex < numMeshes; meshIndex++) { // Get the mesh - const Scenes::Mesh mesh = scene.meshes[meshIndex]; - for (UINT primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) - { - // Get the mesh primitive - const Scenes::MeshPrimitive primitive = mesh.primitives[primitiveIndex]; - - // Create the index buffer and copy the data to the GPU - if (!CreateIndexBuffer(d3d, primitive, - &resources.sceneIBs[primitive.index], - &resources.sceneIBUploadBuffers[primitive.index], - resources.sceneIBViews[primitive.index])) return false; - #ifdef GFX_NAME_OBJECTS - std::string name = "IB: "; - name.append(mesh.name.c_str()); - name.append(", Primitive: "); - name.append(std::to_string(primitiveIndex)); - std::wstring n = std::wstring(name.begin(), name.end()); - resources.sceneIBs[primitive.index]->SetName(n.c_str()); - #endif + const Scenes::Mesh& mesh = scene.meshes[meshIndex]; - // Add the index buffer SRV to the descriptor heap - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - srvDesc.Format = DXGI_FORMAT_R32_TYPELESS; - srvDesc.Buffer.NumElements = static_cast(primitive.indices.size()); - srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - - D3D12_CPU_DESCRIPTOR_HANDLE handle; - handle.ptr = resources.srvDescHeapStart.ptr + ((DescriptorHeapOffsets::SRV_INDICES + (primitive.index * 2)) * resources.srvDescHeapEntrySize); - d3d.device->CreateShaderResourceView(resources.sceneIBs[primitive.index], &srvDesc, handle); - } + // Create the index buffer and copy the index data to the GPU + if (!CreateIndexBuffer(d3d, mesh, + &resources.sceneIBs[meshIndex], + &resources.sceneIBUploadBuffers[meshIndex], + resources.sceneIBViews[meshIndex])) return false; + #ifdef GFX_NAME_OBJECTS + std::string name = "IB: " + mesh.name; + std::wstring n = std::wstring(name.begin(), name.end()); + resources.sceneIBs[meshIndex]->SetName(n.c_str()); + #endif + + // Add the index buffer SRV to the descriptor heap + D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; + srvDesc.Format = DXGI_FORMAT_R32_TYPELESS; + srvDesc.Buffer.NumElements = mesh.numIndices; + srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; + srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + + D3D12_CPU_DESCRIPTOR_HANDLE handle; + handle.ptr = resources.srvDescHeapStart.ptr + ((DescriptorHeapOffsets::SRV_INDICES + (meshIndex * 2)) * resources.srvDescHeapEntrySize); + d3d.device->CreateShaderResourceView(resources.sceneIBs[meshIndex], &srvDesc, handle); } return true; } /** - * Create the scene geometry vertex buffers. + * Create the scene mesh vertex buffers. */ bool CreateSceneVertexBuffers(Globals& d3d, Resources& resources, const Scenes::Scene& scene) { - resources.sceneVBs.resize(scene.numMeshPrimitives); - resources.sceneVBUploadBuffers.resize(scene.numMeshPrimitives); - resources.sceneVBViews.resize(scene.numMeshPrimitives); - for (UINT meshIndex = 0; meshIndex < static_cast(scene.meshes.size()); meshIndex++) + UINT numMeshes = static_cast(scene.meshes.size()); + + resources.sceneVBs.resize(numMeshes); + resources.sceneVBUploadBuffers.resize(numMeshes); + resources.sceneVBViews.resize(numMeshes); + for (UINT meshIndex = 0; meshIndex < numMeshes; meshIndex++) { // Get the mesh - const Scenes::Mesh mesh = scene.meshes[meshIndex]; - for (UINT primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) - { - // Get the mesh primitive - const Scenes::MeshPrimitive primitive = mesh.primitives[primitiveIndex]; - - // Create the vertex buffer and copy the data to the GPU - if (!CreateVertexBuffer(d3d, primitive, - &resources.sceneVBs[primitive.index], - &resources.sceneVBUploadBuffers[primitive.index], - resources.sceneVBViews[primitive.index])) return false; - #ifdef GFX_NAME_OBJECTS - std::string name = "VB: "; - name.append(mesh.name.c_str()); - name.append(", Primitive: "); - name.append(std::to_string(primitiveIndex)); - std::wstring n = std::wstring(name.begin(), name.end()); - resources.sceneVBs[primitive.index]->SetName(n.c_str()); - #endif + const Scenes::Mesh& mesh = scene.meshes[meshIndex]; - // Add the vertex buffer SRV to the descriptor heap - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - srvDesc.Format = DXGI_FORMAT_R32_TYPELESS; - srvDesc.Buffer.NumElements = (sizeof(Vertex) * static_cast(primitive.vertices.size())) / 4; - srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - - D3D12_CPU_DESCRIPTOR_HANDLE handle; - handle.ptr = resources.srvDescHeapStart.ptr + ((DescriptorHeapOffsets::SRV_VERTICES + (primitive.index * 2)) * resources.srvDescHeapEntrySize); - d3d.device->CreateShaderResourceView(resources.sceneVBs[primitive.index], &srvDesc, handle); - } + // Create the vertex buffer and copy the data to the GPU + if (!CreateVertexBuffer(d3d, mesh, + &resources.sceneVBs[meshIndex], + &resources.sceneVBUploadBuffers[meshIndex], + resources.sceneVBViews[meshIndex])) return false; + #ifdef GFX_NAME_OBJECTS + std::string name = "VB: " + mesh.name; + std::wstring n = std::wstring(name.begin(), name.end()); + resources.sceneVBs[meshIndex]->SetName(n.c_str()); + #endif + + // Add the vertex buffer SRV to the descriptor heap + D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; + srvDesc.Format = DXGI_FORMAT_R32_TYPELESS; + srvDesc.Buffer.NumElements = (sizeof(Vertex) * mesh.numVertices) / 4; + srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; + srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + + D3D12_CPU_DESCRIPTOR_HANDLE handle; + handle.ptr = resources.srvDescHeapStart.ptr + ((DescriptorHeapOffsets::SRV_VERTICES + (meshIndex * 2)) * resources.srvDescHeapEntrySize); + d3d.device->CreateShaderResourceView(resources.sceneVBs[meshIndex], &srvDesc, handle); } return true; } /** - * Create the scene's bottom level acceleration structures. + * Create the scene's bottom level acceleration structure(s). */ bool CreateSceneBLAS(Globals& d3d, Resources& resources, const Scenes::Scene& scene) { - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS buildFlags = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_TRACE; - - // Describe the BLAS geometry. Each mesh primitive populates a BLAS. - resources.blas.resize(scene.numMeshPrimitives); + // Build a BLAS for each mesh + resources.blas.resize(scene.meshes.size()); for (UINT meshIndex = 0; meshIndex < static_cast(scene.meshes.size()); meshIndex++) { - // Get the mesh + // Get the mesh and create its BLAS const Scenes::Mesh mesh = scene.meshes[meshIndex]; - for (UINT primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) - { - // Get the mesh primitive - const Scenes::MeshPrimitive primitive = mesh.primitives[primitiveIndex]; - - #ifdef GFX_NAME_OBJECTS - std::string debugName = "BLAS: " + mesh.name + ", Primitive: " + std::to_string(primitiveIndex); - if (!CreateBLAS(d3d, resources, primitive, debugName)) return false; - #else - if (!CreateBLAS(d3d, resources, primitive)) return false; - #endif - } + if (!CreateBLAS(d3d, resources, mesh)) return false; } // Wait for the BLAS builds to complete @@ -1591,32 +1723,23 @@ namespace Graphics std::vector instances; for (size_t instanceIndex = 0; instanceIndex < scene.instances.size(); instanceIndex++) { - const Scenes::MeshInstance instance = scene.instances[instanceIndex]; - const Scenes::Mesh mesh = scene.meshes[instance.meshIndex]; - for (size_t primitiveIndex = 0; primitiveIndex < mesh.primitives.size(); primitiveIndex++) - { - const Scenes::MeshPrimitive primitive = mesh.primitives[primitiveIndex]; - - // Describe the mesh primitive instance - D3D12_RAYTRACING_INSTANCE_DESC desc = {}; - desc.InstanceID = primitive.index; // For indexing into the MeshPrimitives and MaterialIndices arrays. Requires 1 MeshPrimitive per BLAS. - desc.InstanceMask = 0xFF; - desc.AccelerationStructure = resources.blas[primitive.index].as->GetGPUVirtualAddress(); - #if COORDINATE_SYSTEM == COORDINATE_SYSTEM_LEFT || COORDINATE_SYSTEM == COORDINATE_SYSTEM_LEFT_Z_UP - desc.Flags = D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE; - #endif - - // Disable front or back face culling for meshes with double sided materials - if (scene.materials[primitive.material].data.doubleSided) - { - desc.Flags |= D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_CULL_DISABLE; - } + // Get the mesh instance + const Scenes::MeshInstance& instance = scene.instances[instanceIndex]; + + // Describe the mesh instance + D3D12_RAYTRACING_INSTANCE_DESC desc = {}; + desc.InstanceID = instance.meshIndex; // quantized to 24-bits + desc.InstanceMask = 0xFF; + desc.AccelerationStructure = resources.blas[instance.meshIndex].as->GetGPUVirtualAddress(); + #if COORDINATE_SYSTEM == COORDINATE_SYSTEM_LEFT || COORDINATE_SYSTEM == COORDINATE_SYSTEM_LEFT_Z_UP + desc.Flags = D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE; + #endif + desc.Flags |= D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_CULL_DISABLE; - // Write the instance transform - memcpy(desc.Transform, instance.transform, sizeof(XMFLOAT4) * 3); + // Write the instance transform + memcpy(desc.Transform, instance.transform, sizeof(XMFLOAT4) * 3); - instances.push_back(desc); - } + instances.push_back(desc); } // Create the TLAS instances buffer @@ -1741,14 +1864,23 @@ namespace Graphics // Create a command allocator ID3D12CommandAllocator* commandAlloc = nullptr; D3DCHECK(d3d.device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&commandAlloc))); + #ifdef GFX_NAME_OBJECTS + d3d.cmdList->SetName(L"WriteResourceToDisk Command Allocator"); + #endif // Create a command list ID3D12GraphicsCommandList* commandList = nullptr; D3DCHECK(d3d.device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAlloc, nullptr, IID_PPV_ARGS(&commandList))); + #ifdef GFX_NAME_OBJECTS + d3d.cmdList->SetName(L"WriteResourceToDisk Command List"); + #endif // Create fence ID3D12Fence* fence = nullptr; D3DCHECK(d3d.device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence))); + #ifdef GFX_NAME_OBJECTS + d3d.cmdList->SetName(L"WriteResourceToDisk Fence"); + #endif // Get the resource descriptor const D3D12_RESOURCE_DESC desc = pResource->GetDesc(); @@ -1910,7 +2042,7 @@ namespace Graphics glfwSetWindowMonitor(d3d.window, monitor, d3d.x, d3d.y, d3d.windowWidth, d3d.windowHeight, d3d.vsync ? 60 : GLFW_DONT_CARE); } - d3d.fullscreen = !d3d.fullscreen; + d3d.fullscreen = ~d3d.fullscreen; d3d.fullscreenChanged = false; return true; } @@ -1931,6 +2063,10 @@ namespace Graphics } #endif + #if GFX_NVAPI + NvAPI_Initialize(); + #endif + // Create a DXGI factory if (FAILED(CreateDXGIFactory2(0, IID_PPV_ARGS(&d3d.factory)))) return false; @@ -1938,7 +2074,7 @@ namespace Graphics if (!CheckTearingSupport(d3d)) return false; // Create the device - return CreateDeviceInternal(d3d.device, d3d.factory, config); + return CreateDeviceInternal(d3d, config); } /** @@ -1996,6 +2132,10 @@ namespace Graphics { heapProps = uploadHeapProps; } + else if (info.heap == EHeapType::READBACK) + { + heapProps = readbackHeapProps; + } // Create the buffer resource D3DCHECK(d3d.device->CreateCommittedResource(&heapProps, D3D12_HEAP_FLAG_NONE, &desc, info.state, nullptr, IID_PPV_ARGS(ppResource))); @@ -2285,11 +2425,24 @@ namespace Graphics pipelineDesc.NumSubobjects = static_cast(subobjects.size()); pipelineDesc.pSubobjects = subobjects.data(); + #if GFX_NVAPI + // Enable NVAPI extension shader slot + NvAPI_Status status = NvAPI_D3D12_SetNvShaderExtnSlotSpace(device, NV_SHADER_EXTN_SLOT, NV_SHADER_EXTN_REGISTER_SPACE); + assert(status == NVAPI_OK); + #endif + // Create the RT Pipeline State Object (RTPSO) D3DCHECK(device->CreateStateObject(&pipelineDesc, IID_PPV_ARGS(rtpso))); // Get the RT Pipeline State Object properties D3DCHECK((*rtpso)->QueryInterface(IID_PPV_ARGS(rtpsoProps))); + + #if GFX_NVAPI + // Disable NVAPI extension shader slot after the state object is created + status = NvAPI_D3D12_SetNvShaderExtnSlotSpace(device, ~0u, 0); + assert(status == NVAPI_OK); + #endif + return true; } @@ -2333,7 +2486,8 @@ namespace Graphics // Create scene specific resources CHECK(CreateSceneCameraConstantBuffer(d3d, resources, scene), "create scene camera constant buffer!", log); CHECK(CreateSceneLightsBuffer(d3d, resources, scene), "create scene lights structured buffer!", log); - CHECK(CreateSceneMaterialsBuffers(d3d, resources, scene), "create scene materials buffers!", log); + CHECK(CreateSceneMaterialsBuffer(d3d, resources, scene), "create scene materials buffer!", log); + CHECK(CreateSceneMaterialIndexingBuffers(d3d, resources, scene), "create scene material indexing buffers!", log); CHECK(CreateSceneIndexBuffers(d3d, resources, scene), "create scene index buffers!", log); CHECK(CreateSceneVertexBuffers(d3d, resources, scene), "create scene vertex buffers!", log); CHECK(CreateSceneBLAS(d3d, resources, scene), "create scene bottom level acceleration structures!", log); @@ -2347,7 +2501,8 @@ namespace Graphics // Release upload buffers SAFE_RELEASE(resources.materialsSTBUpload); - SAFE_RELEASE(resources.materialIndicesRBUpload); + SAFE_RELEASE(resources.meshOffsetsRBUpload); + SAFE_RELEASE(resources.geometryDataRBUpload); SAFE_RELEASE(resources.tlas.instancesUpload); // Release scene geometry upload buffers diff --git a/samples/test-harness/src/Geometry.cpp b/samples/test-harness/src/Geometry.cpp index 9354ab6..7e3075b 100644 --- a/samples/test-harness/src/Geometry.cpp +++ b/samples/test-harness/src/Geometry.cpp @@ -126,10 +126,14 @@ namespace Geometry // Public Functions //---------------------------------------------------------------------------------------------------------- - void CreateSphere(uint32_t latitudes, uint32_t longitudes, Scenes::MeshPrimitive& mesh) + void CreateSphere(uint32_t latitudes, uint32_t longitudes, Scenes::Mesh& mesh) { - mesh.vertices = GetSphereVertices(latitudes, longitudes); - mesh.indices = GetSphereIndices(latitudes, longitudes, static_cast(mesh.vertices.size())); + Scenes::MeshPrimitive& primitive = mesh.primitives.emplace_back(); + primitive.vertices = GetSphereVertices(latitudes, longitudes); + primitive.indices = GetSphereIndices(latitudes, longitudes, static_cast(primitive.vertices.size())); + + mesh.numVertices = static_cast(primitive.vertices.size()); + mesh.numIndices = static_cast(primitive.indices.size()); } } diff --git a/samples/test-harness/src/ImageCapture.cpp b/samples/test-harness/src/ImageCapture.cpp index e4d566a..54bf496 100644 --- a/samples/test-harness/src/ImageCapture.cpp +++ b/samples/test-harness/src/ImageCapture.cpp @@ -87,6 +87,8 @@ namespace ImageCapture case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: pfGuid = GUID_WICPixelFormat32bppBGRA; sRGB = true; break; case DXGI_FORMAT_B8G8R8X8_UNORM: pfGuid = GUID_WICPixelFormat32bppBGR; break; case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: pfGuid = GUID_WICPixelFormat32bppBGR; sRGB = true; break; + // WIC does not have two-channel formats, four-channel lets us output all data for bitwise comparisons + case DXGI_FORMAT_R32G32_FLOAT: pfGuid = GUID_WICPixelFormat128bppRGBAFloat; break; default: return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); } diff --git a/samples/test-harness/src/Scenes.cpp b/samples/test-harness/src/Scenes.cpp index 268d63d..836dc8f 100644 --- a/samples/test-harness/src/Scenes.cpp +++ b/samples/test-harness/src/Scenes.cpp @@ -309,32 +309,38 @@ namespace Scenes Mesh mesh; mesh.name = gltfMesh.name; + mesh.numVertices = 0; + mesh.numIndices = 0; if (mesh.name.compare("") == 0) mesh.name = "Mesh_" + std::to_string(meshIndex); // Initialize the mesh bounding box mesh.boundingBox.min = { FLT_MAX, FLT_MAX, FLT_MAX }; mesh.boundingBox.max = { -FLT_MAX, -FLT_MAX, -FLT_MAX }; + uint32_t vertexByteOffset = 0; + uint32_t indexByteOffset = 0; for (uint32_t primitiveIndex = 0; primitiveIndex < static_cast(gltfMesh.primitives.size()); primitiveIndex++) { // Get a reference to the mesh primitive const tinygltf::Primitive& p = gltfMesh.primitives[primitiveIndex]; - MeshPrimitive m; - m.index = geometryIndex; - m.material = p.material; + MeshPrimitive mp; + mp.index = geometryIndex; + mp.material = p.material; + mp.vertexByteOffset = vertexByteOffset; + mp.indexByteOffset = indexByteOffset; // Initialize the mesh primitive bounding box - m.boundingBox.min = { FLT_MAX, FLT_MAX, FLT_MAX }; - m.boundingBox.max = { -FLT_MAX, -FLT_MAX, -FLT_MAX }; + mp.boundingBox.min = { FLT_MAX, FLT_MAX, FLT_MAX }; + mp.boundingBox.max = { -FLT_MAX, -FLT_MAX, -FLT_MAX }; // Set the mesh primitive's material to the default material if one is not assigned or if no materials exist in the GLTF - if (m.material == -1) m.material = 0; + if (mp.material == -1) mp.material = 0; // Get a reference to the mesh primitive's material // If the mesh primitive material is blended or masked, it is not opaque - const Material& mat = scene.materials[m.material]; - if (mat.data.alphaMode != 0) m.opaque = false; + const Material& mat = scene.materials[mp.material]; + if (mat.data.alphaMode != 0) mp.opaque = false; // Get data indices int indicesIndex = p.indices; @@ -377,7 +383,7 @@ namespace Scenes const tinygltf::Buffer& indexBuffer = gltfData.buffers[indexBufferView.buffer]; const uint8_t* indexBufferAddress = indexBuffer.data.data(); int indexStride = tinygltf::GetComponentSizeInBytes(indexAccessor.componentType) * tinygltf::GetNumComponentsInType(indexAccessor.type); - m.indices.resize(indexAccessor.count); + mp.indices.resize(indexAccessor.count); // Vertex normals tinygltf::Accessor normalAccessor; @@ -493,10 +499,11 @@ namespace Scenes } // Update the mesh primitive's bounding box - m.boundingBox.min = rtxgi::Min(m.boundingBox.min, v.position); - m.boundingBox.max = rtxgi::Max(m.boundingBox.max, v.position); + mp.boundingBox.min = rtxgi::Min(mp.boundingBox.min, v.position); + mp.boundingBox.max = rtxgi::Max(mp.boundingBox.max, v.position); - m.vertices.push_back(v); + mp.vertices.push_back(v); + mesh.numVertices++; } // Get the index data @@ -513,7 +520,7 @@ namespace Scenes // Convert quarter precision indices to full precision for (size_t i = 0; i < indexAccessor.count; i++) { - m.indices[i] = quarter[i]; + mp.indices[i] = quarter[i]; } } else if (indexStride == 2) @@ -526,27 +533,33 @@ namespace Scenes // Convert half precision indices to full precision for (size_t i = 0; i < indexAccessor.count; i++) { - m.indices[i] = half[i]; + mp.indices[i] = half[i]; } } else { - memcpy(m.indices.data(), baseAddress, (indexAccessor.count * indexStride)); + memcpy(mp.indices.data(), baseAddress, (indexAccessor.count * indexStride)); } + // Update byte offsets + vertexByteOffset += static_cast(mp.vertices.size()) * sizeof(Graphics::Vertex); + indexByteOffset += static_cast(mp.indices.size()) * sizeof(UINT); + // Increment the triangle count - scene.numTriangles += static_cast(indexAccessor.count) / 3; + mesh.numIndices += static_cast(indexAccessor.count); + scene.numTriangles += mesh.numIndices / 3; // Update the mesh's bounding box - mesh.boundingBox.min = rtxgi::Min(mesh.boundingBox.min, m.boundingBox.min); - mesh.boundingBox.max = rtxgi::Max(mesh.boundingBox.max, m.boundingBox.max); + mesh.boundingBox.min = rtxgi::Min(mesh.boundingBox.min, mp.boundingBox.min); + mesh.boundingBox.max = rtxgi::Max(mesh.boundingBox.max, mp.boundingBox.max); // Add the mesh primitive - mesh.primitives.push_back(m); + mesh.primitives.push_back(mp); geometryIndex++; } + mesh.index = static_cast(scene.meshes.size()); scene.meshes.push_back(mesh); } diff --git a/samples/test-harness/src/UI.cpp b/samples/test-harness/src/UI.cpp index 1c5ba8e..c43e6c8 100644 --- a/samples/test-harness/src/UI.cpp +++ b/samples/test-harness/src/UI.cpp @@ -209,7 +209,7 @@ namespace Graphics /** * Converts a number to formatted text. */ - void AddQuantityText(int value, std::string message) + void AddIntQuantityText(int value, std::string message) { // Format text std::string number = std::to_string(value); @@ -222,6 +222,16 @@ namespace Graphics ImGui::Text("%s", message.c_str()); } + void AddFloatQuantityText(float value, std::string message) + { + // Format text + std::string number = std::to_string(value); + + ImGui::Text("%s", std::string(number).c_str()); + ImGui::SameLine(); + ImGui::Text("%s", message.c_str()); + } + /** * Creates the main debug window. */ @@ -229,6 +239,11 @@ namespace Graphics { SetupStyle(); + bool skyChanged = false; + bool anyLightChanged = false; + std::vector volumeChanged; + volumeChanged.resize(volumes.size()); + // Size the debug window based on the application height ImGui::SetNextWindowSize(ImVec2(debugWindowWidth, gfx.height - 40.f)); ImGui::Begin("Settings (Press 'u' to hide)", NULL, ImGuiWindowFlags_AlwaysAutoResize); @@ -381,11 +396,11 @@ namespace Graphics if (ImGui::CollapsingHeader("Scene", ImGuiTreeNodeFlags_CollapsingHeader)) { ImGui::Text("%s", scene.name.c_str()); - AddQuantityText(static_cast(scene.materials.size()), "Materials"); - AddQuantityText(static_cast(scene.meshes.size()), "Mesh"); - AddQuantityText(static_cast(scene.numMeshPrimitives), "Mesh Primitives"); - AddQuantityText(static_cast(scene.instances.size()), "Mesh Instances"); - AddQuantityText(static_cast(scene.numTriangles), "Triangles (unique, not instanced)"); + AddIntQuantityText(static_cast(scene.materials.size()), "Materials"); + AddIntQuantityText(static_cast(scene.meshes.size()), "Mesh"); + AddIntQuantityText(static_cast(scene.numMeshPrimitives), "Mesh Primitives"); + AddIntQuantityText(static_cast(scene.instances.size()), "Mesh Instances"); + AddIntQuantityText(static_cast(scene.numTriangles), "Triangles (unique, not instanced)"); } PopColorStyle(); @@ -441,10 +456,11 @@ namespace Graphics float3 skyColor = { config.scene.skyColor.x, config.scene.skyColor.y, config.scene.skyColor.z }; if (AddColorSlider(skyColor, "##skyColor", "Adjust the color of the sky")) { + skyChanged = true; config.scene.skyColor = { skyColor.x, skyColor.y, skyColor.z }; } - AddSlider(config.scene.skyIntensity, 0.f, 8.f, 0.1f, "##sceneSkyIntensity", "Sky Intensity", "Adjust the intensity of the sky light spot light"); + skyChanged |= AddSlider(config.scene.skyIntensity, 0.f, 8.f, 0.1f, "##sceneSkyIntensity", "Sky Intensity", "Adjust the intensity of the sky light spot light"); } PopColorStyle(); @@ -487,6 +503,7 @@ namespace Graphics scene.lights[0].dirty = true; scene.lights[0].data.power = light.power; } + anyLightChanged = anyLightChanged || scene.lights[0].dirty; } else { @@ -570,6 +587,7 @@ namespace Graphics scene.lights[currentItem].dirty = true; scene.lights[currentItem].data.penumbraAngle = light.penumbraAngle; } + anyLightChanged = anyLightChanged || scene.lights[currentItem].dirty; } else { @@ -612,7 +630,7 @@ namespace Graphics } // Color - if (AddColorSlider(light.color, "##pointLightColor", "Adjust the color of the point light")) + if (AddColorSlider(light.color, "##pointLightColor", "Adjust the color of the point light")) { scene.lights[currentItem].dirty = true; scene.lights[currentItem].data.color = light.color; @@ -631,6 +649,8 @@ namespace Graphics scene.lights[currentItem].dirty = true; scene.lights[currentItem].data.power = light.power; } + + anyLightChanged = anyLightChanged || scene.lights[currentItem].dirty; } else { @@ -641,6 +661,7 @@ namespace Graphics ImGui::Dummy(ImVec2(0, 3.f)); ImGui::EndTabBar(); } + } PopColorStyle(); @@ -662,6 +683,15 @@ namespace Graphics ImGui::PushItemWidth(ImGui::GetWindowWidth()); + ImGui::Checkbox("Antialiasing", &config.pathTrace.antialiasing); + ImGui::SameLine(); AddQuestionMark("Enable or disable antialiasing"); + + if (gfx.supportsShaderExecutionReordering) + { + ImGui::Checkbox("Shader Execution Reordering", &config.pathTrace.shaderExecutionReordering); + ImGui::SameLine(); AddQuestionMark("Enable or disable shader execution reordering (RTX 4000 series)"); + } + ImGui::DragFloat("##ptNormalBias", &config.pathTrace.rayNormalBias, 0.0001f, 0.f, 10.f, "Ray Normal Bias: %.4f"); AddHoverToolTip("A world-space distance along the surface normal, used to avoid self intersection"); @@ -674,9 +704,6 @@ namespace Graphics ImGui::DragInt("##ptNumBounces", &numBounces, 1, 1, 20, "Bounces Per Path: %.i"); AddHoverToolTip("The maximum number of bounces allowed per path"); - ImGui::Checkbox("Antialiasing", &config.pathTrace.antialiasing); - ImGui::SameLine(); AddQuestionMark("Enable or disable antialiasing"); - config.pathTrace.numBounces = static_cast(numBounces); config.pathTrace.samplesPerPixel = static_cast(numPaths); @@ -714,6 +741,12 @@ namespace Graphics } ImGui::SameLine(); AddQuestionMark("Toggle inserting DDGI performance markers in the graphics command list."); + if (gfx.supportsShaderExecutionReordering) + { + ImGui::Checkbox("Shader Execution Reordering", &config.ddgi.shaderExecutionReordering); + ImGui::SameLine(); AddQuestionMark("Enable or disable shader execution reordering (RTX 4000 series)"); + } + ImGui::Checkbox("Show Indirect Lighting", &config.ddgi.showIndirect); ImGui::SameLine(); AddQuestionMark("Show only the indirect lighting contribution. Press '2' on the keyboard for a shortcut."); @@ -733,6 +766,7 @@ namespace Graphics AddSlider(selectedVolumeConfig.probeIrradianceScale, 0.f, 10.f, 0.1f, "##irradianceTextureScale", "Irradiance Texture Scale", "Adjust the display size of the volume's irradiance texture data"); AddSlider(selectedVolumeConfig.probeDistanceScale, 0.f, 10.f, 0.1f, "##distanceTextureScale", "Distance Texture Scale", "Adjust the display size of the volume's distance texture data"); + AddSlider(selectedVolumeConfig.probeVariabilityScale, 0.f, 10.f, 0.1f, "##variTextureScale", "Variability Texture Scale", "Adjust the display size of the volume's variability texture data"); if (selectedVolumeConfig.probeClassificationEnabled) { @@ -770,18 +804,23 @@ namespace Graphics std::stringstream msg; msg << "Probes (" << std::to_string(desc.probeCounts.x) << ", " << std::to_string(desc.probeCounts.y) << ", " << std::to_string(desc.probeCounts.z) << ")"; - AddQuantityText(volume->GetNumProbes(), msg.str()); - AddQuantityText(desc.probeNumRays, "Rays Per Probe"); - AddQuantityText(desc.probeNumRays * volume->GetNumProbes(), "Probe Rays Per Frame (max)"); - AddQuantityText(desc.probeNumRays * volume->GetNumProbes() * 2, "Rays Per Frame (max) - includes shadow rays"); + AddIntQuantityText(volume->GetNumProbes(), msg.str()); + AddIntQuantityText(desc.probeNumRays, "Rays Per Probe"); + AddIntQuantityText(desc.probeNumRays * volume->GetNumProbes(), "Probe Rays Per Frame (max)"); + AddIntQuantityText(desc.probeNumRays * volume->GetNumProbes() * 2, "Rays Per Frame (max) - includes shadow rays"); + if (volume->GetProbeVariabilityEnabled()) + { + AddFloatQuantityText(volume->GetVolumeAverageVariability(), "Probe Variability Average"); + } int memory = (int)ceil((float)volume->GetGPUMemoryUsedInBytes() / 1024.f); - AddQuantityText(memory, "KiB of GPU memory used"); + AddIntQuantityText(memory, "KiB of GPU memory used"); // Clear probes button if (ImGui::Button("Clear Probes")) { config.ddgi.volumes[config.ddgi.selectedVolume].clearProbes = 1; + volumeChanged[config.ddgi.selectedVolume] = true; } if (ImGui::Checkbox("Insert Performance Markers##ddgivolume-perf-markers", &config.ddgi.volumes[config.ddgi.selectedVolume].insertPerfMarkers)) @@ -909,19 +948,27 @@ namespace Graphics ImGui::Unindent(20.f); } + // Probe Variability options + { + if (ImGui::Checkbox("Probe Variability", &config.ddgi.volumes[config.ddgi.selectedVolume].probeVariabilityEnabled)) + { + volume->SetProbeVariabilityEnabled(config.ddgi.volumes[config.ddgi.selectedVolume].probeVariabilityEnabled); + } + ImGui::SameLine(); AddQuestionMark("Probe variability tracks the coefficient of variation of the volume over time. Users can use this value as a proxy for how converged a volume is."); + + if (config.ddgi.volumes[config.ddgi.selectedVolume].probeVariabilityEnabled) + { + AddSlider(config.ddgi.volumes[config.ddgi.selectedVolume].probeVariabilityThreshold, 0.f, 1.f, 0.001f, "##variTextureThreshold", "Variability Threshold", "Variability threshold below which the volume is considered converged and will stop updates."); + } + } + // Infinite Scrolling options { - bool value = (volume->GetMovementType() == EDDGIVolumeMovementType::Scrolling); - if (ImGui::Checkbox("Infinite Scrolling Volume", &value)) + bool type = (volume->GetMovementType() == EDDGIVolumeMovementType::Scrolling); + if (ImGui::Checkbox("Infinite Scrolling Volume", &type)) { - if (value) - { - volume->SetMovementType(EDDGIVolumeMovementType::Scrolling); - } - else - { - volume->SetMovementType(EDDGIVolumeMovementType::Default); - } + if (type) volume->SetMovementType(EDDGIVolumeMovementType::Scrolling); + else volume->SetMovementType(EDDGIVolumeMovementType::Default); } ImGui::SameLine(); AddQuestionMark("Infinite scrolling volumes reuse probes as the volume moves by moving \"planes\" of probes from one side of the volume to the other, in the direction of movement. This method keeps all probes stationary for as long as possible to maximize irradiance stability."); @@ -945,6 +992,7 @@ namespace Graphics if (AddFloat3Slider(desc.origin, step, -max, max, "##volumeOrigin", "Origin", "Adjust the world-space position of the DDGIVolume's origin")) { volume->SetOrigin(desc.origin); + volumeChanged[config.ddgi.selectedVolume] = true; } // Rotation @@ -955,6 +1003,7 @@ namespace Graphics desc.eulerAngles.y = rtxgi::DegreesToRadians(degrees.y); desc.eulerAngles.z = rtxgi::DegreesToRadians(degrees.z); volume->SetEulerAngles(desc.eulerAngles); + volumeChanged[config.ddgi.selectedVolume] = true; } } else if(volume->GetMovementType() == EDDGIVolumeMovementType::Scrolling) @@ -964,6 +1013,7 @@ namespace Graphics if (AddFloat3Slider(anchor, step, -10000.f, 10000.f, "##volumeScrollingAnchor", "Scrolling Anchor", "The world-space position of the infinite scrolling volume tries to move its origin to")) { volume->SetScrollAnchor({ anchor.x, anchor.y, anchor.z }); + volumeChanged[config.ddgi.selectedVolume] = true; } } @@ -971,6 +1021,7 @@ namespace Graphics if (AddFloat3Slider(desc.probeSpacing, step, 0.f, max, "##volumeProbeSpacing", "Probe Spacing", "Adjust the world-space distance between probes")) { volume->SetProbeSpacing(desc.probeSpacing); + volumeChanged[config.ddgi.selectedVolume] = true; } AddTextSeparator(); @@ -1041,6 +1092,18 @@ namespace Graphics } PopColorStyle(); + + // If the sky changed, any light changed, or the volume changed, probe variability data is no longer valid and should be cleared + for (uint32_t volumeIndex = 0; volumeIndex < static_cast(config.ddgi.volumes.size()); volumeIndex++) + { + Configs::DDGIVolume& volume = config.ddgi.volumes[volumeIndex]; + if (volume.probeVariabilityEnabled) + { + volume.clearProbeVariability = (skyChanged || anyLightChanged || volumeChanged[volumeIndex]); + } + } + + // RTAO Options PushColorStyle(90, 60, 70); if (ImGui::CollapsingHeader("Ray Traced Ambient Occlusion", ImGuiTreeNodeFlags_CollapsingHeader)) diff --git a/samples/test-harness/src/Vulkan.cpp b/samples/test-harness/src/Vulkan.cpp index 89839ae..adaaaab 100644 --- a/samples/test-harness/src/Vulkan.cpp +++ b/samples/test-harness/src/Vulkan.cpp @@ -66,7 +66,7 @@ namespace Graphics if(hr == VK_ERROR_OUT_OF_DATE_KHR) return false; // window resized or destroyed if(hr != VK_SUCCESS) { - std::string msg = "Vulkan call failed in:\n" + fileName + " at line " + std::to_string(lineNumber); + std::string msg = "Vulkan call failed in:\n" + fileName + " at line " + std::to_string(lineNumber) + " where VkResult=" + std::to_string(hr); Graphics::UI::MessageBox(msg); return false; } @@ -420,12 +420,16 @@ namespace Graphics vk.deviceProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; vk.deviceASProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR; vk.deviceRTPipelineProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR; + vk.deviceSubgroupProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES; + vk.deviceASProps.pNext = &vk.deviceSubgroupProps; vk.deviceRTPipelineProps.pNext = &vk.deviceASProps; vk.deviceProps.pNext = &vk.deviceRTPipelineProps; vkGetPhysicalDeviceProperties2(vk.physicalDevice, &vk.deviceProps); + vk.features.waveLaneCount = vk.deviceSubgroupProps.subgroupSize; + // Set the graphics API name config.app.api = "Vulkan 1.2"; @@ -865,32 +869,38 @@ namespace Graphics } /** - * Create the index buffer and device memory for a mesh primitive. + * Create the index buffer and device memory for a mesh. * Copy the index data to the upload buffer and schedule a copy to the device buffer. */ - bool CreateIndexBuffer(Globals& vk, const Scenes::MeshPrimitive& primitive, VkBuffer* ib, VkDeviceMemory* ibMemory, VkBuffer* ibUpload, VkDeviceMemory* ibUploadMemory) + bool CreateIndexBuffer(Globals& vk, const Scenes::Mesh& mesh, VkBuffer* ib, VkDeviceMemory* ibMemory, VkBuffer* ibUpload, VkDeviceMemory* ibUploadMemory) { - uint32_t index = primitive.index; - - // Create the upload buffer - uint32_t size = static_cast(primitive.indices.size()) * sizeof(uint32_t); - BufferDesc desc = { size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT }; + // Create the index buffer upload resource + uint32_t sizeInBytes = mesh.numIndices * sizeof(uint32_t); + BufferDesc desc = { sizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT }; if (!CreateBuffer(vk, desc, ibUpload, ibUploadMemory)) return false; - // Create the device index buffer + // Create the index buffer device resource desc.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; desc.memoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; if (!CreateBuffer(vk, desc, ib, ibMemory)) return false; - // Copy the index data to the upload buffer + // Copy the index data of each mesh primitive to the upload buffer uint8_t* pData = nullptr; VKCHECK(vkMapMemory(vk.device, *ibUploadMemory, 0, VK_WHOLE_SIZE, 0, reinterpret_cast(&pData))); - memcpy(pData, primitive.indices.data(), size); + + for (uint32_t primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) + { + // Get the mesh primitive and copy its indices to the upload buffer + const Scenes::MeshPrimitive& primitive = mesh.primitives[primitiveIndex]; + + uint32_t size = static_cast(primitive.indices.size()) * sizeof(uint32_t); + memcpy(pData + primitive.indexByteOffset, primitive.indices.data(), size); + } vkUnmapMemory(vk.device, *ibUploadMemory); // Schedule a copy of the upload buffer to the device buffer VkBufferCopy bufferCopy = {}; - bufferCopy.size = size; + bufferCopy.size = sizeInBytes; vkCmdCopyBuffer(vk.cmdBuffer[vk.frameIndex], *ibUpload, *ib, 1, &bufferCopy); return true; @@ -900,29 +910,36 @@ namespace Graphics * Create the vertex buffer and device memory for a mesh primitive. * Copy the vertex data to the upload buffer and schedule a copy to the device buffer. */ - bool CreateVertexBuffer(Globals& vk, const Scenes::MeshPrimitive& primitive, VkBuffer* vb, VkDeviceMemory* vbMemory, VkBuffer* vbUpload, VkDeviceMemory* vbUploadMemory) + bool CreateVertexBuffer(Globals& vk, const Scenes::Mesh& mesh, VkBuffer* vb, VkDeviceMemory* vbMemory, VkBuffer* vbUpload, VkDeviceMemory* vbUploadMemory) { - uint32_t index = primitive.index; - - // Create upload buffer - uint32_t size = static_cast(primitive.vertices.size()) * sizeof(Vertex); - BufferDesc desc = { size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT }; + // Create the vertex buffer upload resource + uint32_t stride = sizeof(Vertex); + uint32_t sizeInBytes = mesh.numVertices * stride; + BufferDesc desc = { sizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT }; if (!CreateBuffer(vk, desc, vbUpload, vbUploadMemory)) return false; - // Create the device vertex buffer + // Create the vertex buffer device resource desc.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; desc.memoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; if (!CreateBuffer(vk, desc, vb, vbMemory)) return false; - // Copy the vertex data to the upload buffer + // Copy the vertex data of each mesh primitive to the upload uint8_t* pData = nullptr; VKCHECK(vkMapMemory(vk.device, *vbUploadMemory, 0, VK_WHOLE_SIZE, 0, reinterpret_cast(&pData))); - memcpy(pData, primitive.vertices.data(), size); + + for (uint32_t primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) + { + // Get the mesh primitive and copy its vertices to the upload buffer + const Scenes::MeshPrimitive& primitive = mesh.primitives[primitiveIndex]; + + uint32_t size = static_cast(primitive.vertices.size()) * stride; + memcpy(pData + primitive.vertexByteOffset, primitive.vertices.data(), size); + } vkUnmapMemory(vk.device, *vbUploadMemory); // Schedule a copy of the upload buffer to the device buffer VkBufferCopy bufferCopy = {}; - bufferCopy.size = size; + bufferCopy.size = sizeInBytes; vkCmdCopyBuffer(vk.cmdBuffer[vk.frameIndex], *vbUpload, *vb, 1, &bufferCopy); return true; @@ -932,55 +949,70 @@ namespace Graphics * Create a bottom level acceleration structure and device memory for a mesh primitive. * Allocate scratch memory and schedule a GPU BLAS build. */ - bool CreateBLAS(Globals& vk, Resources& resources, const Scenes::MeshPrimitive& primitive, AccelerationStructure& as) + bool CreateBLAS(Globals& vk, Resources& resources, const Scenes::Mesh& mesh, AccelerationStructure& as) { - VkBuildAccelerationStructureFlagBitsKHR buildFlags = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR; + uint32_t numPrimitives = static_cast(mesh.primitives.size()); + + // Describe the mesh primitives + std::vector primitives(numPrimitives); + std::vector buildRanges(numPrimitives); + std::vector buildRangeInfos(numPrimitives); + std::vector primitiveCounts(numPrimitives); + + for (uint32_t primitiveIndex = 0; primitiveIndex < numPrimitives; primitiveIndex++) + { + // Get the mesh primitive + const Scenes::MeshPrimitive& primitive = mesh.primitives[primitiveIndex]; - uint32_t primitiveCount = static_cast(primitive.indices.size()) / 3; + VkAccelerationStructureGeometryKHR desc = {}; + desc.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR; + desc.geometryType = VK_GEOMETRY_TYPE_TRIANGLES_KHR; + desc.geometry.triangles.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR; - // Describe the BLAS primitive triangles - VkAccelerationStructureGeometryTrianglesDataKHR asTriangleData = {}; - asTriangleData.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR; - asTriangleData.vertexData = VkDeviceOrHostAddressConstKHR{ GetBufferDeviceAddress(vk.device, resources.sceneVBs[primitive.index]) }; - asTriangleData.vertexStride = sizeof(Vertex); - asTriangleData.maxVertex = static_cast(primitive.vertices.size()); - asTriangleData.vertexFormat = VK_FORMAT_R32G32B32_SFLOAT; - asTriangleData.indexData = VkDeviceOrHostAddressConstKHR{ GetBufferDeviceAddress(vk.device, resources.sceneIBs[primitive.index]) }; - asTriangleData.indexType = VK_INDEX_TYPE_UINT32; + desc.geometry.triangles.vertexData = VkDeviceOrHostAddressConstKHR{ GetBufferDeviceAddress(vk.device, resources.sceneVBs[mesh.index]) + primitive.vertexByteOffset }; + desc.geometry.triangles.vertexStride = sizeof(Vertex); + desc.geometry.triangles.maxVertex = static_cast(primitive.vertices.size()); + desc.geometry.triangles.vertexFormat = VK_FORMAT_R32G32B32_SFLOAT; + desc.geometry.triangles.indexData = VkDeviceOrHostAddressConstKHR{ GetBufferDeviceAddress(vk.device, resources.sceneIBs[mesh.index]) + primitive.indexByteOffset }; + desc.geometry.triangles.indexType = VK_INDEX_TYPE_UINT32; + desc.flags = primitive.opaque ? VK_GEOMETRY_OPAQUE_BIT_KHR : 0; - // Describe the mesh primitive geometry - VkAccelerationStructureGeometryDataKHR asGeometryData = {}; - asGeometryData.triangles = asTriangleData; + uint32_t primitiveCount = static_cast(primitive.indices.size() / 3); - VkAccelerationStructureGeometryKHR asGeometry = {}; - asGeometry.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR; - asGeometry.geometryType = VK_GEOMETRY_TYPE_TRIANGLES_KHR; - asGeometry.geometry = asGeometryData; - if (primitive.opaque) asGeometry.flags = VK_GEOMETRY_OPAQUE_BIT_KHR; + // Describe the geometry for the builder + VkAccelerationStructureBuildRangeInfoKHR buildRange = { primitiveCount, 0, 0, 0 }; + buildRanges[primitiveIndex] = buildRange; + buildRangeInfos[primitiveIndex] = &buildRanges[primitiveIndex]; + + primitives[primitiveIndex] = desc; + primitiveCounts[primitiveIndex] = primitiveCount; + } + + VkBuildAccelerationStructureFlagBitsKHR buildFlags = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR; // Describe the bottom level acceleration structure inputs VkAccelerationStructureBuildGeometryInfoKHR asInputs = {}; asInputs.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR; asInputs.type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR; asInputs.mode = VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR; - asInputs.geometryCount = 1; - asInputs.pGeometries = &asGeometry; + asInputs.geometryCount = static_cast(primitives.size()); + asInputs.pGeometries = primitives.data(); asInputs.flags = buildFlags; // Get the size requirements for the BLAS buffer VkAccelerationStructureBuildSizesInfoKHR asPreBuildInfo = {}; asPreBuildInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR; - vkGetAccelerationStructureBuildSizesKHR(vk.device, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &asInputs, &primitiveCount, &asPreBuildInfo); + vkGetAccelerationStructureBuildSizesKHR(vk.device, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &asInputs, primitiveCounts.data(), &asPreBuildInfo); - // Create the acceleration structure buffer, allocate and bind device memory - BufferDesc desc = { asPreBuildInfo.accelerationStructureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; - if (!CreateBuffer(vk, desc, &as.asBuffer, &as.asMemory)) return false; - - // Create the scratch buffer, allocate and bind device memory - desc = { asPreBuildInfo.buildScratchSize, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; - if (!CreateBuffer(vk, desc, &as.scratch, &as.scratchMemory)) return false; + // Create the BLAS scratch buffer, allocate and bind device memory + BufferDesc blasScratchDesc = { asPreBuildInfo.buildScratchSize, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; + if (!CreateBuffer(vk, blasScratchDesc, &as.scratch, &as.scratchMemory)) return false; asInputs.scratchData = VkDeviceOrHostAddressKHR{ GetBufferDeviceAddress(vk.device, as.scratch) }; + // Create the BLAS buffer, allocate and bind device memory + BufferDesc blasDesc = { asPreBuildInfo.accelerationStructureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; + if (!CreateBuffer(vk, blasDesc, &as.asBuffer, &as.asMemory)) return false; + // Describe the BLAS acceleration structure VkAccelerationStructureCreateInfoKHR asCreateInfo = {}; asCreateInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR; @@ -994,11 +1026,6 @@ namespace Graphics // Set the location of the final acceleration structure asInputs.dstAccelerationStructure = as.asKHR; - // Describe and build the BLAS - std::vector buildRangeInfos(1); - VkAccelerationStructureBuildRangeInfoKHR buildInfo = { primitiveCount, 0, 0, 0}; - buildRangeInfos[0] = &buildInfo; - vkCmdBuildAccelerationStructuresKHR(vk.cmdBuffer[vk.frameIndex], 1, &asInputs, buildRangeInfos.data()); return true; @@ -1012,22 +1039,13 @@ namespace Graphics { VkBuildAccelerationStructureFlagBitsKHR buildFlags = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR; - uint32_t primitiveCount = static_cast(instances.size()); - // Describe the TLAS geometry instances - VkAccelerationStructureGeometryInstancesDataKHR asInstanceData = {}; - asInstanceData.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR; - asInstanceData.arrayOfPointers = VK_FALSE; - asInstanceData.data = VkDeviceOrHostAddressConstKHR{ GetBufferDeviceAddress(vk.device, as.instances) }; - - // Describe the mesh primitive geometry - VkAccelerationStructureGeometryDataKHR asGeometryData = {}; - asGeometryData.instances = asInstanceData; - - VkAccelerationStructureGeometryKHR asGeometry = {}; - asGeometry.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR; - asGeometry.geometryType = VK_GEOMETRY_TYPE_INSTANCES_KHR; - asGeometry.geometry = asGeometryData; + VkAccelerationStructureGeometryKHR geometries = {}; + geometries.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR; + geometries.geometryType = VK_GEOMETRY_TYPE_INSTANCES_KHR; + geometries.geometry.instances.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR; + geometries.geometry.instances.arrayOfPointers = VK_FALSE; + geometries.geometry.instances.data = VkDeviceOrHostAddressConstKHR{ GetBufferDeviceAddress(vk.device, as.instances) }; // Describe the top level acceleration structure inputs VkAccelerationStructureBuildGeometryInfoKHR asInputs = {}; @@ -1035,23 +1053,24 @@ namespace Graphics asInputs.type = VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR; asInputs.mode = VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR; asInputs.geometryCount = 1; - asInputs.pGeometries = &asGeometry; + asInputs.pGeometries = &geometries; asInputs.flags = buildFlags; // Get the size requirements for the TLAS buffer + uint32_t primitiveCount = static_cast(instances.size()); VkAccelerationStructureBuildSizesInfoKHR asPreBuildInfo = {}; asPreBuildInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR; vkGetAccelerationStructureBuildSizesKHR(vk.device, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &asInputs, &primitiveCount, &asPreBuildInfo); + // Create the TLAS scratch buffer, allocate and bind device memory + BufferDesc scratchDesc = { asPreBuildInfo.buildScratchSize, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; + if (!CreateBuffer(vk, scratchDesc, &as.scratch, &as.scratchMemory)) return false; + asInputs.scratchData = VkDeviceOrHostAddressKHR{ GetBufferDeviceAddress(vk.device, as.scratch) }; + // Create the acceleration structure buffer, allocate and bind device memory BufferDesc desc = { asPreBuildInfo.accelerationStructureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; if (!CreateBuffer(vk, desc, &as.asBuffer, &as.asMemory)) return false; - // Create the scratch buffer, allocate and bind device memory - desc = { asPreBuildInfo.buildScratchSize, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; - if (!CreateBuffer(vk, desc, &as.scratch, &as.scratchMemory)) return false; - asInputs.scratchData = VkDeviceOrHostAddressKHR{ GetBufferDeviceAddress(vk.device, as.scratch) }; - // Describe the TLAS VkAccelerationStructureCreateInfoKHR asCreateInfo = {}; asCreateInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR; @@ -1553,12 +1572,15 @@ namespace Graphics vkDestroyBuffer(device, resources.materialsSTB, nullptr); vkFreeMemory(device, resources.materialsSTBMemory, nullptr); - vkDestroyBuffer(device, resources.materialIndicesRB, nullptr); - vkFreeMemory(device, resources.materialIndicesRBMemory, nullptr); + vkDestroyBuffer(device, resources.meshOffsetsRB, nullptr); + vkFreeMemory(device, resources.meshOffsetsRBMemory, nullptr); + vkDestroyBuffer(device, resources.geometryDataRB, nullptr); + vkFreeMemory(device, resources.geometryDataRBMemory, nullptr); resources.cameraCBPtr = nullptr; resources.lightsSTBPtr = nullptr; resources.materialsSTBPtr = nullptr; - resources.materialIndicesRBPtr = nullptr; + resources.meshOffsetsRBPtr = nullptr; + resources.geometryDataRBPtr = nullptr; // Render Targets vkDestroyImageView(device, resources.rt.GBufferAView, nullptr); @@ -1743,16 +1765,16 @@ namespace Graphics } /** - * Create the scene materials buffers. + * Create the scene materials buffer. */ - bool CreateSceneMaterialsBuffers(Globals& vk, Resources& resources, const Scenes::Scene& scene) + bool CreateSceneMaterialsBuffer(Globals& vk, Resources& resources, const Scenes::Scene& scene) { - // Create the materials upload buffer resource and allocate host memory - uint32_t size = ALIGN(256, Scenes::Material::GetGPUDataSize() * static_cast(scene.materials.size())); - BufferDesc desc = { size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT }; + // Create the materials buffer upload resource + uint32_t sizeInBytes = ALIGN(16, Scenes::Material::GetGPUDataSize() * static_cast(scene.materials.size())); + BufferDesc desc = { sizeInBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT }; if (!CreateBuffer(vk, desc, &resources.materialsSTBUploadBuffer, &resources.materialsSTBUploadMemory)) return false; - // Create the materials upload buffer resource and allocate device memory + // Create the materials buffer device resource desc.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; desc.memoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; if (!CreateBuffer(vk, desc, &resources.materialsSTB, &resources.materialsSTBMemory)) return false; @@ -1766,55 +1788,118 @@ namespace Graphics VKCHECK(vkMapMemory(vk.device, resources.materialsSTBUploadMemory, 0, VK_WHOLE_SIZE, 0, reinterpret_cast(&resources.materialsSTBPtr))); for (uint32_t materialIndex = 0; materialIndex < static_cast(scene.materials.size()); materialIndex++) { + // Get the material Scenes::Material material = scene.materials[materialIndex]; + + // Add the offset to the textures (in resource arrays) if (material.data.albedoTexIdx > -1) material.data.albedoTexIdx += Tex2DIndices::SCENE_TEXTURES; if (material.data.normalTexIdx > -1) material.data.normalTexIdx += Tex2DIndices::SCENE_TEXTURES; if (material.data.roughnessMetallicTexIdx > -1) material.data.roughnessMetallicTexIdx += Tex2DIndices::SCENE_TEXTURES; if (material.data.emissiveTexIdx > -1) material.data.emissiveTexIdx += Tex2DIndices::SCENE_TEXTURES; + + // Copy the material memcpy(resources.materialsSTBPtr + offset, material.GetGPUData(), Scenes::Material::GetGPUDataSize()); + + // Move the destination pointer to the next material offset += Scenes::Material::GetGPUDataSize(); } vkUnmapMemory(vk.device, resources.materialsSTBUploadMemory); // Schedule a copy of the upload buffer to the device buffer VkBufferCopy bufferCopy = {}; - bufferCopy.size = size; + bufferCopy.size = sizeInBytes; vkCmdCopyBuffer(vk.cmdBuffer[vk.frameIndex], resources.materialsSTBUploadBuffer, resources.materialsSTB, 1, &bufferCopy); - // Material Indices + return true; + } + + /** + * Create the scene material indexing buffers. + */ + bool CreateSceneMaterialIndexingBuffers(Globals& vk, Resources& resources, const Scenes::Scene& scene) + { + // Mesh Offsets - // Create the material indices upload buffer resource - size = ALIGN(256, sizeof(uint32_t) * scene.numMeshPrimitives); - desc = { size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT }; - if (!CreateBuffer(vk, desc, &resources.materialIndicesRBUploadBuffer, &resources.materialIndicesRBUploadMemory)) return false; + // Create the mesh offsets buffer upload resource + uint32_t meshOffsetsSize = ALIGN(16, sizeof(uint32_t) * static_cast(scene.meshes.size())); + BufferDesc desc = { meshOffsetsSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT }; + if (!CreateBuffer(vk, desc, &resources.meshOffsetsRBUploadBuffer, &resources.meshOffsetsRBUploadMemory)) return false; + #ifdef GFX_NAME_OBJECTS + SetObjectName(vk.device, reinterpret_cast(resources.meshOffsetsRBUploadBuffer), "Mesh Offsets Upload Buffer", VK_OBJECT_TYPE_BUFFER); + SetObjectName(vk.device, reinterpret_cast(resources.meshOffsetsRBUploadMemory), "Mesh Offsets Upload Buffer Memory", VK_OBJECT_TYPE_DEVICE_MEMORY); + #endif - // Create the material indices device buffer resource + // Create the mesh offsets buffer device resource desc.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; desc.memoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - if (!CreateBuffer(vk, desc, &resources.materialIndicesRB, &resources.materialIndicesRBMemory)) return false; + if (!CreateBuffer(vk, desc, &resources.meshOffsetsRB, &resources.meshOffsetsRBMemory)) return false; #ifdef GFX_NAME_OBJECTS - SetObjectName(vk.device, reinterpret_cast(resources.materialIndicesRB), "Materials Indices Buffer", VK_OBJECT_TYPE_BUFFER); - SetObjectName(vk.device, reinterpret_cast(resources.materialIndicesRBMemory), "Materials Indices Buffer Memory", VK_OBJECT_TYPE_DEVICE_MEMORY); + SetObjectName(vk.device, reinterpret_cast(resources.meshOffsetsRB), "Mesh Offsets Buffer", VK_OBJECT_TYPE_BUFFER); + SetObjectName(vk.device, reinterpret_cast(resources.meshOffsetsRBMemory), "Mesh Offsets Buffer Memory", VK_OBJECT_TYPE_DEVICE_MEMORY); #endif - // Copy the material indices to the upload buffer. - offset = 0; - VKCHECK(vkMapMemory(vk.device, resources.materialIndicesRBUploadMemory, 0, VK_WHOLE_SIZE, 0, reinterpret_cast(&resources.materialIndicesRBPtr))); + // Geometry Data + + // Create the geometry (mesh primitive) data buffer upload resource + uint32_t geometryDataSize = ALIGN(16, sizeof(GeometryData) * scene.numMeshPrimitives); + desc = { geometryDataSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT }; + if (!CreateBuffer(vk, desc, &resources.geometryDataRBUploadBuffer, &resources.geometryDataRBUploadMemory)) return false; + #ifdef GFX_NAME_OBJECTS + SetObjectName(vk.device, reinterpret_cast(resources.geometryDataRBUploadBuffer), "Geometry Data Upload Buffer", VK_OBJECT_TYPE_BUFFER); + SetObjectName(vk.device, reinterpret_cast(resources.geometryDataRBUploadMemory), "Geometry Data Upload Buffer Memory", VK_OBJECT_TYPE_DEVICE_MEMORY); + #endif + + // Create the geometry data (mesh primitive) buffer device resource + desc.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; + desc.memoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + if (!CreateBuffer(vk, desc, &resources.geometryDataRB, &resources.geometryDataRBMemory)) return false; + #ifdef GFX_NAME_OBJECTS + SetObjectName(vk.device, reinterpret_cast(resources.geometryDataRB), "Geometry Data Buffer", VK_OBJECT_TYPE_BUFFER); + SetObjectName(vk.device, reinterpret_cast(resources.geometryDataRBMemory), "Geometry Data Buffer Memory", VK_OBJECT_TYPE_DEVICE_MEMORY); + #endif + + // Copy the mesh offsets and geometry data to the upload buffers + uint32_t primitiveOffset = 0; + VKCHECK(vkMapMemory(vk.device, resources.meshOffsetsRBUploadMemory, 0, VK_WHOLE_SIZE, 0, reinterpret_cast(&resources.meshOffsetsRBPtr))); + VKCHECK(vkMapMemory(vk.device, resources.geometryDataRBUploadMemory, 0, VK_WHOLE_SIZE, 0, reinterpret_cast(&resources.geometryDataRBPtr))); + + uint8_t* meshOffsetsAddress = resources.meshOffsetsRBPtr; + uint8_t* geometryDataAddress = resources.geometryDataRBPtr; for (uint32_t meshIndex = 0; meshIndex < static_cast(scene.meshes.size()); meshIndex++) { - const Scenes::Mesh mesh = scene.meshes[meshIndex]; + // Get the mesh + const Scenes::Mesh& mesh = scene.meshes[meshIndex]; + + // Copy the mesh offset to the upload buffer + uint32_t meshOffset = primitiveOffset * sizeof(GeometryData); + memcpy(meshOffsetsAddress, &meshOffset, sizeof(uint32_t)); + meshOffsetsAddress += sizeof(uint32_t); + for (uint32_t primitiveIndex = 0; primitiveIndex < static_cast(scene.meshes[meshIndex].primitives.size()); primitiveIndex++) { + // Get the mesh primitive and copy its material index to the upload buffer const Scenes::MeshPrimitive& primitive = scene.meshes[meshIndex].primitives[primitiveIndex]; - memcpy(resources.materialIndicesRBPtr + offset, &primitive.material, sizeof(uint32_t)); - offset += sizeof(uint32_t); + + GeometryData data; + data.materialIndex = primitive.material; + data.indexByteAddress = primitive.indexByteOffset; + data.vertexByteAddress = primitive.vertexByteOffset; + memcpy(geometryDataAddress, &data, sizeof(GeometryData)); + + geometryDataAddress += sizeof(GeometryData); + primitiveOffset++; } } - vkUnmapMemory(vk.device, resources.materialIndicesRBUploadMemory); + vkUnmapMemory(vk.device, resources.meshOffsetsRBUploadMemory); + vkUnmapMemory(vk.device, resources.geometryDataRBUploadMemory); - // Schedule a copy of the upload buffer to the device buffer - bufferCopy.size = size; - vkCmdCopyBuffer(vk.cmdBuffer[vk.frameIndex], resources.materialIndicesRBUploadBuffer, resources.materialIndicesRB, 1, &bufferCopy); + // Schedule a copy of the upload buffers to the device buffers + VkBufferCopy bufferCopy = {}; + bufferCopy.size = meshOffsetsSize; + vkCmdCopyBuffer(vk.cmdBuffer[vk.frameIndex], resources.meshOffsetsRBUploadBuffer, resources.meshOffsetsRB, 1, &bufferCopy); + + bufferCopy.size = geometryDataSize; + vkCmdCopyBuffer(vk.cmdBuffer[vk.frameIndex], resources.geometryDataRBUploadBuffer, resources.geometryDataRB, 1, &bufferCopy); return true; } @@ -1853,107 +1938,96 @@ namespace Graphics } /** - * Create the scene geometry index buffers. + * Create the scene mesh index buffers. */ bool CreateSceneIndexBuffers(Globals& vk, Resources& resources, const Scenes::Scene& scene) { - resources.sceneIBs.resize(scene.numMeshPrimitives); - resources.sceneIBMemory.resize(scene.numMeshPrimitives); - resources.sceneIBUploadBuffers.resize(scene.numMeshPrimitives); - resources.sceneIBUploadMemory.resize(scene.numMeshPrimitives); - for (uint32_t meshIndex = 0; meshIndex < static_cast(scene.meshes.size()); meshIndex++) + uint32_t numMeshes = static_cast(scene.meshes.size()); + + resources.sceneIBs.resize(numMeshes); + resources.sceneIBMemory.resize(numMeshes); + resources.sceneIBUploadBuffers.resize(numMeshes); + resources.sceneIBUploadMemory.resize(numMeshes); + for (uint32_t meshIndex = 0; meshIndex < numMeshes; meshIndex++) { // Get the mesh - const Scenes::Mesh mesh = scene.meshes[meshIndex]; - for (size_t primitiveIndex = 0; primitiveIndex < mesh.primitives.size(); primitiveIndex++) - { - // Get the mesh primitive - const Scenes::MeshPrimitive primitive = mesh.primitives[primitiveIndex]; - - // Create the index buffer and copy the data to the GPU - if (!CreateIndexBuffer(vk, primitive, - &resources.sceneIBs[primitive.index], - &resources.sceneIBMemory[primitive.index], - &resources.sceneIBUploadBuffers[primitive.index], - &resources.sceneIBUploadMemory[primitive.index])) return false; - #ifdef GFX_NAME_OBJECTS - std::string name = "IB: " + mesh.name + ", Primitive: " + std::to_string(primitiveIndex); - std::string memoryName = "IB: " + mesh.name + ", Primitive: " + std::to_string(primitiveIndex) + " Memory"; - SetObjectName(vk.device, reinterpret_cast(resources.sceneIBs[primitive.index]), name.c_str(), VK_OBJECT_TYPE_BUFFER); - SetObjectName(vk.device, reinterpret_cast(resources.sceneIBMemory[primitive.index]), memoryName.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); - #endif - } + const Scenes::Mesh& mesh = scene.meshes[meshIndex]; + + // Create the index buffer and copy the index data to the GPU + if (!CreateIndexBuffer(vk, mesh, + &resources.sceneIBs[meshIndex], + &resources.sceneIBMemory[meshIndex], + &resources.sceneIBUploadBuffers[meshIndex], + &resources.sceneIBUploadMemory[meshIndex])) return false; + #ifdef GFX_NAME_OBJECTS + std::string name = "IB: " + mesh.name; + std::string memoryName = "IB: " + mesh.name + " Memory"; + SetObjectName(vk.device, reinterpret_cast(resources.sceneIBs[meshIndex]), name.c_str(), VK_OBJECT_TYPE_BUFFER); + SetObjectName(vk.device, reinterpret_cast(resources.sceneIBMemory[meshIndex]), memoryName.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); + #endif } return true; } /** - * Create the scene geometry vertex buffers. + * Create the scene mesh vertex buffers. */ bool CreateSceneVertexBuffers(Globals& vk, Resources& resources, const Scenes::Scene& scene) { - resources.sceneVBs.resize(scene.numMeshPrimitives); - resources.sceneVBMemory.resize(scene.numMeshPrimitives); - resources.sceneVBUploadBuffers.resize(scene.numMeshPrimitives); - resources.sceneVBUploadMemory.resize(scene.numMeshPrimitives); - for (uint32_t meshIndex = 0; meshIndex < static_cast(scene.meshes.size()); meshIndex++) + uint32_t numMeshes = static_cast(scene.meshes.size()); + + resources.sceneVBs.resize(numMeshes); + resources.sceneVBMemory.resize(numMeshes); + resources.sceneVBUploadBuffers.resize(numMeshes); + resources.sceneVBUploadMemory.resize(numMeshes); + for (uint32_t meshIndex = 0; meshIndex < numMeshes; meshIndex++) { // Get the mesh - const Scenes::Mesh mesh = scene.meshes[meshIndex]; - for (uint32_t primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) - { - // Get the mesh primitive - const Scenes::MeshPrimitive primitive = mesh.primitives[primitiveIndex]; - - // Create the vertex buffer and copy the data to the GPU - if (!CreateVertexBuffer(vk, primitive, - &resources.sceneVBs[primitive.index], - &resources.sceneVBMemory[primitive.index], - &resources.sceneVBUploadBuffers[primitive.index], - &resources.sceneVBUploadMemory[primitive.index])) return false; - #ifdef GFX_NAME_OBJECTS - std::string name = "VB: " + mesh.name + ", Primitive: " + std::to_string(primitiveIndex); - std::string memoryName = "VB: " + mesh.name + ", Primitive: " + std::to_string(primitiveIndex) + " Memory"; - SetObjectName(vk.device, reinterpret_cast(resources.sceneVBs[primitive.index]), name.c_str(), VK_OBJECT_TYPE_BUFFER); - SetObjectName(vk.device, reinterpret_cast(resources.sceneVBMemory[primitive.index]), memoryName.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); - #endif - } + const Scenes::Mesh& mesh = scene.meshes[meshIndex]; + + // Create the vertex buffer and copy the data to the GPU + if (!CreateVertexBuffer(vk, mesh, + &resources.sceneVBs[meshIndex], + &resources.sceneVBMemory[meshIndex], + &resources.sceneVBUploadBuffers[meshIndex], + &resources.sceneVBUploadMemory[meshIndex])) return false; + #ifdef GFX_NAME_OBJECTS + std::string name = "VB: " + mesh.name; + std::string memoryName = "VB: " + mesh.name + " Memory"; + SetObjectName(vk.device, reinterpret_cast(resources.sceneVBs[meshIndex]), name.c_str(), VK_OBJECT_TYPE_BUFFER); + SetObjectName(vk.device, reinterpret_cast(resources.sceneVBMemory[meshIndex]), memoryName.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); + #endif } return true; } /** - * Create the scene's bottom level acceleration structures. + * Create the scene's bottom level acceleration structure(s). */ bool CreateSceneBLAS(Globals& vk, Resources& resources, const Scenes::Scene& scene) { - // Describe the BLAS geometry. Each mesh primitive populates a BLAS. - resources.blas.resize(scene.numMeshPrimitives); + // Build a BLAS for each mesh + resources.blas.resize(scene.meshes.size()); for (uint32_t meshIndex = 0; meshIndex < static_cast(scene.meshes.size()); meshIndex++) { - // Get the mesh - const Scenes::Mesh mesh = scene.meshes[meshIndex]; - for (uint32_t primitiveIndex = 0; primitiveIndex < static_cast(mesh.primitives.size()); primitiveIndex++) - { - // Get the mesh primitive - const Scenes::MeshPrimitive primitive = mesh.primitives[primitiveIndex]; - AccelerationStructure& as = resources.blas[primitive.index]; - - // Create the BLAS and schedule a build - if (!CreateBLAS(vk, resources, primitive, as)) return false; - #ifdef GFX_NAME_OBJECTS - std::string name = "BLAS: " + mesh.name + ", Primitive: " + std::to_string(primitiveIndex); - std::string memory = "BLAS Memory: " + mesh.name + ", Primitive: " + std::to_string(primitiveIndex); - std::string scratch = "BLAS Scratch: " + mesh.name + ", Primitive: " + std::to_string(primitiveIndex); - std::string scratchMemory = "BLAS Scratch Memory: " + mesh.name + ", Primitive: " + std::to_string(primitiveIndex); - SetObjectName(vk.device, reinterpret_cast(as.asKHR), name.c_str(), VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR); - SetObjectName(vk.device, reinterpret_cast(as.asBuffer), memory.c_str(), VK_OBJECT_TYPE_BUFFER); - SetObjectName(vk.device, reinterpret_cast(as.asMemory), memory.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); - SetObjectName(vk.device, reinterpret_cast(as.scratch), scratch.c_str(), VK_OBJECT_TYPE_BUFFER); - SetObjectName(vk.device, reinterpret_cast(as.scratchMemory), scratchMemory.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); - #endif - } + // Get the mesh and its BLAS + const Scenes::Mesh& mesh = scene.meshes[meshIndex]; + AccelerationStructure& as = resources.blas[meshIndex]; + + // Create the BLAS and schedule a build + if (!CreateBLAS(vk, resources, mesh, as)) return false; + #ifdef GFX_NAME_OBJECTS + std::string name = "BLAS: " + mesh.name; + std::string memory = "BLAS Memory: " + mesh.name; + std::string scratch = "BLAS Scratch: " + mesh.name; + std::string scratchMemory = "BLAS Scratch Memory: " + mesh.name; + SetObjectName(vk.device, reinterpret_cast(as.asKHR), name.c_str(), VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR); + SetObjectName(vk.device, reinterpret_cast(as.asBuffer), memory.c_str(), VK_OBJECT_TYPE_BUFFER); + SetObjectName(vk.device, reinterpret_cast(as.asMemory), memory.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); + SetObjectName(vk.device, reinterpret_cast(as.scratch), scratch.c_str(), VK_OBJECT_TYPE_BUFFER); + SetObjectName(vk.device, reinterpret_cast(as.scratchMemory), scratchMemory.c_str(), VK_OBJECT_TYPE_DEVICE_MEMORY); + #endif } // Wait for the BLAS builds to complete @@ -1974,38 +2048,30 @@ namespace Graphics std::vector instances; for (size_t instanceIndex = 0; instanceIndex < scene.instances.size(); instanceIndex++) { - const Scenes::MeshInstance instance = scene.instances[instanceIndex]; - const Scenes::Mesh mesh = scene.meshes[instance.meshIndex]; - for (size_t primitiveIndex = 0; primitiveIndex < mesh.primitives.size(); primitiveIndex++) - { - const Scenes::MeshPrimitive primitive = mesh.primitives[primitiveIndex]; - - VkAccelerationStructureDeviceAddressInfoKHR asDeviceAddressInfo = {}; - asDeviceAddressInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR; - asDeviceAddressInfo.accelerationStructure = resources.blas[primitive.index].asKHR; - VkDeviceAddress blasAddress = vkGetAccelerationStructureDeviceAddressKHR(vk.device, &asDeviceAddressInfo); - - // Describe the mesh primitive instance - VkAccelerationStructureInstanceKHR desc = {}; - desc.instanceCustomIndex = primitive.index; // For indexing into the MeshPrimitives and MaterialIndices arrays. Requires 1 MeshPrimitive per BLAS. - desc.mask = 0xFF; - desc.instanceShaderBindingTableRecordOffset = 0; // A single hit group for all geometry - desc.accelerationStructureReference = blasAddress; - #if (COORDINATE_SYSTEM == COORDINATE_SYSTEM_LEFT) || (COORDINATE_SYSTEM == COORDINATE_SYSTEM_LEFT_Z_UP) - desc.flags = VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR; - #endif - - // Disable front or back face culling for meshes with double sided materials - if (scene.materials[primitive.material].data.doubleSided) - { - desc.flags |= VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR; - } + // Get the mesh instance + const Scenes::MeshInstance& instance = scene.instances[instanceIndex]; + + // Get the BLAS device address + VkAccelerationStructureDeviceAddressInfoKHR asDeviceAddressInfo = {}; + asDeviceAddressInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR; + asDeviceAddressInfo.accelerationStructure = resources.blas[instance.meshIndex].asKHR; + VkDeviceAddress blasAddress = vkGetAccelerationStructureDeviceAddressKHR(vk.device, &asDeviceAddressInfo); + + // Describe the mesh instance + VkAccelerationStructureInstanceKHR desc = {}; + desc.instanceCustomIndex = instance.meshIndex; // quantized to 24-bits + desc.mask = 0xFF; + desc.instanceShaderBindingTableRecordOffset = 0; // A single hit group for all geometry + desc.accelerationStructureReference = blasAddress; + #if (COORDINATE_SYSTEM == COORDINATE_SYSTEM_LEFT) || (COORDINATE_SYSTEM == COORDINATE_SYSTEM_LEFT_Z_UP) + desc.flags = VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR; + #endif + desc.flags |= VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR; - // Write the instance transform - memcpy(desc.transform.matrix, instance.transform, sizeof(DirectX::XMFLOAT4) * 3); + // Write the instance transform + memcpy(desc.transform.matrix, instance.transform, sizeof(DirectX::XMFLOAT4) * 3); - instances.push_back(desc); - } + instances.push_back(desc); } // Create the TLAS instances buffer @@ -2434,7 +2500,7 @@ namespace Graphics glfwSetWindowMonitor(vk.window, monitor, vk.x, vk.y, vk.windowWidth, vk.windowHeight, vk.vsync ? 60 : GLFW_DONT_CARE); } - vk.fullscreen = !vk.fullscreen; + vk.fullscreen = ~vk.fullscreen; vk.fullscreenChanged = false; return true; } @@ -3066,7 +3132,8 @@ namespace Graphics // Create scene specific resources CHECK(CreateSceneCameraConstantBuffer(vk, resources, scene), "create scene camera constant buffer!", log); CHECK(CreateSceneLightsBuffer(vk, resources, scene), "create scene lights structured buffer!", log); - CHECK(CreateSceneMaterialsBuffers(vk, resources, scene), "create scene materials buffers!", log); + CHECK(CreateSceneMaterialsBuffer(vk, resources, scene), "create scene materials buffer!", log); + CHECK(CreateSceneMaterialIndexingBuffers(vk, resources, scene), "create scene material indexing buffers!", log); CHECK(CreateSceneIndexBuffers(vk, resources, scene), "create scene index buffers!", log); CHECK(CreateSceneVertexBuffers(vk, resources, scene), "create scene vertex buffers!", log); CHECK(CreateSceneBLAS(vk, resources, scene), "create scene bottom level acceleration structures!", log); @@ -3090,8 +3157,10 @@ namespace Graphics // Release upload buffers vkDestroyBuffer(vk.device, resources.materialsSTBUploadBuffer, nullptr); vkFreeMemory(vk.device, resources.materialsSTBUploadMemory, nullptr); - vkDestroyBuffer(vk.device, resources.materialIndicesRBUploadBuffer, nullptr); - vkFreeMemory(vk.device, resources.materialIndicesRBUploadMemory, nullptr); + vkDestroyBuffer(vk.device, resources.meshOffsetsRBUploadBuffer, nullptr); + vkFreeMemory(vk.device, resources.meshOffsetsRBUploadMemory, nullptr); + vkDestroyBuffer(vk.device, resources.geometryDataRBUploadBuffer, nullptr); + vkFreeMemory(vk.device, resources.geometryDataRBUploadMemory, nullptr); vkDestroyBuffer(vk.device, resources.tlas.instancesUpload, nullptr); vkFreeMemory(vk.device, resources.tlas.instancesUploadMemory, nullptr); resources.tlas.instancesUpload = nullptr; diff --git a/samples/test-harness/src/graphics/DDGI.cpp b/samples/test-harness/src/graphics/DDGI.cpp index 8bb50ca..59aa691 100644 --- a/samples/test-harness/src/graphics/DDGI.cpp +++ b/samples/test-harness/src/graphics/DDGI.cpp @@ -51,6 +51,9 @@ namespace Graphics Shaders::AddDefine(shader, L"RTXGI_PUSH_CONSTS_STRUCT_NAME", L"GlobalConstants"); // specify the struct name of the application's push constants Shaders::AddDefine(shader, L"RTXGI_PUSH_CONSTS_VARIABLE_NAME", L"GlobalConst"); // specify the variable name of the application's push constants Shaders::AddDefine(shader, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_VOLUME_INDEX_NAME", L"ddgi_volumeIndex"); // specify the name of the DDGIVolume index field in the application's push constants struct + Shaders::AddDefine(shader, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_X_NAME", L"ddgi_reductionInputSizeX"); // specify the name of the DDGIVolume reduction pass input size fields the application's push constants struct + Shaders::AddDefine(shader, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Y_NAME", L"ddgi_reductionInputSizeY"); + Shaders::AddDefine(shader, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Z_NAME", L"ddgi_reductionInputSizeZ"); Shaders::AddDefine(shader, L"VOLUME_CONSTS_REGISTER", L"5"); Shaders::AddDefine(shader, L"VOLUME_CONSTS_SPACE", L"0"); Shaders::AddDefine(shader, L"VOLUME_RESOURCES_REGISTER", L"6"); @@ -68,6 +71,9 @@ namespace Graphics Shaders::AddDefine(shader, L"OUTPUT_SPACE", L"0"); Shaders::AddDefine(shader, L"PROBE_DATA_REGISTER", L"4"); Shaders::AddDefine(shader, L"PROBE_DATA_SPACE", L"0"); + Shaders::AddDefine(shader, L"PROBE_VARIABILITY_SPACE", L"0"); + Shaders::AddDefine(shader, L"PROBE_VARIABILITY_REGISTER", L"5"); + Shaders::AddDefine(shader, L"PROBE_VARIABILITY_AVERAGE_REGISTER", L"6"); #endif } else // DXIL @@ -92,6 +98,9 @@ namespace Graphics Shaders::AddDefine(shader, L"OUTPUT_SPACE", L"space1"); Shaders::AddDefine(shader, L"PROBE_DATA_REGISTER", L"u3"); Shaders::AddDefine(shader, L"PROBE_DATA_SPACE", L"space1"); + Shaders::AddDefine(shader, L"PROBE_VARIABILITY_SPACE", L"space1"); + Shaders::AddDefine(shader, L"PROBE_VARIABILITY_REGISTER", L"u4"); + Shaders::AddDefine(shader, L"PROBE_VARIABILITY_AVERAGE_REGISTER", L"u5"); #endif } #endif @@ -121,6 +130,7 @@ namespace Graphics std::wstring numIrradianceInteriorTexels = std::to_wstring(volumeDesc.probeNumIrradianceInteriorTexels); std::wstring numDistanceTexels = std::to_wstring(volumeDesc.probeNumDistanceTexels); std::wstring numDistanceInteriorTexels = std::to_wstring(volumeDesc.probeNumDistanceInteriorTexels); + std::wstring waveLaneCount = std::to_wstring(gfx.features.waveLaneCount); std::wstring root = std::wstring(gfx.shaderCompiler.rtxgi.begin(), gfx.shaderCompiler.rtxgi.end()); @@ -238,6 +248,40 @@ namespace Graphics CHECK(Shaders::Compile(gfx.shaderCompiler, shader2, true), "load and compile the RTXGI probe classification reset compute shader!\n", log); } + // Probe variability reduction + { + Shaders::ShaderProgram& shader = volumeShaders.emplace_back(); + shader.filepath = root + L"shaders/ddgi/ReductionCS.hlsl"; + shader.entryPoint = L"DDGIReductionCS"; + shader.targetProfile = L"cs_6_6"; + if (spirv) shader.arguments = { L"-spirv", L"-D __spirv__", L"-fspv-target-env=vulkan1.2" }; + + // Add common shader defines + AddCommonShaderDefines(shader, volumeDesc, spirv); + + // Add shader specific defines + Shaders::AddDefine(shader, L"RTXGI_DDGI_PROBE_NUM_INTERIOR_TEXELS", numIrradianceInteriorTexels.c_str()); + Shaders::AddDefine(shader, L"RTXGI_DDGI_WAVE_LANE_COUNT", waveLaneCount); + CHECK(Shaders::Compile(gfx.shaderCompiler, shader, true), "load and compile the RTXGI reduction compute shader!\n", log); + } + + // Extra reduction passes + { + Shaders::ShaderProgram& shader = volumeShaders.emplace_back(); + shader.filepath = root + L"shaders/ddgi/ReductionCS.hlsl"; + shader.entryPoint = L"DDGIExtraReductionCS"; + shader.targetProfile = L"cs_6_6"; + if (spirv) shader.arguments = { L"-spirv", L"-D __spirv__", L"-fspv-target-env=vulkan1.2" }; + + // Add common shader defines + AddCommonShaderDefines(shader, volumeDesc, spirv); + + // Add shader specific defines + Shaders::AddDefine(shader, L"RTXGI_DDGI_PROBE_NUM_INTERIOR_TEXELS", numIrradianceInteriorTexels.c_str()); + Shaders::AddDefine(shader, L"RTXGI_DDGI_WAVE_LANE_COUNT", waveLaneCount); + CHECK(Shaders::Compile(gfx.shaderCompiler, shader, true), "load and compile the RTXGI extra reduction compute shader!\n", log); + } + log << "done.\n"; std::flush(log); diff --git a/samples/test-harness/src/graphics/DDGIVisualizations_D3D12.cpp b/samples/test-harness/src/graphics/DDGIVisualizations_D3D12.cpp index dc79129..c84d143 100644 --- a/samples/test-harness/src/graphics/DDGIVisualizations_D3D12.cpp +++ b/samples/test-harness/src/graphics/DDGIVisualizations_D3D12.cpp @@ -504,12 +504,12 @@ namespace Graphics // Create the probe sphere's vertex and index buffers CHECK(CreateIndexBuffer(d3d, resources.probe, &resources.probeIB, &resources.probeIBUpload, resources.probeIBView), "create probe index buffer!", log); #ifdef GFX_NAME_OBJECTS - resources.probeIB->SetName(L"IB: Probe Sphere, Primitive 0"); + resources.probeIB->SetName(L"IB: DDGI Probe Sphere"); #endif CHECK(CreateVertexBuffer(d3d, resources.probe, &resources.probeVB, &resources.probeVBUpload, resources.probeVBView), "create probe vertex buffer!", log); #ifdef GFX_NAME_OBJECTS - resources.probeVB->SetName(L"VB: DDGI Probe Sphere, Primitive 0"); + resources.probeVB->SetName(L"VB: DDGI Probe Sphere"); #endif // Add the index buffer SRV to the descriptor heap @@ -811,6 +811,8 @@ namespace Graphics d3dResources.constants.ddgivis.irradianceTextureScale = volume.probeIrradianceScale; d3dResources.constants.ddgivis.distanceTextureScale = volume.probeDistanceScale; d3dResources.constants.ddgivis.probeDataTextureScale = volume.probeDataScale; + d3dResources.constants.ddgivis.probeVariabilityTextureScale = volume.probeVariabilityScale; + d3dResources.constants.ddgivis.probeVariabilityTextureThreshold = volume.probeVariabilityThreshold; } } CPU_TIMESTAMP_END(resources.cpuStat); diff --git a/samples/test-harness/src/graphics/DDGIVisualizations_VK.cpp b/samples/test-harness/src/graphics/DDGIVisualizations_VK.cpp index a7e3191..9d38a5a 100644 --- a/samples/test-harness/src/graphics/DDGIVisualizations_VK.cpp +++ b/samples/test-harness/src/graphics/DDGIVisualizations_VK.cpp @@ -144,6 +144,8 @@ namespace Graphics tex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeIrradianceView(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }); tex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeDistanceView(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }); tex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeDataView(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }); + tex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeVariabilityView(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }); + tex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeVariabilityAverageView(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }); } descriptor = &descriptors.emplace_back(); @@ -519,6 +521,9 @@ namespace Graphics Shaders::AddDefine(resources.textureVisCS, L"RTXGI_PUSH_CONSTS_STRUCT_NAME", L"GlobalConstants"); // specify the struct name of the application's push constants Shaders::AddDefine(resources.textureVisCS, L"RTXGI_PUSH_CONSTS_VARIABLE_NAME", L"GlobalConst"); // specify the variable name of the application's push constants Shaders::AddDefine(resources.textureVisCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_VOLUME_INDEX_NAME", L"ddgi_volumeIndex"); // specify the name of the DDGIVolume index field in the application's push constants struct + Shaders::AddDefine(resources.textureVisCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_X_NAME", L"ddgi_reductionInputSizeX"); // specify the name of the DDGIVolume reduction pass input size fields the application's push constants struct + Shaders::AddDefine(resources.textureVisCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Y_NAME", L"ddgi_reductionInputSizeY"); + Shaders::AddDefine(resources.textureVisCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Z_NAME", L"ddgi_reductionInputSizeZ"); Shaders::AddDefine(resources.textureVisCS, L"RTXGI_BINDLESS_TYPE", std::to_wstring(RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS)); Shaders::AddDefine(resources.textureVisCS, L"RTXGI_COORDINATE_SYSTEM", std::to_wstring(RTXGI_COORDINATE_SYSTEM)); Shaders::AddDefine(resources.textureVisCS, L"THGP_DIM_X", L"8"); @@ -536,6 +541,9 @@ namespace Graphics Shaders::AddDefine(resources.updateTlasCS, L"RTXGI_PUSH_CONSTS_STRUCT_NAME", L"GlobalConstants"); // specify the struct name of the application's push constants Shaders::AddDefine(resources.updateTlasCS, L"RTXGI_PUSH_CONSTS_VARIABLE_NAME", L"GlobalConst"); // specify the variable name of the application's push constants Shaders::AddDefine(resources.updateTlasCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_VOLUME_INDEX_NAME", L"ddgi_volumeIndex"); // specify the name of the DDGIVolume index field in the application's push constants struct + Shaders::AddDefine(resources.updateTlasCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_X_NAME", L"ddgi_reductionInputSizeX"); // specify the name of the DDGIVolume reduction pass input size fields the application's push constants struct + Shaders::AddDefine(resources.updateTlasCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Y_NAME", L"ddgi_reductionInputSizeY"); + Shaders::AddDefine(resources.updateTlasCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Z_NAME", L"ddgi_reductionInputSizeZ"); Shaders::AddDefine(resources.updateTlasCS, L"RTXGI_BINDLESS_TYPE", std::to_wstring(RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS)); Shaders::AddDefine(resources.updateTlasCS, L"RTXGI_COORDINATE_SYSTEM", std::to_wstring(RTXGI_COORDINATE_SYSTEM)); CHECK(Shaders::Compile(vk.shaderCompiler, resources.updateTlasCS, true), "compile DDGI Visualizations probes update compute shader!\n", log); @@ -766,29 +774,20 @@ namespace Graphics bool CreateBLAS(Globals& vk, Resources& resources) { - VkBuildAccelerationStructureFlagBitsKHR buildFlags = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR; - - uint32_t primitiveCount = static_cast(resources.probe.indices.size()) / 3; - // Describe the BLAS geometries - VkAccelerationStructureGeometryTrianglesDataKHR asTriangleData = {}; - asTriangleData.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR; - asTriangleData.vertexData = VkDeviceOrHostAddressConstKHR{ GetBufferDeviceAddress(vk.device, resources.probeVB) }; - asTriangleData.vertexStride = sizeof(Vertex); - asTriangleData.maxVertex = static_cast(resources.probe.vertices.size()); - asTriangleData.vertexFormat = VK_FORMAT_R32G32B32_SFLOAT; - asTriangleData.indexData = VkDeviceOrHostAddressConstKHR{ GetBufferDeviceAddress(vk.device, resources.probeIB) }; - asTriangleData.indexType = VK_INDEX_TYPE_UINT32; + VkAccelerationStructureGeometryKHR geometryDesc = {}; + geometryDesc.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR; + geometryDesc.geometryType = VK_GEOMETRY_TYPE_TRIANGLES_KHR; + geometryDesc.geometry.triangles.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR; + geometryDesc.geometry.triangles.vertexData = VkDeviceOrHostAddressConstKHR{ GetBufferDeviceAddress(vk.device, resources.probeVB) }; + geometryDesc.geometry.triangles.vertexStride = sizeof(Vertex); + geometryDesc.geometry.triangles.maxVertex = resources.probe.numVertices; + geometryDesc.geometry.triangles.vertexFormat = VK_FORMAT_R32G32B32_SFLOAT; + geometryDesc.geometry.triangles.indexData = VkDeviceOrHostAddressConstKHR{ GetBufferDeviceAddress(vk.device, resources.probeIB) }; + geometryDesc.geometry.triangles.indexType = VK_INDEX_TYPE_UINT32; + geometryDesc.flags = VK_GEOMETRY_OPAQUE_BIT_KHR; - // Describe the mesh primitive geometry - VkAccelerationStructureGeometryDataKHR asGeometryData = {}; - asGeometryData.triangles = asTriangleData; - - VkAccelerationStructureGeometryKHR asGeometry = {}; - asGeometry.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR; - asGeometry.geometryType = VK_GEOMETRY_TYPE_TRIANGLES_KHR; - asGeometry.geometry = asGeometryData; - if (resources.probe.opaque) asGeometry.flags = VK_GEOMETRY_OPAQUE_BIT_KHR; + VkBuildAccelerationStructureFlagBitsKHR buildFlags = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR; // Describe the bottom level acceleration structure inputs VkAccelerationStructureBuildGeometryInfoKHR asInputs = {}; @@ -796,31 +795,32 @@ namespace Graphics asInputs.type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR; asInputs.mode = VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR; asInputs.geometryCount = 1; - asInputs.pGeometries = &asGeometry; + asInputs.pGeometries = &geometryDesc; asInputs.flags = buildFlags; // Get the size requirements for the BLAS buffer + uint32_t primitiveCount = resources.probe.numIndices / 3; VkAccelerationStructureBuildSizesInfoKHR asPreBuildInfo = {}; asPreBuildInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR; vkGetAccelerationStructureBuildSizesKHR(vk.device, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &asInputs, &primitiveCount, &asPreBuildInfo); - // Create the acceleration structure buffer, allocate and bind device memory - BufferDesc desc = { asPreBuildInfo.accelerationStructureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; - if (!CreateBuffer(vk, desc, &resources.blas.asBuffer, &resources.blas.asMemory)) return false; - #ifdef GFX_NAME_OBJECTS - SetObjectName(vk.device, reinterpret_cast(resources.blas.asBuffer), "BLAS: Probe Sphere, Primitive 0", VK_OBJECT_TYPE_BUFFER); - SetObjectName(vk.device, reinterpret_cast(resources.blas.asMemory), "BLAS Memory: Probe Sphere, Primitive 0", VK_OBJECT_TYPE_DEVICE_MEMORY); - #endif - - // Create the scratch buffer, allocate and bind device memory - desc = { asPreBuildInfo.buildScratchSize, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; - if (!CreateBuffer(vk, desc, &resources.blas.scratch, &resources.blas.scratchMemory)) return false; + // Create the BLAS scratch buffer, allocate and bind device memory + BufferDesc blasScratchDesc = { asPreBuildInfo.buildScratchSize, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; + if (!CreateBuffer(vk, blasScratchDesc, &resources.blas.scratch, &resources.blas.scratchMemory)) return false; asInputs.scratchData = VkDeviceOrHostAddressKHR{ GetBufferDeviceAddress(vk.device, resources.blas.scratch) }; #ifdef GFX_NAME_OBJECTS SetObjectName(vk.device, reinterpret_cast(resources.blas.scratch), "BLAS Scratch: Probe Sphere, Primitive 0", VK_OBJECT_TYPE_BUFFER); SetObjectName(vk.device, reinterpret_cast(resources.blas.scratchMemory), "BLAS Scratch Memory: Probe Sphere, Primitive 0", VK_OBJECT_TYPE_DEVICE_MEMORY); #endif + // Create the BLAS buffer, allocate and bind device memory + BufferDesc blasDesc = { asPreBuildInfo.accelerationStructureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT }; + if (!CreateBuffer(vk, blasDesc, &resources.blas.asBuffer, &resources.blas.asMemory)) return false; + #ifdef GFX_NAME_OBJECTS + SetObjectName(vk.device, reinterpret_cast(resources.blas.asBuffer), "BLAS: Probe Sphere, Primitive 0", VK_OBJECT_TYPE_BUFFER); + SetObjectName(vk.device, reinterpret_cast(resources.blas.asMemory), "BLAS Memory: Probe Sphere, Primitive 0", VK_OBJECT_TYPE_DEVICE_MEMORY); + #endif + // Describe the BLAS acceleration structure VkAccelerationStructureCreateInfoKHR asCreateInfo = {}; asCreateInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR; @@ -1079,6 +1079,8 @@ namespace Graphics vkResources.constants.ddgivis.irradianceTextureScale = volume.probeIrradianceScale; vkResources.constants.ddgivis.distanceTextureScale = volume.probeDistanceScale; vkResources.constants.ddgivis.probeDataTextureScale = volume.probeDataScale; + vkResources.constants.ddgivis.probeVariabilityTextureScale = volume.probeVariabilityScale; + vkResources.constants.ddgivis.probeVariabilityTextureThreshold = volume.probeVariabilityThreshold; } } CPU_TIMESTAMP_END(resources.cpuStat); diff --git a/samples/test-harness/src/graphics/DDGI_D3D12.cpp b/samples/test-harness/src/graphics/DDGI_D3D12.cpp index 8c71304..6cd5dba 100644 --- a/samples/test-harness/src/graphics/DDGI_D3D12.cpp +++ b/samples/test-harness/src/graphics/DDGI_D3D12.cpp @@ -49,6 +49,7 @@ namespace Graphics std::flush(log); UINT arraySize = 0; + UINT variabilityAverageArraySize = 0; // Create the texture arrays { @@ -74,7 +75,7 @@ namespace Graphics GetDDGIVolumeTextureDimensions(volumeDesc, EDDGIVolumeTextureType::Irradiance, width, height, arraySize); format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Irradiance, volumeDesc.probeIrradianceFormat); - TextureDesc desc = { width, height, arraySize, 1, format, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET }; + TextureDesc desc = { width, height, arraySize, 1, format, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET }; CHECK(CreateTexture(d3d, desc, &volumeResources.unmanaged.probeIrradiance), "create DDGIVolume probe irradiance texture array!", log); #ifdef GFX_NAME_OBJECTS std::wstring name = L"DDGIVolume[" + std::to_wstring(volumeDesc.index) + L"], Probe Irradiance"; @@ -87,7 +88,7 @@ namespace Graphics GetDDGIVolumeTextureDimensions(volumeDesc, EDDGIVolumeTextureType::Distance, width, height, arraySize); format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Distance, volumeDesc.probeDistanceFormat); - TextureDesc desc = { width, height, arraySize, 1, format, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET }; + TextureDesc desc = { width, height, arraySize, 1, format, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET }; CHECK(CreateTexture(d3d, desc, &volumeResources.unmanaged.probeDistance), "create DDGIVolume probe distance texture array!", log); #ifdef GFX_NAME_OBJECTS std::wstring name = L"DDGIVolume[" + std::to_wstring(volumeDesc.index) + L"], Probe Distance"; @@ -101,13 +102,47 @@ namespace Graphics if (width <= 0 || height <= 0) return false; format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Data, volumeDesc.probeDataFormat); - TextureDesc desc = { width, height, arraySize, 1, format, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS }; + TextureDesc desc = { width, height, arraySize, 1, format, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS }; CHECK(CreateTexture(d3d, desc, &volumeResources.unmanaged.probeData), "create DDGIVolume probe data texture array!", log); #ifdef GFX_NAME_OBJECTS std::wstring name = L"DDGIVolume[" + std::to_wstring(volumeDesc.index) + L"], Probe Data"; volumeResources.unmanaged.probeData->SetName(name.c_str()); #endif } + + // Probe variability texture + { + GetDDGIVolumeTextureDimensions(volumeDesc, EDDGIVolumeTextureType::Variability, width, height, arraySize); + if (width <= 0 || height <= 0) return false; + format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Variability, volumeDesc.probeVariabilityFormat); + + TextureDesc desc = { width, height, arraySize, 1, format, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS }; + CHECK(CreateTexture(d3d, desc, &volumeResources.unmanaged.probeVariability), "create DDGIVolume Probe variability texture!", log); + #ifdef GFX_NAME_OBJECTS + std::wstring name = L"DDGIVolume[" + std::to_wstring(volumeDesc.index) + L"], Probe Variability"; + volumeResources.unmanaged.probeVariability->SetName(name.c_str()); + #endif + } + + // Probe variability average + { + GetDDGIVolumeTextureDimensions(volumeDesc, EDDGIVolumeTextureType::VariabilityAverage, width, height, variabilityAverageArraySize); + if (width <= 0 || height <= 0) return false; + format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::VariabilityAverage, volumeDesc.probeVariabilityFormat); + + TextureDesc desc = { width, height, variabilityAverageArraySize, 1, format, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS }; + CHECK(CreateTexture(d3d, desc, &volumeResources.unmanaged.probeVariabilityAverage), "create DDGIVolume Probe variability average texture!", log); + #ifdef GFX_NAME_OBJECTS + std::wstring name = L"DDGIVolume[" + std::to_wstring(volumeDesc.index) + L"], Probe Variability Average"; + volumeResources.unmanaged.probeVariabilityAverage->SetName(name.c_str()); + #endif + BufferDesc readbackDesc = { sizeof(float)*2, 0, EHeapType::READBACK, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_FLAG_NONE }; + CHECK(CreateBuffer(d3d, readbackDesc, &volumeResources.unmanaged.probeVariabilityReadback), "create DDGIVolume Probe variability readback buffer!", log); + #ifdef GFX_NAME_OBJECTS + name = L"DDGIVolume[" + std::to_wstring(volumeDesc.index) + L"], Probe Variability Readback"; + volumeResources.unmanaged.probeVariabilityReadback->SetName(name.c_str()); + #endif + } } // Create the resource descriptors @@ -182,6 +217,27 @@ namespace Graphics d3d.device->CreateUnorderedAccessView(volumeResources.unmanaged.probeData, nullptr, &uavDesc, uavHandle); d3d.device->CreateShaderResourceView(volumeResources.unmanaged.probeData, &srvDesc, srvHandle); } + + // Probe variability texture descriptors + { + uavHandle.ptr = heapStart.ptr + (resourceIndices.probeVariabilityUAVIndex * heapDesc.entrySize); + srvHandle.ptr = heapStart.ptr + (resourceIndices.probeVariabilitySRVIndex * heapDesc.entrySize); + + srvDesc.Format = uavDesc.Format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Variability, volumeDesc.probeVariabilityFormat); + d3d.device->CreateUnorderedAccessView(volumeResources.unmanaged.probeVariability, nullptr, &uavDesc, uavHandle); + d3d.device->CreateShaderResourceView(volumeResources.unmanaged.probeVariability, &srvDesc, srvHandle); + } + + // Probe variability average texture descriptors + { + uavHandle.ptr = heapStart.ptr + (resourceIndices.probeVariabilityAverageUAVIndex * heapDesc.entrySize); + srvHandle.ptr = heapStart.ptr + (resourceIndices.probeVariabilityAverageSRVIndex * heapDesc.entrySize); + + srvDesc.Format = uavDesc.Format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::VariabilityAverage, volumeDesc.probeVariabilityFormat); + srvDesc.Texture2DArray.ArraySize = uavDesc.Texture2DArray.ArraySize = variabilityAverageArraySize; + d3d.device->CreateUnorderedAccessView(volumeResources.unmanaged.probeVariabilityAverage, nullptr, &uavDesc, uavHandle); + d3d.device->CreateShaderResourceView(volumeResources.unmanaged.probeVariabilityAverage, &srvDesc, srvHandle); + } } // Set or create the root signature @@ -278,6 +334,31 @@ namespace Graphics #ifdef GFX_NAME_OBJECTS std::wstring name = L"DDGIVolume[" + std::to_wstring(volumeDesc.index) + L"], Probe Classification Reset PSO"; volumeResources.unmanaged.probeClassification.resetPSO->SetName(name.c_str()); + #endif + shaderIndex++; + } + + // Probe Variability Reduction PSO + { + desc.CS.BytecodeLength = shaders[shaderIndex].bytecode->GetBufferSize(); + desc.CS.pShaderBytecode = shaders[shaderIndex].bytecode->GetBufferPointer(); + D3DCHECK(d3d.device->CreateComputePipelineState(&desc, IID_PPV_ARGS(&volumeResources.unmanaged.probeVariabilityPSOs.reductionPSO))); + #ifdef GFX_NAME_OBJECTS + std::wstring name = L"DDGIVolume[" + std::to_wstring(volumeDesc.index) + L"], Probe Variability Reduction PSO"; + volumeResources.unmanaged.probeVariabilityPSOs.reductionPSO->SetName(name.c_str()); + #endif + shaderIndex++; + + } + + // Probe Variability Extra Reduction PSO + { + desc.CS.BytecodeLength = shaders[shaderIndex].bytecode->GetBufferSize(); + desc.CS.pShaderBytecode = shaders[shaderIndex].bytecode->GetBufferPointer(); + D3DCHECK(d3d.device->CreateComputePipelineState(&desc, IID_PPV_ARGS(&volumeResources.unmanaged.probeVariabilityPSOs.extraReductionPSO))); + #ifdef GFX_NAME_OBJECTS + std::wstring name = L"DDGIVolume[" + std::to_wstring(volumeDesc.index) + L"], Probe Variability Extra Reduction PSO"; + volumeResources.unmanaged.probeVariabilityPSOs.extraReductionPSO->SetName(name.c_str()); #endif } } @@ -304,6 +385,9 @@ namespace Graphics if (volume->GetProbeIrradiance()) volume->GetProbeIrradiance()->Release(); if (volume->GetProbeDistance()) volume->GetProbeDistance()->Release(); if (volume->GetProbeData()) volume->GetProbeData()->Release(); + if (volume->GetProbeVariability()) volume->GetProbeVariability()->Release(); + if (volume->GetProbeVariabilityAverage()) volume->GetProbeVariabilityAverage()->Release(); + if (volume->GetProbeVariabilityReadback()) volume->GetProbeVariabilityReadback()->Release(); // Release PSOs if (volume->GetProbeBlendingIrradiancePSO()) volume->GetProbeBlendingIrradiancePSO()->Release(); @@ -312,6 +396,8 @@ namespace Graphics if (volume->GetProbeRelocationResetPSO()) volume->GetProbeRelocationResetPSO()->Release(); if (volume->GetProbeClassificationPSO()) volume->GetProbeClassificationPSO()->Release(); if (volume->GetProbeClassificationResetPSO()) volume->GetProbeClassificationResetPSO()->Release(); + if (volume->GetProbeVariabilityReductionPSO()) volume->GetProbeVariabilityReductionPSO()->Release(); + if (volume->GetProbeVariabilityExtraReductionPSO()) volume->GetProbeVariabilityExtraReductionPSO()->Release(); // Clear pointers volume->Destroy(); @@ -327,7 +413,11 @@ namespace Graphics */ void GetDDGIVolumeDesc(const Configs::DDGIVolume& config, DDGIVolumeDesc& volumeDesc) { - volumeDesc.name = config.name.c_str(); + size_t size = config.name.size(); + volumeDesc.name = new char[size + 1]; + memset(volumeDesc.name, 0, size + 1); + memcpy(volumeDesc.name, config.name.c_str(), size); + volumeDesc.index = config.index; volumeDesc.rngSeed = config.rngSeed; volumeDesc.origin = { config.origin.x, config.origin.y, config.origin.z }; @@ -353,11 +443,12 @@ namespace Graphics volumeDesc.probeIrradianceFormat = config.textureFormats.irradianceFormat; volumeDesc.probeDistanceFormat = config.textureFormats.distanceFormat; volumeDesc.probeDataFormat = config.textureFormats.dataFormat; + volumeDesc.probeVariabilityFormat = config.textureFormats.variabilityFormat; volumeDesc.probeRelocationEnabled = config.probeRelocationEnabled; volumeDesc.probeMinFrontfaceDistance = config.probeMinFrontfaceDistance; - volumeDesc.probeClassificationEnabled = config.probeClassificationEnabled; + volumeDesc.probeVariabilityEnabled = config.probeVariabilityEnabled; if (config.infiniteScrollingEnabled) volumeDesc.movementType = EDDGIVolumeMovementType::Scrolling; else volumeDesc.movementType = EDDGIVolumeMovementType::Default; @@ -402,6 +493,10 @@ namespace Graphics descHeap.resourceIndices.probeDistanceSRVIndex = DescriptorHeapOffsets::SRV_DDGI_VOLUME_TEX2DARRAY + (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 2; descHeap.resourceIndices.probeDataUAVIndex = DescriptorHeapOffsets::UAV_DDGI_VOLUME_TEX2DARRAY + (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 3; descHeap.resourceIndices.probeDataSRVIndex = DescriptorHeapOffsets::SRV_DDGI_VOLUME_TEX2DARRAY + (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 3; + descHeap.resourceIndices.probeVariabilityUAVIndex = DescriptorHeapOffsets::UAV_DDGI_VOLUME_TEX2DARRAY + (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 4; + descHeap.resourceIndices.probeVariabilitySRVIndex = DescriptorHeapOffsets::SRV_DDGI_VOLUME_TEX2DARRAY + (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 4; + descHeap.resourceIndices.probeVariabilityAverageUAVIndex = DescriptorHeapOffsets::UAV_DDGI_VOLUME_TEX2DARRAY + (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 5; + descHeap.resourceIndices.probeVariabilityAverageSRVIndex = DescriptorHeapOffsets::SRV_DDGI_VOLUME_TEX2DARRAY + (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 5; // Set the volume constants structured buffer pointers and size volumeResources.constantsBuffer = resources.volumeConstantsSTB; @@ -435,6 +530,10 @@ namespace Graphics resourceIndices.probeDistanceSRVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 2; resourceIndices.probeDataUAVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 3; resourceIndices.probeDataSRVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 3; + resourceIndices.probeVariabilityUAVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 4; + resourceIndices.probeVariabilitySRVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 4; + resourceIndices.probeVariabilityAverageUAVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 5; + resourceIndices.probeVariabilityAverageSRVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 5; #if RTXGI_DDGI_RESOURCE_MANAGEMENT // Enable "Managed Mode", the RTXGI SDK creates graphics objects @@ -452,9 +551,13 @@ namespace Graphics volumeResources.managed.probeRelocation.updateCS = { volumeShaders[2].bytecode->GetBufferPointer(), volumeShaders[2].bytecode->GetBufferSize() }; volumeResources.managed.probeRelocation.resetCS = { volumeShaders[3].bytecode->GetBufferPointer(), volumeShaders[3].bytecode->GetBufferSize() }; - assert(volumeShaders.size() == 6); + assert(volumeShaders.size() >= 6); volumeResources.managed.probeClassification.updateCS = { volumeShaders[4].bytecode->GetBufferPointer(), volumeShaders[4].bytecode->GetBufferSize() }; volumeResources.managed.probeClassification.resetCS = { volumeShaders[5].bytecode->GetBufferPointer(), volumeShaders[5].bytecode->GetBufferSize() }; + + assert(volumeShaders.size() == 8); + volumeResources.managed.probeVariability.reductionCS = { volumeShaders[6].bytecode->GetBufferPointer(), volumeShaders[6].bytecode->GetBufferSize() }; + volumeResources.managed.probeVariability.extraReductionCS = { volumeShaders[7].bytecode->GetBufferPointer(), volumeShaders[7].bytecode->GetBufferSize() }; #else // Enable "Unmanaged Mode", the application creates graphics objects volumeResources.unmanaged.enabled = true; @@ -500,17 +603,20 @@ namespace Graphics #else DestroyDDGIVolumeResources(resources, volumeConfig.index); #endif - delete resources.volumes[volumeConfig.index]; - resources.volumes[volumeConfig.index] = nullptr; + SAFE_DELETE(resources.volumeDescs[volumeConfig.index].name); + SAFE_DELETE(resources.volumes[volumeConfig.index]); + resources.numVolumeVariabilitySamples[volumeConfig.index] = 0; } } else { + resources.volumeDescs.emplace_back(); resources.volumes.emplace_back(); + resources.numVolumeVariabilitySamples.emplace_back(); } // Describe the DDGIVolume's properties - DDGIVolumeDesc volumeDesc; + DDGIVolumeDesc& volumeDesc = resources.volumeDescs[volumeConfig.index]; GetDDGIVolumeDesc(volumeConfig, volumeDesc); // Describe the DDGIVolume's resources and shaders @@ -678,6 +784,7 @@ namespace Graphics resources.rtShaders.rgs.filepath = root + L"shaders/ddgi/ProbeTraceRGS.hlsl"; resources.rtShaders.rgs.entryPoint = L"RayGen"; resources.rtShaders.rgs.exportName = L"DDGIProbeTraceRGS"; + Shaders::AddDefine(resources.rtShaders.rgs, L"GFX_NVAPI", std::to_wstring(1)); Shaders::AddDefine(resources.rtShaders.rgs, L"CONSTS_REGISTER", L"b0"); // for DDGIRootConstants, see Direct3D12.cpp::CreateGlobalRootSignature(...) Shaders::AddDefine(resources.rtShaders.rgs, L"CONSTS_SPACE", L"space1"); // for DDGIRootConstants, see Direct3D12.cpp::CreateGlobalRootSignature(...) Shaders::AddDefine(resources.rtShaders.rgs, L"RTXGI_BINDLESS_TYPE", std::to_wstring(RTXGI_BINDLESS_TYPE)); @@ -932,13 +1039,19 @@ namespace Graphics // Dispatch the rays d3d.cmdList->DispatchRays(&desc); + // Transition the volume's irradiance, distance, and probe data texture arrays from read-only (non-pixel shader) to read-write (UAV) + volume->TransitionResources(d3d.cmdList, EDDGIExecutionStage::POST_PROBE_TRACE); + // Barrier(s) barrier.UAV.pResource = volume->GetProbeRayData(); barriers.push_back(barrier); } // Wait for the ray traces to complete - d3d.cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); + if (!barriers.empty()) + { + d3d.cmdList->ResourceBarrier(static_cast(barriers.size()), barriers.data()); + } #ifdef GFX_PERF_MARKERS PIXEndEvent(d3d.cmdList); @@ -951,6 +1064,14 @@ namespace Graphics PIXBeginEvent(d3d.cmdList, PIX_COLOR(GFX_PERF_MARKER_GREEN), "Indirect Lighting"); #endif + // Transition the selected volume's irradiance, distance, and data texture arrays from read-write (UAV) to read-only (non-pixel shader) + // Note: use PRE_GATHER_PS if using the pixel shader (instead of compute) to gather indirect light + for (UINT volumeIndex = 0; volumeIndex < static_cast(resources.selectedVolumes.size()); volumeIndex++) + { + const DDGIVolume* volume = resources.selectedVolumes[volumeIndex]; + volume->TransitionResources(d3d.cmdList, EDDGIExecutionStage::PRE_GATHER_CS); + } + // Set the descriptor heaps ID3D12DescriptorHeap* ppHeaps[] = { d3dResources.srvDescHeap, d3dResources.samplerDescHeap }; d3d.cmdList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps); @@ -972,6 +1093,14 @@ namespace Graphics UINT groupsY = DivRoundUp(d3d.height, 4); d3d.cmdList->Dispatch(groupsX, groupsY, 1); + // Note: if using the pixel shader (instead of compute) to gather indirect light, transition + // the selected volume's resources to D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE + //for (UINT volumeIndex = 0; volumeIndex < static_cast(resources.selectedVolumes.size()); volumeIndex++) + //{ + // const DDGIVolume* volume = resources.selectedVolumes[volumeIndex]; + // volume->TransitionResources(d3d.cmdList, EDDGIExecutionStage::POST_GATHER_PS); + //} + // Wait for the compute pass to finish D3D12_RESOURCE_BARRIER barrier = {}; barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; @@ -995,8 +1124,8 @@ namespace Graphics // Validate the SDK version assert(RTXGI_VERSION::major == 1); assert(RTXGI_VERSION::minor == 3); - assert(RTXGI_VERSION::revision == 0); - assert(std::strcmp(RTXGI_VERSION::getVersionString(), "1.3.0") == 0); + assert(RTXGI_VERSION::revision == 5); + assert(std::strcmp(RTXGI_VERSION::getVersionString(), "1.3.5") == 0); UINT numVolumes = static_cast(config.ddgi.volumes.size()); @@ -1033,6 +1162,7 @@ namespace Graphics resources.relocateStat = perf.AddGPUStat(" Relocate"); resources.classifyStat = perf.AddGPUStat(" Classify"); resources.lightingStat = perf.AddGPUStat(" Lighting"); + resources.variabilityStat = perf.AddGPUStat(" Variability"); return true; } @@ -1051,12 +1181,7 @@ namespace Graphics for (UINT volumeIndex = 0; volumeIndex < static_cast(resources.volumes.size()); volumeIndex++) { Configs::DDGIVolume volumeConfig = config.ddgi.volumes[volumeIndex]; - if (!CreateDDGIVolume( - d3d, - d3dResources, - resources, - volumeConfig, - log)) return false; + if (!CreateDDGIVolume(d3d, d3dResources, resources, volumeConfig, log)) return false; } log << "done.\n"; log << std::flush; @@ -1088,6 +1213,8 @@ namespace Graphics // Path Trace constants d3dResources.constants.pt.rayNormalBias = config.pathTrace.rayNormalBias; d3dResources.constants.pt.rayViewBias = config.pathTrace.rayViewBias; + d3dResources.constants.pt.samplesPerPixel = config.pathTrace.samplesPerPixel; + d3dResources.constants.pt.SetShaderExecutionReordering(config.ddgi.shaderExecutionReordering); // Clear the selected volume, if necessary if (config.ddgi.volumes[config.ddgi.selectedVolume].clearProbes) @@ -1096,6 +1223,7 @@ namespace Graphics volume->ClearProbes(d3d.cmdList); config.ddgi.volumes[config.ddgi.selectedVolume].clearProbes = 0; + resources.numVolumeVariabilitySamples[config.ddgi.selectedVolume] = 0; } // Select the active volumes @@ -1103,9 +1231,23 @@ namespace Graphics for (UINT volumeIndex = 0; volumeIndex < static_cast(resources.volumes.size()); volumeIndex++) { // TODO: processing to determine which volumes are in-frustum, active, and prioritized for update / render - // For now, just select all volumes + + // Get the volume DDGIVolume* volume = static_cast(resources.volumes[volumeIndex]); - resources.selectedVolumes.push_back(volume); + + // If the scene's lights, skylight, or geometry have changed *or* the volume moves *or* the probes are reset, reset the variability + if (config.ddgi.volumes[volumeIndex].clearProbeVariability) resources.numVolumeVariabilitySamples[volumeIndex] = 0; + + // Don't update volumes whose variability measurement is low enough to be considered converged + // Enforce a minimum of 16 samples to filter out early outliers + const uint32_t MinimumVariabilitySamples = 16; + float volumeAverageVariability = volume->GetVolumeAverageVariability(); + bool isConverged = volume->GetProbeVariabilityEnabled() + && (resources.numVolumeVariabilitySamples[volumeIndex]++ > MinimumVariabilitySamples) + && (volumeAverageVariability < config.ddgi.volumes[config.ddgi.selectedVolume].probeVariabilityThreshold); + + // Add the volume to the list of volumes to update (it hasn't converged) + if (!isConverged) resources.selectedVolumes.push_back(volume); } // Update the constants for the selected DDGIVolumes @@ -1156,6 +1298,13 @@ namespace Graphics rtxgi::d3d12::ClassifyDDGIVolumeProbes(d3d.cmdList, numVolumes, resources.selectedVolumes.data()); GPU_TIMESTAMP_END(resources.classifyStat->GetGPUQueryEndIndex()); + // Calculate variability + GPU_TIMESTAMP_BEGIN(resources.variabilityStat->GetGPUQueryBeginIndex()); + rtxgi::d3d12::CalculateDDGIVolumeVariability(d3d.cmdList, numVolumes, resources.selectedVolumes.data()); + // The readback happens immediately, not recorded on the command list, so will return a value from a previous update + rtxgi::d3d12::ReadbackDDGIVolumeVariability(numVolumes, resources.selectedVolumes.data()); + GPU_TIMESTAMP_END(resources.variabilityStat->GetGPUQueryEndIndex()); + // Gather indirect lighting in screen-space GPU_TIMESTAMP_BEGIN(resources.lightingStat->GetGPUQueryBeginIndex()); GatherIndirectLighting(d3d, d3dResources, resources); @@ -1197,8 +1346,11 @@ namespace Graphics SAFE_RELEASE(resources.rtvDescriptorHeap); SAFE_RELEASE(resources.volumeResourceIndicesSTB); SAFE_RELEASE(resources.volumeResourceIndicesSTBUpload); + + resources.volumeResourceIndicesSTBSizeInBytes = 0; SAFE_RELEASE(resources.volumeConstantsSTB); SAFE_RELEASE(resources.volumeConstantsSTBUpload); + resources.volumeConstantsSTBSizeInBytes = 0; // Release volumes for (size_t volumeIndex = 0; volumeIndex < resources.volumes.size(); volumeIndex++) @@ -1206,10 +1358,13 @@ namespace Graphics #if !RTXGI_DDGI_RESOURCE_MANAGEMENT DestroyDDGIVolumeResources(resources, volumeIndex); #endif + SAFE_DELETE(resources.volumeDescs[volumeIndex].name); resources.volumes[volumeIndex]->Destroy(); - delete resources.volumes[volumeIndex]; - resources.volumes[volumeIndex] = nullptr; + SAFE_DELETE(resources.volumes[volumeIndex]); } + resources.volumeDescs.clear(); + resources.volumes.clear(); + resources.selectedVolumes.clear(); } /** @@ -1230,13 +1385,22 @@ namespace Graphics // Write probe irradiance std::string filename = baseName + "-Irradiance"; - success &= WriteResourceToDisk(d3d, filename, volume->GetProbeIrradiance(), D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + success &= WriteResourceToDisk(d3d, filename, volume->GetProbeIrradiance(), D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); // Write probe data if(volume->GetProbeRelocationEnabled() || volume->GetProbeClassificationEnabled()) { filename = baseName + "-Probe-Data"; - success &= WriteResourceToDisk(d3d, filename, volume->GetProbeData(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + success &= WriteResourceToDisk(d3d, filename, volume->GetProbeData(), D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); + } + + // Write probe variability + if (volume->GetProbeVariabilityEnabled()) + { + filename = baseName + "-Probe-Variability"; + success &= WriteResourceToDisk(d3d, filename, volume->GetProbeVariability(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + filename = baseName + "-Probe-Variability-Average"; + success &= WriteResourceToDisk(d3d, filename, volume->GetProbeVariabilityAverage(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS); } } return success; diff --git a/samples/test-harness/src/graphics/DDGI_VK.cpp b/samples/test-harness/src/graphics/DDGI_VK.cpp index 86cd33b..a576156 100644 --- a/samples/test-harness/src/graphics/DDGI_VK.cpp +++ b/samples/test-harness/src/graphics/DDGI_VK.cpp @@ -29,8 +29,8 @@ namespace Graphics const char* GetResourceName(std::string input, std::string& output, VkObjectType objType) { output = input; - if(objType = VK_OBJECT_TYPE_DEVICE_MEMORY) output.append(" Memory"); - else if(objType = VK_OBJECT_TYPE_IMAGE_VIEW) output.append(" View"); + if(objType == VK_OBJECT_TYPE_DEVICE_MEMORY) output.append(" Memory"); + else if(objType == VK_OBJECT_TYPE_IMAGE_VIEW) output.append(" View"); return output.c_str(); } @@ -133,6 +133,8 @@ namespace Graphics { VK_NULL_HANDLE, volume->GetProbeIrradianceView(), VK_IMAGE_LAYOUT_GENERAL }, { VK_NULL_HANDLE, volume->GetProbeDistanceView(), VK_IMAGE_LAYOUT_GENERAL }, { VK_NULL_HANDLE, volume->GetProbeDataView(), VK_IMAGE_LAYOUT_GENERAL } + { VK_NULL_HANDLE, volume->GetProbeVariabilityView(), VK_IMAGE_LAYOUT_GENERAL } + { VK_NULL_HANDLE, volume->GetProbeVariabilityAverageView(), VK_IMAGE_LAYOUT_GENERAL } }; descriptor = &descriptors.emplace_back(); @@ -167,6 +169,8 @@ namespace Graphics std::flush(log); uint32_t arraySize = 0; + // need to save averaging texture array size separately because it will be smaller for this texture, and arraySize is used below for barriers + uint32_t variabilityAverageArraySize = 0; // Create the texture arrays { @@ -229,7 +233,7 @@ namespace Graphics format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Data, volumeDesc.probeDataFormat); TextureDesc desc = { width, height, arraySize, 1, format, VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT }; - CHECK(CreateTexture(vk, desc, &volumeResources.unmanaged.probeData, &volumeResources.unmanaged.probeDataMemory, &volumeResources.unmanaged.probeDataView), "", log); + CHECK(CreateTexture(vk, desc, &volumeResources.unmanaged.probeData, &volumeResources.unmanaged.probeDataMemory, &volumeResources.unmanaged.probeDataView), "create DDGIVolume probe data texture!", log); #ifdef GFX_NAME_OBJECTS std::string n = "DDGIVolume[" + std::to_string(volumeDesc.index) + "], Probe Data"; std::string o = ""; @@ -238,6 +242,48 @@ namespace Graphics SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeDataView), GetResourceName(n, o, VK_OBJECT_TYPE_IMAGE_VIEW), VK_OBJECT_TYPE_IMAGE_VIEW); #endif } + + // Probe variability texture + { + GetDDGIVolumeTextureDimensions(volumeDesc, EDDGIVolumeTextureType::Variability, width, height, arraySize); + if (width <= 0 || height <= 0) return false; + format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Variability, volumeDesc.probeVariabilityFormat); + + TextureDesc desc = { width, height, arraySize, 1, format, VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT }; + CHECK(CreateTexture(vk, desc, &volumeResources.unmanaged.probeVariability, &volumeResources.unmanaged.probeVariabilityMemory, &volumeResources.unmanaged.probeVariabilityView), "create DDGIVolume Probe variability texture!", log); + #ifdef GFX_NAME_OBJECTS + std::string n = "DDGIVolume[" + std::to_string(volumeDesc.index) + "], Probe Variability"; + std::string o = ""; + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariability), n.c_str(), VK_OBJECT_TYPE_IMAGE); + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityMemory), GetResourceName(n, o, VK_OBJECT_TYPE_DEVICE_MEMORY), VK_OBJECT_TYPE_DEVICE_MEMORY); + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityView), GetResourceName(n, o, VK_OBJECT_TYPE_IMAGE_VIEW), VK_OBJECT_TYPE_IMAGE_VIEW); + #endif + } + + // Probe variability average + { + GetDDGIVolumeTextureDimensions(volumeDesc, EDDGIVolumeTextureType::VariabilityAverage, width, height, variabilityAverageArraySize); + if (width <= 0 || height <= 0) return false; + format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::VariabilityAverage, volumeDesc.probeVariabilityFormat); + + TextureDesc desc = { width, height, variabilityAverageArraySize, 1, format, VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT }; + CHECK(CreateTexture(vk, desc, &volumeResources.unmanaged.probeVariabilityAverage, &volumeResources.unmanaged.probeVariabilityAverageMemory, &volumeResources.unmanaged.probeVariabilityAverageView), "create DDGIVolume Probe variability average texture!", log); + #ifdef GFX_NAME_OBJECTS + std::string n = "DDGIVolume[" + std::to_string(volumeDesc.index) + "], Probe Variability Average"; + std::string o = ""; + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityAverage), n.c_str(), VK_OBJECT_TYPE_IMAGE); + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityAverageMemory), GetResourceName(n, o, VK_OBJECT_TYPE_DEVICE_MEMORY), VK_OBJECT_TYPE_DEVICE_MEMORY); + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityAverageView), GetResourceName(n, o, VK_OBJECT_TYPE_IMAGE_VIEW), VK_OBJECT_TYPE_IMAGE_VIEW); + #endif + BufferDesc readbackDesc = { sizeof(float)*2, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT }; + CHECK(CreateBuffer(vk, readbackDesc, &volumeResources.unmanaged.probeVariabilityReadback, &volumeResources.unmanaged.probeVariabilityReadbackMemory), "create DDGIVolume Probe variability readback buffer!", log); + #ifdef GFX_NAME_OBJECTS + n = "DDGIVolume[" + std::to_string(volumeDesc.index) + "], Probe Variability Readback"; + o = ""; + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityReadback), n.c_str(), VK_OBJECT_TYPE_BUFFER); + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityReadbackMemory), GetResourceName(n, o, VK_OBJECT_TYPE_DEVICE_MEMORY), VK_OBJECT_TYPE_DEVICE_MEMORY); + #endif + } } // Transition the resources for general use @@ -255,6 +301,9 @@ namespace Graphics SetImageLayoutBarrier(vk.cmdBuffer[vk.frameIndex], volumeResources.unmanaged.probeIrradiance, barrier); SetImageLayoutBarrier(vk.cmdBuffer[vk.frameIndex], volumeResources.unmanaged.probeDistance, barrier); SetImageLayoutBarrier(vk.cmdBuffer[vk.frameIndex], volumeResources.unmanaged.probeData, barrier); + SetImageLayoutBarrier(vk.cmdBuffer[vk.frameIndex], volumeResources.unmanaged.probeVariability, barrier); + barrier.subresourceRange.layerCount = variabilityAverageArraySize; + SetImageLayoutBarrier(vk.cmdBuffer[vk.frameIndex], volumeResources.unmanaged.probeVariabilityAverage, barrier); } // Set the pipeline layout and descriptor set @@ -412,6 +461,54 @@ namespace Graphics name = "DDGIVolume[" + std::to_string(volumeDesc.index) + "], Probe Classification Reset Pipeline"; SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeClassification.resetPipeline), name.c_str(), VK_OBJECT_TYPE_PIPELINE); #endif + + shaderIndex++; + } + + // Probe Variability Reduction Pipeline + { + // Create the shader module + CHECK(CreateShaderModule(vk.device, volumeShaders[shaderIndex], &volumeResources.unmanaged.probeVariabilityPipelines.reductionModule), "create probe variability reduction module!", log); + #ifdef GFX_NAME_OBJECTS + std::string name = "DDGIVolume[" + std::to_string(volumeDesc.index) + "], Probe Variability Reduction Shader Module"; + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityPipelines.reductionModule), name.c_str(), VK_OBJECT_TYPE_SHADER_MODULE); + #endif + + // Create the pipeline + CHECK(CreateComputePipeline( + vk.device, + volumeResources.unmanaged.pipelineLayout, + volumeShaders[shaderIndex], + volumeResources.unmanaged.probeVariabilityPipelines.reductionModule, + &volumeResources.unmanaged.probeVariabilityPipelines.reductionPipeline), "", log); + #ifdef GFX_NAME_OBJECTS + name = "DDGIVolume[" + std::to_string(volumeDesc.index) + "], Probe Variability Reduction Pipeline"; + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityPipelines.reductionPipeline), name.c_str(), VK_OBJECT_TYPE_PIPELINE); + #endif + + shaderIndex++; + } + + // Probe Variability Extra Reduction Pipeline + { + // Create the shader module + CHECK(CreateShaderModule(vk.device, volumeShaders[shaderIndex], &volumeResources.unmanaged.probeVariabilityPipelines.extraReductionModule), "create probe variability extra reduction module!", log); + #ifdef GFX_NAME_OBJECTS + std::string name = "DDGIVolume[" + std::to_string(volumeDesc.index) + "], Probe Variability Extra Reduction Shader Module"; + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityPipelines.reductionModule), name.c_str(), VK_OBJECT_TYPE_SHADER_MODULE); + #endif + + // Create the pipeline + CHECK(CreateComputePipeline( + vk.device, + volumeResources.unmanaged.pipelineLayout, + volumeShaders[shaderIndex], + volumeResources.unmanaged.probeVariabilityPipelines.extraReductionModule, + &volumeResources.unmanaged.probeVariabilityPipelines.extraReductionPipeline), "", log); + #ifdef GFX_NAME_OBJECTS + name = "DDGIVolume[" + std::to_string(volumeDesc.index) + "], Probe Variability Extra Reduction Pipeline"; + SetObjectName(vk.device, reinterpret_cast(volumeResources.unmanaged.probeVariabilityPipelines.extraReductionPipeline), name.c_str(), VK_OBJECT_TYPE_PIPELINE); + #endif } } @@ -433,18 +530,26 @@ namespace Graphics vkDestroyImage(device, volume->GetProbeIrradiance(), nullptr); vkDestroyImage(device, volume->GetProbeDistance(), nullptr); vkDestroyImage(device, volume->GetProbeData(), nullptr); + vkDestroyImage(device, volume->GetProbeVariability(), nullptr); + vkDestroyImage(device, volume->GetProbeVariabilityAverage(), nullptr); + vkDestroyBuffer(device, volume->GetProbeVariabilityReadback(), nullptr); // Texture Array Memory vkFreeMemory(device, volume->GetProbeRayDataMemory(), nullptr); vkFreeMemory(device, volume->GetProbeIrradianceMemory(), nullptr); vkFreeMemory(device, volume->GetProbeDistanceMemory(), nullptr); vkFreeMemory(device, volume->GetProbeDataMemory(), nullptr); + vkFreeMemory(device, volume->GetProbeVariabilityMemory(), nullptr); + vkFreeMemory(device, volume->GetProbeVariabilityAverageMemory(), nullptr); + vkFreeMemory(device, volume->GetProbeVariabilityReadbackMemory(), nullptr); // Texture Array Views vkDestroyImageView(device, volume->GetProbeRayDataView(), nullptr); vkDestroyImageView(device, volume->GetProbeIrradianceView(), nullptr); vkDestroyImageView(device, volume->GetProbeDistanceView(), nullptr); vkDestroyImageView(device, volume->GetProbeDataView(), nullptr); + vkDestroyImageView(device, volume->GetProbeVariabilityView(), nullptr); + vkDestroyImageView(device, volume->GetProbeVariabilityAverageView(), nullptr); // Shader Modules vkDestroyShaderModule(device, volume->GetProbeBlendingIrradianceModule(), nullptr); @@ -454,6 +559,9 @@ namespace Graphics vkDestroyShaderModule(device, volume->GetProbeClassificationModule(), nullptr); vkDestroyShaderModule(device, volume->GetProbeClassificationResetModule(), nullptr); + vkDestroyShaderModule(device, volume->GetProbeVariabilityReductionModule(), nullptr); + vkDestroyShaderModule(device, volume->GetProbeVariabilityExtraReductionModule(), nullptr); + // Pipelines vkDestroyPipeline(device, volume->GetProbeBlendingIrradiancePipeline(), nullptr); vkDestroyPipeline(device, volume->GetProbeBlendingDistancePipeline(), nullptr); @@ -462,6 +570,9 @@ namespace Graphics vkDestroyPipeline(device, volume->GetProbeClassificationPipeline(), nullptr); vkDestroyPipeline(device, volume->GetProbeClassificationResetPipeline(), nullptr); + vkDestroyPipeline(device, volume->GetProbeVariabilityReductionPipeline(), nullptr); + vkDestroyPipeline(device, volume->GetProbeVariabilityExtraReductionPipeline(), nullptr); + // Clear pointers volume->Destroy(); } @@ -476,7 +587,11 @@ namespace Graphics */ void GetDDGIVolumeDesc(const Configs::DDGIVolume& config, DDGIVolumeDesc& volumeDesc) { - volumeDesc.name = config.name.c_str(); + size_t size = config.name.size(); + volumeDesc.name = new char[size + 1]; + memset(volumeDesc.name, 0, size + 1); + memcpy(volumeDesc.name, config.name.c_str(), size); + volumeDesc.index = config.index; volumeDesc.rngSeed = config.rngSeed; volumeDesc.origin = { config.origin.x, config.origin.y, config.origin.z }; @@ -502,11 +617,12 @@ namespace Graphics volumeDesc.probeIrradianceFormat = config.textureFormats.irradianceFormat; volumeDesc.probeDistanceFormat = config.textureFormats.distanceFormat; volumeDesc.probeDataFormat = config.textureFormats.dataFormat; + volumeDesc.probeVariabilityFormat = config.textureFormats.variabilityFormat; volumeDesc.probeRelocationEnabled = config.probeRelocationEnabled; volumeDesc.probeMinFrontfaceDistance = config.probeMinFrontfaceDistance; - volumeDesc.probeClassificationEnabled = config.probeClassificationEnabled; + volumeDesc.probeVariabilityEnabled = config.probeVariabilityEnabled; if (config.infiniteScrollingEnabled) volumeDesc.movementType = EDDGIVolumeMovementType::Scrolling; else volumeDesc.movementType = EDDGIVolumeMovementType::Default; @@ -563,6 +679,10 @@ namespace Graphics resourceIndices.probeDistanceSRVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 2; resourceIndices.probeDataUAVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 3; resourceIndices.probeDataSRVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 3; + resourceIndices.probeVariabilityUAVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 4; + resourceIndices.probeVariabilitySRVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 4; + resourceIndices.probeVariabilityAverageUAVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 5; + resourceIndices.probeVariabilityAverageSRVIndex = (volumeDesc.index * rtxgi::GetDDGIVolumeNumTex2DArrayDescriptors()) + 5; #if RTXGI_DDGI_RESOURCE_MANAGEMENT // Enable "Managed Mode", the RTXGI SDK creates graphics objects @@ -583,9 +703,13 @@ namespace Graphics volumeResources.managed.probeRelocation.updateCS = { volumeShaders[2].bytecode->GetBufferPointer(), volumeShaders[2].bytecode->GetBufferSize() }; volumeResources.managed.probeRelocation.resetCS = { volumeShaders[3].bytecode->GetBufferPointer(), volumeShaders[3].bytecode->GetBufferSize() }; - assert(volumeShaders.size() == 6); + assert(volumeShaders.size() >= 6); volumeResources.managed.probeClassification.updateCS = { volumeShaders[4].bytecode->GetBufferPointer(), volumeShaders[4].bytecode->GetBufferSize() }; volumeResources.managed.probeClassification.resetCS = { volumeShaders[5].bytecode->GetBufferPointer(), volumeShaders[5].bytecode->GetBufferSize() }; + + assert(volumeShaders.size() == 8); + volumeResources.managed.probeVariability.reductionCS = { volumeShaders[6].bytecode->GetBufferPointer(), volumeShaders[6].bytecode->GetBufferSize() }; + volumeResources.managed.probeVariability.extraReductionCS = { volumeShaders[7].bytecode->GetBufferPointer(), volumeShaders[7].bytecode->GetBufferSize() }; #else // Enable "Unmanaged Mode", the application creates graphics objects volumeResources.unmanaged.enabled = true; @@ -618,17 +742,20 @@ namespace Graphics #else DestroyDDGIVolumeResources(vk.device, resources, volumeConfig.index); #endif - delete resources.volumes[volumeConfig.index]; - resources.volumes[volumeConfig.index] = nullptr; + SAFE_DELETE(resources.volumeDescs[volumeConfig.index].name); + SAFE_DELETE(resources.volumes[volumeConfig.index]); + resources.numVolumeVariabilitySamples[volumeConfig.index] = 0; } } else { + resources.volumeDescs.emplace_back(); resources.volumes.emplace_back(); + resources.numVolumeVariabilitySamples.emplace_back(); } // Describe the DDGIVolume's properties - DDGIVolumeDesc volumeDesc; + DDGIVolumeDesc& volumeDesc = resources.volumeDescs[volumeConfig.index]; GetDDGIVolumeDesc(volumeConfig, volumeDesc); // Describe the DDGIVolume's resources and shaders @@ -776,6 +903,9 @@ namespace Graphics Shaders::AddDefine(resources.rtShaders.rgs, L"RTXGI_PUSH_CONSTS_STRUCT_NAME", L"GlobalConstants"); // specify the struct name of the application's push constants Shaders::AddDefine(resources.rtShaders.rgs, L"RTXGI_PUSH_CONSTS_VARIABLE_NAME", L"GlobalConst"); // specify the variable name of the application's push constants Shaders::AddDefine(resources.rtShaders.rgs, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_VOLUME_INDEX_NAME", L"ddgi_volumeIndex"); // specify the name of the DDGIVolume index field in the application's push constants struct + Shaders::AddDefine(resources.rtShaders.rgs, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_X_NAME", L"ddgi_reductionInputSizeX"); // specify the name of the DDGIVolume reduction pass input size fields the application's push constants struct + Shaders::AddDefine(resources.rtShaders.rgs, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Y_NAME", L"ddgi_reductionInputSizeY"); + Shaders::AddDefine(resources.rtShaders.rgs, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Z_NAME", L"ddgi_reductionInputSizeZ"); Shaders::AddDefine(resources.rtShaders.rgs, L"RTXGI_BINDLESS_TYPE", std::to_wstring(RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS)); Shaders::AddDefine(resources.rtShaders.rgs, L"RTXGI_COORDINATE_SYSTEM", std::to_wstring(RTXGI_COORDINATE_SYSTEM)); CHECK(Shaders::Compile(vk.shaderCompiler, resources.rtShaders.rgs, true), "compile DDGI probe tracing ray generation shader!\n", log); @@ -830,6 +960,9 @@ namespace Graphics Shaders::AddDefine(resources.indirectCS, L"RTXGI_PUSH_CONSTS_STRUCT_NAME", L"GlobalConstants"); // specify the struct name of the application's push constants Shaders::AddDefine(resources.indirectCS, L"RTXGI_PUSH_CONSTS_VARIABLE_NAME", L"GlobalConst"); // specify the variable name of the application's push constants Shaders::AddDefine(resources.indirectCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_VOLUME_INDEX_NAME", L"ddgi_volumeIndex"); // specify the name of the DDGIVolume index field in the application's push constants struct + Shaders::AddDefine(resources.indirectCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_X_NAME", L"ddgi_reductionInputSizeX"); // specify the name of the DDGIVolume reduction pass input size fields the application's push constants struct + Shaders::AddDefine(resources.indirectCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Y_NAME", L"ddgi_reductionInputSizeY"); + Shaders::AddDefine(resources.indirectCS, L"RTXGI_PUSH_CONSTS_FIELD_DDGI_REDUCTION_INPUT_SIZE_Z_NAME", L"ddgi_reductionInputSizeZ"); Shaders::AddDefine(resources.indirectCS, L"RTXGI_BINDLESS_TYPE", std::to_wstring(RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS)); Shaders::AddDefine(resources.indirectCS, L"RTXGI_COORDINATE_SYSTEM", std::to_wstring(RTXGI_COORDINATE_SYSTEM)); Shaders::AddDefine(resources.indirectCS, L"RTXGI_DDGI_NUM_VOLUMES", std::to_wstring(numVolumes)); @@ -1120,6 +1253,8 @@ namespace Graphics rwTex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeIrradianceView(), VK_IMAGE_LAYOUT_GENERAL }); rwTex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeDistanceView(), VK_IMAGE_LAYOUT_GENERAL }); rwTex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeDataView(), VK_IMAGE_LAYOUT_GENERAL }); + rwTex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeVariabilityView(), VK_IMAGE_LAYOUT_GENERAL }); + rwTex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeVariabilityAverageView(), VK_IMAGE_LAYOUT_GENERAL }); } descriptor = &descriptors.emplace_back(); @@ -1179,6 +1314,8 @@ namespace Graphics tex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeIrradianceView(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }); tex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeDistanceView(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }); tex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeDataView(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }); + tex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeVariabilityView(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }); + tex2DArray.push_back({ VK_NULL_HANDLE, volume->GetProbeVariabilityAverageView(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }); } descriptor = &descriptors.emplace_back(); @@ -1191,9 +1328,10 @@ namespace Graphics descriptor->pImageInfo = tex2DArray.data(); } - // 13: ByteAddressBuffer SRVs (material indices, index & vertex buffers) + // 13: ByteAddressBuffer SRVs (mesh offsets, geometry data, index & vertex buffers) std::vector byteAddressBuffers; - byteAddressBuffers.push_back({ vkResources.materialIndicesRB, 0, VK_WHOLE_SIZE }); // material indices + byteAddressBuffers.push_back({ vkResources.meshOffsetsRB, 0, VK_WHOLE_SIZE }); // mesh offsets + byteAddressBuffers.push_back({ vkResources.geometryDataRB, 0, VK_WHOLE_SIZE }); // geometry data // Scene index and vertex buffers for (uint32_t bufferIndex = 0; bufferIndex < static_cast(vkResources.sceneIBs.size()); bufferIndex++) @@ -1297,14 +1435,17 @@ namespace Graphics } // Wait for the ray traces to complete - vkCmdPipelineBarrier( - vk.cmdBuffer[vk.frameIndex], - VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, - VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, - 0, - 0, nullptr, - 0, nullptr, - static_cast(barriers.size()), barriers.data()); + if (!barriers.empty()) + { + vkCmdPipelineBarrier( + vk.cmdBuffer[vk.frameIndex], + VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, + VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, + 0, + 0, nullptr, + 0, nullptr, + static_cast(barriers.size()), barriers.data()); + } #ifdef GFX_PERF_MARKERS vkCmdEndDebugUtilsLabelEXT(vk.cmdBuffer[vk.frameIndex]); @@ -1349,8 +1490,8 @@ namespace Graphics // Validate the SDK version assert(RTXGI_VERSION::major == 1); assert(RTXGI_VERSION::minor == 3); - assert(RTXGI_VERSION::revision == 0); - assert(std::strcmp(RTXGI_VERSION::getVersionString(), "1.3.0") == 0); + assert(RTXGI_VERSION::revision == 5); + assert(std::strcmp(RTXGI_VERSION::getVersionString(), "1.3.5") == 0); // Reset the command list before initialization CHECK(ResetCmdList(vk), "reset command list!", log); @@ -1407,6 +1548,7 @@ namespace Graphics resources.relocateStat = perf.AddGPUStat(" Relocate"); resources.classifyStat = perf.AddGPUStat(" Classify"); resources.lightingStat = perf.AddGPUStat(" Lighting"); + resources.variabilityStat = perf.AddGPUStat(" Variability"); // Execute GPU work to finish initialization VKCHECK(vkEndCommandBuffer(vk.cmdBuffer[vk.frameIndex])); @@ -1485,6 +1627,7 @@ namespace Graphics volume->ClearProbes(vk.cmdBuffer[vk.frameIndex]); config.ddgi.volumes[config.ddgi.selectedVolume].clearProbes = 0; + resources.numVolumeVariabilitySamples[config.ddgi.selectedVolume] = 0; } // Select the active volumes @@ -1492,13 +1635,27 @@ namespace Graphics for (UINT volumeIndex = 0; volumeIndex < static_cast(resources.volumes.size()); volumeIndex++) { // TODO: processing to determine which volumes are in-frustum, active, and prioritized for update / render - // For now, just select all volumes + + // Get the volume DDGIVolume* volume = static_cast(resources.volumes[volumeIndex]); - resources.selectedVolumes.push_back(volume); + + // If the scene's lights, skylight, or geometry have changed *or* the volume moves *or the probes are reset, reset variability + if (config.ddgi.volumes[volumeIndex].clearProbeVariability) resources.numVolumeVariabilitySamples[volumeIndex] = 0; + + // Skip volumes whose variability measurement is low enough to be considered converged + // Enforce a minimum of 16 samples to filter out early outliers + const uint32_t MinimumVariabilitySamples = 16; + float volumeAverageVariability = volume->GetVolumeAverageVariability(); + bool isConverged = volume->GetProbeVariabilityEnabled() + && (resources.numVolumeVariabilitySamples[volumeIndex]++ > MinimumVariabilitySamples) + && (volumeAverageVariability < config.ddgi.volumes[config.ddgi.selectedVolume].probeVariabilityThreshold); + + // Add the volume to the list of volumes to update (it hasn't converged) + if (!isConverged) resources.selectedVolumes.push_back(volume); } // Update the DDGIVolume constants - for (uint32_t volumeIndex = 0; volumeIndex < static_cast(resources.volumes.size()); volumeIndex++) + for (uint32_t volumeIndex = 0; volumeIndex < static_cast(resources.selectedVolumes.size()); volumeIndex++) { resources.selectedVolumes[volumeIndex]->Update(); } @@ -1544,6 +1701,13 @@ namespace Graphics rtxgi::vulkan::ClassifyDDGIVolumeProbes(vk.cmdBuffer[vk.frameIndex], numVolumes, resources.selectedVolumes.data()); GPU_TIMESTAMP_END(resources.classifyStat->GetGPUQueryEndIndex()); + // Calculate variability + GPU_TIMESTAMP_BEGIN(resources.variabilityStat->GetGPUQueryBeginIndex()); + rtxgi::vulkan::CalculateDDGIVolumeVariability(vk.cmdBuffer[vk.frameIndex], numVolumes, resources.selectedVolumes.data()); + // The readback happens immediately, not recorded on the command list, so will return a value from a previous update + rtxgi::vulkan::ReadbackDDGIVolumeVariability(vk.device, numVolumes, resources.selectedVolumes.data()); + GPU_TIMESTAMP_END(resources.variabilityStat->GetGPUQueryEndIndex()); + // Render the indirect lighting to screen-space GPU_TIMESTAMP_BEGIN(resources.lightingStat->GetGPUQueryBeginIndex()); GatherIndirectLighting(vk, vkResources, resources); @@ -1619,9 +1783,9 @@ namespace Graphics #if !RTXGI_DDGI_RESOURCE_MANAGEMENT DestroyDDGIVolumeResources(device, resources, volumeIndex); #endif + SAFE_DELETE(resources.volumeDescs[volumeIndex].name); resources.volumes[volumeIndex]->Destroy(); - delete resources.volumes[volumeIndex]; - resources.volumes[volumeIndex] = nullptr; + SAFE_DELETE(resources.volumes[volumeIndex]); } } @@ -1660,6 +1824,19 @@ namespace Graphics format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Data, desc.probeDataFormat); success &= WriteResourceToDisk(vk, filename, volume->GetProbeData(), width, height, arraySize, format, VK_IMAGE_LAYOUT_GENERAL); } + + // Write probe variability + if (volume->GetProbeVariabilityEnabled()) + { + filename = baseName + "-Probe-Variability"; + GetDDGIVolumeTextureDimensions(desc, EDDGIVolumeTextureType::Variability, width, height, arraySize); + format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::Variability, desc.probeVariabilityFormat); + success &= WriteResourceToDisk(vk, filename, volume->GetProbeVariability(), width, height, arraySize, format, VK_IMAGE_LAYOUT_GENERAL); + filename = baseName + "-Probe-Variability-Average"; + GetDDGIVolumeTextureDimensions(desc, EDDGIVolumeTextureType::VariabilityAverage, width, height, arraySize); + format = GetDDGIVolumeTextureFormat(EDDGIVolumeTextureType::VariabilityAverage, desc.probeVariabilityFormat); + success &= WriteResourceToDisk(vk, filename, volume->GetProbeVariabilityAverage(), width, height, arraySize, format, VK_IMAGE_LAYOUT_GENERAL); + } } return success; } diff --git a/samples/test-harness/src/graphics/GBuffer_VK.cpp b/samples/test-harness/src/graphics/GBuffer_VK.cpp index 20c85af..80ca93e 100644 --- a/samples/test-harness/src/graphics/GBuffer_VK.cpp +++ b/samples/test-harness/src/graphics/GBuffer_VK.cpp @@ -330,9 +330,10 @@ namespace Graphics descriptor->descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; descriptor->pImageInfo = tex2D.data(); - // 13: ByteAddressBuffer SRVs (material indices, index & vertex buffers) + // 13: ByteAddressBuffer SRVs (mesh offsets, geometry data, index & vertex buffers) std::vector byteAddressBuffers; - byteAddressBuffers.push_back({ vkResources.materialIndicesRB, 0, VK_WHOLE_SIZE }); // material indices + byteAddressBuffers.push_back({ vkResources.meshOffsetsRB, 0, VK_WHOLE_SIZE }); // mesh offsets + byteAddressBuffers.push_back({ vkResources.geometryDataRB, 0, VK_WHOLE_SIZE }); // geometry data // Scene index and vertex buffers for (uint32_t bufferIndex = 0; bufferIndex < static_cast(vkResources.sceneIBs.size()); bufferIndex++) diff --git a/samples/test-harness/src/graphics/PathTracing_D3D12.cpp b/samples/test-harness/src/graphics/PathTracing_D3D12.cpp index 71a16b4..6337e62 100644 --- a/samples/test-harness/src/graphics/PathTracing_D3D12.cpp +++ b/samples/test-harness/src/graphics/PathTracing_D3D12.cpp @@ -66,6 +66,7 @@ namespace Graphics resources.shaders.rgs.entryPoint = L"RayGen"; resources.shaders.rgs.exportName = L"PathTraceRGS"; Shaders::AddDefine(resources.shaders.rgs, L"RTXGI_BINDLESS_TYPE", std::to_wstring(RTXGI_BINDLESS_TYPE)); + Shaders::AddDefine(resources.shaders.rgs, L"GFX_NVAPI", std::to_wstring(1)); CHECK(Shaders::Compile(d3d.shaderCompiler, resources.shaders.rgs, true), "compile path tracing ray generation shader!\n", log); // Load and compile the miss shader @@ -283,6 +284,7 @@ namespace Graphics d3dResources.constants.pt.numBounces = config.pathTrace.numBounces; d3dResources.constants.pt.samplesPerPixel = config.pathTrace.samplesPerPixel; d3dResources.constants.pt.SetAntialiasing(config.pathTrace.antialiasing); + d3dResources.constants.pt.SetShaderExecutionReordering(config.pathTrace.shaderExecutionReordering); // Post Process constants d3dResources.constants.post.useFlags = POSTPROCESS_FLAG_USE_NONE; diff --git a/samples/test-harness/src/graphics/PathTracing_VK.cpp b/samples/test-harness/src/graphics/PathTracing_VK.cpp index 748bc3b..7d4cb06 100644 --- a/samples/test-harness/src/graphics/PathTracing_VK.cpp +++ b/samples/test-harness/src/graphics/PathTracing_VK.cpp @@ -69,6 +69,7 @@ namespace Graphics resources.shaders.rgs.exportName = L"PathTraceRGS"; resources.shaders.rgs.arguments = { L"-spirv", L"-D __spirv__", L"-fspv-target-env=vulkan1.2"};\ Shaders::AddDefine(resources.shaders.rgs, L"RTXGI_BINDLESS_TYPE", std::to_wstring(RTXGI_BINDLESS_TYPE_RESOURCE_ARRAYS)); + Shaders::AddDefine(resources.shaders.rgs, L"GFX_NVAPI", std::to_wstring(0)); CHECK(Shaders::Compile(vk.shaderCompiler, resources.shaders.rgs, true), "compile path tracing ray generation shader!\n", log); // Load and compile the miss shader @@ -359,9 +360,10 @@ namespace Graphics descriptor->descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; descriptor->pImageInfo = tex2D.data(); - // 13: ByteAddressBuffer SRVs (material indices, index & vertex buffers) + // 13: ByteAddressBuffer SRVs (mesh offsets, geometry data, index & vertex buffers) std::vector byteAddressBuffers; - byteAddressBuffers.push_back({ vkResources.materialIndicesRB, 0, VK_WHOLE_SIZE }); // material indices + byteAddressBuffers.push_back({ vkResources.meshOffsetsRB, 0, VK_WHOLE_SIZE }); // mesh offsets + byteAddressBuffers.push_back({ vkResources.geometryDataRB, 0, VK_WHOLE_SIZE }); // geometry data // Scene index and vertex buffers for (uint32_t bufferIndex = 0; bufferIndex < static_cast(vkResources.sceneIBs.size()); bufferIndex++) @@ -475,6 +477,7 @@ namespace Graphics vkResources.constants.pt.numBounces = config.pathTrace.numBounces; vkResources.constants.pt.samplesPerPixel = config.pathTrace.samplesPerPixel; vkResources.constants.pt.SetAntialiasing(config.pathTrace.antialiasing); + vkResources.constants.pt.SetShaderExecutionReordering(false); // Post Process constants vkResources.constants.post.useFlags = POSTPROCESS_FLAG_USE_NONE; diff --git a/samples/test-harness/src/graphics/RTAO_VK.cpp b/samples/test-harness/src/graphics/RTAO_VK.cpp index 056659c..da07eb5 100644 --- a/samples/test-harness/src/graphics/RTAO_VK.cpp +++ b/samples/test-harness/src/graphics/RTAO_VK.cpp @@ -366,9 +366,10 @@ namespace Graphics descriptor->descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; descriptor->pImageInfo = tex2D.data(); - // 13: ByteAddressBuffer SRVs (material indices, index & vertex buffers) + // 13: ByteAddressBuffer SRVs (mesh offsets, geometry data, index & vertex buffers) std::vector byteAddressBuffers; - byteAddressBuffers.push_back({ vkResources.materialIndicesRB, 0, VK_WHOLE_SIZE }); // material indices + byteAddressBuffers.push_back({ vkResources.meshOffsetsRB, 0, VK_WHOLE_SIZE }); // mesh offsets + byteAddressBuffers.push_back({ vkResources.geometryDataRB, 0, VK_WHOLE_SIZE }); // geometry data // Scene index and vertex buffers for (uint32_t bufferIndex = 0; bufferIndex < static_cast(vkResources.sceneIBs.size()); bufferIndex++) diff --git a/samples/test-harness/src/main.cpp b/samples/test-harness/src/main.cpp index ac46f2f..743957d 100644 --- a/samples/test-harness/src/main.cpp +++ b/samples/test-harness/src/main.cpp @@ -380,7 +380,7 @@ int Run(const std::vector& arguments) if (!Graphics::Present(gfx)) continue; if (!Graphics::WaitForGPU(gfx)) { log << "GPU took too long to complete, device removed!"; break; } - // Image Capture + // Image Capture (user triggered) StoreImages(input.event, config, gfx, gfxResources, rtao, ddgi); if (!Graphics::MoveToNextFrame(gfx)) break; @@ -390,7 +390,18 @@ int Run(const std::vector& arguments) #ifdef GFX_PERF_INSTRUMENTATION if (!Graphics::UpdateTimestamps(gfx, gfxResources, perf)) break; - if (config.app.benchmarkRunning) Benchmark::UpdateBenchmark(benchmarkRun, perf, config, gfx, log); + if (config.app.benchmarkRunning) + { + if (Benchmark::UpdateBenchmark(benchmarkRun, perf, config, gfx, log)) + { + // Store intermediate images when the benchmark ends + Inputs::EInputEvent e = Inputs::EInputEvent::SCREENSHOT; + StoreImages(e, config, gfx, gfxResources, rtao, ddgi); + + e = Inputs::EInputEvent::SAVE_IMAGES; + StoreImages(e, config, gfx, gfxResources, rtao, ddgi); + } + } Graphics::BeginFrame(gfx, gfxResources, perf); #endif } diff --git a/thirdparty/nvapi/NvApiDriverSettings.c b/thirdparty/nvapi/NvApiDriverSettings.c new file mode 100644 index 0000000..bf67f08 --- /dev/null +++ b/thirdparty/nvapi/NvApiDriverSettings.c @@ -0,0 +1,954 @@ +/***************************************************************************\ +|* *| +|* Copyright NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This source code is subject to NVIDIA ownership rights under U.S. *| +|* and international Copyright laws. Users and possessors of this *| +|* source code are hereby granted a nonexclusive, royalty-free *| +|* license to use this code in individual and commercial software. *| +|* *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE *| +|* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR *| +|* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH *| +|* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF *| +|* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR *| +|* PURPOSE. IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, *| +|* INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES *| +|* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN *| +|* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *| +|* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE *| +|* CODE. *| +|* *| +|* U.S. Government End Users. This source code is a "commercial item" *| +|* as that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting *| +|* of "commercial computer software" and "commercial computer software *| +|* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) *| +|* and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through *| +|* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the *| +|* source code with only those rights set forth herein. *| +|* *| +|* Any use of this source code in individual and commercial software must *| +|* include, in the user documentation and internal comments to the code, *| +|* the above Disclaimer and U.S. Government End Users Notice. *| +|* *| +|* *| +\***************************************************************************/ + +#include "NvApiDriverSettings.h" + +EValues_OGL_AA_LINE_GAMMA g_valuesOGL_AA_LINE_GAMMA[OGL_AA_LINE_GAMMA_NUM_VALUES] = +{ + OGL_AA_LINE_GAMMA_DISABLED, + OGL_AA_LINE_GAMMA_ENABLED, + OGL_AA_LINE_GAMMA_MIN, + OGL_AA_LINE_GAMMA_MAX, +}; + +EValues_OGL_DEEP_COLOR_SCANOUT g_valuesOGL_DEEP_COLOR_SCANOUT[OGL_DEEP_COLOR_SCANOUT_NUM_VALUES] = +{ + OGL_DEEP_COLOR_SCANOUT_DISABLE, + OGL_DEEP_COLOR_SCANOUT_ENABLE, +}; + +EValues_OGL_DEFAULT_SWAP_INTERVAL g_valuesOGL_DEFAULT_SWAP_INTERVAL[OGL_DEFAULT_SWAP_INTERVAL_NUM_VALUES] = +{ + OGL_DEFAULT_SWAP_INTERVAL_TEAR, + OGL_DEFAULT_SWAP_INTERVAL_VSYNC_ONE, + OGL_DEFAULT_SWAP_INTERVAL_VSYNC, + OGL_DEFAULT_SWAP_INTERVAL_VALUE_MASK, + OGL_DEFAULT_SWAP_INTERVAL_FORCE_MASK, + OGL_DEFAULT_SWAP_INTERVAL_FORCE_OFF, + OGL_DEFAULT_SWAP_INTERVAL_FORCE_ON, + OGL_DEFAULT_SWAP_INTERVAL_APP_CONTROLLED, + OGL_DEFAULT_SWAP_INTERVAL_DISABLE, +}; + +EValues_OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL g_valuesOGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL[OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_NUM_VALUES] = +{ + OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_ZERO_SCANLINES, + OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_ONE_FULL_FRAME_OF_SCANLINES, +}; + +EValues_OGL_DEFAULT_SWAP_INTERVAL_SIGN g_valuesOGL_DEFAULT_SWAP_INTERVAL_SIGN[OGL_DEFAULT_SWAP_INTERVAL_SIGN_NUM_VALUES] = +{ + OGL_DEFAULT_SWAP_INTERVAL_SIGN_POSITIVE, + OGL_DEFAULT_SWAP_INTERVAL_SIGN_NEGATIVE, +}; + +EValues_OGL_EVENT_LOG_SEVERITY_THRESHOLD g_valuesOGL_EVENT_LOG_SEVERITY_THRESHOLD[OGL_EVENT_LOG_SEVERITY_THRESHOLD_NUM_VALUES] = +{ + OGL_EVENT_LOG_SEVERITY_THRESHOLD_DISABLE, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_CRITICAL, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_WARNING, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_INFORMATION, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_ALL, +}; + +EValues_OGL_FORCE_BLIT g_valuesOGL_FORCE_BLIT[OGL_FORCE_BLIT_NUM_VALUES] = +{ + OGL_FORCE_BLIT_ON, + OGL_FORCE_BLIT_OFF, +}; + +EValues_OGL_FORCE_STEREO g_valuesOGL_FORCE_STEREO[OGL_FORCE_STEREO_NUM_VALUES] = +{ + OGL_FORCE_STEREO_OFF, + OGL_FORCE_STEREO_ON, +}; + +const wchar_t * g_valuesOGL_IMPLICIT_GPU_AFFINITY[OGL_IMPLICIT_GPU_AFFINITY_NUM_VALUES] = +{ + OGL_IMPLICIT_GPU_AFFINITY_AUTOSELECT +}; + +EValues_OGL_OVERLAY_PIXEL_TYPE g_valuesOGL_OVERLAY_PIXEL_TYPE[OGL_OVERLAY_PIXEL_TYPE_NUM_VALUES] = +{ + OGL_OVERLAY_PIXEL_TYPE_NONE, + OGL_OVERLAY_PIXEL_TYPE_CI, + OGL_OVERLAY_PIXEL_TYPE_RGBA, + OGL_OVERLAY_PIXEL_TYPE_CI_AND_RGBA, +}; + +EValues_OGL_OVERLAY_SUPPORT g_valuesOGL_OVERLAY_SUPPORT[OGL_OVERLAY_SUPPORT_NUM_VALUES] = +{ + OGL_OVERLAY_SUPPORT_OFF, + OGL_OVERLAY_SUPPORT_ON, + OGL_OVERLAY_SUPPORT_FORCE_SW, +}; + +EValues_OGL_QUALITY_ENHANCEMENTS g_valuesOGL_QUALITY_ENHANCEMENTS[OGL_QUALITY_ENHANCEMENTS_NUM_VALUES] = +{ + OGL_QUALITY_ENHANCEMENTS_HQUAL, + OGL_QUALITY_ENHANCEMENTS_QUAL, + OGL_QUALITY_ENHANCEMENTS_PERF, + OGL_QUALITY_ENHANCEMENTS_HPERF, +}; + +EValues_OGL_SINGLE_BACKDEPTH_BUFFER g_valuesOGL_SINGLE_BACKDEPTH_BUFFER[OGL_SINGLE_BACKDEPTH_BUFFER_NUM_VALUES] = +{ + OGL_SINGLE_BACKDEPTH_BUFFER_DISABLE, + OGL_SINGLE_BACKDEPTH_BUFFER_ENABLE, + OGL_SINGLE_BACKDEPTH_BUFFER_USE_HW_DEFAULT, +}; + +EValues_OGL_SLI_CFR_MODE g_valuesOGL_SLI_CFR_MODE[OGL_SLI_CFR_MODE_NUM_VALUES] = +{ + OGL_SLI_CFR_MODE_DISABLE, + OGL_SLI_CFR_MODE_ENABLE, + OGL_SLI_CFR_MODE_CLASSIC_SFR, +}; + +EValues_OGL_SLI_MULTICAST g_valuesOGL_SLI_MULTICAST[OGL_SLI_MULTICAST_NUM_VALUES] = +{ + OGL_SLI_MULTICAST_DISABLE, + OGL_SLI_MULTICAST_ENABLE, + OGL_SLI_MULTICAST_FORCE_DISABLE, + OGL_SLI_MULTICAST_ALLOW_MOSAIC, +}; + +EValues_OGL_THREAD_CONTROL g_valuesOGL_THREAD_CONTROL[OGL_THREAD_CONTROL_NUM_VALUES] = +{ + OGL_THREAD_CONTROL_ENABLE, + OGL_THREAD_CONTROL_DISABLE, +}; + +EValues_OGL_TMON_LEVEL g_valuesOGL_TMON_LEVEL[OGL_TMON_LEVEL_NUM_VALUES] = +{ + OGL_TMON_LEVEL_DISABLE, + OGL_TMON_LEVEL_CRITICAL, + OGL_TMON_LEVEL_WARNING, + OGL_TMON_LEVEL_INFORMATION, + OGL_TMON_LEVEL_MOST, + OGL_TMON_LEVEL_VERBOSE, +}; + +EValues_OGL_TRIPLE_BUFFER g_valuesOGL_TRIPLE_BUFFER[OGL_TRIPLE_BUFFER_NUM_VALUES] = +{ + OGL_TRIPLE_BUFFER_DISABLED, + OGL_TRIPLE_BUFFER_ENABLED, +}; + +EValues_AA_BEHAVIOR_FLAGS g_valuesAA_BEHAVIOR_FLAGS[AA_BEHAVIOR_FLAGS_NUM_VALUES] = +{ + AA_BEHAVIOR_FLAGS_NONE, + AA_BEHAVIOR_FLAGS_TREAT_OVERRIDE_AS_APP_CONTROLLED, + AA_BEHAVIOR_FLAGS_TREAT_OVERRIDE_AS_ENHANCE, + AA_BEHAVIOR_FLAGS_DISABLE_OVERRIDE, + AA_BEHAVIOR_FLAGS_TREAT_ENHANCE_AS_APP_CONTROLLED, + AA_BEHAVIOR_FLAGS_TREAT_ENHANCE_AS_OVERRIDE, + AA_BEHAVIOR_FLAGS_DISABLE_ENHANCE, + AA_BEHAVIOR_FLAGS_MAP_VCAA_TO_MULTISAMPLING, + AA_BEHAVIOR_FLAGS_SLI_DISABLE_TRANSPARENCY_SUPERSAMPLING, + AA_BEHAVIOR_FLAGS_DISABLE_CPLAA, + AA_BEHAVIOR_FLAGS_SKIP_RT_DIM_CHECK_FOR_ENHANCE, + AA_BEHAVIOR_FLAGS_DISABLE_SLIAA, + AA_BEHAVIOR_FLAGS_DEFAULT, + AA_BEHAVIOR_FLAGS_AA_RT_BPP_DIV_4, + AA_BEHAVIOR_FLAGS_AA_RT_BPP_DIV_4_SHIFT, + AA_BEHAVIOR_FLAGS_NON_AA_RT_BPP_DIV_4, + AA_BEHAVIOR_FLAGS_NON_AA_RT_BPP_DIV_4_SHIFT, + AA_BEHAVIOR_FLAGS_MASK, +}; + +EValues_AA_MODE_ALPHATOCOVERAGE g_valuesAA_MODE_ALPHATOCOVERAGE[AA_MODE_ALPHATOCOVERAGE_NUM_VALUES] = +{ + AA_MODE_ALPHATOCOVERAGE_MODE_MASK, + AA_MODE_ALPHATOCOVERAGE_MODE_OFF, + AA_MODE_ALPHATOCOVERAGE_MODE_ON, + AA_MODE_ALPHATOCOVERAGE_MODE_MAX, +}; + +EValues_AA_MODE_GAMMACORRECTION g_valuesAA_MODE_GAMMACORRECTION[AA_MODE_GAMMACORRECTION_NUM_VALUES] = +{ + AA_MODE_GAMMACORRECTION_MASK, + AA_MODE_GAMMACORRECTION_OFF, + AA_MODE_GAMMACORRECTION_ON_IF_FOS, + AA_MODE_GAMMACORRECTION_ON_ALWAYS, + AA_MODE_GAMMACORRECTION_MAX, + AA_MODE_GAMMACORRECTION_DEFAULT, + AA_MODE_GAMMACORRECTION_DEFAULT_TESLA, + AA_MODE_GAMMACORRECTION_DEFAULT_FERMI, +}; + +EValues_AA_MODE_METHOD g_valuesAA_MODE_METHOD[AA_MODE_METHOD_NUM_VALUES] = +{ + AA_MODE_METHOD_NONE, + AA_MODE_METHOD_SUPERSAMPLE_2X_H, + AA_MODE_METHOD_SUPERSAMPLE_2X_V, + AA_MODE_METHOD_SUPERSAMPLE_1_5X1_5, + AA_MODE_METHOD_FREE_0x03, + AA_MODE_METHOD_FREE_0x04, + AA_MODE_METHOD_SUPERSAMPLE_4X, + AA_MODE_METHOD_SUPERSAMPLE_4X_BIAS, + AA_MODE_METHOD_SUPERSAMPLE_4X_GAUSSIAN, + AA_MODE_METHOD_FREE_0x08, + AA_MODE_METHOD_FREE_0x09, + AA_MODE_METHOD_SUPERSAMPLE_9X, + AA_MODE_METHOD_SUPERSAMPLE_9X_BIAS, + AA_MODE_METHOD_SUPERSAMPLE_16X, + AA_MODE_METHOD_SUPERSAMPLE_16X_BIAS, + AA_MODE_METHOD_MULTISAMPLE_2X_DIAGONAL, + AA_MODE_METHOD_MULTISAMPLE_2X_QUINCUNX, + AA_MODE_METHOD_MULTISAMPLE_4X, + AA_MODE_METHOD_FREE_0x11, + AA_MODE_METHOD_MULTISAMPLE_4X_GAUSSIAN, + AA_MODE_METHOD_MIXEDSAMPLE_4X_SKEWED_4TAP, + AA_MODE_METHOD_FREE_0x14, + AA_MODE_METHOD_FREE_0x15, + AA_MODE_METHOD_MIXEDSAMPLE_6X, + AA_MODE_METHOD_MIXEDSAMPLE_6X_SKEWED_6TAP, + AA_MODE_METHOD_MIXEDSAMPLE_8X, + AA_MODE_METHOD_MIXEDSAMPLE_8X_SKEWED_8TAP, + AA_MODE_METHOD_MIXEDSAMPLE_16X, + AA_MODE_METHOD_MULTISAMPLE_4X_GAMMA, + AA_MODE_METHOD_MULTISAMPLE_16X, + AA_MODE_METHOD_VCAA_32X_8v24, + AA_MODE_METHOD_CORRUPTION_CHECK, + AA_MODE_METHOD_6X_CT, + AA_MODE_METHOD_MULTISAMPLE_2X_DIAGONAL_GAMMA, + AA_MODE_METHOD_SUPERSAMPLE_4X_GAMMA, + AA_MODE_METHOD_MULTISAMPLE_4X_FOSGAMMA, + AA_MODE_METHOD_MULTISAMPLE_2X_DIAGONAL_FOSGAMMA, + AA_MODE_METHOD_SUPERSAMPLE_4X_FOSGAMMA, + AA_MODE_METHOD_MULTISAMPLE_8X, + AA_MODE_METHOD_VCAA_8X_4v4, + AA_MODE_METHOD_VCAA_16X_4v12, + AA_MODE_METHOD_VCAA_16X_8v8, + AA_MODE_METHOD_MIXEDSAMPLE_32X, + AA_MODE_METHOD_SUPERVCAA_64X_4v12, + AA_MODE_METHOD_SUPERVCAA_64X_8v8, + AA_MODE_METHOD_MIXEDSAMPLE_64X, + AA_MODE_METHOD_MIXEDSAMPLE_128X, + AA_MODE_METHOD_COUNT, + AA_MODE_METHOD_METHOD_MASK, + AA_MODE_METHOD_METHOD_MAX, +}; + +EValues_AA_MODE_REPLAY g_valuesAA_MODE_REPLAY[AA_MODE_REPLAY_NUM_VALUES] = +{ + AA_MODE_REPLAY_SAMPLES_MASK, + AA_MODE_REPLAY_SAMPLES_ONE, + AA_MODE_REPLAY_SAMPLES_TWO, + AA_MODE_REPLAY_SAMPLES_FOUR, + AA_MODE_REPLAY_SAMPLES_EIGHT, + AA_MODE_REPLAY_SAMPLES_MAX, + AA_MODE_REPLAY_MODE_MASK, + AA_MODE_REPLAY_MODE_OFF, + AA_MODE_REPLAY_MODE_ALPHA_TEST, + AA_MODE_REPLAY_MODE_PIXEL_KILL, + AA_MODE_REPLAY_MODE_DYN_BRANCH, + AA_MODE_REPLAY_MODE_OPTIMAL, + AA_MODE_REPLAY_MODE_ALL, + AA_MODE_REPLAY_MODE_MAX, + AA_MODE_REPLAY_TRANSPARENCY, + AA_MODE_REPLAY_DISALLOW_TRAA, + AA_MODE_REPLAY_TRANSPARENCY_DEFAULT, + AA_MODE_REPLAY_TRANSPARENCY_DEFAULT_TESLA, + AA_MODE_REPLAY_TRANSPARENCY_DEFAULT_FERMI, + AA_MODE_REPLAY_MASK, +}; + +EValues_AA_MODE_SELECTOR g_valuesAA_MODE_SELECTOR[AA_MODE_SELECTOR_NUM_VALUES] = +{ + AA_MODE_SELECTOR_MASK, + AA_MODE_SELECTOR_APP_CONTROL, + AA_MODE_SELECTOR_OVERRIDE, + AA_MODE_SELECTOR_ENHANCE, + AA_MODE_SELECTOR_MAX, +}; + +EValues_AA_MODE_SELECTOR_SLIAA g_valuesAA_MODE_SELECTOR_SLIAA[AA_MODE_SELECTOR_SLIAA_NUM_VALUES] = +{ + AA_MODE_SELECTOR_SLIAA_DISABLED, + AA_MODE_SELECTOR_SLIAA_ENABLED, +}; + +EValues_ANISO_MODE_LEVEL g_valuesANISO_MODE_LEVEL[ANISO_MODE_LEVEL_NUM_VALUES] = +{ + ANISO_MODE_LEVEL_MASK, + ANISO_MODE_LEVEL_NONE_POINT, + ANISO_MODE_LEVEL_NONE_LINEAR, + ANISO_MODE_LEVEL_MAX, + ANISO_MODE_LEVEL_DEFAULT, +}; + +EValues_ANISO_MODE_SELECTOR g_valuesANISO_MODE_SELECTOR[ANISO_MODE_SELECTOR_NUM_VALUES] = +{ + ANISO_MODE_SELECTOR_MASK, + ANISO_MODE_SELECTOR_APP, + ANISO_MODE_SELECTOR_USER, + ANISO_MODE_SELECTOR_COND, + ANISO_MODE_SELECTOR_MAX, + ANISO_MODE_SELECTOR_DEFAULT, +}; + +EValues_ANSEL_ALLOW g_valuesANSEL_ALLOW[ANSEL_ALLOW_NUM_VALUES] = +{ + ANSEL_ALLOW_DISALLOWED, + ANSEL_ALLOW_ALLOWED, +}; + +EValues_ANSEL_ALLOWLISTED g_valuesANSEL_ALLOWLISTED[ANSEL_ALLOWLISTED_NUM_VALUES] = +{ + ANSEL_ALLOWLISTED_DISALLOWED, + ANSEL_ALLOWLISTED_ALLOWED, +}; + +EValues_ANSEL_ENABLE g_valuesANSEL_ENABLE[ANSEL_ENABLE_NUM_VALUES] = +{ + ANSEL_ENABLE_OFF, + ANSEL_ENABLE_ON, +}; + +EValues_APPLICATION_PROFILE_NOTIFICATION_TIMEOUT g_valuesAPPLICATION_PROFILE_NOTIFICATION_TIMEOUT[APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_NUM_VALUES] = +{ + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_DISABLED, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_NINE_SECONDS, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_FIFTEEN_SECONDS, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_THIRTY_SECONDS, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_ONE_MINUTE, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_TWO_MINUTES, +}; + +EValues_BATTERY_BOOST_APP_FPS g_valuesBATTERY_BOOST_APP_FPS[BATTERY_BOOST_APP_FPS_NUM_VALUES] = +{ + BATTERY_BOOST_APP_FPS_MIN, + BATTERY_BOOST_APP_FPS_MAX, + BATTERY_BOOST_APP_FPS_NO_OVERRIDE, +}; + +EValues_CPL_HIDDEN_PROFILE g_valuesCPL_HIDDEN_PROFILE[CPL_HIDDEN_PROFILE_NUM_VALUES] = +{ + CPL_HIDDEN_PROFILE_DISABLED, + CPL_HIDDEN_PROFILE_ENABLED, +}; + +const wchar_t * g_valuesCUDA_EXCLUDED_GPUS[CUDA_EXCLUDED_GPUS_NUM_VALUES] = +{ + CUDA_EXCLUDED_GPUS_NONE +}; + +const wchar_t * g_valuesD3DOGL_GPU_MAX_POWER[D3DOGL_GPU_MAX_POWER_NUM_VALUES] = +{ + D3DOGL_GPU_MAX_POWER_DEFAULTPOWER +}; + +EValues_EXPORT_PERF_COUNTERS g_valuesEXPORT_PERF_COUNTERS[EXPORT_PERF_COUNTERS_NUM_VALUES] = +{ + EXPORT_PERF_COUNTERS_OFF, + EXPORT_PERF_COUNTERS_ON, +}; + +EValues_EXTERNAL_QUIET_MODE g_valuesEXTERNAL_QUIET_MODE[EXTERNAL_QUIET_MODE_NUM_VALUES] = +{ + EXTERNAL_QUIET_MODE_ON, + EXTERNAL_QUIET_MODE_OFF, +}; + +EValues_FRL_FPS g_valuesFRL_FPS[FRL_FPS_NUM_VALUES] = +{ + FRL_FPS_DISABLED, + FRL_FPS_MIN, + FRL_FPS_MAX, +}; + +EValues_FXAA_ALLOW g_valuesFXAA_ALLOW[FXAA_ALLOW_NUM_VALUES] = +{ + FXAA_ALLOW_DISALLOWED, + FXAA_ALLOW_ALLOWED, +}; + +EValues_FXAA_ENABLE g_valuesFXAA_ENABLE[FXAA_ENABLE_NUM_VALUES] = +{ + FXAA_ENABLE_OFF, + FXAA_ENABLE_ON, +}; + +EValues_FXAA_INDICATOR_ENABLE g_valuesFXAA_INDICATOR_ENABLE[FXAA_INDICATOR_ENABLE_NUM_VALUES] = +{ + FXAA_INDICATOR_ENABLE_OFF, + FXAA_INDICATOR_ENABLE_ON, +}; + +EValues_LATENCY_INDICATOR_AUTOALIGN g_valuesLATENCY_INDICATOR_AUTOALIGN[LATENCY_INDICATOR_AUTOALIGN_NUM_VALUES] = +{ + LATENCY_INDICATOR_AUTOALIGN_DISABLED, + LATENCY_INDICATOR_AUTOALIGN_ENABLED, +}; + +EValues_MCSFRSHOWSPLIT g_valuesMCSFRSHOWSPLIT[MCSFRSHOWSPLIT_NUM_VALUES] = +{ + MCSFRSHOWSPLIT_DISABLED, + MCSFRSHOWSPLIT_ENABLED, +}; + +EValues_NV_QUALITY_UPSCALING g_valuesNV_QUALITY_UPSCALING[NV_QUALITY_UPSCALING_NUM_VALUES] = +{ + NV_QUALITY_UPSCALING_OFF, + NV_QUALITY_UPSCALING_ON, +}; + +EValues_OPTIMUS_MAXAA g_valuesOPTIMUS_MAXAA[OPTIMUS_MAXAA_NUM_VALUES] = +{ + OPTIMUS_MAXAA_MIN, + OPTIMUS_MAXAA_MAX, +}; + +EValues_PHYSXINDICATOR g_valuesPHYSXINDICATOR[PHYSXINDICATOR_NUM_VALUES] = +{ + PHYSXINDICATOR_DISABLED, + PHYSXINDICATOR_ENABLED, +}; + +EValues_PREFERRED_PSTATE g_valuesPREFERRED_PSTATE[PREFERRED_PSTATE_NUM_VALUES] = +{ + PREFERRED_PSTATE_ADAPTIVE, + PREFERRED_PSTATE_PREFER_MAX, + PREFERRED_PSTATE_DRIVER_CONTROLLED, + PREFERRED_PSTATE_PREFER_CONSISTENT_PERFORMANCE, + PREFERRED_PSTATE_PREFER_MIN, + PREFERRED_PSTATE_OPTIMAL_POWER, + PREFERRED_PSTATE_MIN, + PREFERRED_PSTATE_MAX, +}; + +EValues_PREVENT_UI_AF_OVERRIDE g_valuesPREVENT_UI_AF_OVERRIDE[PREVENT_UI_AF_OVERRIDE_NUM_VALUES] = +{ + PREVENT_UI_AF_OVERRIDE_OFF, + PREVENT_UI_AF_OVERRIDE_ON, +}; + +EValues_SHIM_MCCOMPAT g_valuesSHIM_MCCOMPAT[SHIM_MCCOMPAT_NUM_VALUES] = +{ + SHIM_MCCOMPAT_INTEGRATED, + SHIM_MCCOMPAT_ENABLE, + SHIM_MCCOMPAT_USER_EDITABLE, + SHIM_MCCOMPAT_MASK, + SHIM_MCCOMPAT_VIDEO_MASK, + SHIM_MCCOMPAT_VARYING_BIT, + SHIM_MCCOMPAT_AUTO_SELECT, + SHIM_MCCOMPAT_OVERRIDE_BIT, +}; + +EValues_SHIM_RENDERING_MODE g_valuesSHIM_RENDERING_MODE[SHIM_RENDERING_MODE_NUM_VALUES] = +{ + SHIM_RENDERING_MODE_INTEGRATED, + SHIM_RENDERING_MODE_ENABLE, + SHIM_RENDERING_MODE_USER_EDITABLE, + SHIM_RENDERING_MODE_MASK, + SHIM_RENDERING_MODE_VIDEO_MASK, + SHIM_RENDERING_MODE_VARYING_BIT, + SHIM_RENDERING_MODE_AUTO_SELECT, + SHIM_RENDERING_MODE_OVERRIDE_BIT, +}; + +EValues_SHIM_RENDERING_OPTIONS g_valuesSHIM_RENDERING_OPTIONS[SHIM_RENDERING_OPTIONS_NUM_VALUES] = +{ + SHIM_RENDERING_OPTIONS_DEFAULT_RENDERING_MODE, + SHIM_RENDERING_OPTIONS_DISABLE_ASYNC_PRESENT, + SHIM_RENDERING_OPTIONS_EHSHELL_DETECT, + SHIM_RENDERING_OPTIONS_FLASHPLAYER_HOST_DETECT, + SHIM_RENDERING_OPTIONS_VIDEO_DRM_APP_DETECT, + SHIM_RENDERING_OPTIONS_IGNORE_OVERRIDES, + SHIM_RENDERING_OPTIONS_RESERVED1, + SHIM_RENDERING_OPTIONS_ENABLE_DWM_ASYNC_PRESENT, + SHIM_RENDERING_OPTIONS_RESERVED2, + SHIM_RENDERING_OPTIONS_ALLOW_INHERITANCE, + SHIM_RENDERING_OPTIONS_DISABLE_WRAPPERS, + SHIM_RENDERING_OPTIONS_DISABLE_DXGI_WRAPPERS, + SHIM_RENDERING_OPTIONS_PRUNE_UNSUPPORTED_FORMATS, + SHIM_RENDERING_OPTIONS_ENABLE_ALPHA_FORMAT, + SHIM_RENDERING_OPTIONS_IGPU_TRANSCODING, + SHIM_RENDERING_OPTIONS_DISABLE_CUDA, + SHIM_RENDERING_OPTIONS_ALLOW_CP_CAPS_FOR_VIDEO, + SHIM_RENDERING_OPTIONS_IGPU_TRANSCODING_FWD_OPTIMUS, + SHIM_RENDERING_OPTIONS_DISABLE_DURING_SECURE_BOOT, + SHIM_RENDERING_OPTIONS_INVERT_FOR_QUADRO, + SHIM_RENDERING_OPTIONS_INVERT_FOR_MSHYBRID, + SHIM_RENDERING_OPTIONS_REGISTER_PROCESS_ENABLE_GOLD, + SHIM_RENDERING_OPTIONS_HANDLE_WINDOWED_MODE_PERF_OPT, + SHIM_RENDERING_OPTIONS_HANDLE_WIN7_ASYNC_RUNTIME_BUG, + SHIM_RENDERING_OPTIONS_EXPLICIT_ADAPTER_OPTED_BY_APP, + SHIM_RENDERING_OPTIONS_ALLOW_DYNAMIC_DISPLAY_MUX_SWITCH, + SHIM_RENDERING_OPTIONS_DISALLOW_DYNAMIC_DISPLAY_MUX_SWITCH, + SHIM_RENDERING_OPTIONS_DISABLE_TURING_POWER_POLICY, +}; + +EValues_SLI_GPU_COUNT g_valuesSLI_GPU_COUNT[SLI_GPU_COUNT_NUM_VALUES] = +{ + SLI_GPU_COUNT_AUTOSELECT, + SLI_GPU_COUNT_ONE, + SLI_GPU_COUNT_TWO, + SLI_GPU_COUNT_THREE, + SLI_GPU_COUNT_FOUR, +}; + +EValues_SLI_PREDEFINED_GPU_COUNT g_valuesSLI_PREDEFINED_GPU_COUNT[SLI_PREDEFINED_GPU_COUNT_NUM_VALUES] = +{ + SLI_PREDEFINED_GPU_COUNT_AUTOSELECT, + SLI_PREDEFINED_GPU_COUNT_ONE, + SLI_PREDEFINED_GPU_COUNT_TWO, + SLI_PREDEFINED_GPU_COUNT_THREE, + SLI_PREDEFINED_GPU_COUNT_FOUR, +}; + +EValues_SLI_PREDEFINED_GPU_COUNT_DX10 g_valuesSLI_PREDEFINED_GPU_COUNT_DX10[SLI_PREDEFINED_GPU_COUNT_DX10_NUM_VALUES] = +{ + SLI_PREDEFINED_GPU_COUNT_DX10_AUTOSELECT, + SLI_PREDEFINED_GPU_COUNT_DX10_ONE, + SLI_PREDEFINED_GPU_COUNT_DX10_TWO, + SLI_PREDEFINED_GPU_COUNT_DX10_THREE, + SLI_PREDEFINED_GPU_COUNT_DX10_FOUR, +}; + +EValues_SLI_PREDEFINED_MODE g_valuesSLI_PREDEFINED_MODE[SLI_PREDEFINED_MODE_NUM_VALUES] = +{ + SLI_PREDEFINED_MODE_AUTOSELECT, + SLI_PREDEFINED_MODE_FORCE_SINGLE, + SLI_PREDEFINED_MODE_FORCE_AFR, + SLI_PREDEFINED_MODE_FORCE_AFR2, + SLI_PREDEFINED_MODE_FORCE_SFR, + SLI_PREDEFINED_MODE_FORCE_AFR_OF_SFR__FALLBACK_3AFR, +}; + +EValues_SLI_PREDEFINED_MODE_DX10 g_valuesSLI_PREDEFINED_MODE_DX10[SLI_PREDEFINED_MODE_DX10_NUM_VALUES] = +{ + SLI_PREDEFINED_MODE_DX10_AUTOSELECT, + SLI_PREDEFINED_MODE_DX10_FORCE_SINGLE, + SLI_PREDEFINED_MODE_DX10_FORCE_AFR, + SLI_PREDEFINED_MODE_DX10_FORCE_AFR2, + SLI_PREDEFINED_MODE_DX10_FORCE_SFR, + SLI_PREDEFINED_MODE_DX10_FORCE_AFR_OF_SFR__FALLBACK_3AFR, +}; + +EValues_SLI_RENDERING_MODE g_valuesSLI_RENDERING_MODE[SLI_RENDERING_MODE_NUM_VALUES] = +{ + SLI_RENDERING_MODE_AUTOSELECT, + SLI_RENDERING_MODE_FORCE_SINGLE, + SLI_RENDERING_MODE_FORCE_AFR, + SLI_RENDERING_MODE_FORCE_AFR2, + SLI_RENDERING_MODE_FORCE_SFR, + SLI_RENDERING_MODE_FORCE_AFR_OF_SFR__FALLBACK_3AFR, +}; + +EValues_VRPRERENDERLIMIT g_valuesVRPRERENDERLIMIT[VRPRERENDERLIMIT_NUM_VALUES] = +{ + VRPRERENDERLIMIT_MIN, + VRPRERENDERLIMIT_MAX, + VRPRERENDERLIMIT_APP_CONTROLLED, + VRPRERENDERLIMIT_DEFAULT, +}; + +EValues_VRRFEATUREINDICATOR g_valuesVRRFEATUREINDICATOR[VRRFEATUREINDICATOR_NUM_VALUES] = +{ + VRRFEATUREINDICATOR_DISABLED, + VRRFEATUREINDICATOR_ENABLED, +}; + +EValues_VRROVERLAYINDICATOR g_valuesVRROVERLAYINDICATOR[VRROVERLAYINDICATOR_NUM_VALUES] = +{ + VRROVERLAYINDICATOR_DISABLED, + VRROVERLAYINDICATOR_ENABLED, +}; + +EValues_VRRREQUESTSTATE g_valuesVRRREQUESTSTATE[VRRREQUESTSTATE_NUM_VALUES] = +{ + VRRREQUESTSTATE_DISABLED, + VRRREQUESTSTATE_FULLSCREEN_ONLY, + VRRREQUESTSTATE_FULLSCREEN_AND_WINDOWED, +}; + +EValues_VRR_APP_OVERRIDE g_valuesVRR_APP_OVERRIDE[VRR_APP_OVERRIDE_NUM_VALUES] = +{ + VRR_APP_OVERRIDE_ALLOW, + VRR_APP_OVERRIDE_FORCE_OFF, + VRR_APP_OVERRIDE_DISALLOW, + VRR_APP_OVERRIDE_ULMB, + VRR_APP_OVERRIDE_FIXED_REFRESH, +}; + +EValues_VRR_APP_OVERRIDE_REQUEST_STATE g_valuesVRR_APP_OVERRIDE_REQUEST_STATE[VRR_APP_OVERRIDE_REQUEST_STATE_NUM_VALUES] = +{ + VRR_APP_OVERRIDE_REQUEST_STATE_ALLOW, + VRR_APP_OVERRIDE_REQUEST_STATE_FORCE_OFF, + VRR_APP_OVERRIDE_REQUEST_STATE_DISALLOW, + VRR_APP_OVERRIDE_REQUEST_STATE_ULMB, + VRR_APP_OVERRIDE_REQUEST_STATE_FIXED_REFRESH, +}; + +EValues_VRR_MODE g_valuesVRR_MODE[VRR_MODE_NUM_VALUES] = +{ + VRR_MODE_DISABLED, + VRR_MODE_FULLSCREEN_ONLY, + VRR_MODE_FULLSCREEN_AND_WINDOWED, +}; + +EValues_VSYNCSMOOTHAFR g_valuesVSYNCSMOOTHAFR[VSYNCSMOOTHAFR_NUM_VALUES] = +{ + VSYNCSMOOTHAFR_OFF, + VSYNCSMOOTHAFR_ON, +}; + +EValues_VSYNCVRRCONTROL g_valuesVSYNCVRRCONTROL[VSYNCVRRCONTROL_NUM_VALUES] = +{ + VSYNCVRRCONTROL_DISABLE, + VSYNCVRRCONTROL_ENABLE, + VSYNCVRRCONTROL_NOTSUPPORTED, +}; + +EValues_VSYNC_BEHAVIOR_FLAGS g_valuesVSYNC_BEHAVIOR_FLAGS[VSYNC_BEHAVIOR_FLAGS_NUM_VALUES] = +{ + VSYNC_BEHAVIOR_FLAGS_NONE, + VSYNC_BEHAVIOR_FLAGS_DEFAULT, + VSYNC_BEHAVIOR_FLAGS_IGNORE_FLIPINTERVAL_MULTIPLE, +}; + +EValues_WKS_API_STEREO_EYES_EXCHANGE g_valuesWKS_API_STEREO_EYES_EXCHANGE[WKS_API_STEREO_EYES_EXCHANGE_NUM_VALUES] = +{ + WKS_API_STEREO_EYES_EXCHANGE_OFF, + WKS_API_STEREO_EYES_EXCHANGE_ON, +}; + +EValues_WKS_API_STEREO_MODE g_valuesWKS_API_STEREO_MODE[WKS_API_STEREO_MODE_NUM_VALUES] = +{ + WKS_API_STEREO_MODE_SHUTTER_GLASSES, + WKS_API_STEREO_MODE_VERTICAL_INTERLACED, + WKS_API_STEREO_MODE_TWINVIEW, + WKS_API_STEREO_MODE_NV17_SHUTTER_GLASSES_AUTO, + WKS_API_STEREO_MODE_NV17_SHUTTER_GLASSES_DAC0, + WKS_API_STEREO_MODE_NV17_SHUTTER_GLASSES_DAC1, + WKS_API_STEREO_MODE_COLOR_LINE, + WKS_API_STEREO_MODE_COLOR_INTERLEAVED, + WKS_API_STEREO_MODE_ANAGLYPH, + WKS_API_STEREO_MODE_HORIZONTAL_INTERLACED, + WKS_API_STEREO_MODE_SIDE_FIELD, + WKS_API_STEREO_MODE_SUB_FIELD, + WKS_API_STEREO_MODE_CHECKERBOARD, + WKS_API_STEREO_MODE_INVERSE_CHECKERBOARD, + WKS_API_STEREO_MODE_TRIDELITY_SL, + WKS_API_STEREO_MODE_TRIDELITY_MV, + WKS_API_STEREO_MODE_SEEFRONT, + WKS_API_STEREO_MODE_STEREO_MIRROR, + WKS_API_STEREO_MODE_FRAME_SEQUENTIAL, + WKS_API_STEREO_MODE_AUTODETECT_PASSIVE_MODE, + WKS_API_STEREO_MODE_AEGIS_DT_FRAME_SEQUENTIAL, + WKS_API_STEREO_MODE_OEM_EMITTER_FRAME_SEQUENTIAL, + WKS_API_STEREO_MODE_DP_INBAND, + WKS_API_STEREO_MODE_USE_HW_DEFAULT, + WKS_API_STEREO_MODE_DEFAULT_GL, +}; + +EValues_WKS_MEMORY_ALLOCATION_POLICY g_valuesWKS_MEMORY_ALLOCATION_POLICY[WKS_MEMORY_ALLOCATION_POLICY_NUM_VALUES] = +{ + WKS_MEMORY_ALLOCATION_POLICY_AS_NEEDED, + WKS_MEMORY_ALLOCATION_POLICY_MODERATE_PRE_ALLOCATION, + WKS_MEMORY_ALLOCATION_POLICY_AGGRESSIVE_PRE_ALLOCATION, +}; + +EValues_WKS_STEREO_DONGLE_SUPPORT g_valuesWKS_STEREO_DONGLE_SUPPORT[WKS_STEREO_DONGLE_SUPPORT_NUM_VALUES] = +{ + WKS_STEREO_DONGLE_SUPPORT_OFF, + WKS_STEREO_DONGLE_SUPPORT_DAC, + WKS_STEREO_DONGLE_SUPPORT_DLP, +}; + +EValues_WKS_STEREO_SUPPORT g_valuesWKS_STEREO_SUPPORT[WKS_STEREO_SUPPORT_NUM_VALUES] = +{ + WKS_STEREO_SUPPORT_OFF, + WKS_STEREO_SUPPORT_ON, +}; + +EValues_WKS_STEREO_SWAP_MODE g_valuesWKS_STEREO_SWAP_MODE[WKS_STEREO_SWAP_MODE_NUM_VALUES] = +{ + WKS_STEREO_SWAP_MODE_APPLICATION_CONTROL, + WKS_STEREO_SWAP_MODE_PER_EYE, + WKS_STEREO_SWAP_MODE_PER_EYE_PAIR, + WKS_STEREO_SWAP_MODE_LEGACY_BEHAVIOR, + WKS_STEREO_SWAP_MODE_PER_EYE_FOR_SWAP_GROUP, +}; + +EValues_AO_MODE g_valuesAO_MODE[AO_MODE_NUM_VALUES] = +{ + AO_MODE_OFF, + AO_MODE_LOW, + AO_MODE_MEDIUM, + AO_MODE_HIGH, +}; + +EValues_AO_MODE_ACTIVE g_valuesAO_MODE_ACTIVE[AO_MODE_ACTIVE_NUM_VALUES] = +{ + AO_MODE_ACTIVE_DISABLED, + AO_MODE_ACTIVE_ENABLED, +}; + +EValues_AUTO_LODBIASADJUST g_valuesAUTO_LODBIASADJUST[AUTO_LODBIASADJUST_NUM_VALUES] = +{ + AUTO_LODBIASADJUST_OFF, + AUTO_LODBIASADJUST_ON, +}; + +EValues_EXPORT_PERF_COUNTERS_DX9_ONLY g_valuesEXPORT_PERF_COUNTERS_DX9_ONLY[EXPORT_PERF_COUNTERS_DX9_ONLY_NUM_VALUES] = +{ + EXPORT_PERF_COUNTERS_DX9_ONLY_OFF, + EXPORT_PERF_COUNTERS_DX9_ONLY_ON, +}; + +EValues_LODBIASADJUST g_valuesLODBIASADJUST[LODBIASADJUST_NUM_VALUES] = +{ + LODBIASADJUST_MIN, + LODBIASADJUST_MAX, +}; + +EValues_MAXWELL_B_SAMPLE_INTERLEAVE g_valuesMAXWELL_B_SAMPLE_INTERLEAVE[MAXWELL_B_SAMPLE_INTERLEAVE_NUM_VALUES] = +{ + MAXWELL_B_SAMPLE_INTERLEAVE_OFF, + MAXWELL_B_SAMPLE_INTERLEAVE_ON, +}; + +EValues_PRERENDERLIMIT g_valuesPRERENDERLIMIT[PRERENDERLIMIT_NUM_VALUES] = +{ + PRERENDERLIMIT_MIN, + PRERENDERLIMIT_MAX, + PRERENDERLIMIT_APP_CONTROLLED, +}; + +EValues_PS_SHADERDISKCACHE g_valuesPS_SHADERDISKCACHE[PS_SHADERDISKCACHE_NUM_VALUES] = +{ + PS_SHADERDISKCACHE_OFF, + PS_SHADERDISKCACHE_ON, +}; + +EValues_PS_SHADERDISKCACHE_MAX_SIZE g_valuesPS_SHADERDISKCACHE_MAX_SIZE[PS_SHADERDISKCACHE_MAX_SIZE_NUM_VALUES] = +{ + PS_SHADERDISKCACHE_MAX_SIZE_MIN, + PS_SHADERDISKCACHE_MAX_SIZE_MAX, +}; + +EValues_PS_TEXFILTER_ANISO_OPTS2 g_valuesPS_TEXFILTER_ANISO_OPTS2[PS_TEXFILTER_ANISO_OPTS2_NUM_VALUES] = +{ + PS_TEXFILTER_ANISO_OPTS2_OFF, + PS_TEXFILTER_ANISO_OPTS2_ON, +}; + +EValues_PS_TEXFILTER_BILINEAR_IN_ANISO g_valuesPS_TEXFILTER_BILINEAR_IN_ANISO[PS_TEXFILTER_BILINEAR_IN_ANISO_NUM_VALUES] = +{ + PS_TEXFILTER_BILINEAR_IN_ANISO_OFF, + PS_TEXFILTER_BILINEAR_IN_ANISO_ON, +}; + +EValues_PS_TEXFILTER_DISABLE_TRILIN_SLOPE g_valuesPS_TEXFILTER_DISABLE_TRILIN_SLOPE[PS_TEXFILTER_DISABLE_TRILIN_SLOPE_NUM_VALUES] = +{ + PS_TEXFILTER_DISABLE_TRILIN_SLOPE_OFF, + PS_TEXFILTER_DISABLE_TRILIN_SLOPE_ON, +}; + +EValues_PS_TEXFILTER_NO_NEG_LODBIAS g_valuesPS_TEXFILTER_NO_NEG_LODBIAS[PS_TEXFILTER_NO_NEG_LODBIAS_NUM_VALUES] = +{ + PS_TEXFILTER_NO_NEG_LODBIAS_OFF, + PS_TEXFILTER_NO_NEG_LODBIAS_ON, +}; + +EValues_QUALITY_ENHANCEMENTS g_valuesQUALITY_ENHANCEMENTS[QUALITY_ENHANCEMENTS_NUM_VALUES] = +{ + QUALITY_ENHANCEMENTS_HIGHQUALITY, + QUALITY_ENHANCEMENTS_QUALITY, + QUALITY_ENHANCEMENTS_PERFORMANCE, + QUALITY_ENHANCEMENTS_HIGHPERFORMANCE, +}; + +EValues_QUALITY_ENHANCEMENT_SUBSTITUTION g_valuesQUALITY_ENHANCEMENT_SUBSTITUTION[QUALITY_ENHANCEMENT_SUBSTITUTION_NUM_VALUES] = +{ + QUALITY_ENHANCEMENT_SUBSTITUTION_NO_SUBSTITUTION, + QUALITY_ENHANCEMENT_SUBSTITUTION_HIGHQUALITY_BECOMES_QUALITY, +}; + +EValues_REFRESH_RATE_OVERRIDE g_valuesREFRESH_RATE_OVERRIDE[REFRESH_RATE_OVERRIDE_NUM_VALUES] = +{ + REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED, + REFRESH_RATE_OVERRIDE_HIGHEST_AVAILABLE, + REFRESH_RATE_OVERRIDE_LOW_LATENCY_RR_MASK, +}; + +EValues_SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE g_valuesSET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE[SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_NUM_VALUES] = +{ + SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_OFF, + SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_ON, +}; + +EValues_SET_VAB_DATA g_valuesSET_VAB_DATA[SET_VAB_DATA_NUM_VALUES] = +{ + SET_VAB_DATA_ZERO, + SET_VAB_DATA_UINT_ONE, + SET_VAB_DATA_FLOAT_ONE, + SET_VAB_DATA_FLOAT_POS_INF, + SET_VAB_DATA_FLOAT_NAN, + SET_VAB_DATA_USE_API_DEFAULTS, +}; + +EValues_VSYNCMODE g_valuesVSYNCMODE[VSYNCMODE_NUM_VALUES] = +{ + VSYNCMODE_PASSIVE, + VSYNCMODE_FORCEOFF, + VSYNCMODE_FORCEON, + VSYNCMODE_FLIPINTERVAL2, + VSYNCMODE_FLIPINTERVAL3, + VSYNCMODE_FLIPINTERVAL4, + VSYNCMODE_VIRTUAL, +}; + +EValues_VSYNCTEARCONTROL g_valuesVSYNCTEARCONTROL[VSYNCTEARCONTROL_NUM_VALUES] = +{ + VSYNCTEARCONTROL_DISABLE, + VSYNCTEARCONTROL_ENABLE, +}; + + +SettingDWORDNameString mapSettingDWORD[TOTAL_DWORD_SETTING_NUM] = +{ + {OGL_AA_LINE_GAMMA_ID, OGL_AA_LINE_GAMMA_STRING, 4, (NvU32 *)g_valuesOGL_AA_LINE_GAMMA, OGL_AA_LINE_GAMMA_DISABLED}, + {OGL_DEEP_COLOR_SCANOUT_ID, OGL_DEEP_COLOR_SCANOUT_STRING, 2, (NvU32 *)g_valuesOGL_DEEP_COLOR_SCANOUT, OGL_DEEP_COLOR_SCANOUT_ENABLE}, + {OGL_DEFAULT_SWAP_INTERVAL_ID, OGL_DEFAULT_SWAP_INTERVAL_STRING, 9, (NvU32 *)g_valuesOGL_DEFAULT_SWAP_INTERVAL, OGL_DEFAULT_SWAP_INTERVAL_VSYNC_ONE}, + {OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_ID, OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_STRING, 2, (NvU32 *)g_valuesOGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL, 0x00000000}, + {OGL_DEFAULT_SWAP_INTERVAL_SIGN_ID, OGL_DEFAULT_SWAP_INTERVAL_SIGN_STRING, 2, (NvU32 *)g_valuesOGL_DEFAULT_SWAP_INTERVAL_SIGN, OGL_DEFAULT_SWAP_INTERVAL_SIGN_POSITIVE}, + {OGL_EVENT_LOG_SEVERITY_THRESHOLD_ID, OGL_EVENT_LOG_SEVERITY_THRESHOLD_STRING, 5, (NvU32 *)g_valuesOGL_EVENT_LOG_SEVERITY_THRESHOLD, OGL_EVENT_LOG_SEVERITY_THRESHOLD_ALL}, + {OGL_EXTENSION_STRING_VERSION_ID, OGL_EXTENSION_STRING_VERSION_STRING, 0, NULL, 0x00000000}, + {OGL_FORCE_BLIT_ID, OGL_FORCE_BLIT_STRING, 2, (NvU32 *)g_valuesOGL_FORCE_BLIT, OGL_FORCE_BLIT_OFF}, + {OGL_FORCE_STEREO_ID, OGL_FORCE_STEREO_STRING, 2, (NvU32 *)g_valuesOGL_FORCE_STEREO, OGL_FORCE_STEREO_OFF}, + {OGL_MAX_FRAMES_ALLOWED_ID, OGL_MAX_FRAMES_ALLOWED_STRING, 0, NULL, 0x00000002}, + {OGL_OVERLAY_PIXEL_TYPE_ID, OGL_OVERLAY_PIXEL_TYPE_STRING, 4, (NvU32 *)g_valuesOGL_OVERLAY_PIXEL_TYPE, OGL_OVERLAY_PIXEL_TYPE_CI}, + {OGL_OVERLAY_SUPPORT_ID, OGL_OVERLAY_SUPPORT_STRING, 3, (NvU32 *)g_valuesOGL_OVERLAY_SUPPORT, OGL_OVERLAY_SUPPORT_OFF}, + {OGL_QUALITY_ENHANCEMENTS_ID, OGL_QUALITY_ENHANCEMENTS_STRING, 4, (NvU32 *)g_valuesOGL_QUALITY_ENHANCEMENTS, OGL_QUALITY_ENHANCEMENTS_QUAL}, + {OGL_SINGLE_BACKDEPTH_BUFFER_ID, OGL_SINGLE_BACKDEPTH_BUFFER_STRING, 3, (NvU32 *)g_valuesOGL_SINGLE_BACKDEPTH_BUFFER, OGL_SINGLE_BACKDEPTH_BUFFER_DISABLE}, + {OGL_SLI_CFR_MODE_ID, OGL_SLI_CFR_MODE_STRING, 3, (NvU32 *)g_valuesOGL_SLI_CFR_MODE, OGL_SLI_CFR_MODE_DISABLE}, + {OGL_SLI_MULTICAST_ID, OGL_SLI_MULTICAST_STRING, 4, (NvU32 *)g_valuesOGL_SLI_MULTICAST, OGL_SLI_MULTICAST_DISABLE}, + {OGL_THREAD_CONTROL_ID, OGL_THREAD_CONTROL_STRING, 2, (NvU32 *)g_valuesOGL_THREAD_CONTROL, 0x00000000}, + {OGL_TMON_LEVEL_ID, OGL_TMON_LEVEL_STRING, 6, (NvU32 *)g_valuesOGL_TMON_LEVEL, OGL_TMON_LEVEL_MOST}, + {OGL_TRIPLE_BUFFER_ID, OGL_TRIPLE_BUFFER_STRING, 2, (NvU32 *)g_valuesOGL_TRIPLE_BUFFER, OGL_TRIPLE_BUFFER_DISABLED}, + {AA_BEHAVIOR_FLAGS_ID, AA_BEHAVIOR_FLAGS_STRING, 18, (NvU32 *)g_valuesAA_BEHAVIOR_FLAGS, AA_BEHAVIOR_FLAGS_DEFAULT}, + {AA_MODE_ALPHATOCOVERAGE_ID, AA_MODE_ALPHATOCOVERAGE_STRING, 4, (NvU32 *)g_valuesAA_MODE_ALPHATOCOVERAGE, 0x00000000}, + {AA_MODE_GAMMACORRECTION_ID, AA_MODE_GAMMACORRECTION_STRING, 8, (NvU32 *)g_valuesAA_MODE_GAMMACORRECTION, 0x00000000}, + {AA_MODE_METHOD_ID, AA_MODE_METHOD_STRING, 50, (NvU32 *)g_valuesAA_MODE_METHOD, AA_MODE_METHOD_NONE}, + {AA_MODE_REPLAY_ID, AA_MODE_REPLAY_STRING, 20, (NvU32 *)g_valuesAA_MODE_REPLAY, 0x00000000}, + {AA_MODE_SELECTOR_ID, AA_MODE_SELECTOR_STRING, 5, (NvU32 *)g_valuesAA_MODE_SELECTOR, AA_MODE_SELECTOR_APP_CONTROL}, + {AA_MODE_SELECTOR_SLIAA_ID, AA_MODE_SELECTOR_SLIAA_STRING, 2, (NvU32 *)g_valuesAA_MODE_SELECTOR_SLIAA, AA_MODE_SELECTOR_SLIAA_DISABLED}, + {ANISO_MODE_LEVEL_ID, ANISO_MODE_LEVEL_STRING, 5, (NvU32 *)g_valuesANISO_MODE_LEVEL, ANISO_MODE_LEVEL_DEFAULT}, + {ANISO_MODE_SELECTOR_ID, ANISO_MODE_SELECTOR_STRING, 6, (NvU32 *)g_valuesANISO_MODE_SELECTOR, ANISO_MODE_SELECTOR_DEFAULT}, + {ANSEL_ALLOW_ID, ANSEL_ALLOW_STRING, 2, (NvU32 *)g_valuesANSEL_ALLOW, ANSEL_ALLOW_ALLOWED}, + {ANSEL_ALLOWLISTED_ID, ANSEL_ALLOWLISTED_STRING, 2, (NvU32 *)g_valuesANSEL_ALLOWLISTED, ANSEL_ALLOWLISTED_DISALLOWED}, + {ANSEL_ENABLE_ID, ANSEL_ENABLE_STRING, 2, (NvU32 *)g_valuesANSEL_ENABLE, ANSEL_ENABLE_ON}, + {APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_ID, APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_STRING, 6, (NvU32 *)g_valuesAPPLICATION_PROFILE_NOTIFICATION_TIMEOUT, APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_DISABLED}, + {APPLICATION_STEAM_ID_ID, APPLICATION_STEAM_ID_STRING, 0, NULL, 0x00000000}, + {BATTERY_BOOST_APP_FPS_ID, BATTERY_BOOST_APP_FPS_STRING, 3, (NvU32 *)g_valuesBATTERY_BOOST_APP_FPS, BATTERY_BOOST_APP_FPS_NO_OVERRIDE}, + {CPL_HIDDEN_PROFILE_ID, CPL_HIDDEN_PROFILE_STRING, 2, (NvU32 *)g_valuesCPL_HIDDEN_PROFILE, CPL_HIDDEN_PROFILE_DISABLED}, + {EXPORT_PERF_COUNTERS_ID, EXPORT_PERF_COUNTERS_STRING, 2, (NvU32 *)g_valuesEXPORT_PERF_COUNTERS, EXPORT_PERF_COUNTERS_OFF}, + {EXTERNAL_QUIET_MODE_ID, EXTERNAL_QUIET_MODE_STRING, 2, (NvU32 *)g_valuesEXTERNAL_QUIET_MODE, EXTERNAL_QUIET_MODE_OFF}, + {FRL_FPS_ID, FRL_FPS_STRING, 3, (NvU32 *)g_valuesFRL_FPS, FRL_FPS_DISABLED}, + {FXAA_ALLOW_ID, FXAA_ALLOW_STRING, 2, (NvU32 *)g_valuesFXAA_ALLOW, FXAA_ALLOW_ALLOWED}, + {FXAA_ENABLE_ID, FXAA_ENABLE_STRING, 2, (NvU32 *)g_valuesFXAA_ENABLE, FXAA_ENABLE_OFF}, + {FXAA_INDICATOR_ENABLE_ID, FXAA_INDICATOR_ENABLE_STRING, 2, (NvU32 *)g_valuesFXAA_INDICATOR_ENABLE, FXAA_INDICATOR_ENABLE_OFF}, + {LATENCY_INDICATOR_AUTOALIGN_ID, LATENCY_INDICATOR_AUTOALIGN_STRING, 2, (NvU32 *)g_valuesLATENCY_INDICATOR_AUTOALIGN, LATENCY_INDICATOR_AUTOALIGN_ENABLED}, + {MCSFRSHOWSPLIT_ID, MCSFRSHOWSPLIT_STRING, 2, (NvU32 *)g_valuesMCSFRSHOWSPLIT, MCSFRSHOWSPLIT_DISABLED}, + {NV_QUALITY_UPSCALING_ID, NV_QUALITY_UPSCALING_STRING, 2, (NvU32 *)g_valuesNV_QUALITY_UPSCALING, NV_QUALITY_UPSCALING_OFF}, + {OPTIMUS_MAXAA_ID, OPTIMUS_MAXAA_STRING, 2, (NvU32 *)g_valuesOPTIMUS_MAXAA, 0x00000000}, + {PHYSXINDICATOR_ID, PHYSXINDICATOR_STRING, 2, (NvU32 *)g_valuesPHYSXINDICATOR, PHYSXINDICATOR_DISABLED}, + {PREFERRED_PSTATE_ID, PREFERRED_PSTATE_STRING, 8, (NvU32 *)g_valuesPREFERRED_PSTATE, PREFERRED_PSTATE_OPTIMAL_POWER}, + {PREVENT_UI_AF_OVERRIDE_ID, PREVENT_UI_AF_OVERRIDE_STRING, 2, (NvU32 *)g_valuesPREVENT_UI_AF_OVERRIDE, PREVENT_UI_AF_OVERRIDE_OFF}, + {SHIM_MAXRES_ID, SHIM_MAXRES_STRING, 0, NULL, 0x00000000}, + {SHIM_MCCOMPAT_ID, SHIM_MCCOMPAT_STRING, 8, (NvU32 *)g_valuesSHIM_MCCOMPAT, SHIM_MCCOMPAT_AUTO_SELECT}, + {SHIM_RENDERING_MODE_ID, SHIM_RENDERING_MODE_STRING, 8, (NvU32 *)g_valuesSHIM_RENDERING_MODE, SHIM_RENDERING_MODE_AUTO_SELECT}, + {SHIM_RENDERING_OPTIONS_ID, SHIM_RENDERING_OPTIONS_STRING, 28, (NvU32 *)g_valuesSHIM_RENDERING_OPTIONS, 0x00000000}, + {SLI_GPU_COUNT_ID, SLI_GPU_COUNT_STRING, 5, (NvU32 *)g_valuesSLI_GPU_COUNT, SLI_GPU_COUNT_AUTOSELECT}, + {SLI_PREDEFINED_GPU_COUNT_ID, SLI_PREDEFINED_GPU_COUNT_STRING, 5, (NvU32 *)g_valuesSLI_PREDEFINED_GPU_COUNT, SLI_PREDEFINED_GPU_COUNT_AUTOSELECT}, + {SLI_PREDEFINED_GPU_COUNT_DX10_ID, SLI_PREDEFINED_GPU_COUNT_DX10_STRING, 5, (NvU32 *)g_valuesSLI_PREDEFINED_GPU_COUNT_DX10, SLI_PREDEFINED_GPU_COUNT_DX10_AUTOSELECT}, + {SLI_PREDEFINED_MODE_ID, SLI_PREDEFINED_MODE_STRING, 6, (NvU32 *)g_valuesSLI_PREDEFINED_MODE, SLI_PREDEFINED_MODE_AUTOSELECT}, + {SLI_PREDEFINED_MODE_DX10_ID, SLI_PREDEFINED_MODE_DX10_STRING, 6, (NvU32 *)g_valuesSLI_PREDEFINED_MODE_DX10, SLI_PREDEFINED_MODE_DX10_AUTOSELECT}, + {SLI_RENDERING_MODE_ID, SLI_RENDERING_MODE_STRING, 6, (NvU32 *)g_valuesSLI_RENDERING_MODE, SLI_RENDERING_MODE_AUTOSELECT}, + {VRPRERENDERLIMIT_ID, VRPRERENDERLIMIT_STRING, 4, (NvU32 *)g_valuesVRPRERENDERLIMIT, VRPRERENDERLIMIT_DEFAULT}, + {VRRFEATUREINDICATOR_ID, VRRFEATUREINDICATOR_STRING, 2, (NvU32 *)g_valuesVRRFEATUREINDICATOR, VRRFEATUREINDICATOR_ENABLED}, + {VRROVERLAYINDICATOR_ID, VRROVERLAYINDICATOR_STRING, 2, (NvU32 *)g_valuesVRROVERLAYINDICATOR, VRROVERLAYINDICATOR_ENABLED}, + {VRRREQUESTSTATE_ID, VRRREQUESTSTATE_STRING, 3, (NvU32 *)g_valuesVRRREQUESTSTATE, VRRREQUESTSTATE_FULLSCREEN_ONLY}, + {VRR_APP_OVERRIDE_ID, VRR_APP_OVERRIDE_STRING, 5, (NvU32 *)g_valuesVRR_APP_OVERRIDE, VRR_APP_OVERRIDE_ALLOW}, + {VRR_APP_OVERRIDE_REQUEST_STATE_ID, VRR_APP_OVERRIDE_REQUEST_STATE_STRING, 5, (NvU32 *)g_valuesVRR_APP_OVERRIDE_REQUEST_STATE, VRR_APP_OVERRIDE_REQUEST_STATE_ALLOW}, + {VRR_MODE_ID, VRR_MODE_STRING, 3, (NvU32 *)g_valuesVRR_MODE, VRR_MODE_FULLSCREEN_ONLY}, + {VSYNCSMOOTHAFR_ID, VSYNCSMOOTHAFR_STRING, 2, (NvU32 *)g_valuesVSYNCSMOOTHAFR, VSYNCSMOOTHAFR_OFF}, + {VSYNCVRRCONTROL_ID, VSYNCVRRCONTROL_STRING, 3, (NvU32 *)g_valuesVSYNCVRRCONTROL, VSYNCVRRCONTROL_ENABLE}, + {VSYNC_BEHAVIOR_FLAGS_ID, VSYNC_BEHAVIOR_FLAGS_STRING, 3, (NvU32 *)g_valuesVSYNC_BEHAVIOR_FLAGS, VSYNC_BEHAVIOR_FLAGS_DEFAULT}, + {WKS_API_STEREO_EYES_EXCHANGE_ID, WKS_API_STEREO_EYES_EXCHANGE_STRING, 2, (NvU32 *)g_valuesWKS_API_STEREO_EYES_EXCHANGE, WKS_API_STEREO_EYES_EXCHANGE_OFF}, + {WKS_API_STEREO_MODE_ID, WKS_API_STEREO_MODE_STRING, 25, (NvU32 *)g_valuesWKS_API_STEREO_MODE, WKS_API_STEREO_MODE_SHUTTER_GLASSES}, + {WKS_MEMORY_ALLOCATION_POLICY_ID, WKS_MEMORY_ALLOCATION_POLICY_STRING, 3, (NvU32 *)g_valuesWKS_MEMORY_ALLOCATION_POLICY, WKS_MEMORY_ALLOCATION_POLICY_AS_NEEDED}, + {WKS_STEREO_DONGLE_SUPPORT_ID, WKS_STEREO_DONGLE_SUPPORT_STRING, 3, (NvU32 *)g_valuesWKS_STEREO_DONGLE_SUPPORT, WKS_STEREO_DONGLE_SUPPORT_DAC}, + {WKS_STEREO_SUPPORT_ID, WKS_STEREO_SUPPORT_STRING, 2, (NvU32 *)g_valuesWKS_STEREO_SUPPORT, WKS_STEREO_SUPPORT_OFF}, + {WKS_STEREO_SWAP_MODE_ID, WKS_STEREO_SWAP_MODE_STRING, 5, (NvU32 *)g_valuesWKS_STEREO_SWAP_MODE, WKS_STEREO_SWAP_MODE_APPLICATION_CONTROL}, + {AO_MODE_ID, AO_MODE_STRING, 4, (NvU32 *)g_valuesAO_MODE, AO_MODE_OFF}, + {AO_MODE_ACTIVE_ID, AO_MODE_ACTIVE_STRING, 2, (NvU32 *)g_valuesAO_MODE_ACTIVE, AO_MODE_ACTIVE_DISABLED}, + {AUTO_LODBIASADJUST_ID, AUTO_LODBIASADJUST_STRING, 2, (NvU32 *)g_valuesAUTO_LODBIASADJUST, AUTO_LODBIASADJUST_ON}, + {EXPORT_PERF_COUNTERS_DX9_ONLY_ID, EXPORT_PERF_COUNTERS_DX9_ONLY_STRING, 2, (NvU32 *)g_valuesEXPORT_PERF_COUNTERS_DX9_ONLY, EXPORT_PERF_COUNTERS_DX9_ONLY_OFF}, + {LODBIASADJUST_ID, LODBIASADJUST_STRING, 2, (NvU32 *)g_valuesLODBIASADJUST, 0x00000000}, + {MAXWELL_B_SAMPLE_INTERLEAVE_ID, MAXWELL_B_SAMPLE_INTERLEAVE_STRING, 2, (NvU32 *)g_valuesMAXWELL_B_SAMPLE_INTERLEAVE, MAXWELL_B_SAMPLE_INTERLEAVE_OFF}, + {PRERENDERLIMIT_ID, PRERENDERLIMIT_STRING, 3, (NvU32 *)g_valuesPRERENDERLIMIT, PRERENDERLIMIT_APP_CONTROLLED}, + {PS_SHADERDISKCACHE_ID, PS_SHADERDISKCACHE_STRING, 2, (NvU32 *)g_valuesPS_SHADERDISKCACHE, PS_SHADERDISKCACHE_ON}, + {PS_SHADERDISKCACHE_MAX_SIZE_ID, PS_SHADERDISKCACHE_MAX_SIZE_STRING, 2, (NvU32 *)g_valuesPS_SHADERDISKCACHE_MAX_SIZE, 0x00000000}, + {PS_TEXFILTER_ANISO_OPTS2_ID, PS_TEXFILTER_ANISO_OPTS2_STRING, 2, (NvU32 *)g_valuesPS_TEXFILTER_ANISO_OPTS2, PS_TEXFILTER_ANISO_OPTS2_OFF}, + {PS_TEXFILTER_BILINEAR_IN_ANISO_ID, PS_TEXFILTER_BILINEAR_IN_ANISO_STRING, 2, (NvU32 *)g_valuesPS_TEXFILTER_BILINEAR_IN_ANISO, PS_TEXFILTER_BILINEAR_IN_ANISO_OFF}, + {PS_TEXFILTER_DISABLE_TRILIN_SLOPE_ID, PS_TEXFILTER_DISABLE_TRILIN_SLOPE_STRING, 2, (NvU32 *)g_valuesPS_TEXFILTER_DISABLE_TRILIN_SLOPE, PS_TEXFILTER_DISABLE_TRILIN_SLOPE_OFF}, + {PS_TEXFILTER_NO_NEG_LODBIAS_ID, PS_TEXFILTER_NO_NEG_LODBIAS_STRING, 2, (NvU32 *)g_valuesPS_TEXFILTER_NO_NEG_LODBIAS, PS_TEXFILTER_NO_NEG_LODBIAS_OFF}, + {QUALITY_ENHANCEMENTS_ID, QUALITY_ENHANCEMENTS_STRING, 4, (NvU32 *)g_valuesQUALITY_ENHANCEMENTS, QUALITY_ENHANCEMENTS_QUALITY}, + {QUALITY_ENHANCEMENT_SUBSTITUTION_ID, QUALITY_ENHANCEMENT_SUBSTITUTION_STRING, 2, (NvU32 *)g_valuesQUALITY_ENHANCEMENT_SUBSTITUTION, QUALITY_ENHANCEMENT_SUBSTITUTION_NO_SUBSTITUTION}, + {REFRESH_RATE_OVERRIDE_ID, REFRESH_RATE_OVERRIDE_STRING, 3, (NvU32 *)g_valuesREFRESH_RATE_OVERRIDE, REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED}, + {SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_ID, SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_STRING, 2, (NvU32 *)g_valuesSET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE, SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_OFF}, + {SET_VAB_DATA_ID, SET_VAB_DATA_STRING, 6, (NvU32 *)g_valuesSET_VAB_DATA, SET_VAB_DATA_USE_API_DEFAULTS}, + {VSYNCMODE_ID, VSYNCMODE_STRING, 7, (NvU32 *)g_valuesVSYNCMODE, VSYNCMODE_PASSIVE}, + {VSYNCTEARCONTROL_ID, VSYNCTEARCONTROL_STRING, 2, (NvU32 *)g_valuesVSYNCTEARCONTROL, VSYNCTEARCONTROL_DISABLE}, +}; + +SettingWSTRINGNameString mapSettingWSTRING[TOTAL_WSTRING_SETTING_NUM] = +{ + {OGL_IMPLICIT_GPU_AFFINITY_ID, OGL_IMPLICIT_GPU_AFFINITY_STRING, 1, (const wchar_t **)g_valuesOGL_IMPLICIT_GPU_AFFINITY, L"autoselect"}, + {CUDA_EXCLUDED_GPUS_ID, CUDA_EXCLUDED_GPUS_STRING, 1, (const wchar_t **)g_valuesCUDA_EXCLUDED_GPUS, L"none"}, + {D3DOGL_GPU_MAX_POWER_ID, D3DOGL_GPU_MAX_POWER_STRING, 1, (const wchar_t **)g_valuesD3DOGL_GPU_MAX_POWER, L"0"}, + {ICAFE_LOGO_CONFIG_ID, ICAFE_LOGO_CONFIG_STRING, 0, NULL, L""}, +}; + diff --git a/thirdparty/nvapi/NvApiDriverSettings.h b/thirdparty/nvapi/NvApiDriverSettings.h new file mode 100644 index 0000000..c548a56 --- /dev/null +++ b/thirdparty/nvapi/NvApiDriverSettings.h @@ -0,0 +1,1155 @@ +/***************************************************************************\ +|* *| +|* Copyright NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This source code is subject to NVIDIA ownership rights under U.S. *| +|* and international Copyright laws. Users and possessors of this *| +|* source code are hereby granted a nonexclusive, royalty-free *| +|* license to use this code in individual and commercial software. *| +|* *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE *| +|* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR *| +|* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH *| +|* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF *| +|* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR *| +|* PURPOSE. IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, *| +|* INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES *| +|* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN *| +|* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *| +|* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE *| +|* CODE. *| +|* *| +|* U.S. Government End Users. This source code is a "commercial item" *| +|* as that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting *| +|* of "commercial computer software" and "commercial computer software *| +|* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) *| +|* and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through *| +|* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the *| +|* source code with only those rights set forth herein. *| +|* *| +|* Any use of this source code in individual and commercial software must *| +|* include, in the user documentation and internal comments to the code, *| +|* the above Disclaimer and U.S. Government End Users Notice. *| +|* *| +|* *| +\***************************************************************************/ + +#ifndef _NVAPI_DRIVER_SETTINGS_H_ +#define _NVAPI_DRIVER_SETTINGS_H_ + +#define OGL_AA_LINE_GAMMA_STRING L"Antialiasing - Line gamma" +#define OGL_DEEP_COLOR_SCANOUT_STRING L"Deep color for 3D applications" +#define OGL_DEFAULT_SWAP_INTERVAL_STRING L"OpenGL default swap interval" +#define OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_STRING L"OpenGL default swap interval fraction" +#define OGL_DEFAULT_SWAP_INTERVAL_SIGN_STRING L"OpenGL default swap interval sign" +#define OGL_EVENT_LOG_SEVERITY_THRESHOLD_STRING L"Event Log Severity Threshold" +#define OGL_EXTENSION_STRING_VERSION_STRING L"Extension String version" +#define OGL_FORCE_BLIT_STRING L"Buffer-flipping mode" +#define OGL_FORCE_STEREO_STRING L"Force Stereo shuttering" +#define OGL_IMPLICIT_GPU_AFFINITY_STRING L"Preferred OpenGL GPU" +#define OGL_MAX_FRAMES_ALLOWED_STRING L"Maximum frames allowed" +#define OGL_OVERLAY_PIXEL_TYPE_STRING L"Exported Overlay pixel types" +#define OGL_OVERLAY_SUPPORT_STRING L"Enable overlay" +#define OGL_QUALITY_ENHANCEMENTS_STRING L"High level control of the rendering quality on OpenGL" +#define OGL_SINGLE_BACKDEPTH_BUFFER_STRING L"Unified back/depth buffer" +#define OGL_SLI_CFR_MODE_STRING L"Set CFR mode" +#define OGL_SLI_MULTICAST_STRING L"Enable NV_gpu_multicast extension" +#define OGL_THREAD_CONTROL_STRING L"Threaded optimization" +#define OGL_TMON_LEVEL_STRING L"Event Log Tmon Severity Threshold" +#define OGL_TRIPLE_BUFFER_STRING L"Triple buffering" +#define AA_BEHAVIOR_FLAGS_STRING L"Antialiasing - Behavior Flags" +#define AA_MODE_ALPHATOCOVERAGE_STRING L"Antialiasing - Transparency Multisampling" +#define AA_MODE_GAMMACORRECTION_STRING L"Antialiasing - Gamma correction" +#define AA_MODE_METHOD_STRING L"Antialiasing - Setting" +#define AA_MODE_REPLAY_STRING L"Antialiasing - Transparency Supersampling" +#define AA_MODE_SELECTOR_STRING L"Antialiasing - Mode" +#define AA_MODE_SELECTOR_SLIAA_STRING L"Antialiasing - SLI AA" +#define ANISO_MODE_LEVEL_STRING L"Anisotropic filtering setting" +#define ANISO_MODE_SELECTOR_STRING L"Anisotropic filtering mode" +#define ANSEL_ALLOW_STRING L"NVIDIA Predefined Ansel Usage" +#define ANSEL_ALLOWLISTED_STRING L"Ansel flags for enabled applications" +#define ANSEL_ENABLE_STRING L"Enable Ansel" +#define APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_STRING L"Application Profile Notification Popup Timeout" +#define APPLICATION_STEAM_ID_STRING L"Steam Application ID" +#define BATTERY_BOOST_APP_FPS_STRING L"Battery Boost Application FPS" +#define CPL_HIDDEN_PROFILE_STRING L"Do not display this profile in the Control Panel" +#define CUDA_EXCLUDED_GPUS_STRING L"List of Universal GPU ids" +#define D3DOGL_GPU_MAX_POWER_STRING L"Maximum GPU Power" +#define EXPORT_PERF_COUNTERS_STRING L"Export Performance Counters" +#define EXTERNAL_QUIET_MODE_STRING L"External Quiet Mode (XQM)" +#define FRL_FPS_STRING L"Frame Rate Limiter" +#define FXAA_ALLOW_STRING L"NVIDIA Predefined FXAA Usage" +#define FXAA_ENABLE_STRING L"Enable FXAA" +#define FXAA_INDICATOR_ENABLE_STRING L"Enable FXAA Indicator" +#define LATENCY_INDICATOR_AUTOALIGN_STRING L"Autoalign flash indicator" +#define MCSFRSHOWSPLIT_STRING L"SLI indicator" +#define NV_QUALITY_UPSCALING_STRING L"NVIDIA Quality upscaling" +#define OPTIMUS_MAXAA_STRING L"Maximum AA samples allowed for a given application" +#define PHYSXINDICATOR_STRING L"Display the PhysX indicator" +#define PREFERRED_PSTATE_STRING L"Power management mode" +#define PREVENT_UI_AF_OVERRIDE_STRING L"No override of Anisotropic filtering" +#define SHIM_MAXRES_STRING L"Maximum resolution allowed for a given application" +#define SHIM_MCCOMPAT_STRING L"Optimus flags for enabled applications" +#define SHIM_RENDERING_MODE_STRING L"Enable application for Optimus" +#define SHIM_RENDERING_OPTIONS_STRING L"Shim Rendering Mode Options per application for Optimus" +#define SLI_GPU_COUNT_STRING L"Number of GPUs to use on SLI rendering mode" +#define SLI_PREDEFINED_GPU_COUNT_STRING L"NVIDIA predefined number of GPUs to use on SLI rendering mode" +#define SLI_PREDEFINED_GPU_COUNT_DX10_STRING L"NVIDIA predefined number of GPUs to use on SLI rendering mode on DirectX 10" +#define SLI_PREDEFINED_MODE_STRING L"NVIDIA predefined SLI mode" +#define SLI_PREDEFINED_MODE_DX10_STRING L"NVIDIA predefined SLI mode on DirectX 10" +#define SLI_RENDERING_MODE_STRING L"SLI rendering mode" +#define VRPRERENDERLIMIT_STRING L"Virtual Reality pre-rendered frames" +#define VRRFEATUREINDICATOR_STRING L"Toggle the VRR global feature" +#define VRROVERLAYINDICATOR_STRING L"Display the VRR Overlay Indicator" +#define VRRREQUESTSTATE_STRING L"VRR requested state" +#define VRR_APP_OVERRIDE_STRING L"G-SYNC" +#define VRR_APP_OVERRIDE_REQUEST_STATE_STRING L"G-SYNC" +#define VRR_MODE_STRING L"Enable G-SYNC globally" +#define VSYNCSMOOTHAFR_STRING L"Flag to control smooth AFR behavior" +#define VSYNCVRRCONTROL_STRING L"Variable refresh Rate" +#define VSYNC_BEHAVIOR_FLAGS_STRING L"Vsync - Behavior Flags" +#define WKS_API_STEREO_EYES_EXCHANGE_STRING L"Stereo - Swap eyes" +#define WKS_API_STEREO_MODE_STRING L"Stereo - Display mode" +#define WKS_MEMORY_ALLOCATION_POLICY_STRING L"Memory Allocation Policy" +#define WKS_STEREO_DONGLE_SUPPORT_STRING L"Stereo - Dongle Support" +#define WKS_STEREO_SUPPORT_STRING L"Stereo - Enable" +#define WKS_STEREO_SWAP_MODE_STRING L"Stereo - swap mode" +#define AO_MODE_STRING L"Ambient Occlusion" +#define AO_MODE_ACTIVE_STRING L"NVIDIA Predefined Ambient Occlusion Usage" +#define AUTO_LODBIASADJUST_STRING L"Texture filtering - Driver Controlled LOD Bias" +#define EXPORT_PERF_COUNTERS_DX9_ONLY_STRING L"Export Performance Counters for DX9 only" +#define ICAFE_LOGO_CONFIG_STRING L"ICafe Settings" +#define LODBIASADJUST_STRING L"Texture filtering - LOD Bias" +#define MAXWELL_B_SAMPLE_INTERLEAVE_STRING L"Enable sample interleaving (MFAA)" +#define PRERENDERLIMIT_STRING L"Maximum pre-rendered frames" +#define PS_SHADERDISKCACHE_STRING L"Shader Cache" +#define PS_SHADERDISKCACHE_MAX_SIZE_STRING L"Shader disk cache maximum size" +#define PS_TEXFILTER_ANISO_OPTS2_STRING L"Texture filtering - Anisotropic sample optimization" +#define PS_TEXFILTER_BILINEAR_IN_ANISO_STRING L"Texture filtering - Anisotropic filter optimization" +#define PS_TEXFILTER_DISABLE_TRILIN_SLOPE_STRING L"Texture filtering - Trilinear optimization" +#define PS_TEXFILTER_NO_NEG_LODBIAS_STRING L"Texture filtering - Negative LOD bias" +#define QUALITY_ENHANCEMENTS_STRING L"Texture filtering - Quality" +#define QUALITY_ENHANCEMENT_SUBSTITUTION_STRING L"Texture filtering - Quality Substitution" +#define REFRESH_RATE_OVERRIDE_STRING L"Preferred refresh rate" +#define SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_STRING L"PowerThrottle" +#define SET_VAB_DATA_STRING L"VAB Default Data" +#define VSYNCMODE_STRING L"Vertical Sync" +#define VSYNCTEARCONTROL_STRING L"Vertical Sync Tear Control" + +enum ESetting { + OGL_AA_LINE_GAMMA_ID = 0x2089BF6C, + OGL_DEEP_COLOR_SCANOUT_ID = 0x2097C2F6, + OGL_DEFAULT_SWAP_INTERVAL_ID = 0x206A6582, + OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_ID = 0x206C4581, + OGL_DEFAULT_SWAP_INTERVAL_SIGN_ID = 0x20655CFA, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_ID = 0x209DF23E, + OGL_EXTENSION_STRING_VERSION_ID = 0x20FF7493, + OGL_FORCE_BLIT_ID = 0x201F619F, + OGL_FORCE_STEREO_ID = 0x204D9A0C, + OGL_IMPLICIT_GPU_AFFINITY_ID = 0x20D0F3E6, + OGL_MAX_FRAMES_ALLOWED_ID = 0x208E55E3, + OGL_OVERLAY_PIXEL_TYPE_ID = 0x209AE66F, + OGL_OVERLAY_SUPPORT_ID = 0x206C28C4, + OGL_QUALITY_ENHANCEMENTS_ID = 0x20797D6C, + OGL_SINGLE_BACKDEPTH_BUFFER_ID = 0x20A29055, + OGL_SLI_CFR_MODE_ID = 0x20343843, + OGL_SLI_MULTICAST_ID = 0x2092D3BE, + OGL_THREAD_CONTROL_ID = 0x20C1221E, + OGL_TMON_LEVEL_ID = 0x202888C1, + OGL_TRIPLE_BUFFER_ID = 0x20FDD1F9, + AA_BEHAVIOR_FLAGS_ID = 0x10ECDB82, + AA_MODE_ALPHATOCOVERAGE_ID = 0x10FC2D9C, + AA_MODE_GAMMACORRECTION_ID = 0x107D639D, + AA_MODE_METHOD_ID = 0x10D773D2, + AA_MODE_REPLAY_ID = 0x10D48A85, + AA_MODE_SELECTOR_ID = 0x107EFC5B, + AA_MODE_SELECTOR_SLIAA_ID = 0x107AFC5B, + ANISO_MODE_LEVEL_ID = 0x101E61A9, + ANISO_MODE_SELECTOR_ID = 0x10D2BB16, + ANSEL_ALLOW_ID = 0x1035DB89, + ANSEL_ALLOWLISTED_ID = 0x1085DA8A, + ANSEL_ENABLE_ID = 0x1075D972, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_ID = 0x104554B6, + APPLICATION_STEAM_ID_ID = 0x107CDDBC, + BATTERY_BOOST_APP_FPS_ID = 0x10115C8C, + CPL_HIDDEN_PROFILE_ID = 0x106D5CFF, + CUDA_EXCLUDED_GPUS_ID = 0x10354FF8, + D3DOGL_GPU_MAX_POWER_ID = 0x10D1EF29, + EXPORT_PERF_COUNTERS_ID = 0x108F0841, + EXTERNAL_QUIET_MODE_ID = 0x10115C8D, + FRL_FPS_ID = 0x10835002, + FXAA_ALLOW_ID = 0x1034CB89, + FXAA_ENABLE_ID = 0x1074C972, + FXAA_INDICATOR_ENABLE_ID = 0x1068FB9C, + LATENCY_INDICATOR_AUTOALIGN_ID = 0x1095F170, + MCSFRSHOWSPLIT_ID = 0x10287051, + NV_QUALITY_UPSCALING_ID = 0x10444444, + OPTIMUS_MAXAA_ID = 0x10F9DC83, + PHYSXINDICATOR_ID = 0x1094F16F, + PREFERRED_PSTATE_ID = 0x1057EB71, + PREVENT_UI_AF_OVERRIDE_ID = 0x103BCCB5, + SHIM_MAXRES_ID = 0x10F9DC82, + SHIM_MCCOMPAT_ID = 0x10F9DC80, + SHIM_RENDERING_MODE_ID = 0x10F9DC81, + SHIM_RENDERING_OPTIONS_ID = 0x10F9DC84, + SLI_GPU_COUNT_ID = 0x1033DCD1, + SLI_PREDEFINED_GPU_COUNT_ID = 0x1033DCD2, + SLI_PREDEFINED_GPU_COUNT_DX10_ID = 0x1033DCD3, + SLI_PREDEFINED_MODE_ID = 0x1033CEC1, + SLI_PREDEFINED_MODE_DX10_ID = 0x1033CEC2, + SLI_RENDERING_MODE_ID = 0x1033CED1, + VRPRERENDERLIMIT_ID = 0x10111133, + VRRFEATUREINDICATOR_ID = 0x1094F157, + VRROVERLAYINDICATOR_ID = 0x1095F16F, + VRRREQUESTSTATE_ID = 0x1094F1F7, + VRR_APP_OVERRIDE_ID = 0x10A879CF, + VRR_APP_OVERRIDE_REQUEST_STATE_ID = 0x10A879AC, + VRR_MODE_ID = 0x1194F158, + VSYNCSMOOTHAFR_ID = 0x101AE763, + VSYNCVRRCONTROL_ID = 0x10A879CE, + VSYNC_BEHAVIOR_FLAGS_ID = 0x10FDEC23, + WKS_API_STEREO_EYES_EXCHANGE_ID = 0x11AE435C, + WKS_API_STEREO_MODE_ID = 0x11E91A61, + WKS_MEMORY_ALLOCATION_POLICY_ID = 0x11112233, + WKS_STEREO_DONGLE_SUPPORT_ID = 0x112493BD, + WKS_STEREO_SUPPORT_ID = 0x11AA9E99, + WKS_STEREO_SWAP_MODE_ID = 0x11333333, + AO_MODE_ID = 0x00667329, + AO_MODE_ACTIVE_ID = 0x00664339, + AUTO_LODBIASADJUST_ID = 0x00638E8F, + EXPORT_PERF_COUNTERS_DX9_ONLY_ID = 0x00B65E72, + ICAFE_LOGO_CONFIG_ID = 0x00DB1337, + LODBIASADJUST_ID = 0x00738E8F, + MAXWELL_B_SAMPLE_INTERLEAVE_ID = 0x0098C1AC, + PRERENDERLIMIT_ID = 0x007BA09E, + PS_SHADERDISKCACHE_ID = 0x00198FFF, + PS_SHADERDISKCACHE_MAX_SIZE_ID = 0x00AC8497, + PS_TEXFILTER_ANISO_OPTS2_ID = 0x00E73211, + PS_TEXFILTER_BILINEAR_IN_ANISO_ID = 0x0084CD70, + PS_TEXFILTER_DISABLE_TRILIN_SLOPE_ID = 0x002ECAF2, + PS_TEXFILTER_NO_NEG_LODBIAS_ID = 0x0019BB68, + QUALITY_ENHANCEMENTS_ID = 0x00CE2691, + QUALITY_ENHANCEMENT_SUBSTITUTION_ID = 0x00CE2692, + REFRESH_RATE_OVERRIDE_ID = 0x0064B541, + SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_ID = 0x00AE785C, + SET_VAB_DATA_ID = 0x00AB8687, + VSYNCMODE_ID = 0x00A879CF, + VSYNCTEARCONTROL_ID = 0x005A375C, + TOTAL_DWORD_SETTING_NUM = 94, + TOTAL_WSTRING_SETTING_NUM = 4, + TOTAL_SETTING_NUM = 98, + INVALID_SETTING_ID = 0xFFFFFFFF +}; + +enum EValues_OGL_AA_LINE_GAMMA { + OGL_AA_LINE_GAMMA_DISABLED = 0x10, + OGL_AA_LINE_GAMMA_ENABLED = 0x23, + OGL_AA_LINE_GAMMA_MIN = 1, + OGL_AA_LINE_GAMMA_MAX = 100, + OGL_AA_LINE_GAMMA_NUM_VALUES = 4, + OGL_AA_LINE_GAMMA_DEFAULT = OGL_AA_LINE_GAMMA_DISABLED +}; + +enum EValues_OGL_DEEP_COLOR_SCANOUT { + OGL_DEEP_COLOR_SCANOUT_DISABLE = 0, + OGL_DEEP_COLOR_SCANOUT_ENABLE = 1, + OGL_DEEP_COLOR_SCANOUT_NUM_VALUES = 2, + OGL_DEEP_COLOR_SCANOUT_DEFAULT = OGL_DEEP_COLOR_SCANOUT_ENABLE +}; + +enum EValues_OGL_DEFAULT_SWAP_INTERVAL { + OGL_DEFAULT_SWAP_INTERVAL_TEAR = 0, + OGL_DEFAULT_SWAP_INTERVAL_VSYNC_ONE = 1, + OGL_DEFAULT_SWAP_INTERVAL_VSYNC = 1, + OGL_DEFAULT_SWAP_INTERVAL_VALUE_MASK = 0x0000FFFF, + OGL_DEFAULT_SWAP_INTERVAL_FORCE_MASK = 0xF0000000, + OGL_DEFAULT_SWAP_INTERVAL_FORCE_OFF = 0xF0000000, + OGL_DEFAULT_SWAP_INTERVAL_FORCE_ON = 0x10000000, + OGL_DEFAULT_SWAP_INTERVAL_APP_CONTROLLED = 0x00000000, + OGL_DEFAULT_SWAP_INTERVAL_DISABLE = 0xffffffff, + OGL_DEFAULT_SWAP_INTERVAL_NUM_VALUES = 9, + OGL_DEFAULT_SWAP_INTERVAL_DEFAULT = OGL_DEFAULT_SWAP_INTERVAL_VSYNC_ONE +}; + +enum EValues_OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL { + OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_ZERO_SCANLINES = 0, + OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_ONE_FULL_FRAME_OF_SCANLINES = 100, + OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_NUM_VALUES = 2, + OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_DEFAULT = 0U +}; + +enum EValues_OGL_DEFAULT_SWAP_INTERVAL_SIGN { + OGL_DEFAULT_SWAP_INTERVAL_SIGN_POSITIVE = 0, + OGL_DEFAULT_SWAP_INTERVAL_SIGN_NEGATIVE = 1, + OGL_DEFAULT_SWAP_INTERVAL_SIGN_NUM_VALUES = 2, + OGL_DEFAULT_SWAP_INTERVAL_SIGN_DEFAULT = OGL_DEFAULT_SWAP_INTERVAL_SIGN_POSITIVE +}; + +enum EValues_OGL_EVENT_LOG_SEVERITY_THRESHOLD { + OGL_EVENT_LOG_SEVERITY_THRESHOLD_DISABLE = 0, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_CRITICAL = 1, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_WARNING = 2, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_INFORMATION = 3, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_ALL = 4, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_NUM_VALUES = 5, + OGL_EVENT_LOG_SEVERITY_THRESHOLD_DEFAULT = OGL_EVENT_LOG_SEVERITY_THRESHOLD_ALL +}; + +enum EValues_OGL_FORCE_BLIT { + OGL_FORCE_BLIT_ON = 1, + OGL_FORCE_BLIT_OFF = 0, + OGL_FORCE_BLIT_NUM_VALUES = 2, + OGL_FORCE_BLIT_DEFAULT = OGL_FORCE_BLIT_OFF +}; + +enum EValues_OGL_FORCE_STEREO { + OGL_FORCE_STEREO_OFF = 0, + OGL_FORCE_STEREO_ON = 1, + OGL_FORCE_STEREO_NUM_VALUES = 2, + OGL_FORCE_STEREO_DEFAULT = OGL_FORCE_STEREO_OFF +}; + +#define OGL_IMPLICIT_GPU_AFFINITY_ENV_VAR L"OGL_DEFAULT_RENDERING_GPU" +#define OGL_IMPLICIT_GPU_AFFINITY_AUTOSELECT L"autoselect" +#define OGL_IMPLICIT_GPU_AFFINITY_NUM_VALUES 1 +#define OGL_IMPLICIT_GPU_AFFINITY_DEFAULT OGL_IMPLICIT_GPU_AFFINITY_AUTOSELECT + +enum EValues_OGL_OVERLAY_PIXEL_TYPE { + OGL_OVERLAY_PIXEL_TYPE_NONE = 0x0, + OGL_OVERLAY_PIXEL_TYPE_CI = 0x1, + OGL_OVERLAY_PIXEL_TYPE_RGBA = 0x2, + OGL_OVERLAY_PIXEL_TYPE_CI_AND_RGBA = 0x3, + OGL_OVERLAY_PIXEL_TYPE_NUM_VALUES = 4, + OGL_OVERLAY_PIXEL_TYPE_DEFAULT = OGL_OVERLAY_PIXEL_TYPE_CI +}; + +enum EValues_OGL_OVERLAY_SUPPORT { + OGL_OVERLAY_SUPPORT_OFF = 0, + OGL_OVERLAY_SUPPORT_ON = 1, + OGL_OVERLAY_SUPPORT_FORCE_SW = 2, + OGL_OVERLAY_SUPPORT_NUM_VALUES = 3, + OGL_OVERLAY_SUPPORT_DEFAULT = OGL_OVERLAY_SUPPORT_OFF +}; + +enum EValues_OGL_QUALITY_ENHANCEMENTS { + OGL_QUALITY_ENHANCEMENTS_HQUAL = 0xfffffff6, + OGL_QUALITY_ENHANCEMENTS_QUAL = 0, + OGL_QUALITY_ENHANCEMENTS_PERF = 10, + OGL_QUALITY_ENHANCEMENTS_HPERF = 20, + OGL_QUALITY_ENHANCEMENTS_NUM_VALUES = 4, + OGL_QUALITY_ENHANCEMENTS_DEFAULT = OGL_QUALITY_ENHANCEMENTS_QUAL +}; + +enum EValues_OGL_SINGLE_BACKDEPTH_BUFFER { + OGL_SINGLE_BACKDEPTH_BUFFER_DISABLE = 0x0, + OGL_SINGLE_BACKDEPTH_BUFFER_ENABLE = 0x1, + OGL_SINGLE_BACKDEPTH_BUFFER_USE_HW_DEFAULT = 0xffffffff, + OGL_SINGLE_BACKDEPTH_BUFFER_NUM_VALUES = 3, + OGL_SINGLE_BACKDEPTH_BUFFER_DEFAULT = OGL_SINGLE_BACKDEPTH_BUFFER_DISABLE +}; + +enum EValues_OGL_SLI_CFR_MODE { + OGL_SLI_CFR_MODE_DISABLE = 0x00, + OGL_SLI_CFR_MODE_ENABLE = 0x01, + OGL_SLI_CFR_MODE_CLASSIC_SFR = 0x02, + OGL_SLI_CFR_MODE_NUM_VALUES = 3, + OGL_SLI_CFR_MODE_DEFAULT = OGL_SLI_CFR_MODE_DISABLE +}; + +enum EValues_OGL_SLI_MULTICAST { + OGL_SLI_MULTICAST_DISABLE = 0x00, + OGL_SLI_MULTICAST_ENABLE = 0x01, + OGL_SLI_MULTICAST_FORCE_DISABLE = 0x02, + OGL_SLI_MULTICAST_ALLOW_MOSAIC = 0x04, + OGL_SLI_MULTICAST_NUM_VALUES = 4, + OGL_SLI_MULTICAST_DEFAULT = OGL_SLI_MULTICAST_DISABLE +}; + +enum EValues_OGL_THREAD_CONTROL { + OGL_THREAD_CONTROL_ENABLE = 0x00000001, + OGL_THREAD_CONTROL_DISABLE = 0x00000002, + OGL_THREAD_CONTROL_NUM_VALUES = 2, + OGL_THREAD_CONTROL_DEFAULT = 0U +}; + +enum EValues_OGL_TMON_LEVEL { + OGL_TMON_LEVEL_DISABLE = 0, + OGL_TMON_LEVEL_CRITICAL = 1, + OGL_TMON_LEVEL_WARNING = 2, + OGL_TMON_LEVEL_INFORMATION = 3, + OGL_TMON_LEVEL_MOST = 4, + OGL_TMON_LEVEL_VERBOSE = 5, + OGL_TMON_LEVEL_NUM_VALUES = 6, + OGL_TMON_LEVEL_DEFAULT = OGL_TMON_LEVEL_MOST +}; + +enum EValues_OGL_TRIPLE_BUFFER { + OGL_TRIPLE_BUFFER_DISABLED = 0x00000000, + OGL_TRIPLE_BUFFER_ENABLED = 0x00000001, + OGL_TRIPLE_BUFFER_NUM_VALUES = 2, + OGL_TRIPLE_BUFFER_DEFAULT = OGL_TRIPLE_BUFFER_DISABLED +}; + +enum EValues_AA_BEHAVIOR_FLAGS { + AA_BEHAVIOR_FLAGS_NONE = 0x00000000, + AA_BEHAVIOR_FLAGS_TREAT_OVERRIDE_AS_APP_CONTROLLED = 0x00000001, + AA_BEHAVIOR_FLAGS_TREAT_OVERRIDE_AS_ENHANCE = 0x00000002, + AA_BEHAVIOR_FLAGS_DISABLE_OVERRIDE = 0x00000003, + AA_BEHAVIOR_FLAGS_TREAT_ENHANCE_AS_APP_CONTROLLED = 0x00000004, + AA_BEHAVIOR_FLAGS_TREAT_ENHANCE_AS_OVERRIDE = 0x00000008, + AA_BEHAVIOR_FLAGS_DISABLE_ENHANCE = 0x0000000c, + AA_BEHAVIOR_FLAGS_MAP_VCAA_TO_MULTISAMPLING = 0x00010000, + AA_BEHAVIOR_FLAGS_SLI_DISABLE_TRANSPARENCY_SUPERSAMPLING = 0x00020000, + AA_BEHAVIOR_FLAGS_DISABLE_CPLAA = 0x00040000, + AA_BEHAVIOR_FLAGS_SKIP_RT_DIM_CHECK_FOR_ENHANCE = 0x00080000, + AA_BEHAVIOR_FLAGS_DISABLE_SLIAA = 0x00100000, + AA_BEHAVIOR_FLAGS_DEFAULT = 0x00000000, + AA_BEHAVIOR_FLAGS_AA_RT_BPP_DIV_4 = 0xf0000000, + AA_BEHAVIOR_FLAGS_AA_RT_BPP_DIV_4_SHIFT = 28, + AA_BEHAVIOR_FLAGS_NON_AA_RT_BPP_DIV_4 = 0x0f000000, + AA_BEHAVIOR_FLAGS_NON_AA_RT_BPP_DIV_4_SHIFT = 24, + AA_BEHAVIOR_FLAGS_MASK = 0xff1f000f, + AA_BEHAVIOR_FLAGS_NUM_VALUES = 18, +}; + +enum EValues_AA_MODE_ALPHATOCOVERAGE { + AA_MODE_ALPHATOCOVERAGE_MODE_MASK = 0x00000004, + AA_MODE_ALPHATOCOVERAGE_MODE_OFF = 0x00000000, + AA_MODE_ALPHATOCOVERAGE_MODE_ON = 0x00000004, + AA_MODE_ALPHATOCOVERAGE_MODE_MAX = 0x00000004, + AA_MODE_ALPHATOCOVERAGE_NUM_VALUES = 4, + AA_MODE_ALPHATOCOVERAGE_DEFAULT = 0x00000000 +}; + +enum EValues_AA_MODE_GAMMACORRECTION { + AA_MODE_GAMMACORRECTION_MASK = 0x00000003, + AA_MODE_GAMMACORRECTION_OFF = 0x00000000, + AA_MODE_GAMMACORRECTION_ON_IF_FOS = 0x00000001, + AA_MODE_GAMMACORRECTION_ON_ALWAYS = 0x00000002, + AA_MODE_GAMMACORRECTION_MAX = 0x00000002, + AA_MODE_GAMMACORRECTION_DEFAULT = 0x00000000, + AA_MODE_GAMMACORRECTION_DEFAULT_TESLA = 0x00000002, + AA_MODE_GAMMACORRECTION_DEFAULT_FERMI = 0x00000002, + AA_MODE_GAMMACORRECTION_NUM_VALUES = 8, +}; + +enum EValues_AA_MODE_METHOD { + AA_MODE_METHOD_NONE = 0x0, + AA_MODE_METHOD_SUPERSAMPLE_2X_H = 0x1, + AA_MODE_METHOD_SUPERSAMPLE_2X_V = 0x2, + AA_MODE_METHOD_SUPERSAMPLE_1_5X1_5 = 0x2, + AA_MODE_METHOD_FREE_0x03 = 0x3, + AA_MODE_METHOD_FREE_0x04 = 0x4, + AA_MODE_METHOD_SUPERSAMPLE_4X = 0x5, + AA_MODE_METHOD_SUPERSAMPLE_4X_BIAS = 0x6, + AA_MODE_METHOD_SUPERSAMPLE_4X_GAUSSIAN = 0x7, + AA_MODE_METHOD_FREE_0x08 = 0x8, + AA_MODE_METHOD_FREE_0x09 = 0x9, + AA_MODE_METHOD_SUPERSAMPLE_9X = 0xA, + AA_MODE_METHOD_SUPERSAMPLE_9X_BIAS = 0xB, + AA_MODE_METHOD_SUPERSAMPLE_16X = 0xC, + AA_MODE_METHOD_SUPERSAMPLE_16X_BIAS = 0xD, + AA_MODE_METHOD_MULTISAMPLE_2X_DIAGONAL = 0xE, + AA_MODE_METHOD_MULTISAMPLE_2X_QUINCUNX = 0xF, + AA_MODE_METHOD_MULTISAMPLE_4X = 0x10, + AA_MODE_METHOD_FREE_0x11 = 0x11, + AA_MODE_METHOD_MULTISAMPLE_4X_GAUSSIAN = 0x12, + AA_MODE_METHOD_MIXEDSAMPLE_4X_SKEWED_4TAP = 0x13, + AA_MODE_METHOD_FREE_0x14 = 0x14, + AA_MODE_METHOD_FREE_0x15 = 0x15, + AA_MODE_METHOD_MIXEDSAMPLE_6X = 0x16, + AA_MODE_METHOD_MIXEDSAMPLE_6X_SKEWED_6TAP = 0x17, + AA_MODE_METHOD_MIXEDSAMPLE_8X = 0x18, + AA_MODE_METHOD_MIXEDSAMPLE_8X_SKEWED_8TAP = 0x19, + AA_MODE_METHOD_MIXEDSAMPLE_16X = 0x1a, + AA_MODE_METHOD_MULTISAMPLE_4X_GAMMA = 0x1b, + AA_MODE_METHOD_MULTISAMPLE_16X = 0x1c, + AA_MODE_METHOD_VCAA_32X_8v24 = 0x1d, + AA_MODE_METHOD_CORRUPTION_CHECK = 0x1e, + AA_MODE_METHOD_6X_CT = 0x1f, + AA_MODE_METHOD_MULTISAMPLE_2X_DIAGONAL_GAMMA = 0x20, + AA_MODE_METHOD_SUPERSAMPLE_4X_GAMMA = 0x21, + AA_MODE_METHOD_MULTISAMPLE_4X_FOSGAMMA = 0x22, + AA_MODE_METHOD_MULTISAMPLE_2X_DIAGONAL_FOSGAMMA = 0x23, + AA_MODE_METHOD_SUPERSAMPLE_4X_FOSGAMMA = 0x24, + AA_MODE_METHOD_MULTISAMPLE_8X = 0x25, + AA_MODE_METHOD_VCAA_8X_4v4 = 0x26, + AA_MODE_METHOD_VCAA_16X_4v12 = 0x27, + AA_MODE_METHOD_VCAA_16X_8v8 = 0x28, + AA_MODE_METHOD_MIXEDSAMPLE_32X = 0x29, + AA_MODE_METHOD_SUPERVCAA_64X_4v12 = 0x2a, + AA_MODE_METHOD_SUPERVCAA_64X_8v8 = 0x2b, + AA_MODE_METHOD_MIXEDSAMPLE_64X = 0x2c, + AA_MODE_METHOD_MIXEDSAMPLE_128X = 0x2d, + AA_MODE_METHOD_COUNT = 0x2e, + AA_MODE_METHOD_METHOD_MASK = 0x0000ffff, + AA_MODE_METHOD_METHOD_MAX = 0xf1c57815, + AA_MODE_METHOD_NUM_VALUES = 50, + AA_MODE_METHOD_DEFAULT = AA_MODE_METHOD_NONE +}; + +enum EValues_AA_MODE_REPLAY { + AA_MODE_REPLAY_SAMPLES_MASK = 0x00000070, + AA_MODE_REPLAY_SAMPLES_ONE = 0x00000000, + AA_MODE_REPLAY_SAMPLES_TWO = 0x00000010, + AA_MODE_REPLAY_SAMPLES_FOUR = 0x00000020, + AA_MODE_REPLAY_SAMPLES_EIGHT = 0x00000030, + AA_MODE_REPLAY_SAMPLES_MAX = 0x00000030, + AA_MODE_REPLAY_MODE_MASK = 0x0000000f, + AA_MODE_REPLAY_MODE_OFF = 0x00000000, + AA_MODE_REPLAY_MODE_ALPHA_TEST = 0x00000001, + AA_MODE_REPLAY_MODE_PIXEL_KILL = 0x00000002, + AA_MODE_REPLAY_MODE_DYN_BRANCH = 0x00000004, + AA_MODE_REPLAY_MODE_OPTIMAL = 0x00000004, + AA_MODE_REPLAY_MODE_ALL = 0x00000008, + AA_MODE_REPLAY_MODE_MAX = 0x0000000f, + AA_MODE_REPLAY_TRANSPARENCY = 0x00000023, + AA_MODE_REPLAY_DISALLOW_TRAA = 0x00000100, + AA_MODE_REPLAY_TRANSPARENCY_DEFAULT = 0x00000000, + AA_MODE_REPLAY_TRANSPARENCY_DEFAULT_TESLA = 0x00000000, + AA_MODE_REPLAY_TRANSPARENCY_DEFAULT_FERMI = 0x00000000, + AA_MODE_REPLAY_MASK = 0x0000017f, + AA_MODE_REPLAY_NUM_VALUES = 20, + AA_MODE_REPLAY_DEFAULT = 0x00000000 +}; + +enum EValues_AA_MODE_SELECTOR { + AA_MODE_SELECTOR_MASK = 0x00000003, + AA_MODE_SELECTOR_APP_CONTROL = 0x00000000, + AA_MODE_SELECTOR_OVERRIDE = 0x00000001, + AA_MODE_SELECTOR_ENHANCE = 0x00000002, + AA_MODE_SELECTOR_MAX = 0x00000002, + AA_MODE_SELECTOR_NUM_VALUES = 5, + AA_MODE_SELECTOR_DEFAULT = AA_MODE_SELECTOR_APP_CONTROL +}; + +enum EValues_AA_MODE_SELECTOR_SLIAA { + AA_MODE_SELECTOR_SLIAA_DISABLED = 0, + AA_MODE_SELECTOR_SLIAA_ENABLED = 1, + AA_MODE_SELECTOR_SLIAA_NUM_VALUES = 2, + AA_MODE_SELECTOR_SLIAA_DEFAULT = AA_MODE_SELECTOR_SLIAA_DISABLED +}; + +enum EValues_ANISO_MODE_LEVEL { + ANISO_MODE_LEVEL_MASK = 0x0000ffff, + ANISO_MODE_LEVEL_NONE_POINT = 0x00000000, + ANISO_MODE_LEVEL_NONE_LINEAR = 0x00000001, + ANISO_MODE_LEVEL_MAX = 0x00000010, + ANISO_MODE_LEVEL_DEFAULT = 0x00000001, + ANISO_MODE_LEVEL_NUM_VALUES = 5, +}; + +enum EValues_ANISO_MODE_SELECTOR { + ANISO_MODE_SELECTOR_MASK = 0x0000000f, + ANISO_MODE_SELECTOR_APP = 0x00000000, + ANISO_MODE_SELECTOR_USER = 0x00000001, + ANISO_MODE_SELECTOR_COND = 0x00000002, + ANISO_MODE_SELECTOR_MAX = 0x00000002, + ANISO_MODE_SELECTOR_DEFAULT = 0x00000000, + ANISO_MODE_SELECTOR_NUM_VALUES = 6, +}; + +enum EValues_ANSEL_ALLOW { + ANSEL_ALLOW_DISALLOWED = 0, + ANSEL_ALLOW_ALLOWED = 1, + ANSEL_ALLOW_NUM_VALUES = 2, + ANSEL_ALLOW_DEFAULT = ANSEL_ALLOW_ALLOWED +}; + +enum EValues_ANSEL_ALLOWLISTED { + ANSEL_ALLOWLISTED_DISALLOWED = 0, + ANSEL_ALLOWLISTED_ALLOWED = 1, + ANSEL_ALLOWLISTED_NUM_VALUES = 2, + ANSEL_ALLOWLISTED_DEFAULT = ANSEL_ALLOWLISTED_DISALLOWED +}; + +enum EValues_ANSEL_ENABLE { + ANSEL_ENABLE_OFF = 0, + ANSEL_ENABLE_ON = 1, + ANSEL_ENABLE_NUM_VALUES = 2, + ANSEL_ENABLE_DEFAULT = ANSEL_ENABLE_ON +}; + +enum EValues_APPLICATION_PROFILE_NOTIFICATION_TIMEOUT { + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_DISABLED = 0, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_NINE_SECONDS = 9, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_FIFTEEN_SECONDS = 15, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_THIRTY_SECONDS = 30, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_ONE_MINUTE = 60, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_TWO_MINUTES = 120, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_NUM_VALUES = 6, + APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_DEFAULT = APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_DISABLED +}; + +enum EValues_BATTERY_BOOST_APP_FPS { + BATTERY_BOOST_APP_FPS_MIN = 0x00000001, + BATTERY_BOOST_APP_FPS_MAX = 0x000003ff, + BATTERY_BOOST_APP_FPS_NO_OVERRIDE = 0x00000000, + BATTERY_BOOST_APP_FPS_NUM_VALUES = 3, + BATTERY_BOOST_APP_FPS_DEFAULT = BATTERY_BOOST_APP_FPS_NO_OVERRIDE +}; + +enum EValues_CPL_HIDDEN_PROFILE { + CPL_HIDDEN_PROFILE_DISABLED = 0, + CPL_HIDDEN_PROFILE_ENABLED = 1, + CPL_HIDDEN_PROFILE_NUM_VALUES = 2, + CPL_HIDDEN_PROFILE_DEFAULT = CPL_HIDDEN_PROFILE_DISABLED +}; + +#define CUDA_EXCLUDED_GPUS_NONE L"none" +#define CUDA_EXCLUDED_GPUS_NUM_VALUES 1 +#define CUDA_EXCLUDED_GPUS_DEFAULT CUDA_EXCLUDED_GPUS_NONE + +#define D3DOGL_GPU_MAX_POWER_DEFAULTPOWER L"0" +#define D3DOGL_GPU_MAX_POWER_NUM_VALUES 1 +#define D3DOGL_GPU_MAX_POWER_DEFAULT D3DOGL_GPU_MAX_POWER_DEFAULTPOWER + +enum EValues_EXPORT_PERF_COUNTERS { + EXPORT_PERF_COUNTERS_OFF = 0x00000000, + EXPORT_PERF_COUNTERS_ON = 0x00000001, + EXPORT_PERF_COUNTERS_NUM_VALUES = 2, + EXPORT_PERF_COUNTERS_DEFAULT = EXPORT_PERF_COUNTERS_OFF +}; + +enum EValues_EXTERNAL_QUIET_MODE { + EXTERNAL_QUIET_MODE_ON = 0x00000001, + EXTERNAL_QUIET_MODE_OFF = 0x00000000, + EXTERNAL_QUIET_MODE_NUM_VALUES = 2, + EXTERNAL_QUIET_MODE_DEFAULT = EXTERNAL_QUIET_MODE_OFF +}; + +enum EValues_FRL_FPS { + FRL_FPS_DISABLED = 0x00000000, + FRL_FPS_MIN = 0x00000000, + FRL_FPS_MAX = 0x000003ff, + FRL_FPS_NUM_VALUES = 3, + FRL_FPS_DEFAULT = FRL_FPS_DISABLED +}; + +enum EValues_FXAA_ALLOW { + FXAA_ALLOW_DISALLOWED = 0, + FXAA_ALLOW_ALLOWED = 1, + FXAA_ALLOW_NUM_VALUES = 2, + FXAA_ALLOW_DEFAULT = FXAA_ALLOW_ALLOWED +}; + +enum EValues_FXAA_ENABLE { + FXAA_ENABLE_OFF = 0, + FXAA_ENABLE_ON = 1, + FXAA_ENABLE_NUM_VALUES = 2, + FXAA_ENABLE_DEFAULT = FXAA_ENABLE_OFF +}; + +enum EValues_FXAA_INDICATOR_ENABLE { + FXAA_INDICATOR_ENABLE_OFF = 0, + FXAA_INDICATOR_ENABLE_ON = 1, + FXAA_INDICATOR_ENABLE_NUM_VALUES = 2, + FXAA_INDICATOR_ENABLE_DEFAULT = FXAA_INDICATOR_ENABLE_OFF +}; + +enum EValues_LATENCY_INDICATOR_AUTOALIGN { + LATENCY_INDICATOR_AUTOALIGN_DISABLED = 0x0, + LATENCY_INDICATOR_AUTOALIGN_ENABLED = 0x1, + LATENCY_INDICATOR_AUTOALIGN_NUM_VALUES = 2, + LATENCY_INDICATOR_AUTOALIGN_DEFAULT = LATENCY_INDICATOR_AUTOALIGN_ENABLED +}; + +enum EValues_MCSFRSHOWSPLIT { + MCSFRSHOWSPLIT_DISABLED = 0x34534064, + MCSFRSHOWSPLIT_ENABLED = 0x24545582, + MCSFRSHOWSPLIT_NUM_VALUES = 2, + MCSFRSHOWSPLIT_DEFAULT = MCSFRSHOWSPLIT_DISABLED +}; + +enum EValues_NV_QUALITY_UPSCALING { + NV_QUALITY_UPSCALING_OFF = 0, + NV_QUALITY_UPSCALING_ON = 1, + NV_QUALITY_UPSCALING_NUM_VALUES = 2, + NV_QUALITY_UPSCALING_DEFAULT = NV_QUALITY_UPSCALING_OFF +}; + +enum EValues_OPTIMUS_MAXAA { + OPTIMUS_MAXAA_MIN = 0, + OPTIMUS_MAXAA_MAX = 16, + OPTIMUS_MAXAA_NUM_VALUES = 2, + OPTIMUS_MAXAA_DEFAULT = 0 +}; + +enum EValues_PHYSXINDICATOR { + PHYSXINDICATOR_DISABLED = 0x34534064, + PHYSXINDICATOR_ENABLED = 0x24545582, + PHYSXINDICATOR_NUM_VALUES = 2, + PHYSXINDICATOR_DEFAULT = PHYSXINDICATOR_DISABLED +}; + +enum EValues_PREFERRED_PSTATE { + PREFERRED_PSTATE_ADAPTIVE = 0x00000000, + PREFERRED_PSTATE_PREFER_MAX = 0x00000001, + PREFERRED_PSTATE_DRIVER_CONTROLLED = 0x00000002, + PREFERRED_PSTATE_PREFER_CONSISTENT_PERFORMANCE = 0x00000003, + PREFERRED_PSTATE_PREFER_MIN = 0x00000004, + PREFERRED_PSTATE_OPTIMAL_POWER = 0x00000005, + PREFERRED_PSTATE_MIN = 0x00000000, + PREFERRED_PSTATE_MAX = 0x00000005, + PREFERRED_PSTATE_NUM_VALUES = 8, + PREFERRED_PSTATE_DEFAULT = PREFERRED_PSTATE_OPTIMAL_POWER +}; + +enum EValues_PREVENT_UI_AF_OVERRIDE { + PREVENT_UI_AF_OVERRIDE_OFF = 0, + PREVENT_UI_AF_OVERRIDE_ON = 1, + PREVENT_UI_AF_OVERRIDE_NUM_VALUES = 2, + PREVENT_UI_AF_OVERRIDE_DEFAULT = PREVENT_UI_AF_OVERRIDE_OFF +}; + +enum EValues_SHIM_MCCOMPAT { + SHIM_MCCOMPAT_INTEGRATED = 0x00000000, + SHIM_MCCOMPAT_ENABLE = 0x00000001, + SHIM_MCCOMPAT_USER_EDITABLE = 0x00000002, + SHIM_MCCOMPAT_MASK = 0x00000003, + SHIM_MCCOMPAT_VIDEO_MASK = 0x00000004, + SHIM_MCCOMPAT_VARYING_BIT = 0x00000008, + SHIM_MCCOMPAT_AUTO_SELECT = 0x00000010, + SHIM_MCCOMPAT_OVERRIDE_BIT = 0x80000000, + SHIM_MCCOMPAT_NUM_VALUES = 8, + SHIM_MCCOMPAT_DEFAULT = SHIM_MCCOMPAT_AUTO_SELECT +}; + +enum EValues_SHIM_RENDERING_MODE { + SHIM_RENDERING_MODE_INTEGRATED = 0x00000000, + SHIM_RENDERING_MODE_ENABLE = 0x00000001, + SHIM_RENDERING_MODE_USER_EDITABLE = 0x00000002, + SHIM_RENDERING_MODE_MASK = 0x00000003, + SHIM_RENDERING_MODE_VIDEO_MASK = 0x00000004, + SHIM_RENDERING_MODE_VARYING_BIT = 0x00000008, + SHIM_RENDERING_MODE_AUTO_SELECT = 0x00000010, + SHIM_RENDERING_MODE_OVERRIDE_BIT = 0x80000000, + SHIM_RENDERING_MODE_NUM_VALUES = 8, + SHIM_RENDERING_MODE_DEFAULT = SHIM_RENDERING_MODE_AUTO_SELECT +}; + +enum EValues_SHIM_RENDERING_OPTIONS { + SHIM_RENDERING_OPTIONS_DEFAULT_RENDERING_MODE = 0x00000000, + SHIM_RENDERING_OPTIONS_DISABLE_ASYNC_PRESENT = 0x00000001, + SHIM_RENDERING_OPTIONS_EHSHELL_DETECT = 0x00000002, + SHIM_RENDERING_OPTIONS_FLASHPLAYER_HOST_DETECT = 0x00000004, + SHIM_RENDERING_OPTIONS_VIDEO_DRM_APP_DETECT = 0x00000008, + SHIM_RENDERING_OPTIONS_IGNORE_OVERRIDES = 0x00000010, + SHIM_RENDERING_OPTIONS_RESERVED1 = 0x00000020, + SHIM_RENDERING_OPTIONS_ENABLE_DWM_ASYNC_PRESENT = 0x00000040, + SHIM_RENDERING_OPTIONS_RESERVED2 = 0x00000080, + SHIM_RENDERING_OPTIONS_ALLOW_INHERITANCE = 0x00000100, + SHIM_RENDERING_OPTIONS_DISABLE_WRAPPERS = 0x00000200, + SHIM_RENDERING_OPTIONS_DISABLE_DXGI_WRAPPERS = 0x00000400, + SHIM_RENDERING_OPTIONS_PRUNE_UNSUPPORTED_FORMATS = 0x00000800, + SHIM_RENDERING_OPTIONS_ENABLE_ALPHA_FORMAT = 0x00001000, + SHIM_RENDERING_OPTIONS_IGPU_TRANSCODING = 0x00002000, + SHIM_RENDERING_OPTIONS_DISABLE_CUDA = 0x00004000, + SHIM_RENDERING_OPTIONS_ALLOW_CP_CAPS_FOR_VIDEO = 0x00008000, + SHIM_RENDERING_OPTIONS_IGPU_TRANSCODING_FWD_OPTIMUS = 0x00010000, + SHIM_RENDERING_OPTIONS_DISABLE_DURING_SECURE_BOOT = 0x00020000, + SHIM_RENDERING_OPTIONS_INVERT_FOR_QUADRO = 0x00040000, + SHIM_RENDERING_OPTIONS_INVERT_FOR_MSHYBRID = 0x00080000, + SHIM_RENDERING_OPTIONS_REGISTER_PROCESS_ENABLE_GOLD = 0x00100000, + SHIM_RENDERING_OPTIONS_HANDLE_WINDOWED_MODE_PERF_OPT = 0x00200000, + SHIM_RENDERING_OPTIONS_HANDLE_WIN7_ASYNC_RUNTIME_BUG = 0x00400000, + SHIM_RENDERING_OPTIONS_EXPLICIT_ADAPTER_OPTED_BY_APP = 0x00800000, + SHIM_RENDERING_OPTIONS_ALLOW_DYNAMIC_DISPLAY_MUX_SWITCH = 0x01000000, + SHIM_RENDERING_OPTIONS_DISALLOW_DYNAMIC_DISPLAY_MUX_SWITCH = 0x02000000, + SHIM_RENDERING_OPTIONS_DISABLE_TURING_POWER_POLICY = 0x04000000, + SHIM_RENDERING_OPTIONS_NUM_VALUES = 28, + SHIM_RENDERING_OPTIONS_DEFAULT = 0x00000000 +}; + +enum EValues_SLI_GPU_COUNT { + SLI_GPU_COUNT_AUTOSELECT = 0x00000000, + SLI_GPU_COUNT_ONE = 0x00000001, + SLI_GPU_COUNT_TWO = 0x00000002, + SLI_GPU_COUNT_THREE = 0x00000003, + SLI_GPU_COUNT_FOUR = 0x00000004, + SLI_GPU_COUNT_NUM_VALUES = 5, + SLI_GPU_COUNT_DEFAULT = SLI_GPU_COUNT_AUTOSELECT +}; + +enum EValues_SLI_PREDEFINED_GPU_COUNT { + SLI_PREDEFINED_GPU_COUNT_AUTOSELECT = 0x00000000, + SLI_PREDEFINED_GPU_COUNT_ONE = 0x00000001, + SLI_PREDEFINED_GPU_COUNT_TWO = 0x00000002, + SLI_PREDEFINED_GPU_COUNT_THREE = 0x00000003, + SLI_PREDEFINED_GPU_COUNT_FOUR = 0x00000004, + SLI_PREDEFINED_GPU_COUNT_NUM_VALUES = 5, + SLI_PREDEFINED_GPU_COUNT_DEFAULT = SLI_PREDEFINED_GPU_COUNT_AUTOSELECT +}; + +enum EValues_SLI_PREDEFINED_GPU_COUNT_DX10 { + SLI_PREDEFINED_GPU_COUNT_DX10_AUTOSELECT = 0x00000000, + SLI_PREDEFINED_GPU_COUNT_DX10_ONE = 0x00000001, + SLI_PREDEFINED_GPU_COUNT_DX10_TWO = 0x00000002, + SLI_PREDEFINED_GPU_COUNT_DX10_THREE = 0x00000003, + SLI_PREDEFINED_GPU_COUNT_DX10_FOUR = 0x00000004, + SLI_PREDEFINED_GPU_COUNT_DX10_NUM_VALUES = 5, + SLI_PREDEFINED_GPU_COUNT_DX10_DEFAULT = SLI_PREDEFINED_GPU_COUNT_DX10_AUTOSELECT +}; + +enum EValues_SLI_PREDEFINED_MODE { + SLI_PREDEFINED_MODE_AUTOSELECT = 0x00000000, + SLI_PREDEFINED_MODE_FORCE_SINGLE = 0x00000001, + SLI_PREDEFINED_MODE_FORCE_AFR = 0x00000002, + SLI_PREDEFINED_MODE_FORCE_AFR2 = 0x00000003, + SLI_PREDEFINED_MODE_FORCE_SFR = 0x00000004, + SLI_PREDEFINED_MODE_FORCE_AFR_OF_SFR__FALLBACK_3AFR = 0x00000005, + SLI_PREDEFINED_MODE_NUM_VALUES = 6, + SLI_PREDEFINED_MODE_DEFAULT = SLI_PREDEFINED_MODE_AUTOSELECT +}; + +enum EValues_SLI_PREDEFINED_MODE_DX10 { + SLI_PREDEFINED_MODE_DX10_AUTOSELECT = 0x00000000, + SLI_PREDEFINED_MODE_DX10_FORCE_SINGLE = 0x00000001, + SLI_PREDEFINED_MODE_DX10_FORCE_AFR = 0x00000002, + SLI_PREDEFINED_MODE_DX10_FORCE_AFR2 = 0x00000003, + SLI_PREDEFINED_MODE_DX10_FORCE_SFR = 0x00000004, + SLI_PREDEFINED_MODE_DX10_FORCE_AFR_OF_SFR__FALLBACK_3AFR = 0x00000005, + SLI_PREDEFINED_MODE_DX10_NUM_VALUES = 6, + SLI_PREDEFINED_MODE_DX10_DEFAULT = SLI_PREDEFINED_MODE_DX10_AUTOSELECT +}; + +enum EValues_SLI_RENDERING_MODE { + SLI_RENDERING_MODE_AUTOSELECT = 0x00000000, + SLI_RENDERING_MODE_FORCE_SINGLE = 0x00000001, + SLI_RENDERING_MODE_FORCE_AFR = 0x00000002, + SLI_RENDERING_MODE_FORCE_AFR2 = 0x00000003, + SLI_RENDERING_MODE_FORCE_SFR = 0x00000004, + SLI_RENDERING_MODE_FORCE_AFR_OF_SFR__FALLBACK_3AFR = 0x00000005, + SLI_RENDERING_MODE_NUM_VALUES = 6, + SLI_RENDERING_MODE_DEFAULT = SLI_RENDERING_MODE_AUTOSELECT +}; + +enum EValues_VRPRERENDERLIMIT { + VRPRERENDERLIMIT_MIN = 0x00, + VRPRERENDERLIMIT_MAX = 0xff, + VRPRERENDERLIMIT_APP_CONTROLLED = 0x00, + VRPRERENDERLIMIT_DEFAULT = 0x01, + VRPRERENDERLIMIT_NUM_VALUES = 4, +}; + +enum EValues_VRRFEATUREINDICATOR { + VRRFEATUREINDICATOR_DISABLED = 0x0, + VRRFEATUREINDICATOR_ENABLED = 0x1, + VRRFEATUREINDICATOR_NUM_VALUES = 2, + VRRFEATUREINDICATOR_DEFAULT = VRRFEATUREINDICATOR_ENABLED +}; + +enum EValues_VRROVERLAYINDICATOR { + VRROVERLAYINDICATOR_DISABLED = 0x0, + VRROVERLAYINDICATOR_ENABLED = 0x1, + VRROVERLAYINDICATOR_NUM_VALUES = 2, + VRROVERLAYINDICATOR_DEFAULT = VRROVERLAYINDICATOR_ENABLED +}; + +enum EValues_VRRREQUESTSTATE { + VRRREQUESTSTATE_DISABLED = 0x0, + VRRREQUESTSTATE_FULLSCREEN_ONLY = 0x1, + VRRREQUESTSTATE_FULLSCREEN_AND_WINDOWED = 0x2, + VRRREQUESTSTATE_NUM_VALUES = 3, + VRRREQUESTSTATE_DEFAULT = VRRREQUESTSTATE_FULLSCREEN_ONLY +}; + +enum EValues_VRR_APP_OVERRIDE { + VRR_APP_OVERRIDE_ALLOW = 0, + VRR_APP_OVERRIDE_FORCE_OFF = 1, + VRR_APP_OVERRIDE_DISALLOW = 2, + VRR_APP_OVERRIDE_ULMB = 3, + VRR_APP_OVERRIDE_FIXED_REFRESH = 4, + VRR_APP_OVERRIDE_NUM_VALUES = 5, + VRR_APP_OVERRIDE_DEFAULT = VRR_APP_OVERRIDE_ALLOW +}; + +enum EValues_VRR_APP_OVERRIDE_REQUEST_STATE { + VRR_APP_OVERRIDE_REQUEST_STATE_ALLOW = 0, + VRR_APP_OVERRIDE_REQUEST_STATE_FORCE_OFF = 1, + VRR_APP_OVERRIDE_REQUEST_STATE_DISALLOW = 2, + VRR_APP_OVERRIDE_REQUEST_STATE_ULMB = 3, + VRR_APP_OVERRIDE_REQUEST_STATE_FIXED_REFRESH = 4, + VRR_APP_OVERRIDE_REQUEST_STATE_NUM_VALUES = 5, + VRR_APP_OVERRIDE_REQUEST_STATE_DEFAULT = VRR_APP_OVERRIDE_REQUEST_STATE_ALLOW +}; + +enum EValues_VRR_MODE { + VRR_MODE_DISABLED = 0x0, + VRR_MODE_FULLSCREEN_ONLY = 0x1, + VRR_MODE_FULLSCREEN_AND_WINDOWED = 0x2, + VRR_MODE_NUM_VALUES = 3, + VRR_MODE_DEFAULT = VRR_MODE_FULLSCREEN_ONLY +}; + +enum EValues_VSYNCSMOOTHAFR { + VSYNCSMOOTHAFR_OFF = 0x00000000, + VSYNCSMOOTHAFR_ON = 0x00000001, + VSYNCSMOOTHAFR_NUM_VALUES = 2, + VSYNCSMOOTHAFR_DEFAULT = VSYNCSMOOTHAFR_OFF +}; + +enum EValues_VSYNCVRRCONTROL { + VSYNCVRRCONTROL_DISABLE = 0x00000000, + VSYNCVRRCONTROL_ENABLE = 0x00000001, + VSYNCVRRCONTROL_NOTSUPPORTED = 0x9f95128e, + VSYNCVRRCONTROL_NUM_VALUES = 3, + VSYNCVRRCONTROL_DEFAULT = VSYNCVRRCONTROL_ENABLE +}; + +enum EValues_VSYNC_BEHAVIOR_FLAGS { + VSYNC_BEHAVIOR_FLAGS_NONE = 0x00000000, + VSYNC_BEHAVIOR_FLAGS_DEFAULT = 0x00000000, + VSYNC_BEHAVIOR_FLAGS_IGNORE_FLIPINTERVAL_MULTIPLE = 0x00000001, + VSYNC_BEHAVIOR_FLAGS_NUM_VALUES = 3, +}; + +enum EValues_WKS_API_STEREO_EYES_EXCHANGE { + WKS_API_STEREO_EYES_EXCHANGE_OFF = 0, + WKS_API_STEREO_EYES_EXCHANGE_ON = 1, + WKS_API_STEREO_EYES_EXCHANGE_NUM_VALUES = 2, + WKS_API_STEREO_EYES_EXCHANGE_DEFAULT = WKS_API_STEREO_EYES_EXCHANGE_OFF +}; + +enum EValues_WKS_API_STEREO_MODE { + WKS_API_STEREO_MODE_SHUTTER_GLASSES = 0, + WKS_API_STEREO_MODE_VERTICAL_INTERLACED = 1, + WKS_API_STEREO_MODE_TWINVIEW = 2, + WKS_API_STEREO_MODE_NV17_SHUTTER_GLASSES_AUTO = 3, + WKS_API_STEREO_MODE_NV17_SHUTTER_GLASSES_DAC0 = 4, + WKS_API_STEREO_MODE_NV17_SHUTTER_GLASSES_DAC1 = 5, + WKS_API_STEREO_MODE_COLOR_LINE = 6, + WKS_API_STEREO_MODE_COLOR_INTERLEAVED = 7, + WKS_API_STEREO_MODE_ANAGLYPH = 8, + WKS_API_STEREO_MODE_HORIZONTAL_INTERLACED = 9, + WKS_API_STEREO_MODE_SIDE_FIELD = 10, + WKS_API_STEREO_MODE_SUB_FIELD = 11, + WKS_API_STEREO_MODE_CHECKERBOARD = 12, + WKS_API_STEREO_MODE_INVERSE_CHECKERBOARD = 13, + WKS_API_STEREO_MODE_TRIDELITY_SL = 14, + WKS_API_STEREO_MODE_TRIDELITY_MV = 15, + WKS_API_STEREO_MODE_SEEFRONT = 16, + WKS_API_STEREO_MODE_STEREO_MIRROR = 17, + WKS_API_STEREO_MODE_FRAME_SEQUENTIAL = 18, + WKS_API_STEREO_MODE_AUTODETECT_PASSIVE_MODE = 19, + WKS_API_STEREO_MODE_AEGIS_DT_FRAME_SEQUENTIAL = 20, + WKS_API_STEREO_MODE_OEM_EMITTER_FRAME_SEQUENTIAL = 21, + WKS_API_STEREO_MODE_DP_INBAND = 22, + WKS_API_STEREO_MODE_USE_HW_DEFAULT = 0xffffffff, + WKS_API_STEREO_MODE_DEFAULT_GL = 3, + WKS_API_STEREO_MODE_NUM_VALUES = 25, + WKS_API_STEREO_MODE_DEFAULT = WKS_API_STEREO_MODE_SHUTTER_GLASSES +}; + +enum EValues_WKS_MEMORY_ALLOCATION_POLICY { + WKS_MEMORY_ALLOCATION_POLICY_AS_NEEDED = 0x0, + WKS_MEMORY_ALLOCATION_POLICY_MODERATE_PRE_ALLOCATION = 0x1, + WKS_MEMORY_ALLOCATION_POLICY_AGGRESSIVE_PRE_ALLOCATION = 0x2, + WKS_MEMORY_ALLOCATION_POLICY_NUM_VALUES = 3, + WKS_MEMORY_ALLOCATION_POLICY_DEFAULT = WKS_MEMORY_ALLOCATION_POLICY_AS_NEEDED +}; + +enum EValues_WKS_STEREO_DONGLE_SUPPORT { + WKS_STEREO_DONGLE_SUPPORT_OFF = 0, + WKS_STEREO_DONGLE_SUPPORT_DAC = 1, + WKS_STEREO_DONGLE_SUPPORT_DLP = 2, + WKS_STEREO_DONGLE_SUPPORT_NUM_VALUES = 3, + WKS_STEREO_DONGLE_SUPPORT_DEFAULT = WKS_STEREO_DONGLE_SUPPORT_DAC +}; + +enum EValues_WKS_STEREO_SUPPORT { + WKS_STEREO_SUPPORT_OFF = 0, + WKS_STEREO_SUPPORT_ON = 1, + WKS_STEREO_SUPPORT_NUM_VALUES = 2, + WKS_STEREO_SUPPORT_DEFAULT = WKS_STEREO_SUPPORT_OFF +}; + +enum EValues_WKS_STEREO_SWAP_MODE { + WKS_STEREO_SWAP_MODE_APPLICATION_CONTROL = 0x0, + WKS_STEREO_SWAP_MODE_PER_EYE = 0x1, + WKS_STEREO_SWAP_MODE_PER_EYE_PAIR = 0x2, + WKS_STEREO_SWAP_MODE_LEGACY_BEHAVIOR = 0x3, + WKS_STEREO_SWAP_MODE_PER_EYE_FOR_SWAP_GROUP = 0x4, + WKS_STEREO_SWAP_MODE_NUM_VALUES = 5, + WKS_STEREO_SWAP_MODE_DEFAULT = WKS_STEREO_SWAP_MODE_APPLICATION_CONTROL +}; + +enum EValues_AO_MODE { + AO_MODE_OFF = 0, + AO_MODE_LOW = 1, + AO_MODE_MEDIUM = 2, + AO_MODE_HIGH = 3, + AO_MODE_NUM_VALUES = 4, + AO_MODE_DEFAULT = AO_MODE_OFF +}; + +enum EValues_AO_MODE_ACTIVE { + AO_MODE_ACTIVE_DISABLED = 0, + AO_MODE_ACTIVE_ENABLED = 1, + AO_MODE_ACTIVE_NUM_VALUES = 2, + AO_MODE_ACTIVE_DEFAULT = AO_MODE_ACTIVE_DISABLED +}; + +enum EValues_AUTO_LODBIASADJUST { + AUTO_LODBIASADJUST_OFF = 0x00000000, + AUTO_LODBIASADJUST_ON = 0x00000001, + AUTO_LODBIASADJUST_NUM_VALUES = 2, + AUTO_LODBIASADJUST_DEFAULT = AUTO_LODBIASADJUST_ON +}; + +enum EValues_EXPORT_PERF_COUNTERS_DX9_ONLY { + EXPORT_PERF_COUNTERS_DX9_ONLY_OFF = 0x00000000, + EXPORT_PERF_COUNTERS_DX9_ONLY_ON = 0x00000001, + EXPORT_PERF_COUNTERS_DX9_ONLY_NUM_VALUES = 2, + EXPORT_PERF_COUNTERS_DX9_ONLY_DEFAULT = EXPORT_PERF_COUNTERS_DX9_ONLY_OFF +}; + +enum EValues_LODBIASADJUST { + LODBIASADJUST_MIN = 0xffffff80, + LODBIASADJUST_MAX = 128, + LODBIASADJUST_NUM_VALUES = 2, + LODBIASADJUST_DEFAULT = 0 +}; + +enum EValues_MAXWELL_B_SAMPLE_INTERLEAVE { + MAXWELL_B_SAMPLE_INTERLEAVE_OFF = 0, + MAXWELL_B_SAMPLE_INTERLEAVE_ON = 1, + MAXWELL_B_SAMPLE_INTERLEAVE_NUM_VALUES = 2, + MAXWELL_B_SAMPLE_INTERLEAVE_DEFAULT = MAXWELL_B_SAMPLE_INTERLEAVE_OFF +}; + +enum EValues_PRERENDERLIMIT { + PRERENDERLIMIT_MIN = 0x00, + PRERENDERLIMIT_MAX = 0xff, + PRERENDERLIMIT_APP_CONTROLLED = 0x00, + PRERENDERLIMIT_NUM_VALUES = 3, + PRERENDERLIMIT_DEFAULT = PRERENDERLIMIT_APP_CONTROLLED +}; + +enum EValues_PS_SHADERDISKCACHE { + PS_SHADERDISKCACHE_OFF = 0x00000000, + PS_SHADERDISKCACHE_ON = 0x00000001, + PS_SHADERDISKCACHE_NUM_VALUES = 2, + PS_SHADERDISKCACHE_DEFAULT = PS_SHADERDISKCACHE_ON +}; + +enum EValues_PS_SHADERDISKCACHE_MAX_SIZE { + PS_SHADERDISKCACHE_MAX_SIZE_MIN = 0x0, + PS_SHADERDISKCACHE_MAX_SIZE_MAX = 0xffffffff, + PS_SHADERDISKCACHE_MAX_SIZE_NUM_VALUES = 2, + PS_SHADERDISKCACHE_MAX_SIZE_DEFAULT = 0x1000 +}; + +enum EValues_PS_TEXFILTER_ANISO_OPTS2 { + PS_TEXFILTER_ANISO_OPTS2_OFF = 0x00000000, + PS_TEXFILTER_ANISO_OPTS2_ON = 0x00000001, + PS_TEXFILTER_ANISO_OPTS2_NUM_VALUES = 2, + PS_TEXFILTER_ANISO_OPTS2_DEFAULT = PS_TEXFILTER_ANISO_OPTS2_OFF +}; + +enum EValues_PS_TEXFILTER_BILINEAR_IN_ANISO { + PS_TEXFILTER_BILINEAR_IN_ANISO_OFF = 0x00000000, + PS_TEXFILTER_BILINEAR_IN_ANISO_ON = 0x00000001, + PS_TEXFILTER_BILINEAR_IN_ANISO_NUM_VALUES = 2, + PS_TEXFILTER_BILINEAR_IN_ANISO_DEFAULT = PS_TEXFILTER_BILINEAR_IN_ANISO_OFF +}; + +enum EValues_PS_TEXFILTER_DISABLE_TRILIN_SLOPE { + PS_TEXFILTER_DISABLE_TRILIN_SLOPE_OFF = 0x00000000, + PS_TEXFILTER_DISABLE_TRILIN_SLOPE_ON = 0x00000001, + PS_TEXFILTER_DISABLE_TRILIN_SLOPE_NUM_VALUES = 2, + PS_TEXFILTER_DISABLE_TRILIN_SLOPE_DEFAULT = PS_TEXFILTER_DISABLE_TRILIN_SLOPE_OFF +}; + +enum EValues_PS_TEXFILTER_NO_NEG_LODBIAS { + PS_TEXFILTER_NO_NEG_LODBIAS_OFF = 0x00000000, + PS_TEXFILTER_NO_NEG_LODBIAS_ON = 0x00000001, + PS_TEXFILTER_NO_NEG_LODBIAS_NUM_VALUES = 2, + PS_TEXFILTER_NO_NEG_LODBIAS_DEFAULT = PS_TEXFILTER_NO_NEG_LODBIAS_OFF +}; + +enum EValues_QUALITY_ENHANCEMENTS { + QUALITY_ENHANCEMENTS_HIGHQUALITY = 0xfffffff6, + QUALITY_ENHANCEMENTS_QUALITY = 0x00000000, + QUALITY_ENHANCEMENTS_PERFORMANCE = 0x0000000a, + QUALITY_ENHANCEMENTS_HIGHPERFORMANCE = 0x00000014, + QUALITY_ENHANCEMENTS_NUM_VALUES = 4, + QUALITY_ENHANCEMENTS_DEFAULT = QUALITY_ENHANCEMENTS_QUALITY +}; + +enum EValues_QUALITY_ENHANCEMENT_SUBSTITUTION { + QUALITY_ENHANCEMENT_SUBSTITUTION_NO_SUBSTITUTION = 0x00000000, + QUALITY_ENHANCEMENT_SUBSTITUTION_HIGHQUALITY_BECOMES_QUALITY = 0x00000001, + QUALITY_ENHANCEMENT_SUBSTITUTION_NUM_VALUES = 2, + QUALITY_ENHANCEMENT_SUBSTITUTION_DEFAULT = QUALITY_ENHANCEMENT_SUBSTITUTION_NO_SUBSTITUTION +}; + +enum EValues_REFRESH_RATE_OVERRIDE { + REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED = 0x00000000, + REFRESH_RATE_OVERRIDE_HIGHEST_AVAILABLE = 0x00000001, + REFRESH_RATE_OVERRIDE_LOW_LATENCY_RR_MASK = 0x00000FF0, + REFRESH_RATE_OVERRIDE_NUM_VALUES = 3, + REFRESH_RATE_OVERRIDE_DEFAULT = REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED +}; + +enum EValues_SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE { + SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_OFF = 0x00000000, + SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_ON = 0x00000001, + SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_NUM_VALUES = 2, + SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_DEFAULT = SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_OFF +}; + +enum EValues_SET_VAB_DATA { + SET_VAB_DATA_ZERO = 0x00000000, + SET_VAB_DATA_UINT_ONE = 0x00000001, + SET_VAB_DATA_FLOAT_ONE = 0x3f800000, + SET_VAB_DATA_FLOAT_POS_INF = 0x7f800000, + SET_VAB_DATA_FLOAT_NAN = 0x7fc00000, + SET_VAB_DATA_USE_API_DEFAULTS = 0xffffffff, + SET_VAB_DATA_NUM_VALUES = 6, + SET_VAB_DATA_DEFAULT = SET_VAB_DATA_USE_API_DEFAULTS +}; + +enum EValues_VSYNCMODE { + VSYNCMODE_PASSIVE = 0x60925292, + VSYNCMODE_FORCEOFF = 0x08416747, + VSYNCMODE_FORCEON = 0x47814940, + VSYNCMODE_FLIPINTERVAL2 = 0x32610244, + VSYNCMODE_FLIPINTERVAL3 = 0x71271021, + VSYNCMODE_FLIPINTERVAL4 = 0x13245256, + VSYNCMODE_VIRTUAL = 0x18888888, + VSYNCMODE_NUM_VALUES = 7, + VSYNCMODE_DEFAULT = VSYNCMODE_PASSIVE +}; + +enum EValues_VSYNCTEARCONTROL { + VSYNCTEARCONTROL_DISABLE = 0x96861077, + VSYNCTEARCONTROL_ENABLE = 0x99941284, + VSYNCTEARCONTROL_NUM_VALUES = 2, + VSYNCTEARCONTROL_DEFAULT = VSYNCTEARCONTROL_DISABLE +}; + + + +typedef struct _SettingDWORDNameString { + NvU32 settingId; + const wchar_t * settingNameString; + NvU32 numSettingValues; + NvU32 *settingValues; + NvU32 defaultValue; +} SettingDWORDNameString; + +typedef struct _SettingWSTRINGNameString { + NvU32 settingId; + const wchar_t * settingNameString; + NvU32 numSettingValues; + const wchar_t **settingValues; + const wchar_t * defaultValue; +} SettingWSTRINGNameString; + + +#endif // _NVAPI_DRIVER_SETTINGS_H_ + diff --git a/thirdparty/nvapi/amd64/nvapi64.lib b/thirdparty/nvapi/amd64/nvapi64.lib new file mode 100644 index 0000000..3d6cae6 Binary files /dev/null and b/thirdparty/nvapi/amd64/nvapi64.lib differ diff --git a/thirdparty/nvapi/docs/NVAPI_Public_SDK_R520.pdf b/thirdparty/nvapi/docs/NVAPI_Public_SDK_R520.pdf new file mode 100644 index 0000000..1c307ad Binary files /dev/null and b/thirdparty/nvapi/docs/NVAPI_Public_SDK_R520.pdf differ diff --git a/thirdparty/nvapi/docs/NVAPI_SDKs_Samples_and_Tools_License_Agreement(Public).pdf b/thirdparty/nvapi/docs/NVAPI_SDKs_Samples_and_Tools_License_Agreement(Public).pdf new file mode 100644 index 0000000..081ef3a Binary files /dev/null and b/thirdparty/nvapi/docs/NVAPI_SDKs_Samples_and_Tools_License_Agreement(Public).pdf differ diff --git a/thirdparty/nvapi/nvHLSLExtns.h b/thirdparty/nvapi/nvHLSLExtns.h new file mode 100644 index 0000000..9394036 --- /dev/null +++ b/thirdparty/nvapi/nvHLSLExtns.h @@ -0,0 +1,2206 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + +////////////////////////// NVIDIA SHADER EXTENSIONS ///////////////// + +// this file is to be #included in the app HLSL shader code to make +// use of nvidia shader extensions + + +#include "nvHLSLExtnsInternal.h" + +//----------------------------------------------------------------------------// +//------------------------- Warp Shuffle Functions ---------------------------// +//----------------------------------------------------------------------------// + +// all functions have variants with width parameter which permits sub-division +// of the warp into segments - for example to exchange data between 4 groups of +// 8 lanes in a SIMD manner. If width is less than warpSize then each subsection +// of the warp behaves as a separate entity with a starting logical lane ID of 0. +// A thread may only exchange data with others in its own subsection. Width must +// have a value which is a power of 2 so that the warp can be subdivided equally; +// results are undefined if width is not a power of 2, or is a number greater +// than warpSize. + +// +// simple variant of SHFL instruction +// returns val from the specified lane +// optional width parameter must be a power of two and width <= 32 +// +int NvShfl(int val, uint srcLane, int width = NV_WARP_SIZE) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = val; // variable to be shuffled + g_NvidiaExt[index].src0u.y = srcLane; // source lane + g_NvidiaExt[index].src0u.z = __NvGetShflMaskFromWidth(width); + g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL; + + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +int2 NvShfl(int2 val, uint srcLane, int width = NV_WARP_SIZE) +{ + int x = NvShfl(val.x, srcLane, width); + int y = NvShfl(val.y, srcLane, width); + return int2(x, y); +} + +int4 NvShfl(int4 val, uint srcLane, int width = NV_WARP_SIZE) +{ + int x = NvShfl(val.x, srcLane, width); + int y = NvShfl(val.y, srcLane, width); + int z = NvShfl(val.z, srcLane, width); + int w = NvShfl(val.w, srcLane, width); + return int4(x, y, z, w); +} + +// +// Copy from a lane with lower ID relative to caller +// +int NvShflUp(int val, uint delta, int width = NV_WARP_SIZE) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = val; // variable to be shuffled + g_NvidiaExt[index].src0u.y = delta; // relative lane offset + g_NvidiaExt[index].src0u.z = (NV_WARP_SIZE - width) << 8; // minIndex = maxIndex for shfl_up (src2[4:0] is expected to be 0) + g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_UP; + return g_NvidiaExt.IncrementCounter(); +} + +// +// Copy from a lane with higher ID relative to caller +// +int NvShflDown(int val, uint delta, int width = NV_WARP_SIZE) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = val; // variable to be shuffled + g_NvidiaExt[index].src0u.y = delta; // relative lane offset + g_NvidiaExt[index].src0u.z = __NvGetShflMaskFromWidth(width); + g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_DOWN; + return g_NvidiaExt.IncrementCounter(); +} + +// +// Copy from a lane based on bitwise XOR of own lane ID +// +int NvShflXor(int val, uint laneMask, int width = NV_WARP_SIZE) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = val; // variable to be shuffled + g_NvidiaExt[index].src0u.y = laneMask; // laneMask to be XOR'ed with current laneId to get the source lane id + g_NvidiaExt[index].src0u.z = __NvGetShflMaskFromWidth(width); + g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_XOR; + return g_NvidiaExt.IncrementCounter(); +} + + +//----------------------------------------------------------------------------// +//----------------------------- Warp Vote Functions---------------------------// +//----------------------------------------------------------------------------// + +// returns 0xFFFFFFFF if the predicate is true for any thread in the warp, returns 0 otherwise +uint NvAny(int predicate) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = predicate; + g_NvidiaExt[index].opcode = NV_EXTN_OP_VOTE_ANY; + return g_NvidiaExt.IncrementCounter(); +} + +// returns 0xFFFFFFFF if the predicate is true for ALL threads in the warp, returns 0 otherwise +uint NvAll(int predicate) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = predicate; + g_NvidiaExt[index].opcode = NV_EXTN_OP_VOTE_ALL; + return g_NvidiaExt.IncrementCounter(); +} + +// returns a mask of all threads in the warp with bits set for threads that have predicate true +uint NvBallot(int predicate) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = predicate; + g_NvidiaExt[index].opcode = NV_EXTN_OP_VOTE_BALLOT; + return g_NvidiaExt.IncrementCounter(); +} + + +//----------------------------------------------------------------------------// +//----------------------------- Utility Functions ----------------------------// +//----------------------------------------------------------------------------// + +// returns the lane index of the current thread (thread index in warp) +int NvGetLaneId() +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_GET_LANE_ID; + return g_NvidiaExt.IncrementCounter(); +} + +// returns value of special register - specify subopcode from any of NV_SPECIALOP_* specified in nvShaderExtnEnums.h - other opcodes undefined behavior +uint NvGetSpecial(uint subOpCode) +{ + return __NvGetSpecial(subOpCode); +} + +//----------------------------------------------------------------------------// +//----------------------------- FP16 Atmoic Functions-------------------------// +//----------------------------------------------------------------------------// + +// The functions below performs atomic operations on two consecutive fp16 +// values in the given raw UAV. +// The uint paramater 'fp16x2Val' is treated as two fp16 values byteAddress must be multiple of 4 +// The returned value are the two fp16 values packed into a single uint + +uint NvInterlockedAddFp16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, fp16x2Val, NV_EXTN_ATOM_MAX); +} + + +// versions of the above functions taking two fp32 values (internally converted to fp16 values) +uint NvInterlockedAddFp16x2(RWByteAddressBuffer uav, uint byteAddress, float2 val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWByteAddressBuffer uav, uint byteAddress, float2 val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWByteAddressBuffer uav, uint byteAddress, float2 val) +{ + return __NvAtomicOpFP16x2(uav, byteAddress, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX); +} + + +//----------------------------------------------------------------------------// + +// The functions below perform atomic operation on a R16G16_FLOAT UAV at the given address +// the uint paramater 'fp16x2Val' is treated as two fp16 values +// the returned value are the two fp16 values (.x and .y components) packed into a single uint +// Warning: Behaviour of these set of functions is undefined if the UAV is not +// of R16G16_FLOAT format (might result in app crash or TDR) + +uint NvInterlockedAddFp16x2(RWTexture1D uav, uint address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture1D uav, uint address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture1D uav, uint address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + +uint NvInterlockedAddFp16x2(RWTexture2D uav, uint2 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture2D uav, uint2 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture2D uav, uint2 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + +uint NvInterlockedAddFp16x2(RWTexture3D uav, uint3 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture3D uav, uint3 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture3D uav, uint3 address, uint fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + + +// versions taking two fp32 values (internally converted to fp16) +uint NvInterlockedAddFp16x2(RWTexture1D uav, uint address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture1D uav, uint address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture1D uav, uint address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX); +} + +uint NvInterlockedAddFp16x2(RWTexture2D uav, uint2 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture2D uav, uint2 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture2D uav, uint2 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX); +} + +uint NvInterlockedAddFp16x2(RWTexture3D uav, uint3 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD); +} + +uint NvInterlockedMinFp16x2(RWTexture3D uav, uint3 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN); +} + +uint NvInterlockedMaxFp16x2(RWTexture3D uav, uint3 address, float2 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX); +} + + +//----------------------------------------------------------------------------// + +// The functions below perform Atomic operation on a R16G16B16A16_FLOAT UAV at the given address +// the uint2 paramater 'fp16x2Val' is treated as four fp16 values +// i.e, fp16x2Val.x = uav.xy and fp16x2Val.y = uav.yz +// The returned value are the four fp16 values (.xyzw components) packed into uint2 +// Warning: Behaviour of these set of functions is undefined if the UAV is not +// of R16G16B16A16_FLOAT format (might result in app crash or TDR) + +uint2 NvInterlockedAddFp16x4(RWTexture1D uav, uint address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture1D uav, uint address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture1D uav, uint address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedAddFp16x4(RWTexture2D uav, uint2 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture2D uav, uint2 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture2D uav, uint2 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedAddFp16x4(RWTexture3D uav, uint3 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture3D uav, uint3 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture3D uav, uint3 address, uint2 fp16x2Val) +{ + return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX); +} + +// versions taking four fp32 values (internally converted to fp16) +uint2 NvInterlockedAddFp16x4(RWTexture1D uav, uint address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture1D uav, uint address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture1D uav, uint address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedAddFp16x4(RWTexture2D uav, uint2 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture2D uav, uint2 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture2D uav, uint2 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedAddFp16x4(RWTexture3D uav, uint3 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMinFp16x4(RWTexture3D uav, uint3 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedMaxFp16x4(RWTexture3D uav, uint3 address, float4 val) +{ + return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MAX); +} + + +//----------------------------------------------------------------------------// +//----------------------------- FP32 Atmoic Functions-------------------------// +//----------------------------------------------------------------------------// + +// The functions below performs atomic add on the given UAV treating the value as float +// byteAddress must be multiple of 4 +// The returned value is the value present in memory location before the atomic add + +float NvInterlockedAddFp32(RWByteAddressBuffer uav, uint byteAddress, float val) +{ + return __NvAtomicAddFP32(uav, byteAddress, val); +} + +//----------------------------------------------------------------------------// + +// The functions below perform atomic add on a R32_FLOAT UAV at the given address +// the returned value is the value before performing the atomic add +// Warning: Behaviour of these set of functions is undefined if the UAV is not +// of R32_FLOAT format (might result in app crash or TDR) + +float NvInterlockedAddFp32(RWTexture1D uav, uint address, float val) +{ + return __NvAtomicAddFP32(uav, address, val); +} + +float NvInterlockedAddFp32(RWTexture2D uav, uint2 address, float val) +{ + return __NvAtomicAddFP32(uav, address, val); +} + +float NvInterlockedAddFp32(RWTexture3D uav, uint3 address, float val) +{ + return __NvAtomicAddFP32(uav, address, val); +} + + +//----------------------------------------------------------------------------// +//--------------------------- UINT64 Atmoic Functions-------------------------// +//----------------------------------------------------------------------------// + +// The functions below performs atomic operation on the given UAV treating the value as uint64 +// byteAddress must be multiple of 8 +// The returned value is the value present in memory location before the atomic operation +// uint2 vector type is used to represent a single uint64 value with the x component containing the low 32 bits and y component the high 32 bits. + +uint2 NvInterlockedAddUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMaxUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedMinUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedAndUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_AND); +} + +uint2 NvInterlockedOrUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_OR); +} + +uint2 NvInterlockedXorUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_XOR); +} + +uint2 NvInterlockedCompareExchangeUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 compare_value, uint2 value) +{ + return __NvAtomicCompareExchangeUINT64(uav, byteAddress, compare_value, value); +} + +uint2 NvInterlockedExchangeUint64(RWByteAddressBuffer uav, uint byteAddress, uint2 value) +{ + return __NvAtomicOpUINT64(uav, byteAddress, value, NV_EXTN_ATOM_SWAP); +} + +//----------------------------------------------------------------------------// + +// The functions below perform atomic operation on a R32G32_UINT UAV at the given address treating the value as uint64 +// the returned value is the value before performing the atomic operation +// uint2 vector type is used to represent a single uint64 value with the x component containing the low 32 bits and y component the high 32 bits. +// Warning: Behaviour of these set of functions is undefined if the UAV is not of R32G32_UINT format (might result in app crash or TDR) + +uint2 NvInterlockedAddUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMaxUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedMinUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedAndUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_AND); +} + +uint2 NvInterlockedOrUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_OR); +} + +uint2 NvInterlockedXorUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_XOR); +} + +uint2 NvInterlockedCompareExchangeUint64(RWTexture1D uav, uint address, uint2 compare_value, uint2 value) +{ + return __NvAtomicCompareExchangeUINT64(uav, address, compare_value, value); +} + +uint2 NvInterlockedExchangeUint64(RWTexture1D uav, uint address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_SWAP); +} + +uint2 NvInterlockedAddUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMaxUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedMinUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedAndUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_AND); +} + +uint2 NvInterlockedOrUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_OR); +} + +uint2 NvInterlockedXorUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_XOR); +} + +uint2 NvInterlockedCompareExchangeUint64(RWTexture2D uav, uint2 address, uint2 compare_value, uint2 value) +{ + return __NvAtomicCompareExchangeUINT64(uav, address, compare_value, value); +} + +uint2 NvInterlockedExchangeUint64(RWTexture2D uav, uint2 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_SWAP); +} + +uint2 NvInterlockedAddUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_ADD); +} + +uint2 NvInterlockedMaxUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MAX); +} + +uint2 NvInterlockedMinUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_MIN); +} + +uint2 NvInterlockedAndUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_AND); +} + +uint2 NvInterlockedOrUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_OR); +} + +uint2 NvInterlockedXorUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_XOR); +} + +uint2 NvInterlockedCompareExchangeUint64(RWTexture3D uav, uint3 address, uint2 compare_value, uint2 value) +{ + return __NvAtomicCompareExchangeUINT64(uav, address, compare_value, value); +} + +uint2 NvInterlockedExchangeUint64(RWTexture3D uav, uint3 address, uint2 value) +{ + return __NvAtomicOpUINT64(uav, address, value, NV_EXTN_ATOM_SWAP); +} + +//----------------------------------------------------------------------------// +//--------------------------- VPRS functions ---------------------------------// +//----------------------------------------------------------------------------// + +// Returns the shading rate and the number of per-pixel shading passes for current VPRS pixel +uint3 NvGetShadingRate() +{ + uint3 shadingRate = (uint3)0; + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_GET_SHADING_RATE; + g_NvidiaExt[index].numOutputsForIncCounter = 3; + shadingRate.x = g_NvidiaExt.IncrementCounter(); + shadingRate.y = g_NvidiaExt.IncrementCounter(); + shadingRate.z = g_NvidiaExt.IncrementCounter(); + return shadingRate; +} + +float NvEvaluateAttributeAtSampleForVPRS(float attrib, uint sampleIndex, int2 pixelOffset) +{ + float value = (float)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float2 NvEvaluateAttributeAtSampleForVPRS(float2 attrib, uint sampleIndex, int2 pixelOffset) +{ + float2 value = (float2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float3 NvEvaluateAttributeAtSampleForVPRS(float3 attrib, uint sampleIndex, int2 pixelOffset) +{ + float3 value = (float3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + value.z = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float4 NvEvaluateAttributeAtSampleForVPRS(float4 attrib, uint sampleIndex, int2 pixelOffset) +{ + float4 value = (float4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + value.z = asfloat(g_NvidiaExt.IncrementCounter()); + value.w = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +int NvEvaluateAttributeAtSampleForVPRS(int attrib, uint sampleIndex, int2 pixelOffset) +{ + int value = (int)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int2 NvEvaluateAttributeAtSampleForVPRS(int2 attrib, uint sampleIndex, int2 pixelOffset) +{ + int2 value = (int2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int3 NvEvaluateAttributeAtSampleForVPRS(int3 attrib, uint sampleIndex, int2 pixelOffset) +{ + int3 value = (int3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + value.z = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int4 NvEvaluateAttributeAtSampleForVPRS(int4 attrib, uint sampleIndex, int2 pixelOffset) +{ + int4 value = (int4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + value.z = asint(g_NvidiaExt.IncrementCounter()); + value.w = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint NvEvaluateAttributeAtSampleForVPRS(uint attrib, uint sampleIndex, int2 pixelOffset) +{ + uint value = (uint)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint2 NvEvaluateAttributeAtSampleForVPRS(uint2 attrib, uint sampleIndex, int2 pixelOffset) +{ + uint2 value = (uint2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint3 NvEvaluateAttributeAtSampleForVPRS(uint3 attrib, uint sampleIndex, int2 pixelOffset) +{ + uint3 value = (uint3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + value.z = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint4 NvEvaluateAttributeAtSampleForVPRS(uint4 attrib, uint sampleIndex, int2 pixelOffset) +{ + uint4 value = (uint4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.x = sampleIndex; + g_NvidiaExt[ext].src2u.xy = pixelOffset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + value.z = asuint(g_NvidiaExt.IncrementCounter()); + value.w = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + + +float NvEvaluateAttributeSnappedForVPRS(float attrib, uint2 offset) +{ + float value = (float)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float2 NvEvaluateAttributeSnappedForVPRS(float2 attrib, uint2 offset) +{ + float2 value = (float2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float3 NvEvaluateAttributeSnappedForVPRS(float3 attrib, uint2 offset) +{ + float3 value = (float3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + value.z = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +float4 NvEvaluateAttributeSnappedForVPRS(float4 attrib, uint2 offset) +{ + float4 value = (float4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asfloat(g_NvidiaExt.IncrementCounter()); + value.y = asfloat(g_NvidiaExt.IncrementCounter()); + value.z = asfloat(g_NvidiaExt.IncrementCounter()); + value.w = asfloat(g_NvidiaExt.IncrementCounter()); + return value; +} + +int NvEvaluateAttributeSnappedForVPRS(int attrib, uint2 offset) +{ + int value = (int)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int2 NvEvaluateAttributeSnappedForVPRS(int2 attrib, uint2 offset) +{ + int2 value = (int2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int3 NvEvaluateAttributeSnappedForVPRS(int3 attrib, uint2 offset) +{ + int3 value = (int3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + value.z = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +int4 NvEvaluateAttributeSnappedForVPRS(int4 attrib, uint2 offset) +{ + int4 value = (int4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asint(g_NvidiaExt.IncrementCounter()); + value.y = asint(g_NvidiaExt.IncrementCounter()); + value.z = asint(g_NvidiaExt.IncrementCounter()); + value.w = asint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint NvEvaluateAttributeSnappedForVPRS(uint attrib, uint2 offset) +{ + uint value = (uint)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.x = asuint(attrib.x); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 1; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint2 NvEvaluateAttributeSnappedForVPRS(uint2 attrib, uint2 offset) +{ + uint2 value = (uint2)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xy = asuint(attrib.xy); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 2; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint3 NvEvaluateAttributeSnappedForVPRS(uint3 attrib, uint2 offset) +{ + uint3 value = (uint3)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyz = asuint(attrib.xyz); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 3; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + value.z = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +uint4 NvEvaluateAttributeSnappedForVPRS(uint4 attrib, uint2 offset) +{ + uint4 value = (uint4)0; + uint ext = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[ext].opcode = NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED; + g_NvidiaExt[ext].src0u.xyzw = asuint(attrib.xyzw); + g_NvidiaExt[ext].src1u.xy = offset; + g_NvidiaExt[ext].numOutputsForIncCounter = 4; + value.x = asuint(g_NvidiaExt.IncrementCounter()); + value.y = asuint(g_NvidiaExt.IncrementCounter()); + value.z = asuint(g_NvidiaExt.IncrementCounter()); + value.w = asuint(g_NvidiaExt.IncrementCounter()); + return value; +} + +// MATCH instruction variants +uint NvWaveMatch(uint value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = value; + g_NvidiaExt[index].src1u.x = 1; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +uint NvWaveMatch(uint2 value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = value.xy; + g_NvidiaExt[index].src1u.x = 2; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +uint NvWaveMatch(uint4 value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u = value; + g_NvidiaExt[index].src1u.x = 4; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +uint NvWaveMatch(float value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = asuint(value); + g_NvidiaExt[index].src1u.x = 1; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +uint NvWaveMatch(float2 value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = asuint(value); + g_NvidiaExt[index].src1u.x = 2; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + +uint NvWaveMatch(float4 value) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u = asuint(value); + g_NvidiaExt[index].src1u.x = 4; + g_NvidiaExt[index].opcode = NV_EXTN_OP_MATCH_ANY; + // result is returned as the return value of IncrementCounter on fake UAV slot + return g_NvidiaExt.IncrementCounter(); +} + + +//----------------------------------------------------------------------------// +//------------------------------ Footprint functions -------------------------// +//----------------------------------------------------------------------------// +// texSpace and smpSpace must be immediates, texIndex and smpIndex can be variable +// offset must be immediate +// the required components of location and offset fields can be filled depending on the dimension/type of the texture +// texType should be one of 2D or 3D as defined in nvShaderExtnEnums.h and and should be an immediate literal +// if the above restrictions are not met, the behaviour of this instruction is undefined + +uint4 NvFootprintFine(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprint(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, offset); +} + +uint4 NvFootprintCoarse(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprint(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, offset); +} + + + +uint4 NvFootprintFineBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float bias, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintBias(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, bias, offset); +} + +uint4 NvFootprintCoarseBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float bias, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintBias(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, bias, offset); +} + + + +uint4 NvFootprintFineLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float lodLevel, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintLevel(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, lodLevel, offset); +} + +uint4 NvFootprintCoarseLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float lodLevel, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintLevel(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, lodLevel, offset); +} + + + +uint4 NvFootprintFineGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float3 ddx, float3 ddy, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintGrad(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, ddx, ddy, offset); +} + +uint4 NvFootprintCoarseGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float3 ddx, float3 ddy, int3 offset = int3(0, 0, 0)) +{ + return __NvFootprintGrad(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, ddx, ddy, offset); +} + +uint NvFootprintExtractLOD(uint4 blob) +{ + return ((blob.w & 0xF000) >> 12); +} + +uint NvFootprintExtractReturnGran(uint4 blob) +{ + return ((blob.z & 0xF000000) >> 24); +} + +uint2 NvFootprintExtractAnchorTileLoc2D(uint4 blob) +{ + uint2 loc; + loc.x = (blob.w & 0xFFF); + loc.y = (blob.z & 0xFFF); + return loc; +} + +uint3 NvFootprintExtractAnchorTileLoc3D(uint4 blob) +{ + uint3 loc; + loc.x = (blob.w & 0xFFF); + loc.y = ((blob.w & 0xFFF0000) >> 16); + loc.z = (blob.z & 0x1FFF); + return loc; +} + +uint2 NvFootprintExtractOffset2D(uint4 blob) +{ + uint2 loc; + loc.x = ((blob.z & 0x070000) >> 16); + loc.y = ((blob.z & 0x380000) >> 19); + return loc; +} + +uint3 NvFootprintExtractOffset3D(uint4 blob) +{ + uint3 loc; + loc.x = ((blob.z & 0x030000) >> 16); + loc.y = ((blob.z & 0x0C0000) >> 18); + loc.z = ((blob.z & 0x300000) >> 20); + return loc; +} + +uint2 NvFootprintExtractBitmask(uint4 blob) +{ + return blob.xy; +} + + +// Variant of Footprint extensions which returns isSingleLod (out parameter) +// isSingleLod = true -> This footprint request touched the texels from only single LOD. +uint4 NvFootprintFine(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprint(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + +uint4 NvFootprintCoarse(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprint(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + + + +uint4 NvFootprintFineBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float bias, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintBias(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, bias, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + +uint4 NvFootprintCoarseBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float bias, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintBias(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, bias, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + + + +uint4 NvFootprintFineLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float lodLevel, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintLevel(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, lodLevel, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + +uint4 NvFootprintCoarseLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float lodLevel, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintLevel(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, lodLevel, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + + + +uint4 NvFootprintFineGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float3 ddx, float3 ddy, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintGrad(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_FINE, gran, ddx, ddy, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + +uint4 NvFootprintCoarseGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint gran, float3 ddx, float3 ddy, out uint isSingleLod, int3 offset = int3(0, 0, 0)) +{ + uint4 res = __NvFootprintGrad(texSpace, texIndex, smpSpace, smpIndex, texType, location, NV_EXTN_FOOTPRINT_MODE_COARSE, gran, ddx, ddy, offset); + isSingleLod = __NvGetSpecial(NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED); + return res; +} + + +uint NvActiveThreads() +{ + return NvBallot(1); +} + + +//----------------------------------------------------------------------------// +//------------------------------ WaveMultiPrefix functions -------------------// +//----------------------------------------------------------------------------// + +// Following are the WaveMultiPrefix functions for different operations (Add, Bitand, BitOr, BitXOr) for different datatypes (uint, uint2, uint4) +// This is a set of functions which implement multi-prefix operations among the set of active lanes in the current wave (WARP). +// A multi-prefix operation comprises a set of prefix operations, executed in parallel within subsets of lanes identified with the provided bitmasks. +// These bitmasks represent partitioning of the set of active lanes in the current wave into N groups (where N is the number of unique masks across all lanes in the wave). +// N prefix operations are then performed each within its corresponding group. +// The groups are assumed to be non-intersecting (that is, a given lane can be a member of one and only one group), +// and bitmasks in all lanes belonging to the same group are required to be the same. +// There are 2 type of functions - Exclusive and Inclusive prefix operations. +// e.g. For NvWaveMultiPrefixInclusiveAdd(val, mask) operation - For each of the groups (for which mask input is same) following is the expected output : +// i^th thread in a group has value = sum(values of threads 0 to i) +// For Exclusive version of same opeartion - +// i^th thread in a group has value = sum(values of threads 0 to i-1) and 0th thread in a the Group has value 0 + +// Extensions for Add +uint NvWaveMultiPrefixInclusiveAdd(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + // As remainingThreads only has threads in group with smaller thread ids than its own thread-id nextLane can never be 31 for any thread in the group except the smallest one + // For smallest thread in the group, remainingThreads is 0 --> nextLane is ~0 (i.e. considering last 5 bits its 31) + // So passing maskClampValue=30 to __NvShflGeneric, it will return laneValid=false for the smallest thread in the group. So update val and nextLane based on laneValid. + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val + temp; + nextLane = newLane; + } + } + return val; +} + +uint NvWaveMultiPrefixExclusiveAdd(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : 0; + return NvWaveMultiPrefixInclusiveAdd(val, mask); +} + +uint2 NvWaveMultiPrefixInclusiveAdd(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val + temp; + nextLane = newLane; + } + } + return val; +} + +uint2 NvWaveMultiPrefixExclusiveAdd(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint2(0, 0); + return NvWaveMultiPrefixInclusiveAdd(val, mask); +} + +uint4 NvWaveMultiPrefixInclusiveAdd(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val + temp; + nextLane = newLane; + } + } + return val; +} + +uint4 NvWaveMultiPrefixExclusiveAdd(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint4(0, 0, 0, 0); + return NvWaveMultiPrefixInclusiveAdd(val, mask); +} + +// MultiPrefix extensions for Bitand +uint NvWaveMultiPrefixInclusiveAnd(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val & temp; + nextLane = newLane; + } + } + return val; +} + +uint NvWaveMultiPrefixExclusiveAnd(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : ~0; + return NvWaveMultiPrefixInclusiveAnd(val, mask); +} + +uint2 NvWaveMultiPrefixInclusiveAnd(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val & temp; + nextLane = newLane; + } + } + return val; +} + +uint2 NvWaveMultiPrefixExclusiveAnd(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint2(~0, ~0); + return NvWaveMultiPrefixInclusiveAnd(val, mask); +} + + +uint4 NvWaveMultiPrefixInclusiveAnd(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val & temp; + nextLane = newLane; + } + } + return val; +} + +uint4 NvWaveMultiPrefixExclusiveAnd(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint4(~0, ~0, ~0, ~0); + return NvWaveMultiPrefixInclusiveAnd(val, mask); +} + + +// MultiPrefix extensions for BitOr +uint NvWaveMultiPrefixInclusiveOr(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val | temp; + nextLane = newLane; + } + } + return val; +} + +uint NvWaveMultiPrefixExclusiveOr(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : 0; + return NvWaveMultiPrefixInclusiveOr(val, mask); +} + +uint2 NvWaveMultiPrefixInclusiveOr(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val | temp; + nextLane = newLane; + } + } + return val; +} + +uint2 NvWaveMultiPrefixExclusiveOr(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint2(0, 0); + return NvWaveMultiPrefixInclusiveOr(val, mask); +} + + +uint4 NvWaveMultiPrefixInclusiveOr(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val | temp; + nextLane = newLane; + } + } + return val; +} + +uint4 NvWaveMultiPrefixExclusiveOr(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint4(0, 0, 0, 0); + return NvWaveMultiPrefixInclusiveOr(val, mask); +} + + +// MultiPrefix extensions for BitXOr +uint NvWaveMultiPrefixInclusiveXOr(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val ^ temp; + nextLane = newLane; + } + } + return val; +} + +uint NvWaveMultiPrefixExclusiveXOr(uint val, uint mask) +{ + uint temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : 0; + return NvWaveMultiPrefixInclusiveXOr(val, mask); +} + +uint2 NvWaveMultiPrefixInclusiveXOr(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val ^ temp; + nextLane = newLane; + } + } + return val; +} + +uint2 NvWaveMultiPrefixExclusiveXOr(uint2 val, uint mask) +{ + uint2 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint2(0, 0); + return NvWaveMultiPrefixInclusiveXOr(val, mask); +} + + +uint4 NvWaveMultiPrefixInclusiveXOr(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint nextLane = firstbithigh(remainingThreads); + for (uint i = 0; i < NV_WARP_SIZE_LOG2; i++) + { + temp = NvShfl(val, nextLane); + uint laneValid; + uint newLane = asuint(__NvShflGeneric(nextLane, nextLane, 30, laneValid)); + if (laneValid) // if nextLane's nextLane is valid + { + val = val ^ temp; + nextLane = newLane; + } + } + return val; +} + +uint4 NvWaveMultiPrefixExclusiveXOr(uint4 val, uint mask) +{ + uint4 temp; + uint a = NvActiveThreads(); + uint remainingThreads = a & __NvGetSpecial(NV_SPECIALOP_THREADLTMASK) & mask; + uint lane = firstbithigh(remainingThreads); + temp = NvShfl(val, lane); + val = remainingThreads != 0 ? temp : uint4(0, 0, 0, 0); + return NvWaveMultiPrefixInclusiveXOr(val, mask); +} + +//----------------------------------------------------------------------------// +//------------------------- DXR HitObject Extension --------------------------// +//----------------------------------------------------------------------------// + +// Support for templates in HLSL requires HLSL 2021+. When using dxc, +// use the -HV 2021 command line argument to enable these versions. +#if defined(__HLSL_VERSION) && (__HLSL_VERSION >= 2021) && !defined(NV_HITOBJECT_USE_MACRO_API) + +struct NvHitObject { + uint _handle; + + bool IsMiss() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_MISS; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + bool IsHit() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_HIT; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + bool IsNop() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_NOP; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + uint GetInstanceID() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_ID; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetInstanceIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetPrimitiveIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_PRIMITIVE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetGeometryIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_GEOMETRY_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetHitKind() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_HIT_KIND; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + RayDesc GetRayDesc() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_RAY_DESC; + g_NvidiaExt[index].src0u.x = _handle; + + uint tmin = g_NvidiaExt.IncrementCounter(); + uint tmax = g_NvidiaExt.IncrementCounter(); + uint rayOrgX = g_NvidiaExt.IncrementCounter(); + uint rayOrgY = g_NvidiaExt.IncrementCounter(); + uint rayOrgZ = g_NvidiaExt.IncrementCounter(); + uint rayDirX = g_NvidiaExt.IncrementCounter(); + uint rayDirY = g_NvidiaExt.IncrementCounter(); + uint rayDirZ = g_NvidiaExt.IncrementCounter(); + + RayDesc ray; + ray.TMin = asfloat(tmin); + ray.TMax = asfloat(tmax); + ray.Origin.x = asfloat(rayOrgX); + ray.Origin.y = asfloat(rayOrgY); + ray.Origin.z = asfloat(rayOrgZ); + ray.Direction.x = asfloat(rayDirX); + ray.Direction.y = asfloat(rayDirY); + ray.Direction.z = asfloat(rayDirZ); + + return ray; + } + + template + T GetAttributes() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_ATTRIBUTES; + g_NvidiaExt[index].src0u.x = _handle; + uint callHandle = g_NvidiaExt.IncrementCounter(); + + T attrs; + CallShader(callHandle, attrs); + return attrs; + } + + uint GetShaderTableIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_SHADER_TABLE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint LoadLocalRootTableConstant(uint RootConstantOffsetInBytes) + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_LOAD_LOCAL_ROOT_TABLE_CONSTANT; + g_NvidiaExt[index].src0u.x = _handle; + g_NvidiaExt[index].src0u.y = RootConstantOffsetInBytes; + return g_NvidiaExt.IncrementCounter(); + } +}; + +template +NvHitObject NvTraceRayHitObject( + RaytracingAccelerationStructure AccelerationStructure, + uint RayFlags, + uint InstanceInclusionMask, + uint RayContributionToHitGroupIndex, + uint MultiplierForGeometryContributionToHitGroupIndex, + uint MissShaderIndex, + RayDesc Ray, + inout T Payload) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_TRACE_RAY; + g_NvidiaExt[index].numOutputsForIncCounter = 2; + g_NvidiaExt[index].src0u.x = MissShaderIndex; + uint hitHandle = g_NvidiaExt.IncrementCounter(); + uint traceHandle = g_NvidiaExt.IncrementCounter(); + + TraceRay(AccelerationStructure, RayFlags, InstanceInclusionMask, RayContributionToHitGroupIndex, MultiplierForGeometryContributionToHitGroupIndex, traceHandle, Ray, Payload); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +template +NvHitObject NvMakeHit( + RaytracingAccelerationStructure AccelerationStructure, + uint InstanceIndex, + uint GeometryIndex, + uint PrimitiveIndex, + uint HitKind, + uint RayContributionToHitGroupIndex, + uint MultiplierForGeometryContributionToHitGroupIndex, + RayDesc Ray, + T Attributes) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_HIT; + g_NvidiaExt[index].numOutputsForIncCounter = 2; + g_NvidiaExt[index].src0u.x = InstanceIndex; + g_NvidiaExt[index].src0u.y = GeometryIndex; + g_NvidiaExt[index].src0u.z = PrimitiveIndex; + g_NvidiaExt[index].src0u.w = HitKind; + g_NvidiaExt[index].src1u.x = RayContributionToHitGroupIndex; + g_NvidiaExt[index].src1u.y = MultiplierForGeometryContributionToHitGroupIndex; + uint hitHandle = g_NvidiaExt.IncrementCounter(); + uint traceHandle = g_NvidiaExt.IncrementCounter(); + + struct AttrWrapper { T Attrs; }; + AttrWrapper wrapper; + wrapper.Attrs = Attributes; + CallShader(traceHandle, wrapper); + + struct DummyPayload { int a; }; + DummyPayload payload; + TraceRay(AccelerationStructure, 0, 0, 0, 0, traceHandle, Ray, payload); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +template +NvHitObject NvMakeHitWithRecordIndex( + uint HitGroupRecordIndex, + RaytracingAccelerationStructure AccelerationStructure, + uint InstanceIndex, + uint GeometryIndex, + uint PrimitiveIndex, + uint HitKind, + RayDesc Ray, + T Attributes) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_HIT_WITH_RECORD_INDEX; + g_NvidiaExt[index].numOutputsForIncCounter = 2; + g_NvidiaExt[index].src0u.x = InstanceIndex; + g_NvidiaExt[index].src0u.y = GeometryIndex; + g_NvidiaExt[index].src0u.z = PrimitiveIndex; + g_NvidiaExt[index].src0u.w = HitKind; + g_NvidiaExt[index].src1u.x = HitGroupRecordIndex; + uint hitHandle = g_NvidiaExt.IncrementCounter(); + uint traceHandle = g_NvidiaExt.IncrementCounter(); + + struct AttrWrapper { T Attrs; }; + AttrWrapper wrapper; + wrapper.Attrs = Attributes; + CallShader(traceHandle, wrapper); + + struct DummyPayload { int a; }; + DummyPayload payload; + TraceRay(AccelerationStructure, 0, 0, 0, 0, traceHandle, Ray, payload); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +NvHitObject NvMakeMiss( + uint MissShaderIndex, + RayDesc Ray) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_MISS; + g_NvidiaExt[index].src0u.x = MissShaderIndex; + g_NvidiaExt[index].src0u.y = asuint(Ray.TMin); + g_NvidiaExt[index].src0u.z = asuint(Ray.TMax); + g_NvidiaExt[index].src1u.x = asuint(Ray.Origin.x); + g_NvidiaExt[index].src1u.y = asuint(Ray.Origin.y); + g_NvidiaExt[index].src1u.z = asuint(Ray.Origin.z); + g_NvidiaExt[index].src2u.x = asuint(Ray.Direction.x); + g_NvidiaExt[index].src2u.y = asuint(Ray.Direction.y); + g_NvidiaExt[index].src2u.z = asuint(Ray.Direction.z); + uint hitHandle = g_NvidiaExt.IncrementCounter(); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +NvHitObject NvMakeNop() +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_NOP; + uint hitHandle = g_NvidiaExt.IncrementCounter(); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +void NvReorderThread(uint CoherenceHint, uint NumCoherenceHintBits) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD; + g_NvidiaExt[index].src0u.x = 0; + g_NvidiaExt[index].src0u.y = 0; + g_NvidiaExt[index].src0u.z = CoherenceHint; + g_NvidiaExt[index].src0u.w = NumCoherenceHintBits; + g_NvidiaExt.IncrementCounter(); +} + +void NvReorderThread(NvHitObject HitObj, uint CoherenceHint, uint NumCoherenceHintBits) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD; + g_NvidiaExt[index].src0u.x = 1; + g_NvidiaExt[index].src0u.y = HitObj._handle; + g_NvidiaExt[index].src0u.z = CoherenceHint; + g_NvidiaExt[index].src0u.w = NumCoherenceHintBits; + g_NvidiaExt.IncrementCounter(); +} + +void NvReorderThread(NvHitObject HitObj) +{ + NvReorderThread(HitObj, 0, 0); +} + +template +void NvInvokeHitObject( + RaytracingAccelerationStructure AccelerationStructure, + NvHitObject HitObj, + inout T Payload) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_INVOKE; + g_NvidiaExt[index].src0u.x = HitObj._handle; + uint handle = g_NvidiaExt.IncrementCounter(); + + TraceRay(AccelerationStructure, 0, 0, 0, 0, handle, (RayDesc)0, Payload); +} + +// Macro-based version of the HitObject API. Use this when HLSL 2021 is not available. +// Enable by specifying #define NV_HITOBJECT_USE_MACRO_API before including this header. +#elif defined(NV_HITOBJECT_USE_MACRO_API) + +struct NvHitObject { + uint _handle; + + bool IsMiss() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_MISS; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + bool IsHit() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_HIT; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + bool IsNop() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_IS_NOP; + g_NvidiaExt[index].src0u.x = _handle; + uint ret = g_NvidiaExt.IncrementCounter(); + return ret != 0; + } + + uint GetInstanceID() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_ID; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetInstanceIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetPrimitiveIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_PRIMITIVE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetGeometryIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_GEOMETRY_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint GetHitKind() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_HIT_KIND; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + RayDesc GetRayDesc() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_RAY_DESC; + g_NvidiaExt[index].src0u.x = _handle; + + uint tmin = g_NvidiaExt.IncrementCounter(); + uint tmax = g_NvidiaExt.IncrementCounter(); + uint rayOrgX = g_NvidiaExt.IncrementCounter(); + uint rayOrgY = g_NvidiaExt.IncrementCounter(); + uint rayOrgZ = g_NvidiaExt.IncrementCounter(); + uint rayDirX = g_NvidiaExt.IncrementCounter(); + uint rayDirY = g_NvidiaExt.IncrementCounter(); + uint rayDirZ = g_NvidiaExt.IncrementCounter(); + + RayDesc ray; + ray.TMin = asfloat(tmin); + ray.TMax = asfloat(tmax); + ray.Origin.x = asfloat(rayOrgX); + ray.Origin.y = asfloat(rayOrgY); + ray.Origin.z = asfloat(rayOrgZ); + ray.Direction.x = asfloat(rayDirX); + ray.Direction.y = asfloat(rayDirY); + ray.Direction.z = asfloat(rayDirZ); + + return ray; + } + + uint GetShaderTableIndex() + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_SHADER_TABLE_INDEX; + g_NvidiaExt[index].src0u.x = _handle; + return g_NvidiaExt.IncrementCounter(); + } + + uint LoadLocalRootTableConstant(uint RootConstantOffsetInBytes) + { + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_LOAD_LOCAL_ROOT_TABLE_CONSTANT; + g_NvidiaExt[index].src0u.x = _handle; + g_NvidiaExt[index].src0u.y = RootConstantOffsetInBytes; + return g_NvidiaExt.IncrementCounter(); + } +}; + +#define NvTraceRayHitObject(AccelerationStructure,RayFlags,InstanceInclusionMask,RayContributionToHitGroupIndex,MultiplierForGeometryContributionToHitGroupIndex,MissShaderIndex,Ray,Payload,ResultHitObj) \ +do { \ + uint _rayFlags = RayFlags; \ + uint _instanceInclusionMask = InstanceInclusionMask; \ + uint _rayContributionToHitGroupIndex = RayContributionToHitGroupIndex; \ + uint _multiplierForGeometryContributionToHitGroupIndex = MultiplierForGeometryContributionToHitGroupIndex; \ + uint _missShaderIndex = MissShaderIndex; \ + RayDesc _ray = Ray; \ + uint _index = g_NvidiaExt.IncrementCounter(); \ + g_NvidiaExt[_index].opcode = NV_EXTN_OP_HIT_OBJECT_TRACE_RAY; \ + g_NvidiaExt[_index].numOutputsForIncCounter = 2; \ + g_NvidiaExt[_index].src0u.x = _missShaderIndex; \ + uint _hitHandle = g_NvidiaExt.IncrementCounter(); \ + uint _traceHandle = g_NvidiaExt.IncrementCounter(); \ + TraceRay(AccelerationStructure, _rayFlags, _instanceInclusionMask, _rayContributionToHitGroupIndex, _multiplierForGeometryContributionToHitGroupIndex, _traceHandle, _ray, Payload); \ + ResultHitObj._handle = _hitHandle; \ +} while(0) + +struct NvHitObjectMacroDummyPayloadType { int a; }; + +#define NvMakeHit(AccelerationStructure,InstanceIndex,GeometryIndex,PrimitiveIndex,HitKind,RayContributionToHitGroupIndex,MultiplierForGeometryContributionToHitGroupIndex,Ray,Attributes,ResultHitObj) \ +do { \ + uint _instanceIndex = InstanceIndex; \ + uint _geometryIndex = GeometryIndex; \ + uint _primitiveIndex = PrimitiveIndex; \ + uint _hitKind = HitKind; \ + uint _rayContributionToHitGroupIndex = RayContributionToHitGroupIndex; \ + uint _multiplierForGeometryContributionToHitGroupIndex = MultiplierForGeometryContributionToHitGroupIndex; \ + RayDesc _ray = Ray; \ + uint _index = g_NvidiaExt.IncrementCounter(); \ + g_NvidiaExt[_index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_HIT; \ + g_NvidiaExt[_index].numOutputsForIncCounter = 2; \ + g_NvidiaExt[_index].src0u.x = _instanceIndex; \ + g_NvidiaExt[_index].src0u.y = _geometryIndex; \ + g_NvidiaExt[_index].src0u.z = _primitiveIndex; \ + g_NvidiaExt[_index].src0u.w = _hitKind; \ + g_NvidiaExt[_index].src1u.x = _rayContributionToHitGroupIndex; \ + g_NvidiaExt[_index].src1u.y = _multiplierForGeometryContributionToHitGroupIndex; \ + uint _hitHandle = g_NvidiaExt.IncrementCounter(); \ + uint _traceHandle = g_NvidiaExt.IncrementCounter(); \ + CallShader(_traceHandle, Attributes); \ + NvHitObjectMacroDummyPayloadType _payload; \ + TraceRay(AccelerationStructure, 0, 0, 0, 0, _traceHandle, _ray, _payload); \ + ResultHitObj._handle = _hitHandle; \ +} while(0) + +#define NvMakeHitWithRecordIndex(HitGroupRecordIndex,AccelerationStructure,InstanceIndex,GeometryIndex,PrimitiveIndex,HitKind,Ray,Attributes,ResultHitObj) \ +do { \ + uint _hitGroupRecordIndex = HitGroupRecordIndex; \ + uint _instanceIndex = InstanceIndex; \ + uint _geometryIndex = GeometryIndex; \ + uint _primitiveIndex = PrimitiveIndex; \ + uint _hitKind = HitKind; \ + RayDesc _ray = Ray; \ + uint _index = g_NvidiaExt.IncrementCounter(); \ + g_NvidiaExt[_index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_HIT_WITH_RECORD_INDEX; \ + g_NvidiaExt[_index].numOutputsForIncCounter = 2; \ + g_NvidiaExt[_index].src0u.x = _instanceIndex; \ + g_NvidiaExt[_index].src0u.y = _geometryIndex; \ + g_NvidiaExt[_index].src0u.z = _primitiveIndex; \ + g_NvidiaExt[_index].src0u.w = _hitKind; \ + g_NvidiaExt[_index].src1u.x = _hitGroupRecordIndex; \ + uint _hitHandle = g_NvidiaExt.IncrementCounter(); \ + uint _traceHandle = g_NvidiaExt.IncrementCounter(); \ + CallShader(_traceHandle, Attributes); \ + NvHitObjectMacroDummyPayloadType _payload; \ + TraceRay(AccelerationStructure, 0, 0, 0, 0, _traceHandle, _ray, _payload); \ + ResultHitObj._handle = _hitHandle; \ +} while(0) + +NvHitObject NvMakeMiss( + uint MissShaderIndex, + RayDesc Ray) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_MISS; + g_NvidiaExt[index].src0u.x = MissShaderIndex; + g_NvidiaExt[index].src0u.y = asuint(Ray.TMin); + g_NvidiaExt[index].src0u.z = asuint(Ray.TMax); + g_NvidiaExt[index].src1u.x = asuint(Ray.Origin.x); + g_NvidiaExt[index].src1u.y = asuint(Ray.Origin.y); + g_NvidiaExt[index].src1u.z = asuint(Ray.Origin.z); + g_NvidiaExt[index].src2u.x = asuint(Ray.Direction.x); + g_NvidiaExt[index].src2u.y = asuint(Ray.Direction.y); + g_NvidiaExt[index].src2u.z = asuint(Ray.Direction.z); + uint hitHandle = g_NvidiaExt.IncrementCounter(); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +NvHitObject NvMakeNop() +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_MAKE_NOP; + uint hitHandle = g_NvidiaExt.IncrementCounter(); + + NvHitObject hitObj; + hitObj._handle = hitHandle; + return hitObj; +} + +#define NvGetAttributesFromHitObject(HitObj,ResultAttributes) \ +do { \ + uint _index = g_NvidiaExt.IncrementCounter(); \ + g_NvidiaExt[_index].opcode = NV_EXTN_OP_HIT_OBJECT_GET_ATTRIBUTES; \ + g_NvidiaExt[_index].src0u.x = HitObj._handle; \ + uint _callHandle = g_NvidiaExt.IncrementCounter(); \ + CallShader(_callHandle, ResultAttributes); \ +} while(0) + +void NvReorderThread(uint CoherenceHint, uint NumCoherenceHintBits) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD; + g_NvidiaExt[index].src0u.x = 0; + g_NvidiaExt[index].src0u.y = 0; + g_NvidiaExt[index].src0u.z = CoherenceHint; + g_NvidiaExt[index].src0u.w = NumCoherenceHintBits; + g_NvidiaExt.IncrementCounter(); +} + +void NvReorderThread(NvHitObject HitObj, uint CoherenceHint, uint NumCoherenceHintBits) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD; + g_NvidiaExt[index].src0u.x = 1; + g_NvidiaExt[index].src0u.y = HitObj._handle; + g_NvidiaExt[index].src0u.z = CoherenceHint; + g_NvidiaExt[index].src0u.w = NumCoherenceHintBits; + g_NvidiaExt.IncrementCounter(); +} + +void NvReorderThread(NvHitObject HitObj) +{ + NvReorderThread(HitObj, 0, 0); +} + +#define NvInvokeHitObject(AccelerationStructure,HitObj,Payload) \ +do { \ + uint _index = g_NvidiaExt.IncrementCounter(); \ + g_NvidiaExt[_index].opcode = NV_EXTN_OP_HIT_OBJECT_INVOKE; \ + g_NvidiaExt[_index].src0u.x = HitObj._handle; \ + uint _handle = g_NvidiaExt.IncrementCounter(); \ + TraceRay(AccelerationStructure, 0, 0, 0, 0, _handle, (RayDesc)0, Payload); \ +} while(0) + +#endif diff --git a/thirdparty/nvapi/nvHLSLExtnsInternal.h b/thirdparty/nvapi/nvHLSLExtnsInternal.h new file mode 100644 index 0000000..c5936a5 --- /dev/null +++ b/thirdparty/nvapi/nvHLSLExtnsInternal.h @@ -0,0 +1,767 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + +////////////////////////// NVIDIA SHADER EXTENSIONS ///////////////// +// internal functions +// Functions in this file are not expected to be called by apps directly + +#include "nvShaderExtnEnums.h" + +struct NvShaderExtnStruct +{ + uint opcode; // opcode + uint rid; // resource ID + uint sid; // sampler ID + + uint4 dst1u; // destination operand 1 (for instructions that need extra destination operands) + uint4 src3u; // source operand 3 + uint4 src4u; // source operand 4 + uint4 src5u; // source operand 5 + + uint4 src0u; // uint source operand 0 + uint4 src1u; // uint source operand 0 + uint4 src2u; // uint source operand 0 + uint4 dst0u; // uint destination operand + + uint markUavRef; // the next store to UAV is fake and is used only to identify the uav slot + uint numOutputsForIncCounter; // Used for output to IncrementCounter + float padding1[27]; // struct size: 256 bytes +}; + +// RW structured buffer for Nvidia shader extensions + +// Application needs to define NV_SHADER_EXTN_SLOT as a unused slot, which should be +// set using NvAPI_D3D11_SetNvShaderExtnSlot() call before creating the first shader that +// uses nvidia shader extensions. E.g before including this file in shader define it as: +// #define NV_SHADER_EXTN_SLOT u7 + +// For SM5.1, application needs to define NV_SHADER_EXTN_REGISTER_SPACE as register space +// E.g. before including this file in shader define it as: +// #define NV_SHADER_EXTN_REGISTER_SPACE space2 + +// Note that other operations to this UAV will be ignored so application +// should bind a null resource + +#ifdef NV_SHADER_EXTN_REGISTER_SPACE +RWStructuredBuffer g_NvidiaExt : register( NV_SHADER_EXTN_SLOT, NV_SHADER_EXTN_REGISTER_SPACE ); +#else +RWStructuredBuffer g_NvidiaExt : register( NV_SHADER_EXTN_SLOT ); +#endif + +//----------------------------------------------------------------------------// +// the exposed SHFL instructions accept a mask parameter in src2 +// To compute lane mask from width of segment: +// minLaneID : currentLaneId & src2[12:8] +// maxLaneID : minLaneId | (src2[4:0] & ~src2[12:8]) +// where [minLaneId, maxLaneId] defines the segment where currentLaneId belongs +// we always set src2[4:0] to 11111 (0x1F), and set src2[12:8] as (32 - width) +int __NvGetShflMaskFromWidth(uint width) +{ + return ((NV_WARP_SIZE - width) << 8) | 0x1F; +} + +//----------------------------------------------------------------------------// + +void __NvReferenceUAVForOp(RWByteAddressBuffer uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav.Store(index, 0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = float2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = float2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = float2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = float4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = float4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = float4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = 0.0f; +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = 0.0f; +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = 0.0f; +} + + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = uint2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = uint2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = uint2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = uint4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = uint4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = uint4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = 0; +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = 0; +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = 0; +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = int2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = int2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = int2(0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = int4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = int4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = int4(0,0,0,0); +} + +void __NvReferenceUAVForOp(RWTexture1D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[index] = 0; +} + +void __NvReferenceUAVForOp(RWTexture2D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint2(index,index)] = 0; +} + +void __NvReferenceUAVForOp(RWTexture3D uav) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].markUavRef = 1; + uav[uint3(index,index,index)] = 0; +} + +//----------------------------------------------------------------------------// +// ATOMIC op sub-opcodes +#define NV_EXTN_ATOM_AND 0 +#define NV_EXTN_ATOM_OR 1 +#define NV_EXTN_ATOM_XOR 2 + +#define NV_EXTN_ATOM_ADD 3 +#define NV_EXTN_ATOM_MAX 6 +#define NV_EXTN_ATOM_MIN 7 + +#define NV_EXTN_ATOM_SWAP 8 +#define NV_EXTN_ATOM_CAS 9 + +//----------------------------------------------------------------------------// + +// performs Atomic operation on two consecutive fp16 values in the given UAV +// the uint paramater 'fp16x2Val' is treated as two fp16 values +// the passed sub-opcode 'op' should be an immediate constant +// byteAddress must be multiple of 4 +// the returned value are the two fp16 values packed into a single uint +uint __NvAtomicOpFP16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = byteAddress; + g_NvidiaExt[index].src1u.x = fp16x2Val; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + + return g_NvidiaExt[index].dst0u.x; +} + +//----------------------------------------------------------------------------// + +// performs Atomic operation on a R16G16_FLOAT UAV at the given address +// the uint paramater 'fp16x2Val' is treated as two fp16 values +// the passed sub-opcode 'op' should be an immediate constant +// the returned value are the two fp16 values (.x and .y components) packed into a single uint +// Warning: Behaviour of these set of functions is undefined if the UAV is not +// of R16G16_FLOAT format (might result in app crash or TDR) + +uint __NvAtomicOpFP16x2(RWTexture1D uav, uint address, uint fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address; + g_NvidiaExt[index].src1u.x = fp16x2Val; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + + return g_NvidiaExt[index].dst0u.x; +} + +uint __NvAtomicOpFP16x2(RWTexture2D uav, uint2 address, uint fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = address; + g_NvidiaExt[index].src1u.x = fp16x2Val; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + + return g_NvidiaExt[index].dst0u.x; +} + +uint __NvAtomicOpFP16x2(RWTexture3D uav, uint3 address, uint fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = address; + g_NvidiaExt[index].src1u.x = fp16x2Val; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + + return g_NvidiaExt[index].dst0u.x; +} + +//----------------------------------------------------------------------------// + +// performs Atomic operation on a R16G16B16A16_FLOAT UAV at the given address +// the uint2 paramater 'fp16x2Val' is treated as four fp16 values +// i.e, fp16x2Val.x = uav.xy and fp16x2Val.y = uav.yz +// the passed sub-opcode 'op' should be an immediate constant +// the returned value are the four fp16 values (.xyzw components) packed into uint2 +// Warning: Behaviour of these set of functions is undefined if the UAV is not +// of R16G16B16A16_FLOAT format (might result in app crash or TDR) + +uint2 __NvAtomicOpFP16x2(RWTexture1D uav, uint address, uint2 fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + // break it down into two fp16x2 atomic ops + uint2 retVal; + + // first op has x-coordinate = x * 2 + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address * 2; + g_NvidiaExt[index].src1u.x = fp16x2Val.x; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.x = g_NvidiaExt[index].dst0u.x; + + // second op has x-coordinate = x * 2 + 1 + index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address * 2 + 1; + g_NvidiaExt[index].src1u.x = fp16x2Val.y; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.y = g_NvidiaExt[index].dst0u.x; + + return retVal; +} + +uint2 __NvAtomicOpFP16x2(RWTexture2D uav, uint2 address, uint2 fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + // break it down into two fp16x2 atomic ops + uint2 retVal; + + // first op has x-coordinate = x * 2 + uint2 addressTemp = uint2(address.x * 2, address.y); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = addressTemp; + g_NvidiaExt[index].src1u.x = fp16x2Val.x; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.x = g_NvidiaExt[index].dst0u.x; + + // second op has x-coordinate = x * 2 + 1 + addressTemp.x++; + index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = addressTemp; + g_NvidiaExt[index].src1u.x = fp16x2Val.y; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.y = g_NvidiaExt[index].dst0u.x; + + return retVal; +} + +uint2 __NvAtomicOpFP16x2(RWTexture3D uav, uint3 address, uint2 fp16x2Val, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + // break it down into two fp16x2 atomic ops + uint2 retVal; + + // first op has x-coordinate = x * 2 + uint3 addressTemp = uint3(address.x * 2, address.y, address.z); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = addressTemp; + g_NvidiaExt[index].src1u.x = fp16x2Val.x; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.x = g_NvidiaExt[index].dst0u.x; + + // second op has x-coordinate = x * 2 + 1 + addressTemp.x++; + index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = addressTemp; + g_NvidiaExt[index].src1u.x = fp16x2Val.y; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC; + retVal.y = g_NvidiaExt[index].dst0u.x; + + return retVal; +} + +uint __fp32x2Tofp16x2(float2 val) +{ + return (f32tof16(val.y)<<16) | f32tof16(val.x) ; +} + +uint2 __fp32x4Tofp16x4(float4 val) +{ + return uint2( (f32tof16(val.y)<<16) | f32tof16(val.x), (f32tof16(val.w)<<16) | f32tof16(val.z) ) ; +} + +//----------------------------------------------------------------------------// + +// FP32 Atomic functions +// performs Atomic operation treating the uav as float (fp32) values +// the passed sub-opcode 'op' should be an immediate constant +// byteAddress must be multiple of 4 +float __NvAtomicAddFP32(RWByteAddressBuffer uav, uint byteAddress, float val) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = byteAddress; + g_NvidiaExt[index].src1u.x = asuint(val); // passing as uint to make it more convinient for the driver to translate + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC; + + return asfloat(g_NvidiaExt[index].dst0u.x); +} + +float __NvAtomicAddFP32(RWTexture1D uav, uint address, float val) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address; + g_NvidiaExt[index].src1u.x = asuint(val); + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC; + + return asfloat(g_NvidiaExt[index].dst0u.x); +} + +float __NvAtomicAddFP32(RWTexture2D uav, uint2 address, float val) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = address; + g_NvidiaExt[index].src1u.x = asuint(val); + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC; + + return asfloat(g_NvidiaExt[index].dst0u.x); +} + +float __NvAtomicAddFP32(RWTexture3D uav, uint3 address, float val) +{ + __NvReferenceUAVForOp(uav); + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = address; + g_NvidiaExt[index].src1u.x = asuint(val); + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD; + g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC; + + return asfloat(g_NvidiaExt[index].dst0u.x); +} + +//----------------------------------------------------------------------------// + +// UINT64 Atmoic Functions +// The functions below performs atomic operation on the given UAV treating the value as uint64 +// byteAddress must be multiple of 8 +// The returned value is the value present in memory location before the atomic operation +// uint2 vector type is used to represent a single uint64 value with the x component containing the low 32 bits and y component the high 32 bits. + +uint2 __NvAtomicCompareExchangeUINT64(RWByteAddressBuffer uav, uint byteAddress, uint2 compareValue, uint2 value) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = byteAddress; + g_NvidiaExt[index].src1u.xy = compareValue; + g_NvidiaExt[index].src1u.zw = value; + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicOpUINT64(RWByteAddressBuffer uav, uint byteAddress, uint2 value, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = byteAddress; + g_NvidiaExt[index].src1u.xy = value; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicCompareExchangeUINT64(RWTexture1D uav, uint address, uint2 compareValue, uint2 value) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address; + g_NvidiaExt[index].src1u.xy = compareValue; + g_NvidiaExt[index].src1u.zw = value; + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicOpUINT64(RWTexture1D uav, uint address, uint2 value, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = address; + g_NvidiaExt[index].src1u.xy = value; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicCompareExchangeUINT64(RWTexture2D uav, uint2 address, uint2 compareValue, uint2 value) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = address; + g_NvidiaExt[index].src1u.xy = compareValue; + g_NvidiaExt[index].src1u.zw = value; + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicOpUINT64(RWTexture2D uav, uint2 address, uint2 value, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xy = address; + g_NvidiaExt[index].src1u.xy = value; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicCompareExchangeUINT64(RWTexture3D uav, uint3 address, uint2 compareValue, uint2 value) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = address; + g_NvidiaExt[index].src1u.xy = compareValue; + g_NvidiaExt[index].src1u.zw = value; + g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + +uint2 __NvAtomicOpUINT64(RWTexture3D uav, uint3 address, uint2 value, uint atomicOpType) +{ + __NvReferenceUAVForOp(uav); + + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.xyz = address; + g_NvidiaExt[index].src1u.xy = value; + g_NvidiaExt[index].src2u.x = atomicOpType; + g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC; + + return g_NvidiaExt[index].dst0u.xy; +} + + +uint4 __NvFootprint(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, int3 offset = int3(0, 0, 0)) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = texIndex; + g_NvidiaExt[index].src0u.y = smpIndex; + g_NvidiaExt[index].src1u.xyz = asuint(location); + g_NvidiaExt[index].src1u.w = gran; + g_NvidiaExt[index].src3u.x = texSpace; + g_NvidiaExt[index].src3u.y = smpSpace; + g_NvidiaExt[index].src3u.z = texType; + g_NvidiaExt[index].src3u.w = footprintmode; + g_NvidiaExt[index].src4u.xyz = asuint(offset); + + g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT; + g_NvidiaExt[index].numOutputsForIncCounter = 4; + + // result is returned as the return value of IncrementCounter on fake UAV slot + uint4 op; + op.x = g_NvidiaExt.IncrementCounter(); + op.y = g_NvidiaExt.IncrementCounter(); + op.z = g_NvidiaExt.IncrementCounter(); + op.w = g_NvidiaExt.IncrementCounter(); + return op; +} + +uint4 __NvFootprintBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, float bias, int3 offset = int3(0, 0, 0)) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = texIndex; + g_NvidiaExt[index].src0u.y = smpIndex; + g_NvidiaExt[index].src1u.xyz = asuint(location); + g_NvidiaExt[index].src1u.w = gran; + g_NvidiaExt[index].src2u.x = asuint(bias); + g_NvidiaExt[index].src3u.x = texSpace; + g_NvidiaExt[index].src3u.y = smpSpace; + g_NvidiaExt[index].src3u.z = texType; + g_NvidiaExt[index].src3u.w = footprintmode; + g_NvidiaExt[index].src4u.xyz = asuint(offset); + + g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT_BIAS; + g_NvidiaExt[index].numOutputsForIncCounter = 4; + + // result is returned as the return value of IncrementCounter on fake UAV slot + uint4 op; + op.x = g_NvidiaExt.IncrementCounter(); + op.y = g_NvidiaExt.IncrementCounter(); + op.z = g_NvidiaExt.IncrementCounter(); + op.w = g_NvidiaExt.IncrementCounter(); + return op; +} + +uint4 __NvFootprintLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, float lodLevel, int3 offset = int3(0, 0, 0)) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = texIndex; + g_NvidiaExt[index].src0u.y = smpIndex; + g_NvidiaExt[index].src1u.xyz = asuint(location); + g_NvidiaExt[index].src1u.w = gran; + g_NvidiaExt[index].src2u.x = asuint(lodLevel); + g_NvidiaExt[index].src3u.x = texSpace; + g_NvidiaExt[index].src3u.y = smpSpace; + g_NvidiaExt[index].src3u.z = texType; + g_NvidiaExt[index].src3u.w = footprintmode; + g_NvidiaExt[index].src4u.xyz = asuint(offset); + + g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT_LEVEL; + g_NvidiaExt[index].numOutputsForIncCounter = 4; + + // result is returned as the return value of IncrementCounter on fake UAV slot + uint4 op; + op.x = g_NvidiaExt.IncrementCounter(); + op.y = g_NvidiaExt.IncrementCounter(); + op.z = g_NvidiaExt.IncrementCounter(); + op.w = g_NvidiaExt.IncrementCounter(); + return op; +} + +uint4 __NvFootprintGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, float3 ddx, float3 ddy, int3 offset = int3(0, 0, 0)) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = texIndex; + g_NvidiaExt[index].src0u.y = smpIndex; + g_NvidiaExt[index].src1u.xyz = asuint(location); + g_NvidiaExt[index].src1u.w = gran; + g_NvidiaExt[index].src2u.xyz = asuint(ddx); + g_NvidiaExt[index].src5u.xyz = asuint(ddy); + g_NvidiaExt[index].src3u.x = texSpace; + g_NvidiaExt[index].src3u.y = smpSpace; + g_NvidiaExt[index].src3u.z = texType; + g_NvidiaExt[index].src3u.w = footprintmode; + g_NvidiaExt[index].src4u.xyz = asuint(offset); + g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT_GRAD; + g_NvidiaExt[index].numOutputsForIncCounter = 4; + + // result is returned as the return value of IncrementCounter on fake UAV slot + uint4 op; + op.x = g_NvidiaExt.IncrementCounter(); + op.y = g_NvidiaExt.IncrementCounter(); + op.z = g_NvidiaExt.IncrementCounter(); + op.w = g_NvidiaExt.IncrementCounter(); + return op; +} + +// returns value of special register - specify subopcode from any of NV_SPECIALOP_* specified in nvShaderExtnEnums.h - other opcodes undefined behavior +uint __NvGetSpecial(uint subOpCode) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].opcode = NV_EXTN_OP_GET_SPECIAL; + g_NvidiaExt[index].src0u.x = subOpCode; + return g_NvidiaExt.IncrementCounter(); +} + +// predicate is returned in laneValid indicating if srcLane is in range and val from specified lane is returned. +int __NvShflGeneric(int val, uint srcLane, uint maskClampVal, out uint laneValid) +{ + uint index = g_NvidiaExt.IncrementCounter(); + g_NvidiaExt[index].src0u.x = val; // variable to be shuffled + g_NvidiaExt[index].src0u.y = srcLane; // source lane + g_NvidiaExt[index].src0u.z = maskClampVal; + g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_GENERIC; + g_NvidiaExt[index].numOutputsForIncCounter = 2; + + laneValid = asuint(g_NvidiaExt.IncrementCounter()); + return g_NvidiaExt.IncrementCounter(); +} \ No newline at end of file diff --git a/thirdparty/nvapi/nvShaderExtnEnums.h b/thirdparty/nvapi/nvShaderExtnEnums.h new file mode 100644 index 0000000..cfa918b --- /dev/null +++ b/thirdparty/nvapi/nvShaderExtnEnums.h @@ -0,0 +1,141 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + +//////////////////////////////////////////////////////////////////////////////// +////////////////////////// NVIDIA SHADER EXTENSIONS //////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +// This file can be included both from HLSL shader code as well as C++ code. +// The app should call NvAPI_D3D11_IsNvShaderExtnOpCodeSupported() / NvAPI_D3D12_IsNvShaderExtnOpCodeSupported() +// to check for support for every nv shader extension opcode it plans to use + + + +//----------------------------------------------------------------------------// +//---------------------------- NV Shader Extn Version -----------------------// +//----------------------------------------------------------------------------// +#define NV_SHADER_EXTN_VERSION 1 + +//----------------------------------------------------------------------------// +//---------------------------- Misc constants --------------------------------// +//----------------------------------------------------------------------------// +#define NV_WARP_SIZE 32 +#define NV_WARP_SIZE_LOG2 5 + +//----------------------------------------------------------------------------// +//---------------------------- opCode constants ------------------------------// +//----------------------------------------------------------------------------// + + +#define NV_EXTN_OP_SHFL 1 +#define NV_EXTN_OP_SHFL_UP 2 +#define NV_EXTN_OP_SHFL_DOWN 3 +#define NV_EXTN_OP_SHFL_XOR 4 + +#define NV_EXTN_OP_VOTE_ALL 5 +#define NV_EXTN_OP_VOTE_ANY 6 +#define NV_EXTN_OP_VOTE_BALLOT 7 + +#define NV_EXTN_OP_GET_LANE_ID 8 +#define NV_EXTN_OP_FP16_ATOMIC 12 +#define NV_EXTN_OP_FP32_ATOMIC 13 + +#define NV_EXTN_OP_GET_SPECIAL 19 + +#define NV_EXTN_OP_UINT64_ATOMIC 20 + +#define NV_EXTN_OP_MATCH_ANY 21 + +// FOOTPRINT - For Sample and SampleBias +#define NV_EXTN_OP_FOOTPRINT 28 +#define NV_EXTN_OP_FOOTPRINT_BIAS 29 + +#define NV_EXTN_OP_GET_SHADING_RATE 30 + +// FOOTPRINT - For SampleLevel and SampleGrad +#define NV_EXTN_OP_FOOTPRINT_LEVEL 31 +#define NV_EXTN_OP_FOOTPRINT_GRAD 32 + +// SHFL Generic +#define NV_EXTN_OP_SHFL_GENERIC 33 + +#define NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE 51 +#define NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED 52 + +// HitObject API +#define NV_EXTN_OP_HIT_OBJECT_TRACE_RAY 67 +#define NV_EXTN_OP_HIT_OBJECT_MAKE_HIT 68 +#define NV_EXTN_OP_HIT_OBJECT_MAKE_HIT_WITH_RECORD_INDEX 69 +#define NV_EXTN_OP_HIT_OBJECT_MAKE_MISS 70 +#define NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD 71 +#define NV_EXTN_OP_HIT_OBJECT_INVOKE 72 +#define NV_EXTN_OP_HIT_OBJECT_IS_MISS 73 +#define NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_ID 74 +#define NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_INDEX 75 +#define NV_EXTN_OP_HIT_OBJECT_GET_PRIMITIVE_INDEX 76 +#define NV_EXTN_OP_HIT_OBJECT_GET_GEOMETRY_INDEX 77 +#define NV_EXTN_OP_HIT_OBJECT_GET_HIT_KIND 78 +#define NV_EXTN_OP_HIT_OBJECT_GET_RAY_DESC 79 +#define NV_EXTN_OP_HIT_OBJECT_GET_ATTRIBUTES 80 +#define NV_EXTN_OP_HIT_OBJECT_GET_SHADER_TABLE_INDEX 81 +#define NV_EXTN_OP_HIT_OBJECT_LOAD_LOCAL_ROOT_TABLE_CONSTANT 82 +#define NV_EXTN_OP_HIT_OBJECT_IS_HIT 83 +#define NV_EXTN_OP_HIT_OBJECT_IS_NOP 84 +#define NV_EXTN_OP_HIT_OBJECT_MAKE_NOP 85 + +//----------------------------------------------------------------------------// +//-------------------- GET_SPECIAL subOpCode constants -----------------------// +//----------------------------------------------------------------------------// +#define NV_SPECIALOP_THREADLTMASK 4 +#define NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED 5 +#define NV_SPECIALOP_GLOBAL_TIMER_LO 9 +#define NV_SPECIALOP_GLOBAL_TIMER_HI 10 + +//----------------------------------------------------------------------------// +//----------------------------- Texture Types -------------------------------// +//----------------------------------------------------------------------------// +#define NV_EXTN_TEXTURE_1D 2 +#define NV_EXTN_TEXTURE_1D_ARRAY 3 +#define NV_EXTN_TEXTURE_2D 4 +#define NV_EXTN_TEXTURE_2D_ARRAY 5 +#define NV_EXTN_TEXTURE_3D 6 +#define NV_EXTN_TEXTURE_CUBE 7 +#define NV_EXTN_TEXTURE_CUBE_ARRAY 8 + + +//---------------------------------------------------------------------------// +//----------------FOOTPRINT Enums for NvFootprint* extns---------------------// +//---------------------------------------------------------------------------// +#define NV_EXTN_FOOTPRINT_MODE_FINE 0 +#define NV_EXTN_FOOTPRINT_MODE_COARSE 1 diff --git a/thirdparty/nvapi/nvapi.h b/thirdparty/nvapi/nvapi.h new file mode 100644 index 0000000..4787569 --- /dev/null +++ b/thirdparty/nvapi/nvapi.h @@ -0,0 +1,21413 @@ +#include"nvapi_lite_salstart.h" +#include"nvapi_lite_common.h" +#include"nvapi_lite_sli.h" +#include"nvapi_lite_surround.h" +#include"nvapi_lite_stereo.h" +#include"nvapi_lite_d3dext.h" + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + + +/////////////////////////////////////////////////////////////////////////////// +// +// Date: Oct 6, 2022 +// File: nvapi.h +// +// NvAPI provides an interface to NVIDIA devices. This file contains the +// interface constants, structure definitions and function prototypes. +// +// Target Profile: developer +// Target Platform: windows +// +/////////////////////////////////////////////////////////////////////////////// +#ifndef _NVAPI_H +#define _NVAPI_H + +#pragma pack(push,8) // Make sure we have consistent structure packings + +#ifdef __cplusplus +extern "C" { +#endif +// ==================================================== +// Universal NvAPI Definitions +// ==================================================== +#ifndef _WIN32 +#define __cdecl +#endif + + + +//! @} + + +//! \ingroup nvapistatus +#define NVAPI_API_NOT_INTIALIZED NVAPI_API_NOT_INITIALIZED //!< Fix typo in error code + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Initialize +// +//! This function initializes the NvAPI library (if not already initialized) but always increments the ref-counter. +//! This must be called before calling other NvAPI_ functions. +//! Note: It is now mandatory to call NvAPI_Initialize before calling any other NvAPI. +//! NvAPI_Unload should be called to unload the NVAPI Library. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! \retval NVAPI_LIBRARY_NOT_FOUND Failed to load the NVAPI support library +//! \sa nvapistatus +//! \ingroup nvapifunctions +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Initialize(); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Unload +// +//! DESCRIPTION: Decrements the ref-counter and when it reaches ZERO, unloads NVAPI library. +//! This must be called in pairs with NvAPI_Initialize. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! If the client wants unload functionality, it is recommended to always call NvAPI_Initialize and NvAPI_Unload in pairs. +//! +//! Unloading NvAPI library is not supported when the library is in a resource locked state. +//! Some functions in the NvAPI library initiates an operation or allocates certain resources +//! and there are corresponding functions available, to complete the operation or free the +//! allocated resources. All such function pairs are designed to prevent unloading NvAPI library. +//! +//! For example, if NvAPI_Unload is called after NvAPI_XXX which locks a resource, it fails with +//! NVAPI_ERROR. Developers need to call the corresponding NvAPI_YYY to unlock the resources, +//! before calling NvAPI_Unload again. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! \retval NVAPI_API_IN_USE Atleast an API is still being called hence cannot unload requested driver. +//! +//! \ingroup nvapifunctions +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Unload(); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetErrorMessage +// +//! This function converts an NvAPI error code into a null terminated string. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \param nr The error code to convert +//! \param szDesc The string corresponding to the error code +//! +//! \return NULL terminated string (always, never NULL) +//! \ingroup nvapifunctions +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetErrorMessage(NvAPI_Status nr,NvAPI_ShortString szDesc); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetInterfaceVersionString +// +//! This function returns a string describing the version of the NvAPI library. +//! The contents of the string are human readable. Do not assume a fixed +//! format. +//! +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \param szDesc User readable string giving NvAPI version information +//! +//! \return See \ref nvapistatus for the list of possible return values. +//! \ingroup nvapifunctions +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetInterfaceVersionString(NvAPI_ShortString szDesc); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetInterfaceVersionStringEx +// +//! This function returns a string describing the version of the NvAPI library. +//! The contents of the string are human readable. Do not assume a fixed format. +//! +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 450 +//! +//! \param szDesc User readable string giving NvAPI version information +//! +//! \return See \ref nvapistatus for the list of possible return values. +//! \ingroup nvapifunctions +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetInterfaceVersionStringEx(NvAPI_ShortString szDesc); + + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// All display port related data types definition starts +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +// This category is intentionally added before the #ifdef. The #endif should also be in the same scope + +#ifndef DISPLAYPORT_STRUCTS_DEFINED +#define DISPLAYPORT_STRUCTS_DEFINED + +//! \ingroup dispcontrol +//! Used in NV_DISPLAY_PORT_INFO. +typedef enum _NV_DP_LINK_RATE +{ + NV_DP_1_62GBPS = 6, + NV_DP_2_70GBPS = 0xA, + NV_DP_5_40GBPS = 0x14, + NV_DP_8_10GBPS = 0x1E, +// Recommended Intermidiate Link Transfer Rates + NV_EDP_2_16GBPS = 8, + NV_EDP_2_43GBPS = 9, + NV_EDP_3_24GBPS = 0xC, + NV_EDP_4_32GBPS = 0x10 +} NV_DP_LINK_RATE; + + +//! \ingroup dispcontrol +//! Used in NV_DISPLAY_PORT_INFO. +typedef enum _NV_DP_LANE_COUNT +{ + NV_DP_1_LANE = 1, + NV_DP_2_LANE = 2, + NV_DP_4_LANE = 4, +} NV_DP_LANE_COUNT; + + +//! \ingroup dispcontrol +//! Used in NV_DISPLAY_PORT_INFO. +typedef enum _NV_DP_COLOR_FORMAT +{ + NV_DP_COLOR_FORMAT_RGB = 0, + NV_DP_COLOR_FORMAT_YCbCr422, + NV_DP_COLOR_FORMAT_YCbCr444, +} NV_DP_COLOR_FORMAT; + + +//! \ingroup dispcontrol +//! Used in NV_DISPLAY_PORT_INFO. +typedef enum _NV_DP_COLORIMETRY +{ + NV_DP_COLORIMETRY_RGB = 0, + NV_DP_COLORIMETRY_YCbCr_ITU601, + NV_DP_COLORIMETRY_YCbCr_ITU709, +} NV_DP_COLORIMETRY; + + +//! \ingroup dispcontrol +//! Used in NV_DISPLAY_PORT_INFO. +typedef enum _NV_DP_DYNAMIC_RANGE +{ + NV_DP_DYNAMIC_RANGE_VESA = 0, + NV_DP_DYNAMIC_RANGE_CEA, +} NV_DP_DYNAMIC_RANGE; + + +//! \ingroup dispcontrol +//! Used in NV_DISPLAY_PORT_INFO. +typedef enum _NV_DP_BPC +{ + NV_DP_BPC_DEFAULT = 0, + NV_DP_BPC_6, + NV_DP_BPC_8, + NV_DP_BPC_10, + NV_DP_BPC_12, + NV_DP_BPC_16, +} NV_DP_BPC; + + +#endif //#ifndef DISPLAYPORT_STRUCTS_DEFINED + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// All display port related data types definitions end +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetEDID +// +//! \fn NvAPI_GPU_GetEDID(NvPhysicalGpuHandle hPhysicalGpu, NvU32 displayOutputId, NV_EDID *pEDID) +//! This function returns the EDID data for the specified GPU handle and connection bit mask. +//! displayOutputId should have exactly 1 bit set to indicate a single display. See \ref handles. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 85 +//! +//! \retval NVAPI_INVALID_ARGUMENT pEDID is NULL; displayOutputId has 0 or > 1 bits set +//! \retval NVAPI_OK *pEDID contains valid data. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! \retval NVAPI_DATA_NOT_FOUND The requested display does not contain an EDID. +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup gpu +//! @{ + +#define NV_EDID_V1_DATA_SIZE 256 + +#define NV_EDID_DATA_SIZE NV_EDID_V1_DATA_SIZE + +typedef struct +{ + NvU32 version; //structure version + NvU8 EDID_Data[NV_EDID_DATA_SIZE]; +} NV_EDID_V1; + +//! Used in NvAPI_GPU_GetEDID() +typedef struct +{ + NvU32 version; //!< Structure version + NvU8 EDID_Data[NV_EDID_DATA_SIZE]; + NvU32 sizeofEDID; +} NV_EDID_V2; + +//! Used in NvAPI_GPU_GetEDID() +typedef struct +{ + NvU32 version; //!< Structure version + NvU8 EDID_Data[NV_EDID_DATA_SIZE]; + NvU32 sizeofEDID; + NvU32 edidId; //!< ID which always returned in a monotonically increasing counter. + //!< Across a split-EDID read we need to verify that all calls returned the same edidId. + //!< This counter is incremented if we get the updated EDID. + NvU32 offset; //!< Which 256-byte page of the EDID we want to read. Start at 0. + //!< If the read succeeds with edidSize > NV_EDID_DATA_SIZE, + //!< call back again with offset+256 until we have read the entire buffer +} NV_EDID_V3; + +typedef NV_EDID_V3 NV_EDID; + +#define NV_EDID_VER1 MAKE_NVAPI_VERSION(NV_EDID_V1,1) +#define NV_EDID_VER2 MAKE_NVAPI_VERSION(NV_EDID_V2,2) +#define NV_EDID_VER3 MAKE_NVAPI_VERSION(NV_EDID_V3,3) +#define NV_EDID_VER NV_EDID_VER3 + +//! @} + +//! \ingroup gpu +NVAPI_INTERFACE NvAPI_GPU_GetEDID(NvPhysicalGpuHandle hPhysicalGpu, NvU32 displayOutputId, NV_EDID *pEDID); + +//! \ingroup gpu +//! Used in NV_GPU_CONNECTOR_DATA +typedef enum _NV_GPU_CONNECTOR_TYPE +{ + NVAPI_GPU_CONNECTOR_VGA_15_PIN = 0x00000000, + NVAPI_GPU_CONNECTOR_TV_COMPOSITE = 0x00000010, + NVAPI_GPU_CONNECTOR_TV_SVIDEO = 0x00000011, + NVAPI_GPU_CONNECTOR_TV_HDTV_COMPONENT = 0x00000013, + NVAPI_GPU_CONNECTOR_TV_SCART = 0x00000014, + NVAPI_GPU_CONNECTOR_TV_COMPOSITE_SCART_ON_EIAJ4120 = 0x00000016, + NVAPI_GPU_CONNECTOR_TV_HDTV_EIAJ4120 = 0x00000017, + NVAPI_GPU_CONNECTOR_PC_POD_HDTV_YPRPB = 0x00000018, + NVAPI_GPU_CONNECTOR_PC_POD_SVIDEO = 0x00000019, + NVAPI_GPU_CONNECTOR_PC_POD_COMPOSITE = 0x0000001A, + NVAPI_GPU_CONNECTOR_DVI_I_TV_SVIDEO = 0x00000020, + NVAPI_GPU_CONNECTOR_DVI_I_TV_COMPOSITE = 0x00000021, + NVAPI_GPU_CONNECTOR_DVI_I = 0x00000030, + NVAPI_GPU_CONNECTOR_DVI_D = 0x00000031, + NVAPI_GPU_CONNECTOR_ADC = 0x00000032, + NVAPI_GPU_CONNECTOR_LFH_DVI_I_1 = 0x00000038, + NVAPI_GPU_CONNECTOR_LFH_DVI_I_2 = 0x00000039, + NVAPI_GPU_CONNECTOR_SPWG = 0x00000040, + NVAPI_GPU_CONNECTOR_OEM = 0x00000041, + NVAPI_GPU_CONNECTOR_DISPLAYPORT_EXTERNAL = 0x00000046, + NVAPI_GPU_CONNECTOR_DISPLAYPORT_INTERNAL = 0x00000047, + NVAPI_GPU_CONNECTOR_DISPLAYPORT_MINI_EXT = 0x00000048, + NVAPI_GPU_CONNECTOR_HDMI_A = 0x00000061, + NVAPI_GPU_CONNECTOR_HDMI_C_MINI = 0x00000063, + NVAPI_GPU_CONNECTOR_LFH_DISPLAYPORT_1 = 0x00000064, + NVAPI_GPU_CONNECTOR_LFH_DISPLAYPORT_2 = 0x00000065, + NVAPI_GPU_CONNECTOR_VIRTUAL_WFD = 0x00000070, //!< Deprecated. + NVAPI_GPU_CONNECTOR_USB_C = 0x00000071, + NVAPI_GPU_CONNECTOR_UNKNOWN = 0xFFFFFFFF, +} NV_GPU_CONNECTOR_TYPE; + +//////////////////////////////////////////////////////////////////////////////// +// +// NvAPI_TVOutput Information +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup tvapi +//! Used in NV_DISPLAY_TV_OUTPUT_INFO +typedef enum _NV_DISPLAY_TV_FORMAT +{ + NV_DISPLAY_TV_FORMAT_NONE = 0, + NV_DISPLAY_TV_FORMAT_SD_NTSCM = 0x00000001, + NV_DISPLAY_TV_FORMAT_SD_NTSCJ = 0x00000002, + NV_DISPLAY_TV_FORMAT_SD_PALM = 0x00000004, + NV_DISPLAY_TV_FORMAT_SD_PALBDGH = 0x00000008, + NV_DISPLAY_TV_FORMAT_SD_PALN = 0x00000010, + NV_DISPLAY_TV_FORMAT_SD_PALNC = 0x00000020, + NV_DISPLAY_TV_FORMAT_SD_576i = 0x00000100, + NV_DISPLAY_TV_FORMAT_SD_480i = 0x00000200, + NV_DISPLAY_TV_FORMAT_ED_480p = 0x00000400, + NV_DISPLAY_TV_FORMAT_ED_576p = 0x00000800, + NV_DISPLAY_TV_FORMAT_HD_720p = 0x00001000, + NV_DISPLAY_TV_FORMAT_HD_1080i = 0x00002000, + NV_DISPLAY_TV_FORMAT_HD_1080p = 0x00004000, + NV_DISPLAY_TV_FORMAT_HD_720p50 = 0x00008000, + NV_DISPLAY_TV_FORMAT_HD_1080p24 = 0x00010000, + NV_DISPLAY_TV_FORMAT_HD_1080i50 = 0x00020000, + NV_DISPLAY_TV_FORMAT_HD_1080p50 = 0x00040000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp30 = 0x00080000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp30_3840 = NV_DISPLAY_TV_FORMAT_UHD_4Kp30, + NV_DISPLAY_TV_FORMAT_UHD_4Kp25 = 0x00100000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp25_3840 = NV_DISPLAY_TV_FORMAT_UHD_4Kp25, + NV_DISPLAY_TV_FORMAT_UHD_4Kp24 = 0x00200000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp24_3840 = NV_DISPLAY_TV_FORMAT_UHD_4Kp24, + NV_DISPLAY_TV_FORMAT_UHD_4Kp24_SMPTE = 0x00400000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp50_3840 = 0x00800000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp60_3840 = 0x00900000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp30_4096 = 0x00A00000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp25_4096 = 0x00B00000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp24_4096 = 0x00C00000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp50_4096 = 0x00D00000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp60_4096 = 0x00E00000, + NV_DISPLAY_TV_FORMAT_UHD_8Kp24_7680 = 0x01000000, + NV_DISPLAY_TV_FORMAT_UHD_8Kp25_7680 = 0x02000000, + NV_DISPLAY_TV_FORMAT_UHD_8Kp30_7680 = 0x04000000, + NV_DISPLAY_TV_FORMAT_UHD_8Kp48_7680 = 0x08000000, + NV_DISPLAY_TV_FORMAT_UHD_8Kp50_7680 = 0x09000000, + NV_DISPLAY_TV_FORMAT_UHD_8Kp60_7680 = 0x0A000000, + NV_DISPLAY_TV_FORMAT_UHD_8Kp100_7680 = 0x0B000000, + NV_DISPLAY_TV_FORMAT_UHD_8Kp120_7680 = 0x0C000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp48_3840 = 0x0D000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp48_4096 = 0x0E000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp100_4096 = 0x0F000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp100_3840 = 0x10000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp120_4096 = 0x11000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp120_3840 = 0x12000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp100_5120 = 0x13000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp120_5120 = 0x14000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp24_5120 = 0x15000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp25_5120 = 0x16000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp30_5120 = 0x17000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp48_5120 = 0x18000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp50_5120 = 0x19000000, + NV_DISPLAY_TV_FORMAT_UHD_4Kp60_5120 = 0x20000000, + NV_DISPLAY_TV_FORMAT_UHD_10Kp24_10240 = 0x21000000, + NV_DISPLAY_TV_FORMAT_UHD_10Kp25_10240 = 0x22000000, + NV_DISPLAY_TV_FORMAT_UHD_10Kp30_10240 = 0x23000000, + NV_DISPLAY_TV_FORMAT_UHD_10Kp48_10240 = 0x24000000, + NV_DISPLAY_TV_FORMAT_UHD_10Kp50_10240 = 0x25000000, + NV_DISPLAY_TV_FORMAT_UHD_10Kp60_10240 = 0x26000000, + NV_DISPLAY_TV_FORMAT_UHD_10Kp100_10240 = 0x27000000, + NV_DISPLAY_TV_FORMAT_UHD_10Kp120_10240 = 0x28000000, + + + NV_DISPLAY_TV_FORMAT_SD_OTHER = 0x30000000, + NV_DISPLAY_TV_FORMAT_ED_OTHER = 0x40000000, + NV_DISPLAY_TV_FORMAT_HD_OTHER = 0x50000000, + + NV_DISPLAY_TV_FORMAT_ANY = 0x80000000, + +} NV_DISPLAY_TV_FORMAT; + + +//! \ingroup dispcontrol +//! @{ +#define NVAPI_MAX_VIEW_TARGET 2 +#define NVAPI_ADVANCED_MAX_VIEW_TARGET 4 + +#ifndef _NV_TARGET_VIEW_MODE_ +#define _NV_TARGET_VIEW_MODE_ + +//! Used in NvAPI_SetView(). +typedef enum _NV_TARGET_VIEW_MODE +{ + NV_VIEW_MODE_STANDARD = 0, + NV_VIEW_MODE_CLONE = 1, + NV_VIEW_MODE_HSPAN = 2, + NV_VIEW_MODE_VSPAN = 3, + NV_VIEW_MODE_DUALVIEW = 4, + NV_VIEW_MODE_MULTIVIEW = 5, +} NV_TARGET_VIEW_MODE; +#endif + +//! @} + +// Following definitions are used in NvAPI_SetViewEx. + +//! Scaling modes - used in NvAPI_SetViewEx(). +//! \ingroup dispcontrol +typedef enum _NV_SCALING +{ + NV_SCALING_DEFAULT = 0, //!< No change + + // New Scaling Declarations + NV_SCALING_GPU_SCALING_TO_CLOSEST = 1, //!< Balanced - Full Screen + NV_SCALING_GPU_SCALING_TO_NATIVE = 2, //!< Force GPU - Full Screen + NV_SCALING_GPU_SCANOUT_TO_NATIVE = 3, //!< Force GPU - Centered\No Scaling + NV_SCALING_GPU_SCALING_TO_ASPECT_SCANOUT_TO_NATIVE = 5, //!< Force GPU - Aspect Ratio + NV_SCALING_GPU_SCALING_TO_ASPECT_SCANOUT_TO_CLOSEST = 6, //!< Balanced - Aspect Ratio + NV_SCALING_GPU_SCANOUT_TO_CLOSEST = 7, //!< Balanced - Centered\No Scaling + NV_SCALING_GPU_INTEGER_ASPECT_SCALING = 8, //!< Force GPU - Integer Scaling + + // Legacy Declarations + NV_SCALING_MONITOR_SCALING = NV_SCALING_GPU_SCALING_TO_CLOSEST, + NV_SCALING_ADAPTER_SCALING = NV_SCALING_GPU_SCALING_TO_NATIVE, + NV_SCALING_CENTERED = NV_SCALING_GPU_SCANOUT_TO_NATIVE, + NV_SCALING_ASPECT_SCALING = NV_SCALING_GPU_SCALING_TO_ASPECT_SCANOUT_TO_NATIVE, + + NV_SCALING_CUSTOMIZED = 255 //!< For future use +} NV_SCALING; + +//! Rotate modes- used in NvAPI_SetViewEx(). + +//! \ingroup dispcontrol +typedef enum _NV_ROTATE +{ + NV_ROTATE_0 = 0, + NV_ROTATE_90 = 1, + NV_ROTATE_180 = 2, + NV_ROTATE_270 = 3, + NV_ROTATE_IGNORED = 4, +} NV_ROTATE; + +//! Color formats- used in NvAPI_SetViewEx(). +//! \ingroup dispcontrol +#define NVFORMAT_MAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((NvU32)(NvU8)(ch0) | ((NvU32)(NvU8)(ch1) << 8) | \ + ((NvU32)(NvU8)(ch2) << 16) | ((NvU32)(NvU8)(ch3) << 24 )) + + + +//! Color formats- used in NvAPI_SetViewEx(). +//! \ingroup dispcontrol +typedef enum _NV_FORMAT +{ + NV_FORMAT_UNKNOWN = 0, //!< unknown. Driver will choose one as following value. + NV_FORMAT_P8 = 41, //!< for 8bpp mode + NV_FORMAT_R5G6B5 = 23, //!< for 16bpp mode + NV_FORMAT_A8R8G8B8 = 21, //!< for 32bpp mode + NV_FORMAT_A16B16G16R16F = 113, //!< for 64bpp(floating point) mode. + +} NV_FORMAT; + +// TV standard + +typedef struct +{ + float x; //!< x-coordinate of the viewport top-left point + float y; //!< y-coordinate of the viewport top-left point + float w; //!< Width of the viewport + float h; //!< Height of the viewport +} NV_VIEWPORTF; + + + +//! \ingroup dispcontrol +//! The timing override is not supported yet; must be set to _AUTO. \n + + +typedef enum _NV_TIMING_OVERRIDE +{ + NV_TIMING_OVERRIDE_CURRENT = 0, //!< get the current timing + NV_TIMING_OVERRIDE_AUTO, //!< the timing the driver will use based the current policy + NV_TIMING_OVERRIDE_EDID, //!< EDID timing + NV_TIMING_OVERRIDE_DMT, //!< VESA DMT timing + NV_TIMING_OVERRIDE_DMT_RB, //!< VESA DMT timing with reduced blanking + NV_TIMING_OVERRIDE_CVT, //!< VESA CVT timing + NV_TIMING_OVERRIDE_CVT_RB, //!< VESA CVT timing with reduced blanking + NV_TIMING_OVERRIDE_GTF, //!< VESA GTF timing + NV_TIMING_OVERRIDE_EIA861, //!< EIA 861x pre-defined timing + NV_TIMING_OVERRIDE_ANALOG_TV, //!< analog SD/HDTV timing + NV_TIMING_OVERRIDE_CUST, //!< NV custom timings + NV_TIMING_OVERRIDE_NV_PREDEFINED, //!< NV pre-defined timing (basically the PsF timings) + NV_TIMING_OVERRIDE_NV_PSF = NV_TIMING_OVERRIDE_NV_PREDEFINED, + NV_TIMING_OVERRIDE_NV_ASPR, + NV_TIMING_OVERRIDE_SDI, //!< Override for SDI timing + + NV_TIMING_OVRRIDE_MAX, +}NV_TIMING_OVERRIDE; + + +#ifndef NV_TIMING_STRUCTS_DEFINED +#define NV_TIMING_STRUCTS_DEFINED + +//*********************** +// The Timing Structure +//*********************** +// +//! \ingroup dispcontrol +//! NVIDIA-specific timing extras \n +//! Used in NV_TIMING. +typedef struct tagNV_TIMINGEXT +{ + NvU32 flag; //!< Reserved for NVIDIA hardware-based enhancement, such as double-scan. + NvU16 rr; //!< Logical refresh rate to present + NvU32 rrx1k; //!< Physical vertical refresh rate in 0.001Hz + NvU32 aspect; //!< Display aspect ratio Hi(aspect):horizontal-aspect, Low(aspect):vertical-aspect + NvU16 rep; //!< Bit-wise pixel repetition factor: 0x1:no pixel repetition; 0x2:each pixel repeats twice horizontally,.. + NvU32 status; //!< Timing standard + NvU8 name[40]; //!< Timing name +}NV_TIMINGEXT; + + + +//! \ingroup dispcontrol +//!The very basic timing structure based on the VESA standard: +//! \code +//! |<----------------------------htotal--------------------------->| +//! ---------"active" video-------->|<-------blanking------>|<----- +//! |<-------hvisible-------->|<-hb->|<-hfp->|<-hsw->|<-hbp->|<-hb->| +//! --------- -+-------------------------+ | | | | | +//! A A | | | | | | | +//! : : | | | | | | | +//! : : | | | | | | | +//! :vertical| addressable video | | | | | | +//! : visible| | | | | | | +//! : : | | | | | | | +//! : : | | | | | | | +//! vertical V | | | | | | | +//! total --+-------------------------+ | | | | | +//! : vb border | | | | | +//! : -----------------------------------+ | | | | +//! : vfp front porch | | | | +//! : -------------------------------------------+ | | | +//! : vsw sync width | | | +//! : ---------------------------------------------------+ | | +//! : vbp back porch | | +//! : -----------------------------------------------------------+ | +//! V vb border | +//! ---------------------------------------------------------------------------+ +//! \endcode +typedef struct _NV_TIMING +{ + // VESA scan out timing parameters: + NvU16 HVisible; //!< horizontal visible + NvU16 HBorder; //!< horizontal border + NvU16 HFrontPorch; //!< horizontal front porch + NvU16 HSyncWidth; //!< horizontal sync width + NvU16 HTotal; //!< horizontal total + NvU8 HSyncPol; //!< horizontal sync polarity: 1-negative, 0-positive + + NvU16 VVisible; //!< vertical visible + NvU16 VBorder; //!< vertical border + NvU16 VFrontPorch; //!< vertical front porch + NvU16 VSyncWidth; //!< vertical sync width + NvU16 VTotal; //!< vertical total + NvU8 VSyncPol; //!< vertical sync polarity: 1-negative, 0-positive + + NvU16 interlaced; //!< 1-interlaced, 0-progressive + NvU32 pclk; //!< pixel clock in 10 kHz + + //other timing related extras + NV_TIMINGEXT etc; +}NV_TIMING; +#endif //NV_TIMING_STRUCTS_DEFINED + + +//! \addtogroup dispcontrol +//! Timing-related constants +//! @{ +#define NV_TIMING_H_SYNC_POSITIVE 0 +#define NV_TIMING_H_SYNC_NEGATIVE 1 +#define NV_TIMING_H_SYNC_DEFAULT NV_TIMING_H_SYNC_NEGATIVE +// +#define NV_TIMING_V_SYNC_POSITIVE 0 +#define NV_TIMING_V_SYNC_NEGATIVE 1 +#define NV_TIMING_V_SYNC_DEFAULT NV_TIMING_V_SYNC_POSITIVE +// +#define NV_TIMING_PROGRESSIVE 0 +#define NV_TIMING_INTERLACED 1 +#define NV_TIMING_INTERLACED_EXTRA_VBLANK_ON_FIELD2 1 +#define NV_TIMING_INTERLACED_NO_EXTRA_VBLANK_ON_FIELD2 2 +//! @} + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_SetView +// +//! \fn NvAPI_SetView(NvDisplayHandle hNvDisplay, NV_VIEW_TARGET_INFO *pTargetInfo, NV_TARGET_VIEW_MODE targetView) +//! This function lets the caller modify the target display arrangement of the selected source display handle in any nView mode. +//! It can also modify or extend the source display in Dualview mode. +//! \note Maps the selected source to the associated target Ids. +//! \note Display PATH with this API is limited to single GPU. DUALVIEW across GPUs cannot be enabled with this API. +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_DISP_SetDisplayConfig. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 90 +//! +//! \param [in] hNvDisplay NVIDIA Display selection. #NVAPI_DEFAULT_HANDLE is not allowed, it has to be a handle enumerated with NvAPI_EnumNVidiaDisplayHandle(). +//! \param [in] pTargetInfo Pointer to array of NV_VIEW_TARGET_INFO, specifying device properties in this view. +//! The first device entry in the array is the physical primary. +//! The device entry with the lowest source id is the desktop primary. +//! \param [in] targetCount Count of target devices specified in pTargetInfo. +//! \param [in] targetView Target view selected from NV_TARGET_VIEW_MODE. +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred +//! \retval NVAPI_INVALID_ARGUMENT Invalid input parameter. +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup dispcontrol +//! Used in NvAPI_SetView() and NvAPI_GetView() +typedef struct +{ + NvU32 version; //!< (IN) structure version + NvU32 count; //!< (IN) target count + struct + { + NvU32 deviceMask; //!< (IN/OUT) Device mask + NvU32 sourceId; //!< (IN/OUT) Source ID - values will be based on the number of heads exposed per GPU. + NvU32 bPrimary:1; //!< (OUT) Indicates if this is the GPU's primary view target. This is not the desktop GDI primary. + //!< NvAPI_SetView automatically selects the first target in NV_VIEW_TARGET_INFO index 0 as the GPU's primary view. + NvU32 bInterlaced:1; //!< (IN/OUT) Indicates if the timing being used on this monitor is interlaced. + NvU32 bGDIPrimary:1; //!< (IN/OUT) Indicates if this is the desktop GDI primary. + NvU32 bForceModeSet:1;//!< (IN) Used only on Win7 and higher during a call to NvAPI_SetView(). Turns off optimization & forces OS to set supplied mode. + } target[NVAPI_MAX_VIEW_TARGET]; +} NV_VIEW_TARGET_INFO; + +//! \ingroup dispcontrol +#define NV_VIEW_TARGET_INFO_VER MAKE_NVAPI_VERSION(NV_VIEW_TARGET_INFO,2) + + +//! \ingroup dispcontrol +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 290. Instead, use NvAPI_DISP_SetDisplayConfig.") +NVAPI_INTERFACE NvAPI_SetView(NvDisplayHandle hNvDisplay, NV_VIEW_TARGET_INFO *pTargetInfo, NV_TARGET_VIEW_MODE targetView); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_SetViewEx +// +//! \fn NvAPI_SetViewEx(NvDisplayHandle hNvDisplay, NV_DISPLAY_PATH_INFO *pPathInfo, NV_TARGET_VIEW_MODE displayView) +//! This function lets caller to modify the display arrangement for selected source display handle in any of the nview modes. +//! It also allows to modify or extend the source display in dualview mode. +//! \note Maps the selected source to the associated target Ids. +//! \note Display PATH with this API is limited to single GPU. DUALVIEW across GPUs cannot be enabled with this API. +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_DISP_SetDisplayConfig. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 95 +//! +//! \param [in] hNvDisplay NVIDIA Display selection. #NVAPI_DEFAULT_HANDLE is not allowed, it has to be a handle enumerated with +//! NvAPI_EnumNVidiaDisplayHandle(). +//! \param [in] pPathInfo Pointer to array of NV_VIEW_PATH_INFO, specifying device properties in this view. +//! The first device entry in the array is the physical primary. +//! The device entry with the lowest source id is the desktop primary. +//! \param [in] pathCount Count of paths specified in pPathInfo. +//! \param [in] displayView Display view selected from NV_TARGET_VIEW_MODE. +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred +//! \retval NVAPI_INVALID_ARGUMENT Invalid input parameter. +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup dispcontrol +#define NVAPI_MAX_DISPLAY_PATH NVAPI_MAX_VIEW_TARGET + +//! \ingroup dispcontrol +#define NVAPI_ADVANCED_MAX_DISPLAY_PATH NVAPI_ADVANCED_MAX_VIEW_TARGET + + + +//! \ingroup dispcontrol +//! Used in NV_DISPLAY_PATH_INFO. +typedef struct +{ + NvU32 deviceMask; //!< (IN) Device mask + NvU32 sourceId; //!< (IN) Values will be based on the number of heads exposed per GPU(0, 1?) + NvU32 bPrimary:1; //!< (IN/OUT) Indicates if this is the GPU's primary view target. This is not the desktop GDI primary. + //!< NvAPI_SetViewEx() automatically selects the first target in NV_DISPLAY_PATH_INFO index 0 as the GPU's primary view. + NV_GPU_CONNECTOR_TYPE connector; //!< (IN) Specify connector type. For TV only. + + // source mode information + NvU32 width; //!< (IN) Width of the mode + NvU32 height; //!< (IN) Height of the mode + NvU32 depth; //!< (IN) Depth of the mode + NV_FORMAT colorFormat; //!< Color format if it needs to be specified. Not used now. + + //rotation setting of the mode + NV_ROTATE rotation; //!< (IN) Rotation setting. + + // the scaling mode + NV_SCALING scaling; //!< (IN) Scaling setting + + // Timing info + NvU32 refreshRate; //!< (IN) Refresh rate of the mode + NvU32 interlaced:1; //!< (IN) Interlaced mode flag + + NV_DISPLAY_TV_FORMAT tvFormat; //!< (IN) To choose the last TV format set this value to NV_DISPLAY_TV_FORMAT_NONE + + // Windows desktop position + NvU32 posx; //!< (IN/OUT) X-offset of this display on the Windows desktop + NvU32 posy; //!< (IN/OUT) Y-offset of this display on the Windows desktop + NvU32 bGDIPrimary:1; //!< (IN/OUT) Indicates if this is the desktop GDI primary. + + NvU32 bForceModeSet:1;//!< (IN) Used only on Win7 and higher during a call to NvAPI_SetViewEx(). Turns off optimization & forces OS to set supplied mode. + NvU32 bFocusDisplay:1;//!< (IN) If set, this display path should have the focus after the GPU topology change + NvU32 gpuId:24; //!< (IN) the physical display/target Gpu id which is the owner of the scan out (for SLI multimon, display from the slave Gpu) + +} NV_DISPLAY_PATH; + +//! \ingroup dispcontrol +//! Used in NvAPI_SetViewEx() and NvAPI_GetViewEx(). +typedef struct +{ + NvU32 version; //!< (IN) Structure version + NvU32 count; //!< (IN) Path count + NV_DISPLAY_PATH path[NVAPI_MAX_DISPLAY_PATH]; +} NV_DISPLAY_PATH_INFO_V3; + +//! \ingroup dispcontrol +//! Used in NvAPI_SetViewEx() and NvAPI_GetViewEx(). +typedef struct +{ + NvU32 version; //!< (IN) Structure version + NvU32 count; //!< (IN) Path count + NV_DISPLAY_PATH path[NVAPI_ADVANCED_MAX_DISPLAY_PATH]; +} NV_DISPLAY_PATH_INFO; + +//! \addtogroup dispcontrol +//! Macro for constructing the version fields of NV_DISPLAY_PATH_INFO +//! @{ +#define NV_DISPLAY_PATH_INFO_VER NV_DISPLAY_PATH_INFO_VER4 +#define NV_DISPLAY_PATH_INFO_VER4 MAKE_NVAPI_VERSION(NV_DISPLAY_PATH_INFO,4) +#define NV_DISPLAY_PATH_INFO_VER3 MAKE_NVAPI_VERSION(NV_DISPLAY_PATH_INFO,3) +#define NV_DISPLAY_PATH_INFO_VER2 MAKE_NVAPI_VERSION(NV_DISPLAY_PATH_INFO,2) +#define NV_DISPLAY_PATH_INFO_VER1 MAKE_NVAPI_VERSION(NV_DISPLAY_PATH_INFO,1) +//! @} +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_SetViewEx +// +//! \fn NvAPI_SetViewEx(NvDisplayHandle hNvDisplay, NV_DISPLAY_PATH_INFO *pPathInfo, NV_TARGET_VIEW_MODE displayView) +//! This function lets caller to modify the display arrangement for selected source display handle in any of the nview modes. +//! It also allows to modify or extend the source display in dualview mode. +//! \note Maps the selected source to the associated target Ids. +//! \note Display PATH with this API is limited to single GPU. DUALVIEW across GPUs cannot be enabled with this API. +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_DISP_SetDisplayConfig. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 95 +//! +//! \param [in] hNvDisplay NVIDIA Display selection. #NVAPI_DEFAULT_HANDLE is not allowed, it has to be a handle enumerated with +//! NvAPI_EnumNVidiaDisplayHandle(). +//! \param [in] pPathInfo Pointer to array of NV_VIEW_PATH_INFO, specifying device properties in this view. +//! The first device entry in the array is the physical primary. +//! The device entry with the lowest source id is the desktop primary. +//! \param [in] pathCount Count of paths specified in pPathInfo. +//! \param [in] displayView Display view selected from NV_TARGET_VIEW_MODE. +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred +//! \retval NVAPI_INVALID_ARGUMENT Invalid input parameter. +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup dispcontrol +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 290. Instead, use NvAPI_DISP_SetDisplayConfig.") +NVAPI_INTERFACE NvAPI_SetViewEx(NvDisplayHandle hNvDisplay, NV_DISPLAY_PATH_INFO *pPathInfo, NV_TARGET_VIEW_MODE displayView); + + + +/////////////////////////////////////////////////////////////////////////////// +// SetDisplayConfig/GetDisplayConfig +/////////////////////////////////////////////////////////////////////////////// +//! \ingroup dispcontrol + +typedef struct _NV_POSITION +{ + NvS32 x; + NvS32 y; +} NV_POSITION; + +//! \ingroup dispcontrol +typedef struct _NV_RESOLUTION +{ + NvU32 width; + NvU32 height; + NvU32 colorDepth; +} NV_RESOLUTION; + +//! \ingroup dispcontrol +typedef struct _NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO_V1 +{ + NvU32 version; + + // Rotation and Scaling + NV_ROTATE rotation; //!< (IN) rotation setting. + NV_SCALING scaling; //!< (IN) scaling setting. + + // Refresh Rate + NvU32 refreshRate1K; //!< (IN) Non-interlaced Refresh Rate of the mode, multiplied by 1000, 0 = ignored + //!< This is the value which driver reports to the OS. + // Flags + NvU32 interlaced:1; //!< (IN) Interlaced mode flag, ignored if refreshRate == 0 + NvU32 primary:1; //!< (IN) Declares primary display in clone configuration. This is *NOT* GDI Primary. + //!< Only one target can be primary per source. If no primary is specified, the first + //!< target will automatically be primary. +#ifdef NV_PAN_AND_SCAN_DEFINED + NvU32 isPanAndScanTarget:1; //!< Whether on this target Pan and Scan is enabled or has to be enabled. Valid only + //!< when the target is part of clone topology. +#else + NvU32 reservedBit1:1; +#endif + NvU32 disableVirtualModeSupport:1; + NvU32 isPreferredUnscaledTarget:1; + NvU32 reserved:27; + // TV format information + NV_GPU_CONNECTOR_TYPE connector; //!< Specify connector type. For TV only, ignored if tvFormat == NV_DISPLAY_TV_FORMAT_NONE + NV_DISPLAY_TV_FORMAT tvFormat; //!< (IN) to choose the last TV format set this value to NV_DISPLAY_TV_FORMAT_NONE + //!< In case of NvAPI_DISP_GetDisplayConfig(), this field will indicate the currently applied TV format; + //!< if no TV format is applied, this field will have NV_DISPLAY_TV_FORMAT_NONE value. + //!< In case of NvAPI_DISP_SetDisplayConfig(), this field should only be set in case of TVs; + //!< for other displays this field will be ignored and resolution & refresh rate specified in input will be used to apply the TV format. + + // Backend (raster) timing standard + NV_TIMING_OVERRIDE timingOverride; //!< Ignored if timingOverride == NV_TIMING_OVERRIDE_CURRENT + NV_TIMING timing; //!< Scan out timing, valid only if timingOverride == NV_TIMING_OVERRIDE_CUST + //!< The value NV_TIMING::NV_TIMINGEXT::rrx1k is obtained from the EDID. The driver may + //!< tweak this value for HDTV, stereo, etc., before reporting it to the OS. +} NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO_V1; + +//! \ingroup dispcontrol +typedef NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO_V1 NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO; + +//! \ingroup dispcontrol +#define NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO_VER1 MAKE_NVAPI_VERSION(NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO_V1,1) + +//! \ingroup dispcontrol +#define NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO_VER NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO_VER1 + +//! \ingroup dispcontrol +typedef struct _NV_DISPLAYCONFIG_PATH_TARGET_INFO_V1 +{ + NvU32 displayId; //!< Display ID + NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO* details; //!< May be NULL if no advanced settings are required. NULL for Non-NVIDIA Display. +} NV_DISPLAYCONFIG_PATH_TARGET_INFO_V1; + +//! \ingroup dispcontrol +typedef struct _NV_DISPLAYCONFIG_PATH_TARGET_INFO_V2 +{ + NvU32 displayId; //!< Display ID + NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO* details; //!< May be NULL if no advanced settings are required + NvU32 targetId; //!< Windows CCD target ID. Must be present only for non-NVIDIA adapter, for NVIDIA adapter this parameter is ignored. +} NV_DISPLAYCONFIG_PATH_TARGET_INFO_V2; + + +//! \ingroup dispcontrol +//! As version is not defined for this structure, we will be using version of NV_DISPLAYCONFIG_PATH_INFO +typedef NV_DISPLAYCONFIG_PATH_TARGET_INFO_V2 NV_DISPLAYCONFIG_PATH_TARGET_INFO; + + +//! \ingroup dispcontrol +typedef enum _NV_DISPLAYCONFIG_SPANNING_ORIENTATION +{ + NV_DISPLAYCONFIG_SPAN_NONE = 0, + NV_DISPLAYCONFIG_SPAN_HORIZONTAL = 1, + NV_DISPLAYCONFIG_SPAN_VERTICAL = 2, +} NV_DISPLAYCONFIG_SPANNING_ORIENTATION; + +//! \ingroup dispcontrol +typedef struct _NV_DISPLAYCONFIG_SOURCE_MODE_INFO_V1 +{ + NV_RESOLUTION resolution; + NV_FORMAT colorFormat; //!< Ignored at present, must be NV_FORMAT_UNKNOWN (0) + NV_POSITION position; //!< Is all positions are 0 or invalid, displays will be automatically + //!< positioned from left to right with GDI Primary at 0,0, and all + //!< other displays in the order of the path array. + NV_DISPLAYCONFIG_SPANNING_ORIENTATION spanningOrientation; //!< Spanning is only supported on XP + NvU32 bGDIPrimary : 1; + NvU32 bSLIFocus : 1; + NvU32 reserved : 30; //!< Must be 0 +} NV_DISPLAYCONFIG_SOURCE_MODE_INFO_V1; + + + +//! \ingroup dispcontrol +typedef struct _NV_DISPLAYCONFIG_PATH_INFO_V1 +{ + NvU32 version; + NvU32 reserved_sourceId; //!< This field is reserved. There is ongoing debate if we need this field. + //!< Identifies sourceIds used by Windows. If all sourceIds are 0, + //!< these will be computed automatically. + NvU32 targetInfoCount; //!< Number of elements in targetInfo array + NV_DISPLAYCONFIG_PATH_TARGET_INFO_V1* targetInfo; + NV_DISPLAYCONFIG_SOURCE_MODE_INFO_V1* sourceModeInfo; //!< May be NULL if mode info is not important +} NV_DISPLAYCONFIG_PATH_INFO_V1; + +//! \ingroup dispcontrol +//! This define is temporary and must be removed once DVS failure is fixed. +#define _NV_DISPLAYCONFIG_PATH_INFO_V2 _NV_DISPLAYCONFIG_PATH_INFO + +//! \ingroup dispcontrol +typedef struct _NV_DISPLAYCONFIG_PATH_INFO_V2 +{ + NvU32 version; + union { + NvU32 sourceId; //!< Identifies sourceId used by Windows CCD. This can be optionally set. + NvU32 reserved_sourceId; //!< Only for compatibility + }; + + NvU32 targetInfoCount; //!< Number of elements in targetInfo array + NV_DISPLAYCONFIG_PATH_TARGET_INFO_V2* targetInfo; + NV_DISPLAYCONFIG_SOURCE_MODE_INFO_V1* sourceModeInfo; //!< May be NULL if mode info is not important + NvU32 IsNonNVIDIAAdapter : 1; //!< True for non-NVIDIA adapter. + NvU32 reserved : 31; //!< Must be 0 + void *pOSAdapterID; //!< Used by Non-NVIDIA adapter for pointer to OS Adapter of LUID + //!< type, type casted to void *. +} NV_DISPLAYCONFIG_PATH_INFO_V2; + +//! \ingroup dispcontrol +#define NV_DISPLAYCONFIG_PATH_INFO_VER1 MAKE_NVAPI_VERSION(NV_DISPLAYCONFIG_PATH_INFO_V1,1) + +//! \ingroup dispcontrol +#define NV_DISPLAYCONFIG_PATH_INFO_VER2 MAKE_NVAPI_VERSION(NV_DISPLAYCONFIG_PATH_INFO_V2,2) + +#ifndef NV_DISPLAYCONFIG_PATH_INFO_VER + +typedef NV_DISPLAYCONFIG_PATH_INFO_V2 NV_DISPLAYCONFIG_PATH_INFO; + +#define NV_DISPLAYCONFIG_PATH_INFO_VER NV_DISPLAYCONFIG_PATH_INFO_VER2 + +typedef NV_DISPLAYCONFIG_SOURCE_MODE_INFO_V1 NV_DISPLAYCONFIG_SOURCE_MODE_INFO; + +#endif + + +//! \ingroup dispcontrol +typedef enum _NV_DISPLAYCONFIG_FLAGS +{ + NV_DISPLAYCONFIG_VALIDATE_ONLY = 0x00000001, + NV_DISPLAYCONFIG_SAVE_TO_PERSISTENCE = 0x00000002, + NV_DISPLAYCONFIG_DRIVER_RELOAD_ALLOWED = 0x00000004, //!< Driver reload is permitted if necessary + NV_DISPLAYCONFIG_FORCE_MODE_ENUMERATION = 0x00000008, //!< Refresh OS mode list. + NV_FORCE_COMMIT_VIDPN = 0x00000010, //!< Tell OS to avoid optimizing CommitVidPn call during a modeset +} NV_DISPLAYCONFIG_FLAGS; + + +#define NVAPI_UNICODE_STRING_MAX 2048 +#define NVAPI_BINARY_DATA_MAX 4096 + +typedef NvU16 NvAPI_UnicodeString[NVAPI_UNICODE_STRING_MAX]; +typedef const NvU16 *NvAPI_LPCWSTR; + +// Common + + + +//! \ingroup gpuclock +//! @{ +#define NVAPI_MAX_GPU_CLOCKS 32 +#define NVAPI_MAX_GPU_PUBLIC_CLOCKS 32 +#define NVAPI_MAX_GPU_PERF_CLOCKS 32 +#define NVAPI_MAX_GPU_PERF_VOLTAGES 16 +#define NVAPI_MAX_GPU_PERF_PSTATES 16 +//! @} + +//! \ingroup gpuclock +typedef enum _NV_GPU_PERF_VOLTAGE_INFO_DOMAIN_ID +{ + NVAPI_GPU_PERF_VOLTAGE_INFO_DOMAIN_CORE = 0, + NVAPI_GPU_PERF_VOLTAGE_INFO_DOMAIN_UNDEFINED = NVAPI_MAX_GPU_PERF_VOLTAGES, +} NV_GPU_PERF_VOLTAGE_INFO_DOMAIN_ID; + +//! \ingroup gpuclock +typedef enum _NV_GPU_PUBLIC_CLOCK_ID +{ + NVAPI_GPU_PUBLIC_CLOCK_GRAPHICS = 0, + NVAPI_GPU_PUBLIC_CLOCK_MEMORY = 4, + NVAPI_GPU_PUBLIC_CLOCK_PROCESSOR = 7, + NVAPI_GPU_PUBLIC_CLOCK_VIDEO = 8, + NVAPI_GPU_PUBLIC_CLOCK_UNDEFINED = NVAPI_MAX_GPU_PUBLIC_CLOCKS, +} NV_GPU_PUBLIC_CLOCK_ID; + + +//! \addtogroup gpupstate +//! @{ + +typedef enum _NV_GPU_PERF_PSTATE_ID +{ + NVAPI_GPU_PERF_PSTATE_P0 = 0, + NVAPI_GPU_PERF_PSTATE_P1, + NVAPI_GPU_PERF_PSTATE_P2, + NVAPI_GPU_PERF_PSTATE_P3, + NVAPI_GPU_PERF_PSTATE_P4, + NVAPI_GPU_PERF_PSTATE_P5, + NVAPI_GPU_PERF_PSTATE_P6, + NVAPI_GPU_PERF_PSTATE_P7, + NVAPI_GPU_PERF_PSTATE_P8, + NVAPI_GPU_PERF_PSTATE_P9, + NVAPI_GPU_PERF_PSTATE_P10, + NVAPI_GPU_PERF_PSTATE_P11, + NVAPI_GPU_PERF_PSTATE_P12, + NVAPI_GPU_PERF_PSTATE_P13, + NVAPI_GPU_PERF_PSTATE_P14, + NVAPI_GPU_PERF_PSTATE_P15, + NVAPI_GPU_PERF_PSTATE_UNDEFINED = NVAPI_MAX_GPU_PERF_PSTATES, + NVAPI_GPU_PERF_PSTATE_ALL, + +} NV_GPU_PERF_PSTATE_ID; + +//! @} + + + +//! \addtogroup gpupstate +//! @{ + +#define NVAPI_MAX_GPU_PSTATE20_PSTATES 16 +#define NVAPI_MAX_GPU_PSTATE20_CLOCKS 8 +#define NVAPI_MAX_GPU_PSTATE20_BASE_VOLTAGES 4 + +//! Used to identify clock type +typedef enum +{ + //! Clock domains that use single frequency value within given pstate + NVAPI_GPU_PERF_PSTATE20_CLOCK_TYPE_SINGLE = 0, + + //! Clock domains that allow range of frequency values within given pstate + NVAPI_GPU_PERF_PSTATE20_CLOCK_TYPE_RANGE, +} NV_GPU_PERF_PSTATE20_CLOCK_TYPE_ID; + +//! Used to describe both voltage and frequency deltas +typedef struct +{ + //! Value of parameter delta (in respective units [kHz, uV]) + NvS32 value; + + struct + { + //! Min value allowed for parameter delta (in respective units [kHz, uV]) + NvS32 min; + + //! Max value allowed for parameter delta (in respective units [kHz, uV]) + NvS32 max; + } valueRange; +} NV_GPU_PERF_PSTATES20_PARAM_DELTA; + +//! Used to describe single clock entry +typedef struct +{ + //! ID of the clock domain + NV_GPU_PUBLIC_CLOCK_ID domainId; + + //! Clock type ID + NV_GPU_PERF_PSTATE20_CLOCK_TYPE_ID typeId; + NvU32 bIsEditable:1; + + //! These bits are reserved for future use (must be always 0) + NvU32 reserved:31; + + //! Current frequency delta from nominal settings in (kHz) + NV_GPU_PERF_PSTATES20_PARAM_DELTA freqDelta_kHz; + + //! Clock domain type dependant information + union + { + struct + { + //! Clock frequency within given pstate in (kHz) + NvU32 freq_kHz; + } single; + + struct + { + //! Min clock frequency within given pstate in (kHz) + NvU32 minFreq_kHz; + + //! Max clock frequency within given pstate in (kHz) + NvU32 maxFreq_kHz; + + //! Voltage domain ID and value range in (uV) required for this clock + NV_GPU_PERF_VOLTAGE_INFO_DOMAIN_ID domainId; + NvU32 minVoltage_uV; + NvU32 maxVoltage_uV; + } range; + } data; +} NV_GPU_PSTATE20_CLOCK_ENTRY_V1; + +//! Used to describe single base voltage entry +typedef struct +{ + //! ID of the voltage domain + NV_GPU_PERF_VOLTAGE_INFO_DOMAIN_ID domainId; + NvU32 bIsEditable:1; + + //! These bits are reserved for future use (must be always 0) + NvU32 reserved:31; + + //! Current base voltage settings in [uV] + NvU32 volt_uV; + + NV_GPU_PERF_PSTATES20_PARAM_DELTA voltDelta_uV; // Current base voltage delta from nominal settings in [uV] +} NV_GPU_PSTATE20_BASE_VOLTAGE_ENTRY_V1; + +//! Used in NvAPI_GPU_GetPstates20() interface call. + +typedef struct +{ + //! Version info of the structure (NV_GPU_PERF_PSTATES20_INFO_VER) + NvU32 version; + + NvU32 bIsEditable:1; + + //! These bits are reserved for future use (must be always 0) + NvU32 reserved:31; + + //! Number of populated pstates + NvU32 numPstates; + + //! Number of populated clocks (per pstate) + NvU32 numClocks; + + //! Number of populated base voltages (per pstate) + NvU32 numBaseVoltages; + + //! Performance state (P-State) settings + //! Valid index range is 0 to numPstates-1 + struct + { + //! ID of the P-State + NV_GPU_PERF_PSTATE_ID pstateId; + + NvU32 bIsEditable:1; + + //! These bits are reserved for future use (must be always 0) + NvU32 reserved:31; + + //! Array of clock entries + //! Valid index range is 0 to numClocks-1 + NV_GPU_PSTATE20_CLOCK_ENTRY_V1 clocks[NVAPI_MAX_GPU_PSTATE20_CLOCKS]; + + //! Array of baseVoltage entries + //! Valid index range is 0 to numBaseVoltages-1 + NV_GPU_PSTATE20_BASE_VOLTAGE_ENTRY_V1 baseVoltages[NVAPI_MAX_GPU_PSTATE20_BASE_VOLTAGES]; + } pstates[NVAPI_MAX_GPU_PSTATE20_PSTATES]; +} NV_GPU_PERF_PSTATES20_INFO_V1; + +//! Used in NvAPI_GPU_GetPstates20() interface call. + +typedef struct _NV_GPU_PERF_PSTATES20_INFO_V2 +{ + //! Version info of the structure (NV_GPU_PERF_PSTATES20_INFO_VER) + NvU32 version; + + NvU32 bIsEditable:1; + + //! These bits are reserved for future use (must be always 0) + NvU32 reserved:31; + + //! Number of populated pstates + NvU32 numPstates; + + //! Number of populated clocks (per pstate) + NvU32 numClocks; + + //! Number of populated base voltages (per pstate) + NvU32 numBaseVoltages; + + //! Performance state (P-State) settings + //! Valid index range is 0 to numPstates-1 + struct + { + //! ID of the P-State + NV_GPU_PERF_PSTATE_ID pstateId; + + NvU32 bIsEditable:1; + + //! These bits are reserved for future use (must be always 0) + NvU32 reserved:31; + + //! Array of clock entries + //! Valid index range is 0 to numClocks-1 + NV_GPU_PSTATE20_CLOCK_ENTRY_V1 clocks[NVAPI_MAX_GPU_PSTATE20_CLOCKS]; + + //! Array of baseVoltage entries + //! Valid index range is 0 to numBaseVoltages-1 + NV_GPU_PSTATE20_BASE_VOLTAGE_ENTRY_V1 baseVoltages[NVAPI_MAX_GPU_PSTATE20_BASE_VOLTAGES]; + } pstates[NVAPI_MAX_GPU_PSTATE20_PSTATES]; + + //! OV settings - Please refer to NVIDIA over-volting recommendation to understand impact of this functionality + //! Valid index range is 0 to numVoltages-1 + struct + { + //! Number of populated voltages + NvU32 numVoltages; + + //! Array of voltage entries + //! Valid index range is 0 to numVoltages-1 + NV_GPU_PSTATE20_BASE_VOLTAGE_ENTRY_V1 voltages[NVAPI_MAX_GPU_PSTATE20_BASE_VOLTAGES]; + } ov; +} NV_GPU_PERF_PSTATES20_INFO_V2; + +typedef NV_GPU_PERF_PSTATES20_INFO_V2 NV_GPU_PERF_PSTATES20_INFO; + +//! Macro for constructing the version field of NV_GPU_PERF_PSTATES20_INFO_V1 +#define NV_GPU_PERF_PSTATES20_INFO_VER1 MAKE_NVAPI_VERSION(NV_GPU_PERF_PSTATES20_INFO_V1,1) + +//! Macro for constructing the version field of NV_GPU_PERF_PSTATES20_INFO_V2 +#define NV_GPU_PERF_PSTATES20_INFO_VER2 MAKE_NVAPI_VERSION(NV_GPU_PERF_PSTATES20_INFO_V2,2) + +//! Macro for constructing the version field of NV_GPU_PERF_PSTATES20_INFO_V2 +#define NV_GPU_PERF_PSTATES20_INFO_VER3 MAKE_NVAPI_VERSION(NV_GPU_PERF_PSTATES20_INFO_V2,3) + +//! Macro for constructing the version field of NV_GPU_PERF_PSTATES20_INFO +#define NV_GPU_PERF_PSTATES20_INFO_VER NV_GPU_PERF_PSTATES20_INFO_VER3 + +//! @} + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetDisplayDriverVersion +//! \fn NvAPI_GetDisplayDriverVersion(NvDisplayHandle hNvDisplay, NV_DISPLAY_DRIVER_VERSION *pVersion) +//! This function returns a struct that describes aspects of the display driver +//! build. +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_SYS_GetDriverAndBranchVersion. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \param [in] hNvDisplay NVIDIA display handle. +//! \param [out] pVersion Pointer to NV_DISPLAY_DRIVER_VERSION struc +//! +//! \retval NVAPI_ERROR +//! \retval NVAPI_OK +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup driverapi +//! Used in NvAPI_GetDisplayDriverVersion() +typedef struct +{ + NvU32 version; // Structure version + NvU32 drvVersion; + NvU32 bldChangeListNum; + NvAPI_ShortString szBuildBranchString; + NvAPI_ShortString szAdapterString; +} NV_DISPLAY_DRIVER_VERSION; + +//! \ingroup driverapi +#define NV_DISPLAY_DRIVER_VERSION_VER MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_VERSION,1) + + +//! \ingroup driverapi +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 290. Instead, use NvAPI_SYS_GetDriverAndBranchVersion.") +NVAPI_INTERFACE NvAPI_GetDisplayDriverVersion(NvDisplayHandle hNvDisplay, NV_DISPLAY_DRIVER_VERSION *pVersion); + + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_OGL_ExpertModeSet[Get] +// +//! \name NvAPI_OGL_ExpertModeSet[Get] Functions +//@{ +//! This function configures OpenGL Expert Mode, an API usage feedback and +//! advice reporting mechanism. The effects of this call are +//! applied only to the current context, and are reset to the +//! defaults when the context is destroyed. +//! +//! \note This feature is valid at runtime only when GLExpert +//! functionality has been built into the OpenGL driver +//! installed on the system. All Windows Vista OpenGL +//! drivers provided by NVIDIA have this instrumentation +//! included by default. Windows XP, however, requires a +//! special display driver available with the NVIDIA +//! PerfSDK found at developer.nvidia.com. +//! +//! \note These functions are valid only for the current OpenGL +//! context. Calling these functions prior to creating a +//! context and calling MakeCurrent with it will result +//! in errors and undefined behavior. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \param expertDetailMask Mask made up of NVAPI_OGLEXPERT_DETAIL bits, +//! this parameter specifies the detail level in +//! the feedback stream. +//! +//! \param expertReportMask Mask made up of NVAPI_OGLEXPERT_REPORT bits, +//! this parameter specifies the areas of +//! functional interest. +//! +//! \param expertOutputMask Mask made up of NVAPI_OGLEXPERT_OUTPUT bits, +//! this parameter specifies the feedback output +//! location. +//! +//! \param expertCallback Used in conjunction with OUTPUT_TO_CALLBACK, +//! this is a simple callback function the user +//! may use to obtain the feedback stream. The +//! function will be called once per fully +//! qualified feedback stream extry. +//! +//! \retval NVAPI_API_NOT_INTIALIZED NVAPI not initialized +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU found +//! \retval NVAPI_OPENGL_CONTEXT_NOT_CURRENT No NVIDIA OpenGL context +//! which supports GLExpert +//! has been made current +//! \retval NVAPI_ERROR OpenGL driver failed to load properly +//! \retval NVAPI_OK Success +// +/////////////////////////////////////////////////////////////////////////////// + +//! \addtogroup oglapi +//! @{ +#define NVAPI_OGLEXPERT_DETAIL_NONE 0x00000000 +#define NVAPI_OGLEXPERT_DETAIL_ERROR 0x00000001 +#define NVAPI_OGLEXPERT_DETAIL_SWFALLBACK 0x00000002 +#define NVAPI_OGLEXPERT_DETAIL_BASIC_INFO 0x00000004 +#define NVAPI_OGLEXPERT_DETAIL_DETAILED_INFO 0x00000008 +#define NVAPI_OGLEXPERT_DETAIL_PERFORMANCE_WARNING 0x00000010 +#define NVAPI_OGLEXPERT_DETAIL_QUALITY_WARNING 0x00000020 +#define NVAPI_OGLEXPERT_DETAIL_USAGE_WARNING 0x00000040 +#define NVAPI_OGLEXPERT_DETAIL_ALL 0xFFFFFFFF + +#define NVAPI_OGLEXPERT_REPORT_NONE 0x00000000 +#define NVAPI_OGLEXPERT_REPORT_ERROR 0x00000001 +#define NVAPI_OGLEXPERT_REPORT_SWFALLBACK 0x00000002 +#define NVAPI_OGLEXPERT_REPORT_PIPELINE_VERTEX 0x00000004 +#define NVAPI_OGLEXPERT_REPORT_PIPELINE_GEOMETRY 0x00000008 +#define NVAPI_OGLEXPERT_REPORT_PIPELINE_XFB 0x00000010 +#define NVAPI_OGLEXPERT_REPORT_PIPELINE_RASTER 0x00000020 +#define NVAPI_OGLEXPERT_REPORT_PIPELINE_FRAGMENT 0x00000040 +#define NVAPI_OGLEXPERT_REPORT_PIPELINE_ROP 0x00000080 +#define NVAPI_OGLEXPERT_REPORT_PIPELINE_FRAMEBUFFER 0x00000100 +#define NVAPI_OGLEXPERT_REPORT_PIPELINE_PIXEL 0x00000200 +#define NVAPI_OGLEXPERT_REPORT_PIPELINE_TEXTURE 0x00000400 +#define NVAPI_OGLEXPERT_REPORT_OBJECT_BUFFEROBJECT 0x00000800 +#define NVAPI_OGLEXPERT_REPORT_OBJECT_TEXTURE 0x00001000 +#define NVAPI_OGLEXPERT_REPORT_OBJECT_PROGRAM 0x00002000 +#define NVAPI_OGLEXPERT_REPORT_OBJECT_FBO 0x00004000 +#define NVAPI_OGLEXPERT_REPORT_FEATURE_SLI 0x00008000 +#define NVAPI_OGLEXPERT_REPORT_ALL 0xFFFFFFFF + + +#define NVAPI_OGLEXPERT_OUTPUT_TO_NONE 0x00000000 +#define NVAPI_OGLEXPERT_OUTPUT_TO_CONSOLE 0x00000001 +#define NVAPI_OGLEXPERT_OUTPUT_TO_DEBUGGER 0x00000004 +#define NVAPI_OGLEXPERT_OUTPUT_TO_CALLBACK 0x00000008 +#define NVAPI_OGLEXPERT_OUTPUT_TO_ALL 0xFFFFFFFF + +//! @} + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION TYPE: NVAPI_OGLEXPERT_CALLBACK +// +//! DESCRIPTION: Used in conjunction with OUTPUT_TO_CALLBACK, this is a simple +//! callback function the user may use to obtain the feedback +//! stream. The function will be called once per fully qualified +//! feedback stream entry. +//! +//! \param categoryId Contains the bit from the NVAPI_OGLEXPERT_REPORT +//! mask that corresponds to the current message +//! \param messageId Unique ID for the current message +//! \param detailLevel Contains the bit from the NVAPI_OGLEXPERT_DETAIL +//! mask that corresponds to the current message +//! \param objectId Unique ID of the object that corresponds to the +//! current message +//! \param messageStr Text string from the current message +//! +//! \ingroup oglapi +/////////////////////////////////////////////////////////////////////////////// +typedef void (* NVAPI_OGLEXPERT_CALLBACK) (unsigned int categoryId, unsigned int messageId, unsigned int detailLevel, int objectId, const char *messageStr); + + + +//! \ingroup oglapi +//! SUPPORTED OS: Windows 7 and higher +//! +NVAPI_INTERFACE NvAPI_OGL_ExpertModeSet(NvU32 expertDetailLevel, + NvU32 expertReportMask, + NvU32 expertOutputMask, + NVAPI_OGLEXPERT_CALLBACK expertCallback); + +//! \addtogroup oglapi +//! SUPPORTED OS: Windows 7 and higher +//! +NVAPI_INTERFACE NvAPI_OGL_ExpertModeGet(NvU32 *pExpertDetailLevel, + NvU32 *pExpertReportMask, + NvU32 *pExpertOutputMask, + NVAPI_OGLEXPERT_CALLBACK *pExpertCallback); + +//@} +/////////////////////////////////////////////////////////////////////////////// +// +//! \name NvAPI_OGL_ExpertModeDefaultsSet[Get] Functions +//! +//@{ +//! This function configures OpenGL Expert Mode global defaults. These settings +//! apply to any OpenGL application which starts up after these +//! values are applied (i.e. these settings *do not* apply to +//! currently running applications). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \param expertDetailLevel Value which specifies the detail level in +//! the feedback stream. This is a mask made up +//! of NVAPI_OGLEXPERT_LEVEL bits. +//! +//! \param expertReportMask Mask made up of NVAPI_OGLEXPERT_REPORT bits, +//! this parameter specifies the areas of +//! functional interest. +//! +//! \param expertOutputMask Mask made up of NVAPI_OGLEXPERT_OUTPUT bits, +//! this parameter specifies the feedback output +//! location. Note that using OUTPUT_TO_CALLBACK +//! here is meaningless and has no effect, but +//! using it will not cause an error. +//! +//! \return ::NVAPI_ERROR or ::NVAPI_OK +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup oglapi +//! SUPPORTED OS: Windows 7 and higher +//! +NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsSet(NvU32 expertDetailLevel, + NvU32 expertReportMask, + NvU32 expertOutputMask); + +//! \addtogroup oglapi +//! SUPPORTED OS: Windows 7 and higher +//! +NVAPI_INTERFACE NvAPI_OGL_ExpertModeDefaultsGet(NvU32 *pExpertDetailLevel, + NvU32 *pExpertReportMask, + NvU32 *pExpertOutputMask); +//@} + + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_EnumTCCPhysicalGPUs +// +//! This function returns an array of physical GPU handles that are in TCC Mode. +//! Each handle represents a physical GPU present in the system in TCC Mode. +//! That GPU may not be visible to the OS directly. +//! +//! The array nvGPUHandle will be filled with physical GPU handle values. The returned +//! gpuCount determines how many entries in the array are valid. +//! +//! NOTE: Handles enumerated by this API are only valid for NvAPIs that are tagged as TCC_SUPPORTED +//! If handle is passed to any other API, it will fail with NVAPI_INVALID_HANDLE +//! +//! For WDDM GPU handles please use NvAPI_EnumPhysicalGPUs() +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! +//! \param [out] nvGPUHandle Physical GPU array that will contain all TCC Physical GPUs +//! \param [out] pGpuCount count represent the number of valid entries in nvGPUHandle +//! +//! +//! \retval NVAPI_INVALID_ARGUMENT nvGPUHandle or pGpuCount is NULL +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_EnumTCCPhysicalGPUs( NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_EnumLogicalGPUs +// +//! This function returns an array of logical GPU handles. +//! +//! Each handle represents one or more GPUs acting in concert as a single graphics device. +//! +//! At least one GPU must be present in the system and running an NVIDIA display driver. +//! +//! The array nvGPUHandle will be filled with logical GPU handle values. The returned +//! gpuCount determines how many entries in the array are valid. +//! +//! \note All logical GPUs handles get invalidated on a GPU topology change, so the calling +//! application is required to renum the logical GPU handles to get latest physical handle +//! mapping after every GPU topology change activated by a call to NvAPI_SetGpuTopologies(). +//! +//! To detect if SLI rendering is enabled, use NvAPI_D3D_GetCurrentSLIState(). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT nvGPUHandle or pGpuCount is NULL +//! \retval NVAPI_OK One or more handles were returned +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_EnumLogicalGPUs(NvLogicalGpuHandle nvGPUHandle[NVAPI_MAX_LOGICAL_GPUS], NvU32 *pGpuCount); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetPhysicalGPUsFromDisplay +// +//! This function returns an array of physical GPU handles associated with the specified display. +//! +//! At least one GPU must be present in the system and running an NVIDIA display driver. +//! +//! The array nvGPUHandle will be filled with physical GPU handle values. The returned +//! gpuCount determines how many entries in the array are valid. +//! +//! If the display corresponds to more than one physical GPU, the first GPU returned +//! is the one with the attached active output. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT hNvDisp is not valid; nvGPUHandle or pGpuCount is NULL +//! \retval NVAPI_OK One or more handles were returned +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND no NVIDIA GPU driving a display was found +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetPhysicalGPUsFromDisplay(NvDisplayHandle hNvDisp, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetPhysicalGPUFromUnAttachedDisplay +// +//! This function returns a physical GPU handle associated with the specified unattached display. +//! The source GPU is a physical render GPU which renders the frame buffer but may or may not drive the scan out. +//! +//! At least one GPU must be present in the system and running an NVIDIA display driver. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT hNvUnAttachedDisp is not valid or pPhysicalGpu is NULL. +//! \retval NVAPI_OK One or more handles were returned +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetPhysicalGPUFromUnAttachedDisplay(NvUnAttachedDisplayHandle hNvUnAttachedDisp, NvPhysicalGpuHandle *pPhysicalGpu); + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetLogicalGPUFromDisplay +// +//! This function returns the logical GPU handle associated with the specified display. +//! At least one GPU must be present in the system and running an NVIDIA display driver. +//! hNvDisp can be NVAPI_DEFAULT_HANDLE or a handle enumerated from NvAPI_EnumNVidiaDisplayHandle(). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT hNvDisp is not valid; pLogicalGPU is NULL +//! \retval NVAPI_OK One or more handles were returned +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetLogicalGPUFromDisplay(NvDisplayHandle hNvDisp, NvLogicalGpuHandle *pLogicalGPU); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetLogicalGPUFromPhysicalGPU +// +//! This function returns the logical GPU handle associated with specified physical GPU handle. +//! At least one GPU must be present in the system and running an NVIDIA display driver. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGPU is not valid; pLogicalGPU is NULL +//! \retval NVAPI_OK One or more handles were returned +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetLogicalGPUFromPhysicalGPU(NvPhysicalGpuHandle hPhysicalGPU, NvLogicalGpuHandle *pLogicalGPU); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetPhysicalGPUsFromLogicalGPU +// +//! This function returns the physical GPU handles associated with the specified logical GPU handle. +//! At least one GPU must be present in the system and running an NVIDIA display driver. +//! +//! The array hPhysicalGPU will be filled with physical GPU handle values. The returned +//! gpuCount determines how many entries in the array are valid. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT hLogicalGPU is not valid; hPhysicalGPU is NULL +//! \retval NVAPI_OK One or more handles were returned +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_EXPECTED_LOGICAL_GPU_HANDLE hLogicalGPU was not a logical GPU handle +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetPhysicalGPUsFromLogicalGPU(NvLogicalGpuHandle hLogicalGPU,NvPhysicalGpuHandle hPhysicalGPU[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetPhysicalGPUFromGPUID +// +//! Do not use this function for new software development. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT gpuId is zero or pPhysicalGPU is NULL +//! \retval NVAPI_OK Handle was returned +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetPhysicalGPUFromGPUID(NvU32 gpuId, NvPhysicalGpuHandle *pPhysicalGPU); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetGPUIDfromPhysicalGPU +// +//! Do not use this function for new software development. +// +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 95 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu is NULL or invalid. Re-enumerate the GPU handles. +//! \retval NVAPI_OK Handle was returned +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetGPUIDfromPhysicalGPU(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pGpuId); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetShaderSubPipeCount +// +//! DESCRIPTION: This function retrieves the number of Shader SubPipes on the GPU +//! On newer architectures, this corresponds to the number of SM units +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 170 +//! +//! RETURN STATUS: NVAPI_INVALID_ARGUMENT: pCount is NULL +//! NVAPI_OK: *pCount is set +//! NVAPI_NVIDIA_DEVICE_NOT_FOUND: no NVIDIA GPU driving a display was found +//! NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE: hPhysicalGpu was not a physical GPU handle +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetShaderSubPipeCount(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pCount); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetGpuCoreCount +// +//! DESCRIPTION: Retrieves the total number of cores defined for a GPU. +//! Returns 0 on architectures that don't define GPU cores. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \retval ::NVAPI_INVALID_ARGUMENT pCount is NULL +//! \retval ::NVAPI_OK *pCount is set +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND no NVIDIA GPU driving a display was found +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle +//! \retval ::NVAPI_NOT_SUPPORTED API call is not supported on current architecture +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetGpuCoreCount(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pCount); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetAllOutputs +// +//! This function returns set of all GPU-output identifiers as a bitmask. +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_GPU_GetAllDisplayIds. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 85 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pOutputsMask is NULL. +//! \retval NVAPI_OK *pOutputsMask contains a set of GPU-output identifiers. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 290. Instead, use NvAPI_GPU_GetAllDisplayIds.") +NVAPI_INTERFACE NvAPI_GPU_GetAllOutputs(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pOutputsMask); + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetConnectedOutputs +// +//! This function is the same as NvAPI_GPU_GetAllOutputs() but returns only the set of GPU output +//! identifiers that are connected to display devices. +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_GPU_GetConnectedDisplayIds. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pOutputsMask is NULL. +//! \retval NVAPI_OK *pOutputsMask contains a set of GPU-output identifiers. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 290. Instead, use NvAPI_GPU_GetConnectedDisplayIds.") +NVAPI_INTERFACE NvAPI_GPU_GetConnectedOutputs(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pOutputsMask); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetConnectedSLIOutputs +// +//! DESCRIPTION: This function is the same as NvAPI_GPU_GetConnectedOutputs() but returns only the set of GPU-output +//! identifiers that can be selected in an SLI configuration. +//! NOTE: This function matches NvAPI_GPU_GetConnectedOutputs() +//! - On systems which are not SLI capable. +//! - If the queried GPU is not part of a valid SLI group. +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_GPU_GetConnectedDisplayIds. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 170 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pOutputsMask is NULL +//! \retval NVAPI_OK *pOutputsMask contains a set of GPU-output identifiers +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE: hPhysicalGpu was not a physical GPU handle +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 290. Instead, use NvAPI_GPU_GetConnectedDisplayIds.") +NVAPI_INTERFACE NvAPI_GPU_GetConnectedSLIOutputs(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pOutputsMask); + + + + +//! \ingroup gpu +typedef enum +{ + NV_MONITOR_CONN_TYPE_UNINITIALIZED = 0, + NV_MONITOR_CONN_TYPE_VGA, + NV_MONITOR_CONN_TYPE_COMPONENT, + NV_MONITOR_CONN_TYPE_SVIDEO, + NV_MONITOR_CONN_TYPE_HDMI, + NV_MONITOR_CONN_TYPE_DVI, + NV_MONITOR_CONN_TYPE_LVDS, + NV_MONITOR_CONN_TYPE_DP, + NV_MONITOR_CONN_TYPE_COMPOSITE, + NV_MONITOR_CONN_TYPE_UNKNOWN = -1 +} NV_MONITOR_CONN_TYPE; + + +//! \addtogroup gpu +//! @{ +#define NV_GPU_CONNECTED_IDS_FLAG_UNCACHED NV_BIT(0) //!< Get uncached connected devices +#define NV_GPU_CONNECTED_IDS_FLAG_SLI NV_BIT(1) //!< Get devices such that those can be selected in an SLI configuration +#define NV_GPU_CONNECTED_IDS_FLAG_LIDSTATE NV_BIT(2) //!< Get devices such that to reflect the Lid State +#define NV_GPU_CONNECTED_IDS_FLAG_FAKE NV_BIT(3) //!< Get devices that includes the fake connected monitors +#define NV_GPU_CONNECTED_IDS_FLAG_EXCLUDE_MST NV_BIT(4) //!< Excludes devices that are part of the multi stream topology. + +//! @} + +//! \ingroup gpu +typedef struct _NV_GPU_DISPLAYIDS +{ + NvU32 version; + NV_MONITOR_CONN_TYPE connectorType; //!< out: vga, tv, dvi, hdmi and dp. This is reserved for future use and clients should not rely on this information. Instead get the + //!< GPU connector type from NvAPI_GPU_GetConnectorInfo/NvAPI_GPU_GetConnectorInfoEx + NvU32 displayId; //!< this is a unique identifier for each device + + NvU32 isDynamic : 1; //!< if bit is set then this display is part of MST topology and it's a dynamic + NvU32 isMultiStreamRootNode : 1; //!< if bit is set then this displayID belongs to a multi stream enabled connector(root node). Note that when multi stream is enabled and + //!< a single multi stream capable monitor is connected to it, the monitor will share the display id with the RootNode. + //!< When there is more than one monitor connected in a multi stream topology, then the root node will have a separate displayId. + NvU32 isActive : 1; //!< if bit is set then this display is being actively driven + NvU32 isCluster : 1; //!< if bit is set then this display is the representative display + NvU32 isOSVisible : 1; //!< if bit is set, then this display is reported to the OS + NvU32 isWFD : 1; //!< Deprecated. Will always return 0. + NvU32 isConnected : 1; //!< if bit is set, then this display is connected + + NvU32 reservedInternal : 10; //!< Do not use + NvU32 isPhysicallyConnected : 1; //!< if bit is set, then this display is a phycially connected display; Valid only when isConnected bit is set + NvU32 reserved : 14; //!< must be zero +} NV_GPU_DISPLAYIDS; + +//! \ingroup gpu +//! Macro for constructing the version field of ::_NV_GPU_DISPLAYIDS +#define NV_GPU_DISPLAYIDS_VER1 MAKE_NVAPI_VERSION(NV_GPU_DISPLAYIDS,1) +#define NV_GPU_DISPLAYIDS_VER2 MAKE_NVAPI_VERSION(NV_GPU_DISPLAYIDS,3) + +#define NV_GPU_DISPLAYIDS_VER NV_GPU_DISPLAYIDS_VER2 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetConnectedDisplayIds +// +//! \code +//! DESCRIPTION: Due to space limitation NvAPI_GPU_GetConnectedOutputs can return maximum 32 devices, but +//! this is no longer true for DPMST. NvAPI_GPU_GetConnectedDisplayIds will return all +//! the connected display devices in the form of displayIds for the associated hPhysicalGpu. +//! This function can accept set of flags to request cached, uncached, sli and lid to get the connected devices. +//! Default value for flags will be cached . +//! HOW TO USE: 1) for each PhysicalGpu, make a call to get the number of connected displayId's +//! using NvAPI_GPU_GetConnectedDisplayIds by passing the pDisplayIds as NULL +//! On call success: +//! 2) If pDisplayIdCount is greater than 0, allocate memory based on pDisplayIdCount. Then make a call NvAPI_GPU_GetConnectedDisplayIds to populate DisplayIds. +//! However, if pDisplayIdCount is 0, do not make this call. +//! SUPPORTED OS: Windows 7 and higher +//! +//! PARAMETERS: hPhysicalGpu (IN) - GPU selection +//! flags (IN) - One or more defines from NV_GPU_CONNECTED_IDS_FLAG_* as valid flags. +//! pDisplayIds (IN/OUT) - Pointer to an NV_GPU_DISPLAYIDS struct, each entry represents a one displayID and its attributes +//! pDisplayIdCount(OUT)- Number of displayId's. +//! +//! RETURN STATUS: NVAPI_INVALID_ARGUMENT: hPhysicalGpu or pDisplayIds or pDisplayIdCount is NULL +//! NVAPI_OK: *pDisplayIds contains a set of GPU-output identifiers +//! NVAPI_NVIDIA_DEVICE_NOT_FOUND: no NVIDIA GPU driving a display was found +//! NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE: hPhysicalGpu was not a physical GPU handle +//! \endcode +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetConnectedDisplayIds(__in NvPhysicalGpuHandle hPhysicalGpu, __inout_ecount_part_opt(*pDisplayIdCount, *pDisplayIdCount) NV_GPU_DISPLAYIDS* pDisplayIds, __inout NvU32* pDisplayIdCount, __in NvU32 flags); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetAllDisplayIds +// +//! DESCRIPTION: This API returns display IDs for all possible outputs on the GPU. +//! For DPMST connector, it will return display IDs for all the video sinks in the topology. \n +//! HOW TO USE: 1. The first call should be made to get the all display ID count. To get the display ID count, send in \n +//! a) hPhysicalGpu - a valid GPU handle(enumerated using NvAPI_EnumPhysicalGPUs()) as input, \n +//! b) pDisplayIds - NULL, as we just want to get the display ID count. \n +//! c) pDisplayIdCount - a valid pointer to NvU32, whose value is set to ZERO. \n +//! If all parameters are correct and this call is successful, this call will return the display ID's count. \n +//! 2. To get the display ID array, make the second call to NvAPI_GPU_GetAllDisplayIds() with \n +//! a) hPhysicalGpu - should be same value which was sent in first call, \n +//! b) pDisplayIds - pointer to the display ID array allocated by caller based on display ID count, \n +//! eg. malloc(sizeof(NV_GPU_DISPLAYIDS) * pDisplayIdCount). \n +//! c) pDisplayIdCount - a valid pointer to NvU32. This indicates for how many display IDs \n +//! the memory is allocated(pDisplayIds) by the caller. \n +//! If all parameters are correct and this call is successful, this call will return the display ID array and actual +//! display ID count (which was obtained in the first call to NvAPI_GPU_GetAllDisplayIds). If the input display ID count is +//! less than the actual display ID count, it will overwrite the input and give the pDisplayIdCount as actual count and the +//! API will return NVAPI_INSUFFICIENT_BUFFER. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hPhysicalGpu GPU selection. +//! \param [in,out] DisplayIds Pointer to an array of NV_GPU_DISPLAYIDS structures, each entry represents one displayID +//! and its attributes. +//! \param [in,out] pDisplayIdCount As input, this parameter indicates the number of display's id's for which caller has +//! allocated the memory. As output, it will return the actual number of display IDs. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \retval NVAPI_INSUFFICIENT_BUFFER When the input buffer(pDisplayIds) is less than the actual number of display IDs, this API +//! will return NVAPI_INSUFFICIENT_BUFFER. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetAllDisplayIds(__in NvPhysicalGpuHandle hPhysicalGpu, __inout_ecount_part_opt(*pDisplayIdCount, *pDisplayIdCount) NV_GPU_DISPLAYIDS* pDisplayIds, __inout NvU32* pDisplayIdCount); + + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetConnectedOutputsWithLidState +// +//! This function is similar to NvAPI_GPU_GetConnectedOutputs(), and returns the connected display identifiers that are connected +//! as an output mask but unlike NvAPI_GPU_GetConnectedOutputs() this API "always" reflects the Lid State in the output mask. +//! Thus if you expect the LID close state to be available in the connection mask use this API. +//! - If LID is closed then this API will remove the LID panel from the connected display identifiers. +//! - If LID is open then this API will reflect the LID panel in the connected display identifiers. +//! +//! \note This API should be used on notebook systems and on systems where the LID state is required in the connection +//! output mask. On desktop systems the returned identifiers will match NvAPI_GPU_GetConnectedOutputs(). +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_GPU_GetConnectedDisplayIds. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 95 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pOutputsMask is NULL +//! \retval NVAPI_OK *pOutputsMask contains a set of GPU-output identifiers +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 290. Instead, use NvAPI_GPU_GetConnectedDisplayIds.") +NVAPI_INTERFACE NvAPI_GPU_GetConnectedOutputsWithLidState(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pOutputsMask); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetConnectedSLIOutputsWithLidState +// +//! DESCRIPTION: This function is the same as NvAPI_GPU_GetConnectedOutputsWithLidState() but returns only the set +//! of GPU-output identifiers that can be selected in an SLI configuration. With SLI disabled, +//! this function matches NvAPI_GPU_GetConnectedOutputsWithLidState(). +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_GPU_GetConnectedDisplayIds. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 170 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pOutputsMask is NULL +//! \retval NVAPI_OK *pOutputsMask contains a set of GPU-output identifiers +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 290. Instead, use NvAPI_GPU_GetConnectedDisplayIds.") +NVAPI_INTERFACE NvAPI_GPU_GetConnectedSLIOutputsWithLidState(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pOutputsMask); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetSystemType +// +//! \fn NvAPI_GPU_GetSystemType(NvPhysicalGpuHandle hPhysicalGpu, NV_SYSTEM_TYPE *pSystemType) +//! This function identifies whether the GPU is a notebook GPU or a desktop GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 95 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pOutputsMask is NULL +//! \retval NVAPI_OK *pSystemType contains the GPU system type +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE: hPhysicalGpu was not a physical GPU handle +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup gpu +//! Used in NvAPI_GPU_GetSystemType() +typedef enum +{ + NV_SYSTEM_TYPE_UNKNOWN = 0, + NV_SYSTEM_TYPE_LAPTOP = 1, + NV_SYSTEM_TYPE_DESKTOP = 2, + +} NV_SYSTEM_TYPE; + + + +//! \ingroup gpu +NVAPI_INTERFACE NvAPI_GPU_GetSystemType(NvPhysicalGpuHandle hPhysicalGpu, NV_SYSTEM_TYPE *pSystemType); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetActiveOutputs +// +//! This function is the same as NvAPI_GPU_GetAllOutputs but returns only the set of GPU output +//! identifiers that are actively driving display devices. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 85 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pOutputsMask is NULL. +//! \retval NVAPI_OK *pOutputsMask contains a set of GPU-output identifiers. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetActiveOutputs(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pOutputsMask); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_SetEDID +// +//! Thus function sets the EDID data for the specified GPU handle and connection bit mask. +//! User can either send (Gpu handle & output id) or only display Id in variable displayOutputId parameter & hPhysicalGpu parameter can be default handle (0). +//! \note The EDID will be cached across the boot session and will be enumerated to the OS in this call. +//! To remove the EDID set sizeofEDID to zero. +//! OS and NVAPI connection status APIs will reflect the newly set or removed EDID dynamically. +//! +//! This feature will NOT be supported on the following boards: +//! - GeForce +//! - Quadro VX +//! - Tesla +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 100 +//! +//! \retval NVAPI_INVALID_ARGUMENT pEDID is NULL; displayOutputId has 0 or > 1 bits set +//! \retval NVAPI_OK *pEDID data was applied to the requested displayOutputId. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE: hPhysicalGpu was not a physical GPU handle. +//! \retval NVAPI_NOT_SUPPORTED For the above mentioned GPUs +//! \retval NVAPI_INVALID_USER_PRIVILEGE The application will require Administrator privileges to access this API. +//! The application can be elevated to a higher permission level by selecting "Run as Administrator". +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_SetEDID(NvPhysicalGpuHandle hPhysicalGpu, NvU32 displayOutputId, NV_EDID *pEDID); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetOutputType +// +//! \fn NvAPI_GPU_GetOutputType(NvPhysicalGpuHandle hPhysicalGpu, NvU32 outputId, NV_GPU_OUTPUT_TYPE *pOutputType) +//! This function returns the output type. User can either specify both 'physical GPU handle and outputId (exactly 1 bit set - see \ref handles)' or +//! a valid displayId in the outputId parameter. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \Version Earliest supported ForceWare version: 82.61 +//! +//! \retval NVAPI_INVALID_ARGUMENT outputId, pOutputType is NULL; or if outputId parameter is not displayId and either it has > 1 bit set or hPhysicalGpu is NULL. +//! \retval NVAPI_OK *pOutputType contains a NvGpuOutputType value +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup gpu +//! used in NvAPI_GPU_GetOutputType() +typedef enum _NV_GPU_OUTPUT_TYPE +{ + NVAPI_GPU_OUTPUT_UNKNOWN = 0, + NVAPI_GPU_OUTPUT_CRT = 1, //!< CRT display device + NVAPI_GPU_OUTPUT_DFP = 2, //!< Digital Flat Panel display device + NVAPI_GPU_OUTPUT_TV = 3, //!< TV display device +} NV_GPU_OUTPUT_TYPE; + + + + +//! \ingroup gpu +NVAPI_INTERFACE NvAPI_GPU_GetOutputType(NvPhysicalGpuHandle hPhysicalGpu, NvU32 outputId, NV_GPU_OUTPUT_TYPE *pOutputType); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_ValidateOutputCombination +// +//! This function determines if a set of GPU outputs can be active +//! simultaneously. While a GPU may have outputs, typically they cannot +//! all be active at the same time due to internal resource sharing. +//! +//! Given a physical GPU handle and a mask of candidate outputs, this call +//! will return NVAPI_OK if all of the specified outputs can be driven +//! simultaneously. It will return NVAPI_INVALID_COMBINATION if they cannot. +//! +//! Use NvAPI_GPU_GetAllOutputs() to determine which outputs are candidates. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 85 +//! +//! \retval NVAPI_OK Combination of outputs in outputsMask are valid (can be active simultaneously). +//! \retval NVAPI_INVALID_COMBINATION Combination of outputs in outputsMask are NOT valid. +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or outputsMask does not have at least 2 bits set. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_ValidateOutputCombination(NvPhysicalGpuHandle hPhysicalGpu, NvU32 outputsMask); + + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetFullName +// +//! This function retrieves the full GPU name as an ASCII string - for example, "Quadro FX 1400". +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \return NVAPI_ERROR or NVAPI_OK +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetFullName(NvPhysicalGpuHandle hPhysicalGpu, NvAPI_ShortString szName); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetPCIIdentifiers +// +//! This function returns the PCI identifiers associated with this GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \param DeviceId The internal PCI device identifier for the GPU. +//! \param SubSystemId The internal PCI subsystem identifier for the GPU. +//! \param RevisionId The internal PCI device-specific revision identifier for the GPU. +//! \param ExtDeviceId The external PCI device identifier for the GPU. +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or an argument is NULL +//! \retval NVAPI_OK Arguments are populated with PCI identifiers +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetPCIIdentifiers(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pDeviceId,NvU32 *pSubSystemId,NvU32 *pRevisionId,NvU32 *pExtDeviceId); + + + + +//! \ingroup gpu +//! Used in NvAPI_GPU_GetGPUType(). +typedef enum _NV_GPU_TYPE +{ + NV_SYSTEM_TYPE_GPU_UNKNOWN = 0, + NV_SYSTEM_TYPE_IGPU = 1, //!< Integrated GPU + NV_SYSTEM_TYPE_DGPU = 2, //!< Discrete GPU +} NV_GPU_TYPE; + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetGPUType +// +//! DESCRIPTION: This function returns the GPU type (integrated or discrete). +//! See ::NV_GPU_TYPE. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 173 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu +//! \retval NVAPI_OK *pGpuType contains the GPU type +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE: hPhysicalGpu was not a physical GPU handle +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetGPUType(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GPU_TYPE *pGpuType); + + + + +//! \ingroup gpu +//! Used in NvAPI_GPU_GetBusType() +typedef enum _NV_GPU_BUS_TYPE +{ + NVAPI_GPU_BUS_TYPE_UNDEFINED = 0, + NVAPI_GPU_BUS_TYPE_PCI = 1, + NVAPI_GPU_BUS_TYPE_AGP = 2, + NVAPI_GPU_BUS_TYPE_PCI_EXPRESS = 3, + NVAPI_GPU_BUS_TYPE_FPCI = 4, + NVAPI_GPU_BUS_TYPE_AXI = 5, +} NV_GPU_BUS_TYPE; +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetBusType +// +//! This function returns the type of bus associated with this GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pBusType is NULL. +//! \retval NVAPI_OK *pBusType contains bus identifier. +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetBusType(NvPhysicalGpuHandle hPhysicalGpu,NV_GPU_BUS_TYPE *pBusType); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetBusId +// +//! DESCRIPTION: Returns the ID of the bus associated with this GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 167 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pBusId is NULL. +//! \retval NVAPI_OK *pBusId contains the bus ID. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetBusId(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pBusId); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetBusSlotId +// +//! DESCRIPTION: Returns the ID of the bus slot associated with this GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 167 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pBusSlotId is NULL. +//! \retval NVAPI_OK *pBusSlotId contains the bus slot ID. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetBusSlotId(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pBusSlotId); + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetIRQ +// +//! This function returns the interrupt number associated with this GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pIRQ is NULL. +//! \retval NVAPI_OK *pIRQ contains interrupt number. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetIRQ(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pIRQ); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetVbiosRevision +// +//! This function returns the revision of the video BIOS associated with this GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pBiosRevision is NULL. +//! \retval NVAPI_OK *pBiosRevision contains revision number. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetVbiosRevision(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pBiosRevision); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetVbiosOEMRevision +// +//! This function returns the OEM revision of the video BIOS associated with this GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu or pBiosRevision is NULL +//! \retval NVAPI_OK *pBiosRevision contains revision number +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetVbiosOEMRevision(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pBiosRevision); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetVbiosVersionString +// +//! This function returns the full video BIOS version string in the form of xx.xx.xx.xx.yy where +//! - xx numbers come from NvAPI_GPU_GetVbiosRevision() and +//! - yy comes from NvAPI_GPU_GetVbiosOEMRevision(). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \retval NVAPI_INVALID_ARGUMENT hPhysicalGpu is NULL. +//! \retval NVAPI_OK szBiosRevision contains version string. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetVbiosVersionString(NvPhysicalGpuHandle hPhysicalGpu,NvAPI_ShortString szBiosRevision); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetAGPAperture +// +//! This function returns the AGP aperture in megabytes. +//! +//! \deprecated Do not use this function - it is deprecated in release 455. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \retval NVAPI_NOT_SUPPORTED +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 455.") +NVAPI_INTERFACE NvAPI_GPU_GetAGPAperture(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pSize); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetCurrentAGPRate +// +//! This function returns the current AGP Rate (0 = AGP not present, 1 = 1x, 2 = 2x, etc.). +//! +//! \deprecated Do not use this function - it is deprecated in release 455. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \retval NVAPI_NOT_SUPPORTED +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 455.") +NVAPI_INTERFACE NvAPI_GPU_GetCurrentAGPRate(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pRate); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetCurrentPCIEDownstreamWidth +// +//! This function returns the number of PCIE lanes being used for the PCIE interface +//! downstream from the GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \retval NVAPI_INVALID_ARGUMENT pWidth is NULL. +//! \retval NVAPI_OK Call successful. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetCurrentPCIEDownstreamWidth(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pWidth); + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetPhysicalFrameBufferSize +// +//! This function returns the physical size of framebuffer in KB. This does NOT include any +//! system RAM that may be dedicated for use by the GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \retval NVAPI_INVALID_ARGUMENT pSize is NULL +//! \retval NVAPI_OK Call successful +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetPhysicalFrameBufferSize(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pSize); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetVirtualFrameBufferSize +// +//! This function returns the virtual size of framebuffer in KB. This includes the physical RAM plus any +//! system RAM that has been dedicated for use by the GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 90 +//! +//! \retval NVAPI_INVALID_ARGUMENT pSize is NULL. +//! \retval NVAPI_OK Call successful. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu was not a physical GPU handle. +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetVirtualFrameBufferSize(NvPhysicalGpuHandle hPhysicalGpu,NvU32 *pSize); + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetQuadroStatus +// +//! This function retrieves the Quadro status for the GPU (1 if Quadro, 0 if GeForce) +//! +//! This API is deprecated and it is recommended to instead query +//! NV_GPU_WORKSTATION_FEATURE_TYPE_PROVIZ support from the API +//! NvAPI_GPU_QueryWorkstationFeatureSupport. +//! \deprecated Do not use this function - it is deprecated in release 460. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \return NVAPI_ERROR or NVAPI_OK +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 460.") +NVAPI_INTERFACE NvAPI_GPU_GetQuadroStatus(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pStatus); + + +//! \ingroup gpu +typedef struct _NV_BOARD_INFO +{ + NvU32 version; //!< structure version + NvU8 BoardNum[16]; //!< Board Serial Number + +}NV_BOARD_INFO_V1; + +#define NV_BOARD_INFO_VER1 MAKE_NVAPI_VERSION(NV_BOARD_INFO_V1,1) +#ifndef NV_BOARD_INFO_VER +//! \ingroup gpu +typedef NV_BOARD_INFO_V1 NV_BOARD_INFO; +//! \ingroup gpu +//! \ingroup gpu +#define NV_BOARD_INFO_VER NV_BOARD_INFO_VER1 +#endif + +//! SUPPORTED OS: Windows 7 and higher +//! +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetBoardInfo +// +//! DESCRIPTION: This API Retrieves the Board information (a unique GPU Board Serial Number) stored in the InfoROM. +//! +//! \param [in] hPhysicalGpu Physical GPU Handle. +//! \param [in,out] NV_BOARD_INFO Board Information. +//! +//! TCC_SUPPORTED +//! +//! \retval ::NVAPI_OK completed request +//! \retval ::NVAPI_ERROR miscellaneous error occurred +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE handle passed is not a physical GPU handle +//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized +//! \retval ::NVAPI_INVALID_POINTER pBoardInfo is NULL +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION the version of the INFO struct is not supported +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetBoardInfo(NvPhysicalGpuHandle hPhysicalGpu, NV_BOARD_INFO *pBoardInfo); + + + + +//! Used in NvAPI_GPU_GetArchInfo() +typedef struct +{ + NvU32 version; + + NvU32 architecture; + NvU32 implementation; + NvU32 revision; + +} NV_GPU_ARCH_INFO_V1; + +//! NV_GPU_ARCH_INFO() values to identify Architecture level for the GPU. +typedef enum _NV_GPU_ARCHITECTURE_ID +{ + + NV_GPU_ARCHITECTURE_T2X = 0xE0000020, + NV_GPU_ARCHITECTURE_T3X = 0xE0000030, + NV_GPU_ARCHITECTURE_T4X = 0xE0000040, + NV_GPU_ARCHITECTURE_T12X = 0xE0000040, + NV_GPU_ARCHITECTURE_NV40 = 0x00000040, + NV_GPU_ARCHITECTURE_NV50 = 0x00000050, + NV_GPU_ARCHITECTURE_G78 = 0x00000060, + NV_GPU_ARCHITECTURE_G80 = 0x00000080, + NV_GPU_ARCHITECTURE_G90 = 0x00000090, + NV_GPU_ARCHITECTURE_GT200 = 0x000000A0, + NV_GPU_ARCHITECTURE_GF100 = 0x000000C0, + NV_GPU_ARCHITECTURE_GF110 = 0x000000D0, + NV_GPU_ARCHITECTURE_GK100 = 0x000000E0, + NV_GPU_ARCHITECTURE_GK110 = 0x000000F0, + NV_GPU_ARCHITECTURE_GK200 = 0x00000100, + NV_GPU_ARCHITECTURE_GM000 = 0x00000110, + NV_GPU_ARCHITECTURE_GM200 = 0x00000120, + NV_GPU_ARCHITECTURE_GP100 = 0x00000130, + NV_GPU_ARCHITECTURE_GV100 = 0x00000140, + NV_GPU_ARCHITECTURE_GV110 = 0x00000150, + NV_GPU_ARCHITECTURE_TU100 = 0x00000160, + NV_GPU_ARCHITECTURE_GA100 = 0x00000170, + NV_GPU_ARCHITECTURE_AD100 = 0x00000190, + +}NV_GPU_ARCHITECTURE_ID; + +//! NV_GPU_ARCH_INFO() values to identify GPU Architecture Implementation. +typedef enum _NV_GPU_ARCH_IMPLEMENTATION_ID +{ + + NV_GPU_ARCH_IMPLEMENTATION_T20 = 0x00000000, + + NV_GPU_ARCH_IMPLEMENTATION_T30 = 0x00000000, + NV_GPU_ARCH_IMPLEMENTATION_T35 = 0x00000005, + + NV_GPU_ARCH_IMPLEMENTATION_T40 = 0x00000000, + NV_GPU_ARCH_IMPLEMENTATION_T124 = 0x00000000, + + NV_GPU_ARCH_IMPLEMENTATION_NV40 = 0x00000000, + NV_GPU_ARCH_IMPLEMENTATION_NV41 = 0x00000001, + NV_GPU_ARCH_IMPLEMENTATION_NV42 = 0x00000002, + NV_GPU_ARCH_IMPLEMENTATION_NV43 = 0x00000003, + NV_GPU_ARCH_IMPLEMENTATION_NV44 = 0x00000004, + NV_GPU_ARCH_IMPLEMENTATION_NV44A = 0x0000000A, + NV_GPU_ARCH_IMPLEMENTATION_NV46 = 0x00000006, + NV_GPU_ARCH_IMPLEMENTATION_NV47 = 0x00000007, + NV_GPU_ARCH_IMPLEMENTATION_NV49 = 0x00000009, + NV_GPU_ARCH_IMPLEMENTATION_NV4B = 0x0000000B, + NV_GPU_ARCH_IMPLEMENTATION_NV4C = 0x0000000C, + NV_GPU_ARCH_IMPLEMENTATION_NV4E = 0x0000000E, + + NV_GPU_ARCH_IMPLEMENTATION_NV50 = 0x00000000, + + NV_GPU_ARCH_IMPLEMENTATION_NV63 = 0x00000003, + NV_GPU_ARCH_IMPLEMENTATION_NV67 = 0x00000007, + + NV_GPU_ARCH_IMPLEMENTATION_G84 = 0x00000004, + NV_GPU_ARCH_IMPLEMENTATION_G86 = 0x00000006, + + NV_GPU_ARCH_IMPLEMENTATION_G92 = 0x00000002, + NV_GPU_ARCH_IMPLEMENTATION_G94 = 0x00000004, + NV_GPU_ARCH_IMPLEMENTATION_G96 = 0x00000006, + NV_GPU_ARCH_IMPLEMENTATION_G98 = 0x00000008, + + NV_GPU_ARCH_IMPLEMENTATION_GT200 = 0x00000000, + NV_GPU_ARCH_IMPLEMENTATION_GT212 = 0x00000002, + NV_GPU_ARCH_IMPLEMENTATION_GT214 = 0x00000004, + NV_GPU_ARCH_IMPLEMENTATION_GT215 = 0x00000003, + NV_GPU_ARCH_IMPLEMENTATION_GT216 = 0x00000005, + NV_GPU_ARCH_IMPLEMENTATION_GT218 = 0x00000008, + NV_GPU_ARCH_IMPLEMENTATION_MCP77 = 0x0000000A, + NV_GPU_ARCH_IMPLEMENTATION_GT21C = 0x0000000B, + NV_GPU_ARCH_IMPLEMENTATION_MCP79 = 0x0000000C, + NV_GPU_ARCH_IMPLEMENTATION_GT21A = 0x0000000D, + NV_GPU_ARCH_IMPLEMENTATION_MCP89 = 0x0000000F, + + NV_GPU_ARCH_IMPLEMENTATION_GF100 = 0x00000000, + NV_GPU_ARCH_IMPLEMENTATION_GF104 = 0x00000004, + NV_GPU_ARCH_IMPLEMENTATION_GF106 = 0x00000003, + NV_GPU_ARCH_IMPLEMENTATION_GF108 = 0x00000001, + + NV_GPU_ARCH_IMPLEMENTATION_GF110 = 0x00000000, + NV_GPU_ARCH_IMPLEMENTATION_GF116 = 0x00000006, + NV_GPU_ARCH_IMPLEMENTATION_GF117 = 0x00000007, + NV_GPU_ARCH_IMPLEMENTATION_GF118 = 0x00000008, + NV_GPU_ARCH_IMPLEMENTATION_GF119 = 0x00000009, + + NV_GPU_ARCH_IMPLEMENTATION_GK104 = 0x00000004, + NV_GPU_ARCH_IMPLEMENTATION_GK106 = 0x00000006, + NV_GPU_ARCH_IMPLEMENTATION_GK107 = 0x00000007, + NV_GPU_ARCH_IMPLEMENTATION_GK20A = 0x0000000A, + NV_GPU_ARCH_IMPLEMENTATION_GK110 = 0x00000000, + + NV_GPU_ARCH_IMPLEMENTATION_GK208 = 0x00000008, + + NV_GPU_ARCH_IMPLEMENTATION_GM204 = 0x00000004, + NV_GPU_ARCH_IMPLEMENTATION_GM206 = 0x00000006, + + NV_GPU_ARCH_IMPLEMENTATION_GP100 = 0x00000000, + NV_GPU_ARCH_IMPLEMENTATION_GP000 = 0x00000001, + NV_GPU_ARCH_IMPLEMENTATION_GP102 = 0x00000002, + NV_GPU_ARCH_IMPLEMENTATION_GP104 = 0x00000004, + NV_GPU_ARCH_IMPLEMENTATION_GP106 = 0x00000006, + NV_GPU_ARCH_IMPLEMENTATION_GP107 = 0x00000007, + NV_GPU_ARCH_IMPLEMENTATION_GP108 = 0x00000008, + + NV_GPU_ARCH_IMPLEMENTATION_GV100 = 0x00000000, + NV_GPU_ARCH_IMPLEMENTATION_GV10B = 0x0000000B, + + NV_GPU_ARCH_IMPLEMENTATION_TU100 = 0x00000000, + NV_GPU_ARCH_IMPLEMENTATION_TU102 = 0x00000002, + NV_GPU_ARCH_IMPLEMENTATION_TU104 = 0x00000004, + NV_GPU_ARCH_IMPLEMENTATION_TU106 = 0x00000006, + NV_GPU_ARCH_IMPLEMENTATION_TU116 = 0x00000008, + NV_GPU_ARCH_IMPLEMENTATION_TU117 = 0x00000007, + NV_GPU_ARCH_IMPLEMENTATION_TU000 = 0x00000001, + + NV_GPU_ARCH_IMPLEMENTATION_GA100 = 0x00000000, + NV_GPU_ARCH_IMPLEMENTATION_GA102 = 0x00000002, + NV_GPU_ARCH_IMPLEMENTATION_GA104 = 0x00000004, + + NV_GPU_ARCH_IMPLEMENTATION_AD102 = 0x00000002, + NV_GPU_ARCH_IMPLEMENTATION_AD103 = 0x00000003, + NV_GPU_ARCH_IMPLEMENTATION_AD104 = 0x00000004, + +}NV_GPU_ARCH_IMPLEMENTATION_ID; + +typedef enum _NV_GPU_CHIP_REVISION +{ + NV_GPU_CHIP_REV_EMULATION_QT = 0x00000000, //!< QT chip + NV_GPU_CHIP_REV_EMULATION_FPGA = 0x00000001, //!< FPGA implementation of the chipset + NV_GPU_CHIP_REV_A01 = 0x00000011, //!< First silicon chipset revision + NV_GPU_CHIP_REV_A02 = 0x00000012, //!< Second Silicon chipset revision + NV_GPU_CHIP_REV_A03 = 0x00000013, //!< Third Silicon chipset revision + NV_GPU_CHIP_REV_UNKNOWN = 0xffffffff, //!< Unknown chip revision +}NV_GPU_CHIP_REVISION; + +//! \ingroup gpu +//! Used in NvAPI_GPU_GetArchInfo() +typedef struct +{ + NvU32 version; + + union + { + NvU32 architecture; //!< architecture and architecture_id are the same. The former is NvU32 while the latter is an enum made for readability. + NV_GPU_ARCHITECTURE_ID architecture_id; //!< specifies the architecture level for the GPU. + }; + union + { + NvU32 implementation; //!< implementation and implementation_id are the same. The former is NvU32 while the latter is an enum made for readability. + NV_GPU_ARCH_IMPLEMENTATION_ID implementation_id; //!< specifies the implementation of the architecture for the GPU. + }; + union + { + NvU32 revision; //!< revision and revision_id are the same. The former is NvU32 while the latter is an enum made for readability. + NV_GPU_CHIP_REVISION revision_id; //!< specifies the architecture revision of the GPU. + }; + +} NV_GPU_ARCH_INFO_V2; + +//! \ingroup gpu +typedef NV_GPU_ARCH_INFO_V2 NV_GPU_ARCH_INFO; + +//! \ingroup gpu +#define NV_GPU_ARCH_INFO_VER_1 MAKE_NVAPI_VERSION(NV_GPU_ARCH_INFO_V1,1) +#define NV_GPU_ARCH_INFO_VER_2 MAKE_NVAPI_VERSION(NV_GPU_ARCH_INFO_V2,2) +#define NV_GPU_ARCH_INFO_VER NV_GPU_ARCH_INFO_VER_2 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetArchInfo +// +//! \fn NvAPI_GPU_GetArchInfo(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_ARCH_INFO *pGpuArchInfo) +//! This function retrieves the architecture, implementation and chip revision for the specified GPU . +//! +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! \since Release: 85 +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup gpu +NVAPI_INTERFACE NvAPI_GPU_GetArchInfo(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_ARCH_INFO *pGpuArchInfo); + + + +/////////////////////////////////////////////////////////////////////////////////// +// I2C API +// Provides ability to read or write data using I2C protocol. +// These APIs allow I2C access only to DDC monitors + + +//! \addtogroup i2capi +//! @{ +#define NVAPI_MAX_SIZEOF_I2C_DATA_BUFFER 4096 +#define NVAPI_MAX_SIZEOF_I2C_REG_ADDRESS 4 +#define NVAPI_DISPLAY_DEVICE_MASK_MAX 24 +#define NVAPI_I2C_SPEED_DEPRECATED 0xFFFF + +typedef enum +{ + NVAPI_I2C_SPEED_DEFAULT, //!< Set i2cSpeedKhz to I2C_SPEED_DEFAULT if default I2C speed is to be chosen, ie.use the current frequency setting. + NVAPI_I2C_SPEED_3KHZ, + NVAPI_I2C_SPEED_10KHZ, + NVAPI_I2C_SPEED_33KHZ, + NVAPI_I2C_SPEED_100KHZ, + NVAPI_I2C_SPEED_200KHZ, + NVAPI_I2C_SPEED_400KHZ, +} NV_I2C_SPEED; + +//! Used in NvAPI_I2CRead() and NvAPI_I2CWrite() +typedef struct +{ + NvU32 version; //!< The structure version. + NvU32 displayMask; //!< The Display Mask of the concerned display. + NvU8 bIsDDCPort; //!< This flag indicates either the DDC port (TRUE) or the communication port + //!< (FALSE) of the concerned display. + NvU8 i2cDevAddress; //!< The address of the I2C slave. The address should be shifted left by one. For + //!< example, the I2C address 0x50, often used for reading EDIDs, would be stored + //!< here as 0xA0. This matches the position within the byte sent by the master, as + //!< the last bit is reserved to specify the read or write direction. + NvU8* pbI2cRegAddress; //!< The I2C target register address. May be NULL, which indicates no register + //!< address should be sent. + NvU32 regAddrSize; //!< The size in bytes of target register address. If pbI2cRegAddress is NULL, this + //!< field must be 0. + NvU8* pbData; //!< The buffer of data which is to be read or written (depending on the command). + NvU32 cbSize; //!< The size of the data buffer, pbData, to be read or written. + NvU32 i2cSpeed; //!< The target speed of the transaction (between 28Kbps to 40Kbps; not guaranteed). +} NV_I2C_INFO_V1; + +//! Used in NvAPI_I2CRead() and NvAPI_I2CWrite() +typedef struct +{ + NvU32 version; //!< The structure version. + NvU32 displayMask; //!< The Display Mask of the concerned display. + NvU8 bIsDDCPort; //!< This flag indicates either the DDC port (TRUE) or the communication port + //!< (FALSE) of the concerned display. + NvU8 i2cDevAddress; //!< The address of the I2C slave. The address should be shifted left by one. For + //!< example, the I2C address 0x50, often used for reading EDIDs, would be stored + //!< here as 0xA0. This matches the position within the byte sent by the master, as + //!< the last bit is reserved to specify the read or write direction. + NvU8* pbI2cRegAddress; //!< The I2C target register address. May be NULL, which indicates no register + //!< address should be sent. + NvU32 regAddrSize; //!< The size in bytes of target register address. If pbI2cRegAddress is NULL, this + //!< field must be 0. + NvU8* pbData; //!< The buffer of data which is to be read or written (depending on the command). + NvU32 cbSize; //!< The size of the data buffer, pbData, to be read or written. + NvU32 i2cSpeed; //!< Deprecated, Must be set to NVAPI_I2C_SPEED_DEPRECATED. + NV_I2C_SPEED i2cSpeedKhz; //!< The target speed of the transaction in (kHz) (Chosen from the enum NV_I2C_SPEED). +} NV_I2C_INFO_V2; + +//! Used in NvAPI_I2CRead() and NvAPI_I2CWrite() +typedef struct +{ + NvU32 version; //!< The structure version. + NvU32 displayMask; //!< The Display Mask of the concerned display. + NvU8 bIsDDCPort; //!< This flag indicates either the DDC port (TRUE) or the communication port + //!< (FALSE) of the concerned display. + NvU8 i2cDevAddress; //!< The address of the I2C slave. The address should be shifted left by one. For + //!< example, the I2C address 0x50, often used for reading EDIDs, would be stored + //!< here as 0xA0. This matches the position within the byte sent by the master, as + //!< the last bit is reserved to specify the read or write direction. + NvU8* pbI2cRegAddress; //!< The I2C target register address. May be NULL, which indicates no register + //!< address should be sent. + NvU32 regAddrSize; //!< The size in bytes of target register address. If pbI2cRegAddress is NULL, this + //!< field must be 0. + NvU8* pbData; //!< The buffer of data which is to be read or written (depending on the command). + NvU32 cbSize; //!< The size of the data buffer, pbData, to be read or written. + NvU32 i2cSpeed; //!< Deprecated, Must be set to NVAPI_I2C_SPEED_DEPRECATED. + NV_I2C_SPEED i2cSpeedKhz; //!< The target speed of the transaction in (kHz) (Chosen from the enum NV_I2C_SPEED). + NvU8 portId; //!< The portid on which device is connected (remember to set bIsPortIdSet if this value is set) + //!< Optional for pre-Kepler + NvU32 bIsPortIdSet; //!< set this flag on if and only if portid value is set +} NV_I2C_INFO_V3; + +typedef NV_I2C_INFO_V3 NV_I2C_INFO; + +#define NV_I2C_INFO_VER3 MAKE_NVAPI_VERSION(NV_I2C_INFO_V3,3) +#define NV_I2C_INFO_VER2 MAKE_NVAPI_VERSION(NV_I2C_INFO_V2,2) +#define NV_I2C_INFO_VER1 MAKE_NVAPI_VERSION(NV_I2C_INFO_V1,1) + +#define NV_I2C_INFO_VER NV_I2C_INFO_VER3 +//! @} + +/***********************************************************************************/ + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_I2CRead +// +//! This function reads the data buffer from the I2C port. +//! The I2C request must be for a DDC port: pI2cInfo->bIsDDCPort = 1. +//! +//! A data buffer size larger than 16 bytes may be rejected if a register address is specified. In such a case, +//! NVAPI_ARGUMENT_EXCEED_MAX_SIZE would be returned. +//! +//! If a register address is specified (i.e. regAddrSize is positive), then the transaction will be performed in +//! the combined format described in the I2C specification. The register address will be written, followed by +//! reading into the data buffer. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 85 +//! +//! \param [in] hPhysicalGPU GPU selection. +//! \param [out] NV_I2C_INFO *pI2cInfo The I2C data input structure +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred. +//! \retval NVAPI_HANDLE_INVALIDATED Handle passed has been invalidated (see user guide). +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE Handle passed is not a physical GPU handle. +//! \retval NVAPI_INCOMPATIBLE_STRUCT_VERSION Structure version is not supported. +//! \retval NVAPI_INVALID_ARGUMENT - argument does not meet specified requirements +//! \retval NVAPI_ARGUMENT_EXCEED_MAX_SIZE - an argument exceeds the maximum +//! +//! \ingroup i2capi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_I2CRead(NvPhysicalGpuHandle hPhysicalGpu, NV_I2C_INFO *pI2cInfo); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_I2CWrite +// +//! This function writes the data buffer to the I2C port. +//! +//! The I2C request must be for a DDC port: pI2cInfo->bIsDDCPort = 1. +//! +//! A data buffer size larger than 16 bytes may be rejected if a register address is specified. In such a case, +//! NVAPI_ARGUMENT_EXCEED_MAX_SIZE would be returned. +//! +//! If a register address is specified (i.e. regAddrSize is positive), then the register address will be written +//! and the data buffer will immediately follow without a restart. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 85 +//! +//! \param [in] hPhysicalGPU GPU selection. +//! \param [in] pI2cInfo The I2C data input structure +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred. +//! \retval NVAPI_HANDLE_INVALIDATED Handle passed has been invalidated (see user guide). +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE Handle passed is not a physical GPU handle. +//! \retval NVAPI_INCOMPATIBLE_STRUCT_VERSION Structure version is not supported. +//! \retval NVAPI_INVALID_ARGUMENT Argument does not meet specified requirements +//! \retval NVAPI_ARGUMENT_EXCEED_MAX_SIZE Argument exceeds the maximum +//! +//! \ingroup i2capi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_I2CWrite(NvPhysicalGpuHandle hPhysicalGpu, NV_I2C_INFO *pI2cInfo); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_WorkstationFeatureSetup +// +//! \fn NvAPI_GPU_WorkstationFeatureSetup(NvPhysicalGpuHandle hPhysicalGpu, NvU32 featureEnableMask, NvU32 featureDisableMask) +//! DESCRIPTION: This API configures the driver for a set of workstation features. +//! The driver can allocate the memory resources accordingly. +//! +//! SUPPORTED OS: Windows 7 +//! +//! +//! \param [in] hPhysicalGpu Physical GPU Handle of the display adapter to be configured. GPU handles may be retrieved +//! using NvAPI_EnumPhysicalGPUs. A value of NULL is permitted and applies the same operation +//! to all GPU handles enumerated by NvAPI_EnumPhysicalGPUs. +//! \param [in] featureEnableMask Mask of features the caller requests to enable for use +//! \param [in] featureDisableMask Mask of features the caller requests to disable +//! +//! As a general rule, features in the enable and disable masks are expected to be disjoint, although the disable +//! mask has precedence and a feature flagged in both masks will be disabled. +//! +//! \retval ::NVAPI_OK configuration request succeeded +//! \retval ::NVAPI_ERROR configuration request failed +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu is not a physical GPU handle. +//! \retval ::NVAPI_GPU_WORKSTATION_FEATURE_INCOMPLETE requested feature set does not have all resources allocated for completeness. +//! \retval ::NVAPI_NO_IMPLEMENTATION OS below Win7, implemented only for Win7 but returns NVAPI_OK on OS above Win7 to +//! keep compatibility with apps written against Win7. +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup gpu +typedef enum +{ + NVAPI_GPU_WORKSTATION_FEATURE_MASK_SWAPGROUP = 0x00000001, + NVAPI_GPU_WORKSTATION_FEATURE_MASK_STEREO = 0x00000010, + NVAPI_GPU_WORKSTATION_FEATURE_MASK_WARPING = 0x00000100, + NVAPI_GPU_WORKSTATION_FEATURE_MASK_PIXINTENSITY = 0x00000200, + NVAPI_GPU_WORKSTATION_FEATURE_MASK_GRAYSCALE = 0x00000400, + NVAPI_GPU_WORKSTATION_FEATURE_MASK_BPC10 = 0x00001000 +} NVAPI_GPU_WORKSTATION_FEATURE_MASK; + +//! \ingroup gpu +NVAPI_INTERFACE NvAPI_GPU_WorkstationFeatureSetup(__in NvPhysicalGpuHandle hPhysicalGpu, __in NvU32 featureEnableMask, __in NvU32 featureDisableMask); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_WorkstationFeatureQuery +// +//! DESCRIPTION: This API queries the current set of workstation features. +//! +//! SUPPORTED OS: Windows 7 +//! +//! +//! \param [in] hPhysicalGpu Physical GPU Handle of the display adapter to be configured. GPU handles may be retrieved +//! using NvAPI_EnumPhysicalGPUs. +//! \param [out] pConfiguredFeatureMask Mask of features requested for use by client drivers +//! \param [out] pConsistentFeatureMask Mask of features that have all resources allocated for completeness. +//! +//! \retval ::NVAPI_OK configuration request succeeded +//! \retval ::NVAPI_ERROR configuration request failed +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE hPhysicalGpu is not a physical GPU handle. +//! \retval ::NVAPI_NO_IMPLEMENTATION OS below Win7, implemented only for Win7 but returns NVAPI_OK on OS above Win7 to +//! keep compatibility with apps written against Win7. +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup gpu +NVAPI_INTERFACE NvAPI_GPU_WorkstationFeatureQuery(__in NvPhysicalGpuHandle hPhysicalGpu, __out_opt NvU32 *pConfiguredFeatureMask, __out_opt NvU32 *pConsistentFeatureMask); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetHDCPSupportStatus +// +//! \fn NvAPI_GPU_GetHDCPSupportStatus(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_GET_HDCP_SUPPORT_STATUS *pGetHDCPSupportStatus) +//! DESCRIPTION: This function returns a GPU's HDCP support status. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 175 +//! +//! \retval ::NVAPI_OK +//! \retval ::NVAPI_ERROR +//! \retval ::NVAPI_INVALID_ARGUMENT +//! \retval ::NVAPI_HANDLE_INVALIDATED +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION +// +//////////////////////////////////////////////////////////////////////////////// + + +//! \addtogroup gpu +//! @{ + + +//! HDCP fuse states - used in NV_GPU_GET_HDCP_SUPPORT_STATUS +typedef enum _NV_GPU_HDCP_FUSE_STATE +{ + NV_GPU_HDCP_FUSE_STATE_UNKNOWN = 0, + NV_GPU_HDCP_FUSE_STATE_DISABLED = 1, + NV_GPU_HDCP_FUSE_STATE_ENABLED = 2, +} NV_GPU_HDCP_FUSE_STATE; + + +//! HDCP key sources - used in NV_GPU_GET_HDCP_SUPPORT_STATUS +typedef enum _NV_GPU_HDCP_KEY_SOURCE +{ + NV_GPU_HDCP_KEY_SOURCE_UNKNOWN = 0, + NV_GPU_HDCP_KEY_SOURCE_NONE = 1, + NV_GPU_HDCP_KEY_SOURCE_CRYPTO_ROM = 2, + NV_GPU_HDCP_KEY_SOURCE_SBIOS = 3, + NV_GPU_HDCP_KEY_SOURCE_I2C_ROM = 4, + NV_GPU_HDCP_KEY_SOURCE_FUSES = 5, +} NV_GPU_HDCP_KEY_SOURCE; + + +//! HDCP key source states - used in NV_GPU_GET_HDCP_SUPPORT_STATUS +typedef enum _NV_GPU_HDCP_KEY_SOURCE_STATE +{ + NV_GPU_HDCP_KEY_SOURCE_STATE_UNKNOWN = 0, + NV_GPU_HDCP_KEY_SOURCE_STATE_ABSENT = 1, + NV_GPU_HDCP_KEY_SOURCE_STATE_PRESENT = 2, +} NV_GPU_HDCP_KEY_SOURCE_STATE; + + +//! HDPC support status - used in NvAPI_GPU_GetHDCPSupportStatus() +typedef struct +{ + NvU32 version; //! Structure version constucted by macro #NV_GPU_GET_HDCP_SUPPORT_STATUS + NV_GPU_HDCP_FUSE_STATE hdcpFuseState; //! GPU's HDCP fuse state + NV_GPU_HDCP_KEY_SOURCE hdcpKeySource; //! GPU's HDCP key source + NV_GPU_HDCP_KEY_SOURCE_STATE hdcpKeySourceState; //! GPU's HDCP key source state +} NV_GPU_GET_HDCP_SUPPORT_STATUS; + + +//! Macro for constructing the version for structure NV_GPU_GET_HDCP_SUPPORT_STATUS +#define NV_GPU_GET_HDCP_SUPPORT_STATUS_VER MAKE_NVAPI_VERSION(NV_GPU_GET_HDCP_SUPPORT_STATUS,1) + + +//! @} + + +//! \ingroup gpu +NVAPI_INTERFACE NvAPI_GPU_GetHDCPSupportStatus(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_GET_HDCP_SUPPORT_STATUS *pGetHDCPSupportStatus); + + + + +//! \addtogroup gpucuda +//! @{ + +//! defgroup nvcomp_gpu_top NVIDIA Compute GPU Topology Flags +//! @{ + +#define NV_COMPUTE_GPU_TOPOLOGY_PHYSICS_CAPABLE NV_BIT(0) //!< This is Read only GPU flag - Physics capable GPU. +#define NV_COMPUTE_GPU_TOPOLOGY_PHYSICS_ENABLE NV_BIT(1) //!< This is Read/Write GPU flag - Indicates GPU is already enabled for physics. +#define NV_COMPUTE_GPU_TOPOLOGY_PHYSICS_DEDICATED NV_BIT(2) //!< This is Read only GPU flag - Physics enabled GPU which is *dedicated* for physics indicates + //!< this compute capable GPU was automatically made usable for Physx on CUDA. +#define NV_COMPUTE_GPU_TOPOLOGY_PHYSICS_RECOMMENDED NV_BIT(3) //!< This is Read only GPU flag - Physics GPU which is recommended by the driver. +#define NV_COMPUTE_GPU_TOPOLOGY_CUDA_AVAILABLE NV_BIT(4) //!< This is Read only GPU flag. +#define NV_COMPUTE_GPU_TOPOLOGY_CUDA_CAPABLE NV_BIT(16) //!< This is Read only GPU flag. +#define NV_COMPUTE_GPU_TOPOLOGY_CUDA_DISABLED NV_BIT(17) //!< This is Read only GPU flag. +#define NV_COMPUTE_GPU_TOPOLOGY_PHYSICS_AVAILABLE NV_BIT(21) //!< This is Read only GPU flag - PhysX is able to use this GPU (PhysX is installed, etc) + +//! @} + +typedef struct +{ + NvU32 version; //!< Structure version + NvU32 gpuCount; //!< Total number of compute-capable GPUs + + struct + { + NvPhysicalGpuHandle hPhysicalGpu; //!< Compute-capable physical GPU handle + NvU32 flags; //!< One or more flags from \ref nvcomp_gpu_top + + } computeGpus[NVAPI_MAX_GPU_PER_TOPOLOGY]; //!< Array of compute-capable physical GPUs. + +} NV_COMPUTE_GPU_TOPOLOGY_V1; + + +typedef struct _NV_COMPUTE_GPU +{ + NvPhysicalGpuHandle hPhysicalGpu; //!< Compute-capable physical GPU handle + NvU32 flags; //!< One or more flags from \ref nvcomp_gpu_top + +} NV_COMPUTE_GPU; + +typedef struct _NV_COMPUTE_GPU_TOPOLOGY_V2 +{ + NvU32 version; //!< Structure version + NvU32 gpuCount; //!< Size of array + NV_COMPUTE_GPU *computeGpus; //!< Array of compute-capable physical GPUs (allocate memory of size of Physical gpuCount of system). + +} NV_COMPUTE_GPU_TOPOLOGY_V2; + +//! Macro for constructing the version field of NV_COMPUTE_GPU_TOPOLOGY +#define NV_COMPUTE_GPU_TOPOLOGY_VER1 MAKE_NVAPI_VERSION(NV_COMPUTE_GPU_TOPOLOGY_V1,1) + +#define NV_COMPUTE_GPU_TOPOLOGY_VER MAKE_NVAPI_VERSION(NV_COMPUTE_GPU_TOPOLOGY_V2,2) +typedef NV_COMPUTE_GPU_TOPOLOGY_V2 NV_COMPUTE_GPU_TOPOLOGY; + +//! @} + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_CudaEnumComputeCapableGpus +// +//! DESCRIPTION: This API enumerates one or more compute-capable GPUs. +//! Note that this API is deprecated and should no longer be used for new software development. +//! \deprecated Do not use this function - it is deprecated in release 319. +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [inout] pComputeTopo Pointer to the structure NV_COMPUTE_GPU_TOPOLOGY. +//! +//! \retval ::NVAPI_OK The request was completed successfully. +//! The gpuCount indicates if one or more compute-capable GPUs are found. +//! gpuCount >= 1 means atleast one compute-capable GPU is found. +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION Structure version is not supported, initialize to NV_COMPUTE_GPU_TOPOLOGY_VER. +//! \retval ::NVAPI_ERROR Enumeration of the GPUs failed. Make sure at least one NVIDIA GPU exists in the system. +//! +//! \ingroup gpucuda +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 319.") +NVAPI_INTERFACE NvAPI_GPU_CudaEnumComputeCapableGpus(__inout NV_COMPUTE_GPU_TOPOLOGY *pComputeTopo); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetTachReading +// +//! DESCRIPTION: This API retrieves the fan speed tachometer reading for the specified physical GPU. +//! +//! HOW TO USE: +//! - NvU32 Value = 0; +//! - ret = NvAPI_GPU_GetTachReading(hPhysicalGpu, &Value); +//! - On call success: +//! - Value contains the tachometer reading +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \param [in] hPhysicalGpu GPU selection. +//! \param [out] pValue Pointer to a variable to get the tachometer reading +//! +//! \retval ::NVAPI_OK - completed request +//! \retval ::NVAPI_ERROR - miscellaneous error occurred +//! \retval ::NVAPI_NOT_SUPPORTED - functionality not supported +//! \retval ::NVAPI_API_NOT_INTIALIZED - nvapi not initialized +//! \retval ::NVAPI_INVALID_ARGUMENT - invalid argument passed +//! \retval ::NVAPI_HANDLE_INVALIDATED - handle passed has been invalidated (see user guide) +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE - handle passed is not a physical GPU handle +//! +//! \ingroup gpucooler +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetTachReading(NvPhysicalGpuHandle hPhysicalGPU, NvU32 *pValue); + + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetECCStatusInfo +// +//! \fn NvAPI_GPU_GetECCStatusInfo(NvPhysicalGpuHandle hPhysicalGpu, +//! NV_GPU_ECC_STATUS_INFO *pECCStatusInfo); +//! DESCRIPTION: This function returns ECC memory status information. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \param [in] hPhysicalGpu A handle identifying the physical GPU for which ECC +//! status information is to be retrieved. +//! \param [out] pECCStatusInfo A pointer to an ECC status structure. +//! +//! \retval ::NVAPI_OK The request was completed successfully. +//! \retval ::NVAPI_ERROR An unknown error occurred. +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE The provided GPU handle is not a physical GPU handle. +//! \retval ::NVAPI_INVALID_HANDLE The provided GPU handle is invalid. +//! \retval ::NVAPI_HANDLE_INVALIDATED The provided GPU handle is no longer valid. +//! \retval ::NVAPI_INVALID_POINTER An invalid argument pointer was provided. +//! \retval ::NVAPI_NOT_SUPPORTED The request is not supported. +//! \retval ::NVAPI_API_NOT_INTIALIZED NvAPI was not yet initialized. +// +/////////////////////////////////////////////////////////////////////////////// + +//! \addtogroup gpuecc +//! Used in NV_GPU_ECC_STATUS_INFO. +typedef enum _NV_ECC_CONFIGURATION +{ + NV_ECC_CONFIGURATION_NOT_SUPPORTED = 0, + NV_ECC_CONFIGURATION_DEFERRED, //!< Changes require a POST to take effect + NV_ECC_CONFIGURATION_IMMEDIATE, //!< Changes can optionally be made to take effect immediately +} NV_ECC_CONFIGURATION; + +//! \ingroup gpuecc +//! Used in NvAPI_GPU_GetECCStatusInfo(). +typedef struct +{ + NvU32 version; //!< Structure version + NvU32 isSupported : 1; //!< ECC memory feature support + NV_ECC_CONFIGURATION configurationOptions; //!< Supported ECC memory feature configuration options + NvU32 isEnabled : 1; //!< Active ECC memory setting +} NV_GPU_ECC_STATUS_INFO; + +//! \ingroup gpuecc +//! Macro for constructing the version field of NV_GPU_ECC_STATUS_INFO +#define NV_GPU_ECC_STATUS_INFO_VER MAKE_NVAPI_VERSION(NV_GPU_ECC_STATUS_INFO,1) + +//! \ingroup gpuecc +NVAPI_INTERFACE NvAPI_GPU_GetECCStatusInfo(NvPhysicalGpuHandle hPhysicalGpu, + NV_GPU_ECC_STATUS_INFO *pECCStatusInfo); + +//! \ingroup gpuecc +//! Used in NvAPI_GPU_GetECCErrorInfo()/ +typedef struct +{ + NvU32 version; //!< Structure version + struct + { + NvU64 singleBitErrors; //!< Number of single-bit ECC errors detected since last boot + NvU64 doubleBitErrors; //!< Number of double-bit ECC errors detected since last boot + } current; + struct + { + NvU64 singleBitErrors; //!< Number of single-bit ECC errors detected since last counter reset + NvU64 doubleBitErrors; //!< Number of double-bit ECC errors detected since last counter reset + } aggregate; +} NV_GPU_ECC_ERROR_INFO; + +//! \ingroup gpuecc +//! Macro for constructing the version field of NV_GPU_ECC_ERROR_INFO +#define NV_GPU_ECC_ERROR_INFO_VER MAKE_NVAPI_VERSION(NV_GPU_ECC_ERROR_INFO,1) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetECCErrorInfo +// +//! \fn NvAPI_GPU_GetECCErrorInfo(NvPhysicalGpuHandle hPhysicalGpu, +//! NV_GPU_ECC_ERROR_INFO *pECCErrorInfo); +//! +//! DESCRIPTION: This function returns ECC memory error information. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \param [in] hPhysicalGpu A handle identifying the physical GPU for +//! which ECC error information is to be +//! retrieved. +//! \param [out] pECCErrorInfo A pointer to an ECC error structure. +//! +//! \retval ::NVAPI_OK The request was completed successfully. +//! \retval ::NVAPI_ERROR An unknown error occurred. +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE The provided GPU handle is not a physical GPU handle. +//! \retval ::NVAPI_INVALID_ARGUMENT incorrect param value +//! \retval ::NVAPI_INVALID_POINTER An invalid argument pointer was provided. +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION structure version is not supported, initialize to NV_GPU_ECC_ERROR_INFO_VER. +//! \retval ::NVAPI_HANDLE_INVALIDATED The provided GPU handle is no longer valid. +//! \retval ::NVAPI_NOT_SUPPORTED The request is not supported. +//! \retval ::NVAPI_API_NOT_INTIALIZED NvAPI was not yet initialized. +// +/////////////////////////////////////////////////////////////////////////////// +//! \ingroup gpuecc + +NVAPI_INTERFACE NvAPI_GPU_GetECCErrorInfo(NvPhysicalGpuHandle hPhysicalGpu, + NV_GPU_ECC_ERROR_INFO *pECCErrorInfo); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_ResetECCErrorInfo +// +//! DESCRIPTION: This function resets ECC memory error counters. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \requires Administrator privileges since release 430.39 +//! +//! \param [in] hPhysicalGpu A handle identifying the physical GPU for +//! which ECC error information is to be +//! cleared. +//! \param [in] bResetCurrent Reset the current ECC error counters. +//! \param [in] bResetAggregate Reset the aggregate ECC error counters. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \retval ::NVAPI_INVALID_USER_PRIVILEGE - The application will require Administrator privileges to access this API. +//! The application can be elevated to a higher permission level by selecting "Run as Administrator". +//! +//! \ingroup gpuecc +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_ResetECCErrorInfo(NvPhysicalGpuHandle hPhysicalGpu, NvU8 bResetCurrent, + NvU8 bResetAggregate); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetECCConfigurationInfo +// +//! \fn NvAPI_GPU_GetECCConfigurationInfo(NvPhysicalGpuHandle hPhysicalGpu, +//! NV_GPU_ECC_CONFIGURATION_INFO *pECCConfigurationInfo); +//! DESCRIPTION: This function returns ECC memory configuration information. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \param [in] hPhysicalGpu A handle identifying the physical GPU for +//! which ECC configuration information +//! is to be retrieved. +//! \param [out] pECCConfigurationInfo A pointer to an ECC +//! configuration structure. +//! +//! \retval ::NVAPI_OK The request was completed successfully. +//! \retval ::NVAPI_ERROR An unknown error occurred. +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE The provided GPU handle is not a physical GPU handle. +//! \retval ::NVAPI_INVALID_HANDLE The provided GPU handle is invalid. +//! \retval ::NVAPI_HANDLE_INVALIDATED The provided GPU handle is no longer valid. +//! \retval ::NVAPI_INVALID_POINTER An invalid argument pointer was provided. +//! \retval ::NVAPI_NOT_SUPPORTED The request is not supported. +//! \retval ::NVAPI_API_NOT_INTIALIZED NvAPI was not yet initialized. +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup gpuecc +//! Used in NvAPI_GPU_GetECCConfigurationInfo(). +typedef struct +{ + NvU32 version; //! Structure version + NvU32 isEnabled : 1; //! Current ECC configuration stored in non-volatile memory + NvU32 isEnabledByDefault : 1; //! Factory default ECC configuration (static) +} NV_GPU_ECC_CONFIGURATION_INFO; + +//! \ingroup gpuecc +//! Macro for consstructing the verion field of NV_GPU_ECC_CONFIGURATION_INFO +#define NV_GPU_ECC_CONFIGURATION_INFO_VER MAKE_NVAPI_VERSION(NV_GPU_ECC_CONFIGURATION_INFO,1) + +//! \ingroup gpuecc +NVAPI_INTERFACE NvAPI_GPU_GetECCConfigurationInfo(NvPhysicalGpuHandle hPhysicalGpu, + NV_GPU_ECC_CONFIGURATION_INFO *pECCConfigurationInfo); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_SetECCConfiguration +// +//! DESCRIPTION: This function updates the ECC memory configuration setting. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \requires Administrator privileges since release 430.39 +//! +//! \param [in] hPhysicalGpu A handle identifying the physical GPU for +//! which to update the ECC configuration +//! setting. +//! \param [in] bEnable The new ECC configuration setting. +//! \param [in] bEnableImmediately Request that the new setting take effect immediately. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \retval ::NVAPI_INVALID_CONFIGURATION - Possibly SLI is enabled. Disable SLI and retry. +//! \retval ::NVAPI_INVALID_USER_PRIVILEGE - The application will require Administrator privileges to access this API. +//! The application can be elevated to a higher permission level by selecting "Run as Administrator". +//! +//! \ingroup gpuecc +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_SetECCConfiguration(NvPhysicalGpuHandle hPhysicalGpu, NvU8 bEnable, + NvU8 bEnableImmediately); + + + +// The following enum is providing definitions for events signaled by a Quadro Sync (QSYNC) device. +// QSYNC event broadcast is supported for Windows 10 and later OS. +typedef enum +{ + NV_QSYNC_EVENT_NONE = 0, + NV_QSYNC_EVENT_SYNC_LOSS = 1, // Frame Lock sync loss event + NV_QSYNC_EVENT_SYNC_GAIN = 2, // Frame Lock sync gain event + NV_QSYNC_EVENT_HOUSESYNC_GAIN = 3, // House cable gain(plug in) event + NV_QSYNC_EVENT_HOUSESYNC_LOSS = 4, // House cable loss(plug out) event + NV_QSYNC_EVENT_RJ45_GAIN = 5, // RJ45 cable gain(plug in) event + NV_QSYNC_EVENT_RJ45_LOSS = 6, // RJ45 cable loss(plug out) event +} NV_QSYNC_EVENT; + +typedef struct +{ + NV_QSYNC_EVENT qsyncEvent; // One of the value of the enum NV_QSYNC_EVENT + NvU32 reserved[7]; // Reserved for future use. Do not use this. +} NV_QSYNC_EVENT_DATA; + +//! Callback for QSYNC event +typedef void(__cdecl *NVAPI_CALLBACK_QSYNCEVENT)(NV_QSYNC_EVENT_DATA qyncEventData, void *callbackParam); + + +//! Enum for Event IDs +typedef enum +{ + NV_EVENT_TYPE_NONE = 0, + NV_EVENT_TYPE_QSYNC = 6, +} NV_EVENT_TYPE; + +//! Core NV_EVENT_REGISTER_CALLBACK structure declaration +typedef struct +{ + NvU32 version; //!< version field to ensure minimum version compatibility + NV_EVENT_TYPE eventId; //!< ID of the event being sent + void *callbackParam; //!< This value will be passed back to the callback function when an event occurs + union + { + NVAPI_CALLBACK_QSYNCEVENT nvQSYNCEventCallback; //!< Callback function pointer for QSYNC events + }nvCallBackFunc; + +} NV_EVENT_REGISTER_CALLBACK, *PNV_EVENT_REGISTER_CALLBACK; + +//! Macro for constructing the version field of ::NV_EVENT_REGISTER_CALLBACK +#define NV_EVENT_REGISTER_CALLBACK_VERSION MAKE_NVAPI_VERSION(NV_EVENT_REGISTER_CALLBACK,1) + + +//! \ingroup gpu +typedef enum _NV_GPU_WORKSTATION_FEATURE_TYPE +{ + NV_GPU_WORKSTATION_FEATURE_TYPE_NVIDIA_RTX_VR_READY = 1, //!< NVIDIA RTX VR Ready + NV_GPU_WORKSTATION_FEATURE_TYPE_QUADRO_VR_READY = NV_GPU_WORKSTATION_FEATURE_TYPE_NVIDIA_RTX_VR_READY, //!< DEPRECATED name - do not use + NV_GPU_WORKSTATION_FEATURE_TYPE_PROVIZ = 2, +} NV_GPU_WORKSTATION_FEATURE_TYPE; + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GPU_QueryWorkstationFeatureSupport +// +//! \fn NvAPI_GPU_QueryWorkstationFeatureSupport(NvPhysicalGpuHandle physicalGpu, NV_GPU_WORKSTATION_FEATURE_TYPE gpuWorkstationFeature) +//! \code +//! DESCRIPTION: Indicates whether a queried workstation feature is supported by the requested GPU. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! \since Release: 440 +//! +//! DESCRIPTION: This API, when called with a valid physical gpu handle as Input, lets caller know whether the given workstation feature is supported by this GPU. +//! +//! PARAMETERS: physicalGpu(IN) : The handle of the GPU for the which caller wants to get the support information. +//! gpuWorkstationFeature(IN ) : The feature for the GPU in question. One of the values from enum NV_GPU_WORKSTATION_FEATURE_TYPE. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status listed below +//! +//! \retval ::NVAPI_OK the queried workstation feature is supported on the given GPU. +//! \retval ::NVAPI_NO_IMPLEMENTATION the current driver doesn't support this interface. +//! \retval ::NVAPI_INVALID_HANDLE the incoming physicalGpu handle is invalid. +//! \retval ::NVAPI_NOT_SUPPORTED the requested gpuWorkstationFeature is not supported in the selected GPU. +//! \retval ::NVAPI_SETTING_NOT_FOUND the requested gpuWorkstationFeature is unknown to the current driver version. +//! +//! \endcode +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_QueryWorkstationFeatureSupport(NvPhysicalGpuHandle physicalGpu, NV_GPU_WORKSTATION_FEATURE_TYPE gpuWorkstationFeature); + + + +//! \ingroup gpu +typedef struct +{ + NvU32 version; //!< version of this structure + NvU32 width; //!< width of the input texture + NvU32 height; //!< height of the input texture + float* blendingTexture; //!< array of floating values building an intensity RGB texture +} NV_SCANOUT_INTENSITY_DATA_V1; + +//! \ingroup gpu +typedef struct +{ + NvU32 version; //!< version of this structure + NvU32 width; //!< width of the input texture + NvU32 height; //!< height of the input texture + float* blendingTexture; //!< array of floating values building an intensity RGB texture + float* offsetTexture; //!< array of floating values building an offset texture + NvU32 offsetTexChannels; //!< number of channels per pixel in the offset texture +} NV_SCANOUT_INTENSITY_DATA_V2; + +typedef NV_SCANOUT_INTENSITY_DATA_V2 NV_SCANOUT_INTENSITY_DATA; + +//! \ingroup gpu +#define NV_SCANOUT_INTENSITY_DATA_VER1 MAKE_NVAPI_VERSION(NV_SCANOUT_INTENSITY_DATA_V1, 1) +#define NV_SCANOUT_INTENSITY_DATA_VER2 MAKE_NVAPI_VERSION(NV_SCANOUT_INTENSITY_DATA_V2, 2) +#define NV_SCANOUT_INTENSITY_DATA_VER NV_SCANOUT_INTENSITY_DATA_VER2 + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GPU_SetScanoutIntensity +// +//! DESCRIPTION: This API enables and sets up per-pixel intensity feature on the specified display. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId combined physical display and GPU identifier of the display to apply the intensity control. +//! \param [in] scanoutIntensityData the intensity texture info. +//! \param [out] pbSticky(OUT) indicates whether the settings will be kept over a reboot. +//! +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input parameters. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized. +//! \retval ::NVAPI_NOT_SUPPORTED Interface not supported by the driver used, or only supported on selected GPUs +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input data. +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION NV_SCANOUT_INTENSITY_DATA structure version mismatch. +//! \retval ::NVAPI_OK Feature enabled. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_SetScanoutIntensity(NvU32 displayId, NV_SCANOUT_INTENSITY_DATA* scanoutIntensityData, int *pbSticky); + + +//! \ingroup gpu +typedef struct _NV_SCANOUT_INTENSITY_STATE_DATA +{ + NvU32 version; //!< version of this structure + NvU32 bEnabled; //!< intensity is enabled or not +} NV_SCANOUT_INTENSITY_STATE_DATA; + +//! \ingroup gpu +#define NV_SCANOUT_INTENSITY_STATE_VER MAKE_NVAPI_VERSION(NV_SCANOUT_INTENSITY_STATE_DATA, 1) + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GPU_GetScanoutIntensityState +// +//! DESCRIPTION: This API queries current state of the intensity feature on the specified display. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId combined physical display and GPU identifier of the display to query the configuration. +//! \param [in,out] scanoutIntensityStateData intensity state data. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input parameters. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized. +//! \retval ::NVAPI_NOT_SUPPORTED Interface not supported by the driver used, or only supported on selected GPUs. +//! \retval ::NVAPI_OK Feature enabled. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetScanoutIntensityState(__in NvU32 displayId, __inout NV_SCANOUT_INTENSITY_STATE_DATA* scanoutIntensityStateData); + + +//! \ingroup gpu +typedef enum +{ + NV_GPU_WARPING_VERTICE_FORMAT_TRIANGLESTRIP_XYUVRQ = 0, + NV_GPU_WARPING_VERTICE_FORMAT_TRIANGLES_XYUVRQ = 1, +} NV_GPU_WARPING_VERTICE_FORMAT; + +//! \ingroup gpu +typedef struct +{ + NvU32 version; //!< version of this structure + float* vertices; //!< width of the input texture + NV_GPU_WARPING_VERTICE_FORMAT vertexFormat; //!< format of the input vertices + int numVertices; //!< number of the input vertices + NvSBox* textureRect; //!< rectangle in desktop coordinates describing the source area for the warping +} NV_SCANOUT_WARPING_DATA; + +//! \ingroup gpu +#define NV_SCANOUT_WARPING_VER MAKE_NVAPI_VERSION(NV_SCANOUT_WARPING_DATA, 1) + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GPU_SetScanoutWarping +// +//! DESCRIPTION: This API enables and sets up the warping feature on the specified display. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId Combined physical display and GPU identifier of the display to apply the intensity control +//! \param [in] scanoutWarpingData The warping data info +//! \param [out] pbSticky Indicates whether the settings will be kept over a reboot. +//! +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input parameters. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized. +//! \retval ::NVAPI_NOT_SUPPORTED Interface not supported by the driver used, or only supported on selected GPUs +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input data. +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION NV_SCANOUT_WARPING_DATA structure version mismatch. +//! \retval ::NVAPI_OK Feature enabled. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_GPU_SetScanoutWarping(NvU32 displayId, NV_SCANOUT_WARPING_DATA* scanoutWarpingData, int* piMaxNumVertices, int* pbSticky); + + +//! \ingroup gpu +typedef struct _NV_SCANOUT_WARPING_STATE_DATA +{ + NvU32 version; //!< version of this structure + NvU32 bEnabled; //!< warping is enabled or not +} NV_SCANOUT_WARPING_STATE_DATA; + +//! \ingroup gpu +#define NV_SCANOUT_WARPING_STATE_VER MAKE_NVAPI_VERSION(NV_SCANOUT_WARPING_STATE_DATA, 1) + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GPU_GetScanoutWarpingState +// +//! DESCRIPTION: This API queries current state of the warping feature on the specified display. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId combined physical display and GPU identifier of the display to query the configuration. +//! \param [in,out] scanoutWarpingStateData warping state data. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input parameters. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized. +//! \retval ::NVAPI_NOT_SUPPORTED Interface not supported by the driver used, or only supported on selected GPUs. +//! \retval ::NVAPI_OK Feature enabled. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetScanoutWarpingState(__in NvU32 displayId, __inout NV_SCANOUT_WARPING_STATE_DATA* scanoutWarpingStateData); + +typedef enum +{ + NV_GPU_SCANOUT_COMPOSITION_PARAMETER_WARPING_RESAMPLING_METHOD = 0 +} NV_GPU_SCANOUT_COMPOSITION_PARAMETER; + +//! This enum defines a collection of possible scanout composition values that can be used to configure +//! possible scanout composition settings. (Currently the only parameter defined is the WARPING_RESAMPLING_METHOD). +typedef enum +{ + NV_GPU_SCANOUT_COMPOSITION_PARAMETER_SET_TO_DEFAULT = 0, // Set parameter to default value. + // WARPING_RESAMPLING_METHOD section: + NV_GPU_SCANOUT_COMPOSITION_PARAMETER_VALUE_WARPING_RESAMPLING_METHOD_BILINEAR = 0x100, + NV_GPU_SCANOUT_COMPOSITION_PARAMETER_VALUE_WARPING_RESAMPLING_METHOD_BICUBIC_TRIANGULAR = 0x101, + NV_GPU_SCANOUT_COMPOSITION_PARAMETER_VALUE_WARPING_RESAMPLING_METHOD_BICUBIC_BELL_SHAPED = 0x102, + NV_GPU_SCANOUT_COMPOSITION_PARAMETER_VALUE_WARPING_RESAMPLING_METHOD_BICUBIC_BSPLINE = 0x103, + NV_GPU_SCANOUT_COMPOSITION_PARAMETER_VALUE_WARPING_RESAMPLING_METHOD_BICUBIC_ADAPTIVE_TRIANGULAR = 0x104, + NV_GPU_SCANOUT_COMPOSITION_PARAMETER_VALUE_WARPING_RESAMPLING_METHOD_BICUBIC_ADAPTIVE_BELL_SHAPED = 0x105, + NV_GPU_SCANOUT_COMPOSITION_PARAMETER_VALUE_WARPING_RESAMPLING_METHOD_BICUBIC_ADAPTIVE_BSPLINE = 0x106 +} NV_GPU_SCANOUT_COMPOSITION_PARAMETER_VALUE; + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GPU_SetScanoutCompositionParameter +// +//! DESCRIPTION: This API sets various parameters that configure the scanout composition feature on the specified display. +//! (currently there is only one configurable parameter defined: WARPING_RESAMPLING_METHOD, +//! but this function is designed to support the addition of parameters as needed.) +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId Combined physical display and GPU identifier of the display to apply the intensity control +//! \param [in] parameter The scanout composition parameter to be set +//! \param [in] parameterValue The data to be set for the specified parameter +//! \param [in] pContainer Additional container for data associated with the specified parameter +//! +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input parameters. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized. +//! \retval ::NVAPI_NOT_SUPPORTED Interface not supported by the driver used, or only supported on selected GPUs +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input data. +//! \retval ::NVAPI_OK Feature enabled. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_GPU_SetScanoutCompositionParameter(NvU32 displayId, NV_GPU_SCANOUT_COMPOSITION_PARAMETER parameter, + NV_GPU_SCANOUT_COMPOSITION_PARAMETER_VALUE parameterValue, float *pContainer); + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GPU_GetScanoutCompositionParameter +// +//! DESCRIPTION: This API queries current state of one of the various scanout composition parameters on the specified display. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId combined physical display and GPU identifier of the display to query the configuration. +//! \param [in] parameter scanout composition parameter to by queried. +//! \param [out] parameterData scanout composition parameter data. +//! \param [out] pContainer Additional container for returning data associated with the specified parameter +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input parameters. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized. +//! \retval ::NVAPI_NOT_SUPPORTED Interface not supported by the driver used, or only supported on selected GPUs. +//! \retval ::NVAPI_OK Feature enabled. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetScanoutCompositionParameter(__in NvU32 displayId, __in NV_GPU_SCANOUT_COMPOSITION_PARAMETER parameter, + __out NV_GPU_SCANOUT_COMPOSITION_PARAMETER_VALUE *parameterData, __out float *pContainer); + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GPU_GetScanoutConfiguration +// +//! DESCRIPTION: This API queries the desktop and scanout portion of the specified display. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId combined physical display and GPU identifier of the display to query the configuration. +//! \param [in,out] desktopRect desktop area of the display in desktop coordinates. +//! \param [in,out] scanoutRect scanout area of the display relative to desktopRect. +//! +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input parameters. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized. +//! \retval ::NVAPI_NOT_SUPPORTED Interface not supported by the driver used, or only supported on selected GPUs. +//! \retval ::NVAPI_OK Feature enabled. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetScanoutConfiguration(NvU32 displayId, NvSBox* desktopRect, NvSBox* scanoutRect); + + + +//! \ingroup gpu +//! Used in NvAPI_GPU_GetScanoutConfigurationEx(). +typedef struct _NV_SCANOUT_INFORMATION +{ + NvU32 version; //!< Structure version, needs to be initialized with NV_SCANOUT_INFORMATION_VER. + + NvSBox sourceDesktopRect; //!< Operating system display device rect in desktop coordinates displayId is scanning out from. + NvSBox sourceViewportRect; //!< Area inside the sourceDesktopRect which is scanned out to the display. + NvSBox targetViewportRect; //!< Area inside the rect described by targetDisplayWidth/Height sourceViewportRect is scanned out to. + NvU32 targetDisplayWidth; //!< Horizontal size of the active resolution scanned out to the display. + NvU32 targetDisplayHeight; //!< Vertical size of the active resolution scanned out to the display. + NvU32 cloneImportance; //!< If targets are cloned views of the sourceDesktopRect the cloned targets have an importance assigned (0:primary,1 secondary,...). + NV_ROTATE sourceToTargetRotation; //!< Rotation performed between the sourceViewportRect and the targetViewportRect. +} NV_SCANOUT_INFORMATION; + +#define NV_SCANOUT_INFORMATION_VER MAKE_NVAPI_VERSION(NV_SCANOUT_INFORMATION,1) + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GPU_GetScanoutConfigurationEx +// +//! DESCRIPTION: This API queries the desktop and scanout portion of the specified display. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! \since Release: 331 +//! +//! \param [in] displayId combined physical display and GPU identifier of the display to query the configuration. +//! \param [in,out] pScanoutInformation desktop area to displayId mapping information. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetScanoutConfigurationEx(__in NvU32 displayId, __inout NV_SCANOUT_INFORMATION *pScanoutInformation); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetAdapterIdFromPhysicalGpu +// +//! DESCRIPTION: This API returns the OS-AdapterID from physicalGpu Handle. OS-AdapterID +//! is the Adapter ID that is used by Win7 CCD APIs. +//! This API is deprecated. Please use NvAPI_GPU_GetLogicalGpuInfo to get the OS-AdapterID. +//! NvAPI_GetLogicalGPUFromPhysicalGPU can be used to get the logical GPU handle associated with specified physical GPU handle. +//! +//! \deprecated Do not use this function - it is deprecated in release 520. Instead, use NvAPI_GPU_GetLogicalGpuInfo. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hPhysicalGpu PhysicalGpu Handle +//! \param [out] pOSAdapterId Returns OS-AdapterId, it is typed as void * to +//! avoid dependency with windows.h. User must type cast it to LUID. +//! +//! \retval ::NVAPI_INVALID_ARGUMENT pOSAdapterId is NULL; hPhysicalGpu is invalid +//! \retval ::NVAPI_OK *pOSAdapterId contains valid data. +//! \retval ::NVAPI_NOT_SUPPORTED This API is not supported on the system. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 520. Instead, use NvAPI_GPU_GetLogicalGpuInfo.") +NVAPI_INTERFACE NvAPI_GPU_GetAdapterIdFromPhysicalGpu(NvPhysicalGpuHandle hPhysicalGpu, void *pOSAdapterId); + + + + +//! \ingroup gpu +typedef enum _NV_VIRTUALIZATION_MODE +{ + NV_VIRTUALIZATION_MODE_NONE = 0, //!< Represents Bare Metal GPU + NV_VIRTUALIZATION_MODE_NMOS = 1, //!< Represents GPU-Passthrough + NV_VIRTUALIZATION_MODE_VGX = 2, //!< Represents vGPU inside virtual machine + NV_VIRTUALIZATION_MODE_HOST_VGPU = 3 //!< Represents VGX hypervisor in vGPU mode +} NV_VIRTUALIZATION_MODE; + +//! \ingroup gpu +typedef struct _NV_GPU_VIRTUALIZATION_INFO +{ + NvU32 version; //!< Structure version + + NV_VIRTUALIZATION_MODE virtualizationMode; //!< one of NV_VIRTUALIZATION_MODE. + NvU32 reserved; //!< reserved for future use. Should be set to ZERO. +} NV_GPU_VIRTUALIZATION_INFO_V1; + +//! \ingroup gpu +typedef NV_GPU_VIRTUALIZATION_INFO_V1 NV_GPU_VIRTUALIZATION_INFO; + +//! \ingroup gpu +#define NV_GPU_VIRTUALIZATION_INFO_VER1 MAKE_NVAPI_VERSION(NV_GPU_VIRTUALIZATION_INFO_V1,1) + +//! \ingroup gpu +#define NV_GPU_VIRTUALIZATION_INFO_VER NV_GPU_VIRTUALIZATION_INFO_VER1 + + +/////////////////////////////////////////////////////////////////////////////// +//! +//! FUNCTION NAME: NvAPI_GPU_GetVirtualizationInfo +//! +//! DESCRIPTION: This API returns virtualization information of the GPU +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 367 +//! +//! \param [in,out] pVirtualizationInfo Pointer to NV_GPU_VIRTUALIZATION_INFO structure. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetVirtualizationInfo(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GPU_VIRTUALIZATION_INFO *pVirtualizationInfo); + + +//! \ingroup gpu +typedef struct _NV_LOGICAL_GPU_DATA_V1 +{ + NvU32 version; //!< [in] Structure version. + void *pOSAdapterId; //!< [out] Returns OS-AdapterId. User must send memory buffer of size atleast equal to the size of LUID structure before calling the NVAPI. + NvU32 physicalGpuCount; //!< [out] Number of physical GPU handles associated with the specified logical GPU handle. + + NvPhysicalGpuHandle physicalGpuHandles[NVAPI_MAX_PHYSICAL_GPUS]; //!< [out] This array will be filled with physical GPU handles associated with the given logical GPU handle. + //!< The array index refers to the Physical Gpu Index (Idx). + //!< Idx value is the same as D3D11 MultiGPUDevice GPU index, D3D12 node index, OpenGL GL_NV_gpu_multicast GPU index. + //!< When converted to a bit mask (1 << Idx), it matches: + //!< 1. Vulkan deviceNodeMask in VkPhysicalDeviceIDProperties + //!< 2. CUDA deviceNodeMask returned by cuDeviceGetLuid + NvU32 reserved[8]; //!< Reserved for future use. Should be set to ZERO. +} NV_LOGICAL_GPU_DATA_V1; + +//! \ingroup gpu +typedef NV_LOGICAL_GPU_DATA_V1 NV_LOGICAL_GPU_DATA; +#define NV_LOGICAL_GPU_DATA_VER1 MAKE_NVAPI_VERSION(NV_LOGICAL_GPU_DATA_V1,1) +#define NV_LOGICAL_GPU_DATA_VER NV_LOGICAL_GPU_DATA_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetLogicalGpuInfo +// +//! This function is used to query Logical GPU information. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 421 +//! +//! \param [in] hLogicalGpu logical GPU Handle. +//! \param [inout] pLogicalGpuData Pointer to NV_LOGICAL_GPU_DATA structure. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetLogicalGpuInfo(__in NvLogicalGpuHandle hLogicalGpu, __inout NV_LOGICAL_GPU_DATA *pLogicalGpuData); + + +//! \addtogroup gridlicense +//! @{ + +//! Maximum number of supported Feature License +#define NV_LICENSE_MAX_COUNT 3 + +//! Signature length for GRID License +#define NV_LICENSE_SIGNATURE_SIZE (128) + +//! Length for Grid License +#define NV_LICENSE_INFO_MAX_LENGTH (128) + +//! License string +typedef char NvAPI_LicenseString[NV_LICENSE_INFO_MAX_LENGTH]; + +//! Used in NV_LICENSE_FEATURE_DETAILS +typedef enum _NV_LICENSE_FEATURE_TYPE +{ + NV_LICENSE_FEATURE_UNKNOWN = 0, + NV_LICENSE_FEATURE_VGPU = 1, + NV_LICENSE_FEATURE_NVIDIA_RTX = 2, + NV_LICENSE_FEATURE_QUADRO = NV_LICENSE_FEATURE_NVIDIA_RTX, //!< DEPRECATED name - do not use + NV_LICENSE_FEATURE_GAMING = 3, +} NV_LICENSE_FEATURE_TYPE; + +//! Used in NV_LICENSE_FEATURE_DETAILS +//! +//!< The 'status' variable holds any one of the following license expiry status codes : +//!< 0 - Expiry information not available +//!< 1 - Invalid expiry or error fetching expiry +//!< 2 - Valid expiry +//!< 3 - Expiry not applicable +//!< 4 - Permanent expiry +typedef struct _NV_LICENSE_EXPIRY_DETAILS +{ + NvU32 year; //!< Year value of license expiry + NvU16 month; //!< Month value of license expiry + NvU16 day; //!< Day value of license expiry + NvU16 hour; //!< Hour value of license expiry + NvU16 min; //!< Minutes value of license expiry + NvU16 sec; //!< Seconds value of license expiry + + NvU8 status; //!< License expiry status +}NV_LICENSE_EXPIRY_DETAILS; + +//! Used in NV_LICENSABLE_FEATURES +typedef struct _NV_LICENSE_FEATURE_DETAILS_V1 +{ + NvU32 version; //!< IN - Structure version. + NvU32 isEnabled : 1; //!< The current state of the licensed feature, true=enabled, false=disabled. + NvU32 reserved : 31; //!< Reserved + NV_LICENSE_FEATURE_TYPE featureCode; //!< Feature code that corresponds to the licensable feature. + NvAPI_LicenseString licenseInfo; //!< Deprecated +}NV_LICENSE_FEATURE_DETAILS_V1; + +typedef struct _NV_LICENSE_FEATURE_DETAILS_V2 +{ + NvU32 version; //!< Unused. + NvU32 isEnabled : 1; //!< The current state of the licensed feature, true=enabled, false=disabled. + NvU32 reserved : 31; //!< Reserved + NV_LICENSE_FEATURE_TYPE featureCode; //!< Feature code that corresponds to the licensable feature. + NvAPI_LicenseString licenseInfo; //!< Deprecated + NvAPI_LicenseString productName; //!< Nvidia Grid licensable product name. +}NV_LICENSE_FEATURE_DETAILS_V2; + +typedef struct _NV_LICENSE_FEATURE_DETAILS_V3 +{ + NvU32 version; //!< Unused. + NvU32 isEnabled : 1; //!< The current state of license, true=licensed, false=unlicensed. + NvU32 isFeatureEnabled : 1; //!< The current state of feature, true=enabled, false=disabled. + NvU32 reserved : 30; //!< Reserved + NV_LICENSE_FEATURE_TYPE featureCode; //!< Feature code that corresponds to the licensable feature. + NvAPI_LicenseString licenseInfo; //!< Deprecated + NvAPI_LicenseString productName; //!< Nvidia Grid licensable product name. +}NV_LICENSE_FEATURE_DETAILS_V3; + +typedef struct _NV_LICENSE_FEATURE_DETAILS_V4 +{ + NvU32 version; //!< Unused. + NvU32 isEnabled : 1; //!< The current state of license, true=licensed, false=unlicensed. + NvU32 isFeatureEnabled : 1; //!< The current state of feature, true=enabled, false=disabled. + NvU32 reserved : 30; //!< Reserved + NV_LICENSE_FEATURE_TYPE featureCode; //!< Feature code that corresponds to the licensable feature. + NvAPI_LicenseString licenseInfo; //!< Deprecated + NvAPI_LicenseString productName; //!< Nvidia Grid licensable product name. + NV_LICENSE_EXPIRY_DETAILS licenseExpiry; //!< License expiry information. +}NV_LICENSE_FEATURE_DETAILS_V4; + +typedef NV_LICENSE_FEATURE_DETAILS_V1 NV_LICENSE_FEATURE_DETAILS; + +#define NV_LICENSE_FEATURE_DETAILS_VER1 MAKE_NVAPI_VERSION(NV_LICENSE_FEATURE_DETAILS_V1, 1) +#define NV_LICENSE_FEATURE_DETAILS_VER NV_LICENSE_FEATURE_DETAILS_VER1 + +//! Licensable features +typedef struct _NV_LICENSABLE_FEATURES_V1 +{ + NvU32 version; //!< IN - Structure version. + NvU32 isLicenseSupported : 1; //!< True if Software Licensing is supported. + NvU32 reserved : 31; //!< Reserved + NvU32 licensableFeatureCount; //!< The number of licensable features. + NvU8 signature[NV_LICENSE_SIGNATURE_SIZE]; //!< Dynamic signature required for Authentication of the components, + //!< signature length limited to NV_LICENSE_SIGNATURE_SIZE + NV_LICENSE_FEATURE_DETAILS_V1 licenseDetails[NV_LICENSE_MAX_COUNT]; //!< Array of licensable features +}NV_LICENSABLE_FEATURES_V1; + +typedef struct _NV_LICENSABLE_FEATURES_V2 +{ + NvU32 version; //!< IN - Structure version. + NvU32 isLicenseSupported : 1; //!< True if Software Licensing is supported. + NvU32 reserved : 31; //!< Reserved + NvU32 licensableFeatureCount; //!< The number of licensable features. + NvU8 signature[NV_LICENSE_SIGNATURE_SIZE]; //!< Dynamic signature required for Authentication of the components, + //!< signature length limited to NV_LICENSE_SIGNATURE_SIZE + NV_LICENSE_FEATURE_DETAILS_V2 licenseDetails[NV_LICENSE_MAX_COUNT]; //!< Array of licensable features +}NV_LICENSABLE_FEATURES_V2; + +typedef struct _NV_LICENSABLE_FEATURES_V3 +{ + NvU32 version; //!< IN - Structure version. + NvU32 isLicenseSupported : 1; //!< True if Software Licensing is supported. + NvU32 reserved : 31; //!< Reserved + NvU32 licensableFeatureCount; //!< The number of licensable features. + NvU8 signature[NV_LICENSE_SIGNATURE_SIZE]; //!< Dynamic signature required for Authentication of the components, + //!< signature length limited to NV_LICENSE_SIGNATURE_SIZE + NV_LICENSE_FEATURE_DETAILS_V3 licenseDetails[NV_LICENSE_MAX_COUNT]; //!< Array of licensable features +}NV_LICENSABLE_FEATURES_V3; + +typedef struct _NV_LICENSABLE_FEATURES_V4 +{ + NvU32 version; //!< IN - Structure version. + NvU32 isLicenseSupported : 1; //!< True if Software Licensing is supported. + NvU32 reserved : 31; //!< Reserved + NvU32 licensableFeatureCount; //!< The number of licensable features. + NvU8 signature[NV_LICENSE_SIGNATURE_SIZE]; //!< Dynamic signature required for Authentication of the components, + //!< signature length limited to NV_LICENSE_SIGNATURE_SIZE + NV_LICENSE_FEATURE_DETAILS_V4 licenseDetails[NV_LICENSE_MAX_COUNT]; //!< Array of licensable features +}NV_LICENSABLE_FEATURES_V4; + +typedef NV_LICENSABLE_FEATURES_V4 NV_LICENSABLE_FEATURES; + +#define NV_LICENSABLE_FEATURES_VER1 MAKE_NVAPI_VERSION(NV_LICENSABLE_FEATURES_V1, 1) +#define NV_LICENSABLE_FEATURES_VER2 MAKE_NVAPI_VERSION(NV_LICENSABLE_FEATURES_V2, 2) +#define NV_LICENSABLE_FEATURES_VER3 MAKE_NVAPI_VERSION(NV_LICENSABLE_FEATURES_V3, 3) +#define NV_LICENSABLE_FEATURES_VER4 MAKE_NVAPI_VERSION(NV_LICENSABLE_FEATURES_V4, 4) +#define NV_LICENSABLE_FEATURES_VER NV_LICENSABLE_FEATURES_VER4 + +//! @} + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetLicensableFeatures +// +//! DESCRIPTION: This function call identifies whether licenses are supported on this system and if +//! they are supported, returns the details of the features that can be licensed. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \param [in] hPhysicalGpu GPU selection +//! \param [in,out] pLicensableFeatures Licensable features information. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup gridlicense +///////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetLicensableFeatures(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_LICENSABLE_FEATURES *pLicensableFeatures); + + + +typedef struct _NV_GPU_VR_READY_V1 +{ + NvU32 version; //!< Structure Version. + NvU32 isVRReady : 1; //!< Is the requested GPU VR ready. + NvU32 reserved : 31; +} NV_GPU_VR_READY_V1; + +#define NV_GPU_VR_READY_VER1 MAKE_NVAPI_VERSION(NV_GPU_VR_READY_V1, 1) +#define NV_GPU_VR_READY_VER NV_GPU_VR_READY_VER1 +typedef NV_GPU_VR_READY_V1 NV_GPU_VR_READY; + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetVRReadyData +// +//! DESCRIPTION: This API will return NVIDIA GPU VR Ready state. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 465 +//! +//! \param [inout] pGpuVrReadyData - This structure will be filled with required information. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetVRReadyData(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GPU_VR_READY *pGpuVrReadyData); + +//! Used in NvAPI_GPU_GetPerfDecreaseInfo. +//! Bit masks for knowing the exact reason for performance decrease +typedef enum _NVAPI_GPU_PERF_DECREASE +{ + NV_GPU_PERF_DECREASE_NONE = 0, //!< No Slowdown detected + NV_GPU_PERF_DECREASE_REASON_THERMAL_PROTECTION = 0x00000001, //!< Thermal slowdown/shutdown/POR thermal protection + NV_GPU_PERF_DECREASE_REASON_POWER_CONTROL = 0x00000002, //!< Power capping / pstate cap + NV_GPU_PERF_DECREASE_REASON_AC_BATT = 0x00000004, //!< AC->BATT event + NV_GPU_PERF_DECREASE_REASON_API_TRIGGERED = 0x00000008, //!< API triggered slowdown + NV_GPU_PERF_DECREASE_REASON_INSUFFICIENT_POWER = 0x00000010, //!< Power connector missing + NV_GPU_PERF_DECREASE_REASON_UNKNOWN = 0x80000000, //!< Unknown reason +} NVAPI_GPU_PERF_DECREASE; + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetPerfDecreaseInfo +// +//! DESCRIPTION: This function retrieves - in NvU32 variable - reasons for the current performance decrease. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! \param [in] hPhysicalGPU (IN) - GPU for which performance decrease is to be evaluated. +//! \param [out] pPerfDecrInfo (OUT) - Pointer to a NvU32 variable containing performance decrease info +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! +//! \ingroup gpuPerf +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetPerfDecreaseInfo(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NvU32 *pPerfDecrInfo); + + +//! \ingroup gpupstate +//! Used in NvAPI_GPU_GetPstatesInfoEx() +typedef struct +{ + NvU32 version; + NvU32 flags; //!< - bit 0 indicates if perfmon is enabled or not + //!< - bit 1 indicates if dynamic Pstate is capable or not + //!< - bit 2 indicates if dynamic Pstate is enable or not + //!< - all other bits must be set to 0 + NvU32 numPstates; //!< The number of available p-states + NvU32 numClocks; //!< The number of clock domains supported by each P-State + struct + { + NV_GPU_PERF_PSTATE_ID pstateId; //!< ID of the p-state. + NvU32 flags; //!< - bit 0 indicates if the PCIE limit is GEN1 or GEN2 + //!< - bit 1 indicates if the Pstate is overclocked or not + //!< - bit 2 indicates if the Pstate is overclockable or not + //!< - all other bits must be set to 0 + struct + { + NV_GPU_PUBLIC_CLOCK_ID domainId; //!< ID of the clock domain + NvU32 flags; //!< Reserved. Must be set to 0 + NvU32 freq; //!< Clock frequency in kHz + + } clocks[NVAPI_MAX_GPU_PERF_CLOCKS]; + } pstates[NVAPI_MAX_GPU_PERF_PSTATES]; + +} NV_GPU_PERF_PSTATES_INFO_V1; + + +//! \ingroup gpupstate +typedef struct +{ + NvU32 version; + NvU32 flags; //!< - bit 0 indicates if perfmon is enabled or not + //!< - bit 1 indicates if dynamic Pstate is capable or not + //!< - bit 2 indicates if dynamic Pstate is enable or not + //!< - all other bits must be set to 0 + NvU32 numPstates; //!< The number of available p-states + NvU32 numClocks; //!< The number of clock domains supported by each P-State + NvU32 numVoltages; + struct + { + NV_GPU_PERF_PSTATE_ID pstateId; //!< ID of the p-state. + NvU32 flags; //!< - bit 0 indicates if the PCIE limit is GEN1 or GEN2 + //!< - bit 1 indicates if the Pstate is overclocked or not + //!< - bit 2 indicates if the Pstate is overclockable or not + //!< - all other bits must be set to 0 + struct + { + NV_GPU_PUBLIC_CLOCK_ID domainId; + NvU32 flags; //!< bit 0 indicates if this clock is overclockable + //!< all other bits must be set to 0 + NvU32 freq; + + } clocks[NVAPI_MAX_GPU_PERF_CLOCKS]; + struct + { + NV_GPU_PERF_VOLTAGE_INFO_DOMAIN_ID domainId; //!< ID of the voltage domain, containing flags and mvolt info + NvU32 flags; //!< Reserved for future use. Must be set to 0 + NvU32 mvolt; //!< Voltage in mV + + } voltages[NVAPI_MAX_GPU_PERF_VOLTAGES]; + + } pstates[NVAPI_MAX_GPU_PERF_PSTATES]; //!< Valid index range is 0 to numVoltages-1 + +} NV_GPU_PERF_PSTATES_INFO_V2; + +//! \ingroup gpupstate +typedef NV_GPU_PERF_PSTATES_INFO_V2 NV_GPU_PERF_PSTATES_INFO; + + +//! \ingroup gpupstate +//! @{ + +//! Macro for constructing the version field of NV_GPU_PERF_PSTATES_INFO_V1 +#define NV_GPU_PERF_PSTATES_INFO_VER1 MAKE_NVAPI_VERSION(NV_GPU_PERF_PSTATES_INFO_V1,1) + +//! Macro for constructing the version field of NV_GPU_PERF_PSTATES_INFO_V2 +#define NV_GPU_PERF_PSTATES_INFO_VER2 MAKE_NVAPI_VERSION(NV_GPU_PERF_PSTATES_INFO_V2,2) + +//! Macro for constructing the version field of NV_GPU_PERF_PSTATES_INFO_V2 +#define NV_GPU_PERF_PSTATES_INFO_VER3 MAKE_NVAPI_VERSION(NV_GPU_PERF_PSTATES_INFO_V2,3) + +//! Macro for constructing the version field of NV_GPU_PERF_PSTATES_INFO +#define NV_GPU_PERF_PSTATES_INFO_VER NV_GPU_PERF_PSTATES_INFO_VER3 + +//! @} + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetPstatesInfoEx +// +//! DESCRIPTION: This API retrieves all performance states (P-States) information. This is the same as +//! NvAPI_GPU_GetPstatesInfo(), but supports an input flag for various options. +//! +//! P-States are GPU active/executing performance capability and power consumption states. +//! +//! P-States ranges from P0 to P15, with P0 being the highest performance/power state, and +//! P15 being the lowest performance/power state. Each P-State, if available, maps to a +//! performance level. Not all P-States are available on a given system. The definitions +//! of each P-State are currently as follows: \n +//! - P0/P1 - Maximum 3D performance +//! - P2/P3 - Balanced 3D performance-power +//! - P8 - Basic HD video playback +//! - P10 - DVD playback +//! - P12 - Minimum idle power consumption +//! +//! \deprecated Do not use this function - it is deprecated in release 304. Instead, use NvAPI_GPU_GetPstates20. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hPhysicalGPU GPU selection. +//! \param [out] pPerfPstatesInfo P-States information retrieved, as detailed below: \n +//! - flags is reserved for future use. +//! - numPstates is the number of available P-States +//! - numClocks is the number of clock domains supported by each P-State +//! - pstates has valid index range from 0 to numPstates - 1 +//! - pstates[i].pstateId is the ID of the P-State, +//! containing the following info: +//! - pstates[i].flags containing the following info: +//! - bit 0 indicates if the PCIE limit is GEN1 or GEN2 +//! - bit 1 indicates if the Pstate is overclocked or not +//! - bit 2 indicates if the Pstate is overclockable or not +//! - pstates[i].clocks has valid index range from 0 to numClocks -1 +//! - pstates[i].clocks[j].domainId is the public ID of the clock domain, +//! containing the following info: +//! - pstates[i].clocks[j].flags containing the following info: +//! bit 0 indicates if the clock domain is overclockable or not +//! - pstates[i].clocks[j].freq is the clock frequency in kHz +//! - pstates[i].voltages has a valid index range from 0 to numVoltages - 1 +//! - pstates[i].voltages[j].domainId is the ID of the voltage domain, +//! containing the following info: +//! - pstates[i].voltages[j].flags is reserved for future use. +//! - pstates[i].voltages[j].mvolt is the voltage in mV +//! inputFlags(IN) - This can be used to select various options: +//! - if bit 0 is set, pPerfPstatesInfo would contain the default settings +//! instead of the current, possibily overclocked settings. +//! - if bit 1 is set, pPerfPstatesInfo would contain the maximum clock +//! frequencies instead of the nominal frequencies. +//! - if bit 2 is set, pPerfPstatesInfo would contain the minimum clock +//! frequencies instead of the nominal frequencies. +//! - all other bits must be set to 0. +//! +//! \retval ::NVAPI_OK Completed request +//! \retval ::NVAPI_ERROR Miscellaneous error occurred +//! \retval ::NVAPI_HANDLE_INVALIDATED Handle passed has been invalidated (see user guide) +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE Handle passed is not a physical GPU handle +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION The version of the NV_GPU_PERF_PSTATES struct is not supported +//! +//! \ingroup gpupstate +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 304. Instead, use NvAPI_GPU_GetPstates20.") +NVAPI_INTERFACE NvAPI_GPU_GetPstatesInfoEx(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_PSTATES_INFO *pPerfPstatesInfo, NvU32 inputFlags); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetPstates20 +// +//! DESCRIPTION: This API retrieves all performance states (P-States) 2.0 information. +//! +//! P-States are GPU active/executing performance capability states. +//! They range from P0 to P15, with P0 being the highest performance state, +//! and P15 being the lowest performance state. Each P-State, if available, +//! maps to a performance level. Not all P-States are available on a given system. +//! The definition of each P-States are currently as follow: +//! - P0/P1 - Maximum 3D performance +//! - P2/P3 - Balanced 3D performance-power +//! - P8 - Basic HD video playback +//! - P10 - DVD playback +//! - P12 - Minimum idle power consumption +//! +//! TCC_SUPPORTED +//! +//! \since Release: 295 +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hPhysicalGPU GPU selection +//! \param [out] pPstatesInfo P-States information retrieved, as documented in declaration above +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +//! +//! \ingroup gpupstate +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetPstates20(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GPU_PERF_PSTATES20_INFO *pPstatesInfo); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetCurrentPstate +// +//! DESCRIPTION: This function retrieves the current performance state (P-State). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 165 +//! +//! TCC_SUPPORTED +//! +//! \param [in] hPhysicalGPU GPU selection +//! \param [out] pCurrentPstate The ID of the current P-State of the GPU - see \ref NV_GPU_PERF_PSTATES. +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred. +//! \retval NVAPI_HANDLE_INVALIDATED Handle passed has been invalidated (see user guide). +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE Handle passed is not a physical GPU handle. +//! \retval NVAPI_NOT_SUPPORTED P-States is not supported on this setup. +//! +//! \ingroup gpupstate +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetCurrentPstate(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_PSTATE_ID *pCurrentPstate); + + + + +//! \ingroup gpupstate +#define NVAPI_MAX_GPU_UTILIZATIONS 8 + + + +//! \ingroup gpupstate +//! Used in NvAPI_GPU_GetDynamicPstatesInfoEx(). +typedef struct +{ + NvU32 version; //!< Structure version + NvU32 flags; //!< bit 0 indicates if the dynamic Pstate is enabled or not + struct + { + NvU32 bIsPresent:1; //!< Set if this utilization domain is present on this GPU + NvU32 percentage; //!< Percentage of time where the domain is considered busy in the last 1 second interval + } utilization[NVAPI_MAX_GPU_UTILIZATIONS]; +} NV_GPU_DYNAMIC_PSTATES_INFO_EX; + +//! \ingroup gpupstate +//! Macro for constructing the version field of NV_GPU_DYNAMIC_PSTATES_INFO_EX +#define NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER MAKE_NVAPI_VERSION(NV_GPU_DYNAMIC_PSTATES_INFO_EX,1) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetDynamicPstatesInfoEx +// +//! DESCRIPTION: This API retrieves the NV_GPU_DYNAMIC_PSTATES_INFO_EX structure for the specified physical GPU. +//! Each domain's info is indexed in the array. For example: +//! - pDynamicPstatesInfo->utilization[NVAPI_GPU_UTILIZATION_DOMAIN_GPU] holds the info for the GPU domain. \p +//! There are currently 4 domains for which GPU utilization and dynamic P-State thresholds can be retrieved: +//! graphic engine (GPU), frame buffer (FB), video engine (VID), and bus interface (BUS). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! +//! TCC_SUPPORTED +//! \since Release: 185 +//! +//! \retval ::NVAPI_OK +//! \retval ::NVAPI_ERROR +//! \retval ::NVAPI_INVALID_ARGUMENT pDynamicPstatesInfo is NULL +//! \retval ::NVAPI_HANDLE_INVALIDATED +//! \retval ::NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION The version of the INFO struct is not supported +//! +//! \ingroup gpupstate +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetDynamicPstatesInfoEx(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_DYNAMIC_PSTATES_INFO_EX *pDynamicPstatesInfoEx); +/////////////////////////////////////////////////////////////////////////////////// +// Thermal API +// Provides ability to get temperature levels from the various thermal sensors associated with the GPU + +//! \ingroup gputhermal +#define NVAPI_MAX_THERMAL_SENSORS_PER_GPU 3 + +//! \ingroup gputhermal +//! Used in NV_GPU_THERMAL_SETTINGS +typedef enum +{ + NVAPI_THERMAL_TARGET_NONE = 0, + NVAPI_THERMAL_TARGET_GPU = 1, //!< GPU core temperature requires NvPhysicalGpuHandle + NVAPI_THERMAL_TARGET_MEMORY = 2, //!< GPU memory temperature requires NvPhysicalGpuHandle + NVAPI_THERMAL_TARGET_POWER_SUPPLY = 4, //!< GPU power supply temperature requires NvPhysicalGpuHandle + NVAPI_THERMAL_TARGET_BOARD = 8, //!< GPU board ambient temperature requires NvPhysicalGpuHandle + NVAPI_THERMAL_TARGET_VCD_BOARD = 9, //!< Visual Computing Device Board temperature requires NvVisualComputingDeviceHandle + NVAPI_THERMAL_TARGET_VCD_INLET = 10, //!< Visual Computing Device Inlet temperature requires NvVisualComputingDeviceHandle + NVAPI_THERMAL_TARGET_VCD_OUTLET = 11, //!< Visual Computing Device Outlet temperature requires NvVisualComputingDeviceHandle + + NVAPI_THERMAL_TARGET_ALL = 15, + NVAPI_THERMAL_TARGET_UNKNOWN = -1, +} NV_THERMAL_TARGET; + +//! \ingroup gputhermal +//! Used in NV_GPU_THERMAL_SETTINGS +typedef enum +{ + NVAPI_THERMAL_CONTROLLER_NONE = 0, + NVAPI_THERMAL_CONTROLLER_GPU_INTERNAL, + NVAPI_THERMAL_CONTROLLER_ADM1032, + NVAPI_THERMAL_CONTROLLER_MAX6649, + NVAPI_THERMAL_CONTROLLER_MAX1617, + NVAPI_THERMAL_CONTROLLER_LM99, + NVAPI_THERMAL_CONTROLLER_LM89, + NVAPI_THERMAL_CONTROLLER_LM64, + NVAPI_THERMAL_CONTROLLER_ADT7473, + NVAPI_THERMAL_CONTROLLER_SBMAX6649, + NVAPI_THERMAL_CONTROLLER_VBIOSEVT, + NVAPI_THERMAL_CONTROLLER_OS, + NVAPI_THERMAL_CONTROLLER_UNKNOWN = -1, +} NV_THERMAL_CONTROLLER; + +//! \ingroup gputhermal +//! Used in NvAPI_GPU_GetThermalSettings() +typedef struct +{ + NvU32 version; //!< structure version + NvU32 count; //!< number of associated thermal sensors + struct + { + NV_THERMAL_CONTROLLER controller; //!< internal, ADM1032, MAX6649... + NvU32 defaultMinTemp; //!< The min default temperature value of the thermal sensor in degree Celsius + NvU32 defaultMaxTemp; //!< The max default temperature value of the thermal sensor in degree Celsius + NvU32 currentTemp; //!< The current temperature value of the thermal sensor in degree Celsius + NV_THERMAL_TARGET target; //!< Thermal sensor targeted @ GPU, memory, chipset, powersupply, Visual Computing Device, etc. + } sensor[NVAPI_MAX_THERMAL_SENSORS_PER_GPU]; + +} NV_GPU_THERMAL_SETTINGS_V1; + +//! \ingroup gputhermal +typedef struct +{ + NvU32 version; //!< structure version + NvU32 count; //!< number of associated thermal sensors + struct + { + NV_THERMAL_CONTROLLER controller; //!< internal, ADM1032, MAX6649... + NvS32 defaultMinTemp; //!< Minimum default temperature value of the thermal sensor in degree Celsius + NvS32 defaultMaxTemp; //!< Maximum default temperature value of the thermal sensor in degree Celsius + NvS32 currentTemp; //!< Current temperature value of the thermal sensor in degree Celsius + NV_THERMAL_TARGET target; //!< Thermal sensor targeted - GPU, memory, chipset, powersupply, Visual Computing Device, etc + } sensor[NVAPI_MAX_THERMAL_SENSORS_PER_GPU]; + +} NV_GPU_THERMAL_SETTINGS_V2; + +//! \ingroup gputhermal +typedef NV_GPU_THERMAL_SETTINGS_V2 NV_GPU_THERMAL_SETTINGS; + +//! \ingroup gputhermal +//! @{ + +//! Macro for constructing the version field of NV_GPU_THERMAL_SETTINGS_V1 +#define NV_GPU_THERMAL_SETTINGS_VER_1 MAKE_NVAPI_VERSION(NV_GPU_THERMAL_SETTINGS_V1,1) + +//! Macro for constructing the version field of NV_GPU_THERMAL_SETTINGS_V2 +#define NV_GPU_THERMAL_SETTINGS_VER_2 MAKE_NVAPI_VERSION(NV_GPU_THERMAL_SETTINGS_V2,2) + +//! Macro for constructing the version field of NV_GPU_THERMAL_SETTINGS +#define NV_GPU_THERMAL_SETTINGS_VER NV_GPU_THERMAL_SETTINGS_VER_2 +//! @} + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetThermalSettings +// +//! This function retrieves the thermal information of all thermal sensors or specific thermal sensor associated with the selected GPU. +//! Thermal sensors are indexed 0 to NVAPI_MAX_THERMAL_SENSORS_PER_GPU-1. +//! +//! - To retrieve specific thermal sensor info, set the sensorIndex to the required thermal sensor index. +//! - To retrieve info for all sensors, set sensorIndex to NVAPI_THERMAL_TARGET_ALL. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 85 +//! +//! \param [in] hPhysicalGPU GPU selection. +//! \param [in] sensorIndex Explicit thermal sensor index selection. +//! \param [out] pThermalSettings Array of thermal settings. +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred. +//! \retval NVAPI_INVALID_ARGUMENT pThermalInfo is NULL. +//! \retval NVAPI_HANDLE_INVALIDATED Handle passed has been invalidated (see user guide). +//! \retval NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE Handle passed is not a physical GPU handle. +//! \retval NVAPI_INCOMPATIBLE_STRUCT_VERSION The version of the INFO struct is not supported. +//! \ingroup gputhermal +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetThermalSettings(NvPhysicalGpuHandle hPhysicalGpu, NvU32 sensorIndex, NV_GPU_THERMAL_SETTINGS *pThermalSettings); + + + +//! \ingroup gpuclock +//! Used in NvAPI_GPU_GetAllClockFrequencies() +typedef struct +{ + NvU32 version; //!< Structure version + NvU32 reserved; //!< These bits are reserved for future use. + struct + { + NvU32 bIsPresent:1; //!< Set if this domain is present on this GPU + NvU32 reserved:31; //!< These bits are reserved for future use. + NvU32 frequency; //!< Clock frequency (kHz) + }domain[NVAPI_MAX_GPU_PUBLIC_CLOCKS]; +} NV_GPU_CLOCK_FREQUENCIES_V1; + +#ifndef NV_GPU_MAX_CLOCK_FREQUENCIES + #define NV_GPU_MAX_CLOCK_FREQUENCIES 3 +#endif + +//! \ingroup gpuclock +//! Used in NvAPI_GPU_GetAllClockFrequencies() +typedef enum +{ + NV_GPU_CLOCK_FREQUENCIES_CURRENT_FREQ = 0, + NV_GPU_CLOCK_FREQUENCIES_BASE_CLOCK = 1, + NV_GPU_CLOCK_FREQUENCIES_BOOST_CLOCK = 2, + NV_GPU_CLOCK_FREQUENCIES_CLOCK_TYPE_NUM = NV_GPU_MAX_CLOCK_FREQUENCIES +} NV_GPU_CLOCK_FREQUENCIES_CLOCK_TYPE; + +//! \ingroup gpuclock +//! Used in NvAPI_GPU_GetAllClockFrequencies() +typedef struct +{ + NvU32 version; //!< Structure version + NvU32 ClockType:4; //!< One of NV_GPU_CLOCK_FREQUENCIES_CLOCK_TYPE. Used to specify the type of clock to be returned. + NvU32 reserved:20; //!< These bits are reserved for future use. Must be set to 0. + NvU32 reserved1:8; //!< These bits are reserved. + struct + { + NvU32 bIsPresent:1; //!< Set if this domain is present on this GPU + NvU32 reserved:31; //!< These bits are reserved for future use. + NvU32 frequency; //!< Clock frequency (kHz) + }domain[NVAPI_MAX_GPU_PUBLIC_CLOCKS]; +} NV_GPU_CLOCK_FREQUENCIES_V2; + +//! \ingroup gpuclock +//! Used in NvAPI_GPU_GetAllClockFrequencies() +typedef NV_GPU_CLOCK_FREQUENCIES_V2 NV_GPU_CLOCK_FREQUENCIES; + +//! \addtogroup gpuclock +//! @{ +#define NV_GPU_CLOCK_FREQUENCIES_VER_1 MAKE_NVAPI_VERSION(NV_GPU_CLOCK_FREQUENCIES_V1,1) +#define NV_GPU_CLOCK_FREQUENCIES_VER_2 MAKE_NVAPI_VERSION(NV_GPU_CLOCK_FREQUENCIES_V2,2) +#define NV_GPU_CLOCK_FREQUENCIES_VER_3 MAKE_NVAPI_VERSION(NV_GPU_CLOCK_FREQUENCIES_V2,3) +#define NV_GPU_CLOCK_FREQUENCIES_VER NV_GPU_CLOCK_FREQUENCIES_VER_3 +//! @} + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetAllClockFrequencies +// +//! This function retrieves the NV_GPU_CLOCK_FREQUENCIES structure for the specified physical GPU. +//! +//! For each clock domain: +//! - bIsPresent is set for each domain that is present on the GPU +//! - frequency is the domain's clock freq in kHz +//! +//! Each domain's info is indexed in the array. For example: +//! clkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_MEMORY] holds the info for the MEMORY domain. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 295 +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +//! \retval NVAPI_INVALID_ARGUMENT pClkFreqs is NULL. +//! \ingroup gpuclock +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetAllClockFrequencies(__in NvPhysicalGpuHandle hPhysicalGPU, __inout NV_GPU_CLOCK_FREQUENCIES *pClkFreqs); + + +/////////////////////////////////////////////////////////////////////////////// +//! +//! FUNCTION NAME: NvAPI_GPU_QueryIlluminationSupport +//! +//! \fn NvAPI_GPU_QueryIlluminationSupport(__inout NV_GPU_QUERY_ILLUMINATION_SUPPORT_PARM *pIlluminationSupportInfo) +//! DESCRIPTION: This function reports if the specified illumination attribute is supported. +//! +//! \note Only a single GPU can manage an given attribute on a given HW element, +//! regardless of how many are attatched. I.E. only one GPU will be used to control +//! the brightness of the LED on an SLI bridge, regardless of how many are physicaly attached. +//! You should enumerate thru the GPUs with this call to determine which GPU is managing the attribute. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 300.05 +//! +//! \param [in] hPhysicalGpu Physical GPU handle +//! \param Attribute An enumeration value specifying the Illumination attribute to be querried +//! \param [out] pSupported A boolean indicating if the attribute is supported. +//! +//! \return See \ref nvapistatus for the list of possible return values. +// +////////////////////////////////////////////////////////////////////////////// + +//! \ingroup gpu +typedef enum _NV_GPU_ILLUMINATION_ATTRIB +{ + NV_GPU_IA_LOGO_BRIGHTNESS = 0, + NV_GPU_IA_SLI_BRIGHTNESS = 1, +} NV_GPU_ILLUMINATION_ATTRIB; + +//! \ingroup gpu +typedef struct _NV_GPU_QUERY_ILLUMINATION_SUPPORT_PARM_V1 { + + // IN + NvU32 version; //!< Version of this structure + NvPhysicalGpuHandle hPhysicalGpu; //!< The handle of the GPU that you are checking for the specified attribute. + //!< note that this is the GPU that is managing the attribute. + //!< Only a single GPU can manage an given attribute on a given HW element, + //!< regardless of how many are attatched. + //!< I.E. only one GPU will be used to control the brightness of the LED on an SLI bridge, + //!< regardless of how many are physicaly attached. + //!< You enumerate thru the GPUs with this call to determine which GPU is managing the attribute. + NV_GPU_ILLUMINATION_ATTRIB Attribute; //!< An enumeration value specifying the Illumination attribute to be querried. + //!< refer to enum \ref NV_GPU_ILLUMINATION_ATTRIB. + + // OUT + NvU32 bSupported; //!< A boolean indicating if the attribute is supported. + +} NV_GPU_QUERY_ILLUMINATION_SUPPORT_PARM_V1; + +//! \ingroup gpu +typedef NV_GPU_QUERY_ILLUMINATION_SUPPORT_PARM_V1 NV_GPU_QUERY_ILLUMINATION_SUPPORT_PARM; +//! \ingroup gpu +#define NV_GPU_QUERY_ILLUMINATION_SUPPORT_PARM_VER_1 MAKE_NVAPI_VERSION(NV_GPU_QUERY_ILLUMINATION_SUPPORT_PARM_V1,1) +//! \ingroup gpu +#define NV_GPU_QUERY_ILLUMINATION_SUPPORT_PARM_VER NV_GPU_QUERY_ILLUMINATION_SUPPORT_PARM_VER_1 + +//! \ingroup gpu +NVAPI_INTERFACE NvAPI_GPU_QueryIlluminationSupport(__inout NV_GPU_QUERY_ILLUMINATION_SUPPORT_PARM *pIlluminationSupportInfo); + + + + +/////////////////////////////////////////////////////////////////////////////// +//! +//! FUNCTION NAME: NvAPI_GPU_GetIllumination +//! +//! \fn NvAPI_GPU_GetIllumination(NV_GPU_GET_ILLUMINATION_PARM *pIlluminationInfo) +//! DESCRIPTION: This function reports value of the specified illumination attribute. +//! +//! \note Only a single GPU can manage an given attribute on a given HW element, +//! regardless of how many are attatched. I.E. only one GPU will be used to control +//! the brightness of the LED on an SLI bridge, regardless of how many are physicaly attached. +//! You should enumerate thru the GPUs with the \ref NvAPI_GPU_QueryIlluminationSupport call to +//! determine which GPU is managing the attribute. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 300.05 +//! +//! \param [in] hPhysicalGpu Physical GPU handle +//! \param Attribute An enumeration value specifying the Illumination attribute to be querried +//! \param [out] Value A DWORD containing the current value for the specified attribute. +//! This is specified as a percentage of the full range of the attribute +//! (0-100; 0 = off, 100 = full brightness) +//! +//! \return See \ref nvapistatus for the list of possible return values. Return values of special interest are: +//! NVAPI_INVALID_ARGUMENT The specified attibute is not known to the driver. +//! NVAPI_NOT_SUPPORTED: The specified attribute is not supported on the specified GPU +// +////////////////////////////////////////////////////////////////////////////// + +//! \ingroup gpu +typedef struct _NV_GPU_GET_ILLUMINATION_PARM_V1 { + + // IN + NvU32 version; //!< Version of this structure + NvPhysicalGpuHandle hPhysicalGpu; //!< The handle of the GPU that you are checking for the specified attribute. + //!< Note that this is the GPU that is managing the attribute. + //!< Only a single GPU can manage an given attribute on a given HW element, + //!< regardless of how many are attatched. + //!< I.E. only one GPU will be used to control the brightness of the LED on an SLI bridge, + //!< regardless of how many are physicaly attached. + //!< You enumerate thru the GPUs with this call to determine which GPU is managing the attribute. + NV_GPU_ILLUMINATION_ATTRIB Attribute; //!< An enumeration value specifying the Illumination attribute to be querried. + //!< refer to enum \ref NV_GPU_ILLUMINATION_ATTRIB. + + // OUT + NvU32 Value; //!< A DWORD that will contain the current value of the specified attribute. + //! This is specified as a percentage of the full range of the attribute + //! (0-100; 0 = off, 100 = full brightness) + +} NV_GPU_GET_ILLUMINATION_PARM_V1; + +//! \ingroup gpu +typedef NV_GPU_GET_ILLUMINATION_PARM_V1 NV_GPU_GET_ILLUMINATION_PARM; +//! \ingroup gpu +#define NV_GPU_GET_ILLUMINATION_PARM_VER_1 MAKE_NVAPI_VERSION(NV_GPU_GET_ILLUMINATION_PARM_V1,1) +//! \ingroup gpu +#define NV_GPU_GET_ILLUMINATION_PARM_VER NV_GPU_GET_ILLUMINATION_PARM_VER_1 + +//! \ingroup gpu +NVAPI_INTERFACE NvAPI_GPU_GetIllumination(NV_GPU_GET_ILLUMINATION_PARM *pIlluminationInfo); + + + + +/////////////////////////////////////////////////////////////////////////////// +//! +//! FUNCTION NAME: NvAPI_GPU_SetIllumination +//! +//! \fn NvAPI_GPU_SetIllumination(NV_GPU_SET_ILLUMINATION_PARM *pIlluminationInfo) +//! DESCRIPTION: This function sets the value of the specified illumination attribute. +//! +//! \note Only a single GPU can manage an given attribute on a given HW element, +//! regardless of how many are attatched. I.E. only one GPU will be used to control +//! the brightness of the LED on an SLI bridge, regardless of how many are physicaly attached. +//! You should enumerate thru the GPUs with the \ref NvAPI_GPU_QueryIlluminationSupport call to +//! determine which GPU is managing the attribute. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 300.05 +//! +//! \param [in] hPhysicalGpu Physical GPU handle +//! \param Attribute An enumeration value specifying the Illumination attribute to be set +//! \param Value The new value for the specified attribute. +//! This should be specified as a percentage of the full range of the attribute +//! (0-100; 0 = off, 100 = full brightness) +//! If a value is specified outside this range, NVAPI_INVALID_ARGUMENT will be returned. +//! +//! \return See \ref nvapistatus for the list of possible return values. Return values of special interest are: +//! NVAPI_INVALID_ARGUMENT The specified attibute is not known to the driver, or the specified value is out of range. +//! NVAPI_NOT_SUPPORTED The specified attribute is not supported on the specified GPU. +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup gpu +typedef struct _NV_GPU_SET_ILLUMINATION_PARM_V1 { + + // IN + NvU32 version; //!< Version of this structure + NvPhysicalGpuHandle hPhysicalGpu; //!< The handle of the GPU that you are checking for the specified attribute. + //!< Note that this is the GPU that is managing the attribute. + //!< Only a single GPU can manage an given attribute on a given HW element, + //!< regardless of how many are attatched. + //!< I.E. only one GPU will be used to control the brightness of the LED on an SLI bridge, + //!< regardless of how many are physicaly attached. + //!< You enumerate thru the GPUs with this call to determine which GPU is managing the attribute. + NV_GPU_ILLUMINATION_ATTRIB Attribute; //!< An enumeration value specifying the Illumination attribute to be querried. + //!< refer to enum \ref NV_GPU_ILLUMINATION_ATTRIB. + NvU32 Value; //!< A DWORD containing the new value for the specified attribute. + //!< This should be specified as a percentage of the full range of the attribute + //!< (0-100; 0 = off, 100 = full brightness) + //!< If a value is specified outside this range, NVAPI_INVALID_ARGUMENT will be returned. + + // OUT + +} NV_GPU_SET_ILLUMINATION_PARM_V1; + +//! \ingroup gpu +typedef NV_GPU_SET_ILLUMINATION_PARM_V1 NV_GPU_SET_ILLUMINATION_PARM; +//! \ingroup gpu +#define NV_GPU_SET_ILLUMINATION_PARM_VER_1 MAKE_NVAPI_VERSION(NV_GPU_SET_ILLUMINATION_PARM_V1,1) +//! \ingroup gpu +#define NV_GPU_SET_ILLUMINATION_PARM_VER NV_GPU_SET_ILLUMINATION_PARM_VER_1 + +//! \ingroup gpu +NVAPI_INTERFACE NvAPI_GPU_SetIllumination(NV_GPU_SET_ILLUMINATION_PARM *pIlluminationInfo); + + + +/*! + * Enumeration of control modes that can be applied to Illumination Zones. + */ +typedef enum +{ + NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB = 0, // deprecated + NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB, // deprecated + + NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL = 0, + NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR, + + // Strictly add new control modes above this. + NV_GPU_CLIENT_ILLUM_CTRL_MODE_INVALID = 0xFF, +} NV_GPU_CLIENT_ILLUM_CTRL_MODE; + +/*! + * Enumeration of locations where an Illumination Zone might be present. + * Encoding used - + * 1:0 - Number specifier (0) + * 4:2 - Location (TOP) + * 7:5 - Type (GPU/SLI) + */ +typedef enum +{ + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION_GPU_TOP_0 = 0x00, + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION_GPU_FRONT_0 = 0x08, + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION_GPU_BACK_0 = 0x0C, + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION_SLI_TOP_0 = 0x20, + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION_INVALID = 0xFFFFFFFF, +} NV_GPU_CLIENT_ILLUM_ZONE_LOCATION; + +/*! + * Enumeration of ILLUM_DEVICEs. + */ +typedef enum +{ + NV_GPU_CLIENT_ILLUM_DEVICE_TYPE_INVALID = 0, + NV_GPU_CLIENT_ILLUM_DEVICE_TYPE_MCUV10, + NV_GPU_CLIENT_ILLUM_DEVICE_TYPE_GPIO_PWM_RGBW_V10, + NV_GPU_CLIENT_ILLUM_DEVICE_TYPE_GPIO_PWM_SINGLE_COLOR_V10, +} NV_GPU_CLIENT_ILLUM_DEVICE_TYPE; + +/*! + * Enumeration of ILLUM_ZONEs. + */ +typedef enum +{ + NV_GPU_CLIENT_ILLUM_ZONE_TYPE_INVALID = 0, + NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGB, + NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED, + NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGBW, + NV_GPU_CLIENT_ILLUM_ZONE_TYPE_SINGLE_COLOR, +} NV_GPU_CLIENT_ILLUM_ZONE_TYPE; + +/*! + * Number of color points for the piecewise linear control mode. + */ +#define NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_COLOR_ENDPOINTS 2 + +/*! + * Enumeration of Cycle types for piecewise linear control mode. + */ +typedef enum +{ + NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_HALF_HALT = 0, + NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_FULL_HALT, + NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_FULL_REPEAT, + NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_INVALID = 0xFF, +} NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_TYPE; + +#define NV_GPU_CLIENT_ILLUM_DEVICE_NUM_DEVICES_MAX 32 + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_DEVICE_INFO_V1 + * Describes the static information of illumination device type MCUV10. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_DEVICE_INFO_DATA_MCUV10 +{ + /*! + * I2C Device Index: Pointing to the illumination device in I2C Devices Table. + */ + NvU8 i2cDevIdx; +} NV_GPU_CLIENT_ILLUM_DEVICE_INFO_DATA_MCUV10; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_DEVICE_INFO_V1 + * Describes the static information of illum device type GPIO_PWM_RGBW. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_DEVICE_INFO_DATA_GPIO_PWM_RGBW +{ + /*! + * Red drive GPIO pin. + */ + NvU8 gpioPinRed; + + /*! + * Green drive GPIO pin. + */ + NvU8 gpioPinGreen; + + /*! + * Blue drive GPIO pin. + */ + NvU8 gpioPinBlue; + + /*! + * White drive GPIO pin. + */ + NvU8 gpioPinWhite; +} NV_GPU_CLIENT_ILLUM_DEVICE_INFO_DATA_GPIO_PWM_RGBW; +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_DEVICE_INFO_V1 + * Describes the static information of illum device type GPIO_PWM_SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_DEVICE_INFO_DATA_GPIO_PWM_SINGLE_COLOR +{ + /*! + * Single Color GPIO pin. + */ + NvU8 gpioPinSingleColor; +} NV_GPU_CLIENT_ILLUM_DEVICE_INFO_DATA_GPIO_PWM_SINGLE_COLOR; + +/*! + */ +typedef struct _NV_GPU_CLIENT_ILLUM_DEVICE_INFO_V1 +{ + /*! + * Type of the illumination device. + */ + NV_GPU_CLIENT_ILLUM_DEVICE_TYPE type; + + /*! + * Supported control modes for this illumination device. + */ + NvU32 ctrlModeMask; + + /*! + * Union of illumination device info data. Interpreted as per + * @ref NV_GPU_CLIENT_ILLUM_DEVICE_INFO_V1::type + */ + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_DEVICE_INFO_DATA_MCUV10 mcuv10; + NV_GPU_CLIENT_ILLUM_DEVICE_INFO_DATA_GPIO_PWM_RGBW gpioPwmRgbwv10; + NV_GPU_CLIENT_ILLUM_DEVICE_INFO_DATA_GPIO_PWM_SINGLE_COLOR gpioPwmSingleColorv10; + + /*! + * Reserved bytes for possible future extension of this struct. + */ + NvU8 rsvd[64]; + } data; + + /*! + * Reserved for future. + */ + NvU8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_DEVICE_INFO_V1; + +/*! + */ +typedef struct _NV_GPU_CLIENT_ILLUM_DEVICE_INFO_PARAMS_V1 +{ + /*! + * Version of structure. Must always be first member. + */ + NvU32 version; + + /*! + * Number of illumination devices present. + */ + NvU32 numIllumDevices; + + /*! + * Reserved bytes for possible future extension of this struct. + */ + NvU8 rsvd[64]; + + /*! + */ + NV_GPU_CLIENT_ILLUM_DEVICE_INFO_V1 devices[NV_GPU_CLIENT_ILLUM_DEVICE_NUM_DEVICES_MAX]; +} NV_GPU_CLIENT_ILLUM_DEVICE_INFO_PARAMS_V1; + +#define NV_GPU_CLIENT_ILLUM_DEVICE_INFO_PARAMS_VER_1 MAKE_NVAPI_VERSION(NV_GPU_CLIENT_ILLUM_DEVICE_INFO_PARAMS_V1, 1) +#define NV_GPU_CLIENT_ILLUM_DEVICE_INFO_PARAMS_VER NV_GPU_CLIENT_ILLUM_DEVICE_INFO_PARAMS_VER_1 +typedef NV_GPU_CLIENT_ILLUM_DEVICE_INFO_PARAMS_V1 NV_GPU_CLIENT_ILLUM_DEVICE_INFO_PARAMS; + +/////////////////////////////////////////////////////////////////////////////// +//! +//! FUNCTION NAME: NvAPI_GPU_ClientIllumDevicesGetInfo +//! +//! DESCRIPTION: This API returns static information about illumination devices on the +//! given GPU. +// +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 400 +//! \param [in] hPhysicalGpu The physical GPU handle +//! \param [out] pIllumDevicesInfo Pointer to structure containing static +//! information about illumination devices. +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_ClientIllumDevicesGetInfo(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GPU_CLIENT_ILLUM_DEVICE_INFO_PARAMS *pIllumDevicesInfo); + + +/*! + * Structure representing the data required for synchronization. + */ +typedef struct +{ + /*! + * Boolean representing the need for synchronization. + */ + NvBool bSync; + + /*! + * Time stamp value required for synchronization. + */ + NvU64 timeStampms; + + /*! + * Reserved for future. + */ + NvU8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_DEVICE_SYNC_V1; + +/*! + * Structure representing the device control parameters of each ILLUM_DEVICE. + */ +typedef struct +{ + /*! + * Type of the illum device. + */ + NV_GPU_CLIENT_ILLUM_DEVICE_TYPE type; + + /*! + * Structure containing the synchronization data for the illumination device. + */ + NV_GPU_CLIENT_ILLUM_DEVICE_SYNC_V1 syncData; + + /*! + * Reserved for future. + */ + NvU8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_V1; + +typedef NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_V1 NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL; + +/*! + * Structure representing the control parameters of ILLUM_DEVICE-s. + */ +typedef struct +{ + /*! + * Version of structure. Must always be first member. + */ + NvU32 version; + + /*! + * Number of illumination devices present. + */ + NvU32 numIllumDevices; + + /*! + * Reserved bytes for possible future extension of this struct. + */ + NvU8 rsvd[64]; + + /*! + */ + NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_V1 devices[NV_GPU_CLIENT_ILLUM_DEVICE_NUM_DEVICES_MAX]; +} NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_PARAMS_V1; + +#define NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_PARAMS_VER_1 MAKE_NVAPI_VERSION(NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_PARAMS_V1, 1) +#define NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_PARAMS_VER NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_PARAMS_VER_1 +typedef NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_PARAMS_V1 NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_PARAMS; + +/////////////////////////////////////////////////////////////////////////////// +//! +//! FUNCTION NAME: NvAPI_GPU_ClientIllumDevicesGetControl +//! +//! DESCRIPTION: This API gets control parameters about illumination devices on the +//! given GPU. +// +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 400 +//! \param [in] hPhysicalGpu The physical GPU handle +//! \param [inout] pIllumDevicesControl Pointer to structure containing control +//! information about illum devices. +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_ClientIllumDevicesGetControl(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_PARAMS *pClientIllumDevicesControl); + +/////////////////////////////////////////////////////////////////////////////// +//! +//! FUNCTION NAME: NvAPI_GPU_ClientIllumDevicesSetControl +//! +//! DESCRIPTION: This API sets control parameters about illumination devices on the +//! given GPU. +// +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 400 +//! \param [in] hPhysicalGpu The physical GPU handle +//! \param [inout] pClientIllumDevicesControl Pointer to structure containing control +//! information about illum devices. +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_ClientIllumDevicesSetControl(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GPU_CLIENT_ILLUM_DEVICE_CONTROL_PARAMS *pClientIllumDevicesControl); + + +#define NV_GPU_CLIENT_ILLUM_ZONE_NUM_ZONES_MAX 32 + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGB +{ + NvU8 rsvd; +} NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGB; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_INFO_V1 + * Describes the static information of illum zone type RGBW. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGBW +{ + NvU8 rsvd; +} NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGBW; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_INFO_V1 + * Describes the static information of illum zone type SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_SINGLE_COLOR +{ + NvU8 rsvd; +} NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_SINGLE_COLOR; + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_INFO_V1 +{ + NV_GPU_CLIENT_ILLUM_ZONE_TYPE type; + + /*! + * Index pointing to an Illumination Device that controls this zone. + */ + NvU8 illumDeviceIdx; + + /*! + * Provider index for representing logical to physical zone mapping. + */ + NvU8 provIdx; + + /*! + * Location of the zone on the board. + */ + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION zoneLocation; + + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGB rgb; + NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGBW rgbw; + NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_SINGLE_COLOR singleColor; + + /*! + * Reserved bytes for possible future extension of this struct. + */ + NvU8 rsvd[64]; + } data; + + NvU8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_INFO_V1; + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_V1 +{ + /*! + * Version of structure. Must always be first member. + */ + NvU32 version; + + /*! + * Number of illumination zones present. + */ + NvU32 numIllumZones; + + /*! + * Reserved bytes for possible future extension of this struct. + */ + NvU8 rsvd[64]; + NV_GPU_CLIENT_ILLUM_ZONE_INFO_V1 zones[NV_GPU_CLIENT_ILLUM_ZONE_NUM_ZONES_MAX]; +} NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_V1; + +#define NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_VER_1 MAKE_NVAPI_VERSION(NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_V1, 1) +#define NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_VER NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_VER_1 +typedef NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_V1 NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS; + +/////////////////////////////////////////////////////////////////////////////// +//! +//! FUNCTION NAME: NvAPI_GPU_ClientIllumZonesGetInfo +//! +//! DESCRIPTION: This API returns static information about illumination zones on the +//! given GPU. +// +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 400 +//! \param [in] hPhysicalGpu The physical GPU handle +//! \param [out] pIllumZonesInfo Pointer to structure containing static +//! information about illumination devices. +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_ClientIllumZonesGetInfo(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS *pIllumZonesInfo); + + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB_PARAMS +{ + /*! + * Red compenent of color applied to the zone. + */ + NvU8 colorR; + + /*! + * Green compenent of color applied to the zone. + */ + NvU8 colorG; + + /*! + * Blue compenent of color applied to the zone. + */ + NvU8 colorB; + + /*! + * Brightness perecentage value of the zone. + */ + NvU8 brightnessPct; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB_PARAMS; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGB + * Data required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB_PARAMS rgbParams; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGB + * Data required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR +{ + /*! + * Type of cycle effect to apply. + */ + NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_TYPE cycleType; + + /*! + * Number of times to repeat function within group period. + */ + NvU8 grpCount; + + /*! + * Time in ms to transition from color A to color B. + */ + NvU16 riseTimems; + + /*! + * Time in ms to transition from color B to color A. + */ + NvU16 fallTimems; + + /*! + * Time in ms to remain at color A before color A to color B transition. + */ + NvU16 ATimems; + + /*! + * Time in ms to remain at color B before color B to color A transition. + */ + NvU16 BTimems; + + /*! + * Time in ms to remain idle before next group of repeated function cycles. + */ + NvU16 grpIdleTimems; + + /*! + * Time in ms to offset the cycle relative to other zones. + */ + NvU16 phaseOffsetms; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGB + * Data required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGB +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB_PARAMS rgbParams[NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_COLOR_ENDPOINTS]; + + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR piecewiseLinearData; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGB; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_V1 + * Describes the control data for illumination zone of type + * \ref NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGB +{ + /*! + * Union of illumination zone control data for zone of type NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGB. + * Interpreted as per ctrlMode. + */ + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB manualRGB; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGB piecewiseLinearRGB; + + /*! + * Reserved bytes for possible future extension of this struct. + */ + NvU8 rsvd[64]; + } data; + + /*! + * Reserved for future. + */ + NvU8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGB; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED_PARAMS +{ + /*! + * Brightness percentage value of the zone. + */ + NvU8 brightnessPct; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED_PARAMS; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_COLOR_FIXED + * Data required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED_PARAMS colorFixedParams; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_COLOR_FIXED + * Data required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_COLOR_FIXED +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED_PARAMS colorFixedParams[NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_COLOR_ENDPOINTS]; + + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR piecewiseLinearData; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_COLOR_FIXED; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_V1 + * Describes the control data for illum zone of type + * \ref NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_COLOR_FIXED +{ + /*! + * Union of illum zone control data for zone of type NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED. + * Interpreted as per ctrlMode. + */ + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED manualColorFixed; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_COLOR_FIXED piecewiseLinearColorFixed; + /*! + * Reserved bytes for possible future extension of this struct. + */ + NvU8 rsvd[64]; + } data; + + /*! + * Reserved for future. + */ + NvU8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_COLOR_FIXED; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGBW. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW_PARAMS +{ + /*! + * Red component of color applied to the zone. + */ + NvU8 colorR; + + /*! + * Green component of color applied to the zone. + */ + NvU8 colorG; + + /*! + * Blue component of color applied to the zone. + */ + NvU8 colorB; + + /*! + * White component of color applied to the zone. + */ + NvU8 colorW; + + /*! + * Brightness percentage value of the zone. + */ + NvU8 brightnessPct; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW_PARAMS; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_RGBW + * Data required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_RGBW. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_RGBW. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW_PARAMS rgbwParams; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_RGBW + * Data required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGBW. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGBW +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGBW. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW_PARAMS rgbwParams[NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_COLOR_ENDPOINTS]; + + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR piecewiseLinearData; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGBW; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_V1 + * Describes the control data for illum zone of type + * \ref NV_GPU_ILLUM_ZONE_TYPE_RGBW. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGBW +{ + /*! + * Union of illum zone control data for zone of type NV_GPU_ILLUM_ZONE_TYPE_RGBW. + * Interpreted as per ctrlMode. + */ + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW manualRGBW; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGBW piecewiseLinearRGBW; + /*! + * Reserved bytes for possible future extension of this struct. + */ + NvU8 rsvd[64]; + } data; + + /*! + * Reserved for future. + */ + NvU8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGBW; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR_PARAMS +{ + /*! + * Brightness percentage value of the zone. + */ + NvU8 brightnessPct; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR_PARAMS; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_SINGLE_COLOR + * Data required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_SINGLE_COLOR. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR_PARAMS singleColorParams; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_SINGLE_COLOR + * Data required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_SINGLE_COLOR +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_SINGLE_COLOR. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR_PARAMS singleColorParams[NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_COLOR_ENDPOINTS]; + + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR piecewiseLinearData; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_SINGLE_COLOR; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_V1 + * Describes the control data for illum zone of type + * \ref NV_GPU_ILLUM_ZONE_TYPE_SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_SINGLE_COLOR +{ + /*! + * Union of illum zone control data for zone of type NV_GPU_ILLUM_ZONE_TYPE_SINGLE_COLOR. + * Interpreted as per ctrlMode. + */ + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR manualSingleColor; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_SINGLE_COLOR piecewiseLinearSingleColor; + /*! + * Reserved bytes for possible future extension of this struct. + */ + NvU8 rsvd[64]; + } data; + + /*! + * Reserved for future. + */ + NvU8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_SINGLE_COLOR; + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_V1 +{ + NV_GPU_CLIENT_ILLUM_ZONE_TYPE type; + NV_GPU_CLIENT_ILLUM_CTRL_MODE ctrlMode; + union + { + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGB rgb; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_COLOR_FIXED colorFixed; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGBW rgbw; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_SINGLE_COLOR singleColor; + NvU8 rsvd[64]; + } data; + NvU8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_V1; + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_V1 +{ + NvU32 version; + + /*! + * Bit field specifying the set of values to retrieve or set + * - default (NV_TRUE) + * - currently active (NV_FALSE). + */ + NvU32 bDefault : 1; + NvU32 rsvdField : 31; + + /*! + * Number of illumination zones present. + */ + NvU32 numIllumZonesControl; + + /*! + * Reserved bytes for possible future extension of this struct. + */ + NvU8 rsvd[64]; + + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_V1 zones[NV_GPU_CLIENT_ILLUM_ZONE_NUM_ZONES_MAX]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_V1; + +#define NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_VER_1 MAKE_NVAPI_VERSION(NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_V1, 1) +#define NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_VER NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_VER_1 +typedef NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_V1 NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS; + +/////////////////////////////////////////////////////////////////////////////// +//! +//! FUNCTION NAME: NvAPI_GPU_ClientIllumZonesGetControl +//! +//! DESCRIPTION: Accessor for control information about illumination zones on the +//! given GPU. +// +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 400 +//! \param [in] hPhysicalGpu The physical GPU handle +//! \param [out] pIllumZonesControl Pointer to structure containing control +//! information about illumination zones. +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_ClientIllumZonesGetControl(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS *pIllumZonesControl); + +/////////////////////////////////////////////////////////////////////////////// +//! +//! FUNCTION NAME: NvAPI_GPU_ClientIllumZonesSetControl +//! +//! DESCRIPTION: Mutator for control information about illumination zones on the +//! given GPU. +// +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 400 +//! \param [in] hPhysicalGpu The physical GPU handle +//! \param [out] pIllumZonesControl Pointer to structure containing control +//! information about illumination zones. +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_ClientIllumZonesSetControl(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS *pIllumZonesControl); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Event_RegisterCallback +// +//! DESCRIPTION: This API registers the process for events. This API should be called for each eventcallback. +//! The handle returned to the client will be common across all eventCallbacks. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] eventCallback Pointer to NV_EVENT_REGISTER_CALLBACK structure to call +//! on new events +//! \param [out] phClient Handle to client for use with +//! unregister function +//! +//! \retval ::NVAPI_OK - completed request +//! \retval ::NVAPI_API_NOT_INTIALIZED - NvAPI not initialized +//! \retval ::NVAPI_INVALID_ARGUMENT - Invalid argument +//! \retval ::NVAPI_ERROR - miscellaneous error occurred +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Event_RegisterCallback(PNV_EVENT_REGISTER_CALLBACK eventCallback, + NvEventHandle* phClient); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Event_UnregisterCallback +// +//! DESCRIPTION: This API unregister an event handle. +//! This API should be called only once per process(irrespective of the number of callbacks registered). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hClient Handle associated with this listeners +//! event queue. Same as returned from +//! NvAPI_Event_RegisterCallback(). +//! +//! \retval ::NVAPI_OK - completed request +//! \retval ::NVAPI_API_NOT_INTIALIZED - NvAPI not initialized +//! \retval ::NVAPI_INVALID_ARGUMENT - Invalid argument +//! \retval ::NVAPI_ERROR - miscellaneous error occurred +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Event_UnregisterCallback(NvEventHandle hClient); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_EnumNvidiaDisplayHandle +// +//! This function returns the handle of the NVIDIA display specified by the enum +//! index (thisEnum). The client should keep enumerating until it +//! returns error. +//! +//! Note: Display handles can get invalidated on a modeset, so the calling applications need to +//! renum the handles after every modeset. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \param [in] thisEnum The index of the NVIDIA display. +//! \param [out] pNvDispHandle Pointer to the NVIDIA display handle. +//! +//! \retval NVAPI_INVALID_ARGUMENT Either the handle pointer is NULL or enum index too big +//! \retval NVAPI_OK Return a valid NvDisplayHandle based on the enum index +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA device found in the system +//! \retval NVAPI_END_ENUMERATION No more display device to enumerate +//! \ingroup disphandle +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_EnumNvidiaDisplayHandle(NvU32 thisEnum, NvDisplayHandle *pNvDispHandle); + + + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_EnumNvidiaUnAttachedDisplayHandle +// +//! This function returns the handle of the NVIDIA unattached display specified by the enum +//! index (thisEnum). The client should keep enumerating until it +//! returns error. +//! Note: Display handles can get invalidated on a modeset, so the calling applications need to +//! renum the handles after every modeset. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \param [in] thisEnum The index of the NVIDIA display. +//! \param [out] pNvUnAttachedDispHandle Pointer to the NVIDIA display handle of the unattached display. +//! +//! \retval NVAPI_INVALID_ARGUMENT Either the handle pointer is NULL or enum index too big +//! \retval NVAPI_OK Return a valid NvDisplayHandle based on the enum index +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA device found in the system +//! \retval NVAPI_END_ENUMERATION No more display device to enumerate. +//! \ingroup disphandle +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_EnumNvidiaUnAttachedDisplayHandle(NvU32 thisEnum, NvUnAttachedDisplayHandle *pNvUnAttachedDispHandle); + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_CreateDisplayFromUnAttachedDisplay +// +//! This function converts the unattached display handle to an active attached display handle. +//! +//! At least one GPU must be present in the system and running an NVIDIA display driver. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT hNvUnAttachedDisp is not valid or pNvDisplay is NULL. +//! \retval NVAPI_OK One or more handles were returned +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_CreateDisplayFromUnAttachedDisplay(NvUnAttachedDisplayHandle hNvUnAttachedDisp, NvDisplayHandle *pNvDisplay); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetAssociatedNVidiaDisplayHandle +// +//! This function returns the handle of the NVIDIA display that is associated +//! with the given display "name" (such as "\\.\DISPLAY1"). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT Either argument is NULL +//! \retval NVAPI_OK *pNvDispHandle is now valid +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA device maps to that display name +//! \ingroup disphandle +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetAssociatedNvidiaDisplayHandle(const char *szDisplayName, NvDisplayHandle *pNvDispHandle); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DISP_GetAssociatedUnAttachedNvidiaDisplayHandle +// +//! DESCRIPTION: This function returns the handle of an unattached NVIDIA display that is +//! associated with the given display name (such as "\\DISPLAY1"). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \retval ::NVAPI_INVALID_ARGUMENT Either argument is NULL. +//! \retval ::NVAPI_OK *pNvUnAttachedDispHandle is now valid. +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA device maps to that display name. +//! +//! \ingroup disphandle +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_GetAssociatedUnAttachedNvidiaDisplayHandle(const char *szDisplayName, NvUnAttachedDisplayHandle *pNvUnAttachedDispHandle); + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetAssociatedNVidiaDisplayName +// +//! For a given NVIDIA display handle, this function returns a string (such as "\\.\DISPLAY1") to identify the display. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT Either argument is NULL +//! \retval NVAPI_OK *pNvDispHandle is now valid +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA device maps to that display name +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetAssociatedNvidiaDisplayName(NvDisplayHandle NvDispHandle, NvAPI_ShortString szDisplayName); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetUnAttachedAssociatedDisplayName +// +//! This function returns the display name given, for example, "\\DISPLAY1", using the unattached NVIDIA display handle +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 95 +//! +//! \retval NVAPI_INVALID_ARGUMENT Either argument is NULL +//! \retval NVAPI_OK *pNvDispHandle is now valid +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA device maps to that display name +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetUnAttachedAssociatedDisplayName(NvUnAttachedDisplayHandle hNvUnAttachedDisp, NvAPI_ShortString szDisplayName); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_EnableHWCursor +// +//! This function enables hardware cursor support +//! +//! SUPPORTED OS: Windows XP +//! +//! +//! +//! \since Release: 80 +//! +//! \return NVAPI_ERROR or NVAPI_OK +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_EnableHWCursor(NvDisplayHandle hNvDisplay); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DisableHWCursor +// +//! This function disables hardware cursor support +//! +//! SUPPORTED OS: Windows XP +//! +//! +//! \since Release: 80 +//! +//! \return NVAPI_ERROR or NVAPI_OK +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DisableHWCursor(NvDisplayHandle hNvDisplay); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetVBlankCounter +// +//! This function gets the V-blank counter +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 80 +//! +//! \return NVAPI_ERROR or NVAPI_OK +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetVBlankCounter(NvDisplayHandle hNvDisplay, NvU32 *pCounter); + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_SetRefreshRateOverride +// +//! This function overrides the refresh rate on the given display/outputsMask. +//! The new refresh rate can be applied right away in this API call or deferred to be applied with the +//! next OS modeset. The override is good for only one modeset (regardless whether it's deferred or immediate). +//! +//! +//! SUPPORTED OS: Windows XP +//! +//! +//! \since Release: 80 +//! +//! \param [in] hNvDisplay The NVIDIA display handle. It can be NVAPI_DEFAULT_HANDLE or a handle +//! enumerated from NvAPI_EnumNVidiaDisplayHandle(). +//! \param [in] outputsMask A set of bits that identify all target outputs which are associated with the NVIDIA +//! display handle to apply the refresh rate override. When SLI is enabled, the +//! outputsMask only applies to the GPU that is driving the display output. +//! \param [in] refreshRate The override value. "0.0" means cancel the override. +//! \param [in] bSetDeferred +//! - "0": Apply the refresh rate override immediately in this API call.\p +//! - "1": Apply refresh rate at the next OS modeset. +//! +//! \retval NVAPI_INVALID_ARGUMENT hNvDisplay or outputsMask is invalid +//! \retval NVAPI_OK The refresh rate override is correct set +//! \retval NVAPI_ERROR The operation failed +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_SetRefreshRateOverride(NvDisplayHandle hNvDisplay, NvU32 outputsMask, float refreshRate, NvU32 bSetDeferred); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetAssociatedDisplayOutputId +// +//! This function gets the active outputId associated with the display handle. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 90 +//! +//! \param [in] hNvDisplay NVIDIA Display selection. It can be NVAPI_DEFAULT_HANDLE or a handle enumerated from NvAPI_EnumNVidiaDisplayHandle(). +//! \param [out] outputId The active display output ID associated with the selected display handle hNvDisplay. +//! The outputid will have only one bit set. In the case of Clone or Span mode, this will indicate the +//! display outputId of the primary display that the GPU is driving. See \ref handles. +//! +//! \retval NVAPI_OK Call successful. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_EXPECTED_DISPLAY_HANDLE hNvDisplay is not a valid display handle. +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetAssociatedDisplayOutputId(NvDisplayHandle hNvDisplay, NvU32 *pOutputId); + + +//! \ingroup dispcontrol +//! Used in NvAPI_GetDisplayPortInfo(). +typedef struct _NV_DISPLAY_PORT_INFO_V1 +{ + NvU32 version; //!< Structure version + NvU32 dpcd_ver; //!< DPCD version of the monitor + NV_DP_LINK_RATE maxLinkRate; //!< Maximum supported link rate + NV_DP_LANE_COUNT maxLaneCount; //!< Maximum supported lane count + NV_DP_LINK_RATE curLinkRate; //!< Current link rate + NV_DP_LANE_COUNT curLaneCount; //!< Current lane count + NV_DP_COLOR_FORMAT colorFormat; //!< Current color format + NV_DP_DYNAMIC_RANGE dynamicRange; //!< Dynamic range + NV_DP_COLORIMETRY colorimetry; //!< Ignored in RGB space + NV_DP_BPC bpc; //!< Current bit-per-component + NvU32 isDp : 1; //!< If the monitor is driven by a DisplayPort + NvU32 isInternalDp : 1; //!< If the monitor is driven by an NV Dp transmitter + NvU32 isColorCtrlSupported : 1; //!< If the color format change is supported + NvU32 is6BPCSupported : 1; //!< If 6 bpc is supported + NvU32 is8BPCSupported : 1; //!< If 8 bpc is supported + NvU32 is10BPCSupported : 1; //!< If 10 bpc is supported + NvU32 is12BPCSupported : 1; //!< If 12 bpc is supported + NvU32 is16BPCSupported : 1; //!< If 16 bpc is supported + NvU32 isYCrCb420Supported : 1; //!< If YCrCb420 is supported + NvU32 isYCrCb422Supported : 1; //!< If YCrCb422 is supported + NvU32 isYCrCb444Supported : 1; //!< If YCrCb444 is supported + NvU32 isRgb444SupportedOnCurrentMode : 1; //!< If Rgb444 is supported on the current mode + NvU32 isYCbCr444SupportedOnCurrentMode : 1; //!< If YCbCr444 is supported on the current mode + NvU32 isYCbCr422SupportedOnCurrentMode : 1; //!< If YCbCr422 is supported on the current mode + NvU32 isYCbCr420SupportedOnCurrentMode : 1; //!< If YCbCr420 is supported on the current mode + NvU32 is6BPCSupportedOnCurrentMode : 1; // if 6 bpc is supported On Current Mode + NvU32 is8BPCSupportedOnCurrentMode : 1; // if 8 bpc is supported On Current Mode + NvU32 is10BPCSupportedOnCurrentMode : 1; // if 10 bpc is supported On Current Mode + NvU32 is12BPCSupportedOnCurrentMode : 1; // if 12 bpc is supported On Current Mode + NvU32 is16BPCSupportedOnCurrentMode : 1; // if 16 bpc is supported On Current Mode + NvU32 isMonxvYCC601Capable : 1; // if xvYCC 601 extended colorimetry is supported + NvU32 isMonxvYCC709Capable : 1; // if xvYCC 709 extended colorimetry is supported + NvU32 isMonsYCC601Capable : 1; // if sYCC601 extended colorimetry is supported + NvU32 isMonAdobeYCC601Capable : 1; // if AdobeYCC601 extended colorimetry is supported + NvU32 isMonAdobeRGBCapable : 1; // if AdobeRGB extended colorimetry is supported + NvU32 isMonBT2020RGBCapable : 1; // if BT2020 RGB extended colorimetry is supported + NvU32 isMonBT2020YCCCapable : 1; // if BT2020 Y'CbCr extended colorimetry is supported + NvU32 isMonBT2020cYCCCapable : 1; // if BT2020 cYCbCr (constant luminance) extended colorimetry is supported + + NvU32 reserved : 4; //!< reserved + } NV_DISPLAY_PORT_INFO_V1; + + typedef NV_DISPLAY_PORT_INFO_V1 NV_DISPLAY_PORT_INFO; + +//! Macro for constructing the version field of NV_DISPLAY_PORT_INFO. +#define NV_DISPLAY_PORT_INFO_VER1 MAKE_NVAPI_VERSION(NV_DISPLAY_PORT_INFO,1) +#define NV_DISPLAY_PORT_INFO_VER2 MAKE_NVAPI_VERSION(NV_DISPLAY_PORT_INFO,2) +#define NV_DISPLAY_PORT_INFO_VER NV_DISPLAY_PORT_INFO_VER2 + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GetDisplayPortInfo +// +//! \fn NvAPI_GetDisplayPortInfo(__in_opt NvDisplayHandle hNvDisplay, __in NvU32 outputId, __inout NV_DISPLAY_PORT_INFO *pInfo) +//! DESCRIPTION: This function returns the current DisplayPort-related information on the specified device (monitor). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 165 +//! +//! \param [in] hvDisplay NVIDIA Display selection. It can be NVAPI_DEFAULT_HANDLE or a handle enumerated from NvAPI_EnumNVidiaDisplayHandle(). +//! This parameter is ignored when the outputId is a NvAPI displayId. +//! \param [in] outputId This can either be the connection bit mask or the NvAPI displayId. When the legacy connection bit mask is passed, +//! it should have exactly 1 bit set to indicate a single display. If it's "0" then the default outputId from +//! NvAPI_GetAssociatedDisplayOutputId() will be used. See \ref handles. +//! \param [out] pInfo The DisplayPort information +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred +//! \retval NVAPI_INVALID_ARGUMENT Invalid input parameter. +// +/////////////////////////////////////////////////////////////////////////////// +//! \ingroup dispcontrol +NVAPI_INTERFACE NvAPI_GetDisplayPortInfo(__in_opt NvDisplayHandle hNvDisplay, __in NvU32 outputId, __inout NV_DISPLAY_PORT_INFO *pInfo); + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_SetDisplayPort +// +//! \fn NvAPI_SetDisplayPort(NvDisplayHandle hNvDisplay, NvU32 outputId, NV_DISPLAY_PORT_CONFIG *pCfg) +//! DESCRIPTION: This function sets up DisplayPort-related configurations. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 165 +//! +//! \param [in] hNvDisplay NVIDIA display handle. It can be NVAPI_DEFAULT_HANDLE or a handle enumerated from +//! NvAPI_EnumNVidiaDisplayHandle(). +//! \param [in] outputId This display output ID, when it's "0" it means the default outputId generated from the return of +//! NvAPI_GetAssociatedDisplayOutputId(). See \ref handles. +//! \param [in] pCfg The display port config structure. If pCfg is NULL, it means to use the driver's default value to setup. +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred +//! \retval NVAPI_INVALID_ARGUMENT Invalid input parameter +/////////////////////////////////////////////////////////////////////////////// + + +//! \ingroup dispcontrol +//! DisplayPort configuration settings - used in NvAPI_SetDisplayPort(). +typedef struct +{ + NvU32 version; //!< Structure version - 2 is the latest + NV_DP_LINK_RATE linkRate; //!< Link rate + NV_DP_LANE_COUNT laneCount; //!< Lane count + NV_DP_COLOR_FORMAT colorFormat; //!< Color format to set + NV_DP_DYNAMIC_RANGE dynamicRange; //!< Dynamic range + NV_DP_COLORIMETRY colorimetry; //!< Ignored in RGB space + NV_DP_BPC bpc; //!< Bit-per-component + NvU32 isHPD : 1; //!< If the control panel is making this call due to HPD + NvU32 isSetDeferred : 1; //!< Requires an OS modeset to finalize the setup if set + NvU32 isChromaLpfOff : 1; //!< Force the chroma low_pass_filter to be off + NvU32 isDitherOff : 1; //!< Force to turn off dither + NvU32 testLinkTrain : 1; //!< If testing mode, skip validation + NvU32 testColorChange : 1; //!< If testing mode, skip validation + +} NV_DISPLAY_PORT_CONFIG; + +//! \addtogroup dispcontrol +//! @{ +//! Macro for constructing the version field of NV_DISPLAY_PORT_CONFIG +#define NV_DISPLAY_PORT_CONFIG_VER MAKE_NVAPI_VERSION(NV_DISPLAY_PORT_CONFIG,2) +//! Macro for constructing the version field of NV_DISPLAY_PORT_CONFIG +#define NV_DISPLAY_PORT_CONFIG_VER_1 MAKE_NVAPI_VERSION(NV_DISPLAY_PORT_CONFIG,1) +//! Macro for constructing the version field of NV_DISPLAY_PORT_CONFIG +#define NV_DISPLAY_PORT_CONFIG_VER_2 MAKE_NVAPI_VERSION(NV_DISPLAY_PORT_CONFIG,2) +//! @} + + +//! \ingroup dispcontrol +NVAPI_INTERFACE NvAPI_SetDisplayPort(NvDisplayHandle hNvDisplay, NvU32 outputId, NV_DISPLAY_PORT_CONFIG *pCfg); + + + + +//! \ingroup dispcontrol +//! Used in NvAPI_GetHDMISupportInfo(). +typedef struct _NV_HDMI_SUPPORT_INFO_V1 +{ + NvU32 version; //!< Structure version + + NvU32 isGpuHDMICapable : 1; //!< If the GPU can handle HDMI + NvU32 isMonUnderscanCapable : 1; //!< If the monitor supports underscan + NvU32 isMonBasicAudioCapable : 1; //!< If the monitor supports basic audio + NvU32 isMonYCbCr444Capable : 1; //!< If YCbCr 4:4:4 is supported + NvU32 isMonYCbCr422Capable : 1; //!< If YCbCr 4:2:2 is supported + NvU32 isMonxvYCC601Capable : 1; //!< If xvYCC 601 is supported + NvU32 isMonxvYCC709Capable : 1; //!< If xvYCC 709 is supported + NvU32 isMonHDMI : 1; //!< If the monitor is HDMI (with IEEE's HDMI registry ID) + NvU32 reserved : 24; //!< Reserved. + + NvU32 EDID861ExtRev; //!< Revision number of the EDID 861 extension + } NV_HDMI_SUPPORT_INFO_V1; + +typedef struct _NV_HDMI_SUPPORT_INFO_V2 +{ + NvU32 version; //!< Structure version + + NvU32 isGpuHDMICapable : 1; //!< If the GPU can handle HDMI + NvU32 isMonUnderscanCapable : 1; //!< If the monitor supports underscan + NvU32 isMonBasicAudioCapable : 1; //!< If the monitor supports basic audio + NvU32 isMonYCbCr444Capable : 1; //!< If YCbCr 4:4:4 is supported + NvU32 isMonYCbCr422Capable : 1; //!< If YCbCr 4:2:2 is supported + NvU32 isMonxvYCC601Capable : 1; //!< If xvYCC extended colorimetry 601 is supported + NvU32 isMonxvYCC709Capable : 1; //!< If xvYCC extended colorimetry 709 is supported + NvU32 isMonHDMI : 1; //!< If the monitor is HDMI (with IEEE's HDMI registry ID) + NvU32 isMonsYCC601Capable : 1; //!< if sYCC601 extended colorimetry is supported + NvU32 isMonAdobeYCC601Capable : 1; //!< if AdobeYCC601 extended colorimetry is supported + NvU32 isMonAdobeRGBCapable : 1; //!< if AdobeRGB extended colorimetry is supported + NvU32 reserved : 21; //!< Reserved. + + NvU32 EDID861ExtRev; //!< Revision number of the EDID 861 extension + } NV_HDMI_SUPPORT_INFO_V2; + +#define NV_HDMI_SUPPORT_INFO_VER1 MAKE_NVAPI_VERSION(NV_HDMI_SUPPORT_INFO_V1, 1) +#define NV_HDMI_SUPPORT_INFO_VER2 MAKE_NVAPI_VERSION(NV_HDMI_SUPPORT_INFO_V2, 2) + + + +#ifndef NV_HDMI_SUPPORT_INFO_VER + +typedef NV_HDMI_SUPPORT_INFO_V2 NV_HDMI_SUPPORT_INFO; +#define NV_HDMI_SUPPORT_INFO_VER NV_HDMI_SUPPORT_INFO_VER2 + +#endif + + +//! SUPPORTED OS: Windows 7 and higher +//! +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GetHDMISupportInfo +// +//! \fn NvAPI_GetHDMISupportInfo(__in_opt NvDisplayHandle hNvDisplay, __in NvU32 outputId, __inout NV_HDMI_SUPPORT_INFO *pInfo) +//! This API returns the current infoframe data on the specified device(monitor). +//! +//! \since Release: 95 +//! +//! \param [in] hvDisplay NVIDIA Display selection. It can be NVAPI_DEFAULT_HANDLE or a handle enumerated from NvAPI_EnumNVidiaDisplayHandle(). +//! This parameter is ignored when the outputId is a NvAPI displayId. +//! \param [in] outputId This can either be the connection bit mask or the NvAPI displayId. When the legacy connection bit mask is passed, +//! it should have exactly 1 bit set to indicate a single display. If it's "0" then the default outputId from +//! NvAPI_GetAssociatedDisplayOutputId() will be used. See \ref handles. +//! \param [out] pInfo The monitor and GPU's HDMI support info +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred +//! \retval NVAPI_INVALID_ARGUMENT Invalid input parameter. +/////////////////////////////////////////////////////////////////////////////// + + +//! \ingroup dispcontrol +NVAPI_INTERFACE NvAPI_GetHDMISupportInfo(__in_opt NvDisplayHandle hNvDisplay, __in NvU32 outputId, __inout NV_HDMI_SUPPORT_INFO *pInfo); + + +//! \ingroup dispcontrol + +typedef enum +{ + NV_INFOFRAME_CMD_GET_DEFAULT = 0, //!< Returns the fields in the infoframe with values set by the manufacturer - NVIDIA/OEM. + NV_INFOFRAME_CMD_RESET, //!< Sets the fields in the infoframe to auto, and infoframe to the default infoframe for use in a set. + NV_INFOFRAME_CMD_GET, //!< Get the current infoframe state. + NV_INFOFRAME_CMD_SET, //!< Set the current infoframe state (flushed to the monitor), the values are one time and do not persist. + NV_INFOFRAME_CMD_GET_OVERRIDE, //!< Get the override infoframe state, non-override fields will be set to value = AUTO, overridden fields will have the current override values. + NV_INFOFRAME_CMD_SET_OVERRIDE, //!< Set the override infoframe state, non-override fields will be set to value = AUTO, other values indicate override; persist across modeset/reboot + NV_INFOFRAME_CMD_GET_PROPERTY, //!< get properties associated with infoframe (each of the infoframe type will have properties) + NV_INFOFRAME_CMD_SET_PROPERTY, //!< set properties associated with infoframe +} NV_INFOFRAME_CMD; + + +typedef enum +{ + NV_INFOFRAME_PROPERTY_MODE_AUTO = 0, //!< Driver determines whether to send infoframes. + NV_INFOFRAME_PROPERTY_MODE_ENABLE, //!< Driver always sends infoframe. + NV_INFOFRAME_PROPERTY_MODE_DISABLE, //!< Driver never sends infoframe. + NV_INFOFRAME_PROPERTY_MODE_ALLOW_OVERRIDE, //!< Driver only sends infoframe when client requests it via infoframe escape call. +} NV_INFOFRAME_PROPERTY_MODE; + + +//! Returns whether the current monitor is in blacklist or force this monitor to be in blacklist. +typedef enum +{ + NV_INFOFRAME_PROPERTY_BLACKLIST_FALSE = 0, + NV_INFOFRAME_PROPERTY_BLACKLIST_TRUE, +} NV_INFOFRAME_PROPERTY_BLACKLIST; + +typedef struct +{ + NvU32 mode : 4; + NvU32 blackList : 2; + NvU32 reserved : 10; + NvU32 version : 8; + NvU32 length : 8; +} NV_INFOFRAME_PROPERTY; + +//! Byte1 related +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_SCANINFO_NODATA = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_SCANINFO_OVERSCAN, + NV_INFOFRAME_FIELD_VALUE_AVI_SCANINFO_UNDERSCAN, + NV_INFOFRAME_FIELD_VALUE_AVI_SCANINFO_FUTURE, + NV_INFOFRAME_FIELD_VALUE_AVI_SCANINFO_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AVI_SCANINFO; + + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_BARDATA_NOT_PRESENT = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_BARDATA_VERTICAL_PRESENT, + NV_INFOFRAME_FIELD_VALUE_AVI_BARDATA_HORIZONTAL_PRESENT, + NV_INFOFRAME_FIELD_VALUE_AVI_BARDATA_BOTH_PRESENT, + NV_INFOFRAME_FIELD_VALUE_AVI_BARDATA_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AVI_BARDATA; + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_AFI_ABSENT = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_AFI_PRESENT, + NV_INFOFRAME_FIELD_VALUE_AVI_AFI_AUTO = 3 +} NV_INFOFRAME_FIELD_VALUE_AVI_ACTIVEFORMATINFO; + + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_COLORFORMAT_RGB = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_COLORFORMAT_YCbCr422, + NV_INFOFRAME_FIELD_VALUE_AVI_COLORFORMAT_YCbCr444, + NV_INFOFRAME_FIELD_VALUE_AVI_COLORFORMAT_FUTURE, + NV_INFOFRAME_FIELD_VALUE_AVI_COLORFORMAT_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AVI_COLORFORMAT; + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_F17_FALSE = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_F17_TRUE, + NV_INFOFRAME_FIELD_VALUE_AVI_F17_AUTO = 3 +} NV_INFOFRAME_FIELD_VALUE_AVI_F17; + +//! Byte2 related +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_NO_AFD = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_RESERVE01, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_RESERVE02, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_RESERVE03, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_LETTERBOX_GT16x9, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_RESERVE05, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_RESERVE06, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_RESERVE07, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_EQUAL_CODEDFRAME = 8, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_CENTER_4x3, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_CENTER_16x9, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_CENTER_14x9, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_RESERVE12, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_4x3_ON_14x9, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_16x9_ON_14x9, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_16x9_ON_4x3, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION_AUTO = 31, +} NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOACTIVEPORTION; + + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOCODEDFRAME_NO_DATA = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOCODEDFRAME_4x3, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOCODEDFRAME_16x9, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOCODEDFRAME_FUTURE, + NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOCODEDFRAME_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AVI_ASPECTRATIOCODEDFRAME; + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_COLORIMETRY_NO_DATA = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_COLORIMETRY_SMPTE_170M, + NV_INFOFRAME_FIELD_VALUE_AVI_COLORIMETRY_ITUR_BT709, + NV_INFOFRAME_FIELD_VALUE_AVI_COLORIMETRY_USE_EXTENDED_COLORIMETRY, + NV_INFOFRAME_FIELD_VALUE_AVI_COLORIMETRY_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AVI_COLORIMETRY; + +//! Byte 3 related +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_NONUNIFORMPICTURESCALING_NO_DATA = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_NONUNIFORMPICTURESCALING_HORIZONTAL, + NV_INFOFRAME_FIELD_VALUE_AVI_NONUNIFORMPICTURESCALING_VERTICAL, + NV_INFOFRAME_FIELD_VALUE_AVI_NONUNIFORMPICTURESCALING_BOTH, + NV_INFOFRAME_FIELD_VALUE_AVI_NONUNIFORMPICTURESCALING_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AVI_NONUNIFORMPICTURESCALING; + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_RGBQUANTIZATION_DEFAULT = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_RGBQUANTIZATION_LIMITED_RANGE, + NV_INFOFRAME_FIELD_VALUE_AVI_RGBQUANTIZATION_FULL_RANGE, + NV_INFOFRAME_FIELD_VALUE_AVI_RGBQUANTIZATION_RESERVED, + NV_INFOFRAME_FIELD_VALUE_AVI_RGBQUANTIZATION_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AVI_RGBQUANTIZATION; + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_EXTENDEDCOLORIMETRY_XVYCC601 = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_EXTENDEDCOLORIMETRY_XVYCC709, + NV_INFOFRAME_FIELD_VALUE_AVI_EXTENDEDCOLORIMETRY_SYCC601, + NV_INFOFRAME_FIELD_VALUE_AVI_EXTENDEDCOLORIMETRY_ADOBEYCC601, + NV_INFOFRAME_FIELD_VALUE_AVI_EXTENDEDCOLORIMETRY_ADOBERGB, + NV_INFOFRAME_FIELD_VALUE_AVI_EXTENDEDCOLORIMETRY_RESERVED05, + NV_INFOFRAME_FIELD_VALUE_AVI_EXTENDEDCOLORIMETRY_RESERVED06, + NV_INFOFRAME_FIELD_VALUE_AVI_EXTENDEDCOLORIMETRY_RESERVED07, + NV_INFOFRAME_FIELD_VALUE_AVI_EXTENDEDCOLORIMETRY_AUTO = 15 +} NV_INFOFRAME_FIELD_VALUE_AVI_EXTENDEDCOLORIMETRY; + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_ITC_VIDEO_CONTENT = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_ITC_ITCONTENT, + NV_INFOFRAME_FIELD_VALUE_AVI_ITC_AUTO = 3 +} NV_INFOFRAME_FIELD_VALUE_AVI_ITC; + +//! Byte 4 related +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_NONE = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_X02, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_X03, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_X04, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_X05, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_X06, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_X07, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_X08, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_X09, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_X10, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_RESERVED10, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_RESERVED11, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_RESERVED12, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_RESERVED13, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_RESERVED14, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_RESERVED15, + NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION_AUTO = 31 +} NV_INFOFRAME_FIELD_VALUE_AVI_PIXELREPETITION; + + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_CONTENTTYPE_GRAPHICS = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_CONTENTTYPE_PHOTO, + NV_INFOFRAME_FIELD_VALUE_AVI_CONTENTTYPE_CINEMA, + NV_INFOFRAME_FIELD_VALUE_AVI_CONTENTTYPE_GAME, + NV_INFOFRAME_FIELD_VALUE_AVI_CONTENTTYPE_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AVI_CONTENTTYPE; + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AVI_YCCQUANTIZATION_LIMITED_RANGE = 0, + NV_INFOFRAME_FIELD_VALUE_AVI_YCCQUANTIZATION_FULL_RANGE, + NV_INFOFRAME_FIELD_VALUE_AVI_YCCQUANTIZATION_RESERVED02, + NV_INFOFRAME_FIELD_VALUE_AVI_YCCQUANTIZATION_RESERVED03, + NV_INFOFRAME_FIELD_VALUE_AVI_YCCQUANTIZATION_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AVI_YCCQUANTIZATION; + +//! Adding an Auto bit to each field +typedef struct +{ + NvU32 vic : 8; + NvU32 pixelRepeat : 5; + NvU32 colorSpace : 3; + NvU32 colorimetry : 3; + NvU32 extendedColorimetry : 4; + NvU32 rgbQuantizationRange : 3; + NvU32 yccQuantizationRange : 3; + NvU32 itContent : 2; + NvU32 contentTypes : 3; + NvU32 scanInfo : 3; + NvU32 activeFormatInfoPresent : 2; + NvU32 activeFormatAspectRatio : 5; + NvU32 picAspectRatio : 3; + NvU32 nonuniformScaling : 3; + NvU32 barInfo : 3; + NvU32 top_bar : 17; + NvU32 bottom_bar : 17; + NvU32 left_bar : 17; + NvU32 right_bar : 17; + NvU32 Future17 : 2; + NvU32 Future47 : 2; +} NV_INFOFRAME_VIDEO; + +//! Byte 1 related +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELCOUNT_IN_HEADER = 0, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELCOUNT_2, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELCOUNT_3, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELCOUNT_4, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELCOUNT_5, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELCOUNT_6, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELCOUNT_7, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELCOUNT_8, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELCOUNT_AUTO = 15 +} NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELCOUNT; + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_IN_HEADER = 0, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_PCM, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_AC3, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_MPEG1, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_MP3, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_MPEG2, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_AACLC, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_DTS, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_ATRAC, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_DSD, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_EAC3, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_DTSHD, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_MLP, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_DST, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_WMAPRO, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_USE_CODING_EXTENSION_TYPE, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE_AUTO = 31 +} NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGTYPE; + +//! Byte 2 related +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLESIZE_IN_HEADER = 0, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLESIZE_16BITS, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLESIZE_20BITS, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLESIZE_24BITS, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLESIZE_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLESIZE; + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLEFREQUENCY_IN_HEADER = 0, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLEFREQUENCY_32000HZ, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLEFREQUENCY_44100HZ, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLEFREQUENCY_48000HZ, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLEFREQUENCY_88200KHZ, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLEFREQUENCY_96000KHZ, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLEFREQUENCY_176400KHZ, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLEFREQUENCY_192000KHZ, + NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLEFREQUENCY_AUTO = 15 +} NV_INFOFRAME_FIELD_VALUE_AUDIO_SAMPLEFREQUENCY; + + + +//! Byte 3 related +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_USE_CODING_TYPE = 0, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_HEAAC, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_HEAACV2, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_MPEGSURROUND, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE04, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE05, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE06, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE07, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE08, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE09, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE10, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE11, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE12, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE13, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE14, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE15, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE16, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE17, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE18, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE19, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE20, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE21, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE22, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE23, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE24, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE25, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE26, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE27, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE28, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE29, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE30, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_RESERVE31, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE_AUTO = 63 +} NV_INFOFRAME_FIELD_VALUE_AUDIO_CODINGEXTENSIONTYPE; + + +//! Byte 4 related +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_X_X_X_X_FR_FL =0, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_X_X_X_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_X_X_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_X_X_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_X_RC_X_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_X_RC_X_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_X_RC_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_X_RC_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_RR_RL_X_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_RR_RL_X_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_X_RR_RL_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_RC_RR_RL_X_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_RC_RR_RL_X_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_RC_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_RC_RR_RL_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_RRC_RLC_RR_RL_X_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_RRC_RLC_RR_RL_X_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_RRC_RLC_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_RRC_RLC_RR_RL_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_X_X_X_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_X_X_X_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_X_X_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_X_X_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_X_RC_X_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_X_RC_X_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_X_RC_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_X_RC_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_RR_RL_X_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_RR_RL_X_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRC_FLC_RR_RL_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_FCH_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_X_FCH_RR_RL_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_TC_X_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_TC_X_RR_RL_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRH_FLH_RR_RL_X_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRH_FLH_RR_RL_X_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRW_FLW_RR_RL_X_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRW_FLW_RR_RL_X_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_TC_RC_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_TC_RC_RR_RL_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FCH_RC_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FCH_RC_RR_RL_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_TC_FCH_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_TC_FCH_RR_RL_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRH_FLH_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRH_FLH_RR_RL_FC_LFE_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRW_FLW_RR_RL_FC_X_FR_FL, + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_FRW_FLW_RR_RL_FC_LFE_FR_FL = 0X31, + // all other values should default to auto + NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION_AUTO = 0x1FF +} NV_INFOFRAME_FIELD_VALUE_AUDIO_CHANNELALLOCATION; + +//! Byte 5 related +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AUDIO_LFEPLAYBACKLEVEL_NO_DATA = 0, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LFEPLAYBACKLEVEL_0DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LFEPLAYBACKLEVEL_PLUS10DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LFEPLAYBACKLEVEL_RESERVED03, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LFEPLAYBACKLEVEL_AUTO = 7 +} NV_INFOFRAME_FIELD_VALUE_AUDIO_LFEPLAYBACKLEVEL; + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_0DB = 0, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_1DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_2DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_3DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_4DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_5DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_6DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_7DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_8DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_9DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_10DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_11DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_12DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_13DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_14DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_15DB, + NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES_AUTO = 31 +} NV_INFOFRAME_FIELD_VALUE_AUDIO_LEVELSHIFTVALUES; + + +typedef enum +{ + NV_INFOFRAME_FIELD_VALUE_AUDIO_DOWNMIX_PERMITTED = 0, + NV_INFOFRAME_FIELD_VALUE_AUDIO_DOWNMIX_PROHIBITED, + NV_INFOFRAME_FIELD_VALUE_AUDIO_DOWNMIX_AUTO = 3 +} NV_INFOFRAME_FIELD_VALUE_AUDIO_DOWNMIX; + +typedef struct +{ + NvU32 codingType : 5; + NvU32 codingExtensionType : 6; + NvU32 sampleSize : 3; + NvU32 sampleRate : 4; + NvU32 channelCount : 4; + NvU32 speakerPlacement : 9; + NvU32 downmixInhibit : 2; + NvU32 lfePlaybackLevel : 3; + NvU32 levelShift : 5; + NvU32 Future12 : 2; + NvU32 Future2x : 4; + NvU32 Future3x : 4; + NvU32 Future52 : 2; + NvU32 Future6 : 9; + NvU32 Future7 : 9; + NvU32 Future8 : 9; + NvU32 Future9 : 9; + NvU32 Future10 : 9; +} NV_INFOFRAME_AUDIO; + +typedef struct +{ + NvU32 version; //!< version of this structure + NvU16 size; //!< size of this structure + NvU8 cmd; //!< The actions to perform from NV_INFOFRAME_CMD + NvU8 type; //!< type of infoframe + + union + { + NV_INFOFRAME_PROPERTY property; //!< This is NVIDIA-specific and corresponds to the property cmds and associated infoframe. + NV_INFOFRAME_AUDIO audio; + NV_INFOFRAME_VIDEO video; + } infoframe; +} NV_INFOFRAME_DATA; + +//! Macro for constructing the version field of ::NV_INFOFRAME_DATA +#define NV_INFOFRAME_DATA_VER MAKE_NVAPI_VERSION(NV_INFOFRAME_DATA,1) + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_Disp_InfoFrameControl +// +//! DESCRIPTION: This API controls the InfoFrame values. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId Monitor Identifier +//! \param [in,out] pInfoframeData Contains data corresponding to InfoFrame +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Disp_InfoFrameControl(__in NvU32 displayId, __inout NV_INFOFRAME_DATA *pInfoframeData); + + + + + + +//! \ingroup dispcontrol +//! @{ +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_Disp_ColorControl +// +//! \fn NvAPI_Disp_ColorControl(NvU32 displayId, NV_COLOR_DATA *pColorData) +//! DESCRIPTION: This API controls the Color values. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId Monitor Identifier +//! \param [in,out] pColorData Contains data corresponding to color information +//! +//! \return RETURN STATUS: +//! ::NVAPI_OK, +//! ::NVAPI_ERROR, +//! ::NVAPI_INVALID_ARGUMENT +// +/////////////////////////////////////////////////////////////////////////////// + +typedef enum +{ + NV_COLOR_CMD_GET = 1, + NV_COLOR_CMD_SET, + NV_COLOR_CMD_IS_SUPPORTED_COLOR, + NV_COLOR_CMD_GET_DEFAULT +} NV_COLOR_CMD; + +//! See Table 14 of CEA-861E. Not all of this is supported by the GPU. +typedef enum +{ + NV_COLOR_FORMAT_RGB = 0, + NV_COLOR_FORMAT_YUV422, + NV_COLOR_FORMAT_YUV444, + NV_COLOR_FORMAT_YUV420, + + NV_COLOR_FORMAT_DEFAULT = 0xFE, + NV_COLOR_FORMAT_AUTO = 0xFF +} NV_COLOR_FORMAT; + + + +typedef enum +{ + NV_COLOR_COLORIMETRY_RGB = 0, + NV_COLOR_COLORIMETRY_YCC601, + NV_COLOR_COLORIMETRY_YCC709, + NV_COLOR_COLORIMETRY_XVYCC601, + NV_COLOR_COLORIMETRY_XVYCC709, + NV_COLOR_COLORIMETRY_SYCC601, + NV_COLOR_COLORIMETRY_ADOBEYCC601, + NV_COLOR_COLORIMETRY_ADOBERGB, + NV_COLOR_COLORIMETRY_BT2020RGB, + NV_COLOR_COLORIMETRY_BT2020YCC, + NV_COLOR_COLORIMETRY_BT2020cYCC, + + NV_COLOR_COLORIMETRY_DEFAULT = 0xFE, + NV_COLOR_COLORIMETRY_AUTO = 0xFF +} NV_COLOR_COLORIMETRY; + +typedef enum _NV_DYNAMIC_RANGE +{ + NV_DYNAMIC_RANGE_VESA = 0x0, + NV_DYNAMIC_RANGE_CEA = 0x1, + + NV_DYNAMIC_RANGE_AUTO = 0xFF +} NV_DYNAMIC_RANGE; + +typedef enum _NV_BPC +{ + NV_BPC_DEFAULT = 0, + NV_BPC_6 = 1, + NV_BPC_8 = 2, + NV_BPC_10 = 3, + NV_BPC_12 = 4, + NV_BPC_16 = 5, +} NV_BPC; + +typedef enum _NV_COLOR_SELECTION_POLICY +{ + NV_COLOR_SELECTION_POLICY_USER = 0, //!< app/nvcpl make decision to select the desire color format + NV_COLOR_SELECTION_POLICY_BEST_QUALITY = 1, //!< driver/ OS make decision to select the best color format + NV_COLOR_SELECTION_POLICY_DEFAULT = NV_COLOR_SELECTION_POLICY_BEST_QUALITY, + NV_COLOR_SELECTION_POLICY_UNKNOWN = 0xFF, +} NV_COLOR_SELECTION_POLICY; + +typedef enum _NV_DESKTOP_COLOR_DEPTH +{ + NV_DESKTOP_COLOR_DEPTH_DEFAULT = 0x0, // set if the current setting should be kept + NV_DESKTOP_COLOR_DEPTH_8BPC = 0x1, //8 bit int per color component (8 bit int alpha) + NV_DESKTOP_COLOR_DEPTH_10BPC = 0x2, //10 bit int per color component (2 bit int alpha) + NV_DESKTOP_COLOR_DEPTH_16BPC_FLOAT = 0x3, //16 bit float per color component (16 bit float alpha) + NV_DESKTOP_COLOR_DEPTH_16BPC_FLOAT_WCG = 0x4, //16 bit float per color component (16 bit float alpha) wide color gamut + NV_DESKTOP_COLOR_DEPTH_16BPC_FLOAT_HDR = 0x5, //16 bit float per color component (16 bit float alpha) HDR + NV_DESKTOP_COLOR_DEPTH_MAX_VALUE = NV_DESKTOP_COLOR_DEPTH_16BPC_FLOAT_HDR, // must be set to highest enum value +} NV_DESKTOP_COLOR_DEPTH; + +typedef struct _NV_COLOR_DATA_V1 +{ + NvU32 version; //!< Version of this structure + NvU16 size; //!< Size of this structure + NvU8 cmd; + struct + { + NvU8 colorFormat; //!< One of NV_COLOR_FORMAT enum values. + NvU8 colorimetry; //!< One of NV_COLOR_COLORIMETRY enum values. + } data; +} NV_COLOR_DATA_V1; + +typedef struct _NV_COLOR_DATA_V2 +{ + NvU32 version; //!< Version of this structure + NvU16 size; //!< Size of this structure + NvU8 cmd; + struct + { + NvU8 colorFormat; //!< One of NV_COLOR_FORMAT enum values. + NvU8 colorimetry; //!< One of NV_COLOR_COLORIMETRY enum values. + NvU8 dynamicRange; //!< One of NV_DYNAMIC_RANGE enum values. + } data; +} NV_COLOR_DATA_V2; + +typedef struct _NV_COLOR_DATA_V3 +{ + NvU32 version; //!< Version of this structure + NvU16 size; //!< Size of this structure + NvU8 cmd; + struct + { + NvU8 colorFormat; //!< One of NV_COLOR_FORMAT enum values. + NvU8 colorimetry; //!< One of NV_COLOR_COLORIMETRY enum values. + NvU8 dynamicRange; //!< One of NV_DYNAMIC_RANGE enum values. + NV_BPC bpc; //!< One of NV_BPC enum values. + } data; +} NV_COLOR_DATA_V3; + +typedef struct _NV_COLOR_DATA_V4 +{ + NvU32 version; //!< Version of this structure + NvU16 size; //!< Size of this structure + NvU8 cmd; + struct + { + NvU8 colorFormat; //!< One of NV_COLOR_FORMAT enum values. + NvU8 colorimetry; //!< One of NV_COLOR_COLORIMETRY enum values. + NvU8 dynamicRange; //!< One of NV_DYNAMIC_RANGE enum values. + NV_BPC bpc; //!< One of NV_BPC enum values. + NV_COLOR_SELECTION_POLICY colorSelectionPolicy; //!< One of the color selection policy + } data; +} NV_COLOR_DATA_V4; + +typedef struct _NV_COLOR_DATA_V5 +{ + NvU32 version; //!< Version of this structure + NvU16 size; //!< Size of this structure + NvU8 cmd; + struct + { + NvU8 colorFormat; //!< One of NV_COLOR_FORMAT enum values. + NvU8 colorimetry; //!< One of NV_COLOR_COLORIMETRY enum values. + NvU8 dynamicRange; //!< One of NV_DYNAMIC_RANGE enum values. + NV_BPC bpc; //!< One of NV_BPC enum values. + NV_COLOR_SELECTION_POLICY colorSelectionPolicy; //!< One of the color selection policy + NV_DESKTOP_COLOR_DEPTH depth; //!< One of NV_DESKTOP_COLOR_DEPTH enum values. + } data; +} NV_COLOR_DATA_V5; + +typedef NV_COLOR_DATA_V5 NV_COLOR_DATA; + +#define NV_COLOR_DATA_VER1 MAKE_NVAPI_VERSION(NV_COLOR_DATA_V1, 1) +#define NV_COLOR_DATA_VER2 MAKE_NVAPI_VERSION(NV_COLOR_DATA_V2, 2) +#define NV_COLOR_DATA_VER3 MAKE_NVAPI_VERSION(NV_COLOR_DATA_V3, 3) +#define NV_COLOR_DATA_VER4 MAKE_NVAPI_VERSION(NV_COLOR_DATA_V4, 4) +#define NV_COLOR_DATA_VER5 MAKE_NVAPI_VERSION(NV_COLOR_DATA_V5, 5) +#define NV_COLOR_DATA_VER NV_COLOR_DATA_VER5 + +NVAPI_INTERFACE NvAPI_Disp_ColorControl(NvU32 displayId, NV_COLOR_DATA *pColorData); + +//! @} + + +typedef enum +{ + NV_STATIC_METADATA_TYPE_1 = 0 //!< Tells the type of structure used to define the Static Metadata Descriptor block. +}NV_STATIC_METADATA_DESCRIPTOR_ID; + +typedef struct _NV_HDR_CAPABILITIES_V1 +{ + NvU32 version; //!< Version of this structure + + NvU32 isST2084EotfSupported :1; //!< HDMI2.0a UHDA HDR with ST2084 EOTF (CEA861.3). Boolean: 0 = not supported, 1 = supported; + NvU32 isTraditionalHdrGammaSupported :1; //!< HDMI2.0a traditional HDR gamma (CEA861.3). Boolean: 0 = not supported, 1 = supported; + NvU32 isEdrSupported :1; //!< Extended Dynamic Range on SDR displays. Boolean: 0 = not supported, 1 = supported; + NvU32 driverExpandDefaultHdrParameters :1; //!< If set, driver will expand default (=zero) HDR capabilities parameters contained in display's EDID. + //!< Boolean: 0 = report actual HDR parameters, 1 = expand default HDR parameters; + NvU32 isTraditionalSdrGammaSupported :1; //!< HDMI2.0a traditional SDR gamma (CEA861.3). Boolean: 0 = not supported, 1 = supported; + NvU32 reserved :27; + + NV_STATIC_METADATA_DESCRIPTOR_ID static_metadata_descriptor_id; //!< Static Metadata Descriptor Id (0 for static metadata type 1) + + struct //!< Static Metadata Descriptor Type 1, CEA-861.3, SMPTE ST2086 + { + NvU16 displayPrimary_x0; //!< x coordinate of color primary 0 (e.g. Red) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y0; //!< y coordinate of color primary 0 (e.g. Red) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayPrimary_x1; //!< x coordinate of color primary 1 (e.g. Green) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y1; //!< y coordinate of color primary 1 (e.g. Green) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayPrimary_x2; //!< x coordinate of color primary 2 (e.g. Blue) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y2; //!< y coordinate of color primary 2 (e.g. Blue) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayWhitePoint_x; //!< x coordinate of white point of the display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayWhitePoint_y; //!< y coordinate of white point of the display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 desired_content_max_luminance; //!< Maximum display luminance = desired max luminance of HDR content ([0x0001-0xFFFF] = [1.0 - 65535.0] cd/m^2) + NvU16 desired_content_min_luminance; //!< Minimum display luminance = desired min luminance of HDR content ([0x0001-0xFFFF] = [1.0 - 6.55350] cd/m^2) + NvU16 desired_content_max_frame_average_luminance; //!< Desired maximum Frame-Average Light Level (MaxFALL) of HDR content ([0x0001-0xFFFF] = [1.0 - 65535.0] cd/m^2) + }display_data; +} NV_HDR_CAPABILITIES_V1; + +typedef struct _NV_HDR_CAPABILITIES_V2 +{ + NvU32 version; //!< Version of this structure + + NvU32 isST2084EotfSupported :1; //!< HDMI2.0a UHDA HDR with ST2084 EOTF (CEA861.3). Boolean: 0 = not supported, 1 = supported; + NvU32 isTraditionalHdrGammaSupported :1; //!< HDMI2.0a traditional HDR gamma (CEA861.3). Boolean: 0 = not supported, 1 = supported; + NvU32 isEdrSupported :1; //!< Extended Dynamic Range on SDR displays. Boolean: 0 = not supported, 1 = supported; + NvU32 driverExpandDefaultHdrParameters :1; //!< If set, driver will expand default (=zero) HDR capabilities parameters contained in display's EDID. + //!< Boolean: 0 = report actual HDR parameters, 1 = expand default HDR parameters; + NvU32 isTraditionalSdrGammaSupported :1; //!< HDMI2.0a traditional SDR gamma (CEA861.3). Boolean: 0 = not supported, 1 = supported; + NvU32 isDolbyVisionSupported :1; //!< Dolby Vision Support. Boolean: 0 = not supported, 1 = supported; + NvU32 reserved :26; + + NV_STATIC_METADATA_DESCRIPTOR_ID static_metadata_descriptor_id; //!< Static Metadata Descriptor Id (0 for static metadata type 1) + + struct //!< Static Metadata Descriptor Type 1, CEA-861.3, SMPTE ST2086 + { + NvU16 displayPrimary_x0; //!< x coordinate of color primary 0 (e.g. Red) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y0; //!< y coordinate of color primary 0 (e.g. Red) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayPrimary_x1; //!< x coordinate of color primary 1 (e.g. Green) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y1; //!< y coordinate of color primary 1 (e.g. Green) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayPrimary_x2; //!< x coordinate of color primary 2 (e.g. Blue) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y2; //!< y coordinate of color primary 2 (e.g. Blue) of the display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayWhitePoint_x; //!< x coordinate of white point of the display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayWhitePoint_y; //!< y coordinate of white point of the display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 desired_content_max_luminance; //!< Maximum display luminance = desired max luminance of HDR content ([0x0001-0xFFFF] = [1.0 - 65535.0] cd/m^2) + NvU16 desired_content_min_luminance; //!< Minimum display luminance = desired min luminance of HDR content ([0x0001-0xFFFF] = [1.0 - 6.55350] cd/m^2) + NvU16 desired_content_max_frame_average_luminance; //!< Desired maximum Frame-Average Light Level (MaxFALL) of HDR content ([0x0001-0xFFFF] = [1.0 - 65535.0] cd/m^2) + }display_data; + + struct + { + NvU32 VSVDB_version : 3; //!< Version of Vendor Data block,Version 0: 25 bytes Version 1: 14 bytes + NvU32 dm_version : 8; //!< Upper Nibble represents major version of Display Management(DM) while lower represents minor version of DM + NvU32 supports_2160p60hz : 1; //!< If set sink is capable of 4kx2k @ 60hz + NvU32 supports_YUV422_12bit : 1; //!< If set, sink is capable of YUV422-12 bit + NvU32 supports_global_dimming : 1; //!< Indicates if sink supports global dimming + NvU32 colorimetry : 1; //!< If set indicates sink supports DCI P3 colorimetry, REc709 otherwise + NvU32 supports_backlight_control : 2; //!< This is set when sink is using lowlatency interface and can control its backlight. + NvU32 backlt_min_luma : 2; //!< It is the level for Backlt min luminance value. + NvU32 interface_supported_by_sink : 2; //!< Indicates the interface (standard or low latency) supported by the sink. + NvU32 supports_10b_12b_444 : 2; //!< It is set when interface supported is low latency, it tells whether it supports 10 bit or 12 bit RGB 4:4:4 or YCbCr 4:4:4 or both. + NvU32 reserved : 9; //!< Should be set to zero + //!< All values below are encoded use DolbyVisionHDMITransmissionSpecification document to decode + NvU16 target_min_luminance; //!< Represents min luminance level of Sink + NvU16 target_max_luminance; //!< Represents max luminance level of sink + NvU16 cc_red_x; //!< Red primary chromaticity coordinate x + NvU16 cc_red_y; //!< Red primary chromaticity coordinate y + NvU16 cc_green_x; //!< Green primary chromaticity coordinate x + NvU16 cc_green_y; //!< Green primary chromaticity coordinate Y + NvU16 cc_blue_x; //!< Blue primary chromaticity coordinate x + NvU16 cc_blue_y; //!< Blue primary chromaticity coordinate y + NvU16 cc_white_x; //!< White primary chromaticity coordinate x + NvU16 cc_white_y; //!< White primary chromaticity coordinate y + }dv_static_metadata; + +} NV_HDR_CAPABILITIES_V2; + +#define NV_HDR_CAPABILITIES_VER1 MAKE_NVAPI_VERSION(NV_HDR_CAPABILITIES_V1, 1) +#define NV_HDR_CAPABILITIES_VER2 MAKE_NVAPI_VERSION(NV_HDR_CAPABILITIES_V2, 2) +#define NV_HDR_CAPABILITIES_VER NV_HDR_CAPABILITIES_VER2 +typedef NV_HDR_CAPABILITIES_V2 NV_HDR_CAPABILITIES; + +//! \ingroup dispcontrol +//! @{ +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_Disp_GetHdrCapabilities +// +//! \fn NvAPI_Disp_GetHdrCapabilities(NvU32 displayId, NV_HDR_CAPABILITIES *pHdrCapabilities) +//! DESCRIPTION: This API gets High Dynamic Range (HDR) capabilities of the display. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId Monitor Identifier +//! \param [in,out] pHdrCapabilities display's HDR capabilities +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +// +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Disp_GetHdrCapabilities(__in NvU32 displayId, __inout NV_HDR_CAPABILITIES *pHdrCapabilities); + +//! @} + + +typedef enum +{ + NV_HDR_CMD_GET = 0, //!< Get current HDR output configuration + NV_HDR_CMD_SET = 1 //!< Set HDR output configuration +} NV_HDR_CMD; + +typedef enum +{ + // Official production-ready HDR modes + NV_HDR_MODE_OFF = 0, //!< Turn off HDR + NV_HDR_MODE_UHDA = 2, //!< Source: CCCS [a.k.a FP16 scRGB, linear, sRGB primaries, [-65504,0, 65504] range, RGB(1,1,1) = 80nits] Output : UHDA HDR [a.k.a HDR10, RGB/YCC 10/12bpc ST2084(PQ) EOTF RGB(1,1,1) = 10000 nits, Rec2020 color primaries, ST2086 static HDR metadata]. This is the only supported production HDR mode. + + // Experimental + NV_HDR_MODE_UHDA_PASSTHROUGH = 5, //!< Experimental mode only, not for production! Source: HDR10 RGB 10bpc Output: HDR10 RGB 10 bpc - signal UHDA HDR mode (PQ + Rec2020) to the sink but send source pixel values unmodified (no PQ or Rec2020 conversions) - assumes source is already in HDR10 format. + NV_HDR_MODE_DOLBY_VISION = 7, //!< Experimental mode only, not for production! Source: RGB8 Dolby Vision encoded (12 bpc YCbCr422 packed into RGB8) Output: Dolby Vision encoded : Application is to encoded frames in DV format and embed DV dynamic metadata as described in Dolby Vision specification. + + // Unsupported/obsolete HDR modes + NV_HDR_MODE_EDR = 3, //!< Do not use! Internal test mode only, to be removed. Source: CCCS (a.k.a FP16 scRGB) Output : EDR (Extended Dynamic Range) - HDR content is tonemapped and gamut mapped to output on regular SDR display set to max luminance ( ~300 nits ). + NV_HDR_MODE_SDR = 4, //!< Do not use! Internal test mode only, to be removed. Source: any Output: SDR (Standard Dynamic Range), we continuously send SDR EOTF InfoFrame signaling, HDMI compliance testing. + NV_HDR_MODE_UHDA_NB = 6, //!< Do not use! Internal test mode only, to be removed. Source: CCCS (a.k.a FP16 scRGB) Output : notebook HDR + NV_HDR_MODE_UHDBD = 2 //!< Do not use! Obsolete, to be removed. NV_HDR_MODE_UHDBD == NV_HDR_MODE_UHDA, reflects obsolete pre-UHDA naming convention. + +} NV_HDR_MODE; + +typedef struct _NV_HDR_COLOR_DATA_V1 +{ + NvU32 version; //!< Version of this structure + NV_HDR_CMD cmd; //!< Command get/set + NV_HDR_MODE hdrMode; //!< HDR mode + NV_STATIC_METADATA_DESCRIPTOR_ID static_metadata_descriptor_id; //!< Static Metadata Descriptor Id (0 for static metadata type 1) + + struct //!< Static Metadata Descriptor Type 1, CEA-861.3, SMPTE ST2086 + { + NvU16 displayPrimary_x0; //!< x coordinate of color primary 0 (e.g. Red) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y0; //!< y coordinate of color primary 0 (e.g. Red) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayPrimary_x1; //!< x coordinate of color primary 1 (e.g. Green) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y1; //!< y coordinate of color primary 1 (e.g. Green) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayPrimary_x2; //!< x coordinate of color primary 2 (e.g. Blue) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y2; //!< y coordinate of color primary 2 (e.g. Blue) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayWhitePoint_x; //!< x coordinate of white point of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayWhitePoint_y; //!< y coordinate of white point of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 max_display_mastering_luminance; //!< Maximum display mastering luminance ([0x0001-0xFFFF] = [1.0 - 65535.0] cd/m^2) + NvU16 min_display_mastering_luminance; //!< Minimum display mastering luminance ([0x0001-0xFFFF] = [1.0 - 6.55350] cd/m^2) + + NvU16 max_content_light_level; //!< Maximum Content Light level (MaxCLL) ([0x0001-0xFFFF] = [1.0 - 65535.0] cd/m^2) + NvU16 max_frame_average_light_level; //!< Maximum Frame-Average Light Level (MaxFALL) ([0x0001-0xFFFF] = [1.0 - 65535.0] cd/m^2) + } mastering_display_data; +} NV_HDR_COLOR_DATA_V1; + +typedef struct _NV_HDR_COLOR_DATA_V2 +{ + NvU32 version; //!< Version of this structure + NV_HDR_CMD cmd; //!< Command get/set + NV_HDR_MODE hdrMode; //!< HDR mode + NV_STATIC_METADATA_DESCRIPTOR_ID static_metadata_descriptor_id; //!< Static Metadata Descriptor Id (0 for static metadata type 1) + + struct //!< Static Metadata Descriptor Type 1, CEA-861.3, SMPTE ST2086 + { + NvU16 displayPrimary_x0; //!< x coordinate of color primary 0 (e.g. Red) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y0; //!< y coordinate of color primary 0 (e.g. Red) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayPrimary_x1; //!< x coordinate of color primary 1 (e.g. Green) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y1; //!< y coordinate of color primary 1 (e.g. Green) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayPrimary_x2; //!< x coordinate of color primary 2 (e.g. Blue) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayPrimary_y2; //!< y coordinate of color primary 2 (e.g. Blue) of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 displayWhitePoint_x; //!< x coordinate of white point of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + NvU16 displayWhitePoint_y; //!< y coordinate of white point of mastering display ([0x0000-0xC350] = [0.0 - 1.0]) + + NvU16 max_display_mastering_luminance; //!< Maximum display mastering luminance ([0x0001-0xFFFF] = [1.0 - 65535.0] cd/m^2) + NvU16 min_display_mastering_luminance; //!< Minimum display mastering luminance ([0x0001-0xFFFF] = [1.0 - 6.55350] cd/m^2) + + NvU16 max_content_light_level; //!< Maximum Content Light level (MaxCLL) ([0x0001-0xFFFF] = [1.0 - 65535.0] cd/m^2) + NvU16 max_frame_average_light_level; //!< Maximum Frame-Average Light Level (MaxFALL) ([0x0001-0xFFFF] = [1.0 - 65535.0] cd/m^2) + } mastering_display_data; + + NV_COLOR_FORMAT hdrColorFormat; //!< Optional, One of NV_COLOR_FORMAT enum values, if set it will apply requested color format for HDR session + NV_DYNAMIC_RANGE hdrDynamicRange; //!< Optional, One of NV_DYNAMIC_RANGE enum values, if set it will apply requested dynamic range for HDR session + NV_BPC hdrBpc; //!< Optional, One of NV_BPC enum values, if set it will apply requested color depth + //!< Dolby Vision mode: DV supports specific combinations of colorformat, dynamic range and bpc. Please refer Dolby Vision specification. + //!< If invalid or no combination is passed driver will force default combination of RGB format + full range + 8bpc. + //!< HDR mode: These fields are ignored in hdr mode +} NV_HDR_COLOR_DATA_V2; + +#define NV_HDR_COLOR_DATA_VER1 MAKE_NVAPI_VERSION(NV_HDR_COLOR_DATA_V1, 1) +#define NV_HDR_COLOR_DATA_VER2 MAKE_NVAPI_VERSION(NV_HDR_COLOR_DATA_V2, 2) + +#ifndef NV_HDR_COLOR_DATA_VER +#define NV_HDR_COLOR_DATA_VER NV_HDR_COLOR_DATA_VER2 +typedef NV_HDR_COLOR_DATA_V2 NV_HDR_COLOR_DATA; +#endif + +//! \ingroup dispcontrol +//! @{ + /////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_Disp_HdrColorControl +// +//! \fn NvAPI_Disp_HdrColorControl(NvU32 displayId, NV_HDR_COLOR_DATA *pHdrColorData) +//! DESCRIPTION: This API configures High Dynamic Range (HDR) and Extended Dynamic Range (EDR) output. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId Monitor Identifier +//! \param [in,out] pHdrColorData HDR configuration data +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +// +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Disp_HdrColorControl(__in NvU32 displayId, __inout NV_HDR_COLOR_DATA *pHdrColorData); + +//! @} + + +//! \ingroup dispcontrol +//! Used in NvAPI_DISP_GetTiming(). +typedef struct +{ + NvU32 isInterlaced : 4; //!< To retrieve interlaced/progressive timing + NvU32 reserved0 : 12; + union + { + NvU32 tvFormat : 8; //!< The actual analog HD/SDTV format. Used when the timing type is + //! NV_TIMING_OVERRIDE_ANALOG_TV and width==height==rr==0. + NvU32 ceaId : 8; //!< The EIA/CEA 861B/D predefined short timing descriptor ID. + //! Used when the timing type is NV_TIMING_OVERRIDE_EIA861 + //! and width==height==rr==0. + NvU32 nvPsfId : 8; //!< The NV predefined PsF format Id. + //! Used when the timing type is NV_TIMING_OVERRIDE_NV_PREDEFINED. + }; + NvU32 scaling : 8; //!< Define preferred scaling +}NV_TIMING_FLAG; + +//! \ingroup dispcontrol +//! Used in NvAPI_DISP_GetTiming(). +typedef struct _NV_TIMING_INPUT +{ + NvU32 version; //!< (IN) structure version + + NvU32 width; //!< Visible horizontal size + NvU32 height; //!< Visible vertical size + float rr; //!< Timing refresh rate + + NV_TIMING_FLAG flag; //!< Flag containing additional info for timing calculation. + + NV_TIMING_OVERRIDE type; //!< Timing type(formula) to use for calculating the timing +}NV_TIMING_INPUT; + +#define NV_TIMING_INPUT_VER MAKE_NVAPI_VERSION(NV_TIMING_INPUT,1) + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_GetTiming +// +//! DESCRIPTION: This function calculates the timing from the visible width/height/refresh-rate and timing type info. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! +//! \param [in] displayId Display ID of the display. +//! \param [in] timingInput Inputs used for calculating the timing. +//! \param [out] pTiming Pointer to the NV_TIMING structure. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_GetTiming( __in NvU32 displayId,__in NV_TIMING_INPUT *timingInput, __out NV_TIMING *pTiming); + + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_GetMonitorCapabilities +// +//! \fn NvAPI_DISP_GetMonitorCapabilities(NvU32 displayId, NV_MONITOR_CAPABILITIES *pMonitorCapabilities) +//! DESCRIPTION: This API returns the Monitor capabilities +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId Monitor Identifier +//! \param [out] pMonitorCapabilities The monitor support info +//! +//! \return ::NVAPI_OK, +//! ::NVAPI_ERROR, +//! ::NVAPI_INVALID_ARGUMENT +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup dispcontrol +//! @{ + + +//! HDMI-related and extended CAPs +typedef enum +{ + // hdmi related caps + NV_MONITOR_CAPS_TYPE_HDMI_VSDB = 0x1000, + NV_MONITOR_CAPS_TYPE_HDMI_VCDB = 0x1001, +} NV_MONITOR_CAPS_TYPE; + + + +typedef struct _NV_MONITOR_CAPS_VCDB +{ + NvU8 quantizationRangeYcc : 1; + NvU8 quantizationRangeRgb : 1; + NvU8 scanInfoPreferredVideoFormat : 2; + NvU8 scanInfoITVideoFormats : 2; + NvU8 scanInfoCEVideoFormats : 2; +} NV_MONITOR_CAPS_VCDB; + + +//! See NvAPI_DISP_GetMonitorCapabilities(). +typedef struct _NV_MONITOR_CAPS_VSDB +{ + // byte 1 + NvU8 sourcePhysicalAddressB : 4; //!< Byte 1 + NvU8 sourcePhysicalAddressA : 4; //!< Byte 1 + // byte 2 + NvU8 sourcePhysicalAddressD : 4; //!< Byte 2 + NvU8 sourcePhysicalAddressC : 4; //!< Byte 2 + // byte 3 + NvU8 supportDualDviOperation : 1; //!< Byte 3 + NvU8 reserved6 : 2; //!< Byte 3 + NvU8 supportDeepColorYCbCr444 : 1; //!< Byte 3 + NvU8 supportDeepColor30bits : 1; //!< Byte 3 + NvU8 supportDeepColor36bits : 1; //!< Byte 3 + NvU8 supportDeepColor48bits : 1; //!< Byte 3 + NvU8 supportAI : 1; //!< Byte 3 + // byte 4 + NvU8 maxTmdsClock; //!< Bye 4 + // byte 5 + NvU8 cnc0SupportGraphicsTextContent : 1; //!< Byte 5 + NvU8 cnc1SupportPhotoContent : 1; //!< Byte 5 + NvU8 cnc2SupportCinemaContent : 1; //!< Byte 5 + NvU8 cnc3SupportGameContent : 1; //!< Byte 5 + NvU8 reserved8 : 1; //!< Byte 5 + NvU8 hasVicEntries : 1; //!< Byte 5 + NvU8 hasInterlacedLatencyField : 1; //!< Byte 5 + NvU8 hasLatencyField : 1; //!< Byte 5 + // byte 6 + NvU8 videoLatency; //!< Byte 6 + // byte 7 + NvU8 audioLatency; //!< Byte 7 + // byte 8 + NvU8 interlacedVideoLatency; //!< Byte 8 + // byte 9 + NvU8 interlacedAudioLatency; //!< Byte 9 + // byte 10 + NvU8 reserved13 : 7; //!< Byte 10 + NvU8 has3dEntries : 1; //!< Byte 10 + // byte 11 + NvU8 hdmi3dLength : 5; //!< Byte 11 + NvU8 hdmiVicLength : 3; //!< Byte 11 + // Remaining bytes + NvU8 hdmi_vic[7]; //!< Keeping maximum length for 3 bits + NvU8 hdmi_3d[31]; //!< Keeping maximum length for 5 bits +} NV_MONITOR_CAPS_VSDB; + +typedef struct _NV_MONITOR_CAPS_GENERIC +{ + NvU8 supportVRR : 1; //!< monitor supports variable refresh rate. Valid for NV_MONITOR_CAPS_TYPE_GENERIC only. + NvU8 supportULMB : 1; //!< monitor supports ULMB with variable refresh rate. Valid for NV_MONITOR_CAPS_TYPE_GENERIC only. + NvU8 isTrueGsync : 1; //!< whether the monitor is actually GSYNC or adaptive sync monitor : 0 for adaptive sync. + NvU8 isRLACapable : 1; //!< whether monitor supports RLA + NvU8 reserved : 4; +} NV_MONITOR_CAPS_GENERIC; + +//! See NvAPI_DISP_GetMonitorCapabilities(). +typedef struct _NV_MONITOR_CAPABILITIES_V1 +{ + NvU32 version; + NvU16 size; + NvU32 infoType; + NvU32 connectorType; //!< Out: VGA, TV, DVI, HDMI, DP + NvU8 bIsValidInfo : 1; //!< Boolean : Returns invalid if requested info is not present such as VCDB not present + union { + NV_MONITOR_CAPS_VSDB vsdb; + NV_MONITOR_CAPS_VCDB vcdb; + NV_MONITOR_CAPS_GENERIC caps; + } data; +} NV_MONITOR_CAPABILITIES_V1; + +typedef NV_MONITOR_CAPABILITIES_V1 NV_MONITOR_CAPABILITIES; + +//! Macro for constructing the version field of ::NV_MONITOR_CAPABILITIES_V1 +#define NV_MONITOR_CAPABILITIES_VER1 MAKE_NVAPI_VERSION(NV_MONITOR_CAPABILITIES_V1,1) +#define NV_MONITOR_CAPABILITIES_VER NV_MONITOR_CAPABILITIES_VER1 + +//! @} + +//! SUPPORTED OS: Windows 7 and higher +//! +//! \ingroup dispcontrol +NVAPI_INTERFACE NvAPI_DISP_GetMonitorCapabilities(__in NvU32 displayId, __inout NV_MONITOR_CAPABILITIES *pMonitorCapabilities); + +//! \ingroup dispcontrol +typedef struct _NV_MONITOR_COLOR_DATA +{ + NvU32 version; +// We are only supporting DP monitors for now. We need to extend this to HDMI panels as well + NV_DP_COLOR_FORMAT colorFormat; //!< One of the supported color formats + NV_DP_BPC backendBitDepths; //!< One of the supported bit depths +} NV_MONITOR_COLOR_CAPS_V1; + +typedef NV_MONITOR_COLOR_CAPS_V1 NV_MONITOR_COLOR_CAPS; + +//! \ingroup dispcontrol +#define NV_MONITOR_COLOR_CAPS_VER1 MAKE_NVAPI_VERSION(NV_MONITOR_COLOR_CAPS_V1,1) +#define NV_MONITOR_COLOR_CAPS_VER NV_MONITOR_COLOR_CAPS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_GetMonitorColorCapabilities +// +//! DESCRIPTION: This API returns all the color formats and bit depth values supported by a given DP monitor. +//! +//! USAGE: Sequence of calls which caller should make to get the information. +//! 1. First call NvAPI_DISP_GetMonitorColorCapabilities() with pMonitorColorCapabilities as NULL to get the count. +//! 2. Allocate memory for color caps(NV_MONITOR_COLOR_CAPS) array. +//! 3. Call NvAPI_DISP_GetMonitorColorCapabilities() again with the pointer to the memory allocated to get all the +//! color capabilities. +//! +//! Note : +//! 1. pColorCapsCount should never be NULL, else the API will fail with NVAPI_INVALID_ARGUMENT. +//! 2. *pColorCapsCount returned from the API will always be the actual count in any/every call. +//! 3. Memory size to be allocated should be (*pColorCapsCount * sizeof(NV_MONITOR_COLOR_CAPS)). +//! 4. If the memory allocated is less than what is required to return all the timings, this API will return the +//! amount of information which can fit in user provided buffer and API will return NVAPI_INSUFFICIENT_BUFFER. +//! 5. If the caller specifies a greater value for *pColorCapsCount in second call to NvAPI_DISP_GetMonitorColorCapabilities() +//! than what was returned from first call, the API will return only the actual number of elements in the color +//! capabilities array and the extra buffer will remain unused. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId Monitor Identifier +//! \param [in, out] pMonitorColorCapabilities The monitor color capabilities information +//! \param [in, out] pColorCapsCount - During input, the number of elements allocated for the pMonitorColorCapabilities pointer +//! - During output, the actual number of color data elements the monitor supports +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \retval NVAPI_INSUFFICIENT_BUFFER The input buffer size is not sufficient to hold the total contents. In this case +//! *pColorCapsCount will hold the required amount of elements. +//! \retval NVAPI_INVALID_DISPLAY_ID The input monitor is either not connected or is not a DP panel. +//! +//! \ingroup dispcontrol +//! +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_GetMonitorColorCapabilities(__in NvU32 displayId, __inout_ecount_part_opt(*pColorCapsCount, *pColorCapsCount) NV_MONITOR_COLOR_CAPS *pMonitorColorCapabilities, __inout NvU32 *pColorCapsCount); + +//! \ingroup dispcontrol +//! Used in NvAPI_DISP_EnumCustomDisplay() and NvAPI_DISP_TryCustomDisplay(). +typedef struct +{ + NvU32 version; + + // the source mode information + NvU32 width; //!< Source surface(source mode) width + NvU32 height; //!< Source surface(source mode) height + NvU32 depth; //!< Source surface color depth."0" means all 8/16/32bpp + NV_FORMAT colorFormat; //!< Color format (optional) + + NV_VIEWPORTF srcPartition; //!< For multimon support, should be set to (0,0,1.0,1.0) for now. + + float xRatio; //!< Horizontal scaling ratio + float yRatio; //!< Vertical scaling ratio + + NV_TIMING timing; //!< Timing used to program TMDS/DAC/LVDS/HDMI/TVEncoder, etc. + NvU32 hwModeSetOnly : 1; //!< If set, it means a hardware modeset without OS update + +}NV_CUSTOM_DISPLAY; + +//! \ingroup dispcontrol +//! Used in NV_CUSTOM_DISPLAY. +#define NV_CUSTOM_DISPLAY_VER MAKE_NVAPI_VERSION(NV_CUSTOM_DISPLAY,1) + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_EnumCustomDisplay +// +//! DESCRIPTION: This API enumerates the custom timing specified by the enum index. +//! The client should keep enumerating until it returns NVAPI_END_ENUMERATION. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! \param [in] displayId Dispaly ID of the display. +//! \param [in] index Enum index +//! \param [inout] pCustDisp Pointer to the NV_CUSTOM_DISPLAY structure +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! \retval NVAPI_INVALID_DISPLAY_ID: Custom Timing is not supported on the Display, whose display id is passed +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_EnumCustomDisplay( __in NvU32 displayId, __in NvU32 index, __inout NV_CUSTOM_DISPLAY *pCustDisp); + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_TryCustomDisplay +// +//! DESCRIPTION: This API is used to set up a custom display without saving the configuration on multiple displays. +//! +//! \note +//! All the members of srcPartition, present in NV_CUSTOM_DISPLAY structure, should have their range in (0.0,1.0). +//! In clone mode the timings can applied to both the target monitors but only one target at a time. \n +//! For the secondary target the applied timings works under the following conditions: +//! - If the secondary monitor EDID supports the selected timing, OR +//! - If the selected custom timings can be scaled by the secondary monitor for the selected source resolution on the primary, OR +//! - If the selected custom timings matches the existing source resolution on the primary. +//! Setting up a custom display on non-active but connected monitors is supported only for Win7 and above. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! +//! \param [in] pDisplayIds Array of the target display Dispaly IDs - See \ref handles. +//! \param [in] count Total number of the incoming Display IDs and corresponding NV_CUSTOM_DISPLAY structure. This is for the multi-head support. +//! \param [in] pCustDisp Pointer to the NV_CUSTOM_DISPLAY structure array. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! \retval NVAPI_INVALID_DISPLAY_ID: Custom Timing is not supported on the Display, whose display id is passed +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_TryCustomDisplay( __in_ecount(count) NvU32 *pDisplayIds, __in NvU32 count, __in_ecount(count) NV_CUSTOM_DISPLAY *pCustDisp); + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_DeleteCustomDisplay +// +//! DESCRIPTION: This function deletes the custom display configuration, specified from the registry for all the displays whose display IDs are passed. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! +//! \param [in] pDisplayIds Array of Dispaly IDs on which custom display configuration is to be saved. +//! \param [in] count Total number of the incoming Dispaly IDs. This is for the multi-head support. +//! \param [in] pCustDisp Pointer to the NV_CUSTOM_DISPLAY structure +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! \retval NVAPI_INVALID_DISPLAY_ID: Custom Timing is not supported on the Display, whose display id is passed +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_DeleteCustomDisplay( __in_ecount(count) NvU32 *pDisplayIds, __in NvU32 count, __in NV_CUSTOM_DISPLAY *pCustDisp); + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_SaveCustomDisplay +// +//! DESCRIPTION: This function saves the current hardware display configuration on the specified Display IDs as a custom display configuration. +//! This function should be called right after NvAPI_DISP_TryCustomDisplay() to save the custom display from the current +//! hardware context. This function will not do anything if the custom display configuration is not tested on the hardware. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! +//! \param [in] pDisplayIds Array of Dispaly IDs on which custom display configuration is to be saved. +//! \param [in] count Total number of the incoming Dispaly IDs. This is for the multi-head support. +//! \param [in] isThisOutputIdOnly If set, the saved custom display will only be applied on the monitor with the same outputId (see \ref handles). +//! \param [in] isThisMonitorIdOnly If set, the saved custom display will only be applied on the monitor with the same EDID ID or +//! the same TV connector in case of analog TV. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! \retval NVAPI_INVALID_DISPLAY_ID: Custom Timing is not supported on the Display, whose display id is passed +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_SaveCustomDisplay( __in_ecount(count) NvU32 *pDisplayIds, __in NvU32 count, __in NvU32 isThisOutputIdOnly, __in NvU32 isThisMonitorIdOnly); + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_RevertCustomDisplayTrial +// +//! DESCRIPTION: This API is used to restore the display configuration, that was changed by calling NvAPI_DISP_TryCustomDisplay(). This function +//! must be called only after a custom display configuration is tested on the hardware, using NvAPI_DISP_TryCustomDisplay(), +//! otherwise no action is taken. On Vista, NvAPI_DISP_RevertCustomDisplayTrial should be called with an active display that +//! was affected during the NvAPI_DISP_TryCustomDisplay() call, per GPU. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! +//! \param [in] pDisplayIds Pointer to display Id, of an active display. +//! \param [in] count Total number of incoming Display IDs. For future use only. Currently it is expected to be passed as 1. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_RevertCustomDisplayTrial( __in_ecount(count) NvU32* pDisplayIds, __in NvU32 count); + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GetView +// +//! This API lets caller retrieve the target display arrangement for selected source display handle. +//! \note Display PATH with this API is limited to single GPU. DUALVIEW across GPUs will be returned as STANDARD VIEW. +//! Use NvAPI_SYS_GetDisplayTopologies() to query views across GPUs. +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_DISP_GetDisplayConfig. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 85 +//! +//! \param [in] hNvDisplay NVIDIA Display selection. It can be #NVAPI_DEFAULT_HANDLE or a handle enumerated from +//! NvAPI_EnumNVidiaDisplayHandle(). +//! \param [out] pTargets User allocated storage to retrieve an array of NV_VIEW_TARGET_INFO. Can be NULL to retrieve +//! the targetCount. +//! \param [in,out] targetMaskCount Count of target device mask specified in pTargetMask. +//! \param [out] targetView Target view selected from NV_TARGET_VIEW_MODE. +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred +//! \retval NVAPI_INVALID_ARGUMENT Invalid input parameter. +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 290. Instead, use NvAPI_DISP_GetDisplayConfig.") +NVAPI_INTERFACE NvAPI_GetView(NvDisplayHandle hNvDisplay, NV_VIEW_TARGET_INFO *pTargets, NvU32 *pTargetMaskCount, NV_TARGET_VIEW_MODE *pTargetView); + + + + + + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GetViewEx +// +//! DESCRIPTION: This API lets caller retrieve the target display arrangement for selected source display handle. +//! \note Display PATH with this API is limited to single GPU. DUALVIEW across GPUs will be returned as STANDARD VIEW. +//! Use NvAPI_SYS_GetDisplayTopologies() to query views across GPUs. +//! +//! \deprecated Do not use this function - it is deprecated in release 290. Instead, use NvAPI_DISP_GetDisplayConfig. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 165 +//! +//! \param [in] hNvDisplay NVIDIA Display selection. #NVAPI_DEFAULT_HANDLE is not allowed, it has to be a handle enumerated with +//! NvAPI_EnumNVidiaDisplayHandle(). +//! \param [in,out] pPathInfo Count field should be set to NVAPI_MAX_DISPLAY_PATH. Can be NULL to retrieve just the pathCount. +//! \param [in,out] pPathCount Number of elements in array pPathInfo->path. +//! \param [out] pTargetViewMode Display view selected from NV_TARGET_VIEW_MODE. +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_API_NOT_INTIALIZED NVAPI not initialized +//! \retval NVAPI_ERROR Miscellaneous error occurred +//! \retval NVAPI_INVALID_ARGUMENT Invalid input parameter. +//! \retval NVAPI_EXPECTED_DISPLAY_HANDLE hNvDisplay is not a valid display handle. +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 290. Instead, use NvAPI_DISP_GetDisplayConfig.") +NVAPI_INTERFACE NvAPI_GetViewEx(NvDisplayHandle hNvDisplay, NV_DISPLAY_PATH_INFO *pPathInfo, NvU32 *pPathCount, NV_TARGET_VIEW_MODE *pTargetViewMode); + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_GetSupportedViews +// +//! This API lets caller enumerate all the supported NVIDIA display views - nView and Dualview modes. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 85 +//! +//! \param [in] hNvDisplay NVIDIA Display selection. It can be #NVAPI_DEFAULT_HANDLE or a handle enumerated from +//! NvAPI_EnumNVidiaDisplayHandle(). +//! \param [out] pTargetViews Array of supported views. Can be NULL to retrieve the pViewCount first. +//! \param [in,out] pViewCount Count of supported views. +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Miscellaneous error occurred +//! \retval NVAPI_INVALID_ARGUMENT Invalid input parameter. +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetSupportedViews(NvDisplayHandle hNvDisplay, NV_TARGET_VIEW_MODE *pTargetViews, NvU32 *pViewCount); + + +//! SUPPORTED OS: Windows 7 and higher +//! +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DISP_GetDisplayIdByDisplayName +// +//! DESCRIPTION: This API retrieves the Display Id of a given display by +//! display name. The display must be active to retrieve the +//! displayId. In the case of clone mode or Surround gaming, +//! the primary or top-left display will be returned. +//! +//! \param [in] displayName Name of display (Eg: "\\DISPLAY1" to +//! retrieve the displayId for. +//! \param [out] displayId Display ID of the requested display. +//! +//! retval ::NVAPI_OK: Capabilties have been returned. +//! retval ::NVAPI_INVALID_ARGUMENT: One or more args passed in are invalid. +//! retval ::NVAPI_API_NOT_INTIALIZED: The NvAPI API needs to be initialized first +//! retval ::NVAPI_NO_IMPLEMENTATION: This entrypoint not available +//! retval ::NVAPI_ERROR: Miscellaneous error occurred +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_GetDisplayIdByDisplayName(const char *displayName, NvU32* displayId); + + + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_GetDisplayConfig +// +//! DESCRIPTION: This API lets caller retrieve the current global display +//! configuration. +//! USAGE: The caller might have to call this three times to fetch all the required configuration details as follows: +//! First Pass: Caller should Call NvAPI_DISP_GetDisplayConfig() with pathInfo set to NULL to fetch pathInfoCount. +//! Second Pass: Allocate memory for pathInfo with respect to the number of pathInfoCount(from First Pass) to fetch +//! targetInfoCount. If sourceModeInfo is needed allocate memory or it can be initialized to NULL. +//! Third Pass(Optional, only required if target information is required): Allocate memory for targetInfo with respect +//! to number of targetInfoCount(from Second Pass). +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in,out] pathInfoCount Number of elements in pathInfo array, returns number of valid topologies, this cannot be null. +//! \param [in,out] pathInfo Array of path information +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. If there are return error codes with +//! specific meaning for this API, they are listed below. +//! +//! \retval NVAPI_INVALID_ARGUMENT - Invalid input parameter. Following can be the reason for this return value: +//! -# pathInfoCount is NULL. +//! -# *pathInfoCount is 0 and pathInfo is not NULL. +//! -# *pathInfoCount is not 0 and pathInfo is NULL. +//! \retval NVAPI_DEVICE_BUSY - ModeSet has not yet completed. Please wait and call it again. +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_GetDisplayConfig(__inout NvU32 *pathInfoCount, __out_ecount_full_opt(*pathInfoCount) NV_DISPLAYCONFIG_PATH_INFO *pathInfo); + + + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_SetDisplayConfig +// +// +//! DESCRIPTION: This API lets caller apply a global display configuration +//! across multiple GPUs. +//! +//! If all sourceIds are zero, then NvAPI will pick up sourceId's based on the following criteria : +//! - If user provides sourceModeInfo then we are trying to assign 0th sourceId always to GDIPrimary. +//! This is needed since active windows always moves along with 0th sourceId. +//! - For rest of the paths, we are incrementally assigning the sourceId per adapter basis. +//! - If user doesn't provide sourceModeInfo then NVAPI just picks up some default sourceId's in incremental order. +//! Note : NVAPI will not intelligently choose the sourceIDs for any configs that does not need a modeset. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pathInfoCount Number of supplied elements in pathInfo +//! \param [in] pathInfo Array of path information +//! \param [in] flags Flags for applying settings +//! +//! \retval ::NVAPI_OK - completed request +//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized +//! \retval ::NVAPI_ERROR - miscellaneous error occurred +//! \retval ::NVAPI_INVALID_ARGUMENT - Invalid input parameter. +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_SetDisplayConfig(__in NvU32 pathInfoCount, __in_ecount(pathInfoCount) NV_DISPLAYCONFIG_PATH_INFO* pathInfo, __in NvU32 flags); + + + +typedef struct _NV_GET_ADAPTIVE_SYNC_DATA_V1 +{ + NvU32 version ; //!< [in] structure version + NvU32 maxFrameInterval; //!< [out] maximum frame interval in micro seconds as set previously using NvAPI_DISP_SetAdaptiveSyncData function. + //!< If default values from EDID are used, this parameter returns 0. + NvU32 bDisableAdaptiveSync : 1; //!< [out] Indicates if adaptive sync is disabled on the display. + NvU32 bDisableFrameSplitting : 1; //!< [out] Indicates if frame splitting is disabled on the display. + NvU32 reserved : 30; //!< reserved for future use. + NvU32 lastFlipRefreshCount; //!< [out] Number of times the last flip was shown on the screen + NvU64 lastFlipTimeStamp; //!< [out] Timestamp for the lastest flip on the screen + NvU32 reservedEx[4]; //!< reserved for future use. +} NV_GET_ADAPTIVE_SYNC_DATA_V1; + +#define NV_GET_ADAPTIVE_SYNC_DATA_VER1 MAKE_NVAPI_VERSION(NV_GET_ADAPTIVE_SYNC_DATA_V1,1) +#define NV_GET_ADAPTIVE_SYNC_DATA_VER NV_GET_ADAPTIVE_SYNC_DATA_VER1 + +typedef NV_GET_ADAPTIVE_SYNC_DATA_V1 NV_GET_ADAPTIVE_SYNC_DATA; + +/////////////////////////////////////////////////////////////////////////////// +// +//! \fn NvAPI_DISP_GetAdaptiveSyncData(__in NvU32 displayId, __inout NV_GET_ADAPTIVE_SYNC_DATA *pAdaptiveSyncData) +//! \code +//! DESCRIPTION: This function is used to get data for the Adaptive Sync Display. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! \since Release: 415 +//! +//! \param [in] displayId - display id of the display +//! \param [inout] pAdaptiveSyncData - A pointer to NV_GET_ADAPTIVE_SYNC_DATA, containing the information about the values of parameters that are to be retrieved on given display. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \endcode +/////////////////////////////////////////////////////////////////////////////// +//! \ingroup dispcontrol +NVAPI_INTERFACE NvAPI_DISP_GetAdaptiveSyncData(__in NvU32 displayId, __inout NV_GET_ADAPTIVE_SYNC_DATA *pAdaptiveSyncData); + +typedef struct _NV_SET_ADAPTIVE_SYNC_DATA_V1 +{ + NvU32 version ; //!< [in] structure version + NvU32 maxFrameInterval; //!< [in] maximum frame interval in micro seconds. + //!< If maxFrameInterval is send as 0, default values from EDID will be used. + NvU32 bDisableAdaptiveSync : 1; //!< [in] Indicates if adaptive sync is disabled on the display. + NvU32 bDisableFrameSplitting : 1; //!< [in] Indicates if Frame Splitting should be disabled. + NvU32 reserved : 30; //!< reserved for future use. + NvU32 reservedEx[7]; //!< reserved for future use. +} NV_SET_ADAPTIVE_SYNC_DATA_V1; + +#define NV_SET_ADAPTIVE_SYNC_DATA_VER1 MAKE_NVAPI_VERSION(NV_SET_ADAPTIVE_SYNC_DATA_V1,1) +#define NV_SET_ADAPTIVE_SYNC_DATA_VER NV_SET_ADAPTIVE_SYNC_DATA_VER1 + +typedef NV_SET_ADAPTIVE_SYNC_DATA_V1 NV_SET_ADAPTIVE_SYNC_DATA; + +/////////////////////////////////////////////////////////////////////////////// +// +//! \fn NvAPI_DISP_SetAdaptiveSyncData(__in NvU32 displayId, __in NV_SET_ADAPTIVE_SYNC_DATA *pAdaptiveSyncData) +//! \code +//! DESCRIPTION: This function is used to set data for Adaptive Sync Display. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! \since Release: 415 +//! +//! \param [in] displayId - display id of the display +//! \param [in] pAdaptiveSyncData - A pointer to NV_SET_ADAPTIVE_SYNC_DATA, containing the information about the values of parameters that are to be set on given display. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \endcode +/////////////////////////////////////////////////////////////////////////////// +//! \ingroup dispcontrol +NVAPI_INTERFACE NvAPI_DISP_SetAdaptiveSyncData(__in NvU32 displayId, __in NV_SET_ADAPTIVE_SYNC_DATA *pAdaptiveSyncData); + + +typedef struct _NV_GET_VIRTUAL_REFRESH_RATE_DATA_V1 +{ + NvU32 version ; //!< [in] structure version + NvU32 frameIntervalUs; //!< [out] frame interval in micro seconds if Virtual RR is currently applied + NvU32 reservedEx[8]; //!< reserved for future use. +} NV_GET_VIRTUAL_REFRESH_RATE_DATA_V1; + +#define NV_GET_VIRTUAL_REFRESH_RATE_DATA_VER1 MAKE_NVAPI_VERSION(_NV_GET_VIRTUAL_REFRESH_RATE_DATA_V1,1) +#define NV_GET_VIRTUAL_REFRESH_RATE_DATA_VER NV_GET_VIRTUAL_REFRESH_RATE_DATA_VER1 + +typedef NV_GET_VIRTUAL_REFRESH_RATE_DATA_V1 NV_GET_VIRTUAL_REFRESH_RATE_DATA; + +/////////////////////////////////////////////////////////////////////////////// +// +//! \fn NvAPI_DISP_GetVirtualRefreshRateData(__in NvU32 displayId, __inout NV_GET_VIRTUAL_REFRESH_RATE_DATA *pVirtualRefreshRateData) +//! \code +//! DESCRIPTION: This function is used to get Virtual Refresh Rate data for a VRR Capable Display. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! \since Release: 510 +//! +//! \param [in] displayId - display id of the display +//! \param [inout] pVirtualRefreshRateData - A pointer to NV_GET_VIRTUAL_REFRESH_RATE_DATA, containing the information about the values of parameters that are to be retrieved on given display. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \endcode +/////////////////////////////////////////////////////////////////////////////// +//! \ingroup dispcontrol +NVAPI_INTERFACE NvAPI_DISP_GetVirtualRefreshRateData(__in NvU32 displayId, __inout NV_GET_VIRTUAL_REFRESH_RATE_DATA *pVirtualRefreshRateData); + +typedef struct _NV_SET_VIRTUAL_REFRESH_RATE_DATA_V1 +{ + NvU32 version ; //!< [in] structure version + NvU32 frameIntervalUs; //!< [in] frame interval in micro seconds if Virtual RR is currently applied + NvU32 reservedEx[8]; //!< reserved for future use. +} NV_SET_VIRTUAL_REFRESH_RATE_DATA_V1; + +#define NV_SET_VIRTUAL_REFRESH_RATE_DATA_VER1 MAKE_NVAPI_VERSION(_NV_SET_VIRTUAL_REFRESH_RATE_DATA_V1,1) +#define NV_SET_VIRTUAL_REFRESH_RATE_DATA_VER NV_SET_VIRTUAL_REFRESH_RATE_DATA_VER1 + +typedef NV_SET_VIRTUAL_REFRESH_RATE_DATA_V1 NV_SET_VIRTUAL_REFRESH_RATE_DATA; + +/////////////////////////////////////////////////////////////////////////////// +// +//! \fn NvAPI_DISP_SetVirtualRefreshRateData(__in NvU32 displayId, __in NV_SET_VIRTUAL_REFRESH_RATE_DATA *pVirtualRefreshRateData) +//! \code +//! DESCRIPTION: This function is used to set Virtual Refresh Rate data for a VRR Capable Display. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! \since Release: 510 +//! +//! \param [in] displayId - display id of the display +//! \param [inout] pVirtualRefreshRateData - A pointer to NV_SET_VIRTUAL_REFRESH_RATE_DATA, containing the information about the values of parameters that are to be retrieved on given display. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \endcode +/////////////////////////////////////////////////////////////////////////////// +//! \ingroup dispcontrol +NVAPI_INTERFACE NvAPI_DISP_SetVirtualRefreshRateData(__in NvU32 displayId, __in NV_SET_VIRTUAL_REFRESH_RATE_DATA *pVirtualRefreshRateData); + +//! \ingroup dispcontrol +typedef struct +{ + NvU32 version; //!< [in] Structure version + NvU32 displayId; //!< [in] Monitor Identifier to be set + NvU32 reserved; //!< Reserved for future use without adding versioning +} NV_SET_PREFERRED_STEREO_DISPLAY_V1; + +//! \ingroup dispcontrol +typedef NV_SET_PREFERRED_STEREO_DISPLAY_V1 NV_SET_PREFERRED_STEREO_DISPLAY; + +//! \ingroup dispcontrol +#define NV_SET_PREFERRED_STEREO_DISPLAY_VER1 MAKE_NVAPI_VERSION(NV_SET_PREFERRED_STEREO_DISPLAY_V1,1) + +//! \ingroup dispcontrol +#define NV_SET_PREFERRED_STEREO_DISPLAY_VER NV_SET_PREFERRED_STEREO_DISPLAY_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_SetPreferredStereoDisplay +// +//! DESCRIPTION: Specifies a display output that drives the 3pin DIN output signal +//! in a workstation stereo system environment. +//! If display output is specified as a displayId of 0, the preferred +//! stereo display target is reset to the driver default selection. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! \since Release: 470 +//! +//! \param [in] pPreferredStereoDisplay Pointer to a NV_SET_PREFERRED_STEREO_DISPLAY structure +//! +//! \retval ::NVAPI_OK completed request +//! \retval ::NVAPI_ERROR miscellaneous error occurred +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input parameter. +//! \retval ::NVAPI_INVALID_USER_PRIVILEGE - The application will require Administrator privileges to access this API. +//! The application can be elevated to a higher permission level by selecting "Run as Administrator". +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_SetPreferredStereoDisplay(__in NV_SET_PREFERRED_STEREO_DISPLAY *pPreferredStereoDisplay); + +//! \ingroup dispcontrol +typedef struct +{ + NvU32 version; //!< [in] Structure version + NvU32 displayId; //!< [out] The queried stereo display + NvU32 reserved; //!< Reserved for future use without adding versioning +} NV_GET_PREFERRED_STEREO_DISPLAY_V1; + +//! \ingroup dispcontrol +typedef NV_GET_PREFERRED_STEREO_DISPLAY_V1 NV_GET_PREFERRED_STEREO_DISPLAY; + +//! \ingroup dispcontrol +#define NV_GET_PREFERRED_STEREO_DISPLAY_VER1 MAKE_NVAPI_VERSION(NV_GET_PREFERRED_STEREO_DISPLAY_V1,1) + +//! \ingroup dispcontrol +#define NV_GET_PREFERRED_STEREO_DISPLAY_VER NV_GET_PREFERRED_STEREO_DISPLAY_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_DISP_GetPreferredStereoDisplay +// +//! DESCRIPTION: Queries the displayId of the display output driving the 3pin +//! DIN stereo signal, if any. +//! SUPPORTED OS: Windows 10 and higher +//! +//! \since Release: 470 +//! +//! \param [inout] pPreferredStereoDisplay Pointer to a NV_GET_PREFERRED_STEREO_DISPLAY structure +//! +//! \retval ::NVAPI_OK completed request +//! \retval ::NVAPI_ERROR miscellaneous error occurred +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid input parameter. +//! \retval ::NVAPI_INVALID_POINTER An invalid pointer was passed as an argument (probably NULL). +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_GetPreferredStereoDisplay(__inout NV_GET_PREFERRED_STEREO_DISPLAY *pPreferredStereoDisplay); + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) + +typedef struct _NV_MANAGED_DEDICATED_DISPLAY_INFO +{ + NvU32 version; //!< [in] Version of this structure. + NvU32 displayId; //!< [out] DisplayId. + NvU32 isAcquired : 1; //!< [out] If bit is set, this display has been acquired by another process through NvAPI_DISP_AcquireDedicatedDisplay(). + NvU32 isMosaic : 1; //!< [out] If bit is set, this display represents a Mosaic grid. + NvU32 reserved : 30; //!< [out] Reserved for future use without adding versioning. +} NV_MANAGED_DEDICATED_DISPLAY_INFO_V1; + +#define NV_MANAGED_DEDICATED_DISPLAY_INFO_VER1 MAKE_NVAPI_VERSION(NV_MANAGED_DEDICATED_DISPLAY_INFO_V1,1) +#define NV_MANAGED_DEDICATED_DISPLAY_INFO_VER NV_MANAGED_DEDICATED_DISPLAY_INFO_VER1 + +typedef NV_MANAGED_DEDICATED_DISPLAY_INFO_V1 NV_MANAGED_DEDICATED_DISPLAY_INFO; + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DISP_GetNvManagedDedicatedDisplays +// +//! DESCRIPTION: This API returns the count of dedicated displays managed by +//! the Nvidia driver, and specific driver info of each display. +//! This API does not return VR displays. +//! +//! HOW TO USE: 1) First make a call NvAPI_DISP_GetNvManagedDedicatedDisplays to get the number of dedicated displays managed by the Nvidia driver +//! by passing pDedicatedDisplays as NULL. +//! On call success: +//! 2) Allocate memory based on pDisplayCount, then call NvAPI_DISP_GetNvManagedDedicatedDisplays to populate pDedicatedDisplays. +//! +//! \since Release: 495 +//! +//! \param [in/out] pDedicatedDisplayCount The count of dedicated displays managed by the Nvidia driver. +//! \param [in/out] pDedicatedDisplays Pointer to an array of NV_MANAGED_DEDICATED_DISPLAY_INFO data structure. +//! +//! \retval ::NVAPI_OK The call succeeded. +//! \retval ::NVAPI_ERROR The call failed. +//! \retval ::NVAPI_NO_IMPLEMENTATION The API is not implemented in current driver. +//! \retval ::NVAPI_OUT_OF_MEMORY Could not allocate sufficient memory to complete the call. +//! \retval ::NVAPI_INVALID_POINTER An invalid pointer was passed as an argument. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not initialized. +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION The version of NV_MANAGED_DEDICATED_DISPLAY_INFO structure is invalid. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_GetNvManagedDedicatedDisplays(__inout NvU32* pDedicatedDisplayCount, __inout NV_MANAGED_DEDICATED_DISPLAY_INFO* pDedicatedDisplays); +#endif // defined(__cplusplus) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DISP_AcquireDedicatedDisplay +// +//! DESCRIPTION: This API requests exclusive access to the specified dedicated +//! display managed by the Nvidia driver. If the call succeeds, a handle +//! is returned which could be opened as a DisplaySource. +//! The call fails if the display is not managed by the Nvidia driver. +//! The call fails if the display has already been acquired by another process. +//! +//! \since Release: 495 +//! +//! \param [in] displayId Display ID of the dedicated display to be acquired. +//! \param [in/out] pDisplaySourceHandle Pointer to memory that receives the shared handle to a DisplaySource. +//! +//! \retval ::NVAPI_OK The call succeeded. +//! \retval ::NVAPI_ERROR The call failed. +//! \retval ::NVAPI_NO_IMPLEMENTATION The API not implemented. +//! \retval ::NVAPI_INVALID_POINTER An invalid pointer was passed as an argument. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized. +//! \retval ::NVAPI_INVALID_DISPLAY_ID An invalid displayId was passed as an argument. +//! \retval ::NVAPI_UNREGISTERED_RESOURCE The display is not managed by the Nvidia driver. +//! \retval ::NVAPI_RESOURCE_IN_USE The display has already been acquired by another process. +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_AcquireDedicatedDisplay(__in NvU32 displayId, __inout NvU64* pDisplaySourceHandle); +#endif // defined(__cplusplus) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DISP_ReleaseDedicatedDisplay +// +//! DESCRIPTION: This API releases the exclusive ownership of a specific dedicated +//! display previously acquired by the process. +//! +//! \since Release: 495 +//! +//! \param [in] displayId Display ID of the dedicated display to be released. +//! +//! \retval ::NVAPI_OK The call succeeded. +//! \retval ::NVAPI_ERROR The call failed. +//! \retval ::NVAPI_NO_IMPLEMENTATION The API not implemented. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized. +//! \retval ::NVAPI_UNREGISTERED_RESOURCE The display is not managed by the Nvidia driver. +//! \retval ::NVAPI_DDISPLAY_NOT_ACQUIRED The display is not acquired by the process. +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_ReleaseDedicatedDisplay(__in NvU32 displayId); +#endif // defined(__cplusplus) + + + +//////////////////////////////////////////////////////////////////////////////////////// +// +// MOSAIC allows a multi display target output scanout on a single source. +// +// SAMPLE of MOSAIC 1x4 topo with 8 pixel horizontal overlap +// +//+-------------------------++-------------------------++-------------------------++-------------------------+ +//| || || || | +//| || || || | +//| || || || | +//| DVI1 || DVI2 || DVI3 || DVI4 | +//| || || || | +//| || || || | +//| || || || | +//| || || || | +//+-------------------------++-------------------------++-------------------------++-------------------------+ + + +//! \addtogroup mosaicapi +//! @{ + +#define NVAPI_MAX_MOSAIC_DISPLAY_ROWS 8 +#define NVAPI_MAX_MOSAIC_DISPLAY_COLUMNS 8 +// +// These bits are used to describe the validity of a topo. +// +#define NV_MOSAIC_TOPO_VALIDITY_VALID 0x00000000 //!< The topology is valid +#define NV_MOSAIC_TOPO_VALIDITY_MISSING_GPU 0x00000001 //!< Not enough SLI GPUs were found to fill the entire + //! topology. hPhysicalGPU will be 0 for these. +#define NV_MOSAIC_TOPO_VALIDITY_MISSING_DISPLAY 0x00000002 //!< Not enough displays were found to fill the entire + //! topology. displayOutputId will be 0 for these. +#define NV_MOSAIC_TOPO_VALIDITY_MIXED_DISPLAY_TYPES 0x00000004 //!< The topoogy is only possible with displays of the same + //! NV_GPU_OUTPUT_TYPE. Check displayOutputIds to make + //! sure they are all CRTs, or all DFPs. + + +// +//! This structure defines the topology details. +typedef struct +{ + NvU32 version; //!< Version of this structure + NvLogicalGpuHandle hLogicalGPU; //!< Logical GPU for this topology + NvU32 validityMask; //!< 0 means topology is valid with the current hardware. + //! If not 0, inspect bits against NV_MOSAIC_TOPO_VALIDITY_*. + NvU32 rowCount; //!< Number of displays in a row + NvU32 colCount; //!< Number of displays in a column + + struct + { + NvPhysicalGpuHandle hPhysicalGPU; //!< Physical GPU to be used in the topology (0 if GPU missing) + NvU32 displayOutputId; //!< Connected display target (0 if no display connected) + NvS32 overlapX; //!< Pixels of overlap on left of target: (+overlap, -gap) + NvS32 overlapY; //!< Pixels of overlap on top of target: (+overlap, -gap) + + } gpuLayout[NVAPI_MAX_MOSAIC_DISPLAY_ROWS][NVAPI_MAX_MOSAIC_DISPLAY_COLUMNS]; + +} NV_MOSAIC_TOPO_DETAILS; + +//! Macro for constructing te vesion field of NV_MOSAIC_TOPO_DETAILS +#define NVAPI_MOSAIC_TOPO_DETAILS_VER MAKE_NVAPI_VERSION(NV_MOSAIC_TOPO_DETAILS,1) + + +// +//! These values refer to the different types of Mosaic topologies that are possible. When +//! getting the supported Mosaic topologies, you can specify one of these types to narrow down +//! the returned list to only those that match the given type. +typedef enum +{ + NV_MOSAIC_TOPO_TYPE_ALL, //!< All mosaic topologies + NV_MOSAIC_TOPO_TYPE_BASIC, //!< Basic Mosaic topologies + NV_MOSAIC_TOPO_TYPE_PASSIVE_STEREO, //!< Passive Stereo topologies + NV_MOSAIC_TOPO_TYPE_SCALED_CLONE, //!< Not supported at this time + NV_MOSAIC_TOPO_TYPE_PASSIVE_STEREO_SCALED_CLONE, //!< Not supported at this time + NV_MOSAIC_TOPO_TYPE_MAX, //!< Always leave this at end of the enum +} NV_MOSAIC_TOPO_TYPE; + + +// +//! This is a complete list of supported Mosaic topologies. +//! +//! Using a "Basic" topology combines multiple monitors to create a single desktop. +//! +//! Using a "Passive" topology combines multiples monitors to create a passive stereo desktop. +//! In passive stereo, two identical topologies combine - one topology is used for the right eye and the other identical //! topology (targeting different displays) is used for the left eye. \n +//! NOTE: common\inc\nvEscDef.h shadows a couple PASSIVE_STEREO enums. If this +//! enum list changes and effects the value of NV_MOSAIC_TOPO_BEGIN_PASSIVE_STEREO +//! please update the corresponding value in nvEscDef.h +typedef enum +{ + NV_MOSAIC_TOPO_NONE, + + // 'BASIC' topos start here + // + // The result of using one of these Mosaic topos is that multiple monitors + // will combine to create a single desktop. + // + NV_MOSAIC_TOPO_BEGIN_BASIC, + NV_MOSAIC_TOPO_1x2_BASIC = NV_MOSAIC_TOPO_BEGIN_BASIC, + NV_MOSAIC_TOPO_2x1_BASIC, + NV_MOSAIC_TOPO_1x3_BASIC, + NV_MOSAIC_TOPO_3x1_BASIC, + NV_MOSAIC_TOPO_1x4_BASIC, + NV_MOSAIC_TOPO_4x1_BASIC, + NV_MOSAIC_TOPO_2x2_BASIC, + NV_MOSAIC_TOPO_2x3_BASIC, + NV_MOSAIC_TOPO_2x4_BASIC, + NV_MOSAIC_TOPO_3x2_BASIC, + NV_MOSAIC_TOPO_4x2_BASIC, + NV_MOSAIC_TOPO_1x5_BASIC, + NV_MOSAIC_TOPO_1x6_BASIC, + NV_MOSAIC_TOPO_7x1_BASIC, + + // Add padding for 10 more entries. 6 will be enough room to specify every + // possible topology with 8 or fewer displays, so this gives us a little + // extra should we need it. + NV_MOSAIC_TOPO_END_BASIC = NV_MOSAIC_TOPO_7x1_BASIC + 9, + + // 'PASSIVE_STEREO' topos start here + // + // The result of using one of these Mosaic topos is that multiple monitors + // will combine to create a single PASSIVE STEREO desktop. What this means is + // that there will be two topos that combine to create the overall desktop. + // One topo will be used for the left eye, and the other topo (of the + // same rows x cols), will be used for the right eye. The difference between + // the two topos is that different GPUs and displays will be used. + // + NV_MOSAIC_TOPO_BEGIN_PASSIVE_STEREO, // value shadowed in nvEscDef.h + NV_MOSAIC_TOPO_1x2_PASSIVE_STEREO = NV_MOSAIC_TOPO_BEGIN_PASSIVE_STEREO, + NV_MOSAIC_TOPO_2x1_PASSIVE_STEREO, + NV_MOSAIC_TOPO_1x3_PASSIVE_STEREO, + NV_MOSAIC_TOPO_3x1_PASSIVE_STEREO, + NV_MOSAIC_TOPO_1x4_PASSIVE_STEREO, + NV_MOSAIC_TOPO_4x1_PASSIVE_STEREO, + NV_MOSAIC_TOPO_2x2_PASSIVE_STEREO, + NV_MOSAIC_TOPO_END_PASSIVE_STEREO = NV_MOSAIC_TOPO_2x2_PASSIVE_STEREO + 4, + + + // + // Total number of topos. Always leave this at the end of the enumeration. + // + NV_MOSAIC_TOPO_MAX //! Total number of topologies. + +} NV_MOSAIC_TOPO; + + +// +//! This is a "topology brief" structure. It tells you what you need to know about +//! a topology at a high level. A list of these is returned when you query for the +//! supported Mosaic information. +//! +//! If you need more detailed information about the topology, call +//! NvAPI_Mosaic_GetTopoGroup() with the topology value from this structure. +typedef struct +{ + NvU32 version; //!< Version of this structure + NV_MOSAIC_TOPO topo; //!< The topology + NvU32 enabled; //!< 1 if topo is enabled, else 0 + NvU32 isPossible; //!< 1 if topo *can* be enabled, else 0 + +} NV_MOSAIC_TOPO_BRIEF; + +//! Macro for constructing the version field of NV_MOSAIC_TOPO_BRIEF +#define NVAPI_MOSAIC_TOPO_BRIEF_VER MAKE_NVAPI_VERSION(NV_MOSAIC_TOPO_BRIEF,1) + + +// +//! Basic per-display settings that are used in setting/getting the Mosaic mode +typedef struct _NV_MOSAIC_DISPLAY_SETTING_V1 +{ + NvU32 version; //!< Version of this structure + NvU32 width; //!< Per-display width + NvU32 height; //!< Per-display height + NvU32 bpp; //!< Bits per pixel + NvU32 freq; //!< Display frequency +} NV_MOSAIC_DISPLAY_SETTING_V1; + +typedef struct NV_MOSAIC_DISPLAY_SETTING_V2 +{ + NvU32 version; //!< Version of this structure + NvU32 width; //!< Per-display width + NvU32 height; //!< Per-display height + NvU32 bpp; //!< Bits per pixel + NvU32 freq; //!< Display frequency + NvU32 rrx1k; //!< Display frequency in x1k +} NV_MOSAIC_DISPLAY_SETTING_V2; + +typedef NV_MOSAIC_DISPLAY_SETTING_V2 NV_MOSAIC_DISPLAY_SETTING; + +//! Macro for constructing the version field of NV_MOSAIC_DISPLAY_SETTING +#define NVAPI_MOSAIC_DISPLAY_SETTING_VER1 MAKE_NVAPI_VERSION(NV_MOSAIC_DISPLAY_SETTING_V1,1) +#define NVAPI_MOSAIC_DISPLAY_SETTING_VER2 MAKE_NVAPI_VERSION(NV_MOSAIC_DISPLAY_SETTING_V2,2) +#define NVAPI_MOSAIC_DISPLAY_SETTING_VER NVAPI_MOSAIC_DISPLAY_SETTING_VER2 + + +// +// Set a reasonable max number of display settings to support +// so arrays are bound. +// +#define NV_MOSAIC_DISPLAY_SETTINGS_MAX 40 //!< Set a reasonable maximum number of display settings to support + //! so arrays are bound. + + +// +//! This structure is used to contain a list of supported Mosaic topologies +//! along with the display settings that can be used. +typedef struct _NV_MOSAIC_SUPPORTED_TOPO_INFO_V1 +{ + NvU32 version; //!< Version of this structure + NvU32 topoBriefsCount; //!< Number of topologies in below array + NV_MOSAIC_TOPO_BRIEF topoBriefs[NV_MOSAIC_TOPO_MAX]; //!< List of supported topologies with only brief details + NvU32 displaySettingsCount; //!< Number of display settings in below array + NV_MOSAIC_DISPLAY_SETTING_V1 displaySettings[NV_MOSAIC_DISPLAY_SETTINGS_MAX]; //!< List of per display settings possible + +} NV_MOSAIC_SUPPORTED_TOPO_INFO_V1; + +typedef struct _NV_MOSAIC_SUPPORTED_TOPO_INFO_V2 +{ + NvU32 version; //!< Version of this structure + NvU32 topoBriefsCount; //!< Number of topologies in below array + NV_MOSAIC_TOPO_BRIEF topoBriefs[NV_MOSAIC_TOPO_MAX]; //!< List of supported topologies with only brief details + NvU32 displaySettingsCount; //!< Number of display settings in below array + NV_MOSAIC_DISPLAY_SETTING_V2 displaySettings[NV_MOSAIC_DISPLAY_SETTINGS_MAX]; //!< List of per display settings possible + +} NV_MOSAIC_SUPPORTED_TOPO_INFO_V2; + +typedef NV_MOSAIC_SUPPORTED_TOPO_INFO_V2 NV_MOSAIC_SUPPORTED_TOPO_INFO; + +//! Macro forconstructing the version field of NV_MOSAIC_SUPPORTED_TOPO_INFO +#define NVAPI_MOSAIC_SUPPORTED_TOPO_INFO_VER1 MAKE_NVAPI_VERSION(NV_MOSAIC_SUPPORTED_TOPO_INFO_V1,1) +#define NVAPI_MOSAIC_SUPPORTED_TOPO_INFO_VER2 MAKE_NVAPI_VERSION(NV_MOSAIC_SUPPORTED_TOPO_INFO_V2,2) +#define NVAPI_MOSAIC_SUPPORTED_TOPO_INFO_VER NVAPI_MOSAIC_SUPPORTED_TOPO_INFO_VER2 + + +// +// Indices to use to access the topos array within the mosaic topology +#define NV_MOSAIC_TOPO_IDX_DEFAULT 0 + +#define NV_MOSAIC_TOPO_IDX_LEFT_EYE 0 +#define NV_MOSAIC_TOPO_IDX_RIGHT_EYE 1 +#define NV_MOSAIC_TOPO_NUM_EYES 2 + + +// +//! This defines the maximum number of topos that can be in a topo group. +//! At this time, it is set to 2 because our largest topo group (passive +//! stereo) only needs 2 topos (left eye and right eye). +//! +//! If a new topo group with more than 2 topos is added above, then this +//! number will also have to be incremented. +#define NV_MOSAIC_MAX_TOPO_PER_TOPO_GROUP 2 + + +// +//! This structure defines a group of topologies that work together to create one +//! overall layout. All of the supported topologies are represented with this +//! structure. +//! +//! For example, a 'Passive Stereo' topology would be represented with this +//! structure, and would have separate topology details for the left and right eyes. +//! The count would be 2. A 'Basic' topology is also represented by this structure, +//! with a count of 1. +//! +//! The structure is primarily used internally, but is exposed to applications in a +//! read-only fashion because there are some details in it that might be useful +//! (like the number of rows/cols, or connected display information). A user can +//! get the filled-in structure by calling NvAPI_Mosaic_GetTopoGroup(). +//! +//! You can then look at the detailed values within the structure. There are no +//! entrypoints which take this structure as input (effectively making it read-only). +typedef struct +{ + NvU32 version; //!< Version of this structure + NV_MOSAIC_TOPO_BRIEF brief; //!< The brief details of this topo + NvU32 count; //!< Number of topos in array below + NV_MOSAIC_TOPO_DETAILS topos[NV_MOSAIC_MAX_TOPO_PER_TOPO_GROUP]; + +} NV_MOSAIC_TOPO_GROUP; + +//! Macro for constructing the version field of NV_MOSAIC_TOPO_GROUP +#define NVAPI_MOSAIC_TOPO_GROUP_VER MAKE_NVAPI_VERSION(NV_MOSAIC_TOPO_GROUP,1) + +//! @} + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_GetSupportedTopoInfo +// +//! DESCRIPTION: This API returns information on the topologies and display resolutions +//! supported by Mosaic mode. +//! +//! NOTE: Not all topologies returned can be set immediately. +//! See 'OUT' Notes below. +//! +//! Once you get the list of supported topologies, you can call +//! NvAPI_Mosaic_GetTopoGroup() with one of the Mosaic topologies if you need +//! more information about it. +//! +//! 'IN' Notes: pSupportedTopoInfo->version must be set before calling this function. +//! If the specified version is not supported by this implementation, +//! an error will be returned (NVAPI_INCOMPATIBLE_STRUCT_VERSION). +//! +//! 'OUT' Notes: Some of the topologies returned might not be valid for one reason or +//! another. It could be due to mismatched or missing displays. It +//! could also be because the required number of GPUs is not found. +//! At a high level, you can see if the topology is valid and can be enabled +//! by looking at the pSupportedTopoInfo->topoBriefs[xxx].isPossible flag. +//! If this is true, the topology can be enabled. If it +//! is false, you can find out why it cannot be enabled by getting the +//! details of the topology via NvAPI_Mosaic_GetTopoGroup(). From there, +//! look at the validityMask of the individual topologies. The bits can +//! be tested against the NV_MOSAIC_TOPO_VALIDITY_* bits. +//! +//! It is possible for this function to return NVAPI_OK with no topologies +//! listed in the return structure. If this is the case, it means that +//! the current hardware DOES support Mosaic, but with the given configuration +//! no valid topologies were found. This most likely means that SLI was not +//! enabled for the hardware. Once enabled, you should see valid topologies +//! returned from this function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! +//! \param [in,out] pSupportedTopoInfo Information about what topologies and display resolutions +//! are supported for Mosaic. +//! \param [in] type The type of topologies the caller is interested in +//! getting. See NV_MOSAIC_TOPO_TYPE for possible values. +//! +//! \retval ::NVAPI_OK No errors in returning supported topologies. +//! \retval ::NVAPI_NOT_SUPPORTED Mosaic is not supported with the existing hardware. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more arguments passed in are invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first. +//! \retval ::NVAPI_NO_IMPLEMENTATION This entrypoint not available. +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION The version of the structure passed in is not +// compatible with this entry point. +//! \retval ::NVAPI_ERROR: Miscellaneous error occurred. +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_GetSupportedTopoInfo(NV_MOSAIC_SUPPORTED_TOPO_INFO *pSupportedTopoInfo, NV_MOSAIC_TOPO_TYPE type); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_GetTopoGroup +// +//! DESCRIPTION: This API returns a structure filled with the details +//! of the specified Mosaic topology. +//! +//! If the pTopoBrief passed in matches the current topology, +//! then information in the brief and group structures +//! will reflect what is current. Thus the brief would have +//! the current 'enable' status, and the group would have the +//! current overlap values. If there is no match, then the +//! returned brief has an 'enable' status of FALSE (since it +//! is obviously not enabled), and the overlap values will be 0. +//! +//! 'IN' Notes: pTopoGroup->version must be set before calling this function. +//! If the specified version is not supported by this implementation, +//! an error will be returned (NVAPI_INCOMPATIBLE_STRUCT_VERSION). +//! +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [in] pTopoBrief The topology for getting the details +//! This must be one of the topology briefs +//! returned from NvAPI_Mosaic_GetSupportedTopoInfo(). +//! \param [in,out] pTopoGroup The topology details matching the brief +//! +//! \retval ::NVAPI_OK Details were retrieved successfully. +//! \retval ::NVAPI_NOT_SUPPORTED Mosaic is not supported with the existing hardware. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more argumentss passed in are invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first. +//! \retval ::NVAPI_NO_IMPLEMENTATION This entrypoint not available. +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION The version of the structure passed in is not +// compatible with this entry point. +//! \retval ::NVAPI_ERROR: Miscellaneous error occurred. +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_GetTopoGroup(NV_MOSAIC_TOPO_BRIEF *pTopoBrief, NV_MOSAIC_TOPO_GROUP *pTopoGroup); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_GetOverlapLimits +// +//! DESCRIPTION: This API returns the X and Y overlap limits required if +//! the given Mosaic topology and display settings are to be used. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [in] pTopoBrief The topology for getting limits +//! This must be one of the topo briefs +//! returned from NvAPI_Mosaic_GetSupportedTopoInfo(). +//! \param [in] pDisplaySetting The display settings for getting the limits. +//! This must be one of the settings +//! returned from NvAPI_Mosaic_GetSupportedTopoInfo(). +//! \param [out] pMinOverlapX X overlap minimum +//! \param [out] pMaxOverlapX X overlap maximum +//! \param [out] pMinOverlapY Y overlap minimum +//! \param [out] pMaxOverlapY Y overlap maximum +//! +//! \retval ::NVAPI_OK Details were retrieved successfully. +//! \retval ::NVAPI_NOT_SUPPORTED Mosaic is not supported with the existing hardware. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more argumentss passed in are invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first. +//! \retval ::NVAPI_NO_IMPLEMENTATION This entrypoint not available. +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION The version of the structure passed in is not +//! compatible with this entry point. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred. +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_GetOverlapLimits(NV_MOSAIC_TOPO_BRIEF *pTopoBrief, NV_MOSAIC_DISPLAY_SETTING *pDisplaySetting, NvS32 *pMinOverlapX, NvS32 *pMaxOverlapX, NvS32 *pMinOverlapY, NvS32 *pMaxOverlapY); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_SetCurrentTopo +// +//! DESCRIPTION: This API sets the Mosaic topology and performs a mode switch +//! using the given display settings. +//! +//! If NVAPI_OK is returned, the current Mosaic topology was set +//! correctly. Any other status returned means the +//! topology was not set, and remains what it was before this +//! function was called. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [in] pTopoBrief The topology to set. This must be one of the topologies returned from +//! NvAPI_Mosaic_GetSupportedTopoInfo(), and it must have an isPossible value of 1. +//! \param [in] pDisplaySetting The per display settings to be used in the Mosaic mode. This must be one of the +//! settings returned from NvAPI_Mosaic_GetSupportedTopoInfo(). +//! \param [in] overlapX The pixel overlap to use between horizontal displays (use positive a number for +//! overlap, or a negative number to create a gap.) If the overlap is out of bounds +//! for what is possible given the topo and display setting, the overlap will be clamped. +//! \param [in] overlapY The pixel overlap to use between vertical displays (use positive a number for +//! overlap, or a negative number to create a gap.) If the overlap is out of bounds for +//! what is possible given the topo and display setting, the overlap will be clamped. +//! \param [in] enable If 1, the topology being set will also be enabled, meaning that the mode set will +//! occur. \n +//! If 0, you don't want to be in Mosaic mode right now, but want to set the current +//! Mosaic topology so you can enable it later with NvAPI_Mosaic_EnableCurrentTopo(). +//! +//! \retval ::NVAPI_OK The Mosaic topology was set. +//! \retval ::NVAPI_NOT_SUPPORTED Mosaic is not supported with the existing hardware. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more argumentss passed in are invalid. +//! \retval ::NVAPI_TOPO_NOT_POSSIBLE The topology passed in is not currently possible. +//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first. +//! \retval ::NVAPI_NO_IMPLEMENTATION This entrypoint not available. +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION The version of the structure passed in is not +//! compatible with this entrypoint. +//! \retval ::NVAPI_MODE_CHANGE_FAILED There was an error changing the display mode. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred. +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_SetCurrentTopo(NV_MOSAIC_TOPO_BRIEF *pTopoBrief, NV_MOSAIC_DISPLAY_SETTING *pDisplaySetting, NvS32 overlapX, NvS32 overlapY, NvU32 enable); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_GetCurrentTopo +// +//! DESCRIPTION: This API returns information for the current Mosaic topology. +//! This includes topology, display settings, and overlap values. +//! +//! You can call NvAPI_Mosaic_GetTopoGroup() with the topology +//! if you require more information. +//! +//! If there isn't a current topology, then pTopoBrief->topo will +//! be NV_MOSAIC_TOPO_NONE. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [out] pTopoBrief The current Mosaic topology +//! \param [out] pDisplaySetting The current per-display settings +//! \param [out] pOverlapX The pixel overlap between horizontal displays +//! \param [out] pOverlapY The pixel overlap between vertical displays +//! +//! \retval ::NVAPI_OK Success getting current info. +//! \retval ::NVAPI_NOT_SUPPORTED Mosaic is not supported with the existing hardware. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more argumentss passed in are invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first. +//! \retval ::NVAPI_NO_IMPLEMENTATION This entry point not available. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred. +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_GetCurrentTopo(NV_MOSAIC_TOPO_BRIEF *pTopoBrief, NV_MOSAIC_DISPLAY_SETTING *pDisplaySetting, NvS32 *pOverlapX, NvS32 *pOverlapY); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_EnableCurrentTopo +// +//! DESCRIPTION: This API enables or disables the current Mosaic topology +//! based on the setting of the incoming 'enable' parameter. +//! +//! An "enable" setting enables the current (previously set) Mosaic topology. +//! Note that when the current Mosaic topology is retrieved, it must have an isPossible value of 1 or +//! an error will occur. +//! +//! A "disable" setting disables the current Mosaic topology. +//! The topology information will persist, even across reboots. +//! To re-enable the Mosaic topology, call this function +//! again with the enable parameter set to 1. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [in] enable 1 to enable the current Mosaic topo, 0 to disable it. +//! +//! \retval ::NVAPI_OK The Mosaic topo was enabled/disabled. +//! \retval ::NVAPI_NOT_SUPPORTED Mosaic is not supported with the existing hardware. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more arguments passed in are invalid. +//! \retval ::NVAPI_TOPO_NOT_POSSIBLE The current topology is not currently possible. +//! \retval ::NVAPI_MODE_CHANGE_FAILED There was an error changing the display mode. +//! \retval ::NVAPI_ERROR: Miscellaneous error occurred. +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_EnableCurrentTopo(NvU32 enable); + +//! \ingroup mosaicapi +//! @{ +typedef struct _NV_MOSAIC_GRID_TOPO_DISPLAY_V1 +{ + NvU32 displayId; //!< DisplayID of the display + NvS32 overlapX; //!< (+overlap, -gap) + NvS32 overlapY; //!< (+overlap, -gap) + NV_ROTATE rotation; //!< Rotation of display + NvU32 cloneGroup; //!< Reserved, must be 0 +} NV_MOSAIC_GRID_TOPO_DISPLAY_V1; + +typedef enum _NV_PIXEL_SHIFT_TYPE +{ + NV_PIXEL_SHIFT_TYPE_NO_PIXEL_SHIFT = 0, //!< No pixel shift will be applied to this display. + NV_PIXEL_SHIFT_TYPE_2x2_TOP_LEFT_PIXELS = 1, //!< This display will be used to scanout top left pixels in 2x2 PixelShift configuration + NV_PIXEL_SHIFT_TYPE_2x2_BOTTOM_RIGHT_PIXELS = 2, //!< This display will be used to scanout bottom right pixels in 2x2 PixelShift configuration + NV_PIXEL_SHIFT_TYPE_2x2_TOP_RIGHT_PIXELS = 4, //!< This display will be used to scanout top right pixels in 2x2 PixelShift configuration + NV_PIXEL_SHIFT_TYPE_2x2_BOTTOM_LEFT_PIXELS = 8, //!< This display will be used to scanout bottom left pixels in 2x2 PixelShift configuration +} NV_PIXEL_SHIFT_TYPE; + +typedef struct _NV_MOSAIC_GRID_TOPO_DISPLAY_V2 +{ + NvU32 version; //!< Version of this structure + + NvU32 displayId; //!< DisplayID of the display + NvS32 overlapX; //!< (+overlap, -gap) + NvS32 overlapY; //!< (+overlap, -gap) + NV_ROTATE rotation; //!< Rotation of display + NvU32 cloneGroup; //!< Reserved, must be 0 + NV_PIXEL_SHIFT_TYPE pixelShiftType; //!< Type of the pixel shift enabled display +} NV_MOSAIC_GRID_TOPO_DISPLAY_V2; + +#ifndef NV_MOSAIC_GRID_TOPO_DISPLAY_VER + +typedef NV_MOSAIC_GRID_TOPO_DISPLAY_V1 NV_MOSAIC_GRID_TOPO_DISPLAY; + +#endif + +typedef struct _NV_MOSAIC_GRID_TOPO_V1 +{ + NvU32 version; //!< Version of this structure + NvU32 rows; //!< Number of rows + NvU32 columns; //!< Number of columns + NvU32 displayCount; //!< Number of display details + NvU32 applyWithBezelCorrect : 1; //!< When enabling and doing the modeset, do we switch to the bezel-corrected resolution + NvU32 immersiveGaming : 1; //!< Enable as immersive gaming instead of Mosaic SLI (for Quadro-boards only) + NvU32 baseMosaic : 1; //!< Enable as Base Mosaic (Panoramic) instead of Mosaic SLI (for NVS and Quadro-boards only) + NvU32 driverReloadAllowed : 1; //!< If necessary, reloading the driver is permitted (for Vista and above only). Will not be persisted. Value undefined on get. + NvU32 acceleratePrimaryDisplay : 1; //!< Enable SLI acceleration on the primary display while in single-wide mode (For Immersive Gaming only). Will not be persisted. Value undefined on get. + NvU32 reserved : 27; //!< Reserved, must be 0 + NV_MOSAIC_GRID_TOPO_DISPLAY_V1 displays[NV_MOSAIC_MAX_DISPLAYS]; //!< Displays are done as [(row * columns) + column] + NV_MOSAIC_DISPLAY_SETTING_V1 displaySettings; //!< Display settings +} NV_MOSAIC_GRID_TOPO_V1; + +typedef struct _NV_MOSAIC_GRID_TOPO_V2 +{ + NvU32 version; //!< Version of this structure + NvU32 rows; //!< Number of rows + NvU32 columns; //!< Number of columns + NvU32 displayCount; //!< Number of display details + NvU32 applyWithBezelCorrect : 1; //!< When enabling and doing the modeset, do we switch to the bezel-corrected resolution + NvU32 immersiveGaming : 1; //!< Enable as immersive gaming instead of Mosaic SLI (for Quadro-boards only) + NvU32 baseMosaic : 1; //!< Enable as Base Mosaic (Panoramic) instead of Mosaic SLI (for NVS and Quadro-boards only) + NvU32 driverReloadAllowed : 1; //!< If necessary, reloading the driver is permitted (for Vista and above only). Will not be persisted. Value undefined on get. + NvU32 acceleratePrimaryDisplay : 1; //!< Enable SLI acceleration on the primary display while in single-wide mode (For Immersive Gaming only). Will not be persisted. Value undefined on get. + NvU32 pixelShift : 1; //!< Enable Pixel shift + NvU32 reserved : 26; //!< Reserved, must be 0 + NV_MOSAIC_GRID_TOPO_DISPLAY_V2 displays[NV_MOSAIC_MAX_DISPLAYS]; //!< Displays are done as [(row * columns) + column] + NV_MOSAIC_DISPLAY_SETTING_V1 displaySettings; //!< Display settings +} NV_MOSAIC_GRID_TOPO_V2; + +//! Macro for constructing the version field of ::NV_MOSAIC_GRID_TOPO +#define NV_MOSAIC_GRID_TOPO_VER1 MAKE_NVAPI_VERSION(NV_MOSAIC_GRID_TOPO_V1,1) +#define NV_MOSAIC_GRID_TOPO_VER2 MAKE_NVAPI_VERSION(NV_MOSAIC_GRID_TOPO_V2,2) +#ifndef NV_MOSAIC_GRID_TOPO_VER + +typedef NV_MOSAIC_GRID_TOPO_V2 NV_MOSAIC_GRID_TOPO; + +//! Macro for constructing the version field of ::NV_MOSAIC_GRID_TOPO +#define NV_MOSAIC_GRID_TOPO_VER NV_MOSAIC_GRID_TOPO_VER2 + +#endif + +//! @} + +//! since Release R290 + +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_DISPLAY_ON_INVALID_GPU NV_BIT(0) +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_DISPLAY_ON_WRONG_CONNECTOR NV_BIT(1) +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_NO_COMMON_TIMINGS NV_BIT(2) +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_NO_EDID_AVAILABLE NV_BIT(3) +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_MISMATCHED_OUTPUT_TYPE NV_BIT(4) +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_NO_DISPLAY_CONNECTED NV_BIT(5) +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_NO_GPU_TOPOLOGY NV_BIT(6) +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_NOT_SUPPORTED NV_BIT(7) +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_NO_SLI_BRIDGE NV_BIT(8) +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_ECC_ENABLED NV_BIT(9) +#define NV_MOSAIC_DISPLAYCAPS_PROBLEM_GPU_TOPOLOGY_NOT_SUPPORTED NV_BIT(10) + + + + + + + +//! Do not change the current GPU topology. If the NO_DRIVER_RELOAD bit is not +//! specified, then it may still require a driver reload. +#define NV_MOSAIC_SETDISPLAYTOPO_FLAG_CURRENT_GPU_TOPOLOGY NV_BIT(0) + +//! Do not allow a driver reload. That is, stick with the same master GPU as well as the +//! same SLI configuration. +#define NV_MOSAIC_SETDISPLAYTOPO_FLAG_NO_DRIVER_RELOAD NV_BIT(1) + +//! When choosing a GPU topology, choose the topology with the best performance. +//! Without this flag, it will choose the topology that uses the smallest number +//! of GPU's. +#define NV_MOSAIC_SETDISPLAYTOPO_FLAG_MAXIMIZE_PERFORMANCE NV_BIT(2) + +//! Do not return an error if no configuration will work with all of the grids. +#define NV_MOSAIC_SETDISPLAYTOPO_FLAG_ALLOW_INVALID NV_BIT(3) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_SetDisplayGrids +// +//! DESCRIPTION: Sets a new display topology, replacing any existing topologies +//! that use the same displays. +//! +//! This function will look for an SLI configuration that will +//! allow the display topology to work. +//! +//! To revert to a single display, specify that display as a 1x1 +//! grid. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pGridTopologies The topology details to set. +//! \param [in] gridCount The number of elements in the pGridTopologies array. +//! \param [in] setTopoFlags Zero or more of the NVAPI_MOSAIC_SETDISPLAYTOPO_FLAG_* +//! flags. +//! +//! +//! \retval ::NVAPI_OK Capabilities have been returned. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first +//! \retval ::NVAPI_NO_IMPLEMENTATION This entrypoint not available +//! \retval ::NVAPI_NO_ACTIVE_SLI_TOPOLOGY No matching GPU topologies could be found. +//! \retval ::NVAPI_TOPO_NOT_POSSIBLE One or more of the display grids are not valid. +//! \retval ::NVAPI_ERROR Miscellaneous error occurred +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_SetDisplayGrids(__in_ecount(gridCount) NV_MOSAIC_GRID_TOPO *pGridTopologies, __in NvU32 gridCount, __in NvU32 setTopoFlags); + + +//! \ingroup mosaicapi +//! Indicates that a display's position in the grid is sub-optimal. +#define NV_MOSAIC_DISPLAYTOPO_WARNING_DISPLAY_POSITION NV_BIT(0) + +//! \ingroup mosaicapi +//! Indicates that SetDisplaySettings would need to perform a driver reload. +#define NV_MOSAIC_DISPLAYTOPO_WARNING_DRIVER_RELOAD_REQUIRED NV_BIT(1) + +//! \ingroup mosaicapi +typedef struct +{ + NvU32 version; + NvU32 errorFlags; //!< (OUT) Any of the NV_MOSAIC_DISPLAYTOPO_ERROR_* flags. + NvU32 warningFlags; //!< (OUT) Any of the NV_MOSAIC_DISPLAYTOPO_WARNING_* flags. + + NvU32 displayCount; //!< (OUT) The number of valid entries in the displays array. + struct + { + NvU32 displayId; //!< (OUT) The DisplayID of this display. + NvU32 errorFlags; //!< (OUT) Any of the NV_MOSAIC_DISPLAYCAPS_PROBLEM_* flags. + NvU32 warningFlags; //!< (OUT) Any of the NV_MOSAIC_DISPLAYTOPO_WARNING_* flags. + + NvU32 supportsRotation : 1; //!< (OUT) This display can be rotated + NvU32 reserved : 31; //!< (OUT) reserved + } displays[NVAPI_MAX_DISPLAYS]; +} NV_MOSAIC_DISPLAY_TOPO_STATUS; + +//! \ingroup mosaicapi +#define NV_MOSAIC_DISPLAY_TOPO_STATUS_VER MAKE_NVAPI_VERSION(NV_MOSAIC_DISPLAY_TOPO_STATUS,1) + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_ValidateDisplayGrids +// +//! DESCRIPTION: Determines if a list of grid topologies is valid. It will choose an SLI +//! configuration in the same way that NvAPI_Mosaic_SetDisplayGrids() does. +//! +//! On return, each element in the pTopoStatus array will contain any errors or +//! warnings about each grid topology. If any error flags are set, then the topology +//! is not valid. If any warning flags are set, then the topology is valid, but +//! sub-optimal. +//! +//! If the ALLOW_INVALID flag is set, then it will continue to validate the grids +//! even if no SLI configuration will allow all of the grids. In this case, a grid +//! grid with no matching GPU topology will have the error +//! flags NO_GPU_TOPOLOGY or NOT_SUPPORTED set. +//! +//! If the ALLOW_INVALID flag is not set and no matching SLI configuration is +//! found, then it will skip the rest of the validation and return +//! NVAPI_NO_ACTIVE_SLI_TOPOLOGY. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] setTopoFlags Zero or more of the NVAPI_MOSAIC_SETDISPLAYTOPO_FLAG_* +//! flags. +//! \param [in] pGridTopologies The array of grid topologies to verify. +//! \param [in,out] pTopoStatus The array of problems and warnings with each grid topology. +//! \param [in] gridCount The number of elements in the pGridTopologies and +//! pTopoStatus arrays. +//! +//! +//! \retval ::NVAPI_OK: Capabilities have been returned. +//! \retval ::NVAPI_INVALID_ARGUMENT: One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED: The NvAPI API needs to be initialized first +//! \retval ::NVAPI_NO_IMPLEMENTATION: This entrypoint not available +//! \retval ::NVAPI_NO_ACTIVE_SLI_TOPOLOGY: No matching GPU topologies could be found. +//! \retval ::NVAPI_ERROR: Miscellaneous error occurred +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_ValidateDisplayGrids(__in NvU32 setTopoFlags, + __in_ecount(gridCount) NV_MOSAIC_GRID_TOPO *pGridTopologies, + __inout_ecount_full(gridCount) NV_MOSAIC_DISPLAY_TOPO_STATUS *pTopoStatus, + __in NvU32 gridCount); + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_EnumDisplayModes +// +//! DESCRIPTION: Determines the set of available display modes for a given grid topology. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pGridTopology The grid topology to use. +//! \param [in,out] pDisplaySettings A pointer to an array of display settings to populate, +//! or NULL to find out the total number of available modes. +//! \param [in,out] pDisplayCount If pDisplaySettings is not NULL, then pDisplayCount +//! should point to the number of elements in the +//! pDisplaySettings array. On return, it will contain the +//! number of modes that were actually returned. If +//! pDisplaySettings is NULL, then pDisplayCount will receive +//! the total number of modes that are available. +//! +//! +//! \retval ::NVAPI_OK Capabilities have been returned. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first +//! \retval ::NVAPI_NO_IMPLEMENTATION This entrypoint not available +//! \retval ::NVAPI_ERROR Miscellaneous error occurred +//! +//! \ingroup mosaciapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_EnumDisplayModes(__in NV_MOSAIC_GRID_TOPO *pGridTopology, + __inout_ecount_part_opt(*pDisplayCount, *pDisplayCount) NV_MOSAIC_DISPLAY_SETTING *pDisplaySettings, + __inout NvU32 *pDisplayCount); + + +//! SUPPORTED OS: Windows 7 and higher +//! +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_EnumDisplayGrids +// +//! DESCRIPTION: Enumerates the current active grid topologies. This includes Mosaic, IG, and +//! Panoramic topologies, as well as single displays. +//! +//! If pGridTopologies is NULL, then pGridCount will be set to the number of active +//! grid topologies. +//! +//! If pGridTopologies is not NULL, then pGridCount contains the maximum number of +//! grid topologies to return. On return, pGridCount will be set to the number of +//! grid topologies that were returned. +//! +//! \param [out] pGridTopologies The list of active grid topologies. +//! \param [in,out] pGridCount A pointer to the number of grid topologies returned. +//! +//! \retval ::NVAPI_OK Capabilties have been returned. +//! \retval ::NVAPI_END_ENUMERATION There are no more topologies to return. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first +//! \retval ::NVAPI_NO_IMPLEMENTATION This entrypoint not available +//! \retval ::NVAPI_ERROR Miscellaneous error occurred +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_EnumDisplayGrids(__inout_ecount_part_opt(*pGridCount, *pGridCount) NV_MOSAIC_GRID_TOPO *pGridTopologies, + __inout NvU32 *pGridCount); + + +//////////////////////////////////////////////////////////////////////////////////////// +// +// ########################################################################### +// DELME_RUSS - DELME_RUSS - DELME_RUSS - DELME_RUSS - DELME_RUSS - DELME_RUSS +// +// Below is the Phase 1 Mosaic stuff, the Phase 2 stuff above is what will remain +// once Phase 2 is complete. For a small amount of time, the two will co-exist. As +// soon as apps (nvapichk, NvAPITestMosaic, and CPL) are updated to use the Phase 2 +// entrypoints, the code below will be deleted. +// +// DELME_RUSS - DELME_RUSS - DELME_RUSS - DELME_RUSS - DELME_RUSS - DELME_RUSS +// ########################################################################### +// +// Supported topos 1x4, 4x1 and 2x2 to start with. +// +// Selected scan out targets can be one per GPU or more than one on the same GPU. +// +// SAMPLE of MOSAIC 1x4 SCAN OUT TOPO with 8 pixel horizontal overlap +// +//+-------------------------++-------------------------++-------------------------++-------------------------+ +//| || || || | +//| || || || | +//| || || || | +//| DVI1 || DVI2 || DVI3 || DVI4 | +//| || || || | +//| || || || | +//| || || || | +//| || || || | +//+-------------------------++-------------------------++-------------------------++-------------------------+ + + +//! \addtogroup mosaicapi +//! @{ + +//! Used in NV_MOSAIC_TOPOLOGY. +#define NVAPI_MAX_MOSAIC_DISPLAY_ROWS 8 + +//! Used in NV_MOSAIC_TOPOLOGY. +#define NVAPI_MAX_MOSAIC_DISPLAY_COLUMNS 8 + +//! Used in NV_MOSAIC_TOPOLOGY. +#define NVAPI_MAX_MOSAIC_TOPOS 16 + +//! Used in NvAPI_GetCurrentMosaicTopology() and NvAPI_SetCurrentMosaicTopology(). +typedef struct +{ + NvU32 version; //!< Version number of the mosaic topology + NvU32 rowCount; //!< Horizontal display count + NvU32 colCount; //!< Vertical display count + + struct + { + NvPhysicalGpuHandle hPhysicalGPU; //!< Physical GPU to be used in the topology + NvU32 displayOutputId; //!< Connected display target + NvS32 overlapX; //!< Pixels of overlap on the left of target: (+overlap, -gap) + NvS32 overlapY; //!< Pixels of overlap on the top of target: (+overlap, -gap) + + } gpuLayout[NVAPI_MAX_MOSAIC_DISPLAY_ROWS][NVAPI_MAX_MOSAIC_DISPLAY_COLUMNS]; + +} NV_MOSAIC_TOPOLOGY; + +//! Used in NV_MOSAIC_TOPOLOGY. +#define NVAPI_MOSAIC_TOPOLOGY_VER MAKE_NVAPI_VERSION(NV_MOSAIC_TOPOLOGY,1) + +//! Used in NvAPI_GetSupportedMosaicTopologies(). +typedef struct +{ + NvU32 version; + NvU32 totalCount; //!< Count of valid topologies + NV_MOSAIC_TOPOLOGY topos[NVAPI_MAX_MOSAIC_TOPOS]; //!< Maximum number of topologies + +} NV_MOSAIC_SUPPORTED_TOPOLOGIES; + +//! Used in NV_MOSAIC_SUPPORTED_TOPOLOGIES. +#define NVAPI_MOSAIC_SUPPORTED_TOPOLOGIES_VER MAKE_NVAPI_VERSION(NV_MOSAIC_SUPPORTED_TOPOLOGIES,1) + +//!@} + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetSupportedMosaicTopologies +// +//! DESCRIPTION: This API returns all valid Mosaic topologies. +//! +//! SUPPORTED OS: Windows XP +//! +//! +//! \since Release: 177 +//! +//! \param [out] pMosaicTopos An array of valid Mosaic topologies. +//! +//! \retval NVAPI_OK Call succeeded; 1 or more topologies were returned +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid +//! \retval NVAPI_MIXED_TARGET_TYPES Mosaic topology is only possible with all targets of the same NV_GPU_OUTPUT_TYPE. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_NOT_SUPPORTED Mosaic is not supported with GPUs on this system. +//! \retval NVAPI_NO_ACTIVE_SLI_TOPOLOGY SLI is not enabled, yet needs to be, in order for this function to succeed. +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetSupportedMosaicTopologies(NV_MOSAIC_SUPPORTED_TOPOLOGIES *pMosaicTopos); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetCurrentMosaicTopology +// +//! DESCRIPTION: This API gets the current Mosaic topology. +//! +//! SUPPORTED OS: Windows XP +//! +//! +//! \since Release: 177 +//! +//! \param [out] pMosaicTopo The current Mosaic topology +//! \param [out] pEnabled TRUE if returned topology is currently enabled, else FALSE +//! +//! \retval NVAPI_OK Call succeeded +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_NOT_SUPPORTED Mosaic is not supported with GPUs on this system. +//! \retval NVAPI_NO_ACTIVE_SLI_TOPOLOGY SLI is not enabled, yet needs to be, in order for this function to succeed. +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GetCurrentMosaicTopology(NV_MOSAIC_TOPOLOGY *pMosaicTopo, NvU32 *pEnabled); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_SetCurrentMosaicTopology +// +//! DESCRIPTION: This API sets the Mosaic topology, and enables it so that the +//! Mosaic display settings are enumerated upon request. +//! +//! SUPPORTED OS: Windows XP +//! +//! +//! \since Release: 177 +//! +//! \param [in] pMosaicTopo A valid Mosaic topology +//! +//! \retval NVAPI_OK Call succeeded +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_NOT_SUPPORTED Mosaic is not supported with GPUs on this system. +//! \retval NVAPI_NO_ACTIVE_SLI_TOPOLOGY SLI is not enabled, yet needs to be, in order for this function to succeed. +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_SetCurrentMosaicTopology(NV_MOSAIC_TOPOLOGY *pMosaicTopo); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_EnableCurrentMosaicTopology +// +//! DESCRIPTION: This API enables or disables the current Mosaic topology. +//! When enabling, the last Mosaic topology will be set. +//! +//! - If enabled, enumeration of display settings will include valid Mosaic resolutions. +//! - If disabled, enumeration of display settings will not include Mosaic resolutions. +//! +//! SUPPORTED OS: Windows XP +//! +//! +//! \since Release: 177 +//! +//! \param [in] enable TRUE to enable the Mosaic Topology, FALSE to disable it. +//! +//! \retval NVAPI_OK Call succeeded +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \retval NVAPI_NOT_SUPPORTED Mosaic is not supported with GPUs on this system. +//! \retval NVAPI_NO_ACTIVE_SLI_TOPOLOGY SLI is not enabled, yet needs to be, in order for this function to succeed. +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_EnableCurrentMosaicTopology(NvU32 enable); + + +#define NVAPI_MAX_GSYNC_DEVICES 4 + + +// Sync Display APIs + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GSync_EnumSyncDevices +// +//! DESCRIPTION: This API returns an array of Sync device handles. A Sync device handle represents a +//! single Sync device on the system. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! \param [out] nvGSyncHandles- The caller provides an array of handles, which must contain at least +//! NVAPI_MAX_GSYNC_DEVICES elements. The API will zero out the entire array and then fill in one +//! or more handles. If an error occurs, the array is invalid. +//! \param [out] *gsyncCount- The caller provides the storage space. NvAPI_GSync_EnumSyncDevices +//! sets *gsyncCount to indicate how many of the elements in the nvGSyncHandles[] array are valid. +//! If an error occurs, *gsyncCount will be set to zero. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval ::NVAPI_INVALID_ARGUMENT nvGSyncHandles or gsyncCount is NULL. +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND The queried Graphics system does not have any Sync Device. +//! +//! \ingroup gsyncapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GSync_EnumSyncDevices(__out NvGSyncDeviceHandle nvGSyncHandles[NVAPI_MAX_GSYNC_DEVICES], __out NvU32 *gsyncCount); + + +// GSync boardId values +#define NVAPI_GSYNC_BOARD_ID_P358 856 //!< GSync board ID 0x358, see NV_GSYNC_CAPABILITIES +#define NVAPI_GSYNC_BOARD_ID_P2060 8288 //!< GSync board ID 0x2060, see NV_GSYNC_CAPABILITIES + +//! \since Release: 375 +#define NVAPI_GSYNC_BOARD_ID_P2061 8289 //!< GSync board ID 0x2061, see NV_GSYNC_CAPABILITIES + + +//! Used in NvAPI_GSync_QueryCapabilities(). +typedef struct _NV_GSYNC_CAPABILITIES_V1 +{ + NvU32 version; //!< Version of the structure + NvU32 boardId; //!< Board ID + NvU32 revision; //!< FPGA Revision + NvU32 capFlags; //!< Capabilities of the Sync board. Reserved for future use +} NV_GSYNC_CAPABILITIES_V1; + +typedef struct _NV_GSYNC_CAPABILITIES_V2 +{ + NvU32 version; //!< Version of the structure + NvU32 boardId; //!< Board ID + NvU32 revision; //!< FPGA major revision + NvU32 capFlags; //!< Capabilities of the Sync board. Reserved for future use + NvU32 extendedRevision; //!< FPGA minor revision +} NV_GSYNC_CAPABILITIES_V2; + +typedef NV_GSYNC_CAPABILITIES_V2 NV_GSYNC_CAPABILITIES; + + +//! \ingroup gsyncapi +//! Macro for constructing the version field of NV_GSYNC_CAPABILITIES. +#define NV_GSYNC_CAPABILITIES_VER1 MAKE_NVAPI_VERSION(NV_GSYNC_CAPABILITIES_V1,1) +#define NV_GSYNC_CAPABILITIES_VER2 MAKE_NVAPI_VERSION(NV_GSYNC_CAPABILITIES_V2,2) +#define NV_GSYNC_CAPABILITIES_VER NV_GSYNC_CAPABILITIES_VER2 + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GSync_QueryCapabilities +// +//! DESCRIPTION: This API returns the capabilities of the Sync device. +//! +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! \param [in] hNvGSyncDevice- The handle for a Sync device for which the capabilities will be queried. +//! \param [inout] *pNvGSyncCapabilities- The caller provides the storage space. NvAPI_GSync_QueryCapabilities() sets +//! *pNvGSyncCapabilities to the version and capabilities details of the Sync device +//! If an error occurs, *pNvGSyncCapabilities will be set to NULL. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval ::NVAPI_INVALID_ARGUMENT hNvGSyncDevice is NULL. +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND The queried Graphics system does not have any Sync Device. +//! +//! \ingroup gsyncapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GSync_QueryCapabilities(__in NvGSyncDeviceHandle hNvGSyncDevice, __inout NV_GSYNC_CAPABILITIES *pNvGSyncCapabilities); + + + +//! Connector values for a GPU. Used in NV_GSYNC_GPU. +typedef enum _NVAPI_GSYNC_GPU_TOPOLOGY_CONNECTOR +{ + NVAPI_GSYNC_GPU_TOPOLOGY_CONNECTOR_NONE = 0, + NVAPI_GSYNC_GPU_TOPOLOGY_CONNECTOR_PRIMARY = 1, + NVAPI_GSYNC_GPU_TOPOLOGY_CONNECTOR_SECONDARY = 2, + NVAPI_GSYNC_GPU_TOPOLOGY_CONNECTOR_TERTIARY = 3, + NVAPI_GSYNC_GPU_TOPOLOGY_CONNECTOR_QUARTERNARY = 4, +} NVAPI_GSYNC_GPU_TOPOLOGY_CONNECTOR; + +//! Display sync states. Used in NV_GSYNC_DISPLAY. +typedef enum _NVAPI_GSYNC_DISPLAY_SYNC_STATE +{ + NVAPI_GSYNC_DISPLAY_SYNC_STATE_UNSYNCED = 0, + NVAPI_GSYNC_DISPLAY_SYNC_STATE_SLAVE = 1, + NVAPI_GSYNC_DISPLAY_SYNC_STATE_MASTER = 2, +} NVAPI_GSYNC_DISPLAY_SYNC_STATE; + +typedef struct _NV_GSYNC_GPU +{ + NvU32 version; //!< Version of the structure + NvPhysicalGpuHandle hPhysicalGpu; //!< GPU handle + NVAPI_GSYNC_GPU_TOPOLOGY_CONNECTOR connector; //!< Indicates which connector on the device the GPU is connected to. + NvPhysicalGpuHandle hProxyPhysicalGpu; //!< GPU through which hPhysicalGpu is connected to the Sync device (if not directly connected) + //!< - this is NULL otherwise + NvU32 isSynced : 1; //!< Whether this GPU is sync'd or not. + NvU32 reserved : 31; //!< Should be set to ZERO +} NV_GSYNC_GPU; + +typedef struct _NV_GSYNC_DISPLAY +{ + NvU32 version; //!< Version of the structure + NvU32 displayId; //!< display identifier for displays.The GPU to which it is connected, can be retireved from NvAPI_SYS_GetPhysicalGpuFromDisplayId + NvU32 isMasterable : 1; //!< Can this display be the master? (Read only) + NvU32 reserved : 31; //!< Should be set to ZERO + NVAPI_GSYNC_DISPLAY_SYNC_STATE syncState; //!< Is this display slave/master + //!< (Retrieved with topology or set by caller for enable/disable sync) +} NV_GSYNC_DISPLAY; + +#define NV_GSYNC_DISPLAY_VER MAKE_NVAPI_VERSION(NV_GSYNC_DISPLAY,1) +#define NV_GSYNC_GPU_VER MAKE_NVAPI_VERSION(NV_GSYNC_GPU,1) + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GSync_GetTopology +// +//! DESCRIPTION: This API returns the topology for the specified Sync device. +//! +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! \param [in] hNvGSyncDevice- The caller provides the handle for a Sync device for which the topology will be queried. +//! \param [in, out] gsyncGpuCount- It returns number of GPUs connected to Sync device +//! \param [in, out] gsyncGPUs- It returns info about GPUs connected to Sync device +//! \param [in, out] gsyncDisplayCount- It returns number of active displays that belongs to Sync device +//! \param [in, out] gsyncDisplays- It returns info about all active displays that belongs to Sync device +//! +//! HOW TO USE: 1) make a call to get the number of GPUs connected OR displays synced through Sync device +//! by passing the gsyncGPUs OR gsyncDisplays as NULL respectively. Both gsyncGpuCount and gsyncDisplayCount can be retrieved in same call by passing +//! both gsyncGPUs and gsyncDisplays as NULL +//! On call success: +//! 2) Allocate memory based on gsyncGpuCount(for gsyncGPUs) and/or gsyncDisplayCount(for gsyncDisplays) then make a call to populate gsyncGPUs and/or gsyncDisplays respectively. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval ::NVAPI_INVALID_ARGUMENT hNvGSyncDevice is NULL. +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND The queried Graphics system does not have any Sync Device. +//! \retval ::NVAPI_INSUFFICIENT_BUFFER When the actual number of GPUs/displays in the topology exceed the number of elements allocated for SyncGPUs/SyncDisplays respectively. +//! +//! \ingroup gsyncapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GSync_GetTopology(__in NvGSyncDeviceHandle hNvGSyncDevice, __inout_opt NvU32 *gsyncGpuCount, __inout_ecount_part_opt(*gsyncGpuCount, *gsyncGpuCount) NV_GSYNC_GPU *gsyncGPUs, + __inout_opt NvU32 *gsyncDisplayCount, __inout_ecount_part_opt(*gsyncDisplayCount, *gsyncDisplayCount) NV_GSYNC_DISPLAY *gsyncDisplays); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GSync_SetSyncStateSettings +// +//! DESCRIPTION: Sets a new sync state for the displays in system. +//! +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! \param [in] gsyncDisplayCount- The number of displays in gsyncDisplays. +//! \param [in] pGsyncDisplays- The caller provides the structure containing all displays that need to be synchronized in the system. +//! The displays that are not part of pGsyncDisplays, will be un-synchronized. +//! \param [in] flags- Reserved for future use. +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \retval ::NVAPI_INVALID_ARGUMENT If the display topology or count not valid. +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND The queried Graphics system does not have any Sync Device. +//! \retval ::NVAPI_INVALID_SYNC_TOPOLOGY 1.If any mosaic grid is partial. +//! 2.If timing(HVisible/VVisible/refreshRate) applied of any display is different. +//! 3.If There is a across GPU mosaic grid in system and that is not a part of pGsyncDisplays. +//! +//! \ingroup gsyncapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GSync_SetSyncStateSettings(__in NvU32 gsyncDisplayCount, __in_ecount(gsyncDisplayCount) NV_GSYNC_DISPLAY *pGsyncDisplays, __in NvU32 flags); + + +//! \ingroup gsyncapi + +//! Source signal edge to be used for output pulse. See NV_GSYNC_CONTROL_PARAMS. +typedef enum _NVAPI_GSYNC_POLARITY +{ + NVAPI_GSYNC_POLARITY_RISING_EDGE = 0, + NVAPI_GSYNC_POLARITY_FALLING_EDGE = 1, + NVAPI_GSYNC_POLARITY_BOTH_EDGES = 2, +} NVAPI_GSYNC_POLARITY; + +//! Used in NV_GSYNC_CONTROL_PARAMS. +typedef enum _NVAPI_GSYNC_VIDEO_MODE +{ + NVAPI_GSYNC_VIDEO_MODE_NONE = 0, + NVAPI_GSYNC_VIDEO_MODE_TTL = 1, + NVAPI_GSYNC_VIDEO_MODE_NTSCPALSECAM = 2, + NVAPI_GSYNC_VIDEO_MODE_HDTV = 3, + NVAPI_GSYNC_VIDEO_MODE_COMPOSITE = 4, +} NVAPI_GSYNC_VIDEO_MODE; + +//! Used in NV_GSYNC_CONTROL_PARAMS. +typedef enum _NVAPI_GSYNC_SYNC_SOURCE +{ + NVAPI_GSYNC_SYNC_SOURCE_VSYNC = 0, + NVAPI_GSYNC_SYNC_SOURCE_HOUSESYNC = 1, +} NVAPI_GSYNC_SYNC_SOURCE; + +//! Used in NV_GSYNC_CONTROL_PARAMS. +typedef struct _NV_GSYNC_DELAY +{ + NvU32 version; //!< Version of the structure + NvU32 numLines; //!< delay to be induced in number of horizontal lines. + NvU32 numPixels; //!< delay to be induced in number of pixels. + NvU32 maxLines; //!< maximum number of lines supported at current display mode to induce delay. Updated by NvAPI_GSync_GetControlParameters(). Read only. + NvU32 minPixels; //!< minimum number of pixels required at current display mode to induce delay. Updated by NvAPI_GSync_GetControlParameters(). Read only. +} NV_GSYNC_DELAY; + +#define NV_GSYNC_DELAY_VER MAKE_NVAPI_VERSION(NV_GSYNC_DELAY,1) + +//! Used in NvAPI_GSync_GetControlParameters() and NvAPI_GSync_SetControlParameters(). +typedef struct _NV_GSYNC_CONTROL_PARAMS +{ + NvU32 version; //!< Version of the structure + NVAPI_GSYNC_POLARITY polarity; //!< Leading edge / Falling edge / both + NVAPI_GSYNC_VIDEO_MODE vmode; //!< None, TTL, NTSCPALSECAM, HDTV + NvU32 interval; //!< Number of pulses to wait between framelock signal generation + NVAPI_GSYNC_SYNC_SOURCE source; //!< VSync/House sync + NvU32 interlaceMode:1; //!< interlace mode for a Sync device + NvU32 syncSourceIsOutput:1; //!< Set this to make house sync as an output; valid only when NV_GSYNC_CONTROL_PARAMS::source is NVAPI_GSYNC_SYNC_SOURCE_VSYNC on P2061 boards. + //!< syncSourceIsOutput should always be NVAPI_GSYNC_SYNC_SOURCE_HOUSESYNC i.e. 0 on P2060 boards or when NV_GSYNC_CONTROL_PARAMS::source is set to NVAPI_GSYNC_SYNC_SOURCE_HOUSESYNC. + NvU32 reserved:30; //!< should be set zero + NV_GSYNC_DELAY syncSkew; //!< The time delay between the frame sync signal and the GPUs signal. + NV_GSYNC_DELAY startupDelay; //!< Sync start delay for master. +} NV_GSYNC_CONTROL_PARAMS; + +#define NV_GSYNC_CONTROL_PARAMS_VER MAKE_NVAPI_VERSION(NV_GSYNC_CONTROL_PARAMS,1) + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GSync_GetControlParameters +// +//! DESCRIPTION: This API queries for sync control parameters as defined in NV_GSYNC_CONTROL_PARAMS. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! \param [in] hNvGSyncDevice- The caller provides the handle of the Sync device for which to get parameters +//! \param [inout] *pGsyncControls- The caller provides the storage space. NvAPI_GSync_GetControlParameters() populates *pGsyncControls with values. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval ::NVAPI_INVALID_ARGUMENT hNvGSyncDevice is NULL. +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND The queried Graphics system does not have any Sync Device. +//! +//! \ingroup gsyncapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GSync_GetControlParameters(__in NvGSyncDeviceHandle hNvGSyncDevice, __inout NV_GSYNC_CONTROL_PARAMS *pGsyncControls); + + + +////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GSync_SetControlParameters +// +//! DESCRIPTION: This API sets control parameters as defined in NV_SYNC_CONTROL_PARAMS. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! \param [in] hNvGSyncDevice- The caller provides the handle of the Sync device for which to get parameters +//! \param [inout] *pGsyncControls- The caller provides NV_GSYNC_CONTROL_PARAMS. skew and startDelay will be updated to the applied values. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval ::NVAPI_INVALID_ARGUMENT hNvGSyncDevice is NULL. +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND The queried Graphics system does not have any Sync Device. +//! \retval ::NVAPI_SYNC_MASTER_NOT_FOUND Control Parameters can only be set if there is a Sync Master enabled on the Gsync card. +//! +//! \ingroup gsyncapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GSync_SetControlParameters(__in NvGSyncDeviceHandle hNvGSyncDevice, __inout NV_GSYNC_CONTROL_PARAMS *pGsyncControls); + + + + +//! Used in NvAPI_GSync_AdjustSyncDelay() +typedef enum _NVAPI_GSYNC_DELAY_TYPE +{ + NVAPI_GSYNC_DELAY_TYPE_UNKNOWN = 0, + NVAPI_GSYNC_DELAY_TYPE_SYNC_SKEW = 1, + NVAPI_GSYNC_DELAY_TYPE_STARTUP = 2 +} NVAPI_GSYNC_DELAY_TYPE; + +////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GSync_AdjustSyncDelay +// +//! DESCRIPTION: This API adjusts the skew and startDelay to the closest possible values. Use this API before calling NvAPI_GSync_SetControlParameters for skew or startDelay. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 319 +//! +//! \param [in] hNvGSyncDevice- The caller provides the handle of the Sync device for which to get parameters +//! \param [in] delayType- Specifies whether the delay is syncSkew or startupDelay. +//! \param [inout] *pGsyncDelay- The caller provides NV_GSYNC_DELAY. skew and startDelay will be adjusted and updated to the closest values. +//! \param [out] *syncSteps- This parameter is optional. It returns the sync delay in unit steps. If 0, it means either the NV_GSYNC_DELAY::numPixels is less than NV_GSYNC_DELAY::minPixels or NV_GSYNC_DELAY::numOfLines exceeds the NV_GSYNC_DELAY::maxLines. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup gsyncapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GSync_AdjustSyncDelay(__in NvGSyncDeviceHandle hNvGSyncDevice, __in NVAPI_GSYNC_DELAY_TYPE delayType, __inout NV_GSYNC_DELAY *pGsyncDelay, __out_opt NvU32* syncSteps); + + + +//! Used in NvAPI_GSync_GetSyncStatus(). +typedef struct _NV_GSYNC_STATUS +{ + NvU32 version; //!< Version of the structure + NvU32 bIsSynced; //!< Is timing in sync? + NvU32 bIsStereoSynced; //!< Does the phase of the timing signal from the GPU = the phase of the master sync signal? + NvU32 bIsSyncSignalAvailable; //!< Is the sync signal available? +} NV_GSYNC_STATUS; + +//! Macro for constructing the version field for NV_GSYNC_STATUS. +#define NV_GSYNC_STATUS_VER MAKE_NVAPI_VERSION(NV_GSYNC_STATUS,1) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GSync_GetSyncStatus +// +//! DESCRIPTION: This API queries the sync status of a GPU - timing, stereosync and sync signal availability. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! \param [in] hNvGSyncDevice- Handle of the Sync device +//! \param [in] hPhysicalGpu- GPU to be queried for sync status. +//! \param [out] *status- The caller provides the storage space. NvAPI_GSync_GetSyncStatus() populates *status with +//! values - timing, stereosync and signal availability. On error, *status is set to NULL. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval ::NVAPI_INVALID_ARGUMENT hNvGSyncDevice is NULL / SyncTarget is NULL. +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND The queried Graphics system does not have any G-Sync Device. +//! +//! \ingroup gsyncapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GSync_GetSyncStatus(__in NvGSyncDeviceHandle hNvGSyncDevice, __in NvPhysicalGpuHandle hPhysicalGpu, __inout NV_GSYNC_STATUS *status); + + +//! \ingroup gsyncapi + +#define NVAPI_MAX_RJ45_PER_GSYNC 2 + +//! Used in NV_GSYNC_STATUS_PARAMS. +typedef enum _NVAPI_GSYNC_RJ45_IO +{ + NVAPI_GSYNC_RJ45_OUTPUT = 0, + NVAPI_GSYNC_RJ45_INPUT = 1, + NVAPI_GSYNC_RJ45_UNUSED = 2 //!< This field is used to notify that the framelock is not actually present. + +} NVAPI_GSYNC_RJ45_IO; + +//! \ingroup gsyncapi +//! Used in NvAPI_GSync_GetStatusParameters(). +typedef struct _NV_GSYNC_STATUS_PARAMS_V1 +{ + NvU32 version; + NvU32 refreshRate; //!< The refresh rate + NVAPI_GSYNC_RJ45_IO RJ45_IO[NVAPI_MAX_RJ45_PER_GSYNC]; //!< Configured as input / output + NvU32 RJ45_Ethernet[NVAPI_MAX_RJ45_PER_GSYNC]; //!< Connected to ethernet hub? [ERRONEOUSLY CONNECTED!] + NvU32 houseSyncIncoming; //!< Incoming house sync frequency in Hz + NvU32 bHouseSync; //!< Is house sync connected? +} NV_GSYNC_STATUS_PARAMS_V1; + +typedef struct _NV_GSYNC_STATUS_PARAMS_V2 +{ + NvU32 version; + NvU32 refreshRate; //!< The refresh rate + NVAPI_GSYNC_RJ45_IO RJ45_IO[NVAPI_MAX_RJ45_PER_GSYNC]; //!< Configured as input / output + NvU32 RJ45_Ethernet[NVAPI_MAX_RJ45_PER_GSYNC]; //!< Connected to ethernet hub? [ERRONEOUSLY CONNECTED!] + NvU32 houseSyncIncoming; //!< Incoming house sync frequency in Hz + NvU32 bHouseSync; //!< Is house sync connected? + NvU32 bInternalSlave : 1; //!< Valid only for P2061 board. + //!< If set to 1, it means that this P2061 board receives input from another P2061 board. + NvU32 reserved : 31; //!< Reserved for future use. +} NV_GSYNC_STATUS_PARAMS_V2; + + +typedef NV_GSYNC_STATUS_PARAMS_V2 NV_GSYNC_STATUS_PARAMS; + +//! \ingroup gsyncapi +//! Macro for constructing the version field of NV_GSYNC_STATUS_PARAMS +#define NV_GSYNC_STATUS_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_GSYNC_STATUS_PARAMS_V1,1) +#define NV_GSYNC_STATUS_PARAMS_VER2 MAKE_NVAPI_VERSION(NV_GSYNC_STATUS_PARAMS_V2,2) +#define NV_GSYNC_STATUS_PARAMS_VER NV_GSYNC_STATUS_PARAMS_VER2 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GSync_GetStatusParameters +// +//! DESCRIPTION: This API queries for sync status parameters as defined in NV_GSYNC_STATUS_PARAMS. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 313 +//! +//! \param [in] hNvGSyncDevice The caller provides the handle of the GSync device for which to get parameters +//! \param [out] *pStatusParams The caller provides the storage space. NvAPI_GSync_GetStatusParameters populates *pStatusParams with +//! values. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval ::NVAPI_INVALID_ARGUMENT hNvGSyncDevice is NULL / pStatusParams is NULL. +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND The queried Graphics system does not have any GSync Device. +//! +//! \ingroup gsyncapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GSync_GetStatusParameters(NvGSyncDeviceHandle hNvGSyncDevice, NV_GSYNC_STATUS_PARAMS *pStatusParams); + +//! @} + + + + + + + + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_RegisterResource +// +//! DESCRIPTION: This API binds a resource (surface/texture) so that it can be retrieved +//! internally by NVAPI. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! \param [in] pResource surface/texture +//! +//! \return ::NVAPI_OK, ::NVAPI_ERROR +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_RegisterResource(IDirect3DResource9* pResource); +#endif //defined(_D3D9_H_) + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_UnregisterResource +// +//! DESCRIPTION: This API unbinds a resource (surface/texture) after use. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pResource surface/texture +//! +//! \return ::NVAPI_OK, ::NVAPI_ERROR +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_UnregisterResource(IDirect3DResource9* pResource); + +#endif //defined(_D3D9_H_) + + + + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_AliasSurfaceAsTexture +// +//! \fn NvAPI_D3D9_AliasSurfaceAsTexture(IDirect3DDevice9* pDev, +//! IDirect3DSurface9* pSurface, +//! IDirect3DTexture9 **ppTexture, +//! DWORD dwFlag); +//! DESCRIPTION: Create a texture that is an alias of a surface registered with NvAPI. The +//! new texture can be bound with IDirect3DDevice9::SetTexture(). Note that the texture must +//! be unbound before drawing to the surface again. +//! Unless the USE_SUPER flag is passed, MSAA surfaces will be resolved before +//! being used as a texture. MSAA depth buffers are resolved with a point filter, +//! and non-depth MSAA surfaces are resolved with a linear filter. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDev The D3D device that owns the objects +//! \param [in] pSurface Pointer to a surface that has been registered with NvAPI +//! to which a texture alias is to be provided +//! \param [out] ppTexture Fill with the texture created +//! \param [in] dwFlag NVAPI_ALIAS_SURFACE_FLAG to describe how to handle the texture +//! +//! \retval ::NVAPI_OK completed request +//! \retval ::NVAPI_INVALID_POINTER A null pointer was passed as an argument +//! \retval ::NVAPI_INVALID_ARGUMENT One of the arguments was invalid, probably dwFlag. +//! \retval ::NVAPI_UNREGISTERED_RESOURCE pSurface has not been registered with NvAPI +//! \retval ::NVAPI_ERROR error occurred +// +/////////////////////////////////////////////////////////////////////////////// + + +//! \ingroup dx +//! See NvAPI_D3D9_AliasSurfaceAsTexture(). +typedef enum { + NVAPI_ALIAS_SURFACE_FLAG_NONE = 0x00000000, + NVAPI_ALIAS_SURFACE_FLAG_USE_SUPER = 0x00000001, //!< Use the surface's msaa buffer directly as a texture, rather than resolving. (This is much slower, but potentially has higher quality.) + NVAPI_ALIAS_SURFACE_FLAG_MASK = 0x00000001 +} NVAPI_ALIAS_SURFACE_FLAG; + + +//! \ingroup dx +NVAPI_INTERFACE NvAPI_D3D9_AliasSurfaceAsTexture(IDirect3DDevice9* pDev, + IDirect3DSurface9* pSurface, + IDirect3DTexture9 **ppTexture, + DWORD dwFlag); +#endif //defined(_D3D9_H_) + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_StretchRectEx +// +//! DESCRIPTION: This API copies the contents of the source resource to the destination +//! resource. This function can convert +//! between a wider range of surfaces than +//! IDirect3DDevice9::StretchRect. For example, it can copy +//! from a depth/stencil surface to a texture. +//! +//! The source and destination resources *must* be registered +//! with NvAPI before being used with NvAPI_D3D9_StretchRectEx(). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDevice The D3D device that owns the objects. +//! \param [in] pSourceResource Pointer to the source resource. +//! \param [in] pSrcRect Defines the rectangle on the source to copy from. If NULL, copy from the entire resource. +//! \param [in] pDestResource Pointer to the destination resource. +//! \param [in] pDstRect Defines the rectangle on the destination to copy to. If NULL, copy to the entire resource. +//! \param [in] Filter Choose a filtering method: D3DTEXF_NONE, D3DTEXF_POINT, D3DTEXF_LINEAR. +//! +//! \retval ::NVAPI_OK completed request +//! \retval ::NVAPI_INVALID_POINTER An invalid pointer was passed as an argument (probably NULL) +//! \retval ::NVAPI_INVALID_ARGUMENT One of the arguments was invalid +//! \retval ::NVAPI_UNREGISTERED_RESOURCE a resource was passed in without being registered +//! \retval ::NVAPI_ERROR error occurred +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_StretchRectEx(IDirect3DDevice9 * pDevice, + IDirect3DResource9 * pSourceResource, + CONST RECT * pSourceRect, + IDirect3DResource9 * pDestResource, + CONST RECT * pDestRect, + D3DTEXTUREFILTERTYPE Filter); + +#endif //defined(_D3D9_H_) + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_ClearRT +// +//! DESCRIPTION: This API Clears the currently bound render target(s) with the +//! given color +//! +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDevice The D3D device that owns the objects. +//! \param [in] dwNumRects The no of rectangles to clear. If 0, clear the entire surface (clipped to viewport) +//! \param [in] pRects Defines the rectangles to clear. Should be NULL if dwNumRects == 0 +//! \param [in] r red component of the clear color +//! \param [in] g green component of the clear color +//! \param [in] b blue component of the clear color +//! \param [in] a alpha component of the clear color +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_ClearRT(IDirect3DDevice9 * pDevice, + NvU32 dwNumRects, + CONST RECT * pRects, + float r, float g, float b, float a); +#endif //if defined(_D3D9_H_) + + + + + + + + + + +#if defined(_D3D9_H_) && defined(__cplusplus) +//! SUPPORTED OS: Windows 7 and higher +//! + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_GetSurfaceHandle +// +//! This function gets the handle of a given surface. This handle uniquely +//! identifies the surface through all NvAPI entries. +//! +//! +//! \since Release: 313 +//! +//! \param [in] pSurface Surface to be identified +//! \param [out] pHandle Will be filled by the return handle +//! +//! \return An int which could be an NvAPI status or DX HRESULT code +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_GetSurfaceHandle(IDirect3DSurface9 *pSurface, + NVDX_ObjectHandle *pHandle); + +#endif //defined(_D3D9_H_) && defined(__cplusplus) + +#if defined(_D3D9_H_) && defined(__cplusplus) +//! SUPPORTED OS: Windows 7 and higher +//! +//! \addtogroup dxvidcontrol +//! @{ + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION_NAME: NvAPI_D3D9_VideoSetStereoInfo +// +//! \fn NvAPI_D3D9_VideoSetStereoInfo(IDirect3DDevice9 *pDev, +//! NV_DX_VIDEO_STEREO_INFO *pStereoInfo); +//! \code +//! DESCRIPTION: This api specifies the stereo format of a surface, so that the +//! surface could be used for stereo video processing or compositing. +//! In particular, this api could be used to link the left and right +//! views of a decoded picture. +//! +//! \since Release: 313 +//! +//! INPUT: pDev - The device on which the stereo surface will be used +//! pStereoInfo - The stereo format of the surface +//! +//! RETURN STATUS: an int which could be an NvAPI status or DX HRESULT code +//! \endcode +/////////////////////////////////////////////////////////////////////////////// + +#ifndef NV_STEREO_VIDEO_FORMAT_DEFINE +#define NV_STEREO_VIDEO_FORMAT_DEFINE + + +typedef enum _NV_STEREO_VIDEO_FORMAT +{ + NV_STEREO_VIDEO_FORMAT_NOT_STEREO = 0, + + NV_STEREO_VIDEO_FORMAT_SIDE_BY_SIDE_LR = 1, + NV_STEREO_VIDEO_FORMAT_SIDE_BY_SIDE_RL = 2, + NV_STEREO_VIDEO_FORMAT_TOP_BOTTOM_LR = 3, + NV_STEREO_VIDEO_FORMAT_TOP_BOTTOM_RL = 4, + NV_STEREO_VIDEO_FORMAT_ROW_INTERLEAVE_LR = 5, + NV_STEREO_VIDEO_FORMAT_ROW_INTERLEAVE_RL = 6, + NV_STEREO_VIDEO_FORMAT_TWO_FRAMES_LR = 7, + NV_STEREO_VIDEO_FORMAT_MONO_PLUS_OFFSET = 8, + + NV_STEREO_VIDEO_FORMAT_LAST = 9, +} NV_STEREO_VIDEO_FORMAT; + +#endif // NV_STEREO_VIDEO_FORMAT_DEFINE + + +typedef struct _NV_DX_VIDEO_STEREO_INFO { + NvU32 dwVersion; //!< Must be NV_DX_VIDEO_STEREO_INFO_VER + NVDX_ObjectHandle hSurface; //!< The surface whose stereo format is to be set + NVDX_ObjectHandle hLinkedSurface; //!< The linked surface (must be valid when eFormat==NV_STEREO_VIDEO_FORMAT_TWO_FRAMES_LR) + NV_STEREO_VIDEO_FORMAT eFormat; //!< Stereo format of the surface + NvS32 sViewOffset; //!< Signed offset of each view (positive offset indicating left view is shifted left) + BOOL bStereoEnable; //!< Whether stereo rendering should be enabled (if FALSE, only left view will be used) +} NV_DX_VIDEO_STEREO_INFO; + +//! Macro for constructing the version field of ::NV_DX_VIDEO_STEREO_INFO +#define NV_DX_VIDEO_STEREO_INFO_VER MAKE_NVAPI_VERSION(NV_DX_VIDEO_STEREO_INFO,1) + +NVAPI_INTERFACE NvAPI_D3D9_VideoSetStereoInfo(IDirect3DDevice9 *pDev, + NV_DX_VIDEO_STEREO_INFO *pStereoInfo); + +//! @} +#endif //defined(_D3D9_H_) && defined(__cplusplus) + + +#if defined(__cplusplus) && defined(__d3d10_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D10_SetDepthBoundsTest +// +//! DESCRIPTION: This function enables/disables the depth bounds test. +//! +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDev The device to set the depth bounds test +//! \param [in] bEnable Enable(non-zero)/disable(zero) the depth bounds test +//! \param [in] fMinDepth The minimum depth for the depth bounds test +//! \param [in] fMaxDepth The maximum depth for the depth bounds test \n +//! The valid values for fMinDepth and fMaxDepth +//! are such that 0 <= fMinDepth <= fMaxDepth <= 1 +//! +//! \return NVAPI_OK if the depth bounds test was correctly enabled or disabled +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D10_SetDepthBoundsTest(ID3D10Device *pDev, + NvU32 bEnable, + float fMinDepth, + float fMaxDepth); + +#endif //defined(__cplusplus) && defined(__d3d10_h__) + + + + + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_IsNvShaderExtnOpCodeSupported +// +//! DESCRIPTION: This function checks if a nv HLSL shader extension opcode is +//! supported on current hardware. List of opcodes is in nvShaderExtnEnums.h +//! To use Nvidia HLSL extensions the application must include nvHLSLExtns.h +//! in the hlsl shader code. See nvHLSLExtns.h for more details on supported opcodes. +//! +//! This function can be called from a different thread than the one calling immediate device setstate functions. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDev The device on which to query for support, +//! should be a ID3D11Device+ device +//! \param [in] opCode the opcode to check +//! \param [out] pSupported true if supported, false otherwise +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval :: NVAPI_OK if the call succeeded +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_IsNvShaderExtnOpCodeSupported(__in IUnknown *pDev, + __in NvU32 opCode, + __out bool *pSupported); + +#endif //defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_SetNvShaderExtnSlot +// +//! DESCRIPTION: This function sets the fake UAV slot that is used by Nvidia HLSL +//! shader extensions globally. All createShader calls made to the driver after +//! setting this slot would treat writes/reads to this UAV in a +//! different way. Applications are expected to bind null UAV to this slot. +//! The same slot is used for all shader stages. +//! To disable shader extensions the app need to set this uav slot to 0xFFFFFFFF. +//! To use Nvidia HLSL extensions the application must include nvHLSLExtns.h +//! in the hlsl shader code. See nvHLSLExtns.h for more details. +//! +//! This function can be called from a different thread than the one calling immediate device setstate functions. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDev The device for which to set the extension slot +//! should be a ID3D11Device+ device +//! \param [in] uavSlot the uav slot to use +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval :: NVAPI_OK : success, the uavSlot was set sucessfully +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_SetNvShaderExtnSlot(__in IUnknown *pDev, + __in NvU32 uavSlot); + +#endif //defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +#if defined (__cplusplus) && defined (__d3d12_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_SetNvShaderExtnSlotSpace +// +//! DESCRIPTION: This function is specifically created for ray tracing since we do not +//! currently support PSOs with DXR. +//! This function sets the device's fake UAV slot and space that is used by Nvidia HLSL +//! shader extensions globally. All state objects created by the driver after +//! setting this slot would treat writes/reads to this UAV in a +//! different way. Applications are expected to bind null UAV to this slot. +//! The same slot is used for all shader stages. +//! To disable shader extensions the app need to set this uav slot to 0xFFFFFFFF. +//! To use Nvidia HLSL extensions the application must include nvHLSLExtns.h +//! in the hlsl shader code. See nvHLSLExtns.h for more details. +//! +//! This function can be called from a different thread than the one calling immediate device setstate functions. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDev The device for which to set the extension slot +//! should be a ID3D12Device+ device +//! \param [in] uavSlot The uav slot to use +//! \param [in] uavSpace The uav space to use +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval :: NVAPI_OK : success, the uavSlot and uavSpace were set sucessfully +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_SetNvShaderExtnSlotSpace(__in IUnknown *pDev, + __in NvU32 uavSlot, + __in NvU32 uavSpace); + + /////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread +// +//! DESCRIPTION: This function is specifically created for ray tracing shaders since we do not +//! currently support PSOs with DXR. +//! This function sets the device's fake UAV slot that is used by Nvidia HLSL +//! shader extensions on local thread. All state objects created by the driver +//! on the same thread that call this function after setting this slot would treat writes/reads +//! to this UAV in a different way. +//! Applications are expected to bind null UAV to this slot. +//! The same slot is used for all shader stages for the device. +//! To disable shader extensions the app may set this uav slot to 0xFFFFFFFF. +//! To use Nvidia HLSL extensions the application must include nvHLSLExtns.h +//! in the hlsl shader code. See nvHLSLExtns.h for more details. +//! +//! This function can be called from a different thread than the one calling immediate device setstate functions. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! +//! \since Release: 387 +//! +//! \param [in] pDev The device for which to set the extension slot +//! should be a ID3D12Device+ device +//! \param [in] uavSlot the uav slot to use +//! \param [in] uavSpace the uav space to use +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval :: NVAPI_OK : success, the uavSlot and uavSpace were set sucessfully +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread(__in IUnknown *pDev, + __in NvU32 uavSlot, + __in NvU32 uavSpace); + +#endif //defined (__cplusplus) && defined (__d3d12_h__) + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_SetNvShaderExtnSlotLocalThread +// +//! DESCRIPTION: This function sets the fake UAV slot that is used by Nvidia HLSL +//! shader extensions on local thread. All createShader calls on the same thread +//! that calls this function after setting this slot would treat writes/reads +//! to this UAV in a different way. +//! Applications are expected to bind null UAV to this slot. +//! The same slot is used for all shader stages. +//! To disable shader extensions the app may set this uav slot to 0xFFFFFFFF. +//! To use Nvidia HLSL extensions the application must include nvHLSLExtns.h +//! in the hlsl shader code. See nvHLSLExtns.h for more details. +//! +//! This function can be called from a different thread than the one calling immediate device setstate functions. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 387 +//! +//! \param [in] pDev The device for which to set the extension slot +//! should be a ID3D11Device+ device +//! \param [in] uavSlot the uav slot to use +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval :: NVAPI_OK : success, the uavSlot was set sucessfully +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_SetNvShaderExtnSlotLocalThread(__in IUnknown *pDev, + __in NvU32 uavSlot); + +#endif //defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_BeginUAVOverlapEx +// +//! DESCRIPTION: Causes the driver to skip synchronization that is normally needed when accessing UAVs. +//! Applications must use this with caution otherwise this might cause data hazards when +//! multiple draw calls/compute shader launches are accessing same memory locations +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] *pDeviceOrContext pointer to D3D11 device, or D3D11 device context +//! \param [in] insertWFIFlags bit fields to indicate which WFI would be inserted (gfx / compute / both). +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +typedef enum _NVAPI_D3D11_INSERTWFI_FLAG +{ + NVAPI_D3D_BEGIN_UAV_OVERLAP_NO_WFI = 0x00000000, //!< no WFI + NVAPI_D3D_BEGIN_UAV_OVERLAP_GFX_WFI = 0x00000001, //!< (bit 0) force graphics WFI + NVAPI_D3D_BEGIN_UAV_OVERLAP_COMP_WFI = 0x00000002, //!< (bit 1) force compute WFI +} NVAPI_D3D11_INSERTWFI_FLAG; + +NVAPI_INTERFACE NvAPI_D3D11_BeginUAVOverlapEx(__in IUnknown *pDeviceOrContext, __in NvU32 insertWFIFlags); + +#endif //defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_BeginUAVOverlap +// +//! DESCRIPTION: Causes the driver to skip synchronization that is normally needed when accessing UAVs. +//! Applications must use this with caution otherwise this might cause data hazards when +//! multiple draw calls/compute shader launches are accessing same memory locations +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] *pDeviceOrContext pointer to D3D11 device, or D3D11 device context +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_BeginUAVOverlap(__in IUnknown *pDeviceOrContext); + +#endif //defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_EndUAVOverlap +// +//! DESCRIPTION: Re-enables driver synchronization between calls that access same UAVs +//! See NvAPI_D3D_BeginUAVOverlap for more details. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] *pDeviceOrContext pointer to D3D11 device, or D3D11 device context +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_EndUAVOverlap(__in IUnknown *pDeviceOrContext); + +#endif //defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +#if defined(__cplusplus) && defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_GetResourceHandle +// +//! \code +//! DESCRIPTION: This function retrieves a driver handle to a DX10 resource +//! +//! INPUT: pDev The device on which the resource was created +//! pResource The resource for which we want to retrieve a +//! driver handle. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! OUTPUT: phObject Pointer to an NvAPI handle to be populated +//! on success +//! +//! RETURN STATUS: NVAPI_OK if and only if phObject was populated with a valid +//! driver handle +//! \endcode +//! \ingroup nsightapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_GetResourceHandle(ID3D11Device *pDev, + ID3D11Resource* pResource, + NVDX_ObjectHandle* phObject); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + +#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_SetFPSIndicatorState +// +//! DESCRIPTION: Display an overlay that tracks the number of times the app presents per second, or, +//! the number of frames-per-second (FPS) +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] bool Whether or not to enable the fps indicator. +//! +//! \return ::NVAPI_OK, +//! ::NVAPI_ERROR +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_SetFPSIndicatorState(IUnknown *pDev, NvU8 doEnable); + +#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_Present +// +//! DESCRIPTION: This API presents the contents of the next buffer in the sequence of back buffers +//! owned by a IDirect3DDevice9 device. +//! This Present operation supports using a SwapGroup and SwapBarrier on the SwapChain +//! that owns the back buffer to be presented. +//! +//! NOTE: NvAPI_D3D9_Present is a wrapper of the method IDirect3DDevice9::Present which +//! additionally notifies the D3D driver of the SwapChain used by the runtime for +//! presentation, thus allowing the D3D driver to apply SwapGroup and SwapBarrier +//! functionality to that SwapChain. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDevice The IDirect3DDevice9 interface that is used to issue the Present, +//! using the following IDirect3DDevice9::Present input parameters +//! \param [in] pSwapChain Optional pointer to a IDirect3DSwapChain9 interface. If provided, the presentation is executed +//! using this interface (i.e. pSwapChain->Present()) for the given swapchain only. +//! If NULL, the presentation is executed on the device for all swapchains as in pDevice->Present() +//! \param [in] pSourceRect A pointer to a RECT structure containing the source rectangle. +//! If NULL, the entire source surface is presented. +//! \param [in] pDestRect A pointer to a RECT structure containing the destination rectangle, in window client coordinates. +//! If NULL, the entire client area is filled. +//! \param [in] hDestWindowOverride A pointer to a destination window whose client area is taken as the target for this presentation. +//! If this value is NULL, then the hWndDeviceWindow member of D3DPRESENT_PARAMTERS is taken. +//! \param [in] pDirtyRegion (IN) A pointer to a region to be presented. It must be NULL unless the swap chain was reated with +//! D3DSWAPEFFECT_COPY. If this value is non-NULL, the contained region is expressed in back buffer coordinates. +//! +//! \retval ::NVAPI_OK the Present operation was successfully executed +//! \retval ::NVAPI_D3D_DEVICE_LOST D3D device status is D3DERR_DEVICELOST or D3DERR_DEVICENOTRESET, the caller has to reset device +//! \retval ::NVAPI_DEVICE_BUSY the Present operation failed with an error other than D3DERR_DEVICELOST or D3DERR_DEVICENOTRESET +//! \retval ::NVAPI_ERROR the communication with the D3D driver failed, SwapGroup/SwapBarrier may not be possible. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//!\ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_Present(IDirect3DDevice9 *pDevice, + IDirect3DSwapChain9 *pSwapChain, + const RECT *pSourceRect, + const RECT *pDestRect, + HWND hDestWindowOverride, + const RGNDATA *pDirtyRegion); +#endif //if defined(_D3D9_H_) + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_QueryFrameCount +// +//! DESCRIPTION: This API queries the universal framecounter of the Quadro-Sync master device. +//! +//! \param [in] pDevice The caller provides the DX9 device that has access to the Quadro-Sync device +//! \param [out] pFrameCount The caller provides the storage space where the framecount is stored. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK *pFrameCount populated with framecount value. +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_QueryFrameCount(IDirect3DDevice9 *pDevice, + NvU32 *pFrameCount); +#endif //if defined(_D3D9_H_) + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_ResetFrameCount +// +//! DESCRIPTION: This API resets the universal framecounter on the Quadro-Sync master device. +//! +//! \param [in] pDevice The caller provides the DX9 device that has access to the Quadro-Sync device +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK framecounter has been reset +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_ResetFrameCount(IDirect3DDevice9 *pDevice); +#endif //if defined(_D3D9_H_) + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_QueryMaxSwapGroup +// +//! DESCRIPTION: This API queries the number of supported SwapGroups and SwapBarriers in the graphics system. +//! +//! \param [in] pDevice The caller provides the DirectX 9 device that is used as a swapgroup client +//! \param [out] pMaxGroups The caller provides the storage space where the number of available SwapGroups is stored. +//! \param [out] pMaxBarriers The caller provides the storage space where the number of available SwapBarriers is stored. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK the number of SwapGroups and SwapBarriers has been stored +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_QueryMaxSwapGroup(IDirect3DDevice9 *pDevice, + NvU32 *pMaxGroups, + NvU32 *pMaxBarriers); +#endif //if defined(_D3D9_H_) + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_QuerySwapGroup +// +//! DESCRIPTION: This API queries the current SwapGroup and SwapBarrier that a SwapChain of a specific client device is bound to. +//! +//! \param [in] pDevice The caller provides the DirectX 9 device that is used as a swapgroup client +//! \param [in] pSwapChain The caller provides the IDirect3DSwapChain9 interface as a handle to the SwapChain +//! that belongs to the swapgroup client device +//! \param [out] pSwapGroup The caller provides the storage space where the current SwapGroup is stored. +//! \param [out] pSwapBarrier The caller provides the storage space where the current SwapBarrier is stored. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK the current SwapGroup and SwapBarrier has been stored +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_QuerySwapGroup(IDirect3DDevice9 *pDevice, + IDirect3DSwapChain9 *pSwapChain, + NvU32 *pSwapGroup, + NvU32 *pSwapBarrier); +#endif //if defined(_D3D9_H_) + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_JoinSwapGroup +// +//! DESCRIPTION: This API causes the SwapChain of a SwapGroup client to join or leave the specified SwapGroup. +//! +//! \param [in] pDevice The caller provides the DirectX 9 device that is used as a swapgroup client +//! \param [in] pSwapChain The caller provides the IDirect3DSwapChain9 interface as a handle to the SwapChain +//! that belongs to the swapgroup client device +//! \param [in] group The caller specifies the SwapGroup which the SwapChain should join. +//! - If the value of group is zero, the SwapChain leaves the SwapGroup. +//! - The SwapChain joins a SwapGroup if the SwapGroup number is a positive integer less than or +//! equal to the maximum number of SwapGroups queried by NvAPI_SwapGroup_QueryMaxSwapGroup. +//! \param [in] blocking The caller specifies that a presentation of this SwapChain should return immediately or block +//! until all members of the SwapGroup are ready and the presentation was actually executed. +//! A boolean value of false means the Present operation returns immediately and a value of true +//! means the Present operation is blocking. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK the SwapChain joined/left the SwapGroup accordingly +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_JoinSwapGroup(IDirect3DDevice9 *pDevice, + IDirect3DSwapChain9 *pSwapChain, + NvU32 group, + BOOL blocking); +#endif //if defined(_D3D9_H_) + +#if defined(_D3D9_H_) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_BindSwapBarrier +// +//! DESCRIPTION: This API causes a SwapGroup to be bound to or released from the specified SwapBarrier. +//! +//! \param [in] pDevice The caller provides the DirectX 9 device that is used as a swapgroup client +//! \param [in] group The caller specifies the SwapGroup to be bound to the SwapBarrier. +//! \param [in] barrier The caller specifies the SwapBarrier that the SwapGroup should be bound to. +//! - If the value of barrier is zero, the SwapGroup will be released from the SwapBarrier. +//! - The SwapGroup will be bound to the SwapBarrier if the value of barrier is a positive +//! integer less than or equal to the maximum number of SwapBarriers queried by NvAPI_SwapGroup_QueryMaxSwapGroup. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK the SwapGroup is bound to or released from the specified SwapBarrier +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_BindSwapBarrier(IDirect3DDevice9 *pDevice, + NvU32 group, + NvU32 barrier); +#endif //if defined(_D3D9_H_) + +#if defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D1x_Present +// +//! DESCRIPTION: Presents the contents of the next buffer in the sequence of back buffers +//! owned by a D3D device. +//! This Present operation supports using a SwapGroup and SwapBarrier on the SwapChain +//! that owns the back buffer to be presented. +//! +//! NOTE: NvAPI_D3D1x_Present is a wrapper of the method IDXGISwapChain::Present which +//! additionally notifies the D3D driver of the SwapChain used by the runtime for +//! presentation, thus allowing the D3D driver to apply SwapGroup and SwapBarrier +//! functionality to that SwapChain. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDevice The D3D device interface that is used to issue the Present operation, +//! using the following IDirect3DDevice9::Present input parameters. +//! pDevice can be either ID3D10Device or ID3D10Device1 or ID3D11Device or ID3D12Device. +//! \param [in] pSwapChain The IDXGISwapChain interface that is intended to present +//! \param [in] SyncInterval An integer that specifies the how to synchronize presentation of a frame with the vertical blank. +//! Values are: +//! - 0: The presentation occurs immediately, there is no synchronization. +//! - 1,2,3,4 : Synchronize presentation after the n'th vertical blank. +//! \param [in] Flags An integer value that contains swap-chain presentation options as defined in DXGI_PRESENT. +//! +//! \retval ::NVAPI_OK the Present operation was successfully executed +//! \retval ::NVAPI_DEVICE_BUSY the Present operation failed with an error DXGI_ERROR_DEVICE_RESET or DXGI_ERROR_DEVICE_REMOVED, +// DXGI_STATUS_OCCLUDED, or D3DDDIERR_DEVICEREMOVED. +//! \retval ::NVAPI_ERROR the communication with the D3D driver failed, SwapGroup/SwapBarrier may not be possible. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D1x_Present(IUnknown *pDevice, + IDXGISwapChain *pSwapChain, + UINT SyncInterval, + UINT Flags); +#endif // defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) + +#if defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D1x_QueryFrameCount +// +//! DESCRIPTION: This API queries the universal framecounter of the Quadro-Sync master device. +//! +//! \param [in] pDevice The caller provides the D3D device that has access to the Quadro-Sync device, +//! pDevice can be either ID3D10Device or ID3D10Device1 or ID3D11Device or ID3D12Device. +//! \param [out] pFrameCount The caller provides the storage space where the framecount is stored. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK *pFrameCount populated with framecount value. +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D1x_QueryFrameCount(IUnknown *pDevice, + NvU32 *pFrameCount); +#endif // defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) + +#if defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D1x_ResetFrameCount +// +//! DESCRIPTION: This API resets the universal framecounter on the Quadro-Sync master device. +//! +//! \param [in] pDevice The caller provides the D3D device that has access to the Quadro-Sync device, +//! pDevice can be either ID3D10Device or ID3D10Device1 or ID3D11Device or ID3D12Device. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK framecounter has been reset +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT pDevice arg passed in is invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D1x_ResetFrameCount(IUnknown *pDevice); +#endif // defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) + +#if defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D1x_QueryMaxSwapGroup +// +//! DESCRIPTION: This API queries the number of supported SwapGroups and SwapBarriers in the graphics system. +//! +//! \param [in] pDevice The caller provides the D3D device that is intended to use SwapGroup functionality. +//! pDevice can be either ID3D10Device or ID3D10Device1 or ID3D11Device or ID3D12Device. +//! \param [out] pMaxGroups The caller provides the storage space where the number of available SwapGroups is stored. +//! \param [out] pMaxBarriers The caller provides the storage space where the number of available SwapBarriers is stored. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK the number of SwapGroups and SwapBarriers has been stored +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D1x_QueryMaxSwapGroup(IUnknown *pDevice, + NvU32 *pMaxGroups, + NvU32 *pMaxBarriers); +#endif // defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) + +#if defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D1x_QuerySwapGroup +// +//! DESCRIPTION: This API queries the current SwapGroup and SwapBarrier that a SwapChain of a specific client device is bound to. +//! +//! \param [in] pDevice The caller provides the D3D device that owns the SwapChain used as a SwapGroup client. +//! pDevice can be either ID3D10Device or ID3D10Device1 or ID3D11Device or ID3D12Device. +//! \param [in] pSwapChain The IDXGISwapChain interface that is used as the SwapGroup client. +//! +//! \param [out] pSwapGroup The caller provides the storage space where the current SwapGroup is stored. +//! \param [out] pSwapBarrier The caller provides the storage space where the current SwapBarrier is stored. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK the current SwapGroup and SwapBarrier has been stored +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D1x_QuerySwapGroup(IUnknown *pDevice, + IDXGISwapChain *pSwapChain, + NvU32 *pSwapGroup, + NvU32 *pSwapBarrier); +#endif // defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) + +#if defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D1x_JoinSwapGroup +// +//! DESCRIPTION: This API causes the SwapChain of a SwapGroup client to join or leave the specified SwapGroup. +//! +//! \param [in] pDevice The caller provides the D3D device that owns the SwapChain used as a SwapGroup client. +//! pDevice can be either ID3D10Device or ID3D10Device1 or ID3D11Device or ID3D12Device. +//! \param [in] pSwapChain The IDXGISwapChain interface that is used as the SwapGroup client. +//! \param [in] group The caller specifies the SwapGroup which the SwapChain should join. +//! - If the value of group is zero, the SwapChain leaves the SwapGroup. +//! - The SwapChain joins a SwapGroup if the SwapGroup number is a positive integer less than or +//! equal to the maximum number of SwapGroups queried by NvAPI_SwapGroup_QueryMaxSwapGroup. +//! \param [in] blocking The caller specifies that a presentation of this SwapChain should return immediately or block +//! until all members of the SwapGroup are ready and the presentation was actually executed. +//! A boolean value of false means the Present operation returns immediately and a value of true +//! means the Present operation is blocking. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK the SwapChain joined/left the SwapGroup accordingly +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D1x_JoinSwapGroup(IUnknown *pDevice, + IDXGISwapChain *pSwapChain, + NvU32 group, + BOOL blocking); +#endif // defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) + +#if defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D1x_BindSwapBarrier +// +//! DESCRIPTION: This API causes a SwapGroup to be bound to or released from the specified SwapBarrier. +//! +//! \param [in] pDevice The caller provides the D3D device that owns the SwapChain used as a SwapGroup client. +//! pDevice can be either ID3D10Device or ID3D10Device1 or ID3D11Device or ID3D12Device. +//! \param [in] group The caller specifies the SwapGroup to be bound to the SwapBarrier. +//! \param [in] barrier The caller specifies the SwapBarrier that the SwapGroup should be bound to. +//! - If the value of barrier is zero, the SwapGroup releases the SwapBarrier. +//! - The SwapGroup will be bound to the SwapBarrier if the value of barrier is a positive +//! integer less than or equal to the maximum number of SwapBarriers queried by NvAPI_D3D1x_QueryMaxSwapGroup. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \retval ::NVAPI_OK the SwapGroup is bound to the specified SwapBarrier +//! \retval ::NVAPI_ERROR The operation failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI was not yet initialized. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D1x_BindSwapBarrier(IUnknown *pDevice, + NvU32 group, + NvU32 barrier); +#endif // defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_QueryPresentBarrierSupport +// +//! DESCRIPTION: This API returns if presentBarrier feature is supported on the specified device. +//! +//! \since Release: 470 +//! +//! \param [in] pDevice The ID3D12Device device which owns the SwapChain as a PresentBarrier client. +//! \param [out] pSupported Pointer to a boolean returning true if supported, false otherwise. +//! +//! \return ::NVAPI_OK the call succeeded +//! \return ::NVAPI_ERROR the call failed +//! \return ::NVAPI_NO_IMPLEMENTATION the API is not implemented +//! \return ::NVAPI_INVALID_POINTER an invalid pointer was passed as an argument +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_QueryPresentBarrierSupport(__in ID3D12Device *pDevice, __out bool *pSupported); +#endif // defined(__cplusplus) && defined(__d3d12_h__) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_CreatePresentBarrierClient +// +//! DESCRIPTION: This API returns an NvPresentBarrierClientHandle handle, which +//! owns the swapchain to be synchronized through PresentBarrier. +//! This handle is used in other PresentBarrier functions. +//! +//! \since Release: 470 +//! +//! \param [in] pDevice The ID3D12Device device which owns the SwapChain as a PresentBarrier client. +//! \param [in] pSwapChain The IDXGISwapChain interface that presentBarrier is operated on. +//! \param [OUT] pPresentBarrierClient Pointer to an NvPresentBarrierClientHandle handle created by the driver +//! on success. +//! +//! \return ::NVAPI_OK the call succeeded +//! \return ::NVAPI_ERROR the call failed +//! \return ::NVAPI_INVALID_POINTER an invalid pointer was passed as an argument +//! \return ::NVAPI_NO_IMPLEMENTATION the API is not implemented +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_CreatePresentBarrierClient(__in ID3D12Device *pDevice, + __in IDXGISwapChain *pSwapChain, + __out NvPresentBarrierClientHandle *pPresentBarrierClient); +#endif // defined(__cplusplus) && defined(__d3d12_h__) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_RegisterPresentBarrierResources +// +//! DESCRIPTION: This API registers scanout resources of a presentBarrier client +//! to the presentBarrier, and a fence object which is used for +//! presentBarrier synchronization. Once the registration has completed +//! successfully, it is not allowed to add additional resources, i.e. the +//! number of back buffers and fence object are not allowed to be +//! changed. However, application must call this function whenever the +//! back buffers are changed, e.g. ResizeBuffers() is called. +//! +//! \since Release: 470 +//! +//! \param [in] presentBarrierClient The NvPresentBarrierClientHandle client handle that owns the resources. +//! \param [in] pFence An ID3D12Fence object created by the application and used for present +//! synchronization through presentBarrier. Application must wait on this +//! fence to ensure the scanout resources are ready for use in the next +//! rendering loop. The fence is only signaled by the driver and must not +//! be signaled through any other queue command. The fence value must be +//! monotonically increasing on every present call, and tracked by the +//! application. +//! \param [in] ppResources An array of ID3D12Resource to be synchronized through presentBarrier, and +//! the size is specified by numResources. +//! \param [in] numResources The number of ID3D12Resource elements in ppResources. +//! +//! \return ::NVAPI_OK the call succeeded +//! \return ::NVAPI_ERROR the call failed +//! \return ::NVAPI_NO_IMPLEMENTATION the API is not implemented +//! \return ::NVAPI_INVALID_POINTER an invalid pointer was passed as an argument +//! \return ::NVAPI_INVALID_HANDLE an invalid NvPresentBarrierClientHandle was passed as an argument +//! \return ::NVAPI_INVALID_ARGUMENT an invalid number of resources was passed as an argument +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_RegisterPresentBarrierResources(__in NvPresentBarrierClientHandle presentBarrierClient, + __in ID3D12Fence *pFence, + __in ID3D12Resource **ppResources, + __in NvU32 numResources); +#endif // defined(__cplusplus) && defined(__d3d12_h__) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DestroyPresentBarrierClient +// +//! DESCRIPTION: This API destroys a presentBarrier client, and must be called +//! after client leaves presentBarrier to avoid memory leak. +//! +//! \since Release: 470 +//! +//! \param [in] presentBarrierClient An NvPresentBarrierClientHandle handle created by NvAPI_xxxx_CreatedPresentBarrierClient +//! +//! \return ::NVAPI_OK the call succeeded +//! \return ::NVAPI_INVALID_HANDLE an invalid NvPresentBarrierClientHandle was passed as an argument +//! \return ::NVAPI_NO_IMPLEMENTATION the API is not implemented +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DestroyPresentBarrierClient(__in NvPresentBarrierClientHandle presentBarrierClient); +#endif // defined(__cplusplus) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) +typedef struct _NV_JOIN_PRESENT_BARRIER_PARAMS +{ + NvU32 dwVersion; //!< Must be NV_JOIN_PRESENT_BARRIER_PARAMS_VER1 +} NV_JOIN_PRESENT_BARRIER_PARAMS; + +//! Macro for constructing the version field of ::NV_JOIN_PRESENT_BARRIER_PARAMS +#define NV_JOIN_PRESENT_BARRIER_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_JOIN_PRESENT_BARRIER_PARAMS, 1) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_JoinPresentBarrier +// +//! DESCRIPTION: This API adds a registered PresentBarrier client to the presentBarrier. +//! If the call suceeds, image present of the registered scanout resources +//! from this client is under the synchronization of presentBarrier. +//! +//! \since Release: 470 +//! +//! \param [in] presentBarrierClient An NvPresentBarrierClientHandle handle created by NvAPI_xxxx_CreatedPresentBarrierClient +//! \param [in] pParams Parameters to joining presentBarrier. +//! +//! \retval ::NVAPI_OK the call succeeded +//! \retval ::NVAPI_ERROR the call failed +//! \retval ::NVAPI_NO_IMPLEMENTATION the interface is not implemented +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION the version of data structure is not correct +//! \retval ::NVAPI_INVALID_HANDLE an invalid NvPresentBarrierClientHandle was passed as an argument +//! \retval ::NVAPI_INVALID_POINTER an invalid pointer was passed as an argument (probably NULL) +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_JoinPresentBarrier(__in NvPresentBarrierClientHandle presentBarrierClient, __in NV_JOIN_PRESENT_BARRIER_PARAMS *pParams); +#endif // defined(__cplusplus) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_LeavePresentBarrier +// +//! DESCRIPTION: This API removes a registered client from presentBarrier. If this +//! client does not join presentBarrier, this function does nothing. +//! +//! \since Release: 470 +//! +//! \param [in] presentBarrierClient An NvPresentBarrierClientHandle handle created by NvAPI_xxxxx_CreatePresentBarrierClient. +//! +//! \retval ::NVAPI_OK the call succeeded +//! \retval ::NVAPI_ERROR the call failed +//! \retval ::NVAPI_NO_IMPLEMENTATION the interface is not implemented +//! \retval ::NVAPI_INVALID_HANDLE an invalid NvPresentBarrierClientHandle was passed as an argument +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_LeavePresentBarrier(__in NvPresentBarrierClientHandle presentBarrierClient); +#endif // defined(__cplusplus) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) + +#define NV_PRESENT_BARRIER_FRAME_STATICS_VER1 MAKE_NVAPI_VERSION(NV_PRESENT_BARRIER_FRAME_STATISTICS,1) + +typedef enum _NV_PRESENT_BARRIER_SYNC_MODE +{ + PRESENT_BARRIER_NOT_JOINED = 0x00000000, //!< The client hasn't joined presentBarrier + PRESENT_BARRIER_SYNC_CLIENT = 0x00000001, //!< The client joined the presentBarrier, but is not synchronized with + //! any other presentBarrier clients. This happens if the back buffers + //! of this client are composited instead of being flipped out to screen + PRESENT_BARRIER_SYNC_SYSTEM = 0x00000002, //!< The client joined the presentBarrier, and is synchronized with other + //! presentBarrier clients within the system + PRESENT_BARRIER_SYNC_CLUSTER = 0x00000003, //!< The client joined the presentBarrier, and is synchronized with other + //! clients within the system and across systems through QSync devices +} NV_PRESENT_BARRIER_SYNC_MODE; + +typedef struct _NV_PRESENT_BARRIER_FRAME_STATISTICS +{ + NvU32 dwVersion; //!< Must be NV_PRESENT_BARRIER_FRAME_STATICS_VER1 + NV_PRESENT_BARRIER_SYNC_MODE SyncMode; //!< The presentBarrier mode of this client from last present call + NvU32 PresentCount; //!< The total count of times that a frame has been presented from this + //! client after it joined presentBarrier successfully. + NvU32 PresentInSyncCount; //!< The total count of times that a frame has been presented from this + //! client and that has happened since the returned SyncMode is + //! PRESENT_BARRIER_SYNC_SYSTEM or PRESENT_BARRIER_SYNC_CLUSTER. + //! If the returned SyncMode is any other mode, this value is 0. + //! This count is set back to 0 in case the SyncMode switches away from + //! PRESENT_BARRIER_SYNC_SYSTEM or PRESENT_BARRIER_SYNC_CLUSTER. + NvU32 FlipInSyncCount; //!< The total count of flips from this client since the returned SyncMode + //! is PRESENT_BARRIER_SYNC_SYSTEM or PRESENT_BARRIER_SYNC_CLUSTER. + //! If the returned SyncMode is any other mode, this value is 0. + //! This count is set back to 0 in case the SyncMode switches away from + //! PRESENT_BARRIER_SYNC_SYSTEM or PRESENT_BARRIER_SYNC_CLUSTER. + NvU32 RefreshCount; //!< The total count of v-blanks since the returned SyncMode of this client + //! is PRESENT_BARRIER_SYNC_SYSTEM or PRESENT_BARRIER_SYNC_CLUSTER. + //! If the returned SyncMode is any other mode, this value is 0. + //! This count is set back to 0 in case the SyncMode switches away from + //! PRESENT_BARRIER_SYNC_SYSTEM or PRESENT_BARRIER_SYNC_CLUSTER. +} NV_PRESENT_BARRIER_FRAME_STATISTICS; + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_QueryPresentBarrierFrameStatistics +// +//! DESCRIPTION: This API returns the presentBarrier frame statistics of last +//! present call from this client. If the client did not join +//! presentBarrier, the SyncMode is returned as PRESENT_BARRIER_NOT_JOINED, +//! and all other fields are reset. Driver does not retain any +//! presentBarrier info of the client once it leaves presentBarrier. +//! +//! \since Release: 470 +//! +//! \param [in] presentBarrierClient An NvPresentBarrierClientHandle handle created by NvAPI_xxxxx_CreatePresentBarrierClient. +//! \param [out] pFrameStats Pointer to NV_PRESENT_BARRIER_FRAME_STATISTICS structure about presentBarrier statistics. +//! +//! \retval ::NVAPI_OK the call succeeded +//! \retval ::NVAPI_ERROR the call failed +//! \retval ::NVAPI_NO_IMPLEMENTATION the interface is not implemented +//! \retval ::NVAPI_INVALID_HANDLE an invalid NvPresentBarrierClientHandle was passed as an argument +//! \retval ::NVAPI_INVALID_POINTER an invalid pointer was passed as an argument (probably NULL) +//! \retval ::NVAPI_INCOMPATIBLE_STRUCT_VERSION invalid version of frameStatistics params +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_QueryPresentBarrierFrameStatistics(__in NvPresentBarrierClientHandle presentBarrierClient, + __out NV_PRESENT_BARRIER_FRAME_STATISTICS *pFrameStats); +#endif // defined(__cplusplus) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_CreateDDisplayPresentBarrierClient +// +//! DESCRIPTION: This API returns an NvPresentBarrierClientHandle handle. +//! +//! \since Release: 510 +//! +//! \param [in] pDevice The ID3D12Device device which executes the rendering commands of this PresentBarrier +//! client. It must be created on the same adapter as DisplayDevice. +//! \param [in] sourceId The adapter-relative identifier for the DisplaySource obtained from DisplaySource.SourceId(). +//! \param [OUT] pPresentBarrierClient Pointer to an NvPresentBarrierClientHandle handle created by the driver on success. +//! +//! \return ::NVAPI_OK the call succeeded +//! \return ::NVAPI_ERROR the call failed +//! \return ::NVAPI_INVALID_POINTER an invalid pointer was passed as an argument +//! \return ::NVAPI_INVALID_HANDLE the input displaySource handle is not owned by the process +//! \return ::NVAPI_NOT_SUPPORTED PresentBarrier featue is not supported on this configuration +//! \return ::NVAPI_NO_IMPLEMENTATION the API is not implemented +//! \retval ::NVAPI_API_NOT_INITIALIZED NvAPI not initialized +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_CreateDDisplayPresentBarrierClient(__in ID3D12Device *pDevice, __in NvU32 sourceId, __out NvPresentBarrierClientHandle *pPresentBarrierClient); +#endif // defined(__cplusplus) && defined(__d3d12_h__) + +//! SUPPORTED OS: Windows 7 and higher +//! +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__) || defined(__d3d12_h__)) + +enum NVAPI_QUAD_FILLMODE +{ + NVAPI_QUAD_FILLMODE_DISABLED = 0, + NVAPI_QUAD_FILLMODE_BBOX = 1, + NVAPI_QUAD_FILLMODE_FULL_VIEWPORT = 2, +}; + +#endif //defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__) || defined(__d3d12_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +typedef struct NvAPI_D3D11_RASTERIZER_DESC_EX +{ + // D3D11_RASTERIZER_DESC member variables + D3D11_FILL_MODE FillMode; + D3D11_CULL_MODE CullMode; + BOOL FrontCounterClockwise; + INT DepthBias; + FLOAT DepthBiasClamp; + FLOAT SlopeScaledDepthBias; + BOOL DepthClipEnable; + BOOL ScissorEnable; + BOOL MultisampleEnable; + BOOL AntialiasedLineEnable; + + // NvAPI_D3D11_RASTERIZER_DESC_EX specific member variables + NvU32 ForcedSampleCount; //1 it needs to match N, in non-TIR it needs to match RT sample count. Ignored if ForcePerSampleInterlock is set + NvU8 SamplePositionsX[16]; // 1 && (pDesc->MiscFlags&D3D11_RESOURCE_MISC_TILED) +//! \param [in] pInitialData A pointer to an array of D3D11_SUBRESOURCE_DATA structures that describe subresources for the 2D texture resource. +//! \param [out] ppTexture2D A pointer to a buffer that receives a pointer to a ID3D11Texture2D interface for the created texture. + +//! +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_CreateTiledTexture2DArray(__in ID3D11Device *pDevice, + __in const D3D11_TEXTURE2D_DESC *pDesc, + __in const D3D11_SUBRESOURCE_DATA *pInitialData, + __out ID3D11Texture2D **ppTexture2D); + +#endif //defined(__cplusplus) && defined(__d3d11_2_h__) + +//! SUPPORTED OS: Windows 10 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_h__) + +typedef enum _NV_D3D11_FEATURE +{ + NV_D3D11_FEATURE_RASTERIZER, +} NV_D3D11_FEATURE; + +typedef struct _NV_D3D11_FEATURE_DATA_RASTERIZER_SUPPORT +{ + BOOL TargetIndependentRasterWithDepth; + BOOL ProgrammableSamplePositions; + BOOL InterleavedSampling; + BOOL ConservativeRaster; + BOOL PostZCoverage; + BOOL CoverageToColor; +} NV_D3D11_FEATURE_DATA_RASTERIZER_SUPPORT; + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CheckFeatureSupport +// +//! DESCRIPTION: This function gets information about the features that are supported by the current graphics driver. +//! +//! +//! +//! \param [in] pDevice The device on which to query for support. +//! \param [in] Feature A member of the NvAPI_D3D11_FEATURE enumerated type that describes which feature to query for suppor. +//! \param [in] pFeatureSupportData Upon completion of the method, the passed structure is filled with data that describes the feature support. +//! \param [out] FeatureSupportDataSize The size of the structure passed to the pFeatureSupportData parameter. +//! +//! \since Release: 410 +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! \retval :: Returns NVAPI_OK if successful; returns NVAPI_INVALID_ARGUMENT if an unsupported data type is passed to the pFeatureSupportData parameter +//! or a size mismatch is detected for the FeatureSupportDataSize parameter; +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_CheckFeatureSupport(__in ID3D11Device *pDevice, + __in NV_D3D11_FEATURE Feature, + __out void *pFeatureSupportData, + __in UINT FeatureSupportDataSize); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + +//! SUPPORTED OS: Windows 10 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateImplicitMSAATexture2D +// +//! \since Release: 410 +// +//! \code +//! DESCRIPTION: NvAPI_D3D11_CreateImplicitMSAATexture2D is a simple wrapper of ID3D11Device::CreateTexture2D +//! which allows to create multisampled 2D texture that is exposed to DX runtime as non-multisampled texture. +//! +//! \param [in] pDevice Current d3d device +//! \param [in] pDesc A pointer to a D3D11_TEXTURE2D_DESC structure that describes a 2D texture resource. +//! To create a typeless resource that can be interpreted at runtime into different, +//! compatible formats, specify a typeless format in the texture description. +//! To generatemipmap levels automatically, set the number of mipmap levels to 0. +//! SampleDesc.SampleCount specifies actual resource sample count, while D3D runtime object +//! sees resource as non-multisampled. +//! +//! \param [out] ppTexture2D A pointer to a buffer that receives a pointer to a ID3D11Texture2D interface for the +//! created texture. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. See MSDN for the API specific error codes. +//! +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_CreateImplicitMSAATexture2D(__in ID3D11Device *pDevice, + __in const D3D11_TEXTURE2D_DESC *pDesc, + __out ID3D11Texture2D **ppTexture2D); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + +//! SUPPORTED OS: Windows 10 and higher +//! + +#if defined (__cplusplus) && defined(__d3d12_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_CreateImplicitMSAATexture2D +// +//! \since Release: 410 +// +//! \code +//! DESCRIPTION: NvAPI_D3D12_CreateCommittedImplicitMSAATexture2D is a simple wrapper of ID3D12Device::CreateCommittedResource +//! which allows to create multisampled 2D texture that is exposed to DX runtime as non-multisampled texture. +//! +//! \param [in] pDevice Current d3d device +//! \param [in] pDesc A pointer to a D3D12_RESOURCE_DESC structure that describes a 2D texture resource. +//! To create a typeless resource that can be interpreted at runtime into different, +//! compatible formats, specify a typeless format in the texture description. +//! To generatemipmap levels automatically, set the number of mipmap levels to 0. +//! SampleDesc.SampleCount specifies actual resource sample count, while D3D runtime object +//! sees resource as non-multisampled. +//! \param [in] pHeapProperties, HeapFlags, InitialResourceState, pOptimizedClearValue, riidResource See D3D12 docs +//! +//! \param [out] ppResource Same ID3D12Device::CreateCommittedResource +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. See MSDN for the API specific error codes. +//! +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_CreateCommittedImplicitMSAATexture2D( + __in ID3D12Device* pDevice, + __in const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + __in const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + __in_opt const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + __out void **ppvResource); + +#endif //defined(__cplusplus) && defined(__d3d12_h__) + + +//! SUPPORTED OS: Windows 10 and higher +//! + +//! \ingroup dx +//! Valid modes for NvAPI_D3D11_ResolveSubresourceRegion() and NvAPI_D3D12_ResolveSubresourceRegion +typedef enum _NV_RESOLVE_MODE { + NV_RESOLVE_MODE_SAMPLE_0, +} NV_RESOLVE_MODE; + +#if defined (__cplusplus) && defined(__d3d11_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_ResolveSubresourceRegion +// +//! \since Release: 410 +// +//! \code +//! DESCRIPTION: NvAPI_D3D11_ResolveSubresourceRegion is D3D11 an analog of D3D12 ResolveSubresourceRegion. +//! +//! \param [in] pDstResource Destination resource. Must be a created with the D3D11_USAGE_DEFAULT flag and be single-sampled. +//! \param [in] DstSubresource A zero-based index, that identifies the destination subresource. Use D3D11CalcSubresource to calculate the index. +//! \param [in] DstX The X coordinate of the left-most edge of the destination region. +//! The width of the destination region is the same as the width of the source rect. +//! +//! \param [in] DstY The Y coordinate of the top-most edge of the destination region. +//! The height of the destination region is the same as the height of the source rect. +//! +//! \param [in] pSrcResource Source resource. Must be multisampled. +//! \param [in] SrcSubresource The source subresource of the source resource. +//! \param [in] pSrcRect Specifies the rectangular region of the source resource to be resolved. +//! Passing NULL for pSrcRect specifies that the entire subresource is to be resolved. +//! +//! \param [in] Format A DXGI_FORMAT that indicates how the multisampled resource will be resolved to a single-sampled resource. +//! \param [in] ResolveMode Specifies the operation used to resolve the source samples. NV_RESOLVE_MODE_SAMPLE_0 is the only supported mode. +//! NV_RESOLVE_MODE_SAMPLE_0 outputs sample 0 and discards all other samples. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. See MSDN for the API specific error codes. +//! +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_ResolveSubresourceRegion( + __in ID3D11Device *pDevice, + __in ID3D11Texture2D *pDstResource, + __in UINT DstSubresource, + __in UINT DstX, + __in UINT DstY, + __in ID3D11Texture2D *pSrcResource, + __in UINT SrcSubresource, + __in_opt const RECT *pSrcRect, + __in DXGI_FORMAT Format, + __in NV_RESOLVE_MODE ResolveMode); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + +//! SUPPORTED OS: Windows 10 and higher +//! + +#if defined (__cplusplus) && defined(__d3d12_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_ResolveSubresourceRegion +// +//! \since Release: 410 +// +//! \code +//! DESCRIPTION: NvAPI_D3D12_ResolveSubresourceRegion is D3D11 an analog of D3D12 ResolveSubresourceRegion. +//! +//! \param [in] pDstResource Destination resource. Must be a created with the D3D11_USAGE_DEFAULT flag and be single-sampled. +//! \param [in] DstSubresource A zero-based index, that identifies the destination subresource. Use D3D11CalcSubresource to calculate the index. +//! \param [in] DstX The X coordinate of the left-most edge of the destination region. +//! The width of the destination region is the same as the width of the source rect. +//! +//! \param [in] DstY The Y coordinate of the top-most edge of the destination region. +//! The height of the destination region is the same as the height of the source rect. +//! +//! \param [in] pSrcResource Source resource. Must be multisampled. +//! \param [in] SrcSubresource The source subresource of the source resource. +//! \param [in] pSrcRect Specifies the rectangular region of the source resource to be resolved. +//! Passing NULL for pSrcRect specifies that the entire subresource is to be resolved. +//! +//! \param [in] Format A DXGI_FORMAT that indicates how the multisampled resource will be resolved to a single-sampled resource. +//! \param [in] ResolveMode Specifies the operation used to resolve the source samples. NV_RESOLVE_MODE_SAMPLE_0 is the only supported mode. +//! NV_RESOLVE_MODE_SAMPLE_0 outputs sample 0 and discards all other samples. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. See MSDN for the API specific error codes. +//! +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_ResolveSubresourceRegion( + __in ID3D12GraphicsCommandList1*pCommandList, + __in ID3D12Resource *pDstResource, + __in UINT DstSubresource, + __in UINT DstX, + __in UINT DstY, + __in ID3D12Resource *pSrcResource, + __in UINT SrcSubresource, + __in_opt RECT *pSrcRect, + __in DXGI_FORMAT Format, + __in NV_RESOLVE_MODE ResolveMode); + +#endif //defined(__cplusplus) && defined(__d3d12_h__) + +//! SUPPORTED OS: Windows 8 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_2_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_TiledTexture2DArrayGetDesc +// +//! \since Release: 375 +// +//! \code +//! DESCRIPTION: NvAPI_D3D11_TiledTexture2DArrayGetDesc is an simple wrapper of ID3D11Texture2D::GetDesc +//! when pTiledTexture2DArray is created with NvAPI_D3D11_CreateTiledTexture2DArray. +//! Runtime doesn't know the created resource is actually a tiled resource. +//! So calling ID3D11Texture2D::GetDesc will get a desc without D3D11_RESOURCE_MISC_TILED in MiscFlags. +//! This wrapper API just adds D3D11_RESOURCE_MISC_TILED back. +//! +//! \param [in] pTiledTexture2DArray Pointer of tiled texture2D array to get resource desc from. +//! \param [out] pDesc Pointer to a resource description. + +//! +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_TiledTexture2DArrayGetDesc(__in ID3D11Texture2D *pTiledTexture2DArray, + __out D3D11_TEXTURE2D_DESC *pDesc); + +#endif //defined(__cplusplus) && defined(__d3d11_2_h__) + +//! SUPPORTED OS: Windows 8 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_2_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_UpdateTileMappings +// +//! \since Release: 375 +// +//! \code +//! DESCRIPTION: NvAPI_D3D11_UpdateTileMappings is an extension of ID3D11DeviceContext2::UpdateTileMappings. +//! It allows pTiledResource to be a resource created with NvAPI_D3D11_CreateTiledTexture2DArray, and should be used only in such case. +//! +//! \param [in] pDeviceContext Must be Immediate DeviceContext. +//! \param [in] pTiledResource A pointer to the tiled texture 2D array resource created by NvAPI_D3D11_CreateTiledTexture2DArray. +//! \param [in] NumTiledResourceRegions The number of tiled resource regions. +//! \param [in] pTiledResourceRegionStartCoordinates An array of D3D11_TILED_RESOURCE_COORDINATE structures that describe the starting coordinates of the tiled resource regions. Cannot be NULL. +//! \param [in] pTiledResourceRegionSizes An array of D3D11_TILE_REGION_SIZE structures that describe the sizes of the tiled resource regions. Cannot be NULL. +//! \param [in] pTilePool A pointer to the tile pool. This resource should be created by standard API. +//! \param [in] NumRanges The number of tile-pool ranges. +//! \param [in] pRangeFlags An array of D3D11_TILE_RANGE_FLAG values that describe each tile-pool range. +//! \param [in] pTilePoolStartOffsets An array of offsets into the tile pool. These are 0-based tile offsets, counting in tiles (not bytes). +//! \param [in] pRangeTileCounts An array of values that specify the number of tiles in each tile-pool range. +//! \param [in] Flags A combination of D3D11_TILE_MAPPING_FLAGS values that are combined by using a bitwise OR operation. + +//! +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_UpdateTileMappings( + __in ID3D11DeviceContext2 *pDeviceContext, + __in ID3D11Resource *pTiledResource, + __in UINT NumTiledResourceRegions, + __in const D3D11_TILED_RESOURCE_COORDINATE *pTiledResourceRegionStartCoordinates, + __in const D3D11_TILE_REGION_SIZE *pTiledResourceRegionSizes, + __in ID3D11Buffer *pTilePool, + __in UINT NumRanges, + __in const UINT *pRangeFlags, + __in const UINT *pTilePoolStartOffsets, + __in const UINT *pRangeTileCounts, + __in UINT Flags); + +#endif //defined(__cplusplus) && defined(__d3d11_2_h__) + +//! SUPPORTED OS: Windows 8 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_2_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CopyTileMappings +// +//! \since Release: 375 +// +//! \code +//! DESCRIPTION: NvAPI_D3D11_CopyTileMappings is an extension of ID3D11DeviceContext2::CopyTileMappings +//! It allows pDestTiledResource or pSourceTiledResource or both to be created with NvAPI_D3D11_CreateTiledTexture2DArray. +//! It should be used only in such case. +//! +//! \param [in] pDeviceContext Must be Immediate DeviceContext. +//! \param [in] pDestTiledResource Tiled resource created by NvAPI_D3D11_CreateTiledTexture2DArray to copy tile mappings into. +//! \param [in] pDestRegionStartCoordinate A pointer to a D3D11_TILED_RESOURCE_COORDINATE structure that describes the starting coordinates of the destination tiled resource. +//! \param [in] pSourceTiledResource Tiled resource created by NvAPI_D3D11_CreateTiledTexture2DArray to copy tile mappings from. +//! \param [in] pSourceRegionStartCoordinate A pointer to a D3D11_TILED_RESOURCE_COORDINATE structure that describes the starting coordinates of the source tiled resource. +//! \param [in] pTileRegionSize A pointer to a D3D11_TILE_REGION_SIZE structure that describes the size of the tiled region. +//! \param [in] Flags A combination of D3D11_TILE_MAPPING_FLAGS values that are combined by using a bitwise OR operation. + +//! +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_CopyTileMappings( + __in ID3D11DeviceContext *pDeviceContext, + __in ID3D11Resource *pDestTiledResource, + __in const D3D11_TILED_RESOURCE_COORDINATE *pDestRegionStartCoordinate, + __in ID3D11Resource *pSourceTiledResource, + __in const D3D11_TILED_RESOURCE_COORDINATE *pSourceRegionStartCoordinate, + __in const D3D11_TILE_REGION_SIZE *pTileRegionSize, + __in UINT Flags); + +#endif //defined(__cplusplus) && defined(__d3d11_2_h__) + +//! SUPPORTED OS: Windows 8 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_2_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_TiledResourceBarrier +// +//! \since Release: 375 +// +//! \code +//! DESCRIPTION: NvAPI_D3D11_TiledResourceBarrier is an extension of ID3D11DeviceContext2::TiledResourceBarrier, but only works on ID3D11Resource(no support for ID3D11View). +//! If pTiledResourceAccessBeforeBarrier or pTiledResourceAccessAfterBarrier or both are created by NvAPI_D3D11_CreateTiledTexture2DArray, +//! NvAPI_D3D11_TiledResourceBarrier must be used instead of ID3D11DeviceContext2::TiledResourceBarrier. +//! +//! \param [in] pDeviceContext Must be Immediate DeviceContext. +//! \param [in] pTiledResourceAccessBeforeBarrier Access operations on this resource must complete before the access operations on the object that pTiledResourceAccessAfterBarrier specifies. +//! \param [in] pTiledResourceAccessAfterBarrier Access operations on this resource must begin after the access operations on the object that pTiledResourceAccessBeforeBarrier specifies. + +//! +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_TiledResourceBarrier( + __in ID3D11DeviceContext *pDeviceContext, + __in ID3D11Resource *pTiledResourceAccessBeforeBarrier, + __in ID3D11Resource *pTiledResourceAccessAfterBarrier); + +#endif //defined(__cplusplus) && defined(__d3d11_2_h__) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_AliasMSAATexture2DAsNonMSAA +// +//! \code +//! DESCRIPTION: This function allows creating (aliasing) a non-MSAA Texture2D object using the same memory as the given multi-sampled +//! texture (pInputTex). The surface created would be bloated in width and height but it will have SampleCount = 1 +//! For 2X MSAA: OutTex.Width = InputTex.Width * 2, outTex.Height = InputTex.Height +//! For 4X MSAA: OutTex.Width = InputTex.Width * 2, outTex.Height = InputTex.Height * 2 +//! For 8X MSAA: OutTex.Width = InputTex.Width * 4, outTex.Height = InputTex.Height * 2 +//! Only textures SampleQuality = 0 can be aliased as Non MSAA +//! The app should ensure that original texture is released only after the aliased copy is released. +//! +//! This function is free-threaded create compatible i.e. it can be called from a different thread +//! than the one calling immediate device setstate functions. +//! +//! \param [in] pDevice current d3d device +//! \param [in] pInputTex The MultiSampled Texture2D resource that is being aliased +//! \param [out] ppOutTex The aliased non AA copy MultiSampled Texture2D resource +//! +//! +//! \return :: NVAPI_OK if the call succeeds. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_AliasMSAATexture2DAsNonMSAA(__in ID3D11Device *pDevice, + __in ID3D11Texture2D *pInputTex, + __out ID3D11Texture2D **ppOutTex); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) && (!defined(CINTERFACE)) +typedef UINT NvAPI_D3D11_SWIZZLE_MODE; + +typedef enum _NV_SWIZZLE_MODE +{ + NV_SWIZZLE_POS_X = 0, + NV_SWIZZLE_NEG_X = 1, + NV_SWIZZLE_POS_Y = 2, + NV_SWIZZLE_NEG_Y = 3, + NV_SWIZZLE_POS_Z = 4, + NV_SWIZZLE_NEG_Z = 5, + NV_SWIZZLE_POS_W = 6, + NV_SWIZZLE_NEG_W = 7 +}NV_SWIZZLE_MODE; + +typedef enum _NV_SWIZZLE_OFFSET +{ + NV_SWIZZLE_OFFSET_X = 0, + NV_SWIZZLE_OFFSET_Y = 4, + NV_SWIZZLE_OFFSET_Z = 8, + NV_SWIZZLE_OFFSET_W = 12 +}NV_SWIZZLE_OFFSET; + +#endif //defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) && (!defined(CINTERFACE)) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) && (!defined(CINTERFACE)) +#define NV_CUSTOM_SEMANTIC_MAX_LIMIT 32 + +typedef enum NV_CUSTOM_SEMANTIC_TYPE +{ + NV_NONE_SEMANTIC = 0, + NV_X_RIGHT_SEMANTIC = 1, + NV_VIEWPORT_MASK_SEMANTIC = 2, + NV_XYZW_RIGHT_SEMANTIC = 3, + NV_VIEWPORT_MASK_2_SEMANTIC = 4, + + NV_POSITION_SEMANTIC = 5, + NV_CLIP_DISTANCE_0_SEMANTIC = 6, // MultiView can accept upto two vec4 values. So the application should not use + NV_CLIP_DISTANCE_1_SEMANTIC = 7, // more than 2 of the below Clip / Cull semantics in a single shader. + NV_CULL_DISTANCE_0_SEMANTIC = 8, + NV_CULL_DISTANCE_1_SEMANTIC = 9, + NV_GENERIC_ATTRIBUTE_SEMANTIC = 10, + + NV_PACKED_EYE_INDEX_SEMANTIC = 17, + NV_CUSTOM_SEMANTIC_MAX = NV_CUSTOM_SEMANTIC_MAX_LIMIT, +} NV_CUSTOM_SEMANTIC_TYPE; + +typedef struct _NV_CUSTOM_SEMANTIC +{ + UINT version; // NV_CUSTOM_SEMANTIC_VERSION + + NV_CUSTOM_SEMANTIC_TYPE NVCustomSemanticType; // type of custom semantic (NV_CUSTOM_SEMANTIC_TYPE) + NvAPI_LongString NVCustomSemanticNameString; // name of custom semantic e.g. "NV_X_RIGHT", "NV_VIEWPORT_MASK" + BOOL RegisterSpecified; // (optional) set to TRUE to explicitly provide register number and mask as below + NvU32 RegisterNum; // (optional) output register which has the custom semantic. + NvU32 RegisterMask; // (optional) output register component mask which has the custom semantic (X:1, Y:2, Z:4) + NvU32 Reserved; // reserved +} NV_CUSTOM_SEMANTIC; + +#define NV_CUSTOM_SEMANTIC_VERSION MAKE_NVAPI_VERSION(NV_CUSTOM_SEMANTIC, 1) + +#endif //defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) && (!defined(CINTERFACE)) + +#if defined (__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE)) + +typedef struct NvAPI_D3D11_CREATE_GEOMETRY_SHADER_EX_V5 +{ + UINT version; + + BOOL UseViewportMask; + BOOL OffsetRtIndexByVpIndex; + BOOL ForceFastGS; + BOOL DontUseViewportOrder; + BOOL UseAttributeSkipMask; + BOOL UseCoordinateSwizzle; + NvAPI_D3D11_SWIZZLE_MODE *pCoordinateSwizzling; + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC + BOOL ConvertToFastGS; // reserved + BOOL UseSpecificShaderExt; // TRUE if creating minimal specific shaders with nvapi shader extensions +} NvAPI_D3D11_CREATE_GEOMETRY_SHADER_EX_V5; + +typedef NvAPI_D3D11_CREATE_GEOMETRY_SHADER_EX_V5 NvAPI_D3D11_CREATE_GEOMETRY_SHADER_EX; +#define NVAPI_D3D11_CREATEGEOMETRYSHADEREX_2_VER_5 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_GEOMETRY_SHADER_EX_V5, 5) +#define NVAPI_D3D11_CREATEGEOMETRYSHADEREX_2_VERSION NVAPI_D3D11_CREATEGEOMETRYSHADEREX_2_VER_5 + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateGeometryShaderEx +// +//! \fn NvAPI_D3D11_CreateGeometryShaderEx +//! +//! DESCRIPTION: This function allows us to extend the creation of geometry shaders with extra bits +//! of functionality. +//! +//! The first parameters are identical to ID3D11Device::CreateGeometryShader() +//! so please refer to its documentation for their usage. +//! +//! The new parameter is UseViewportMask which is to tell the driver to create a shader +//! that outputs a viewport mask instead when a viewport index is indicated. +//! Outputting a viewport mask allows a single primitive to land on many different viewports +//! as specified by the bits set in the mask, rather than to rely on a single number that tells it +//! which unique viewport it would be drawn on. +//! This can be used for example in conjunction with the setting of coordinates swizzling (see XXX_NVAPI function) +//! to generates multiple adjacent views of the same primitive in a more efficient fashion +//! (outputting the primitive only once). +//! +//! This function is free-threaded create compatible i.e. it can be called from a different +//! thread than the one calling immediate device setstate functions. +//! +//! \since Release: +//! +//! \param [in] pDevice The device pointer +//! \param [in] pShaderBytecode A pointer to the compiled shader. +//! \param [in] BytecodeLength Size of the compiled geometry shader. +//! \param [in] pClassLinkage A pointer to a class linkage interface. Can be NULL. +//! \param [in] UseViewportMask Set to FALSE for custom semantic shaders. Tell the driver to create a shader that outputs the viewport mask in lieu of the viewport index. See above description. +//! \param [in] OffsetRtIndexByVpIndex Set to FALSE for custom semantic shaders. The Rendertarget index is offset by the viewport index +//! \param [in] ForceFastGS If TRUE, GS must be written with maxvertexcount(1) and must pass-through input vertex 0 to the output without modification +//! \param [in] DontUseViewportOrder Default FALSE for Primitives batched per viewport to improve performance. Set TRUE for API order (slow). +//! \param [in] UseAttributeSkipMask reserved +//! \param [in] UseCoordinateSwizzle reserved +//! \param [in] pCoordinateSwizzling reserved +//! \param [in] NumCustomSemantics Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics +//! \param [in] pCustomSemantics pointer to array of NV_CUSTOM_SEMANTIC +//! \param [in] ConvertToFastGS reserved +//! \param [in] UseSpecificShaderExt TRUE if creating minimal specific shaders with nvapi shader extensions +//! \param [out] ppGeometryShader Address of a pointer to a ID3D11GeometryShader interface. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +// +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_CreateGeometryShaderEx_2(__in ID3D11Device *pDevice, __in const void *pShaderBytecode, + __in SIZE_T BytecodeLength, __in_opt ID3D11ClassLinkage *pClassLinkage, + __in const NvAPI_D3D11_CREATE_GEOMETRY_SHADER_EX *pCreateGeometryShaderExArgs, + __out ID3D11GeometryShader **ppGeometryShader); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE)) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE) ) + +typedef struct NvAPI_D3D11_CREATE_VERTEX_SHADER_EX_V1 +{ + UINT version; + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC +} NvAPI_D3D11_CREATE_VERTEX_SHADER_EX_V1; + +typedef struct NvAPI_D3D11_CREATE_VERTEX_SHADER_EX_V2 +{ + UINT version; + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC + BOOL UseWithFastGS; // reserved +} NvAPI_D3D11_CREATE_VERTEX_SHADER_EX_V2; + +typedef struct NvAPI_D3D11_CREATE_VERTEX_SHADER_EX_V3 +{ + UINT version; + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC + BOOL UseWithFastGS; // reserved + BOOL UseSpecificShaderExt; // TRUE if creating minimal specific shaders with nvapi shader extensions +} NvAPI_D3D11_CREATE_VERTEX_SHADER_EX_V3; + +typedef NvAPI_D3D11_CREATE_VERTEX_SHADER_EX_V3 NvAPI_D3D11_CREATE_VERTEX_SHADER_EX; +#define NVAPI_D3D11_CREATEVERTEXSHADEREX_VER_1 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_VERTEX_SHADER_EX_V1, 1) +#define NVAPI_D3D11_CREATEVERTEXSHADEREX_VER_2 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_VERTEX_SHADER_EX_V2, 2) +#define NVAPI_D3D11_CREATEVERTEXSHADEREX_VER_3 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_VERTEX_SHADER_EX_V2, 3) +#define NVAPI_D3D11_CREATEVERTEXSHADEREX_VERSION NVAPI_D3D11_CREATEVERTEXSHADEREX_VER_3 + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateVertexShaderEx +// +//! \fn NvAPI_D3D11_CreateVertexShaderEx +//! +//! DESCRIPTION: This function allows us to extend the creation of vertex shaders with extra bits +//! of functionality. +//! +//! The first parameters are identical to ID3D11Device::CreateVertexShader() +//! so please refer to its documentation for their usage. +//! +//! The new parameter are custom semantics which allow setting of custom semantic variables +//! in the shader +//! +//! This function is free-threaded create compatible i.e. it can be called from a different thread +//! than the one calling immediate device setstate functions. +//! +//! \since Release: +//! +//! \param [in] pDevice The device pointer +//! \param [in] pShaderBytecode A pointer to the compiled shader. +//! \param [in] BytecodeLength Size of the compiled vertex shader. +//! \param [in] pClassLinkage A pointer to a class linkage interface. Can be NULL. +//! \param [in] NumCustomSemantics Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics +//! \param [in] pCustomSemantics pointer to array of NV_CUSTOM_SEMANTIC +//! \param [in] UseWithFastGS reserved +//! \param [in] UseSpecificShaderExt TRUE if creating minimal specific shaders with nvapi shader extensions +//! \param [out] ppVertexShader Address of a pointer to a ID3D11VertexShader interface. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +// +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_CreateVertexShaderEx(__in ID3D11Device *pDevice, __in const void *pShaderBytecode, + __in SIZE_T BytecodeLength, __in_opt ID3D11ClassLinkage *pClassLinkage, + __in const NvAPI_D3D11_CREATE_VERTEX_SHADER_EX *pCreateVertexShaderExArgs, + __out ID3D11VertexShader **ppVertexShader); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE)) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE) ) + +typedef struct NvAPI_D3D11_CREATE_HULL_SHADER_EX_V1 +{ + UINT version; + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC + BOOL UseWithFastGS; // reserved +} NvAPI_D3D11_CREATE_HULL_SHADER_EX_V1; + +typedef struct NvAPI_D3D11_CREATE_HULL_SHADER_EX_V2 +{ + UINT version; + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC + BOOL UseWithFastGS; // reserved + BOOL UseSpecificShaderExt; // TRUE if creating minimal specific shaders with nvapi shader extensions +} NvAPI_D3D11_CREATE_HULL_SHADER_EX_V2; + +typedef NvAPI_D3D11_CREATE_HULL_SHADER_EX_V2 NvAPI_D3D11_CREATE_HULL_SHADER_EX; +#define NVAPI_D3D11_CREATEHULLSHADEREX_VER_1 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_HULL_SHADER_EX_V1, 1) +#define NVAPI_D3D11_CREATEHULLSHADEREX_VER_2 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_HULL_SHADER_EX_V1, 2) +#define NVAPI_D3D11_CREATEHULLSHADEREX_VERSION NVAPI_D3D11_CREATEHULLSHADEREX_VER_2 + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateHullShaderEx +// +//! \fn NvAPI_D3D11_CreateHullShaderEx +//! +//! DESCRIPTION: This function allows us to extend the creation of hull shaders with extra bits +//! of functionality. +//! +//! The first parameters are identical to ID3D11Device::CreateHullShader() +//! so please refer to its documentation for their usage. +//! +//! The new parameter are custom semantics which allow setting of custom semantic variables +//! in the shader +//! +//! This function is free-threaded create compatible i.e. it can be called from a different thread +//! than the one calling immediate device setstate functions. +//! +//! \since Release: +//! +//! \param [in] pDevice The device pointer +//! \param [in] pShaderBytecode A pointer to the compiled shader. +//! \param [in] BytecodeLength Size of the compiled hull shader. +//! \param [in] pClassLinkage A pointer to a class linkage interface. Can be NULL. +//! \param [in] NumCustomSemantics Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics +//! \param [in] pCustomSemantics pointer to array of NV_CUSTOM_SEMANTIC +//! \param [in] UseWithFastGS reserved +//! \param [in] UseSpecificShaderExt TRUE if creating minimal specific shaders with nvapi shader extensions +//! \param [out] ppHullShader Address of a pointer to a ID3D11HullShader interface. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +// +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_CreateHullShaderEx(__in ID3D11Device *pDevice, __in const void *pShaderBytecode, + __in SIZE_T BytecodeLength, __in_opt ID3D11ClassLinkage *pClassLinkage, + __in const NvAPI_D3D11_CREATE_HULL_SHADER_EX *pCreateHullShaderExArgs, + __out ID3D11HullShader **ppHullShader); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE)) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE) ) + +typedef struct NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX_V1 +{ + UINT version; + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC +} NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX_V1; + +typedef struct NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX_V2 +{ + UINT version; + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC + BOOL UseWithFastGS; // reserved +} NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX_V2; + +typedef struct NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX_V3 +{ + UINT version; + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC + BOOL UseWithFastGS; // reserved + BOOL UseSpecificShaderExt; // TRUE if creating minimal specific shaders with nvapi shader extensions +} NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX_V3; + +typedef NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX_V3 NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX; +#define NVAPI_D3D11_CREATEDOMAINSHADEREX_VER_1 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX_V1, 1) +#define NVAPI_D3D11_CREATEDOMAINSHADEREX_VER_2 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX_V2, 2) +#define NVAPI_D3D11_CREATEDOMAINSHADEREX_VER_3 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX_V3, 3) +#define NVAPI_D3D11_CREATEDOMAINSHADEREX_VERSION NVAPI_D3D11_CREATEDOMAINSHADEREX_VER_3 + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateDomainShaderEx +// +//! \fn NvAPI_D3D11_CreateDomainShaderEx +//! +//! DESCRIPTION: This function allows us to extend the creation of domain shaders with extra bits +//! of functionality. +//! +//! The first parameters are identical to ID3D11Device::CreateDomainShader() +//! so please refer to its documentation for their usage. +//! +//! The new parameter are custom semantics which allow setting of custom semantic variables +//! in the shader +//! +//! This function is free-threaded create compatible i.e. it can be called from a different thread +//! than the one calling immediate device setstate functions. +//! +//! \since Release: +//! +//! \param [in] pDevice The device pointer +//! \param [in] pShaderBytecode A pointer to the compiled shader. +//! \param [in] BytecodeLength Size of the compiled domain shader. +//! \param [in] pClassLinkage A pointer to a class linkage interface. Can be NULL. +//! \param [in] NumCustomSemantics Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics +//! \param [in] pCustomSemantics pointer to array of NV_CUSTOM_SEMANTIC +//! \param [in] UseWithFastGS reserved +//! \param [in] UseSpecificShaderExt TRUE if creating minimal specific shaders with nvapi shader extensions +//! \param [out] ppDomainShader Address of a pointer to a ID3D11DomainShader interface. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +// +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_CreateDomainShaderEx(__in ID3D11Device *pDevice, __in const void *pShaderBytecode, + __in SIZE_T BytecodeLength, __in_opt ID3D11ClassLinkage *pClassLinkage, + __in const NvAPI_D3D11_CREATE_DOMAIN_SHADER_EX *pCreateDomainShaderExArgs, + __out ID3D11DomainShader **ppDomainShader); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE)) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE) ) + +typedef struct NvAPI_D3D11_CREATE_PIXEL_SHADER_EX_V1 +{ + UINT version; + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC +} NvAPI_D3D11_CREATE_PIXEL_SHADER_EX_V1; + +#define NVAPI_D3D11_CREATEPIXELSHADEREX_VER_1 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_PIXEL_SHADER_EX_V1, 1) + +typedef struct NvAPI_D3D11_CREATE_PIXEL_SHADER_EX_V2 +{ + UINT version; // Always use NVAPI_D3D11_CREATEPIXELSHADEREX_VERSION + + NvU32 NumCustomSemantics; // Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics + NV_CUSTOM_SEMANTIC *pCustomSemantics; // pointer to array of NV_CUSTOM_SEMANTIC + NvU32 bEnableSuperSamplingPredicationForVRS : 1; // This enables sampling within a pixel for SuperSampling mode of Variable Rate Shading for relevant attributes tagged with "sample" modifier + NvU32 bEnableSuperSamplingPredicationForVRSAllAttributes : 1; // This enables sampling within a pixel for SuperSampling mode of Variable Rate Shading for all relevant attributes + NvU32 reserved : 30; // Reserved for further use +} NvAPI_D3D11_CREATE_PIXEL_SHADER_EX_V2; + +typedef NvAPI_D3D11_CREATE_PIXEL_SHADER_EX_V2 NvAPI_D3D11_CREATE_PIXEL_SHADER_EX; +#define NVAPI_D3D11_CREATEPIXELSHADEREX_VER_2 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_PIXEL_SHADER_EX_V2, 2) +#define NVAPI_D3D11_CREATEPIXELSHADEREX_VERSION NVAPI_D3D11_CREATEPIXELSHADEREX_VER_2 + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreatePixelShaderEx_2 +// +//! \fn NvAPI_D3D11_CreatePixelShaderEx_2 +//! +//! DESCRIPTION: This function allows us to extend the creation of pixel shaders with extra bits +//! of functionality. +//! +//! The first parameters are identical to ID3D11Device::CreatePixelShader() +//! so please refer to its documentation for their usage. +//! +//! The new parameter are custom semantics which allow setting of custom semantic variables +//! in the shader +//! +//! This function is free-threaded create compatible i.e. it can be called from a different thread +//! than the one calling immediate device setstate functions. +//! +//! \since Release: 410 +//! +//! \param [in] pDevice The device pointer +//! \param [in] pShaderBytecode A pointer to the compiled shader. +//! \param [in] BytecodeLength Size of the compiled domain shader. +//! \param [in] pClassLinkage A pointer to a class linkage interface. Can be NULL. +//! \param [in] NumCustomSemantics Number of custom semantics elements (upto NV_CUSTOM_SEMANTIC_MAX) provided in array pointer pCustomSemantics +//! \param [in] pCustomSemantics pointer to array of NV_CUSTOM_SEMANTIC +//! \param [out] ppPixelShader Address of a pointer to a ID3D11PixelShader interface. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +// +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_CreatePixelShaderEx_2(__in ID3D11Device *pDevice, __in const void *pShaderBytecode, + __in SIZE_T BytecodeLength, __in_opt ID3D11ClassLinkage *pClassLinkage, + __in const NvAPI_D3D11_CREATE_PIXEL_SHADER_EX *pCreatePixelShaderExArgs, + __out ID3D11PixelShader **ppPixelShader); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE)) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) && (!defined(CINTERFACE)) + +typedef enum _NV_FASTGS_FLAGS +{ + NV_FASTGS_USE_VIEWPORT_MASK = 0x01, // Causes SV_ViewportArrayIndex value to be interpreted as a bitmask of viewports to broadcast to. + NV_FASTGS_OFFSET_RT_INDEX_BY_VP_INDEX = 0x02, // Causes SV_RenderTargetArrayIndex value to be offset by the viewport index when broadcasting. + NV_FASTGS_STRICT_API_ORDER = 0x04, // Causes broadcast primitives to be rendered strictly in API order (slow). + // By default, primitives may be batched per viewport to improve performance. +} NV_FASTGS_FLAGS; + +#endif //defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) && (!defined(CINTERFACE)) + +#if defined (__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE)) + +struct NvAPI_D3D11_CREATE_FASTGS_EXPLICIT_DESC_V1 +{ + NvU32 version; // ALWAYS == NVAPI_D3D11_CREATEFASTGSEXPLICIT_VER + NvU32 flags; // A combination of flags from NV_FASTGS_FLAGS + NvAPI_D3D11_SWIZZLE_MODE *pCoordinateSwizzling; // [optional] Array of 16 coordinate swizzle modes, one per viewport. NULL if not used. + // The output x, y, z, and w coordinates of all vertices can be set to any of the coordinates or their + // negated versions i.e. {x, y, z, w, -x, -y, -z, -w}. Coordinates are swizzled before any viewport + // operation occurs i.e. before frustum clipping, scaling, and viewport clipping. And after + // last of vertex/tesselation/geometry shader stage, stream-out and viewport broadcast expansion (see NV_FASTGS_USE_VIEWPORT_MASK) + // pCoordinateSwizzling[i] sets the swizzle-mode of each component for viewport i. + // See NV_SWIZZLE_MODE for values of allowed swizzle modes. + // See NV_SWIZZLE_OFFSET for bit offset from where NV_SWIZZLE_MODE to be set for each component. + // For example : + // 1. To set swizzle for viewport 0 such that - w and z are unchanged and values of x and y are swapped : + // pCoordinateSwizzling[0] = (NV_SWIZZLE_POS_W << NV_SWIZZLE_OFFSET_W) | + // (NV_SWIZZLE_POS_Z << NV_SWIZZLE_OFFSET_Z) | + // (NV_SWIZZLE_POS_X << NV_SWIZZLE_OFFSET_Y) | + // (NV_SWIZZLE_POS_Y << NV_SWIZZLE_OFFSET_X); + // 2. To set swizzle for viewport 0 such that - w, z and y are unchanged and value of x is negated : + // pCoordinateSwizzling[0] = (NV_SWIZZLE_POS_W << NV_SWIZZLE_OFFSET_W) | + // (NV_SWIZZLE_POS_Z << NV_SWIZZLE_OFFSET_Z) | + // (NV_SWIZZLE_POS_Y << NV_SWIZZLE_OFFSET_Y) | + // (NV_SWIZZLE_NEG_X << NV_SWIZZLE_OFFSET_X); + // Need to set some valid combination of swizzle-modes for all viewports, irrespective of whether that viewport is set. + // Invalid swizzle-mode for any viewport (even if that viewport is not set) may result in removal of device. +}; + +#define NVAPI_D3D11_CREATEFASTGSEXPLICIT_VER1 MAKE_NVAPI_VERSION(NvAPI_D3D11_CREATE_FASTGS_EXPLICIT_DESC_V1, 1) +#define NVAPI_D3D11_CREATEFASTGSEXPLICIT_VER NVAPI_D3D11_CREATEFASTGSEXPLICIT_VER1 + +typedef NvAPI_D3D11_CREATE_FASTGS_EXPLICIT_DESC_V1 NvAPI_D3D11_CREATE_FASTGS_EXPLICIT_DESC; + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateFastGeometryShaderExplicit +// +//! \fn NvAPI_D3D11_CreateFastGeometryShaderExplicit +//! +//! DESCRIPTION: This function will create a fast geometry shader written using an "explicit" +//! coding style, rather than converting a standard GS. For the explicit coding +//! style, the GS must be written with maxvertexcount(1), and must pass-through +//! input vertex 0 to the output without modification. +//! +//! Additional per-primitive outputs may also be computed and written to the single +//! output vertex. If these outputs are read by the pixel shader, they must be +//! declared with the "nointerpolation" attribute in the PS input signature; +//! otherwise, visual corruption may occur. Also, unlike D3D API, there is no guarantee +//! that pixel shader will get the default value of an attribute if that attribute is not written +//! by the earlier shader stage in the pipeline. +//! +//! The first four parameters are identical to ID3D11Device::CreateGeometryShader(), +//! so please refer to its documentation for their usage. +//! +//! This function is free-threaded create compatible i.e. it can be called from a different thread +//! than the one calling immediate device setstate functions. +//! +//! \since Release: +//! +//! \param [in] pDevice The device pointer +//! \param [in] pShaderBytecode A pointer to the compiled shader. +//! \param [in] BytecodeLength Size of the compiled geometry shader. +//! \param [in] pClassLinkage A pointer to a class linkage interface. Can be NULL. +//! \param [in] pCreateFastGSArgs A pointer to a NvAPI_D3D11_CREATE_FASTGS_EXPLICIT struct. +//! \param [out] ppGeometryShader Address of a pointer to a ID3D11GeometryShader interface. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_CreateFastGeometryShaderExplicit(__in ID3D11Device *pDevice, __in const void *pShaderBytecode, + __in SIZE_T BytecodeLength, __in_opt ID3D11ClassLinkage *pClassLinkage, + __in const NvAPI_D3D11_CREATE_FASTGS_EXPLICIT_DESC *pCreateFastGSArgs, + __out ID3D11GeometryShader **ppGeometryShader); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE)) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE) ) +//////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateFastGeometryShader +// +//! \fn NvAPI_D3D11_CreateFastGeometryShader +//! +//! DESCRIPTION: This function will convert a regular geometry shader into a fast GS variant if possible. +//! It will not do any validation regarding the compatibility of the resulting fast GS with any +//! Pixel shader. The validation has to be done by the application manually. +//! +//! The parameters are identical to ID3D11Device::CreateGeometryShader() +//! so please refer to its documentation for their usage. +//! +//! If the shader is too complex or is not in adequate form to be converted to fast GS +//! this function will simply fail. You should then call ID3D11Device::CreateGeometryShader() +//! to create the regular geometry shader. +//! +//! This function is free-threaded create compatible i.e. it can be called from a different thread +//! than the one calling immediate device setstate functions. +//! +//! \since Release: +//! +//! \param [in] pDevice The device pointer +//! \param [in] pShaderBytecode A pointer to the compiled shader. +//! \param [in] BytecodeLength Size of the compiled geometry shader. +//! \param [in] pClassLinkage A pointer to a class linkage interface. Can be NULL. +//! \param [out] ppGeometryShader Address of a pointer to a ID3D11GeometryShader interface. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +// +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_CreateFastGeometryShader(__in ID3D11Device *pDevice, __in const void *pShaderBytecode, + __in SIZE_T BytecodeLength, __in_opt ID3D11ClassLinkage *pClassLinkage, + __out ID3D11GeometryShader **ppGeometryShader); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) && (!defined(CINTERFACE)) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined (__cplusplus) && defined(__d3d11_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_DecompressView +// +//! \code +//! DESCRIPTION: This function is used to decompress a surface using the currently bound programmable sample positions. +//! +//! This is needed: +//! - When writing to a surface in a region previously rendered by different sample positions and no clear was done. +//! - When reading a surface in a shader that was rendered using non-standard sample positions. +//! - When copying from a surface that was rendered using non-standard sample positions. +//! +//! \param [in] pDevice Current d3d11 device +//! \param [in] pDeviceContext Current d3d11 device context +//! \param [in] pView Current view to decompress +//! +//! +//! \return ::NVAPI_OK if the call succeeds. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_DecompressView(__in ID3D11Device* pDevice, __in ID3D11DeviceContext *pDeviceContext, __in ID3D11View* pView); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + + +#if defined (__cplusplus) && defined(__d3d12_h__) + +//! Enum for CreatePSO extensions. +//! \ingroup dx +//! constant 5 is assigned to two members of this enum becuase the first member name contains a typo: EXTNENSION. Please use the correctly-spelled enumerator. +typedef enum _NV_PSO_EXTENSION +{ + NV_PSO_RASTER_EXTENSION = 0, + NV_PSO_REQUEST_FASTGS_EXTENSION = 1, + NV_PSO_GEOMETRY_SHADER_EXTENSION = 2, + NV_PSO_ENABLE_DEPTH_BOUND_TEST_EXTENSION = 3, + NV_PSO_EXPLICIT_FASTGS_EXTENSION = 4, + NV_PSO_SET_SHADER_EXTNENSION_SLOT_AND_SPACE = 5, + NV_PSO_SET_SHADER_EXTENSION_SLOT_AND_SPACE = 5, + NV_PSO_VERTEX_SHADER_EXTENSION = 6, + NV_PSO_DOMAIN_SHADER_EXTENSION = 7, + NV_PSO_HULL_SHADER_EXTENSION = 9, +}NV_PSO_EXTENSION; + +struct NVAPI_D3D12_PSO_EXTENSION_DESC_V1 +{ + NvU32 baseVersion; //1 it needs to match N, in non-TIR it needs to match RT sample count. Ignored if ForcePerSampleInterlock is set + NvU8 SamplePositionsX[16]; //= 201103L + +#define compile_time_assert(b) static_assert((b), "Compile time assertion failed: "#b) + +enum NV_META_COMMAND_TENSOR_DATA_TYPE : NvU64 +{ + NV_META_COMMAND_TENSOR_DATA_TYPE_FLOAT32, + NV_META_COMMAND_TENSOR_DATA_TYPE_FLOAT16, + NV_META_COMMAND_TENSOR_DATA_TYPE_UINT32, + + NV_META_COMMAND_TENSOR_DATA_TYPE_COUNT, +}; + + +enum NV_META_COMMAND_TENSOR_LAYOUT : NvU64 +{ + NV_META_COMMAND_TENSOR_LAYOUT_UNKNOWN, // opaque HW-native layout + NV_META_COMMAND_TENSOR_LAYOUT_STANDARD, // NCDHW - planar / row major layout (width is inner-most dimension, batch-size N is the outermost) + NV_META_COMMAND_TENSOR_LAYOUT_COUNT, +}; + +enum NV_META_COMMAND_TENSOR_FLAGS : NvU64 +{ + NV_META_COMMAND_TENSOR_FLAG_NONE = 0, + NV_META_COMMAND_TENSOR_FLAG_DATA_STATIC = 0x1, // data pointed by the tensor is static (i.e, won't be modified after command list recording) +}; + +enum NV_META_COMMAND_PRECISION : NvU64 +{ + NV_META_COMMAND_PRECISION_FLOAT32, + NV_META_COMMAND_PRECISION_FLOAT16, + NV_META_COMMAND_PRECISION_MUL_FLOAT16_ADD_FLOAT32, + + NV_META_COMMAND_PRECISION_COUNT, +}; + +struct NV_META_COMMAND_TENSOR_DESC +{ + NV_META_COMMAND_TENSOR_DATA_TYPE DataType; + NV_META_COMMAND_TENSOR_LAYOUT Layout; + NV_META_COMMAND_TENSOR_FLAGS Flags; + NvU64 DimensionCount; // 4 or 5 + NvU64 Size[NV_META_COMMAND_MAX_TENSOR_DIM]; + NvU64 Stride[NV_META_COMMAND_MAX_TENSOR_DIM]; // only used with NV_META_COMMAND_TENSOR_LAYOUT_STANDARD +}; + +enum NV_META_COMMAND_ACTIVATION_FUNCTION : NvU64 +{ + NV_META_COMMAND_ACTIVATION_FUNCTION_ELU, + NV_META_COMMAND_ACTIVATION_FUNCTION_HARDMAX, + NV_META_COMMAND_ACTIVATION_FUNCTION_HARD_SIGMOID, + NV_META_COMMAND_ACTIVATION_FUNCTION_IDENTITY, + NV_META_COMMAND_ACTIVATION_FUNCTION_LEAKY_RELU, + NV_META_COMMAND_ACTIVATION_FUNCTION_LINEAR, + NV_META_COMMAND_ACTIVATION_FUNCTION_LOG_SOFTMAX, + NV_META_COMMAND_ACTIVATION_FUNCTION_PARAMETERIZED_RELU, + NV_META_COMMAND_ACTIVATION_FUNCTION_PARAMETRIC_SOFTPLUS, + NV_META_COMMAND_ACTIVATION_FUNCTION_RELU, + NV_META_COMMAND_ACTIVATION_FUNCTION_SCALED_ELU, + NV_META_COMMAND_ACTIVATION_FUNCTION_SCALED_TANH, + NV_META_COMMAND_ACTIVATION_FUNCTION_SIGMOID, + NV_META_COMMAND_ACTIVATION_FUNCTION_SOFTMAX, + NV_META_COMMAND_ACTIVATION_FUNCTION_SOFTPLUS, + NV_META_COMMAND_ACTIVATION_FUNCTION_SOFTSIGN, + NV_META_COMMAND_ACTIVATION_FUNCTION_TANH, + NV_META_COMMAND_ACTIVATION_FUNCTION_THRESHOLDED_RELU, + + NV_META_COMMAND_ACTIVATION_FUNCTION_COUNT, +}; + +struct NV_META_COMMAND_ACTIVATION_DESC +{ + NV_META_COMMAND_ACTIVATION_FUNCTION Function; + float Params[NV_META_COMMAND_ACTIVATION_MAX_PARAMS]; +}; + +#else + +#define compile_time_assert(b) typedef char compile_time_assertion_failed_in_line_##__LINE__[(b)?1:-1] + +enum NV_META_COMMAND_TENSOR_DATA_TYPE +{ + NV_META_COMMAND_TENSOR_DATA_TYPE_FLOAT32, + NV_META_COMMAND_TENSOR_DATA_TYPE_FLOAT16, + NV_META_COMMAND_TENSOR_DATA_TYPE_UINT32, + + NV_META_COMMAND_TENSOR_DATA_TYPE_COUNT, +}; + + +enum NV_META_COMMAND_TENSOR_LAYOUT +{ + NV_META_COMMAND_TENSOR_LAYOUT_UNKNOWN, // opaque HW-native layout + NV_META_COMMAND_TENSOR_LAYOUT_STANDARD, // NCDHW - planar / row major layout (width is inner-most dimension, batch-size N is the outermost) + NV_META_COMMAND_TENSOR_LAYOUT_COUNT, +}; + +enum NV_META_COMMAND_TENSOR_FLAGS +{ + NV_META_COMMAND_TENSOR_FLAG_NONE = 0, + NV_META_COMMAND_TENSOR_FLAG_DATA_STATIC = 0x1, // data pointed by the tensor is static (i.e, won't be modified after command list recording) +}; + +enum NV_META_COMMAND_PRECISION +{ + NV_META_COMMAND_PRECISION_FLOAT32, + NV_META_COMMAND_PRECISION_FLOAT16, + NV_META_COMMAND_PRECISION_MUL_FLOAT16_ADD_FLOAT32, + + NV_META_COMMAND_PRECISION_COUNT, +}; + +struct NV_META_COMMAND_TENSOR_DESC +{ + NvU64 DataType; // NV_META_COMMAND_TENSOR_DATA_TYPE + NvU64 Layout; // NV_META_COMMAND_TENSOR_LAYOUT + NvU64 Flags; // NV_META_COMMAND_TENSOR_FLAGS + NvU64 DimensionCount; // 4 or 5 + NvU64 Size[NV_META_COMMAND_MAX_TENSOR_DIM]; + NvU64 Stride[NV_META_COMMAND_MAX_TENSOR_DIM]; // only used with NV_META_COMMAND_TENSOR_LAYOUT_STANDARD +}; + +enum NV_META_COMMAND_ACTIVATION_FUNCTION +{ + NV_META_COMMAND_ACTIVATION_FUNCTION_ELU, + NV_META_COMMAND_ACTIVATION_FUNCTION_HARDMAX, + NV_META_COMMAND_ACTIVATION_FUNCTION_HARD_SIGMOID, + NV_META_COMMAND_ACTIVATION_FUNCTION_IDENTITY, + NV_META_COMMAND_ACTIVATION_FUNCTION_LEAKY_RELU, + NV_META_COMMAND_ACTIVATION_FUNCTION_LINEAR, + NV_META_COMMAND_ACTIVATION_FUNCTION_LOG_SOFTMAX, + NV_META_COMMAND_ACTIVATION_FUNCTION_PARAMETERIZED_RELU, + NV_META_COMMAND_ACTIVATION_FUNCTION_PARAMETRIC_SOFTPLUS, + NV_META_COMMAND_ACTIVATION_FUNCTION_RELU, + NV_META_COMMAND_ACTIVATION_FUNCTION_SCALED_ELU, + NV_META_COMMAND_ACTIVATION_FUNCTION_SCALED_TANH, + NV_META_COMMAND_ACTIVATION_FUNCTION_SIGMOID, + NV_META_COMMAND_ACTIVATION_FUNCTION_SOFTMAX, + NV_META_COMMAND_ACTIVATION_FUNCTION_SOFTPLUS, + NV_META_COMMAND_ACTIVATION_FUNCTION_SOFTSIGN, + NV_META_COMMAND_ACTIVATION_FUNCTION_TANH, + NV_META_COMMAND_ACTIVATION_FUNCTION_THRESHOLDED_RELU, + + NV_META_COMMAND_ACTIVATION_FUNCTION_COUNT, +}; + +struct NV_META_COMMAND_ACTIVATION_DESC +{ + NvU64 Function; // NV_META_COMMAND_ACTIVATION_FUNCTION + float Params[NV_META_COMMAND_ACTIVATION_MAX_PARAMS]; +}; + +#endif + +struct NV_META_COMMAND_OPTIONAL_TENSOR_DESC : NV_META_COMMAND_TENSOR_DESC +{ + // true when the tensor isn't needed (e.g, bias is optional) + NV_META_COMMAND_BOOL IsNull; +}; + + +struct NV_META_COMMAND_OPTIONAL_ACTIVATION_DESC : NV_META_COMMAND_ACTIVATION_DESC +{ + // true when activation isn't needed + NV_META_COMMAND_BOOL IsNull; +}; + + +enum NV_META_COMMAND_PADDING_MODE +{ + NV_META_COMMAND_PADDING_ZEROS, + NV_META_COMMAND_PADDING_MIRROR, + NV_META_COMMAND_PADDING_CLAMP, + NV_META_COMMAND_PADDING_CONSTANT, + + NV_META_COMMAND_PADDING_COUNT, +}; + +struct NV_META_COMMAND_PADDING_DESC +{ + NV_META_COMMAND_PADDING_MODE Mode; + + // used with NV_META_COMMAND_PADDING_CONSTANT + float ConstantPadVal; +}; + +// use this enum to query resource sizes using GetRequiredParameterResourceSize() call +enum NV_META_COMMAND_RESOURCE_TYPE +{ + NV_META_COMMAND_RESOURCE_TYPE_INPUT = 0, + NV_META_COMMAND_RESOURCE_TYPE_OUTPUT = 1, + + NV_META_COMMAND_RESOURCE_TYPE_FILTER = 2, + NV_META_COMMAND_RESOURCE_TYPE_WEIGHT = 2, + NV_META_COMMAND_RESOURCE_TYPE_BIAS = 3, + + NV_META_COMMAND_RESOURCE_TYPE_MATRIX_A = 0, + NV_META_COMMAND_RESOURCE_TYPE_MATRIX_B = 2, + NV_META_COMMAND_RESOURCE_TYPE_MATRIX_C = 3, + + NV_META_COMMAND_RESOURCE_TYPE_PERSISTENT = 4, + NV_META_COMMAND_RESOURCE_TYPE_TEMPORARY = 5, +}; + + +// Extended version of convolution operation that performs: +// +// y = act ( alpha1 * conv(x) + alpha2 * z + bias ) +// +// alpha1 and alpha2 are either scalars or if PerChannelScaling is TRUE, they are vectors of +// same dimension as the bias tensor (vector of size equal to number of output channels) +// +// z (SkipConnectionResource) has same dimension as output tensor y (OutputResource). + +static const GUID MetaCommand_ConvolutionEx = +{ 0xa7666f1e, 0x9c55, 0x47ee, { 0x9e, 0xb3, 0xe1, 0x62, 0x0, 0x92, 0xd1, 0xe9 } }; + +#define NV_META_COMMAND_NUM_SPATIAL_DIM 3 +// D, H, W when DimensionCount is 3 +// H, W when DimensionCount is 2 + + +#if __cplusplus >= 201103L +enum NV_META_COMMAND_CONVOLUTION_DIRECTION : NvU64 +{ + NV_META_COMMAND_CONVOLUTION_DIRECTION_FORWARD, // Corresponds to regular Convolution + NV_META_COMMAND_CONVOLUTION_DIRECTION_BACKWARD, // Corresponds to ConvolutionTranspose + + NV_META_COMMAND_CONVOLUTION_DIRECTION_COUNT, +}; + +enum NV_META_COMMAND_CONVOLUTION_MODE : NvU64 +{ + NV_META_COMMAND_CONVOLUTION_MODE_CONVOLUTION, + NV_META_COMMAND_CONVOLUTION_MODE_CROSS_CORRELATION, + + NV_META_COMMAND_CONVOLUTION_MODE_COUNT, +}; + +struct NV_META_COMMAND_CREATE_CONVOLUTION_EX_DESC +{ + // Descriptor of the input tensor + NV_META_COMMAND_TENSOR_DESC DescIn; + + // Descriptor of the tensor acting as the filter kernel + NV_META_COMMAND_TENSOR_DESC DescFilter; + + // Descriptor of the optional bias tensor + NV_META_COMMAND_OPTIONAL_TENSOR_DESC DescBias; + + // Descriptor of the output tensor + NV_META_COMMAND_TENSOR_DESC DescOut; + + // Convolution mode (CROSS_CORRELATION or CONVOLUTION) + NV_META_COMMAND_CONVOLUTION_MODE Mode; + + // Convolution direction (FORWARD or BACKWARD) + NV_META_COMMAND_CONVOLUTION_DIRECTION Direction; + + // Precision at which convolution is done + NV_META_COMMAND_PRECISION Precision; + + // Optional activation function + NV_META_COMMAND_OPTIONAL_ACTIVATION_DESC Activation; + + // Padding mode (only used when output tensor dimensions are different from input tensor dimensions) + NV_META_COMMAND_PADDING_DESC Padding; + + // enables per channel scaling i.e, use Alpha1Resource and Alpha2Resource + // instead of Alpha1 and Alpha2 below + NV_META_COMMAND_BOOL PerChannelScaling; + + // scaling factors used when PerChannelScaling is FALSE + // set Alpha1 = 1.0f, Alpha2 = 0.0f for simple convolutions + // that don't need scaling or skip connection + float Alpha1; + float Alpha2; + + // Strides for the filter kernel position + NvU64 Stride[NV_META_COMMAND_NUM_SPATIAL_DIM]; + + // The distance per dimension between elements that are multiplied + NvU64 Dilation[NV_META_COMMAND_NUM_SPATIAL_DIM]; + + // Padding at the start of each dimension + NvU64 StartPadding[NV_META_COMMAND_NUM_SPATIAL_DIM]; + + // Padding at the end of each dimension + NvU64 EndPadding[NV_META_COMMAND_NUM_SPATIAL_DIM]; + + // Number of dimensions to which convolution occurs (2 or 3) + NvU64 DimensionCount; + + // Number of channel groups convolved independently + NvU64 GroupCount; +}; + +#else + +enum NV_META_COMMAND_CONVOLUTION_DIRECTION +{ + NV_META_COMMAND_CONVOLUTION_DIRECTION_FORWARD, // Corresponds to regular Convolution + NV_META_COMMAND_CONVOLUTION_DIRECTION_BACKWARD, // Corresponds to ConvolutionTranspose + + NV_META_COMMAND_CONVOLUTION_DIRECTION_COUNT, +}; + +enum NV_META_COMMAND_CONVOLUTION_MODE +{ + NV_META_COMMAND_CONVOLUTION_MODE_CONVOLUTION, + NV_META_COMMAND_CONVOLUTION_MODE_CROSS_CORRELATION, + + NV_META_COMMAND_CONVOLUTION_MODE_COUNT, +}; + +struct NV_META_COMMAND_CREATE_CONVOLUTION_EX_DESC +{ + // Descriptor of the input tensor + NV_META_COMMAND_TENSOR_DESC DescIn; + + // Descriptor of the tensor acting as the filter kernel + NV_META_COMMAND_TENSOR_DESC DescFilter; + + // Descriptor of the optional bias tensor + NV_META_COMMAND_OPTIONAL_TENSOR_DESC DescBias; + + // Descriptor of the output tensor + NV_META_COMMAND_TENSOR_DESC DescOut; + + // Convolution mode (CROSS_CORRELATION or CONVOLUTION) + NvU64 Mode; // NV_META_COMMAND_CONVOLUTION_MODE + + // Convolution direction (FORWARD or BACKWARD) + NvU64 Direction; // NV_META_COMMAND_CONVOLUTION_DIRECTION + + // Precision at which convolution is done + NvU64 Precision; // NV_META_COMMAND_PRECISION + + // Optional activation function + NV_META_COMMAND_OPTIONAL_ACTIVATION_DESC Activation; + + // Padding mode (only used when output tensor dimensions are different from input tensor dimensions) + NV_META_COMMAND_PADDING_DESC Padding; + + // enables per channel scaling i.e, use Alpha1Resource and Alpha2Resource + // instead of Alpha1 and Alpha2 below + NV_META_COMMAND_BOOL PerChannelScaling; + + // scaling factors used when PerChannelScaling is FALSE + // set Alpha1 = 1.0f, Alpha2 = 0.0f for simple convolutions + // that don't need scaling or skip connection + float Alpha1; + float Alpha2; + + // Strides for the filter kernel position + NvU64 Stride[NV_META_COMMAND_NUM_SPATIAL_DIM]; + + // The distance per dimension between elements that are multiplied + NvU64 Dilation[NV_META_COMMAND_NUM_SPATIAL_DIM]; + + // Padding at the start of each dimension + NvU64 StartPadding[NV_META_COMMAND_NUM_SPATIAL_DIM]; + + // Padding at the end of each dimension + NvU64 EndPadding[NV_META_COMMAND_NUM_SPATIAL_DIM]; + + // Number of dimensions to which convolution occurs (2 or 3) + NvU64 DimensionCount; + + // Number of channel groups convolved independently + NvU64 GroupCount; +}; +#endif + + +// Fused Convolution variants + +// supported combinations right now are: +// - Convolution + Max Pooling (also optionally outputs pre-pool data) +// - 2x2 upsample + (optional) residual add + Convolution +// +// other combinations may be exposed in future + +static const GUID MetaCommand_ConvolutionExFused = +{ 0xe1b112eb, 0xdecd, 0x4ff6,{ 0x85, 0xbb, 0x1f, 0xe, 0x3a, 0xb0, 0x4, 0x14 } }; + + +enum NV_META_COMMAND_CONVOLUTION_POOL_MODE +{ + NV_META_COMMAND_CONVOLUTION_POOL_MODE_NONE, + NV_META_COMMAND_CONVOLUTION_POOL_MODE_REDUCTION_MAX, + NV_META_COMMAND_CONVOLUTION_POOL_MODE_REDUCTION_AVG, + NV_META_COMMAND_CONVOLUTION_POOL_MODE_REDUCTION_MIN, + + NV_META_COMMAND_CONVOLUTION_POOL_MODE_COUNT, +}; + +enum NV_META_COMMAND_CONVOLUTION_UPSAMPLE_MODE +{ + NV_META_COMMAND_CONVOLUTION_UPSAMPLE_MODE_NONE, + NV_META_COMMAND_CONVOLUTION_UPSAMPLE_MODE_REPLICATE, + NV_META_COMMAND_CONVOLUTION_UPSAMPLE_MODE_BILINEAR, + + NV_META_COMMAND_CONVOLUTION_UPSAMPLE_MODE_COUNT, +}; + +enum NV_META_COMMAND_CONVOLUTION_SKIP_MODE +{ + NV_META_COMMAND_CONVOLUTION_SKIP_MODE_NONE, + NV_META_COMMAND_CONVOLUTION_SKIP_MODE_ADD, + NV_META_COMMAND_CONVOLUTION_SKIP_MODE_CONCAT, + + NV_META_COMMAND_CONVOLUTION_SKIP_MODE_COUNT, +}; + +struct NV_META_COMMAND_CONVOLUTION_FUSE_DESC +{ + NV_META_COMMAND_CONVOLUTION_POOL_MODE PoolMode; + NV_META_COMMAND_CONVOLUTION_UPSAMPLE_MODE UpsampleMode; + NV_META_COMMAND_CONVOLUTION_SKIP_MODE SkipMode; + + NV_META_COMMAND_BOOL OutputPrepool; // used with NV_META_COMMAND_CONVOLUTION_POOL_MODE +}; + +// uses same structures for init and execute descriptors +// SkipConnectionResource is used to specify the resource for pre-pool data or residual add +struct NV_META_COMMAND_CREATE_CONVOLUTION_EX_FUSED_DESC : NV_META_COMMAND_CREATE_CONVOLUTION_EX_DESC +{ + NV_META_COMMAND_CONVOLUTION_FUSE_DESC FuseDesc; +}; + +// make sure structure sizes match what the driver assumes +compile_time_assert(sizeof(NV_META_COMMAND_TENSOR_DESC) == 112); +compile_time_assert(sizeof(NV_META_COMMAND_CREATE_CONVOLUTION_EX_DESC) == 640); +compile_time_assert(sizeof(NV_META_COMMAND_CONVOLUTION_FUSE_DESC) == 20); +compile_time_assert(sizeof(NV_META_COMMAND_CREATE_CONVOLUTION_EX_FUSED_DESC) == 660); + + +// GEMM (General matrix multiply) +// +// Y = alpha * t(A) * t(B) + beta * C, +// +// where t is a matrix transform option +// +// If C is null, and beta is non-zero, the output +// matrix is used as C matrix. i.e, the operation performed is: +// Y = alpha * t(A) * t(B) + beta * Y +// +static const GUID MetaCommand_Gemm = + { 0x8f9ff059, 0xfe72, 0x488e, { 0xa0, 0x66, 0xb1, 0x4e, 0x79, 0x48, 0xec, 0x8 } }; + +#if __cplusplus >= 201103L + +enum NV_META_COMMAND_MATRIX_TRANSFORM : NvU64 +{ + NV_META_COMMAND_MATRIX_TRANSFORM_NONE, + NV_META_COMMAND_MATRIX_TRANSFORM_TRANSPOSE, + + NV_META_COMMAND_MATRIX_TRANSFORM_COUNT, +}; + +struct NV_META_COMMAND_CREATE_GEMM_DESC +{ + NV_META_COMMAND_TENSOR_DESC DescA; + NV_META_COMMAND_TENSOR_DESC DescB; + NV_META_COMMAND_OPTIONAL_TENSOR_DESC DescC; + NV_META_COMMAND_TENSOR_DESC DescOut; + NV_META_COMMAND_PRECISION Precision; + + NV_META_COMMAND_MATRIX_TRANSFORM TransA; + NV_META_COMMAND_MATRIX_TRANSFORM TransB; + float Alpha; + float Beta; + + NV_META_COMMAND_OPTIONAL_ACTIVATION_DESC Activation; +}; + +#else + +enum NV_META_COMMAND_MATRIX_TRANSFORM +{ + NV_META_COMMAND_MATRIX_TRANSFORM_NONE, + NV_META_COMMAND_MATRIX_TRANSFORM_TRANSPOSE, + + NV_META_COMMAND_MATRIX_TRANSFORM_COUNT, +}; + +struct NV_META_COMMAND_CREATE_GEMM_DESC +{ + NV_META_COMMAND_TENSOR_DESC DescA; + NV_META_COMMAND_TENSOR_DESC DescB; + NV_META_COMMAND_OPTIONAL_TENSOR_DESC DescC; + NV_META_COMMAND_TENSOR_DESC DescOut; + NvU64 Precision; // NV_META_COMMAND_PRECISION + + NvU64 TransA; // NV_META_COMMAND_MATRIX_TRANSFORM + NvU64 TransB; // NV_META_COMMAND_MATRIX_TRANSFORM + float Alpha; + float Beta; + + NV_META_COMMAND_OPTIONAL_ACTIVATION_DESC Activation; +}; + +#endif + + +#pragma pack(pop) + +#endif // #if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) + + +#if defined (__cplusplus) && defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_EnumerateMetaCommands +// +//! \since Release: 400 +// +//! \code +//! DESCRIPTION: Enumerates MetaCommands supported on the system +//! +//! \param [in] pDevice A pointer to D3D11 device. +//! \param [in/out] pNumMetaCommands Should be non-null. When the value pointed by pNumMetaCommands is 0 (or when pDescs is NULL), the function returns number of metacommands supported. +//! When the value pointed is non-zero, the value indicates number of Metacommand descriptions to be populated in pDescs array. +//! \param [out] pDescs Pointer to array where Metacommand descriptions will be returned. Can be null to indicate that the app is querying the number of supported metacommands. +//! Otherwise should have enough space to hold *pNumMetaCommands descriptors +//! SUPPORTED OS: Windows 10 +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_EnumerateMetaCommands(__in ID3D11Device *pDevice, + __inout NvU32 *pNumMetaCommands, + __out_ecount_opt(*pNumMetaCommands) NVAPI_META_COMMAND_DESC *pDescs); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + + + +#if defined (__cplusplus) && defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateMetaCommand +// +//! \since Release: 400 +// +//! \code +//! DESCRIPTION: Creates a MetaCommand object which can be used to execute optimized operations exposed by driver like convolutions. +//! +//! \param [in] pDevice A pointer to D3D11 device. +//! \param [in] CommandId GUID of the operations to perform +//! \param [in] pCreationParametersData structure containing all creation parameters for the requested Metacommand +//! \param [in] CreationParametersDataSize size of parameter data structure +//! \param [out] ppMetaCommand A pointer to memory that receives the pointer to the created MetaCommand object. +//! SUPPORTED OS: Windows 10 +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! NVAPI_NOT_SUPPORTED - The requested Metacommand is not supported. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +#pragma pack(push, 4) +struct NV_D3D11_META_COMMAND_RESOURCE +{ + union + { + NVDX_ObjectHandle ResourceHandle; // NVAPI handle of a buffer resource (use NvAPI_D3D11_GetResourceHandle to get this handle) + NvU64 unused; // to get correct sturcutre size on 32 bit builds + }; + NvU64 Offset; // offset within the resource in bytes +}; + +struct NV_D3D11_META_COMMAND_INITIALIZE_CONVOLUTION_EX_DESC +{ + // Persistent resource used as scratch space by driver + // it's written at time of init, and read at time of execute + // use GetRequiredParameterResourceSize to query its size + NV_D3D11_META_COMMAND_RESOURCE PersistentResource; +}; + +struct NV_D3D11_META_COMMAND_EXECUTE_CONVOLUTION_EX_DESC +{ + NV_D3D11_META_COMMAND_RESOURCE InputResource; + NV_D3D11_META_COMMAND_RESOURCE FilterResource; + NV_D3D11_META_COMMAND_RESOURCE BiasResource; // optional + NV_D3D11_META_COMMAND_RESOURCE OutputResource; + + // Alpha1Resource and Alpha2Resource are used only when + // PerChannelScaling is set. Otherwise the scalars Alpha1/Alpha2 are used + // should have same dimension as bias + NV_D3D11_META_COMMAND_RESOURCE Alpha1Resource; + NV_D3D11_META_COMMAND_RESOURCE Alpha2Resource; + + // optional, same dimension/descriptor as output + NV_D3D11_META_COMMAND_RESOURCE SkipConnectionResource; + + + // should point to same memory that was specified at time of init + NV_D3D11_META_COMMAND_RESOURCE PersistentResource; + + // temporary resource used as scratch space by driver + // used for both read and write at the time of execute + // use GetRequiredParameterResourceSize to query its size + NV_D3D11_META_COMMAND_RESOURCE TemporaryResource; +}; + +// make sure structure sizes match what the driver assumes +compile_time_assert(sizeof(NV_D3D11_META_COMMAND_INITIALIZE_CONVOLUTION_EX_DESC) == 16); +compile_time_assert(sizeof(NV_D3D11_META_COMMAND_EXECUTE_CONVOLUTION_EX_DESC) == 144); + +struct NV_D3D11_META_COMMAND_INITIALIZE_GEMM_DESC +{ + NV_D3D11_META_COMMAND_RESOURCE PersistentResource; +}; + +struct NV_D3D11_META_COMMAND_EXECUTE_GEMM_DESC +{ + NV_D3D11_META_COMMAND_RESOURCE AResource; + NV_D3D11_META_COMMAND_RESOURCE BResource; + NV_D3D11_META_COMMAND_RESOURCE CResource; + NV_D3D11_META_COMMAND_RESOURCE OutputResource; + + NV_D3D11_META_COMMAND_RESOURCE PersistentResource; + NV_D3D11_META_COMMAND_RESOURCE TemporaryResource; +}; + +// make sure structure sizes match what the driver assumes +compile_time_assert(sizeof(NV_D3D11_META_COMMAND_INITIALIZE_GEMM_DESC) == 16); +compile_time_assert(sizeof(NV_D3D11_META_COMMAND_EXECUTE_GEMM_DESC) == 96); + + +#pragma pack(pop) + +DECLARE_INTERFACE_(__declspec(uuid("00BF193A-117B-42BC-BBCD-E964A0EA4F2B"))ID3D11NvMetaCommand_V1, IUnknown) +{ + BEGIN_INTERFACE + + // *** IUnknown methods *** + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppv) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // ** ID3D11NvMetaCommand methods *** + // Return size of parameter + STDMETHOD(GetRequiredParameterResourceSize)(THIS_ NV_META_COMMAND_RESOURCE_TYPE ResourceType, NvU64 *SizeInBytes) const PURE; + + END_INTERFACE +}; + +typedef ID3D11NvMetaCommand_V1 ID3D11NvMetaCommand; +#define ID3D11NvMetaCommand_VER1 MAKE_NVAPI_VERSION(IID3D11NvMetaCommand_V1, 1) +#define ID3D11NvMetaCommand_VER ID3D11NvMetaCommand_VER1 + +NVAPI_INTERFACE NvAPI_D3D11_CreateMetaCommand(__in ID3D11Device *pDevice, + __in REFGUID CommandId, + __in_bcount(CreationParametersDataSize) const void *pCreationParametersData, + __in NvU32 CreationParametersDataSize, + __out ID3D11NvMetaCommand **ppMetaCommand); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + + +#if defined (__cplusplus) && defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_InitializeMetaCommand +// +//! \since Release: 400 +// +//! \code +//! DESCRIPTION: Initializes the given MetaCommand with the parameters passed in +//! +//! \param [in] pDeviceContext A pointer to the d3d11 device context +//! \param [in] pMetaCommand the MetaCommand to initialize +//! \param [in] pInitializationParametersData Structure containing parameters +//! \param [in] InitializationParametersDataSize Size of the parameter structure in bytes +//! SUPPORTED OS: Windows 10 +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_InitializeMetaCommand(__in ID3D11DeviceContext *pDeviceContext, + __in ID3D11NvMetaCommand *pMetaCommand, + __in_bcount(InitializationParametersDataSize) const void *pInitializationParametersData, + __in NvU32 InitializationParametersDataSize); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + + +#if defined (__cplusplus) && defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_ExecuteMetaCommand +// +//! \since Release: 400 +// +//! \code +//! DESCRIPTION: Executes the given MetaCommand with the parameters passed in +//! +//! \param [in] pDeviceContext A pointer to the d3d11 device context +//! \param [in] pMetaCommand the MetaCommand to execute +//! \param [in] pExecutionParametersData Structure containing parameters +//! \param [in] ExecutionParametersDataSize Size of the parameter structure in bytes +//! SUPPORTED OS: Windows 10 +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_ExecuteMetaCommand(__in ID3D11DeviceContext *pDeviceContext, + __in ID3D11NvMetaCommand *pMetaCommand, + __in_bcount(ExecutionParametersDataSize) const void *pExecutionParametersData, + __in NvU32 ExecutionParametersDataSize); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + + + + +#if defined (__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_EnumerateMetaCommands +// +//! \since Release: 400 +// +//! \code +//! DESCRIPTION: Enumerates MetaCommands supported on the system +//! +//! \param [in] pDevice A pointer to D3D12 device. +//! \param [in/out] pNumMetaCommands Should be non-null. When the value pointed by pNumMetaCommands is 0 or when pDescs is NULL, the function returns number of metacommands supported. +//! When the value pointed is non-zero, the value indicates number of Metacommand descriptions to be populated in pDescs array. +//! \param [out] pDescs Pointer to array where Metacommand descriptions will be returned. Can be null to indicate that the app is querying the number of supported metacommands. +//! Otherwise should have enough space to hold *pNumMetaCommands descriptors +//! SUPPORTED OS: Windows 10 +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_EnumerateMetaCommands(__in ID3D12Device *pDevice, + __inout NvU32 *pNumMetaCommands, + __out_ecount_opt(*pNumMetaCommands) NVAPI_META_COMMAND_DESC *pDescs); + +#endif //defined(__cplusplus) && defined(__d3d12_h__) + + + +#if defined (__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_CreateMetaCommand +// +//! \since Release: 400 +// +//! \code +//! DESCRIPTION: Creates a MetaCommand object which can be used to execute optimized operations exposed by driver like convolutions. +//! +//! \param [in] pDevice A pointer to D3D12 device. +//! \param [in] CommandId GUID of the operations to perform +//! \param [in] NodeMask GPU mask for which metacommand is to be created. Set it to 0 for single GPU systems +//! \param [in] pCreationParametersData structure containing all creation parameters for the requested Metacommand +//! \param [in] CreationParametersDataSize size of parameter data structure +//! \param [out] ppMetaCommand A pointer to memory that receives the pointer to the created MetaCommand object. +//! SUPPORTED OS: Windows 10 +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! NVAPI_NOT_SUPPORTED - The requested Metacommand is not supported. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +#pragma pack(push, 4) +struct NV_D3D12_META_COMMAND_INITIALIZE_CONVOLUTION_EX_DESC +{ + // Persistent resource used as scratch space by driver + // it's written at time of init, and read at time of execute + // use GetRequiredParameterResourceSize to query its size + D3D12_GPU_VIRTUAL_ADDRESS PersistentResource; +}; + +struct NV_D3D12_META_COMMAND_EXECUTE_CONVOLUTION_EX_DESC +{ + D3D12_GPU_VIRTUAL_ADDRESS InputResource; + D3D12_GPU_VIRTUAL_ADDRESS FilterResource; + D3D12_GPU_VIRTUAL_ADDRESS BiasResource; // optional + D3D12_GPU_VIRTUAL_ADDRESS OutputResource; + + // Alpha1Resource and Alpha2Resource are used only when + // PerChannelScaling is set. Otherwise the scalars Alpha1/Alpha2 are used + // should have same dimension as bias + D3D12_GPU_VIRTUAL_ADDRESS Alpha1Resource; + D3D12_GPU_VIRTUAL_ADDRESS Alpha2Resource; + + // optional, same dimension/descriptor as output + D3D12_GPU_VIRTUAL_ADDRESS SkipConnectionResource; + + // should point to same memory that was specified at time of init + D3D12_GPU_VIRTUAL_ADDRESS PersistentResource; + + // temporary resource used as scratch space by driver + // both written and read at time of execute + // use GetRequiredParameterResourceSize to query its size + D3D12_GPU_VIRTUAL_ADDRESS TemporaryResource; +}; + +// make sure structure sizes match what the driver assumes +compile_time_assert(sizeof(NV_D3D12_META_COMMAND_INITIALIZE_CONVOLUTION_EX_DESC) == 8); +compile_time_assert(sizeof(NV_D3D12_META_COMMAND_EXECUTE_CONVOLUTION_EX_DESC) == 72); + +struct NV_D3D12_META_COMMAND_INITIALIZE_GEMM_DESC +{ + NvU64 PersistentResource; +}; + +struct NV_D3D12_META_COMMAND_EXECUTE_GEMM_DESC +{ + NvU64 AResource; + NvU64 BResource; + NvU64 CResource; + NvU64 OutputResource; + + NvU64 PersistentResource; + NvU64 TemporaryResource; +}; + +// make sure structure sizes match what the driver assumes +compile_time_assert(sizeof(NV_D3D12_META_COMMAND_INITIALIZE_GEMM_DESC) == 8); +compile_time_assert(sizeof(NV_D3D12_META_COMMAND_EXECUTE_GEMM_DESC) == 48); + + +#pragma pack(pop) + +DECLARE_INTERFACE_(__declspec(uuid("00BF193A-117B-42BC-BBCD-E964A0EA4F2B"))ID3D12NvMetaCommand_V1, IUnknown) +{ + BEGIN_INTERFACE + + // *** IUnknown methods *** + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppv) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // ** ID3D12NvMetaCommand methods *** + // Return size of parameter + STDMETHOD(GetRequiredParameterResourceSize)(THIS_ NV_META_COMMAND_RESOURCE_TYPE ResourceType, NvU64 *SizeInBytes) const PURE; + + END_INTERFACE +}; + +typedef ID3D12NvMetaCommand_V1 ID3D12NvMetaCommand; +#define ID3D12NvMetaCommand_VER1 MAKE_NVAPI_VERSION(IID3D12NvMetaCommand_V1, 1) +#define ID3D12NvMetaCommand_VER ID3D12NvMetaCommand_VER1 + +NVAPI_INTERFACE NvAPI_D3D12_CreateMetaCommand(__in ID3D12Device *pDevice, + __in REFGUID CommandId, + __in NvU32 NodeMask, + __in_bcount(CreationParametersDataSize) const void *pCreationParametersData, + __in NvU32 CreationParametersDataSize, + __out ID3D12NvMetaCommand **ppMetaCommand); + +#endif //defined(__cplusplus) && defined(__d3d12_h__) + + +#if defined (__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_InitializeMetaCommand +// +//! \since Release: 400 +// +//! \code +//! DESCRIPTION: Initializes the given MetaCommand with the parameters passed in +//! +//! \param [in] pCommandList A pointer to D3D12 command list. +//! \param [in] pMetaCommand the MetaCommand to initialize +//! \param [in] pInitializationParametersData Structure containing parameters +//! \param [in] InitializationParametersDataSize Size of the parameter structure in bytes +//! SUPPORTED OS: Windows 10 +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_InitializeMetaCommand(__in ID3D12GraphicsCommandList *pCommandlist, + __in ID3D12NvMetaCommand *pMetaCommand, + __in_bcount(InitializationParametersDataSize) const void *pInitializationParametersData, + __in NvU32 InitializationParametersDataSize); + +#endif //defined(__cplusplus) && defined(__d3d12_h__) + + +#if defined (__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_ExecuteMetaCommand +// +//! \since Release: 400 +// +//! \code +//! DESCRIPTION: Executes the given MetaCommand with the parameters passed in +//! +//! \param [in] pCommandList A pointer to D3D12 command list. +//! \param [in] pMetaCommand the MetaCommand to execute +//! \param [in] pExecutionParametersData Structure containing parameters +//! \param [in] ExecutionParametersDataSize Size of the parameter structure in bytes +//! SUPPORTED OS: Windows 10 +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_ExecuteMetaCommand(__in ID3D12GraphicsCommandList *pCommandlist, + __in ID3D12NvMetaCommand *pMetaCommand, + __in_bcount(ExecutionParametersDataSize) const void *pExecutionParametersData, + __in NvU32 ExecutionParametersDataSize); + +#endif //defined(__cplusplus) && defined(__d3d12_h__) + + +#if defined (__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_CreateCommittedResource +// +//! \since Release: 384 +// +//! \code +//! DESCRIPTION: Wrapper around ID3D12Device::CreateCommittedResource to allow creation of resources according to params provided. +//! HTEX resource is created when NV_D3D12_RESOURCE_FLAG_HTEX is set in the nvResourceFlags parameter. +//! NV_D3D12_RESOURCE_FLAG_CPUVISIBLE_VIDMEM gives driver hint to create the resource on cpu visible vidmem +//! only upload resources use this flag currently, others behave exactly as ID3D12Device::CreateCommittedResource +//! Otherwise the function behaves exactly same as regular ID3D12Device::CreateCommittedResource. +//! When NV_D3D12_RESOURCE_FLAG_HTEX is set, the texels are centered on integer coordinates and filtering +//! and LOD are calculated based on the size minus one, which then allows the edges to filter to the exact texels on the edge, +//! eliminating the border/edge filtering issue. Dimension of next mip level is CEIL(currentMipDimension/2), and size of smallest mip is 2x2. +//! Note that NV_D3D12_RESOURCE_FLAG_HTEX can't be used for shared resources. +//! Best practice: Query available space in cpu visible vidmem using NvAPI_D3D12_QueryCpuVisibleVidmem +//! before using NV_D3D12_RESOURCE_FLAG_CPUVISIBLE_VIDMEM +//! +//! \param [in] pDevice A pointer to D3D12 device. +//! \param [in] pHeapProperties A pointer to a D3D12_HEAP_PROPERTIES structure that provides properties for the resource's heap. +//! \param [in] HeapFlags Heap options, as a bitwise-OR'd combination of D3D12_HEAP_FLAGS enumeration constants. +//! \param [in] pDesc A pointer to a D3D12_RESOURCE_DESC structure that describes the resource. +//! \param [in] InitialState The initial state of the resource, as a bitwise-OR'd combination of D3D12_RESOURCE_STATES enumeration constants. +//! \param [in] pOptimizedClearValue Specifies a D3D12_CLEAR_VALUE that describes the default value for a clear color. +//! \param [in] pNVResourceParams A pointer to a structure containing additional NV specific resource creation information (see NV_D3D12_RESOURCE_FLAGS below for more info on flags) +//! \param [in] riid The globally unique identifier (GUID) for the resource interface. +//! \param [out] ppvResource A pointer to memory that receives the requested interface pointer to the created resource object. +//! ppvResource can be NULL, to enable capability testing. When ppvResource is NULL, no object will be created and pSupported +//! will be set to true when pResourceDesc is valid. +//! \param [out] pSupported optional, needed only for capability testing when ppvResource is NULL +//! SUPPORTED OS: Windows 10 +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +typedef enum { + NV_D3D12_RESOURCE_FLAG_NONE = 0, + NV_D3D12_RESOURCE_FLAG_HTEX = 1, //!< Create HTEX texture + NV_D3D12_RESOURCE_FLAG_CPUVISIBLE_VIDMEM= 2, //!< Hint to create resource in cpuvisible vidmem +} NV_D3D12_RESOURCE_FLAGS; + +typedef struct _NV_RESOURCE_PARAMS_V1 +{ + NvU32 version; //!SetFence(dstGpu, hFence, Value); \ + pMultiGPUDevice->WaitForFence(1 << (srcGpu), hFence, Value); \ + Value++; + +#define FENCE_SYNCHRONIZATION_END(pMultiGPUDevice, hFence, Value, srcGpu, dstGpu) \ + pMultiGPUDevice->SetFence(srcGpu, hFence, Value); \ + pMultiGPUDevice->WaitForFence(1 << (dstGpu), hFence, Value); \ + Value++; + +//! PresentCompositingConfig method flags. +#define NVAPI_PRESENT_COMPOSITING_CONFIG_FLAG_USE_VIDEO_BRIDGE 0x01 +#define NVAPI_PRESENT_COMPOSITING_CONFIG_FLAG_CLEAR_OUTBANDS 0x02 +#define NVAPI_PRESENT_COMPOSITING_CONFIG_FLAG_GET_VIDEO_BRIDGE_STATUS 0x80000000 + +#define NVAPI_VIDEO_BRIDGE_STATUS_AVAILABLE 0 +#define NVAPI_VIDEO_BRIDGE_STATUS_NOT_AVAILABLE 1 +#define NVAPI_VIDEO_BRIDGE_STATUS_FAILED_ACCESS 2 +#define NVAPI_VIDEO_BRIDGE_STATUS_UNKNOWN 3 + +#define NVAPI_ALL_GPUS 0 +typedef ID3D11MultiGPUDevice_V1 ID3D11MultiGPUDevice; + +#define ID3D11MultiGPUDevice_VER1 MAKE_NVAPI_VERSION(ID3D11MultiGPUDevice_V1, 1) +#define ID3D11MultiGPUDevice_VER2 MAKE_NVAPI_VERSION(ID3D11MultiGPUDevice_V1, 2) +#define ID3D11MultiGPUDevice_VER3 MAKE_NVAPI_VERSION(ID3D11MultiGPUDevice_V1, 3) +#define ID3D11MultiGPUDevice_VER ID3D11MultiGPUDevice_VER3 + +#define ALL_GPUS 0 + +//! \ingroup dx +NVAPI_INTERFACE NvAPI_D3D11_CreateMultiGPUDevice(__in ID3D11Device *pDevice, __in ULONG version, __out ULONG *currentVersion, __out ID3D11MultiGPUDevice **ppD3D11MultiGPUDevice, __in UINT maxGpus=ALL_GPUS); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + +//! SUPPORTED OS: Windows 7 and higher +//! +//! Used to query the support of Single Pass Stereo HW feature +//! \ingroup dx +typedef struct _NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_V1 +{ + NvU32 version; // parameter struct version + NvU32 bSinglePassStereoSupported; // Single Pass Stereo supported +} NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_V1; + +typedef struct _NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_V2 +{ + NvU32 version; // _IN_ parameter struct version + NvU32 bSinglePassStereoSupported : 1; // _OUT_ Single Pass Stereo supported + NvU32 bSinglePassStereoXYZWSupported : 1; // _OUT_ Single Pass Stereo XYZW supported + NvU32 reserved : 30; // _INOUT_ bits reserved for future use +} NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_V2; + +typedef NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_V2 NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS; +#define NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_V1, 1) +#define NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_VER2 MAKE_NVAPI_VERSION(NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_V2, 2) +#define NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_VER NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_VER2 + +#ifndef NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_VER +typedef NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_V1 NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS; +#define NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_V1, 1) +#define NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_VER NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS_VER1 +#endif + +#if defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_QuerySinglePassStereoSupport +// +//! DESCRIPTION: Queries the support of Single Pass Stereo feature on current setup and returns appropriate boolean value. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDevice The ID3D11Device to use. +//! \param [inout] pSinglePassStereoSupportedParams Stores value of whether Single Pass Stereo is supported on current setup or not. +//! +//! \retval NVAPI_OK Call succeeded. +//! \retval NVAPI_ERROR Call failed. +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_QuerySinglePassStereoSupport(__in IUnknown *pDevice, + __inout NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS *pQuerySinglePassStereoSupportedParams); + +#endif //defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) + +#if defined(__cplusplus) && defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_SetSinglePassStereoMode +// +//! DESCRIPTION: Set the Single Pass Stereo state +//! +//! \note Note that this is an asynchronous function and returns NVAPI_OK if all arguments are valid. +//! Returned value NVAPI_OK does not reflect that Single Pass Stereo is supported or is set in hardware. +//! One must call NvAPI_D3D_QuerySinglePassStereoSupport() to confirm that the current setup +//! supports Single Pass Stereo before calling this set-function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDevOrContext The ID3D11Device or ID3D11DeviceContext to use. +//! \param [in] numViews Number of views to render. +//! \param [in] renderTargetIndexOffset Offset between render targets of the different views. +//! \param [in] independentViewportMaskEnable Is the independent viewport mask enabled. +//! +//! \retval NVAPI_OK Call succeeded. +//! \retval NVAPI_ERROR Call failed. +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_SetSinglePassStereoMode(__in IUnknown *pDevOrContext, __in NvU32 numViews, __in NvU32 renderTargetIndexOffset, __in NvU8 independentViewportMaskEnable); + +#endif //defined(__cplusplus) && defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) + +#if defined(__cplusplus) && ( defined(__d3d12_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_QuerySinglePassStereoSupport +// +//! DESCRIPTION: Queries the support of Single Pass Stereo feature on current setup and returns appropriate boolean value. +//! +//! SUPPORTED OS: Windows 10 +//! +//! +//! \param [in] pDevice The IDirect3DDevice12 to use. +//! \param [inout] pQuerySinglePassStereoSupportedParams Stores value of whether Single Pass Stereo is supported on current setup or not. +//! +//! \retval NVAPI_OK Call succeeded. +//! \retval NVAPI_ERROR Call failed. +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_QuerySinglePassStereoSupport(__in ID3D12Device *pDevice, + __inout NV_QUERY_SINGLE_PASS_STEREO_SUPPORT_PARAMS *pQuerySinglePassStereoSupportedParams); + +#endif // defined(__cplusplus) && ( defined(__d3d12_h__)) + +#if defined(__cplusplus) && ( defined(__d3d12_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_SetSinglePassStereoMode +// +//! DESCRIPTION: Set the Single Pass Stereo state. +//! +//! \note Note that Single Pass Stereo state persists on a particular CommandList till it is closed. +//! The state is reset to default (disabled) for every newly created CommandList. +//! One must call NvAPI_D3D12_QuerySinglePassStereoSupport() to confirm that the current setup +//! supports Single Pass Stereo before calling this set-function. +//! +//! SUPPORTED OS: Windows 10 +//! +//! +//! \param [in] pCommandList The command list in which we will add push buffer commmands for enabling Single Pass Stereo feature +//! Note: Command list of type D3D12_COMMAND_LIST_TYPE_BUNDLE is not allowed for setting the state of this feature. +//! \param [in] numViews Number of views to render. +//! \param [in] RenderTargetIndexOffset Offset between render targets of the different views. +//! \param [in] IndependentViewportMaskEnable Is the independent viewport mask enabled. +//! +//! \retval NVAPI_OK Call succeeded. +//! \retval NVAPI_ERROR Call failed. +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_SetSinglePassStereoMode(__in ID3D12GraphicsCommandList* pCommandList, + __in NvU32 numViews, + __in NvU32 renderTargetIndexOffset, + __in NvU8 independentViewportMaskEnable); + +#endif // defined(__cplusplus) && ( defined(__d3d12_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! +//! Used to query the support of MultiView HW feature +//! \ingroup dx + +typedef struct _NV_QUERY_MULTIVIEW_SUPPORT_PARAMS_V1 +{ + NvU32 version; // _IN_ parameter struct version + NvU32 bMultiViewSupported : 1; // _OUT_ MultiView supported (Render 4 views in a single pass) + NvU32 bSinglePassStereoSupported : 1; // _OUT_ StereoX supported (Render 2 views in a single pass) + NvU32 bSinglePassStereoXYZWSupported : 1; // _OUT_ StereoXYZW supported (Render 2 views in a single pass) + NvU32 reserved : 29; // _INOUT_ bits reserved for future use +} NV_QUERY_MULTIVIEW_SUPPORT_PARAMS_V1; + +typedef NV_QUERY_MULTIVIEW_SUPPORT_PARAMS_V1 NV_QUERY_MULTIVIEW_SUPPORT_PARAMS; +#define NV_QUERY_MULTIVIEW_SUPPORT_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_QUERY_MULTIVIEW_SUPPORT_PARAMS_V1, 1) +#define NV_QUERY_MULTIVIEW_SUPPORT_PARAMS_VER NV_QUERY_MULTIVIEW_SUPPORT_PARAMS_VER1 +#define NV_MULTIVIEW_MAX_SUPPORTED_VIEWS 4 + +#if defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_QueryMultiViewSupport +// +//! DESCRIPTION: Queries the support of MultiView feature on current setup and returns appropriate boolean value. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 410 +//! +//! \param [in] pDevice The ID3D11Device to use. +//! \param [inout] pMultiViewSupportedParams Stores value of whether MultiView is supported on current setup or not. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_QueryMultiViewSupport(__in IUnknown *pDevice, + __inout NV_QUERY_MULTIVIEW_SUPPORT_PARAMS *pQueryMultiViewSupportedParams); + +#endif //defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! +//! Used for setting the Mode for MultiView HW Feature. +//! \ingroup dx +typedef struct _NV_MULTIVIEW_PARAMS_V1 +{ + NvU32 version; // _IN_ parameter struct version + NvU32 numViews; // _IN_ Number of views to render. + NvU32 renderTargetIndexOffset[NV_MULTIVIEW_MAX_SUPPORTED_VIEWS]; // _IN_ Offset between render targets for each of the per views. + NvU8 independentViewportMaskEnable; // _IN_ Is the independent viewport mask enabled. +} NV_MULTIVIEW_PARAMS_V1; + +typedef NV_MULTIVIEW_PARAMS_V1 NV_MULTIVIEW_PARAMS; +#define NV_MULTIVIEW_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_MULTIVIEW_PARAMS_V1, 1) +#define NV_MULTIVIEW_PARAMS_VER NV_MULTIVIEW_PARAMS_VER1 + +#if defined(__cplusplus) && defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_SetMultiViewMode +// +//! DESCRIPTION: Set the MultiView state +//! +//! \note Note that this is an asynchronous function and returns NVAPI_OK if all arguments are valid. +//! Returned value NVAPI_OK does not reflect that MultiView is supported or is set in hardware. +//! One must call NvAPI_D3D_QueryMultiViewSupport() to confirm that the current setup +//! supports MultiView before calling this set-function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 410 +//! +//! \param [in] pDevOrContext The ID3D11Device or ID3D11DeviceContext to use. +//! \param [in] pMultiViewParams MultiView Params +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_SetMultiViewMode(__in IUnknown *pDevOrContext, __in NV_MULTIVIEW_PARAMS *pMultiViewParams); + +#endif //defined(__cplusplus) && defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) + +//! SUPPORTED OS: Windows 7 and higher +//! +//! Used to query the support of Lens Matched Shading HW feature +//! \ingroup dx +typedef struct _NV_QUERY_MODIFIED_W_SUPPORT_PARAMS +{ + NvU32 version; // parameter struct version + NvU32 bModifiedWSupported; // Modified W supported +} NV_QUERY_MODIFIED_W_SUPPORT_PARAMS_V1; + +typedef NV_QUERY_MODIFIED_W_SUPPORT_PARAMS_V1 NV_QUERY_MODIFIED_W_SUPPORT_PARAMS; +#define NV_QUERY_MODIFIED_W_SUPPORT_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_QUERY_MODIFIED_W_SUPPORT_PARAMS_V1, 1) +#define NV_QUERY_MODIFIED_W_SUPPORT_PARAMS_VER NV_QUERY_MODIFIED_W_SUPPORT_PARAMS_VER1 + +#if defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_QueryModifiedWSupport +// +//! DESCRIPTION: Queries the support of Modified W feature on current setup and returns appropriate boolean value. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDevice The ID3D11Device to use. +//! \param [inout] pQueryModifiedWSupportedParams Stores value of whether Modified W is supported on current setup or not. +//! +//! \retval NVAPI_OK Call succeeded. +//! \retval NVAPI_ERROR Call failed. +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_QueryModifiedWSupport(__in IUnknown *pDev, + __inout NV_QUERY_MODIFIED_W_SUPPORT_PARAMS *pQueryModifiedWSupportedParams); +#endif //defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! +#define NV_MODIFIED_W_MAX_VIEWPORTS 16 + +typedef struct _NV_MODIFIED_W_COEFFICIENTS +{ + float fA; // A coefficient in w' = w + Ax + By + float fB; // B coefficient in w' = w + Ax + By + float fAReserved; // reserved + float fBReserved; // reserved + + float fReserved[2]; // reserved +} NV_MODIFIED_W_COEFFICIENTS; + +typedef struct _NV_MODIFIED_W_PARAMS +{ + NvU32 version; // parameter struct version + NvU32 numEntries; // number of valid NV_MODIFIED_W_COEFFICIENTS structs in array + NV_MODIFIED_W_COEFFICIENTS modifiedWCoefficients[NV_MODIFIED_W_MAX_VIEWPORTS]; // coefficients + + NvU32 id; // reserved + NvU32 reserved[NV_MODIFIED_W_MAX_VIEWPORTS]; // reserved +} NV_MODIFIED_W_PARAMS_V1; + +typedef NV_MODIFIED_W_PARAMS_V1 NV_MODIFIED_W_PARAMS; +#define NV_MODIFIED_W_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_MODIFIED_W_PARAMS_V1, 1) +#define NV_MODIFIED_W_PARAMS_VER NV_MODIFIED_W_PARAMS_VER1 + +#if defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_SetModifiedWMode +// +//! DESCRIPTION: Set the Modified W state and A,B coefficients for HW support +//! +//! \note Note that this is an asynchronous function and returns NVAPI_OK if all arguments are valid. +//! Returned value NVAPI_OK does not reflect that Modified-W is supported or is set in hardware. +//! One must call NvAPI_D3D_QueryModifiedWSupport() to confirm that the current setup +//! supports Modified-W before calling this set-function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDevOrContext The ID3D11Device or ID3D11DeviceContext to use. +//! \param [in] psModifiedWParams Modified W parameters. +//! +//! \retval NVAPI_OK Call succeeded. +//! \retval NVAPI_ERROR Call failed. +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_SetModifiedWMode(__in IUnknown *pDevOrContext, __in NV_MODIFIED_W_PARAMS *psModifiedWParams); + +#endif //defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) + +#if defined(__cplusplus) && ( defined(__d3d12_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_QueryModifiedWSupport +// +//! DESCRIPTION: Queries the support of Modified-W feature on current setup and returns appropriate boolean value. +//! +//! SUPPORTED OS: Windows 10 +//! +//! +//! \param [in] pDevice The ID3D12Device Device created by application +//! \param [inout] pQueryModifiedWSupportedParams Stores value of whether Modified-W is supported on current setup or not. +//! +//! \retval NVAPI_OK Call succeeded. +//! \retval NVAPI_ERROR Call failed. +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_QueryModifiedWSupport(__in ID3D12Device *pDevice, + __inout NV_QUERY_MODIFIED_W_SUPPORT_PARAMS *pQueryModifiedWSupportedParams); + +#endif // defined(__cplusplus) && ( defined(__d3d12_h__)) + +#if defined(__cplusplus) && ( defined(__d3d12_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_SetModifiedWMode +// +//! DESCRIPTION: Set the Modified-W state and A, B coefficients for HW support +//! +//! \note Note that Modified-W state persists on a particular CommandList till it is closed. +//! The state is reset to default (disabled) for every newly created CommandList. +//! One must call NvAPI_D3D12_QueryModifiedWSupport() to confirm that the current setup +//! supports Modified-W before calling this set-function. +//! +//! SUPPORTED OS: Windows 10 +//! +//! +//! \param [in] pCommandList The command list in which we will add push buffer commmands for enabling Modified-W feature +//! Note: Command list of type D3D12_COMMAND_LIST_TYPE_BUNDLE is not allowed for setting the state of this feature. +//! \param [in] pModifiedWParams Modified-W parameters. +//! +//! \retval NVAPI_OK Call succeeded. +//! \retval NVAPI_ERROR Call failed. +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_SetModifiedWMode(__in ID3D12GraphicsCommandList* pCommandList, + __in NV_MODIFIED_W_PARAMS *pModifiedWParams); + +#endif // defined(__cplusplus) && ( defined(__d3d12_h__)) + + +#if defined(__cplusplus) && (defined(__d3d11_h__)) + +//! \ingroup dx +//! See NvAPI_D3D_CreateLateLatchObject +DECLARE_INTERFACE(ID3DLateLatchObject_V1) +{ + STDMETHOD_(UINT,Release) (THIS) PURE; //! Release the created LateLatch object and associated buffers. + STDMETHOD_(NvAPI_Status,Latch) (THIS_ __in IUnknown* pContext = NULL) PURE; //! Request to queue the latch operation to the GPU. + STDMETHOD_(ID3D11Buffer*,GetD3D11Buffer) (THIS_ __in UINT index = 0) PURE; //! Get ID3D11Buffer* available at the given 'index' + STDMETHOD_(UINT,GetBufferCount) (THIS) PURE; //! Returns the number of late latch buffers created for this LateLatchObject. + STDMETHOD_(NvAPI_Status,UpdateData) (THIS_ __in void **ppData) PURE; //! Fully update all LateLatch buffers with new data. + STDMETHOD_(NvAPI_Status,UpdateData) (THIS_ __in void *pData, __in size_t offset, + __in size_t size, __in UINT index = 0) PURE; //! Partially update one of the LateLatch buffers with new data. +}; + +//! \ingroup dx +//! See NvAPI_D3D_CreateLateLatchObject +typedef ID3DLateLatchObject_V1 ID3DLateLatchObject; +#define ID3DLateLatchObject_VER1 MAKE_NVAPI_VERSION(ID3DLateLatchObject_V1, 1) +#define ID3DLateLatchObject_VER ID3DLateLatchObject_VER1 + +typedef struct _NV_D3D_LATELATCH_OBJECT_DESC_V1 +{ + NvU32 version; + NvU32 numBuffers; // _IN_ Number of LateLatch buffers that the app wants to create. + D3D11_BUFFER_DESC **ppBufferDesc; // _IN_ Description of buffers + ID3DLateLatchObject **ppD3DLateLatchObject; // _Out_ Pointer to created interface +} NV_D3D_LATELATCH_OBJECT_DESC_V1; + +typedef NV_D3D_LATELATCH_OBJECT_DESC_V1 NV_D3D_LATELATCH_OBJECT_DESC; +#define NV_D3D_LATELATCH_OBJECT_DESC_VER1 MAKE_NVAPI_VERSION(NV_D3D_LATELATCH_OBJECT_DESC_V1, 1) +#define NV_D3D_LATELATCH_OBJECT_DESC_VER NV_D3D_LATELATCH_OBJECT_DESC_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_CreateLateLatchObject +// +//! DESCRIPTION: Creates a Late Latch Object interface +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 384 +//! +//! \param [in] pDevice Current ID3D11Device. +//! \param [inout] pLateLatchObjectDesc Pointer to in/out structure for late latch object creation +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D_CreateLateLatchObject(__in IUnknown *pDevice, __inout NV_D3D_LATELATCH_OBJECT_DESC* pLateLatchObjectDesc); + +#endif // defined(__cplusplus) && (defined(__d3d11_h__)) + + + +#if defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) +//! \ingroup dx +//! See NvAPI_D3D_QueryLateLatchSupport +typedef struct _NV_QUERY_LATELATCH_SUPPORT_PARAMS +{ + NvU32 version; //!< (IN) Parameter structure version + NvU32 bLateLatchSupported; //!< (OUT) LateLatch supported +} NV_QUERY_LATELATCH_SUPPORT_PARAMS_V1; + +typedef NV_QUERY_LATELATCH_SUPPORT_PARAMS_V1 NV_QUERY_LATELATCH_SUPPORT_PARAMS; +#define NV_QUERY_LATELATCH_SUPPORT_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_QUERY_LATELATCH_SUPPORT_PARAMS_V1, 1) +#define NV_QUERY_LATELATCH_SUPPORT_PARAMS_VER NV_QUERY_LATELATCH_SUPPORT_PARAMS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_QueryLateLatchSupport +// +//! DESCRIPTION: Queries the support of DX11 Late Latch feature on current setup. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 384 +//! +//! \param [in] pDevice Current ID3D11Device. +//! \param [inout] pQueryLateLatchSupportParams Stores value of whether Late Latch is supported on current setup or not. +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_QueryLateLatchSupport(__in IUnknown *pDevice, + __inout NV_QUERY_LATELATCH_SUPPORT_PARAMS *pQueryLateLatchSupportParams); +#endif // defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) + + + +#if defined (__cplusplus) && (defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_RegisterDevice +// +//! DESCRIPTION: Tells NvAPI about a D3D device. This must be called prior to using any DX1x +//! deferred-context calls. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDev The ID3D10Device or ID3D11Device to use. +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_RegisterDevice(__in IUnknown *pDev); + +#endif //if defined(__cplusplus) && (defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) + + + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_MultiDrawInstancedIndirect +// +//! DESCRIPTION: Extension of DrawInstancedIndirect that takes a draw count in. The effect of this function is to loop over +//! that draw count and perform the DrawInstancedIndirect operation each time, incrementing the buffer offset +//! by the supplied stride each time. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] *pDevContext11 Pointer to D3D11 device context (IC or DC) +//! \param [in] drawCount Do DrawInstancedIndirect operation this many times +//! \param [in] *pBuffer ID3D11Buffer that contains the command parameters +//! \param [in] alignedByteOffsetForArgs Start in pBuffer of the command parameters +//! \param [in] alignedByteStrideForArgs Stride of the command parameters - must be >= 4 * sizeof(NvU32) +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \retval NVAPI_D3D_DEVICE_NOT_REGISTERED When MultiDraw is called on a deferred context, and the device has not yet +//! been registered (NvAPI_D3D_RegisterDevice), this error is returned. +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_MultiDrawInstancedIndirect(__in ID3D11DeviceContext *pDevContext11, + __in NvU32 drawCount, + __in ID3D11Buffer *pBuffer, + __in NvU32 alignedByteOffsetForArgs, + __in NvU32 alignedByteStrideForArgs); + +#endif //defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + + +#if defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_MultiDrawIndexedInstancedIndirect +// +//! DESCRIPTION: Extension of DrawIndexedInstancedIndirect that takes a draw count in. The effect of this function is to loop over +//! that draw count and perform the DrawIndexedInstancedIndirect operation each time, incrementing the buffer offset +//! by the supplied stride each time. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] *pDevContext11 Pointer to D3D11 device context (IC or DC) +//! \param [in] drawCount Do DrawIndexedInstancedIndirect operation this many times +//! \param [in] *pBuffer ID3D11Buffer that contains the command parameters +//! \param [in] alignedByteOffsetForArgs Start in pBuffer of the command parameters +//! \param [in] alignedByteStrideForArgs Stride of the command parameters - must be >= 5 * sizeof(NvU32) +//! +//! RETURN STATUS: This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \retval NVAPI_D3D_DEVICE_NOT_REGISTERED When MultiDraw is called on a deferred context, and the device has not yet +//! been registered (NvAPI_D3D_RegisterDevice), this error is returned. +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_MultiDrawIndexedInstancedIndirect(__in ID3D11DeviceContext *pDevContext11, + __in NvU32 drawCount, + __in ID3D11Buffer *pBuffer, + __in NvU32 alignedByteOffsetForArgs, + __in NvU32 alignedByteStrideForArgs); + +#endif //defined (__cplusplus) && (defined(__d3d11_h__) || defined(__d3d11_1_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! +#if defined (__cplusplus) && ( defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) ||defined(__d3d11_h__) ) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_ImplicitSLIControl +// +//! This function enables/disables the SLI rendering mode. It has to be called prior to D3D device creation. Once this function is called with DISABLE_IMPLICIT_SLI +//! parameter all subsequently created devices will be forced to run in a single gpu mode until the same function is called with ENABLE_IMPLICIT_SLI parameter. The enable +//! call will force all subsequently created devices to run in default implicit SLI mode being determined by an application profile or a global control panel SLI setting. +//! This NvAPI call is supported in all DX10+ versions of the driver. It is supported on all Windows versions. +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Error occurred +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup dx +typedef enum _IMPLICIT_SLI_CONTROL +{ + DISABLE_IMPLICIT_SLI = 0, + ENABLE_IMPLICIT_SLI = 1, +} IMPLICIT_SLI_CONTROL; + +//! \ingroup dx +NVAPI_INTERFACE NvAPI_D3D_ImplicitSLIControl(__in IMPLICIT_SLI_CONTROL implicitSLIControl); + +#endif //defined (__cplusplus) && ( defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) ||defined(__d3d11_h__) ) + +//! SUPPORTED OS: Windows 10 +//! + +#if defined (__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_UseDriverHeapPriorities +// +//! \code +//! DESCRIPTION: Sets the driver to override Microsoft's heap allocation priority values with Nvidia driver priority values. Use this once per process before allocating resources. +//! +//! \param [in] pDevice The IDirect3DDevice12 to use. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \since Release: 381 +//! +//! \endcode +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_UseDriverHeapPriorities(__in ID3D12Device *pDevice); + +#endif // defined (__cplusplus) && defined(__d3d12_h__) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) && ( defined(__d3d12_h__)) + + +typedef struct _NV_D3D12_MOSAIC_GETCOMPANIONALLOCATIONS +{ + __in NvU32 version; //!< Structure version + __in ID3D12Device *pDevice; //!< The ID3D12Device created by application. + __in ID3D12Resource *pSwapChainBuffer; //!< The ID3D12Resource part of the application swap chain that has companion allocations. + __in NvU32 companionBufferCount; //!< The number of ID3D12Resource pointers requested to be returned in the ppComanionResources array, which should match ID3D12Device::GetNodeCount for the complete set of companion allocations. + __inout ID3D12Resource **ppCompanionResources; //!< An array of ID3D12Resource pointers sized to match companionBufferCount, which will receive the companion allocations. +} NV_D3D12_MOSAIC_GETCOMPANIONALLOCATIONS_V1; + +typedef NV_D3D12_MOSAIC_GETCOMPANIONALLOCATIONS_V1 NV_D3D12_MOSAIC_GETCOMPANIONALLOCATIONS; +#define NV_D3D12_MOSAIC_GETCOMPANIONALLOCATIONS_VER1 MAKE_NVAPI_VERSION(NV_D3D12_MOSAIC_GETCOMPANIONALLOCATIONS_V1, 1) +#define NV_D3D12_MOSAIC_GETCOMPANIONALLOCATIONS_VER NV_D3D12_MOSAIC_GETCOMPANIONALLOCATIONS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_Mosaic_GetCompanionAllocations +// +//! DESCRIPTION: Queries the driver for internally created allocations that accompany a swap chain buffer for present-related operations. +//! Surfaces returned by this interface must be destroied at the same time that the original swap chain buffer is destroyed. +//! In general this occurs prior to a ResizeBuffers call, or when the swap chain is released. +//! Note that this function only works in Landscape orientation due to Windows behavior, and attempts to utilize it with any type of display +//! rotation will result in failure. +//! +//! \param [inout] companionBufferCount The parameters for this function. +//! +//! \retval NVAPI_OK Call succeeded. +//! \retval NVAPI_ERROR Call failed. +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid. +//! \retval NVAPI_INVALID_CALL System configuration does not support this interface (eg, display is rotated, mosaic not enabled, etc) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_Mosaic_GetCompanionAllocations(__inout NV_D3D12_MOSAIC_GETCOMPANIONALLOCATIONS *params); + +#endif // defined(__cplusplus) && ( defined(__d3d12_h__)) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) && ( defined(__d3d12_h__)) + +typedef struct _NV_D3D12_MOSAIC_GETVIEWPORTANDGPUPARTITIONS +{ + __in NvU32 version; //!< Structure version + __in ID3D12Device *pDevice; //!< The ID3D12Device created by application. + __in ID3D12Resource *pSwapChainBuffer; //!< The ID3D12Resource part of the application swap chain. + __inout NvU32 *pPartitionCount; //!< A variable to receive the number of NV_MGPU_MOSAIC_DISPLAY_SURFACE_PARTITION elements returned or that holds the size of pPartitions when it is non-NULL. + __inout RECT *pViewport; //!< An optional array to hold the viewport information per partition. When this is valid pNodeMask must also be valid. + __inout NvU32 *pNodeMask; //!< An optional array to hold the GPU mask where this viewport must be valid per partition. When this is valid pViewport must also be valid. +} NV_D3D12_MOSAIC_GETVIEWPORTANDGPUPARTITIONS_V1; + +typedef NV_D3D12_MOSAIC_GETVIEWPORTANDGPUPARTITIONS_V1 NV_D3D12_MOSAIC_GETVIEWPORTANDGPUPARTITIONS; +#define NV_D3D12_MOSAIC_GETVIEWPORTANDGPUPARTITIONS_VER1 MAKE_NVAPI_VERSION(NV_D3D12_MOSAIC_GETVIEWPORTANDGPUPARTITIONS_V1, 1) +#define NV_D3D12_MOSAIC_GETVIEWPORTANDGPUPARTITIONS_VER NV_D3D12_MOSAIC_GETVIEWPORTANDGPUPARTITIONS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_Mosaic_GetViewportAndGpuPartitions +// +//! DESCRIPTION: Queries the driver for how a swap chain display surface is subdivided across devices in relation to display connectivity. +//! Call this interface with NULL pPartitions in order to know how many subdivisions exist and allocate the proper size to hold all data. +//! Call it a second time with a properly sized partitions array to receive all subdivisions along with GPU node masks of each rectangle. +//! Note that this function only works in Landscape orientation due to Windows behavior, and attempts to utilize it with any type of display +//! rotation will result in failure. +//! +//! \param [inout] params The parameters for this function. +//! +//! \retval NVAPI_OK Call succeeded. +//! \retval NVAPI_ERROR Call failed. +//! \retval NVAPI_INVALID_ARGUMENT One or more arguments are invalid. +//! \retval NVAPI_INVALID_CALL System configuration does not support this interface (eg, display is rotated, mosaic not enabled, etc) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_Mosaic_GetViewportAndGpuPartitions(__inout NV_D3D12_MOSAIC_GETVIEWPORTANDGPUPARTITIONS *params); + +#endif // defined(__cplusplus) && ( defined(__d3d12_h__)) + + +#if defined(__cplusplus) && (defined(__d3d11_h__)) +//! \ingroup dx +//! See NvAPI_D3D1x_GetGraphicsCapabilities + +typedef struct _NV_D3D1x_GRAPHICS_CAPS_V1 +{ + NvU32 bExclusiveScissorRectsSupported : 1; //!< (OUT) Outputs whether Exclusive Scissor Rects are supported or not + NvU32 bVariablePixelRateShadingSupported : 1; //!< (OUT) Outputs whether Variable Pixel Shading Rates are supported or not + NvU32 reservedBits : 30; // Reserved bits for future expansion + NvU32 reserved[7]; // Reserved for future expansion +} NV_D3D1x_GRAPHICS_CAPS_V1; + +#define NV_D3D1x_GRAPHICS_CAPS_VER1 MAKE_NVAPI_VERSION(NV_D3D1x_GRAPHICS_CAPS_V1, 1) + +typedef struct _NV_D3D1x_GRAPHICS_CAPS_V2 +{ + NvU32 bExclusiveScissorRectsSupported : 1; //!< (OUT) Outputs whether Exclusive Scissor Rects are supported or not + NvU32 bVariablePixelRateShadingSupported : 1; //!< (OUT) Outputs whether Variable Pixel Shading Rates are supported or not + NvU32 bFastUAVClearSupported : 1; //!< (OUT) Outputs whether UAVClear is implemented using ZBC rather than compute shader + NvU32 reservedBits : 29; // Reserved bits for future expansion + NvU16 majorSMVersion; //!< (OUT) Major SM version of the device + NvU16 minorSMVersion; //!< (OUT) Minor SM version of the device + NvU32 reserved[14]; // Reserved for future expansion +} NV_D3D1x_GRAPHICS_CAPS_V2; + +typedef NV_D3D1x_GRAPHICS_CAPS_V2 NV_D3D1x_GRAPHICS_CAPS; +#define NV_D3D1x_GRAPHICS_CAPS_VER2 MAKE_NVAPI_VERSION(NV_D3D1x_GRAPHICS_CAPS_V2, 2) +#define NV_D3D1x_GRAPHICS_CAPS_VER NV_D3D1x_GRAPHICS_CAPS_VER2 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D1x_GetGraphicsCapabilities +// +//! DESCRIPTION: Get the graphics capabilities for current hardware/software setup +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 410 +//! +//! \param [in] pDevice The ID3D11Device device to be used for getting the graphics capabilities. +//! \param [in] structVersion Version of the caps struct. Should be set to NV_D3D1x_GRAPHICS_CAPS_VER. +//! \param [inout] pGraphicsCaps Pointer to a NV_D3D1x_GRAPHICS_CAPS_CAPS struct created by app. +//! Graphics capabilities will be filled in this struct by the driver. +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D1x_GetGraphicsCapabilities(__in IUnknown *pDevice, + __in NvU32 structVersion, + __inout NV_D3D1x_GRAPHICS_CAPS *pGraphicsCaps); + +#endif // defined(__cplusplus) && (defined(__d3d11_h__)) + +#if defined(__cplusplus) && (defined(__d3d12_h__)) +//! \ingroup dx +//! See NvAPI_D3D12_GetGraphicsCapabilities + +typedef struct _NV_D3D12_GRAPHICS_CAPS_V1 +{ + NvU32 bExclusiveScissorRectsSupported : 1; //!< (OUT) Outputs whether Exclusive Scissor Rects are supported or not + NvU32 bVariablePixelRateShadingSupported : 1; //!< (OUT) Outputs whether Variable Pixel Shading Rates are supported or not + NvU32 bFastUAVClearSupported : 1; //!< (OUT) Outputs whether UAVClear is implemented using ZBC rather than compute shader + NvU32 reservedBits : 29; // Reserved bits for future expansion + NvU16 majorSMVersion; //!< (OUT) Major SM version of the device + NvU16 minorSMVersion; //!< (OUT) Minor SM version of the device + NvU32 reserved[6]; // Reserved for future expansion +} NV_D3D12_GRAPHICS_CAPS_V1; + +typedef NV_D3D12_GRAPHICS_CAPS_V1 NV_D3D12_GRAPHICS_CAPS; +#define NV_D3D12_GRAPHICS_CAPS_VER1 MAKE_NVAPI_VERSION(NV_D3D12_GRAPHICS_CAPS_V1, 1) +#define NV_D3D12_GRAPHICS_CAPS_VER NV_D3D12_GRAPHICS_CAPS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_GetGraphicsCapabilities +// +//! DESCRIPTION: Get the graphics capabilities for current hardware/software setup +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 410 +//! +//! \param [in] pDevice The ID3D12Device device to be used for getting the graphics capabilities. +//! \param [in] structVersion Version of the caps struct. Should be set to NV_D3D12_GRAPHICS_CAPS_VER. +//! \param [inout] pGraphicsCaps Pointer to a NV_D3D12_GRAPHICS_CAPS_CAPS struct created by app. +//! Graphics capabilities will be filled in this struct by the driver. +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D12_GetGraphicsCapabilities(__in IUnknown *pDevice, + __in NvU32 structVersion, + __inout NV_D3D12_GRAPHICS_CAPS *pGraphicsCaps); + +#endif // defined(__cplusplus) && (defined(__d3d12_h__)) + + +#if defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) +#define NV_MAX_NUM_EXCLUSIVE_SCISSOR_RECTS 16 +#endif // defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) + +#if defined(__cplusplus) && (defined(__d3d11_h__)) +//! \ingroup dx +//! See NvAPI_D3D11_RSSetExclusiveScissorRects + +typedef struct _NV_D3D11_EXCLUSIVE_SCISSOR_RECT_DESC_V1 +{ + bool enableExclusiveScissorRect; //!< (IN) Control of enabling Exclusive ScissorRect per rect + D3D11_RECT scissorRect; //!< (IN) Single rect dimensions +} NV_D3D11_EXCLUSIVE_SCISSOR_RECT_DESC_V1; + +typedef struct _NV_D3D11_EXCLUSIVE_SCISSOR_RECTS_DESC_V1 +{ + NvU32 version; //!< (IN) Parameter struct version + NvU32 numRects; //!< (IN) Number of Exclusive Scissor Rects to be set. + // \note Passing zero will globally disable Exclusive Scissor Rects + // \note Max value can be equal to NV_MAX_NUM_EXCLUSIVE_SCISSOR_RECTS + NV_D3D11_EXCLUSIVE_SCISSOR_RECT_DESC_V1 *pRects; //!< (IN) Array of NV_D3D11_EXCLUSIVE_SCISSOR_RECT_DESC with number of elements equal to Exclusive Scissor Rects +} NV_D3D11_EXCLUSIVE_SCISSOR_RECTS_DESC_V1; + +typedef NV_D3D11_EXCLUSIVE_SCISSOR_RECTS_DESC_V1 NV_D3D11_EXCLUSIVE_SCISSOR_RECTS_DESC; +typedef NV_D3D11_EXCLUSIVE_SCISSOR_RECT_DESC_V1 NV_D3D11_EXCLUSIVE_SCISSOR_RECT_DESC; +#define NV_D3D11_EXCLUSIVE_SCISSOR_RECTS_DESC_VER1 MAKE_NVAPI_VERSION(NV_D3D11_EXCLUSIVE_SCISSOR_RECTS_DESC_V1, 1) +#define NV_D3D11_EXCLUSIVE_SCISSOR_RECTS_DESC_VER NV_D3D11_EXCLUSIVE_SCISSOR_RECTS_DESC_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_RSSetExclusiveScissorRects +// +//! DESCRIPTION: Sets Exclusive Scissor Rects. The content bounded within the Scissor Rects +//! will be excluded from rendering unlike regular Scissor Rects. These are +//! orthogonal with Regular Scissor Rects. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 410 +//! +//! \param [in] pContext The device context (ID3D11DeviceContext) to be used for setting the Exclusive Scissor Rects. +//! \param [in] pExclusiveScissorRectsDesc Description of the Exclusive Scissor Rects duly filled with their dimensions +//! and control over enablement of individual ScissorRect +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_RSSetExclusiveScissorRects(__in IUnknown *pContext, + __in NV_D3D11_EXCLUSIVE_SCISSOR_RECTS_DESC *pExclusiveScissorRectsDesc); + +#endif // defined(__cplusplus) && (defined(__d3d11_h__)) + +#if defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) +//! \ingroup dx +//! See NvAPI_D3D11_RSSetViewportsPixelShadingRates + +#define NV_MAX_PIXEL_SHADING_RATES 16 // Currently only 12 Shading Rates are available +#define NV_MAX_NUM_VIEWPORTS 16 + +// Every element in Shading Rate Resource represents the shading rate for all pixels in the corresponding tile +// The Shading Rate Resource dimensions must be the bound render target size divided by the tile dimensions (width/height) + +#define NV_VARIABLE_PIXEL_SHADING_TILE_WIDTH 16 // Width of the tile, in pixels +#define NV_VARIABLE_PIXEL_SHADING_TILE_HEIGHT 16 // Height of the tile, in pixels + +typedef enum +{ + NV_PIXEL_X0_CULL_RASTER_PIXELS, // No shading, tiles are culled + NV_PIXEL_X16_PER_RASTER_PIXEL, // 16 shading passes per 1 raster pixel + NV_PIXEL_X8_PER_RASTER_PIXEL, // 8 shading passes per 1 raster pixel + NV_PIXEL_X4_PER_RASTER_PIXEL, // 4 shading passes per 1 raster pixel + NV_PIXEL_X2_PER_RASTER_PIXEL, // 2 shading passes per 1 raster pixel + NV_PIXEL_X1_PER_RASTER_PIXEL, // Per-pixel shading + NV_PIXEL_X1_PER_2X1_RASTER_PIXELS, // 1 shading pass per 2 raster pixels + NV_PIXEL_X1_PER_1X2_RASTER_PIXELS, // 1 shading pass per 2 raster pixels + NV_PIXEL_X1_PER_2X2_RASTER_PIXELS, // 1 shading pass per 4 raster pixels + NV_PIXEL_X1_PER_4X2_RASTER_PIXELS, // 1 shading pass per 8 raster pixels + NV_PIXEL_X1_PER_2X4_RASTER_PIXELS, // 1 shading pass per 8 raster pixels + NV_PIXEL_X1_PER_4X4_RASTER_PIXELS // 1 shading pass per 16 raster pixels +} NV_PIXEL_SHADING_RATE; +#endif // defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) + +#if defined(__cplusplus) && (defined(__d3d11_h__)) +typedef struct _NV_D3D11_VIEWPORT_SHADING_RATE_DESC_V1 +{ + bool enableVariablePixelShadingRate; //!< (IN) Control of enabling Variable Pixel Shading Rate per viewport + NV_PIXEL_SHADING_RATE shadingRateTable[NV_MAX_PIXEL_SHADING_RATES]; //!< (IN) Lookup table of converting Shading Rate Index to NV_PIXEL_SHADING_RATE + // \note Shading Rate Resource View would be populated by application with indices of this table +} NV_D3D11_VIEWPORT_SHADING_RATE_DESC_V1; + +typedef struct _NV_D3D11_VIEWPORTS_SHADING_RATE_DESC_V1 +{ + NvU32 version; //!< (IN) Struct version + NvU32 numViewports; //!< (IN) Number of viewports with shading rate set. + // \note Passing zero will globally disable Variable Pixel Rate Shading for all viewports immaterial of values in pViewports + // \note Max value can be equal to NV_MAX_NUM_VIEWPORTS + NV_D3D11_VIEWPORT_SHADING_RATE_DESC_V1 *pViewports; //!< (IN) Array of NV_D3D11_VIEWPORT_SHADING_RATE_DESC with number of elements equal to NumViewports +} NV_D3D11_VIEWPORTS_SHADING_RATE_DESC_V1; + +typedef NV_D3D11_VIEWPORTS_SHADING_RATE_DESC_V1 NV_D3D11_VIEWPORTS_SHADING_RATE_DESC; +typedef NV_D3D11_VIEWPORT_SHADING_RATE_DESC_V1 NV_D3D11_VIEWPORT_SHADING_RATE_DESC; +#define NV_D3D11_VIEWPORTS_SHADING_RATE_DESC_VER1 MAKE_NVAPI_VERSION(NV_D3D11_VIEWPORTS_SHADING_RATE_DESC_V1, 1) +#define NV_D3D11_VIEWPORTS_SHADING_RATE_DESC_VER NV_D3D11_VIEWPORTS_SHADING_RATE_DESC_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_RSSetViewportsPixelShadingRates +// +//! DESCRIPTION: Sets Pixel Shading Rates and Enables/Disables per-viewport Variable Pixel Shading Rate feature +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 410 +//! +//! \param [in] pContext The device context (ID3D11DeviceContext) to be used for setting the Viewports Shading Rates +//! \param [in] pShadingRateDesc Shading rate descriptor +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_RSSetViewportsPixelShadingRates(__in IUnknown *pContext, + __in NV_D3D11_VIEWPORTS_SHADING_RATE_DESC *pShadingRateDesc); + +#endif // defined(__cplusplus) && (defined(__d3d11_h__)) + +#if defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) + +typedef enum _NV_SRRV_DIMENSION +{ + NV_SRRV_DIMENSION_TEXTURE2D = 4, + NV_SRRV_DIMENSION_TEXTURE2DARRAY = 5, +} NV_SRRV_DIMENSION; + +typedef struct _NV_TEX2D_SRRV +{ + UINT MipSlice; +} NV_TEX2D_SRRV; + +typedef struct _NV_TEX2D_ARRAY_SRRV +{ + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} NV_TEX2D_ARRAY_SRRV; +#endif // defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) + +#if defined(__cplusplus) && (defined(__d3d11_h__)) +typedef struct _NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC_V1 +{ + NvU32 version; //!< (IN) Parameter struct version + DXGI_FORMAT Format; //!< (IN) Format of the resource used as Shading Rate Surface. Should be either DXGI_FORMAT_R8_UINT or DXGI_FORMAT_R8_TYPELESS + NV_SRRV_DIMENSION ViewDimension; //!< (IN) This declares whether the Shading Rate Surface is a simple 2D Texture or Array of 2D Textures + union + { + NV_TEX2D_SRRV Texture2D; + NV_TEX2D_ARRAY_SRRV Texture2DArray; + }; +} NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC_V1; + +typedef NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC_V1 NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC; +#define NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC_VER1 MAKE_NVAPI_VERSION(NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC_V1, 1) +#define NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC_VER NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC_VER1 + +DECLARE_INTERFACE_(__declspec(uuid("E14BE7F6-8FF5-4F5E-B63A-AD016EB8FBE5"))ID3D11NvShadingRateResourceView_V1, ID3D11View) +{ + BEGIN_INTERFACE + + // *** IUnknown methods *** + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppv) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // **** ID3D11View method **/ + // Get Shading Rate Resource used while creating the Shading Rate Resource View + STDMETHOD_(void,GetResource)(THIS_ _Outptr_ ID3D11Resource **ppResource) PURE; + + // ** ID3D11NvShadingRateResourceView methods *** + // The descriptor used while creating the Shading Rate Resource View + STDMETHOD(GetDesc)(THIS_ NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC* pDesc) PURE; + + END_INTERFACE +}; + +typedef ID3D11NvShadingRateResourceView_V1 ID3D11NvShadingRateResourceView; +#define ID3D11NvShadingRateResourceView_VER1 MAKE_NVAPI_VERSION(ID3D11NvShadingRateResourceView_V1, 1) +#define ID3D11NvShadingRateResourceView_VER ID3D11NvShadingRateResourceView_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateShadingRateResourceView +// +//! DESCRIPTION: Creates Shading Rate Resource View by taking ID3D11Resource as an input Shading Rate Surface. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 410 +//! +//! \param [in] pDevice The device to be used for creating the Shading Rate Resource View +//! \param [in] pShadingRateResource Shading Rate Resource on which the view is to be created. +//! \note This should be of format DXGI_FORMAT_R8_UINT or DXGI_FORMAT_R8_TYPELESS +//! \note This should be confined to size calculated using render target dimensions, +//! NV_VARIABLE_PIXEL_SHADING_TILE_WIDTH and NV_VARIABLE_PIXEL_SHADING_TILE_HEIGHT +//! \param [in] pShadingRateDesc Shading Rate Resource View descriptor +//! \param [out] ppShadingRateResourceView Address of a pointer to ID3D11NvShadingRateResourceView for returning the newly created Shading Rate Resource View +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_CreateShadingRateResourceView(__in ID3D11Device *pDevice, + __in ID3D11Resource *pShadingRateResource, + __in NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC *pShadingRateResourceViewDesc, + __out ID3D11NvShadingRateResourceView **ppShadingRateResourceView); + +#endif // defined(__cplusplus) && (defined(__d3d11_h__)) + +#if defined(__cplusplus) && (defined(__d3d11_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_RSSetShadingRateResourceView +// +//! DESCRIPTION: Sets Shading Rate Resource View +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 410 +//! +//! \param [in] pContext The device context (ID3D11DeviceContext) used for setting the Shading Rate Resource View +//! \param [out] pShadingRateResourceView Shading Rate Resource View to be set +//! \note See NvAPI_D3D11_CreateShadingRateResourceView +//! \note Passing this as null will reset Shading Rate Resource View to defaults +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_RSSetShadingRateResourceView(__in IUnknown *pContext, + __in ID3D11NvShadingRateResourceView *pShadingRateResourceView); + +#endif // defined(__cplusplus) && (defined(__d3d11_h__)) + +#if defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) +//! \ingroup dx +//! See NvAPI_D3D11_RSGetPixelShadingRateSampleOrder +//! See NvAPI_D3D11_RSSetPixelShadingRateSampleOrder + +// X, Y = sample position. S = sample number. +// The inner-most dimension is the sample number, followed by X and Y. + +typedef struct _NV_PIXEL_SRSO_1x2 +{ + struct NV_PIXEL_SRSO_1x2_X1 { NvU8 Y[2]; } X1; + struct NV_PIXEL_SRSO_1x2_X2 { NvU8 YS[2][2]; } X2; + struct NV_PIXEL_SRSO_1x2_X4 { NvU8 YS[2][4]; } X4; + struct NV_PIXEL_SRSO_1x2_X8 { NvU8 YS[2][8]; } X8; +} NV_PIXEL_SRSO_1x2; + +typedef struct _NV_PIXEL_SRSO_2x1 +{ + struct NV_PIXEL_SRSO_2x1_X1 { NvU8 X[2]; } X1; + struct NV_PIXEL_SRSO_2x1_X2 { NvU8 XS[2][2]; } X2; + struct NV_PIXEL_SRSO_2x1_X4 { NvU8 XS[2][4]; } X4; +} NV_PIXEL_SRSO_2x1; + +typedef struct _NV_PIXEL_SRSO_2x2 +{ + struct NV_PIXEL_SRSO_2x2_X1 { NvU8 YX[2][2]; } X1; + struct NV_PIXEL_SRSO_2x2_X2 { NvU8 YXS[2][2][2]; } X2; + struct NV_PIXEL_SRSO_2x2_X4 { NvU8 YXS[2][2][4]; } X4; +} NV_PIXEL_SRSO_2x2; + +typedef struct _NV_PIXEL_SRSO_2x4 +{ + struct NV_PIXEL_SRSO_2x4_X1 { NvU8 YX[4][2]; } X1; + struct NV_PIXEL_SRSO_2x4_X2 { NvU8 YXS[4][2][2]; } X2; +} NV_PIXEL_SRSO_2x4; + +typedef struct _NV_PIXEL_SRSO_4x2 +{ + struct NV_PIXEL_SRSO_4x2_X1 { NvU8 YX[2][4]; } X1; +} NV_PIXEL_SRSO_4x2; + +typedef struct _NV_PIXEL_SRSO_4x4 +{ + struct NV_PIXEL_SRSO_4x4_X1 { NvU8 YX[4][4]; } X1; +} NV_PIXEL_SRSO_4x4; + +typedef struct _NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE_V1 +{ + NvU32 version; + NV_PIXEL_SRSO_1x2 Pixel_1x2; + NV_PIXEL_SRSO_2x1 Pixel_2x1; + NV_PIXEL_SRSO_2x2 Pixel_2x2; + NV_PIXEL_SRSO_2x4 Pixel_2x4; + NV_PIXEL_SRSO_4x2 Pixel_4x2; + NV_PIXEL_SRSO_4x4 Pixel_4x4; +} NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE_V1; + +typedef NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE_V1 NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE; +#define NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE_VER1 MAKE_NVAPI_VERSION(NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE_V1, 1) +#define NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE_VER NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE_VER1 + +#endif // defined(__cplusplus) && (defined(__d3d11_h__) || defined(__d3d12_h__)) + +#if defined(__cplusplus) && (defined(__d3d11_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_RSGetPixelShadingRateSampleOrder +// +//! DESCRIPTION: Get the Sample Order for Variable Shading Rate +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 410 +//! +//! \param [in] pContext The device context (ID3D11DeviceContext) used for getting the Shading Rate Sample Order +//! \param [out] pSampleOrderTable A pointer to NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE where the current Sample Order for Variable Pixel Rate Shading that is returned +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_RSGetPixelShadingRateSampleOrder(__in IUnknown *pContext, + __out NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE* pSampleOrderTable); + +#endif // defined(__cplusplus) && (defined(__d3d11_h__)) + +#if defined(__cplusplus) && (defined(__d3d11_h__)) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_RSSetPixelShadingRateSampleOrder +// +//! DESCRIPTION: Set the Sample Order for Variable Shading Rate +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 410 +//! +//! \param [in] pContext The device context (ID3D11DeviceContext) used for setting the Shading Rate Sample Order +//! \param [out] pSampleOrderTable Sample Order for Variable Shading Rate to be set +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D11_RSSetPixelShadingRateSampleOrder(__in IUnknown *pContext, + __in NV_PIXEL_SHADING_RATE_SAMPLE_ORDER_TABLE* pSampleOrderTable); + +#endif // defined(__cplusplus) && (defined(__d3d11_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined(__cplusplus) && (defined(__d3d11_h__)) +typedef struct _NV_VRS_HELPER_LATCH_GAZE_PARAMS_V1 +{ + NvU32 version; //!< (IN) Struct version + NvU32 flags; //!< (IN) Reserved for future use +} NV_VRS_HELPER_LATCH_GAZE_PARAMS_V1; + +typedef NV_VRS_HELPER_LATCH_GAZE_PARAMS_V1 NV_VRS_HELPER_LATCH_GAZE_PARAMS; +#define NV_VRS_HELPER_LATCH_GAZE_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_VRS_HELPER_LATCH_GAZE_PARAMS_V1, 1) +#define NV_VRS_HELPER_LATCH_GAZE_PARAMS_VER NV_VRS_HELPER_LATCH_GAZE_PARAMS_VER1 + +typedef enum _NV_VRS_CONTENT_TYPE +{ + NV_VRS_CONTENT_TYPE_INVALID = 0x0, + NV_VRS_CONTENT_TYPE_FOVEATED_RENDERING = 0x1, + NV_VRS_CONTENT_TYPE_MAX = NV_VRS_CONTENT_TYPE_FOVEATED_RENDERING +} NV_VRS_CONTENT_TYPE; + +typedef enum _NV_FOVEATED_RENDERING_SHADING_RATE_PRESET +{ + NV_FOVEATED_RENDERING_SHADING_RATE_PRESET_INVALID = 0, + NV_FOVEATED_RENDERING_SHADING_RATE_PRESET_HIGHEST_PERFORMANCE = 1, + NV_FOVEATED_RENDERING_SHADING_RATE_PRESET_HIGH_PERFORMANCE = 2, + NV_FOVEATED_RENDERING_SHADING_RATE_PRESET_BALANCED = 3, + NV_FOVEATED_RENDERING_SHADING_RATE_PRESET_HIGH_QUALITY = 4, + NV_FOVEATED_RENDERING_SHADING_RATE_PRESET_HIGHEST_QUALITY = 5, + NV_FOVEATED_RENDERING_SHADING_RATE_PRESET_CUSTOM = 6, + NV_FOVEATED_RENDERING_SHADING_RATE_PRESET_MAX = NV_FOVEATED_RENDERING_SHADING_RATE_PRESET_CUSTOM +} NV_FOVEATED_RENDERING_SHADING_RATE_PRESET; + +typedef struct _NV_FOVEATED_RENDERING_CUSTOM_SHADING_RATE_PRESET_DESC_V1 +{ + NvU32 version; + + NV_PIXEL_SHADING_RATE InnerMostRegionShadingRate; //!< (IN) Shading Rate for the inner-most region of the foveated rendering pattern + NV_PIXEL_SHADING_RATE MiddleRegionShadingRate; //!< (IN) Shading Rate for the middle region of the foveated rendering pattern + NV_PIXEL_SHADING_RATE PeripheralRegionShadingRate; //!< (IN) Shading Rate for the peripheral region of the foveated rendering pattern +} NV_FOVEATED_RENDERING_CUSTOM_SHADING_RATE_PRESET_DESC_V1; + +typedef NV_FOVEATED_RENDERING_CUSTOM_SHADING_RATE_PRESET_DESC_V1 NV_FOVEATED_RENDERING_CUSTOM_SHADING_RATE_PRESET_DESC; +#define NV_FOVEATED_RENDERING_CUSTOM_SHADING_RATE_PRESET_DESC_VER1 MAKE_NVAPI_VERSION(NV_FOVEATED_RENDERING_CUSTOM_SHADING_RATE_PRESET_DESC_V1, 1) +#define NV_FOVEATED_RENDERING_CUSTOM_SHADING_RATE_PRESET_DESC_VER NV_FOVEATED_RENDERING_CUSTOM_SHADING_RATE_PRESET_DESC_VER1 + +typedef enum _NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET +{ + NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET_INVALID = 0, + NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET_WIDE = 1, + NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET_BALANCED = 2, + NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET_NARROW = 3, + NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET_CUSTOM = 4, + NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET_MAX = NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET_CUSTOM +} NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET; + +typedef struct _NV_FOVEATED_RENDERING_CUSTOM_FOVEATION_PATTERN_PRESET_DESC_V1 +{ + NvU32 version; + + float fInnermostRadii[2]; //!< (IN) Horizontal and vertical radius for the inner-most region of the foveated rendering pattern + float fMiddleRadii[2]; //!< (IN) Horizontal and vertical radius for the middle region of the foveated rendering pattern + float fPeripheralRadii[2]; //!< (IN) Horizontal and vertical radius for the peripheral region of the foveated rendering pattern +} NV_FOVEATED_RENDERING_CUSTOM_FOVEATION_PATTERN_PRESET_DESC_V1; + +typedef NV_FOVEATED_RENDERING_CUSTOM_FOVEATION_PATTERN_PRESET_DESC_V1 NV_FOVEATED_RENDERING_CUSTOM_FOVEATION_PATTERN_PRESET_DESC; +#define NV_FOVEATED_RENDERING_CUSTOM_FOVEATION_PATTERN_PRESET_DESC_VER1 MAKE_NVAPI_VERSION(NV_FOVEATED_RENDERING_CUSTOM_FOVEATION_PATTERN_PRESET_DESC_V1, 1) +#define NV_FOVEATED_RENDERING_CUSTOM_FOVEATION_PATTERN_PRESET_DESC_VER NV_FOVEATED_RENDERING_CUSTOM_FOVEATION_PATTERN_PRESET_DESC_VER1 + +typedef struct _NV_FOVEATED_RENDERING_DESC_V1 +{ + NvU32 version; //!< (IN) Struct version + NvU32 flags; //!< (IN) Reserved for future use + + NV_FOVEATED_RENDERING_SHADING_RATE_PRESET ShadingRatePreset; //!< (IN) Preset of the shading rate + NV_FOVEATED_RENDERING_CUSTOM_SHADING_RATE_PRESET_DESC_V1 ShadingRateCustomPresetDesc; //!< (IN) To be provided only if ShadingRatePreset is NV_FOVEATED_RENDERING_SHADING_RATE_PRESET_CUSTOM + + NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET FoveationPatternPreset; //!< (IN) Preset of the foveation pattern + NV_FOVEATED_RENDERING_CUSTOM_FOVEATION_PATTERN_PRESET_DESC_V1 FoveationPatternCustomPresetDesc; //!< (IN) To be provided only if FoveationPatternPreset is NV_FOVEATED_RENDERING_FOVEATION_PATTERN_PRESET_CUSTOM + + NvU32 GazeDataDeviceId; //!< (IN) ID of the gaze data provider. Needed only for supporting more than one device with eye tracking. + // Should be 0 if gaze data is provided only from a single device. Should be less than (MAX_NUMBER_OF_GAZE_DATA_PROVIDERS - 1) + +} NV_FOVEATED_RENDERING_DESC_V1; + +typedef NV_FOVEATED_RENDERING_DESC_V1 NV_FOVEATED_RENDERING_DESC; +#define NV_FOVEATED_RENDERING_DESC_VER1 MAKE_NVAPI_VERSION(NV_FOVEATED_RENDERING_DESC_V1, 1) +#define NV_FOVEATED_RENDERING_DESC_VER NV_FOVEATED_RENDERING_DESC_VER1 + +typedef enum _NV_VRS_RENDER_MODE +{ + NV_VRS_RENDER_MODE_INVALID = 0, + NV_VRS_RENDER_MODE_MONO = 1, // States mono rendering on the entire render target + NV_VRS_RENDER_MODE_LEFT_EYE = 2, // States Left eye rendering of a stereo pair on the entire render target + NV_VRS_RENDER_MODE_RIGHT_EYE = 3, // States Right eye rendering of a stereo pair on the entire render target + NV_VRS_RENDER_MODE_STEREO = 4, // States side-by-side stereo rendering on the render target + NV_VRS_RENDER_MODE_MAX = NV_VRS_RENDER_MODE_STEREO +} NV_VRS_RENDER_MODE; + +#define MAX_NUMBER_OF_GAZE_DATA_PROVIDERS 8 // Maximum number of gaze data providers / devices. + +typedef struct _NV_VRS_HELPER_ENABLE_PARAMS_V1 +{ + NvU32 version; //!< (IN) Struct version + NvU32 flags; //!< (IN) Reserved for future use + + NV_VRS_RENDER_MODE RenderMode; //!< (IN) This defines whether subsequent render calls are for mono/stereo + NV_VRS_CONTENT_TYPE ContentType; //!< (IN) This defines the type of content with which the VRS pattern will be generated + + NV_FOVEATED_RENDERING_DESC_V1 sFoveatedRenderingDesc; //!< (IN) Provide this if ContentType has NV_VRS_CONTENT_TYPE_FOVEATED_RENDERING flag +} NV_VRS_HELPER_ENABLE_PARAMS_V1; + +typedef NV_VRS_HELPER_ENABLE_PARAMS_V1 NV_VRS_HELPER_ENABLE_PARAMS; +#define NV_VRS_HELPER_ENABLE_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_VRS_HELPER_ENABLE_PARAMS_V1, 1) +#define NV_VRS_HELPER_ENABLE_PARAMS_VER NV_VRS_HELPER_ENABLE_PARAMS_VER1 + +typedef struct _NV_VRS_HELPER_DISABLE_PARAMS_V1 +{ + NvU32 version; //!< (IN) Struct version + NvU32 reserved; //!< (IN) Reserved for future use +} NV_VRS_HELPER_DISABLE_PARAMS_V1; + +typedef NV_VRS_HELPER_DISABLE_PARAMS_V1 NV_VRS_HELPER_DISABLE_PARAMS; +#define NV_VRS_HELPER_DISABLE_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_VRS_HELPER_DISABLE_PARAMS_V1, 1) +#define NV_VRS_HELPER_DISABLE_PARAMS_VER NV_VRS_HELPER_DISABLE_PARAMS_VER1 + +typedef struct _NV_VRS_HELPER_GET_SHADING_RATE_RESOURCE_PARAMS_V1 +{ + NvU32 version; //!< (IN) Struct version + IUnknown **ppShadingRateResource; //!< (OUT) Pointer to 2D Texture resource with currently applied shading rate pattern + NV_PIXEL_SHADING_RATE shadingRateTable[NV_MAX_PIXEL_SHADING_RATES]; //!< (OUT) Shading Rate Table filled by the driver +} NV_VRS_HELPER_GET_SHADING_RATE_RESOURCE_PARAMS_V1; + +typedef NV_VRS_HELPER_GET_SHADING_RATE_RESOURCE_PARAMS_V1 NV_VRS_HELPER_GET_SHADING_RATE_RESOURCE_PARAMS; +#define NV_VRS_HELPER_GET_SHADING_RATE_RESOURCE_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_VRS_HELPER_GET_SHADING_RATE_RESOURCE_PARAMS_V1, 1) +#define NV_VRS_HELPER_GET_SHADING_RATE_RESOURCE_PARAMS_VER NV_VRS_HELPER_GET_SHADING_RATE_RESOURCE_PARAMS_VER1 + +typedef struct _NV_VRS_HELPER_PURGE_INTERNAL_RESOURCES_PARAMS_V1 +{ + NvU32 version; //!< (IN) Struct version + NvU32 reserved; //!< (IN) Reserved for future use +} NV_VRS_HELPER_PURGE_INTERNAL_RESOURCES_PARAMS_V1; + +typedef NV_VRS_HELPER_PURGE_INTERNAL_RESOURCES_PARAMS_V1 NV_VRS_HELPER_PURGE_INTERNAL_RESOURCES_PARAMS; +#define NV_VRS_HELPER_PURGE_INTERNAL_RESOURCES_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_VRS_HELPER_PURGE_INTERNAL_RESOURCES_PARAMS_V1, 1) +#define NV_VRS_HELPER_PURGE_INTERNAL_RESOURCES_PARAMS_VER NV_VRS_HELPER_PURGE_INTERNAL_RESOURCES_PARAMS_VER1 + +DECLARE_INTERFACE(ID3DNvVRSHelper_V1) +{ + BEGIN_INTERFACE + + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // Latches the latest gaze which will be used for subsequent foveated rendering. Recommended to be called once per frame before scene drawing begins. + STDMETHOD_(NvAPI_Status,LatchGaze)(THIS_ IUnknown* pContext, NV_VRS_HELPER_LATCH_GAZE_PARAMS* pLatchGazeParams) PURE; + + // Enables VRS with sepcified content type and preset. This can be called per draw call. + STDMETHOD_(NvAPI_Status,Enable)(THIS_ IUnknown* pContext, NV_VRS_HELPER_ENABLE_PARAMS* pEnableParams) PURE; + + // Disables VRS till re-enabled. + STDMETHOD_(NvAPI_Status,Disable)(THIS_ IUnknown* pContext, NV_VRS_HELPER_DISABLE_PARAMS* pDisableParams) PURE; + + // Creates a 2D texture, copies the current shading rate pattern on it and returns the pointer to this texture. + // It also returns an array that conveys which value in the shading rate resource corresponds to which exact pixel shading rate. + STDMETHOD_(NvAPI_Status,GetShadingRateResource)(THIS_ IUnknown* pContext, NV_VRS_HELPER_GET_SHADING_RATE_RESOURCE_PARAMS *pGetShadingRateResourceParams) PURE; + + // Destroys all internally created shading rate resources and views. + STDMETHOD_(NvAPI_Status,PurgeInternalShadingRateResources)(THIS_ IUnknown* pContext, NV_VRS_HELPER_PURGE_INTERNAL_RESOURCES_PARAMS* pPurgeParams) PURE; + + END_INTERFACE +}; + +typedef ID3DNvVRSHelper_V1 ID3DNvVRSHelper; +#define ID3DNvVRSHelper_VER1 MAKE_NVAPI_VERSION(ID3DNvVRSHelper_V1, 1) +#define ID3DNvVRSHelper_VER ID3DNvVRSHelper_VER1 + +typedef struct _NV_VRS_HELPER_INIT_PARAMS_V1 +{ + NvU32 version; //!< (IN) Struct version + NvU32 flags; //!< (IN) Reserved for future use + + ID3DNvVRSHelper_V1 **ppVRSHelper; //!< (OUT) Interface for Shading Rate Pattern Tracker +} NV_VRS_HELPER_INIT_PARAMS_V1; + +typedef NV_VRS_HELPER_INIT_PARAMS_V1 NV_VRS_HELPER_INIT_PARAMS; +#define NV_VRS_HELPER_INIT_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_VRS_HELPER_INIT_PARAMS_V1, 1) +#define NV_VRS_HELPER_INIT_PARAMS_VER NV_VRS_HELPER_INIT_PARAMS_VER1 + +//! SUPPORTED OS: Windows 7 and higher +//! +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_InitializeVRSHelper +// +//! DESCRIPTION: Creates an interface for updating, enabling and disabling internally tracked shading rate pattern for Variable Rate Shading +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 430 +//! +//! \param [in] pDevice The device to be used for creating the VRS Handler interface +//! \note This should be same the device used for Gaze Handler. See also: NvAPI_D3D_InitializeNvGazeHandler. +//! \param [in] pInitializeVRSHelperParams Descriptor for VRS Helper initialization +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D_InitializeVRSHelper(__in IUnknown *pDevice, + __inout NV_VRS_HELPER_INIT_PARAMS *pInitializeVRSHelperParams); + +typedef enum _NV_GAZE_DATA_VALIDITY_FLAGS +{ + NV_GAZE_ORIGIN_VALID = 0x1, + NV_GAZE_DIRECTION_VALID = 0x2, + NV_GAZE_LOCATION_VALID = 0x4, + NV_GAZE_VELOCITY_VALID = 0x8, + NV_GAZE_PUPIL_DIAMETER_VALID = 0x10, + NV_GAZE_EYE_OPENNESS_VALID = 0x20, + NV_GAZE_EYE_SACCADE_DATA_VALID = 0x40 +} NV_GAZE_DATA_VALIDITY_FLAGS; + +typedef struct _NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE +{ + NvU32 version; //!< (IN) Version of the structure + + NvU32 GazeDataValidityFlags; //!< (IN) To be populated with OR'ing flags from NV_GAZE_DATA_VALIDITY_FLAGS + + float fGazeOrigin_mm[3]; //!< (IN) Use flag NV_GAZE_ORIGIN_VALID. Origin of the eye in millimeters. Used mainly to detect whether Left Eye or Right Eye. + float fGazeDirection[3]; //!< (IN) Use flag NV_GAZE_DIRECTION_VALID. Normalized direction of the gaze of the eye. Used for calculating the gaze location using the FOV. + float fGazeNormalizedLocation[2]; //!< (IN) Use flag NV_GAZE_LOCATION_VALID. Precalculated normalized gaze location in limits (-1 to +1) for X and Y. Center of the screen denotes (0, 0). If this is valid, this will be given higher priority than direction. + float fGazeVelocity[2]; //!< (IN) Use flag NV_GAZE_VELOCITY_VALID. Optional: Velocity of the eye on the normalized space in each direction. Central foveated region would be skewed in the direction of the velocity. + float fPupilDiameter_mm; //!< (IN) Use flag NV_GAZE_PUPIL_DIAMETER_VALID. Unused at the moment. + float fEyeOpenness; //!< (IN) Use flag NV_GAZE_EYE_OPENNESS_VALID. Unused at the moment. + BOOL bInSaccade; //!< (IN) Use flag NV_GAZE_EYE_SACCADE_DATA_VALID. Denotes whether eye is currently in saccade movement or not. +} NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE_V1; + +typedef NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE_V1 NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE; +#define NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE_VER1 MAKE_NVAPI_VERSION(NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE_V1, 1) +#define NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE_VER NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE_VER1 + +typedef struct _NV_FOVEATED_RENDERING_UPDATE_GAZE_DATA_PARAMS +{ + NvU32 version; //!< (IN) Struct version + NvU32 flags; //!< (IN) Reserved for future use + + NvU64 Timestamp; //!< (IN) Timestamp at which the gaze data has been captured. Should be larger than timestamp provided at previous update. + union + { + NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE_V1 sMonoData; //!< (IN) Gaze data for Mono rendering mode + struct + { + NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE_V1 sLeftEye; //!< (IN) Gaze data for Left Eye of Stereo rendering mode + NV_FOVEATED_RENDERING_GAZE_DATA_PER_EYE_V1 sRightEye; //!< (IN) Gaze data for Right Eye of Stereo rendering mode + } sStereoData; + }; +} NV_FOVEATED_RENDERING_UPDATE_GAZE_DATA_PARAMS_V1; + +typedef NV_FOVEATED_RENDERING_UPDATE_GAZE_DATA_PARAMS_V1 NV_FOVEATED_RENDERING_UPDATE_GAZE_DATA_PARAMS; +#define NV_FOVEATED_RENDERING_UPDATE_GAZE_DATA_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_FOVEATED_RENDERING_UPDATE_GAZE_DATA_PARAMS_V1, 1) +#define NV_FOVEATED_RENDERING_UPDATE_GAZE_DATA_PARAMS_VER NV_FOVEATED_RENDERING_UPDATE_GAZE_DATA_PARAMS_VER1 + + +DECLARE_INTERFACE(ID3DNvGazeHandler_V2) +{ + BEGIN_INTERFACE + + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // Updates the gaze data for foveated rendering + STDMETHOD_(NvAPI_Status,UpdateGazeData)(THIS_ IUnknown* pContext, NV_FOVEATED_RENDERING_UPDATE_GAZE_DATA_PARAMS* pUpdateGazeDataParams) PURE; + + + END_INTERFACE +}; +typedef ID3DNvGazeHandler_V2 ID3DNvGazeHandler; +#define ID3DNvGazeHandler_VER2 MAKE_NVAPI_VERSION(ID3DNvGazeHandler_V2, 2) +#define ID3DNvGazeHandler_VER ID3DNvGazeHandler_VER2 + +DECLARE_INTERFACE(ID3DNvGazeHandler_V1) +{ + BEGIN_INTERFACE + + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // Updates the gaze data for foveated rendering + STDMETHOD_(NvAPI_Status,UpdateGazeData)(THIS_ IUnknown* pContext, NV_FOVEATED_RENDERING_UPDATE_GAZE_DATA_PARAMS* pUpdateGazeDataParams) PURE; + + END_INTERFACE +}; +#define ID3DNvGazeHandler_VER1 MAKE_NVAPI_VERSION(ID3DNvGazeHandler_V1, 1) +#ifndef ID3DNvGazeHandler_VER +typedef ID3DNvGazeHandler_V1 ID3DNvGazeHandler; +#define ID3DNvGazeHandler_VER ID3DNvGazeHandler_VER1 +#endif + +typedef enum _NV_GAZE_DATA_TYPE +{ + NV_GAZE_DATA_INVALID = 0, + NV_GAZE_DATA_MONO = 1, + NV_GAZE_DATA_STEREO = 2, + NV_GAZE_DATA_MAX = NV_GAZE_DATA_STEREO +} NV_GAZE_DATA_TYPE; + +typedef struct _NV_GAZE_HANDLER_INIT_PARAMS_V2 +{ + NvU32 version; //!< (IN) Struct version + + NvU32 GazeDataDeviceId; //!< (IN) ID of the gaze data provider. Needed only for supporting more than one device with eye tracking. + // Should be 0 if gaze data is provided only from a single device. Should be less than (MAX_NUMBER_OF_GAZE_DATA_PROVIDERS - 1) + + NV_GAZE_DATA_TYPE GazeDataType; //!< (IN) Describes whether gaze is Mono or Stereo + NvU32 flags; //!< (IN) Reserved for future use + float fHorizontalFOV; //!< (IN) Horizontal Field of View + float fVericalFOV; //!< (IN) Vertical Field of View + + ID3DNvGazeHandler_V2 **ppNvGazeHandler; //!< (OUT) Interface for Gaze Data Handler +} NV_GAZE_HANDLER_INIT_PARAMS_V2; + +typedef NV_GAZE_HANDLER_INIT_PARAMS_V2 NV_GAZE_HANDLER_INIT_PARAMS; +#define NV_GAZE_HANDLER_INIT_PARAMS_VER2 MAKE_NVAPI_VERSION(NV_GAZE_HANDLER_INIT_PARAMS_V2, 2) +#define NV_GAZE_HANDLER_INIT_PARAMS_VER NV_GAZE_HANDLER_INIT_PARAMS_VER2 + +typedef struct _NV_GAZE_HANDLER_INIT_PARAMS_V1 +{ + NvU32 version; //!< (IN) Struct version + + NvU32 GazeDataDeviceId; //!< (IN) ID of the gaze data provider. Needed only for supporting more than one device with eye tracking. + // Should be 0 if gaze data is provided only from a single device. Should be less than (MAX_NUMBER_OF_GAZE_DATA_PROVIDERS - 1) + + NV_GAZE_DATA_TYPE GazeDataType; //!< (IN) Describes whether gaze is Mono or Stereo + NvU32 flags; //!< (IN) Reserved for future use + float fHorizontalFOV; //!< (IN) Horizontal Field of View + float fVericalFOV; //!< (IN) Vertical Field of View + + ID3DNvGazeHandler_V1 **ppNvGazeHandler; //!< (OUT) Interface for Gaze Data Handler +} NV_GAZE_HANDLER_INIT_PARAMS_V1; + +#define NV_GAZE_HANDLER_INIT_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_GAZE_HANDLER_INIT_PARAMS_V1, 1) +#ifndef NV_GAZE_HANDLER_INIT_PARAMS_VER +typedef NV_GAZE_HANDLER_INIT_PARAMS_V1 NV_GAZE_HANDLER_INIT_PARAMS; +#define NV_GAZE_HANDLER_INIT_PARAMS_VER NV_GAZE_HANDLER_INIT_PARAMS_VER1 +#endif + +#endif // defined(__cplusplus) && (defined(__d3d11_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! + +#if defined(__cplusplus) && (defined(__d3d11_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_InitializeNvGazeHandler +// +//! DESCRIPTION: Creates an interface for updating and managing gaze data +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 430 +//! +//! \param [in] pDevice The device to be used for creating the Gaze Handler interface +//! \note This should be same as the device used with VRS Handler. See also: NvAPI_D3D_InitializeVRSHelper. +//! \param [in] pInitializeNvGazeHandlerParams Descriptor for Gaze Data Handler initialization +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! (none) +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// + +NVAPI_INTERFACE NvAPI_D3D_InitializeNvGazeHandler(__in IUnknown *pDevice, + __inout NV_GAZE_HANDLER_INIT_PARAMS *pInitializeNvGazeHandlerParams); + +#endif // defined(__cplusplus) && (defined(__d3d11_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! +#if defined (__cplusplus) && defined(__d3d11_h__) + +//! \ingroup dx + +typedef enum NV_SMP_ASSIST_TYPE +{ + NV_SMP_ASSIST_NONE = 0, + NV_SMP_ASSIST_MRS = 1, // SMP Assist required for Multi-Res Shading + NV_SMP_ASSIST_LMS = 2, // SMP Assist required for Lens Matched Shading + NV_SMP_ASSIST_NUM_TYPES +} NV_SMP_ASSIST_TYPE; + +typedef enum NV_SMP_ASSIST_LEVEL +{ + NV_SMP_ASSIST_LEVEL_FULL = 0, // Full assistance. App selects a pre-baked MRS/LMS config, driver handles correct setting of viewport, scissors and FastGS + NV_SMP_ASSIST_LEVEL_PARTIAL = 1, // Partial assistance. App provides a custom MRS/LMS config, driver handles correct setting of viewport, scissors and FastGS + NV_SMP_ASSIST_LEVEL_MINIMAL = 2, // Minimal assistance. App provides viewports and scissors. App sets FastGS as required. App sets LMS params as required (NvAPI_D3D_SetModifiedWMode). App provides SMPType as NONE. Driver handles correct setting of viewports and scissors. + NV_SMP_ASSIST_NUM_LEVELS +} NV_SMP_ASSIST_LEVEL; + +typedef enum NV_MRS_CONFIG +{ + NV_MRS_CONFIG_BALANCED = 0, + NV_MRS_CONFIG_AGGRESSIVE = 1, + NV_MRS_CONFIG_OCULUSRIFT_CV1_CONSERVATIVE = 2, + NV_MRS_CONFIG_OCULUSRIFT_CV1_BALANCED = 3, + NV_MRS_CONFIG_OCULUSRIFT_CV1_AGGRESSIVE = 4, + NV_MRS_CONFIG_HTC_VIVE_CONSERVATIVE = 5, + NV_MRS_CONFIG_HTC_VIVE_BALANCED = 6, + NV_MRS_CONFIG_HTC_VIVE_AGGRESSIVE = 7, + NV_MRS_NUM_CONFIGS +} NV_MRS_CONFIG; + +typedef enum NV_LMS_CONFIG +{ + NV_LMS_CONFIG_OCULUSRIFT_CV1_CONSERVATIVE = 0, + NV_LMS_CONFIG_OCULUSRIFT_CV1_BALANCED = 1, + NV_LMS_CONFIG_OCULUSRIFT_CV1_AGGRESSIVE = 2, + NV_LMS_CONFIG_HTC_VIVE_CONSERVATIVE = 3, + NV_LMS_CONFIG_HTC_VIVE_BALANCED = 4, + NV_LMS_CONFIG_HTC_VIVE_AGGRESSIVE = 5, + NV_LMS_NUM_CONFIGS +} NV_LMS_CONFIG; + +#define NV_SMP_ASSIST_FLAGS_DEFAULT 0x00000000 + +#define NV_SMP_ASSIST_MAX_VIEWPORTS 16 + +typedef struct _NV_MRS_CUSTOM_CONFIG_V1 +{ + float centerWidth; //!< (IN) Size of the central viewport, ranging (0,1], where 1 is full original viewport size + float centerHeight; + float centerX; //!< (IN) Location of the central viewport, ranging 0..1, where 0.5 is the center of the screen + float centerY; + float densityScaleX[3]; //!< (IN) Pixel density scale factors: how much the linear pixel density is scaled within each row and column (1.0 = full density) + float densityScaleY[3]; +} NV_MRS_CUSTOM_CONFIG_V1; + +typedef NV_MRS_CUSTOM_CONFIG_V1 NV_MRS_CUSTOM_CONFIG; + +typedef struct _NV_MRS_INSTANCED_STEREO_CONFIG_V1 +{ //!< (OUT) MRS Instanced stereo config returned by the SMP Assist GetConstants API + float centerWidth[2]; //!< (OUT) Size of the central viewport, ranging (0,1], where 1 is full original viewport size + float centerHeight; + float centerX[2]; //!< (OUT) Location of the central viewport, ranging 0..1, where 0.5 is the center of the screen + float centerY; + float densityScaleX[5]; //!< (OUT) Pixel density scale factors: how much the linear pixel density is scaled within each row and column (1.0 = full density) + float densityScaleY[3]; +} NV_MRS_INSTANCED_STEREO_CONFIG_V1; + +typedef NV_MRS_INSTANCED_STEREO_CONFIG_V1 NV_MRS_INSTANCED_STEREO_CONFIG; + +typedef struct _NV_LMS_CUSTOM_CONFIG_V1 +{ + float warpLeft; //!< (IN) LMS params to control warping of the 2 left quadrants + float warpRight; //!< (IN) LMS params to control warping of the 2 right quadrants + float warpUp; //!< (IN) LMS params to control warping of the 2 upper quadrants + float warpDown; //!< (IN) LMS params to control warping of the 2 lower quadrants + + float relativeSizeLeft; //!< (IN) LMS params to control the width of the 2 left quandrants relative to the bounding box width + float relativeSizeRight; //!< (IN) LMS params to control the width of the 2 right quandrants relative to the bounding box width + float relativeSizeUp; //!< (IN) LMS params to control the height of the 2 upper quandrants relative to the bounding box height + float relativeSizeDown; //!< (IN) LMS params to control the height of the 2 lower quandrants relative to the bounding box height +} NV_LMS_CUSTOM_CONFIG_V1; + +typedef NV_LMS_CUSTOM_CONFIG_V1 NV_LMS_CUSTOM_CONFIG; + +typedef struct _NV_LMS_INSTANCED_STEREO_CONFIG_V1 +{ //!< (OUT) LMS Instanced stereo config returned by the SMP Assist GetConstants API + NV_LMS_CUSTOM_CONFIG_V1 sLeftConfig; //!< (OUT) LMS config for the Left eye view + NV_LMS_CUSTOM_CONFIG_V1 sRightConfig; //!< (OUT) LMS config for the Right eye view +} NV_LMS_INSTANCED_STEREO_CONFIG_V1; + +typedef NV_LMS_INSTANCED_STEREO_CONFIG_V1 NV_LMS_INSTANCED_STEREO_CONFIG; + +typedef enum _NV_SMP_ASSIST_EYE_INDEX +{ + NV_SMP_ASSIST_EYE_INDEX_MONO = 0, // Non-stereo rendering + NV_SMP_ASSIST_EYE_INDEX_LEFT_EYE = 1, // Stereo - Rendering left eye + NV_SMP_ASSIST_EYE_INDEX_RIGHT_EYE = 2, // Stereo - Rendering right eye + NV_SMP_ASSIST_EYE_INDEX_INSTANCED_STEREO = 3, // Stereo - Rendering both eyes +} NV_SMP_ASSIST_EYE_INDEX; + +#define NV_SMP_ASSIST_MINIMAL_LEVEL_NUM_EYE_INDICES 4 + +typedef struct _NV_CUSTOM_RECTS_V1 +{ + NvU32 numViewports[NV_SMP_ASSIST_MINIMAL_LEVEL_NUM_EYE_INDICES]; + D3D11_VIEWPORT *pViewports[NV_SMP_ASSIST_MINIMAL_LEVEL_NUM_EYE_INDICES]; //!< (IN) Viewports, for each eye index, that should be set when app calls Enable(eyeIndex) + D3D11_RECT *pScissors[NV_SMP_ASSIST_MINIMAL_LEVEL_NUM_EYE_INDICES]; //!< (IN) Scissors, for each eye index, that should be set when app calls Enable(eyeIndex) +} NV_CUSTOM_RECTS_V1; + +typedef NV_CUSTOM_RECTS_V1 NV_CUSTOM_RECTS; + +typedef struct _NV_SMP_ASSIST_ENABLE_PARAMS_V1 +{ + NvU32 version; //!< (IN) Structure version + NV_SMP_ASSIST_EYE_INDEX eEyeIndex; //!< (IN) Rendering mode for upcoming draw calls (Mono/Stereo-Left/Stereo-Right/Instanced Stereo) +} NV_SMP_ASSIST_ENABLE_PARAMS_V1; + +typedef NV_SMP_ASSIST_ENABLE_PARAMS_V1 NV_SMP_ASSIST_ENABLE_PARAMS; +#define NV_SMP_ASSIST_ENABLE_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_SMP_ASSIST_ENABLE_PARAMS_V1, 1) +#define NV_SMP_ASSIST_ENABLE_PARAMS_VER NV_SMP_ASSIST_ENABLE_PARAMS_VER1 + +typedef struct _NV_SMP_ASSIST_DISABLE_PARAMS_V1 +{ + NvU32 version; //!< (IN) Structure version + NvU32 Reserved; //!< (IN) Unused. +} NV_SMP_ASSIST_DISABLE_PARAMS_V1; + +typedef NV_SMP_ASSIST_DISABLE_PARAMS_V1 NV_SMP_ASSIST_DISABLE_PARAMS; +#define NV_SMP_ASSIST_DISABLE_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_SMP_ASSIST_DISABLE_PARAMS_V1, 1) +#define NV_SMP_ASSIST_DISABLE_PARAMS_VER NV_SMP_ASSIST_DISABLE_PARAMS_VER1 + +// FastGS constant buffer data returned by the GetConstants API. +// Refer VRWorks SDK's multiprojection_dx app (struct FastGSCBData) +typedef struct _NV_SMP_ASSIST_FASTGSCBDATA_V1 +{ + float NDCSplitsX[2]; //!< (OUT) FastGS constant buffer data for Multi-Res Shading/ Lens Matched Shading + float NDCSplitsY[2]; +} NV_SMP_ASSIST_FASTGSCBDATA_V1; + +typedef NV_SMP_ASSIST_FASTGSCBDATA_V1 NV_SMP_ASSIST_FASTGSCBDATA; + +typedef struct _NV_SMP_ASSIST_FASTGSCBDATA_MRS_INSTANCED_STEREO_V1 +{ + float NDCSplitsX[4]; //!< (OUT) FastGS constant buffer data for Multi-Res Shading (Instanced stereo). 2 splits for left eye followed by 2 splits for right eye + float NDCSplitsY[2]; +} NV_SMP_ASSIST_FASTGSCBDATA_MRS_INSTANCED_STEREO_V1; + +typedef NV_SMP_ASSIST_FASTGSCBDATA_MRS_INSTANCED_STEREO_V1 NV_SMP_ASSIST_FASTGSCBDATA_MRS_INSTANCED_STEREO; + +// Constant buffer data to supply the UV-remapping helper functions +// Refer VRWorks SDK's multiprojection_dx app (struct RemapCBData) +typedef struct _NV_SMP_ASSIST_REMAPCBDATA_V1 +{ + //!< (OUT) Constant buffer data to supply the UV-remapping helper functions + float ClipToWindowSplitsX[2]; + float ClipToWindowSplitsY[2]; + float ClipToWindowX[3][2]; // ClipToWindowX[i][0] is Scale and ClipToWindowX[i][1] is Bias + float ClipToWindowY[3][2]; // ClipToWindowY[i][0] is Scale and ClipToWindowY[i][1] is Bias + float ClipToWindowZ[2]; // ClipToWindowZ[0] is Scale and ClipToWindowZ[1] is Bias + + float WindowToClipSplitsX[2]; + float WindowToClipSplitsY[2]; + float WindowToClipX[3][2]; // WindowToClipX[i][0] is Scale and WindowToClipX[i][1] is Bias + float WindowToClipY[3][2]; // WindowToClipY[i][0] is Scale and WindowToClipY[i][1] is Bias + float WindowToClipZ[2]; // WindowToClipZ[0] is Scale and WindowToClipZ[1] is Bias + + float BoundingRectOriginX; + float BoundingRectOriginY; + float BoundingRectSizeWidth; + float BoundingRectSizeHeight; + float BoundingRectSizeInvWidth; + float BoundingRectSizeInvHeight; + + float Padding[2]; +}NV_SMP_ASSIST_REMAPCBDATA_V1; + +typedef NV_SMP_ASSIST_REMAPCBDATA_V1 NV_SMP_ASSIST_REMAPCBDATA; + +//! SUPPORTED OS: Windows 7 and higher +//! + +typedef struct _NV_SMP_ASSIST_GET_CONSTANTS_V3 +{ + NvU32 version; //!< (IN) Structure version + NV_SMP_ASSIST_EYE_INDEX eEyeIndex; //!< (IN) Viewports/scissors/constant buffer data corresponding to the input eEyeIndex will be returned + NvU32 numViewports; //!< (OUT) Number of valid viewport entries + D3D11_VIEWPORT *pViewports; //!< (OUT) If not NULL, this will contain the viewports computed by driver based on init params + D3D11_RECT *pScissors; //!< (OUT) If not NULL, this will contain the scissors computed by the driver based on init params + + NV_SMP_ASSIST_TYPE eSMPAssistType; //!< (OUT) SMP type provided in Init call + NV_SMP_ASSIST_LEVEL eSMPAssistLevel; //!< (OUT) SMP Assist level provided in Init call + + union + { + NV_MRS_CUSTOM_CONFIG_V1 sMRSConfig; //!< (OUT) If eSMPAssistType is MRS, then MRS config will be populated + NV_LMS_CUSTOM_CONFIG_V1 sLMSConfig; //!< (OUT) If eSMPAssistType is LMS, then LMS config will be populated + }; + + float projectionSizeWidth; //!< (OUT) MRS/LMS projection size + float projectionSizeHeight; //!< (OUT) + + NV_SMP_ASSIST_FASTGSCBDATA_V1 *pFastGSCBData; //!< (OUT) If not NULL, this will contain constant buffer data to supply the FastGS for culling primitives per-viewport + NV_SMP_ASSIST_REMAPCBDATA_V1 *pRemapCBData; //!< (OUT) If not NULL, this will contain constant buffer data to supply the UV-remapping helper functions + + D3D11_VIEWPORT boundingViewport; //!< (OUT) If eSMPType is MRS or LMS then this will be a union of the individual viewports populated in pViewports + D3D11_RECT boundingScissor; //!< (OUT) If eSMPType is MRS or LMS then this will be a union of the individual scissor rects populated in pScissors + + union + { + NV_MRS_INSTANCED_STEREO_CONFIG_V1 sMRS_ISConfig; //!< (OUT) If eSMPAssistType is MRS and eEyeIndex is NV_SMP_ASSIST_EYE_INDEX_INSTANCED_STEREO then MRS Instanced stereo config will be populated + NV_LMS_INSTANCED_STEREO_CONFIG_V1 sLMS_ISConfig; //!< (OUT) If eSMPAssistType is LMS and eEyeIndex is NV_SMP_ASSIST_EYE_INDEX_INSTANCED_STEREO then LMS Instanced stereo config will be populated + }; + + NV_SMP_ASSIST_FASTGSCBDATA_MRS_INSTANCED_STEREO_V1 *pFastGSCBDataMRS_IS; //!< (OUT) If non-NULL and eSMPAssistType is MRS and eEyeIndex is NV_SMP_ASSIST_EYE_INDEX_INSTANCED_STEREO then MRS Instanced stereo FastGS constant buffer data will be populated +} NV_SMP_ASSIST_GET_CONSTANTS_V3; + +#define NV_SMP_ASSIST_GET_CONSTANTS_VER3 MAKE_NVAPI_VERSION(NV_SMP_ASSIST_GET_CONSTANTS_V3, 3) +typedef NV_SMP_ASSIST_GET_CONSTANTS_V3 NV_SMP_ASSIST_GET_CONSTANTS; +#define NV_SMP_ASSIST_GET_CONSTANTS_VER NV_SMP_ASSIST_GET_CONSTANTS_VER3 + +//! SUPPORTED OS: Windows 7 and higher +//! + +typedef struct _NV_SMP_ASSIST_SETUP_PARAMS_V1 +{ + NvU32 version; //!< (IN) Structure version + union + { + NV_MRS_CONFIG eMRSConfig; //!< (IN) If eSMPAssistType is MRS and SMP Assist Level is Full then provide MRS config enum + NV_LMS_CONFIG eLMSConfig; //!< (IN) If eSMPAssistType is LMS and SMP Assist Level is Full then provide LMS config enum + NV_MRS_CUSTOM_CONFIG_V1 sMRSCustomConfig; //!< (IN) If eSMPAssistType is MRS and SMP Assist Level is Partial, then provide MRS config + NV_LMS_CUSTOM_CONFIG_V1 sLMSCustomConfig; //!< (IN) If eSMPAssistType is LMS and SMP Assist Level is Partial, then provide LMS config + NV_CUSTOM_RECTS_V1 sCustomRects; //!< (IN) If SMP Assist Level is Minimal, provide custom viewports and scissor rects for each eye index. + }; + + float resolutionScale; //!< (IN) A resolution multiplier in the range [0.1, 3.0] if app wants to render at higher resolution + D3D11_VIEWPORT boundingBox; //!< (IN) Rect on the rendertarget, to place the projection + float vpOffsets[2]; //!< (IN) Default set to 0. If non-zero, MRS/LMS viewports' TopLeftX and TopLeftY will be + //!< offset by vpOffsets[0] and vpOffsets[1] respectively. +} NV_SMP_ASSIST_SETUP_PARAMS_V1; + +typedef NV_SMP_ASSIST_SETUP_PARAMS_V1 NV_SMP_ASSIST_SETUP_PARAMS; +#define NV_SMP_ASSIST_SETUP_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_SMP_ASSIST_SETUP_PARAMS_V1, 1) +#define NV_SMP_ASSIST_SETUP_PARAMS_VER NV_SMP_ASSIST_SETUP_PARAMS_VER1 + +typedef struct _NV_SMP_ASSIST_UPDATE_INSTANCEDSTEREO_DATA_PARAMS_V1 +{ + NvU32 version; //!< (IN) Structure version + NV_SMP_ASSIST_TYPE eSMPAssistType; // Patch instanced stereo shaders (created with packed eye index) with this SMPAssistType (NV_SMP_ASSIST_LMS only) + float leftCoeffs[4]; // Left eye: outpos.x = dotproduct(outputpos, leftCoeffs) + leftConst + float leftConst; + float rightCoeffs[4]; // Right eye: outpos.x = dotproduct(outputpos, rightCoeffs) + rightConst + float rightConst; +} NV_SMP_ASSIST_UPDATE_INSTANCEDSTEREO_DATA_PARAMS_V1; + +typedef NV_SMP_ASSIST_UPDATE_INSTANCEDSTEREO_DATA_PARAMS_V1 NV_SMP_ASSIST_UPDATE_INSTANCEDSTEREO_DATA_PARAMS; +#define NV_SMP_ASSIST_UPDATE_INSTANCEDSTEREO_DATA_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_SMP_ASSIST_UPDATE_INSTANCEDSTEREO_DATA_PARAMS_V1, 1) +#define NV_SMP_ASSIST_UPDATE_INSTANCEDSTEREO_DATA_PARAMS_VER NV_SMP_ASSIST_UPDATE_INSTANCEDSTEREO_DATA_PARAMS_VER1 + +//! SUPPORTED OS: Windows 7 and higher +//! + +DECLARE_INTERFACE(ID3DNvSMPAssist_V1) +{ +////////////////////////////// VER1 methods ////////////////////////////////////////// + // Disable SMP Assist for further Draw calls + STDMETHOD_(NvAPI_Status,Disable)(THIS_ __in IUnknown *pDevContext, __in const NV_SMP_ASSIST_DISABLE_PARAMS *psSMPAssistDisableParams) PURE; + + // Enable SMP Assist for further Draw calls. App has to provide the type of rendering done in upcoming Draw calls - Mono/Left eye/Right eye/Instanced Stereo + STDMETHOD_(NvAPI_Status,Enable)(THIS_ __in IUnknown *pDevContext, __in const NV_SMP_ASSIST_ENABLE_PARAMS *psSMPAssistEnableParams) PURE; + + // Get the constants used by the drivers + STDMETHOD_(NvAPI_Status,GetConstants)(THIS_ __inout NV_SMP_ASSIST_GET_CONSTANTS *psSMPAssistGetConstants) PURE; + + // Setup the projections (rects, constant buffer data etc.) + STDMETHOD_(NvAPI_Status,SetupProjections)(THIS_ __in IUnknown *pDevice, __in const NV_SMP_ASSIST_SETUP_PARAMS *psSMPAssistSetupParams) PURE; + + // Update instanced stereo specific data + STDMETHOD_(NvAPI_Status,UpdateInstancedStereoData)(THIS_ __in IUnknown *pDevice, __in const NV_SMP_ASSIST_UPDATE_INSTANCEDSTEREO_DATA_PARAMS *psSMPAssistInstancedStereoParams) PURE; +////////////////////////////// end of VER1 methods ////////////////////////////////////////// +}; + +typedef ID3DNvSMPAssist_V1 ID3DNvSMPAssist; +#define ID3DNVSMPASSIST_VER1 MAKE_NVAPI_VERSION(ID3DNvSMPAssist_V1, 1) +#define ID3DNVSMPASSIST_VER ID3DNVSMPASSIST_VER1 + +//! SUPPORTED OS: Windows 7 and higher +//! + +typedef struct _NV_SMP_ASSIST_INITIALIZE_PARAMS_V1 +{ + NvU32 version; //!< (IN) Structure version + NV_SMP_ASSIST_TYPE eSMPAssistType; //!< (IN) None/MRS/LMS + NV_SMP_ASSIST_LEVEL eSMPAssistLevel; //!< (IN) Full/Partial/Minimal + NvU32 flags; //!< (IN) Flags, if any + + ID3DNvSMPAssist **ppD3DNvSMPAssist; //!< (OUT) Interface pointer returned by the Init call. Use for future Enable/Disable etc. calls + +} NV_SMP_ASSIST_INITIALIZE_PARAMS_V1; + +#define NV_SMP_ASSIST_INITIALIZE_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_SMP_ASSIST_INITIALIZE_PARAMS_V1, 1) +#ifndef NV_SMP_ASSIST_INITIALIZE_PARAMS_VER +typedef NV_SMP_ASSIST_INITIALIZE_PARAMS_V1 NV_SMP_ASSIST_INITIALIZE_PARAMS; +#define NV_SMP_ASSIST_INITIALIZE_PARAMS_VER NV_SMP_ASSIST_INITIALIZE_PARAMS_VER1 +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_InitializeSMPAssist +// +//! DESCRIPTION: Initialize SMP Assist extension. Take the SMPAssist(MRS/LMS) params from the application. +//! Provide the application with a interface pointer for future use. +//! +//! \since Release: 396 +//! \param [in] pDevice Pointer to IUnknown (Currently supports ID3D11Device) +//! \param [inout] pSMPAssistInitParams SMP Assist initialization params +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval ::NVAPI_OK Call succeeded. +//! \retval ::NVAPI_ERROR Call failed. +//! \retval ::NVAPI_INVALID_ARGUMENT One of the required input arguments was NULL +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_InitializeSMPAssist(__in IUnknown *pDevice, __inout NV_SMP_ASSIST_INITIALIZE_PARAMS *pSMPAssistInitParams); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + +//! SUPPORTED OS: Windows 7 and higher +//! +#if defined (__cplusplus) && defined(__d3d11_h__) +//! \ingroup dx +typedef struct _NV_QUERY_SMP_ASSIST_SUPPORT_PARAMS_V1 +{ + NvU32 version; //!< (IN) Structure version + NV_SMP_ASSIST_TYPE eSMPAssistType; //!< (IN) None/MRS/LMS + NV_SMP_ASSIST_LEVEL eSMPAssistLevel; //!< (IN) Full/Partial/Minimal + NvBool bSMPAssistSupported; //!< (OUT) SMP Assist supported or not +} NV_QUERY_SMP_ASSIST_SUPPORT_PARAMS_V1; + +typedef NV_QUERY_SMP_ASSIST_SUPPORT_PARAMS_V1 NV_QUERY_SMP_ASSIST_SUPPORT_PARAMS; +#define NV_QUERY_SMP_ASSIST_SUPPORT_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_QUERY_SMP_ASSIST_SUPPORT_PARAMS_V1, 1) +#define NV_QUERY_SMP_ASSIST_SUPPORT_PARAMS_VER NV_QUERY_SMP_ASSIST_SUPPORT_PARAMS_VER1 + +//! SUPPORTED OS: Windows 7 and higher +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_QuerySMPAssistSupport +// +//! DESCRIPTION: Query SMP assist extension support. +//! +//! \since Release: 396 +//! \param [in] pDev Pointer to IUnknown (Currently supports ID3D11Device) +//! \param [out] pQuerySMPAssistSupportParams Pointer to a structure returning requested SMP assist support +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! \retval ::NVAPI_NOT_SUPPORTED Requested SMP assist is not supported. +//! \retval ::NVAPI_OK Call succeeded. Check value of pQuerySMPAssistSupportParams->bSMPAssistSupported +//! \retval ::NVAPI_INVALID_POINTER pDev or pQuerySMPAssistSupportParams was a NULL pointer +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_QuerySMPAssistSupport(__in IUnknown *pDev, __inout NV_QUERY_SMP_ASSIST_SUPPORT_PARAMS *pQuerySMPAssistSupportParams); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + + + +//! SUPPORTED OS: Windows 7 and higher +//! +//! Used to get sleep status +//! \ingroup dx +typedef struct _NV_GET_SLEEP_STATUS_PARAMS +{ + NvU32 version; //!< (IN) Structure version + NvBool bLowLatencyMode; //!< (OUT) Is low latency mode enabled? + NvU8 rsvd[128]; //!< (IN) Reserved. Must be set to 0s. +} NV_GET_SLEEP_STATUS_PARAMS_V1; + +typedef NV_GET_SLEEP_STATUS_PARAMS_V1 NV_GET_SLEEP_STATUS_PARAMS; +#define NV_GET_SLEEP_STATUS_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_GET_SLEEP_STATUS_PARAMS_V1, 1) +#define NV_GET_SLEEP_STATUS_PARAMS_VER NV_GET_SLEEP_STATUS_PARAMS_VER1 + +#if defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_GetSleepStatus +// +//! DESCRIPTION: This function can be used to get the latest sleep status. +//! bLowLatencyMode indicates whether low latency mode is currently +//! enabled in the driver. +//! Note that it may not always reflect the previously requested sleep mode, +//! as the feature may not be available on the platform, or the setting has +//! been overridden by the control panel, for example. +//! +//! \since Release: 455 +//! \param [in] pDev The target device. +//! \param [in] pGetSleepStatusParams Sleep status params. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_GetSleepStatus(__in IUnknown *pDev, __in NV_GET_SLEEP_STATUS_PARAMS *pGetSleepStatusParams); +#endif //defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! +//! Used to set sleep mode +//! \ingroup dx +typedef struct _NV_SET_SLEEP_MODE_PARAMS +{ + NvU32 version; //!< (IN) Structure version + NvBool bLowLatencyMode; //!< (IN) Low latency mode enable/disable. + NvBool bLowLatencyBoost; //!< (IN) Request maximum GPU clock frequency regardless of workload. + NvU32 minimumIntervalUs; //!< (IN) Minimum frame interval in microseconds. 0 = no frame rate limit. + NvBool bUseMarkersToOptimize; //!< (IN) Allow latency markers to be used for runtime optimizations. + NvU8 rsvd[31]; //!< (IN) Reserved. Must be set to 0s. +} NV_SET_SLEEP_MODE_PARAMS_V1; + +typedef NV_SET_SLEEP_MODE_PARAMS_V1 NV_SET_SLEEP_MODE_PARAMS; +#define NV_SET_SLEEP_MODE_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_SET_SLEEP_MODE_PARAMS_V1, 1) +#define NV_SET_SLEEP_MODE_PARAMS_VER NV_SET_SLEEP_MODE_PARAMS_VER1 + +#if defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_SetSleepMode +// +//! DESCRIPTION: This function can be used to update sleep mode dynamically. +//! The settings are not dependent to each other, meaning low latency mode +//! can be enabled/disabled regardless of whether minimum interval is set or +//! not. The former is to intelligently lower latency without impacting frame +//! rate. The later is to limit frame rate (e.g. minimumIntervalUs = 10000 +//! limits frame rate to 100 FPS). They work well separately and/or together. +//! Note that minimumIntervalUs usage is not limited to lowering latency, so +//! feel free to use it to limit frame rate for menu, cut scenes, etc. +//! Note that low latency mode can be enabled, and/or minimum interval can +//! be set, even without using NvAPI_D3D_Sleep(). However, without it, the +//! sleep to achieve these features would happen at a less optimal point, +//! resulting in higher overall latency. +//! The bLowLatencyBoost will request the GPU run at max clocks even in +//! scenarios where it is idle most of the frame and would normally try +//! to save power. This can decrease latency in CPU-limited scenarios. +//! While this function can be called as often as needed, it is not +//! necessary nor recommended to call this too frequently (e.g. every frame), +//! as the settings persist for the target device. +//! +//! \since Release: 455 +//! \param [in] pDev The target device. +//! \param [in] pSetSleepModeParams Sleep mode params. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_SetSleepMode(__in IUnknown *pDev, __in NV_SET_SLEEP_MODE_PARAMS *pSetSleepModeParams); +#endif //defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)) + +#if defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_Sleep +// +//! DESCRIPTION: It is recommended to call this function at the very start of +//! each frame (e.g. before input sampling). If there is a need to sleep, +//! due to frame rate limit and/or low latency features, for example, +//! this call provides an entry point for the driver to sleep at the most +//! optimal spot to achieve the lowest latency. +//! It is recommended to call this function even when low latency mode is +//! disabled and minimum interval is 0. Other features, such as Maximum Frame +//! Rate setting, could be enabled in the control panel to benefit from this. +//! It is OK to start (or stop) using this function at any time. However, +//! when using this function, it must be called exactly once on each frame. +//! If this function is not called, after several frames, the driver would +//! fallback to sleep at its less optimal spot. +//! +//! \since Release: 455 +//! \param [in] pDev The target device. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_Sleep(__in IUnknown *pDev); +#endif //defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! +//! Used to get latency report. +//! \ingroup dx + +typedef struct _NV_LATENCY_RESULT_PARAMS +{ + NvU32 version; //!< (IN) Structure version + struct FrameReport { + NvU64 frameID; + NvU64 inputSampleTime; + NvU64 simStartTime; + NvU64 simEndTime; + NvU64 renderSubmitStartTime; + NvU64 renderSubmitEndTime; + NvU64 presentStartTime; + NvU64 presentEndTime; + NvU64 driverStartTime; + NvU64 driverEndTime; + NvU64 osRenderQueueStartTime; + NvU64 osRenderQueueEndTime; + NvU64 gpuRenderStartTime; + NvU64 gpuRenderEndTime; + NvU32 gpuActiveRenderTimeUs; //!< (OUT) Difference between gpuRenderStartTime and gpuRenderEndTime, excluding the idles in between, in microseconds. + NvU32 gpuFrameTimeUs; //!< (OUT) Difference between previous and current frame's gpuRenderEndTime, in microseconds. + NvU8 rsvd[120]; + } frameReport[64]; + NvU8 rsvd[32]; +} NV_LATENCY_RESULT_PARAMS_V1; + +typedef NV_LATENCY_RESULT_PARAMS_V1 NV_LATENCY_RESULT_PARAMS; +#define NV_LATENCY_RESULT_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_LATENCY_RESULT_PARAMS_V1, 1) +#define NV_LATENCY_RESULT_PARAMS_VER NV_LATENCY_RESULT_PARAMS_VER1 + +#if defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_GetLatency +// +//! DESCRIPTION: Get a latency report including the timestamps of the +//! application latency markers set with NvAPI_D3D_SetLatencyMarker as well +//! as driver, OS queue and graphics hardware times. Requires calling +//! NvAPI_D3D_SetLatencyMarker with incrementing frameID for valid results. +//! Rendering for at least 90 frames is recommended to properly fill out the +//! structure. The newest completed frame is at the end (element 63) and +//! is preceeded by older frames. If not enough frames are valid then all +//! frames are returned with all zeroes. +//! +//! \since Release: 455 +//! \param [in] pDev The target device +//! \param [in] pGetLatencyParams The latency result structure. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_GetLatency(__in IUnknown *pDev, __out NV_LATENCY_RESULT_PARAMS *pGetLatencyParams); +#endif //defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)) + +//! SUPPORTED OS: Windows 7 and higher +//! +//! Used define latency marker type +//! \ingroup dx +typedef enum +{ + SIMULATION_START = 0, + SIMULATION_END = 1, + RENDERSUBMIT_START = 2, + RENDERSUBMIT_END = 3, + PRESENT_START = 4, + PRESENT_END = 5, + INPUT_SAMPLE = 6, + TRIGGER_FLASH = 7, + PC_LATENCY_PING = 8, + OUT_OF_BAND_RENDERSUBMIT_START = 9, + OUT_OF_BAND_RENDERSUBMIT_END = 10, + OUT_OF_BAND_PRESENT_START = 11, + OUT_OF_BAND_PRESENT_END = 12, +} NV_LATENCY_MARKER_TYPE; + +//! SUPPORTED OS: Windows 7 and higher +//! +//! Used set latency markers +//! \ingroup dx +typedef struct _NV_LATENCY_MARKER_PARAMS +{ + NvU32 version; //!< (IN) Structure version + NvU64 frameID; + NV_LATENCY_MARKER_TYPE markerType; + NvU8 rsvd[64]; +} NV_LATENCY_MARKER_PARAMS_V1; + +typedef NV_LATENCY_MARKER_PARAMS_V1 NV_LATENCY_MARKER_PARAMS; +#define NV_LATENCY_MARKER_PARAMS_VER1 MAKE_NVAPI_VERSION(NV_LATENCY_MARKER_PARAMS_V1, 1) +#define NV_LATENCY_MARKER_PARAMS_VER NV_LATENCY_MARKER_PARAMS_VER1 + +#if defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_SetLatencyMarker +// +//! DESCRIPTION: Set a latency marker to be tracked by the +//! NvAPI_D3D_GetLatency function. SIMULATION_START must be the first marker +//! sent in a frame, after the previous frame's Sleep call (if used). +//! INPUT_SAMPLE may be sent to record the moment user input was sampled and +//! should come between SIMULATION_START and SIMULATION_END. +//! RENDERSUBMIT_START should come before any Direct3D calls are made for +//! the given frame and RENDERSUBMIT_END should come before calling Present. +//! PRESENT_START and END should wrap the Present call to inform the driver +//! of a present block done by the OS before the driver receives the Present. +//! TRIGGER_FLASH tells the driver to render its flash indicator for latency +//! testing, typically driven by a mouse click. +//! The frameID can start at an abitrary moment in the application lifetime +//! but must strictly increment from that point forward for consistent results. +//! +//! \since Release: 455 +//! \param [in] pDev The target device +//! \param [in] pSetLatencyMarkerParams The latency marker structure +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_SetLatencyMarker(__in IUnknown *pDev, __in NV_LATENCY_MARKER_PARAMS* pSetLatencyMarkerParams); +#endif //defined(__cplusplus) && (defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)) + +//! Used in NvAPI_D3D12_SetAsyncFrameMarker +//! \ingroup dx +typedef NV_LATENCY_MARKER_PARAMS_V1 NV_ASYNC_FRAME_MARKER_PARAMS_V1; +typedef NV_ASYNC_FRAME_MARKER_PARAMS_V1 NV_ASYNC_FRAME_MARKER_PARAMS; +#define NV_ASYNC_FRAME_MARKER_PARAMS_VER1 NV_LATENCY_MARKER_PARAMS_VER1 +#define NV_ASYNC_FRAME_MARKER_PARAMS_VER NV_LATENCY_MARKER_PARAMS_VER1 + +#if defined(__cplusplus) && (defined(__d3d12_h__)) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_SetAsyncFrameMarker +// +//! DESCRIPTION: Set an async frame marker for present and out-of-band render tracking. +//! +//! \since Release: 520 +//! \param [in] pCommandQueue The D3D12CommandQueue +//! \param [in] pSetAsyncFrameMarkerParams The async frame marker structure +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_SetAsyncFrameMarker(__in ID3D12CommandQueue *pCommandQueue, __in NV_ASYNC_FRAME_MARKER_PARAMS* pSetAsyncFrameMarkerParams); +#endif //defined(__cplusplus) && (defined(__d3d12_h__)) + +//! SUPPORTED OS: Windows 10 and higher +//! +//! Used in NvAPI_D3D12_NotifyOutOfBandCommandQueue +//! \ingroup dx +typedef enum +{ + OUT_OF_BAND_RENDER = 0, + OUT_OF_BAND_PRESENT = 1, +} NV_OUT_OF_BAND_CQ_TYPE; + +#if defined(__cplusplus) && defined(__d3d12_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_NotifyOutOfBandCommandQueue +// +//! DESCRIPTION: Notifies the driver that this command queue runs out of band +//! from the application's frame cadence. +//! +//! \since Release: 520 +//! \param [in] pCommandQueue The D3D12CommandQueue +//! \param [in] cqType The type of out of band command queue +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_NotifyOutOfBandCommandQueue(__in ID3D12CommandQueue *pCommandQueue, __in NV_OUT_OF_BAND_CQ_TYPE cqType); +#endif //defined(__cplusplus) && defined(__d3d12_h__)) + + +#if defined (__cplusplus) && defined(__d3d12_h__) + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_CreateCubinComputeShader(__in ID3D12Device* pDevice, + __in const void* pCubin, + __in NvU32 size, + __in NvU32 blockX, + __in NvU32 blockY, + __in NvU32 blockZ, + __out NVDX_ObjectHandle* phShader); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_CreateCubinComputeShaderEx(__in ID3D12Device* pDevice, + __in const void* pCubin, + __in NvU32 size, + __in NvU32 blockX, + __in NvU32 blockY, + __in NvU32 blockZ, + __in NvU32 dynSharedMemBytes, + __in const char* pShaderName, + __out NVDX_ObjectHandle* phShader); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_CreateCubinComputeShaderWithName(__in ID3D12Device* pDevice, + __in const void* pCubin, + __in NvU32 size, + __in NvU32 blockX, + __in NvU32 blockY, + __in NvU32 blockZ, + __in const char* pShaderName, + __out NVDX_ObjectHandle* phShader); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_LaunchCubinShader(__in ID3D12GraphicsCommandList* pCommandList, + __in NVDX_ObjectHandle hShader, + __in NvU32 gridX, + __in NvU32 gridY, + __in NvU32 gridZ, + __in const void* pParams, + __in NvU32 paramSize); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_DestroyCubinComputeShader(__in ID3D12Device* pDevice, + __in NVDX_ObjectHandle hShader); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_GetCudaTextureObject(__in ID3D12Device* pDevice, + __in D3D12_CPU_DESCRIPTOR_HANDLE texDesc, + __in D3D12_CPU_DESCRIPTOR_HANDLE smpDesc, + __out NvU32* pTextureHandle); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_GetCudaSurfaceObject(__in ID3D12Device* pDevice, + __in D3D12_CPU_DESCRIPTOR_HANDLE uavDesc, + __out NvU32* pSurfaceHandle); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_IsFatbinPTXSupported(__in ID3D12Device *pDevice, + __out bool *pSupported); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_CreateCuModule(__in ID3D12Device* pDevice, + __in const void* pBlob, + __in NvU32 size, + __out NVDX_ObjectHandle* phModule); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_EnumFunctionsInModule(__in ID3D12Device* pDevice, + __in NVDX_ObjectHandle hModule, + __inout NvU32* pArraySize, + __out const char** const pFunctionNames); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_CreateCuFunction(__in ID3D12Device* pDevice, + __in NVDX_ObjectHandle hModule, + __in const char* pName, + __out NVDX_ObjectHandle* phFunction); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! + +typedef struct _NVAPI_DIM3 +{ + NvU32 x; + NvU32 y; + NvU32 z; +} NVAPI_DIM3; + +typedef struct _NVAPI_CU_KERNEL_LAUNCH_PARAMS +{ + NVDX_ObjectHandle hFunction; + NVAPI_DIM3 gridDim; + NVAPI_DIM3 blockDim; + NvU32 dynSharedMemBytes; + void const * pParams; + NvU32 paramSize; +} NVAPI_CU_KERNEL_LAUNCH_PARAMS; + +NVAPI_INTERFACE NvAPI_D3D12_LaunchCuKernelChain(__in ID3D12GraphicsCommandList* pCommandList, + __in const NVAPI_CU_KERNEL_LAUNCH_PARAMS* pKernels, + __in NvU32 numKernels); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_DestroyCuModule(__in ID3D12Device* pDevice, + __in NVDX_ObjectHandle hModule); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D12_DestroyCuFunction(__in ID3D12Device* pDevice, + __in NVDX_ObjectHandle hFunction); +#endif //if defined (__cplusplus) && defined(__d3d12_h__) + + +#if defined (__cplusplus) && defined(__d3d11_h__) + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_CreateCubinComputeShader(__in ID3D11Device* pDevice, + __in const void* pCubin, + __in NvU32 size, + __in NvU32 blockX, + __in NvU32 blockY, + __in NvU32 blockZ, + __out NVDX_ObjectHandle* phShader); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_CreateCubinComputeShaderEx(__in ID3D11Device* pDevice, + __in const void* pCubin, + __in NvU32 size, + __in NvU32 blockX, + __in NvU32 blockY, + __in NvU32 blockZ, + __in NvU32 dynSharedMemBytes, + __in const char* pShaderName, + __out NVDX_ObjectHandle* phShader); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_CreateCubinComputeShaderWithName(__in ID3D11Device* pDevice, + __in const void* pCubin, + __in NvU32 size, + __in NvU32 blockX, + __in NvU32 blockY, + __in NvU32 blockZ, + __in const char* pShaderName, + __out NVDX_ObjectHandle* phShader); + + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_LaunchCubinShader(__in ID3D11DeviceContext *pDeviceContext, + __in NVDX_ObjectHandle hShader, + __in NvU32 gridX, + __in NvU32 gridY, + __in NvU32 gridZ, + __in const void* pParams, + __in NvU32 paramSize, + __in const NVDX_ObjectHandle* pReadResources, + __in NvU32 numReadResources, + __in const NVDX_ObjectHandle* pWriteResources, + __in NvU32 numWriteResources); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_DestroyCubinComputeShader(__in ID3D11Device* pDevice, + __in NVDX_ObjectHandle hShader); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_IsFatbinPTXSupported(__in ID3D11Device *pDevice, + __out bool *pSupported); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_CreateUnorderedAccessView(__in ID3D11Device* pDevice, + __in ID3D11Resource* pResource, + __in const D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc, + __out ID3D11UnorderedAccessView** ppUAV, + __out NvU32* pDriverHandle); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_CreateShaderResourceView(__in ID3D11Device* pDevice, + __in ID3D11Resource* pResource, + __in const D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc, + __out ID3D11ShaderResourceView** ppSRV, + __out NvU32* pDriverHandle); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_CreateSamplerState(__in ID3D11Device* pDevice, + __in const D3D11_SAMPLER_DESC* pSamplerDesc, + __out ID3D11SamplerState** ppSamplerState, + __out NvU32* pDriverHandle); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_GetCudaTextureObject(__in ID3D11Device* pDevice, + __in NvU32 srvDriverHandle, + __in NvU32 samplerDriverHandle, + __out NvU32* pCudaTextureHandle); + +// Experimental API for internal use. DO NOT USE! +//! SUPPORTED OS: Windows 10 and higher +//! +NVAPI_INTERFACE NvAPI_D3D11_GetResourceGPUVirtualAddress(__in ID3D11Device* pDevice, + __in const NVDX_ObjectHandle hResource, + __out NvU64* pGpuVA); +#endif //defined(__cplusplus) && defined(__d3d11_h__) + + +#if defined(__cplusplus) && defined(__d3d12_h__) +//! Flags specifying raytracing thread reordering hardware support. +//! Additional flags will be added as support becomes available. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_THREAD_REORDERING_CAPS +{ + NVAPI_D3D12_RAYTRACING_THREAD_REORDERING_CAP_NONE = 0x0, //!< Thread reordering acts as a no-op + NVAPI_D3D12_RAYTRACING_THREAD_REORDERING_CAP_STANDARD = NV_BIT(0) //!< Standard thread reordering is supported +} NVAPI_D3D12_RAYTRACING_THREAD_REORDERING_CAPS; + +//! Flags specifying raytracing Opacity Micromap support. +//! Additional flags will be added as support becomes available. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_CAPS +{ + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_CAP_NONE = 0x0, //!< Opacity Micromap support is not available. + //!< The application must not attempt to use any OMM entrypoints or flags. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_CAP_STANDARD = NV_BIT(0) //!< Standard Opacity Micromap support is available +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_CAPS; + +//! List of Raytracing CAPS types that can be queried. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_CAPS_TYPE +{ + NVAPI_D3D12_RAYTRACING_CAPS_TYPE_THREAD_REORDERING = 0, + NVAPI_D3D12_RAYTRACING_CAPS_TYPE_OPACITY_MICROMAP = 1, + NVAPI_D3D12_RAYTRACING_CAPS_TYPE_INVALID = -1 +} NVAPI_D3D12_RAYTRACING_CAPS_TYPE; +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_GetRaytracingCaps +// +//! DESCRIPTION: Query raytracing capabilities of a device. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 520 +//! +//! \param [in] pDevice Pointer to the device on which caps should be queried from. Pointer to the device from which ray tracing caps should be queried. Device to query ray tracing caps from. +//! \param [in] type Raytracing caps type requested. +//! \param [out] pData Memory to write raytracing caps to. +//! \param [in] dataSize Size in bytes of the memory pointed to by pData, must match the size of the raytracing caps type requested. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \retval ::NVAPI_OK Completed request +//! \retval ::NVAPI_INVALID_POINTER A null pointer was passed as an argument +//! \retval ::NVAPI_INVALID_ARGUMENT At least one of the arguments are invalid +//! \retval ::NVAPI_ERROR Error occurred +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_GetRaytracingCaps( + __in ID3D12Device* pDevice, + __in NVAPI_D3D12_RAYTRACING_CAPS_TYPE type, + __out void* pData, + __in size_t dataSize); +#endif // defined(__cplusplus) && defined(__d3d12_h__) + +//! SUPPORTED OS: Windows 10 and higher +//! +#if defined(__cplusplus) && defined(__d3d12_h__) && (defined(__ID3D12Device5_INTERFACE_DEFINED__) || defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__)) + +// Types used by both device and command list functions. + +//! Flags specifying building instructions and hints when constructing an OMM Array. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BUILD_FLAGS +{ + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BUILD_FLAG_NONE = 0x0, //!< No options specified for the OMM Array build. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BUILD_FLAG_PREFER_FAST_TRACE = NV_BIT(0), //!< Allow the OMM Array build to take a little longer in order to optimize for traversal performance. + //!< This flag is incompatible with #NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BUILD_FLAG_PREFER_FAST_BUILD. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BUILD_FLAG_PREFER_FAST_BUILD = NV_BIT(1) //!< Spend as little time as possible on the OMM Array build with some potential loss to traversal performance. + //!< This flag is incompatible with #NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BUILD_FLAG_PREFER_FAST_TRACE. +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BUILD_FLAGS; + +//! Specifies the input Opacity Micromap formats. +//! The OC1 (Opacity Compression 1) format follows the space-filling curve in barycentric space over the uniformly tessellated micro-triangles. +//! +//! \note This is a 16-bit value when used in #NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_DESC. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_FORMAT +{ + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_FORMAT_OC1_2_STATE = 0x1, //!< 2-state (Transparent/Opaque) format. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_FORMAT_OC1_4_STATE = 0x2 //!< 4-state (Transparent/Opaque, Known/Unknown) format. +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_FORMAT; + +//! Number of OMMs of a specific configuration in an OMM Array. +//! Used to compute conservative buffer size estimates for OMM Array builds. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_USAGE_COUNT +{ + NvU32 count; //!< Total number of OMMs in the OMM Array with the particular \p subdivisionLevel and \p format specified in this descriptor. + NvU32 subdivisionLevel; //!< Number of subdivisions for the OMM; valid inputs are [0, 12] (#NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_OC1_MAX_SUBDIVISION_LEVEL). + //!< The total number of micro-triangles is 4subdivisionLevel. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_FORMAT format; //!< Opacity Micromap format. +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_USAGE_COUNT; + +//! Describes one Opacity Micromap. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_DESC +{ + NvU32 byteOffset; //!< Byte offset from the \c inputBuffer, specified in the input structure #NVAPI_D3D12_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_INPUTS, to where the input OMM data is located. + NvU16 subdivisionLevel; //!< Number of subdivisions for the OMM; valid inputs are [0, 12] (#NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_OC1_MAX_SUBDIVISION_LEVEL). + //!< The total number of micro-triangles is 4subdivisionLevel. + NvU16 format; //!< Format of the OMM of type #NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_FORMAT. +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_DESC; + +//! Input structure to OMM Array construction. +//! Individual OMMs are accessed via indices when used in bottom-level acceleration structure (BLAS) construction. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_INPUTS +{ + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BUILD_FLAGS flags; //!< Flags which apply to all OMMs in the array. + NvU32 numOMMUsageCounts; //!< Number of OMM usage count entries in the \p pOMMUsageCounts array. + const NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_USAGE_COUNT* pOMMUsageCounts; //!< Usage counts for each subdivision level and format combination across all the OMM entries in the build. + D3D12_GPU_VIRTUAL_ADDRESS inputBuffer; //!< Address for raw OMM input data; it must be 256-byte aligned. + //!< It is recommended to try to organize OMMs together in memory that are expected to be used close together spatially. + D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE perOMMDescs; //!< GPU array with one #NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_DESC entry per OMM. +} NVAPI_D3D12_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_INPUTS; + +#endif // defined(__cplusplus) && defined(__d3d12_h__) && (defined(__ID3D12Device5_INTERFACE_DEFINED__) || defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__)) + +#if defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12Device5_INTERFACE_DEFINED__) + +//! Conservative memory requirements for building an OMM Array. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO +{ + NvU64 resultDataMaxSizeInBytes; //!< Size required to hold the result of an OMM Array build based on the specified inputs. + NvU64 scratchDataSizeInBytes; //!< Scratch storage on GPU required during OMM Array build based on the specified inputs. +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO; + +//! Parameters given to NvAPI_D3D12_GetRaytracingOpacityMicromapArrayPrebuildInfo(). +//! +//! \ingroup dx +typedef struct _NVAPI_GET_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO_PARAMS_V1 +{ + NvU32 version; //!< [in] Structure version; it should be set to #NVAPI_GET_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO_PARAMS_VER. + const NVAPI_D3D12_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_INPUTS* pDesc; //!< [in] Description of the OMM Array build. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO* pInfo; //!< [out] Result of the query. +} NVAPI_GET_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO_PARAMS_V1; +#define NVAPI_GET_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO_PARAMS_VER1 MAKE_NVAPI_VERSION(NVAPI_GET_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO_PARAMS_V1, 1) +typedef NVAPI_GET_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO_PARAMS_V1 NVAPI_GET_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO_PARAMS; +#define NVAPI_GET_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO_PARAMS_VER NVAPI_GET_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO_PARAMS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_GetRaytracingOpacityMicromapArrayPrebuildInfo +// +//! DESCRIPTION: Query conservative memory requirements for building an OMM (Opacity Micromap) Array. +//! The returned size is conservative for OMM Array builds containing +//! a lower or equal number of entries for each resolution and format combination. +//! +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 520 +//! +//! \param [in] pDevice Device on which the OMM Array will be built. +//! \param [in,out] pParams Wrapper around the inputs and outputs of the function. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_GetRaytracingOpacityMicromapArrayPrebuildInfo( + __in ID3D12Device5* pDevice, + __inout NVAPI_GET_RAYTRACING_OPACITY_MICROMAP_ARRAY_PREBUILD_INFO_PARAMS* pParams); + +#endif // defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12Device5_INTERFACE_DEFINED__) + +#if defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12Device5_INTERFACE_DEFINED__) + +//! Pipeline creation state flags. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_PIPELINE_CREATION_STATE_FLAGS +{ + NVAPI_D3D12_PIPELINE_CREATION_STATE_FLAGS_ENABLE_OMM_SUPPORT = NV_BIT(0) //!< [in] Change whether raytracing pipelines are created with support for Opacity Micromaps. + //!< If a triangle with an OMM is encountered during traversal and the pipeline was not created with support for them, behavior is undefined. + //!< Support should only be enabled if there are OMMs present, since it may incur a small penalty on traversal performance overall. +} NVAPI_D3D12_PIPELINE_CREATION_STATE_FLAGS; + +//! State used when creating new pipelines. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_SET_CREATE_PIPELINE_STATE_OPTIONS_PARAMS_V1 +{ + NvU32 version; //!< [in] Structure version; it should be set to #NVAPI_D3D12_SET_CREATE_PIPELINE_STATE_OPTIONS_PARAMS_VER. + NvU32 flags; //!< [in] A bitwise OR of one or more #NVAPI_D3D12_PIPELINE_CREATION_STATE_FLAGS flags for raytracing pipeline creation. +} NVAPI_D3D12_SET_CREATE_PIPELINE_STATE_OPTIONS_PARAMS_V1; +#define NVAPI_D3D12_SET_CREATE_PIPELINE_STATE_OPTIONS_PARAMS_VER1 MAKE_NVAPI_VERSION(NVAPI_D3D12_SET_CREATE_PIPELINE_STATE_OPTIONS_PARAMS_V1, 1) +typedef NVAPI_D3D12_SET_CREATE_PIPELINE_STATE_OPTIONS_PARAMS_V1 NVAPI_D3D12_SET_CREATE_PIPELINE_STATE_OPTIONS_PARAMS; +#define NVAPI_D3D12_SET_CREATE_PIPELINE_STATE_OPTIONS_PARAMS_VER NVAPI_D3D12_SET_CREATE_PIPELINE_STATE_OPTIONS_PARAMS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_SetCreatePipelineStateOptions +// +//! DESCRIPTION: Globally change the state affecting pipeline creations. +//! This affects all pipelines created after this call, and until this function is called again. +//! +//! \note Only supported on GPUs capable of DXR. +//! Some of the flags and fields have further restrictions, in which case their description will include a note with more details. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 520 +//! +//! \param [in] pDevice Device on which the pipelines will be created. +//! \param [in] pState State to be applied to all future pipeline creations. + +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_SetCreatePipelineStateOptions( + __in ID3D12Device5* pDevice, + __in const NVAPI_D3D12_SET_CREATE_PIPELINE_STATE_OPTIONS_PARAMS* pState); + +#endif // defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12Device5_INTERFACE_DEFINED__) + +#if defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12Device5_INTERFACE_DEFINED__) + +//! Type of serialized data. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_SERIALIZED_DATA_TYPE_EX +{ + // D3D12_SERIALIZED_DATA_TYPE flags + NVAPI_D3D12_SERIALIZED_DATA_RAYTRACING_ACCELERATION_STRUCTURE_EX = 0x0, //!< Serialized data contains a raytracing acceleration structure. + //!< Starting from offset 0, the first bytes of the serialized acceleration structure can be reinterpreted as \c D3D12_SERIALIZED_RAYTRACING_ACCELERATION_STRUCTURE_HEADER. + //!< That structure contains the identifier to be passed along to NvAPI_D3D12_CheckDriverMatchingIdentifierEx(). + + // NVAPI_D3D12_SERIALIZED_DATA_TYPE_EX specific flags + NVAPI_D3D12_SERIALIZED_DATA_RAYTRACING_OPACITY_MICROMAP_ARRAY_EX = 0x1 //!< Data blob contains an OMM Array. + //!< Starting from offset 0, the first bytes of the OMM Array can be reinterpreted as \c D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER. + +} NVAPI_D3D12_SERIALIZED_DATA_TYPE_EX; + +//! Parameters given to NvAPI_D3D12_CheckDriverMatchingIdentifierEx(). +//! +//! \ingroup dx +typedef struct _NVAPI_CHECK_DRIVER_MATCHING_IDENTIFIER_EX_PARAMS_V1 +{ + NvU32 version; //!< [in] Structure version; it should be set to #NVAPI_CHECK_DRIVER_MATCHING_IDENTIFIER_EX_PARAMS_VER. + NVAPI_D3D12_SERIALIZED_DATA_TYPE_EX serializedDataType; //!< [in] Type of data to be deserialized; see #NVAPI_D3D12_SERIALIZED_DATA_TYPE_EX. + const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER* pIdentifierToCheck; //!< [in] Identifier from the header of the serialized data to check with the driver; see \c D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER. + //!< Information about how to retrieve that identifier can be found in the description of each #NVAPI_D3D12_SERIALIZED_DATA_TYPE_EX enum. + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS checkStatus; //!< [out] Result of the check; see \c D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS. +} NVAPI_CHECK_DRIVER_MATCHING_IDENTIFIER_EX_PARAMS_V1; +#define NVAPI_CHECK_DRIVER_MATCHING_IDENTIFIER_EX_PARAMS_VER1 MAKE_NVAPI_VERSION(NVAPI_CHECK_DRIVER_MATCHING_IDENTIFIER_EX_PARAMS_V1, 1) +typedef NVAPI_CHECK_DRIVER_MATCHING_IDENTIFIER_EX_PARAMS_V1 NVAPI_CHECK_DRIVER_MATCHING_IDENTIFIER_EX_PARAMS; +#define NVAPI_CHECK_DRIVER_MATCHING_IDENTIFIER_EX_PARAMS_VER NVAPI_CHECK_DRIVER_MATCHING_IDENTIFIER_EX_PARAMS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_CheckDriverMatchingIdentifierEx +// +//! DESCRIPTION: This function is an extension of ID3D12Device5::CheckDriverMatchingIdentifier() with additional serialized data types. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 520 +//! +//! \param [in] pDevice Device on which the data will be deserialized. +//! \param [in,out] pParams Wrapper around the inputs and outputs of the function. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_CheckDriverMatchingIdentifierEx( + __in ID3D12Device5* pDevice, + __inout NVAPI_CHECK_DRIVER_MATCHING_IDENTIFIER_EX_PARAMS* pParams); + +#endif // defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12Device5_INTERFACE_DEFINED__) + +#if defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12Device5_INTERFACE_DEFINED__) + +//! This enum extends \c D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS with modified and additional values. +//! Only modified/new values are fully described; for more information on the other values, please check Microsoft's DirectX Raytracing Specification. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS_EX +{ + // D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS flags + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_NONE_EX = 0x0, //!< No options specified for the acceleration structure build. + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_UPDATE_EX = NV_BIT(0), //!< Allow the acceleration structure to later be updated (via the flag #NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE_EX), rather than always requiring a full rebuild. + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_COMPACTION_EX = NV_BIT(1), //!< Allow for the acceleration structure to later be compacted. + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_TRACE_EX = NV_BIT(2), //!< Favorize higher raytracing performance at the cost of longer build times. + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_BUILD_EX = NV_BIT(3), //!< Favorize faster build times at the cost of lower raytracing performance. + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_MINIMIZE_MEMORY_EX = NV_BIT(4), //!< Minimize the memory footprint of the produced acceleration structure, potentially at the cost of longer build time or lower raytracing performance. + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE_EX = NV_BIT(5), //!< Instead of rebuilding the acceleration structure from scratch, the existing acceleration structure will be updated. + //!< Added behaviour: If #NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_OMM_UPDATE_EX is specified, OMM references may be changed along with positions when an update is performed. + + // NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS_EX specific flags + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_OMM_UPDATE_EX = NV_BIT(6), //!< The acceleration structure (AS) supports updating OMM contents (base OMM Array and/or indices). + //!< Specifying this flag may result in larger AS size and may reduce traversal performance. + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_DISABLE_OMMS_EX = NV_BIT(7), //!< Only applicable for BLAS builds. If enabled, any instances referencing this BLAS are allowed to disable the OMM test through the #NVAPI_D3D12_RAYTRACING_INSTANCE_FLAG_DISABLE_OMMS_EX flag. + //!< Specifying this build flag may result in some reductions in traversal performance. + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_OMM_OPACITY_STATES_UPDATE_EX = NV_BIT(8) //!< The acceleration structure (AS) supports updating OMM data (encoded opacity values). + //!< Specifying this flag may reduce traversal performance. + +} NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS_EX; + +//! This enum extends \c D3D12_RAYTRACING_GEOMETRY_TYPE with additional values. +//! Only new values are fully described below; for more information on the other values, please check Microsoft's DirectX Raytracing Specification. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_GEOMETRY_TYPE_EX +{ + // D3D12_RAYTRACING_GEOMETRY_TYPE flags + NVAPI_D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES_EX = 0x0, //!< This geometry is made of basic triangles. + NVAPI_D3D12_RAYTRACING_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS_EX = 0x1, //!< This geometry is made of axis-aligned bounding boxes (AABBs). + + // NVAPI_D3D12_RAYTRACING_GEOMETRY_TYPE_EX specific flags + NVAPI_D3D12_RAYTRACING_GEOMETRY_TYPE_OMM_TRIANGLES_EX = 0x2 //!< Shares most fields with the basic triangle geometry type, but allows an OMM Array to be attached to the geometry. + //!< The basic triangle type and this OMM-enabled type geometries may be mixed in the same BLAS build. +} NVAPI_D3D12_RAYTRACING_GEOMETRY_TYPE_EX; + +//! If a triangle has a uniform OMM state in a BLAS build, it is preferable to signal this explicitly rather than attaching a single state OMM. +//! This can be accomplished by supplying these special indices as entries in \c opacityMicromapIndexBuffer, in #NVAPI_D3D12_RAYTRACING_GEOMETRY_OMM_TRIANGLES_DESC. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_SPECIAL_INDEX +{ + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_TRANSPARENT = -1, //!< Uniform transparent OMM state. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_OPAQUE = -2, //!< Uniform opaque OMM state. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_UNKNOWN_TRANSPARENT = -3, //!< Uniform unknown-transparent OMM state. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_UNKNOWN_OPAQUE = -4 //!< Uniform unknown-opaque OMM state. +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_SPECIAL_INDEX; + +//! Geometry descriptor attachment with Opacity Micromaps. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_RAYTRACING_GEOMETRY_OMM_ATTACHMENT_DESC +{ + D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE opacityMicromapIndexBuffer; //!< Optional buffer specifying which OMM index to use for each triangle; if \c NULL, there is a 1:1 mapping between input triangles and OMM Array entries. + //!< Special values can be used to encode OMMs with uniform state for individual triangles (see #NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_SPECIAL_INDEX). + //!< For BLAS updates, this input buffer must match that of the original build if the #NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_OMM_UPDATE_EX build flag is not set. + DXGI_FORMAT opacityMicromapIndexFormat; //!< Format of \c opacityMicromapIndexBuffer, either \c DXGI_FORMAT_R32_UINT or \c DXGI_FORMAT_R16_UINT. + NvU32 opacityMicromapBaseLocation; //!< Constant added to all non-negative OMM indices in \p opacityMicromapIndexBuffer. + D3D12_GPU_VIRTUAL_ADDRESS opacityMicromapArray; //!< Pointer to an OMM Array used by this geometry; it may be set to \c NULL if no non-uniform OMMs are used. + //!< Unlike vertex, index, and transform buffers, this resource is dereferenced during raytracing. + + NvU32 numOMMUsageCounts; //!< Number of OMM usage count entries in the \p pOMMUsageCounts array. + const NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_USAGE_COUNT* pOMMUsageCounts; //!< Usage counts for each subdivision level and format combination across all the OMM entries referred-to by the OMM index buffer specified by this geometry. + +} NVAPI_D3D12_RAYTRACING_GEOMETRY_OMM_ATTACHMENT_DESC; + +//! Geometry triangle descriptor with attached augmented Opacity Micromaps. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_RAYTRACING_GEOMETRY_OMM_TRIANGLES_DESC +{ + D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC triangles; //!< Triangle mesh descriptor. + NVAPI_D3D12_RAYTRACING_GEOMETRY_OMM_ATTACHMENT_DESC ommAttachment; //!< Opacity Micromap attachment descriptor. +} NVAPI_D3D12_RAYTRACING_GEOMETRY_OMM_TRIANGLES_DESC; + +//! This structure extends \c D3D12_RAYTRACING_GEOMETRY_DESC by supporting additional geometry types. +//! Only new members are fully described below; for more information on the other members, please check Microsoft's DirectX Raytracing Specification. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_RAYTRACING_GEOMETRY_DESC_EX +{ + NVAPI_D3D12_RAYTRACING_GEOMETRY_TYPE_EX type; //!< The type of geometry stored in the union of this structure. + D3D12_RAYTRACING_GEOMETRY_FLAGS flags; //!< Flags affecting how this geometry is processed by the raytracing pipeline. + union + { + D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC triangles; //!< Describes triangle geometry if \c type is #NVAPI_D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES_EX. + //!< Otherwise, this parameter is unused (space repurposed in a union). + D3D12_RAYTRACING_GEOMETRY_AABBS_DESC aabbs; //!< Describes AABB geometry if \c type is #NVAPI_D3D12_RAYTRACING_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS_EX. + //!< Otherwise, this parameter is unused (space repurposed in a union). + NVAPI_D3D12_RAYTRACING_GEOMETRY_OMM_TRIANGLES_DESC ommTriangles; //!< Describes triangle geometry which may optionally use Opacity Micromaps, if \c type is #NVAPI_D3D12_RAYTRACING_GEOMETRY_TYPE_OMM_TRIANGLES_EX. + //!< Otherwise, this parameter is unused (space repurposed in a union). + }; +} NVAPI_D3D12_RAYTRACING_GEOMETRY_DESC_EX; + +//! This enum extends \c D3D12_RAYTRACING_INSTANCE_FLAGS with additional values. +//! Only new values are fully described below; for more information on the other values, please check Microsoft's DirectX Raytracing Specification. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_INSTANCE_FLAGS_EX +{ + // D3D12_RAYTRACING_INSTANCE_FLAGS flags + NVAPI_D3D12_RAYTRACING_INSTANCE_FLAG_NONE_EX = 0x0, //!< No options specified for this instance. + NVAPI_D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_CULL_DISABLE_EX = NV_BIT(0), //!< Disable triangle culling for this instance. + NVAPI_D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE_EX = NV_BIT(1), //!< Use counter-clockwise winding for defining front faces, instead of the default of clockwise winding. + NVAPI_D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_OPAQUE_EX = NV_BIT(2), //!< Force all geometries in this instance to be opaque. + NVAPI_D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_NON_OPAQUE_EX = NV_BIT(3), //!< All geometries in this instance will be processed as if they never had the \c D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE flag applied to them. + + // NVAPI_D3D12_RAYTRACING_INSTANCE_FLAGS_EX specific flags + NVAPI_D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_OMM_2_STATE_EX = NV_BIT(4), //!< Ignore the Unknown state and only consider the Transparent/Opaque bit for all 4-state OMMs encountered during traversal. + //!< This flag has no effect if #NVAPI_D3D12_RAYTRACING_INSTANCE_FLAG_DISABLE_OMMS_EX is set. + NVAPI_D3D12_RAYTRACING_INSTANCE_FLAG_DISABLE_OMMS_EX = NV_BIT(5) //!< Disable OMMs for all triangles, and revert to using geometry opaque/non-opaque state instead (legacy behavior). + //!< This flag is only valid if the referenced BLAS was built with the #NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_DISABLE_OMMS_EX flag; omitting that flag during BLAS build will result in undefined behavior. +} NVAPI_D3D12_RAYTRACING_INSTANCE_FLAGS_EX; + +//! This structure extends \c D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS by supporting additional geometry types. +//! Only modified members are fully described below; for more information on the other members, please check Microsoft's DirectX Raytracing Specification. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS_EX +{ + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type; //!< Whether a top-level acceleration structure (TLAS) or bottom-level acceleration structure (BLAS) will be built using this information. + NVAPI_D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS_EX flags; //!< Options influencing how the acceleration structure is built and which of its features can be used. + NvU32 numDescs; //!< If \c type is \c D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TOP_LEVEL, it represents the number of descriptions stored in \c instanceDescs. + //!< Otherwise, it contains the number of geometry descriptions stored in \c pGeometryDescs or \c ppGeometryDescs. + D3D12_ELEMENTS_LAYOUT descsLayout; //!< If \c type is \c D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BOTTOM_LEVEL, it specifies which of \c pGeometryDescs and \c ppGeometryDescs to use. + //!< Otherwise, this parameter is unused. + NvU32 geometryDescStrideInBytes; //!< Stride between consecutive geometry descriptors. Should typically be set to sizeof(NVAPI_D3D12_RAYTRACING_GEOMETRY_DESC_EX). + //!< Only used if \c type is \c D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL and \c descLayout is \c D3D12_ELEMENTS_LAYOUT_ARRAY. + //!< This field guarantees backwards compatibility, even if the geometry descriptor size increases in future NVAPI versions. + union + { + D3D12_GPU_VIRTUAL_ADDRESS instanceDescs; //!< If \c type is \c D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TOP_LEVEL, the referenced instance structures can used the extended set of flags #NVAPI_D3D12_RAYTRACING_INSTANCE_FLAGS_EX in place of the \c D3D12_RAYTRACING_INSTANCE_FLAGS mentioned in \c D3D12_RAYTRACING_INSTANCE_DESC. + //!< Otherwise, this parameter is unused (space repurposed in a union). + const NVAPI_D3D12_RAYTRACING_GEOMETRY_DESC_EX* pGeometryDescs; //!< If \c type is \c D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BOTTOM_LEVEL and \c descLayout is \c D3D12_ELEMENTS_LAYOUT_ARRAY, it contains the descriptions of all geometries to be built into a BLAS. + //!< Otherwise, this parameter is unused (space repurposed in a union). + const NVAPI_D3D12_RAYTRACING_GEOMETRY_DESC_EX*const* ppGeometryDescs; //!< If \c type is \c D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BOTTOM_LEVEL and \c descLayout is \c D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS, it contains the addresses of descriptions for all geometries to be built into a BLAS. + //!< Otherwise, this parameter is unused (space repurposed in a union). + }; +} NVAPI_D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS_EX; + +//! Parameters given to NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx(). +//! +//! \ingroup dx +typedef struct _NVAPI_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_EX_PARAMS_V1 +{ + NvU32 version; //!< [in] Structure version; it should be set to #NVAPI_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_EX_PARAMS_VER. + const NVAPI_D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS_EX* pDesc; //!< [in] Description of the acceleration-structure build. + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO* pInfo; //!< [out] Result of the query. +} NVAPI_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_EX_PARAMS_V1; +#define NVAPI_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_EX_PARAMS_VER1 MAKE_NVAPI_VERSION(NVAPI_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_EX_PARAMS_V1, 1) +typedef NVAPI_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_EX_PARAMS_V1 NVAPI_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_EX_PARAMS; +#define NVAPI_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_EX_PARAMS_VER NVAPI_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_EX_PARAMS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx +// +//! DESCRIPTION: This function is an extension of ID3D12Device5::GetRaytracingAccelerationStructurePrebuildInfo() with additional input types. +//! +//! \note Only supported on GPUs capable of DXR. +//! Some of the flags and fields have further restrictions, in which case their description will include a note with more details. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 520 +//! +//! \param [in] pDevice Device on which the acceleration structure will be built. +//! \param [in,out] pParams Wrapper around the inputs and outputs of the function. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx( + __in ID3D12Device5* pDevice, + __inout NVAPI_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_EX_PARAMS* pParams); + +#endif // defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12Device5_INTERFACE_DEFINED__) + +#if defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__) + +//! Description of the inputs and memory areas used during the building of OMM Arrays. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_DESC +{ + D3D12_GPU_VIRTUAL_ADDRESS destOpacityMicromapArrayData; //!< Output location for the OMM Array build. + //!< NvAPI_D3D12_GetRaytracingOpacityMicromapArrayPrebuildInfo() reports the amount of memory required for the result given a set of input parameters. + //!< The address must be aligned to 256 bytes (#NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BYTE_ALIGNMENT). + NVAPI_D3D12_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_INPUTS inputs; //!< Description of the input data for the OMM Array build. + D3D12_GPU_VIRTUAL_ADDRESS scratchOpacityMicromapArrayData; //!< Location where the build will store temporary data. + //!< NvAPI_D3D12_GetRaytracingOpacityMicromapArrayPrebuildInfo() reports the amount of scratch memory the implementation will need for a given set of input parameters. + //!< The address must be aligned to 256 bytes (#NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BYTE_ALIGNMENT). + //!< Contents of this memory going into a build on the GPU timeline are irrelevant and will not be preserved. + //!< After the build is complete on the GPU timeline, the memory is left with whatever undefined contents the build finished with. + //!< The memory pointed to must be in state \c D3D12_RESOURCE_STATE_UNORDERED_ACCESS. +} NVAPI_D3D12_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_DESC; + +//! Structure emitted by NvAPI_D3D12_EmitRaytracingOpacityMicromapArrayPostbuildInfo(), and optionally NvAPI_D3D12_BuildRaytracingOpacityMicromapArray(), when \c type equals #NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_CURRENT_SIZE. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_CURRENT_SIZE_DESC +{ + NvU64 currentSizeInBytes; //!< Size of the OMM Array buffer. + //!< The queried size may be smaller than the size reported by NvAPI_D3D12_GetRaytracingOpacityMicromapArrayPrebuildInfo(). + //!< This allows the application to move and relocate the OMM Array to a smaller buffer to reclaim any unused memory after the OMM Array build is complete. +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_CURRENT_SIZE_DESC; + +//! Type of postbuild info to emit after an OMM Array build. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_TYPE +{ + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_CURRENT_SIZE = 0x0 //!< Size of the current OMM Array. May be smaller than reported by the NvAPI_D3D12_GetRaytracingOpacityMicromapArrayPrebuildInfo() call. + //!< Unused memory can be reclaimed by copying the OMM Array into a new resource; see #NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_CURRENT_SIZE_DESC. +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_TYPE; + +//! Description of the postbuild information to generate from an OMM Array. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_DESC +{ + D3D12_GPU_VIRTUAL_ADDRESS destBuffer; //!< Result storage. + //!< Size required and the layout of the contents written by the system depend on \p infoType. + //!< The memory pointed to must be in state \c D3D12_RESOURCE_STATE_UNORDERED_ACCESS. + //!< The memory must be aligned to the natural alignment for the members of the particular output structure being generated (e.g. 8 bytes for a struct with the largest member being \c NvU64). + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_TYPE infoType; //!< Type of postbuild information to retrieve. +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_DESC; + +//! Parameters given to NvAPI_D3D12_BuildRaytracingOpacityMicromapArray(). +//! +//! \ingroup dx +typedef struct _NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_V1 +{ + NvU32 version; //!< [in] Structure version; it should be set to #NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_VER. + const NVAPI_D3D12_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_DESC* pDesc; //!< [in] Description of the OMM Array build. + NvU32 numPostbuildInfoDescs; //!< [in] Size of postbuild info desc array. Set to 0 if none are needed. + const NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_DESC* pPostbuildInfoDescs; //!< [in] Optional array of descriptions for postbuild info to generate describing properties of the acceleration structure that was built. + //!< [in] Any given postbuild info type, \c D3D12_RAYTRACING_ACCEELRATION_STRUCTURE_POSTBUILD_INFO_TYPE, can only be selected for output by at most one array entry. +} NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_V1; +#define NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_VER1 MAKE_NVAPI_VERSION(NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_V1, 1) +typedef NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_V1 NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS; +#define NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_VER NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_BuildRaytracingOpacityMicromapArray +// +//! DESCRIPTION: Construct OMM Array for a collection of OMMs on the GPU. +//! The CPU-side input buffers are not referenced after this call. +//! The GPU-side input resources are not referenced after the build has concluded after ExecuteCommandList(). +//! Additionally, the application may optionally output postbuild information immediately after the build. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 520 +//! +//! \param [in] pCommandList Command list on which the command will execute. +//! \param [in] pParams Wrapper around the inputs and outputs of the function. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \retval NVAPI_INVALID_COMBINATION pParams->pPostbuildInfoDescs was set to \c NULL while pParams->numPostbuildInfoDescs is non zero. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_BuildRaytracingOpacityMicromapArray( + __in ID3D12GraphicsCommandList4* pCommandList, + __in NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS* pParams); + +#endif // defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__) + +#if defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__) + +//! Parameters given to NvAPI_D3D12_RelocateRaytracingOpacityMicromapArray(). +//! +//! \ingroup dx +typedef struct _NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_V1 +{ + NvU32 version; //!< [in] Structure version; it should be set to #NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_VER. + D3D12_GPU_VIRTUAL_ADDRESS opacityMicromapArray; //!< [in] OMM Array current memory address; it must be 256-byte aligned (#NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BYTE_ALIGNMENT). +} NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_V1; +#define NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_VER1 MAKE_NVAPI_VERSION(NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_V1, 1) +typedef NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_V1 NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS; +#define NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_VER NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_RelocateRaytracingOpacityMicromapArray +// +//! DESCRIPTION: Makes the OMM Array usable at its current location in memory. +//! An OMM Array that has been copied to a new location must be relocated using this function before it may be attached to any BLAS. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 520 +//! +//! \param [in] pCommandList Command list on which the command will execute. +//! \param [in] pParams Wrapper around the inputs and outputs of the function. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_RelocateRaytracingOpacityMicromapArray( + __in ID3D12GraphicsCommandList4* pCommandList, + __in const NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS* pParams); + +#endif // defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__) + +#if defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__) + +//! Parameters given to NvAPI_D3D12_EmitRaytracingOpacityMicromapArrayPostbuildInfo(). +//! +//! \ingroup dx +typedef struct _NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS_V1 +{ + NvU32 version; //!< [in] Structure version; it should be set to #NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS_VER. + const NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_DESC* pDesc; //!< [in] Description of which postbuild info to emit. + NvU32 numSources; //!< [in] Number of OMM Arrays in \p pSources. + const D3D12_GPU_VIRTUAL_ADDRESS* pSources; //!< [in] List of OMM Arrays for which postbuild info should be emitted. +} NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS_V1; +#define NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS_VER1 MAKE_NVAPI_VERSION(NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS_V1, 1) +typedef NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS_V1 NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS; +#define NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS_VER NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_EmitRaytracingOpacityMicromapArrayPostbuildInfo +// +//! DESCRIPTION: Emits information about one or more OMM Arrays, only available after the OMM Array constructions have finished. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 520 +//! +//! \param [in] pCommandList Command list on which the command will execute. +//! \param [in] pParams Wrapper around the inputs and outputs of the function. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_EmitRaytracingOpacityMicromapArrayPostbuildInfo( + __in ID3D12GraphicsCommandList4* pCommandList, + __in const NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS* pParams); + +#endif // defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__) + +#if defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__) + +//! This structure extends \c D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC by supporting additional geometry types as inputs. +//! For more information on the different members, please check Microsoft's DirectX Raytracing Specification. +//! +//! \ingroup dx +typedef struct _NVAPI_D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC_EX +{ + D3D12_GPU_VIRTUAL_ADDRESS destAccelerationStructureData; //!< Memory where the resulting acceleration structure will be stored. + NVAPI_D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS_EX inputs; //!< The inputs to the build process. + D3D12_GPU_VIRTUAL_ADDRESS sourceAccelerationStructureData; //!< The acceleration structure to be updated. + //!< Otherwise if the acceleration structure should be rebuilt entirely, this value must be \c NULL. + D3D12_GPU_VIRTUAL_ADDRESS scratchAccelerationStructureData; //!< Memory that will be temporarily used during the building process. +} NVAPI_D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC_EX; + +//! Parameters given to NvAPI_D3D12_RelocateRaytracingOpacityMicromapArray(). +//! +//! \ingroup dx +typedef struct _NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS_V1 +{ + NvU32 version; //!< [in] Structure version; it should be set to #NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS_VER. + const NVAPI_D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC_EX* pDesc; //!< [in] Description of the acceleration structure to build. + NvU32 numPostbuildInfoDescs; //!< [in] Size of postbuild info desc array. Set to 0 if none are needed. + const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC* pPostbuildInfoDescs; //!< [in] Optional array of descriptions for postbuild info to generate describing properties of the acceleration structure that was built. + //!< Any given postbuild info type, \c D3D12_RAYTRACING_ACCEELRATION_STRUCTURE_POSTBUILD_INFO_TYPE, can only be selected for output by at most one array entry. +} NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS_V1; +#define NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS_VER1 MAKE_NVAPI_VERSION(NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS_V1, 1) +typedef NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS_V1 NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS; +#define NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS_VER NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D12_BuildRaytracingAccelerationStructureEx +// +//! DESCRIPTION: Perform an acceleration structure build on the GPU. +//! Also optionally output postbuild information immediately after the build. +//! This function is an extension of ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure() with additional serialized data types. +//! +//! \note Only supported on GPUs capable of DXR. +//! Some of the flags and fields have further restrictions, in which case their description will include a note with more details. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release: 520 +//! +//! \param [in] pCommandList Command list on which the command will execute. +//! \param [in] pParams Wrapper around the inputs and outputs of the function. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, they are listed below. +//! +//! \retval NVAPI_INVALID_COMBINATION pParams->pPostbuildInfoDescs was set to \c NULL while pParams->numPostbuildInfoDescs is non zero. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D12_BuildRaytracingAccelerationStructureEx( + __in ID3D12GraphicsCommandList4* pCommandList, + __in const NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS* pParams); + +#endif // defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__) + +#if defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__) + +/////////////////////////////////////////////////////////////////////////////// +// +// Miscellaneous +// +/////////////////////////////////////////////////////////////////////////////// + +//! Opacity Micromap micro-triangle states. +//! Not part of any input, but listed here for convenience. +//! +//! \ingroup dx +typedef enum _NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_STATE +{ + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_STATE_TRANSPARENT = 0, //!< Transparent OMM state: hit is ignored. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_STATE_OPAQUE = 1, //!< Opaque OMM state: hit is committed. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_STATE_UNKNOWN_TRANSPARENT = 2, //!< Unknown-transparent OMM state. + //!< * If operating in 2-state mode, ignore hit. + //!< * If operating in 4-state mode, invoke any-hit shader. + NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_STATE_UNKNOWN_OPAQUE = 3 //!< Unknown-opaque OMM state. + //!< * If operating in 2-state mode, commit hit. + //!< * If operating in 4-state mode, invoke any-hit shader. +} NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_STATE; + +//! Mandatory alignment for the address of an OMM Array. +//! +//! \ingroup dx +#define NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_ARRAY_BYTE_ALIGNMENT 256 + +//! Highest subdivision-level allowed with OC1. +//! +//! \ingroup dx +#define NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_OC1_MAX_SUBDIVISION_LEVEL 12 + +//! A list of flags that can be given to the \c TraceRay() function in HLSL. +//! Only new or modified values are fully described below; for more information on the other values, please check Microsoft's DirectX Raytracing Specification. +//! +//! \ingroup dx +typedef enum _NVAPI_RAY_FLAGS_EX +{ + // RAY_FLAGS flags + NVAPI_RAY_FLAG_NONE_EX = 0x0, //!< No flag specified. + NVAPI_RAY_FLAG_FORCE_OPAQUE_EX = NV_BIT( 0), //!< Consider all intersected geometries to be opaque, regardless of the flags specified at the geometry and instance level. + NVAPI_RAY_FLAG_FORCE_NON_OPAQUE_EX = NV_BIT( 1), //!< Consider all intersected geometries to be non-opaque, regardless of the flags specified at the geometry and instance level. + NVAPI_RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH_EX = NV_BIT( 2), //!< End the traversal as soon as a geometry is hit, and that hit is not ignored by the any hit shader. + NVAPI_RAY_FLAG_SKIP_CLOSEST_HIT_SHADER_EX = NV_BIT( 3), //!< Do not invoke the closest hit shader once the traversal ends. + NVAPI_RAY_FLAG_CULL_BACK_FACING_TRIANGLES_EX = NV_BIT( 4), //!< Never intersect triangle geometries that are back facing with regard to the ray. + NVAPI_RAY_FLAG_CULL_FRONT_FACING_TRIANGLES_EX = NV_BIT( 5), //!< Never intersect triangle geometries that are front facing with regard to the ray. + NVAPI_RAY_FLAG_CULL_OPAQUE_EX = NV_BIT( 6), //!< Never intersect geometries that were flagged as opaque. + NVAPI_RAY_FLAG_CULL_NON_OPAQUE_EX = NV_BIT( 7), //!< Never intersect geometries that were not flagged as opaque. + NVAPI_RAY_FLAG_SKIP_TRIANGLES_EX = NV_BIT( 8), //!< Never intersect triangle geometries. + NVAPI_RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES_EX = NV_BIT( 9), //!< Never intersect AABB geometries. + + // NVAPI_RAY_FLAGS_EX specific flags + NVAPI_RAY_FLAG_FORCE_OMM_2_STATE_EX = NV_BIT(10) //!< Treat unknown-opaque and unknown-transparent as opaque and transparent, respectively, during traversal. + //!< If an instance is flagged with #NVAPI_D3D12_RAYTRACING_INSTANCE_FLAG_DISABLE_OMMS_EX, that takes precedence over this flag. +} NVAPI_RAY_FLAG_EX; + +#endif // defined(__cplusplus) && defined(__d3d12_h__) && defined(__ID3D12GraphicsCommandList4_INTERFACE_DEFINED__) + +///////////////////////////////////////////////////////////////////////// +// Video Input Output (VIO) API +///////////////////////////////////////////////////////////////////////// + + + +//! \ingroup vidio +//! Unique identifier for VIO owner (process identifier or NVVIOOWNERID_NONE) +typedef NvU32 NVVIOOWNERID; + + +//! \addtogroup vidio +//! @{ + + +#define NVVIOOWNERID_NONE 0 //!< Unregistered ownerId + + +//! Owner type for device +typedef enum _NVVIOOWNERTYPE +{ + NVVIOOWNERTYPE_NONE , //!< No owner for the device + NVVIOOWNERTYPE_APPLICATION , //!< Application owns the device + NVVIOOWNERTYPE_DESKTOP , //!< Desktop transparent mode owns the device (not applicable for video input) +}NVVIOOWNERTYPE; + +// Access rights for NvAPI_VIO_Open() + +//! Read access (not applicable for video output) +#define NVVIO_O_READ 0x00000000 + +//! Write exclusive access (not applicable for video input) +#define NVVIO_O_WRITE_EXCLUSIVE 0x00010001 + +//! +#define NVVIO_VALID_ACCESSRIGHTS (NVVIO_O_READ | \ + NVVIO_O_WRITE_EXCLUSIVE ) + + +//! VIO_DATA.ulOwnerID high-bit is set only if device has been initialized by VIOAPI +//! examined at NvAPI_GetCapabilities|NvAPI_VIO_Open to determine if settings need to be applied from registry or POR state read +#define NVVIO_OWNERID_INITIALIZED 0x80000000 + +//! VIO_DATA.ulOwnerID next-bit is set only if device is currently in exclusive write access mode from NvAPI_VIO_Open() +#define NVVIO_OWNERID_EXCLUSIVE 0x40000000 + +//! VIO_DATA.ulOwnerID lower bits are: +//! NVGVOOWNERTYPE_xxx enumerations indicating use context +#define NVVIO_OWNERID_TYPEMASK 0x0FFFFFFF //!< mask for NVVIOOWNERTYPE_xxx + + +//! @} + +//--------------------------------------------------------------------- +// Enumerations +//--------------------------------------------------------------------- + + +//! \addtogroup vidio +//! @{ + +//! Video signal format and resolution +typedef enum _NVVIOSIGNALFORMAT +{ + NVVIOSIGNALFORMAT_NONE, //!< Invalid signal format + NVVIOSIGNALFORMAT_487I_59_94_SMPTE259_NTSC, //!< 01 487i 59.94Hz (SMPTE259) NTSC + NVVIOSIGNALFORMAT_576I_50_00_SMPTE259_PAL, //!< 02 576i 50.00Hz (SMPTE259) PAL + NVVIOSIGNALFORMAT_1035I_60_00_SMPTE260, //!< 03 1035i 60.00Hz (SMPTE260) + NVVIOSIGNALFORMAT_1035I_59_94_SMPTE260, //!< 04 1035i 59.94Hz (SMPTE260) + NVVIOSIGNALFORMAT_1080I_50_00_SMPTE295, //!< 05 1080i 50.00Hz (SMPTE295) + NVVIOSIGNALFORMAT_1080I_60_00_SMPTE274, //!< 06 1080i 60.00Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080I_59_94_SMPTE274, //!< 07 1080i 59.94Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080I_50_00_SMPTE274, //!< 08 1080i 50.00Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080P_30_00_SMPTE274, //!< 09 1080p 30.00Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080P_29_97_SMPTE274, //!< 10 1080p 29.97Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080P_25_00_SMPTE274, //!< 11 1080p 25.00Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080P_24_00_SMPTE274, //!< 12 1080p 24.00Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080P_23_976_SMPTE274, //!< 13 1080p 23.976Hz (SMPTE274) + NVVIOSIGNALFORMAT_720P_60_00_SMPTE296, //!< 14 720p 60.00Hz (SMPTE296) + NVVIOSIGNALFORMAT_720P_59_94_SMPTE296, //!< 15 720p 59.94Hz (SMPTE296) + NVVIOSIGNALFORMAT_720P_50_00_SMPTE296, //!< 16 720p 50.00Hz (SMPTE296) + NVVIOSIGNALFORMAT_1080I_48_00_SMPTE274, //!< 17 1080I 48.00Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080I_47_96_SMPTE274, //!< 18 1080I 47.96Hz (SMPTE274) + NVVIOSIGNALFORMAT_720P_30_00_SMPTE296, //!< 19 720p 30.00Hz (SMPTE296) + NVVIOSIGNALFORMAT_720P_29_97_SMPTE296, //!< 20 720p 29.97Hz (SMPTE296) + NVVIOSIGNALFORMAT_720P_25_00_SMPTE296, //!< 21 720p 25.00Hz (SMPTE296) + NVVIOSIGNALFORMAT_720P_24_00_SMPTE296, //!< 22 720p 24.00Hz (SMPTE296) + NVVIOSIGNALFORMAT_720P_23_98_SMPTE296, //!< 23 720p 23.98Hz (SMPTE296) + NVVIOSIGNALFORMAT_2048P_30_00_SMPTE372, //!< 24 2048p 30.00Hz (SMPTE372) + NVVIOSIGNALFORMAT_2048P_29_97_SMPTE372, //!< 25 2048p 29.97Hz (SMPTE372) + NVVIOSIGNALFORMAT_2048I_60_00_SMPTE372, //!< 26 2048i 60.00Hz (SMPTE372) + NVVIOSIGNALFORMAT_2048I_59_94_SMPTE372, //!< 27 2048i 59.94Hz (SMPTE372) + NVVIOSIGNALFORMAT_2048P_25_00_SMPTE372, //!< 28 2048p 25.00Hz (SMPTE372) + NVVIOSIGNALFORMAT_2048I_50_00_SMPTE372, //!< 29 2048i 50.00Hz (SMPTE372) + NVVIOSIGNALFORMAT_2048P_24_00_SMPTE372, //!< 30 2048p 24.00Hz (SMPTE372) + NVVIOSIGNALFORMAT_2048P_23_98_SMPTE372, //!< 31 2048p 23.98Hz (SMPTE372) + NVVIOSIGNALFORMAT_2048I_48_00_SMPTE372, //!< 32 2048i 48.00Hz (SMPTE372) + NVVIOSIGNALFORMAT_2048I_47_96_SMPTE372, //!< 33 2048i 47.96Hz (SMPTE372) + + NVVIOSIGNALFORMAT_1080PSF_25_00_SMPTE274, //!< 34 1080PsF 25.00Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080PSF_29_97_SMPTE274, //!< 35 1080PsF 29.97Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080PSF_30_00_SMPTE274, //!< 36 1080PsF 30.00Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080PSF_24_00_SMPTE274, //!< 37 1080PsF 24.00Hz (SMPTE274) + NVVIOSIGNALFORMAT_1080PSF_23_98_SMPTE274, //!< 38 1080PsF 23.98Hz (SMPTE274) + + NVVIOSIGNALFORMAT_1080P_50_00_SMPTE274_3G_LEVEL_A, //!< 39 1080P 50.00Hz (SMPTE274) 3G Level A + NVVIOSIGNALFORMAT_1080P_59_94_SMPTE274_3G_LEVEL_A, //!< 40 1080P 59.94Hz (SMPTE274) 3G Level A + NVVIOSIGNALFORMAT_1080P_60_00_SMPTE274_3G_LEVEL_A, //!< 41 1080P 60.00Hz (SMPTE274) 3G Level A + + NVVIOSIGNALFORMAT_1080P_60_00_SMPTE274_3G_LEVEL_B, //!< 42 1080p 60.00Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_1080I_60_00_SMPTE274_3G_LEVEL_B, //!< 43 1080i 60.00Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_2048I_60_00_SMPTE372_3G_LEVEL_B, //!< 44 2048i 60.00Hz (SMPTE372) 3G Level B + NVVIOSIGNALFORMAT_1080P_50_00_SMPTE274_3G_LEVEL_B, //!< 45 1080p 50.00Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_1080I_50_00_SMPTE274_3G_LEVEL_B, //!< 46 1080i 50.00Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_2048I_50_00_SMPTE372_3G_LEVEL_B, //!< 47 2048i 50.00Hz (SMPTE372) 3G Level B + NVVIOSIGNALFORMAT_1080P_30_00_SMPTE274_3G_LEVEL_B, //!< 48 1080p 30.00Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_2048P_30_00_SMPTE372_3G_LEVEL_B, //!< 49 2048p 30.00Hz (SMPTE372) 3G Level B + NVVIOSIGNALFORMAT_1080P_25_00_SMPTE274_3G_LEVEL_B, //!< 50 1080p 25.00Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_2048P_25_00_SMPTE372_3G_LEVEL_B, //!< 51 2048p 25.00Hz (SMPTE372) 3G Level B + NVVIOSIGNALFORMAT_1080P_24_00_SMPTE274_3G_LEVEL_B, //!< 52 1080p 24.00Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_2048P_24_00_SMPTE372_3G_LEVEL_B, //!< 53 2048p 24.00Hz (SMPTE372) 3G Level B + NVVIOSIGNALFORMAT_1080I_48_00_SMPTE274_3G_LEVEL_B, //!< 54 1080i 48.00Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_2048I_48_00_SMPTE372_3G_LEVEL_B, //!< 55 2048i 48.00Hz (SMPTE372) 3G Level B + NVVIOSIGNALFORMAT_1080P_59_94_SMPTE274_3G_LEVEL_B, //!< 56 1080p 59.94Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_1080I_59_94_SMPTE274_3G_LEVEL_B, //!< 57 1080i 59.94Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_2048I_59_94_SMPTE372_3G_LEVEL_B, //!< 58 2048i 59.94Hz (SMPTE372) 3G Level B + NVVIOSIGNALFORMAT_1080P_29_97_SMPTE274_3G_LEVEL_B, //!< 59 1080p 29.97Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_2048P_29_97_SMPTE372_3G_LEVEL_B, //!< 60 2048p 29.97Hz (SMPTE372) 3G Level B + NVVIOSIGNALFORMAT_1080P_23_98_SMPTE274_3G_LEVEL_B, //!< 61 1080p 29.98Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_2048P_23_98_SMPTE372_3G_LEVEL_B, //!< 62 2048p 29.98Hz (SMPTE372) 3G Level B + NVVIOSIGNALFORMAT_1080I_47_96_SMPTE274_3G_LEVEL_B, //!< 63 1080i 47.96Hz (SMPTE274) 3G Level B + NVVIOSIGNALFORMAT_2048I_47_96_SMPTE372_3G_LEVEL_B, //!< 64 2048i 47.96Hz (SMPTE372) 3G Level B + + NVVIOSIGNALFORMAT_END //!< 65 To indicate end of signal format list + +}NVVIOSIGNALFORMAT; + +//! SMPTE standards format +typedef enum _NVVIOVIDEOSTANDARD +{ + NVVIOVIDEOSTANDARD_SMPTE259 , //!< SMPTE259 + NVVIOVIDEOSTANDARD_SMPTE260 , //!< SMPTE260 + NVVIOVIDEOSTANDARD_SMPTE274 , //!< SMPTE274 + NVVIOVIDEOSTANDARD_SMPTE295 , //!< SMPTE295 + NVVIOVIDEOSTANDARD_SMPTE296 , //!< SMPTE296 + NVVIOVIDEOSTANDARD_SMPTE372 , //!< SMPTE372 +}NVVIOVIDEOSTANDARD; + +//! HD or SD video type +typedef enum _NVVIOVIDEOTYPE +{ + NVVIOVIDEOTYPE_SD , //!< Standard-definition (SD) + NVVIOVIDEOTYPE_HD , //!< High-definition (HD) +}NVVIOVIDEOTYPE; + +//! Interlace mode +typedef enum _NVVIOINTERLACEMODE +{ + NVVIOINTERLACEMODE_PROGRESSIVE , //!< Progressive (p) + NVVIOINTERLACEMODE_INTERLACE , //!< Interlace (i) + NVVIOINTERLACEMODE_PSF , //!< Progressive Segment Frame (psf) +}NVVIOINTERLACEMODE; + +//! Video data format +typedef enum _NVVIODATAFORMAT +{ + NVVIODATAFORMAT_UNKNOWN = -1 , //!< Invalid DataFormat + NVVIODATAFORMAT_R8G8B8_TO_YCRCB444 , //!< R8:G8:B8 => YCrCb (4:4:4) + NVVIODATAFORMAT_R8G8B8A8_TO_YCRCBA4444 , //!< R8:G8:B8:A8 => YCrCbA (4:4:4:4) + NVVIODATAFORMAT_R8G8B8Z10_TO_YCRCBZ4444 , //!< R8:G8:B8:Z10 => YCrCbZ (4:4:4:4) + NVVIODATAFORMAT_R8G8B8_TO_YCRCB422 , //!< R8:G8:B8 => YCrCb (4:2:2) + NVVIODATAFORMAT_R8G8B8A8_TO_YCRCBA4224 , //!< R8:G8:B8:A8 => YCrCbA (4:2:2:4) + NVVIODATAFORMAT_R8G8B8Z10_TO_YCRCBZ4224 , //!< R8:G8:B8:Z10 => YCrCbZ (4:2:2:4) + NVVIODATAFORMAT_X8X8X8_444_PASSTHRU , //!< R8:G8:B8 => RGB (4:4:4) + NVVIODATAFORMAT_X8X8X8A8_4444_PASSTHRU , //!< R8:G8:B8:A8 => RGBA (4:4:4:4) + NVVIODATAFORMAT_X8X8X8Z10_4444_PASSTHRU , //!< R8:G8:B8:Z10 => RGBZ (4:4:4:4) + NVVIODATAFORMAT_X10X10X10_444_PASSTHRU , //!< Y10:CR10:CB10 => YCrCb (4:4:4) + NVVIODATAFORMAT_X10X8X8_444_PASSTHRU , //!< Y10:CR8:CB8 => YCrCb (4:4:4) + NVVIODATAFORMAT_X10X8X8A10_4444_PASSTHRU , //!< Y10:CR8:CB8:A10 => YCrCbA (4:4:4:4) + NVVIODATAFORMAT_X10X8X8Z10_4444_PASSTHRU , //!< Y10:CR8:CB8:Z10 => YCrCbZ (4:4:4:4) + NVVIODATAFORMAT_DUAL_R8G8B8_TO_DUAL_YCRCB422 , //!< R8:G8:B8 + R8:G8:B8 => YCrCb (4:2:2 + 4:2:2) + NVVIODATAFORMAT_DUAL_X8X8X8_TO_DUAL_422_PASSTHRU , //!< Y8:CR8:CB8 + Y8:CR8:CB8 => YCrCb (4:2:2 + 4:2:2) + NVVIODATAFORMAT_R10G10B10_TO_YCRCB422 , //!< R10:G10:B10 => YCrCb (4:2:2) + NVVIODATAFORMAT_R10G10B10_TO_YCRCB444 , //!< R10:G10:B10 => YCrCb (4:4:4) + NVVIODATAFORMAT_X12X12X12_444_PASSTHRU , //!< X12:X12:X12 => XXX (4:4:4) + NVVIODATAFORMAT_X12X12X12_422_PASSTHRU , //!< X12:X12:X12 => XXX (4:2:2) + NVVIODATAFORMAT_Y10CR10CB10_TO_YCRCB422 , //!< Y10:CR10:CB10 => YCrCb (4:2:2) + NVVIODATAFORMAT_Y8CR8CB8_TO_YCRCB422 , //!< Y8:CR8:CB8 => YCrCb (4:2:2) + NVVIODATAFORMAT_Y10CR8CB8A10_TO_YCRCBA4224 , //!< Y10:CR8:CB8:A10 => YCrCbA (4:2:2:4) + NVVIODATAFORMAT_R10G10B10_TO_RGB444 , //!< R10:G10:B10 => RGB (4:4:4) + NVVIODATAFORMAT_R12G12B12_TO_YCRCB444 , //!< R12:G12:B12 => YCrCb (4:4:4) + NVVIODATAFORMAT_R12G12B12_TO_YCRCB422 , //!< R12:G12:B12 => YCrCb (4:2:2) +}NVVIODATAFORMAT; + +//! Video output area +typedef enum _NVVIOOUTPUTAREA +{ + NVVIOOUTPUTAREA_FULLSIZE , //!< Output to entire video resolution (full size) + NVVIOOUTPUTAREA_SAFEACTION , //!< Output to centered 90% of video resolution (safe action) + NVVIOOUTPUTAREA_SAFETITLE , //!< Output to centered 80% of video resolution (safe title) +}NVVIOOUTPUTAREA; + +//! Synchronization source +typedef enum _NVVIOSYNCSOURCE +{ + NVVIOSYNCSOURCE_SDISYNC , //!< SDI Sync (Digital input) + NVVIOSYNCSOURCE_COMPSYNC , //!< COMP Sync (Composite input) +}NVVIOSYNCSOURCE; + +//! Composite synchronization type +typedef enum _NVVIOCOMPSYNCTYPE +{ + NVVIOCOMPSYNCTYPE_AUTO , //!< Auto-detect + NVVIOCOMPSYNCTYPE_BILEVEL , //!< Bi-level signal + NVVIOCOMPSYNCTYPE_TRILEVEL , //!< Tri-level signal +}NVVIOCOMPSYNCTYPE; + +//! Video input output status +typedef enum _NVVIOINPUTOUTPUTSTATUS +{ + NVINPUTOUTPUTSTATUS_OFF , //!< Not in use + NVINPUTOUTPUTSTATUS_ERROR , //!< Error detected + NVINPUTOUTPUTSTATUS_SDI_SD , //!< SDI (standard-definition) + NVINPUTOUTPUTSTATUS_SDI_HD , //!< SDI (high-definition) +}NVVIOINPUTOUTPUTSTATUS; + +//! Synchronization input status +typedef enum _NVVIOSYNCSTATUS +{ + NVVIOSYNCSTATUS_OFF , //!< Sync not detected + NVVIOSYNCSTATUS_ERROR , //!< Error detected + NVVIOSYNCSTATUS_SYNCLOSS , //!< Genlock in use, format mismatch with output + NVVIOSYNCSTATUS_COMPOSITE , //!< Composite sync + NVVIOSYNCSTATUS_SDI_SD , //!< SDI sync (standard-definition) + NVVIOSYNCSTATUS_SDI_HD , //!< SDI sync (high-definition) +}NVVIOSYNCSTATUS; + +//! Video Capture Status +typedef enum _NVVIOCAPTURESTATUS +{ + NVVIOSTATUS_STOPPED , //!< Sync not detected + NVVIOSTATUS_RUNNING , //!< Error detected + NVVIOSTATUS_ERROR , //!< Genlock in use, format mismatch with output +}NVVIOCAPTURESTATUS; + +//! Video Capture Status +typedef enum _NVVIOSTATUSTYPE +{ + NVVIOSTATUSTYPE_IN , //!< Input Status + NVVIOSTATUSTYPE_OUT , //!< Output Status +}NVVIOSTATUSTYPE; + + +//! Assumption, maximum 4 SDI input and 4 SDI output cards supported on a system +#define NVAPI_MAX_VIO_DEVICES 8 + +//! 4 physical jacks supported on each SDI input card. +#define NVAPI_MAX_VIO_JACKS 4 + + +//! Each physical jack an on SDI input card can have +//! two "channels" in the case of "3G" VideoFormats, as specified +//! by SMPTE 425; for non-3G VideoFormats, only the first channel within +//! a physical jack is valid. +#define NVAPI_MAX_VIO_CHANNELS_PER_JACK 2 + +//! 4 Streams, 1 per physical jack +#define NVAPI_MAX_VIO_STREAMS 4 + +#define NVAPI_MIN_VIO_STREAMS 1 + +//! SDI input supports a max of 2 links per stream +#define NVAPI_MAX_VIO_LINKS_PER_STREAM 2 + + +#define NVAPI_MAX_FRAMELOCK_MAPPING_MODES 20 + +//! Min number of capture images +#define NVAPI_GVI_MIN_RAW_CAPTURE_IMAGES 1 + +//! Max number of capture images +#define NVAPI_GVI_MAX_RAW_CAPTURE_IMAGES 32 + +//! Default number of capture images +#define NVAPI_GVI_DEFAULT_RAW_CAPTURE_IMAGES 5 + + + +// Data Signal notification events. These need a event handler in RM. +// Register/Unregister and PopEvent NVAPI's are already available. + +//! Device configuration +typedef enum _NVVIOCONFIGTYPE +{ + NVVIOCONFIGTYPE_IN , //!< Input Status + NVVIOCONFIGTYPE_OUT , //!< Output Status +}NVVIOCONFIGTYPE; + +typedef enum _NVVIOCOLORSPACE +{ + NVVIOCOLORSPACE_UNKNOWN, + NVVIOCOLORSPACE_YCBCR, + NVVIOCOLORSPACE_YCBCRA, + NVVIOCOLORSPACE_YCBCRD, + NVVIOCOLORSPACE_GBR, + NVVIOCOLORSPACE_GBRA, + NVVIOCOLORSPACE_GBRD, +} NVVIOCOLORSPACE; + +//! Component sampling +typedef enum _NVVIOCOMPONENTSAMPLING +{ + NVVIOCOMPONENTSAMPLING_UNKNOWN, + NVVIOCOMPONENTSAMPLING_4444, + NVVIOCOMPONENTSAMPLING_4224, + NVVIOCOMPONENTSAMPLING_444, + NVVIOCOMPONENTSAMPLING_422 +} NVVIOCOMPONENTSAMPLING; + +typedef enum _NVVIOBITSPERCOMPONENT +{ + NVVIOBITSPERCOMPONENT_UNKNOWN, + NVVIOBITSPERCOMPONENT_8, + NVVIOBITSPERCOMPONENT_10, + NVVIOBITSPERCOMPONENT_12, +} NVVIOBITSPERCOMPONENT; + +typedef enum _NVVIOLINKID +{ + NVVIOLINKID_UNKNOWN, + NVVIOLINKID_A, + NVVIOLINKID_B, + NVVIOLINKID_C, + NVVIOLINKID_D +} NVVIOLINKID; + + +typedef enum _NVVIOANCPARITYCOMPUTATION +{ + NVVIOANCPARITYCOMPUTATION_AUTO, + NVVIOANCPARITYCOMPUTATION_ON, + NVVIOANCPARITYCOMPUTATION_OFF +} NVVIOANCPARITYCOMPUTATION; + + + +//! @} + + +//--------------------------------------------------------------------- +// Structures +//--------------------------------------------------------------------- + +//! \addtogroup vidio +//! @{ + + +//! Supports Serial Digital Interface (SDI) output +#define NVVIOCAPS_VIDOUT_SDI 0x00000001 + +//! Supports Internal timing source +#define NVVIOCAPS_SYNC_INTERNAL 0x00000100 + +//! Supports Genlock timing source +#define NVVIOCAPS_SYNC_GENLOCK 0x00000200 + +//! Supports Serial Digital Interface (SDI) synchronization input +#define NVVIOCAPS_SYNCSRC_SDI 0x00001000 + +//! Supports Composite synchronization input +#define NVVIOCAPS_SYNCSRC_COMP 0x00002000 + +//! Supports Desktop transparent mode +#define NVVIOCAPS_OUTPUTMODE_DESKTOP 0x00010000 + +//! Supports OpenGL application mode +#define NVVIOCAPS_OUTPUTMODE_OPENGL 0x00020000 + +//! Supports Serial Digital Interface (SDI) input +#define NVVIOCAPS_VIDIN_SDI 0x00100000 + +//! Supports Packed ANC +#define NVVIOCAPS_PACKED_ANC_SUPPORTED 0x00200000 + +//! Supports ANC audio blanking +#define NVVIOCAPS_AUDIO_BLANKING_SUPPORTED 0x00400000 + +//! SDI-class interface: SDI output with two genlock inputs +#define NVVIOCLASS_SDI 0x00000001 + +//! Device capabilities +typedef struct _NVVIOCAPS +{ + NvU32 version; //!< Structure version + NvAPI_String adapterName; //!< Graphics adapter name + NvU32 adapterClass; //!< Graphics adapter classes (NVVIOCLASS_SDI mask) + NvU32 adapterCaps; //!< Graphics adapter capabilities (NVVIOCAPS_* mask) + NvU32 dipSwitch; //!< On-board DIP switch settings bits + NvU32 dipSwitchReserved; //!< On-board DIP switch settings reserved bits + NvU32 boardID; //!< Board ID + //! Driver version + struct // + { + NvU32 majorVersion; //!< Major version. For GVI, majorVersion contains MajorVersion(HIWORD) And MinorVersion(LOWORD) + NvU32 minorVersion; //!< Minor version. For GVI, minorVersion contains Revison(HIWORD) And Build(LOWORD) + } driver; // + //! Firmware version + struct + { + NvU32 majorVersion; //!< Major version. In version 2, for both GVI and GVO, majorVersion contains MajorVersion(HIWORD) And MinorVersion(LOWORD) + NvU32 minorVersion; //!< Minor version. In version 2, for both GVI and GVO, minorVersion contains Revison(HIWORD) And Build(LOWORD) + } firmWare; // + NVVIOOWNERID ownerId; //!< Unique identifier for owner of video output (NVVIOOWNERID_INVALID if free running) + NVVIOOWNERTYPE ownerType; //!< Owner type (OpenGL application or Desktop mode) +} NVVIOCAPS; + +//! Macro for constructing the version field of NVVIOCAPS +#define NVVIOCAPS_VER1 MAKE_NVAPI_VERSION(NVVIOCAPS,1) +#define NVVIOCAPS_VER2 MAKE_NVAPI_VERSION(NVVIOCAPS,2) +#define NVVIOCAPS_VER NVVIOCAPS_VER2 + +//! Input channel status +typedef struct _NVVIOCHANNELSTATUS +{ + NvU32 smpte352; //!< 4-byte SMPTE 352 video payload identifier + NVVIOSIGNALFORMAT signalFormat; //!< Signal format + NVVIOBITSPERCOMPONENT bitsPerComponent; //!< Bits per component + NVVIOCOMPONENTSAMPLING samplingFormat; //!< Sampling format + NVVIOCOLORSPACE colorSpace; //!< Color space + NVVIOLINKID linkID; //!< Link ID +} NVVIOCHANNELSTATUS; + +//! Input device status +typedef struct _NVVIOINPUTSTATUS +{ + NVVIOCHANNELSTATUS vidIn[NVAPI_MAX_VIO_JACKS][NVAPI_MAX_VIO_CHANNELS_PER_JACK]; //!< Video input status per channel within a jack + NVVIOCAPTURESTATUS captureStatus; //!< status of video capture +} NVVIOINPUTSTATUS; + +//! Output device status +typedef struct _NVVIOOUTPUTSTATUS +{ + NVVIOINPUTOUTPUTSTATUS vid1Out; //!< Video 1 output status + NVVIOINPUTOUTPUTSTATUS vid2Out; //!< Video 2 output status + NVVIOSYNCSTATUS sdiSyncIn; //!< SDI sync input status + NVVIOSYNCSTATUS compSyncIn; //!< Composite sync input status + NvU32 syncEnable; //!< Sync enable (TRUE if using syncSource) + NVVIOSYNCSOURCE syncSource; //!< Sync source + NVVIOSIGNALFORMAT syncFormat; //!< Sync format + NvU32 frameLockEnable; //!< Framelock enable flag + NvU32 outputVideoLocked; //!< Output locked status + NvU32 dataIntegrityCheckErrorCount; //!< Data integrity check error count + NvU32 dataIntegrityCheckEnabled; //!< Data integrity check status enabled + NvU32 dataIntegrityCheckFailed; //!< Data integrity check status failed + NvU32 uSyncSourceLocked; //!< genlocked to framelocked to ref signal + NvU32 uPowerOn; //!< TRUE: indicates there is sufficient power +} NVVIOOUTPUTSTATUS; + +//! Video device status. +typedef struct _NVVIOSTATUS +{ + NvU32 version; //!< Structure version + NVVIOSTATUSTYPE nvvioStatusType; //!< Input or Output status + union + { + NVVIOINPUTSTATUS inStatus; //!< Input device status + NVVIOOUTPUTSTATUS outStatus; //!< Output device status + }vioStatus; +} NVVIOSTATUS; + +//! Macro for constructingthe version field of NVVIOSTATUS +#define NVVIOSTATUS_VER MAKE_NVAPI_VERSION(NVVIOSTATUS,1) + +//! Output region +typedef struct _NVVIOOUTPUTREGION +{ + NvU32 x; //!< Horizontal origin in pixels + NvU32 y; //!< Vertical origin in pixels + NvU32 width; //!< Width of region in pixels + NvU32 height; //!< Height of region in pixels +} NVVIOOUTPUTREGION; + +//! Gamma ramp (8-bit index) +typedef struct _NVVIOGAMMARAMP8 +{ + NvU16 uRed[256]; //!< Red channel gamma ramp (8-bit index, 16-bit values) + NvU16 uGreen[256]; //!< Green channel gamma ramp (8-bit index, 16-bit values) + NvU16 uBlue[256]; //!< Blue channel gamma ramp (8-bit index, 16-bit values) +} NVVIOGAMMARAMP8; + +//! Gamma ramp (10-bit index) +typedef struct _NVVIOGAMMARAMP10 +{ + NvU16 uRed[1024]; //!< Red channel gamma ramp (10-bit index, 16-bit values) + NvU16 uGreen[1024]; //!< Green channel gamma ramp (10-bit index, 16-bit values) + NvU16 uBlue[1024]; //!< Blue channel gamma ramp (10-bit index, 16-bit values) +} NVVIOGAMMARAMP10; + + +//! Sync delay +typedef struct _NVVIOSYNCDELAY +{ + NvU32 version; //!< Structure version + NvU32 horizontalDelay; //!< Horizontal delay in pixels + NvU32 verticalDelay; //!< Vertical delay in lines +} NVVIOSYNCDELAY; + +//! Macro for constructing the version field of NVVIOSYNCDELAY +#define NVVIOSYNCDELAY_VER MAKE_NVAPI_VERSION(NVVIOSYNCDELAY,1) + + +//! Video mode information +typedef struct _NVVIOVIDEOMODE +{ + NvU32 horizontalPixels; //!< Horizontal resolution (in pixels) + NvU32 verticalLines; //!< Vertical resolution for frame (in lines) + float fFrameRate; //!< Frame rate + NVVIOINTERLACEMODE interlaceMode; //!< Interlace mode + NVVIOVIDEOSTANDARD videoStandard; //!< SMPTE standards format + NVVIOVIDEOTYPE videoType; //!< HD or SD signal classification +} NVVIOVIDEOMODE; + +//! Signal format details +typedef struct _NVVIOSIGNALFORMATDETAIL +{ + NVVIOSIGNALFORMAT signalFormat; //!< Signal format enumerated value + NVVIOVIDEOMODE videoMode; //!< Video mode for signal format +}NVVIOSIGNALFORMATDETAIL; + + +//! R8:G8:B8 +#define NVVIOBUFFERFORMAT_R8G8B8 0x00000001 + +//! R8:G8:B8:Z24 +#define NVVIOBUFFERFORMAT_R8G8B8Z24 0x00000002 + +//! R8:G8:B8:A8 +#define NVVIOBUFFERFORMAT_R8G8B8A8 0x00000004 + +//! R8:G8:B8:A8:Z24 +#define NVVIOBUFFERFORMAT_R8G8B8A8Z24 0x00000008 + +//! R16FP:G16FP:B16FP +#define NVVIOBUFFERFORMAT_R16FPG16FPB16FP 0x00000010 + +//! R16FP:G16FP:B16FP:Z24 +#define NVVIOBUFFERFORMAT_R16FPG16FPB16FPZ24 0x00000020 + +//! R16FP:G16FP:B16FP:A16FP +#define NVVIOBUFFERFORMAT_R16FPG16FPB16FPA16FP 0x00000040 + +//! R16FP:G16FP:B16FP:A16FP:Z24 +#define NVVIOBUFFERFORMAT_R16FPG16FPB16FPA16FPZ24 0x00000080 + + + +//! Data format details +typedef struct _NVVIODATAFORMATDETAIL +{ + NVVIODATAFORMAT dataFormat; //!< Data format enumerated value + NvU32 vioCaps; //!< Data format capabilities (NVVIOCAPS_* mask) +}NVVIODATAFORMATDETAIL; + +//! Colorspace conversion +typedef struct _NVVIOCOLORCONVERSION +{ + NvU32 version; //!< Structure version + float colorMatrix[3][3]; //!< Output[n] = + float colorOffset[3]; //!< Input[0] * colorMatrix[n][0] + + float colorScale[3]; //!< Input[1] * colorMatrix[n][1] + + //!< Input[2] * colorMatrix[n][2] + + //!< OutputRange * colorOffset[n] + //!< where OutputRange is the standard magnitude of + //!< Output[n][n] and colorMatrix and colorOffset + //!< values are within the range -1.0 to +1.0 + NvU32 compositeSafe; //!< compositeSafe constrains luminance range when using composite output +} NVVIOCOLORCONVERSION; + +//! macro for constructing the version field of _NVVIOCOLORCONVERSION. +#define NVVIOCOLORCONVERSION_VER MAKE_NVAPI_VERSION(NVVIOCOLORCONVERSION,1) + +//! Gamma correction +typedef struct _NVVIOGAMMACORRECTION +{ + NvU32 version; //!< Structure version + NvU32 vioGammaCorrectionType; //!< Gamma correction type (8-bit or 10-bit) + //! Gamma correction: + union + { + NVVIOGAMMARAMP8 gammaRamp8; //!< Gamma ramp (8-bit index, 16-bit values) + NVVIOGAMMARAMP10 gammaRamp10; //!< Gamma ramp (10-bit index, 16-bit values) + }gammaRamp; + float fGammaValueR; //!< Red Gamma value within gamma ranges. 0.5 - 6.0 + float fGammaValueG; //!< Green Gamma value within gamma ranges. 0.5 - 6.0 + float fGammaValueB; //!< Blue Gamma value within gamma ranges. 0.5 - 6.0 +} NVVIOGAMMACORRECTION; + +//! Macro for constructing thevesion field of _NVVIOGAMMACORRECTION +#define NVVIOGAMMACORRECTION_VER MAKE_NVAPI_VERSION(NVVIOGAMMACORRECTION,1) + +//! Maximum number of ranges per channel +#define MAX_NUM_COMPOSITE_RANGE 2 + + +typedef struct _NVVIOCOMPOSITERANGE +{ + NvU32 uRange; + NvU32 uEnabled; + NvU32 uMin; + NvU32 uMax; +} NVVIOCOMPOSITERANGE; + + + +// Device configuration (fields masks indicating NVVIOCONFIG fields to use for NvAPI_VIO_GetConfig/NvAPI_VIO_SetConfig() ) +// +#define NVVIOCONFIG_SIGNALFORMAT 0x00000001 //!< fields: signalFormat +#define NVVIOCONFIG_DATAFORMAT 0x00000002 //!< fields: dataFormat +#define NVVIOCONFIG_OUTPUTREGION 0x00000004 //!< fields: outputRegion +#define NVVIOCONFIG_OUTPUTAREA 0x00000008 //!< fields: outputArea +#define NVVIOCONFIG_COLORCONVERSION 0x00000010 //!< fields: colorConversion +#define NVVIOCONFIG_GAMMACORRECTION 0x00000020 //!< fields: gammaCorrection +#define NVVIOCONFIG_SYNCSOURCEENABLE 0x00000040 //!< fields: syncSource and syncEnable +#define NVVIOCONFIG_SYNCDELAY 0x00000080 //!< fields: syncDelay +#define NVVIOCONFIG_COMPOSITESYNCTYPE 0x00000100 //!< fields: compositeSyncType +#define NVVIOCONFIG_FRAMELOCKENABLE 0x00000200 //!< fields: EnableFramelock +#define NVVIOCONFIG_422FILTER 0x00000400 //!< fields: bEnable422Filter +#define NVVIOCONFIG_COMPOSITETERMINATE 0x00000800 //!< fields: bCompositeTerminate (Not supported on Quadro FX 4000 SDI) +#define NVVIOCONFIG_DATAINTEGRITYCHECK 0x00001000 //!< fields: bEnableDataIntegrityCheck (Not supported on Quadro FX 4000 SDI) +#define NVVIOCONFIG_CSCOVERRIDE 0x00002000 //!< fields: colorConversion override +#define NVVIOCONFIG_FLIPQUEUELENGTH 0x00004000 //!< fields: flipqueuelength control +#define NVVIOCONFIG_ANCTIMECODEGENERATION 0x00008000 //!< fields: bEnableANCTimeCodeGeneration +#define NVVIOCONFIG_COMPOSITE 0x00010000 //!< fields: bEnableComposite +#define NVVIOCONFIG_ALPHAKEYCOMPOSITE 0x00020000 //!< fields: bEnableAlphaKeyComposite +#define NVVIOCONFIG_COMPOSITE_Y 0x00040000 //!< fields: compRange +#define NVVIOCONFIG_COMPOSITE_CR 0x00080000 //!< fields: compRange +#define NVVIOCONFIG_COMPOSITE_CB 0x00100000 //!< fields: compRange +#define NVVIOCONFIG_FULL_COLOR_RANGE 0x00200000 //!< fields: bEnableFullColorRange +#define NVVIOCONFIG_RGB_DATA 0x00400000 //!< fields: bEnableRGBData +#define NVVIOCONFIG_RESERVED_SDIOUTPUTENABLE 0x00800000 //!< fields: bEnableSDIOutput +#define NVVIOCONFIG_STREAMS 0x01000000 //!< fields: streams +#define NVVIOCONFIG_ANC_PARITY_COMPUTATION 0x02000000 //!< fields: ancParityComputation +#define NVVIOCONFIG_ANC_AUDIO_REPEAT 0x04000000 //!< fields: enableAudioBlanking + + +// Don't forget to update NVVIOCONFIG_VALIDFIELDS in nvapi.spec when NVVIOCONFIG_ALLFIELDS changes. +#define NVVIOCONFIG_ALLFIELDS ( NVVIOCONFIG_SIGNALFORMAT | \ + NVVIOCONFIG_DATAFORMAT | \ + NVVIOCONFIG_OUTPUTREGION | \ + NVVIOCONFIG_OUTPUTAREA | \ + NVVIOCONFIG_COLORCONVERSION | \ + NVVIOCONFIG_GAMMACORRECTION | \ + NVVIOCONFIG_SYNCSOURCEENABLE | \ + NVVIOCONFIG_SYNCDELAY | \ + NVVIOCONFIG_COMPOSITESYNCTYPE | \ + NVVIOCONFIG_FRAMELOCKENABLE | \ + NVVIOCONFIG_422FILTER | \ + NVVIOCONFIG_COMPOSITETERMINATE | \ + NVVIOCONFIG_DATAINTEGRITYCHECK | \ + NVVIOCONFIG_CSCOVERRIDE | \ + NVVIOCONFIG_FLIPQUEUELENGTH | \ + NVVIOCONFIG_ANCTIMECODEGENERATION | \ + NVVIOCONFIG_COMPOSITE | \ + NVVIOCONFIG_ALPHAKEYCOMPOSITE | \ + NVVIOCONFIG_COMPOSITE_Y | \ + NVVIOCONFIG_COMPOSITE_CR | \ + NVVIOCONFIG_COMPOSITE_CB | \ + NVVIOCONFIG_FULL_COLOR_RANGE | \ + NVVIOCONFIG_RGB_DATA | \ + NVVIOCONFIG_RESERVED_SDIOUTPUTENABLE | \ + NVVIOCONFIG_STREAMS | \ + NVVIOCONFIG_ANC_PARITY_COMPUTATION | \ + NVVIOCONFIG_ANC_AUDIO_REPEAT ) + +#define NVVIOCONFIG_VALIDFIELDS ( NVVIOCONFIG_SIGNALFORMAT | \ + NVVIOCONFIG_DATAFORMAT | \ + NVVIOCONFIG_OUTPUTREGION | \ + NVVIOCONFIG_OUTPUTAREA | \ + NVVIOCONFIG_COLORCONVERSION | \ + NVVIOCONFIG_GAMMACORRECTION | \ + NVVIOCONFIG_SYNCSOURCEENABLE | \ + NVVIOCONFIG_SYNCDELAY | \ + NVVIOCONFIG_COMPOSITESYNCTYPE | \ + NVVIOCONFIG_FRAMELOCKENABLE | \ + NVVIOCONFIG_RESERVED_SDIOUTPUTENABLE | \ + NVVIOCONFIG_422FILTER | \ + NVVIOCONFIG_COMPOSITETERMINATE | \ + NVVIOCONFIG_DATAINTEGRITYCHECK | \ + NVVIOCONFIG_CSCOVERRIDE | \ + NVVIOCONFIG_FLIPQUEUELENGTH | \ + NVVIOCONFIG_ANCTIMECODEGENERATION | \ + NVVIOCONFIG_COMPOSITE | \ + NVVIOCONFIG_ALPHAKEYCOMPOSITE | \ + NVVIOCONFIG_COMPOSITE_Y | \ + NVVIOCONFIG_COMPOSITE_CR | \ + NVVIOCONFIG_COMPOSITE_CB | \ + NVVIOCONFIG_FULL_COLOR_RANGE | \ + NVVIOCONFIG_RGB_DATA | \ + NVVIOCONFIG_RESERVED_SDIOUTPUTENABLE | \ + NVVIOCONFIG_STREAMS | \ + NVVIOCONFIG_ANC_PARITY_COMPUTATION | \ + NVVIOCONFIG_ANC_AUDIO_REPEAT) + +#define NVVIOCONFIG_DRIVERFIELDS ( NVVIOCONFIG_OUTPUTREGION | \ + NVVIOCONFIG_OUTPUTAREA | \ + NVVIOCONFIG_COLORCONVERSION | \ + NVVIOCONFIG_FLIPQUEUELENGTH) + +#define NVVIOCONFIG_GAMMAFIELDS ( NVVIOCONFIG_GAMMACORRECTION ) + +#define NVVIOCONFIG_RMCTRLFIELDS ( NVVIOCONFIG_SIGNALFORMAT | \ + NVVIOCONFIG_DATAFORMAT | \ + NVVIOCONFIG_SYNCSOURCEENABLE | \ + NVVIOCONFIG_COMPOSITESYNCTYPE | \ + NVVIOCONFIG_FRAMELOCKENABLE | \ + NVVIOCONFIG_422FILTER | \ + NVVIOCONFIG_COMPOSITETERMINATE | \ + NVVIOCONFIG_DATAINTEGRITYCHECK | \ + NVVIOCONFIG_COMPOSITE | \ + NVVIOCONFIG_ALPHAKEYCOMPOSITE | \ + NVVIOCONFIG_COMPOSITE_Y | \ + NVVIOCONFIG_COMPOSITE_CR | \ + NVVIOCONFIG_COMPOSITE_CB) + +#define NVVIOCONFIG_RMSKEWFIELDS ( NVVIOCONFIG_SYNCDELAY ) + +#define NVVIOCONFIG_ALLOWSDIRUNNING_FIELDS ( NVVIOCONFIG_DATAINTEGRITYCHECK | \ + NVVIOCONFIG_SYNCDELAY | \ + NVVIOCONFIG_CSCOVERRIDE | \ + NVVIOCONFIG_ANCTIMECODEGENERATION | \ + NVVIOCONFIG_COMPOSITE | \ + NVVIOCONFIG_ALPHAKEYCOMPOSITE | \ + NVVIOCONFIG_COMPOSITE_Y | \ + NVVIOCONFIG_COMPOSITE_CR | \ + NVVIOCONFIG_COMPOSITE_CB | \ + NVVIOCONFIG_ANC_PARITY_COMPUTATION) + + + #define NVVIOCONFIG_RMMODESET_FIELDS ( NVVIOCONFIG_SIGNALFORMAT | \ + NVVIOCONFIG_DATAFORMAT | \ + NVVIOCONFIG_SYNCSOURCEENABLE | \ + NVVIOCONFIG_FRAMELOCKENABLE | \ + NVVIOCONFIG_COMPOSITESYNCTYPE | \ + NVVIOCONFIG_ANC_AUDIO_REPEAT) + + +//! Output device configuration +// No members can be deleted from below structure. Only add new members at the +// end of the structure. +typedef struct _NVVIOOUTPUTCONFIG_V1 +{ + NVVIOSIGNALFORMAT signalFormat; //!< Signal format for video output + NVVIODATAFORMAT dataFormat; //!< Data format for video output + NVVIOOUTPUTREGION outputRegion; //!< Region for video output (Desktop mode) + NVVIOOUTPUTAREA outputArea; //!< Usable resolution for video output (safe area) + NVVIOCOLORCONVERSION colorConversion; //!< Color conversion. + NVVIOGAMMACORRECTION gammaCorrection; + NvU32 syncEnable; //!< Sync enable (TRUE to use syncSource) + NVVIOSYNCSOURCE syncSource; //!< Sync source + NVVIOSYNCDELAY syncDelay; //!< Sync delay + NVVIOCOMPSYNCTYPE compositeSyncType; //!< Composite sync type + NvU32 frameLockEnable; //!< Flag indicating whether framelock was on/off + NvU32 psfSignalFormat; //!< Indicates whether contained format is PSF Signal format + NvU32 enable422Filter; //!< Enables/Disables 4:2:2 filter + NvU32 compositeTerminate; //!< Composite termination + NvU32 enableDataIntegrityCheck; //!< Enable data integrity check: true - enable, false - disable + NvU32 cscOverride; //!< Use provided CSC color matrix to overwrite + NvU32 flipQueueLength; //!< Number of buffers used for the internal flipqueue + NvU32 enableANCTimeCodeGeneration; //!< Enable SDI ANC time code generation + NvU32 enableComposite; //!< Enable composite + NvU32 enableAlphaKeyComposite; //!< Enable Alpha key composite + NVVIOCOMPOSITERANGE compRange; //!< Composite ranges + NvU8 reservedData[256]; //!< Inicates last stored SDI output state TRUE-ON / FALSE-OFF + NvU32 enableFullColorRange; //!< Flag indicating Full Color Range + NvU32 enableRGBData; //!< Indicates data is in RGB format +} NVVIOOUTPUTCONFIG_V1; + +typedef struct _NVVIOOUTPUTCONFIG_V2 +{ + NVVIOSIGNALFORMAT signalFormat; //!< Signal format for video output + NVVIODATAFORMAT dataFormat; //!< Data format for video output + NVVIOOUTPUTREGION outputRegion; //!< Region for video output (Desktop mode) + NVVIOOUTPUTAREA outputArea; //!< Usable resolution for video output (safe area) + NVVIOCOLORCONVERSION colorConversion; //!< Color conversion. + NVVIOGAMMACORRECTION gammaCorrection; + NvU32 syncEnable; //!< Sync enable (TRUE to use syncSource) + NVVIOSYNCSOURCE syncSource; //!< Sync source + NVVIOSYNCDELAY syncDelay; //!< Sync delay + NVVIOCOMPSYNCTYPE compositeSyncType; //!< Composite sync type + NvU32 frameLockEnable; //!< Flag indicating whether framelock was on/off + NvU32 psfSignalFormat; //!< Indicates whether contained format is PSF Signal format + NvU32 enable422Filter; //!< Enables/Disables 4:2:2 filter + NvU32 compositeTerminate; //!< Composite termination + NvU32 enableDataIntegrityCheck; //!< Enable data integrity check: true - enable, false - disable + NvU32 cscOverride; //!< Use provided CSC color matrix to overwrite + NvU32 flipQueueLength; //!< Number of buffers used for the internal flip queue + NvU32 enableANCTimeCodeGeneration; //!< Enable SDI ANC time code generation + NvU32 enableComposite; //!< Enable composite + NvU32 enableAlphaKeyComposite; //!< Enable Alpha key composite + NVVIOCOMPOSITERANGE compRange; //!< Composite ranges + NvU8 reservedData[256]; //!< Indicates last stored SDI output state TRUE-ON / FALSE-OFF + NvU32 enableFullColorRange; //!< Flag indicating Full Color Range + NvU32 enableRGBData; //!< Indicates data is in RGB format + NVVIOANCPARITYCOMPUTATION ancParityComputation; //!< Enable HW ANC parity bit computation (auto/on/off) +} NVVIOOUTPUTCONFIG_V2; + +typedef struct _NVVIOOUTPUTCONFIG_V3 +{ + NVVIOSIGNALFORMAT signalFormat; //!< Signal format for video output + NVVIODATAFORMAT dataFormat; //!< Data format for video output + NVVIOOUTPUTREGION outputRegion; //!< Region for video output (Desktop mode) + NVVIOOUTPUTAREA outputArea; //!< Usable resolution for video output (safe area) + NVVIOCOLORCONVERSION colorConversion; //!< Color conversion. + NVVIOGAMMACORRECTION gammaCorrection; + NvU32 syncEnable; //!< Sync enable (TRUE to use syncSource) + NVVIOSYNCSOURCE syncSource; //!< Sync source + NVVIOSYNCDELAY syncDelay; //!< Sync delay + NVVIOCOMPSYNCTYPE compositeSyncType; //!< Composite sync type + NvU32 frameLockEnable; //!< Flag indicating whether framelock was on/off + NvU32 psfSignalFormat; //!< Indicates whether contained format is PSF Signal format + NvU32 enable422Filter; //!< Enables/Disables 4:2:2 filter + NvU32 compositeTerminate; //!< Composite termination + NvU32 enableDataIntegrityCheck; //!< Enable data integrity check: true - enable, false - disable + NvU32 cscOverride; //!< Use provided CSC color matrix to overwrite + NvU32 flipQueueLength; //!< Number of buffers used for the internal flip queue + NvU32 enableANCTimeCodeGeneration; //!< Enable SDI ANC time code generation + NvU32 enableComposite; //!< Enable composite + NvU32 enableAlphaKeyComposite; //!< Enable Alpha key composite + NVVIOCOMPOSITERANGE compRange; //!< Composite ranges + NvU8 reservedData[256]; //!< Indicates last stored SDI output state TRUE-ON / FALSE-OFF + NvU32 enableFullColorRange; //!< Flag indicating Full Color Range + NvU32 enableRGBData; //!< Indicates data is in RGB format + NVVIOANCPARITYCOMPUTATION ancParityComputation; //!< Enable HW ANC parity bit computation (auto/on/off) + NvU32 enableAudioBlanking; //!< Enable HANC audio blanking on repeat frames +} NVVIOOUTPUTCONFIG_V3; + +//! Stream configuration +typedef struct _NVVIOSTREAM +{ + NvU32 bitsPerComponent; //!< Bits per component + NVVIOCOMPONENTSAMPLING sampling; //!< Sampling + NvU32 expansionEnable; //!< Enable/disable 4:2:2->4:4:4 expansion + NvU32 numLinks; //!< Number of active links + struct + { + NvU32 jack; //!< This stream's link[i] will use the specified (0-based) channel within the + NvU32 channel; //!< specified (0-based) jack + } links[NVAPI_MAX_VIO_LINKS_PER_STREAM]; +} NVVIOSTREAM; + +//! Input device configuration +typedef struct _NVVIOINPUTCONFIG +{ + NvU32 numRawCaptureImages; //!< numRawCaptureImages is the number of frames to keep in the capture queue. + //!< must be between NVAPI_GVI_MIN_RAW_CAPTURE_IMAGES and NVAPI_GVI_MAX_RAW_CAPTURE_IMAGES, + NVVIOSIGNALFORMAT signalFormat; //!< Signal format. + //!< Please note that both numRawCaptureImages and signalFormat should be set together. + NvU32 numStreams; //!< Number of active streams. + NVVIOSTREAM streams[NVAPI_MAX_VIO_STREAMS]; //!< Stream configurations + NvU32 bTestMode; //!< This attribute controls the GVI test mode. + //!< Possible values 0/1. When testmode enabled, the + //!< GVI device will generate fake data as quickly as possible. +} NVVIOINPUTCONFIG; + +typedef struct _NVVIOCONFIG_V1 +{ + NvU32 version; //!< Structure version + NvU32 fields; //!< Caller sets to NVVIOCONFIG_* mask for fields to use + NVVIOCONFIGTYPE nvvioConfigType; //!< Input or Output configuration + union + { + NVVIOINPUTCONFIG inConfig; //!< Input device configuration + NVVIOOUTPUTCONFIG_V1 outConfig; //!< Output device configuration + }vioConfig; +} NVVIOCONFIG_V1; + + +typedef struct _NVVIOCONFIG_V2 +{ + NvU32 version; //!< Structure version + NvU32 fields; //!< Caller sets to NVVIOCONFIG_* mask for fields to use + NVVIOCONFIGTYPE nvvioConfigType; //!< Input or Output configuration + union + { + NVVIOINPUTCONFIG inConfig; //!< Input device configuration + NVVIOOUTPUTCONFIG_V2 outConfig; //!< Output device configuration + }vioConfig; +} NVVIOCONFIG_V2; + +typedef struct _NVVIOCONFIG_V3 +{ + NvU32 version; //!< Structure version + NvU32 fields; //!< Caller sets to NVVIOCONFIG_* mask for fields to use + NVVIOCONFIGTYPE nvvioConfigType; //!< Input or Output configuration + union + { + NVVIOINPUTCONFIG inConfig; //!< Input device configuration + NVVIOOUTPUTCONFIG_V3 outConfig; //!< Output device configuration + }vioConfig; +} NVVIOCONFIG_V3; +typedef NVVIOOUTPUTCONFIG_V3 NVVIOOUTPUTCONFIG; +typedef NVVIOCONFIG_V3 NVVIOCONFIG; + +#define NVVIOCONFIG_VER1 MAKE_NVAPI_VERSION(NVVIOCONFIG_V1,1) +#define NVVIOCONFIG_VER2 MAKE_NVAPI_VERSION(NVVIOCONFIG_V2,2) +#define NVVIOCONFIG_VER3 MAKE_NVAPI_VERSION(NVVIOCONFIG_V3,3) +#define NVVIOCONFIG_VER NVVIOCONFIG_VER3 + + +typedef struct +{ + NvPhysicalGpuHandle hPhysicalGpu; //!< Handle to Physical GPU (This could be NULL for GVI device if its not binded) + NvVioHandle hVioHandle; //!Create Stereo Handle->InitActivation->Reset Device +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! \since Release: 302 +//! +//! \param [in] stereoHandle Stereo handle corresponding to the device interface. +//! \param [in] bDelayed Use delayed activation +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED - Stereo part of NVAPI not initialized. +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// + +//! \addtogroup stereoapi +//! @{ + +//! InitActivation Flags +typedef enum _NVAPI_STEREO_INIT_ACTIVATION_FLAGS +{ + NVAPI_STEREO_INIT_ACTIVATION_IMMEDIATE = 0X00, + NVAPI_STEREO_INIT_ACTIVATION_DELAYED = 0x01, +} NVAPI_STEREO_INIT_ACTIVATION_FLAGS; + +NVAPI_INTERFACE NvAPI_Stereo_InitActivation(__in StereoHandle hStereoHandle, __in NVAPI_STEREO_INIT_ACTIVATION_FLAGS flags); + +//! @} + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_Trigger_Activation +// +//! DESCRIPTION: This API allows an application to trigger creation of a stereo desktop, +//! in case the creation was stopped on application launch. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! \since Release: 302 +//! +//! \param [in] stereoHandle Stereo handle that corresponds to the device interface. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +//! \retval ::NVAPI_STEREO_INIT_ACTIVATION_NOT_DONE - Stereo InitActivation not called. +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED - Stereo part of NVAPI not initialized. +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_Trigger_Activation(__in StereoHandle hStereoHandle); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_CapturePngImage +// +//! DESCRIPTION: This API captures the current stereo image in PNG stereo format. +//! Only the last capture call per flip will be effective. +//! +//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [in] stereoHandle Stereo handle corresponding to the device interface. +//! +//! \retval ::NVAPI_OK Image captured. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_CapturePngImage(StereoHandle stereoHandle); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_ReverseStereoBlitControl +// +//! DESCRIPTION: This API turns on/off reverse stereo blit. +//! +//! HOW TO USE: Use after the stereo handle for the device interface is created via successfull call to the appropriate +//! NvAPI_Stereo_CreateHandleFrom() function. +//! After reversed stereo blit control is turned on, blits from the stereo surface will +//! produce the right-eye image in the left side of the destination surface and the left-eye +//! image in the right side of the destination surface. +//! +//! In DirectX 9, the destination surface must be created as the render target, and StretchRect must be used. +//! Conditions: +//! - DstWidth == 2*SrcWidth +//! - DstHeight == SrcHeight +//! - Src surface is the stereo surface. +//! - SrcRect must be {0,0,SrcWidth,SrcHeight} +//! - DstRect must be {0,0,DstWidth,DstHeight} +//! +//! In DirectX 10, ResourceCopyRegion must be used. +//! Conditions: +//! - DstWidth == 2*SrcWidth +//! - DstHeight == SrcHeight +//! - dstX == 0, +//! - dstY == 0, +//! - dstZ == 0, +//! - SrcBox: left=top=front==0; right==SrcWidth; bottom==SrcHeight; back==1; +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [in] stereoHandle Stereo handle corresponding to the device interface. +//! \param [in] TurnOn != 0 : Turns on \n +//! == 0 : Turns off +//! +//! +//! \retval ::NVAPI_OK Retrieval of frustum adjust mode was successfull. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_ReverseStereoBlitControl(StereoHandle hStereoHandle, NvU8 TurnOn); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_SetNotificationMessage +// +//! DESCRIPTION: This API is a Setup notification message that the stereo driver uses to notify the application +//! when the user changes the stereo driver state. +//! +//! When the user changes the stereo state (Activated or Deactivated, separation or conversion) +//! the stereo driver posts a defined message with the following parameters: +//! +//! lParam is the current conversion. (Actual conversion is *(float*)&lParam ) +//! +//! wParam == MAKEWPARAM(l, h) where +//! - l == 0 if stereo is deactivated +//! - l == 1 if stereo is deactivated +//! - h is the current separation. (Actual separation is float(h*100.f/0xFFFF) +//! +//! Call this API with NULL hWnd to prohibit notification. +//! +//! WHEN TO USE: Use after the stereo handle for device interface is created via successful call to appropriate +//! NvAPI_Stereo_CreateHandleFrom() function. +//! +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! +//! \param [in] stereoHandle Stereo handle corresponding to the device interface. +//! \param [in] hWnd Window HWND that will be notified when the user changes the stereo driver state. +//! Actual HWND must be cast to an NvU64. +//! \param [in] messageID MessageID of the message that will be posted to hWnd +//! +//! \retval ::NVAPI_OK Notification set. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_SetNotificationMessage(StereoHandle hStereoHandle, NvU64 hWnd,NvU64 messageID); + + + + + + + + + + + + + + + +//! \ingroup stereoapi +#define NVAPI_STEREO_QUADBUFFERED_API_VERSION 0x2 + +//! \ingroup stereoapi + typedef enum _NV_StereoSwapChainMode + { + NVAPI_STEREO_SWAPCHAIN_DEFAULT = 0, + NVAPI_STEREO_SWAPCHAIN_STEREO = 1, + NVAPI_STEREO_SWAPCHAIN_MONO = 2, + } NV_STEREO_SWAPCHAIN_MODE; + +#if defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D1x_CreateSwapChain +// +//! DESCRIPTION: This API allows the user to create a mono or a stereo swap chain. +//! +//! NOTE: NvAPI_D3D1x_CreateSwapChain is a wrapper of the method IDXGIFactory::CreateSwapChain which +//! additionally notifies the D3D driver of the mode in which stereo mode the swap chain is to be +//! created. +//! +//! \since Release: 285 +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface. +//! A pointer to the device that will write 2D images to the swap chain. +//! \param [in] pDesc A pointer to the swap-chain description (DXGI_SWAP_CHAIN_DESC). This parameter cannot be NULL. +//! \param [out] ppSwapChain A pointer to the swap chain created. +//! \param [in] mode The stereo mode fot the swap chain. +//! NVAPI_STEREO_SWAPCHAIN_DEFAULT +//! NVAPI_STEREO_SWAPCHAIN_STEREO +//! NVAPI_STEREO_SWAPCHAIN_MONO +//! +//! \retval ::NVAPI_OK The swap chain was created successfully. +//! \retval ::NVAPI_ERROR The operation failed. +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D1x_CreateSwapChain(StereoHandle hStereoHandle, + DXGI_SWAP_CHAIN_DESC* pDesc, + IDXGISwapChain** ppSwapChain, + NV_STEREO_SWAPCHAIN_MODE mode); + +#endif //if defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__) + + +#if defined(_D3D9_H_) //NvAPI_D3D9_CreateSwapChain +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D9_CreateSwapChain +// +//! DESCRIPTION: This API allows the user to create a mono or a stereo swap chain. +//! +//! NOTE: NvAPI_D3D9_CreateSwapChain is a wrapper of the method IDirect3DDevice9::CreateAdditionalSwapChain which +//! additionally notifies the D3D driver if the swap chain creation mode must be stereo or mono. +//! +//! +//! \since Release: 285 +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface. +//! \param [in, out] pPresentationParameters A pointer to the swap-chain description (DXGI). This parameter cannot be NULL. +//! \param [out] ppSwapChain A pointer to the swap chain created. +//! \param [in] mode The stereo mode for the swap chain. +//! NVAPI_STEREO_SWAPCHAIN_DEFAULT +//! NVAPI_STEREO_SWAPCHAIN_STEREO +//! NVAPI_STEREO_SWAPCHAIN_MONO +//! +//! \retval ::NVAPI_OK The swap chain creation was successful +//! \retval ::NVAPI_ERROR The operation failed. +//! +//!\ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D9_CreateSwapChain(StereoHandle hStereoHandle, + D3DPRESENT_PARAMETERS *pPresentationParameters, + IDirect3DSwapChain9 **ppSwapChain, + NV_STEREO_SWAPCHAIN_MODE mode); +#endif //if defined(_D3D9_H_) //NvAPI_D3D9_CreateSwapChain + + + + + +//! \addtogroup drsapi +//! @{ + + +// GPU Profile APIs + +NV_DECLARE_HANDLE(NvDRSSessionHandle); +NV_DECLARE_HANDLE(NvDRSProfileHandle); + +#define NVAPI_DRS_GLOBAL_PROFILE ((NvDRSProfileHandle) -1) + +#define NVAPI_SETTING_MAX_VALUES 100 + +typedef enum _NVDRS_SETTING_TYPE +{ + NVDRS_DWORD_TYPE, + NVDRS_BINARY_TYPE, + NVDRS_STRING_TYPE, + NVDRS_WSTRING_TYPE +} NVDRS_SETTING_TYPE; + +typedef enum _NVDRS_SETTING_LOCATION +{ + NVDRS_CURRENT_PROFILE_LOCATION, + NVDRS_GLOBAL_PROFILE_LOCATION, + NVDRS_BASE_PROFILE_LOCATION, + NVDRS_DEFAULT_PROFILE_LOCATION +} NVDRS_SETTING_LOCATION; + + +typedef struct _NVDRS_GPU_SUPPORT +{ + NvU32 geforce : 1; + NvU32 quadro : 1; + NvU32 nvs : 1; + NvU32 reserved4 : 1; + NvU32 reserved5 : 1; + NvU32 reserved6 : 1; + NvU32 reserved7 : 1; + NvU32 reserved8 : 1; + NvU32 reserved9 : 1; + NvU32 reserved10 : 1; + NvU32 reserved11 : 1; + NvU32 reserved12 : 1; + NvU32 reserved13 : 1; + NvU32 reserved14 : 1; + NvU32 reserved15 : 1; + NvU32 reserved16 : 1; + NvU32 reserved17 : 1; + NvU32 reserved18 : 1; + NvU32 reserved19 : 1; + NvU32 reserved20 : 1; + NvU32 reserved21 : 1; + NvU32 reserved22 : 1; + NvU32 reserved23 : 1; + NvU32 reserved24 : 1; + NvU32 reserved25 : 1; + NvU32 reserved26 : 1; + NvU32 reserved27 : 1; + NvU32 reserved28 : 1; + NvU32 reserved29 : 1; + NvU32 reserved30 : 1; + NvU32 reserved31 : 1; + NvU32 reserved32 : 1; +} NVDRS_GPU_SUPPORT; + +//! Enum to decide on the datatype of setting value. +typedef struct _NVDRS_BINARY_SETTING +{ + NvU32 valueLength; //!< valueLength should always be in number of bytes. + NvU8 valueData[NVAPI_BINARY_DATA_MAX]; +} NVDRS_BINARY_SETTING; + +typedef struct _NVDRS_SETTING_VALUES +{ + NvU32 version; //!< Structure Version + NvU32 numSettingValues; //!< Total number of values available in a setting. + NVDRS_SETTING_TYPE settingType; //!< Type of setting value. + union //!< Setting can hold either DWORD or Binary value or string. Not mixed types. + { + NvU32 u32DefaultValue; //!< Accessing default DWORD value of this setting. + NVDRS_BINARY_SETTING binaryDefaultValue; //!< Accessing default Binary value of this setting. + //!< Must be allocated by caller with valueLength specifying buffer size, or only valueLength will be filled in. + NvAPI_UnicodeString wszDefaultValue; //!< Accessing default unicode string value of this setting. + }; + union //!< Setting values can be of either DWORD, Binary values or String type, + { //!< NOT mixed types. + NvU32 u32Value; //!< All possible DWORD values for a setting + NVDRS_BINARY_SETTING binaryValue; //!< All possible Binary values for a setting + NvAPI_UnicodeString wszValue; //!< Accessing current unicode string value of this setting. + }settingValues[NVAPI_SETTING_MAX_VALUES]; +} NVDRS_SETTING_VALUES; + +//! Macro for constructing the version field of ::_NVDRS_SETTING_VALUES +#define NVDRS_SETTING_VALUES_VER MAKE_NVAPI_VERSION(NVDRS_SETTING_VALUES,1) + +typedef struct _NVDRS_SETTING_V1 +{ + NvU32 version; //!< Structure Version + NvAPI_UnicodeString settingName; //!< String name of setting + NvU32 settingId; //!< 32 bit setting Id + NVDRS_SETTING_TYPE settingType; //!< Type of setting value. + NVDRS_SETTING_LOCATION settingLocation; //!< Describes where the value in CurrentValue comes from. + NvU32 isCurrentPredefined; //!< It is different than 0 if the currentValue is a predefined Value, + //!< 0 if the currentValue is a user value. + NvU32 isPredefinedValid; //!< It is different than 0 if the PredefinedValue union contains a valid value. + union //!< Setting can hold either DWORD or Binary value or string. Not mixed types. + { + NvU32 u32PredefinedValue; //!< Accessing default DWORD value of this setting. + NVDRS_BINARY_SETTING binaryPredefinedValue; //!< Accessing default Binary value of this setting. + //!< Must be allocated by caller with valueLength specifying buffer size, + //!< or only valueLength will be filled in. + NvAPI_UnicodeString wszPredefinedValue; //!< Accessing default unicode string value of this setting. + }; + union //!< Setting can hold either DWORD or Binary value or string. Not mixed types. + { + NvU32 u32CurrentValue; //!< Accessing current DWORD value of this setting. + NVDRS_BINARY_SETTING binaryCurrentValue; //!< Accessing current Binary value of this setting. + //!< Must be allocated by caller with valueLength specifying buffer size, + //!< or only valueLength will be filled in. + NvAPI_UnicodeString wszCurrentValue; //!< Accessing current unicode string value of this setting. + }; +} NVDRS_SETTING_V1; + +//! Macro for constructing the version field of ::_NVDRS_SETTING +#define NVDRS_SETTING_VER1 MAKE_NVAPI_VERSION(NVDRS_SETTING_V1, 1) + +typedef NVDRS_SETTING_V1 NVDRS_SETTING; +#define NVDRS_SETTING_VER NVDRS_SETTING_VER1 + +typedef struct _NVDRS_APPLICATION_V1 +{ + NvU32 version; //!< Structure Version + NvU32 isPredefined; //!< Is the application userdefined/predefined + NvAPI_UnicodeString appName; //!< String name of the Application + NvAPI_UnicodeString userFriendlyName; //!< UserFriendly name of the Application + NvAPI_UnicodeString launcher; //!< Indicates the name (if any) of the launcher that starts the application +} NVDRS_APPLICATION_V1; + +typedef struct _NVDRS_APPLICATION_V2 +{ + NvU32 version; //!< Structure Version + NvU32 isPredefined; //!< Is the application userdefined/predefined + NvAPI_UnicodeString appName; //!< String name of the Application + NvAPI_UnicodeString userFriendlyName; //!< UserFriendly name of the Application + NvAPI_UnicodeString launcher; //!< Indicates the name (if any) of the launcher that starts the Application + NvAPI_UnicodeString fileInFolder; //!< Select this application only if this file is found. + //!< When specifying multiple files, separate them using the ':' character. +} NVDRS_APPLICATION_V2; + +typedef struct _NVDRS_APPLICATION_V3 +{ + NvU32 version; //!< Structure Version + NvU32 isPredefined; //!< Is the application userdefined/predefined + NvAPI_UnicodeString appName; //!< String name of the Application + NvAPI_UnicodeString userFriendlyName; //!< UserFriendly name of the Application + NvAPI_UnicodeString launcher; //!< Indicates the name (if any) of the launcher that starts the Application + NvAPI_UnicodeString fileInFolder; //!< Select this application only if this file is found. + //!< When specifying multiple files, separate them using the ':' character. + NvU32 isMetro:1; //!< Windows 8 style app + NvU32 isCommandLine:1; //!< Command line parsing for the application name + NvU32 reserved:30; //!< Reserved. Should be 0. +} NVDRS_APPLICATION_V3; + +typedef struct _NVDRS_APPLICATION_V4 +{ + NvU32 version; //!< Structure Version + NvU32 isPredefined; //!< Is the application userdefined/predefined + NvAPI_UnicodeString appName; //!< String name of the Application + NvAPI_UnicodeString userFriendlyName; //!< UserFriendly name of the Application + NvAPI_UnicodeString launcher; //!< Indicates the name (if any) of the launcher that starts the Application + NvAPI_UnicodeString fileInFolder; //!< Select this application only if this file is found. + //!< When specifying multiple files, separate them using the ':' character. + NvU32 isMetro:1; //!< Windows 8 style app + NvU32 isCommandLine:1; //!< Command line parsing for the application name + NvU32 reserved:30; //!< Reserved. Should be 0. + NvAPI_UnicodeString commandLine; //!< If isCommandLine is set to 0 this must be an empty. If isCommandLine is set to 1 + //!< this contains application's command line as if it was returned by GetCommandLineW. +} NVDRS_APPLICATION_V4; + +#define NVDRS_APPLICATION_VER_V1 MAKE_NVAPI_VERSION(NVDRS_APPLICATION_V1,1) +#define NVDRS_APPLICATION_VER_V2 MAKE_NVAPI_VERSION(NVDRS_APPLICATION_V2,2) +#define NVDRS_APPLICATION_VER_V3 MAKE_NVAPI_VERSION(NVDRS_APPLICATION_V3,3) +#define NVDRS_APPLICATION_VER_V4 MAKE_NVAPI_VERSION(NVDRS_APPLICATION_V4,4) + +typedef NVDRS_APPLICATION_V4 NVDRS_APPLICATION; +#define NVDRS_APPLICATION_VER NVDRS_APPLICATION_VER_V4 + +typedef struct _NVDRS_PROFILE_V1 +{ + NvU32 version; //!< Structure Version + NvAPI_UnicodeString profileName; //!< String name of the Profile + NVDRS_GPU_SUPPORT gpuSupport; //!< This read-only flag indicates the profile support on either + //!< Quadro, or Geforce, or both. + NvU32 isPredefined; //!< Is the Profile user-defined, or predefined + NvU32 numOfApps; //!< Total number of applications that belong to this profile. Read-only + NvU32 numOfSettings; //!< Total number of settings applied for this Profile. Read-only +} NVDRS_PROFILE_V1; + +typedef NVDRS_PROFILE_V1 NVDRS_PROFILE; + +//! Macro for constructing the version field of ::NVDRS_PROFILE +#define NVDRS_PROFILE_VER1 MAKE_NVAPI_VERSION(NVDRS_PROFILE_V1,1) +#define NVDRS_PROFILE_VER NVDRS_PROFILE_VER1 + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_CreateSession +// +//! DESCRIPTION: This API allocates memory and initializes the session. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [out] *phSession Return pointer to the session handle. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR: For miscellaneous errors. +// +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_CreateSession(NvDRSSessionHandle *phSession); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_DestroySession +// +//! DESCRIPTION: This API frees the allocation: cleanup of NvDrsSession. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +// +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_DestroySession(NvDRSSessionHandle hSession); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_LoadSettings +// +//! DESCRIPTION: This API loads and parses the settings data. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +// +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_LoadSettings(NvDRSSessionHandle hSession); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_SaveSettings +// +//! DESCRIPTION: This API saves the settings data to the system. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +// +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_SaveSettings(NvDRSSessionHandle hSession); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_LoadSettingsFromFile +// +//! DESCRIPTION: This API loads settings from the given file path. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle +//! \param [in] fileName Binary File Name/Path +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +// +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_LoadSettingsFromFile(NvDRSSessionHandle hSession, NvAPI_UnicodeString fileName); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_SaveSettingsToFile +// +//! DESCRIPTION: This API saves settings to the given file path. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] fileName Binary File Name/Path +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +// +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_SaveSettingsToFile(NvDRSSessionHandle hSession, NvAPI_UnicodeString fileName); + +//! @} + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_CreateProfile +// +//! DESCRIPTION: This API creates an empty profile. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] *pProfileInfo Input pointer to NVDRS_PROFILE. +//! \param [in] *phProfile Returns pointer to profile handle. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_CreateProfile(NvDRSSessionHandle hSession, NVDRS_PROFILE *pProfileInfo, NvDRSProfileHandle *phProfile); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_DeleteProfile +// +//! DESCRIPTION: This API deletes a profile or sets it back to a predefined value. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! +//! \retval ::NVAPI_OK SUCCESS if the profile is found +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_DeleteProfile(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_SetCurrentGlobalProfile +// +//! DESCRIPTION: This API sets the current global profile in the driver. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] wszGlobalProfileName Input current Global profile name. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_SetCurrentGlobalProfile(NvDRSSessionHandle hSession, NvAPI_UnicodeString wszGlobalProfileName); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_GetCurrentGlobalProfile +// +//! DESCRIPTION: This API returns the handle to the current global profile. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [out] *phProfile Returns current Global profile handle. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_GetCurrentGlobalProfile(NvDRSSessionHandle hSession, NvDRSProfileHandle *phProfile); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_GetProfileInfo +// +//! DESCRIPTION: This API gets information about the given profile. User needs to specify the name of the Profile. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [out] *pProfileInfo Return the profile info. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_GetProfileInfo(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NVDRS_PROFILE *pProfileInfo); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_SetProfileInfo +// +//! DESCRIPTION: Specifies flags for a given profile. Currently only the NVDRS_GPU_SUPPORT is +//! used to update the profile. Neither the name, number of settings or applications +//! or other profile information can be changed with this function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [in] *pProfileInfo Input the new profile info. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_SetProfileInfo(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NVDRS_PROFILE *pProfileInfo); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_FindProfileByName +// +//! DESCRIPTION: This API finds a profile in the current session. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] profileName Input profileName. +//! \param [out] phProfile Input profile handle. +//! +//! \retval ::NVAPI_OK SUCCESS if the profile is found +//! \retval ::NVAPI_PROFILE_NOT_FOUND if profile is not found +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_FindProfileByName(NvDRSSessionHandle hSession, NvAPI_UnicodeString profileName, NvDRSProfileHandle* phProfile); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_EnumProfiles +// +//! DESCRIPTION: This API enumerates through all the profiles in the session. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] index Input the index for enumeration. +//! \param [out] *phProfile Returns profile handle. +//! +//! RETURN STATUS: NVAPI_OK: SUCCESS if the profile is found +//! NVAPI_ERROR: For miscellaneous errors. +//! NVAPI_END_ENUMERATION: index exceeds the total number of available Profiles in DB. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_EnumProfiles(NvDRSSessionHandle hSession, NvU32 index, NvDRSProfileHandle *phProfile); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_GetNumProfiles +// +//! DESCRIPTION: This API obtains the number of profiles in the current session object. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param out] *numProfiles Returns count of profiles in the current hSession. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_API_NOT_INTIALIZED Failed to initialize. +//! \retval ::NVAPI_INVALID_ARGUMENT Invalid Arguments. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_GetNumProfiles(NvDRSSessionHandle hSession, NvU32 *numProfiles); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_CreateApplication +// +//! DESCRIPTION: This API adds an executable name to a profile. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [in] *pApplication Input NVDRS_APPLICATION struct with the executable name to be added. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_CreateApplication(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NVDRS_APPLICATION *pApplication); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_DeleteApplicationEx +// +//! DESCRIPTION: This API removes an executable from a profile. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession - Input to the session handle. +//! \param [in] hProfile - Input profile handle. +//! \param [in] *pApp - Input all the information about the application to be removed. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! \retval ::NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS If the path provided could refer to two different executables, +//! this error will be returned. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_DeleteApplicationEx(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NVDRS_APPLICATION *pApp); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_DeleteApplication +// +//! DESCRIPTION: This API removes an executable name from a profile. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSessionPARAMETERS Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [in] appName Input the executable name to be removed. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! \retval ::NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS If the path provided could refer to two different executables, +//! this error will be returned +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_DeleteApplication(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvAPI_UnicodeString appName); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_GetApplicationInfo +// +//! DESCRIPTION: This API gets information about the given application. The input application name +//! must match exactly what the Profile has stored for the application. +//! This function is better used to retrieve application information from a previous +//! enumeration. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [in] appName Input application name. +//! \param [out] *pApplication Returns NVDRS_APPLICATION struct with all the attributes. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below. +//! \retval ::NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS The application name could not +// single out only one executable. +//! \retval ::NVAPI_EXECUTABLE_NOT_FOUND No application with that name is found on the profile. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_GetApplicationInfo(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvAPI_UnicodeString appName, NVDRS_APPLICATION *pApplication); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_EnumApplications +// +//! DESCRIPTION: This API enumerates all the applications in a given profile from the starting index to the maximum length. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [in] startIndex Indicates starting index for enumeration. +//! \param [in,out] *appCount Input maximum length of the passed in arrays. Returns the actual length. +//! \param [out] *pApplication Returns NVDRS_APPLICATION struct with all the attributes. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! \retval ::NVAPI_END_ENUMERATION startIndex exceeds the total appCount. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_EnumApplications(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 startIndex, NvU32 *appCount, NVDRS_APPLICATION *pApplication); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_FindApplicationByName +// +//! DESCRIPTION: This API searches the application and the associated profile for the given application name. +//! If a fully qualified path is provided, this function will always return the profile +//! the driver will apply upon running the application (on the path provided). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the hSession handle +//! \param [in] appName Input appName. For best results, provide a fully qualified path of the type +//! c:/Folder1/Folder2/App.exe +//! \param [out] *phProfile Returns profile handle. +//! \param [in,out] *pApplication Returns NVDRS_APPLICATION struct pointer. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! If there are return error codes with specific meaning for this API, +//! they are listed below: +//! \retval ::NVAPI_APPLICATION_NOT_FOUND If App not found +//! \retval ::NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS If the input appName was not fully qualified, this error might return in the case of multiple matches +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_FindApplicationByName(__in NvDRSSessionHandle hSession, __in NvAPI_UnicodeString appName, __out NvDRSProfileHandle *phProfile, __inout NVDRS_APPLICATION *pApplication); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_SetSetting +// +//! DESCRIPTION: This API adds/modifies a setting to a profile. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [in] *pSetting Input NVDRS_SETTING struct pointer. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_SetSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NVDRS_SETTING *pSetting); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_GetSetting +// +//! DESCRIPTION: This API gets information about the given setting. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [in] settingId Input settingId. +//! \param [out] *pSetting Returns all the setting info +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_GetSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 settingId, NVDRS_SETTING *pSetting); + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_EnumSettings +// +//! DESCRIPTION: This API enumerates all the settings of a given profile from startIndex to the maximum length. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [in] startIndex Indicates starting index for enumeration. +//! \param [in,out] *settingsCount Input max length of the passed in arrays, Returns the actual length. +//! \param [out] *pSetting Returns all the settings info. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! \retval ::NVAPI_END_ENUMERATION startIndex exceeds the total appCount. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_EnumSettings(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 startIndex, NvU32 *settingsCount, NVDRS_SETTING *pSetting); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_EnumAvailableSettingIds +// +//! DESCRIPTION: This API enumerates all the Ids of all the settings recognized by NVAPI. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [out] pSettingIds User-provided array of length *pMaxCount that NVAPI will fill with IDs. +//! \param [in,out] pMaxCount Input max length of the passed in array, Returns the actual length. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! NVAPI_END_ENUMERATION: the provided pMaxCount is not enough to hold all settingIds. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_EnumAvailableSettingIds(NvU32 *pSettingIds, NvU32 *pMaxCount); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_EnumAvailableSettingValues +// +//! DESCRIPTION: This API enumerates all available setting values for a given setting. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] settingId Input settingId. +//! \param [in,out] pMaxNumValues Input max length of the passed in arrays, Returns the actual length. +//! \param [out] *pSettingValues Returns all available setting values and its count. +//! +//! \retval ::NVAPI_OK SUCCESS +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_EnumAvailableSettingValues(NvU32 settingId, NvU32 *pMaxNumValues, NVDRS_SETTING_VALUES *pSettingValues); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_GetSettingIdFromName +// +//! DESCRIPTION: This API gets the binary ID of a setting given the setting name. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] settingName Input Unicode settingName. +//! \param [out] *pSettingId Returns corresponding settingId. +//! +//! \retval ::NVAPI_OK SUCCESS if the profile is found +//! \retval ::NVAPI_PROFILE_NOT_FOUND if profile is not found +//! \retval ::NVAPI_SETTING_NOT_FOUND if setting is not found +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_GetSettingIdFromName(NvAPI_UnicodeString settingName, NvU32 *pSettingId); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_GetSettingNameFromId +// +//! DESCRIPTION: This API gets the setting name given the binary ID. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] settingId Input settingId. +//! \param [in] *pSettingName Returns corresponding Unicode settingName. +//! +//! \retval ::NVAPI_OK SUCCESS if the profile is found +//! \retval ::NVAPI_PROFILE_NOT_FOUND if profile is not found +//! \retval ::NVAPI_SETTING_NOT_FOUND if setting is not found +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_GetSettingNameFromId(NvU32 settingId, NvAPI_UnicodeString *pSettingName); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_DeleteProfileSetting +// +//! DESCRIPTION: This API deletes a setting or sets it back to predefined value. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [in] settingId Input settingId to be deleted. +//! +//! \retval ::NVAPI_OK SUCCESS if the profile is found +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_DeleteProfileSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 settingId); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_RestoreAllDefaults +// +//! DESCRIPTION: This API restores the whole system to predefined(default) values. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! +//! \retval ::NVAPI_OK SUCCESS if the profile is found +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_RestoreAllDefaults(NvDRSSessionHandle hSession); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_RestoreProfileDefault +// +//! DESCRIPTION: This API restores the given profile to predefined(default) values. +//! Any and all user specified modifications will be removed. +//! If the whole profile was set by the user, the profile will be removed. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! +//! \retval ::NVAPI_OK SUCCESS if the profile is found +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! \retval ::NVAPI_PROFILE_REMOVED SUCCESS, and the hProfile is no longer valid. +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_RestoreProfileDefault(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_RestoreProfileDefaultSetting +// +//! DESCRIPTION: This API restores the given profile setting to predefined(default) values. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] hProfile Input profile handle. +//! \param [in] settingId Input settingId. +//! +//! \retval ::NVAPI_OK SUCCESS if the profile is found +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_RestoreProfileDefaultSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 settingId); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DRS_GetBaseProfile +// +//! DESCRIPTION: Returns the handle to the current global profile. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hSession Input to the session handle. +//! \param [in] *phProfile Returns Base profile handle. +//! +//! \retval ::NVAPI_OK SUCCESS if the profile is found +//! \retval ::NVAPI_ERROR For miscellaneous errors. +//! +//! \ingroup drsapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DRS_GetBaseProfile(NvDRSSessionHandle hSession, NvDRSProfileHandle *phProfile); + + + + +//! \addtogroup sysgeneral +//! @{ + +typedef struct +{ + NvU32 version; //!< structure version + NvU32 vendorId; //!< Chipset vendor identification + NvU32 deviceId; //!< Chipset device identification + NvAPI_ShortString szVendorName; //!< Chipset vendor Name + NvAPI_ShortString szChipsetName; //!< Chipset device Name + NvU32 flags; //!< Chipset info flags - obsolete + NvU32 subSysVendorId; //!< Chipset subsystem vendor identification + NvU32 subSysDeviceId; //!< Chipset subsystem device identification + NvAPI_ShortString szSubSysVendorName; //!< subsystem vendor Name + NvU32 HBvendorId; //!< Host bridge vendor identification + NvU32 HBdeviceId; //!< Host bridge device identification + NvU32 HBsubSysVendorId; //!< Host bridge subsystem vendor identification + NvU32 HBsubSysDeviceId; //!< Host bridge subsystem device identification + +} NV_CHIPSET_INFO_v4; + +typedef struct +{ + NvU32 version; //!< structure version + NvU32 vendorId; //!< vendor ID + NvU32 deviceId; //!< device ID + NvAPI_ShortString szVendorName; //!< vendor Name + NvAPI_ShortString szChipsetName; //!< device Name + NvU32 flags; //!< Chipset info flags - obsolete + NvU32 subSysVendorId; //!< subsystem vendor ID + NvU32 subSysDeviceId; //!< subsystem device ID + NvAPI_ShortString szSubSysVendorName; //!< subsystem vendor Name +} NV_CHIPSET_INFO_v3; + +typedef enum +{ + NV_CHIPSET_INFO_HYBRID = 0x00000001, +} NV_CHIPSET_INFO_FLAGS; + +typedef struct +{ + NvU32 version; //!< structure version + NvU32 vendorId; //!< vendor ID + NvU32 deviceId; //!< device ID + NvAPI_ShortString szVendorName; //!< vendor Name + NvAPI_ShortString szChipsetName; //!< device Name + NvU32 flags; //!< Chipset info flags +} NV_CHIPSET_INFO_v2; + +typedef struct +{ + NvU32 version; //structure version + NvU32 vendorId; //vendor ID + NvU32 deviceId; //device ID + NvAPI_ShortString szVendorName; //vendor Name + NvAPI_ShortString szChipsetName; //device Name +} NV_CHIPSET_INFO_v1; + +#define NV_CHIPSET_INFO_VER_1 MAKE_NVAPI_VERSION(NV_CHIPSET_INFO_v1,1) +#define NV_CHIPSET_INFO_VER_2 MAKE_NVAPI_VERSION(NV_CHIPSET_INFO_v2,2) +#define NV_CHIPSET_INFO_VER_3 MAKE_NVAPI_VERSION(NV_CHIPSET_INFO_v3,3) +#define NV_CHIPSET_INFO_VER_4 MAKE_NVAPI_VERSION(NV_CHIPSET_INFO_v4,4) + +#define NV_CHIPSET_INFO NV_CHIPSET_INFO_v4 +#define NV_CHIPSET_INFO_VER NV_CHIPSET_INFO_VER_4 + +//! @} + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_SYS_GetChipSetInfo +// +//! This function returns information about the system's chipset. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 95 +//! +//! \retval NVAPI_INVALID_ARGUMENT pChipSetInfo is NULL. +//! \retval NVAPI_OK *pChipSetInfo is now set. +//! \retval NVAPI_INCOMPATIBLE_STRUCT_VERSION NV_CHIPSET_INFO version not compatible with driver. +//! \ingroup sysgeneral +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_SYS_GetChipSetInfo(NV_CHIPSET_INFO *pChipSetInfo); + + +//! \ingroup sysgeneral +//! Lid and dock information - used in NvAPI_GetLidDockInfo() +typedef struct +{ + NvU32 version; //! Structure version, constructed from the macro #NV_LID_DOCK_PARAMS_VER + NvU32 currentLidState; + NvU32 currentDockState; + NvU32 currentLidPolicy; + NvU32 currentDockPolicy; + NvU32 forcedLidMechanismPresent; + NvU32 forcedDockMechanismPresent; +}NV_LID_DOCK_PARAMS; + + +//! ingroup sysgeneral +#define NV_LID_DOCK_PARAMS_VER MAKE_NVAPI_VERSION(NV_LID_DOCK_PARAMS,1) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GetLidDockInfo +// +//! DESCRIPTION: This function returns the current lid and dock information. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 177 +//! +//! \retval ::NVAPI_OK +//! \retval ::NVAPI_ERROR +//! \retval ::NVAPI_NOT_SUPPORTED +//! \retval ::NVAPI_HANDLE_INVALIDATED +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! +//! \ingroup sysgeneral +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_SYS_GetLidAndDockInfo(NV_LID_DOCK_PARAMS *pLidAndDock); + + + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_SYS_GetDisplayIdFromGpuAndOutputId +// +//! DESCRIPTION: This API converts a Physical GPU handle and output ID to a +//! display ID. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] hPhysicalGpu Handle to the physical GPU +//! \param [in] outputId Connected display output ID on the +//! target GPU - must only have one bit set +//! \param [out] displayId Pointer to an NvU32 which contains +//! the display ID +//! +//! \retval ::NVAPI_OK - completed request +//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized +//! \retval ::NVAPI_ERROR - miscellaneous error occurred +//! \retval ::NVAPI_INVALID_ARGUMENT - Invalid input parameter. +//! +//! \ingroup sysgeneral +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_SYS_GetDisplayIdFromGpuAndOutputId(NvPhysicalGpuHandle hPhysicalGpu, NvU32 outputId, NvU32* displayId); + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_SYS_GetGpuAndOutputIdFromDisplayId +// +//! DESCRIPTION: This API converts a display ID to a Physical GPU handle and output ID. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] displayId Display ID of display to retrieve +//! GPU and outputId for +//! \param [out] hPhysicalGpu Handle to the physical GPU +//! \param [out] outputId ) Connected display output ID on the +//! target GPU will only have one bit set. +//! +//! \retval ::NVAPI_OK +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_ID_OUT_OF_RANGE The DisplayId corresponds to a +//! display which is not within the +//! normal outputId range. +//! \retval ::NVAPI_ERROR +//! \retval ::NVAPI_INVALID_ARGUMENT +//! +//! \ingroup sysgeneral +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_SYS_GetGpuAndOutputIdFromDisplayId(NvU32 displayId, NvPhysicalGpuHandle *hPhysicalGpu, NvU32 *outputId); + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION NAME: NvAPI_SYS_GetPhysicalGpuFromDisplayId +// +//! \code +//! DESCRIPTION: This API retrieves the Physical GPU handle of the connected display +//! +//! \since Release: 313 +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! PARAMETERS: displayId(IN) - Display ID of display to retrieve +//! GPU handle +//! hPhysicalGpu(OUT) - Handle to the physical GPU +//! +//! RETURN STATUS: +//! NVAPI_OK - completed request +//! NVAPI_API_NOT_INTIALIZED - NVAPI not initialized +//! NVAPI_ERROR - miscellaneous error occurred +//! NVAPI_INVALID_ARGUMENT - Invalid input parameter. +//! \endcode +//! \ingroup sysgeneral +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_SYS_GetPhysicalGpuFromDisplayId(NvU32 displayId, NvPhysicalGpuHandle *hPhysicalGpu); + +typedef struct _NV_DISPLAY_DRIVER_INFO +{ + NvU32 version; //!< Structure Version. + NvU32 driverVersion; //!< Contains the driver version after successful return. + NvAPI_ShortString szBuildBranch; //!< Contains the driver-branch string after successful return. + NvU32 bIsDCHDriver : 1; //!< Contains the driver DCH status after successful return. + //!< Value of 1 means that this is DCH driver. + //!< Value of 0 means that this is not a DCH driver (NVAPI may be unable to query the DCH status of the driver due to some registry API errors, in that case the API will return with NVAPI_ERROR) + NvU32 bIsNVIDIAStudioPackage : 1; //!< On successful return, this field provides information about whether the installed driver is from an NVIDIA Studio Driver package. + //!< Value of 1 means that this driver is from the NVIDIA Studio Driver package. + NvU32 bIsNVIDIAGameReadyPackage : 1; //!< On successful return, this field provides information about whether the installed driver is from an NVIDIA Game Ready Driver package. + //!< Value of 1 means that this driver is from the NVIDIA Game Ready Driver package. + NvU32 bIsNVIDIARTXProductionBranchPackage : 1; //!< On successful return, this field confirms whether the installed driver package is from an NVIDIA RTX Enterprise Production Branch which offers ISV certifications, long life-cycle support, regular security updates, and access to the same functionality as corresponding NVIDIA Studio Driver Packages (i.e., of the same driver version number). + //!< Value of 1 means that this driver is from the NVIDIA RTX Enterprise Production Branch package. + NvU32 bIsNVIDIARTXNewFeatureBranchPackage : 1; //!< On successful return, this field confirms whether the installed driver package is from an NVIDIA RTX New Feature Branch. + //!< This driver typically gives access to new features, bug fixes, new operating system support, and other driver enhancements offered between NVIDIA RTX Enterprise Production Branch releases. Support duration for NVIDIA RTX New Feature Branches is shorter than that for NVIDIA RTX Enterprise Production Branches. + //!< Value of 1 means that this driver is from the NVIDIA RTX New Feature Branch package. + NvU32 reserved : 27; //!< Reserved for future use. +} NV_DISPLAY_DRIVER_INFO_V1; + +#define NV_DISPLAY_DRIVER_INFO_VER1 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_INFO_V1, 1) +typedef NV_DISPLAY_DRIVER_INFO_V1 NV_DISPLAY_DRIVER_INFO; +#define NV_DISPLAY_DRIVER_INFO_VER NV_DISPLAY_DRIVER_INFO_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_SYS_GetDisplayDriverInfo +// +//! DESCRIPTION: This API will return information related to the NVIDIA Display Driver. +//! Note that out of the driver types - Studio, Game Ready, RTX Production Branch, RTX New Feature Branch - only one driver type can be available in system. +//! If NVAPI is unable to get the information of particular driver type, we report all flags as 0 (Unknown). +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 396 +//! +//! \param [inout] pDriverInfo - This structure will be filled with required information. +//! +//! \return This API can return any of the error codes enumerated in +//! #NvAPI_Status. If there are return error codes with specific +//! meaning for this API, they are listed below. +//! +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_SYS_GetDisplayDriverInfo(__inout NV_DISPLAY_DRIVER_INFO *pDriverInfo); + + +/*! + * Callback settings common to all client callbacks. + */ +typedef struct _NV_CLIENT_CALLBACK_SETTINGS_SUPER_V1 +{ + /*! + * [in] Generic callback parameter which will be passed to the callback. + */ + void* pCallbackParam; + + /*! + * Reserved bytes for future expansion. + */ + NvU8 rsvd[64]; +} NV_CLIENT_CALLBACK_SETTINGS_SUPER_V1; + +typedef NV_CLIENT_CALLBACK_SETTINGS_SUPER_V1 NV_GPU_CLIENT_CALLBACK_SETTINGS_SUPER_V1; + + +/*! + * Callback settings common to all periodic client callbacks. + */ +typedef struct _NV_GPU_CLIENT_PERIODIC_CALLBACK_SETTINGS_SUPER_V1 +{ + /*! + * [in] Super class data. + */ + NV_GPU_CLIENT_CALLBACK_SETTINGS_SUPER_V1 super; + + /*! + * [in] Minimum interval at which callback will be called. + * + * The callback may be invoked slower than this interval if underlying + * sampling rate does not align precisely to the provided period. + */ + NvU32 callbackPeriodms; + + /*! + * Reserved bytes for future expansion. + */ + NvU8 rsvd[64]; +} NV_GPU_CLIENT_PERIODIC_CALLBACK_SETTINGS_SUPER_V1; + +/*! + * Callback data common to all client callbacks. + */ +typedef struct _NV_GPU_CLIENT_CALLBACK_DATA_SUPER_V1 +{ + /*! + * [out] Generic callback parameter which was passed in at registration time. + */ + void* pCallbackParam; + + /*! + * Reserved bytes for future expansion. + */ + NvU8 rsvd[64]; +} NV_GPU_CLIENT_CALLBACK_DATA_SUPER_V1; + + +/*! + * Enumeration of different utilization domains + */ +typedef enum _NV_GPU_CLIENT_UTIL_DOMAIN_ID +{ + NV_GPU_CLIENT_UTIL_DOMAIN_GRAPHICS = 0, + NV_GPU_CLIENT_UTIL_DOMAIN_FRAME_BUFFER = 1, + NV_GPU_CLIENT_UTIL_DOMAIN_VIDEO = 2, + /*! + * Reserved for future use. + */ + NV_GPU_CLIENT_UTIL_DOMAIN_RSVD = 3, +} NV_GPU_CLIENT_UTIL_DOMAIN_ID; + +#define NV_GPU_CLIENT_UTIL_DOMAINS_MAX_V1 (4) + +/*! + * Data specific to a single utilization domain. + */ +typedef struct _NV_GPU_CLIENT_UTILIZATION_DATA_V1 +{ + /*! + * [out] Utilization domain identifier. + */ + NV_GPU_CLIENT_UTIL_DOMAIN_ID utilId; + + /*! + * [out] Percentage of time where the domain is considered busy since the + * last sample. Units of percent*100; i.e. 5000 = 50%. + */ + NvU32 utilizationPercent; + + /*! + * Reserved bytes for future expansion. + */ + NvU8 rsvd[61]; +} NV_GPU_CLIENT_UTILIZATION_DATA_V1; + +/*! + * Data passed back to callback registered with + * @ref NvAPI_GPU_ClientRegisterForUtilizationSampleUpdates. + */ +typedef struct _NV_GPU_CLIENT_CALLBACK_UTILIZATION_DATA_V1 +{ + /*! + * [out] Super struct. + */ + NV_GPU_CLIENT_CALLBACK_DATA_SUPER_V1 super; + + /*! + * [out] Number of valid entries in `utils` array. + */ + NvU32 numUtils; + + /*! + * [out] Time at which data was collected. Represented as elapsed + * microseconds since 00:00:00 UTC on January 1, 1970. + */ + NvU64 timestamp; + + /*! + * Reserved bytes for future expansion. + */ + NvU8 rsvd[64]; + + /*! + * [out] Status data for each utilization domain. + */ + NV_GPU_CLIENT_UTILIZATION_DATA_V1 utils[NV_GPU_CLIENT_UTIL_DOMAINS_MAX_V1]; +} NV_GPU_CLIENT_CALLBACK_UTILIZATION_DATA_V1; + +/*! + * Function prototype for a periodic utilization data callback that will be registered with NvAPI. + */ +typedef void (__cdecl *NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_V1)(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_CLIENT_CALLBACK_UTILIZATION_DATA_V1* pData); + +/*! + * Data required to register a periodic callback for utilization data. + */ +typedef struct _NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_SETTINGS_V1 +{ + /*! + * [in] Structure Version, must always be first. + */ + NvU32 version; + + /*! + * [in] Generic callback settings. Some data within will be passed to the + * callback when invoked. + */ + NV_GPU_CLIENT_PERIODIC_CALLBACK_SETTINGS_SUPER_V1 super; + + /*! + * [in] Callback. Pass in NULL or nullptr to indicate request to unregister. + */ + NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_V1 callback; + + /*! + * Reserved bytes for future expansion. + */ + NvU8 rsvd[64]; +} NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_SETTINGS_V1; + +#define NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_SETTINGS_VER1 MAKE_NVAPI_VERSION(NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_SETTINGS_V1, 1) +typedef NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_SETTINGS_V1 NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_SETTINGS; +#define NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_SETTINGS_VER NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_SETTINGS_VER1 + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_ClientRegisterForUtilizationSampleUpdates +// +//! \fn NvAPI_GPU_ClientRegisterForUtilizationSampleUpdates() +//! \code +//! DESCRIPTION: Register to receive samples of utilization data periodically +//! via a function pointer callback. +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! \since Release 455 +//! +//! \return NVAPI_OK - Registration was successful +//! NVAPI_API_NOT_INITIALIZED - NVAPI not initialized +//! NVAPI_INCOMPATIBLE_STRUCT_VERSION - Invalid structure version specified +//! NVAPI_INVALID_CONFIGURATION - Invalid software environment configuration +//! NVAPI_TIMEOUT - Registration request timed out +//! NVAPI_ERROR - Unknown underlying error +//! +//! \endcode +//! \ingroup nvtopps +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_ClientRegisterForUtilizationSampleUpdates(__in NvPhysicalGpuHandle hPhysicalGpu, __in NV_GPU_CLIENT_UTILIZATION_PERIODIC_CALLBACK_SETTINGS* pCallbackSettings); + + + + + +#ifdef __cplusplus +}; //extern "C" { + +#endif + +#pragma pack(pop) + +#endif // _NVAPI_H + +#include"nvapi_lite_salend.h" diff --git a/thirdparty/nvapi/nvapi_lite_common.h b/thirdparty/nvapi/nvapi_lite_common.h new file mode 100644 index 0000000..a4ddb1f --- /dev/null +++ b/thirdparty/nvapi/nvapi_lite_common.h @@ -0,0 +1,648 @@ +/************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ +#pragma once +#include"nvapi_lite_salstart.h" +#pragma pack(push,8) +#ifdef __cplusplus +extern "C" { +#endif +#if (defined(WIN32) || defined(_WIN32)) && defined(_MSC_VER) && (_MSC_VER > 1399) && !defined(NVAPI_INTERNAL) && !defined(NVAPI_DEPRECATED_OLD) +#ifndef __nvapi_deprecated_function +#define __nvapi_deprecated_function(message) __declspec(deprecated(message)) +#endif +#ifndef __nvapi_deprecated_datatype +#define __nvapi_deprecated_datatype(FirstRelease) __declspec(deprecated("Do not use this data type - it is deprecated in release " #FirstRelease ".")) +#endif +#else +#ifndef __nvapi_deprecated_function +#define __nvapi_deprecated_function(message) +#endif +#ifndef __nvapi_deprecated_datatype +#define __nvapi_deprecated_datatype(FirstRelease) +#endif +#endif + + +/* 64-bit types for compilers that support them, plus some obsolete variants */ +#if defined(__GNUC__) || defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(__ghs__) || defined(_WIN64) +typedef unsigned long long NvU64; /* 0 to 18446744073709551615 */ +typedef long long NvS64; /* -9223372036854775808 to 9223372036854775807 */ +#else +typedef unsigned __int64 NvU64; /* 0 to 18446744073709551615 */ +typedef __int64 NvS64; /* -9223372036854775808 to 9223372036854775807 */ +#endif + +// mac os 32-bit still needs this +#if (defined(macintosh) || defined(__APPLE__)) && !defined(__LP64__) +typedef signed long NvS32; /* -2147483648 to 2147483647 */ +#else +typedef signed int NvS32; /* -2147483648 to 2147483647 */ +#endif + +#ifndef __unix +// mac os 32-bit still needs this +#if ( (defined(macintosh) && defined(__LP64__) && (__NVAPI_RESERVED0__)) || \ + (!defined(macintosh) && defined(__NVAPI_RESERVED0__)) ) +typedef unsigned int NvU32; /* 0 to 4294967295 */ +#else +typedef unsigned long NvU32; /* 0 to 4294967295 */ +#endif +#else +typedef unsigned int NvU32; /* 0 to 4294967295 */ +#endif + +typedef unsigned long temp_NvU32; /* 0 to 4294967295 */ +typedef signed short NvS16; +typedef unsigned short NvU16; +typedef unsigned char NvU8; +typedef signed char NvS8; +typedef float NvF32; + +/*! + * Macro to convert NvU32 to NvF32. + */ +#define NvU32TONvF32(_pData) *(NvF32 *)(_pData) +/*! + * Macro to convert NvF32 to NvU32. + */ +#define NvF32TONvU32(_pData) *(NvU32 *)(_pData) + +/* Boolean type */ +typedef NvU8 NvBool; +#define NV_TRUE ((NvBool)(0 == 0)) +#define NV_FALSE ((NvBool)(0 != 0)) + +typedef struct _NV_RECT +{ + NvU32 left; + NvU32 top; + NvU32 right; + NvU32 bottom; +} NV_RECT; + + +#define NV_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name + +//! \addtogroup nvapihandles +//! NVAPI Handles - These handles are retrieved from various calls and passed in to others in NvAPI +//! These are meant to be opaque types. Do not assume they correspond to indices, HDCs, +//! display indexes or anything else. +//! +//! Most handles remain valid until a display re-configuration (display mode set) or GPU +//! reconfiguration (going into or out of SLI modes) occurs. If NVAPI_HANDLE_INVALIDATED +//! is received by an app, it should discard all handles, and re-enumerate them. +//! @{ +NV_DECLARE_HANDLE(NvLogicalGpuHandle); //!< One or more physical GPUs acting in concert (SLI) +NV_DECLARE_HANDLE(NvPhysicalGpuHandle); //!< A single physical GPU +NV_DECLARE_HANDLE(NvDisplayHandle); //!< Display Device driven by NVIDIA GPU(s) (an attached display) +NV_DECLARE_HANDLE(NvMonitorHandle); //!< Monitor handle +NV_DECLARE_HANDLE(NvUnAttachedDisplayHandle); //!< Unattached Display Device driven by NVIDIA GPU(s) +NV_DECLARE_HANDLE(NvVisualComputingDeviceHandle); //!< A handle to a Visual Computing Device +NV_DECLARE_HANDLE(NvEventHandle); //!< A handle to an event registration instance + + +NV_DECLARE_HANDLE(NvHICHandle); //!< A handle to a Host Interface Card +NV_DECLARE_HANDLE(NvGSyncDeviceHandle); //!< A handle to a Sync device +NV_DECLARE_HANDLE(NvVioHandle); //!< A handle to an SDI device +NV_DECLARE_HANDLE(NvTransitionHandle); //!< A handle to address a single transition request +NV_DECLARE_HANDLE(NvAudioHandle); //!< NVIDIA HD Audio Device +NV_DECLARE_HANDLE(Nv3DVPContextHandle); //!< A handle for a 3D Vision Pro (3DVP) context +NV_DECLARE_HANDLE(Nv3DVPTransceiverHandle); //!< A handle for a 3DVP RF transceiver +NV_DECLARE_HANDLE(Nv3DVPGlassesHandle); //!< A handle for a pair of 3DVP RF shutter glasses + +typedef void* StereoHandle; //!< A stereo handle, that corresponds to the device interface + +NV_DECLARE_HANDLE(NvSourceHandle); //!< Unique source handle on the system +NV_DECLARE_HANDLE(NvTargetHandle); //!< Unique target handle on the system +NV_DECLARE_HANDLE(NVDX_SwapChainHandle); //!< DirectX SwapChain objects +static const NVDX_SwapChainHandle NVDX_SWAPCHAIN_NONE = 0; +NV_DECLARE_HANDLE(NvPresentBarrierClientHandle); //!< PresentBarrier client object +//! @} + +//! \ingroup nvapihandles +//! @{ +#define NVAPI_DEFAULT_HANDLE 0 +#define NV_BIT(x) (1 << (x)) +//! @} + + + +//! \addtogroup nvapitypes +//! @{ +#define NVAPI_GENERIC_STRING_MAX 4096 +#define NVAPI_LONG_STRING_MAX 256 +#define NVAPI_SHORT_STRING_MAX 64 + +typedef struct +{ + NvS32 sX; + NvS32 sY; + NvS32 sWidth; + NvS32 sHeight; +} NvSBox; + +#ifndef NvGUID_Defined +#define NvGUID_Defined + +typedef struct +{ + NvU32 data1; + NvU16 data2; + NvU16 data3; + NvU8 data4[8]; +} NvGUID, NvLUID; + + +#endif //#ifndef NvGUID_Defined +#define NVAPI_MAX_PHYSICAL_GPUS 64 + + +#define NVAPI_MAX_PHYSICAL_BRIDGES 100 +#define NVAPI_PHYSICAL_GPUS 32 +#define NVAPI_MAX_LOGICAL_GPUS 64 +#define NVAPI_MAX_AVAILABLE_GPU_TOPOLOGIES 256 +#define NVAPI_MAX_AVAILABLE_SLI_GROUPS 256 +#define NVAPI_MAX_GPU_TOPOLOGIES NVAPI_MAX_PHYSICAL_GPUS +#define NVAPI_MAX_GPU_PER_TOPOLOGY 8 +#define NVAPI_MAX_DISPLAY_HEADS 2 +#define NVAPI_ADVANCED_DISPLAY_HEADS 4 +#define NVAPI_MAX_DISPLAYS NVAPI_PHYSICAL_GPUS * NVAPI_ADVANCED_DISPLAY_HEADS +#define NVAPI_MAX_ACPI_IDS 16 +#define NVAPI_MAX_VIEW_MODES 8 + + +#define NVAPI_SYSTEM_MAX_HWBCS 128 +#define NVAPI_SYSTEM_HWBC_INVALID_ID 0xffffffff + +#define NVAPI_SYSTEM_MAX_DISPLAYS NVAPI_MAX_PHYSICAL_GPUS * NV_MAX_HEADS +#define NV_MAX_HEADS 4 //!< Maximum heads, each with NVAPI_DESKTOP_RES resolution +#define NVAPI_MAX_HEADS_PER_GPU 32 +#define NV_MAX_VID_STREAMS 4 //!< Maximum number of input video streams, each with a #NVAPI_VIDEO_SRC_INFO +#define NV_MAX_VID_STREAMS_EX 20 //!< Increasing MAX no. of input video streams, each with a #NVAPI_VIDEO_SRC_INFO +#define NV_MAX_VID_PROFILES 4 //!< Maximum number of output video profiles supported + +#define NVAPI_MAX_AUDIO_DEVICES 16 + + +typedef char NvAPI_String[NVAPI_GENERIC_STRING_MAX]; +typedef char NvAPI_LongString[NVAPI_LONG_STRING_MAX]; +typedef char NvAPI_ShortString[NVAPI_SHORT_STRING_MAX]; +typedef NvU16 NvAPI_UnicodeShortString[NVAPI_SHORT_STRING_MAX]; +//! @} + + +// ========================================================================================= +//! NvAPI Version Definition \n +//! Maintain per structure specific version define using the MAKE_NVAPI_VERSION macro. \n +//! Usage: #define NV_GENLOCK_STATUS_VER MAKE_NVAPI_VERSION(NV_GENLOCK_STATUS, 1) +//! \ingroup nvapitypes +// ========================================================================================= +#define MAKE_NVAPI_VERSION(typeName,ver) (NvU32)(sizeof(typeName) | ((ver)<<16)) + +//! \ingroup nvapitypes +#define GET_NVAPI_VERSION(ver) (NvU32)((ver)>>16) + +//! \ingroup nvapitypes +#define GET_NVAPI_SIZE(ver) (NvU32)((ver) & 0xffff) + + +// ==================================================== +//! NvAPI Status Values +//! All NvAPI functions return one of these codes. +//! \ingroup nvapistatus +// ==================================================== + + +typedef enum _NvAPI_Status +{ + NVAPI_OK = 0, //!< Success. Request is completed. + NVAPI_ERROR = -1, //!< Generic error + NVAPI_LIBRARY_NOT_FOUND = -2, //!< NVAPI support library cannot be loaded. + NVAPI_NO_IMPLEMENTATION = -3, //!< not implemented in current driver installation + NVAPI_API_NOT_INITIALIZED = -4, //!< NvAPI_Initialize has not been called (successfully) + NVAPI_INVALID_ARGUMENT = -5, //!< The argument/parameter value is not valid or NULL. + NVAPI_NVIDIA_DEVICE_NOT_FOUND = -6, //!< No NVIDIA display driver, or NVIDIA GPU driving a display, was found. + NVAPI_END_ENUMERATION = -7, //!< No more items to enumerate + NVAPI_INVALID_HANDLE = -8, //!< Invalid handle + NVAPI_INCOMPATIBLE_STRUCT_VERSION = -9, //!< An argument's structure version is not supported + NVAPI_HANDLE_INVALIDATED = -10, //!< The handle is no longer valid (likely due to GPU or display re-configuration) + NVAPI_OPENGL_CONTEXT_NOT_CURRENT = -11, //!< No NVIDIA OpenGL context is current (but needs to be) + NVAPI_INVALID_POINTER = -14, //!< An invalid pointer, usually NULL, was passed as a parameter + NVAPI_NO_GL_EXPERT = -12, //!< OpenGL Expert is not supported by the current drivers + NVAPI_INSTRUMENTATION_DISABLED = -13, //!< OpenGL Expert is supported, but driver instrumentation is currently disabled + NVAPI_NO_GL_NSIGHT = -15, //!< OpenGL does not support Nsight + + NVAPI_EXPECTED_LOGICAL_GPU_HANDLE = -100, //!< Expected a logical GPU handle for one or more parameters + NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE = -101, //!< Expected a physical GPU handle for one or more parameters + NVAPI_EXPECTED_DISPLAY_HANDLE = -102, //!< Expected an NV display handle for one or more parameters + NVAPI_INVALID_COMBINATION = -103, //!< The combination of parameters is not valid. + NVAPI_NOT_SUPPORTED = -104, //!< Requested feature is not supported in the selected GPU + NVAPI_PORTID_NOT_FOUND = -105, //!< No port ID was found for the I2C transaction + NVAPI_EXPECTED_UNATTACHED_DISPLAY_HANDLE = -106, //!< Expected an unattached display handle as one of the input parameters. + NVAPI_INVALID_PERF_LEVEL = -107, //!< Invalid perf level + NVAPI_DEVICE_BUSY = -108, //!< Device is busy; request not fulfilled + NVAPI_NV_PERSIST_FILE_NOT_FOUND = -109, //!< NV persist file is not found + NVAPI_PERSIST_DATA_NOT_FOUND = -110, //!< NV persist data is not found + NVAPI_EXPECTED_TV_DISPLAY = -111, //!< Expected a TV output display + NVAPI_EXPECTED_TV_DISPLAY_ON_DCONNECTOR = -112, //!< Expected a TV output on the D Connector - HDTV_EIAJ4120. + NVAPI_NO_ACTIVE_SLI_TOPOLOGY = -113, //!< SLI is not active on this device. + NVAPI_SLI_RENDERING_MODE_NOTALLOWED = -114, //!< Setup of SLI rendering mode is not possible right now. + NVAPI_EXPECTED_DIGITAL_FLAT_PANEL = -115, //!< Expected a digital flat panel. + NVAPI_ARGUMENT_EXCEED_MAX_SIZE = -116, //!< Argument exceeds the expected size. + NVAPI_DEVICE_SWITCHING_NOT_ALLOWED = -117, //!< Inhibit is ON due to one of the flags in NV_GPU_DISPLAY_CHANGE_INHIBIT or SLI active. + NVAPI_TESTING_CLOCKS_NOT_SUPPORTED = -118, //!< Testing of clocks is not supported. + NVAPI_UNKNOWN_UNDERSCAN_CONFIG = -119, //!< The specified underscan config is from an unknown source (e.g. INF) + NVAPI_TIMEOUT_RECONFIGURING_GPU_TOPO = -120, //!< Timeout while reconfiguring GPUs + NVAPI_DATA_NOT_FOUND = -121, //!< Requested data was not found + NVAPI_EXPECTED_ANALOG_DISPLAY = -122, //!< Expected an analog display + NVAPI_NO_VIDLINK = -123, //!< No SLI video bridge is present + NVAPI_REQUIRES_REBOOT = -124, //!< NVAPI requires a reboot for the settings to take effect + NVAPI_INVALID_HYBRID_MODE = -125, //!< The function is not supported with the current Hybrid mode. + NVAPI_MIXED_TARGET_TYPES = -126, //!< The target types are not all the same + NVAPI_SYSWOW64_NOT_SUPPORTED = -127, //!< The function is not supported from 32-bit on a 64-bit system. + NVAPI_IMPLICIT_SET_GPU_TOPOLOGY_CHANGE_NOT_ALLOWED = -128, //!< There is no implicit GPU topology active. Use NVAPI_SetHybridMode to change topology. + NVAPI_REQUEST_USER_TO_CLOSE_NON_MIGRATABLE_APPS = -129, //!< Prompt the user to close all non-migratable applications. + NVAPI_OUT_OF_MEMORY = -130, //!< Could not allocate sufficient memory to complete the call. + NVAPI_WAS_STILL_DRAWING = -131, //!< The previous operation that is transferring information to or from this surface is incomplete. + NVAPI_FILE_NOT_FOUND = -132, //!< The file was not found. + NVAPI_TOO_MANY_UNIQUE_STATE_OBJECTS = -133, //!< There are too many unique instances of a particular type of state object. + NVAPI_INVALID_CALL = -134, //!< The method call is invalid. For example, a method's parameter may not be a valid pointer. + NVAPI_D3D10_1_LIBRARY_NOT_FOUND = -135, //!< d3d10_1.dll cannot be loaded. + NVAPI_FUNCTION_NOT_FOUND = -136, //!< Couldn't find the function in the loaded DLL. + NVAPI_INVALID_USER_PRIVILEGE = -137, //!< The application will require Administrator privileges to access this API. + //!< The application can be elevated to a higher permission level by selecting "Run as Administrator". + NVAPI_EXPECTED_NON_PRIMARY_DISPLAY_HANDLE = -138, //!< The handle corresponds to GDIPrimary. + NVAPI_EXPECTED_COMPUTE_GPU_HANDLE = -139, //!< Setting Physx GPU requires that the GPU is compute-capable. + NVAPI_STEREO_NOT_INITIALIZED = -140, //!< The Stereo part of NVAPI failed to initialize completely. Check if the stereo driver is installed. + NVAPI_STEREO_REGISTRY_ACCESS_FAILED = -141, //!< Access to stereo-related registry keys or values has failed. + NVAPI_STEREO_REGISTRY_PROFILE_TYPE_NOT_SUPPORTED = -142, //!< The given registry profile type is not supported. + NVAPI_STEREO_REGISTRY_VALUE_NOT_SUPPORTED = -143, //!< The given registry value is not supported. + NVAPI_STEREO_NOT_ENABLED = -144, //!< Stereo is not enabled and the function needed it to execute completely. + NVAPI_STEREO_NOT_TURNED_ON = -145, //!< Stereo is not turned on and the function needed it to execute completely. + NVAPI_STEREO_INVALID_DEVICE_INTERFACE = -146, //!< Invalid device interface. + NVAPI_STEREO_PARAMETER_OUT_OF_RANGE = -147, //!< Separation percentage or JPEG image capture quality is out of [0-100] range. + NVAPI_STEREO_FRUSTUM_ADJUST_MODE_NOT_SUPPORTED = -148, //!< The given frustum adjust mode is not supported. + NVAPI_TOPO_NOT_POSSIBLE = -149, //!< The mosaic topology is not possible given the current state of the hardware. + NVAPI_MODE_CHANGE_FAILED = -150, //!< An attempt to do a display resolution mode change has failed. + NVAPI_D3D11_LIBRARY_NOT_FOUND = -151, //!< d3d11.dll/d3d11_beta.dll cannot be loaded. + NVAPI_INVALID_ADDRESS = -152, //!< Address is outside of valid range. + NVAPI_STRING_TOO_SMALL = -153, //!< The pre-allocated string is too small to hold the result. + NVAPI_MATCHING_DEVICE_NOT_FOUND = -154, //!< The input does not match any of the available devices. + NVAPI_DRIVER_RUNNING = -155, //!< Driver is running. + NVAPI_DRIVER_NOTRUNNING = -156, //!< Driver is not running. + NVAPI_ERROR_DRIVER_RELOAD_REQUIRED = -157, //!< A driver reload is required to apply these settings. + NVAPI_SET_NOT_ALLOWED = -158, //!< Intended setting is not allowed. + NVAPI_ADVANCED_DISPLAY_TOPOLOGY_REQUIRED = -159, //!< Information can't be returned due to "advanced display topology". + NVAPI_SETTING_NOT_FOUND = -160, //!< Setting is not found. + NVAPI_SETTING_SIZE_TOO_LARGE = -161, //!< Setting size is too large. + NVAPI_TOO_MANY_SETTINGS_IN_PROFILE = -162, //!< There are too many settings for a profile. + NVAPI_PROFILE_NOT_FOUND = -163, //!< Profile is not found. + NVAPI_PROFILE_NAME_IN_USE = -164, //!< Profile name is duplicated. + NVAPI_PROFILE_NAME_EMPTY = -165, //!< Profile name is empty. + NVAPI_EXECUTABLE_NOT_FOUND = -166, //!< Application not found in the Profile. + NVAPI_EXECUTABLE_ALREADY_IN_USE = -167, //!< Application already exists in the other profile. + NVAPI_DATATYPE_MISMATCH = -168, //!< Data Type mismatch + NVAPI_PROFILE_REMOVED = -169, //!< The profile passed as parameter has been removed and is no longer valid. + NVAPI_UNREGISTERED_RESOURCE = -170, //!< An unregistered resource was passed as a parameter. + NVAPI_ID_OUT_OF_RANGE = -171, //!< The DisplayId corresponds to a display which is not within the normal outputId range. + NVAPI_DISPLAYCONFIG_VALIDATION_FAILED = -172, //!< Display topology is not valid so the driver cannot do a mode set on this configuration. + NVAPI_DPMST_CHANGED = -173, //!< Display Port Multi-Stream topology has been changed. + NVAPI_INSUFFICIENT_BUFFER = -174, //!< Input buffer is insufficient to hold the contents. + NVAPI_ACCESS_DENIED = -175, //!< No access to the caller. + NVAPI_MOSAIC_NOT_ACTIVE = -176, //!< The requested action cannot be performed without Mosaic being enabled. + NVAPI_SHARE_RESOURCE_RELOCATED = -177, //!< The surface is relocated away from video memory. + NVAPI_REQUEST_USER_TO_DISABLE_DWM = -178, //!< The user should disable DWM before calling NvAPI. + NVAPI_D3D_DEVICE_LOST = -179, //!< D3D device status is D3DERR_DEVICELOST or D3DERR_DEVICENOTRESET - the user has to reset the device. + NVAPI_INVALID_CONFIGURATION = -180, //!< The requested action cannot be performed in the current state. + NVAPI_STEREO_HANDSHAKE_NOT_DONE = -181, //!< Call failed as stereo handshake not completed. + NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS = -182, //!< The path provided was too short to determine the correct NVDRS_APPLICATION + NVAPI_DEFAULT_STEREO_PROFILE_IS_NOT_DEFINED = -183, //!< Default stereo profile is not currently defined + NVAPI_DEFAULT_STEREO_PROFILE_DOES_NOT_EXIST = -184, //!< Default stereo profile does not exist + NVAPI_CLUSTER_ALREADY_EXISTS = -185, //!< A cluster is already defined with the given configuration. + NVAPI_DPMST_DISPLAY_ID_EXPECTED = -186, //!< The input display id is not that of a multi stream enabled connector or a display device in a multi stream topology + NVAPI_INVALID_DISPLAY_ID = -187, //!< The input display id is not valid or the monitor associated to it does not support the current operation + NVAPI_STREAM_IS_OUT_OF_SYNC = -188, //!< While playing secure audio stream, stream goes out of sync + NVAPI_INCOMPATIBLE_AUDIO_DRIVER = -189, //!< Older audio driver version than required + NVAPI_VALUE_ALREADY_SET = -190, //!< Value already set, setting again not allowed. + NVAPI_TIMEOUT = -191, //!< Requested operation timed out + NVAPI_GPU_WORKSTATION_FEATURE_INCOMPLETE = -192, //!< The requested workstation feature set has incomplete driver internal allocation resources + NVAPI_STEREO_INIT_ACTIVATION_NOT_DONE = -193, //!< Call failed because InitActivation was not called. + NVAPI_SYNC_NOT_ACTIVE = -194, //!< The requested action cannot be performed without Sync being enabled. + NVAPI_SYNC_MASTER_NOT_FOUND = -195, //!< The requested action cannot be performed without Sync Master being enabled. + NVAPI_INVALID_SYNC_TOPOLOGY = -196, //!< Invalid displays passed in the NV_GSYNC_DISPLAY pointer. + NVAPI_ECID_SIGN_ALGO_UNSUPPORTED = -197, //!< The specified signing algorithm is not supported. Either an incorrect value was entered or the current installed driver/hardware does not support the input value. + NVAPI_ECID_KEY_VERIFICATION_FAILED = -198, //!< The encrypted public key verification has failed. + NVAPI_FIRMWARE_OUT_OF_DATE = -199, //!< The device's firmware is out of date. + NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED = -200, //!< The device's firmware is not supported. + NVAPI_LICENSE_CALLER_AUTHENTICATION_FAILED = -201, //!< The caller is not authorized to modify the License. + NVAPI_D3D_DEVICE_NOT_REGISTERED = -202, //!< The user tried to use a deferred context without registering the device first + NVAPI_RESOURCE_NOT_ACQUIRED = -203, //!< Head or SourceId was not reserved for the VR Display before doing the Modeset or the dedicated display. + NVAPI_TIMING_NOT_SUPPORTED = -204, //!< Provided timing is not supported. + NVAPI_HDCP_ENCRYPTION_FAILED = -205, //!< HDCP Encryption Failed for the device. Would be applicable when the device is HDCP Capable. + NVAPI_PCLK_LIMITATION_FAILED = -206, //!< Provided mode is over sink device pclk limitation. + NVAPI_NO_CONNECTOR_FOUND = -207, //!< No connector on GPU found. + NVAPI_HDCP_DISABLED = -208, //!< When a non-HDCP capable HMD is connected, we would inform user by this code. + NVAPI_API_IN_USE = -209, //!< Atleast an API is still being called + NVAPI_NVIDIA_DISPLAY_NOT_FOUND = -210, //!< No display found on Nvidia GPU(s). + NVAPI_PRIV_SEC_VIOLATION = -211, //!< Priv security violation, improper access to a secured register. + NVAPI_INCORRECT_VENDOR = -212, //!< NVAPI cannot be called by this vendor + NVAPI_DISPLAY_IN_USE = -213, //!< DirectMode Display is already in use + NVAPI_UNSUPPORTED_CONFIG_NON_HDCP_HMD = -214, //!< The Config is having Non-NVidia GPU with Non-HDCP HMD connected + NVAPI_MAX_DISPLAY_LIMIT_REACHED = -215, //!< GPU's Max Display Limit has Reached + NVAPI_INVALID_DIRECT_MODE_DISPLAY = -216, //!< DirectMode not Enabled on the Display + NVAPI_GPU_IN_DEBUG_MODE = -217, //!< GPU is in debug mode, OC is NOT allowed. + NVAPI_D3D_CONTEXT_NOT_FOUND = -218, //!< No NvAPI context was found for this D3D object + NVAPI_STEREO_VERSION_MISMATCH = -219, //!< there is version mismatch between stereo driver and dx driver + NVAPI_GPU_NOT_POWERED = -220, //!< GPU is not powered and so the request cannot be completed. + NVAPI_ERROR_DRIVER_RELOAD_IN_PROGRESS = -221, //!< The display driver update in progress. + NVAPI_WAIT_FOR_HW_RESOURCE = -222, //!< Wait for HW resources allocation + NVAPI_REQUIRE_FURTHER_HDCP_ACTION = -223, //!< operation requires further HDCP action + NVAPI_DISPLAY_MUX_TRANSITION_FAILED = -224, //!< Dynamic Mux transition failure + NVAPI_INVALID_DSC_VERSION = -225, //!< Invalid DSC version + NVAPI_INVALID_DSC_SLICECOUNT = -226, //!< Invalid DSC slice count + NVAPI_INVALID_DSC_OUTPUT_BPP = -227, //!< Invalid DSC output BPP + NVAPI_FAILED_TO_LOAD_FROM_DRIVER_STORE = -228, //!< There was an error while loading nvapi.dll from the driver store. + NVAPI_NO_VULKAN = -229, //!< OpenGL does not export Vulkan fake extensions + NVAPI_REQUEST_PENDING = -230, //!< A request for NvTOPPs telemetry CData has already been made and is pending a response. + NVAPI_RESOURCE_IN_USE = -231, //!< Operation cannot be performed because the resource is in use. + NVAPI_INVALID_IMAGE = -232, //!< Device kernel image is invalid + NVAPI_INVALID_PTX = -233, //!< PTX JIT compilation failed + NVAPI_NVLINK_UNCORRECTABLE = -234, //!< Uncorrectable NVLink error was detected during the execution + NVAPI_JIT_COMPILER_NOT_FOUND = -235, //!< PTX JIT compiler library was not found. + NVAPI_INVALID_SOURCE = -236, //!< Device kernel source is invalid. + NVAPI_ILLEGAL_INSTRUCTION = -237, //!< While executing a kernel, the device encountered an illegal instruction. + NVAPI_INVALID_PC = -238, //!< While executing a kernel, the device program counter wrapped its address space + NVAPI_LAUNCH_FAILED = -239, //!< An exception occurred on the device while executing a kernel + NVAPI_NOT_PERMITTED = -240, //!< Attempted operation is not permitted. +} NvAPI_Status; + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_SYS_GetDriverAndBranchVersion +// +//! DESCRIPTION: This API returns display driver version and driver-branch string. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [out] pDriverVersion Contains the driver version after successful return. +//! \param [out] szBuildBranchString Contains the driver-branch string after successful return. +//! +//! \retval ::NVAPI_INVALID_ARGUMENT: either pDriverVersion is NULL or enum index too big +//! \retval ::NVAPI_OK - completed request +//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized +//! \retval ::NVAPI_ERROR - miscellaneous error occurred +//! +//! \ingroup driverapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_SYS_GetDriverAndBranchVersion(NvU32* pDriverVersion, NvAPI_ShortString szBuildBranchString); +//! \ingroup driverapi +//! Used in NvAPI_GPU_GetMemoryInfo(). +typedef struct +{ + NvU32 version; //!< Version info + NvU32 dedicatedVideoMemory; //!< Size(in kb) of the physical framebuffer. + NvU32 availableDedicatedVideoMemory; //!< Size(in kb) of the available physical framebuffer for allocating video memory surfaces. + NvU32 systemVideoMemory; //!< Size(in kb) of system memory the driver allocates at load time. + NvU32 sharedSystemMemory; //!< Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations. + +} NV_DISPLAY_DRIVER_MEMORY_INFO_V1; + + +//! \ingroup driverapi +//! Used in NvAPI_GPU_GetMemoryInfo(). +typedef struct +{ + NvU32 version; //!< Version info + NvU32 dedicatedVideoMemory; //!< Size(in kb) of the physical framebuffer. + NvU32 availableDedicatedVideoMemory; //!< Size(in kb) of the available physical framebuffer for allocating video memory surfaces. + NvU32 systemVideoMemory; //!< Size(in kb) of system memory the driver allocates at load time. + NvU32 sharedSystemMemory; //!< Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations. + NvU32 curAvailableDedicatedVideoMemory; //!< Size(in kb) of the current available physical framebuffer for allocating video memory surfaces. + +} NV_DISPLAY_DRIVER_MEMORY_INFO_V2; + +//! \ingroup driverapi +//! Used in NvAPI_GPU_GetMemoryInfo(). +typedef struct +{ + NvU32 version; //!< Version info + NvU32 dedicatedVideoMemory; //!< Size(in kb) of the physical framebuffer. + NvU32 availableDedicatedVideoMemory; //!< Size(in kb) of the available physical framebuffer for allocating video memory surfaces. + NvU32 systemVideoMemory; //!< Size(in kb) of system memory the driver allocates at load time. + NvU32 sharedSystemMemory; //!< Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations. + NvU32 curAvailableDedicatedVideoMemory; //!< Size(in kb) of the current available physical framebuffer for allocating video memory surfaces. + NvU32 dedicatedVideoMemoryEvictionsSize; //!< Size(in kb) of the total size of memory released as a result of the evictions. + NvU32 dedicatedVideoMemoryEvictionCount; //!< Indicates the number of eviction events that caused an allocation to be removed from dedicated video memory to free GPU + //!< video memory to make room for other allocations. +} NV_DISPLAY_DRIVER_MEMORY_INFO_V3; + +//! \ingroup driverapi +typedef NV_DISPLAY_DRIVER_MEMORY_INFO_V3 NV_DISPLAY_DRIVER_MEMORY_INFO; + +//! \ingroup driverapi +//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V1 +#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_1 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V1,1) + +//! \ingroup driverapi +//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V2 +#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_2 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V2,2) + +//! \ingroup driverapi +//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V3 +#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_3 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V3,3) + +//! \ingroup driverapi +#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER NV_DISPLAY_DRIVER_MEMORY_INFO_VER_3 + + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetMemoryInfo +// +//! DESCRIPTION: This function retrieves the available driver memory footprint for the specified GPU. +//! If the GPU is in TCC Mode, only dedicatedVideoMemory will be returned in pMemoryInfo (NV_DISPLAY_DRIVER_MEMORY_INFO). +//! +//! \deprecated Do not use this function - it is deprecated in release 520. Instead, use NvAPI_GPU_GetMemoryInfoEx. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 177 +//! +//! \param [in] hPhysicalGpu Handle of the physical GPU for which the memory information is to be extracted. +//! \param [out] pMemoryInfo The memory footprint available in the driver. See NV_DISPLAY_DRIVER_MEMORY_INFO. +//! +//! \retval NVAPI_INVALID_ARGUMENT pMemoryInfo is NULL. +//! \retval NVAPI_OK Call successful. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_INCOMPATIBLE_STRUCT_VERSION NV_DISPLAY_DRIVER_MEMORY_INFO structure version mismatch. +//! +//! \ingroup driverapi +/////////////////////////////////////////////////////////////////////////////// +__nvapi_deprecated_function("Do not use this function - it is deprecated in release 520. Instead, use NvAPI_GPU_GetMemoryInfoEx.") +NVAPI_INTERFACE NvAPI_GPU_GetMemoryInfo(NvPhysicalGpuHandle hPhysicalGpu, NV_DISPLAY_DRIVER_MEMORY_INFO *pMemoryInfo); + + +//! \ingroup driverapi +//! Used in NvAPI_GPU_GetMemoryInfoEx(). +typedef struct +{ + NvU32 version; //!< Structure version + NvU64 dedicatedVideoMemory; //!< Size(in bytes) of the physical framebuffer. + NvU64 availableDedicatedVideoMemory; //!< Size(in bytes) of the available physical framebuffer for allocating video memory surfaces. + NvU64 systemVideoMemory; //!< Size(in bytes) of system memory the driver allocates at load time. + NvU64 sharedSystemMemory; //!< Size(in bytes) of shared system memory that driver is allowed to commit for surfaces across all allocations. + NvU64 curAvailableDedicatedVideoMemory; //!< Size(in bytes) of the current available physical framebuffer for allocating video memory surfaces. + NvU64 dedicatedVideoMemoryEvictionsSize; //!< Size(in bytes) of the total size of memory released as a result of the evictions. + NvU64 dedicatedVideoMemoryEvictionCount; //!< Indicates the number of eviction events that caused an allocation to be removed from dedicated video memory to free GPU + //!< video memory to make room for other allocations. + NvU64 dedicatedVideoMemoryPromotionsSize; //!< Size(in bytes) of the total size of memory allocated as a result of the promotions. + NvU64 dedicatedVideoMemoryPromotionCount; //!< Indicates the number of promotion events that caused an allocation to be promoted to dedicated video memory +} NV_GPU_MEMORY_INFO_EX_V1; + +//! \ingroup driverapi +typedef NV_GPU_MEMORY_INFO_EX_V1 NV_GPU_MEMORY_INFO_EX; + +//! \ingroup driverapi +//! Macro for constructing the version field of NV_GPU_MEMORY_INFO_EX_V1 +#define NV_GPU_MEMORY_INFO_EX_VER_1 MAKE_NVAPI_VERSION(NV_GPU_MEMORY_INFO_EX_V1,1) + +//! \ingroup driverapi +#define NV_GPU_MEMORY_INFO_EX_VER NV_GPU_MEMORY_INFO_EX_VER_1 + + + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_GPU_GetMemoryInfoEx +// +//! DESCRIPTION: This function retrieves the available driver memory footprint for the specified GPU. +//! If the GPU is in TCC Mode, only dedicatedVideoMemory will be returned in pMemoryInfo (NV_GPU_MEMORY_INFO_EX). +//! +//! SUPPORTED OS: Windows 10 and higher +//! +//! +//! TCC_SUPPORTED +//! +//! \since Release: 520 +//! +//! \param [in] hPhysicalGpu Handle of the physical GPU for which the memory information is to be extracted. +//! \param [out] pMemoryInfo The memory footprint available in the driver. See NV_GPU_MEMORY_INFO_EX. +//! +//! \retval NVAPI_INVALID_ARGUMENT pMemoryInfo is NULL. +//! \retval NVAPI_OK Call successful. +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found. +//! \retval NVAPI_INCOMPATIBLE_STRUCT_VERSION NV_GPU_MEMORY_INFO_EX structure version mismatch. +//! +//! \ingroup driverapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_GPU_GetMemoryInfoEx(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_MEMORY_INFO_EX *pMemoryInfo); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_EnumPhysicalGPUs +// +//! This function returns an array of physical GPU handles. +//! Each handle represents a physical GPU present in the system. +//! That GPU may be part of an SLI configuration, or may not be visible to the OS directly. +//! +//! At least one GPU must be present in the system and running an NVIDIA display driver. +//! +//! The array nvGPUHandle will be filled with physical GPU handle values. The returned +//! gpuCount determines how many entries in the array are valid. +//! +//! \note In drivers older than 105.00, all physical GPU handles get invalidated on a +//! modeset. So the calling applications need to renum the handles after every modeset.\n +//! With drivers 105.00 and up, all physical GPU handles are constant. +//! Physical GPU handles are constant as long as the GPUs are not physically moved and +//! the SBIOS VGA order is unchanged. +//! +//! For GPU handles in TCC MODE please use NvAPI_EnumTCCPhysicalGPUs() +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \par Introduced in +//! \since Release: 80 +//! +//! \retval NVAPI_INVALID_ARGUMENT nvGPUHandle or pGpuCount is NULL +//! \retval NVAPI_OK One or more handles were returned +//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found +//! \ingroup gpu +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_EnumPhysicalGPUs(NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); +#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) + +NV_DECLARE_HANDLE(NVDX_ObjectHandle); // DX Objects +static const NVDX_ObjectHandle NVDX_OBJECT_NONE = 0; + +#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) +#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_GetObjectHandleForResource +// +//! DESCRIPTION: This API gets a handle to a resource. +//! +//! \param [in] pDev The ID3D11Device, ID3D10Device or IDirect3DDevice9 or ID3D11DeviceContext to use +//! \param [in] pResource The ID3D11Resource, ID3D10Resource or IDirect3DResource9 from which +//! we want the NvAPI handle +//! \param [out] pHandle A handle to the resource +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \return ::NVAPI_OK if the handle was populated. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_GetObjectHandleForResource( + IUnknown *pDevice, + IUnknown *pResource, + NVDX_ObjectHandle *pHandle); + + +#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) || defined(__d3d12_h__) + +#include"nvapi_lite_salend.h" +#ifdef __cplusplus +} +#endif +#pragma pack(pop) diff --git a/thirdparty/nvapi/nvapi_lite_d3dext.h b/thirdparty/nvapi/nvapi_lite_d3dext.h new file mode 100644 index 0000000..fbc97c4 --- /dev/null +++ b/thirdparty/nvapi/nvapi_lite_d3dext.h @@ -0,0 +1,191 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ +#pragma once +#include"nvapi_lite_salstart.h" +#include"nvapi_lite_common.h" +#pragma pack(push,8) +#ifdef __cplusplus +extern "C" { +#endif +#if defined(__cplusplus) && (defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) +//! \ingroup dx +//! D3D_FEATURE_LEVEL supported - used in NvAPI_D3D11_CreateDevice() and NvAPI_D3D11_CreateDeviceAndSwapChain() +typedef enum +{ + NVAPI_DEVICE_FEATURE_LEVEL_NULL = -1, + NVAPI_DEVICE_FEATURE_LEVEL_10_0 = 0, + NVAPI_DEVICE_FEATURE_LEVEL_10_0_PLUS = 1, + NVAPI_DEVICE_FEATURE_LEVEL_10_1 = 2, + NVAPI_DEVICE_FEATURE_LEVEL_11_0 = 3, +} NVAPI_DEVICE_FEATURE_LEVEL; + +#endif //defined(__cplusplus) && (defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)) +#if defined(__cplusplus) && defined(__d3d11_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateDevice +// +//! DESCRIPTION: This function tries to create a DirectX 11 device. If the call fails (if we are running +//! on pre-DirectX 11 hardware), depending on the type of hardware it will try to create a DirectX 10.1 OR DirectX 10.0+ +//! OR DirectX 10.0 device. The function call is the same as D3D11CreateDevice(), but with an extra +//! argument (D3D_FEATURE_LEVEL supported by the device) that the function fills in. This argument +//! can contain -1 (NVAPI_DEVICE_FEATURE_LEVEL_NULL), if the requested featureLevel is less than DirecX 10.0. +//! +//! NOTE: When NvAPI_D3D11_CreateDevice is called with 10+ feature level we have an issue on few set of +//! tesla hardware (G80/G84/G86/G92/G94/G96) which does not support all feature level 10+ functionality +//! e.g. calling driver with mismatch between RenderTarget and Depth Buffer. App developers should +//! take into consideration such limitation when using NVAPI on such tesla hardwares. +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [in] pAdapter +//! \param [in] DriverType +//! \param [in] Software +//! \param [in] Flags +//! \param [in] *pFeatureLevels +//! \param [in] FeatureLevels +//! \param [in] SDKVersion +//! \param [in] **ppDevice +//! \param [in] *pFeatureLevel +//! \param [in] **ppImmediateContext +//! \param [in] *pSupportedLevel D3D_FEATURE_LEVEL supported +//! +//! \return NVAPI_OK if the createDevice call succeeded. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_CreateDevice(IDXGIAdapter* pAdapter, + D3D_DRIVER_TYPE DriverType, + HMODULE Software, + UINT Flags, + CONST D3D_FEATURE_LEVEL *pFeatureLevels, + UINT FeatureLevels, + UINT SDKVersion, + ID3D11Device **ppDevice, + D3D_FEATURE_LEVEL *pFeatureLevel, + ID3D11DeviceContext **ppImmediateContext, + NVAPI_DEVICE_FEATURE_LEVEL *pSupportedLevel); + + +#endif //defined(__cplusplus) && defined(__d3d11_h__) +#if defined(__cplusplus) && defined(__d3d11_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_CreateDeviceAndSwapChain +// +//! DESCRIPTION: This function tries to create a DirectX 11 device and swap chain. If the call fails (if we are +//! running on pre=DirectX 11 hardware), depending on the type of hardware it will try to create a DirectX 10.1 OR +//! DirectX 10.0+ OR DirectX 10.0 device. The function call is the same as D3D11CreateDeviceAndSwapChain, +//! but with an extra argument (D3D_FEATURE_LEVEL supported by the device) that the function fills +//! in. This argument can contain -1 (NVAPI_DEVICE_FEATURE_LEVEL_NULL), if the requested featureLevel +//! is less than DirectX 10.0. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [in] pAdapter +//! \param [in] DriverType +//! \param [in] Software +//! \param [in] Flags +//! \param [in] *pFeatureLevels +//! \param [in] FeatureLevels +//! \param [in] SDKVersion +//! \param [in] *pSwapChainDesc +//! \param [in] **ppSwapChain +//! \param [in] **ppDevice +//! \param [in] *pFeatureLevel +//! \param [in] **ppImmediateContext +//! \param [in] *pSupportedLevel D3D_FEATURE_LEVEL supported +//! +//!return NVAPI_OK if the createDevice with swap chain call succeeded. +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_CreateDeviceAndSwapChain(IDXGIAdapter* pAdapter, + D3D_DRIVER_TYPE DriverType, + HMODULE Software, + UINT Flags, + CONST D3D_FEATURE_LEVEL *pFeatureLevels, + UINT FeatureLevels, + UINT SDKVersion, + CONST DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, + IDXGISwapChain **ppSwapChain, + ID3D11Device **ppDevice, + D3D_FEATURE_LEVEL *pFeatureLevel, + ID3D11DeviceContext **ppImmediateContext, + NVAPI_DEVICE_FEATURE_LEVEL *pSupportedLevel); + + + +#endif //defined(__cplusplus) && defined(__d3d11_h__) +#if defined(__cplusplus) && defined(__d3d11_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D11_SetDepthBoundsTest +// +//! DESCRIPTION: This function enables/disables the depth bounds test +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] pDeviceOrContext The device or device context to set depth bounds test +//! \param [in] bEnable Enable(non-zero)/disable(zero) the depth bounds test +//! \param [in] fMinDepth The minimum depth for depth bounds test +//! \param [in] fMaxDepth The maximum depth for depth bounds test +//! The valid values for fMinDepth and fMaxDepth +//! are such that 0 <= fMinDepth <= fMaxDepth <= 1 +//! +//! \return ::NVAPI_OK if the depth bounds test was correcly enabled or disabled +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D11_SetDepthBoundsTest(IUnknown* pDeviceOrContext, + NvU32 bEnable, + float fMinDepth, + float fMaxDepth); + +#endif //defined(__cplusplus) && defined(__d3d11_h__) + +#include"nvapi_lite_salend.h" +#ifdef __cplusplus +} +#endif +#pragma pack(pop) diff --git a/thirdparty/nvapi/nvapi_lite_salend.h b/thirdparty/nvapi/nvapi_lite_salend.h new file mode 100644 index 0000000..e1efc51 --- /dev/null +++ b/thirdparty/nvapi/nvapi_lite_salend.h @@ -0,0 +1,816 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ +#ifndef __NVAPI_EMPTY_SAL +#ifdef __nvapi_undef__ecount + #undef __ecount + #undef __nvapi_undef__ecount +#endif +#ifdef __nvapi_undef__bcount + #undef __bcount + #undef __nvapi_undef__bcount +#endif +#ifdef __nvapi_undef__in + #undef __in + #undef __nvapi_undef__in +#endif +#ifdef __nvapi_undef__in_ecount + #undef __in_ecount + #undef __nvapi_undef__in_ecount +#endif +#ifdef __nvapi_undef__in_bcount + #undef __in_bcount + #undef __nvapi_undef__in_bcount +#endif +#ifdef __nvapi_undef__in_z + #undef __in_z + #undef __nvapi_undef__in_z +#endif +#ifdef __nvapi_undef__in_ecount_z + #undef __in_ecount_z + #undef __nvapi_undef__in_ecount_z +#endif +#ifdef __nvapi_undef__in_bcount_z + #undef __in_bcount_z + #undef __nvapi_undef__in_bcount_z +#endif +#ifdef __nvapi_undef__in_nz + #undef __in_nz + #undef __nvapi_undef__in_nz +#endif +#ifdef __nvapi_undef__in_ecount_nz + #undef __in_ecount_nz + #undef __nvapi_undef__in_ecount_nz +#endif +#ifdef __nvapi_undef__in_bcount_nz + #undef __in_bcount_nz + #undef __nvapi_undef__in_bcount_nz +#endif +#ifdef __nvapi_undef__out + #undef __out + #undef __nvapi_undef__out +#endif +#ifdef __nvapi_undef__out_ecount + #undef __out_ecount + #undef __nvapi_undef__out_ecount +#endif +#ifdef __nvapi_undef__out_bcount + #undef __out_bcount + #undef __nvapi_undef__out_bcount +#endif +#ifdef __nvapi_undef__out_ecount_part + #undef __out_ecount_part + #undef __nvapi_undef__out_ecount_part +#endif +#ifdef __nvapi_undef__out_bcount_part + #undef __out_bcount_part + #undef __nvapi_undef__out_bcount_part +#endif +#ifdef __nvapi_undef__out_ecount_full + #undef __out_ecount_full + #undef __nvapi_undef__out_ecount_full +#endif +#ifdef __nvapi_undef__out_bcount_full + #undef __out_bcount_full + #undef __nvapi_undef__out_bcount_full +#endif +#ifdef __nvapi_undef__out_z + #undef __out_z + #undef __nvapi_undef__out_z +#endif +#ifdef __nvapi_undef__out_z_opt + #undef __out_z_opt + #undef __nvapi_undef__out_z_opt +#endif +#ifdef __nvapi_undef__out_ecount_z + #undef __out_ecount_z + #undef __nvapi_undef__out_ecount_z +#endif +#ifdef __nvapi_undef__out_bcount_z + #undef __out_bcount_z + #undef __nvapi_undef__out_bcount_z +#endif +#ifdef __nvapi_undef__out_ecount_part_z + #undef __out_ecount_part_z + #undef __nvapi_undef__out_ecount_part_z +#endif +#ifdef __nvapi_undef__out_bcount_part_z + #undef __out_bcount_part_z + #undef __nvapi_undef__out_bcount_part_z +#endif +#ifdef __nvapi_undef__out_ecount_full_z + #undef __out_ecount_full_z + #undef __nvapi_undef__out_ecount_full_z +#endif +#ifdef __nvapi_undef__out_bcount_full_z + #undef __out_bcount_full_z + #undef __nvapi_undef__out_bcount_full_z +#endif +#ifdef __nvapi_undef__out_nz + #undef __out_nz + #undef __nvapi_undef__out_nz +#endif +#ifdef __nvapi_undef__out_nz_opt + #undef __out_nz_opt + #undef __nvapi_undef__out_nz_opt +#endif +#ifdef __nvapi_undef__out_ecount_nz + #undef __out_ecount_nz + #undef __nvapi_undef__out_ecount_nz +#endif +#ifdef __nvapi_undef__out_bcount_nz + #undef __out_bcount_nz + #undef __nvapi_undef__out_bcount_nz +#endif +#ifdef __nvapi_undef__inout + #undef __inout + #undef __nvapi_undef__inout +#endif +#ifdef __nvapi_undef__inout_ecount + #undef __inout_ecount + #undef __nvapi_undef__inout_ecount +#endif +#ifdef __nvapi_undef__inout_bcount + #undef __inout_bcount + #undef __nvapi_undef__inout_bcount +#endif +#ifdef __nvapi_undef__inout_ecount_part + #undef __inout_ecount_part + #undef __nvapi_undef__inout_ecount_part +#endif +#ifdef __nvapi_undef__inout_bcount_part + #undef __inout_bcount_part + #undef __nvapi_undef__inout_bcount_part +#endif +#ifdef __nvapi_undef__inout_ecount_full + #undef __inout_ecount_full + #undef __nvapi_undef__inout_ecount_full +#endif +#ifdef __nvapi_undef__inout_bcount_full + #undef __inout_bcount_full + #undef __nvapi_undef__inout_bcount_full +#endif +#ifdef __nvapi_undef__inout_z + #undef __inout_z + #undef __nvapi_undef__inout_z +#endif +#ifdef __nvapi_undef__inout_ecount_z + #undef __inout_ecount_z + #undef __nvapi_undef__inout_ecount_z +#endif +#ifdef __nvapi_undef__inout_bcount_z + #undef __inout_bcount_z + #undef __nvapi_undef__inout_bcount_z +#endif +#ifdef __nvapi_undef__inout_nz + #undef __inout_nz + #undef __nvapi_undef__inout_nz +#endif +#ifdef __nvapi_undef__inout_ecount_nz + #undef __inout_ecount_nz + #undef __nvapi_undef__inout_ecount_nz +#endif +#ifdef __nvapi_undef__inout_bcount_nz + #undef __inout_bcount_nz + #undef __nvapi_undef__inout_bcount_nz +#endif +#ifdef __nvapi_undef__ecount_opt + #undef __ecount_opt + #undef __nvapi_undef__ecount_opt +#endif +#ifdef __nvapi_undef__bcount_opt + #undef __bcount_opt + #undef __nvapi_undef__bcount_opt +#endif +#ifdef __nvapi_undef__in_opt + #undef __in_opt + #undef __nvapi_undef__in_opt +#endif +#ifdef __nvapi_undef__in_ecount_opt + #undef __in_ecount_opt + #undef __nvapi_undef__in_ecount_opt +#endif +#ifdef __nvapi_undef__in_bcount_opt + #undef __in_bcount_opt + #undef __nvapi_undef__in_bcount_opt +#endif +#ifdef __nvapi_undef__in_z_opt + #undef __in_z_opt + #undef __nvapi_undef__in_z_opt +#endif +#ifdef __nvapi_undef__in_ecount_z_opt + #undef __in_ecount_z_opt + #undef __nvapi_undef__in_ecount_z_opt +#endif +#ifdef __nvapi_undef__in_bcount_z_opt + #undef __in_bcount_z_opt + #undef __nvapi_undef__in_bcount_z_opt +#endif +#ifdef __nvapi_undef__in_nz_opt + #undef __in_nz_opt + #undef __nvapi_undef__in_nz_opt +#endif +#ifdef __nvapi_undef__in_ecount_nz_opt + #undef __in_ecount_nz_opt + #undef __nvapi_undef__in_ecount_nz_opt +#endif +#ifdef __nvapi_undef__in_bcount_nz_opt + #undef __in_bcount_nz_opt + #undef __nvapi_undef__in_bcount_nz_opt +#endif +#ifdef __nvapi_undef__out_opt + #undef __out_opt + #undef __nvapi_undef__out_opt +#endif +#ifdef __nvapi_undef__out_ecount_opt + #undef __out_ecount_opt + #undef __nvapi_undef__out_ecount_opt +#endif +#ifdef __nvapi_undef__out_bcount_opt + #undef __out_bcount_opt + #undef __nvapi_undef__out_bcount_opt +#endif +#ifdef __nvapi_undef__out_ecount_part_opt + #undef __out_ecount_part_opt + #undef __nvapi_undef__out_ecount_part_opt +#endif +#ifdef __nvapi_undef__out_bcount_part_opt + #undef __out_bcount_part_opt + #undef __nvapi_undef__out_bcount_part_opt +#endif +#ifdef __nvapi_undef__out_ecount_full_opt + #undef __out_ecount_full_opt + #undef __nvapi_undef__out_ecount_full_opt +#endif +#ifdef __nvapi_undef__out_bcount_full_opt + #undef __out_bcount_full_opt + #undef __nvapi_undef__out_bcount_full_opt +#endif +#ifdef __nvapi_undef__out_ecount_z_opt + #undef __out_ecount_z_opt + #undef __nvapi_undef__out_ecount_z_opt +#endif +#ifdef __nvapi_undef__out_bcount_z_opt + #undef __out_bcount_z_opt + #undef __nvapi_undef__out_bcount_z_opt +#endif +#ifdef __nvapi_undef__out_ecount_part_z_opt + #undef __out_ecount_part_z_opt + #undef __nvapi_undef__out_ecount_part_z_opt +#endif +#ifdef __nvapi_undef__out_bcount_part_z_opt + #undef __out_bcount_part_z_opt + #undef __nvapi_undef__out_bcount_part_z_opt +#endif +#ifdef __nvapi_undef__out_ecount_full_z_opt + #undef __out_ecount_full_z_opt + #undef __nvapi_undef__out_ecount_full_z_opt +#endif +#ifdef __nvapi_undef__out_bcount_full_z_opt + #undef __out_bcount_full_z_opt + #undef __nvapi_undef__out_bcount_full_z_opt +#endif +#ifdef __nvapi_undef__out_ecount_nz_opt + #undef __out_ecount_nz_opt + #undef __nvapi_undef__out_ecount_nz_opt +#endif +#ifdef __nvapi_undef__out_bcount_nz_opt + #undef __out_bcount_nz_opt + #undef __nvapi_undef__out_bcount_nz_opt +#endif +#ifdef __nvapi_undef__inout_opt + #undef __inout_opt + #undef __nvapi_undef__inout_opt +#endif +#ifdef __nvapi_undef__inout_ecount_opt + #undef __inout_ecount_opt + #undef __nvapi_undef__inout_ecount_opt +#endif +#ifdef __nvapi_undef__inout_bcount_opt + #undef __inout_bcount_opt + #undef __nvapi_undef__inout_bcount_opt +#endif +#ifdef __nvapi_undef__inout_ecount_part_opt + #undef __inout_ecount_part_opt + #undef __nvapi_undef__inout_ecount_part_opt +#endif +#ifdef __nvapi_undef__inout_bcount_part_opt + #undef __inout_bcount_part_opt + #undef __nvapi_undef__inout_bcount_part_opt +#endif +#ifdef __nvapi_undef__inout_ecount_full_opt + #undef __inout_ecount_full_opt + #undef __nvapi_undef__inout_ecount_full_opt +#endif +#ifdef __nvapi_undef__inout_bcount_full_opt + #undef __inout_bcount_full_opt + #undef __nvapi_undef__inout_bcount_full_opt +#endif +#ifdef __nvapi_undef__inout_z_opt + #undef __inout_z_opt + #undef __nvapi_undef__inout_z_opt +#endif +#ifdef __nvapi_undef__inout_ecount_z_opt + #undef __inout_ecount_z_opt + #undef __nvapi_undef__inout_ecount_z_opt +#endif +#ifdef __nvapi_undef__inout_ecount_z_opt + #undef __inout_ecount_z_opt + #undef __nvapi_undef__inout_ecount_z_opt +#endif +#ifdef __nvapi_undef__inout_bcount_z_opt + #undef __inout_bcount_z_opt + #undef __nvapi_undef__inout_bcount_z_opt +#endif +#ifdef __nvapi_undef__inout_nz_opt + #undef __inout_nz_opt + #undef __nvapi_undef__inout_nz_opt +#endif +#ifdef __nvapi_undef__inout_ecount_nz_opt + #undef __inout_ecount_nz_opt + #undef __nvapi_undef__inout_ecount_nz_opt +#endif +#ifdef __nvapi_undef__inout_bcount_nz_opt + #undef __inout_bcount_nz_opt + #undef __nvapi_undef__inout_bcount_nz_opt +#endif +#ifdef __nvapi_undef__deref_ecount + #undef __deref_ecount + #undef __nvapi_undef__deref_ecount +#endif +#ifdef __nvapi_undef__deref_bcount + #undef __deref_bcount + #undef __nvapi_undef__deref_bcount +#endif +#ifdef __nvapi_undef__deref_out + #undef __deref_out + #undef __nvapi_undef__deref_out +#endif +#ifdef __nvapi_undef__deref_out_ecount + #undef __deref_out_ecount + #undef __nvapi_undef__deref_out_ecount +#endif +#ifdef __nvapi_undef__deref_out_bcount + #undef __deref_out_bcount + #undef __nvapi_undef__deref_out_bcount +#endif +#ifdef __nvapi_undef__deref_out_ecount_part + #undef __deref_out_ecount_part + #undef __nvapi_undef__deref_out_ecount_part +#endif +#ifdef __nvapi_undef__deref_out_bcount_part + #undef __deref_out_bcount_part + #undef __nvapi_undef__deref_out_bcount_part +#endif +#ifdef __nvapi_undef__deref_out_ecount_full + #undef __deref_out_ecount_full + #undef __nvapi_undef__deref_out_ecount_full +#endif +#ifdef __nvapi_undef__deref_out_bcount_full + #undef __deref_out_bcount_full + #undef __nvapi_undef__deref_out_bcount_full +#endif +#ifdef __nvapi_undef__deref_out_z + #undef __deref_out_z + #undef __nvapi_undef__deref_out_z +#endif +#ifdef __nvapi_undef__deref_out_ecount_z + #undef __deref_out_ecount_z + #undef __nvapi_undef__deref_out_ecount_z +#endif +#ifdef __nvapi_undef__deref_out_bcount_z + #undef __deref_out_bcount_z + #undef __nvapi_undef__deref_out_bcount_z +#endif +#ifdef __nvapi_undef__deref_out_nz + #undef __deref_out_nz + #undef __nvapi_undef__deref_out_nz +#endif +#ifdef __nvapi_undef__deref_out_ecount_nz + #undef __deref_out_ecount_nz + #undef __nvapi_undef__deref_out_ecount_nz +#endif +#ifdef __nvapi_undef__deref_out_bcount_nz + #undef __deref_out_bcount_nz + #undef __nvapi_undef__deref_out_bcount_nz +#endif +#ifdef __nvapi_undef__deref_inout + #undef __deref_inout + #undef __nvapi_undef__deref_inout +#endif +#ifdef __nvapi_undef__deref_inout_z + #undef __deref_inout_z + #undef __nvapi_undef__deref_inout_z +#endif +#ifdef __nvapi_undef__deref_inout_ecount + #undef __deref_inout_ecount + #undef __nvapi_undef__deref_inout_ecount +#endif +#ifdef __nvapi_undef__deref_inout_bcount + #undef __deref_inout_bcount + #undef __nvapi_undef__deref_inout_bcount +#endif +#ifdef __nvapi_undef__deref_inout_ecount_part + #undef __deref_inout_ecount_part + #undef __nvapi_undef__deref_inout_ecount_part +#endif +#ifdef __nvapi_undef__deref_inout_bcount_part + #undef __deref_inout_bcount_part + #undef __nvapi_undef__deref_inout_bcount_part +#endif +#ifdef __nvapi_undef__deref_inout_ecount_full + #undef __deref_inout_ecount_full + #undef __nvapi_undef__deref_inout_ecount_full +#endif +#ifdef __nvapi_undef__deref_inout_bcount_full + #undef __deref_inout_bcount_full + #undef __nvapi_undef__deref_inout_bcount_full +#endif +#ifdef __nvapi_undef__deref_inout_z + #undef __deref_inout_z + #undef __nvapi_undef__deref_inout_z +#endif +#ifdef __nvapi_undef__deref_inout_ecount_z + #undef __deref_inout_ecount_z + #undef __nvapi_undef__deref_inout_ecount_z +#endif +#ifdef __nvapi_undef__deref_inout_bcount_z + #undef __deref_inout_bcount_z + #undef __nvapi_undef__deref_inout_bcount_z +#endif +#ifdef __nvapi_undef__deref_inout_nz + #undef __deref_inout_nz + #undef __nvapi_undef__deref_inout_nz +#endif +#ifdef __nvapi_undef__deref_inout_ecount_nz + #undef __deref_inout_ecount_nz + #undef __nvapi_undef__deref_inout_ecount_nz +#endif +#ifdef __nvapi_undef__deref_inout_bcount_nz + #undef __deref_inout_bcount_nz + #undef __nvapi_undef__deref_inout_bcount_nz +#endif +#ifdef __nvapi_undef__deref_ecount_opt + #undef __deref_ecount_opt + #undef __nvapi_undef__deref_ecount_opt +#endif +#ifdef __nvapi_undef__deref_bcount_opt + #undef __deref_bcount_opt + #undef __nvapi_undef__deref_bcount_opt +#endif +#ifdef __nvapi_undef__deref_out_opt + #undef __deref_out_opt + #undef __nvapi_undef__deref_out_opt +#endif +#ifdef __nvapi_undef__deref_out_ecount_opt + #undef __deref_out_ecount_opt + #undef __nvapi_undef__deref_out_ecount_opt +#endif +#ifdef __nvapi_undef__deref_out_bcount_opt + #undef __deref_out_bcount_opt + #undef __nvapi_undef__deref_out_bcount_opt +#endif +#ifdef __nvapi_undef__deref_out_ecount_part_opt + #undef __deref_out_ecount_part_opt + #undef __nvapi_undef__deref_out_ecount_part_opt +#endif +#ifdef __nvapi_undef__deref_out_bcount_part_opt + #undef __deref_out_bcount_part_opt + #undef __nvapi_undef__deref_out_bcount_part_opt +#endif +#ifdef __nvapi_undef__deref_out_ecount_full_opt + #undef __deref_out_ecount_full_opt + #undef __nvapi_undef__deref_out_ecount_full_opt +#endif +#ifdef __nvapi_undef__deref_out_bcount_full_opt + #undef __deref_out_bcount_full_opt + #undef __nvapi_undef__deref_out_bcount_full_opt +#endif +#ifdef __nvapi_undef__deref_out_z_opt + #undef __deref_out_z_opt + #undef __nvapi_undef__deref_out_z_opt +#endif +#ifdef __nvapi_undef__deref_out_ecount_z_opt + #undef __deref_out_ecount_z_opt + #undef __nvapi_undef__deref_out_ecount_z_opt +#endif +#ifdef __nvapi_undef__deref_out_bcount_z_opt + #undef __deref_out_bcount_z_opt + #undef __nvapi_undef__deref_out_bcount_z_opt +#endif +#ifdef __nvapi_undef__deref_out_nz_opt + #undef __deref_out_nz_opt + #undef __nvapi_undef__deref_out_nz_opt +#endif +#ifdef __nvapi_undef__deref_out_ecount_nz_opt + #undef __deref_out_ecount_nz_opt + #undef __nvapi_undef__deref_out_ecount_nz_opt +#endif +#ifdef __nvapi_undef__deref_out_bcount_nz_opt + #undef __deref_out_bcount_nz_opt + #undef __nvapi_undef__deref_out_bcount_nz_opt +#endif +#ifdef __nvapi_undef__deref_inout_opt + #undef __deref_inout_opt + #undef __nvapi_undef__deref_inout_opt +#endif +#ifdef __nvapi_undef__deref_inout_ecount_opt + #undef __deref_inout_ecount_opt + #undef __nvapi_undef__deref_inout_ecount_opt +#endif +#ifdef __nvapi_undef__deref_inout_bcount_opt + #undef __deref_inout_bcount_opt + #undef __nvapi_undef__deref_inout_bcount_opt +#endif +#ifdef __nvapi_undef__deref_inout_ecount_part_opt + #undef __deref_inout_ecount_part_opt + #undef __nvapi_undef__deref_inout_ecount_part_opt +#endif +#ifdef __nvapi_undef__deref_inout_bcount_part_opt + #undef __deref_inout_bcount_part_opt + #undef __nvapi_undef__deref_inout_bcount_part_opt +#endif +#ifdef __nvapi_undef__deref_inout_ecount_full_opt + #undef __deref_inout_ecount_full_opt + #undef __nvapi_undef__deref_inout_ecount_full_opt +#endif +#ifdef __nvapi_undef__deref_inout_bcount_full_opt + #undef __deref_inout_bcount_full_opt + #undef __nvapi_undef__deref_inout_bcount_full_opt +#endif +#ifdef __nvapi_undef__deref_inout_z_opt + #undef __deref_inout_z_opt + #undef __nvapi_undef__deref_inout_z_opt +#endif +#ifdef __nvapi_undef__deref_inout_ecount_z_opt + #undef __deref_inout_ecount_z_opt + #undef __nvapi_undef__deref_inout_ecount_z_opt +#endif +#ifdef __nvapi_undef__deref_inout_bcount_z_opt + #undef __deref_inout_bcount_z_opt + #undef __nvapi_undef__deref_inout_bcount_z_opt +#endif +#ifdef __nvapi_undef__deref_inout_nz_opt + #undef __deref_inout_nz_opt + #undef __nvapi_undef__deref_inout_nz_opt +#endif +#ifdef __nvapi_undef__deref_inout_ecount_nz_opt + #undef __deref_inout_ecount_nz_opt + #undef __nvapi_undef__deref_inout_ecount_nz_opt +#endif +#ifdef __nvapi_undef__deref_inout_bcount_nz_opt + #undef __deref_inout_bcount_nz_opt + #undef __nvapi_undef__deref_inout_bcount_nz_opt +#endif +#ifdef __nvapi_undef__deref_opt_ecount + #undef __deref_opt_ecount + #undef __nvapi_undef__deref_opt_ecount +#endif +#ifdef __nvapi_undef__deref_opt_bcount + #undef __deref_opt_bcount + #undef __nvapi_undef__deref_opt_bcount +#endif +#ifdef __nvapi_undef__deref_opt_out + #undef __deref_opt_out + #undef __nvapi_undef__deref_opt_out +#endif +#ifdef __nvapi_undef__deref_opt_out_z + #undef __deref_opt_out_z + #undef __nvapi_undef__deref_opt_out_z +#endif +#ifdef __nvapi_undef__deref_opt_out_ecount + #undef __deref_opt_out_ecount + #undef __nvapi_undef__deref_opt_out_ecount +#endif +#ifdef __nvapi_undef__deref_opt_out_bcount + #undef __deref_opt_out_bcount + #undef __nvapi_undef__deref_opt_out_bcount +#endif +#ifdef __nvapi_undef__deref_opt_out_ecount_part + #undef __deref_opt_out_ecount_part + #undef __nvapi_undef__deref_opt_out_ecount_part +#endif +#ifdef __nvapi_undef__deref_opt_out_bcount_part + #undef __deref_opt_out_bcount_part + #undef __nvapi_undef__deref_opt_out_bcount_part +#endif +#ifdef __nvapi_undef__deref_opt_out_ecount_full + #undef __deref_opt_out_ecount_full + #undef __nvapi_undef__deref_opt_out_ecount_full +#endif +#ifdef __nvapi_undef__deref_opt_out_bcount_full + #undef __deref_opt_out_bcount_full + #undef __nvapi_undef__deref_opt_out_bcount_full +#endif +#ifdef __nvapi_undef__deref_opt_inout + #undef __deref_opt_inout + #undef __nvapi_undef__deref_opt_inout +#endif +#ifdef __nvapi_undef__deref_opt_inout_ecount + #undef __deref_opt_inout_ecount + #undef __nvapi_undef__deref_opt_inout_ecount +#endif +#ifdef __nvapi_undef__deref_opt_inout_bcount + #undef __deref_opt_inout_bcount + #undef __nvapi_undef__deref_opt_inout_bcount +#endif +#ifdef __nvapi_undef__deref_opt_inout_ecount_part + #undef __deref_opt_inout_ecount_part + #undef __nvapi_undef__deref_opt_inout_ecount_part +#endif +#ifdef __nvapi_undef__deref_opt_inout_bcount_part + #undef __deref_opt_inout_bcount_part + #undef __nvapi_undef__deref_opt_inout_bcount_part +#endif +#ifdef __nvapi_undef__deref_opt_inout_ecount_full + #undef __deref_opt_inout_ecount_full + #undef __nvapi_undef__deref_opt_inout_ecount_full +#endif +#ifdef __nvapi_undef__deref_opt_inout_bcount_full + #undef __deref_opt_inout_bcount_full + #undef __nvapi_undef__deref_opt_inout_bcount_full +#endif +#ifdef __nvapi_undef__deref_opt_inout_z + #undef __deref_opt_inout_z + #undef __nvapi_undef__deref_opt_inout_z +#endif +#ifdef __nvapi_undef__deref_opt_inout_ecount_z + #undef __deref_opt_inout_ecount_z + #undef __nvapi_undef__deref_opt_inout_ecount_z +#endif +#ifdef __nvapi_undef__deref_opt_inout_bcount_z + #undef __deref_opt_inout_bcount_z + #undef __nvapi_undef__deref_opt_inout_bcount_z +#endif +#ifdef __nvapi_undef__deref_opt_inout_nz + #undef __deref_opt_inout_nz + #undef __nvapi_undef__deref_opt_inout_nz +#endif +#ifdef __nvapi_undef__deref_opt_inout_ecount_nz + #undef __deref_opt_inout_ecount_nz + #undef __nvapi_undef__deref_opt_inout_ecount_nz +#endif +#ifdef __nvapi_undef__deref_opt_inout_bcount_nz + #undef __deref_opt_inout_bcount_nz + #undef __nvapi_undef__deref_opt_inout_bcount_nz +#endif +#ifdef __nvapi_undef__deref_opt_ecount_opt + #undef __deref_opt_ecount_opt + #undef __nvapi_undef__deref_opt_ecount_opt +#endif +#ifdef __nvapi_undef__deref_opt_bcount_opt + #undef __deref_opt_bcount_opt + #undef __nvapi_undef__deref_opt_bcount_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_opt + #undef __deref_opt_out_opt + #undef __nvapi_undef__deref_opt_out_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_ecount_opt + #undef __deref_opt_out_ecount_opt + #undef __nvapi_undef__deref_opt_out_ecount_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_bcount_opt + #undef __deref_opt_out_bcount_opt + #undef __nvapi_undef__deref_opt_out_bcount_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_ecount_part_opt + #undef __deref_opt_out_ecount_part_opt + #undef __nvapi_undef__deref_opt_out_ecount_part_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_bcount_part_opt + #undef __deref_opt_out_bcount_part_opt + #undef __nvapi_undef__deref_opt_out_bcount_part_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_ecount_full_opt + #undef __deref_opt_out_ecount_full_opt + #undef __nvapi_undef__deref_opt_out_ecount_full_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_bcount_full_opt + #undef __deref_opt_out_bcount_full_opt + #undef __nvapi_undef__deref_opt_out_bcount_full_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_z_opt + #undef __deref_opt_out_z_opt + #undef __nvapi_undef__deref_opt_out_z_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_ecount_z_opt + #undef __deref_opt_out_ecount_z_opt + #undef __nvapi_undef__deref_opt_out_ecount_z_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_bcount_z_opt + #undef __deref_opt_out_bcount_z_opt + #undef __nvapi_undef__deref_opt_out_bcount_z_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_nz_opt + #undef __deref_opt_out_nz_opt + #undef __nvapi_undef__deref_opt_out_nz_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_ecount_nz_opt + #undef __deref_opt_out_ecount_nz_opt + #undef __nvapi_undef__deref_opt_out_ecount_nz_opt +#endif +#ifdef __nvapi_undef__deref_opt_out_bcount_nz_opt + #undef __deref_opt_out_bcount_nz_opt + #undef __nvapi_undef__deref_opt_out_bcount_nz_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_opt + #undef __deref_opt_inout_opt + #undef __nvapi_undef__deref_opt_inout_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_ecount_opt + #undef __deref_opt_inout_ecount_opt + #undef __nvapi_undef__deref_opt_inout_ecount_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_bcount_opt + #undef __deref_opt_inout_bcount_opt + #undef __nvapi_undef__deref_opt_inout_bcount_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_ecount_part_opt + #undef __deref_opt_inout_ecount_part_opt + #undef __nvapi_undef__deref_opt_inout_ecount_part_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_bcount_part_opt + #undef __deref_opt_inout_bcount_part_opt + #undef __nvapi_undef__deref_opt_inout_bcount_part_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_ecount_full_opt + #undef __deref_opt_inout_ecount_full_opt + #undef __nvapi_undef__deref_opt_inout_ecount_full_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_bcount_full_opt + #undef __deref_opt_inout_bcount_full_opt + #undef __nvapi_undef__deref_opt_inout_bcount_full_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_z_opt + #undef __deref_opt_inout_z_opt + #undef __nvapi_undef__deref_opt_inout_z_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_ecount_z_opt + #undef __deref_opt_inout_ecount_z_opt + #undef __nvapi_undef__deref_opt_inout_ecount_z_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_bcount_z_opt + #undef __deref_opt_inout_bcount_z_opt + #undef __nvapi_undef__deref_opt_inout_bcount_z_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_nz_opt + #undef __deref_opt_inout_nz_opt + #undef __nvapi_undef__deref_opt_inout_nz_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_ecount_nz_opt + #undef __deref_opt_inout_ecount_nz_opt + #undef __nvapi_undef__deref_opt_inout_ecount_nz_opt +#endif +#ifdef __nvapi_undef__deref_opt_inout_bcount_nz_opt + #undef __deref_opt_inout_bcount_nz_opt + #undef __nvapi_undef__deref_opt_inout_bcount_nz_opt +#endif +#ifdef __nvapi_success + #undef __success + #undef __nvapi_success +#endif +#ifdef __nvapi__Ret_notnull_ + #undef __nvapi__Ret_notnull_ + #undef _Ret_notnull_ +#endif +#ifdef __nvapi__Post_writable_byte_size_ + #undef __nvapi__Post_writable_byte_size_ + #undef _Post_writable_byte_size_ +#endif +#ifdef __nvapi_Outptr_ + #undef __nvapi_Outptr_ + #undef _Outptr_ +#endif + +#endif // __NVAPI_EMPTY_SAL diff --git a/thirdparty/nvapi/nvapi_lite_salstart.h b/thirdparty/nvapi/nvapi_lite_salstart.h new file mode 100644 index 0000000..7e463fc --- /dev/null +++ b/thirdparty/nvapi/nvapi_lite_salstart.h @@ -0,0 +1,821 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + +// ==================================================== +// SAL related support +// ==================================================== + +#ifndef __ecount + #define __nvapi_undef__ecount + #define __ecount(size) +#endif +#ifndef __bcount + #define __nvapi_undef__bcount + #define __bcount(size) +#endif +#ifndef __in + #define __nvapi_undef__in + #define __in +#endif +#ifndef __in_ecount + #define __nvapi_undef__in_ecount + #define __in_ecount(size) +#endif +#ifndef __in_bcount + #define __nvapi_undef__in_bcount + #define __in_bcount(size) +#endif +#ifndef __in_z + #define __nvapi_undef__in_z + #define __in_z +#endif +#ifndef __in_ecount_z + #define __nvapi_undef__in_ecount_z + #define __in_ecount_z(size) +#endif +#ifndef __in_bcount_z + #define __nvapi_undef__in_bcount_z + #define __in_bcount_z(size) +#endif +#ifndef __in_nz + #define __nvapi_undef__in_nz + #define __in_nz +#endif +#ifndef __in_ecount_nz + #define __nvapi_undef__in_ecount_nz + #define __in_ecount_nz(size) +#endif +#ifndef __in_bcount_nz + #define __nvapi_undef__in_bcount_nz + #define __in_bcount_nz(size) +#endif +#ifndef __out + #define __nvapi_undef__out + #define __out +#endif +#ifndef __out_ecount + #define __nvapi_undef__out_ecount + #define __out_ecount(size) +#endif +#ifndef __out_bcount + #define __nvapi_undef__out_bcount + #define __out_bcount(size) +#endif +#ifndef __out_ecount_part + #define __nvapi_undef__out_ecount_part + #define __out_ecount_part(size,length) +#endif +#ifndef __out_bcount_part + #define __nvapi_undef__out_bcount_part + #define __out_bcount_part(size,length) +#endif +#ifndef __out_ecount_full + #define __nvapi_undef__out_ecount_full + #define __out_ecount_full(size) +#endif +#ifndef __out_bcount_full + #define __nvapi_undef__out_bcount_full + #define __out_bcount_full(size) +#endif +#ifndef __out_z + #define __nvapi_undef__out_z + #define __out_z +#endif +#ifndef __out_z_opt + #define __nvapi_undef__out_z_opt + #define __out_z_opt +#endif +#ifndef __out_ecount_z + #define __nvapi_undef__out_ecount_z + #define __out_ecount_z(size) +#endif +#ifndef __out_bcount_z + #define __nvapi_undef__out_bcount_z + #define __out_bcount_z(size) +#endif +#ifndef __out_ecount_part_z + #define __nvapi_undef__out_ecount_part_z + #define __out_ecount_part_z(size,length) +#endif +#ifndef __out_bcount_part_z + #define __nvapi_undef__out_bcount_part_z + #define __out_bcount_part_z(size,length) +#endif +#ifndef __out_ecount_full_z + #define __nvapi_undef__out_ecount_full_z + #define __out_ecount_full_z(size) +#endif +#ifndef __out_bcount_full_z + #define __nvapi_undef__out_bcount_full_z + #define __out_bcount_full_z(size) +#endif +#ifndef __out_nz + #define __nvapi_undef__out_nz + #define __out_nz +#endif +#ifndef __out_nz_opt + #define __nvapi_undef__out_nz_opt + #define __out_nz_opt +#endif +#ifndef __out_ecount_nz + #define __nvapi_undef__out_ecount_nz + #define __out_ecount_nz(size) +#endif +#ifndef __out_bcount_nz + #define __nvapi_undef__out_bcount_nz + #define __out_bcount_nz(size) +#endif +#ifndef __inout + #define __nvapi_undef__inout + #define __inout +#endif +#ifndef __inout_ecount + #define __nvapi_undef__inout_ecount + #define __inout_ecount(size) +#endif +#ifndef __inout_bcount + #define __nvapi_undef__inout_bcount + #define __inout_bcount(size) +#endif +#ifndef __inout_ecount_part + #define __nvapi_undef__inout_ecount_part + #define __inout_ecount_part(size,length) +#endif +#ifndef __inout_bcount_part + #define __nvapi_undef__inout_bcount_part + #define __inout_bcount_part(size,length) +#endif +#ifndef __inout_ecount_full + #define __nvapi_undef__inout_ecount_full + #define __inout_ecount_full(size) +#endif +#ifndef __inout_bcount_full + #define __nvapi_undef__inout_bcount_full + #define __inout_bcount_full(size) +#endif +#ifndef __inout_z + #define __nvapi_undef__inout_z + #define __inout_z +#endif +#ifndef __inout_ecount_z + #define __nvapi_undef__inout_ecount_z + #define __inout_ecount_z(size) +#endif +#ifndef __inout_bcount_z + #define __nvapi_undef__inout_bcount_z + #define __inout_bcount_z(size) +#endif +#ifndef __inout_nz + #define __nvapi_undef__inout_nz + #define __inout_nz +#endif +#ifndef __inout_ecount_nz + #define __nvapi_undef__inout_ecount_nz + #define __inout_ecount_nz(size) +#endif +#ifndef __inout_bcount_nz + #define __nvapi_undef__inout_bcount_nz + #define __inout_bcount_nz(size) +#endif +#ifndef __ecount_opt + #define __nvapi_undef__ecount_opt + #define __ecount_opt(size) +#endif +#ifndef __bcount_opt + #define __nvapi_undef__bcount_opt + #define __bcount_opt(size) +#endif +#ifndef __in_opt + #define __nvapi_undef__in_opt + #define __in_opt +#endif +#ifndef __in_ecount_opt + #define __nvapi_undef__in_ecount_opt + #define __in_ecount_opt(size) +#endif +#ifndef __in_bcount_opt + #define __nvapi_undef__in_bcount_opt + #define __in_bcount_opt(size) +#endif +#ifndef __in_z_opt + #define __nvapi_undef__in_z_opt + #define __in_z_opt +#endif +#ifndef __in_ecount_z_opt + #define __nvapi_undef__in_ecount_z_opt + #define __in_ecount_z_opt(size) +#endif +#ifndef __in_bcount_z_opt + #define __nvapi_undef__in_bcount_z_opt + #define __in_bcount_z_opt(size) +#endif +#ifndef __in_nz_opt + #define __nvapi_undef__in_nz_opt + #define __in_nz_opt +#endif +#ifndef __in_ecount_nz_opt + #define __nvapi_undef__in_ecount_nz_opt + #define __in_ecount_nz_opt(size) +#endif +#ifndef __in_bcount_nz_opt + #define __nvapi_undef__in_bcount_nz_opt + #define __in_bcount_nz_opt(size) +#endif +#ifndef __out_opt + #define __nvapi_undef__out_opt + #define __out_opt +#endif +#ifndef __out_ecount_opt + #define __nvapi_undef__out_ecount_opt + #define __out_ecount_opt(size) +#endif +#ifndef __out_bcount_opt + #define __nvapi_undef__out_bcount_opt + #define __out_bcount_opt(size) +#endif +#ifndef __out_ecount_part_opt + #define __nvapi_undef__out_ecount_part_opt + #define __out_ecount_part_opt(size,length) +#endif +#ifndef __out_bcount_part_opt + #define __nvapi_undef__out_bcount_part_opt + #define __out_bcount_part_opt(size,length) +#endif +#ifndef __out_ecount_full_opt + #define __nvapi_undef__out_ecount_full_opt + #define __out_ecount_full_opt(size) +#endif +#ifndef __out_bcount_full_opt + #define __nvapi_undef__out_bcount_full_opt + #define __out_bcount_full_opt(size) +#endif +#ifndef __out_ecount_z_opt + #define __nvapi_undef__out_ecount_z_opt + #define __out_ecount_z_opt(size) +#endif +#ifndef __out_bcount_z_opt + #define __nvapi_undef__out_bcount_z_opt + #define __out_bcount_z_opt(size) +#endif +#ifndef __out_ecount_part_z_opt + #define __nvapi_undef__out_ecount_part_z_opt + #define __out_ecount_part_z_opt(size,length) +#endif +#ifndef __out_bcount_part_z_opt + #define __nvapi_undef__out_bcount_part_z_opt + #define __out_bcount_part_z_opt(size,length) +#endif +#ifndef __out_ecount_full_z_opt + #define __nvapi_undef__out_ecount_full_z_opt + #define __out_ecount_full_z_opt(size) +#endif +#ifndef __out_bcount_full_z_opt + #define __nvapi_undef__out_bcount_full_z_opt + #define __out_bcount_full_z_opt(size) +#endif +#ifndef __out_ecount_nz_opt + #define __nvapi_undef__out_ecount_nz_opt + #define __out_ecount_nz_opt(size) +#endif +#ifndef __out_bcount_nz_opt + #define __nvapi_undef__out_bcount_nz_opt + #define __out_bcount_nz_opt(size) +#endif +#ifndef __inout_opt + #define __nvapi_undef__inout_opt + #define __inout_opt +#endif +#ifndef __inout_ecount_opt + #define __nvapi_undef__inout_ecount_opt + #define __inout_ecount_opt(size) +#endif +#ifndef __inout_bcount_opt + #define __nvapi_undef__inout_bcount_opt + #define __inout_bcount_opt(size) +#endif +#ifndef __inout_ecount_part_opt + #define __nvapi_undef__inout_ecount_part_opt + #define __inout_ecount_part_opt(size,length) +#endif +#ifndef __inout_bcount_part_opt + #define __nvapi_undef__inout_bcount_part_opt + #define __inout_bcount_part_opt(size,length) +#endif +#ifndef __inout_ecount_full_opt + #define __nvapi_undef__inout_ecount_full_opt + #define __inout_ecount_full_opt(size) +#endif +#ifndef __inout_bcount_full_opt + #define __nvapi_undef__inout_bcount_full_opt + #define __inout_bcount_full_opt(size) +#endif +#ifndef __inout_z_opt + #define __nvapi_undef__inout_z_opt + #define __inout_z_opt +#endif +#ifndef __inout_ecount_z_opt + #define __nvapi_undef__inout_ecount_z_opt + #define __inout_ecount_z_opt(size) +#endif +#ifndef __inout_ecount_z_opt + #define __nvapi_undef__inout_ecount_z_opt + #define __inout_ecount_z_opt(size) +#endif +#ifndef __inout_bcount_z_opt + #define __nvapi_undef__inout_bcount_z_opt + #define __inout_bcount_z_opt(size) +#endif +#ifndef __inout_nz_opt + #define __nvapi_undef__inout_nz_opt + #define __inout_nz_opt +#endif +#ifndef __inout_ecount_nz_opt + #define __nvapi_undef__inout_ecount_nz_opt + #define __inout_ecount_nz_opt(size) +#endif +#ifndef __inout_bcount_nz_opt + #define __nvapi_undef__inout_bcount_nz_opt + #define __inout_bcount_nz_opt(size) +#endif +#ifndef __deref_ecount + #define __nvapi_undef__deref_ecount + #define __deref_ecount(size) +#endif +#ifndef __deref_bcount + #define __nvapi_undef__deref_bcount + #define __deref_bcount(size) +#endif +#ifndef __deref_out + #define __nvapi_undef__deref_out + #define __deref_out +#endif +#ifndef __deref_out_ecount + #define __nvapi_undef__deref_out_ecount + #define __deref_out_ecount(size) +#endif +#ifndef __deref_out_bcount + #define __nvapi_undef__deref_out_bcount + #define __deref_out_bcount(size) +#endif +#ifndef __deref_out_ecount_part + #define __nvapi_undef__deref_out_ecount_part + #define __deref_out_ecount_part(size,length) +#endif +#ifndef __deref_out_bcount_part + #define __nvapi_undef__deref_out_bcount_part + #define __deref_out_bcount_part(size,length) +#endif +#ifndef __deref_out_ecount_full + #define __nvapi_undef__deref_out_ecount_full + #define __deref_out_ecount_full(size) +#endif +#ifndef __deref_out_bcount_full + #define __nvapi_undef__deref_out_bcount_full + #define __deref_out_bcount_full(size) +#endif +#ifndef __deref_out_z + #define __nvapi_undef__deref_out_z + #define __deref_out_z +#endif +#ifndef __deref_out_ecount_z + #define __nvapi_undef__deref_out_ecount_z + #define __deref_out_ecount_z(size) +#endif +#ifndef __deref_out_bcount_z + #define __nvapi_undef__deref_out_bcount_z + #define __deref_out_bcount_z(size) +#endif +#ifndef __deref_out_nz + #define __nvapi_undef__deref_out_nz + #define __deref_out_nz +#endif +#ifndef __deref_out_ecount_nz + #define __nvapi_undef__deref_out_ecount_nz + #define __deref_out_ecount_nz(size) +#endif +#ifndef __deref_out_bcount_nz + #define __nvapi_undef__deref_out_bcount_nz + #define __deref_out_bcount_nz(size) +#endif +#ifndef __deref_inout + #define __nvapi_undef__deref_inout + #define __deref_inout +#endif +#ifndef __deref_inout_z + #define __nvapi_undef__deref_inout_z + #define __deref_inout_z +#endif +#ifndef __deref_inout_ecount + #define __nvapi_undef__deref_inout_ecount + #define __deref_inout_ecount(size) +#endif +#ifndef __deref_inout_bcount + #define __nvapi_undef__deref_inout_bcount + #define __deref_inout_bcount(size) +#endif +#ifndef __deref_inout_ecount_part + #define __nvapi_undef__deref_inout_ecount_part + #define __deref_inout_ecount_part(size,length) +#endif +#ifndef __deref_inout_bcount_part + #define __nvapi_undef__deref_inout_bcount_part + #define __deref_inout_bcount_part(size,length) +#endif +#ifndef __deref_inout_ecount_full + #define __nvapi_undef__deref_inout_ecount_full + #define __deref_inout_ecount_full(size) +#endif +#ifndef __deref_inout_bcount_full + #define __nvapi_undef__deref_inout_bcount_full + #define __deref_inout_bcount_full(size) +#endif +#ifndef __deref_inout_z + #define __nvapi_undef__deref_inout_z + #define __deref_inout_z +#endif +#ifndef __deref_inout_ecount_z + #define __nvapi_undef__deref_inout_ecount_z + #define __deref_inout_ecount_z(size) +#endif +#ifndef __deref_inout_bcount_z + #define __nvapi_undef__deref_inout_bcount_z + #define __deref_inout_bcount_z(size) +#endif +#ifndef __deref_inout_nz + #define __nvapi_undef__deref_inout_nz + #define __deref_inout_nz +#endif +#ifndef __deref_inout_ecount_nz + #define __nvapi_undef__deref_inout_ecount_nz + #define __deref_inout_ecount_nz(size) +#endif +#ifndef __deref_inout_bcount_nz + #define __nvapi_undef__deref_inout_bcount_nz + #define __deref_inout_bcount_nz(size) +#endif +#ifndef __deref_ecount_opt + #define __nvapi_undef__deref_ecount_opt + #define __deref_ecount_opt(size) +#endif +#ifndef __deref_bcount_opt + #define __nvapi_undef__deref_bcount_opt + #define __deref_bcount_opt(size) +#endif +#ifndef __deref_out_opt + #define __nvapi_undef__deref_out_opt + #define __deref_out_opt +#endif +#ifndef __deref_out_ecount_opt + #define __nvapi_undef__deref_out_ecount_opt + #define __deref_out_ecount_opt(size) +#endif +#ifndef __deref_out_bcount_opt + #define __nvapi_undef__deref_out_bcount_opt + #define __deref_out_bcount_opt(size) +#endif +#ifndef __deref_out_ecount_part_opt + #define __nvapi_undef__deref_out_ecount_part_opt + #define __deref_out_ecount_part_opt(size,length) +#endif +#ifndef __deref_out_bcount_part_opt + #define __nvapi_undef__deref_out_bcount_part_opt + #define __deref_out_bcount_part_opt(size,length) +#endif +#ifndef __deref_out_ecount_full_opt + #define __nvapi_undef__deref_out_ecount_full_opt + #define __deref_out_ecount_full_opt(size) +#endif +#ifndef __deref_out_bcount_full_opt + #define __nvapi_undef__deref_out_bcount_full_opt + #define __deref_out_bcount_full_opt(size) +#endif +#ifndef __deref_out_z_opt + #define __nvapi_undef__deref_out_z_opt + #define __deref_out_z_opt +#endif +#ifndef __deref_out_ecount_z_opt + #define __nvapi_undef__deref_out_ecount_z_opt + #define __deref_out_ecount_z_opt(size) +#endif +#ifndef __deref_out_bcount_z_opt + #define __nvapi_undef__deref_out_bcount_z_opt + #define __deref_out_bcount_z_opt(size) +#endif +#ifndef __deref_out_nz_opt + #define __nvapi_undef__deref_out_nz_opt + #define __deref_out_nz_opt +#endif +#ifndef __deref_out_ecount_nz_opt + #define __nvapi_undef__deref_out_ecount_nz_opt + #define __deref_out_ecount_nz_opt(size) +#endif +#ifndef __deref_out_bcount_nz_opt + #define __nvapi_undef__deref_out_bcount_nz_opt + #define __deref_out_bcount_nz_opt(size) +#endif +#ifndef __deref_inout_opt + #define __nvapi_undef__deref_inout_opt + #define __deref_inout_opt +#endif +#ifndef __deref_inout_ecount_opt + #define __nvapi_undef__deref_inout_ecount_opt + #define __deref_inout_ecount_opt(size) +#endif +#ifndef __deref_inout_bcount_opt + #define __nvapi_undef__deref_inout_bcount_opt + #define __deref_inout_bcount_opt(size) +#endif +#ifndef __deref_inout_ecount_part_opt + #define __nvapi_undef__deref_inout_ecount_part_opt + #define __deref_inout_ecount_part_opt(size,length) +#endif +#ifndef __deref_inout_bcount_part_opt + #define __nvapi_undef__deref_inout_bcount_part_opt + #define __deref_inout_bcount_part_opt(size,length) +#endif +#ifndef __deref_inout_ecount_full_opt + #define __nvapi_undef__deref_inout_ecount_full_opt + #define __deref_inout_ecount_full_opt(size) +#endif +#ifndef __deref_inout_bcount_full_opt + #define __nvapi_undef__deref_inout_bcount_full_opt + #define __deref_inout_bcount_full_opt(size) +#endif +#ifndef __deref_inout_z_opt + #define __nvapi_undef__deref_inout_z_opt + #define __deref_inout_z_opt +#endif +#ifndef __deref_inout_ecount_z_opt + #define __nvapi_undef__deref_inout_ecount_z_opt + #define __deref_inout_ecount_z_opt(size) +#endif +#ifndef __deref_inout_bcount_z_opt + #define __nvapi_undef__deref_inout_bcount_z_opt + #define __deref_inout_bcount_z_opt(size) +#endif +#ifndef __deref_inout_nz_opt + #define __nvapi_undef__deref_inout_nz_opt + #define __deref_inout_nz_opt +#endif +#ifndef __deref_inout_ecount_nz_opt + #define __nvapi_undef__deref_inout_ecount_nz_opt + #define __deref_inout_ecount_nz_opt(size) +#endif +#ifndef __deref_inout_bcount_nz_opt + #define __nvapi_undef__deref_inout_bcount_nz_opt + #define __deref_inout_bcount_nz_opt(size) +#endif +#ifndef __deref_opt_ecount + #define __nvapi_undef__deref_opt_ecount + #define __deref_opt_ecount(size) +#endif +#ifndef __deref_opt_bcount + #define __nvapi_undef__deref_opt_bcount + #define __deref_opt_bcount(size) +#endif +#ifndef __deref_opt_out + #define __nvapi_undef__deref_opt_out + #define __deref_opt_out +#endif +#ifndef __deref_opt_out_z + #define __nvapi_undef__deref_opt_out_z + #define __deref_opt_out_z +#endif +#ifndef __deref_opt_out_ecount + #define __nvapi_undef__deref_opt_out_ecount + #define __deref_opt_out_ecount(size) +#endif +#ifndef __deref_opt_out_bcount + #define __nvapi_undef__deref_opt_out_bcount + #define __deref_opt_out_bcount(size) +#endif +#ifndef __deref_opt_out_ecount_part + #define __nvapi_undef__deref_opt_out_ecount_part + #define __deref_opt_out_ecount_part(size,length) +#endif +#ifndef __deref_opt_out_bcount_part + #define __nvapi_undef__deref_opt_out_bcount_part + #define __deref_opt_out_bcount_part(size,length) +#endif +#ifndef __deref_opt_out_ecount_full + #define __nvapi_undef__deref_opt_out_ecount_full + #define __deref_opt_out_ecount_full(size) +#endif +#ifndef __deref_opt_out_bcount_full + #define __nvapi_undef__deref_opt_out_bcount_full + #define __deref_opt_out_bcount_full(size) +#endif +#ifndef __deref_opt_inout + #define __nvapi_undef__deref_opt_inout + #define __deref_opt_inout +#endif +#ifndef __deref_opt_inout_ecount + #define __nvapi_undef__deref_opt_inout_ecount + #define __deref_opt_inout_ecount(size) +#endif +#ifndef __deref_opt_inout_bcount + #define __nvapi_undef__deref_opt_inout_bcount + #define __deref_opt_inout_bcount(size) +#endif +#ifndef __deref_opt_inout_ecount_part + #define __nvapi_undef__deref_opt_inout_ecount_part + #define __deref_opt_inout_ecount_part(size,length) +#endif +#ifndef __deref_opt_inout_bcount_part + #define __nvapi_undef__deref_opt_inout_bcount_part + #define __deref_opt_inout_bcount_part(size,length) +#endif +#ifndef __deref_opt_inout_ecount_full + #define __nvapi_undef__deref_opt_inout_ecount_full + #define __deref_opt_inout_ecount_full(size) +#endif +#ifndef __deref_opt_inout_bcount_full + #define __nvapi_undef__deref_opt_inout_bcount_full + #define __deref_opt_inout_bcount_full(size) +#endif +#ifndef __deref_opt_inout_z + #define __nvapi_undef__deref_opt_inout_z + #define __deref_opt_inout_z +#endif +#ifndef __deref_opt_inout_ecount_z + #define __nvapi_undef__deref_opt_inout_ecount_z + #define __deref_opt_inout_ecount_z(size) +#endif +#ifndef __deref_opt_inout_bcount_z + #define __nvapi_undef__deref_opt_inout_bcount_z + #define __deref_opt_inout_bcount_z(size) +#endif +#ifndef __deref_opt_inout_nz + #define __nvapi_undef__deref_opt_inout_nz + #define __deref_opt_inout_nz +#endif +#ifndef __deref_opt_inout_ecount_nz + #define __nvapi_undef__deref_opt_inout_ecount_nz + #define __deref_opt_inout_ecount_nz(size) +#endif +#ifndef __deref_opt_inout_bcount_nz + #define __nvapi_undef__deref_opt_inout_bcount_nz + #define __deref_opt_inout_bcount_nz(size) +#endif +#ifndef __deref_opt_ecount_opt + #define __nvapi_undef__deref_opt_ecount_opt + #define __deref_opt_ecount_opt(size) +#endif +#ifndef __deref_opt_bcount_opt + #define __nvapi_undef__deref_opt_bcount_opt + #define __deref_opt_bcount_opt(size) +#endif +#ifndef __deref_opt_out_opt + #define __nvapi_undef__deref_opt_out_opt + #define __deref_opt_out_opt +#endif +#ifndef __deref_opt_out_ecount_opt + #define __nvapi_undef__deref_opt_out_ecount_opt + #define __deref_opt_out_ecount_opt(size) +#endif +#ifndef __deref_opt_out_bcount_opt + #define __nvapi_undef__deref_opt_out_bcount_opt + #define __deref_opt_out_bcount_opt(size) +#endif +#ifndef __deref_opt_out_ecount_part_opt + #define __nvapi_undef__deref_opt_out_ecount_part_opt + #define __deref_opt_out_ecount_part_opt(size,length) +#endif +#ifndef __deref_opt_out_bcount_part_opt + #define __nvapi_undef__deref_opt_out_bcount_part_opt + #define __deref_opt_out_bcount_part_opt(size,length) +#endif +#ifndef __deref_opt_out_ecount_full_opt + #define __nvapi_undef__deref_opt_out_ecount_full_opt + #define __deref_opt_out_ecount_full_opt(size) +#endif +#ifndef __deref_opt_out_bcount_full_opt + #define __nvapi_undef__deref_opt_out_bcount_full_opt + #define __deref_opt_out_bcount_full_opt(size) +#endif +#ifndef __deref_opt_out_z_opt + #define __nvapi_undef__deref_opt_out_z_opt + #define __deref_opt_out_z_opt +#endif +#ifndef __deref_opt_out_ecount_z_opt + #define __nvapi_undef__deref_opt_out_ecount_z_opt + #define __deref_opt_out_ecount_z_opt(size) +#endif +#ifndef __deref_opt_out_bcount_z_opt + #define __nvapi_undef__deref_opt_out_bcount_z_opt + #define __deref_opt_out_bcount_z_opt(size) +#endif +#ifndef __deref_opt_out_nz_opt + #define __nvapi_undef__deref_opt_out_nz_opt + #define __deref_opt_out_nz_opt +#endif +#ifndef __deref_opt_out_ecount_nz_opt + #define __nvapi_undef__deref_opt_out_ecount_nz_opt + #define __deref_opt_out_ecount_nz_opt(size) +#endif +#ifndef __deref_opt_out_bcount_nz_opt + #define __nvapi_undef__deref_opt_out_bcount_nz_opt + #define __deref_opt_out_bcount_nz_opt(size) +#endif +#ifndef __deref_opt_inout_opt + #define __nvapi_undef__deref_opt_inout_opt + #define __deref_opt_inout_opt +#endif +#ifndef __deref_opt_inout_ecount_opt + #define __nvapi_undef__deref_opt_inout_ecount_opt + #define __deref_opt_inout_ecount_opt(size) +#endif +#ifndef __deref_opt_inout_bcount_opt + #define __nvapi_undef__deref_opt_inout_bcount_opt + #define __deref_opt_inout_bcount_opt(size) +#endif +#ifndef __deref_opt_inout_ecount_part_opt + #define __nvapi_undef__deref_opt_inout_ecount_part_opt + #define __deref_opt_inout_ecount_part_opt(size,length) +#endif +#ifndef __deref_opt_inout_bcount_part_opt + #define __nvapi_undef__deref_opt_inout_bcount_part_opt + #define __deref_opt_inout_bcount_part_opt(size,length) +#endif +#ifndef __deref_opt_inout_ecount_full_opt + #define __nvapi_undef__deref_opt_inout_ecount_full_opt + #define __deref_opt_inout_ecount_full_opt(size) +#endif +#ifndef __deref_opt_inout_bcount_full_opt + #define __nvapi_undef__deref_opt_inout_bcount_full_opt + #define __deref_opt_inout_bcount_full_opt(size) +#endif +#ifndef __deref_opt_inout_z_opt + #define __nvapi_undef__deref_opt_inout_z_opt + #define __deref_opt_inout_z_opt +#endif +#ifndef __deref_opt_inout_ecount_z_opt + #define __nvapi_undef__deref_opt_inout_ecount_z_opt + #define __deref_opt_inout_ecount_z_opt(size) +#endif +#ifndef __deref_opt_inout_bcount_z_opt + #define __nvapi_undef__deref_opt_inout_bcount_z_opt + #define __deref_opt_inout_bcount_z_opt(size) +#endif +#ifndef __deref_opt_inout_nz_opt + #define __nvapi_undef__deref_opt_inout_nz_opt + #define __deref_opt_inout_nz_opt +#endif +#ifndef __deref_opt_inout_ecount_nz_opt + #define __nvapi_undef__deref_opt_inout_ecount_nz_opt + #define __deref_opt_inout_ecount_nz_opt(size) +#endif +#ifndef __deref_opt_inout_bcount_nz_opt + #define __nvapi_undef__deref_opt_inout_bcount_nz_opt + #define __deref_opt_inout_bcount_nz_opt(size) +#endif +#ifndef __success + #define __nvapi_success + #define __success(epxr) +#endif +#ifndef _Ret_notnull_ + #define __nvapi__Ret_notnull_ + #define _Ret_notnull_ +#endif +#ifndef _Post_writable_byte_size_ + #define __nvapi__Post_writable_byte_size_ + #define _Post_writable_byte_size_(n) +#endif +#ifndef _Outptr_ + #define __nvapi_Outptr_ + #define _Outptr_ +#endif + + +#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl diff --git a/thirdparty/nvapi/nvapi_lite_sli.h b/thirdparty/nvapi/nvapi_lite_sli.h new file mode 100644 index 0000000..68e248d --- /dev/null +++ b/thirdparty/nvapi/nvapi_lite_sli.h @@ -0,0 +1,255 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + +#pragma once +#include"nvapi_lite_salstart.h" +#include"nvapi_lite_common.h" +#pragma pack(push,8) +#ifdef __cplusplus +extern "C" { +#endif +//----------------------------------------------------------------------------- +// DirectX APIs +//----------------------------------------------------------------------------- + + +//! \ingroup dx +//! Used in NvAPI_D3D10_GetCurrentSLIState(), and NvAPI_D3D_GetCurrentSLIState(). +typedef struct +{ + NvU32 version; //!< Structure version + NvU32 maxNumAFRGroups; //!< [OUT] The maximum possible value of numAFRGroups + NvU32 numAFRGroups; //!< [OUT] The number of AFR groups enabled in the system + NvU32 currentAFRIndex; //!< [OUT] The AFR group index for the frame currently being rendered + NvU32 nextFrameAFRIndex; //!< [OUT] What the AFR group index will be for the next frame (i.e. after calling Present) + NvU32 previousFrameAFRIndex; //!< [OUT] The AFR group index that was used for the previous frame (~0 if more than one frame has not been rendered yet) + NvU32 bIsCurAFRGroupNew; //!< [OUT] Boolean: Is this frame the first time running on the current AFR group + +} NV_GET_CURRENT_SLI_STATE_V1; + +typedef struct +{ + NvU32 version; //!< Structure version + NvU32 maxNumAFRGroups; //!< [OUT] The maximum possible value of numAFRGroups + NvU32 numAFRGroups; //!< [OUT] The number of AFR groups enabled in the system + NvU32 currentAFRIndex; //!< [OUT] The AFR group index for the frame currently being rendered + NvU32 nextFrameAFRIndex; //!< [OUT] What the AFR group index will be for the next frame (i.e. after calling Present) + NvU32 previousFrameAFRIndex; //!< [OUT] The AFR group index that was used for the previous frame (~0 if more than one frame has not been rendered yet) + NvU32 bIsCurAFRGroupNew; //!< [OUT] Boolean: Is this frame the first time running on the current AFR group + NvU32 numVRSLIGpus; //!< [OUT] The number of GPUs used in VR-SLI. If it is 0 VR-SLI is not active + +} NV_GET_CURRENT_SLI_STATE_V2; + +//! \ingroup dx +#define NV_GET_CURRENT_SLI_STATE_VER1 MAKE_NVAPI_VERSION(NV_GET_CURRENT_SLI_STATE_V1,1) +#define NV_GET_CURRENT_SLI_STATE_VER2 MAKE_NVAPI_VERSION(NV_GET_CURRENT_SLI_STATE_V2,1) +#define NV_GET_CURRENT_SLI_STATE_VER NV_GET_CURRENT_SLI_STATE_VER2 +#define NV_GET_CURRENT_SLI_STATE NV_GET_CURRENT_SLI_STATE_V2 +#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_GetCurrentSLIState +// +//! DESCRIPTION: This function returns the current SLI state for the specified device. The structure +//! contains the number of AFR groups, the current AFR group index, +//! and what the AFR group index will be for the next frame. \p +//! pDevice can be either a IDirect3DDevice9 or ID3D10Device pointer. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 173 +//! +//! \retval NVAPI_OK Completed request +//! \retval NVAPI_ERROR Error occurred +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_GetCurrentSLIState(IUnknown *pDevice, NV_GET_CURRENT_SLI_STATE *pSliState); +#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) +#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_SetResourceHint +// +//! \fn NvAPI_D3D_SetResourceHint(IUnknown *pDev, NVDX_ObjectHandle obj, +//! NVAPI_D3D_SETRESOURCEHINT_CATEGORY dwHintCategory, +//! NvU32 dwHintName, +//! NvU32 *pdwHintValue) +//! +//! DESCRIPTION: This is a general purpose function for passing down various resource +//! related hints to the driver. Hints are divided into categories +//! and types within each category. For DX11 devices this function is free-threaded. +//! An application is responsible to complete this call before making use of the resource +//! in a rendering context (therefore applying inter-thread synchronization as appropriate). +//! As a debug help to an application the driver enforces that a resource in this call was never bound. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [in] pDev The ID3D10Device or IDirect3DDevice9 that is a using the resource +//! \param [in] obj Previously obtained HV resource handle +//! \param [in] dwHintCategory Category of the hints +//! \param [in] dwHintName A hint within this category +//! \param [in/out] *pdwHintValue Pointer to location containing hint value, function returns previous hint value in this slot +//! +//! \return an int which could be an NvAPI status or DX HRESULT code +//! +//! \retval ::NVAPI_OK +//! \retval ::NVAPI_INVALID_ARGUMENT +//! \retval ::NVAPI_INVALID_CALL It is illegal to change a hint dynamically when the resource is already bound. +// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + +//! \ingroup dx +//! Valid categories for NvAPI_D3D_SetResourceHint() +typedef enum _NVAPI_D3D_SETRESOURCEHINT_CATEGORY +{ + NVAPI_D3D_SRH_CATEGORY_SLI = 1 +} NVAPI_D3D_SETRESOURCEHINT_CATEGORY; + + +// +// NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC: +// NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USING: +// NVAPI_D3D_SRH_SLI_RESPECT_DRIVER_INTERFRAME_CONTENT_SYNC: + + +//! \ingroup dx +//! Types of SLI hints; \n +//! NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC: Valid values : 0 or 1 \n +//! Default value: 0 \n +//! Explanation: If the value is 1, the driver will not track any rendering operations that would mark this resource as dirty, +//! avoiding any form of synchronization across frames rendered in parallel in multiple GPUs in AFR mode. +//! +//! NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USAGE: Valid values : 0 or 1 \n +//! Default value: 0 \n +//! Explanation: If the value is 1, the driver will try to perform operations which involved target resource in broadcast, +//! where it's possible. Hint is static and must be set before resource starts using. +//! +//! NVAPI_D3D_SRH_SLI_RESPECT_DRIVER_INTERFRAME_CONTENT_SYNC: Valid values : 0 or 1 \n +//! Default value: 0 \n +//! Explanation: If the value is 1, the driver will do dirty resource resolve regardless of discard flags in the application profile or +//! AFR-FriendlyD3DHints.exe name using. +//! +typedef enum _NVAPI_D3D_SETRESOURCEHINT_SLI +{ + NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC = 1, + NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USAGE = 2, + NVAPI_D3D_SRH_SLI_RESPECT_DRIVER_INTERFRAME_CONTENT_SYNC = 3 +} NVAPI_D3D_SETRESOURCEHINT_SLI; + +//! \ingroup dx +NVAPI_INTERFACE NvAPI_D3D_SetResourceHint(IUnknown *pDev, NVDX_ObjectHandle obj, + NVAPI_D3D_SETRESOURCEHINT_CATEGORY dwHintCategory, + NvU32 dwHintName, + NvU32 *pdwHintValue); +#endif //defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) + +#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_BeginResourceRendering +// +//! \fn NvAPI_D3D_BeginResourceRendering(IUnknown *pDeviceOrContext, NVDX_ObjectHandle obj, NvU32 Flags) +//! DESCRIPTION: This function tells the driver that the resource will begin to receive updates. It must be used in combination with NvAPI_D3D_EndResourceRendering(). +//! The primary use of this function is allow the driver to initiate early inter-frame synchronization of resources while running in AFR SLI mode. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [in] pDev IDirect3DDevice9, ID3D10Device, ID3D11Device or ID3D11DeviceContext that is using the resource +//! \param [in] obj Previously obtained HV resource handle +//! \param [in] Flags The flags for functionality applied to resource while being used. +//! +//! \retval ::NVAPI_OK Function succeeded, if used properly and driver can initiate proper sync'ing of the resources. +//! \retval ::NVAPI_INVALID_ARGUMENT Bad argument(s) or invalid flag values +//! \retval ::NVAPI_INVALID_CALL Mismatched begin/end calls +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup dx +//! Used in NvAPI_D3D_BeginResourceRendering(). +typedef enum _NVAPI_D3D_RESOURCERENDERING_FLAG +{ + NVAPI_D3D_RR_FLAG_DEFAULTS = 0x00000000, //!< All bits set to 0 are defaults. + NVAPI_D3D_RR_FLAG_FORCE_DISCARD_CONTENT = 0x00000001, //!< (bit 0) The flag forces to discard previous content of the resource regardless of the NvApiHints_Sli_Disable_InterframeSync hint + NVAPI_D3D_RR_FLAG_FORCE_KEEP_CONTENT = 0x00000002, //!< (bit 1) The flag forces to respect previous content of the resource regardless of the NvApiHints_Sli_Disable_InterframeSync hint + NVAPI_D3D_RR_FLAG_MULTI_FRAME = 0x00000004 //!< (bit 2) The flag hints the driver that content will be used for many frames. If not specified then the driver assumes that content is used only on the next frame +} NVAPI_D3D_RESOURCERENDERING_FLAG; + +//! \ingroup dx +NVAPI_INTERFACE NvAPI_D3D_BeginResourceRendering(IUnknown *pDeviceOrContext, NVDX_ObjectHandle obj, NvU32 Flags); + +#endif //defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) + +#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_D3D_EndResourceRendering +// +//! DESCRIPTION: This function tells the driver that the resource is done receiving updates. It must be used in combination with +//! NvAPI_D3D_BeginResourceRendering(). +//! The primary use of this function is allow the driver to initiate early inter-frame syncs of resources while running in AFR SLI mode. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 185 +//! +//! \param [in] pDev IDirect3DDevice9, ID3D10Device, ID3D11Device or ID3D11DeviceContext that is using the resource +//! \param [in] obj Previously obtained HV resource handle +//! \param [in] Flags Reserved, must be zero +// +//! \retval ::NVAPI_OK Function succeeded, if used properly and driver can initiate proper sync'ing of the resources. +//! \retval ::NVAPI_INVALID_ARGUMENT Bad argument(s) or invalid flag values +//! \retval ::NVAPI_INVALID_CALL Mismatched begin/end calls +//! +//! \ingroup dx +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_D3D_EndResourceRendering(IUnknown *pDeviceOrContext, NVDX_ObjectHandle obj, NvU32 Flags); +#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) + +#include"nvapi_lite_salend.h" +#ifdef __cplusplus +} +#endif +#pragma pack(pop) diff --git a/thirdparty/nvapi/nvapi_lite_stereo.h b/thirdparty/nvapi/nvapi_lite_stereo.h new file mode 100644 index 0000000..1cbeb23 --- /dev/null +++ b/thirdparty/nvapi/nvapi_lite_stereo.h @@ -0,0 +1,600 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + +#pragma once +#include"nvapi_lite_salstart.h" +#include"nvapi_lite_common.h" +#pragma pack(push,8) +#ifdef __cplusplus +extern "C" { +#endif +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_Enable +// +//! DESCRIPTION: This APU enables stereo mode in the registry. +//! Calls to this function affect the entire system. +//! If stereo is not enabled, then calls to functions that require that stereo is enabled have no effect, +//! and will return the appropriate error code. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \retval ::NVAPI_OK Stereo is now enabled. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_Enable(void); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_Disable +// +//! DESCRIPTION: This API disables stereo mode in the registry. +//! Calls to this function affect the entire system. +//! If stereo is not enabled, then calls to functions that require that stereo is enabled have no effect, +//! and will return the appropriate error code. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \retval ::NVAPI_OK Stereo is now disabled. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_Disable(void); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_IsEnabled +// +//! DESCRIPTION: This API checks if stereo mode is enabled in the registry. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [out] pIsStereoEnabled Address where the result of the inquiry will be placed. +//! +//! \retval ::NVAPI_OK Check was sucessfully completed and result reflects current state of stereo availability. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_IsEnabled(NvU8 *pIsStereoEnabled); +#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)|| defined(__d3d12_h__) + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_CreateHandleFromIUnknown +// +//! DESCRIPTION: This API creates a stereo handle that is used in subsequent calls related to a given device interface. +//! This must be called before any other NvAPI_Stereo_ function for that handle. +//! Multiple devices can be used at one time using multiple calls to this function (one per each device). +//! +//! HOW TO USE: After the Direct3D device is created, create the stereo handle. +//! On call success: +//! -# Use all other NvAPI_Stereo_ functions that have stereo handle as first parameter. +//! -# After the device interface that corresponds to the the stereo handle is destroyed, +//! the application should call NvAPI_DestroyStereoHandle() for that stereo handle. +//! +//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [in] pDevice Pointer to IUnknown interface that is IDirect3DDevice9* in DX9, ID3D10Device*. +//! \param [out] pStereoHandle Pointer to the newly created stereo handle. +//! +//! \retval ::NVAPI_OK Stereo handle is created for given device interface. +//! \retval ::NVAPI_INVALID_ARGUMENT Provided device interface is invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_CreateHandleFromIUnknown(IUnknown *pDevice, StereoHandle *pStereoHandle); + +#endif // defined(_D3D9_H_) || defined(__d3d10_h__) +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_DestroyHandle +// +//! DESCRIPTION: This API destroys the stereo handle created with one of the NvAPI_Stereo_CreateHandleFrom() functions. +//! This should be called after the device corresponding to the handle has been destroyed. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [in] stereoHandle Stereo handle that is to be destroyed. +//! +//! \retval ::NVAPI_OK Stereo handle is destroyed. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_DestroyHandle(StereoHandle stereoHandle); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_Activate +// +//! DESCRIPTION: This API activates stereo for the device interface corresponding to the given stereo handle. +//! Activating stereo is possible only if stereo was enabled previously in the registry. +//! If stereo is not activated, then calls to functions that require that stereo is activated have no effect, +//! and will return the appropriate error code. +//! +//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [in] stereoHandle Stereo handle corresponding to the device interface. +//! +//! \retval ::NVAPI_OK Stereo is turned on. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_Activate(StereoHandle stereoHandle); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_Deactivate +// +//! DESCRIPTION: This API deactivates stereo for the given device interface. +//! If stereo is not activated, then calls to functions that require that stereo is activated have no effect, +//! and will return the appropriate error code. +//! +//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [in] stereoHandle Stereo handle that corresponds to the device interface. +//! +//! \retval ::NVAPI_OK Stereo is turned off. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_Deactivate(StereoHandle stereoHandle); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_IsActivated +// +//! DESCRIPTION: This API checks if stereo is activated for the given device interface. +//! +//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [in] stereoHandle Stereo handle that corresponds to the device interface. +//! \param [in] pIsStereoOn Address where result of the inquiry will be placed. +//! +//! \retval ::NVAPI_OK - Check was sucessfully completed and result reflects current state of stereo (on/off). +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE - Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized. +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED - Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR - Something is wrong (generic error). +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_IsActivated(StereoHandle stereoHandle, NvU8 *pIsStereoOn); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_GetSeparation +// +//! DESCRIPTION: This API gets current separation value (in percents). +//! +//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [in] stereoHandle Stereo handle that corresponds to the device interface. +//! \param [out] pSeparationPercentage Address of @c float type variable to store current separation percentage in. +//! +//! \retval ::NVAPI_OK Retrieval of separation percentage was successfull. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_GetSeparation(StereoHandle stereoHandle, float *pSeparationPercentage); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_SetSeparation +// +//! DESCRIPTION: This API sets separation to given percentage. +//! +//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to appropriate NvAPI_Stereo_CreateHandleFrom() function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [in] stereoHandle Stereo handle that corresponds to the device interface. +//! \param [in] newSeparationPercentage New value for separation percentage. +//! +//! \retval ::NVAPI_OK Setting of separation percentage was successfull. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized. +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_STEREO_PARAMETER_OUT_OF_RANGE Given separation percentage is out of [0..100] range. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_SetSeparation(StereoHandle stereoHandle, float newSeparationPercentage); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_GetConvergence +// +//! DESCRIPTION: This API gets the current convergence value. +//! +//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [in] stereoHandle Stereo handle that corresponds to the device interface. +//! \param [out] pConvergence Address of @c float type variable to store current convergence value in. +//! +//! \retval ::NVAPI_OK Retrieval of convergence value was successfull. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_GetConvergence(StereoHandle stereoHandle, float *pConvergence); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_SetConvergence +// +//! DESCRIPTION: This API sets convergence to the given value. +//! +//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \since Release: 180 +//! +//! \param [in] stereoHandle Stereo handle that corresponds to the device interface. +//! \param [in] newConvergence New value for convergence. +//! +//! \retval ::NVAPI_OK Setting of convergence value was successfull. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_SetConvergence(StereoHandle stereoHandle, float newConvergence); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_SetActiveEye +// +//! \fn NvAPI_Stereo_SetActiveEye(StereoHandle hStereoHandle, NV_STEREO_ACTIVE_EYE StereoEye); +//! DESCRIPTION: This API sets the back buffer to left or right in Direct stereo mode. +//! +//! HOW TO USE: After the stereo handle for device interface is created via successfull call to appropriate +//! NvAPI_Stereo_CreateHandleFrom function. +//! +//! \since Release: 285 +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] stereoHandle Stereo handle that corresponds to the device interface. +//! \param [in] StereoEye Defines active eye in Direct stereo mode +//! +//! \retval ::NVAPI_OK - Active eye is set. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE - Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized. +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED - Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_INVALID_ARGUMENT - StereoEye parameter has not allowed value. +//! \retval ::NVAPI_SET_NOT_ALLOWED - Current stereo mode is not Direct +//! \retval ::NVAPI_ERROR - Something is wrong (generic error). +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup stereoapi +typedef enum _NV_StereoActiveEye +{ + NVAPI_STEREO_EYE_RIGHT = 1, + NVAPI_STEREO_EYE_LEFT = 2, + NVAPI_STEREO_EYE_MONO = 3, +} NV_STEREO_ACTIVE_EYE; + +//! \ingroup stereoapi +NVAPI_INTERFACE NvAPI_Stereo_SetActiveEye(StereoHandle hStereoHandle, NV_STEREO_ACTIVE_EYE StereoEye); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_SetDriverMode +// +//! \fn NvAPI_Stereo_SetDriverMode( NV_STEREO_DRIVER_MODE mode ); +//! DESCRIPTION: This API sets the 3D stereo driver mode: Direct or Automatic +//! +//! HOW TO USE: This API must be called before the device is created. +//! Applies to DirectX 9 and higher. +//! +//! \since Release: 285 +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] mode Defines the 3D stereo driver mode: Direct or Automatic +//! +//! \retval ::NVAPI_OK Active eye is set. +//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized. +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_INVALID_ARGUMENT mode parameter has not allowed value. +//! \retval ::NVAPI_ERROR Something is wrong (generic error). +// +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup stereoapi +typedef enum _NV_StereoDriverMode +{ + NVAPI_STEREO_DRIVER_MODE_AUTOMATIC = 0, + NVAPI_STEREO_DRIVER_MODE_DIRECT = 2, +} NV_STEREO_DRIVER_MODE; + +//! \ingroup stereoapi +NVAPI_INTERFACE NvAPI_Stereo_SetDriverMode( NV_STEREO_DRIVER_MODE mode ); + +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_GetEyeSeparation +// +//! DESCRIPTION: This API returns eye separation as a ratio of /. +//! +//! HOW TO USE: After the stereo handle for device interface is created via successfull call to appropriate API. Applies only to DirectX 9 and up. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [in] stereoHandle Stereo handle that corresponds to the device interface. +//! \param [out] pSeparation Eye separation. +//! +//! \retval ::NVAPI_OK Active eye is set. +//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again. +//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized. +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR (generic error). +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_GetEyeSeparation(StereoHandle hStereoHandle, float *pSeparation ); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_IsWindowedModeSupported +// +//! DESCRIPTION: This API returns availability of windowed mode stereo +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! \param [out] bSupported(OUT) != 0 - supported, \n +//! == 0 - is not supported +//! +//! +//! \retval ::NVAPI_OK Retrieval of frustum adjust mode was successfull. +//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized. +//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized. +//! \retval ::NVAPI_ERROR Something is wrong (generic error). +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_IsWindowedModeSupported(NvU8* bSupported); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_SetSurfaceCreationMode +// +//! \function NvAPI_Stereo_SetSurfaceCreationMode(StereoHandle hStereoHandle, NVAPI_STEREO_SURFACECREATEMODE creationMode) +//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface. +//! \param [in] creationMode New surface creation mode for this device interface. +//! +//! \since Release: 285 +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! DESCRIPTION: This API sets surface creation mode for this device interface. +//! +//! WHEN TO USE: After the stereo handle for device interface is created via successful call to appropriate NvAPI_Stereo_CreateHandleFrom function. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! There are no return error codes with specific meaning for this API. +//! +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup stereoapi +typedef enum _NVAPI_STEREO_SURFACECREATEMODE +{ + NVAPI_STEREO_SURFACECREATEMODE_AUTO, //!< Use driver registry profile settings for surface creation mode. + NVAPI_STEREO_SURFACECREATEMODE_FORCESTEREO, //!< Always create stereo surfaces. + NVAPI_STEREO_SURFACECREATEMODE_FORCEMONO //!< Always create mono surfaces. +} NVAPI_STEREO_SURFACECREATEMODE; + +//! \ingroup stereoapi +NVAPI_INTERFACE NvAPI_Stereo_SetSurfaceCreationMode(__in StereoHandle hStereoHandle, __in NVAPI_STEREO_SURFACECREATEMODE creationMode); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_GetSurfaceCreationMode +// +//! \function NvAPI_Stereo_GetSurfaceCreationMode(StereoHandle hStereoHandle, NVAPI_STEREO_SURFACECREATEMODE* pCreationMode) +//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface. +//! \param [out] pCreationMode The current creation mode for this device interface. +//! +//! \since Release: 295 +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! DESCRIPTION: This API gets surface creation mode for this device interface. +//! +//! WHEN TO USE: After the stereo handle for device interface is created via successful call to appropriate NvAPI_Stereo_CreateHandleFrom function. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! There are no return error codes with specific meaning for this API. +//! +/////////////////////////////////////////////////////////////////////////////// + +//! \ingroup stereoapi +NVAPI_INTERFACE NvAPI_Stereo_GetSurfaceCreationMode(__in StereoHandle hStereoHandle, __in NVAPI_STEREO_SURFACECREATEMODE* pCreationMode); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_Debug_WasLastDrawStereoized +// +//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface. +//! \param [out] pWasStereoized Address where result of the inquiry will be placed. +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! DESCRIPTION: This API checks if the last draw call was stereoized. It is a very expensive to call and should be used for debugging purpose *only*. +//! +//! WHEN TO USE: After the stereo handle for device interface is created via successful call to appropriate NvAPI_Stereo_CreateHandleFrom function. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! There are no return error codes with specific meaning for this API. +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_Debug_WasLastDrawStereoized(__in StereoHandle hStereoHandle, __out NvU8 *pWasStereoized); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_SetDefaultProfile +// +//! +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! DESCRIPTION: This API defines the stereo profile used by the driver in case the application has no associated profile. +//! +//! WHEN TO USE: To take effect, this API must be called before D3D device is created. Calling once a device has been created will not affect the current device. +//! +//! \param [in] szProfileName Default profile name. +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! Error codes specific to this API are described below. +//! +//! \retval NVAPI_SUCCESS - Default stereo profile name has been copied into szProfileName. +//! \retval NVAPI_INVALID_ARGUMENT - szProfileName == NULL. +//! \retval NVAPI_DEFAULT_STEREO_PROFILE_DOES_NOT_EXIST - Default stereo profile does not exist +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_SetDefaultProfile(__in const char* szProfileName); +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Stereo_GetDefaultProfile +// +//! SUPPORTED OS: Windows 7 and higher +//! +//! +//! DESCRIPTION: This API retrieves the current default stereo profile. +//! +//! After call cbSizeOut contain 0 if default profile is not set required buffer size cbSizeOut. +//! To get needed buffer size this function can be called with szProfileName==0 and cbSizeIn == 0. +//! +//! WHEN TO USE: This API can be called at any time. +//! +//! +//! \param [in] cbSizeIn Size of buffer allocated for default stereo profile name. +//! \param [out] szProfileName Default stereo profile name. +//! \param [out] pcbSizeOut Required buffer size. +//! # ==0 - there is no default stereo profile name currently set +//! # !=0 - size of buffer required for currently set default stereo profile name including trailing '0'. +//! +//! +//! \return This API can return any of the error codes enumerated in #NvAPI_Status. +//! Error codes specific to this API are described below. +//! +//! \retval NVAPI_SUCCESS - Default stereo profile name has been copied into szProfileName. +//! \retval NVAPI_DEFAULT_STEREO_PROFILE_IS_NOT_DEFINED - There is no default stereo profile set at this time. +//! \retval NVAPI_INVALID_ARGUMENT - pcbSizeOut == 0 or cbSizeIn >= *pcbSizeOut && szProfileName == 0 +//! \retval NVAPI_INSUFFICIENT_BUFFER - cbSizeIn < *pcbSizeOut +//! +//! \ingroup stereoapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Stereo_GetDefaultProfile( __in NvU32 cbSizeIn, __out_bcount_part_opt(cbSizeIn, *pcbSizeOut) char* szProfileName, __out NvU32 *pcbSizeOut); + +#include"nvapi_lite_salend.h" +#ifdef __cplusplus +} +#endif +#pragma pack(pop) diff --git a/thirdparty/nvapi/nvapi_lite_surround.h b/thirdparty/nvapi/nvapi_lite_surround.h new file mode 100644 index 0000000..e680dd2 --- /dev/null +++ b/thirdparty/nvapi/nvapi_lite_surround.h @@ -0,0 +1,105 @@ + /************************************************************************************************************************************\ +|* *| +|* Copyright ? 2012 NVIDIA Corporation. All rights reserved. *| +|* *| +|* NOTICE TO USER: *| +|* *| +|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *| +|* *| +|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *| +|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *| +|* Otherwise, you have no rights to use or access this software in any manner. *| +|* *| +|* If not covered by the applicable NVIDIA software license agreement: *| +|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *| +|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *| +|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *| +|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *| +|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *| +|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *| +|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| +|* *| +|* U.S. Government End Users. *| +|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| +|* consisting of "commercial computer software" and "commercial computer software documentation" *| +|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *| +|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| +|* all U.S. Government End Users acquire the software with only those rights set forth herein. *| +|* *| +|* Any use of this software in individual and commercial software must include, *| +|* in the user documentation and internal comments to the code, *| +|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *| +|* *| + \************************************************************************************************************************************/ + +#pragma once +#include"nvapi_lite_salstart.h" +#include"nvapi_lite_common.h" +#pragma pack(push,8) +#ifdef __cplusplus +extern "C" { +#endif +//! SUPPORTED OS: Windows 7 and higher +//! +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_DISP_GetGDIPrimaryDisplayId +// +//! DESCRIPTION: This API returns the Display ID of the GDI Primary. +//! +//! \param [out] displayId Display ID of the GDI Primary display. +//! +//! \retval ::NVAPI_OK: Capabilties have been returned. +//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND: GDI Primary not on an NVIDIA GPU. +//! \retval ::NVAPI_INVALID_ARGUMENT: One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED: The NvAPI API needs to be initialized first +//! \retval ::NVAPI_NO_IMPLEMENTATION: This entrypoint not available +//! \retval ::NVAPI_ERROR: Miscellaneous error occurred +//! +//! \ingroup dispcontrol +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_DISP_GetGDIPrimaryDisplayId(NvU32* displayId); +#define NV_MOSAIC_MAX_DISPLAYS (64) +//! SUPPORTED OS: Windows 7 and higher +//! +/////////////////////////////////////////////////////////////////////////////// +// +// FUNCTION NAME: NvAPI_Mosaic_GetDisplayViewportsByResolution +// +//! DESCRIPTION: This API returns the viewports that would be applied on +//! the requested display. +//! +//! \param [in] displayId Display ID of a single display in the active +//! mosaic topology to query. +//! \param [in] srcWidth Width of full display topology. If both +//! width and height are 0, the current +//! resolution is used. +//! \param [in] srcHeight Height of full display topology. If both +//! width and height are 0, the current +//! resolution is used. +//! \param [out] viewports Array of NV_RECT viewports which represent +//! the displays as identified in +//! NvAPI_Mosaic_EnumGridTopologies. If the +//! requested resolution is a single-wide +//! resolution, only viewports[0] will +//! contain the viewport details, regardless +//! of which display is driving the display. +//! \param [out] bezelCorrected Returns 1 if the requested resolution is +//! bezel corrected. May be NULL. +//! +//! \retval ::NVAPI_OK Capabilties have been returned. +//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid. +//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first +//! \retval ::NVAPI_MOSAIC_NOT_ACTIVE The display does not belong to an active Mosaic Topology +//! \retval ::NVAPI_NO_IMPLEMENTATION This entrypoint not available +//! \retval ::NVAPI_ERROR Miscellaneous error occurred +//! +//! \ingroup mosaicapi +/////////////////////////////////////////////////////////////////////////////// +NVAPI_INTERFACE NvAPI_Mosaic_GetDisplayViewportsByResolution(NvU32 displayId, NvU32 srcWidth, NvU32 srcHeight, NV_RECT viewports[NV_MOSAIC_MAX_DISPLAYS], NvU8* bezelCorrected); + +#include"nvapi_lite_salend.h" +#ifdef __cplusplus +} +#endif +#pragma pack(pop)