mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
gpu: reclaim stale images in atlas texture before resizing
Issue found by Anthony Starks. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+11
-3
@@ -267,6 +267,7 @@ func (g *compute) uploadImages(ops []imageOp) error {
|
|||||||
a := &g.atlas
|
a := &g.atlas
|
||||||
var uploads map[interface{}]*image.RGBA
|
var uploads map[interface{}]*image.RGBA
|
||||||
resize := false
|
resize := false
|
||||||
|
reclaimed := false
|
||||||
restart:
|
restart:
|
||||||
for {
|
for {
|
||||||
for _, op := range ops {
|
for _, op := range ops {
|
||||||
@@ -284,12 +285,19 @@ restart:
|
|||||||
a.positions = nil
|
a.positions = nil
|
||||||
uploads = nil
|
uploads = nil
|
||||||
a.packer = packer{
|
a.packer = packer{
|
||||||
maxDim: maxDim + 256,
|
maxDim: maxDim,
|
||||||
}
|
}
|
||||||
if maxDim > g.maxTextureDim {
|
if !reclaimed {
|
||||||
|
// Some images may no longer be in use, try again
|
||||||
|
// after clearing existing maps.
|
||||||
|
reclaimed = true
|
||||||
|
} else {
|
||||||
|
a.packer.maxDim += 256
|
||||||
|
resize = true
|
||||||
|
if a.packer.maxDim > g.maxTextureDim {
|
||||||
return errors.New("compute: no space left in atlas texture")
|
return errors.New("compute: no space left in atlas texture")
|
||||||
}
|
}
|
||||||
resize = true
|
}
|
||||||
a.packer.newPage()
|
a.packer.newPage()
|
||||||
continue restart
|
continue restart
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user