From ce68fffa3b33819dbd5a4ea65c35576d7712c3c4 Mon Sep 17 00:00:00 2001 From: nillerusr Date: Sun, 1 May 2022 15:53:52 +0300 Subject: [PATCH] togles: use original glCompressedTexture2D when gpu have DXT support --- togles/linuxwin/cglmbuffer.cpp | 2 +- togles/linuxwin/cglmtex.cpp | 24 +++++++++--------------- togles/linuxwin/glentrypoints.cpp | 4 ++-- togles/linuxwin/glmgr.cpp | 5 ++--- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/togles/linuxwin/cglmbuffer.cpp b/togles/linuxwin/cglmbuffer.cpp index 8f866da2..1fb77b62 100644 --- a/togles/linuxwin/cglmbuffer.cpp +++ b/togles/linuxwin/cglmbuffer.cpp @@ -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 ) diff --git a/togles/linuxwin/cglmtex.cpp b/togles/linuxwin/cglmtex.cpp index 2cc034e9..5230ad11 100644 --- a/togles/linuxwin/cglmtex.cpp +++ b/togles/linuxwin/cglmtex.cpp @@ -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, diff --git a/togles/linuxwin/glentrypoints.cpp b/togles/linuxwin/glentrypoints.cpp index 394f4f99..e4f78713 100644 --- a/togles/linuxwin/glentrypoints.cpp +++ b/togles/linuxwin/glentrypoints.cpp @@ -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() diff --git a/togles/linuxwin/glmgr.cpp b/togles/linuxwin/glmgr.cpp index cab42e47..7fb01e38 100644 --- a/togles/linuxwin/glmgr.cpp +++ b/togles/linuxwin/glmgr.cpp @@ -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 );