diff --git a/kraken/KRContext.cpp b/kraken/KRContext.cpp index f0287ab..3a97469 100755 --- a/kraken/KRContext.cpp +++ b/kraken/KRContext.cpp @@ -79,10 +79,6 @@ int KRContext::KRENGINE_SYS_PAGE_SIZE; std::mutex KRContext::g_SurfaceInfoMutex; std::mutex KRContext::g_DeviceInfoMutex; -const char *KRContext::extension_names[KRENGINE_NUM_EXTENSIONS] = { - "GL_EXT_texture_storage" -}; - KRContext::log_callback *KRContext::s_log_callback = NULL; void *KRContext::s_log_callback_user_data = NULL; diff --git a/kraken/KRContext.h b/kraken/KRContext.h index 4e41934..ba326f5 100755 --- a/kraken/KRContext.h +++ b/kraken/KRContext.h @@ -115,14 +115,6 @@ public: KRSurfaceManager* getSurfaceManager(); KRDeviceManager* getDeviceManager(); - enum { - KRENGINE_GL_EXT_texture_storage, - KRENGINE_NUM_EXTENSIONS - }; - - static const char * extension_names[KRENGINE_NUM_EXTENSIONS]; - static bool extension_available[KRENGINE_NUM_EXTENSIONS]; - void startFrame(float deltaTime); void endFrame(float deltaTime); diff --git a/kraken/KRTexture2D.h b/kraken/KRTexture2D.h index 42e764e..58e38bf 100755 --- a/kraken/KRTexture2D.h +++ b/kraken/KRTexture2D.h @@ -45,7 +45,7 @@ public: virtual bool save(const std::string& path); virtual bool save(KRDataBlock &data); - virtual bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress = false, bool premultiply_alpha = false) = 0; + virtual bool uploadTexture(int lod_max_dim, int ¤t_lod_max_dim, bool compress = false, bool premultiply_alpha = false) = 0; virtual void bind(GLuint texture_unit); virtual Vector2i getDimensions() const = 0; diff --git a/kraken/KRTextureKTX.cpp b/kraken/KRTextureKTX.cpp index 389d94c..87b7b86 100755 --- a/kraken/KRTextureKTX.cpp +++ b/kraken/KRTextureKTX.cpp @@ -158,7 +158,7 @@ long KRTextureKTX::getMemRequiredForSize(int max_dim) return memoryRequired; } -bool KRTextureKTX::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress, bool premultiply_alpha) +bool KRTextureKTX::uploadTexture(int lod_max_dim, int ¤t_lod_max_dim, bool compress, bool premultiply_alpha) { int target_dim = lod_max_dim; if(target_dim < (int)m_min_lod_max_dim) target_dim = m_min_lod_max_dim; @@ -172,44 +172,7 @@ bool KRTextureKTX::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo int height = m_header.pixelHeight; long memoryRequired = 0; long memoryTransferred = 0; - - -#if GL_EXT_texture_storage - - if(target == GL_TEXTURE_CUBE_MAP_POSITIVE_X || target == GL_TEXTURE_2D) { - // Call glTexStorage2DEXT only for the first uploadTexture used when creating a texture - int level_count=0; - int max_lod_width=0; - int max_lod_height=0; - for(std::list::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) { - if(width <= target_dim && height <= target_dim) { - if(max_lod_width == 0) { - max_lod_width = width; - max_lod_height = height; - } - - level_count++; - } - - width = width >> 1; - if(width < 1) { - width = 1; - } - height = height >> 1; - if(height < 1) { - height = 1; - } - } - width = m_header.pixelWidth; - height = m_header.pixelHeight; - - if(target == GL_TEXTURE_CUBE_MAP_POSITIVE_X) { - glTexStorage2DEXT(GL_TEXTURE_CUBE_MAP, level_count, (GLenum)m_header.glInternalFormat, max_lod_width, max_lod_height); - } else if(target == GL_TEXTURE_2D) { - glTexStorage2DEXT(target, level_count, (GLenum)m_header.glInternalFormat, max_lod_width, max_lod_height); - } - } -#endif + // Upload texture data int destination_level=0; @@ -224,28 +187,15 @@ bool KRTextureKTX::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo if(height > current_lod_max_dim) { current_lod_max_dim = height; } -#if GL_APPLE_copy_texture_levels && GL_EXT_texture_storage - if(target == GL_TEXTURE_2D && width <= m_current_lod_max_dim && height <= m_current_lod_max_dim) { - //GLDEBUG(glCompressedTexImage2D(target, i, (GLenum)m_header.glInternalFormat, width, height, 0, block.length, NULL)); // Allocate, but don't copy - // GLDEBUG(glTexImage2D(target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL)); - GLDEBUG(glCopyTextureLevelsAPPLE(m_iNewHandle, m_iHandle, source_level, 1)); - } else { - block->lock(); - GLDEBUG(glCompressedTexSubImage2D(target, destination_level, 0, 0, width, height, (GLenum)m_header.glInternalFormat, (GLsizei)block->getSize(), block->getStart())); - block->unlock(); - - memoryTransferred += block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE - } -#else + block->lock(); -#if GL_EXT_texture_storage - GLDEBUG(glCompressedTexSubImage2D(target, destination_level, 0, 0, width, height, (GLenum)m_header.glInternalFormat, (GLsizei)block->getSize(), block->getStart())); -#else + /* + * TODO - Vulkan Refactoring GLDEBUG(glCompressedTexImage2D(target, destination_level, (GLenum)m_header.glInternalFormat, width, height, 0, (GLsizei)block->getSize(), block->getStart())); -#endif + */ + block->unlock(); memoryTransferred += (long)block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE -#endif memoryRequired += (long)block->getSize(); // // err = glGetError(); diff --git a/kraken/KRTextureKTX.h b/kraken/KRTextureKTX.h index da5bf1b..afeb6b7 100755 --- a/kraken/KRTextureKTX.h +++ b/kraken/KRTextureKTX.h @@ -41,7 +41,7 @@ public: virtual ~KRTextureKTX(); virtual std::string getExtension(); - bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress = false, bool premultiply_alpha = false); + bool uploadTexture(int lod_max_dim, int& current_lod_max_dim, bool compress = false, bool premultiply_alpha = false) override; virtual long getMemRequiredForSize(int max_dim); virtual Vector2i getDimensions() const override; diff --git a/kraken/KRTexturePVR.cpp b/kraken/KRTexturePVR.cpp index 7bfa054..c7f6ae1 100755 --- a/kraken/KRTexturePVR.cpp +++ b/kraken/KRTexturePVR.cpp @@ -178,7 +178,7 @@ long KRTexturePVR::getMemRequiredForSize(int max_dim) return memoryRequired; } -bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress, bool premultiply_alpha) +bool KRTexturePVR::uploadTexture(int lod_max_dim, int ¤t_lod_max_dim, bool compress, bool premultiply_alpha) { int target_dim = lod_max_dim; if(target_dim < (int)m_min_lod_max_dim) target_dim = m_min_lod_max_dim; @@ -193,44 +193,6 @@ bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo long memoryRequired = 0; long memoryTransferred = 0; - -#if GL_EXT_texture_storage - - if(target == GL_TEXTURE_CUBE_MAP_POSITIVE_X || target == GL_TEXTURE_2D) { - // Call glTexStorage2DEXT only for the first uploadTexture used when creating a texture - int level_count=0; - int max_lod_width=0; - int max_lod_height=0; - for(std::list::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) { - if(width <= target_dim && height <= target_dim) { - if(max_lod_width == 0) { - max_lod_width = width; - max_lod_height = height; - } - - level_count++; - } - - width = width >> 1; - if(width < 1) { - width = 1; - } - height = height >> 1; - if(height < 1) { - height = 1; - } - } - width = m_iWidth; - height = m_iHeight; - - if(target == GL_TEXTURE_CUBE_MAP_POSITIVE_X) { - glTexStorage2DEXT(GL_TEXTURE_CUBE_MAP, level_count, m_internalFormat, max_lod_width, max_lod_height); - } else if(target == GL_TEXTURE_2D) { - glTexStorage2DEXT(target, level_count, m_internalFormat, max_lod_width, max_lod_height); - } - } -#endif - // Upload texture data int destination_level=0; int source_level = 0; @@ -244,28 +206,14 @@ bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo if(height > current_lod_max_dim) { current_lod_max_dim = height; } -#if GL_APPLE_copy_texture_levels && GL_EXT_texture_storage - if(target == GL_TEXTURE_2D && width <= m_current_lod_max_dim && height <= m_current_lod_max_dim) { - //GLDEBUG(glCompressedTexImage2D(target, i, m_internalFormat, width, height, 0, block.length, NULL)); // Allocate, but don't copy -// GLDEBUG(glTexImage2D(target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL)); - GLDEBUG(glCopyTextureLevelsAPPLE(m_iNewHandle, m_iHandle, source_level, 1)); - } else { - block->lock(); - GLDEBUG(glCompressedTexSubImage2D(target, destination_level, 0, 0, width, height, m_internalFormat, (GLsizei)block->getSize(), block->getStart())); - block->unlock(); - - memoryTransferred += block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE - } -#else + block->lock(); - #if GL_EXT_texture_storage - GLDEBUG(glCompressedTexSubImage2D(target, destination_level, 0, 0, width, height, m_internalFormat, block->getSize(), block->getStart())); - #else + /* + * TODO - Vulkan Refactoring GLDEBUG(glCompressedTexImage2D(target, destination_level, m_internalFormat, width, height, 0, (GLsizei)block->getSize(), block->getStart())); - #endif + */ block->unlock(); memoryTransferred += (long)block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE -#endif memoryRequired += (long)block->getSize(); // // err = glGetError(); diff --git a/kraken/KRTexturePVR.h b/kraken/KRTexturePVR.h index 190df86..c892dbe 100755 --- a/kraken/KRTexturePVR.h +++ b/kraken/KRTexturePVR.h @@ -40,7 +40,7 @@ public: virtual ~KRTexturePVR(); virtual std::string getExtension(); - bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress = false, bool premultiply_alpha = false); + bool uploadTexture(int lod_max_dim, int& current_lod_max_dim, bool compress = false, bool premultiply_alpha = false) override; virtual long getMemRequiredForSize(int max_dim); virtual Vector2i getDimensions() const override; diff --git a/kraken/KRTextureTGA.cpp b/kraken/KRTextureTGA.cpp index 8802241..2469ec0 100755 --- a/kraken/KRTextureTGA.cpp +++ b/kraken/KRTextureTGA.cpp @@ -114,7 +114,7 @@ KRTextureTGA::~KRTextureTGA() } -bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress, bool premultiply_alpha) +bool KRTextureTGA::uploadTexture(int lod_max_dim, int ¤t_lod_max_dim, bool compress, bool premultiply_alpha) { m_pData->lock(); TGA_HEADER *pHeader = (TGA_HEADER *)m_pData->getStart(); @@ -156,8 +156,11 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo } assert(pSource <= m_pData->getEnd()); //#endif + /* + * TODO - Vulkan Refactoring GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image)); GLDEBUG(glFinish()); + */ free(converted_image); current_lod_max_dim = m_max_lod_max_dim; @@ -179,9 +182,11 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo pSource += 4; } assert(pSource <= m_pData->getEnd()); - + /* + * TODO - Vulkan Refactoring GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image)); GLDEBUG(glFinish()); + */ free(converted_image); } else { unsigned char *converted_image = (unsigned char *)malloc(pHeader->width * pHeader->height * 4); @@ -197,8 +202,11 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo pSource += 4; } assert(pSource <= m_pData->getEnd()); + /* + * TODO - Vulkan Refactoring GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)pData)); GLDEBUG(glFinish()); + */ free(converted_image); } @@ -273,8 +281,11 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo assert(pSource <= m_pData->getEnd()); assert(pDest == pEnd); } + /* + * TODO - Vulkan Refactoring GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image)); GLDEBUG(glFinish()); + */ free(converted_image); current_lod_max_dim = m_max_lod_max_dim; } @@ -311,8 +322,11 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo } assert(pSource <= m_pData->getEnd()); assert(pDest == pEnd); + /* + * TODO - Vulkan Refactoring GLDEBUG(glTexImage2D(target, 0, internal_format, pHeader->width, pHeader->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image)); GLDEBUG(glFinish()); + */ free(converted_image); current_lod_max_dim = m_max_lod_max_dim; } @@ -347,7 +361,7 @@ KRTexture *KRTextureTGA::compress(bool premultiply_alpha) GLDEBUG(glBindTexture(GL_TEXTURE_2D, compressed_handle)); int current_max_dim = 0; - if(!uploadTexture(GL_TEXTURE_2D, m_max_lod_max_dim, current_max_dim, true, premultiply_alpha)) { + if(!uploadTexture(m_max_lod_max_dim, current_max_dim, true, premultiply_alpha)) { assert(false); // Failed to upload the texture } GLDEBUG(glGenerateMipmap(GL_TEXTURE_2D)); diff --git a/kraken/KRTextureTGA.h b/kraken/KRTextureTGA.h index fdabab3..165bf04 100755 --- a/kraken/KRTextureTGA.h +++ b/kraken/KRTextureTGA.h @@ -40,7 +40,7 @@ public: virtual ~KRTextureTGA(); virtual std::string getExtension(); - bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, bool compress = false, bool premultiply_alpha = false); + bool uploadTexture(int lod_max_dim, int& current_lod_max_dim, bool compress = false, bool premultiply_alpha = false) override; #if !TARGET_OS_IPHONE && !defined(ANDROID) virtual KRTexture *compress(bool premultiply_alpha = false);