On Wed, Oct 21, 2009 at 01:49:42AM +0200, Lionel Landwerlin wrote: > Le lundi 19 octobre 2009 à 14:42 +0100, Ilyes Gouta a écrit : > > Hi, > > > > I'm dealing with a configuration where the video RAM is mapped into > > the user-space application as a cached region. What happens if the > > destination is the framebuffer (VRAM) which was locked and then > > written to using the CPU? Don't we need a: > > > > if (allocation->accessed & CSAF_CPU_WRITE) > > dfb_gfxcard_flush_texture_cache(); > > > > in dfb_surface_buffer_unlock() (surface_buffer.c) ? > > > > Hi Ilyes, > > DirectFB does not manage the cache stuff at unlock time but only at lock > time. This is a "lazy" cache management. > When accessing a buffer (read or write), DirectFB first looks at the > last operation done on this buffer, and according to this last operation > it knows if there is some synchronization stuff to do. > > If you're interested in, have a look at the dfb_surface_buffer_lock > function. Espacialy the "Manage access interlocks" part. > > In the end, it remains to your gfxdriver to implement the FlushReadCache > function to unsure the read cache is flushed when requested by DirectFB.
FlushTextureCache and FlushReadCache are for invalidating the caches on the GPU. For CPU caches they may not be enough. Eg. with write back cache you would need to to do the write back after a CPU write but before any GPU access. FlushTextureCache would only be called for GPU read access, not write access. And on a CPU access after a GPU write you would need to invalidate the CPU cache. For this FlushReadCache would be enough since it will be called for any CPU access. Ideally it would only be called for a CPU read access since a CPU write would invalidate the cache anyway (at least on Matrox hardware for which FLushReadCache was added), but since there's no guarantee that a write access will happen even if a CPU write lock was requested it was decided that FlushReadCache will be called for any CPU access after a GPU write. I don't think you should even try to use FlushTextureCache and FlushReadCache for CPU cache management. If you have a custom surface pool you could do the cache management there (in Lock/Read/Write). -- Ville Syrjälä syrj...@sci.fi http://www.sci.fi/~syrjala/ _______________________________________________ directfb-dev mailing list directfb-dev@directfb.org http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev