yum-mirror/slang

Making it easier to work with shaders

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

Ellie Hermaszewskaformatf65d756bf

master
1.7 KiB64 linesraw
1// d3d12-query.h
2#pragma once
3
4#include "d3d12-base.h"
5#include "d3d12-buffer.h"
6#include "d3d12-device.h"
7
8namespace gfx
9{
10namespace d3d12
11{
12
13using namespace Slang;
14
15class QueryPoolImpl : public QueryPoolBase
16{
17public:
18    Result init(const IQueryPool::Desc& desc, DeviceImpl* device);
19
20    virtual SLANG_NO_THROW Result SLANG_MCALL
21    getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data) override;
22
23    void writeTimestamp(ID3D12GraphicsCommandList* cmdList, GfxIndex index);
24
25public:
26    D3D12_QUERY_TYPE m_queryType;
27    ComPtr<ID3D12QueryHeap> m_queryHeap;
28    D3D12Resource m_readBackBuffer;
29    ComPtr<ID3D12CommandAllocator> m_commandAllocator;
30    ComPtr<ID3D12GraphicsCommandList> m_commandList;
31    ComPtr<ID3D12Fence> m_fence;
32    ComPtr<ID3D12CommandQueue> m_commandQueue;
33    HANDLE m_waitEvent;
34    UINT64 m_eventValue = 0;
35};
36
37/// Implements the IQueryPool interface with a plain buffer.
38/// Used for query types that does not correspond to a D3D query,
39/// such as ray-tracing acceleration structure post-build info.
40class PlainBufferProxyQueryPoolImpl : public QueryPoolBase
41{
42public:
43    SLANG_COM_OBJECT_IUNKNOWN_ALL
44    IQueryPool* getInterface(const Guid& guid);
45
46public:
47    Result init(const IQueryPool::Desc& desc, DeviceImpl* device, uint32_t stride);
48
49    virtual SLANG_NO_THROW Result SLANG_MCALL reset() override;
50    virtual SLANG_NO_THROW Result SLANG_MCALL
51    getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data) override;
52
53public:
54    QueryType m_queryType;
55    RefPtr<BufferResourceImpl> m_bufferResource;
56    RefPtr<DeviceImpl> m_device;
57    List<uint8_t> m_result;
58    bool m_resultDirty = true;
59    uint32_t m_stride = 0;
60    uint32_t m_count = 0;
61};
62
63} // namespace d3d12
64} // namespace gfx