virgl: pass virgl transfer to virgl_res_needs_flush_wait

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
This commit is contained in:
Gurchetan Singh
2019-02-08 18:07:37 -08:00
committed by Gert Wollny
parent d98fbd9c92
commit ab6ea6e9ce
5 changed files with 22 additions and 14 deletions
+3 -4
View File
@@ -42,17 +42,16 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
bool readback;
bool doflushwait = false;
trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource,
&vbuf->metadata, level, usage, box);
if (usage & PIPE_TRANSFER_READ)
doflushwait = true;
else
doflushwait = virgl_res_needs_flush_wait(vctx, vbuf, usage);
doflushwait = virgl_res_needs_flush_wait(vctx, trans);
if (doflushwait)
ctx->flush(ctx, NULL, 0);
trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource,
&vbuf->metadata, level, usage, box);
readback = virgl_res_needs_readback(vctx, vbuf, usage, 0);
if (readback)
vs->vws->transfer_get(vs->vws, vbuf->hw_res, box, trans->base.stride,
+10 -1
View File
@@ -524,10 +524,19 @@ void virgl_transfer_inline_write(struct pipe_context *ctx,
struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *vs = virgl_screen(ctx->screen);
struct virgl_resource *grres = virgl_resource(res);
struct virgl_transfer trans = { 0 };
trans.base.resource = res;
trans.base.level = level;
trans.base.usage = usage;
trans.base.box = *box;
trans.base.stride = stride;
trans.base.layer_stride = layer_stride;
trans.offset = box->x;
virgl_resource_dirty(grres, 0);
if (virgl_res_needs_flush_wait(vctx, grres, usage)) {
if (virgl_res_needs_flush_wait(vctx, &trans)) {
ctx->flush(ctx, NULL, 0);
vs->vws->resource_wait(vs->vws, grres->hw_res);
+4 -3
View File
@@ -28,12 +28,13 @@
#include "virgl_screen.h"
bool virgl_res_needs_flush_wait(struct virgl_context *vctx,
struct virgl_resource *res,
unsigned usage)
struct virgl_transfer *trans)
{
struct virgl_screen *vs = virgl_screen(vctx->base.screen);
struct virgl_resource *res = virgl_resource(trans->base.resource);
if ((!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) && vs->vws->res_is_referenced(vs->vws, vctx->cbuf, res->hw_res)) {
if ((!(trans->base.usage & PIPE_TRANSFER_UNSYNCHRONIZED)) &&
vs->vws->res_is_referenced(vs->vws, vctx->cbuf, res->hw_res)) {
return true;
}
return false;
+1 -2
View File
@@ -112,8 +112,7 @@ static inline unsigned pipe_to_virgl_bind(unsigned pbind)
}
bool virgl_res_needs_flush_wait(struct virgl_context *vctx,
struct virgl_resource *res,
unsigned usage);
struct virgl_transfer *transfer);
bool virgl_res_needs_readback(struct virgl_context *vctx,
struct virgl_resource *res,
unsigned usage, unsigned level);
+4 -4
View File
@@ -110,13 +110,13 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
struct virgl_hw_res *hw_res;
bool doflushwait;
doflushwait = virgl_res_needs_flush_wait(vctx, vtex, usage);
if (doflushwait)
ctx->flush(ctx, NULL, 0);
trans = virgl_resource_create_transfer(&vctx->transfer_pool, resource,
&vtex->metadata, level, usage, box);
doflushwait = virgl_res_needs_flush_wait(vctx, trans);
if (doflushwait)
ctx->flush(ctx, NULL, 0);
if (resource->nr_samples > 1) {
struct pipe_resource tmp_resource;
virgl_init_temp_resource_from_box(&tmp_resource, resource, box,