diff options
author | Alexandros Frantzis <[email protected]> | 2019-06-04 16:40:33 +0300 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2019-06-07 21:45:20 -0700 |
commit | 8eb8222c102ee6cd38a01e7df952ea87e1ca4f42 (patch) | |
tree | 526c56871cdaa5fa697227e1553ad3af58afcef8 /src/gallium/winsys/virgl/vtest | |
parent | e0ffcdf16a61a41f2a2e4e2c0dca94cf506ba17e (diff) |
virgl: Deduplicate checks for resource caching
Also fixes a missed check for VIRGL_BIND_CUSTOM in one of the duplicate
code snippets.
Note that legacy fences also use VIRGL_BIND_CUSTOM, but we ensured they
don't go through the cache in the previous commit.
Signed-off-by: Alexandros Frantzis <[email protected]>
Reviewed-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/gallium/winsys/virgl/vtest')
-rw-r--r-- | src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c | 16 | ||||
-rw-r--r-- | src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h | 1 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c index 0273d96f0dc..ccacb81d233 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c @@ -37,9 +37,12 @@ static void *virgl_vtest_resource_map(struct virgl_winsys *vws, static void virgl_vtest_resource_unmap(struct virgl_winsys *vws, struct virgl_hw_res *res); -static inline boolean can_cache_resource(struct virgl_hw_res *res) +static inline boolean can_cache_resource_with_bind(uint32_t bind) { - return res->cacheable == TRUE; + return bind == VIRGL_BIND_CONSTANT_BUFFER || + bind == VIRGL_BIND_INDEX_BUFFER || + bind == VIRGL_BIND_VERTEX_BUFFER || + bind == VIRGL_BIND_CUSTOM; } static uint32_t vtest_get_transfer_size(struct virgl_hw_res *res, @@ -242,7 +245,7 @@ static void virgl_vtest_resource_reference(struct virgl_vtest_winsys *vtws, { struct virgl_hw_res *old = *dres; if (pipe_reference(&(*dres)->reference, &sres->reference)) { - if (!can_cache_resource(old)) { + if (!can_cache_resource_with_bind(old->bind)) { virgl_hw_res_destroy(vtws, old); } else { mtx_lock(&vtws->mutex); @@ -419,9 +422,7 @@ virgl_vtest_winsys_resource_cache_create(struct virgl_winsys *vws, int64_t now; int ret = -1; - /* only store binds for vertex/index/const buffers */ - if (bind != VIRGL_BIND_CONSTANT_BUFFER && bind != VIRGL_BIND_INDEX_BUFFER && - bind != VIRGL_BIND_VERTEX_BUFFER && bind != VIRGL_BIND_CUSTOM) + if (!can_cache_resource_with_bind(bind)) goto alloc; mtx_lock(&vtws->mutex); @@ -478,9 +479,6 @@ alloc: res = virgl_vtest_winsys_resource_create(vws, target, format, bind, width, height, depth, array_size, last_level, nr_samples, size); - if (bind == VIRGL_BIND_CONSTANT_BUFFER || bind == VIRGL_BIND_INDEX_BUFFER || - bind == VIRGL_BIND_VERTEX_BUFFER) - res->cacheable = TRUE; return res; } diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h index c6b1589d7db..2a600f6a49c 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h @@ -71,7 +71,6 @@ struct virgl_hw_res { struct list_head head; uint32_t bind; - boolean cacheable; int64_t start, end; }; |