Files
test/source
Jason Fielder 658700ddff Fix #126364: Metal: modified texture usage flags causing cache misses
For Metal we can change the texture usage flags to get more optimal
behaviour - one example is adding the attachment flag so we can utilise
renders to do texture clears. However these usage flags are used as the
part of the match-criteria when trying to reuse released textures in
the texture pool.

The modifications means a request for the same type of texture will
fail causing a cache miss. When we render to an
image-view the texture pool is not released until the final sample has
been rendered as we consider the entire render to be a single frame
(as opposed to normal viewport rendering when we are presenting the
intermediate results).

This causes the texture pool to grow and grow and grow hence the large
memory usage. This fix splits the usage flags
into two sets, the internal ones we use to create the MTLTexture (which
we may modify) and the originally requested ones. The originally requested
ones are used for the texture pool matching.

This fix also improves memory efficiency for normal viewport rendering.

Mr Elephant Scene
Before -> After
Load scene in viewport: 13.04Gb ->  9.15 Gb
Viewport Render Image: 78.69Gb -> 16.61Gb

Authored by Apple: James McCarthy

Pull Request: https://projects.blender.org/blender/blender/pulls/129951
2024-11-07 15:53:09 +01:00
..