コード例 #1
0
ファイル: glretrace_main.cpp プロジェクト: jciehl/apitrace
static void
completeCallQuery(CallQuery& query) {
    /* Get call start and duration */
    int64_t gpuStart = 0, gpuDuration = 0, cpuDuration = 0, pixels = 0;

    if (query.isDraw) {
        if (retrace::profilingGpuTimes) {
            if (supportsTimestamp) {
                glGetQueryObjecti64vEXT(query.ids[0], GL_QUERY_RESULT, &gpuStart);
            }

            glGetQueryObjecti64vEXT(query.ids[1], GL_QUERY_RESULT, &gpuDuration);
        }

        if (retrace::profilingPixelsDrawn) {
            glGetQueryObjecti64vEXT(query.ids[2], GL_QUERY_RESULT, &pixels);
        }

        glDeleteQueries(3, query.ids);
    } else {
        pixels = -1;
    }

    if (retrace::profilingCpuTimes) {
        cpuDuration = query.cpuEnd - query.cpuStart;
    }

    /* Add call to profile */
    retrace::profiler.addCall(query.call, query.sig->name, query.program, pixels, gpuStart, gpuDuration, query.cpuStart, cpuDuration);
}
コード例 #2
0
static void
completeCallQuery(CallQuery& query) {
    /* Get call start and duration */
    int64_t gpuStart = 0, gpuDuration = 0, cpuDuration = 0, pixels = 0, vsizeDuration = 0, rssDuration = 0;

    if (query.isDraw) {
        if (retrace::profilingGpuTimes) {
            if (supportsTimestamp) {
                /* Use ARB queries in case EXT not present */
                glGetQueryObjecti64v(query.ids[GPU_START], GL_QUERY_RESULT, &gpuStart);
                glGetQueryObjecti64v(query.ids[GPU_DURATION], GL_QUERY_RESULT, &gpuDuration);
            } else {
                glGetQueryObjecti64vEXT(query.ids[GPU_DURATION], GL_QUERY_RESULT, &gpuDuration);
            }
        }

        if (retrace::profilingPixelsDrawn) {
            if (supportsTimestamp) {
                glGetQueryObjecti64v(query.ids[OCCLUSION], GL_QUERY_RESULT, &pixels);
            } else if (supportsElapsed) {
                glGetQueryObjecti64vEXT(query.ids[OCCLUSION], GL_QUERY_RESULT, &pixels);
            } else {
                uint32_t pixels32;
                glGetQueryObjectuiv(query.ids[OCCLUSION], GL_QUERY_RESULT, &pixels32);
                pixels = static_cast<int64_t>(pixels32);
            }
        }

    } else {
        pixels = -1;
    }

    if (retrace::profilingCpuTimes) {
        double cpuTimeScale = 1.0E9 / getTimeFrequency();
        cpuDuration = (query.cpuEnd - query.cpuStart) * cpuTimeScale;
        query.cpuStart *= cpuTimeScale;
    }

    if (retrace::profilingMemoryUsage) {
        vsizeDuration = query.vsizeEnd - query.vsizeStart;
        rssDuration = query.rssEnd - query.rssStart;
    }

    glDeleteQueries(NUM_QUERIES, query.ids);

    /* Add call to profile */
    retrace::profiler.addCall(query.call, query.sig->name, query.program, pixels, gpuStart, gpuDuration, query.cpuStart, cpuDuration, query.vsizeStart, vsizeDuration, query.rssStart, rssDuration);
}
コード例 #3
0
ファイル: time-elapsed.c プロジェクト: Zoxc/piglit
static float
get_gpu_time(GLuint *q)
{
	GLint64EXT elapsed;

	if (test == TIMESTAMP) {
		GLint64 start, end;
		glGetQueryObjecti64vEXT(q[0], GL_QUERY_RESULT, &start);
		glGetQueryObjecti64vEXT(q[1], GL_QUERY_RESULT, &end);
		elapsed = end - start;
	} else {
		glGetQueryObjecti64vEXT(q[0], GL_QUERY_RESULT, &elapsed);
	}

	return elapsed / 1000.0 / 1000.0 / 1000.0;
}
コード例 #4
0
EXTERN_C_ENTER

JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTimerQuery_nglGetQueryObjecti64vEXT__IIJ(JNIEnv *__env, jclass clazz, jint id, jint pname, jlong paramsAddress) {
    glGetQueryObjecti64vEXTPROC glGetQueryObjecti64vEXT = (glGetQueryObjecti64vEXTPROC)tlsGetFunction(1821);
    intptr_t params = (intptr_t)paramsAddress;
    UNUSED_PARAM(clazz)
    glGetQueryObjecti64vEXT(id, pname, params);
}
コード例 #5
0
ファイル: time-elapsed.c プロジェクト: nobled/piglit
static float
get_gpu_time(GLuint q)
{
	GLint64EXT elapsed;

	glGetQueryObjecti64vEXT(q, GL_QUERY_RESULT, &elapsed);

	return elapsed / 1000.0 / 1000.0 / 1000.0;
}
コード例 #6
0
template<> Long AbstractQuery::result<Long>() {
    Long result;
#ifndef MAGNUM_TARGET_GLES
    glGetQueryObjecti64v(_id, GL_QUERY_RESULT, &result);
#elif !defined(CORRADE_TARGET_NACL)
    glGetQueryObjecti64vEXT(_id, GL_QUERY_RESULT_EXT, &result);
#else
    CORRADE_ASSERT_UNREACHABLE();
#endif
    return result;
}
コード例 #7
0
void MetricBackend_opengl::processQueries() {
    int64_t gpuStart, gpuEnd, pixels;
    for (int i = 0; i < QUERY_BOUNDARY_LIST_END; i++) {
        QueryBoundary boundary = static_cast<QueryBoundary>(i);
        while (!queries[i].empty()) {
            auto &query = queries[i].front();
            if (metrics[METRIC_GPU_START].profiled[i]) {
                glGetQueryObjecti64v(query[QUERY_GPU_START], GL_QUERY_RESULT,
                                     &gpuStart);
                int64_t value = gpuStart - baseTime;
                data[METRIC_GPU_START][i]->addData(boundary, value);
            }
            if (metrics[METRIC_GPU_DURATION].profiled[i]) {
                if (supportsTimestamp) {
                    glGetQueryObjecti64v(query[QUERY_GPU_DURATION], GL_QUERY_RESULT,
                                         &gpuEnd);
                    gpuEnd -= gpuStart;
                } else {
                    glGetQueryObjecti64vEXT(query[QUERY_GPU_DURATION], GL_QUERY_RESULT,
                                            &gpuEnd);
                }
                data[METRIC_GPU_DURATION][i]->addData(boundary, gpuEnd);
            }
            if (metrics[METRIC_GPU_PIXELS].profiled[i]) {
                if (supportsTimestamp) {
                    glGetQueryObjecti64v(query[QUERY_OCCLUSION], GL_QUERY_RESULT, &pixels);
                } else if (supportsElapsed) {
                    glGetQueryObjecti64vEXT(query[QUERY_OCCLUSION], GL_QUERY_RESULT, &pixels);
                } else {
                    uint32_t pixels32;
                    glGetQueryObjectuiv(query[QUERY_OCCLUSION], GL_QUERY_RESULT, &pixels32);
                    pixels = static_cast<int64_t>(pixels32);
                }
                data[METRIC_GPU_PIXELS][i]->addData(boundary, pixels);
            }
            glDeleteQueries(QUERY_LIST_END, query.data());
            queries[i].pop();
        }
    }
}
コード例 #8
0
static void
completeCallQuery(CallQuery& query) {
    /* Get call start and duration */
    int64_t gpuStart = 0, gpuDuration = 0, cpuDuration = 0, pixels = 0, vsizeDuration = 0, rssDuration = 0;

    if (query.isDraw) {
        if (retrace::profilingGpuTimes) {
            if (supportsTimestamp) {
                glGetQueryObjecti64vEXT(query.ids[GPU_START], GL_QUERY_RESULT, &gpuStart);
            }

            glGetQueryObjecti64vEXT(query.ids[GPU_DURATION], GL_QUERY_RESULT, &gpuDuration);
        }

        if (retrace::profilingPixelsDrawn) {
            glGetQueryObjecti64vEXT(query.ids[OCCLUSION], GL_QUERY_RESULT, &pixels);
        }

    } else {
        pixels = -1;
    }

    if (retrace::profilingCpuTimes) {
        cpuDuration = query.cpuEnd - query.cpuStart;
    }

    if (retrace::profilingMemoryUsage) {
        vsizeDuration = query.vsizeEnd - query.vsizeStart;
        rssDuration = query.rssEnd - query.rssStart;
    }

    glDeleteQueries(NUM_QUERIES, query.ids);

    /* Add call to profile */
    retrace::profiler.addCall(query.call, query.sig->name, query.program, pixels, gpuStart, gpuDuration, query.cpuStart, cpuDuration, query.vsizeStart, vsizeDuration, query.rssStart, rssDuration);
}
コード例 #9
0
ファイル: glretrace_main.cpp プロジェクト: jciehl/apitrace
static void
getCurrentTimes(int64_t& cpuTime, int64_t& gpuTime) {
    GLuint query;

    if (retrace::profilingGpuTimes && supportsTimestamp) {
        glGenQueries(1, &query);
        glQueryCounter(query, GL_TIMESTAMP);
        glGetQueryObjecti64vEXT(query, GL_QUERY_RESULT, &gpuTime);
    } else {
        gpuTime = 0;
    }

    if (retrace::profilingCpuTimes) {
        cpuTime = os::getTime();
    } else {
        cpuTime = 0;
    }

    if (retrace::profilingGpuTimes && supportsTimestamp) {
        glDeleteQueries(1, &query);
    }
}