Commit c43ad4fd authored by Frédéric Larue's avatar Frédéric Larue

gpuAssert function added to the GPU module in order to track possible GL errors in debug mode.

parent 5ffe4bb5
......@@ -57,7 +57,7 @@ namespace GPU
inline void SetAlignment( GLenum alignParam, unsigned int stride )
{
static const int alignment[8] = { 8, 1, 2, 1, 4, 1, 2, 1 };
glPixelStorei( alignParam, alignment[stride & 7] );
gpuAssert( glPixelStorei( alignParam, alignment[stride & 7] ) );
}
inline void SetPackAlignment( unsigned int stride )
......
......@@ -14,14 +14,14 @@
bool GPU::RenderBuffer::Allocate()
{
glGenRenderbuffersEXT( 1, &m_Id );
gpuAssert( glGenRenderbuffersEXT( 1, &m_Id ) );
return m_Id != 0;
}
bool GPU::RenderBuffer::Unallocate()
{
glDeleteRenderbuffersEXT( 1, &m_Id );
gpuAssert( glDeleteRenderbuffersEXT( 1, &m_Id ) );
m_Id = 0;
return true;
}
......@@ -34,9 +34,9 @@ bool GPU::RenderBuffer::Create( const GLenum internalFormats[],
if( w && h && Instantiate() )
{
GLint prevBuffer;
glGetIntegerv( GL_RENDERBUFFER_BINDING, &prevBuffer );
gpuAssert( glGetIntegerv( GL_RENDERBUFFER_BINDING, &prevBuffer ) );
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_Id );
gpuAssert( glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_Id ) );
int currentFormatId = -1;
GLint isSupported;
......@@ -46,26 +46,28 @@ bool GPU::RenderBuffer::Create( const GLenum internalFormats[],
{
m_Width = m_Height = 0;
std::cout << "RenderBuffer error - specified internal format(s) not supported." << std::endl;
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, prevBuffer );
gpuAssert( glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, prevBuffer ) );
return false;
}
if( glGetInternalformativ )
glGetInternalformativ( GL_RENDERBUFFER, internalFormats[currentFormatId], GL_INTERNALFORMAT_SUPPORTED, 1, &isSupported );
{
gpuAssert( glGetInternalformativ( GL_RENDERBUFFER, internalFormats[currentFormatId], GL_INTERNALFORMAT_SUPPORTED, 1, &isSupported ) );
}
else
{
glGetError();
glRenderbufferStorageEXT( GL_RENDERBUFFER, internalFormats[currentFormatId], w, h );
isSupported = glGetError() == GL_NO_ERROR;
isSupported = (glGetError() == GL_NO_ERROR);
}
} while( !isSupported );
glRenderbufferStorageEXT( GL_RENDERBUFFER, internalFormats[currentFormatId], w, h );
gpuAssert( glRenderbufferStorageEXT( GL_RENDERBUFFER, internalFormats[currentFormatId], w, h ) );
m_Width = w;
m_Height = h;
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, prevBuffer );
gpuAssert( glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, prevBuffer ) );
return true;
}
......@@ -79,10 +81,10 @@ GLint GPU::RenderBuffer::InternalFormat() const
if( m_Id )
{
GLint prevBuffer;
glGetIntegerv( GL_RENDERBUFFER_BINDING, &prevBuffer );
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_Id );
glGetRenderbufferParameterivEXT( GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_INTERNAL_FORMAT, &format );
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, prevBuffer );
gpuAssert( glGetIntegerv( GL_RENDERBUFFER_BINDING, &prevBuffer ) );
gpuAssert( glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_Id ) );
gpuAssert( glGetRenderbufferParameterivEXT( GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_INTERNAL_FORMAT, &format ) );
gpuAssert( glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, prevBuffer ) );
}
return format;
}
......@@ -99,12 +101,12 @@ bool GPU::FrameBuffer::Create( const unsigned int w,
m_Height = h;
GLint prevBuffer;
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &prevBuffer );
gpuAssert( glGetIntegerv( GL_FRAMEBUFFER_BINDING, &prevBuffer ) );
glGenFramebuffersEXT( 1, &m_Id );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id );
gpuAssert( glGenFramebuffersEXT( 1, &m_Id ) );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id ) );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, prevBuffer );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, prevBuffer ) );
return true;
}
......@@ -120,7 +122,7 @@ void GPU::FrameBuffer::Release()
m_Buffers.clear();
m_EnabledBuffers.clear();
glDeleteFramebuffersEXT( 1, &m_Id );
gpuAssert( glDeleteFramebuffersEXT( 1, &m_Id ) );
m_Id = 0;
}
}
......@@ -153,15 +155,15 @@ bool GPU::FrameBuffer::Attach( const GLuint attachment,
Detach( attachment );
GLint prevBuffer;
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &prevBuffer );
gpuAssert( glGetIntegerv( GL_FRAMEBUFFER_BINDING, &prevBuffer ) );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id );
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER, buff.Id() );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id ) );
gpuAssert( glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER, buff.Id() ) );
m_Buffers[ attachment ] = new RenderBuffer( buff );
Enable( attachment );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, prevBuffer );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, prevBuffer ) );
return true;
}
......@@ -180,15 +182,15 @@ bool GPU::FrameBuffer::Attach( const GLuint attachment,
Detach( attachment );
GLint prevBuffer;
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &prevBuffer );
gpuAssert( glGetIntegerv( GL_FRAMEBUFFER_BINDING, &prevBuffer ) );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id );
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, tex.Id(), 0 );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id ) );
gpuAssert( glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, tex.Id(), 0 ) );
m_Buffers[ attachment ] = new Texture2D( tex );
Enable( attachment );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, prevBuffer );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, prevBuffer ) );
return true;
}
......@@ -208,15 +210,15 @@ bool GPU::FrameBuffer::Attach( const GLuint attachment,
Detach( attachment );
GLint prevBuffer;
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &prevBuffer );
gpuAssert( glGetIntegerv( GL_FRAMEBUFFER_BINDING, &prevBuffer ) );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id );
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, targetCubeFace, tex.Id(), 0 );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id ) );
gpuAssert( glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, targetCubeFace, tex.Id(), 0 ) );
m_Buffers[ attachment ] = new TextureCube( tex );
Enable( attachment );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, prevBuffer );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, prevBuffer ) );
return true;
}
......@@ -266,24 +268,28 @@ void GPU::FrameBuffer::Disable( const GLuint attachment )
void GPU::FrameBuffer::Bind() const
{
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &m_PrevBuffer );
glGetIntegerv( GL_VIEWPORT, m_PrevViewport );
gpuAssert( glGetIntegerv( GL_FRAMEBUFFER_BINDING, &m_PrevBuffer ) );
gpuAssert( glGetIntegerv( GL_VIEWPORT, m_PrevViewport ) );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id ) );
if( !m_EnabledBuffers.empty() )
glDrawBuffersARB( (GLsizei) m_EnabledBuffers.size(), &m_EnabledBuffers.front() );
{
gpuAssert( glDrawBuffersARB( (GLsizei) m_EnabledBuffers.size(), &m_EnabledBuffers.front() ) );
}
else
glDrawBuffersARB( 0, NULL );
{
gpuAssert( glDrawBuffersARB( 0, NULL ) );
}
glViewport( 0, 0, m_Width, m_Height );
gpuAssert( glViewport( 0, 0, m_Width, m_Height ) );
}
void GPU::FrameBuffer::Unbind() const
{
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_PrevBuffer );
glViewport( m_PrevViewport[0], m_PrevViewport[1], m_PrevViewport[2], m_PrevViewport[3] );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_PrevBuffer ) );
gpuAssert( glViewport( m_PrevViewport[0], m_PrevViewport[1], m_PrevViewport[2], m_PrevViewport[3] ) );
}
......@@ -299,18 +305,18 @@ bool GPU::FrameBuffer::DumpTo( const GLuint attachment,
{
// Read data from the buffer into which the mask has been painted.
GLint prevBuffer, prevAlignment;
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &prevBuffer );
glGetIntegerv( GL_PACK_ALIGNMENT, &prevAlignment );
gpuAssert( glGetIntegerv( GL_FRAMEBUFFER_BINDING, &prevBuffer ) );
gpuAssert( glGetIntegerv( GL_PACK_ALIGNMENT, &prevAlignment ) );
const int alignment[8] = { 8, 1, 2, 1, 4, 1, 2, 1 };
glPixelStorei( GL_PACK_ALIGNMENT, alignment[stride & 7] );
gpuAssert( glPixelStorei( GL_PACK_ALIGNMENT, alignment[stride & 7] ) );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id );
glReadBuffer( attachment );
glReadPixels( x, y, w, h, format, type, buffer );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Id ) );
gpuAssert( glReadBuffer( attachment ) );
gpuAssert( glReadPixels( x, y, w, h, format, type, buffer ) );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, prevBuffer );
glPixelStorei( GL_PACK_ALIGNMENT, prevAlignment );
gpuAssert( glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, prevBuffer ) );
gpuAssert( glPixelStorei( GL_PACK_ALIGNMENT, prevAlignment ) );
return true;
}
......
......@@ -11,3 +11,27 @@
#include <windows.h>
#endif
#include <GL/gl.h>
#ifdef NDEBUG
#define gpuAssert( expression ) expression
#else
#include <assert.h>
#include <stdio.h>
#define gpuAssert( expression ) \
{ \
expression; \
GLenum err = glGetError(); \
if( err != GL_NO_ERROR ) \
{ \
const GLubyte* errStr = glewGetErrorString( err ); \
printf( "gpuAssert( %s ): %s\n", #expression, errStr ); \
assert( err == GL_NO_ERROR ); \
} \
}
#endif
\ No newline at end of file
This diff is collapsed.
......@@ -180,8 +180,8 @@ namespace GPU
inline const GeomPg& GeomProgram() const { return m_GeomPg; }
inline GeomPg& GeomProgram() { return m_GeomPg; }
inline void Bind() { glUseProgramObjectARB( m_Id ); BindSamplers(); }
inline void Unbind() { UnbindSamplers(); glUseProgramObjectARB( 0 ); }
inline void Bind() { gpuAssert( glUseProgramObjectARB( m_Id ) ); BindSamplers(); }
inline void Unbind() { UnbindSamplers(); gpuAssert( glUseProgramObjectARB( 0 ) ); }
void SetUniform( const std::string& name,
const void *value );
......@@ -242,7 +242,7 @@ namespace GPU
for( auto sb=m_SamplerBinding.begin(); sb!=m_SamplerBinding.end(); ++sb )
{
sb->second->Bind( texUnit );
glUniform1iARB( sb->first, texUnit++ );
gpuAssert( glUniform1iARB( sb->first, texUnit++ ) );
}
}
......
......@@ -17,16 +17,16 @@
void GPU::Texture::Bind( GLuint texUnit )
{
m_TexUnit = GL_TEXTURE0_ARB + texUnit;
glActiveTextureARB( m_TexUnit );
glEnable( m_Target );
glBindTexture( m_Target, m_Id );
gpuAssert( glActiveTextureARB( m_TexUnit ) );
gpuAssert( glEnable( m_Target ) );
gpuAssert( glBindTexture( m_Target, m_Id ) );
}
void GPU::Texture::Unbind() const
{
glActiveTextureARB( m_TexUnit );
glDisable( m_Target );
gpuAssert( glActiveTextureARB( m_TexUnit ) );
gpuAssert( glDisable( m_Target ) );
//glBindTexture( m_Target, 0 );
}
......@@ -36,8 +36,8 @@ GLint GPU::Texture::InternalFormat() const
GLint format = 0;
if( m_Id )
{
glBindTexture( m_Target, m_Id );
glGetTexLevelParameteriv( m_Target, 0, GL_TEXTURE_INTERNAL_FORMAT, &format );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glGetTexLevelParameteriv( m_Target, 0, GL_TEXTURE_INTERNAL_FORMAT, &format ) );
}
return format;
}
......@@ -50,14 +50,14 @@ GLint GPU::Texture::InternalFormat() const
bool GPU::Texture2D::Allocate()
{
glGenTextures( 1, &m_Id );
gpuAssert( glGenTextures( 1, &m_Id ) );
return m_Id != 0;
}
bool GPU::Texture2D::Unallocate()
{
glDeleteTextures( 1, &m_Id );
gpuAssert( glDeleteTextures( 1, &m_Id ) );
m_Id = 0;
return true;
}
......@@ -67,7 +67,7 @@ bool GPU::Texture2D::Create()
{
if( Instantiate() )
{
glBindTexture( m_Target, m_Id );
gpuAssert( glBindTexture( m_Target, m_Id ) );
m_Width = m_Height = 0;
return true;
}
......@@ -105,7 +105,7 @@ bool GPU::Texture2D::Load( GLenum internalFormats[],
const GLvoid* data,
GLint level )
{
glBindTexture( m_Target, m_Id );
gpuAssert( glBindTexture( m_Target, m_Id ) );
int currentFormatId = -1;
GLint isSupported;
......@@ -144,7 +144,7 @@ bool GPU::Texture2D::Load( GLenum internalFormats[],
type,
data
);
isSupported = glGetError() == GL_NO_ERROR;
isSupported = (glGetError() == GL_NO_ERROR);
}
}
} while( !isSupported );
......@@ -154,17 +154,21 @@ bool GPU::Texture2D::Load( GLenum internalFormats[],
GLint validatedType;
if( format == GL_NONE )
glGetInternalformativ( m_Target, internalFormats[currentFormatId], GL_TEXTURE_IMAGE_FORMAT, 1, &validatedFormat );
{
gpuAssert( glGetInternalformativ( m_Target, internalFormats[currentFormatId], GL_TEXTURE_IMAGE_FORMAT, 1, &validatedFormat ) );
}
else
validatedFormat = (GLint) format;
if( type == GL_NONE )
glGetInternalformativ( m_Target, internalFormats[currentFormatId], GL_TEXTURE_IMAGE_TYPE , 1, &validatedType );
{
gpuAssert( glGetInternalformativ( m_Target, internalFormats[currentFormatId], GL_TEXTURE_IMAGE_TYPE , 1, &validatedType ) );
}
else
validatedType = (GLint) type;
glTexImage2D(
gpuAssert( glTexImage2D(
m_Target,
level,
internalFormats[currentFormatId],
......@@ -174,7 +178,7 @@ bool GPU::Texture2D::Load( GLenum internalFormats[],
validatedFormat,
validatedType,
data
);
) );
m_Width = width;
m_Height = height;
......@@ -217,7 +221,7 @@ bool GPU::Texture2D::DumpTo( void *buffer,
if( m_Id )
{
#if glGetTextureImageEXT // Extension GL_EXT_direct_state_access is no supported by every common computer...
glGetTextureImageEXT( m_Id, GL_TEXTURE_2D, level, format, type, buffer );
gpuAssert( glGetTextureImageEXT( m_Id, GL_TEXTURE_2D, level, format, type, buffer ) );
#else
GPU::FrameBuffer fbuffer( m_Width, m_Height );
fbuffer.Attach( GL_COLOR_ATTACHMENT0_EXT, this );
......@@ -241,7 +245,7 @@ bool GPU::Texture2D::DumpTo( void *buffer,
if( m_Id )
{
#if glGetTextureImageEXT // Extension GL_EXT_direct_state_access is no supported by every common computer...
glGetTextureImageEXT( m_Id, GL_TEXTURE_2D, level, format, type, buffer );
gpuAssert( glGetTextureImageEXT( m_Id, GL_TEXTURE_2D, level, format, type, buffer ) );
#else
GPU::FrameBuffer fbuffer( m_Width, m_Height );
fbuffer.Attach( GL_COLOR_ATTACHMENT0_EXT, this );
......
......@@ -47,13 +47,13 @@ namespace GPU
inline void SetBaseLevel( int lvl )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_BASE_LEVEL, lvl );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_BASE_LEVEL, lvl ) );
}
inline void SetMaxLevel( int lvl )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_MAX_LEVEL, lvl );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_MAX_LEVEL, lvl ) );
}
inline void SetBaseAndMaxLevels( int bothLvl )
{
......@@ -61,33 +61,33 @@ namespace GPU
}
inline void SetBaseAndMaxLevels( int baseLvl, int maxLvl )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_BASE_LEVEL, baseLvl );
glTexParameteri( m_Target, GL_TEXTURE_MAX_LEVEL , maxLvl );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_BASE_LEVEL, baseLvl ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_MAX_LEVEL , maxLvl ) );
}
inline void SetCompareMode( GLenum mode )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_COMPARE_MODE, mode );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_COMPARE_MODE, mode ) );
}
inline void SetCompareFunc( GLenum func )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_COMPARE_FUNC, func );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_COMPARE_FUNC, func ) );
}
inline void SetDepthTextureMode( GLenum mode )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_DEPTH_TEXTURE_MODE, mode );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_DEPTH_TEXTURE_MODE, mode ) );
}
inline void SetFiltering( const GLenum minFilter, const GLenum magFilter )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_MIN_FILTER, minFilter );
glTexParameteri( m_Target, GL_TEXTURE_MAG_FILTER, magFilter );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_MIN_FILTER, minFilter ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_MAG_FILTER, magFilter ) );
}
inline void SetFiltering( const GLenum bothFilters )
{
......@@ -96,18 +96,18 @@ namespace GPU
inline void SetWrapS( GLenum s )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_WRAP_S, s );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_WRAP_S, s ) );
}
inline void SetWrapT( GLenum t )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_WRAP_T, t );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_WRAP_T, t ) );
}
inline void SetWrapR( GLenum r )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_WRAP_R, r );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_WRAP_R, r ) );
}
inline void SetWrapST( GLenum st )
{
......@@ -115,9 +115,9 @@ namespace GPU
}
inline void SetWrapST( GLenum s, GLenum t )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_WRAP_S, s );
glTexParameteri( m_Target, GL_TEXTURE_WRAP_T, t );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_WRAP_S, s ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_WRAP_T, t ) );
}
inline void SetWrapSTR( GLenum str )
{
......@@ -125,10 +125,10 @@ namespace GPU
}
inline void SetWrapSTR( GLenum s, GLenum t, GLenum r )
{
glBindTexture( m_Target, m_Id );
glTexParameteri( m_Target, GL_TEXTURE_WRAP_S, s );
glTexParameteri( m_Target, GL_TEXTURE_WRAP_T, t );
glTexParameteri( m_Target, GL_TEXTURE_WRAP_R, r );
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_WRAP_S, s ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_WRAP_T, t ) );
gpuAssert( glTexParameteri( m_Target, GL_TEXTURE_WRAP_R, r ) );
}
};
......
......@@ -16,14 +16,14 @@
bool GPU::Texture2DArray::Allocate()
{
glGenTextures( 1, &m_Id );
gpuAssert( glGenTextures( 1, &m_Id ) );
return m_Id != 0;
}
bool GPU::Texture2DArray::Unallocate()
{
glDeleteTextures( 1, &m_Id );
gpuAssert( glDeleteTextures( 1, &m_Id ) );
m_Id = 0;
return true;
}
......@@ -33,7 +33,7 @@ bool GPU::Texture2DArray::Create()
{
if( Instantiate() )
{
glBindTexture( m_Target, m_Id );
gpuAssert( glBindTexture( m_Target, m_Id ) );
m_Width = m_Height = m_Depth = 0;
return true;
}
......@@ -52,7 +52,7 @@ bool GPU::Texture2DArray::Create( GLenum internalFormats[],
return false;
glBindTexture( m_Target, m_Id );
gpuAssert( glBindTexture( m_Target, m_Id ) );
int currentFormatId = -1;
GLint isSupported;
......@@ -94,14 +94,14 @@ bool GPU::Texture2DArray::Create( GLenum internalFormats[],
}
} while( !isSupported );
glTexStorage3D(
gpuAssert( glTexStorage3D(
m_Target,
nMipMaps,
internalFormats[currentFormatId],
width,
height,
depth
);
) );
m_Width = width;
m_Height = height;
......@@ -119,8 +119,8 @@ bool GPU::Texture2DArray::LoadSlice( GLsizei sliceDepth,
{
if( m_Id )
{
glBindTexture( m_Target, m_Id );
glTexSubImage3D(
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexSubImage3D(
m_Target,
level,
......@@ -135,7 +135,7 @@ bool GPU::Texture2DArray::LoadSlice( GLsizei sliceDepth,
format,
type,
data
);
) );
return true;
}
......
......@@ -16,14 +16,14 @@
bool GPU::Texture3D::Allocate()
{
glGenTextures( 1, &m_Id );
gpuAssert( glGenTextures( 1, &m_Id ) );
return m_Id != 0;
}
bool GPU::Texture3D::Unallocate()
{
glDeleteTextures( 1, &m_Id );
gpuAssert( glDeleteTextures( 1, &m_Id ) );
m_Id = 0;
return true;
}
......@@ -33,7 +33,7 @@ bool GPU::Texture3D::Create()
{
if( Instantiate() )
{
glBindTexture( m_Target, m_Id );
gpuAssert( glBindTexture( m_Target, m_Id ) );
m_Width = m_Height = m_Depth = 0;
return true;
}
......@@ -73,7 +73,7 @@ bool GPU::Texture3D::Load( GLenum internalFormats[],
const GLvoid* data,
GLint level )
{
glBindTexture( m_Target, m_Id );
gpuAssert( glBindTexture( m_Target, m_Id ) );
int currentFormatId = -1;
GLint isSupported;
......@@ -123,17 +123,21 @@ bool GPU::Texture3D::Load( GLenum internalFormats[],
GLint validatedType;
if( format == GL_NONE )
glGetInternalformativ( m_Target, internalFormats[currentFormatId], GL_TEXTURE_IMAGE_FORMAT, 1, &validatedFormat );
{
gpuAssert( glGetInternalformativ( m_Target, internalFormats[currentFormatId], GL_TEXTURE_IMAGE_FORMAT, 1, &validatedFormat ) );
}
else
validatedFormat = (GLint) format;
if( type == GL_NONE )
glGetInternalformativ( m_Target, internalFormats[currentFormatId], GL_TEXTURE_IMAGE_TYPE , 1, &validatedType );
{
gpuAssert( glGetInternalformativ( m_Target, internalFormats[currentFormatId], GL_TEXTURE_IMAGE_TYPE , 1, &validatedType ) );
}
else
validatedType = (GLint) type;
glTexImage3D(
gpuAssert( glTexImage3D(
m_Target,
level,
internalFormats[currentFormatId],
......@@ -144,7 +148,7 @@ bool GPU::Texture3D::Load( GLenum internalFormats[],
validatedFormat,
validatedType,
data
);
) );
m_Width = width;
m_Height = height;
......@@ -162,8 +166,8 @@ bool GPU::Texture3D::LoadSlice( GLsizei sliceDepth,
{
if( m_Id )
{
glBindTexture( m_Target, m_Id );
glTexSubImage3D(
gpuAssert( glBindTexture( m_Target, m_Id ) );
gpuAssert( glTexSubImage3D(
m_Target,
level,
......@@ -178,7 +182,7 @@ bool GPU::Texture3D::LoadSlice( GLsizei sliceDepth,
format,
type,
data
);
) );
return true;
}
......
......@@ -16,14 +16,14 @@
bool GPU::TextureCube::Allocate()
{
glGenTextures( 1, &m_Id );
gpuAssert( glGenTextures( 1, &m_Id ) );
return m_Id != 0;
}
bool GPU::TextureCube::Unallocate()
{
glDeleteTextures( 1, &m_Id );
gpuAssert( glDeleteTextures( 1, &m_Id ) );
m_Id = 0;
return true;
}
......@@ -33,7 +33,7 @@ bool GPU::TextureCube::Create()
{