mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
Revert "[Optimize] (MG_Backend/DirectGLES): Texture object mipmap dirty bit"
This reverts commit 8f551794
This commit is contained in:
@@ -273,8 +273,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
backendFBOObject->SyncToBackend(currentFBO, target);
|
backendFBOObject->SyncToBackend(currentFBO, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// backendFBOObject->Bind(target);
|
|
||||||
|
|
||||||
lastUpdatedFBO = currentFBO.get();
|
lastUpdatedFBO = currentFBO.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,11 +360,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stateTextureObject->CheckDirtyBit(MG_State::GLState::TextureDirtyBit::StorageDirtyBit)) {
|
|
||||||
MGLOG_D("Texture parameters changed but storage is not dirty, skipping mipmap sync for texture ID: %u",
|
|
||||||
m_backendTextureId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
@@ -396,7 +391,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bind(target);
|
Bind(target);
|
||||||
|
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
||||||
|
MGLOG_D("%s(%s:%d) ES error: %s", func, file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
|
});
|
||||||
const auto baseSize = stateTextureObject->GetBaseSize();
|
const auto baseSize = stateTextureObject->GetBaseSize();
|
||||||
StateTextureBasicInfo currentTextureInfo = {stateTextureObject->GetFormat(),
|
StateTextureBasicInfo currentTextureInfo = {stateTextureObject->GetFormat(),
|
||||||
static_cast<SizeT>(baseSize.x()),
|
static_cast<SizeT>(baseSize.x()),
|
||||||
@@ -436,11 +433,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
auto* pData = (levelDirty && levelByteSize != 0)
|
auto* pData = (levelDirty && levelByteSize != 0)
|
||||||
? textureMipmapObject->MapMipmapData(uploadTarget, level)
|
? textureMipmapObject->MapMipmapData(uploadTarget, level)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
MGLOG_D("%s: target: %s: syncing mip %d: %dx%dx%d, byteSize = %d, pData = %p, "
|
MGLOG_D(
|
||||||
"levelDirty = %s",
|
"%s: target: %s: syncing mip %d: %dx%dx%d, byteSize = %d, pData = %p, levelDirty = %s",
|
||||||
__func__, MG_Util::ConvertTextureUploadTargetToString(uploadTarget).c_str(), level,
|
__func__, MG_Util::ConvertTextureUploadTargetToString(uploadTarget).c_str(), level,
|
||||||
levelTexelSize.x(), levelTexelSize.y(), levelTexelSize.z(), levelByteSize, pData,
|
levelTexelSize.x(), levelTexelSize.y(), levelTexelSize.z(), levelByteSize, pData,
|
||||||
levelDirty ? "true" : "false");
|
levelDirty ? "true" : "false");
|
||||||
|
|
||||||
errorLopper.Clear();
|
errorLopper.Clear();
|
||||||
MG_External::GLES::glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
MG_External::GLES::glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||||
@@ -525,8 +522,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textureMipmapObject->ClearAllStorageDirtyBit();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TextureStorageType::Buffer: {
|
case TextureStorageType::Buffer: {
|
||||||
@@ -562,8 +557,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
&glType);
|
&glType);
|
||||||
|
|
||||||
MG_External::GLES::glTexBuffer(GL_TEXTURE_BUFFER, glInternalFormat, backendId);
|
MG_External::GLES::glTexBuffer(GL_TEXTURE_BUFFER, glInternalFormat, backendId);
|
||||||
|
|
||||||
textureBufferObject->ClearAllStorageDirtyBit();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Includes.h>
|
#include <Includes.h>
|
||||||
#include "DirectGLES.h"
|
#include "DirectGLES.h"
|
||||||
#include "Utils.h"
|
|
||||||
#include "MG_State/GLState/SamplerState/SamplerObject.h"
|
#include "MG_State/GLState/SamplerState/SamplerObject.h"
|
||||||
#include "MG_State/GLState/TextureState/TextureEnum.h"
|
#include "MG_State/GLState/TextureState/TextureEnum.h"
|
||||||
#include <MG_State/GLState/TextureState/TextureObject.h>
|
#include <MG_State/GLState/TextureState/TextureObject.h>
|
||||||
|
|||||||
@@ -788,7 +788,6 @@ namespace MobileGL {
|
|||||||
auto* texBufferObject = static_cast<MG_State::GLState::TextureObjectBuffer*>(textureObject.get());
|
auto* texBufferObject = static_cast<MG_State::GLState::TextureObjectBuffer*>(textureObject.get());
|
||||||
auto& bufferSlot = texBufferObject->GetBufferBindingSlot();
|
auto& bufferSlot = texBufferObject->GetBufferBindingSlot();
|
||||||
bufferSlot.Bind(bufferObject);
|
bufferSlot.Bind(bufferObject);
|
||||||
texBufferObject->SetStorageDirtyBit();
|
|
||||||
|
|
||||||
texBufferObject->SetInternalFormat(textureInternalFormat);
|
texBufferObject->SetInternalFormat(textureInternalFormat);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,14 +135,6 @@ namespace MobileGL {
|
|||||||
++m_textureParamsVersion;
|
++m_textureParamsVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool TextureObjectBase::IsDirty() const {
|
|
||||||
return m_dirtyBit;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bool TextureObjectBase::CheckDirtyBit(TextureDirtyBit bit) const {
|
|
||||||
return m_dirtyBit & bit;
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint16 TextureObjectBase::GetTextureParamsVersion() const {
|
Uint16 TextureObjectBase::GetTextureParamsVersion() const {
|
||||||
return m_textureParamsVersion;
|
return m_textureParamsVersion;
|
||||||
}
|
}
|
||||||
@@ -178,9 +170,6 @@ namespace MobileGL {
|
|||||||
void TextureObjectWithOneMipmap::MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
void TextureObjectWithOneMipmap::MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
||||||
Bool dirty) {
|
Bool dirty) {
|
||||||
m_textureStorage.MarkDirty(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, dirty);
|
m_textureStorage.MarkDirty(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, dirty);
|
||||||
if (dirty) {
|
|
||||||
m_dirtyBit.Set(TextureDirtyBit::StorageDirtyBit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool TextureObjectWithOneMipmap::IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const {
|
Bool TextureObjectWithOneMipmap::IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const {
|
||||||
@@ -224,14 +213,6 @@ namespace MobileGL {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureObjectWithOneMipmap::ClearAllStorageDirtyBit() {
|
|
||||||
auto levelCount = GetMipmapLevelCount();
|
|
||||||
for (Uint i = 0; i < levelCount; ++i) {
|
|
||||||
m_textureStorage.MarkDirty(0, i, false);
|
|
||||||
}
|
|
||||||
m_dirtyBit.Clear(TextureDirtyBit::StorageDirtyBit);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: add other texture types as needed
|
// TODO: add other texture types as needed
|
||||||
|
|
||||||
} // namespace GLState
|
} // namespace GLState
|
||||||
|
|||||||
@@ -17,12 +17,6 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_State {
|
namespace MG_State {
|
||||||
namespace GLState {
|
namespace GLState {
|
||||||
enum class TextureDirtyBit : Uint8 {
|
|
||||||
None = 0,
|
|
||||||
StorageDirtyBit = 1 << 0, // refers to mipmap or TexBuffer according to tex type
|
|
||||||
ParamDirtyBit = 1 << 1
|
|
||||||
};
|
|
||||||
|
|
||||||
class ITextureObject {
|
class ITextureObject {
|
||||||
public:
|
public:
|
||||||
using TargetEnum = TextureTarget;
|
using TargetEnum = TextureTarget;
|
||||||
@@ -47,8 +41,6 @@ namespace MobileGL {
|
|||||||
virtual const UintVec2& GetLevelRange() const = 0;
|
virtual const UintVec2& GetLevelRange() const = 0;
|
||||||
virtual void SetBaseLevel(Uint baseLevel) = 0;
|
virtual void SetBaseLevel(Uint baseLevel) = 0;
|
||||||
virtual void SetMaxLevel(Uint maxLevel) = 0;
|
virtual void SetMaxLevel(Uint maxLevel) = 0;
|
||||||
virtual Bool IsDirty() const = 0;
|
|
||||||
virtual Bool CheckDirtyBit(TextureDirtyBit bit) const = 0;
|
|
||||||
virtual Uint16 GetTextureParamsVersion() const = 0;
|
virtual Uint16 GetTextureParamsVersion() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -76,11 +68,7 @@ namespace MobileGL {
|
|||||||
const UintVec2& GetLevelRange() const override;
|
const UintVec2& GetLevelRange() const override;
|
||||||
void SetBaseLevel(Uint baseLevel) override;
|
void SetBaseLevel(Uint baseLevel) override;
|
||||||
void SetMaxLevel(Uint maxLevel) override;
|
void SetMaxLevel(Uint maxLevel) override;
|
||||||
Bool IsDirty() const override;
|
|
||||||
Bool CheckDirtyBit(TextureDirtyBit bit) const override;
|
|
||||||
Uint16 GetTextureParamsVersion() const override;
|
Uint16 GetTextureParamsVersion() const override;
|
||||||
virtual void ClearAllStorageDirtyBit() = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const Uint m_externalIndex;
|
const Uint m_externalIndex;
|
||||||
const TextureTarget m_target = TextureTarget::Unknown;
|
const TextureTarget m_target = TextureTarget::Unknown;
|
||||||
@@ -91,8 +79,6 @@ namespace MobileGL {
|
|||||||
TextureSwizzleParam::Blue, TextureSwizzleParam::Alpha};
|
TextureSwizzleParam::Blue, TextureSwizzleParam::Alpha};
|
||||||
UintVec2 m_levelRange = {0, 1000};
|
UintVec2 m_levelRange = {0, 1000};
|
||||||
Uint16 m_textureParamsVersion = 0;
|
Uint16 m_textureParamsVersion = 0;
|
||||||
|
|
||||||
Flags<TextureDirtyBit> m_dirtyBit = TextureDirtyBit::None;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextureObjectMipmap : public TextureObjectBase {
|
class TextureObjectMipmap : public TextureObjectBase {
|
||||||
@@ -126,8 +112,7 @@ namespace MobileGL {
|
|||||||
void UpdateMipmapSubData(TextureUploadTarget uploadTarget, Uint mipmapLevel, DataPtr input) override;
|
void UpdateMipmapSubData(TextureUploadTarget uploadTarget, Uint mipmapLevel, DataPtr input) override;
|
||||||
void* MapMipmapData(TextureUploadTarget uploadTarget, Uint mipmapLevel) override;
|
void* MapMipmapData(TextureUploadTarget uploadTarget, Uint mipmapLevel) override;
|
||||||
void MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, Bool dirty) override;
|
void MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, Bool dirty) override;
|
||||||
Bool IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const override;
|
bool IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const override;
|
||||||
void ClearAllStorageDirtyBit() override;
|
|
||||||
|
|
||||||
IntVec3 GetBaseSize() const override;
|
IntVec3 GetBaseSize() const override;
|
||||||
Bool IsComplete() const override;
|
Bool IsComplete() const override;
|
||||||
|
|||||||
@@ -42,9 +42,6 @@ namespace MobileGL {
|
|||||||
|
|
||||||
void TextureObject2DCube::MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, bool dirty) {
|
void TextureObject2DCube::MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, bool dirty) {
|
||||||
m_textureStorage.MarkDirty(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, dirty);
|
m_textureStorage.MarkDirty(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, dirty);
|
||||||
if (dirty) {
|
|
||||||
m_dirtyBit.Set(TextureDirtyBit::StorageDirtyBit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextureObject2DCube::IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const {
|
bool TextureObject2DCube::IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const {
|
||||||
@@ -85,17 +82,6 @@ namespace MobileGL {
|
|||||||
// TODO: add more completeness checks based on texture type and mipmap levels
|
// TODO: add more completeness checks based on texture type and mipmap levels
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureObject2DCube::ClearAllStorageDirtyBit() {
|
|
||||||
auto uploadTargetCount = GetUploadTargets().size();
|
|
||||||
auto levelCount = GetMipmapLevelCount();
|
|
||||||
for (SizeT target = 0; target < uploadTargetCount; ++target) {
|
|
||||||
for (Uint level = 0; level < levelCount; ++level) {
|
|
||||||
m_textureStorage.MarkDirty(target, level, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_dirtyBit.Clear(TextureDirtyBit::StorageDirtyBit);
|
|
||||||
}
|
|
||||||
} // namespace GLState
|
} // namespace GLState
|
||||||
} // namespace MG_State
|
} // namespace MG_State
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ namespace MobileGL {
|
|||||||
void* MapMipmapData(TextureUploadTarget uploadTarget, Uint mipmapLevel) override;
|
void* MapMipmapData(TextureUploadTarget uploadTarget, Uint mipmapLevel) override;
|
||||||
void MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, bool dirty) override;
|
void MarkStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, bool dirty) override;
|
||||||
bool IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const override;
|
bool IsStorageDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) const override;
|
||||||
void ClearAllStorageDirtyBit() override;
|
|
||||||
|
|
||||||
IntVec3 GetBaseSize() const override;
|
IntVec3 GetBaseSize() const override;
|
||||||
Bool IsComplete() const override;
|
Bool IsComplete() const override;
|
||||||
|
|||||||
@@ -23,14 +23,6 @@ namespace MobileGL {
|
|||||||
MOBILEGL_ASSERT(target == TextureUploadTarget::TextureBuffer, "Invalid TextureUploadTarget!");
|
MOBILEGL_ASSERT(target == TextureUploadTarget::TextureBuffer, "Invalid TextureUploadTarget!");
|
||||||
return m_bufferBindingSlot;
|
return m_bufferBindingSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureObjectBuffer::ClearAllStorageDirtyBit() {
|
|
||||||
m_dirtyBit.Clear(TextureDirtyBit::StorageDirtyBit);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextureObjectBuffer::SetStorageDirtyBit() {
|
|
||||||
m_dirtyBit.Set(TextureDirtyBit::StorageDirtyBit);
|
|
||||||
}
|
|
||||||
} // namespace GLState
|
} // namespace GLState
|
||||||
} // namespace MG_State
|
} // namespace MG_State
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -20,8 +20,6 @@ namespace MobileGL {
|
|||||||
const Vector<TextureUploadTarget>& GetUploadTargets() const override { return m_uploadTargets; }
|
const Vector<TextureUploadTarget>& GetUploadTargets() const override { return m_uploadTargets; }
|
||||||
BindingSlot<BufferObject>& GetBufferBindingSlot(
|
BindingSlot<BufferObject>& GetBufferBindingSlot(
|
||||||
TextureUploadTarget target = TextureUploadTarget::TextureBuffer);
|
TextureUploadTarget target = TextureUploadTarget::TextureBuffer);
|
||||||
void ClearAllStorageDirtyBit() override;
|
|
||||||
void SetStorageDirtyBit();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
|
Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const override;
|
||||||
|
|||||||
@@ -281,16 +281,6 @@ namespace MobileGL {
|
|||||||
|
|
||||||
Flags(typename Underlying::type b) : flags(b) {}
|
Flags(typename Underlying::type b) : flags(b) {}
|
||||||
|
|
||||||
Flags Set(const Bit b) {
|
|
||||||
flags |= static_cast<typename Underlying::type>(b);
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
Flags Clear(const Bit b) {
|
|
||||||
flags &= ~static_cast<typename Underlying::type>(b);
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flags - Bit
|
// Flags - Bit
|
||||||
Flags operator|(const Bit b) const { return Flags(flags | static_cast<typename Underlying::type>(b)); }
|
Flags operator|(const Bit b) const { return Flags(flags | static_cast<typename Underlying::type>(b)); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user