Hi guys,

recently some XBMC users complained about crashes with the relatively new NV_vdpau_interop support.

That turned out to be a problem with how st_atom_texture.c caches the sampler view for a texture. Since the texture in question is shared between two GLX contexts the pipe object the sampler view was originally created for doesn't necessary match the pipe object it is used with.

Now my question is am I missing something or is this case really not correctly supported? Where is the check if a texture is used in more than one context? The attached patch fixes the issue, but I'm not sure if it is the right approach.

Please comment,
Christian.
>From 01e3097fcdaf0bb242dd6db334292be4d73f26be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koe...@amd.com>
Date: Sat, 22 Mar 2014 21:30:07 +0100
Subject: [PATCH] st/mesa: recreate sampler view on context change
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

With shared glx contexts it is possible that a texture is create and used
in one context and then used in another one resulting in incorrect
sampler view usage.

Signed-off-by: Christian König <christian.koe...@amd.com>
---
 src/mesa/state_tracker/st_atom_texture.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 3557a3f..50e5905 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -198,6 +198,12 @@ st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
    if (!stObj->sampler_view) {
       stObj->sampler_view =
          st_create_texture_sampler_view_from_stobj(pipe, stObj, samp, format);
+
+   } else if (stObj->sampler_view->context != pipe) {
+      /* Recreate view in correct context, use existing view as template */
+      struct pipe_sampler_view templ = *stObj->sampler_view;
+      pipe_sampler_view_reference(&stObj->sampler_view, NULL);
+      stObj->sampler_view = pipe->create_sampler_view(pipe, stObj->pt, &templ);
    }
 
    return stObj->sampler_view;
-- 
1.9.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to