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; }
void R_ShutdownVisTests() { int hTest; for (hTest = 0; hTest < MAX_VISTESTS; hTest++) { visTestQueries_t* test = &backEnd.visTestQueries[hTest]; glDeleteQueries(1, &test->hQuery); glDeleteQueries(1, &test->hQueryRef); } }
BasicLFB::~BasicLFB() { delete counts; delete data; if (query) glDeleteQueries(1, &query); }
enum piglit_result piglit_display(void) { int test_pass = 1; GLuint query; GLint result; piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Guaranteed to be random, see: http://xkcd.com/221 */ query = 3243; test_pass &= is_query_matches(query, 0, "with un-generated name"); glGenQueries(1, &query); test_pass &= is_query_matches(query, 0, "after glGenQueries"); glQueryCounter(query, GL_TIMESTAMP); test_pass &= is_query_matches(query, 1, "after glQueryCounter"); /* Do a little drawing at least */ glColor3ub(0x00, 0xff, 0x00); piglit_draw_rect(0, 0, piglit_width, piglit_height); glGetQueryObjectiv(query, GL_QUERY_RESULT, &result); test_pass &= is_query_matches(query, 1, "after glGetQueryObjectiv"); glDeleteQueries(1, &query); test_pass &= is_query_matches(query, 0, "after glDeleteQueries"); piglit_present_results(); return test_pass ? PIGLIT_PASS : PIGLIT_FAIL; }
std::vector<int> CDecalsDrawerGL4::UpdateOverlap_PreCheck() { std::vector<int> candidatesForOverlap; // we are in a test already, check if one of the tested decals changed, if so we need to restart the test if ((overlapStage == 1) && !waitingDecalsForOverlapTest.empty()) { for (auto& p: waitingOverlapGlQueries) { auto it = spring::find(waitingDecalsForOverlapTest, p.first); if (it == waitingDecalsForOverlapTest.end()) continue; // one of the decals changed, we need to restart the overlap test overlapStage = 0; for (auto& p: waitingOverlapGlQueries) { glDeleteQueries(1, &p.second); waitingDecalsForOverlapTest.push_back(p.first); } waitingOverlapGlQueries.clear(); break; } } // not enough changed decals -> wait further if ((overlapStage == 0) && (waitingDecalsForOverlapTest.size() <= (MAX_OVERLAP * 4))) return candidatesForOverlap; // only test those decals which overlap with others and add them to the vector if (overlapStage == 0) { candidatesForOverlap = CandidatesForOverlap(); waitingDecalsForOverlapTest.clear(); } return candidatesForOverlap; }
GPUTimer::~GPUTimer() { #if !defined (PLATFORM_ES2) if( !_queryPool.empty() ) glDeleteQueries( (uint32)_queryPool.size(), &_queryPool[0] ); #endif }
void SampleQueryGLTest::wrap() { #ifdef MAGNUM_TARGET_GLES2 if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::occlusion_query_boolean>()) CORRADE_SKIP(Extensions::GL::EXT::occlusion_query_boolean::string() + std::string(" is not available.")); #endif GLuint id; #ifndef MAGNUM_TARGET_GLES2 glGenQueries(1, &id); #else glGenQueriesEXT(1, &id); #endif /* Releasing won't delete anything */ { auto query = SampleQuery::wrap(id, SampleQuery::Target::AnySamplesPassed, ObjectFlag::DeleteOnDestruction); CORRADE_COMPARE(query.release(), id); } /* ...so we can wrap it again */ SampleQuery::wrap(id, SampleQuery::Target::AnySamplesPassed); #ifndef MAGNUM_TARGET_GLES2 glDeleteQueries(1, &id); #else glDeleteQueriesEXT(1, &id); #endif }
PIGLIT_GL_TEST_CONFIG_END void piglit_init(int argc, char **argv) { /** * Separate queries for four different cases preventing the test from * re-using a query that got possibly activated by the previous attempt. * * generated with maximum * generated with maximum + 1 * written with maximum * written with maximum + 1 */ GLuint queries[4]; GLint max_streams; bool pass = true; piglit_require_extension("GL_ARB_transform_feedback3"); glGetIntegerv(GL_MAX_VERTEX_STREAMS, &max_streams); if (!piglit_check_gl_error(GL_NO_ERROR)) { printf("failed to resolve the maximum number of streams\n"); piglit_report_result(PIGLIT_FAIL); } if (max_streams <= 0) { printf("invalid maximum number of streams: %d\n", max_streams); piglit_report_result(PIGLIT_FAIL); } glGenQueries(ARRAY_SIZE(queries), queries); glBeginQueryIndexed(GL_PRIMITIVES_GENERATED, max_streams - 1, queries[0]); if (!piglit_check_gl_error(GL_NO_ERROR)) { printf("failed to activate primitives generated query for the " "maximum supported stream\n"); pass = false; } glBeginQueryIndexed(GL_PRIMITIVES_GENERATED, max_streams, queries[1]); pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, max_streams - 1, queries[2]); if (!piglit_check_gl_error(GL_NO_ERROR)) { printf("failed to activate primitives written query for the " "maximum supported stream\n"); pass = false; } glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, max_streams, queries[3]); pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; glDeleteQueries(ARRAY_SIZE(queries), queries); piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
// Resets profile stats void VSProfileLib::Reset() { for(int i=0; i < sTotalLevels; ++i) { for (unsigned int s = 0; s < sLevels[i].sec.size(); ++s) { for (unsigned int k = 0; k < sLevels[i].sec[s].queriesGL[0].size(); ++k) { glDeleteQueries(2, sLevels[i].sec[s].queriesGL[0][k].queries); } for (unsigned int k = 0; k < sLevels[i].sec[s].queriesGL[1].size(); ++k) { glDeleteQueries(2, sLevels[i].sec[s].queriesGL[1][k].queries); } } sLevels[i].sec.clear(); } sTotalLevels = 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; }
Tessellator::~Tessellator() { glDeleteVertexArrays(1, &m_vaoID); glDeleteBuffers(1, &m_bufferID); glDeleteQueries(1, &m_primitivesQuery); safeDelete(program); }
~TimerQuery() { if (thisQueryActive) end(); glDeleteQueries(1, &query); }
// -------------------------------------------------------------------------------------------------------------------- void UntexturedObjectsGLBindlessIndirect::Shutdown() { if (m_transform_ptr) { glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_transform_buffer); glUnmapBuffer(GL_SHADER_STORAGE_BUFFER); } glDeleteBuffers(1, &m_transform_buffer); if (m_cmd_ptr) { glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_cmd_buffer); glUnmapBuffer(GL_DRAW_INDIRECT_BUFFER); } glDeleteQueries(m_queries.size(), &*m_queries.begin()); glDeleteBuffers(1, &m_cmd_buffer); glDeleteBuffers(m_ibs.size(), &*m_ibs.begin()); glDeleteBuffers(m_vbs.size(), &*m_vbs.begin()); glDeleteProgram(m_prog); // TODO: These could also go in ::End. glDisableClientState(GL_ELEMENT_ARRAY_UNIFIED_NV); glDisableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV); }
GLOcclusionQuery::~GLOcclusionQuery() { glDeleteQueries(1, &mQueryObj); BS_CHECK_GL_ERROR(); BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_Query); }
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); }
/** * Method is used to delete query - one non-independent scene entity needs one query object. Engine call this * method when deleting entity from engine scene. */ void Occlusion::deleteQuery() { GLuint query; query = queries.back(); glDeleteQueries(1,&query); queries.pop_back(); }
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; }
//------------------------------------------------------------------------------ static void #if GLFW_VERSION_MAJOR>=3 motion(GLFWwindow *, double dx, double dy) { int x=(int)dx, y=(int)dy; #else motion(int x, int y) { #endif if (g_mbutton[0] && !g_mbutton[1] && !g_mbutton[2]) { // orbit g_rotate[0] += x - g_prev_x; g_rotate[1] += y - g_prev_y; } else if (!g_mbutton[0] && !g_mbutton[1] && g_mbutton[2]) { // pan g_pan[0] -= g_dolly*(x - g_prev_x)/g_width; g_pan[1] += g_dolly*(y - g_prev_y)/g_height; } else if ((g_mbutton[0] && !g_mbutton[1] && g_mbutton[2]) or (!g_mbutton[0] && g_mbutton[1] && !g_mbutton[2])) { // dolly g_dolly -= g_dolly*0.01f*(x - g_prev_x); if(g_dolly <= 0.01) g_dolly = 0.01f; } g_prev_x = x; g_prev_y = y; } //------------------------------------------------------------------------------ static void #if GLFW_VERSION_MAJOR>=3 mouse(GLFWwindow *, int button, int state, int mods) { #else mouse(int button, int state) { #endif if (button == 0 && state == GLFW_PRESS && g_hud.MouseClick(g_prev_x, g_prev_y)) return; if (button < 3) { g_mbutton[button] = (state == GLFW_PRESS); } } //------------------------------------------------------------------------------ static void uninitGL() { glDeleteQueries(2, g_queries); delete g_batch; g_batch = NULL; #ifdef OPENSUBDIV_HAS_CUDA cudaDeviceReset(); #endif #ifdef OPENSUBDIV_HAS_OPENCL uninitCL(g_clContext, g_clQueue); #endif }
void Profiler::deinit() { for (size_t i = 0; i < m_entries.size(); i++){ Entry &entry = m_entries[i]; glDeleteQueries(2 * FRAME_DELAY, &entry.queries[0]); entry.name = NULL; } }
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; }
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; }
void occlusion_query::dispose() { if (id_ != 0) { state_ = disposed; glCheck(glDeleteQueries(1, &id_)); id_ = 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; }
enum piglit_result piglit_display(void) { GLint64 t1, t2; GLint64 query_overhead, get_overhead, tolerance; GLuint q; int64_t delay; glGenQueries(1, &q); /* this creates the query in the driver */ get_gpu_time_via_query(q); /* compute a reasonable tolerance based on driver overhead */ t1 = piglit_time_get_nano(); get_gpu_time_via_query(q); query_overhead = piglit_time_get_nano() - t1; t1 = piglit_time_get_nano(); get_gpu_time_via_get(q); get_overhead = piglit_time_get_nano() - t1; printf("glGet overhead: %" PRIu64 " us\n", (uint64_t) get_overhead / 1000); printf("glQuery overhead: %" PRIu64 " us\n", (uint64_t) query_overhead / 1000); /* minimum tolerance is 3 ms */ tolerance = query_overhead + get_overhead + 3000000; /* do testing */ puts("Test: first glQuery, then glGet"); t1 = get_gpu_time_via_query(q); t2 = get_gpu_time_via_get(q); validate_times(t1, t2, tolerance); usleep(10000); puts("Test: first glGet, then glQuery"); t1 = get_gpu_time_via_get(q); t2 = get_gpu_time_via_query(q); validate_times(t1, t2, tolerance); puts("Test: wall clock time via glQuery"); t1 = get_gpu_time_via_query(q); delay = piglit_delay_ns(1000000000); t2 = get_gpu_time_via_query(q); validate_delta(t1, t2, delay); puts("Test: wall clock time via glGet"); t1 = get_gpu_time_via_get(q); delay = piglit_delay_ns(1000000000); t2 = get_gpu_time_via_get(q); validate_delta(t1, t2, delay); glDeleteQueries(1, &q); return PIGLIT_PASS; }
std::vector<int> CDecalsDrawerGL4::UpdateOverlap_CheckQueries() { // query the results of the last issued test (if any pixels were rendered for the decal) std::vector<int> candidatesForRemoval; candidatesForRemoval.reserve(waitingOverlapGlQueries.size()); for (auto& p: waitingOverlapGlQueries) { GLint rendered = GL_FALSE; glGetQueryObjectiv(p.second, GL_QUERY_RESULT, &rendered); glDeleteQueries(1, &p.second); if (rendered == GL_FALSE) { candidatesForRemoval.push_back(p.first); } } waitingOverlapGlQueries.clear(); // no candidates left, restart with stage 0 if (candidatesForRemoval.empty()) { overlapStage = 0; return candidatesForRemoval; } //FIXME comment auto sortBeginIt = candidatesForRemoval.begin(); auto sortEndIt = candidatesForRemoval.end(); while (sortBeginIt != sortEndIt) { std::sort(sortBeginIt, sortEndIt, [&](const int& idx1, const int& idx2){ return decals[idx1].generation < decals[idx2].generation; }); sortEndIt = std::partition(sortBeginIt+1, sortEndIt, [&](const int& idx){ return !Overlap(decals[*sortBeginIt], decals[idx]); }); ++sortBeginIt; } auto eraseIt = sortEndIt; // free one decal (+ remove it from the overlap texture) int freed = 0; CVertexArray* va = GetVertexArray(); glStencilFunc(GL_ALWAYS, 0, 0xFF); glStencilOp(GL_DECR_WRAP, GL_DECR_WRAP, GL_DECR_WRAP); va->Initialize(); for (auto it = candidatesForRemoval.begin(); it != eraseIt; ++it) { const int curIndex = *it; const Decal& d = decals[curIndex]; DRAW_DECAL(va, &d); FreeDecal(curIndex); freed++; } va->DrawArray2dT(GL_QUADS); candidatesForRemoval.erase(candidatesForRemoval.begin(), eraseIt); //FIXME LOG_L(L_ERROR, "Query freed: %i of %i (decals:%i groups:%i)", freed, int(candidatesForRemoval.size()), int(decals.size() - freeIds.size()), int(groups.size())); // overlap texture changed, so need to retest the others return candidatesForRemoval; }
Profiler::~Profiler() { // Wait for all queries to complete nextFrame(); // Delete all queries if (m_queryFreelist.size() > 0) { glDeleteQueries(m_queryFreelist.size(), m_queryFreelist.getCArray()); m_queryFreelist.clear(); } }
bool end() { glDeleteProgramPipelines(1, &PipelineName); glDeleteProgram(ProgramName); glDeleteBuffers(buffer::MAX, &BufferName[0]); glDeleteVertexArrays(1, &VertexArrayName); glDeleteQueries(1, &QueryName); return true; }
GpuQuery::~GpuQuery() { if (m_id) { Context::EnsureContext(); GLuint query = static_cast<GLuint>(m_id); glDeleteQueries(1, &query); } }
void GL3OcclusionQueryProvider::on_dispose() { if (handle) { if (OpenGL::set_active()) { glDeleteQueries(1, &handle); } } }
bool end() { for(std::size_t i = 0; i < program::MAX; ++i) glDeleteProgram(ProgramName[i]); glDeleteVertexArrays(program::MAX, &VertexArrayName[0]); glDeleteBuffers(program::MAX, &BufferName[0]); glDeleteQueries(1, &QueryName); return this->checkError("end"); }