MCPcopy Create free account
hub / github.com/DragonJoker/RenderGraph / retrieveGpuTime

Method retrieveGpuTime

source/RenderGraph/FramePassTimer.cpp:128–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126 }
127
128 void FramePassTimer::retrieveGpuTime()noexcept
129 {
130 static float const period = m_context.properties.limits.timestampPeriod;
131
132 auto before = Clock::now();
133 m_gpuTime = 0ns;
134
135 if ( auto & query = m_queries.front(); query.started && query.written )
136 {
137 std::array< uint64_t, 2u > values{ 0u, 0u };
138 m_context.vkGetQueryPoolResults( m_context.device
139 , m_timerQueries
140 , query.offset
141 , 2u
142 , sizeof( uint64_t ) * values.size()
143 , values.data()
144 , sizeof( uint64_t )
145 , VK_QUERY_RESULT_WAIT_BIT | VK_QUERY_RESULT_64_BIT );
146
147 auto gpuTime = Nanoseconds{ uint64_t( float( values[1] - values[0] ) / period ) };
148 m_gpuTime += gpuTime;
149
150 query.started = false;
151 query.written = false;
152 }
153
154 auto after = Clock::now();
155 m_cpuTime += ( after - before );
156 }
157
158 //*********************************************************************************************
159}

Callers 1

TESTFunction · 0.80

Calls 1

sizeMethod · 0.80

Tested by 1

TESTFunction · 0.64