1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

GPU time transfer.

This commit is contained in:
Bartosz Taudul
2017-11-11 22:08:47 +01:00
parent a0729d3500
commit 7ebaa46f75
4 changed files with 76 additions and 0 deletions
+43
View File
@@ -5,6 +5,7 @@
#include <atomic>
#include "Tracy.hpp"
#include "client/TracyProfiler.hpp"
#define TracyGpuZone( ctx, name ) static const tracy::SourceLocation __tracy_gpu_source_location { __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; auto ___tracy_gpu_zone = tracy::detail::__GpuHelper( ctx, name, &__tracy_gpu_source_location );
@@ -95,6 +96,48 @@ public:
tail.store( magic + 1, std::memory_order_release );
}
void Collect()
{
ZoneScopedC( 0x881111 );
auto start = m_tail;
auto end = m_head + Num;
auto cnt = ( end - start ) % Num;
while( cnt > 1 )
{
auto mid = start + cnt / 2;
GLint available;
glGetQueryObjectiv( m_query[mid % Num], GL_QUERY_RESULT_AVAILABLE, &available );
if( available )
{
start = mid;
}
else
{
end = mid;
}
cnt = ( end - start ) % Num;
}
start %= Num;
while( m_tail != start )
{
uint64_t time;
glGetQueryObjectui64v( m_query[m_tail], GL_QUERY_RESULT, &time );
Magic magic;
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
item->hdr.type = QueueType::GpuTime;
item->gpuTime.gpuTime = (int64_t)time;
item->gpuTime.context = m_context;
tail.store( magic + 1, std::memory_order_release );
m_tail = ( m_tail + 1 ) % Num;
}
}
private:
tracy_force_inline __GpuCtxScope<Num> SpawnZone( const char* name, const SourceLocation* srcloc )
{