'Second call to glDrawElements() takes 1.8 seconds in debug or release
The first frame takes forever to render, and I've narrowed it down to my second call to glDrawElements()
. How weird.
Here's the relevant code, obnoxious logging included:
void GLRenderAPI::draw_indexed(const VertexBuffer &vertex_buffer) const {
PDR_ENGINE_WARN("lolperf");
PerfMetrics::api_call();
PDR_ENGINE_WARN("perfdone");
uint32_t indices = vertex_buffer.index_count();
PDR_ENGINE_WARN("indices done");
glDrawElements(
GL_TRIANGLES,
static_cast<GLsizei>(indices),
GL_UNSIGNED_INT,
nullptr
);
PDR_ENGINE_WARN("drawdone");
}
And here's what the log spits out. There are a grand total of three objects which are being drawn with a perspective projection. First is the light caster placeholders. Second is the skybox, and that's the one that stalls. Third is the player spaceship model. Here's what I see:
[23:02:01] Client: Camera...
[23:02:01] Client: Lights...
[23:02:01] Client: Skybox...
[23:02:01] Client: Lasers...
[23:02:01] Client: Gunship...
[23:02:01] Engine: Update...
[23:02:01] Engine: Draw...
[23:02:01] Engine: scene begun
[23:02:01] Engine: 3DDraw 1
[23:02:01] Engine: lolperf
[23:02:01] Engine: perfdone
[23:02:01] Engine: indices done
[23:02:01] Engine: drawdone
[23:02:01] Engine: lolperf
[23:02:01] Engine: perfdone
[23:02:01] Engine: indices done
[23:02:01] Engine: drawdone
[23:02:01] Engine: 3DDraw 2
[23:02:01] Client: skybox shader binding
[23:02:01] Client: skybox texture binding
[23:02:01] Client: skybox world setting
[23:02:01] Client: skybox drawing
[23:02:01] Engine: binding vao
[23:02:01] Engine: lolperf
[23:02:01] Engine: perfdone
--------------------------------- // Here's the issue
[23:02:01] Engine: indices done
[23:02:03] Engine: drawdone
-----------------------------------------------------
[23:02:03] Engine: api did the draw
[23:02:03] Engine: 3DDraw 3
[23:02:03] Engine: lolperf
[23:02:03] Engine: perfdone
[23:02:03] Engine: indices done
[23:02:03] Engine: drawdone
[23:02:03] Engine: 2DDraw 4
[23:02:03] Engine: 2DDraw 5
[23:02:03] Engine: 2DDraw 6
[23:02:03] Engine: draws processed
[23:02:03] Engine: lolperf
[23:02:03] Engine: perfdone
[23:02:03] Engine: indices done
[23:02:03] Engine: drawdone
[23:02:03] Engine: lolperf
[23:02:03] Engine: perfdone
[23:02:03] Engine: indices done
[23:02:03] Engine: drawdone
[23:02:03] Engine: lolperf
[23:02:03] Engine: perfdone
[23:02:03] Engine: indices done
[23:02:03] Engine: drawdone
[23:02:03] Engine: lolperf
[23:02:03] Engine: perfdone
[23:02:03] Engine: indices done
[23:02:03] Engine: drawdone
[23:02:03] Engine: colvis done
[23:02:03] Engine: scene ended
[23:02:03] Engine: binding vao
[23:02:03] Engine: api did the draw
[23:02:03] Engine: ScreenLog rendered
[23:02:03] Engine: Game time frozen for 1.8735242 secs (corrected to 0.01666665)
[23:02:03] Engine: Update...
[23:02:03] Engine: Draw...
[23:02:03] Engine: scene begun
I'll beg your pardon for the convoluted logging schemes, but this is directly where my drilling has led me. I'm on Windows, using C++, and for whatever it's worth I'm running an RDNA2 GPU. A Pascal GPU presents the same behavior, and the pause persists between release and debug builds. Originally, the call to glDrawElements()
included the call to vertex_buffer.index_count()
, but I moved it to isolate what I could.
Of course I can't simply ask, "What's wrong here?" Instead... I'm wondering, how do I delve further into this? RenderDoc won't be any help (that I know of?) since I likely can't capture the first frame without a great deal of luck. What other tools of the trade exist to examine this type of hiccup?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|