From e3683f0fbd5a58afb5e6b5b7068e3354487d0242 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Tue, 30 Jul 2019 17:54:45 -0700 Subject: [PATCH] vrend: also report scanout formats to the guest It's good to tell the guest about these formats. v2: move this check with the rest of the v2 caps remove host version check bump (@kusma) Reviewed-by: David Riley Signed-off-by: Gurchetan Singh --- src/virgl_hw.h | 1 + src/vrend_renderer.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/virgl_hw.h b/src/virgl_hw.h index 94e1d5e..d966093 100644 --- a/src/virgl_hw.h +++ b/src/virgl_hw.h @@ -398,6 +398,7 @@ struct virgl_caps_v2 { uint32_t max_combined_atomic_counter_buffers; uint32_t host_feature_check_version; struct virgl_supported_format_mask supported_readback_formats; + struct virgl_supported_format_mask scanout; }; union virgl_caps { diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index ba807c5..570fc86 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -686,6 +686,19 @@ static inline bool vrend_format_is_ds(enum virgl_formats format) return tex_conv_table[format].bindings & VIRGL_BIND_DEPTH_STENCIL; } +static inline bool vrend_format_can_scanout(enum virgl_formats format) +{ +#ifdef ENABLE_GBM_ALLOCATION + uint32_t gbm_format = virgl_gbm_convert_format(format); + if (!gbm_format) + return false; + + return gbm_device_is_format_supported(gbm->device, gbm_format, GBM_BO_USE_SCANOUT); +#else + return true; +#endif +} + struct vrend_context_tweaks *vrend_get_context_tweaks(struct vrend_context *ctx) { return &ctx->sub->tweaks; @@ -9461,14 +9474,17 @@ static void vrend_renderer_fill_caps_v2(int gl_ver, int gles_ver, union virgl_c caps->v2.capability_bits |= VIRGL_CAP_INDIRECT_PARAMS; for (int i = 0; i < VIRGL_FORMAT_MAX; i++) { + enum virgl_formats fmt = (enum virgl_formats)i; if (tex_conv_table[i].internalformat != 0) { - enum virgl_formats fmt = (enum virgl_formats)i; if (vrend_format_can_readback(fmt)) { VREND_DEBUG(dbg_features, NULL, "Support readback of %s\n", util_format_name(fmt)); set_format_bit(&caps->v2.supported_readback_formats, fmt); } } + + if (vrend_format_can_scanout(fmt)) + set_format_bit(&caps->v2.scanout, fmt); } if (has_feature(feat_clip_control))