Browse Source

togles: use GL_EXT_buffer_storage if avalible

ToGLES3
nillerusr 3 years ago
parent
commit
1aa234af4d
  1. 4
      public/togles/linuxwin/glfuncs.h
  2. 10
      togles/linuxwin/cglmbuffer.cpp
  3. 4
      togles/linuxwin/glentrypoints.cpp
  4. 2
      togles/linuxwin/glmgr.cpp

4
public/togles/linuxwin/glfuncs.h

@ -273,8 +273,8 @@ GL_EXT(GL_EXT_texture_compression_dxt1,-1,-1) @@ -273,8 +273,8 @@ GL_EXT(GL_EXT_texture_compression_dxt1,-1,-1)
GL_EXT(GL_ANGLE_texture_compression_dxt3,-1,-1)
GL_EXT(GL_ANGLE_texture_compression_dxt5,-1,-1)
GL_EXT( GL_ARB_buffer_storage, 4, 4 )
GL_FUNC_VOID( GL_ARB_buffer_storage, false, glBufferStorage, (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags), (target, size, data, flags) )
GL_EXT( GL_EXT_buffer_storage, -1, -1 )
GL_FUNC_VOID( GL_EXT_buffer_storage, false, glBufferStorageEXT, (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags), (target, size, data, flags) )
// This one is an OS extension. We'll add a little helper function to look for it.
#ifdef _WIN32

10
togles/linuxwin/cglmbuffer.cpp

@ -93,7 +93,7 @@ CPersistentBuffer::~CPersistentBuffer() @@ -93,7 +93,7 @@ CPersistentBuffer::~CPersistentBuffer()
void CPersistentBuffer::Init( EGLMBufferType type,uint nSize )
{
Assert( gGL->m_bHave_GL_ARB_buffer_storage );
Assert( gGL->m_bHave_GL_EXT_buffer_storage );
Assert( gGL->m_bHave_GL_ARB_map_buffer_range );
m_nSize = nSize;
@ -115,10 +115,10 @@ void CPersistentBuffer::Init( EGLMBufferType type,uint nSize ) @@ -115,10 +115,10 @@ void CPersistentBuffer::Init( EGLMBufferType type,uint nSize )
// Create persistent immutable buffer that we will permanently map. This buffer can be written from any thread (not just
// the renderthread)
gGL->glBufferStorage( m_buffGLTarget, m_nSize, (const GLvoid *)NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT ); // V_GL_REQ: GL_ARB_buffer_storage, GL_ARB_map_buffer_range, GL_VERSION_4_4
gGL->glBufferStorageEXT( m_buffGLTarget, m_nSize, (const GLvoid *)NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT ); // V_GL_REQ: GL_EXT_buffer_storage, GL_ARB_map_buffer_range, GL_VERSION_4_4
// Map the buffer for all of eternity. Pointer can be used from multiple threads.
m_pImmutablePersistentBuf = gGL->glMapBufferRange( m_buffGLTarget, 0, m_nSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT ); // V_GL_REQ: GL_ARB_map_buffer_range, GL_ARB_buffer_storage, GL_VERSION_4_4
m_pImmutablePersistentBuf = gGL->glMapBufferRange( m_buffGLTarget, 0, m_nSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT ); // V_GL_REQ: GL_ARB_map_buffer_range, GL_EXT_buffer_storage, GL_VERSION_4_4
Assert( m_pImmutablePersistentBuf != NULL );
}
}
@ -687,7 +687,7 @@ void CGLMBuffer::Lock( GLMBuffLockParams *pParams, char **pAddressOut ) @@ -687,7 +687,7 @@ void CGLMBuffer::Lock( GLMBuffLockParams *pParams, char **pAddressOut )
bool bUsingPersistentBuffer = false;
uint padding = 0;
if ( m_bDynamic && gGL->m_bHave_GL_ARB_buffer_storage )
if ( m_bDynamic && gGL->m_bHave_GL_EXT_buffer_storage )
{
// Compute padding to add to make sure the start offset is valid
CPersistentBuffer *pTempBuffer = m_pCtx->GetCurPersistentBuffer( m_type );
@ -747,7 +747,7 @@ void CGLMBuffer::Lock( GLMBuffLockParams *pParams, char **pAddressOut ) @@ -747,7 +747,7 @@ void CGLMBuffer::Lock( GLMBuffLockParams *pParams, char **pAddressOut )
}
#endif
}
else if ( m_bDynamic && gGL->m_bHave_GL_ARB_buffer_storage && ( m_pCtx->GetCurPersistentBuffer( m_type )->GetBytesRemaining() >= ( pParams->m_nSize + padding ) ) )
else if ( m_bDynamic && gGL->m_bHave_GL_EXT_buffer_storage && ( m_pCtx->GetCurPersistentBuffer( m_type )->GetBytesRemaining() >= ( pParams->m_nSize + padding ) ) )
{
CPersistentBuffer *pTempBuffer = m_pCtx->GetCurPersistentBuffer( m_type );

4
togles/linuxwin/glentrypoints.cpp

@ -448,12 +448,12 @@ COpenGLEntryPoints::COpenGLEntryPoints() @@ -448,12 +448,12 @@ COpenGLEntryPoints::COpenGLEntryPoints()
// So disable it for now.
if ( ( m_nDriverProvider == cGLDriverProviderAMD ) || CommandLine()->CheckParm( "-gl_disable_arb_buffer_storage" ) )
{
m_bHave_GL_ARB_buffer_storage = false;
m_bHave_GL_EXT_buffer_storage = false;
}
printf( "GL_NV_bindless_texture: %s\n", m_bHave_GL_NV_bindless_texture ? "ENABLED" : "DISABLED" );
printf( "GL_AMD_pinned_memory: %s\n", m_bHave_GL_AMD_pinned_memory ? "ENABLED" : "DISABLED" );
printf( "GL_ARB_buffer_storage: %s\n", m_bHave_GL_ARB_buffer_storage ? "AVAILABLE" : "NOT AVAILABLE" );
printf( "GL_EXT_buffer_storage: %s\n", m_bHave_GL_EXT_buffer_storage ? "AVAILABLE" : "NOT AVAILABLE" );
printf( "GL_EXT_texture_sRGB_decode: %s\n", m_bHave_GL_EXT_texture_sRGB_decode ? "AVAILABLE" : "NOT AVAILABLE" );
bool bGLCanDecodeS3TCTextures = m_bHave_GL_EXT_texture_compression_s3tc || ( m_bHave_GL_EXT_texture_compression_dxt1 && m_bHave_GL_ANGLE_texture_compression_dxt3 && m_bHave_GL_ANGLE_texture_compression_dxt5 );

2
togles/linuxwin/glmgr.cpp

@ -2452,7 +2452,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params ) @@ -2452,7 +2452,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
ClearCurAttribs();
m_nCurPersistentBuffer = 0;
if ( gGL->m_bHave_GL_ARB_buffer_storage )
if ( gGL->m_bHave_GL_EXT_buffer_storage )
{
for ( uint lpType = 0; lpType < kGLMNumBufferTypes; ++lpType )
{

Loading…
Cancel
Save