mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Feat] (MG_State/TextureState|MG_Impl/Texture): Add hasData mark for MipmapLevelInternal.
This commit is contained in:
@@ -117,6 +117,7 @@ namespace MobileGL {
|
|||||||
free(processedPixels);
|
free(processedPixels);
|
||||||
|
|
||||||
mipmap.dirty = true;
|
mipmap.dirty = true;
|
||||||
|
mipmap.hasData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TexSubImage1D_State(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type,
|
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) {
|
if (!isProxy && !mipmap.inputData.data) {
|
||||||
MGLOG_E("TexImage2D_State: Failed to allocate memory for mipmap level data, size: %zu", totalBytes);
|
MGLOG_E("TexImage2D_State: Failed to allocate memory for mipmap level data, size: %zu", totalBytes);
|
||||||
if (processedPixels) free(processedPixels);
|
free(processedPixels);
|
||||||
processedPixels = nullptr;
|
processedPixels = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,9 +411,9 @@ namespace MobileGL {
|
|||||||
const SizeT copySize = std::min(imageSize, totalBytes);
|
const SizeT copySize = std::min(imageSize, totalBytes);
|
||||||
Memcpy(mipmap.inputData.data, processedPixels, copySize);
|
Memcpy(mipmap.inputData.data, processedPixels, copySize);
|
||||||
free(processedPixels);
|
free(processedPixels);
|
||||||
} else if (pixels && !isProxy) {
|
} else if (processedPixels && !isProxy) {
|
||||||
MGLOG_E("TexImage2D_State: Failed to process pixel data, initializing with original data.");
|
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 {
|
} else {
|
||||||
if (mipmap.inputData.data) {
|
if (mipmap.inputData.data) {
|
||||||
free(mipmap.inputData.data);
|
free(mipmap.inputData.data);
|
||||||
@@ -421,7 +422,7 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
textureObject->SetInternalFormat(textureInternalFormat);
|
textureObject->SetInternalFormat(textureInternalFormat);
|
||||||
textureObject->SetMipmapLevel(mipmap);
|
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,
|
void TexImage1D_State(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border,
|
||||||
|
|||||||
@@ -200,12 +200,14 @@ namespace MobileGL {
|
|||||||
struct MipmapLevelInternal : MipmapLevelBase {
|
struct MipmapLevelInternal : MipmapLevelBase {
|
||||||
Data data;
|
Data data;
|
||||||
Bool dirty = true;
|
Bool dirty = true;
|
||||||
|
Bool hasData = false;
|
||||||
|
|
||||||
MipmapLevelInternal(const MipmapLevelInput& input) : MipmapLevelBase(input) {
|
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) {
|
if (input.inputData.data && input.inputData.size > 0) {
|
||||||
const Uint8* src = static_cast<const Uint8*>(input.inputData.data);
|
const Uint8* src = static_cast<const Uint8*>(input.inputData.data);
|
||||||
Memcpy(data.data(), src, input.inputData.size);
|
Memcpy(data.data(), src, input.inputData.size);
|
||||||
|
hasData = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user