i965g: plumb in some surface state
authorKeith Whitwell <keithw@vmware.com>
Wed, 4 Nov 2009 20:36:48 +0000 (20:36 +0000)
committerKeith Whitwell <keithw@vmware.com>
Wed, 4 Nov 2009 20:36:48 +0000 (20:36 +0000)
src/gallium/drivers/i965/brw_context.c
src/gallium/drivers/i965/brw_pipe_clear.c
src/gallium/drivers/i965/brw_screen_surface.c

index 5accc858a9c7e62951144c556318de69e89ecbc3..cd8963bebcb78f87da66765c32ac52c0dffb2e7d 100644 (file)
@@ -39,6 +39,7 @@
 #include "brw_state.h"
 #include "brw_batchbuffer.h"
 #include "brw_winsys.h"
+#include "brw_screen.h"
 
 
 static void brw_destroy_context( struct pipe_context *pipe )
@@ -46,6 +47,8 @@ static void brw_destroy_context( struct pipe_context *pipe )
    struct brw_context *brw = brw_context(pipe);
    int i;
 
+   brw_context_flush( brw );
+   brw_batchbuffer_free( brw->batch );
    brw_destroy_state(brw);
 
    brw_draw_cleanup( brw );
@@ -101,15 +104,12 @@ struct pipe_context *brw_create_context(struct pipe_screen *screen)
 
    if (!brw) {
       debug_printf("%s: failed to alloc context\n", __FUNCTION__);
-      return GL_FALSE;
+      return NULL;
    }
 
-   /* We want the GLSL compiler to emit code that uses condition codes */
-   //ctx->Shader.EmitCondCodes = GL_TRUE;
-   //ctx->Shader.EmitNVTempInitialization = GL_TRUE;
-
    brw->base.screen = screen;
    brw->base.destroy = brw_destroy_context;
+   brw->sws = brw_screen(screen)->sws;
 
    brw_pipe_blend_init( brw );
    brw_pipe_depth_stencil_init( brw );
@@ -133,7 +133,15 @@ struct pipe_context *brw_create_context(struct pipe_screen *screen)
 
    make_empty_list(&brw->query.active_head);
 
+   brw->batch = brw_batchbuffer_alloc( brw->sws );
+   if (brw->batch == NULL)
+      goto fail;
 
    return &brw->base;
+
+fail:
+   if (brw->batch)
+      brw_batchbuffer_free( brw->batch );
+   return NULL;
 }
 
index f48175c0f71a4a2c0a018f90f86afc64c3c54bcd..69bc95e51aa8ac71fcb03d01f01a150f8ed1b730 100644 (file)
@@ -64,7 +64,7 @@ try_clear( struct brw_context *brw,
    debug_printf("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
                 __FUNCTION__,
                 (void *)surface->bo, pitch * cpp,
-                surface->draw_offset,
+                surface->base.offset,
                 x1, y1, x2 - x1, y2 - y1);
 
    BR13 = 0xf0 << 16;
@@ -96,7 +96,7 @@ try_clear( struct brw_context *brw,
    OUT_BATCH((y2 << 16) | x2);
    OUT_RELOC(surface->bo,
              BRW_USAGE_BLIT_DEST,
-             surface->draw_offset);
+             surface->base.offset);
    OUT_BATCH(value);
    ADVANCE_BATCH();
 
index 04a6fc7b66dce9a25576e0f09d009f007a236172..1c408e9f2e5d37ae211057747c126e02d5a39be6 100644 (file)
@@ -35,6 +35,7 @@
 #include "pipe/p_screen.h"
 #include "brw_screen.h"
 #include "brw_defines.h"
+#include "brw_winsys.h"
 
 enum {
    BRW_VIEW_LINEAR,
@@ -145,6 +146,12 @@ static struct brw_surface *create_in_place_view( struct brw_screen *brw_screen,
    surface->base.face = id.bits.face;
    surface->base.level = id.bits.level;
    surface->id = id;
+   surface->cpp = tex->cpp;
+   surface->pitch = tex->pitch;
+   surface->tiling = tex->tiling;
+
+   surface->bo = tex->bo;
+   brw_screen->sws->bo_reference(surface->bo);
 
    pipe_texture_reference( &surface->base.texture, &tex->base );
 
@@ -234,10 +241,16 @@ static struct pipe_surface *brw_get_tex_surface(struct pipe_screen *screen,
 }
 
 
-static void brw_tex_surface_destroy( struct pipe_surface *surface )
+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);
+   pipe_texture_reference( &surface->base.texture, NULL );
+
 
    FREE(surface);
 }