mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Fix] (TextureState, GL_Drawing): mark dirty textures to skip uploading unmodified ones
This commit is contained in:
@@ -416,6 +416,9 @@ namespace MG_GL::GL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto& [level, mip] : texObj.params.mipmapData) {
|
for (auto& [level, mip] : texObj.params.mipmapData) {
|
||||||
|
if (!mip.dirty)
|
||||||
|
continue;
|
||||||
|
mip.dirty = false;
|
||||||
const void* data = !mip.pixelData.empty() ? mip.pixelData.data() : nullptr;
|
const void* data = !mip.pixelData.empty() ? mip.pixelData.data() : nullptr;
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case GL_TEXTURE_2D: {
|
case GL_TEXTURE_2D: {
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ GLenum TextureState::Upload2D(GLenum target, GLint level, GLint internalFormat,
|
|||||||
if (isProxyTexture) {
|
if (isProxyTexture) {
|
||||||
MG_Util::Debug::LogD("MG_State: Texture: Upload2D proxy texture detected");
|
MG_Util::Debug::LogD("MG_State: Texture: Upload2D proxy texture detected");
|
||||||
TextureObject& proxyTex = proxyTextures_[target];
|
TextureObject& proxyTex = proxyTextures_[target];
|
||||||
TextureParams::MipmapLevel mip{};
|
auto& mip = proxyTex.params.mipmapData[level];
|
||||||
mip.width = width;
|
mip.width = width;
|
||||||
mip.height = height;
|
mip.height = height;
|
||||||
mip.internalFormat = internalFormat;
|
mip.internalFormat = internalFormat;
|
||||||
@@ -266,7 +266,6 @@ GLenum TextureState::Upload2D(GLenum target, GLint level, GLint internalFormat,
|
|||||||
mip.type = type;
|
mip.type = type;
|
||||||
proxyTex.generated = true;
|
proxyTex.generated = true;
|
||||||
proxyTex.target = target;
|
proxyTex.target = target;
|
||||||
proxyTex.params.mipmapData[level] = mip;
|
|
||||||
return GL_NO_ERROR;
|
return GL_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,6 +279,7 @@ GLenum TextureState::Upload2D(GLenum target, GLint level, GLint internalFormat,
|
|||||||
mip.internalFormat = internalFormat;
|
mip.internalFormat = internalFormat;
|
||||||
mip.format = format;
|
mip.format = format;
|
||||||
mip.type = type;
|
mip.type = type;
|
||||||
|
mip.dirty = true;
|
||||||
|
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
mip.hasData = false;
|
mip.hasData = false;
|
||||||
@@ -491,6 +491,7 @@ GLenum TextureState::UpdateRegion2D(GLenum target, GLint level, GLint xoffset,
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
mip.hasData = true;
|
mip.hasData = true;
|
||||||
|
mip.dirty = true;
|
||||||
MG_Util::Debug::LogD("MG_State: Texture: UpdateRegion2D succeeded");
|
MG_Util::Debug::LogD("MG_State: Texture: UpdateRegion2D succeeded");
|
||||||
return GL_NO_ERROR;
|
return GL_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ struct TextureParams {
|
|||||||
GLenum type = GL_UNSIGNED_BYTE;
|
GLenum type = GL_UNSIGNED_BYTE;
|
||||||
std::vector<GLubyte> pixelData;
|
std::vector<GLubyte> pixelData;
|
||||||
bool hasData = false;
|
bool hasData = false;
|
||||||
|
bool dirty = false; // TODO: encapsulate this with an public API to RHI
|
||||||
};
|
};
|
||||||
unordered_map<GLint, MipmapLevel> mipmapData;
|
unordered_map<GLint, MipmapLevel> mipmapData;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user