Commit 99a25cfb authored by hybrid's avatar hybrid

Remove debug output, add ifdefs for OpenGL versions not supporting...

Remove debug output, add ifdefs for OpenGL versions not supporting ARB_occlusion_query. Add support for NV_occlusion query.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3266 dfc29bdd-3216-0410-991c-e03cc46cb475
parent ccd1a241
...@@ -1274,7 +1274,6 @@ void CD3D9Driver::runOcclusionQuery(scene::ISceneNode* node, bool visible) ...@@ -1274,7 +1274,6 @@ void CD3D9Driver::runOcclusionQuery(scene::ISceneNode* node, bool visible)
const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); const s32 index = OcclusionQueries.linear_search(SOccQuery(node));
if (index != -1) if (index != -1)
{ {
os::Printer::log("Start query", core::stringc(reinterpret_cast<u32>(OcclusionQueries[index].ID)));
if (OcclusionQueries[index].ID) if (OcclusionQueries[index].ID)
reinterpret_cast<IDirect3DQuery9*>(OcclusionQueries[index].ID)->Issue(D3DISSUE_BEGIN); reinterpret_cast<IDirect3DQuery9*>(OcclusionQueries[index].ID)->Issue(D3DISSUE_BEGIN);
CNullDriver::runOcclusionQuery(node,visible); CNullDriver::runOcclusionQuery(node,visible);
...@@ -1310,10 +1309,7 @@ void CD3D9Driver::updateOcclusionQuery(scene::ISceneNode* node, bool block) ...@@ -1310,10 +1309,7 @@ void CD3D9Driver::updateOcclusionQuery(scene::ISceneNode* node, bool block)
} while (!available); } while (!available);
} }
if (available) if (available)
{
OcclusionQueries[index].Result = tmp; OcclusionQueries[index].Result = tmp;
os::Printer::log("Occ result", core::stringc(tmp));
}
} }
} }
......
...@@ -1268,12 +1268,22 @@ void COpenGLDriver::runOcclusionQuery(scene::ISceneNode* node, bool visible) ...@@ -1268,12 +1268,22 @@ void COpenGLDriver::runOcclusionQuery(scene::ISceneNode* node, bool visible)
const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); const s32 index = OcclusionQueries.linear_search(SOccQuery(node));
if (index != -1) if (index != -1)
{ {
os::Printer::log("Start query", core::stringc(reinterpret_cast<GLuint>(OcclusionQueries[index].ID)));
if (OcclusionQueries[index].ID) if (OcclusionQueries[index].ID)
extGlBeginQuery(GL_SAMPLES_PASSED_ARB, reinterpret_cast<GLuint>(OcclusionQueries[index].ID)); extGlBeginQuery(
#ifdef GL_ARB_occlusion_query
GL_SAMPLES_PASSED_ARB,
#else
0,
#endif
reinterpret_cast<GLuint>(OcclusionQueries[index].ID));
CNullDriver::runOcclusionQuery(node,visible); CNullDriver::runOcclusionQuery(node,visible);
if (OcclusionQueries[index].ID) if (OcclusionQueries[index].ID)
extGlEndQuery(GL_SAMPLES_PASSED_ARB); extGlEndQuery(
#ifdef GL_ARB_occlusion_query
GL_SAMPLES_PASSED_ARB);
#else
0);
#endif
testGLError(); testGLError();
} }
} }
...@@ -1284,7 +1294,6 @@ void COpenGLDriver::runOcclusionQuery(scene::ISceneNode* node, bool visible) ...@@ -1284,7 +1294,6 @@ void COpenGLDriver::runOcclusionQuery(scene::ISceneNode* node, bool visible)
Update might not occur in this case, though */ Update might not occur in this case, though */
void COpenGLDriver::updateOcclusionQuery(scene::ISceneNode* node, bool block) void COpenGLDriver::updateOcclusionQuery(scene::ISceneNode* node, bool block)
{ {
const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); const s32 index = OcclusionQueries.linear_search(SOccQuery(node));
if (index != -1) if (index != -1)
{ {
...@@ -1294,16 +1303,28 @@ void COpenGLDriver::updateOcclusionQuery(scene::ISceneNode* node, bool block) ...@@ -1294,16 +1303,28 @@ void COpenGLDriver::updateOcclusionQuery(scene::ISceneNode* node, bool block)
GLint available = block?GL_TRUE:GL_FALSE; GLint available = block?GL_TRUE:GL_FALSE;
if (!block) if (!block)
extGlGetQueryObjectiv(reinterpret_cast<GLuint>(OcclusionQueries[index].ID), extGlGetQueryObjectiv(reinterpret_cast<GLuint>(OcclusionQueries[index].ID),
#ifdef GL_ARB_occlusion_query
GL_QUERY_RESULT_AVAILABLE_ARB, GL_QUERY_RESULT_AVAILABLE_ARB,
#elif defined(GL_NV_occlusion_query)
GL_PIXEL_COUNT_AVAILABLE_NV,
#else
0,
#endif
&available); &available);
testGLError(); testGLError();
if (available==GL_TRUE) if (available==GL_TRUE)
{ {
extGlGetQueryObjectiv(reinterpret_cast<GLuint>(OcclusionQueries[index].ID), extGlGetQueryObjectiv(reinterpret_cast<GLuint>(OcclusionQueries[index].ID),
#ifdef GL_ARB_occlusion_query
GL_QUERY_RESULT_ARB, GL_QUERY_RESULT_ARB,
#elif defined(GL_NV_occlusion_query)
GL_PIXEL_COUNT_NV,
#else
0,
#endif
&available); &available);
OcclusionQueries[index].Result = available; if (queryFeature(EVDF_OCCLUSION_QUERY))
os::Printer::log("Occ result", core::stringc(available)); OcclusionQueries[index].Result = available;
} }
testGLError(); testGLError();
} }
......
...@@ -672,10 +672,17 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -672,10 +672,17 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
OcclusionQuerySupport=(num>0); OcclusionQuerySupport=(num>0);
} }
else else
#endif
#ifdef GL_NV_occlusion_query
if (FeatureAvailable[IRR_NV_occlusion_query])
{
glGetIntegerv(GL_PIXEL_COUNTER_BITS_NV, &num);
OcclusionQuerySupport=(num>0);
}
else
#endif #endif
OcclusionQuerySupport=false; OcclusionQuerySupport=false;
#ifdef _DEBUG #ifdef _DEBUG
if (FeatureAvailable[IRR_NVX_gpu_memory_info]) if (FeatureAvailable[IRR_NVX_gpu_memory_info])
{ {
......
...@@ -2108,6 +2108,8 @@ inline void COpenGLExtensionHandler::extGlGenQueries(GLsizei n, GLuint *ids) ...@@ -2108,6 +2108,8 @@ inline void COpenGLExtensionHandler::extGlGenQueries(GLsizei n, GLuint *ids)
pGlGenQueriesARB(n, ids); pGlGenQueriesARB(n, ids);
#elif defined(GL_ARB_occlusion_query) #elif defined(GL_ARB_occlusion_query)
glGenQueriesARB(n, ids); glGenQueriesARB(n, ids);
#elif defined(GL_NV_occlusion_query)
glGenOcclusionQueriesNV(n, ids);
#else #else
os::Printer::log("glGenQueriesARB not supported", ELL_ERROR); os::Printer::log("glGenQueriesARB not supported", ELL_ERROR);
#endif #endif
...@@ -2120,6 +2122,8 @@ inline void COpenGLExtensionHandler::extGlDeleteQueries(GLsizei n, const GLuint ...@@ -2120,6 +2122,8 @@ inline void COpenGLExtensionHandler::extGlDeleteQueries(GLsizei n, const GLuint
pGlDeleteQueriesARB(n, ids); pGlDeleteQueriesARB(n, ids);
#elif defined(GL_ARB_occlusion_query) #elif defined(GL_ARB_occlusion_query)
glDeleteQueriesARB(n, ids); glDeleteQueriesARB(n, ids);
#elif defined(GL_NV_occlusion_query)
glDeleteOcclusionQueriesNV(n, ids);
#else #else
os::Printer::log("glDeleteQueriesARB not supported", ELL_ERROR); os::Printer::log("glDeleteQueriesARB not supported", ELL_ERROR);
#endif #endif
...@@ -2132,6 +2136,8 @@ inline GLboolean COpenGLExtensionHandler::extGlIsQuery(GLuint id) ...@@ -2132,6 +2136,8 @@ inline GLboolean COpenGLExtensionHandler::extGlIsQuery(GLuint id)
return pGlIsQueryARB(id); return pGlIsQueryARB(id);
#elif defined(GL_ARB_occlusion_query) #elif defined(GL_ARB_occlusion_query)
return glIsQueryARB(id); return glIsQueryARB(id);
#elif defined(GL_NV_occlusion_query)
glIsOcclusionQueryNV(id);
#else #else
return false; return false;
#endif #endif
...@@ -2144,6 +2150,8 @@ inline void COpenGLExtensionHandler::extGlBeginQuery(GLenum target, GLuint id) ...@@ -2144,6 +2150,8 @@ inline void COpenGLExtensionHandler::extGlBeginQuery(GLenum target, GLuint id)
pGlBeginQueryARB(target, id); pGlBeginQueryARB(target, id);
#elif defined(GL_ARB_occlusion_query) #elif defined(GL_ARB_occlusion_query)
glBeginQueryARB(target, id); glBeginQueryARB(target, id);
#elif defined(GL_NV_occlusion_query)
glBeginOcclusionQueryNV(id);
#else #else
os::Printer::log("glBeginQueryARB not supported", ELL_ERROR); os::Printer::log("glBeginQueryARB not supported", ELL_ERROR);
#endif #endif
...@@ -2156,6 +2164,8 @@ inline void COpenGLExtensionHandler::extGlEndQuery(GLenum target) ...@@ -2156,6 +2164,8 @@ inline void COpenGLExtensionHandler::extGlEndQuery(GLenum target)
pGlEndQueryARB(target); pGlEndQueryARB(target);
#elif defined(GL_ARB_occlusion_query) #elif defined(GL_ARB_occlusion_query)
glEndQueryARB(target); glEndQueryARB(target);
#elif defined(GL_NV_occlusion_query)
glEndOcclusionQueryNV();
#else #else
os::Printer::log("glEndQueryARB not supported", ELL_ERROR); os::Printer::log("glEndQueryARB not supported", ELL_ERROR);
#endif #endif
...@@ -2180,8 +2190,10 @@ inline void COpenGLExtensionHandler::extGlGetQueryObjectiv(GLuint id, GLenum pna ...@@ -2180,8 +2190,10 @@ inline void COpenGLExtensionHandler::extGlGetQueryObjectiv(GLuint id, GLenum pna
pGlGetQueryObjectivARB(id, pname, params); pGlGetQueryObjectivARB(id, pname, params);
#elif defined(GL_ARB_occlusion_query) #elif defined(GL_ARB_occlusion_query)
glGetQueryObjectivARB(id, pname, params); glGetQueryObjectivARB(id, pname, params);
#elif defined(GL_NV_occlusion_query)
glGetOcclusionQueryivNV(id, pname, params);
#else #else
os::Printer::log("glGetQueryObjectivARB not supported", ELL_ERROR); os::Printer::log("glGetQueryObjectiv not supported", ELL_ERROR);
#endif #endif
} }
...@@ -2192,8 +2204,10 @@ inline void COpenGLExtensionHandler::extGlGetQueryObjectuiv(GLuint id, GLenum pn ...@@ -2192,8 +2204,10 @@ inline void COpenGLExtensionHandler::extGlGetQueryObjectuiv(GLuint id, GLenum pn
pGlGetQueryObjectuivARB(id, pname, params); pGlGetQueryObjectuivARB(id, pname, params);
#elif defined(GL_ARB_occlusion_query) #elif defined(GL_ARB_occlusion_query)
glGetQueryObjectuivARB(id, pname, params); glGetQueryObjectuivARB(id, pname, params);
#elif defined(GL_NV_occlusion_query)
glGetOcclusionQueryuivNV(id, pname, params);
#else #else
os::Printer::log("glGetQueryObjectuivARB not supported", ELL_ERROR); os::Printer::log("glGetQueryObjectuiv not supported", ELL_ERROR);
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment