diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index ba831ca3fb7..8d6f4a77409 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -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); diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c index 6acaa38e7c2..679b6dfe6d5 100644 --- a/src/gallium/drivers/virgl/virgl_screen.c +++ b/src/gallium/drivers/virgl/virgl_screen.c @@ -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) diff --git a/src/gallium/drivers/virgl/virgl_screen.h b/src/gallium/drivers/virgl/virgl_screen.h index 7b32e3d8294..491d7202eb5 100644 --- a/src/gallium/drivers/virgl/virgl_screen.h +++ b/src/gallium/drivers/virgl/virgl_screen.h @@ -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 {