Пример #1
0
void
endProfile(trace::Call &call, bool isDraw) {
    if (retrace::profilingWithBackends) {
        if (profilingBoundaries[QUERY_BOUNDARY_CALL] ||
            profilingBoundaries[QUERY_BOUNDARY_DRAWCALL]) {
            if (curMetricBackend) {
                curMetricBackend->endQuery(isDraw ? QUERY_BOUNDARY_DRAWCALL : QUERY_BOUNDARY_CALL);
            }
        }
        return;
    }

    /* CPU profiling for all calls */
    if (retrace::profilingCpuTimes) {
        CallQuery& query = callQueries.back();
        query.cpuEnd = getCurrentTime();
    }

    /* GPU profiling only for draw calls */
    if (isDraw) {
        if (retrace::profilingGpuTimes) {
            glEndQuery(GL_TIME_ELAPSED);
        }

        if (retrace::profilingPixelsDrawn) {
            glEndQuery(GL_SAMPLES_PASSED);
        }
    }

    if (retrace::profilingMemoryUsage) {
        CallQuery& query = callQueries.back();
        query.vsizeEnd = os::getVsize();
        query.rssEnd = os::getRss();
    }
}
Пример #2
0
void
endProfile(trace::Call &call, bool isDraw) {

    /* CPU profiling for all calls */
    if (retrace::profilingCpuTimes) {
        CallQuery& query = callQueries.back();
        query.cpuEnd = getCurrentTime();
    }

    /* GPU profiling only for draw calls */
    if (isDraw) {
        if (retrace::profilingGpuTimes) {
            glEndQuery(GL_TIME_ELAPSED);
        }

        if (retrace::profilingPixelsDrawn) {
            glEndQuery(GL_SAMPLES_PASSED);
        }
    }

    if (retrace::profilingMemoryUsage) {
        CallQuery& query = callQueries.back();
        query.vsizeEnd = os::getVsize();
        query.rssEnd = os::getRss();
    }
}
Пример #3
0
enum piglit_result
piglit_display(void)
{
	bool pass = true;
	float green[4] = {0.0, 1.0, 0.0, 0.0};
	float *buf;
	int i;
	GLuint q;

	glClearColor(0.5, 0.5, 0.5, 0.5);
	glClear(GL_COLOR_BUFFER_BIT);

	buf = malloc(sizeof(float) * 4 * piglit_width * piglit_height);

	glGenQueries(1, &q);

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

	/* Conditional render that should draw bottom half of screen. */
	for (i = 0; i < piglit_width * piglit_height / 2; i++) {
		buf[i * 4 + 0] = 0.0;
		buf[i * 4 + 1] = 1.0;
		buf[i * 4 + 2] = 0.0;
		buf[i * 4 + 3] = 0.0;
	}
	glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
	glRasterPos2i(-1, -1);
	glDrawPixels(piglit_width, piglit_height / 2, GL_RGBA, GL_FLOAT, buf);
	glEndConditionalRenderNV();

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

	/* Conditional render that should not draw full screen. */
	for (i = 0; i < piglit_width * piglit_height; i++) {
		buf[i * 4 + 0] = 1.0;
		buf[i * 4 + 1] = 0.0;
		buf[i * 4 + 2] = 0.0;
		buf[i * 4 + 3] = 0.0;
	}
	glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
	glRasterPos2i(-1, -1);
	glDrawPixels(piglit_width, piglit_height, GL_RGBA, GL_FLOAT, buf);
	glEndConditionalRenderNV();

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

	glutSwapBuffers();

	glDeleteQueries(1, &q);
	free(buf);

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Пример #4
0
PIGLIT_GL_TEST_CONFIG_END

enum piglit_result
piglit_display(void)
{
    GLuint active, inactive;
    GLint elapsed;

    /* Generate and start a query. */
    glGenQueries(1, &active);

    glBeginQuery(GL_SAMPLES_PASSED, active);

    printf ("Testing Gen/Delete of query while another query is active.\n");
    {
        /* While first query is active, gen a new one. */
        glGenQueries(1, &inactive);

        if (!piglit_check_gl_error(GL_NO_ERROR))
            return PIGLIT_FAIL;

        /* Delete the inactive query. */
        glDeleteQueries(1, &inactive);

        if (!piglit_check_gl_error(GL_NO_ERROR))
            return PIGLIT_FAIL;

        /* Finish and get result from active query. */
        glEndQuery(GL_SAMPLES_PASSED);

        glGetQueryObjectiv(active, GL_QUERY_RESULT, &elapsed);
    }

    printf ("Testing Delete of currently-active query.\n");
    {
        /* Finally, ensure that an active query can be deleted. */
        glGenQueries(1, &active);

        glBeginQuery(GL_SAMPLES_PASSED, active);

        glDeleteQueries(1, &active);

        if (!piglit_check_gl_error(GL_NO_ERROR))
            return PIGLIT_FAIL;
    }

    printf ("Testing that glEndQuery on deleted query (expecting error).\n");
    {
        /* And ensure that we get an error if we try to end a deleted
         * query. */
        glEndQuery(GL_SAMPLES_PASSED);

        if (!piglit_check_gl_error(GL_INVALID_OPERATION))
            return PIGLIT_FAIL;
    }

    return PIGLIT_PASS;
}
Пример #5
0
PIGLIT_GL_TEST_CONFIG_END

enum piglit_result
piglit_display(void)
{
	GLuint oq[3];
	GLint result[3] = {2, 2, 2};
	bool pass = true;
	int i;

	glEnable(GL_DEPTH_TEST);

	glClearDepth(1.0);
	glClearColor(0.5, 0.5, 0.5, 0.5);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glGenQueries(3, oq);
	glDeleteQueries(3, oq);

	glColor4f(0.0, 1.0, 0.0, 0.0);
	glBeginQuery(GL_ANY_SAMPLES_PASSED, oq[0]);
	piglit_draw_rect_z(0.5, -1, -1, 2, 2);
	glEndQuery(GL_ANY_SAMPLES_PASSED);

	glBeginQuery(GL_ANY_SAMPLES_PASSED, oq[1]);
	glEndQuery(GL_ANY_SAMPLES_PASSED);

	glColor4f(1.0, 0.0, 0.0, 0.0);
	glBeginQuery(GL_ANY_SAMPLES_PASSED, oq[2]);
	piglit_draw_rect_z(0.75, -0.5, -0.5, 1.0, 1.0);
	glEndQuery(GL_ANY_SAMPLES_PASSED);

	piglit_present_results();

	for (i = 0; i < 3; i++) {
		glGetQueryObjectiv(oq[i], GL_QUERY_RESULT, &result[i]);
	}

	if (result[0] != GL_TRUE) {
		fprintf(stderr, "GL_ANY_SAMPLES_PASSED with passed fragments returned %d\n",
			result[0]);
		pass = false;
	}

	if (result[1] != GL_FALSE) {
		fprintf(stderr, "GL_ANY_SAMPLES_PASSED with no rendering returned %d\n",
			result[1]);
		pass = false;
	}

	if (result[2] != GL_FALSE) {
		fprintf(stderr, "GL_ANY_SAMPLES_PASSED with occluded rendering returned %d\n",
			result[2]);
		pass = false;
	}

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Пример #6
0
	void OGLConditionalRender::End()
	{
		if (glloader_GL_VERSION_3_3() || glloader_GL_ARB_occlusion_query2())
		{
			glEndQuery(GL_ANY_SAMPLES_PASSED);
		}
		else
		{
			glEndQuery(GL_SAMPLES_PASSED);
		}
	}
Пример #7
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;
}
Пример #8
0
void recursion( float startX,
				float startY,
				float startZ,
				float startW)
{
	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,0,streamoutBufffer[0]);

	glBeginTransformFeedback(GL_POINTS);
	glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, outputQuery);
	glPointSize(1);
	glBegin(GL_POINTS);
	glVertex4f(startX, startY, startZ, startW);
	glEnd();
	glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);

	glEndTransformFeedback();

	GLint outPointCount = 0;
	GLint succ = 0;

	while(!succ)
		glGetQueryObjectiv(outputQuery, GL_QUERY_RESULT_AVAILABLE, &succ);
	glGetQueryObjectiv(outputQuery, GL_QUERY_RESULT, &outPointCount);
	//std::cout << "points written: " << outPointCount << std::endl;
	succ = 0;

	glEnableClientState(GL_VERTEX_ARRAY);
	int bb = 0;
	while(outPointCount > 0)
	{
		glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,0,streamoutBufffer[(bb+1)%2]);
		glBeginTransformFeedback(GL_POINTS);

		glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, outputQuery);

		glBindBufferARB(GL_ARRAY_BUFFER_ARB, streamoutBufffer[bb]);
		glVertexPointer(4,GL_FLOAT,0,NULL);
		glDrawArrays(GL_POINTS, 0, outPointCount);

		glEndTransformFeedback();

		glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
		while(!succ)
			glGetQueryObjectiv(outputQuery, GL_QUERY_RESULT_AVAILABLE, &succ);
		glGetQueryObjectiv(outputQuery, GL_QUERY_RESULT, &outPointCount);
		succ = 0;

		bb = (bb + 1) % 2;
	}
	glDisableClientState(GL_VERTEX_ARRAY);
}
Пример #9
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;
}
Пример #10
0
static float
draw(GLuint *q, int iters)
{
	float start_time, end_time;

	glUseProgram(prog);
	glUniform1i(iters_loc, iters);

	start_time = get_time();

	if (test == TIMESTAMP) {
		glQueryCounter(q[0], GL_TIMESTAMP);
	} else {
		glBeginQuery(GL_TIME_ELAPSED, q[0]);
	}
	piglit_draw_rect(-1, -1, 2, 2);
	if (test == TIMESTAMP) {
		glQueryCounter(q[1], GL_TIMESTAMP);
	} else {
		glEndQuery(GL_TIME_ELAPSED);
	}

	/* This glFinish() is important, since this is used in a
	 * timing loop.
	 */
	glFinish();

	end_time = get_time();

	return end_time - start_time;
}
Пример #11
0
void TransitionParticles::update(const ofBufferObject & blobs, const ofxTexture3d & noiseField, float now){
	auto numParticles = totalVertices / every;

	computeShader.begin();
	computeShader.setUniform1f("every", every);
	computeShader.setUniform1f("now", now);
	computeShader.setUniform1f("dt",ofGetLastFrameTime()*speed);
	computeShader.setUniform1f("repulsionForce", repulsion);
	computeShader.setUniform1f("attractionForce", attraction);
	computeShader.setUniform1f("elapsedTime",now);
	computeShader.setUniform1f("bufferSize", totalVertices);
	computeShader.setUniform1f("noiseSize", noiseField.texData.width);
	computeShader.setUniform1f("frameNum", ofGetFrameNum());
	computeShader.setUniformTexture("noiseField", GL_TEXTURE_3D, noiseField.texData.textureID, 0);
	computeShader.dispatchCompute(numParticles / 1024 + 1, 1, 1);
	computeShader.end();

	glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, numVerticesQuery);
	shader.beginTransformFeedback(GL_TRIANGLES, feedbackBuffer);
	blobs.bindBase(GL_SHADER_STORAGE_BUFFER, 0);
	shader.setUniform1f("every", every);
	shader.setUniform1f("scale", scale);
	shader.setUniform4f("particleColor", color);
	model.drawInstanced(GL_TRIANGLES, 0, model.getNumVertices(), numParticles);
	shader.endTransformFeedback(feedbackBuffer);
	glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
	glGetQueryObjectuiv(numVerticesQuery, GL_QUERY_RESULT, &numPrimitives);
}
Пример #12
0
void LODmodel::getLODvalue()
{
	// ==================================
	// occlusion query alg
	
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
		glMultMatrixf( transformMatrix.m );
		// draw bbox and query it...
		glBeginQuery(GL_SAMPLES_PASSED, queryID);
			lods[0]->drawForLOD();
		glEndQuery(GL_SAMPLES_PASSED);
	glPopMatrix(); 
	// decide which LOD depending on query result...
	GLuint	result = 0;
	glGetQueryObjectuiv(queryID, GL_QUERY_RESULT, &result);
	*LODvalue = result;

	/*
	// ===================================
	// distance alg
	
	// get distance to camera

	// decide which LOD depending distance...
 
	
	*/
	

}
Пример #13
0
void FeedbackTransformPass::DoRun()
{
	glDisable(GL_DEPTH_TEST);

	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf->vbo);
	{
		Use shader(program);
		glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query); 
		glBeginTransformFeedback(objtype);
		glEnable(GL_RASTERIZER_DISCARD); 

		out->Draw(program);

		glDisable(GL_RASTERIZER_DISCARD); 
		glEndTransformFeedback();
		glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); 
		
		// performance loss of 15ms order
		TODO_W("Move this query to the *start* of the transform, use the old objects in the drawing phase.");
		glGetQueryObjectuiv(query, GL_QUERY_RESULT, &buf->count);
	}
	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);

	swap(*buf, *out);
}
Пример #14
0
void occlusion_query::end_query() const
{
    if (state_ == inactive)
        return;

    glCheck(glEndQuery(GL_SAMPLES_PASSED));
}
Пример #15
0
int stopGPUTimer(GPUtimer* timer, float* times, int maxTimes)
{
//	NVG_NOTUSED(times);
//	NVG_NOTUSED(maxTimes);
	GLint available = 1;
	int n = 0;
	if (!timer->supported)
		return 0;
    
	glEndQuery(GL_TIME_ELAPSED);
	while (available && timer->ret <= timer->cur) {
		// check for results if there are any
		glGetQueryObjectiv(timer->queries[timer->ret % GPU_QUERY_COUNT], GL_QUERY_RESULT_AVAILABLE, &available);
		if (available) {
            GLuint64 timeElapsed = 0;
            glGetQueryObjectui64v(timer->queries[timer->ret % GPU_QUERY_COUNT], GL_QUERY_RESULT, &timeElapsed);
            timer->ret++;
            if (n < maxTimes) {
                times[n] = (float)((double)timeElapsed * 1e-9);
                n++;
            }
		}
	}
	return n;
}
Пример #16
0
void GLGSRender::check_zcull_status(bool framebuffer_swap, bool force_read)
{
	if (g_cfg.video.disable_zcull_queries)
		return;

	bool testing_enabled = zcull_pixel_cnt_enabled || zcull_stats_enabled;

	if (framebuffer_swap)
	{
		zcull_surface_active = false;
		const u32 zeta_address = depth_surface_info.address;

		if (zeta_address)
		{
			//Find zeta address in bound zculls
			for (int i = 0; i < rsx::limits::zculls_count; i++)
			{
				if (zculls[i].binded)
				{
					const u32 rsx_address = rsx::get_address(zculls[i].offset, CELL_GCM_LOCATION_LOCAL);
					if (rsx_address == zeta_address)
					{
						zcull_surface_active = true;
						break;
					}
				}
			}
		}
	}

	occlusion_query_info* query = nullptr;

	if (zcull_task_queue.task_stack.size() > 0)
		query = zcull_task_queue.active_query;

	if (query && query->active)
	{
		if (force_read || (!zcull_rendering_enabled || !testing_enabled || !zcull_surface_active))
		{
			glEndQuery(GL_ANY_SAMPLES_PASSED);
			query->active = false;
			query->pending = true;
		}
	}
	else
	{
		if (zcull_rendering_enabled && testing_enabled && zcull_surface_active)
		{
			//Find query
			u32 free_index = synchronize_zcull_stats();
			query = &occlusion_query_data[free_index];
			zcull_task_queue.add(query);

			glBeginQuery(GL_ANY_SAMPLES_PASSED, query->handle);
			query->active = true;
			query->result = 0;
			query->num_draws = 0;
		}
	}
}
Пример #17
0
void IrrDriver::computeSunVisibility()
{
    // Is the lens flare enabled & visible? Check last frame's query.
    bool hasgodrays = false;

    if (World::getWorld() != NULL)
    {
        hasgodrays = World::getWorld()->getTrack()->hasGodRays();
    }

    if (UserConfigParams::m_light_shaft && hasgodrays)
    {
        GLuint res = 0;
        if (m_query_issued)
            glGetQueryObjectuiv(m_lensflare_query, GL_QUERY_RESULT, &res);
        m_post_processing->setSunPixels(res);

        // Prepare the query for the next frame.
        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
        glBeginQuery(GL_SAMPLES_PASSED_ARB, m_lensflare_query);
        m_scene_manager->setCurrentRendertime(scene::ESNRP_SOLID);
        m_scene_manager->drawAll(scene::ESNRP_CAMERA);
        irr_driver->setPhase(GLOW_PASS);
        m_sun_interposer->render();
        glEndQuery(GL_SAMPLES_PASSED_ARB);
        m_query_issued = true;

        m_lensflare->setStrength(res / 4000.0f);

        // Make sure the color mask is reset
        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    }
}
Пример #18
0
unsigned int GPU_select_end(void)
{
	unsigned int hits = 0;
	if (!g_query_state.use_gpu_select) {
		glPopName();
		hits = glRenderMode(GL_RENDER);
	}
	else {
		int i;

		if (g_query_state.query_issued) {
			glEndQuery(GL_SAMPLES_PASSED);
		}

		for (i = 0; i < g_query_state.active_query; i++) {
			unsigned int result;
			glGetQueryObjectuiv(g_query_state.queries[i], GL_QUERY_RESULT, &result);
			if (result > 0) {
				if (g_query_state.mode != GPU_SELECT_NEAREST_SECOND_PASS) {
					int maxhits = g_query_state.bufsize / 4;

					if (hits < maxhits) {
						g_query_state.buffer[hits * 4] = 1;
						g_query_state.buffer[hits * 4 + 1] = 0xFFFF;
						g_query_state.buffer[hits * 4 + 2] = 0xFFFF;
						g_query_state.buffer[hits * 4 + 3] = g_query_state.id[i];

						hits++;
					}
					else {
						hits = -1;
						break;
					}
				}
				else {
					int j;
					/* search in buffer and make selected object first */
					for (j = 0; j < g_query_state.oldhits; j++) {
						if (g_query_state.buffer[j * 4 + 3] == g_query_state.id[i]) {
							g_query_state.buffer[j * 4 + 1] = 0;
							g_query_state.buffer[j * 4 + 2] = 0;
						}
					}
					break;
				}
			}
		}

		glDeleteQueries(g_query_state.num_of_queries, g_query_state.queries);
		MEM_freeN(g_query_state.queries);
		MEM_freeN(g_query_state.id);
		glPopAttrib();
		glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
	}

	g_query_state.select_is_active = false;

	return hits;
}
Пример #19
0
uint64_t kit::GLTimer::end()
{
  
  glEndQuery(GL_TIME_ELAPSED);
  uint64_t timenano = 0;
  glGetQueryObjectui64v(m_glHandle, GL_QUERY_RESULT, &timenano);
  return timenano;// / 1,000,000.0;
}
Пример #20
0
void whitgl_profile_gpu_section(const char* name)
{
	if(next_gpu_event > 0)
		glEndQuery(GL_TIME_ELAPSED);
	gpu_events[next_gpu_event].name = name;
	glBeginQuery(GL_TIME_ELAPSED, _front ? _front_queries[next_gpu_event] : _back_queries[next_gpu_event]);
	next_gpu_event++;
}
Пример #21
0
enum piglit_result
piglit_display(void)
{
	bool pass = true;
	float green[4] = {0.0, 1.0, 0.0, 0.0};
	GLuint qpass, qfail;

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

	glGenQueries(1, &qpass);
	glGenQueries(1, &qfail);

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

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

	/* Conditional render that should not copy red over the green. */
	glBeginConditionalRenderNV(qfail, GL_QUERY_WAIT_NV);
	glRasterPos2i(-1, 0);
	glCopyPixels(0, 0, piglit_width, piglit_height / 2, GL_COLOR);
	glEndConditionalRenderNV();

	/* Conditional render that should copy green over remaining red. */
	glBeginConditionalRenderNV(qpass, GL_QUERY_WAIT_NV);
	glRasterPos2i(-1, -1);
	glCopyPixels(0, piglit_height / 2, piglit_width, piglit_height / 2,
		     GL_COLOR);
	glEndConditionalRenderNV();

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

	glutSwapBuffers();

	glDeleteQueries(1, &qfail);
	glDeleteQueries(1, &qpass);

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Пример #22
0
void PerfQuery::DisableQuery(PerfQueryGroup type)
{
	// stop query
	if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
	{
		glEndQuery(GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL ? GL_SAMPLES_PASSED : GL_ANY_SAMPLES_PASSED);
	}
}
Пример #23
0
static void fgl_stats_end_recording(void) {
    unsigned i;
    for(i=0 ; i<11 ; ++i)
        glEndQuery(fgl_stats.targets[i]);
    for(i=0 ; i<11 ; ++i)
        glGetQueryObjectuiv(fgl_stats.names[i], GL_QUERY_RESULT,
                            fgl_stats.results + i);
}
Пример #24
0
void PerfQueryGL::DisableQuery(PerfQueryGroup type)
{
	// stop query
	if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
	{
		glEndQuery(m_query_type);
	}
}
Пример #25
0
void GPUClock::stop()
{
    if(mStarted && !mStopped)
    {
        glEndQuery(GL_TIME_ELAPSED);
        mStarted = false;
        mStopped = true;
    }
}
void hge::render::GeometryUnit::occlusionQuery(const math::Matrix4D<> &vp)
{
	mvp = vp * modelMatrix.getConstRotateScaleTranslateMatrix();
	glBeginQuery(GL_ANY_SAMPLES_PASSED, queries[HGEGEOMETRYOCCLUSIONQUERYINDEX]);
	occlusionQueryShader->setModelViewProjectionMatrix(mvp);
	occlusionQueryMesh->bindTotal();
	occlusionQueryMesh->draw();
	glEndQuery(GL_ANY_SAMPLES_PASSED);
}
Пример #27
0
	void end()
	{
		if (!thisQueryActive)
			return;

		glEndQuery(GL_TIME_ELAPSED);
		queryActive = false;
		thisQueryActive = false;
	}
Пример #28
0
static void SCE_ROcclusionQueryCallback (int begin)
{
    if (begin)
        glBeginQuery (GL_SAMPLES_PASSED, queryid);
    else {
        glEndQuery (GL_SAMPLES_PASSED);
        glGetQueryObjectiv (queryid, GL_QUERY_RESULT, &drawpixels);
    }
}
Пример #29
0
enum piglit_result
piglit_display(void)
{
	bool pass = true;
	GLfloat *v;
	int i;
	GLuint q, num_prims;

	glClear(GL_COLOR_BUFFER_BIT);

	glGenQueries(1, &q);
	glBeginQuery(GL_PRIMITIVES_GENERATED_EXT, q);

	glBeginTransformFeedback(GL_POINTS);
	glBindBuffer(GL_ARRAY_BUFFER, vert_buf);
	glVertexPointer(3, GL_FLOAT, 0, 0);
	glEnable(GL_VERTEX_ARRAY);
	glDrawArrays(GL_POINTS, 0, 3);
	glEndTransformFeedback();

	glEndQuery(GL_PRIMITIVES_GENERATED);

	glGetQueryObjectuiv(q, GL_QUERY_RESULT, &num_prims);
	glDeleteQueries(1, &q);
	printf("%u primitives generated:\n", num_prims);

	if (num_prims != NUM_VERTS) {
		printf("Incorrect number of prims generated.\n");
		printf("Found %u, expected %u\n", num_prims, NUM_VERTS);
		pass = false;
	}

	glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, xfb_buf);
	v = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, GL_READ_ONLY);
	for (i = 0; i < num_prims; i++) {
		printf("vertex %2d: pos %5.2g, %5.2g, %5.2g, %5.2g   "
		       "color %5.2g, %5.2g, %5.2g, %5.2g\n", i,
		       v[i*8+0], v[i*8+1], v[i*8+2], v[i*8+3],
		       v[i*8+4], v[i*8+5], v[i*8+6], v[i*8+7]);
		/* spot-check results */
		if (!equal(v[i*8+1], 0.1)) {
			printf("Incorrect Y coord for point %d: %f\n",
			       i, v[i*8+1]);
			pass = false;
		}
		if (!equal(v[i*8+4], 0.9)) {
			printf("Incorrect red value for point %d: %f\n",
			       i, v[i*8+4]);
			pass = false;
		}
	}
	glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
	bool render()
	{
		glm::ivec2 WindowSize(this->getWindowSize());

		{
			glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
			glm::mat4* Pointer = reinterpret_cast<glm::mat4*>(glMapBufferRange(GL_UNIFORM_BUFFER,
				0, sizeof(glm::mat4), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT));

			glm::mat4 Projection = glm::perspective(glm::pi<float>() * 0.25f, static_cast<float>(WindowSize.x) / static_cast<float>(WindowSize.y), 0.1f, 100.0f);
			glm::mat4 Model = glm::mat4(1.0f);
		
			*Pointer = Projection * this->view() * Model;

			glUnmapBuffer(GL_UNIFORM_BUFFER);
		}

		// Set the display viewport
		glViewport(0, 0, WindowSize.x, WindowSize.y);
		glBindBufferBase(GL_UNIFORM_BUFFER, semantic::uniform::TRANSFORM0, BufferName[buffer::TRANSFORM]);

		// Clear color buffer with black
		glClearBufferfv(GL_COLOR, 0, &glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)[0]);

		// Bind program
		glUseProgram(ProgramName);
		glBindVertexArray(VertexArrayName);

		glBindBufferRange(GL_UNIFORM_BUFFER, semantic::uniform::MATERIAL, BufferName[buffer::MATERIAL], 0, sizeof(glm::vec4));
	
		// The first orange quad is not written in the framebuffer.
		glColorMaski(0, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

		// Beginning of the samples count query
		glBeginQuery(GL_SAMPLES_PASSED, QueryName);
			// To test the condional rendering, comment this line, the next draw call won't happen.
			glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
		// End of the samples count query
		glEndQuery(GL_SAMPLES_PASSED);

		// The second blue quad is written in the framebuffer only if a sample pass the occlusion query.
		glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
	
		glBindBufferRange(GL_UNIFORM_BUFFER, semantic::uniform::MATERIAL, BufferName[buffer::MATERIAL], this->UniformMaterialOffset, sizeof(glm::vec4));

		// Draw only if one sample went through the tests, 
		// we don't need to get the query result which prevent the rendering pipeline to stall.
		glBeginConditionalRender(QueryName, GL_QUERY_WAIT);

			// Clear color buffer with white
			glClearBufferfv(GL_COLOR, 0, &glm::vec4(1.0f)[0]);

			glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
		glEndConditionalRender();

		return true;
	}