summaryrefslogtreecommitdiffstats
path: root/docs/target-compatibility.md
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-08-21 16:04:42 -0400
committerGitHub <noreply@github.com>2020-08-21 13:04:42 -0700
commitfcac02e405661de311b5ceebbd6d3e2c78bf8aea (patch)
tree6e79865b39f0739d2ac9c3f91cc4129c244b6977 /docs/target-compatibility.md
parent49067fd2e97b40649df3fa2ce096f78c2e45da5a (diff)
Vulkan update/NVAPI support (#1511)
* First pass at incorporating nvapi into test harness. * D3d12 Atomic Float Add via NVAPI working * Dx12 atomic float appears to work. * Atomic float add on Dx12. * Added atomic64 feature addition to vk. Fix correct output for atomic-float-byte-address.slang * Disable atomic float failing tests. * Upgraded VK headers. * Detect atomic float availability on VK. * Try to get test working for in64 atomic. * Made HLSL prelude controlled via the render-test requirements. * Added -enable-nvapi to premake. * Fix D3D12Renderer when NVAPI is not available. * Small improvements to VKRenderer. * Improve atomic documentation in target-compatibility.md.
Diffstat (limited to 'docs/target-compatibility.md')
-rw-r--r--docs/target-compatibility.md32
1 files changed, 30 insertions, 2 deletions
diff --git a/docs/target-compatibility.md b/docs/target-compatibility.md
index ecc89694e..f5b402af3 100644
--- a/docs/target-compatibility.md
+++ b/docs/target-compatibility.md
@@ -192,9 +192,37 @@ void RWByteAddressBuffer::InterlockedAddI64(uint byteAddress, int64_t valueToAdd
void RWByteAddressBuffer::InterlockedAddI64(uint byteAddress, int64_t valueToAdd);
```
-On HLSL based targets this functionality is achieved using [NVAPI](https://developer.nvidia.com/nvapi) based functionality. Therefore for the feature to work you must have NVAPI installed on your system. Then the 'prelude' functionality allows via the API for an include (or the text) of the relevent files. To see how to do this in practice look at the function `setSessionDefaultPrelude`. This makes the prelude for HLSL hold an include to the *absolute* path to the required include file `nvHLSLExtns.h`. As an absolute path is used, it means other includes that includes, look in the correct place without having to set up special include paths.
+On HLSL based targets this functionality is achieved using [NVAPI](https://developer.nvidia.com/nvapi). For this to work it is necessary to have NVAPI available on your system. The 'prelude' functionality in the Slang API allows for text to be inserted before any Slang code generated code is output. If the input source uses an NVAPI feature - like the methods above - it will output code that *assumes* that `nvHLSLExtns.h` is included. The following code from `render-test-main.cpp` sets up a suitable prelude for HLSL that includes `nvHLSLExtns.h` with an absolute path.
-To use NVAPI it is nessary to specify a unordered access views (UAV) based 'u' register that will be used to communicate with NVAPI. Note! Slang does not do any special handling around this, it will be necessary for application code to ensure the UAV is either guarenteed to not collide with what Slang assigns, or it's specified (but not used) in the Slang source. The u register number has to be specified also to the NVAPI runtime library.
+```
+String rootPath;
+SLANG_RETURN_ON_FAIL(TestToolUtil::getRootPath(exePath, rootPath));
+
+String includePath;
+SLANG_RETURN_ON_FAIL(TestToolUtil::getIncludePath(rootPath, "external/nvapi/nvHLSLExtns.h", includePath));
+
+StringBuilder buf;
+// We have to choose a slot that NVAPI will use.
+buf << "#define NV_SHADER_EXTN_SLOT " << options.nvapiRegister << "\n";
+
+// Include the NVAPI header
+buf << "#include \"" << includePath << "\"\n\n";
+
+session->setLanguagePrelude(SLANG_SOURCE_LANGUAGE_HLSL, buf.getBuffer());
+```
+
+This sets the HLSL prelude to something like...
+
+```
+#define NV_SHADER_EXTN_SLOT u0
+#include "d:/path/to/nvapi/nvHLSLExtns.h"
+```
+
+Note the use of the *absolute* path to the file `nvHLSLExtns.h`. Doing so means the other includes that `nvHLSLExtns.h` includes look in the correct place without having to set up special include paths. As is required by using NVAPI, before the include it is necessary to specify what UAV will be used.
+
+To use NVAPI it is nessary to specify a unordered access views (UAV) based 'u' register that will be used to communicate with NVAPI.
+
+Note! Slang does not do any special handling around this, it will be necessary for application code to ensure the UAV is either guarenteed to not collide with what Slang assigns, or it's specified (but not used) in the Slang source. The u register number has to be specified also to the NVAPI runtime library.
On Vulkan, for float the [`GL_EXT_shader_atomic_float`](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT_shader_atomic_float.html) extension is required. For int64 the [`GL_EXT_shader_atomic_int64`](https://raw.githubusercontent.com/KhronosGroup/GLSL/master/extensions/ext/GL_EXT_shader_atomic_int64.txt) extension is required.