aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Neph <ryanneph@google.com>2024-02-28 18:24:36 -0800
committerMarge Bot <emma+marge@anholt.net>2024-03-05 21:18:24 +0000
commitd9c002fac153b834a2c17731f2b85c36e333e102 (patch)
tree7110cd036e695747228b399d203ce659ca7707cd
parent69495348d1d6d8ea69488463c5c42b809f309d8b (diff)
downloadvirglrenderer-d9c002fac153b834a2c17731f2b85c36e333e102.tar.gz
vrend: workaround non-conformant sampler view pattern
Works around a rendering artifact in clients that are presumed to be relying on implementation-defined behavior when sampling the alpha channel of imported textures without one. Do the simplest thing and pass the implementation-defined behavior decision to the native host driver. Signed-off-by: Ryan Neph <ryanneph@google.com> Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1344>
-rw-r--r--src/vrend_renderer.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index afa934cf..56083e12 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -2830,6 +2830,20 @@ int vrend_create_sampler_view(struct vrend_context *ctx,
view->gl_swizzle[2] = temp;
}
+ // Workaround for clients that attempt this non-spec-conformant (or at
+ // least non-spec-defined) behavior. Gallium seems to allow this for
+ // internally-allocated textures, but textures imported from dmabuf take
+ // a different path that imposes stricter enforcement of allowable
+ // internalformat for glTextureView().
+
+ if (util_format_has_alpha(view->format) &&
+ vrend_resource_has_24bpp_internal_format(view->texture)) {
+ VREND_DEBUG(dbg_tex, ctx, "Fixing view with alpha into EGL-backed texture without alpha (format: %s, view: %s)\n",
+ util_format_name(view->texture->base.format),
+ util_format_name(view->format));
+ internalformat = GL_RGB8;
+ }
+
glTextureView(view->gl_id, view->target, view->texture->gl_id, internalformat,
view->u.tex.first_level, view->levels,
view->u.tex.first_layer, num_layers);