virgl: ARB_texture_barrier support
authorDave Airlie <airlied@redhat.com>
Fri, 3 Aug 2018 05:19:41 +0000 (15:19 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 14 Aug 2018 06:55:56 +0000 (16:55 +1000)
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
docs/features.txt
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
src/gallium/drivers/virgl/virgl_screen.c

index 9d590b181dc829bcea922deed211f2a3c3e8fc5b..800a132e509fff38e9218b9b42b4fbfb7587737b 100644 (file)
@@ -219,7 +219,7 @@ GL 4.5, GLSL 4.50 -- all DONE: nvc0, radeonsi
   GL_ARB_direct_state_access                            DONE (all drivers)
   GL_ARB_get_texture_sub_image                          DONE (all drivers)
   GL_ARB_shader_texture_image_samples                   DONE (i965, nv50, r600, virgl)
-  GL_ARB_texture_barrier                                DONE (freedreno, i965, nv50, r600)
+  GL_ARB_texture_barrier                                DONE (freedreno, i965, nv50, r600, virgl)
   GL_KHR_context_flush_control                          DONE (all - but needs GLX/EGL extension to be useful)
   GL_KHR_robustness                                     DONE (i965)
   GL_EXT_shader_integer_mix                             DONE (all drivers that support GLSL)
index 03c0fd7cd500c8f6db3e3fcaafcc6ccb7423ab0d..dc1dd2d3c2956e9d147663ff45f4dc4700e8720a 100644 (file)
@@ -805,9 +805,14 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
 }
 
 static void
-virgl_texture_barrier(struct pipe_context *pctx, unsigned flags)
+virgl_texture_barrier(struct pipe_context *ctx, unsigned flags)
 {
-   /* stub */
+   struct virgl_context *vctx = virgl_context(ctx);
+   struct virgl_screen *rs = virgl_screen(ctx->screen);
+
+   if (!(rs->caps.caps.v2.capability_bits & VIRGL_CAP_TEXTURE_BARRIER))
+      return;
+   virgl_encode_texture_barrier(vctx, flags);
 }
 
 static void virgl_destroy_sampler_view(struct pipe_context *ctx,
index 670c5fe6c3d767b418c0bc1f153a5d2bb9f677d4..190c338f4584ba7dfd71c4ef70cc59f52b5feb59 100644 (file)
@@ -1009,3 +1009,11 @@ int virgl_encode_launch_grid(struct virgl_context *ctx,
    virgl_encoder_write_dword(ctx->cbuf, grid_info->indirect_offset);
    return 0;
 }
+
+int virgl_encode_texture_barrier(struct virgl_context *ctx,
+                                 unsigned flags)
+{
+   virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_TEXTURE_BARRIER, 0, 1));
+   virgl_encoder_write_dword(ctx->cbuf, flags);
+   return 0;
+}
index c982eb954f367942168385f6e90426fd9627a862..749cd33012041dca635ee5f32e62f443904800f8 100644 (file)
@@ -272,4 +272,6 @@ int virgl_encode_memory_barrier(struct virgl_context *ctx,
                                 unsigned flags);
 int virgl_encode_launch_grid(struct virgl_context *ctx,
                              const struct pipe_grid_info *grid_info);
+int virgl_encode_texture_barrier(struct virgl_context *ctx,
+                                 unsigned flags);
 #endif
index 1df9d0e77d104676f53009c79a5e936d9c564d93..b56f554b0013f3909a5cfc914413df8d5b47e746 100644 (file)
@@ -229,6 +229,7 @@ enum virgl_formats {
 #define VIRGL_CAP_ROBUST_BUFFER_ACCESS (1 << 9)
 #define VIRGL_CAP_TGSI_FBFETCH         (1 << 10)
 #define VIRGL_CAP_SHADER_CLOCK         (1 << 11)
+#define VIRGL_CAP_TEXTURE_BARRIER      (1 << 12)
 
 /* virgl bind flags - these are compatible with mesa 10.5 gallium.
  * but are fixed, no other should be passed to virgl either.
index 982bc5c8c2bb28f557764db0a134e8f95d756d16..0a41c0174f27c4c93c396e5ca5fd91d599f48e32 100644 (file)
@@ -91,6 +91,7 @@ enum virgl_context_cmd {
    VIRGL_CCMD_MEMORY_BARRIER,
    VIRGL_CCMD_LAUNCH_GRID,
    VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH,
+   VIRGL_CCMD_TEXTURE_BARRIER,
 };
 
 /*
@@ -539,4 +540,8 @@ enum virgl_context_cmd {
 #define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_LAYERS(x) (x & 0xffff)
 #define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_SAMPLES(x) ((x >> 16) & 0xff)
 
+/* texture barrier */
+#define VIRGL_TEXTURE_BARRIER_SIZE 1
+#define VIRGL_TEXTURE_BARRIER_FLAGS 1
+
 #endif
index 421fde5249dafd6d3809589724e0c9d0d5e25944..87ce3b7355dfc0f5a13e6bcd74149c977fdf53f2 100644 (file)
@@ -124,7 +124,7 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_CONDITIONAL_RENDER:
       return vscreen->caps.caps.v1.bset.conditional_render;
    case PIPE_CAP_TEXTURE_BARRIER:
-      return 0;
+      return vscreen->caps.caps.v2.capability_bits & VIRGL_CAP_TEXTURE_BARRIER;
    case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
       return 1;
    case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: