summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/i965
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-11-06 14:20:04 +0000
committerKeith Whitwell <[email protected]>2009-11-06 17:26:52 +0000
commit4fbe6c4e4e754e0e850165d5a303990515ceaba6 (patch)
tree850e74504fde989fcd5dbc1c7cac04edae2ddc5d /src/gallium/drivers/i965
parent0532cc0c86d36f98ae33291847fbd9f2564cbed2 (diff)
i965g: get rid of cc key, simplify state upload
Keep a valid reloc table active between uploads, avoid recalculating it every time.
Diffstat (limited to 'src/gallium/drivers/i965')
-rw-r--r--src/gallium/drivers/i965/brw_cc.c155
-rw-r--r--src/gallium/drivers/i965/brw_context.c8
-rw-r--r--src/gallium/drivers/i965/brw_context.h13
-rw-r--r--src/gallium/drivers/i965/brw_pipe_fb.c4
4 files changed, 51 insertions, 129 deletions
diff --git a/src/gallium/drivers/i965/brw_cc.c b/src/gallium/drivers/i965/brw_cc.c
index f05728ea5d7..3e070f5591a 100644
--- a/src/gallium/drivers/i965/brw_cc.c
+++ b/src/gallium/drivers/i965/brw_cc.c
@@ -35,48 +35,13 @@
#include "brw_defines.h"
-struct sane_viewport {
- float top;
- float left;
- float width;
- float height;
- float near;
- float far;
-};
-
-static void calc_sane_viewport( const struct pipe_viewport_state *vp,
- struct sane_viewport *svp )
-{
- /* XXX fix me, obviously.
- */
- svp->top = 0;
- svp->left = 0;
- svp->width = 250;
- svp->height = 250;
- svp->near = 0;
- svp->far = 1;
-}
-
static enum pipe_error prepare_cc_vp( struct brw_context *brw )
{
- struct brw_cc_viewport ccv;
- struct sane_viewport svp;
- enum pipe_error ret;
-
- memset(&ccv, 0, sizeof(ccv));
-
- /* PIPE_NEW_VIEWPORT */
- calc_sane_viewport( &brw->curr.viewport, &svp );
-
- ccv.min_depth = svp.near;
- ccv.max_depth = svp.far;
-
- ret = brw_cache_data( &brw->cache, BRW_CC_VP, &ccv, NULL, 0,
- &brw->cc.vp_bo );
- if (ret)
- return ret;
-
- return PIPE_OK;
+ return brw_cache_data( &brw->cache,
+ BRW_CC_VP,
+ &brw->curr.ccv,
+ NULL, 0,
+ &brw->cc.reloc[CC_RELOC_VP].bo );
}
const struct brw_tracked_state brw_cc_vp = {
@@ -88,15 +53,6 @@ const struct brw_tracked_state brw_cc_vp = {
.prepare = prepare_cc_vp
};
-struct brw_cc_unit_key {
- struct brw_cc0 cc0;
- struct brw_cc1 cc1;
- struct brw_cc2 cc2;
- struct brw_cc3 cc3;
- struct brw_cc5 cc5;
- struct brw_cc6 cc6;
- struct brw_cc7 cc7;
-};
/* A long-winded way to OR two unsigned integers together:
*/
@@ -110,85 +66,22 @@ combine_cc3( struct brw_cc3 a, struct brw_cc3 b )
return ca.cc3;
}
-static void
-cc_unit_populate_key(const struct brw_context *brw,
- struct brw_cc_unit_key *key)
-{
- key->cc0 = brw->curr.zstencil->cc0;
- key->cc1 = brw->curr.zstencil->cc1;
- key->cc2 = brw->curr.zstencil->cc2;
- key->cc3 = combine_cc3( brw->curr.zstencil->cc3, brw->curr.blend->cc3 );
- key->cc5 = brw->curr.blend->cc5;
- key->cc6 = brw->curr.blend->cc6;
- key->cc7 = brw->curr.zstencil->cc7;
-}
-
-/**
- * Creates the state cache entry for the given CC unit key.
- */
-static enum pipe_error
-cc_unit_create_from_key(struct brw_context *brw,
- struct brw_cc_unit_key *key,
- struct brw_winsys_reloc *reloc,
- struct brw_winsys_buffer **bo_out)
-{
- struct brw_cc_unit_state cc;
- enum pipe_error ret;
-
- memset(&cc, 0, sizeof(cc));
-
- cc.cc0 = key->cc0;
- cc.cc1 = key->cc1;
- cc.cc2 = key->cc2;
- cc.cc3 = key->cc3;
-
- cc.cc4.cc_viewport_state_offset = 0;
-
- cc.cc5 = key->cc5;
- cc.cc6 = key->cc6;
- cc.cc7 = key->cc7;
-
- ret = brw_upload_cache(&brw->cache, BRW_CC_UNIT,
- key, sizeof(*key),
- reloc, 1,
- &cc, sizeof(cc),
- NULL, NULL,
- bo_out);
- if (ret)
- return ret;
-
- return PIPE_OK;
-}
static int prepare_cc_unit( struct brw_context *brw )
{
- struct brw_cc_unit_key key;
- struct brw_winsys_reloc reloc[1];
- enum pipe_error ret;
-
- cc_unit_populate_key(brw, &key);
-
- /* CACHE_NEW_CC_VP */
- make_reloc(&reloc[0],
- BRW_USAGE_STATE,
- 0,
- offsetof(struct brw_cc_unit_state, cc4),
- brw->cc.vp_bo);
-
- if (brw_search_cache(&brw->cache, BRW_CC_UNIT,
- &key, sizeof(key),
- reloc, 1,
- NULL,
- &brw->cc.state_bo))
- return PIPE_OK;
-
- ret = cc_unit_create_from_key(brw, &key,
- reloc,
- &brw->cc.state_bo);
- if (ret)
- return ret;
+ brw->cc.cc.cc0 = brw->curr.zstencil->cc0;
+ brw->cc.cc.cc1 = brw->curr.zstencil->cc1;
+ brw->cc.cc.cc2 = brw->curr.zstencil->cc2;
+ brw->cc.cc.cc3 = combine_cc3( brw->curr.zstencil->cc3, brw->curr.blend->cc3 );
- return PIPE_OK;
+ brw->cc.cc.cc5 = brw->curr.blend->cc5;
+ brw->cc.cc.cc6 = brw->curr.blend->cc6;
+ brw->cc.cc.cc7 = brw->curr.zstencil->cc7;
+
+ return brw_cache_data_sz(&brw->cache, BRW_CC_UNIT,
+ &brw->cc.cc, sizeof(brw->cc.cc),
+ brw->cc.reloc, 1,
+ &brw->cc.state_bo);
}
const struct brw_tracked_state brw_cc_unit = {
@@ -201,4 +94,18 @@ const struct brw_tracked_state brw_cc_unit = {
};
+void brw_hw_cc_init( struct brw_context *brw )
+{
+ make_reloc(&brw->cc.reloc[0],
+ BRW_USAGE_STATE,
+ 0,
+ offsetof(struct brw_cc_unit_state, cc4),
+ NULL);
+}
+
+void brw_hw_cc_cleanup( struct brw_context *brw )
+{
+ bo_reference(&brw->cc.state_bo, NULL);
+ bo_reference(&brw->cc.reloc[0].bo, NULL);
+}
diff --git a/src/gallium/drivers/i965/brw_context.c b/src/gallium/drivers/i965/brw_context.c
index f85116a568c..e67551882dc 100644
--- a/src/gallium/drivers/i965/brw_context.c
+++ b/src/gallium/drivers/i965/brw_context.c
@@ -65,6 +65,9 @@ static void brw_destroy_context( struct pipe_context *pipe )
brw_pipe_vertex_cleanup( brw );
brw_pipe_clear_cleanup( brw );
+ brw_hw_cc_cleanup( brw );
+
+
FREE(brw->wm.compile_data);
for (i = 0; i < brw->curr.fb.nr_cbufs; i++)
@@ -96,9 +99,6 @@ static void brw_destroy_context( struct pipe_context *pipe )
bo_reference(&brw->wm.sampler_bo, NULL);
bo_reference(&brw->wm.prog_bo, NULL);
bo_reference(&brw->wm.state_bo, NULL);
- bo_reference(&brw->cc.prog_bo, NULL);
- bo_reference(&brw->cc.state_bo, NULL);
- bo_reference(&brw->cc.vp_bo, NULL);
}
@@ -128,6 +128,8 @@ struct pipe_context *brw_create_context(struct pipe_screen *screen)
brw_pipe_vertex_init( brw );
brw_pipe_clear_init( brw );
+ brw_hw_cc_init( brw );
+
brw_init_state( brw );
brw_draw_init( brw );
diff --git a/src/gallium/drivers/i965/brw_context.h b/src/gallium/drivers/i965/brw_context.h
index f53b92d4f53..4a975ecd7ec 100644
--- a/src/gallium/drivers/i965/brw_context.h
+++ b/src/gallium/drivers/i965/brw_context.h
@@ -481,6 +481,8 @@ struct brw_query_object {
uint64_t result;
};
+#define CC_RELOC_VP 0
+
/**
* brw_context is derived from pipe_context
@@ -525,6 +527,7 @@ struct brw_context
struct brw_blend_constant_color bcc;
struct brw_polygon_stipple bps;
+ struct brw_cc_viewport ccv;
/**
* Index buffer for this draw_prims call.
@@ -708,9 +711,10 @@ struct brw_context
struct {
- struct brw_winsys_buffer *prog_bo;
struct brw_winsys_buffer *state_bo;
- struct brw_winsys_buffer *vp_bo;
+
+ struct brw_cc_unit_state cc;
+ struct brw_winsys_reloc reloc[1];
} cc;
struct {
@@ -764,6 +768,7 @@ void brw_pipe_shader_init( struct brw_context *brw );
void brw_pipe_vertex_init( struct brw_context *brw );
void brw_pipe_clear_init( struct brw_context *brw );
+
void brw_pipe_blend_cleanup( struct brw_context *brw );
void brw_pipe_depth_stencil_cleanup( struct brw_context *brw );
void brw_pipe_framebuffer_cleanup( struct brw_context *brw );
@@ -776,6 +781,10 @@ void brw_pipe_shader_cleanup( struct brw_context *brw );
void brw_pipe_vertex_cleanup( struct brw_context *brw );
void brw_pipe_clear_cleanup( struct brw_context *brw );
+void brw_hw_cc_init( struct brw_context *brw );
+void brw_hw_cc_cleanup( struct brw_context *brw );
+
+
void brw_context_flush( struct brw_context *brw );
diff --git a/src/gallium/drivers/i965/brw_pipe_fb.c b/src/gallium/drivers/i965/brw_pipe_fb.c
index f65f45fb844..15112204478 100644
--- a/src/gallium/drivers/i965/brw_pipe_fb.c
+++ b/src/gallium/drivers/i965/brw_pipe_fb.c
@@ -49,7 +49,11 @@ static void brw_set_viewport_state( struct pipe_context *pipe,
const struct pipe_viewport_state *viewport )
{
struct brw_context *brw = brw_context(pipe);
+
brw->curr.viewport = *viewport;
+ brw->curr.ccv.min_depth = 0.0; /* XXX: near */
+ brw->curr.ccv.max_depth = 1.0; /* XXX: far */
+
brw->state.dirty.mesa |= PIPE_NEW_VIEWPORT;
}