i965g: add lots of error checks and early returns
[mesa.git] / src / gallium / drivers / i965 / brw_screen_surface.c
index 1c408e9f2e5d37ae211057747c126e02d5a39be6..21a7382873ffce617e7614984c1a86d5965e2d44 100644 (file)
@@ -150,9 +150,7 @@ static struct brw_surface *create_in_place_view( struct brw_screen *brw_screen,
    surface->pitch = tex->pitch;
    surface->tiling = tex->tiling;
 
-   surface->bo = tex->bo;
-   brw_screen->sws->bo_reference(surface->bo);
-
+   bo_reference( &surface->bo, tex->bo );
    pipe_texture_reference( &surface->base.texture, &tex->base );
 
    surface->ss.ss0.surface_format = tex->ss.ss0.surface_format;
@@ -244,11 +242,10 @@ static struct pipe_surface *brw_get_tex_surface(struct pipe_screen *screen,
 static void brw_tex_surface_destroy( struct pipe_surface *surf )
 {
    struct brw_surface *surface = brw_surface(surf);
-   struct brw_screen *screen = brw_screen(surf->texture->screen);
 
    /* Unreference texture, shared buffer:
     */
-   screen->sws->bo_unreference(surface->bo);
+   bo_reference(&surface->bo, NULL);
    pipe_texture_reference( &surface->base.texture, NULL );