virgl: Set sRGB write control CAP based on host capabilities
authorGert Wollny <gert.wollny@collabora.com>
Tue, 13 Nov 2018 10:39:06 +0000 (11:39 +0100)
committerGert Wollny <gert.wollny@collabora.com>
Mon, 28 Jan 2019 11:18:40 +0000 (12:18 +0100)
v2: - Use the renamed CAPS
    - add assetions to make sure that mesa doesn't try to switch
      destination surface formats when it is not supported. (Ilia Mirkin)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/virgl/virgl_hw.h
src/gallium/drivers/virgl/virgl_screen.c

index 6ed4e2f839466d5dd566b54fe31417c3656ff70b..08f85f8574ab67a39b456dcffad2b68bd24a8e6d 100644 (file)
@@ -229,6 +229,11 @@ static struct pipe_surface *virgl_create_surface(struct pipe_context *ctx,
    if (!surf)
       return NULL;
 
+   assert(ctx->screen->get_param(ctx->screen,
+                                 PIPE_CAP_DEST_SURFACE_SRGB_CONTROL) ||
+          (util_format_is_srgb(templ->format) ==
+           util_format_is_srgb(resource->format)));
+
    res->clean = FALSE;
    handle = virgl_object_assign_handle();
    pipe_reference_init(&surf->base.reference, 1);
@@ -990,6 +995,11 @@ static void virgl_blit(struct pipe_context *ctx,
    struct virgl_resource *dres = virgl_resource(blit->dst.resource);
    struct virgl_resource *sres = virgl_resource(blit->src.resource);
 
+   assert(ctx->screen->get_param(ctx->screen,
+                                 PIPE_CAP_DEST_SURFACE_SRGB_CONTROL) ||
+          (util_format_is_srgb(blit->dst.resource->format) ==
+            util_format_is_srgb(blit->dst.format)));
+
    dres->clean = FALSE;
    virgl_encode_blit(vctx, dres, sres,
                     blit);
index e682c750e75cb30a7138696ca628e498c1362f9d..7b4c063f35356a1381c78bcb10a77b9ff151a41a 100644 (file)
@@ -232,6 +232,7 @@ enum virgl_formats {
 #define VIRGL_CAP_TEXTURE_BARRIER      (1 << 12)
 #define VIRGL_CAP_TGSI_COMPONENTS      (1 << 13)
 #define VIRGL_CAP_GUEST_MAY_INIT_LOG   (1 << 14)
+#define VIRGL_CAP_SRGB_WRITE_CONTROL   (1 << 15)
 
 /* virgl bind flags - these are compatible with mesa 10.5 gallium.
  * but are fixed, no other should be passed to virgl either.
index ef9af21acf0e1160171db92f504ca23f762280f1..42e0987e0c9928fed9ac755845792ac6e33752b5 100644 (file)
@@ -342,6 +342,8 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
       return 0;
    case PIPE_CAP_NATIVE_FENCE_FD:
       return vscreen->vws->supports_fences;
+   case PIPE_CAP_DEST_SURFACE_SRGB_CONTROL:
+      return vscreen->caps.caps.v2.capability_bits & VIRGL_CAP_SRGB_WRITE_CONTROL;
    default:
       return u_pipe_screen_get_param_defaults(screen, param);
    }