virgl: check a debug option again at context creation

Android apps commonly use HWUI (a GLES-based UI framework provided by
the system), that generally performs eglInitialize() before the app can
do the same for its custom rendering needs.

If an app is going to set VIRGL_DEBUG to enable case-by-case driver
behaviors (e.g. experimental shader_sync option), it should be checked
again during context creation.

Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22744>
This commit is contained in:
Ryan Neph 2023-04-27 12:02:19 -07:00 committed by Marge Bot
parent 73952bfbfd
commit 551e92d8a6
3 changed files with 27 additions and 12 deletions

View file

@ -1786,6 +1786,20 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
if (rs->caps.caps.v2.capability_bits & VIRGL_CAP_APP_TWEAK_SUPPORT)
virgl_send_tweaks(vctx, rs);
/* On Android, a virgl_screen is generally created first by the HWUI
* service, followed by the application's no-op attempt to do the same with
* eglInitialize(). To retain the ability for apps to set their own driver
* config procedurally right before context creation, we must check the
* envvar again.
*/
#if DETECT_OS_ANDROID
if (!rs->shader_sync) {
uint64_t debug_options = debug_get_flags_option("VIRGL_DEBUG",
virgl_debug_options, 0);
rs->shader_sync |= !!(debug_options & VIRGL_DEBUG_SHADER_SYNC);
}
#endif
return &vctx->base;
fail:
virgl_context_destroy(&vctx->base);

View file

@ -44,18 +44,18 @@
#include "virgl_encode.h"
int virgl_debug = 0;
static const struct debug_named_value virgl_debug_options[] = {
{ "verbose", VIRGL_DEBUG_VERBOSE, NULL },
{ "tgsi", VIRGL_DEBUG_TGSI, NULL },
{ "use_tgsi", VIRGL_DEBUG_USE_TGSI, NULL },
{ "noemubgra", VIRGL_DEBUG_NO_EMULATE_BGRA, "Disable tweak to emulate BGRA as RGBA on GLES hosts"},
{ "nobgraswz", VIRGL_DEBUG_NO_BGRA_DEST_SWIZZLE,"Disable tweak to swizzle emulated BGRA on GLES hosts" },
{ "sync", VIRGL_DEBUG_SYNC, "Sync after every flush" },
{ "xfer", VIRGL_DEBUG_XFER, "Do not optimize for transfers" },
{ "r8srgb-readback", VIRGL_DEBUG_L8_SRGB_ENABLE_READBACK, "Enable redaback for L8 sRGB textures" },
{ "nocoherent", VIRGL_DEBUG_NO_COHERENT, "Disable coherent memory"},
{ "video", VIRGL_DEBUG_VIDEO, "Video codec"},
{ "shader_sync", VIRGL_DEBUG_SHADER_SYNC, "Sync after every shader link"},
const struct debug_named_value virgl_debug_options[] = {
{ "verbose", VIRGL_DEBUG_VERBOSE, NULL },
{ "tgsi", VIRGL_DEBUG_TGSI, NULL },
{ "use_tgsi", VIRGL_DEBUG_USE_TGSI, NULL },
{ "noemubgra", VIRGL_DEBUG_NO_EMULATE_BGRA, "Disable tweak to emulate BGRA as RGBA on GLES hosts" },
{ "nobgraswz", VIRGL_DEBUG_NO_BGRA_DEST_SWIZZLE, "Disable tweak to swizzle emulated BGRA on GLES hosts" },
{ "sync", VIRGL_DEBUG_SYNC, "Sync after every flush" },
{ "xfer", VIRGL_DEBUG_XFER, "Do not optimize for transfers" },
{ "r8srgb-readback", VIRGL_DEBUG_L8_SRGB_ENABLE_READBACK, "Enable redaback for L8 sRGB textures" },
{ "nocoherent", VIRGL_DEBUG_NO_COHERENT, "Disable coherent memory" },
{ "video", VIRGL_DEBUG_VIDEO, "Video codec" },
{ "shader_sync", VIRGL_DEBUG_SHADER_SYNC, "Sync after every shader link" },
DEBUG_NAMED_VALUE_END
};
DEBUG_GET_ONCE_FLAGS_OPTION(virgl_debug, "VIRGL_DEBUG", virgl_debug_options, 0)

View file

@ -44,6 +44,7 @@ enum virgl_debug_flags {
VIRGL_DEBUG_SHADER_SYNC = 1 << 10,
};
extern const struct debug_named_value virgl_debug_options[];
extern int virgl_debug;
struct virgl_screen {