blob: 6075d5549978875a954dbe8817babd7db2e6950a (
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
|
// metal-query.cpp
#include "metal-query.h"
// #include "metal-util.h"
namespace gfx
{
using namespace Slang;
namespace metal
{
QueryPoolImpl::~QueryPoolImpl() {}
static MTL::CounterSet* findCounterSet(MTL::Device* device, QueryType queryType)
{
if (queryType != QueryType::Timestamp)
{
return nullptr;
}
static NS::String* timestampStr = MTLSTR("timestamp");
for (int i = 0; i < device->counterSets()->count(); ++i)
{
MTL::CounterSet* counterSet =
static_cast<MTL::CounterSet*>(device->counterSets()->object(i));
for (int j = 0; j < counterSet->counters()->count(); ++j)
{
MTL::Counter* counter = static_cast<MTL::Counter*>(counterSet->counters()->object(j));
if (counter->name()->isEqualToString(MTL::CommonCounterTimestamp))
{
return counterSet;
}
}
}
return nullptr;
}
Result QueryPoolImpl::init(DeviceImpl* device, const IQueryPool::Desc& desc)
{
m_device = device;
m_desc = desc;
MTL::CounterSet* counterSet = findCounterSet(m_device->m_device.get(), m_desc.type);
if (!counterSet)
{
return SLANG_E_NOT_AVAILABLE;
}
NS::SharedPtr<MTL::CounterSampleBufferDescriptor> counterSampleBufferDesc =
NS::TransferPtr(MTL::CounterSampleBufferDescriptor::alloc()->init());
counterSampleBufferDesc->setStorageMode(MTL::StorageModeShared);
counterSampleBufferDesc->setSampleCount(m_desc.count);
counterSampleBufferDesc->setCounterSet(counterSet);
m_device->m_device->counterSets();
NS::Error* error;
m_counterSampleBuffer = NS::TransferPtr(
m_device->m_device->newCounterSampleBuffer(counterSampleBufferDesc.get(), &error));
return m_counterSampleBuffer ? SLANG_OK : SLANG_FAIL;
}
Result QueryPoolImpl::getResult(GfxIndex index, GfxCount count, uint64_t* data)
{
return SLANG_E_NOT_IMPLEMENTED;
}
} // namespace metal
} // namespace gfx
|