diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-10 12:35:28 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-10 13:24:46 +0100 |
commit | 8bd9d63a863b88ecd6f72c11468e0940f3bcd9fc (patch) | |
tree | 0d70dc3a6dbdfee855bcf7738c8583979f8515c2 /src/sna/gen7_render.c | |
parent | ddcd8607027c67f8260ffd4eae8543f832885cb8 (diff) |
sna/gen6+: Share the common routines for ring preferrence
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/gen7_render.c')
-rw-r--r-- | src/sna/gen7_render.c | 227 |
1 files changed, 12 insertions, 215 deletions
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index e9295299..f6eef4aa 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -44,6 +44,7 @@ #include "gen7_render.h" #include "gen4_source.h" #include "gen4_vertex.h" +#include "gen6_common.h" #define ALWAYS_INVALIDATE 0 #define ALWAYS_FLUSH 0 @@ -2134,101 +2135,6 @@ gen7_composite_set_target(struct sna *sna, return true; } -inline static bool can_switch_to_blt(struct sna *sna, - struct kgem_bo *bo, - unsigned flags) -{ - if (sna->kgem.ring != KGEM_RENDER) - return true; - - if (NO_RING_SWITCH) - return false; - - if (!sna->kgem.has_semaphores) - return false; - - if (flags & COPY_LAST) - return true; - - if (bo && RQ_IS_BLT(bo->rq)) - return true; - - return kgem_ring_is_idle(&sna->kgem, KGEM_BLT); -} - -inline static bool can_switch_to_render(struct sna *sna, - struct kgem_bo *bo) -{ - if (sna->kgem.ring == KGEM_RENDER) - return true; - - if (NO_RING_SWITCH) - return false; - - if (!sna->kgem.has_semaphores) - return false; - - if (bo && !RQ_IS_BLT(bo->rq) && !(bo->scanout && !sna->kgem.has_wt)) - return true; - - return !kgem_ring_is_idle(&sna->kgem, KGEM_RENDER); -} - -static inline bool untiled_tlb_miss(struct kgem_bo *bo) -{ - if (kgem_bo_is_render(bo)) - return false; - - return bo->tiling == I915_TILING_NONE && bo->pitch >= 4096; -} - -static int prefer_blt_bo(struct sna *sna, struct kgem_bo *bo) -{ - if (bo->rq) - return RQ_IS_BLT(bo->rq); - - if (sna->flags & SNA_POWERSAVE) - return true; - - return bo->tiling == I915_TILING_NONE || (bo->scanout && !sna->kgem.has_wt); -} - -inline static bool force_blt_ring(struct sna *sna) -{ - if (sna->flags & SNA_POWERSAVE) - return true; - - if (sna->kgem.mode == KGEM_RENDER) - return false; - - if (sna->render_state.gen7.info->gt < 2) - return true; - - return false; -} - -inline static bool prefer_blt_ring(struct sna *sna, - struct kgem_bo *bo, - unsigned flags) -{ - assert(!force_blt_ring(sna)); - assert(!kgem_bo_is_render(bo)); - - return can_switch_to_blt(sna, bo, flags); -} - -inline static bool prefer_render_ring(struct sna *sna, - struct kgem_bo *bo) -{ - if (sna->flags & SNA_POWERSAVE) - return false; - - if (sna->render_state.gen7.info->gt < 2) - return false; - - return can_switch_to_render(sna, bo); -} - static bool try_blt(struct sna *sna, PicturePtr dst, PicturePtr src, @@ -2476,29 +2382,6 @@ reuse_source(struct sna *sna, } static bool -prefer_blt_composite(struct sna *sna, struct sna_composite_op *tmp) -{ - if (untiled_tlb_miss(tmp->dst.bo) || - untiled_tlb_miss(tmp->src.bo)) - return true; - - if (force_blt_ring(sna)) - return true; - - if (kgem_bo_is_render(tmp->dst.bo) || - kgem_bo_is_render(tmp->src.bo)) - return false; - - if (prefer_render_ring(sna, tmp->dst.bo)) - return false; - - if (!prefer_blt_ring(sna, tmp->dst.bo, 0)) - return false; - - return prefer_blt_bo(sna, tmp->dst.bo) || prefer_blt_bo(sna, tmp->src.bo); -} - -static bool gen7_render_composite(struct sna *sna, uint8_t op, PicturePtr src, @@ -2918,10 +2801,11 @@ gen7_emit_copy_state(struct sna *sna, gen7_emit_state(sna, op, offset); } -static inline bool prefer_blt_copy(struct sna *sna, - struct kgem_bo *src_bo, - struct kgem_bo *dst_bo, - unsigned flags) +static inline bool +prefer_blt_copy(struct sna *sna, + struct kgem_bo *src_bo, + struct kgem_bo *dst_bo, + unsigned flags) { if (sna->kgem.mode == KGEM_BLT) return true; @@ -3345,32 +3229,6 @@ gen7_emit_fill_state(struct sna *sna, const struct sna_composite_op *op) gen7_emit_state(sna, op, offset); } -static inline bool prefer_blt_fill(struct sna *sna, - struct kgem_bo *bo, - unsigned flags) -{ - if (flags & (FILL_POINTS | FILL_SPANS) && - can_switch_to_blt(sna, bo, 0)) - return true; - - if (untiled_tlb_miss(bo)) - return true; - - if (force_blt_ring(sna)) - return true; - - if (kgem_bo_is_render(bo)) - return false; - - if (prefer_render_ring(sna, bo)) - return false; - - if (!prefer_blt_ring(sna, bo, 0)) - return false; - - return prefer_blt_bo(sna, bo); -} - static bool gen7_render_fill_boxes(struct sna *sna, CARD8 op, @@ -3836,69 +3694,6 @@ gen7_render_clear(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo) return true; } - -static void gen7_render_flush(struct sna *sna) -{ - gen4_vertex_close(sna); - - assert(sna->render.vb_id == 0); - assert(sna->render.vertex_offset == 0); -} - -static void -gen7_render_context_switch(struct kgem *kgem, - int new_mode) -{ - if (kgem->nbatch) { - DBG(("%s: from %d to %d, submit batch\n", __FUNCTION__, kgem->mode, new_mode)); - _kgem_submit(kgem); - } - - if (kgem->nexec) { - DBG(("%s: from %d to %d, reset incomplete batch\n", __FUNCTION__, kgem->mode, new_mode)); - kgem_reset(kgem); - } - - assert(kgem->nbatch == 0); - assert(kgem->nreloc == 0); - assert(kgem->nexec == 0); - - kgem->ring = new_mode; -} - -static void -gen7_render_retire(struct kgem *kgem) -{ - struct sna *sna; - - if (kgem->ring && (kgem->has_semaphores || !kgem->need_retire)) - kgem->ring = kgem->mode; - - sna = container_of(kgem, struct sna, kgem); - if (kgem->nbatch == 0 && sna->render.vbo && !kgem_bo_is_busy(sna->render.vbo)) { - DBG(("%s: resetting idle vbo\n", __FUNCTION__)); - sna->render.vertex_used = 0; - sna->render.vertex_index = 0; - } -} - -static void -gen7_render_expire(struct kgem *kgem) -{ - struct sna *sna; - - sna = container_of(kgem, struct sna, kgem); - if (sna->render.vbo && !sna->render.vertex_used) { - DBG(("%s: discarding vbo\n", __FUNCTION__)); - kgem_bo_destroy(kgem, sna->render.vbo); - sna->render.vbo = NULL; - sna->render.vertices = sna->render.vertex_data; - sna->render.vertex_size = ARRAY_SIZE(sna->render.vertex_data); - sna->render.vertex_used = 0; - sna->render.vertex_index = 0; - } -} - static void gen7_render_reset(struct sna *sna) { sna->render_state.gen7.emit_flush = false; @@ -3969,6 +3764,8 @@ static bool gen7_render_setup(struct sna *sna, int devid) } else return false; + state->gt = state->info->gt; + sna_static_stream_init(&general); /* Zero pad the start. If you see an offset of 0x0 in the batchbuffer @@ -4038,9 +3835,9 @@ const char *gen7_render_init(struct sna *sna, const char *backend) if (!gen7_render_setup(sna, devid)) return backend; - sna->kgem.context_switch = gen7_render_context_switch; - sna->kgem.retire = gen7_render_retire; - sna->kgem.expire = gen7_render_expire; + sna->kgem.context_switch = gen6_render_context_switch; + sna->kgem.retire = gen6_render_retire; + sna->kgem.expire = gen6_render_expire; #if !NO_COMPOSITE sna->render.composite = gen7_render_composite; @@ -4074,7 +3871,7 @@ const char *gen7_render_init(struct sna *sna, const char *backend) sna->render.clear = gen7_render_clear; #endif - sna->render.flush = gen7_render_flush; + sna->render.flush = gen6_render_flush; sna->render.reset = gen7_render_reset; sna->render.fini = gen7_render_fini; |