togles: use original glCompressedTexture2D when gpu have DXT support

This commit is contained in:
nillerusr 2022-05-01 15:53:52 +03:00
parent 2ec2a47a53
commit ce68fffa3b
4 changed files with 14 additions and 21 deletions

View File

@ -472,7 +472,7 @@ CGLMBuffer::CGLMBuffer( GLMContext *pCtx, EGLMBufferType type, uint size, uint o
m_bPseudo = true;
#endif
const char *szRenderer = gGL->glGetString(GL_VENDOR);
const char *szRenderer = (const char*)gGL->glGetString(GL_VENDOR);
// Msg("GL_VENDOR: %s\n", szRenderer);
if( strcmp(szRenderer, "ARM") == 0 )

View File

@ -3435,15 +3435,15 @@ GLvoid *uncompressDXTc(GLsizei width, GLsizei height, GLenum format, GLsizei ima
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
DecompressBlockDXT1(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, pixels);
DecompressBlockDXT1(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, (uint32_t*)pixels);
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
DecompressBlockDXT3(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, pixels);
DecompressBlockDXT3(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, (uint32_t*)pixels);
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
DecompressBlockDXT5(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, pixels);
DecompressBlockDXT5(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, (uint32_t*)pixels);
break;
}
src+=blocksize;
@ -3641,24 +3641,18 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
// adjust target to steer to the proper face, then fall through to the 2D texture path.
target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + desc->m_req.m_face;
case GL_TEXTURE_2D:
{
{
// check compressed or not
if (format->m_chunkSize != 1)
{
Assert( writeWholeSlice ); //subimage not implemented in this path yet
// compressed path
// http://www.opengl.org/sdk/docs/man/xhtml/glCompressedTexImage2D.xml
CompressedTexImage2D( target, // target
desc->m_req.m_mip, // level
intformat, // internalformat - don't use format->m_glIntFormat because we have the SRGB select going on above
slice->m_xSize, // width
slice->m_ySize, // height
0, // border
slice->m_storageSize, // imageSize
sliceAddress ); // data
if( gGL->m_bHave_GL_EXT_texture_compression_dxt1 )
gGL->glCompressedTexImage2D( target, desc->m_req.m_mip, intformat, slice->m_xSize, slice->m_ySize, 0, slice->m_storageSize, sliceAddress );
else
CompressedTexImage2D( target, desc->m_req.m_mip, intformat, slice->m_xSize, slice->m_ySize, 0, slice->m_storageSize, sliceAddress );
}
else
{
@ -3669,7 +3663,7 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
gGL->glPixelStorei( GL_UNPACK_ROW_LENGTH, slice->m_xSize ); // in pixels
gGL->glPixelStorei( GL_UNPACK_SKIP_PIXELS, writeBox.xmin ); // in pixels
gGL->glPixelStorei( GL_UNPACK_SKIP_ROWS, writeBox.ymin ); // in pixels
convert_texture(intformat, writeBox.xmax - writeBox.xmin, writeBox.ymax - writeBox.ymin, glDataFormat, glDataType, sliceAddress);
gGL->glTexSubImage2D( target,

View File

@ -485,12 +485,12 @@ COpenGLEntryPoints::COpenGLEntryPoints()
}
#endif
#ifndef OSX
/*#ifndef OSX
if ( !m_bHave_GL_EXT_texture_sRGB_decode )
{
Error( "Required OpenGL extension \"GL_EXT_texture_sRGB_decode\" is not supported. Please update your OpenGL driver.\n" );
}
#endif
#endif*/
}
COpenGLEntryPoints::~COpenGLEntryPoints()

View File

@ -1729,14 +1729,13 @@ void GLMContext::PreloadTex( CGLMTex *tex, bool force )
0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f };
static int indices[] = { 0, 1, 2 };
static unsigned short indices[] = { 0, 1, 2 };
gGL->glEnableVertexAttribArray( 0 );
gGL->glVertexAttribPointer( 0, 3, GL_FLOAT, 0, 0, posns );
gGL->glDrawRangeElements( GL_TRIANGLES, 0, 2, 3, GL_UNSIGNED_INT, indices);
gGL->glDrawRangeElements( GL_TRIANGLES, 0, 2, 3, GL_UNSIGNED_SHORT, indices);
gGL->glDisableVertexAttribArray( 0 );