From 70e3fd1aec9cd0eb5653dd1f69edfd51e53a5523 Mon Sep 17 00:00:00 2001 From: Jens Hemprich <31758696+jenshemprich@users.noreply.github.com> Date: Mon, 19 Feb 2007 15:53:25 +0000 Subject: [PATCH] EXT_client_texture global mode --- MacGLide/OpenGLide/GLExtensions.cpp | 8 ++++++++ MacGLide/OpenGLide/PGTexture.cpp | 31 ++++++++++++++++------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/MacGLide/OpenGLide/GLExtensions.cpp b/MacGLide/OpenGLide/GLExtensions.cpp index 968cc0c..d14519f 100644 --- a/MacGLide/OpenGLide/GLExtensions.cpp +++ b/MacGLide/OpenGLide/GLExtensions.cpp @@ -67,6 +67,7 @@ stExtensionSupport glNecessaryExt[] = { "GL_APPLE_packed_pixels", OGL_EXT_REQUIRED, &dummyExtVariable, &dummyExtVariable2 }, { "GL_APPLE_client_storage", OGL_EXT_DESIRED, &dummyExtVariable, &InternalConfig.EXT_Client_Storage }, { "GL_EXT_compiled_vertex_array", OGL_EXT_DESIRED, &UserConfig.EXT_compiled_vertex_array,&InternalConfig.EXT_compiled_vertex_array }, + { "GL_ARB_texture_rectangle", OGL_EXT_DESIRED, &UserConfig.ARB_texture_rectangle, &InternalConfig.ARB_texture_rectangle }, #ifdef OPENGLIDE_SYSTEM_HAS_FOGCOORD { "GL_EXT_fog_coord", OGL_EXT_DESIRED, &dummyExtVariable, &InternalConfig.EXT_fog_coord }, #endif @@ -247,6 +248,13 @@ void GLExtensions(void) glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &MaxAnisotropyLevel); GlideMsg("Maximum level of anisotropy = %d\n", MaxAnisotropyLevel); + // Since this a global setting, texture data must not be uploaded from temp buffers + if (InternalConfig.EXT_Client_Storage) + { + glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, true); + glReportError(); + } + if (InternalConfig.EXT_texture_filter_anisotropic) { GLint MaxAnisotropyLevel; diff --git a/MacGLide/OpenGLide/PGTexture.cpp b/MacGLide/OpenGLide/PGTexture.cpp index 81954f5..6e6aed3 100644 --- a/MacGLide/OpenGLide/PGTexture.cpp +++ b/MacGLide/OpenGLide/PGTexture.cpp @@ -623,8 +623,14 @@ bool PGTexture::MakeReady(TTextureStruct* tex_coords, unsigned long number_of_tr } glReportError(); + // use client storage to avoid OpenGL-internal copy + // OpenGL may still make a copy if the color format isn't supported natively + // by the graphics card but all xto8888 conversions should benefit from this + // @todo: Not true for OSX, but for now we stay compatible to native OS9 + const bool useClientStorage = InternalConfig.EXT_Client_Storage /* && !subtexcoords */; if (subtexcoords) { + // EXT_Client_Storage doesn't explicitely forbid to adjust pixel unpack :^) glPixelStorei(GL_UNPACK_SKIP_PIXELS, subtexcoords->left); glPixelStorei(GL_UNPACK_SKIP_ROWS, subtexcoords->top); glPixelStorei(GL_UNPACK_ROW_LENGTH, texVals.width); @@ -632,26 +638,23 @@ bool PGTexture::MakeReady(TTextureStruct* tex_coords, unsigned long number_of_tr texVals.width = subtexcoords->texImageWidth; texVals.height = subtexcoords->texImageHeight; } - // use client storage to avoid OpenGL-internal copy - // OpenGL may still make a copy if the colro format isn't supported natively - // by the graphics card but all xto8888 conversions should benefit from this - const bool useClientStorage = InternalConfig.EXT_Client_Storage && !subtexcoords; FxU32* texBuffer; + // Which buffer if (useClientStorage) { texBuffer = &m_textureCache[m_startAddress]; - glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, true); - glReportError(); + // glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, true); + // glReportError(); } else { texBuffer = m_tex_temp; } // Convert Glide texture data to format understood by OpenGL - switch ( m_info.format ) + switch (m_info.format) { case GR_TEXFMT_RGB_565: - if ( m_chromakey_mode ) + if (m_chromakey_mode) { // Read about anisotropy and chromakey issues in macFormatConversions.cpp Convert565Kto8888((FxU16*)data, m_chromakey_value_565, texBuffer, texVals.nPixels); @@ -785,14 +788,14 @@ bool PGTexture::MakeReady(TTextureStruct* tex_coords, unsigned long number_of_tr break; } // Cleanup - if (useClientStorage) - { - glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, false); - glReportError(); - } + // if (useClientStorage) + // { + // glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, false); + // glReportError(); + // } if (subtexcoords) { - // restore values + // restore default values glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);