yum-mirror/slang

Making it easier to work with shaders

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

Ellie Hermaszewskaformatf65d756bf

master
2.4 KiB91 linesraw
1// debug-command-queue.cpp
2#include "debug-command-queue.h"
3
4#include "debug-command-buffer.h"
5#include "debug-fence.h"
6#include "debug-helper-functions.h"
7#include "debug-transient-heap.h"
8
9namespace gfx
10{
11using namespace Slang;
12
13namespace debug
14{
15
16const ICommandQueue::Desc& DebugCommandQueue::getDesc()
17{
18    SLANG_GFX_API_FUNC;
19    return baseObject->getDesc();
20}
21
22void DebugCommandQueue::executeCommandBuffers(
23    GfxCount count,
24    ICommandBuffer* const* commandBuffers,
25    IFence* fence,
26    uint64_t valueToSignal)
27{
28    SLANG_GFX_API_FUNC;
29    List<ICommandBuffer*> innerCommandBuffers;
30    for (GfxIndex i = 0; i < count; i++)
31    {
32        auto cmdBufferIn = commandBuffers[i];
33        auto cmdBufferImpl = getDebugObj(cmdBufferIn);
34        auto innerCmdBuffer = getInnerObj(cmdBufferIn);
35        innerCommandBuffers.add(innerCmdBuffer);
36        if (cmdBufferImpl->isOpen)
37        {
38            GFX_DIAGNOSE_ERROR_FORMAT(
39                "Command buffer %lld is still open. A command buffer must be closed "
40                "before submitting to a command queue.",
41                cmdBufferImpl->uid);
42        }
43        if (i > 0)
44        {
45            if (cmdBufferImpl->m_transientHeap != getDebugObj(commandBuffers[0])->m_transientHeap)
46            {
47                GFX_DIAGNOSE_ERROR("Command buffers passed to a single executeCommandBuffers "
48                                   "call must be allocated from the same transient heap.");
49            }
50        }
51    }
52    baseObject->executeCommandBuffers(
53        count,
54        innerCommandBuffers.getBuffer(),
55        getInnerObj(fence),
56        valueToSignal);
57    if (fence)
58    {
59        getDebugObj(fence)->maxValueToSignal =
60            Math::Max(getDebugObj(fence)->maxValueToSignal, valueToSignal);
61    }
62}
63
64void DebugCommandQueue::waitOnHost()
65{
66    SLANG_GFX_API_FUNC;
67    baseObject->waitOnHost();
68}
69
70Result DebugCommandQueue::waitForFenceValuesOnDevice(
71    GfxCount fenceCount,
72    IFence** fences,
73    uint64_t* waitValues)
74{
75    SLANG_GFX_API_FUNC;
76    List<IFence*> innerFences;
77    for (GfxIndex i = 0; i < fenceCount; ++i)
78    {
79        innerFences.add(getInnerObj(fences[i]));
80    }
81    return baseObject->waitForFenceValuesOnDevice(fenceCount, innerFences.getBuffer(), waitValues);
82}
83
84Result DebugCommandQueue::getNativeHandle(InteropHandle* outHandle)
85{
86    SLANG_GFX_API_FUNC;
87    return baseObject->getNativeHandle(outHandle);
88}
89
90} // namespace debug
91} // namespace gfx