From e79d2fd059fbe312955ee443b2e55d723a1063c8 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Tue, 25 Nov 2025 14:20:37 +0800 Subject: [PATCH] [Chore]: get rid of junk in texture stuff --- MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp | 8 ---- MobileGL/MG_Backend/DirectGLES/Managers.cpp | 13 +----- .../MG_Impl/GLImpl/Texture/GL_Texture.cpp | 39 ------------------ .../GLState/TextureState/TextureObject.h | 41 ------------------- .../GLState/TextureState/TextureObject1D.cpp | 5 --- .../GLState/TextureState/TextureObject1D.h | 1 - .../GLState/TextureState/TextureObject2D.cpp | 5 --- .../GLState/TextureState/TextureObject2D.h | 1 - .../GLState/TextureState/TextureObject3D.cpp | 5 --- .../GLState/TextureState/TextureObject3D.h | 1 - .../GLState/TextureState/TextureStorage.h | 4 -- 11 files changed, 1 insertion(+), 122 deletions(-) diff --git a/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp b/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp index 9381ee4f..8b7ab809 100644 --- a/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp +++ b/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp @@ -598,14 +598,6 @@ namespace MobileGL::MG_Backend::DirectGLES { auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget); auto textureObject = bindingSlot.GetBoundObject(); - -// const SizeT bytesPerPixel = MG_Util::GetInputBytesPerPixel(mglInternalFormat, texturePixelDataType); -// const SizeT totalBytes = width * height * bytesPerPixel; - - // MG_State::GLState::MipmapLevelInput mipmap = - // MG_State::GLState::MipmapLevelInput({width, height, 1}, level, false, 0, - // {nullptr, totalBytes}); - textureObject->SetInternalFormat(mglInternalFormat); textureObject->AllocateStorage(TextureUploadTarget::Texture2D, level, {{width, height, 1}, 0}); } diff --git a/MobileGL/MG_Backend/DirectGLES/Managers.cpp b/MobileGL/MG_Backend/DirectGLES/Managers.cpp index 0d8107c3..955e414d 100644 --- a/MobileGL/MG_Backend/DirectGLES/Managers.cpp +++ b/MobileGL/MG_Backend/DirectGLES/Managers.cpp @@ -316,14 +316,6 @@ namespace MobileGL::MG_Backend::DirectGLES { static_cast(levelTexelSize.y()), 0, glFormat, glType, pData); - // errorLopper.Loop([index = stateTextureObject->GetExternalIndex(), &mipmap, level, glInternalFormat, glFormat, glType, file = __FILE__, line = __LINE__, func = __func__](GLenum err) { - // MGLOG_D("%s(%s:%d) ES error: %s, texobj %d, mip %d (%dx%d, %s, %s, %s)", func, file, line, MG_Util::ConvertGLEnumToString(err).c_str(), - // index, level, mipmap.size.x(), mipmap.size.y(), - // MG_Util::ConvertGLEnumToString(glInternalFormat).c_str(), - // MG_Util::ConvertGLEnumToString(glFormat).c_str(), - // MG_Util::ConvertGLEnumToString(glType).c_str() - // ); - // }); // TODO: handle more texture types MGLOG_D("Regenerated mipmap level %d for texture with ID: %u", level, m_backendTextureId); @@ -459,10 +451,7 @@ namespace MobileGL::MG_Backend::DirectGLES { static_cast(texelSize.x()), static_cast(texelSize.y()), glFormat, glType, (byteSize != 0) ? stateTextureObject->MapMipmapData(TextureUploadTarget::Texture2D, level) : nullptr); - // errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__, &mipmap, glFormat, glType](GLenum err) { - // MGLOG_D("%s(%s:%d) ES error at glTexSubImage2D: %s (mip %d, %dx%d, %s, %s)", func, file, line, MG_Util::ConvertGLEnumToString(err).c_str(), - // mipmap.level, mipmap.size.x(), mipmap.size.y(), MG_Util::ConvertGLEnumToString(glFormat).c_str(), MG_Util::ConvertGLEnumToString(glType).c_str()); - // }); + stateTextureObject->MarkStorageDirty(TextureUploadTarget::Texture2D, level, false); } } diff --git a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp index f178312c..cbf013a4 100644 --- a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp +++ b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp @@ -425,45 +425,6 @@ namespace MobileGL { } free(processedPixels); - - // MG_State::GLState::MipmapLevelInput mipmap = - // MG_State::GLState::MipmapLevelInput({width, height, 1}, level, false, 0, - // {(isProxy || originalPixels == nullptr) ? nullptr : malloc(totalBytes), isProxy ? 0 : totalBytes}); - - - // if (!isProxy && originalPixels != nullptr && !mipmap.inputData.data) { - // MGLOG_E("TexImage2D_State: Failed to allocate memory for mipmap level data, size: %zu", totalBytes); - // free(processedPixels); - // processedPixels = nullptr; - // } - - // if (!isProxy && originalPixels != nullptr) { - // MGLOG_E("TexImage2D_State: Failed to allocate memory for mipmap level data, size: %zu", totalBytes); - // free(processedPixels); - // processedPixels = nullptr; - // } - // - // if (processedPixels && imageSize > 0 && !isProxy) { - // if (imageSize != totalBytes) { - // MGLOG_W("TexImage2D_State: Processed pixel data size (%zu) does not match expected size (%zu). " - // "This may indicate an alignment or processing issue.", - // imageSize, totalBytes); - // } - // - // const SizeT copySize = std::min(imageSize, totalBytes); - // Memcpy(mipmap.inputData.data, processedPixels, copySize); - // free(processedPixels); - // } else if (processedPixels && !isProxy) { - // MGLOG_E("TexImage2D_State: Failed to process pixel data, initializing with original data."); - // Memcpy(mipmap.inputData.data, originalPixels, totalBytes); - // } else { - // if (mipmap.inputData.data) { - // free(mipmap.inputData.data); - // mipmap.inputData.data = nullptr; - // } - // } - // textureObject->SetMipmapLevel(mipmap); - // free(mipmap.inputData.data); } void TexImage1D_State(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject.h b/MobileGL/MG_State/GLState/TextureState/TextureObject.h index 2f1da7e0..973cc83d 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject.h +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject.h @@ -9,45 +9,11 @@ namespace MobileGL { namespace MG_State { namespace GLState { - struct MipmapLevelBase { - IntVec3 size = {0, 0, 0}; - Int level = 0; - Bool compressed = false; - Int compressedSize = 0; - }; - - struct MipmapLevelInput : MipmapLevelBase { - DataPtr inputData = {nullptr, 0}; - - MipmapLevelInput(IntVec3 size, Int level, Bool compressed, Int compressedSize, DataPtr data) - : MipmapLevelBase{size, level, compressed, compressedSize}, inputData(data) {} - }; - - struct MipmapLevelInternal : MipmapLevelBase { - Data data; - Bool dirty = true; - Bool hasData = false; - - MipmapLevelInternal(const MipmapLevelInput& input) : MipmapLevelBase(input) { - data.resize(input.inputData.size, 0); - if (input.inputData.data && input.inputData.size > 0) { - const Uint8* src = static_cast(input.inputData.data); - Memcpy(data.data(), src, input.inputData.size); - hasData = true; - } - } - }; - class ITextureObject { public: using TargetEnum = TextureTarget; virtual ~ITextureObject() = default; - // virtual void SetMipmapLevel(const MipmapLevelInput& level) = 0; - // virtual const Vector& GetMipmaps() const = 0; - // virtual MipmapLevelInternal& GetMipmap(Int index) = 0; - // virtual void UnmarkMipmapDirty(Int index) = 0; - virtual Uint GetMipmapLevelCount() const = 0; virtual const IntVec3 GetMipmapTexelSize(TextureUploadTarget target, Uint mipmapLevel) const = 0; virtual const SizeT GetMipmapByteSize(TextureUploadTarget target, Uint mipmapLevel) const = 0; @@ -80,11 +46,6 @@ namespace MobileGL { TextureObjectBase(TextureTarget target, Uint externalIndex); virtual ~TextureObjectBase() = default; - // void SetMipmapLevel(const MipmapLevelInput& level) override; - // const Vector& GetMipmaps() const override; - // MipmapLevelInternal& GetMipmap(TextureUploadTarget target, Int index) override; - // void UnmarkMipmapDirty(Int index) override; - Uint GetMipmapLevelCount() const override; const IntVec3 GetMipmapTexelSize(TextureUploadTarget target, Uint mipmapLevel) const override; const SizeT GetMipmapByteSize(TextureUploadTarget target, Uint mipmapLevel) const override; @@ -110,8 +71,6 @@ namespace MobileGL { void SetMaxLevel(Uint maxLevel) override; protected: - // virtual void SetMipmapImpl(const MipmapLevelInput& level) = 0; - const Uint m_externalIndex; const TextureTarget m_target = TextureTarget::Unknown; TextureInternalFormat m_internalFormat = TextureInternalFormat::Unknown; diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject1D.cpp b/MobileGL/MG_State/GLState/TextureState/TextureObject1D.cpp index e6ce7b40..4ddaf396 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject1D.cpp +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject1D.cpp @@ -11,11 +11,6 @@ namespace MobileGL { return 0; } - // void TextureObject1D::SetMipmapImpl(const MipmapLevelInput& level) { - // if (level.size.x() > 0) { - // m_mipmaps.push_back(MipmapLevelInternal(level)); - // } - // } } } } \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject1D.h b/MobileGL/MG_State/GLState/TextureState/TextureObject1D.h index cd0272b2..d9b34a90 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject1D.h +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject1D.h @@ -9,7 +9,6 @@ namespace MobileGL { explicit TextureObject1D(Uint externalIndex); protected: - // void SetMipmapImpl(const MipmapLevelInput& level) override; Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override; }; } diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject2D.cpp b/MobileGL/MG_State/GLState/TextureState/TextureObject2D.cpp index 4fab74b8..b77d7117 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject2D.cpp +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject2D.cpp @@ -10,11 +10,6 @@ namespace MobileGL { MOBILEGL_ASSERT(target == TextureUploadTarget::Texture1D, "Invalid TextureUploadTarget!"); return 0; } - // void TextureObject2D::SetMipmapImpl(const MipmapLevelInput& level) { - // if (level.size.x() > 0 && level.size.y() > 0) { - // m_mipmaps.push_back(MipmapLevelInternal(level)); - // } - // } } } } \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject2D.h b/MobileGL/MG_State/GLState/TextureState/TextureObject2D.h index ed57fe2d..cff5d07f 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject2D.h +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject2D.h @@ -10,7 +10,6 @@ namespace MobileGL { protected: Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override; - // void SetMipmapImpl(const MipmapLevelInput& level) override; }; } } diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject3D.cpp b/MobileGL/MG_State/GLState/TextureState/TextureObject3D.cpp index f06eb7e6..0a02303f 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject3D.cpp +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject3D.cpp @@ -10,11 +10,6 @@ namespace MobileGL { MOBILEGL_ASSERT(target == TextureUploadTarget::Texture3D, "Invalid TextureUploadTarget!"); return 0; } - // void TextureObject3D::SetMipmapImpl(const MipmapLevelInput& level) { - // if (level.size.x() > 0 && level.size.y() > 0 && level.size.z() > 0) { - // m_mipmaps.push_back(MipmapLevelInternal(level)); - // } - // } } } } \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject3D.h b/MobileGL/MG_State/GLState/TextureState/TextureObject3D.h index 84cb1762..08ba815c 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject3D.h +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject3D.h @@ -10,7 +10,6 @@ namespace MobileGL { protected: Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override; - // void SetMipmapImpl(const MipmapLevelInput& level) override; }; } } diff --git a/MobileGL/MG_State/GLState/TextureState/TextureStorage.h b/MobileGL/MG_State/GLState/TextureState/TextureStorage.h index 13f21b62..ecbebe57 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureStorage.h +++ b/MobileGL/MG_State/GLState/TextureState/TextureStorage.h @@ -33,10 +33,6 @@ namespace MobileGL { auto& data = targetData[level]; data.resize(input.byteSize, 0); - // if (input.texelData.data && input.texelData.size > 0) { - // const Uint8* src = static_cast(input.texelData.data); - // Memcpy(data.data(), src, input.texelData.size); - // } } void UpdateSubData(Uint targetIndex, Uint level, DataPtr input) {