summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2011-02-26 15:53:01 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2011-02-26 22:00:01 +0100
commit1cb6a741347968ebb9ef0262ee047e11eb1242c1 (patch)
treeea5586e25d8c47a483780ffdd11e8d494e3ef3cc
parentedff3714417e193386d0eda6db45a8df8311b943 (diff)
i915g: cleanup static state calculation, part 2
Now also for the DRAW_RECT command Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--src/gallium/drivers/i915/i915_context.h2
-rw-r--r--src/gallium/drivers/i915/i915_state_emit.c53
-rw-r--r--src/gallium/drivers/i915/i915_state_static.c43
3 files changed, 48 insertions, 50 deletions
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index 6125c3629e..1da637d068 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -156,6 +156,8 @@ struct i915_state
struct i915_winsys_buffer *depth_bo;
unsigned depth_flags;
unsigned dst_buf_vars;
+ uint32_t draw_offset;
+ uint32_t draw_size;
unsigned id; /* track lost context events */
};
diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c
index 4cca6961f2..7534963c16 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -45,29 +45,6 @@ struct i915_tracked_hw_state {
unsigned dirty, batch_space;
};
-/**
- * Examine framebuffer state to determine width, height.
- */
-static boolean
-framebuffer_size(const struct pipe_framebuffer_state *fb,
- uint *width, uint *height)
-{
- if (fb->cbufs[0]) {
- *width = fb->cbufs[0]->width;
- *height = fb->cbufs[0]->height;
- return TRUE;
- }
- else if (fb->zsbuf) {
- *width = fb->zsbuf->width;
- *height = fb->zsbuf->height;
- return TRUE;
- }
- else {
- *width = *height = 0;
- return FALSE;
- }
-}
-
static void
emit_flush(struct i915_context *i915)
{
@@ -442,35 +419,11 @@ i915_emit_hardware_state(struct i915_context *i915 )
/* 6 dwords, 0 relocs */
if (i915->hardware_dirty & I915_HW_STATIC)
{
- uint w, h;
- struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
- unsigned x, y;
- int layer;
- uint32_t draw_offset;
- boolean ret;
-
- ret = framebuffer_size(&i915->framebuffer, &w, &h);
- assert(ret);
-
- if (cbuf_surface) {
- struct i915_texture *tex = i915_texture(cbuf_surface->texture);
- layer = cbuf_surface->u.tex.first_layer;
-
- x = tex->image_offset[cbuf_surface->u.tex.level][layer].nblocksx;
- y = tex->image_offset[cbuf_surface->u.tex.level][layer].nblocksy;
-
- } else
- x = y = 0;
-
- draw_offset = x | (y << 16);
-
- /* XXX flush only required when the draw_offset changes! */
- OUT_BATCH(MI_FLUSH | INHIBIT_FLUSH_RENDER_CACHE);
OUT_BATCH(_3DSTATE_DRAW_RECT_CMD);
OUT_BATCH(DRAW_RECT_DIS_DEPTH_OFS);
- OUT_BATCH(draw_offset);
- OUT_BATCH((w - 1 + x) | ((h - 1 + y) << 16));
- OUT_BATCH(draw_offset);
+ OUT_BATCH(i915->current.draw_offset);
+ OUT_BATCH(i915->current.draw_size);
+ OUT_BATCH(i915->current.draw_offset);
}
#endif
diff --git a/src/gallium/drivers/i915/i915_state_static.c b/src/gallium/drivers/i915/i915_state_static.c
index d210813a14..f3feeacd4f 100644
--- a/src/gallium/drivers/i915/i915_state_static.c
+++ b/src/gallium/drivers/i915/i915_state_static.c
@@ -78,11 +78,38 @@ buf_3d_tiling_bits(enum i915_winsys_buffer_tile tiling)
return tiling_bits;
}
+/**
+ * Examine framebuffer state to determine width, height.
+ */
+static boolean
+framebuffer_size(const struct pipe_framebuffer_state *fb,
+ uint *width, uint *height)
+{
+ if (fb->cbufs[0]) {
+ *width = fb->cbufs[0]->width;
+ *height = fb->cbufs[0]->height;
+ return TRUE;
+ }
+ else if (fb->zsbuf) {
+ *width = fb->zsbuf->width;
+ *height = fb->zsbuf->height;
+ return TRUE;
+ }
+ else {
+ *width = *height = 0;
+ return FALSE;
+ }
+}
+
static void update_framebuffer(struct i915_context *i915)
{
struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
struct pipe_surface *depth_surface = i915->framebuffer.zsbuf;
unsigned cformat, zformat;
+ unsigned x, y, w, h;
+ int layer;
+ uint32_t draw_offset;
+ boolean ret;
if (cbuf_surface) {
struct i915_texture *tex = i915_texture(cbuf_surface->texture);
@@ -93,9 +120,15 @@ static void update_framebuffer(struct i915_context *i915)
BUF_3D_PITCH(tex->stride) | /* pitch in bytes */
buf_3d_tiling_bits(tex->tiling);
cformat = cbuf_surface->format;
+
+ layer = cbuf_surface->u.tex.first_layer;
+
+ x = tex->image_offset[cbuf_surface->u.tex.level][layer].nblocksx;
+ y = tex->image_offset[cbuf_surface->u.tex.level][layer].nblocksy;
} else {
i915->current.cbuf_bo = NULL;
cformat = PIPE_FORMAT_B8G8R8A8_UNORM; /* arbitrary */
+ x = y = 0;
}
cformat = translate_format(cformat);
@@ -125,6 +158,16 @@ static void update_framebuffer(struct i915_context *i915)
cformat |
zformat;
+ /* drawing rect calculations */
+ draw_offset = x | (y << 16);
+ ret = framebuffer_size(&i915->framebuffer, &w, &h);
+ assert(ret);
+ if (i915->current.draw_offset != draw_offset) {
+ i915->current.draw_offset = draw_offset;
+ i915_set_flush_dirty(i915, I915_PIPELINE_FLUSH);
+ }
+ i915->current.draw_size = (w - 1 + x) | ((h - 1 + y) << 16);
+
i915->hardware_dirty |= I915_HW_STATIC;
/* flush the cache in case we sample from the old renderbuffers */