summaryrefslogtreecommitdiff
path: root/tools/gfx/cuda/cuda-buffer.h
blob: 838a06555b40e6d5cad1b04fb9dd53f3ec2a7cc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// cuda-buffer.h
#pragma once
#include "cuda-base.h"
#include "cuda-context.h"

namespace gfx
{
#ifdef GFX_ENABLE_CUDA
using namespace Slang;

namespace cuda
{

class BufferResourceImpl : public BufferResource
{
public:
    BufferResourceImpl(const Desc& _desc)
        : BufferResource(_desc)
    {}

    ~BufferResourceImpl();

    uint64_t getBindlessHandle();

    void* m_cudaExternalMemory = nullptr;
    void* m_cudaMemory = nullptr;

    RefPtr<CUDAContext> m_cudaContext;

    virtual SLANG_NO_THROW DeviceAddress SLANG_MCALL getDeviceAddress() override;
    virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) override;
    virtual SLANG_NO_THROW Result SLANG_MCALL
        map(MemoryRange* rangeToRead, void** outPointer) override;
    virtual SLANG_NO_THROW Result SLANG_MCALL unmap(MemoryRange* writtenRange) override;
};

} // namespace cuda
#endif
} // namespace gfx