mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 04:08:32 +09:00
[Perf] (MG_State): answer texture sampling completeness from a memo
Every draw asks, for every bound texture, whether it is mipmap-complete for the filter in use, and the answer was recomputed from scratch each time: walk the level chain, read each level's texel size, verify each is half the previous. With the Minecraft-shaped bench that walk plus the GetTexelSize calls under it measured about 8% of the render thread on both backends. The answer depends only on the texture's shape - internal format, stored level set, level sizes, level range - and never on its texel content, which is the thing that actually changes between draws. A shape version now moves on exactly those four mutations (SetInternalFormat, SetBaseLevel/SetMaxLevel, and the AllocateStorage/TruncateMipmapLevels pair on both mipmap storage classes), and the completeness answer is memoised against it, one slot for the mipmapped question and one for the plain one. An upload leaves the memo standing, which is the whole point; anything that could change the answer invalidates it. ns per draw, DriverBench on a GTX 1660 SUPER (native / Espryt / Magma): mc_vanilla_draw 257 / 2201->2037 / 1550->1346, mc_ubo_range 203 / 1832->1684 / 1089->934, mc_sampler_churn 272 / 2349->2325 / 1533->1396. Texture-upload cases are unchanged, as expected - they were never asking this question in a loop. Unit tests 421/421.
This commit is contained in:
@@ -28,10 +28,12 @@ namespace MobileGL {
|
||||
|
||||
void TextureObject2DCube::AllocateStorage(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
||||
MipmapInput input) {
|
||||
++m_shapeVersion;
|
||||
m_textureStorage.AllocateLevel(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, input);
|
||||
}
|
||||
|
||||
void TextureObject2DCube::TruncateMipmapLevels(TextureUploadTarget uploadTarget, Uint levelCount) {
|
||||
++m_shapeVersion;
|
||||
m_textureStorage.TruncateToLevelCount(GetIndexOfTextureUploadTarget(uploadTarget), levelCount);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user