From: Dave Airlie Date: Wed, 18 Jul 2018 19:35:53 +0000 (+1000) Subject: virgl: Support ARB_framebuffer_no_attachments X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2df8b80c4c4842ef80d8b80f1fed53e75a82645d;p=mesa.git virgl: Support ARB_framebuffer_no_attachments This uses new protocol to send the default sizes to the host. Reviewed-by: Gurchetan Singh --- diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index 0cb5184d193..670c5fe6c3d 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -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; } diff --git a/src/gallium/drivers/virgl/virgl_hw.h b/src/gallium/drivers/virgl/virgl_hw.h index d58b347020b..3ccc979ac8c 100644 --- a/src/gallium/drivers/virgl/virgl_hw.h +++ b/src/gallium/drivers/virgl/virgl_hw.h @@ -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) diff --git a/src/gallium/drivers/virgl/virgl_protocol.h b/src/gallium/drivers/virgl/virgl_protocol.h index b94b7528c0c..982bc5c8c2b 100644 --- a/src/gallium/drivers/virgl/virgl_protocol.h +++ b/src/gallium/drivers/virgl/virgl_protocol.h @@ -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 diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c index a2fa2a4dd26..223eb6f229b 100644 --- a/src/gallium/drivers/virgl/virgl_screen.c +++ b/src/gallium/drivers/virgl/virgl_screen.c @@ -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;