virgl: Support ARB_framebuffer_no_attachments
authorDave Airlie <airlied@redhat.com>
Wed, 18 Jul 2018 19:35:53 +0000 (05:35 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 1 Aug 2018 04:00:35 +0000 (14:00 +1000)
This uses new protocol to send the default sizes to the host.

Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
src/gallium/drivers/virgl/virgl_encode.c
src/gallium/drivers/virgl/virgl_hw.h
src/gallium/drivers/virgl/virgl_protocol.h
src/gallium/drivers/virgl/virgl_screen.c

index 0cb5184d1933b54020274709b50e7680599f608f..670c5fe6c3d767b418c0bc1f153a5d2bb9f677d4 100644 (file)
@@ -350,6 +350,12 @@ int virgl_encoder_set_framebuffer_state(struct virgl_context *ctx,
       virgl_encoder_write_dword(ctx->cbuf, surf ? surf->handle : 0);
    }
 
+   struct virgl_screen *rs = virgl_screen(ctx->base.screen);
+   if (rs->caps.caps.v2.capability_bits & VIRGL_CAP_FB_NO_ATTACH) {
+      virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH, 0, VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_SIZE));
+      virgl_encoder_write_dword(ctx->cbuf, state->width | (state->height << 16));
+      virgl_encoder_write_dword(ctx->cbuf, state->layers | (state->samples << 16));
+   }
    return 0;
 }
 
index d58b347020b5777dc52e733dec4de35240e5b922..3ccc979ac8cf4d4f703cdb82f07f7883a96f1bfc 100644 (file)
@@ -207,6 +207,7 @@ enum virgl_formats {
 #define VIRGL_CAP_TXQS                 (1 << 5)
 #define VIRGL_CAP_MEMORY_BARRIER       (1 << 6)
 #define VIRGL_CAP_COMPUTE_SHADER       (1 << 7)
+#define VIRGL_CAP_FB_NO_ATTACH         (1 << 8)
 
 #define VIRGL_BIND_DEPTH_STENCIL (1 << 0)
 #define VIRGL_BIND_RENDER_TARGET (1 << 1)
index b94b7528c0c7426fe51cfb7e171267830e1f024e..982bc5c8c2bb28f557764db0a134e8f95d756d16 100644 (file)
@@ -90,6 +90,7 @@ enum virgl_context_cmd {
    VIRGL_CCMD_SET_SHADER_IMAGES,
    VIRGL_CCMD_MEMORY_BARRIER,
    VIRGL_CCMD_LAUNCH_GRID,
+   VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH,
 };
 
 /*
@@ -529,4 +530,13 @@ enum virgl_context_cmd {
 #define VIRGL_LAUNCH_INDIRECT_HANDLE 7
 #define VIRGL_LAUNCH_INDIRECT_OFFSET 8
 
+/* framebuffer state no attachment */
+#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_SIZE 2
+#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_WIDTH_HEIGHT 1
+#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_WIDTH(x) (x & 0xffff)
+#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_HEIGHT(x) ((x >> 16) & 0xffff)
+#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_LAYERS_SAMPLES 2
+#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_LAYERS(x) (x & 0xffff)
+#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_SAMPLES(x) ((x >> 16) & 0xff)
+
 #endif
index a2fa2a4dd26039765a721565c8e9fb088e8abe32..223eb6f229bef51741965dc9c62811e16bfcfe05 100644 (file)
@@ -225,6 +225,8 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
       return vscreen->caps.caps.v2.capability_bits & VIRGL_CAP_COPY_IMAGE;
    case PIPE_CAP_TGSI_TXQS:
       return vscreen->caps.caps.v2.capability_bits & VIRGL_CAP_TXQS;
+   case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:
+      return vscreen->caps.caps.v2.capability_bits & VIRGL_CAP_FB_NO_ATTACH;
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_FAKE_SW_MSAA:
@@ -256,7 +258,6 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_PCI_BUS:
    case PIPE_CAP_PCI_DEVICE:
    case PIPE_CAP_PCI_FUNCTION:
-   case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:
    case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR:
    case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
    case PIPE_CAP_TGSI_VOTE:
@@ -579,6 +580,10 @@ virgl_is_format_supported( struct pipe_screen *screen,
       return FALSE;
 
    if (bind & PIPE_BIND_RENDER_TARGET) {
+      /* For ARB_framebuffer_no_attachments. */
+      if (format == PIPE_FORMAT_NONE)
+         return TRUE;
+
       if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS)
          return FALSE;