yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

jsmall-nvidiaPreliminary support for realtime clock (#2772)68c7d5cda

master
986 B49 linesraw
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{
16    if (!device->m_nvapi)
17    {
18        // There is nothing to set as nvapi is not set
19        return SLANG_OK;
20    }
21
22#ifdef GFX_NVAPI
23    NvAPI_Status nvapiStatus = NvAPI_D3D11_SetNvShaderExtnSlot(device->m_device, NvU32(regIndex));
24    if (nvapiStatus != NVAPI_OK)
25    {
26        return SLANG_FAIL;
27    }
28#endif
29
30    // Record the renderer so it can be freed
31    m_renderer = device;
32    return SLANG_OK;
33}
34
35ScopeNVAPI::~ScopeNVAPI()
36{
37    // If the m_renderer is not set, it must not have been set up
38    if (m_renderer)
39    {
40#ifdef GFX_NVAPI
41        // Disable the slot used
42        NvAPI_Status nvapiStatus = NvAPI_D3D11_SetNvShaderExtnSlot(m_renderer->m_device, ~0);
43        SLANG_ASSERT(nvapiStatus == NVAPI_OK);
44#endif
45    }
46}
47
48} // namespace d3d11
49} // namespace gfx