summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-10-17 23:06:30 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-10-18 10:29:33 +0100
commitf40e6ab50b264ef7eb7750f72ab7418c0d3dc9c1 (patch)
tree6239df05696dd60838177065f9411fe7cc7b2371
parent941e3504e049be8af50ca9df2d0aafe9eb477983 (diff)
sna/gen3: Prefer to use the BLT to clear the scratch glyph pixmaps
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/gen3_render.c40
-rw-r--r--src/sna/kgem.c23
-rw-r--r--src/sna/sna_glyphs.c27
3 files changed, 50 insertions, 40 deletions
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index bae65051..4dd027fb 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -49,8 +49,11 @@
#define NO_COPY 0
#define NO_COPY_BOXES 0
#define NO_FILL 0
+#define NO_FILL_ONE 0
#define NO_FILL_BOXES 0
+#define PREFER_BLT_FILL 1
+
enum {
SHADER_NONE = 0,
SHADER_ZERO,
@@ -2966,10 +2969,9 @@ gen3_emit_video_state(struct sna *sna,
S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) |
S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT) |
S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT));
- OUT_BATCH((2 << S6_DEPTH_TEST_FUNC_SHIFT) |
- (2 << S6_CBUF_SRC_BLEND_FACT_SHIFT) |
+ OUT_BATCH((2 << S6_CBUF_SRC_BLEND_FACT_SHIFT) |
(1 << S6_CBUF_DST_BLEND_FACT_SHIFT) |
- S6_COLOR_WRITE_ENABLE | (2 << S6_TRISTRIP_PV_SHIFT));
+ S6_COLOR_WRITE_ENABLE);
sna->render_state.gen3.last_blend = 0;
sna->render_state.gen3.last_sampler = 0;
@@ -3663,6 +3665,15 @@ gen3_render_fill_boxes_try_blt(struct sna *sna,
pixel, box, n);
}
+static inline Bool prefer_fill_blt(struct sna *sna)
+{
+#if PREFER_BLT_FILL
+ return true;
+#else
+ return sna->kgem.mode != KGEM_RENDER;
+#endif
+}
+
static Bool
gen3_render_fill_boxes(struct sna *sna,
CARD8 op,
@@ -3698,7 +3709,7 @@ gen3_render_fill_boxes(struct sna *sna,
dst, dst_bo,
box, n);
- if (sna->kgem.mode != KGEM_RENDER &&
+ if (prefer_fill_blt(sna) &&
gen3_render_fill_boxes_try_blt(sna, op, format, color,
dst, dst_bo,
box, n))
@@ -3803,7 +3814,7 @@ gen3_render_fill(struct sna *sna, uint8_t alu,
#endif
/* Prefer to use the BLT if already engaged */
- if (sna->kgem.mode != KGEM_RENDER &&
+ if (prefer_fill_blt(sna) &&
sna_blt_fill(sna, alu,
dst_bo, dst->drawable.bitsPerPixel,
color,
@@ -3875,13 +3886,13 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
{
struct sna_composite_op tmp;
-#if NO_FILL_BOXES
+#if NO_FILL_ONE
return gen3_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 &&
+ if (prefer_fill_blt(sna) &&
gen3_render_fill_one_try_blt(sna, dst, bo, color,
x1, y1, x2, y2, alu))
return TRUE;
@@ -3905,10 +3916,17 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
tmp.floats_per_vertex = 2;
tmp.floats_per_rect = 6;
- tmp.src.u.gen3.type = SHADER_CONSTANT;
- tmp.src.u.gen3.mode =
- sna_rgba_for_color(color, dst->drawable.depth);
- tmp.mask.u.gen3.mode = SHADER_NONE;
+ color = sna_rgba_for_color(color, dst->drawable.depth);
+ if (color == 0)
+ tmp.src.u.gen3.type = SHADER_ZERO;
+ else if (color == 0xff000000)
+ tmp.src.u.gen3.type = SHADER_BLACK;
+ else if (color == 0xffffffff)
+ tmp.src.u.gen3.type = SHADER_WHITE;
+ else
+ tmp.src.u.gen3.type = SHADER_CONSTANT;
+ tmp.src.u.gen3.mode = color;
+ tmp.mask.u.gen3.type = SHADER_NONE;
tmp.u.gen3.num_constants = 0;
if (!kgem_check_bo(&sna->kgem, bo, NULL)) {
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index a11e9553..4d876dbf 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1313,30 +1313,29 @@ int kgem_choose_tiling(struct kgem *kgem, int tiling, int width, int height, int
if (tiling < 0)
return tiling;
- if (tiling && width * bpp > 8 * 4096) {
+ if (tiling == I915_TILING_Y && height <= 16) {
+ DBG(("%s: too short [%d] for TILING_Y\n",
+ __FUNCTION__,height));
+ tiling = I915_TILING_X;
+ }
+ if (tiling && width * bpp >= 8 * 4096) {
DBG(("%s: TLB miss between lines %dx%d (pitch=%d), forcing tiling %d\n",
__FUNCTION__,
width, height, width*bpp/8,
tiling));
return -tiling;
}
+ if (tiling == I915_TILING_X && height < 4) {
+ DBG(("%s: too short [%d] for TILING_X\n",
+ __FUNCTION__, height));
+ tiling = I915_TILING_NONE;
+ }
/* Before the G33, we only have a small GTT to play with and tiled
* surfaces always require full fence regions and so cause excessive
* aperture thrashing.
*/
if (kgem->gen < 33) {
- if (tiling == I915_TILING_Y && height < 16) {
- DBG(("%s: too short [%d] for TILING_Y\n",
- __FUNCTION__,height));
- tiling = I915_TILING_X;
- }
- if (tiling == I915_TILING_X && height < 4) {
- DBG(("%s: too short [%d] for TILING_X\n",
- __FUNCTION__, height));
- tiling = I915_TILING_NONE;
- }
-
if (tiling == I915_TILING_X && width * bpp < 8*512/2) {
DBG(("%s: too thin [%d] for TILING_X\n",
__FUNCTION__, width));
diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index 4db5bafb..13b0ccaf 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -651,19 +651,16 @@ next_glyph:
return TRUE;
}
-static Bool
-clear_pixmap(struct sna *sna, PixmapPtr pixmap, PictFormat format)
+static void
+clear_pixmap(struct sna *sna, PixmapPtr pixmap)
{
- BoxRec box;
- xRenderColor color = { 0 };
-
- box.x1 = box.y1 = 0;
- box.x2 = pixmap->drawable.width;
- box.y2 = pixmap->drawable.height;
-
- return sna->render.fill_boxes(sna, PictOpClear, format, &color,
- pixmap, sna_pixmap_get_bo(pixmap),
- &box, 1);
+ struct sna_pixmap *priv = sna_pixmap(pixmap);
+ assert(priv->gpu_only);
+ sna->render.fill_one(sna, pixmap, priv->gpu_bo, 0,
+ 0, 0,
+ pixmap->drawable.width,
+ pixmap->drawable.height,
+ GXclear);
}
static Bool
@@ -742,11 +739,7 @@ glyphs_via_mask(struct sna *sna,
return FALSE;
ValidatePicture(mask);
-
- if (!clear_pixmap(sna, pixmap, mask->format)) {
- FreePicture(mask, 0);
- return FALSE;
- }
+ clear_pixmap(sna, pixmap);
memset(&tmp, 0, sizeof(tmp));
glyph_atlas = NULL;