diff options
author | Chia-I Wu <[email protected]> | 2019-05-09 20:40:41 -0700 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2019-05-15 20:51:28 +0000 |
commit | a62ab178cecadae8ead16c0910707c2218e856e7 (patch) | |
tree | b1c29ceb225cf12016fa4379e2013f7cdbc4afd0 /src/gallium/drivers | |
parent | 391a836e8fb1c84170f3aa7550f0b347d31528f3 (diff) |
virgl: clean up virgl_res_needs_readback
Add comments and follow the coding style of virgl_res_needs_flush.
Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/virgl/virgl_resource.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c index 83918f85216..52197b80175 100644 --- a/src/gallium/drivers/virgl/virgl_resource.c +++ b/src/gallium/drivers/virgl/virgl_resource.c @@ -79,16 +79,27 @@ bool virgl_res_needs_flush(struct virgl_context *vctx, return true; } +/* We need to read back from the host storage to make sure the guest storage + * is up-to-date. But there are cases where the readback can be skipped: + * + * - the content can be discarded + * - the host storage is read-only + * + * Note that PIPE_TRANSFER_WRITE without discard bits requires readback. + * PIPE_TRANSFER_READ becomes irrelevant. PIPE_TRANSFER_UNSYNCHRONIZED and + * PIPE_TRANSFER_FLUSH_EXPLICIT are also irrelevant. + */ bool virgl_res_needs_readback(struct virgl_context *vctx, struct virgl_resource *res, unsigned usage, unsigned level) { - bool readback = true; + if (usage & PIPE_TRANSFER_DISCARD_RANGE) + return false; + if (res->clean_mask & (1 << level)) - readback = false; - else if (usage & PIPE_TRANSFER_DISCARD_RANGE) - readback = false; - return readback; + return false; + + return true; } static struct pipe_resource *virgl_resource_create(struct pipe_screen *screen, |