summaryrefslogtreecommitdiff
path: root/src/sna/gen4_render.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-01-06 13:24:23 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-01-06 13:30:37 +0000
commit3244e4b23397f54ca76876dd76ebea9a0abd357e (patch)
tree076018b5e109c827620c0d6a0ffca3a654c12764 /src/sna/gen4_render.c
parentd3be77f87916e38af717bafaf2000becd5180d76 (diff)
Revert "sna/gen4+: Backport tight vertex packing for simple renderblits"
This reverts commit 8ff76fad1fadc5e309f9a12c30f883460a432049 and commit 48e4dc4bd4b2980f0f804f572d0e3fc1bb4bc21e. I forgot gen4 and gen5 do not have the 'non-normalized' bit in their sampler states.
Diffstat (limited to 'src/sna/gen4_render.c')
-rw-r--r--src/sna/gen4_render.c229
1 files changed, 89 insertions, 140 deletions
diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index ac099a53..e713d351 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -172,8 +172,6 @@ static const struct blendinfo {
#define SAMPLER_OFFSET(sf, se, mf, me, k) \
((((((sf) * EXTEND_COUNT + (se)) * FILTER_COUNT + (mf)) * EXTEND_COUNT + (me)) * KERNEL_COUNT + (k)) * 64)
-#define VERTEX_2s2s 0
-
static void
gen4_emit_pipelined_pointers(struct sna *sna,
const struct sna_composite_op *op,
@@ -2131,6 +2129,28 @@ gen4_copy_bind_surfaces(struct sna *sna, const struct sna_composite_op *op)
gen4_emit_state(sna, op, offset | dirty);
}
+static void
+gen4_render_copy_one(struct sna *sna,
+ const struct sna_composite_op *op,
+ int sx, int sy,
+ int w, int h,
+ int dx, int dy)
+{
+ gen4_get_rectangles(sna, op, 1, gen4_copy_bind_surfaces);
+
+ OUT_VERTEX(dx+w, dy+h);
+ OUT_VERTEX_F((sx+w)*op->src.scale[0]);
+ OUT_VERTEX_F((sy+h)*op->src.scale[1]);
+
+ OUT_VERTEX(dx, dy+h);
+ OUT_VERTEX_F(sx*op->src.scale[0]);
+ OUT_VERTEX_F((sy+h)*op->src.scale[1]);
+
+ OUT_VERTEX(dx, dy);
+ OUT_VERTEX_F(sx*op->src.scale[0]);
+ OUT_VERTEX_F(sy*op->src.scale[1]);
+}
+
static bool
gen4_render_copy_boxes(struct sna *sna, uint8_t alu,
PixmapPtr src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
@@ -2233,20 +2253,20 @@ fallback_blt:
extents.x2 - extents.x1,
extents.y2 - extents.y1))
goto fallback_tiled_dst;
-
- src_dx += tmp.src.offset[0];
- src_dy += tmp.src.offset[1];
} else {
tmp.src.bo = kgem_bo_reference(src_bo);
tmp.src.width = src->drawable.width;
tmp.src.height = src->drawable.height;
+ tmp.src.offset[0] = tmp.src.offset[1] = 0;
+ tmp.src.scale[0] = 1.f/src->drawable.width;
+ tmp.src.scale[1] = 1.f/src->drawable.height;
}
tmp.is_affine = true;
- tmp.floats_per_vertex = 2;
- tmp.floats_per_rect = 6;
+ tmp.floats_per_vertex = 3;
+ tmp.floats_per_rect = 9;
tmp.u.gen4.wm_kernel = WM_KERNEL;
- tmp.u.gen4.ve_id = VERTEX_2s2s;
+ tmp.u.gen4.ve_id = 2;
tmp.u.gen4.sf = 0;
if (!kgem_check_bo(&sna->kgem, dst_bo, src_bo, NULL)) {
@@ -2259,33 +2279,19 @@ fallback_blt:
dst_dy += tmp.dst.y;
tmp.dst.x = tmp.dst.y = 0;
+ src_dx += tmp.src.offset[0];
+ src_dy += tmp.src.offset[1];
+
gen4_copy_bind_surfaces(sna, &tmp);
gen4_align_vertex(sna, &tmp);
do {
- int n_this_time;
-
- n_this_time = gen4_get_rectangles(sna, &tmp, n,
- gen4_copy_bind_surfaces);
- n -= n_this_time;
-
- do {
- DBG((" (%d, %d) -> (%d, %d) + (%d, %d)\n",
- box->x1 + src_dx, box->y1 + src_dy,
- box->x1 + dst_dx, box->y1 + dst_dy,
- box->x2 - box->x1, box->y2 - box->y1));
- OUT_VERTEX(box->x2 + dst_dx, box->y2 + dst_dy);
- OUT_VERTEX(box->x2 + src_dx, box->y2 + src_dy);
-
- OUT_VERTEX(box->x1 + dst_dx, box->y2 + dst_dy);
- OUT_VERTEX(box->x1 + src_dx, box->y2 + src_dy);
-
- OUT_VERTEX(box->x1 + dst_dx, box->y1 + dst_dy);
- OUT_VERTEX(box->x1 + src_dx, box->y1 + src_dy);
-
- box++;
- } while (--n_this_time);
- } while (n);
+ gen4_render_copy_one(sna, &tmp,
+ box->x1 + src_dx, box->y1 + src_dy,
+ box->x2 - box->x1, box->y2 - box->y1,
+ box->x1 + dst_dx, box->y1 + dst_dy);
+ box++;
+ } while (--n);
gen4_vertex_flush(sna);
sna_render_composite_redirect_done(sna, &tmp);
@@ -2319,19 +2325,7 @@ gen4_render_copy_blt(struct sna *sna,
int16_t w, int16_t h,
int16_t dx, int16_t dy)
{
- DBG(("%s: src=(%d, %d), dst=(%d, %d), size=(%d, %d)\n", __FUNCTION__,
- sx, sy, dx, dy, w, h));
-
- gen4_get_rectangles(sna, &op->base, 1, gen4_copy_bind_surfaces);
-
- OUT_VERTEX(dx+w, dy+h);
- OUT_VERTEX(sx+w, sy+h);
-
- OUT_VERTEX(dx, dy+h);
- OUT_VERTEX(sx, sy+h);
-
- OUT_VERTEX(dx, dy);
- OUT_VERTEX(sx, sy);
+ gen4_render_copy_one(sna, &op->base, sx, sy, w, h, dx, dy);
}
static void
@@ -2339,8 +2333,6 @@ gen4_render_copy_done(struct sna *sna, const struct sna_copy_op *op)
{
if (sna->render.vertex_offset)
gen4_vertex_flush(sna);
-
- DBG(("%s()\n", __FUNCTION__));
}
static bool
@@ -2396,14 +2388,16 @@ fallback:
gen4_get_card_format(op->base.src.pict_format);
op->base.src.width = src->drawable.width;
op->base.src.height = src->drawable.height;
+ op->base.src.scale[0] = 1.f/src->drawable.width;
+ op->base.src.scale[1] = 1.f/src->drawable.height;
op->base.src.filter = SAMPLER_FILTER_NEAREST;
op->base.src.repeat = SAMPLER_EXTEND_NONE;
op->base.is_affine = true;
- op->base.floats_per_vertex = 2;
- op->base.floats_per_rect = 6;
+ op->base.floats_per_vertex = 3;
+ op->base.floats_per_rect = 9;
op->base.u.gen4.wm_kernel = WM_KERNEL;
- op->base.u.gen4.ve_id = VERTEX_2s2s;
+ op->base.u.gen4.ve_id = 2;
op->base.u.gen4.sf = 0;
if (!kgem_check_bo(&sna->kgem, dst_bo, src_bo, NULL)) {
@@ -2429,6 +2423,26 @@ fallback:
return true;
}
+static void
+gen4_render_fill_rectangle(struct sna *sna,
+ const struct sna_composite_op *op,
+ int x, int y, int w, int h)
+{
+ gen4_get_rectangles(sna, op, 1, gen4_bind_surfaces);
+
+ OUT_VERTEX(x+w, y+h);
+ OUT_VERTEX_F(1);
+ OUT_VERTEX_F(1);
+
+ OUT_VERTEX(x, y+h);
+ OUT_VERTEX_F(0);
+ OUT_VERTEX_F(1);
+
+ OUT_VERTEX(x, y);
+ OUT_VERTEX_F(0);
+ OUT_VERTEX_F(0);
+}
+
static bool
gen4_render_fill_boxes(struct sna *sna,
CARD8 op,
@@ -2500,10 +2514,10 @@ gen4_render_fill_boxes(struct sna *sna,
gen4_channel_init_solid(sna, &tmp.src, pixel);
tmp.is_affine = true;
- tmp.floats_per_vertex = 2;
- tmp.floats_per_rect = 6;
+ tmp.floats_per_vertex = 3;
+ tmp.floats_per_rect = 9;
tmp.u.gen4.wm_kernel = WM_KERNEL;
- tmp.u.gen4.ve_id = VERTEX_2s2s;
+ tmp.u.gen4.ve_id = 2;
tmp.u.gen4.sf = 0;
if (!kgem_check_bo(&sna->kgem, dst_bo, NULL)) {
@@ -2515,27 +2529,12 @@ gen4_render_fill_boxes(struct sna *sna,
gen4_align_vertex(sna, &tmp);
do {
- int n_this_time;
-
- n_this_time = gen4_get_rectangles(sna, &tmp, n,
- gen4_bind_surfaces);
- n -= n_this_time;
-
- do {
- DBG((" (%d, %d), (%d, %d)\n",
- box->x1, box->y1, box->x2, box->y2));
- OUT_VERTEX(box->x2, box->y2);
- OUT_VERTEX(1, 1);
-
- OUT_VERTEX(box->x1, box->y2);
- OUT_VERTEX(0, 1);
-
- OUT_VERTEX(box->x1, box->y1);
- OUT_VERTEX(0, 0);
-
- box++;
- } while (--n_this_time);
- } while (n);
+ gen4_render_fill_rectangle(sna, &tmp,
+ box->x1, box->y1,
+ box->x2 - box->x1,
+ box->y2 - box->y1);
+ box++;
+ } while (--n);
gen4_vertex_flush(sna);
kgem_bo_destroy(&sna->kgem, tmp.src.bo);
@@ -2543,22 +2542,10 @@ gen4_render_fill_boxes(struct sna *sna,
}
static void
-gen4_render_fill_op_blt(struct sna *sna,
- const struct sna_fill_op *op,
+gen4_render_fill_op_blt(struct sna *sna, const struct sna_fill_op *op,
int16_t x, int16_t y, int16_t w, int16_t h)
{
- DBG(("%s (%d, %d)x(%d, %d)\n", __FUNCTION__, x,y,w,h));
-
- gen4_get_rectangles(sna, &op->base, 1, gen4_bind_surfaces);
-
- OUT_VERTEX(x+w, y+h);
- OUT_VERTEX(1, 1);
-
- OUT_VERTEX(x, y+h);
- OUT_VERTEX(0, 1);
-
- OUT_VERTEX(x, y);
- OUT_VERTEX(0, 0);
+ gen4_render_fill_rectangle(sna, &op->base, x, y, w, h);
}
fastcall static void
@@ -2566,19 +2553,9 @@ gen4_render_fill_op_box(struct sna *sna,
const struct sna_fill_op *op,
const BoxRec *box)
{
- DBG(("%s: (%d, %d),(%d, %d)\n", __FUNCTION__,
- box->x1, box->y1, box->x2, box->y2));
-
- gen4_get_rectangles(sna, &op->base, 1, gen4_bind_surfaces);
-
- OUT_VERTEX(box->x2, box->y2);
- OUT_VERTEX(1, 1);
-
- OUT_VERTEX(box->x1, box->y2);
- OUT_VERTEX(0, 1);
-
- OUT_VERTEX(box->x1, box->y1);
- OUT_VERTEX(0, 0);
+ gen4_render_fill_rectangle(sna, &op->base,
+ box->x1, box->y1,
+ box->x2-box->x1, box->y2-box->y1);
}
fastcall static void
@@ -2587,28 +2564,12 @@ gen4_render_fill_op_boxes(struct sna *sna,
const BoxRec *box,
int nbox)
{
- DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__,
- box->x1, box->y1, box->x2, box->y2, nbox));
-
do {
- int nbox_this_time;
-
- nbox_this_time = gen4_get_rectangles(sna, &op->base, nbox,
- gen4_bind_surfaces);
- nbox -= nbox_this_time;
-
- do {
- OUT_VERTEX(box->x2, box->y2);
- OUT_VERTEX(1, 1);
-
- OUT_VERTEX(box->x1, box->y2);
- OUT_VERTEX(0, 1);
-
- OUT_VERTEX(box->x1, box->y1);
- OUT_VERTEX(0, 0);
- box++;
- } while (--nbox_this_time);
- } while (nbox);
+ gen4_render_fill_rectangle(sna, &op->base,
+ box->x1, box->y1,
+ box->x2-box->x1, box->y2-box->y1);
+ box++;
+ } while (--nbox);
}
static void
@@ -2617,8 +2578,6 @@ gen4_render_fill_op_done(struct sna *sna, const struct sna_fill_op *op)
if (sna->render.vertex_offset)
gen4_vertex_flush(sna);
kgem_bo_destroy(&sna->kgem, op->base.src.bo);
-
- DBG(("%s()\n", __FUNCTION__));
}
static bool
@@ -2661,10 +2620,10 @@ gen4_render_fill(struct sna *sna, uint8_t alu,
op->base.mask.bo = NULL;
op->base.is_affine = true;
- op->base.floats_per_vertex = 2;
- op->base.floats_per_rect = 6;
+ op->base.floats_per_vertex = 3;
+ op->base.floats_per_rect = 9;
op->base.u.gen4.wm_kernel = WM_KERNEL;
- op->base.u.gen4.ve_id = VERTEX_2s2s;
+ op->base.u.gen4.ve_id = 2;
op->base.u.gen4.sf = 0;
if (!kgem_check_bo(&sna->kgem, dst_bo, NULL)) {
@@ -2738,13 +2697,13 @@ gen4_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
tmp.mask.bo = NULL;
tmp.is_affine = true;
- tmp.floats_per_vertex = 2;
- tmp.floats_per_rect = 6;
+ tmp.floats_per_vertex = 3;
+ tmp.floats_per_rect = 9;
tmp.has_component_alpha = false;
tmp.need_magic_ca_pass = false;
tmp.u.gen4.wm_kernel = WM_KERNEL;
- tmp.u.gen4.ve_id = VERTEX_2s2s;
+ tmp.u.gen4.ve_id = 2;
tmp.u.gen4.sf = 0;
if (!kgem_check_bo(&sna->kgem, bo, NULL)) {
@@ -2755,17 +2714,7 @@ gen4_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo,
gen4_bind_surfaces(sna, &tmp);
gen4_align_vertex(sna, &tmp);
- gen4_get_rectangles(sna, &tmp, 1, gen4_bind_surfaces);
-
- DBG((" (%d, %d), (%d, %d)\n", x1, y1, x2, y2));
- OUT_VERTEX(x2, y2);
- OUT_VERTEX(1, 1);
-
- OUT_VERTEX(x1, y2);
- OUT_VERTEX(0, 1);
-
- OUT_VERTEX(x1, y1);
- OUT_VERTEX(0, 0);
+ gen4_render_fill_rectangle(sna, &tmp, x1, y1, x2 - x1, y2 - y1);
gen4_vertex_flush(sna);
kgem_bo_destroy(&sna->kgem, tmp.src.bo);