[Feat] (MG_State/TextureState|MG_Impl/Texture): Add hasData mark for MipmapLevelInternal.

This commit is contained in:
BZLZHH
2025-11-15 23:17:01 +08:00
parent 8b39e3c8a9
commit 784b53344c
2 changed files with 8 additions and 5 deletions
@@ -117,6 +117,7 @@ namespace MobileGL {
free(processedPixels);
mipmap.dirty = true;
mipmap.hasData = true;
}
void TexSubImage1D_State(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type,
@@ -396,7 +397,7 @@ namespace MobileGL {
if (!isProxy && !mipmap.inputData.data) {
MGLOG_E("TexImage2D_State: Failed to allocate memory for mipmap level data, size: %zu", totalBytes);
if (processedPixels) free(processedPixels);
free(processedPixels);
processedPixels = nullptr;
}
@@ -410,9 +411,9 @@ namespace MobileGL {
const SizeT copySize = std::min(imageSize, totalBytes);
Memcpy(mipmap.inputData.data, processedPixels, copySize);
free(processedPixels);
} else if (pixels && !isProxy) {
} else if (processedPixels && !isProxy) {
MGLOG_E("TexImage2D_State: Failed to process pixel data, initializing with original data.");
Memcpy(mipmap.inputData.data, pixels, totalBytes);
Memcpy(mipmap.inputData.data, originalPixels, totalBytes);
} else {
if (mipmap.inputData.data) {
free(mipmap.inputData.data);
@@ -421,7 +422,7 @@ namespace MobileGL {
}
textureObject->SetInternalFormat(textureInternalFormat);
textureObject->SetMipmapLevel(mipmap);
if (mipmap.inputData.data) free(mipmap.inputData.data);
free(mipmap.inputData.data);
}
void TexImage1D_State(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border,
@@ -200,12 +200,14 @@ namespace MobileGL {
struct MipmapLevelInternal : MipmapLevelBase {
Data data;
Bool dirty = true;
Bool hasData = false;
MipmapLevelInternal(const MipmapLevelInput& input) : MipmapLevelBase(input) {
data.resize(input.inputData.size);
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;
}
}
};