summaryrefslogtreecommitdiff
path: root/tools/gfx/d3d12/d3d12-command-queue.h
blob: dadb85d176c8102bc2761718f97674b4caa17752 (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
43
44
45
46
47
48
49
// d3d12-command-queue.h
#pragma once

#include "d3d12-base.h"

namespace gfx
{
namespace d3d12
{

using namespace Slang;

class CommandQueueImpl : public ICommandQueue, public ComObject
{
public:
    SLANG_COM_OBJECT_IUNKNOWN_ALL
    ICommandQueue* getInterface(const Guid& guid);
    void breakStrongReferenceToDevice() { m_renderer.breakStrongReference(); }

    virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* handle) override;

public:
    BreakableReference<DeviceImpl> m_renderer;
    ComPtr<ID3D12Device> m_device;
    ComPtr<ID3D12CommandQueue> m_d3dQueue;
    ComPtr<ID3D12Fence> m_fence;
    uint64_t m_fenceValue = 0;
    HANDLE globalWaitHandle;
    Desc m_desc;
    uint32_t m_queueIndex = 0;

    Result init(DeviceImpl* device, uint32_t queueIndex);
    ~CommandQueueImpl();
    virtual SLANG_NO_THROW const Desc& SLANG_MCALL getDesc() override;

    virtual SLANG_NO_THROW void SLANG_MCALL executeCommandBuffers(
        GfxCount count,
        ICommandBuffer* const* commandBuffers,
        IFence* fence,
        uint64_t valueToSignal) override;

    virtual SLANG_NO_THROW void SLANG_MCALL waitOnHost() override;

    virtual SLANG_NO_THROW Result SLANG_MCALL
    waitForFenceValuesOnDevice(GfxCount fenceCount, IFence** fences, uint64_t* waitValues) override;
};

} // namespace d3d12
} // namespace gfx