yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// cuda-query.cpp 2#include "cuda-query.h" 3 4namespace gfx 5{ 6#ifdef GFX_ENABLE_CUDA 7using namespace Slang ; 8 9namespace cuda 10{ 11 12Result QueryPoolImpl ::init (const IQueryPool ::Desc & desc ) 13{ 14cuEventCreate (& m_startEvent ,0 ); 15cuEventRecord (m_startEvent ,0 ); 16m_events .setCount (desc .count ); 17for (SlangInt i = 0 ;i < m_events .getCount ();i ++ ) 18 { 19cuEventCreate (& m_events [i ],0 ); 20 } 21return SLANG_OK ; 22} 23 24QueryPoolImpl ::~QueryPoolImpl () 25{ 26for (auto & e :m_events ) 27 { 28cuEventDestroy (e ); 29 } 30cuEventDestroy (m_startEvent ); 31} 32 33SLANG_NO_THROW Result SLANG_MCALL 34QueryPoolImpl ::getResult (GfxIndex queryIndex ,GfxCount count ,uint64_t * data ) 35{ 36for (GfxIndex i = 0 ;i < count ;i ++ ) 37 { 38float time = 0.0f ; 39cuEventSynchronize (m_events [i + queryIndex ]); 40cuEventElapsedTime (& time ,m_startEvent ,m_events [i + queryIndex ]); 41data [i ]= (uint64_t )((double )time * 1000.0f ); 42 } 43return SLANG_OK ; 44} 45 46}// namespace cuda 47#endif 48}// namespace gfx