// 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
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. */
#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.
#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;
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,
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;
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)