yum-mirror/slang

Making it easier to work with shaders

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

Ellie Hermaszewskaformatf65d756bf

master
2.1 KiB88 linesraw
1// vk-resource-views.h
2#pragma once
3
4#include "vk-base.h"
5#include "vk-buffer.h"
6#include "vk-device.h"
7#include "vk-texture.h"
8
9namespace gfx
10{
11
12using namespace Slang;
13
14namespace vk
15{
16
17class ResourceViewImpl : public ResourceViewBase
18{
19public:
20    enum class ViewType
21    {
22        Texture,
23        TexelBuffer,
24        PlainBuffer,
25    };
26
27public:
28    ResourceViewImpl(ViewType viewType, DeviceImpl* device)
29        : m_type(viewType), m_device(device)
30    {
31    }
32    ViewType m_type;
33    RefPtr<DeviceImpl> m_device;
34};
35
36class TextureResourceViewImpl : public ResourceViewImpl
37{
38public:
39    TextureResourceViewImpl(DeviceImpl* device)
40        : ResourceViewImpl(ViewType::Texture, device)
41    {
42    }
43    ~TextureResourceViewImpl();
44    RefPtr<TextureResourceImpl> m_texture;
45    VkImageView m_view;
46    VkImageLayout m_layout;
47
48    virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override;
49};
50
51class TexelBufferResourceViewImpl : public ResourceViewImpl
52{
53public:
54    TexelBufferResourceViewImpl(DeviceImpl* device);
55    ~TexelBufferResourceViewImpl();
56    RefPtr<BufferResourceImpl> m_buffer;
57    VkBufferView m_view;
58    virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override;
59};
60
61class PlainBufferResourceViewImpl : public ResourceViewImpl
62{
63public:
64    PlainBufferResourceViewImpl(DeviceImpl* device);
65    RefPtr<BufferResourceImpl> m_buffer;
66    VkDeviceSize offset;
67    VkDeviceSize size;
68
69    virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override;
70};
71
72class AccelerationStructureImpl : public AccelerationStructureBase
73{
74public:
75    VkAccelerationStructureKHR m_vkHandle = VK_NULL_HANDLE;
76    RefPtr<BufferResourceImpl> m_buffer;
77    VkDeviceSize m_offset;
78    VkDeviceSize m_size;
79    RefPtr<DeviceImpl> m_device;
80
81public:
82    virtual SLANG_NO_THROW DeviceAddress SLANG_MCALL getDeviceAddress() override;
83    virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override;
84    ~AccelerationStructureImpl();
85};
86
87} // namespace vk
88} // namespace gfx