[Chore]: get rid of junk in texture stuff

This commit is contained in:
2025-11-25 14:20:37 +08:00
parent 352df37b91
commit e79d2fd059
11 changed files with 1 additions and 122 deletions
@@ -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});
}
+1 -12
View File
@@ -316,14 +316,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
static_cast<GLsizei>(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<GLsizei>(texelSize.x()),
static_cast<GLsizei>(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);
}
}
@@ -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,
@@ -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<const Uint8*>(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<MipmapLevelInternal>& 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<MipmapLevelInternal>& 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;
@@ -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));
// }
// }
}
}
}
@@ -9,7 +9,6 @@ namespace MobileGL {
explicit TextureObject1D(Uint externalIndex);
protected:
// void SetMipmapImpl(const MipmapLevelInput& level) override;
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
};
}
@@ -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));
// }
// }
}
}
}
@@ -10,7 +10,6 @@ namespace MobileGL {
protected:
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
// void SetMipmapImpl(const MipmapLevelInput& level) override;
};
}
}
@@ -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));
// }
// }
}
}
}
@@ -10,7 +10,6 @@ namespace MobileGL {
protected:
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
// void SetMipmapImpl(const MipmapLevelInput& level) override;
};
}
}
@@ -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<const Uint8*>(input.texelData.data);
// Memcpy(data.data(), src, input.texelData.size);
// }
}
void UpdateSubData(Uint targetIndex, Uint level, DataPtr input) {