summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-11-04 20:36:48 +0000
committerKeith Whitwell <[email protected]>2009-11-04 20:36:48 +0000
commitc5ed7b6e76a71d34e4a42ebfca092bd99cb39438 (patch)
treecdeecf7da81d4f85d12abaebdc4c903628a6bf30 /src/gallium
parente18f223da710a6e1f6a08d346951ea66c6a1de99 (diff)
i965g: plumb in some surface state
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/i965/brw_context.c18
-rw-r--r--src/gallium/drivers/i965/brw_pipe_clear.c4
-rw-r--r--src/gallium/drivers/i965/brw_screen_surface.c15
3 files changed, 29 insertions, 8 deletions
diff --git a/src/gallium/drivers/i965/brw_context.c b/src/gallium/drivers/i965/brw_context.c
index 5accc858a9c..cd8963bebcb 100644
--- a/src/gallium/drivers/i965/brw_context.c
+++ b/src/gallium/drivers/i965/brw_context.c
@@ -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;
}
diff --git a/src/gallium/drivers/i965/brw_pipe_clear.c b/src/gallium/drivers/i965/brw_pipe_clear.c
index f48175c0f71..69bc95e51aa 100644
--- a/src/gallium/drivers/i965/brw_pipe_clear.c
+++ b/src/gallium/drivers/i965/brw_pipe_clear.c
@@ -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();
diff --git a/src/gallium/drivers/i965/brw_screen_surface.c b/src/gallium/drivers/i965/brw_screen_surface.c
index 04a6fc7b66d..1c408e9f2e5 100644
--- a/src/gallium/drivers/i965/brw_screen_surface.c
+++ b/src/gallium/drivers/i965/brw_screen_surface.c
@@ -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);
}