cso: don't release sampler states that are bound
authorMarek Olšák <marek.olsak@amd.com>
Fri, 2 Dec 2016 14:39:25 +0000 (15:39 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 7 Dec 2016 17:46:54 +0000 (18:46 +0100)
This fixes random radeonsi GPU hangs in Batman Arkham: Origins (Wine) and
probably many other games too.

cso_cache deletes sampler states when the cache size is too big and doesn't
check which sampler states are bound, causing use-after-free in drivers.
Because of that, radeonsi uploaded garbage sampler states and the hardware
went bananas. Other drivers may have experienced similar issues.

Cc: 12.0 13.0 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
src/gallium/auxiliary/cso_cache/cso_cache.c

index b240c938dcc7154abaf4365796e18d09eb8e7a73..1f3be4b28c77db9f09f2386a80da402325342170 100644 (file)
@@ -188,7 +188,9 @@ cso_insert_state(struct cso_cache *sc,
                  void *state)
 {
    struct cso_hash *hash = _cso_hash_for_type(sc, type);
-   sanitize_hash(sc, hash, type, sc->max_size);
+
+   if (type != CSO_SAMPLER)
+      sanitize_hash(sc, hash, type, sc->max_size);
 
    return cso_hash_insert(hash, hash_key, state);
 }