Browse Source

virgl: pass virgl transfer to virgl_res_needs_flush_wait

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
tags/19.1-branchpoint
Gurchetan Singh 6 years ago
parent
commit
ab6ea6e9ce

+ 3
- 4
src/gallium/drivers/virgl/virgl_buffer.c 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
src/gallium/drivers/virgl/virgl_context.c 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
src/gallium/drivers/virgl/virgl_resource.c 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
src/gallium/drivers/virgl/virgl_resource.h 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
src/gallium/drivers/virgl/virgl_texture.c 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,

Loading…
Cancel
Save