summaryrefslogtreecommitdiffstats
path: root/tools/gfx/debug-layer/debug-transient-heap.cpp
blob: 424a8feb171e3224e92fc9670b0a1b24e020df48 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// debug-transient-heap.cpp
#include "debug-transient-heap.h"

#include "debug-command-buffer.h"
#include "debug-helper-functions.h"

namespace gfx
{
using namespace Slang;

namespace debug
{

SlangResult DebugTransientResourceHeap::queryInterface(SlangUUID const& uuid, void** outObject)
{
    if (uuid == GfxGUID::IID_ISlangUnknown || uuid == GfxGUID::IID_ITransientResourceHeap)
        *outObject = static_cast<ITransientResourceHeap*>(this);
    if (uuid == GfxGUID::IID_ITransientResourceHeapD3D12)
    {
        RefPtr<DebugTransientResourceHeapD3D12> result = new DebugTransientResourceHeapD3D12();
        baseObject->queryInterface(uuid, (void**)result->baseObject.writeRef());
        returnComPtr((ITransientResourceHeapD3D12**)outObject, result);
        return SLANG_OK;
    }
    else
    {
        return baseObject->queryInterface(uuid, outObject);
    }
}

Result DebugTransientResourceHeap::synchronizeAndReset()
{
    SLANG_GFX_API_FUNC;
    return baseObject->synchronizeAndReset();
}

Result DebugTransientResourceHeap::finish()
{
    SLANG_GFX_API_FUNC;
    return baseObject->finish();
}

Result DebugTransientResourceHeap::createCommandBuffer(ICommandBuffer** outCommandBuffer)
{
    SLANG_GFX_API_FUNC;
    RefPtr<DebugCommandBuffer> outObject = new DebugCommandBuffer();
    outObject->m_transientHeap = this;
    auto result = baseObject->createCommandBuffer(outObject->baseObject.writeRef());
    if (SLANG_FAILED(result))
        return result;
    outObject->queryInterface(SlangUUID SLANG_UUID_ICommandBuffer, (void**)outCommandBuffer);
    return result;
}

SlangResult DebugTransientResourceHeapD3D12::queryInterface(SlangUUID const& uuid, void** outObject)
{
    if (uuid == GfxGUID::IID_ISlangUnknown || uuid == GfxGUID::IID_ITransientResourceHeapD3D12)
        *outObject = static_cast<ITransientResourceHeapD3D12*>(this);
    if (uuid == GfxGUID::IID_ITransientResourceHeap)
    {
        RefPtr<DebugTransientResourceHeap> result = new DebugTransientResourceHeap();
        baseObject->queryInterface(uuid, (void**)result->baseObject.writeRef());
        returnComPtr((ITransientResourceHeap**)outObject, result);
        return SLANG_OK;
    }
    else
    {
        return baseObject->queryInterface(uuid, outObject);
    }
}

Result DebugTransientResourceHeapD3D12::allocateTransientDescriptorTable(
    DescriptorType type,
    GfxCount count,
    Offset& outDescriptorOffset,
    void** outD3DDescriptorHeapHandle)
{
    SLANG_GFX_API_FUNC;

    return baseObject->allocateTransientDescriptorTable(
        type,
        count,
        outDescriptorOffset,
        outD3DDescriptorHeapHandle);
}

} // namespace debug
} // namespace gfx