softpipe: update to new draw interfaces
[mesa.git] / src / gallium / drivers / softpipe / sp_texture.c
index faf9e871f932939c99606069c1c36227c907a139..3eed0d0d2934d024574b88dd7c922a26b7b03f32 100644 (file)
@@ -33,7 +33,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
-#include "pipe/p_winsys.h"
+#include "pipe/internal/p_winsys_screen.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -106,11 +106,11 @@ softpipe_displaytarget_layout(struct pipe_screen *screen,
    spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);  
 
    spt->buffer = ws->surface_buffer_create( ws, 
-                                           spt->base.width[0], 
-                                           spt->base.height[0],
-                                           spt->base.format,
-                                           usage,
-                                           &spt->stride[0]);
+                                            spt->base.width[0], 
+                                            spt->base.height[0],
+                                            spt->base.format,
+                                            usage,
+                                            &spt->stride[0]);
 
    return spt->buffer != NULL;
 }
@@ -211,11 +211,9 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
    assert(level <= pt->last_level);
 
    ps = CALLOC_STRUCT(pipe_surface);
-   ps->refcount = 1;
    if (ps) {
-      assert(ps->refcount);
+      ps->refcount = 1;
       pipe_texture_reference(&ps->texture, pt);
-      pipe_buffer_reference(screen, &ps->buffer, spt->buffer);
       ps->format = pt->format;
       ps->block = pt->block;
       ps->width = pt->width[level];
@@ -225,7 +223,7 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
       ps->stride = spt->stride[level];
       ps->offset = spt->level_offset[level];
       ps->usage = usage;
-      
+
       /* Because we are softpipe, anything that the state tracker
        * thought was going to be done with the GPU will actually get
        * done with the CPU.  Let's adjust the flags to take that into
@@ -272,10 +270,9 @@ softpipe_tex_surface_release(struct pipe_screen *screen,
     * needed post-processing to put them into hardware layout, this is
     * where it would happen.  For softpipe, nothing to do.
     */
-   assert ((*s)->texture);
+   assert(surf->texture);
    if (--surf->refcount == 0) {
-      pipe_texture_reference(&surf->texture, NULL); 
-      pipe_buffer_reference(screen, &surf->buffer, NULL);
+      pipe_texture_reference(&surf->texture, NULL);
       FREE(surf);
    }
    *s = NULL;
@@ -288,13 +285,16 @@ softpipe_surface_map( struct pipe_screen *screen,
                       unsigned flags )
 {
    ubyte *map;
+   struct softpipe_texture *spt;
 
    if (flags & ~surface->usage) {
       assert(0);
       return NULL;
    }
 
-   map = pipe_buffer_map( screen, surface->buffer, flags );
+   assert(surface->texture);
+   spt = softpipe_texture(surface->texture);
+   map = pipe_buffer_map(screen, spt->buffer, flags);
    if (map == NULL)
       return NULL;
 
@@ -318,7 +318,12 @@ static void
 softpipe_surface_unmap(struct pipe_screen *screen,
                        struct pipe_surface *surface)
 {
-   pipe_buffer_unmap( screen, surface->buffer );
+   struct softpipe_texture *spt;
+
+   assert(surface->texture);
+   spt = softpipe_texture(surface->texture);
+
+   pipe_buffer_unmap( screen, spt->buffer );
 }