diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-10-11 08:45:47 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-10-11 08:48:54 +0100 |
commit | 4a2e833ab17e4facf0f90166b82a5696a1deef91 (patch) | |
tree | ca2264d319af67ac0e0d6607ed753945dfaec926 /src/sna/gen7_render.c | |
parent | 41f525fab5a82c24adafc7e8c8409417d16a0e9a (diff) |
sna/gen7: Add render support for fill one
To prevent the RENDER to BLT transition and potential stall.
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 | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index ec5a0163..30de36fc 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2942,6 +2942,114 @@ gen7_render_fill(struct sna *sna, uint8_t alu, return TRUE; } +static Bool +gen7_render_fill_one_try_blt(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, int16_t x2, int16_t y2, + uint8_t alu) +{ + BoxRec box; + + box.x1 = x1; + box.y1 = y1; + box.x2 = x2; + box.y2 = y2; + + return sna_blt_fill_boxes(sna, alu, + bo, dst->drawable.bitsPerPixel, + color, &box, 1); +} + +static Bool +gen7_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, + int16_t x2, int16_t y2, + uint8_t alu) +{ + struct sna_composite_op tmp; + +#if NO_FILL_BOXES + return gen7_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); +#endif + + /* Prefer to use the BLT if already engaged */ + if (sna->kgem.mode != KGEM_RENDER && + gen7_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu)) + return TRUE; + + /* Must use the BLT if we can't RENDER... */ + if (!(alu == GXcopy || alu == GXclear) || + dst->drawable.width > 8192 || dst->drawable.height > 8192) + return gen7_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); + + if (alu == GXclear) + color = 0; + + tmp.op = color == 0 ? PictOpClear : PictOpSrc; + + tmp.dst.pixmap = dst; + tmp.dst.width = dst->drawable.width; + tmp.dst.height = dst->drawable.height; + tmp.dst.format = sna_format_for_depth(dst->drawable.depth); + tmp.dst.bo = bo; + tmp.dst.x = tmp.dst.y = 0; + + tmp.src.bo = + sna_render_get_solid(sna, + sna_rgba_for_color(color, + dst->drawable.depth)); + tmp.src.filter = SAMPLER_FILTER_NEAREST; + tmp.src.repeat = SAMPLER_EXTEND_REPEAT; + + tmp.mask.bo = NULL; + tmp.mask.filter = SAMPLER_FILTER_NEAREST; + tmp.mask.repeat = SAMPLER_EXTEND_NONE; + + tmp.is_affine = TRUE; + tmp.floats_per_vertex = 3; + tmp.has_component_alpha = 0; + tmp.need_magic_ca_pass = FALSE; + + tmp.u.gen7.wm_kernel = GEN6_WM_KERNEL_NOMASK; + tmp.u.gen7.nr_surfaces = 2; + tmp.u.gen7.nr_inputs = 1; + tmp.u.gen7.ve_id = 1; + + if (!kgem_check_bo(&sna->kgem, bo, NULL)) + _kgem_submit(&sna->kgem); + + gen7_emit_fill_state(sna, &tmp); + gen7_align_vertex(sna, &tmp); + + if (!gen7_get_rectangles(sna, &tmp, 1)) { + gen7_emit_fill_state(sna, &tmp); + gen7_get_rectangles(sna, &tmp, 1); + } + + DBG((" (%d, %d), (%d, %d)\n", x1, y1, x2, y2)); + OUT_VERTEX(x2, y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(x1, y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(x1, y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); + + gen7_vertex_flush(sna); + kgem_bo_destroy(&sna->kgem, tmp.src.bo); + _kgem_set_mode(&sna->kgem, KGEM_RENDER); + + return TRUE; +} + static void gen7_render_flush(struct sna *sna) { gen7_vertex_finish(sna, TRUE); @@ -3041,6 +3149,7 @@ Bool gen7_render_init(struct sna *sna) sna->render.fill_boxes = gen7_render_fill_boxes; sna->render.fill = gen7_render_fill; + sna->render.fill_one = gen7_render_fill_one; sna->render.flush = gen7_render_flush; sna->render.reset = gen7_render_reset; |