summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/virgl/virgl_driinfo.h.in1
-rw-r--r--src/gallium/drivers/virgl/virgl_hw.h11
-rw-r--r--src/gallium/drivers/virgl/virgl_resource.c10
-rw-r--r--src/gallium/drivers/virgl/virgl_screen.c6
4 files changed, 27 insertions, 1 deletions
diff --git a/src/gallium/drivers/virgl/virgl_driinfo.h.in b/src/gallium/drivers/virgl/virgl_driinfo.h.in
index 626e21c3648..66d547d4712 100644
--- a/src/gallium/drivers/virgl/virgl_driinfo.h.in
+++ b/src/gallium/drivers/virgl/virgl_driinfo.h.in
@@ -7,5 +7,6 @@
// 4. Add the code to send the tweek to the host in virgl_send_tweaks
// 5. Implement the tweak in virglrenderer
DRI_CONF_SECTION_MISCELLANEOUS
+ DRI_CONF_GLES_EMULATE_BGRA("false")
DRI_CONF_SECTION_END
diff --git a/src/gallium/drivers/virgl/virgl_hw.h b/src/gallium/drivers/virgl/virgl_hw.h
index 91e4259abe3..94f5987fe32 100644
--- a/src/gallium/drivers/virgl/virgl_hw.h
+++ b/src/gallium/drivers/virgl/virgl_hw.h
@@ -222,7 +222,12 @@ enum virgl_formats {
VIRGL_FORMAT_A4B4G4R4_UNORM = 311,
VIRGL_FORMAT_R8_SRGB = 312,
- VIRGL_FORMAT_MAX,
+ VIRGL_FORMAT_MAX /* = PIPE_FORMAT_COUNT */,
+
+ /* Below formats must not be used in the guest. */
+ VIRGL_FORMAT_B8G8R8X8_UNORM_EMULATED,
+ VIRGL_FORMAT_B8G8R8A8_UNORM_EMULATED,
+ VIRGL_FORMAT_MAX_EXTENDED
};
/* These are used by the capability_bits field in virgl_caps_v2. */
@@ -256,6 +261,7 @@ enum virgl_formats {
#define VIRGL_CAP_COPY_TRANSFER (1 << 26)
#define VIRGL_CAP_CLIP_HALFZ (1 << 27)
#define VIRGL_CAP_APP_TWEAK_SUPPORT (1 << 28)
+#define VIRGL_CAP_BGRA_SRGB_IS_EMULATED (1 << 29)
/* virgl bind flags - these are compatible with mesa 10.5 gallium.
* but are fixed, no other should be passed to virgl either.
@@ -280,6 +286,9 @@ enum virgl_formats {
#define VIRGL_BIND_STAGING (1 << 19)
#define VIRGL_BIND_SHARED (1 << 20)
+/* Extra flags that may be passed */
+#define VIRGL_BIND_PREFER_EMULATED_BGRA (1 << 21)
+
struct virgl_caps_bool_set1 {
unsigned indep_blend_enable:1;
unsigned indep_blend_func:1;
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c
index 4e585d72490..0659b38c692 100644
--- a/src/gallium/drivers/virgl/virgl_resource.c
+++ b/src/gallium/drivers/virgl/virgl_resource.c
@@ -222,6 +222,16 @@ static struct pipe_resource *virgl_resource_create(struct pipe_screen *screen,
pipe_reference_init(&res->u.b.reference, 1);
vbind = pipe_to_virgl_bind(vs, templ->bind, templ->flags);
virgl_resource_layout(&res->u.b, &res->metadata);
+
+ if ((vs->caps.caps.v2.capability_bits & VIRGL_CAP_APP_TWEAK_SUPPORT) &&
+ vs->tweak_gles_emulate_bgra &&
+ (templ->format == PIPE_FORMAT_B8G8R8A8_SRGB ||
+ templ->format == PIPE_FORMAT_B8G8R8A8_UNORM ||
+ templ->format == PIPE_FORMAT_B8G8R8X8_SRGB ||
+ templ->format == PIPE_FORMAT_B8G8R8X8_UNORM)) {
+ vbind |= VIRGL_BIND_PREFER_EMULATED_BGRA;
+ }
+
res->hw_res = vs->vws->resource_create(vs->vws, templ->target,
templ->format, vbind,
templ->width0,
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index 1baea5d3f19..31de32f9289 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -639,6 +639,8 @@ virgl_is_format_supported( struct pipe_screen *screen,
const struct util_format_description *format_desc;
int i;
+ boolean may_emulate_bgra = false;
+
if (MAX2(1, sample_count) != MAX2(1, storage_sample_count))
return false;
@@ -692,6 +694,10 @@ virgl_is_format_supported( struct pipe_screen *screen,
target == PIPE_TEXTURE_3D)
return FALSE;
+ may_emulate_bgra = (vscreen->caps.caps.v2.capability_bits &
+ VIRGL_CAP_APP_TWEAK_SUPPORT) &&
+ vscreen->tweak_gles_emulate_bgra;
+
if (bind & PIPE_BIND_RENDER_TARGET) {
/* For ARB_framebuffer_no_attachments. */
if (format == PIPE_FORMAT_NONE)