Re: [Mesa3d-dev] [PATCH 2/4] [egl_g3d] Cache DRI2 textures and don't recreate them if the name is the same

2010-01-11 Thread Luca Barbieri
> This looks good.  Do you mind re-create this patch without the
> dependency on the depth/stencil patch?
OK.

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev


Re: [Mesa3d-dev] [PATCH 2/4] [egl_g3d] Cache DRI2 textures and don't recreate them if the name is the same

2010-01-11 Thread Chia-I Wu
On Mon, Jan 4, 2010 at 11:12 PM, Luca Barbieri  wrote:
> Currently DRI2 always calls texture_from_shared_handle on validate.
> This may cause problems due if it is called multiple times on the same 
> handle, since multiple struct pipe_texture pointing to the same GEM buffer 
> will be created.
> On some drivers, this results in pushbuffers being submitted with different 
> local GEM buffers pointing to the same kernel object, causing the kernel to 
> complain about duplicated buffer in pushbuffer submission.
> This scenario does not usually happen with the current code because it checks 
> whether the size changed before requesting textures.
> However, this check will be replaced in the next patch, because it doesn't 
> play well with having the same drawable bound to multiple contexts, and 
> doesn't play well with allowing the user to call ->validate directly through 
> eglGetGalliumTexturesMESA.
This looks good.  Do you mind re-create this patch without the
dependency on the depth/stencil patch?

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev


[Mesa3d-dev] [PATCH 2/4] [egl_g3d] Cache DRI2 textures and don't recreate them if the name is the same

2010-01-04 Thread Luca Barbieri
Currently DRI2 always calls texture_from_shared_handle on validate.
This may cause problems due if it is called multiple times on the same handle, 
since multiple struct pipe_texture pointing to the same GEM buffer will be 
created.
On some drivers, this results in pushbuffers being submitted with different 
local GEM buffers pointing to the same kernel object, causing the kernel to 
complain about duplicated buffer in pushbuffer submission.

This scenario does not usually happen with the current code because it checks 
whether the size changed before requesting textures.
However, this check will be replaced in the next patch, because it doesn't play 
well with having the same drawable bound to multiple contexts, and doesn't play 
well with allowing the user to call ->validate directly through 
eglGetGalliumTexturesMESA.
---
 .../state_trackers/egl_g3d/x11/native_dri2.c   |   39 +++-
 src/glx/x11/dri2.c |4 +-
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c 
b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c
index 138f797..890e11d 100644
--- a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c
@@ -63,7 +63,8 @@ struct dri2_surface {
int dri2_depth_stencil_attachment;
struct dri2_display *dri2dpy;
 
-   struct pipe_texture *pbuffer_textures[NUM_NATIVE_ATTACHMENTS];
+   struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+   unsigned names[NUM_NATIVE_ATTACHMENTS];
boolean have_back, have_fake;
int width, height;
 };
@@ -166,11 +167,11 @@ dri2_surface_validate(struct native_surface *nsurf,
 
   for (i = 0; i < num_natts; i++) {
  enum native_attachment natt = natts[i];
- struct pipe_texture *ptex = dri2surf->pbuffer_textures[natt];
+ struct pipe_texture *ptex = dri2surf->textures[natt];
 
  if (!ptex) {
 ptex = screen->texture_create(screen, &templ);
-dri2surf->pbuffer_textures[natt] = ptex;
+dri2surf->textures[natt] = ptex;
  }
 
  if (textures)
@@ -284,25 +285,27 @@ dri2_surface_validate(struct native_surface *nsurf,
   }
 
   if (textures) {
- if(natt == NATIVE_ATTACHMENT_DEPTH_STENCIL)
+ if(dri2surf->names[natt] != xbuf->name)
  {
-templ.format = dri2surf->depth_stencil_format;
-templ.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
- }
- else
- {
-templ.format = dri2surf->color_format;
-templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
- }
+pipe_texture_reference(&dri2surf->textures[natt], 0);
+if(natt == NATIVE_ATTACHMENT_DEPTH_STENCIL)
+{
+   templ.format = dri2surf->depth_stencil_format;
+   templ.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+}
+else
+{
+   templ.format = dri2surf->color_format;
+   templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+}
 
- struct pipe_texture *ptex =
-dri2dpy->api->texture_from_shared_handle(dri2dpy->api,
+dri2surf->textures[natt] = 
dri2dpy->api->texture_from_shared_handle(dri2dpy->api,
   dri2dpy->base.screen, &templ,
   desc, xbuf->pitch, xbuf->name);
- if (ptex) {
-/* the caller owns the textures */
-textures[texture_indices[natt]] = ptex;
+dri2surf->names[natt] = xbuf->name;
  }
+
+ pipe_texture_reference(&textures[texture_indices[natt]], 
dri2surf->textures[natt]);
   }
}
 
@@ -336,7 +339,7 @@ dri2_surface_destroy(struct native_surface *nsurf)
int i;
 
for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) {
-  struct pipe_texture *ptex = dri2surf->pbuffer_textures[i];
+  struct pipe_texture *ptex = dri2surf->textures[i];
   pipe_texture_reference(&ptex, NULL);
}
 

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev