virtual void releaseName(GLuint name) { #if LL_TRACK_PENDING_OCCLUSION_QUERIES LLOcclusionCullingGroup::sPendingQueries.erase(name); #endif glDeleteQueriesARB(1, &name); }
enum piglit_result piglit_display(void) { bool pass = true; GLuint queryId; glEnable(GL_DEPTH_TEST); glGenQueriesARB(1, &queryId); if (queryId == 0) return PIGLIT_FAIL; pass = conformOQ_GetQueryCounterBits() && pass; pass = conformOQ_GetObjivAval_multi1(queryId) && pass; pass = conformOQ_GetObjivAval_multi2() && pass; pass = conformOQ_Begin_unused_id() && pass; pass = conformOQ_EndAfter(queryId) && pass; pass = conformOQ_BeginIn(queryId) && pass; pass = GetObjectAvailableIn(queryId) && pass; pass = conformOQ_GetObjResultIn(queryId) && pass; pass = conformOQ_GetObjivAval(queryId) && pass; pass = conformOQ_Gen_Delete(64) && pass; pass = conformOQ_IsIdZero() && pass; pass = conformOQ_BeginIdZero() && pass; glDeleteQueriesARB(1, &queryId); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
/** * Object destructor */ GLHardwareOcclusionQuery::~GLHardwareOcclusionQuery() { if(GLEW_VERSION_1_5 || GLEW_ARB_occlusion_query) { glDeleteQueriesARB(1, &mQueryID); } else if (GLEW_NV_occlusion_query) { glDeleteOcclusionQueriesNV(1, &mQueryID); } }
CRenderCaptureGL::~CRenderCaptureGL() { #ifndef HAS_GLES if (m_asyncSupported) { if (m_pbo) { glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, m_pbo); glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); glDeleteBuffersARB(1, &m_pbo); } if (m_query) glDeleteQueriesARB(1, &m_query); } #endif delete[] m_pixels; }
void CRenderCaptureGL::BeginRender() { if (!m_asyncChecked) { #ifndef HAS_GLES m_asyncSupported = CServiceBroker::GetRenderSystem().IsExtSupported("GL_ARB_pixel_buffer_object"); m_occlusionQuerySupported = CServiceBroker::GetRenderSystem().IsExtSupported("GL_ARB_occlusion_query"); if (m_flags & CAPTUREFLAG_CONTINUOUS) { if (!m_occlusionQuerySupported) CLog::Log(LOGWARNING, "CRenderCaptureGL: GL_ARB_occlusion_query not supported, performance might suffer"); if (!CServiceBroker::GetRenderSystem().IsExtSupported("GL_ARB_pixel_buffer_object")) CLog::Log(LOGWARNING, "CRenderCaptureGL: GL_ARB_pixel_buffer_object not supported, performance might suffer"); if (UseOcclusionQuery()) CLog::Log(LOGWARNING, "CRenderCaptureGL: GL_ARB_occlusion_query disabled, performance might suffer"); } #endif m_asyncChecked = true; } #ifndef HAS_GLES if (m_asyncSupported) { if (!m_pbo) glGenBuffersARB(1, &m_pbo); if (UseOcclusionQuery() && m_occlusionQuerySupported) { //generate an occlusion query if we don't have one if (!m_query) glGenQueriesARB(1, &m_query); } else { //don't use an occlusion query, clean up any old one if (m_query) { glDeleteQueriesARB(1, &m_query); m_query = 0; } } //start the occlusion query if (m_query) glBeginQueryARB(GL_SAMPLES_PASSED_ARB, m_query); //allocate data on the pbo and pixel buffer glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, m_pbo); if (m_bufferSize != m_width * m_height * 4) { m_bufferSize = m_width * m_height * 4; glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, m_bufferSize, 0, GL_STREAM_READ_ARB); delete[] m_pixels; m_pixels = new uint8_t[m_bufferSize]; } } else #endif { if (m_bufferSize != m_width * m_height * 4) { delete[] m_pixels; m_bufferSize = m_width * m_height * 4; m_pixels = new uint8_t[m_bufferSize]; } } }
/* Basic tests on query id generation and deletion */ static bool conformOQ_Gen_Delete(unsigned int id_n) { GLuint *ids1 = NULL, *ids2 = NULL; unsigned int i, j; bool pass = true; ids1 = (GLuint *) malloc(id_n * sizeof(GLuint)); ids2 = (GLuint *) malloc(id_n * sizeof(GLuint)); if (!ids1 || !ids2) { printf(" Error: Cannot alloc memory to pointer ids[12].\n"); if (ids1) free(ids1); if (ids2) free(ids2); return false; } glGenQueriesARB(id_n, ids1); glGenQueriesARB(id_n, ids2); /* compare whether <id> generated during the previous 2 rounds are * duplicated */ for (i = 0; i < id_n; i++) { for (j = 0; j < id_n; j++) { if (ids1[i] == ids2[j]) { char str[1000]; sprintf(str, "ids1[%d] == ids2[%d] == %u.", i, j, ids1[i]); printf(" Error: %s\n", str); pass = false; } } } /* Note: the spec seems to indicate that glGenQueries reserves query * IDs but doesn't create query objects for those IDs. A query object * isn't created until they are used by glBeginQuery. So this part * of the test is invalid. */ #if 0 /* Checkout whether the Query ID just generated is valid */ for (i = 0; i < id_n; i++) { if (glIsQueryARB(ids1[i]) == GL_FALSE) { char str[1000]; sprintf(str, "id [%d] just generated is not valid.", ids1[i]); printf(" Error: %s\n", str); pass = false; } } #endif /* if <id> is a non-zero value that is not the name of a query object, * IsQueryARB returns FALSE. */ glDeleteQueriesARB(id_n, ids1); for (i = 0; i < id_n; i++) { if (glIsQueryARB(ids1[i]) == GL_TRUE) { char str[1000]; sprintf(str, "id [%d] just deleted is still valid.", ids1[i]); printf(" Error: %s\n", str); pass = false; } } /* Delete only for sanity purpose */ glDeleteQueriesARB(id_n, ids2); if (ids1) free(ids1); if (ids2) free(ids2); ids1 = (GLuint *) malloc(id_n * sizeof(GLuint)); if (ids1 == NULL) return false; for (i = 0; i < id_n; i++) { glGenQueriesARB(1, ids1 + i); for (j = 0; j < i; j++) { if (ids1[i] == ids1[j]) { char str[1000]; sprintf(str, "duplicated id generated [%u]", ids1[i]); printf(" Error: %s\n", str); pass = false; } } } glDeleteQueriesARB(id_n, ids1); if (ids1) free(ids1); return pass; }
/* If mutiple queries are issued on the same target and diff ids prior * to calling GetQueryObject[u]iVARB, the results should be * corresponding to those queries (ids) respectively. */ static bool conformOQ_GetObjivAval_multi2(void) { GLuint passed1 = 0, passed2 = 0, passed3 = 0; GLuint id1, id2, id3; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, 0.0, 25.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(0.0, 0.0, -10.0); /* draw the occluder (red) */ glColorMask(1, 1, 1, 1); glDepthMask(GL_TRUE); glColor3f(1, 0, 0); piglit_draw_rect(-0.5, 0.5, 0.5, -0.5); glPushMatrix(); glTranslatef(0.0, 0.0, -5.0); glColorMask(0, 0, 0, 0); glDepthMask(GL_FALSE); id1 = find_unused_id(); glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id1); /* draw green quad, much larger than occluder */ glColor3f(0, 1, 0); piglit_draw_rect(-0.7, 0.7, 0.7, -0.7); glEndQueryARB(GL_SAMPLES_PASSED_ARB); id2 = find_unused_id(); glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id2); /* draw blue quad, slightly larger than occluder */ glColor3f(0, 0, 1); piglit_draw_rect(-0.53, 0.53, 0.53, -0.53); glEndQueryARB(GL_SAMPLES_PASSED_ARB); id3 = find_unused_id(); glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id3); /* draw white quad, smaller than occluder (should not be visible) */ glColor3f(1, 1, 1); piglit_draw_rect(-0.4, 0.4, 0.4, -0.4); glEndQueryARB(GL_SAMPLES_PASSED_ARB); glPopMatrix(); glGetQueryObjectuivARB(id1, GL_QUERY_RESULT_ARB, &passed1); glGetQueryObjectuivARB(id2, GL_QUERY_RESULT_ARB, &passed2); glGetQueryObjectuivARB(id3, GL_QUERY_RESULT_ARB, &passed3); glDepthMask(GL_TRUE); glDeleteQueriesARB(1, &id1); glDeleteQueriesARB(1, &id2); glDeleteQueriesARB(1, &id3); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); if (passed1 > passed2 && passed2 > passed3 && passed3 == 0) return true; else return false; }
cOcclusionQueryOGL::~cOcclusionQueryOGL() { glDeleteQueriesARB(1, (GLuint *)&mlQueryId); }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBOcclusionQuery_nglDeleteQueriesARB(JNIEnv *env, jclass clazz, jint n, jlong ids, jlong function_pointer) { GLuint *ids_address = (GLuint *)(intptr_t)ids; glDeleteQueriesARBPROC glDeleteQueriesARB = (glDeleteQueriesARBPROC)((intptr_t)function_pointer); glDeleteQueriesARB(n, ids_address); }
void MGLContext::deleteQuery(unsigned int * queryId){ glDeleteQueriesARB(1, queryId); }
void CRenderCaptureGL::BeginRender() { if (!m_asyncChecked) { #ifndef HAS_GLES bool usePbo = g_guiSettings.GetBool("videoplayer.usepbo"); m_asyncSupported = g_Windowing.IsExtSupported("GL_ARB_occlusion_query") && g_Windowing.IsExtSupported("GL_ARB_pixel_buffer_object") && usePbo; if (m_flags & CAPTUREFLAG_CONTINUOUS) { if (!g_Windowing.IsExtSupported("GL_ARB_occlusion_query")) CLog::Log(LOGWARNING, "CRenderCaptureGL: GL_ARB_occlusion_query not supported, performance might suffer"); if (!g_Windowing.IsExtSupported("GL_ARB_pixel_buffer_object")) CLog::Log(LOGWARNING, "CRenderCaptureGL: GL_ARB_pixel_buffer_object not supported, performance might suffer"); if (!usePbo) CLog::Log(LOGWARNING, "CRenderCaptureGL: GL_ARB_pixel_buffer_object disabled, performance might suffer"); } #endif m_asyncChecked = true; } #ifndef HAS_GLES if (m_asyncSupported) { if (!m_pbo) glGenBuffersARB(1, &m_pbo); //only use a query when not capturing immediately if (!m_query && !(m_flags & CAPTUREFLAG_IMMEDIATELY)) { glGenQueriesARB(1, &m_query); } else if (m_query && (m_flags & CAPTUREFLAG_IMMEDIATELY)) { //clean up any old query if the previous capture was not immediately glDeleteQueriesARB(1, &m_query); m_query = 0; } //start the occlusion query if (m_query) glBeginQueryARB(GL_SAMPLES_PASSED_ARB, m_query); //allocate data on the pbo and pixel buffer glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, m_pbo); if (m_bufferSize != m_width * m_height * 4) { m_bufferSize = m_width * m_height * 4; glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, m_bufferSize, 0, GL_STREAM_READ_ARB); delete[] m_pixels; m_pixels = new uint8_t[m_bufferSize]; } } else #endif { if (m_bufferSize != m_width * m_height * 4) { delete[] m_pixels; m_bufferSize = m_width * m_height * 4; m_pixels = new uint8_t[m_bufferSize]; } } }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBOcclusionQuery_nglDeleteQueriesARB(JNIEnv *env, jclass clazz, jint n, jobject ids, jint ids_position, jlong function_pointer) { GLuint *ids_address = ((GLuint *)(*env)->GetDirectBufferAddress(env, ids)) + ids_position; glDeleteQueriesARBPROC glDeleteQueriesARB = (glDeleteQueriesARBPROC)((intptr_t)function_pointer); glDeleteQueriesARB(n, ids_address); }
World::~World() { glDeleteQueriesARB(1, &m_chunkOcclusionQueryID); }
void Sector::clear(){ for (unsigned int i = 0; i < portals.getCount(); i++){ glDeleteQueriesARB(1, &portals[i].query); } }