summaryrefslogtreecommitdiffstats
path: root/tools/gfx/vulkan/vk-transient-heap.h
blob: 8a0f7a74da904733c6b23e0ca4f9b2dcb03383f5 (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
40
41
42
// vk-transient-heap.h
#pragma once

#include "vk-base.h"
#include "vk-buffer.h"
#include "vk-command-buffer.h"

namespace gfx
{

using namespace Slang;

namespace vk
{

class TransientResourceHeapImpl
    : public TransientResourceHeapBaseImpl<DeviceImpl, BufferResourceImpl>
{
private:
    typedef TransientResourceHeapBaseImpl<DeviceImpl, BufferResourceImpl> Super;

public:
    VkCommandPool m_commandPool;
    DescriptorSetAllocator m_descSetAllocator;
    List<VkFence> m_fences;
    Index m_fenceIndex = -1;
    List<RefPtr<CommandBufferImpl>> m_commandBufferPool;
    uint32_t m_commandBufferAllocId = 0;
    VkFence getCurrentFence() { return m_fences[m_fenceIndex]; }
    void advanceFence();

    Result init(const ITransientResourceHeap::Desc& desc, DeviceImpl* device);
    ~TransientResourceHeapImpl();

public:
    virtual SLANG_NO_THROW Result SLANG_MCALL
    createCommandBuffer(ICommandBuffer** outCommandBuffer) override;
    virtual SLANG_NO_THROW Result SLANG_MCALL synchronizeAndReset() override;
};

} // namespace vk
} // namespace gfx