add code metrics to time-lapse frame generation

This commit is contained in:
2019-11-09 12:07:12 +01:00
parent 58b93edcc8
commit 21d0ff23c7
2 changed files with 28 additions and 8 deletions

View File

@@ -74,7 +74,7 @@ Texture2D Layer::gen_equirect(glm::ivec2 size /*= { 0, 0 }*/)
latlong.bindFramebuffer();
latlong.clear({ 0, 1, 1, 1 });
//latlong.clear({ 0, 1, 1, 1 });
glViewport(0, 0, latlong.getWidth(), latlong.getHeight());
@@ -108,6 +108,8 @@ PBO Layer::gen_equirect_pbo(glm::ivec2 size /*= { 0, 0 }*/)
{
gl_state gl;
gl.save();
auto t0 = std::chrono::high_resolution_clock::now();
TextureCube cube;
RTT latlong;
@@ -116,12 +118,14 @@ PBO Layer::gen_equirect_pbo(glm::ivec2 size /*= { 0, 0 }*/)
size = { w, h };
cube = gen_cube();
auto t1 = std::chrono::high_resolution_clock::now();
latlong.create(size.x * 4, size.y * 2);
auto t2 = std::chrono::high_resolution_clock::now();
glDisable(GL_BLEND);
latlong.bindFramebuffer();
latlong.clear({ 0, 1, 1, 1 });
//latlong.clear({ 0, 1, 1, 1 });
glViewport(0, 0, latlong.getWidth(), latlong.getHeight());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP, cube.m_cubetex_id);
@@ -133,11 +137,26 @@ PBO Layer::gen_equirect_pbo(glm::ivec2 size /*= { 0, 0 }*/)
Canvas::I->m_plane.draw_fill();
latlong.unbindFramebuffer();
auto t3 = std::chrono::high_resolution_clock::now();
pbo.create(latlong);
auto t4 = std::chrono::high_resolution_clock::now();
latlong.destroy();
cube.destroy();
typedef std::chrono::duration<int, std::micro> micro;
LOG("frame time: %d\n"
"- gen cube: %d\n"
"- create latlong: %d\n"
"- draw latlong: %d\n"
"- create pbo: %d\n",
std::chrono::duration_cast<micro>(t4-t0).count(), // total
std::chrono::duration_cast<micro>(t1-t0).count(), // gen cube
std::chrono::duration_cast<micro>(t2-t1).count(), // create latlong
std::chrono::duration_cast<micro>(t3-t2).count(), // draw latlong
std::chrono::duration_cast<micro>(t4-t3).count() // create pbo
);
gl.restore();
});

View File

@@ -507,9 +507,10 @@ void PBO::unbind() noexcept
glm::uint8_t* PBO::map() noexcept
{
App::I->render_task([this] {
glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer_id);
mapped_ptr = (GLubyte*)glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, width * height * 4, GL_MAP_READ_BIT);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer_id);
mapped_ptr = (GLubyte*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0,
width * height * 4, GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
});
return mapped_ptr;
}
@@ -517,8 +518,8 @@ glm::uint8_t* PBO::map() noexcept
void PBO::unmap() noexcept
{
App::I->render_task([this] {
glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer_id);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer_id);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
});
}