yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
68c7d5cda
master
1// d3d11-scopeNVAPI.cpp 2#include "d3d11-scopeNVAPI.h" 3 4#include "d3d11-device.h" 5 6namespace gfx 7{ 8 9using namespace Slang ; 10 11namespace d3d11 12{ 13 14SlangResult ScopeNVAPI ::init (DeviceImpl * device ,Index regIndex ) 15{ 16if (!device -> m_nvapi ) 17 { 18// There is nothing to set as nvapi is not set 19return SLANG_OK ; 20 } 21 22#ifdef GFX_NVAPI 23NvAPI_Status nvapiStatus = NvAPI_D3D11_SetNvShaderExtnSlot (device -> m_device ,NvU32 (regIndex )); 24if (nvapiStatus != NVAPI_OK ) 25 { 26return SLANG_FAIL ; 27 } 28#endif 29 30// Record the renderer so it can be freed 31m_renderer = device ; 32return SLANG_OK ; 33} 34 35ScopeNVAPI ::~ScopeNVAPI () 36{ 37// If the m_renderer is not set, it must not have been set up 38if (m_renderer ) 39 { 40#ifdef GFX_NVAPI 41// Disable the slot used 42NvAPI_Status nvapiStatus = NvAPI_D3D11_SetNvShaderExtnSlot (m_renderer -> m_device , ~0 ); 43SLANG_ASSERT (nvapiStatus == NVAPI_OK ); 44#endif 45 } 46} 47 48}// namespace d3d11 49}// namespace gfx