diff options
| author | lucy96chen <47800040+lucy96chen@users.noreply.github.com> | 2022-06-30 11:09:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-30 11:09:45 -0700 |
| commit | 5eee6b03c391d0bb6ed0ded2d8d91c2e525fdb97 (patch) | |
| tree | 0d47d3ebc385699ff195c8a19400dd3780107667 /tools/gfx/d3d11/d3d11-scopeNVAPI.cpp | |
| parent | abc100f81d4b22229105f9ed569a7efafc653a3a (diff) | |
Split render-d3d11.cpp into smaller files (#2307)
* render-d3d11 split, does not compile
* Compiles but unit tests failing
* ran premake.bat
* Readded constructor code that was accidentally removed
Diffstat (limited to 'tools/gfx/d3d11/d3d11-scopeNVAPI.cpp')
| -rw-r--r-- | tools/gfx/d3d11/d3d11-scopeNVAPI.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/gfx/d3d11/d3d11-scopeNVAPI.cpp b/tools/gfx/d3d11/d3d11-scopeNVAPI.cpp new file mode 100644 index 000000000..b230623fe --- /dev/null +++ b/tools/gfx/d3d11/d3d11-scopeNVAPI.cpp @@ -0,0 +1,49 @@ +// d3d11-scopeNVAPI.cpp +#include "d3d11-scopeNVAPI.h" + +#include "d3d11-device.h" + +namespace gfx +{ + +using namespace Slang; + +namespace d3d11 +{ + +SlangResult ScopeNVAPI::init(DeviceImpl* device, Index regIndex) +{ + if (!device->m_nvapi) + { + // There is nothing to set as nvapi is not set + return SLANG_OK; + } + +#ifdef GFX_NVAPI + NvAPI_Status nvapiStatus = NvAPI_D3D11_SetNvShaderExtnSlot(renderer->m_device, NvU32(regIndex)); + if (nvapiStatus != NVAPI_OK) + { + return SLANG_FAIL; + } +#endif + + // Record the renderer so it can be freed + m_renderer = device; + return SLANG_OK; +} + +ScopeNVAPI::~ScopeNVAPI() +{ + // If the m_renderer is not set, it must not have been set up + if (m_renderer) + { +#ifdef GFX_NVAPI + // Disable the slot used + NvAPI_Status nvapiStatus = NvAPI_D3D11_SetNvShaderExtnSlot(m_renderer->m_device, ~0); + SLANG_ASSERT(nvapiStatus == NVAPI_OK); +#endif + } +} + +} // namespace d3d11 +} // namespace gfx |
