yum-mirror/slang

Making it easier to work with shaders

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

Ellie Hermaszewskaformatf65d756bf

master
2.0 KiB87 linesraw
1// metal-resource-views.h
2#pragma once
3
4#include "metal-base.h"
5#include "metal-buffer.h"
6#include "metal-device.h"
7#include "metal-texture.h"
8
9namespace gfx
10{
11
12using namespace Slang;
13
14namespace metal
15{
16
17class ResourceViewImpl : public ResourceViewBase
18{
19public:
20    enum class ViewType
21    {
22        Texture,
23        Buffer,
24        TexelBuffer,
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    NS::SharedPtr<MTL::Texture> m_textureView;
46
47    virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override;
48};
49
50class BufferResourceViewImpl : public ResourceViewImpl
51{
52public:
53    BufferResourceViewImpl(DeviceImpl* device)
54        : ResourceViewImpl(ViewType::Buffer, device)
55    {
56    }
57    ~BufferResourceViewImpl();
58    RefPtr<BufferResourceImpl> m_buffer;
59    Offset m_offset;
60    Size m_size;
61
62    virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override;
63};
64
65class TexelBufferResourceViewImpl : public ResourceViewImpl
66{
67public:
68    TexelBufferResourceViewImpl(DeviceImpl* device);
69    ~TexelBufferResourceViewImpl();
70    RefPtr<BufferResourceImpl> m_buffer;
71    virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override;
72};
73
74class AccelerationStructureImpl : public AccelerationStructureBase
75{
76public:
77    RefPtr<BufferResourceImpl> m_buffer;
78    RefPtr<DeviceImpl> m_device;
79
80public:
81    virtual SLANG_NO_THROW DeviceAddress SLANG_MCALL getDeviceAddress() override;
82    virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override;
83    ~AccelerationStructureImpl();
84};
85
86} // namespace metal
87} // namespace gfx