yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
b118451e3
master
1// d3d11-query.cpp 2#include "d3d11-query.h" 3 4#include "core/slang-process.h" 5 6namespace gfx 7{ 8 9using namespace Slang ; 10 11namespace d3d11 12{ 13 14Result QueryPoolImpl ::init (const IQueryPool ::Desc & desc ,DeviceImpl * device ) 15{ 16m_device = device ; 17m_queryDesc .MiscFlags = 0 ; 18switch (desc .type ) 19 { 20case QueryType ::Timestamp : 21m_queryDesc .Query = D3D11_QUERY_TIMESTAMP ; 22break ; 23default : 24return SLANG_E_INVALID_ARG ; 25 } 26m_queries .setCount (desc .count ); 27return SLANG_OK ; 28} 29 30ID3D11Query * QueryPoolImpl ::getQuery (SlangInt index ) 31{ 32if (!m_queries [index ]) 33m_device -> m_device -> CreateQuery (& m_queryDesc ,m_queries [index ].writeRef ()); 34return m_queries [index ].get (); 35} 36 37SLANG_NO_THROW Result SLANG_MCALL 38QueryPoolImpl ::getResult (GfxIndex queryIndex ,GfxCount count ,uint64_t * data ) 39{ 40D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjointData ; 41while (S_OK != m_device -> m_immediateContext -> GetData ( 42m_device -> m_disjointQuery , 43& disjointData , 44sizeof (D3D11_QUERY_DATA_TIMESTAMP_DISJOINT ), 450 )) 46 { 47Process ::sleepCurrentThread (1 ); 48 } 49m_device -> m_info .timestampFrequency = disjointData .Frequency ; 50 51for (SlangInt i = 0 ;i < count ;i ++ ) 52 { 53SLANG_RETURN_ON_FAIL (m_device -> m_immediateContext -> GetData ( 54m_queries [queryIndex + i ], 55data + i , 56sizeof (uint64_t ), 570 )); 58 } 59return SLANG_OK ; 60} 61 62}// namespace d3d11 63}// namespace gfx