summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_vdpau.c
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-11-03 21:49:40 +0100
committerNicolai Hähnle <[email protected]>2016-11-04 21:26:29 +0100
commit322483f71b068b3bbf69e5434e888f3fd3f4589e (patch)
tree6e836b6d1187dd859083505797c875d3c5104a57 /src/mesa/state_tracker/st_vdpau.c
parentd0d5f7600c2e8ab8d0c153787185f7a534753edd (diff)
st/mesa: fix the layer of VDPAU surface samplers
A (latent) bug in VDPAU interop was exposed by commit e5cc84dd43be066c1dd418e32f5ad258e31a150a. Before that commit, the st_vdpau code created samplers with first_layer == last_layer == 1 that the general texture handling code would immediately delete and re-create, because the layer does not match the information in the GL texture object. This was correct behavior at least in the DMABUF case, because the imported resource is supposed to have the correct offset already applied. In the non-DMABUF case, this was just plain wrong but apparently nobody noticed. After that commit, the state tracker assumes that an existing sampler is correct at all times. Existing samplers are supposed to be deleted when they may become invalid, and they will be created on-demand. This meant that the sampler with first_layer == last_layer == 1 stuck around, leading to rendering artefacts (on radeonsi), command stream failures (on r600), and assertions (in debug builds everywhere). This patch fixes the problem by simply not creating a sampler at all in st_vdpau_map_surface. We rely on the generic texture code to do the right thing, adding the layer_override to make the non-DMABUF case work. v2: add the layer_override Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98512 Cc: 13.0 <[email protected]> Cc: Christian König <[email protected]> Cc: Ilia Mirkin <[email protected]> Reviewed-by: Marek Olšák <[email protected]> (v1) Reviewed-by: Christian König <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_vdpau.c')
-rw-r--r--src/mesa/state_tracker/st_vdpau.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c
index 79120579ff5..02738153085 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -189,8 +189,8 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
struct st_texture_image *stImage = st_texture_image(texImage);
struct pipe_resource *res;
- struct pipe_sampler_view templ, **sampler_view;
mesa_format texFormat;
+ uint layer_override = 0;
if (output) {
res = st_vdpau_output_surface_dma_buf(ctx, vdpSurface);
@@ -201,8 +201,10 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
} else {
res = st_vdpau_video_surface_dma_buf(ctx, vdpSurface, index);
- if (!res)
+ if (!res) {
res = st_vdpau_video_surface_gallium(ctx, vdpSurface, index);
+ layer_override = index & 1;
+ }
}
if (!res) {
@@ -233,18 +235,8 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
st_texture_release_all_sampler_views(st, stObj);
pipe_resource_reference(&stImage->pt, res);
- u_sampler_view_default_template(&templ, res, res->format);
- templ.u.tex.first_layer = index & 1;
- templ.u.tex.last_layer = index & 1;
- templ.swizzle_r = GET_SWZ(stObj->base._Swizzle, 0);
- templ.swizzle_g = GET_SWZ(stObj->base._Swizzle, 1);
- templ.swizzle_b = GET_SWZ(stObj->base._Swizzle, 2);
- templ.swizzle_a = GET_SWZ(stObj->base._Swizzle, 3);
-
- sampler_view = st_texture_get_sampler_view(st, stObj);
- *sampler_view = st->pipe->create_sampler_view(st->pipe, res, &templ);
-
stObj->surface_format = res->format;
+ stObj->layer_override = layer_override;
_mesa_dirty_texobj(ctx, texObj);
pipe_resource_reference(&res, NULL);
@@ -264,6 +256,8 @@ st_vdpau_unmap_surface(struct gl_context *ctx, GLenum target, GLenum access,
st_texture_release_all_sampler_views(st, stObj);
pipe_resource_reference(&stImage->pt, NULL);
+ stObj->layer_override = 0;
+
_mesa_dirty_texobj(ctx, texObj);
st_flush(st, NULL, 0);