virgl: Add override for BGRA format to use swizzled SRGB format
Tie in the check whether the host supports tweaks and whether this tweak
is enabled.
v2: Add comment about the emulated formats not being used directly in the
guest (Gurchetan)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained 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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user