mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
Added profile blocks for GL.
This commit is contained in:
parent
6caafc9844
commit
db6d91925d
6 changed files with 29 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ public:
|
||||||
|
|
||||||
void init(U32 start, U32 end)
|
void init(U32 start, U32 end)
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLQueryFence_issue);
|
||||||
mStart = start;
|
mStart = start;
|
||||||
mEnd = end;
|
mEnd = end;
|
||||||
mSync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
mSync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||||
|
|
@ -36,6 +37,7 @@ public:
|
||||||
|
|
||||||
void wait()
|
void wait()
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLQueryFence_block);
|
||||||
GLbitfield waitFlags = 0;
|
GLbitfield waitFlags = 0;
|
||||||
GLuint64 waitDuration = 0;
|
GLuint64 waitDuration = 0;
|
||||||
while( 1 )
|
while( 1 )
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,7 @@ void GFXGLDevice::resurrect()
|
||||||
|
|
||||||
GFXVertexBuffer* GFXGLDevice::findVolatileVBO(U32 numVerts, const GFXVertexFormat *vertexFormat, U32 vertSize)
|
GFXVertexBuffer* GFXGLDevice::findVolatileVBO(U32 numVerts, const GFXVertexFormat *vertexFormat, U32 vertSize)
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLDevice_findVBPool);
|
||||||
for(U32 i = 0; i < mVolatileVBs.size(); i++)
|
for(U32 i = 0; i < mVolatileVBs.size(); i++)
|
||||||
if ( mVolatileVBs[i]->mNumVerts >= numVerts &&
|
if ( mVolatileVBs[i]->mNumVerts >= numVerts &&
|
||||||
mVolatileVBs[i]->mVertexFormat.isEqual( *vertexFormat ) &&
|
mVolatileVBs[i]->mVertexFormat.isEqual( *vertexFormat ) &&
|
||||||
|
|
@ -333,6 +334,7 @@ GFXVertexBuffer* GFXGLDevice::findVolatileVBO(U32 numVerts, const GFXVertexForma
|
||||||
return mVolatileVBs[i];
|
return mVolatileVBs[i];
|
||||||
|
|
||||||
// No existing VB, so create one
|
// No existing VB, so create one
|
||||||
|
PROFILE_SCOPE(GFXGLDevice_createVBPool);
|
||||||
StrongRefPtr<GFXGLVertexBuffer> buf(new GFXGLVertexBuffer(GFX, numVerts, vertexFormat, vertSize, GFXBufferTypeVolatile));
|
StrongRefPtr<GFXGLVertexBuffer> buf(new GFXGLVertexBuffer(GFX, numVerts, vertexFormat, vertSize, GFXBufferTypeVolatile));
|
||||||
buf->registerResourceWithDevice(this);
|
buf->registerResourceWithDevice(this);
|
||||||
mVolatileVBs.push_back(buf);
|
mVolatileVBs.push_back(buf);
|
||||||
|
|
@ -358,6 +360,7 @@ GFXVertexBuffer *GFXGLDevice::allocVertexBuffer( U32 numVerts,
|
||||||
GFXBufferType bufferType,
|
GFXBufferType bufferType,
|
||||||
void* data )
|
void* data )
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLDevice_allocVertexBuffer);
|
||||||
if(bufferType == GFXBufferTypeVolatile)
|
if(bufferType == GFXBufferTypeVolatile)
|
||||||
return findVolatileVBO(numVerts, vertexFormat, vertSize);
|
return findVolatileVBO(numVerts, vertexFormat, vertSize);
|
||||||
|
|
||||||
|
|
@ -523,6 +526,7 @@ inline GLsizei GFXGLDevice::primCountToIndexCount(GFXPrimitiveType primType, U32
|
||||||
|
|
||||||
GFXVertexDecl* GFXGLDevice::allocVertexDecl( const GFXVertexFormat *vertexFormat )
|
GFXVertexDecl* GFXGLDevice::allocVertexDecl( const GFXVertexFormat *vertexFormat )
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLDevice_allocVertexDecl);
|
||||||
typedef Map<void*, GFXGLVertexDecl> GFXGLVertexDeclMap;
|
typedef Map<void*, GFXGLVertexDecl> GFXGLVertexDeclMap;
|
||||||
static GFXGLVertexDeclMap declMap;
|
static GFXGLVertexDeclMap declMap;
|
||||||
GFXGLVertexDeclMap::Iterator itr = declMap.find( (void*)vertexFormat->getDescription().c_str() ); // description string are interned, safe to use c_str()
|
GFXGLVertexDeclMap::Iterator itr = declMap.find( (void*)vertexFormat->getDescription().c_str() ); // description string are interned, safe to use c_str()
|
||||||
|
|
@ -855,6 +859,7 @@ void GFXGLDevice::setShader(GFXShader *shader, bool force)
|
||||||
|
|
||||||
void GFXGLDevice::setShaderConstBufferInternal(GFXShaderConstBuffer* buffer)
|
void GFXGLDevice::setShaderConstBufferInternal(GFXShaderConstBuffer* buffer)
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLDevice_setShaderConstBufferInternal);
|
||||||
static_cast<GFXGLShaderConstBuffer*>(buffer)->activate();
|
static_cast<GFXGLShaderConstBuffer*>(buffer)->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -344,6 +344,7 @@ void GFXGLShaderConstBuffer::set(GFXShaderConstHandle* handle, const MatrixF* ma
|
||||||
|
|
||||||
void GFXGLShaderConstBuffer::activate()
|
void GFXGLShaderConstBuffer::activate()
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLShaderConstBuffer_activate);
|
||||||
mShader->setConstantsFromBuffer(this);
|
mShader->setConstantsFromBuffer(this);
|
||||||
mWasLost = false;
|
mWasLost = false;
|
||||||
}
|
}
|
||||||
|
|
@ -394,6 +395,7 @@ void GFXGLShader::clearShaders()
|
||||||
|
|
||||||
bool GFXGLShader::_init()
|
bool GFXGLShader::_init()
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLShader_Init);
|
||||||
// Don't initialize empty shaders.
|
// Don't initialize empty shaders.
|
||||||
if ( mVertexFile.isEmpty() && mPixelFile.isEmpty() )
|
if ( mVertexFile.isEmpty() && mPixelFile.isEmpty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1013,6 +1015,7 @@ bool GFXGLShader::initShader( const Torque::Path &file,
|
||||||
bool isVertex,
|
bool isVertex,
|
||||||
const Vector<GFXShaderMacro> ¯os )
|
const Vector<GFXShaderMacro> ¯os )
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLShader_CompileShader);
|
||||||
GLuint activeShader = glCreateShader(isVertex ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER);
|
GLuint activeShader = glCreateShader(isVertex ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER);
|
||||||
if(isVertex)
|
if(isVertex)
|
||||||
mVertexShader = activeShader;
|
mVertexShader = activeShader;
|
||||||
|
|
@ -1072,6 +1075,7 @@ bool GFXGLShader::initShader( const Torque::Path &file,
|
||||||
/// Returns our list of shader constants, the material can get this and just set the constants it knows about
|
/// Returns our list of shader constants, the material can get this and just set the constants it knows about
|
||||||
const Vector<GFXShaderConstDesc>& GFXGLShader::getShaderConstDesc() const
|
const Vector<GFXShaderConstDesc>& GFXGLShader::getShaderConstDesc() const
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLShader_GetShaderConstants);
|
||||||
return mConstants;
|
return mConstants;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ const GFXStateBlockDesc& GFXGLStateBlock::getDesc() const
|
||||||
/// @param oldState The current state, used to make sure we don't set redundant states on the device. Pass NULL to reset all states.
|
/// @param oldState The current state, used to make sure we don't set redundant states on the device. Pass NULL to reset all states.
|
||||||
void GFXGLStateBlock::activate(const GFXGLStateBlock* oldState)
|
void GFXGLStateBlock::activate(const GFXGLStateBlock* oldState)
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLStateBlock_Activate);
|
||||||
// Big scary warning copied from Apple docs
|
// Big scary warning copied from Apple docs
|
||||||
// http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_performance/chapter_13_section_2.html#//apple_ref/doc/uid/TP40001987-CH213-SW12
|
// http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_performance/chapter_13_section_2.html#//apple_ref/doc/uid/TP40001987-CH213-SW12
|
||||||
// Don't set a state that's already set. Once a feature is enabled, it does not need to be enabled again.
|
// Don't set a state that's already set. Once a feature is enabled, it does not need to be enabled again.
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,7 @@ static void _fastTextureLoad(GFXGLTextureObject* texture, GBitmap* pDL)
|
||||||
|
|
||||||
if(pDL->getFormat() == GFXFormatR8G8B8A8 || pDL->getFormat() == GFXFormatR8G8B8X8)
|
if(pDL->getFormat() == GFXFormatR8G8B8A8 || pDL->getFormat() == GFXFormatR8G8B8X8)
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(Swizzle32_Upload);
|
||||||
FrameAllocatorMarker mem;
|
FrameAllocatorMarker mem;
|
||||||
U8* pboMemory = (U8*)mem.alloc(bufSize);
|
U8* pboMemory = (U8*)mem.alloc(bufSize);
|
||||||
GFX->getDeviceSwizzle32()->ToBuffer(pboMemory, pDL->getBits(0), bufSize);
|
GFX->getDeviceSwizzle32()->ToBuffer(pboMemory, pDL->getBits(0), bufSize);
|
||||||
|
|
@ -241,6 +242,7 @@ static void _fastTextureLoad(GFXGLTextureObject* texture, GBitmap* pDL)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(SwizzleNull_Upload);
|
||||||
glBufferSubData(GL_PIXEL_UNPACK_BUFFER_ARB, 0, bufSize, pDL->getBits(0) );
|
glBufferSubData(GL_PIXEL_UNPACK_BUFFER_ARB, 0, bufSize, pDL->getBits(0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -262,6 +264,7 @@ static void _slowTextureLoad(GFXGLTextureObject* texture, GBitmap* pDL)
|
||||||
|
|
||||||
bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, GBitmap *pDL)
|
bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, GBitmap *pDL)
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLTextureManager_loadTexture);
|
||||||
GFXGLTextureObject *texture = static_cast<GFXGLTextureObject*>(aTexture);
|
GFXGLTextureObject *texture = static_cast<GFXGLTextureObject*>(aTexture);
|
||||||
|
|
||||||
AssertFatal(texture->getBinding() == GL_TEXTURE_1D || texture->getBinding() == GL_TEXTURE_2D,
|
AssertFatal(texture->getBinding() == GL_TEXTURE_1D || texture->getBinding() == GL_TEXTURE_2D,
|
||||||
|
|
@ -291,6 +294,8 @@ bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, GBitmap *pDL)
|
||||||
|
|
||||||
bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, DDSFile *dds)
|
bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, DDSFile *dds)
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLTextureManager_loadTextureDDS);
|
||||||
|
|
||||||
AssertFatal(!(dds->mFormat == GFXFormatDXT2 || dds->mFormat == GFXFormatDXT4), "GFXGLTextureManager::_loadTexture - OpenGL does not support DXT2 or DXT4 compressed textures");
|
AssertFatal(!(dds->mFormat == GFXFormatDXT2 || dds->mFormat == GFXFormatDXT4), "GFXGLTextureManager::_loadTexture - OpenGL does not support DXT2 or DXT4 compressed textures");
|
||||||
GFXGLTextureObject* texture = static_cast<GFXGLTextureObject*>(aTexture);
|
GFXGLTextureObject* texture = static_cast<GFXGLTextureObject*>(aTexture);
|
||||||
|
|
||||||
|
|
@ -308,6 +313,8 @@ bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, DDSFile *dds)
|
||||||
numMips = 1;
|
numMips = 1;
|
||||||
for(U32 i = 0; i < numMips; i++)
|
for(U32 i = 0; i < numMips; i++)
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLTexMan_loadSurface);
|
||||||
|
|
||||||
if(isCompressedFormat(dds->mFormat))
|
if(isCompressedFormat(dds->mFormat))
|
||||||
{
|
{
|
||||||
if((!isPow2(dds->getWidth()) || !isPow2(dds->getHeight())) && GFX->getCardProfiler()->queryProfile("GL::Workaround::noCompressedNPoTTextures"))
|
if((!isPow2(dds->getWidth()) || !isPow2(dds->getHeight())) && GFX->getCardProfiler()->queryProfile("GL::Workaround::noCompressedNPoTTextures"))
|
||||||
|
|
@ -344,6 +351,7 @@ bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, DDSFile *dds)
|
||||||
|
|
||||||
bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, void *raw)
|
bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, void *raw)
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLTextureManager_loadTextureRaw);
|
||||||
if(aTexture->getDepth() < 1)
|
if(aTexture->getDepth() < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,9 @@ void GFXGLTextureObject::unlock(U32 mipLevel)
|
||||||
if(!mLockedRect.bits)
|
if(!mLockedRect.bits)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// I know this is in unlock, but in GL we actually do our submission in unlock.
|
||||||
|
PROFILE_SCOPE(GFXGLTextureObject_lockRT);
|
||||||
|
|
||||||
PRESERVE_TEXTURE(mBinding);
|
PRESERVE_TEXTURE(mBinding);
|
||||||
glBindTexture(mBinding, mHandle);
|
glBindTexture(mBinding, mHandle);
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, mBuffer);
|
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, mBuffer);
|
||||||
|
|
@ -137,6 +140,8 @@ void GFXGLTextureObject::reInit()
|
||||||
|
|
||||||
bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
|
bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
|
||||||
{
|
{
|
||||||
|
PROFILE_SCOPE(GFXGLTextureObject_copyToBmp);
|
||||||
|
|
||||||
if (!bmp)
|
if (!bmp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -175,6 +180,7 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
|
||||||
|
|
||||||
glGetTexImage(mBinding, 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], orig);
|
glGetTexImage(mBinding, 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], orig);
|
||||||
|
|
||||||
|
PROFILE_START(GFXGLTextureObject_copyToBmp_pixCopy);
|
||||||
for(int i = 0; i < srcPixelCount; ++i)
|
for(int i = 0; i < srcPixelCount; ++i)
|
||||||
{
|
{
|
||||||
dest[0] = orig[0];
|
dest[0] = orig[0];
|
||||||
|
|
@ -186,6 +192,7 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
|
||||||
orig += srcBytesPerPixel;
|
orig += srcBytesPerPixel;
|
||||||
dest += dstBytesPerPixel;
|
dest += dstBytesPerPixel;
|
||||||
}
|
}
|
||||||
|
PROFILE_END();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue