virgl: use virgl_resource_dirty helper
authorGurchetan Singh <gurchetansingh@chromium.org>
Sat, 12 Jan 2019 01:29:49 +0000 (17:29 -0800)
committerGert Wollny <gert.wollny@collabora.com>
Fri, 15 Feb 2019 10:19:04 +0000 (11:19 +0100)
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/virgl/virgl_encode.c
src/gallium/drivers/virgl/virgl_query.c
src/gallium/drivers/virgl/virgl_resource.c
src/gallium/drivers/virgl/virgl_resource.h
src/gallium/drivers/virgl/virgl_streamout.c

index 0e4fd5b..d1348f1 100644 (file)
@@ -234,7 +234,7 @@ static struct pipe_surface *virgl_create_surface(struct pipe_context *ctx,
           (util_format_is_srgb(templ->format) ==
            util_format_is_srgb(resource->format)));
 
-   res->clean[0] = FALSE;
+   virgl_resource_dirty(res, 0);
    handle = virgl_object_assign_handle();
    pipe_reference_init(&surf->base.reference, 1);
    pipe_resource_reference(&surf->base.texture, resource);
@@ -521,7 +521,7 @@ void virgl_transfer_inline_write(struct pipe_context *ctx,
    struct virgl_screen *vs = virgl_screen(ctx->screen);
    struct virgl_resource *grres = virgl_resource(res);
 
-   grres->clean[0] = FALSE;
+   virgl_resource_dirty(grres, 0);
 
    if (virgl_res_needs_flush_wait(vctx, grres, usage)) {
       ctx->flush(ctx, NULL, 0);
@@ -975,7 +975,7 @@ static void virgl_resource_copy_region(struct pipe_context *ctx,
    struct virgl_resource *dres = virgl_resource(dst);
    struct virgl_resource *sres = virgl_resource(src);
 
-   dres->clean[0] = FALSE;
+   virgl_resource_dirty(dres, 0);
    virgl_encode_resource_copy_region(vctx, dres,
                                     dst_level, dstx, dsty, dstz,
                                     sres, src_level,
@@ -1000,7 +1000,7 @@ static void virgl_blit(struct pipe_context *ctx,
           (util_format_is_srgb(blit->dst.resource->format) ==
             util_format_is_srgb(blit->dst.format)));
 
-   dres->clean[0] = FALSE;
+   virgl_resource_dirty(dres, 0);
    virgl_encode_blit(vctx, dres, sres,
                     blit);
 }
index b7fa317..6fbefc5 100644 (file)
@@ -61,12 +61,6 @@ static void virgl_encoder_write_res(struct virgl_context *ctx,
    }
 }
 
-static void virgl_dirty_res(struct virgl_resource *res)
-{
-   if (res)
-      res->clean[0] = FALSE;
-}
-
 int virgl_encode_bind_object(struct virgl_context *ctx,
                             uint32_t handle, uint32_t object)
 {
@@ -621,7 +615,7 @@ int virgl_encode_sampler_view(struct virgl_context *ctx,
    if (res->u.b.target == PIPE_BUFFER) {
       virgl_encoder_write_dword(ctx->cbuf, state->u.buf.offset / elem_size);
       virgl_encoder_write_dword(ctx->cbuf, (state->u.buf.offset + state->u.buf.size) / elem_size - 1);
-      virgl_dirty_res(res);
+      virgl_resource_dirty(res, 0);
    } else {
       virgl_encoder_write_dword(ctx->cbuf, state->u.tex.first_layer | state->u.tex.last_layer << 16);
       virgl_encoder_write_dword(ctx->cbuf, state->u.tex.first_level | state->u.tex.last_level << 8);
@@ -956,7 +950,7 @@ int virgl_encode_set_shader_buffers(struct virgl_context *ctx,
          virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_offset);
          virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_size);
          virgl_encoder_write_res(ctx, res);
-         virgl_dirty_res(res);
+         virgl_resource_dirty(res, 0);
       } else {
          virgl_encoder_write_dword(ctx->cbuf, 0);
          virgl_encoder_write_dword(ctx->cbuf, 0);
@@ -980,7 +974,7 @@ int virgl_encode_set_hw_atomic_buffers(struct virgl_context *ctx,
          virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_offset);
          virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_size);
          virgl_encoder_write_res(ctx, res);
-         virgl_dirty_res(res);
+         virgl_resource_dirty(res, 0);
       } else {
          virgl_encoder_write_dword(ctx->cbuf, 0);
          virgl_encoder_write_dword(ctx->cbuf, 0);
@@ -1008,7 +1002,7 @@ int virgl_encode_set_shader_images(struct virgl_context *ctx,
          virgl_encoder_write_dword(ctx->cbuf, images[i].u.buf.offset);
          virgl_encoder_write_dword(ctx->cbuf, images[i].u.buf.size);
          virgl_encoder_write_res(ctx, res);
-         virgl_dirty_res(res);
+         virgl_resource_dirty(res, 0);
       } else {
          virgl_encoder_write_dword(ctx->cbuf, 0);
          virgl_encoder_write_dword(ctx->cbuf, 0);
index 0085cc5..4fc5dd8 100644 (file)
@@ -137,7 +137,7 @@ static boolean virgl_begin_query(struct pipe_context *ctx,
    struct virgl_context *vctx = virgl_context(ctx);
    struct virgl_query *query = virgl_query(q);
 
-   query->buf->clean[0] = FALSE;
+   virgl_resource_dirty(query->buf, 0);
    virgl_encoder_begin_query(vctx, query->handle);
    return true;
 }
index b7dfcac..883dad0 100644 (file)
@@ -278,3 +278,9 @@ boolean virgl_resource_get_handle(struct pipe_screen *screen,
                                        res->metadata.stride[0],
                                        whandle);
 }
+
+void virgl_resource_dirty(struct virgl_resource *res, uint32_t level)
+{
+   if (res)
+      res->clean[0] = FALSE;
+}
index fee630b..3341195 100644 (file)
@@ -137,4 +137,7 @@ void virgl_resource_destroy(struct pipe_screen *screen,
 boolean virgl_resource_get_handle(struct pipe_screen *screen,
                                   struct pipe_resource *resource,
                                   struct winsys_handle *whandle);
+
+void virgl_resource_dirty(struct virgl_resource *res, uint32_t level);
+
 #endif
index a3465e5..a467a6a 100644 (file)
@@ -48,7 +48,7 @@ static struct pipe_stream_output_target *virgl_create_so_target(
    t->base.buffer_offset = buffer_offset;
    t->base.buffer_size = buffer_size;
    t->handle = handle;
-   res->clean[0] = FALSE;
+   virgl_resource_dirty(res, 0);
    virgl_encoder_create_so_target(vctx, handle, res, buffer_offset, buffer_size);
    return &t->base;
 }