virgl: Add a tweak to set the value for emulated queries of GL_SAMPLES_PASSED
authorGert Wollny <gert.wollny@collabora.com>
Mon, 27 May 2019 14:38:14 +0000 (16:38 +0200)
committerGert Wollny <gert.wollny@collabora.com>
Thu, 20 Jun 2019 06:50:38 +0000 (08:50 +0200)
On GLES hosts GL_SAMPLES_PASSED is emulated by GL_ANY_SAMPLES_PASSED which returns a boolen.
With this tweak the value that is returned if any sample passed can be set. This
may be of iterest when an application decides whether some geometry is rendered based
on an amount of visibility and not just a binary desicion. virgelrenderer sets a default
of 1024 on th host.

v2: Remove reference from virgl and correct description (Emil)
v3: Send the tweak binary encoded instead of using strings (Gurchetan)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/virgl/virgl_driinfo.h.in
src/gallium/drivers/virgl/virgl_protocol.h
src/gallium/drivers/virgl/virgl_screen.c
src/gallium/drivers/virgl/virgl_screen.h
src/util/xmlpool/t_options.h

index 5f6437886642160e6dc8bfe753957e8a1581f417..987cdc38be2bc74c28aba36efa395ed5928aa2a0 100644 (file)
@@ -1409,6 +1409,10 @@ static void virgl_send_tweaks(struct virgl_context *vctx, struct virgl_screen *r
 
    if (rs->tweak_gles_apply_bgra_dest_swizzle)
       virgl_encode_tweak(vctx, virgl_tweak_gles_brga_apply_dest_swizzle, 1);
+
+   if (rs->tweak_gles_tf3_value > 0)
+      virgl_encode_tweak(vctx, virgl_tweak_gles_tf3_samples_passes_multiplier,
+                         rs->tweak_gles_tf3_value);
 }
 
 struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
index d6162b3f39a3ee055717364dd8f35e5a437bf796..cbb0bc5a77b35fd2965a4cfd6c435c97e7013c6a 100644 (file)
@@ -9,5 +9,5 @@
 DRI_CONF_SECTION_MISCELLANEOUS
     DRI_CONF_GLES_EMULATE_BGRA("false")
     DRI_CONF_GLES_APPLY_BGRA_DEST_SWIZZLE("false")
+    DRI_CONF_GLES_SAMPLES_PASSED_VALUE(int, 1024, "1:400000000")
 DRI_CONF_SECTION_END
-
index 73795a8a7cdee6cd4bb1168ea4d5f4c637ba2093..d14caa292b31d3b5f13b624ae44db64ef9e74f6f 100644 (file)
@@ -594,6 +594,7 @@ enum virgl_context_cmd {
 enum vrend_tweak_type {
    virgl_tweak_gles_brga_emulate,
    virgl_tweak_gles_brga_apply_dest_swizzle,
+   virgl_tweak_gles_tf3_samples_passes_multiplier,
    virgl_tweak_undefined
 };
 
index e96a10ffbc70b8bd6262cc93143e595a60aff39c..be684dbf3c14b9ea0fc11bdf5f02cebdb761304e 100644 (file)
@@ -856,6 +856,8 @@ virgl_create_screen(struct virgl_winsys *vws, const struct pipe_screen_config *c
 
    const char *VIRGL_GLES_EMULATE_BGRA = "gles_emulate_bgra";
    const char *VIRGL_GLES_APPLY_BGRA_DEST_SWIZZLE = "gles_apply_bgra_dest_swizzle";
+   const char *VIRGL_GLES_SAMPLES_PASSED_VALUE = "gles_samples_passed_value";
+
    if (!screen)
       return NULL;
 
@@ -866,7 +868,10 @@ virgl_create_screen(struct virgl_winsys *vws, const struct pipe_screen_config *c
             driQueryOptionb(config->options, VIRGL_GLES_EMULATE_BGRA);
       screen->tweak_gles_apply_bgra_dest_swizzle =
             driQueryOptionb(config->options, VIRGL_GLES_APPLY_BGRA_DEST_SWIZZLE);
+      screen->tweak_gles_tf3_value =
+            driQueryOptioni(config->options, VIRGL_GLES_SAMPLES_PASSED_VALUE);
    }
+
    screen->vws = vws;
    screen->base.get_name = virgl_get_name;
    screen->base.get_vendor = virgl_get_vendor;
index 89b06a25e3569a34cf9ece97e9661120a8f12d17..089402d576dd0fc6c1f7d41b5fa9f9a8400f722c 100644 (file)
@@ -48,6 +48,7 @@ struct virgl_screen {
    uint32_t sub_ctx_id;
    bool tweak_gles_emulate_bgra;
    bool tweak_gles_apply_bgra_dest_swizzle;
+   int32_t tweak_gles_tf3_value;
 };
 
 
index 2abd2dd0fc4174d9ec5ede054c7a777051b1f2c5..43f397b30f6275671ee65596f7510255d5af8dc1 100644 (file)
@@ -374,3 +374,8 @@ DRI_CONF_OPT_END
 DRI_CONF_OPT_BEGIN_B(gles_apply_bgra_dest_swizzle, def) \
         DRI_CONF_DESC(en,gettext("When the BGRA formats are emulated by using swizzled RGBA formats on GLES apply the swizzle when writing")) \
 DRI_CONF_OPT_END
+
+#define DRI_CONF_GLES_SAMPLES_PASSED_VALUE(def, minimum, maximum) \
+DRI_CONF_OPT_BEGIN_V(gles_samples_passed_value, def, minimum, maximum) \
+        DRI_CONF_DESC(en,gettext("GL_SAMPLES_PASSED value when emulated by GL_ANY_SAMPLES_PASSED")) \
+DRI_CONF_OPT_END