bool initQuery()
	{
		glGenQueries(1, &QueryName);

		int QueryBits(0);
		glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &QueryBits);

		bool Validated = QueryBits >= 32;

		return Validated && this->checkError("initQuery");
	}
Ejemplo n.º 2
0
 Timer::Timer(bool timeGPU)
   :
     d_id(0),
     d_CPUtime(0),
     d_startCPUtime(chrono::steady_clock::now()),
     d_GPUtime(0),
     d_running(false)
 {
   if(timeGPU && GLEW_ARB_timer_query)
     glGenQueries(1, &d_id);
 }
Ejemplo n.º 3
0
enum piglit_result
piglit_display(void)
{
#define NUM_QUERIES 5
	GLuint queries[NUM_QUERIES], available;
	bool test_pass = true;
	GLint result;
	int i;

	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glClearColor(1.0, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glGenQueries(NUM_QUERIES, queries);

	glColor4f(0.0f, 1.0f, 0.0f, 1.0f);

	/* Queue up a bunch of drawing with several queries. */
	for (i = 0; i < NUM_QUERIES - 1;  i++)
	{
		glBeginQuery(GL_SAMPLES_PASSED, queries[i]);

		draw_some_things((double)i / (NUM_QUERIES - 1));

		glEndQuery(GL_SAMPLES_PASSED);
	}

	/* Now fire off a query with no drawing. */
	glBeginQuery(GL_SAMPLES_PASSED, queries[NUM_QUERIES - 1]);
	glEndQuery(GL_SAMPLES_PASSED);

	/* Get the result for the final query. */
	glGetQueryObjectiv(queries[NUM_QUERIES - 1], GL_QUERY_RESULT, &result);

	/* At this point, the results of all the previous queries
	 * should be available.
	 */
	for (i = 0; i < NUM_QUERIES - 1; i++)
	{
		glGetQueryObjectuiv(queries[i], GL_QUERY_RESULT_AVAILABLE,
				    &available);
		if (available != 1) {
			printf("Query #%d result not available (expected in-order processing)\n", i);
			test_pass = false;
		}
	}

	glDeleteQueries(NUM_QUERIES, queries);

	piglit_present_results();

	return test_pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Ejemplo n.º 4
0
	bool initQuery()
	{
		int QueryBits(0);
		glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, &QueryBits);

		bool Validated = QueryBits >= 30;
		if(Validated)
			glGenQueries(static_cast<GLsizei>(QueryName.size()), &QueryName[0]);

		return Validated && this->checkError("initQuery");
	}
	bool initQuery()
	{
		glGenQueries(1, &QueryName);

		int QueryBits(0);
		glGetQueryiv(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, GL_QUERY_COUNTER_BITS, &QueryBits);

		bool Validated = QueryBits >= 1;

		return Validated && this->checkError("initQuery");
	}
	bool initQuery()
	{
		glGenQueries(1, &QueryName);

		int QueryBits(0);
		glGetQueryiv(GL_ANY_SAMPLES_PASSED_CONSERVATIVE, GL_QUERY_COUNTER_BITS, &QueryBits);

		bool Validated = QueryBits >= 1;

		return Validated;
	}
Ejemplo n.º 7
0
//------------------------------------------------------------------------------
static void
initGL() {

    glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);

    glGenQueries(2, g_queries);
}
Ejemplo n.º 8
0
void
piglit_init(int argc, char **argv)
{
	int i;
	const struct test_set *test = NULL;
	GLuint prog, vs, gs, vao, xfb_buf;
	char *gs_text;
	bool pass = true;

	/* Parse params */
	if (argc != 2)
		print_usage_and_exit(argv[0]);
	for (i = 0; i < ARRAY_SIZE(tests); i++) {
		if (strcmp(argv[1], tests[i].name) == 0) {
			test = &tests[i];
			break;
		}
	}
	if (test == NULL)
		print_usage_and_exit(argv[0]);

	/* Compile shaders */
	prog = glCreateProgram();
	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
	glAttachShader(prog, vs);
	asprintf(&gs_text, gs_template, test->input_layout,
		 test->vertices_per_prim);
	gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gs_text);
	free(gs_text);
	glAttachShader(prog, gs);
	glTransformFeedbackVaryings(prog, test->vertices_per_prim, varyings,
				    GL_INTERLEAVED_ATTRIBS);
	glLinkProgram(prog);
	if (!piglit_link_check_status(prog))
		piglit_report_result(PIGLIT_FAIL);
	glUseProgram(prog);

	/* Set up other GL state */
	glGenVertexArrays(1, &vao);
	glBindVertexArray(vao);
	glGenBuffers(1, &xfb_buf);
	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, xfb_buf);
	glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER,
		     MAX_OUTPUT_VERTICES * sizeof(GLint), NULL,
		     GL_STREAM_READ);
	glGenQueries(1, &generated_query);
	glEnable(GL_RASTERIZER_DISCARD);

	for (i = 0; i < test->num_test_vectors; i++) {
		pass = do_test_vector(test, &test->test_vectors[i]) && pass;
	}

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
Ejemplo n.º 9
0
/**
 * @brief glBeginTimeQuery
 * @return
 */
inline GLuint glBeginTimeQuery()
{
    //Timing
    GLuint ret;
    glGenQueries(1, &ret);
    glFinish();
    #ifndef PIC_DISABLE_OPENGL_NON_CORE
    glBeginQuery(GL_TIME_ELAPSED_EXT, ret);
    #endif
    return ret;
}
Ejemplo n.º 10
0
	GLTimerQuery::GLTimerQuery()
		:mQueryStartObj(0), mQueryEndObj(0), mFinalized(false), mEndIssued(false), mTimeDelta(0.0f)
	{
		GLuint queries[2];
		glGenQueries(2, queries);

		mQueryStartObj = queries[0];
		mQueryEndObj = queries[1];

		BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_Query);
	}
	void GL3OcclusionQueryProvider::create()
	{
		OpenGL::set_active(gc_provider);

		if (handle)
		{
			glDeleteQueries(1, &handle);
			handle = 0;
		}

		glGenQueries(1, &handle);
	}
Ejemplo n.º 12
0
  void Profiler::grow(size_t newsize)
  {
    size_t oldsize = m_entries.size();
    assert(newsize > oldsize);

    m_entries.resize(newsize);
    for (size_t i = oldsize; i < newsize; i++){
      Entry &entry = m_entries[i];
      glGenQueries(2 * FRAME_DELAY, &entry.queries[0]);
      entry.name = NULL;
    }
  }
Ejemplo n.º 13
0
void MetricBackend_opengl::beginQuery(QueryBoundary boundary) {
    // GPU related
    if (glQueriesNeeded[boundary]) {
        std::array<GLuint, QUERY_LIST_END> query;
        glGenQueries(QUERY_LIST_END, query.data());

        if (metrics[METRIC_GPU_START].profiled[boundary] ||
           (metrics[METRIC_GPU_DURATION].profiled[boundary] && supportsTimestamp))
        {
            glQueryCounter(query[QUERY_GPU_START], GL_TIMESTAMP);
        }
        if (metrics[METRIC_GPU_DURATION].profiled[boundary] && !supportsTimestamp) {
            glBeginQuery(GL_TIME_ELAPSED, query[QUERY_GPU_DURATION]);
        }
        if (metrics[METRIC_GPU_PIXELS].profiled[boundary]) {
            glBeginQuery(GL_SAMPLES_PASSED, query[QUERY_OCCLUSION]);
        }
        queries[boundary].push(std::move(query));
    }


    // CPU related
    if (metrics[METRIC_CPU_START].profiled[boundary] ||
        metrics[METRIC_CPU_DURATION].profiled[boundary])
    {
        cpuStart[boundary] = getCurrentTime();
        if (metrics[METRIC_CPU_START].profiled[boundary]) {
            int64_t time = cpuStart[boundary] * cpuTimeScale - baseTime;
            data[METRIC_CPU_START][boundary]->addData(boundary, time);
        }
    }
    if (metrics[METRIC_CPU_VSIZE_START].profiled[boundary] ||
        metrics[METRIC_CPU_VSIZE_DURATION].profiled[boundary])
    {
        vsizeStart[boundary] = os::getVsize();
        if (metrics[METRIC_CPU_VSIZE_START].profiled[boundary]) {
            int64_t time = vsizeStart[boundary];
            data[METRIC_CPU_VSIZE_START][boundary]->addData(boundary, time);
        }
    }
    if (metrics[METRIC_CPU_RSS_START].profiled[boundary] ||
        metrics[METRIC_CPU_RSS_DURATION].profiled[boundary])
    {
        rssStart[boundary] = os::getRss();
        if (metrics[METRIC_CPU_RSS_START].profiled[boundary]) {
            int64_t time = rssStart[boundary];
            data[METRIC_CPU_RSS_START][boundary]->addData(boundary, time);
        }
    }
    queryInProgress[boundary] = true;
    // DRAWCALL is a CALL
    if (boundary == QUERY_BOUNDARY_DRAWCALL) beginQuery(QUERY_BOUNDARY_CALL);
}
Ejemplo n.º 14
0
void
piglit_init(int argc, char **argv)
{
    GLuint vs;
    int i;

    /* Parse params. */
    if (argc != 2)
        print_usage_and_exit(argv[0]);
    test_to_run = find_matching_test(argv[0], argv[1]);

    /* Set up test */
    piglit_require_GLSL_version(test_to_run->version);
    piglit_require_transform_feedback();
    vs = piglit_compile_shader_text(GL_VERTEX_SHADER, test_to_run->vs);
    prog = glCreateProgram();
    glAttachShader(prog, vs);
    glBindAttribLocation(prog, 0, "vertex_pos");
    glBindAttribLocation(prog, 1, "vertex_num");
    glTransformFeedbackVaryings(prog, test_to_run->num_varyings,
                                (const char **) test_to_run->varyings,
                                GL_INTERLEAVED_ATTRIBS_EXT);
    glLinkProgram(prog);
    if (!piglit_link_check_status(prog)) {
        glDeleteProgram(prog);
        piglit_report_result(PIGLIT_FAIL);
    }

    /* Test that GetTransformFeedbackVarying reports the correct
     * size and type for all of the varyings.
     */
    for (i = 0; i < test_to_run->num_varyings; ++i) {
        GLsizei size;
        GLenum type;
        glGetTransformFeedbackVarying(prog, i, 0, NULL, &size,
                                      &type, NULL);
        if (size != test_to_run->expected_size) {
            printf("For varying %i, expected size %i, got %i\n",
                   i, test_to_run->expected_size, size);
            size_and_type_ok = GL_FALSE;
        }
        if (type != test_to_run->expected_type) {
            printf("For varying %i, expected type %i, got %i\n",
                   i, test_to_run->expected_type, type);
            size_and_type_ok = GL_FALSE;
        }
    }

    glGenBuffers(1, &xfb_buf);
    glGenQueries(1, &query);
    glEnable(GL_VERTEX_PROGRAM_TWO_SIDE);
}
Ejemplo n.º 15
0
    GL3PlusRenderToVertexBuffer::GL3PlusRenderToVertexBuffer()
        : mTargetBufferIndex(0)
        , mFirstUpdate(true)
    {
        mVertexBuffers[0].setNull();
        mVertexBuffers[1].setNull();

        // Create query objects.
        OGRE_CHECK_GL_ERROR(glGenQueries(1, &mPrimitivesDrawnQuery));

        //TODO GL4+
        // glGenTransformFeedbacks(1, mFeedbackObject);
    }
Ejemplo n.º 16
0
  /*virtual*/ void
  GPUTimer::start(){
    if(0 == m_id){
      glGenQueries(1, &m_id);
      if(0 == m_id){
	std::cerr << "ERROR: GPUTimer::start() ...could not request a query id" << std::endl;
	exit(0);
      }
    }

    glBeginQuery(GL_TIME_ELAPSED_EXT, m_id);

  }
Ejemplo n.º 17
0
void GPUClock::start()
{
    // Stop the time query to restart it.
    if(mStarted)
        glEndQuery(GL_TIME_ELAPSED);

    if(!mQuery)
        glGenQueries(1, &mQuery);

    glBeginQuery(GL_TIME_ELAPSED, mQuery);
    mStarted = true;
    mStopped = false;
}
Ejemplo n.º 18
0
void GPU_Profile::create_timer()
{
	u32 timer = 0;
#ifdef GLSL4_API
	glGenQueries(1, &timer);
	glQueryCounter(timer, GL_TIMESTAMP);
#endif
	datas.push_back(ProfileInfo(timer, frame, draw));

#ifdef ENABLE_MARKER
	dump(true);
#endif
}
Ejemplo n.º 19
0
void TerrainTessellation::initRendering(void) {
    if (!requireExtension("GL_ARB_tessellation_shader")) return;

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);    

    NvAssetLoaderAddSearchPath("TerrainTessellation");

    loadShaders();
    CHECK_GL_ERROR();

    //
    // Create a single default program pipeline to handle binding and unbinding
    // separate shader objects
    //
    glGenProgramPipelines( 1, &mTerrainPipeline);
    glBindProgramPipeline( mTerrainPipeline);
    CHECK_GL_ERROR();

    //create ubo and initialize it with the structure data
    glGenBuffers( 1, &mUBO);
    glBindBuffer( GL_UNIFORM_BUFFER, mUBO);
    glBufferData( GL_UNIFORM_BUFFER, sizeof(TessellationParams), &mParams, GL_STREAM_DRAW);
    CHECK_GL_ERROR();
    
    //create simple single-vertex VBO
    float vtx_data[] = { 0.0f, 0.0f, 0.0f, 1.0f};
    glGenBuffers( 1, &mVBO);
    glBindBuffer( GL_ARRAY_BUFFER, mVBO);
    glBufferData( GL_ARRAY_BUFFER, sizeof(vtx_data), vtx_data, GL_STATIC_DRAW);
    CHECK_GL_ERROR();

    srand(0);

    int noiseSize = 256;
    int noiseSize3D = 64;
    mRandTex = createNoiseTexture2D(noiseSize, noiseSize, GL_R8);
    CHECK_GL_ERROR();

    mRandTex3D = createNoiseTexture4f3D(noiseSize3D, noiseSize3D, noiseSize3D, GL_RGBA8);
    CHECK_GL_ERROR();

    mParams.invNoiseSize = 1.0f / noiseSize;
    mParams.invNoise3DSize = 1.0f / noiseSize3D;

    glGenQueries(1, &mGPUQuery);
    CHECK_GL_ERROR();

    //initTerrainFbo();
    //updateQuality();
    //CHECK_GL_ERROR();
}
Ejemplo n.º 20
0
void init(){

	glewExperimental = GL_TRUE;
	GLenum err = glewInit();
	if (GLEW_OK != err)	{
		std::cerr << "Error: "<< glewGetErrorString(err) << std::endl;
	} else {
		if (GLEW_VERSION_3_3)
		{
			std::cout<< "Driver supports OpenGL 3.3\nDetails:"<< std::endl;
			std::cout << "Using GLEW " << glewGetString(GLEW_VERSION)<< std::endl;
			std::cout << "Vendor: " << glGetString (GL_VENDOR)<< std::endl;
			std::cout << "Renderer: " << glGetString (GL_RENDERER)<< std::endl;
			std::cout << "Version: " << glGetString (GL_VERSION)<< std::endl;
			std::cout << "GLSL: " << glGetString (GL_SHADING_LANGUAGE_VERSION)<< std::endl;
		}
	}
	glGetError();


	fullscreenQuad = new Quad();
	simpleShader = new Shader("shaders/passthrough.vert", "shaders/simple.frag");

	noiseTexture = new Texture2D();
	noiseTexture->loadFromFile(std::string("../common/images/noise.tga"));

	dataBuffer = new Framebuffer(labyrinthSize, labyrinthSize, 2, true, false);
	generateShader = new Shader("shaders/passthrough.vert", "shaders/generate.frag");

	visualizeTex = new Framebuffer(dataBuffer->getWidth() * 2 + 1,
									dataBuffer->getHeight() * 2 + 1,
									1,
									false,
									false);
	visualizeShader = new Shader("shaders/passthrough.vert", "shaders/visualize.frag");

	shortestPath = new Framebuffer(labyrinthSize, labyrinthSize, 1, false, true);

	glGenBuffers(2,streamoutBufffer);
	glBindBuffer(GL_ARRAY_BUFFER_ARB,streamoutBufffer[0]);
	glBufferData(GL_ARRAY_BUFFER_ARB, 	labyrinthSize*labyrinthSize*4*sizeof(float)*2,0,GL_DYNAMIC_DRAW);
	glBindBuffer(GL_ARRAY_BUFFER_ARB,streamoutBufffer[1]);
	glBufferData(GL_ARRAY_BUFFER_ARB, 	labyrinthSize*labyrinthSize*4*sizeof(float)*2,0,GL_DYNAMIC_DRAW);

	searchShader = new Shader("shaders/search.vert", "shaders/search.frag", "shaders/search.geom");
	walkPathShader = new Shader("shaders/search.vert", "shaders/red.frag", "shaders/walkpath.geom");

	glGenQueries(1, &outputQuery);

	glutReshapeWindow(labyrinthSize * windowScale, labyrinthSize * windowScale);
}
Ejemplo n.º 21
0
void piglit_init(int argc, char **argv)
{
	if (argc != 2)
		print_usage_and_exit(argv[0]);
	if (strcmp(argv[1], "discard") == 0)
		discard = GL_TRUE;
	else if (strcmp(argv[1], "buffer") == 0)
		buffer = GL_TRUE;
	else if (strcmp(argv[1], "prims_written") == 0)
		prims_written = GL_TRUE;
	else if (strcmp(argv[1], "prims_generated") == 0)
		prims_generated = GL_TRUE;
	else
		print_usage_and_exit(argv[0]);

	piglit_require_transform_feedback();

	if (buffer || prims_written) {
		GLuint vs;
		piglit_require_GLSL();
		vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
		xfb_prog = glCreateProgram();
		glAttachShader(xfb_prog, vs);
		glTransformFeedbackVaryings(xfb_prog, 1, xfb_varyings,
					    GL_INTERLEAVED_ATTRIBS);
		glLinkProgram(xfb_prog);
		if (!piglit_link_check_status(xfb_prog)) {
			piglit_report_result(PIGLIT_FAIL);
		}
		glGenBuffers(1, &xfb_buf);
	}
	if (prims_written) {
		glGenQueries(1, &prims_written_query);
	}
	if (prims_generated) {
		glGenQueries(1, &prims_generated_query);
	}
}
Ejemplo n.º 22
0
ScopedGPUTimer::ScopedGPUTimer(GPUTimer &t) : timer(t)
{
    if (!UserConfigParams::m_profiler_enabled) return;
    if (profiler.isFrozen()) return;
    if (!timer.canSubmitQuery) return;
#ifdef GL_TIME_ELAPSED
    if (!timer.initialised)
    {
        glGenQueries(1, &timer.query);
        timer.initialised = true;
    }
    glBeginQuery(GL_TIME_ELAPSED, timer.query);
#endif
}
Ejemplo n.º 23
0
PIGLIT_GL_TEST_CONFIG_END

enum piglit_result
piglit_display(void)
{
	bool pass = true;
	float green[4] = {0.0, 1.0, 0.0, 0.0};
	GLuint q;
	GLuint list;

	list = glGenLists(1);
	glNewList(list, GL_COMPILE);
	glClearColor(0.5, 0.5, 0.5, 0.5);
	glClear(GL_COLOR_BUFFER_BIT);

	glGenQueries(1, &q);

	/* Generate query pass: draw bottom half of screen. */
	glColor4f(0.0, 1.0, 0.0, 0.0);
	glBeginQuery(GL_SAMPLES_PASSED, q);
	piglit_draw_rect(-1, -1, 2, 1);
	glEndQuery(GL_SAMPLES_PASSED);

	/* Conditional render that should draw top half of screen. */
	glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
	piglit_draw_rect(-1, 0, 2, 1);
	glEndConditionalRenderNV();

	/* Generate query fail */
	glBeginQuery(GL_SAMPLES_PASSED, q);
	glEndQuery(GL_SAMPLES_PASSED);

	/* Conditional render that should not draw full screen. */
	glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
	glColor4f(1.0, 0.0, 0.0, 0.0);
	piglit_draw_rect(-1, -1, 2, 2);
	glEndConditionalRenderNV();
	glEndList();

	glCallList(list);

	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
				      green);

	piglit_present_results();

	glDeleteQueries(1, &q);

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Ejemplo n.º 24
0
void GpuTimer::start()
{
    QueryPair qp;
    if (availablePairs.empty()) {
        glGenQueries(1, &qp.startQuery);
        glGenQueries(1, &qp.endQuery);
    }
    else {
        qp = availablePairs.front();
        availablePairs.pop(); // Reuse old OpenGL ids, no need for additional glGenQueries.
    }

    inflightPairs.push(qp);
    // Create a fence and insert it into the command stream. This fence will be signaled
    // when the GPU has completed all previously issued commands. glWaitSync will defer
    // subsequently issued commands (without blocking CPU) until the fence signals.
    // This prevents overlapped execution of OpenGL calls and should make timing measurements
    // more precise. For more, see e.g. OpenGL Insights.
    GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
    glWaitSync(sync, 0, GL_TIMEOUT_IGNORED);
    glDeleteSync(sync); // Flag for deletion.

    glQueryCounter(qp.startQuery, GL_TIMESTAMP);
}
Ejemplo n.º 25
0
static void init_if_needed() {
  static int is_initialized = 0;
  if (is_initialized) return;

  glGenQueries(num_timer_queries, timer_queries);

  for (int i = 0; i < num_timer_queries; ++i) {
    query_names[i] = NULL;
  }

  checkpoint_times     = map__new(str_hash, str_eq);
  checkpoint_callbacks = map__new(str_hash, str_eq);
  
  is_initialized = 1;
}
Ejemplo n.º 26
0
	void VertexBuffer::DrawToFeedbackBuffer(VertexBuffer* target, ShaderProgram* shader_program, bool keep_fragments)
	{
		GLDEBUG();

		if(!keep_fragments)
			glEnable(GL_RASTERIZER_DISCARD);

		ShaderProgram::SetActiveProgram(shader_program);

		GLchar const* strings[] = { "gl_Position" };
//		glTransformFeedbackVaryings(shader_program->program_id, 1, strings, GL_SEPARATE_ATTRIBS);

		// we must re-link the program to force some things to update (i think?)
		glLinkProgram(shader_program->program_id);

		GLuint query;
		glGenQueries(1, &query);

		GLuint out_buf;
		glGenBuffers(1, &out_buf);
		glBindBuffer(GL_ARRAY_BUFFER, out_buf);
		glBufferData(GL_ARRAY_BUFFER, 4 * num_verts * sizeof(float), NULL, GL_STATIC_DRAW);
		glBindBuffer(GL_ARRAY_BUFFER, 0);

		glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, out_buf);

//		glBindVertexArray(transform vertex array name);

		glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query); 
		glBeginTransformFeedback((GLenum)storage_mode);
			glDrawArrays((GLenum)storage_mode, 0, num_verts);
		glEndTransformFeedback();
		glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); 
		
		glDisable(GL_RASTERIZER_DISCARD);

		GLuint primitives_written = 0;
		glGetQueryObjectuiv(query, GL_QUERY_RESULT, &primitives_written);

		glDeleteQueries(1, &query);

		/*
		TODO: put results into target
		*/


		GLDEBUG();
	}
Ejemplo n.º 27
0
void initGPUTimer (GPUtimer * timer)
{
   memset (timer, 0, sizeof (*timer));
   /*	timer->supported = glfwExtensionSupported("GL_ARB_timer_query");
      if (timer->supported) {*/
   //#ifndef GL_ARB_timer_query
   //glGetQueryObjectui64v = (pfnGLGETQUERYOBJECTUI64V)glfwGetProcAddress("glGetQueryObjectui64v");
   ////printf("glGetQueryObjectui64v=%p\n", glGetQueryObjectui64v);
   //if (!glGetQueryObjectui64v) {
   //timer->supported = GL_FALSE;
   //return;
   //}*/
   //#endif
   glGenQueries (GPU_QUERY_COUNT, timer->queries);
   //}
}
Ejemplo n.º 28
0
OpenGLRenderer::OpenGLRenderer() {
    // We need to query for some profiling exts.
    ogl_CheckExtensions();

    glGenQueries(1, &debugQuery);

    createUBO(UBOScene, sizeof(SceneUniformData), sizeof(SceneUniformData));
    glBindBufferBase(GL_UNIFORM_BUFFER, kUBOIndexScene, UBOScene.name);

    GLint MaxUBOSize;
    glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &MaxUBOSize);

    createUBO(UBOObject, MaxUBOSize, sizeof(ObjectUniformData));

    swap();
}
Ejemplo n.º 29
0
	GpuQuery::GpuQuery() :
	m_id(0)
	{
		Context::EnsureContext();

		m_id = 0;
		glGenQueries(1, static_cast<GLuint*>(&m_id));

		#ifdef NAZARA_DEBUG
		if (!m_id)
		{
			NazaraError("Failed to create occlusion query");
			throw std::runtime_error("Constructor failed");
		}
		#endif
	}
Ejemplo n.º 30
0
Archivo: perf.c Proyecto: imclab/nanovg
void initGPUTimer(struct GPUtimer* timer)
{
	memset(timer, 0, sizeof(*timer));

	timer->supported = glfwExtensionSupported("GL_ARB_timer_query");
	if (timer->supported) {
#ifndef GL_ARB_timer_query
		glGetQueryObjectui64v = (pfnGLGETQUERYOBJECTUI64V)glfwGetProcAddress("glGetQueryObjectui64v");
		if (!glGetQueryObjectui64v) {
			timer->supported = GL_FALSE;
			return;
		}
#endif
		glGenQueries(GPU_QUERY_COUNT, timer->queries);
	}
}