summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/virgl/virgl_screen.c
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2019-04-05 08:13:37 +0200
committerErik Faye-Lund <[email protected]>2019-04-17 07:27:08 +0000
commitfba03322a2977600ea5cd8ca0ca47aced6abf124 (patch)
treebbb9d3ed4c829c7d12e1d6cdba97496f11b841ac /src/gallium/drivers/virgl/virgl_screen.c
parent749bbd39c719a600cd2555932bb47aa73ca42336 (diff)
virgl: get readback-formats from host
Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Gurchetan Singh <[email protected]>
Diffstat (limited to 'src/gallium/drivers/virgl/virgl_screen.c')
-rw-r--r--src/gallium/drivers/virgl/virgl_screen.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index 66fadddc262..65106dbb616 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -531,6 +531,27 @@ virgl_get_compute_param(struct pipe_screen *screen,
}
static boolean
+has_format_bit(struct virgl_supported_format_mask *mask,
+ enum virgl_formats fmt)
+{
+ assert(fmt < VIRGL_FORMAT_MAX);
+ unsigned val = (unsigned)fmt;
+ unsigned idx = val / 32;
+ unsigned bit = val % 32;
+ assert(idx < ARRAY_SIZE(mask->bitmask));
+ return (mask->bitmask[val / 32] & (1u << bit)) != 0;
+}
+
+boolean
+virgl_has_readback_format(struct pipe_screen *screen,
+ enum virgl_formats fmt)
+{
+ struct virgl_screen *vscreen = virgl_screen(screen);
+ return has_format_bit(&vscreen->caps.caps.v2.supported_readback_formats,
+ fmt);
+}
+
+static boolean
virgl_is_vertex_format_supported(struct pipe_screen *screen,
enum pipe_format format)
{
@@ -779,6 +800,24 @@ virgl_destroy_screen(struct pipe_screen *screen)
FREE(vscreen);
}
+static void
+fixup_readback_format(union virgl_caps *caps)
+{
+ const size_t size = ARRAY_SIZE(caps->v2.supported_readback_formats.bitmask);
+ for (int i = 0; i < size; ++i) {
+ if (caps->v2.supported_readback_formats.bitmask[i] != 0)
+ return; /* we got some formats, we definately have a new protocol */
+ }
+
+ /* old protocol used; fall back to considering all sampleable formats valid
+ * readback-formats
+ */
+ for (int i = 0; i < size; ++i) {
+ caps->v2.supported_readback_formats.bitmask[i] =
+ caps->v1.sampler.bitmask[i];
+ }
+}
+
struct pipe_screen *
virgl_create_screen(struct virgl_winsys *vws)
{
@@ -809,6 +848,7 @@ virgl_create_screen(struct virgl_winsys *vws)
virgl_init_screen_resource_functions(&screen->base);
vws->get_caps(vws, &screen->caps);
+ fixup_readback_format(&screen->caps.caps);
screen->refcnt = 1;