# metal renderer: Increase instance buffer size dynamically \(\#11849\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/43d79af94a5224356b236a266c598a65e375b4f9)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 43d79af94a5224356b236a266c598a65e375b4f9

Requested commit: 43d79af94a5224356b236a266c598a65e375b4f9

Commit: 43d79af94a5224356b236a266c598a65e375b4f9

Tree: e1f5f808d46035f84e10ccdf028fcf5fad8a7fc4

Author: Thorsten Ball

Committer: GitHub

## Message

```
metal renderer: Increase instance buffer size dynamically (#11849)

Previously, we had an instance buffer pool that could only allocate
buffers with a fixed size (hardcoded to 2mb). This caused certain scenes
to render partially, e.g. when showing tens of thousands of glyphs on a
big screen.

With this commit, when `MetalRenderer` detects that a scene would be too
large to render using the current instance buffer size, it will:

- Clear the existing instance buffers
- Allocate new instance buffers that are twice as large
- Retry rendering the scene that failed with the newly-allocated buffers
during the same frame.

This fixes #11615.

Release Notes:

- Fixed rendering issues that could arise when having large amounts of
text displayed on a large display. Fixed by dynamically increasing the
size of the buffers used on the GPU.
([#11615](https://github.com/zed-industries/zed/issues/11615)).

Before:


https://github.com/zed-industries/zed/assets/1185253/464463be-b61c-4149-a417-01701699decb


After:



https://github.com/zed-industries/zed/assets/1185253/4feacf5a-d862-4a6b-90b8-317ac74e9851

Co-authored-by: Antonio <me@as-cii.com>
```

## Parents

- [26ffdaffe2b36ee955c721afac1a19011577d234](https://git.cafe/gitcafe/zed/commit/26ffdaffe2b36ee955c721afac1a19011577d234?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/43d79af94a5224356b236a266c598a65e375b4f9?format=markdown)
