Skip to content

Commit 3ffe68d

Browse files
Reduce GPU mem usage / spikes
Change creates a cap for the texture size to increase reuse of textures from the BitmapTexturePool. A fix is also added to account for the depth buffer in the pool usage accounting algorithm.
1 parent 6ba89b2 commit 3ffe68d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ RefPtr<BitmapTexture> BitmapTexturePool::acquireTexture(const IntSize& size, Opt
7070
m_textures.append(Entry(BitmapTexture::create(size, flags)));
7171
selectedEntry = &m_textures.last();
7272
m_poolSize += size.unclampedArea();
73+
74+
if (flags.contains(BitmapTexture::Flags::DepthBuffer))
75+
m_poolSize += size.unclampedArea();
7376
} else
7477
selectedEntry->m_texture->reset(size, flags);
7578

@@ -100,6 +103,10 @@ void BitmapTexturePool::releaseUnusedTexturesTimerFired()
100103
m_textures.removeAllMatching([this, &minUsedTime](const Entry& entry) {
101104
if (entry.canBeReleased(minUsedTime)) {
102105
m_poolSize -= entry.m_texture->size().unclampedArea();
106+
107+
if (entry.m_texture->flags().contains(BitmapTexture::Flags::DepthBuffer))
108+
m_poolSize -= entry.m_texture->size().unclampedArea();
109+
103110
return true;
104111
}
105112
return false;

Source/WebCore/platform/graphics/texmap/TextureMapper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ class TextureMapperGLData {
112112
SharedGLData()
113113
{
114114
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize);
115+
116+
#if PLATFORM(WPE)
117+
// Limit the max texture size to allow textures reuse and reduce GPU mem spikes
118+
if (m_maxTextureSize > 2000)
119+
m_maxTextureSize = 2000;
120+
#endif
115121
}
116122

117123
HashMap<unsigned, RefPtr<TextureMapperShaderProgram>> m_programs;

0 commit comments

Comments
 (0)