virgl: add support for missing command buffer binding.
authorDave Airlie <airlied@redhat.com>
Mon, 11 Feb 2019 02:53:38 +0000 (12:53 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 9 Apr 2019 04:15:12 +0000 (14:15 +1000)
When I added indirect support I forgot this, however to use it
now we need to check for a new enough capability on the host side.

Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
src/gallium/drivers/virgl/virgl_hw.h
src/gallium/drivers/virgl/virgl_resource.c
src/gallium/drivers/virgl/virgl_resource.h

index 7038f3973d9d556677007d62f97515f474ec2423..e193752c498c95fc45d23ab0de47299bad0b0074 100644 (file)
@@ -237,6 +237,7 @@ enum virgl_formats {
 #define VIRGL_CAP_TRANSFER             (1 << 17)
 #define VIRGL_CAP_FBO_MIXED_COLOR_FORMATS (1 << 18)
 #define VIRGL_CAP_FAKE_FP64            (1 << 19)
+#define VIRGL_CAP_BIND_COMMAND_ARGS    (1 << 20)
 #define VIRGL_CAP_TRANSFORM_FEEDBACK3  (1 << 23)
 
 /* virgl bind flags - these are compatible with mesa 10.5 gallium.
@@ -249,6 +250,7 @@ enum virgl_formats {
 #define VIRGL_BIND_INDEX_BUFFER  (1 << 5)
 #define VIRGL_BIND_CONSTANT_BUFFER (1 << 6)
 #define VIRGL_BIND_DISPLAY_TARGET (1 << 7)
+#define VIRGL_BIND_COMMAND_ARGS  (1 << 8)
 #define VIRGL_BIND_STREAM_OUTPUT (1 << 11)
 #define VIRGL_BIND_SHADER_BUFFER (1 << 14)
 #define VIRGL_BIND_QUERY_BUFFER  (1 << 15)
index 7aef1dfdd23b13f1ffc7ba498905098f09946fc1..5f0040c1db1c50b7d01d1a2e5f6c0fd9eb28255b 100644 (file)
@@ -72,7 +72,7 @@ static struct pipe_resource *virgl_resource_create(struct pipe_screen *screen,
    res->u.b = *templ;
    res->u.b.screen = &vs->base;
    pipe_reference_init(&res->u.b.reference, 1);
-   vbind = pipe_to_virgl_bind(templ->bind);
+   vbind = pipe_to_virgl_bind(vs, templ->bind);
    virgl_resource_layout(&res->u.b, &res->metadata);
    res->hw_res = vs->vws->resource_create(vs->vws, templ->target,
                                           templ->format, vbind,
index a60987c5b86209dfde179c9ee0e1740177b752b4..f127d45cff1d4854c03d2c0212fe05a302c64654 100644 (file)
@@ -30,6 +30,7 @@
 #include "util/u_transfer.h"
 
 #include "virgl_hw.h"
+#include "virgl_screen.h"
 #define VR_MAX_TEXTURE_2D_LEVELS 15
 
 struct winsys_handle;
@@ -80,7 +81,7 @@ static inline struct virgl_transfer *virgl_transfer(struct pipe_transfer *trans)
 
 void virgl_buffer_init(struct virgl_resource *res);
 
-static inline unsigned pipe_to_virgl_bind(unsigned pbind)
+static inline unsigned pipe_to_virgl_bind(const struct virgl_screen *vs, unsigned pbind)
 {
    unsigned outbind = 0;
    if (pbind & PIPE_BIND_DEPTH_STENCIL)
@@ -108,7 +109,10 @@ static inline unsigned pipe_to_virgl_bind(unsigned pbind)
    if (pbind & PIPE_BIND_SHADER_BUFFER)
       outbind |= VIRGL_BIND_SHADER_BUFFER;
    if (pbind & PIPE_BIND_QUERY_BUFFER)
-     outbind |= VIRGL_BIND_QUERY_BUFFER;
+      outbind |= VIRGL_BIND_QUERY_BUFFER;
+   if (pbind & PIPE_BIND_COMMAND_ARGS_BUFFER)
+      if (vs->caps.caps.v2.capability_bits & VIRGL_CAP_BIND_COMMAND_ARGS)
+         outbind |= VIRGL_BIND_COMMAND_ARGS;
    return outbind;
 }