yum-mirror/slang

Making it easier to work with shaders

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

Ellie Hermaszewskaformatf65d756bf

master
1.8 KiB75 linesraw
1// vk-resource-views.cpp
2#include "vk-resource-views.h"
3
4namespace gfx
5{
6
7using namespace Slang;
8
9namespace vk
10{
11
12TextureResourceViewImpl::~TextureResourceViewImpl()
13{
14    m_device->m_api.vkDestroyImageView(m_device->m_api.m_device, m_view, nullptr);
15}
16
17Result TextureResourceViewImpl::getNativeHandle(InteropHandle* outHandle)
18{
19    outHandle->api = InteropHandleAPI::Vulkan;
20    outHandle->handleValue = (uint64_t)(m_view);
21    return SLANG_OK;
22}
23
24TexelBufferResourceViewImpl::TexelBufferResourceViewImpl(DeviceImpl* device)
25    : ResourceViewImpl(ViewType::TexelBuffer, device)
26{
27}
28
29TexelBufferResourceViewImpl::~TexelBufferResourceViewImpl()
30{
31    m_device->m_api.vkDestroyBufferView(m_device->m_api.m_device, m_view, nullptr);
32}
33
34Result TexelBufferResourceViewImpl::getNativeHandle(InteropHandle* outHandle)
35{
36    outHandle->api = InteropHandleAPI::Vulkan;
37    outHandle->handleValue = (uint64_t)(m_view);
38    return SLANG_OK;
39}
40
41PlainBufferResourceViewImpl::PlainBufferResourceViewImpl(DeviceImpl* device)
42    : ResourceViewImpl(ViewType::PlainBuffer, device)
43{
44}
45
46Result PlainBufferResourceViewImpl::getNativeHandle(InteropHandle* outHandle)
47{
48    return m_buffer->getNativeResourceHandle(outHandle);
49}
50
51DeviceAddress AccelerationStructureImpl::getDeviceAddress()
52{
53    return m_buffer->getDeviceAddress() + m_offset;
54}
55
56Result AccelerationStructureImpl::getNativeHandle(InteropHandle* outHandle)
57{
58    outHandle->api = InteropHandleAPI::Vulkan;
59    outHandle->handleValue = (uint64_t)(m_vkHandle);
60    return SLANG_OK;
61}
62
63AccelerationStructureImpl::~AccelerationStructureImpl()
64{
65    if (m_device)
66    {
67        m_device->m_api.vkDestroyAccelerationStructureKHR(
68            m_device->m_api.m_device,
69            m_vkHandle,
70            nullptr);
71    }
72}
73
74} // namespace vk
75} // namespace gfx