mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-05 13:30:34 +00:00
Core implementation of Physical Based Rendering.
This commit is contained in:
parent
54f1d8c18e
commit
b4a1d18f42
148 changed files with 4464 additions and 1016 deletions
|
|
@ -25,7 +25,9 @@
|
|||
#include "gfx/gl/tGL/tGL.h"
|
||||
|
||||
GFXGLOcclusionQuery::GFXGLOcclusionQuery(GFXDevice* device) :
|
||||
GFXOcclusionQuery(device), mQuery(-1)
|
||||
GFXOcclusionQuery(device),
|
||||
mQuery(-1),
|
||||
mTesting(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -37,16 +39,29 @@ GFXGLOcclusionQuery::~GFXGLOcclusionQuery()
|
|||
|
||||
bool GFXGLOcclusionQuery::begin()
|
||||
{
|
||||
if(mQuery == -1)
|
||||
if (GFXDevice::getDisableOcclusionQuery())
|
||||
return true;
|
||||
|
||||
if (!glIsQuery(mQuery))
|
||||
glGenQueries(1, &mQuery);
|
||||
|
||||
glBeginQuery(GL_SAMPLES_PASSED, mQuery);
|
||||
if (!mTesting)
|
||||
{
|
||||
glBeginQuery(GL_SAMPLES_PASSED, mQuery);
|
||||
mTesting = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void GFXGLOcclusionQuery::end()
|
||||
{
|
||||
if (GFXDevice::getDisableOcclusionQuery())
|
||||
return;
|
||||
|
||||
if (!glIsQuery(mQuery))
|
||||
return;
|
||||
glEndQuery(GL_SAMPLES_PASSED);
|
||||
mTesting = false;
|
||||
}
|
||||
|
||||
GFXOcclusionQuery::OcclusionQueryStatus GFXGLOcclusionQuery::getStatus(bool block, U32* data)
|
||||
|
|
@ -55,16 +70,33 @@ GFXOcclusionQuery::OcclusionQueryStatus GFXGLOcclusionQuery::getStatus(bool bloc
|
|||
// then your system is GPU bound.
|
||||
PROFILE_SCOPE(GFXGLOcclusionQuery_getStatus);
|
||||
|
||||
if(mQuery == -1)
|
||||
if (GFXDevice::getDisableOcclusionQuery())
|
||||
return NotOccluded;
|
||||
|
||||
if (!glIsQuery(mQuery))
|
||||
return NotOccluded;
|
||||
|
||||
GLint numPixels = 0;
|
||||
GLint queryDone = false;
|
||||
|
||||
if (block)
|
||||
queryDone = true;
|
||||
{
|
||||
while (!queryDone)
|
||||
{
|
||||
//If we're stalled out, proceed with worst-case scenario -BJR
|
||||
if (GFX->mFrameTime->getElapsedMs()>4)
|
||||
{
|
||||
this->begin();
|
||||
this->end();
|
||||
return NotOccluded;
|
||||
}
|
||||
glGetQueryObjectiv(mQuery, GL_QUERY_RESULT_AVAILABLE, &queryDone);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glGetQueryObjectiv(mQuery, GL_QUERY_RESULT_AVAILABLE, &queryDone);
|
||||
}
|
||||
|
||||
if (queryDone)
|
||||
glGetQueryObjectiv(mQuery, GL_QUERY_RESULT, &numPixels);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue