virgl: add memory barrier support
authorDave Airlie <airlied@redhat.com>
Wed, 18 Jul 2018 03:37:49 +0000 (13:37 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 31 Jul 2018 22:02:35 +0000 (08:02 +1000)
Reviwed-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_encode.h
src/gallium/drivers/virgl/virgl_hw.h
src/gallium/drivers/virgl/virgl_protocol.h

index 41ba853805bef4375f7faaea5fcfe7486eaabdab..d224b68cfcd6e79529bf656236302bd7e73ad27b 100644 (file)
@@ -997,6 +997,17 @@ static void virgl_set_shader_images(struct pipe_context *ctx,
    virgl_encode_set_shader_images(vctx, shader, start_slot, count, images);
 }
 
+static void virgl_memory_barrier(struct pipe_context *ctx,
+                                 unsigned flags)
+{
+   struct virgl_context *vctx = virgl_context(ctx);
+   struct virgl_screen *rs = virgl_screen(ctx->screen);
+
+   if (!(rs->caps.caps.v2.capability_bits & VIRGL_CAP_MEMORY_BARRIER))
+      return;
+   virgl_encode_memory_barrier(vctx, flags);
+}
+
 static void
 virgl_context_destroy( struct pipe_context *ctx )
 {
@@ -1136,6 +1147,8 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
 
    vctx->base.set_shader_buffers = virgl_set_shader_buffers;
    vctx->base.set_shader_images = virgl_set_shader_images;
+   vctx->base.memory_barrier = virgl_memory_barrier;
+
    virgl_init_context_resource_functions(&vctx->base);
    virgl_init_query_functions(vctx);
    virgl_init_so_functions(vctx);
index 68ec5a1dc9d36359765a7c02821fa2286a5c6a4c..1d193ae6c7f7aafe2bb7f0bf87c34a99df88f17b 100644 (file)
@@ -972,3 +972,11 @@ int virgl_encode_set_shader_images(struct virgl_context *ctx,
    }
    return 0;
 }
+
+int virgl_encode_memory_barrier(struct virgl_context *ctx,
+                                unsigned flags)
+{
+   virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_MEMORY_BARRIER, 0, 1));
+   virgl_encoder_write_dword(ctx->cbuf, flags);
+   return 0;
+}
index a45c0ac4c6b04830afee8710dae8bbf2e0901407..e353c3d04d51031cb8689da8eaf90e1815f67173 100644 (file)
@@ -267,4 +267,6 @@ int virgl_encode_set_shader_images(struct virgl_context *ctx,
                                    enum pipe_shader_type shader,
                                    unsigned start_slot, unsigned count,
                                    const struct pipe_image_view *images);
+int virgl_encode_memory_barrier(struct virgl_context *ctx,
+                                unsigned flags);
 #endif
index 01baf05e6d473d8b064a9b6d8cbf4dad5d515d26..6bb11f6598a21fef69ad4d0fb21511f1af631468 100644 (file)
@@ -205,6 +205,7 @@ enum virgl_formats {
 #define VIRGL_CAP_COPY_IMAGE           (1 << 3)
 #define VIRGL_CAP_TGSI_PRECISE         (1 << 4)
 #define VIRGL_CAP_TXQS                 (1 << 5)
+#define VIRGL_CAP_MEMORY_BARRIER       (1 << 6)
 
 #define VIRGL_BIND_DEPTH_STENCIL (1 << 0)
 #define VIRGL_BIND_RENDER_TARGET (1 << 1)
index cdd534ff2435b0eeabe8905104bae446b56f5eda..0c38b1fc2edbe88facb99e033bf46330ee9a394c 100644 (file)
@@ -88,6 +88,7 @@ enum virgl_context_cmd {
    VIRGL_CCMD_SET_MIN_SAMPLES,
    VIRGL_CCMD_SET_SHADER_BUFFERS,
    VIRGL_CCMD_SET_SHADER_IMAGES,
+   VIRGL_CCMD_MEMORY_BARRIER,
 };
 
 /*
@@ -513,4 +514,8 @@ enum virgl_context_cmd {
 #define VIRGL_SET_SHADER_IMAGE_LEVEL_SIZE(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 6)
 #define VIRGL_SET_SHADER_IMAGE_RES_HANDLE(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 7)
 
+/* memory barrier */
+#define VIRGL_MEMORY_BARRIER_SIZE 1
+#define VIRGL_MEMORY_BARRIER_FLAGS 1
+
 #endif