Esempio n. 1
0
void QSGRenderer::renderScene(const QSGBindable &bindable)
{
    if (!m_root_node)
        return;

    m_is_rendering = true;
#ifdef QSG_RENDERER_TIMING
    frameTimer.start();
#endif

    m_bindable = &bindable;
    preprocess();

    bindable.bind();
#ifdef QSG_RENDERER_TIMING
    int bindTime = frameTimer.elapsed();
#endif

#ifndef QT_NO_DEBUG
    // Sanity check that attribute registers are disabled
    {
        GLint count;
        glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &count);
        GLint enabled;
        for (int i=0; i<count; ++i) {
            glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled);
            if (enabled) {
                qWarning("QSGRenderer: attribute %d is enabled, this can lead to memory corruption and crashes.", i);
            }
        }
    }
#endif

    render();
#ifdef QSG_RENDERER_TIMING
    int renderTime = frameTimer.elapsed();
#endif

    glDisable(GL_SCISSOR_TEST);
    m_is_rendering = false;
    m_changed_emitted = false;
    m_bindable = 0;

#ifdef QSG_RENDERER_TIMING
    printf(" - Breakdown of frametime: preprocess=%d, updates=%d, binding=%d, render=%d, total=%d\n",
           preprocessTime,
           updatePassTime - preprocessTime,
           bindTime - updatePassTime,
           renderTime - bindTime,
           renderTime);
#endif
}
Esempio n. 2
0
void QSGRenderer::renderScene(const QSGBindable &bindable)
{
    if (!m_root_node)
        return;

    m_is_rendering = true;


#ifndef QSG_NO_RENDER_TIMING
    bool profileFrames = qsg_render_timing || QQmlProfilerService::enabled;
    if (profileFrames)
        frameTimer.start();
    qint64 bindTime = 0;
    qint64 renderTime = 0;
#endif

    m_bindable = &bindable;
    preprocess();

    bindable.bind();
#ifndef QSG_NO_RENDER_TIMING
    if (profileFrames)
        bindTime = frameTimer.nsecsElapsed();
#endif

#ifndef QT_NO_DEBUG
    // Sanity check that attribute registers are disabled
    {
        GLint count = 0;
        glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &count);
        GLint enabled;
        for (int i=0; i<count; ++i) {
            glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled);
            if (enabled) {
                qWarning("QSGRenderer: attribute %d is enabled, this can lead to memory corruption and crashes.", i);
            }
        }
    }
#endif

    render();
#ifndef QSG_NO_RENDER_TIMING
    if (profileFrames)
        renderTime = frameTimer.nsecsElapsed();
#endif

    glDisable(GL_SCISSOR_TEST);
    m_is_rendering = false;
    m_changed_emitted = false;
    m_bindable = 0;

    if (m_vertex_buffer_bound) {
        glBindBuffer(GL_ARRAY_BUFFER, 0);
        m_vertex_buffer_bound = false;
    }

    if (m_index_buffer_bound) {
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
        m_index_buffer_bound = false;
    }

#ifndef QSG_NO_RENDER_TIMING
    if (qsg_render_timing) {
        printf(" - Breakdown of render time: preprocess=%d, updates=%d, binding=%d, render=%d, total=%d\n",
               int(preprocessTime / 1000000),
               int((updatePassTime - preprocessTime) / 1000000),
               int((bindTime - updatePassTime) / 1000000),
               int((renderTime - bindTime) / 1000000),
               int(renderTime / 1000000));
    }

    if (QQmlProfilerService::enabled) {
        QQmlProfilerService::sceneGraphFrame(
                    QQmlProfilerService::SceneGraphRendererFrame,
                    preprocessTime,
                    updatePassTime - preprocessTime,
                    bindTime - updatePassTime,
                    renderTime - bindTime);
    }

#endif
}