yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// metal-query.cpp 2#include "metal-query.h" 3 4// #include "metal-util.h" 5 6namespace gfx 7{ 8 9using namespace Slang ; 10 11namespace metal 12{ 13 14QueryPoolImpl ::~QueryPoolImpl () {} 15 16static MTL ::CounterSet * findCounterSet (MTL ::Device * device ,QueryType queryType ) 17{ 18if (queryType != QueryType ::Timestamp ) 19 { 20return nullptr ; 21 } 22 23static NS ::String * timestampStr = MTLSTR ("timestamp" ); 24 25for (int i = 0 ;i < device -> counterSets ()-> count ();++ i ) 26 { 27MTL ::CounterSet * counterSet = 28static_cast < MTL ::CounterSet *> (device -> counterSets ()-> object (i )); 29for (int j = 0 ;j < counterSet -> counters ()-> count ();++ j ) 30 { 31MTL ::Counter * counter = static_cast < MTL ::Counter *> (counterSet -> counters ()-> object (j )); 32if (counter -> name ()-> isEqualToString (MTL ::CommonCounterTimestamp )) 33 { 34return counterSet ; 35 } 36 } 37 } 38return nullptr ; 39} 40 41Result QueryPoolImpl ::init (DeviceImpl * device ,const IQueryPool ::Desc & desc ) 42{ 43m_device = device ; 44m_desc = desc ; 45 46MTL ::CounterSet * counterSet = findCounterSet (m_device -> m_device .get (),m_desc .type ); 47if (!counterSet ) 48 { 49return SLANG_E_NOT_AVAILABLE ; 50 } 51 52NS ::SharedPtr < MTL ::CounterSampleBufferDescriptor > counterSampleBufferDesc = 53NS ::TransferPtr (MTL ::CounterSampleBufferDescriptor ::alloc ()-> init ()); 54counterSampleBufferDesc -> setStorageMode (MTL ::StorageModeShared ); 55counterSampleBufferDesc -> setSampleCount (m_desc .count ); 56counterSampleBufferDesc -> setCounterSet (counterSet ); 57 58m_device -> m_device -> counterSets (); 59 60NS ::Error * error ; 61m_counterSampleBuffer = NS ::TransferPtr ( 62m_device -> m_device -> newCounterSampleBuffer (counterSampleBufferDesc .get (),& error )); 63 64return m_counterSampleBuffer ?SLANG_OK :SLANG_FAIL ; 65} 66 67Result QueryPoolImpl ::getResult (GfxIndex index ,GfxCount count ,uint64_t * data ) 68{ 69return SLANG_E_NOT_IMPLEMENTED ; 70} 71 72}// namespace metal 73}// namespace gfx