Subversion Repositories Kolibri OS

Rev

Rev 3769 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3769 Rev 4251
Line 28... Line 28...
28
 *    Keith Packard 
28
 *    Keith Packard 
29
 *    Chris Wilson 
29
 *    Chris Wilson 
30
 *
30
 *
31
 */
31
 */
Line 32... Line -...
32
 
-
 
33
#ifdef HAVE_CONFIG_H
-
 
34
#include "config.h"
-
 
Line 35... Line 32...
35
#endif
32
 
36
 
33
 
37
#include "sna.h"
34
#include "sna.h"
38
#include "sna_reg.h"
35
#include "sna_reg.h"
Line 52... Line 49...
52
#define NO_FILL 0
49
#define NO_FILL 0
53
#define NO_FILL_BOXES 0
50
#define NO_FILL_BOXES 0
54
#define NO_FILL_ONE 0
51
#define NO_FILL_ONE 0
55
#define NO_FILL_CLEAR 0
52
#define NO_FILL_CLEAR 0
Line 56... Line 53...
56
 
53
 
57
#define NO_RING_SWITCH 1
54
#define NO_RING_SWITCH 0
Line 58... Line 55...
58
#define PREFER_RENDER 0
55
#define PREFER_RENDER 0
59
 
56
 
60
#define USE_8_PIXEL_DISPATCH 1
57
#define USE_8_PIXEL_DISPATCH 1
Line 66... Line 63...
66
#endif
63
#endif
Line 67... Line 64...
67
 
64
 
Line 68... Line 65...
68
#define GEN6_MAX_SIZE 8192
65
#define GEN6_MAX_SIZE 8192
-
 
66
 
69
 
67
struct gt_info {
70
struct gt_info {
68
	const char *name;
71
	int max_vs_threads;
69
	int max_vs_threads;
72
	int max_gs_threads;
70
	int max_gs_threads;
73
	int max_wm_threads;
71
	int max_wm_threads;
Line 77... Line 75...
77
		int max_gs_entries;
75
		int max_gs_entries;
78
	} urb;
76
	} urb;
79
};
77
};
Line 80... Line 78...
80
 
78
 
-
 
79
static const struct gt_info gt1_info = {
81
static const struct gt_info gt1_info = {
80
	.name = "Sandybridge (gen6, gt1)",
82
	.max_vs_threads = 24,
81
	.max_vs_threads = 24,
83
	.max_gs_threads = 21,
82
	.max_gs_threads = 21,
84
	.max_wm_threads = 40,
83
	.max_wm_threads = 40,
85
	.urb = { 32, 256, 256 },
84
	.urb = { 32, 256, 256 },
Line 86... Line 85...
86
};
85
};
-
 
86
 
87
 
87
static const struct gt_info gt2_info = {
88
static const struct gt_info gt2_info = {
88
	.name = "Sandybridge (gen6, gt2)",
89
	.max_vs_threads = 60,
89
	.max_vs_threads = 60,
90
	.max_gs_threads = 60,
90
	.max_gs_threads = 60,
91
	.max_wm_threads = 80,
91
	.max_wm_threads = 80,
Line 252... Line 252...
252
		return -1;
252
		return -1;
253
	case PICT_a8r8g8b8:
253
	case PICT_a8r8g8b8:
254
    return GEN6_SURFACEFORMAT_B8G8R8A8_UNORM;
254
    return GEN6_SURFACEFORMAT_B8G8R8A8_UNORM;
255
	case PICT_x8r8g8b8:
255
	case PICT_x8r8g8b8:
256
		return GEN6_SURFACEFORMAT_B8G8R8X8_UNORM;
256
		return GEN6_SURFACEFORMAT_B8G8R8X8_UNORM;
257
	case PICT_a8:
-
 
258
		return GEN6_SURFACEFORMAT_A8_UNORM;
-
 
259
	};
-
 
260
 
-
 
261
/*
-
 
262
	switch (format) {
-
 
263
	default:
-
 
264
		return -1;
-
 
265
	case PICT_a8r8g8b8:
-
 
266
		return GEN6_SURFACEFORMAT_B8G8R8A8_UNORM;
-
 
267
	case PICT_x8r8g8b8:
-
 
268
		return GEN6_SURFACEFORMAT_B8G8R8X8_UNORM;
-
 
269
	case PICT_a8b8g8r8:
257
	case PICT_a8b8g8r8:
270
		return GEN6_SURFACEFORMAT_R8G8B8A8_UNORM;
258
		return GEN6_SURFACEFORMAT_R8G8B8A8_UNORM;
271
	case PICT_x8b8g8r8:
259
	case PICT_x8b8g8r8:
272
		return GEN6_SURFACEFORMAT_R8G8B8X8_UNORM;
260
		return GEN6_SURFACEFORMAT_R8G8B8X8_UNORM;
273
	case PICT_a2r10g10b10:
261
	case PICT_a2r10g10b10:
Line 283... Line 271...
283
	case PICT_a8:
271
	case PICT_a8:
284
		return GEN6_SURFACEFORMAT_A8_UNORM;
272
		return GEN6_SURFACEFORMAT_A8_UNORM;
285
	case PICT_a4r4g4b4:
273
	case PICT_a4r4g4b4:
286
		return GEN6_SURFACEFORMAT_B4G4R4A4_UNORM;
274
		return GEN6_SURFACEFORMAT_B4G4R4A4_UNORM;
287
	}
275
	}
288
 */
-
 
289
}
276
}
Line 290... Line 277...
290
 
277
 
291
static uint32_t gen6_get_dest_format(PictFormat format)
278
static uint32_t gen6_get_dest_format(PictFormat format)
292
{
279
{
Line 401... Line 388...
401
gen6_choose_composite_kernel(int op, bool has_mask, bool is_ca, bool is_affine)
388
gen6_choose_composite_kernel(int op, bool has_mask, bool is_ca, bool is_affine)
402
{
389
{
403
	int base;
390
	int base;
Line 404... Line 391...
404
 
391
 
405
	if (has_mask) {
-
 
406
 
392
	if (has_mask) {
407
		if (is_ca) {
393
		if (is_ca) {
408
			if (gen6_blend_op[op].src_alpha)
394
			if (gen6_blend_op[op].src_alpha)
409
				base = GEN6_WM_KERNEL_MASKSA;
395
				base = GEN6_WM_KERNEL_MASKSA;
410
			else
396
			else
411
				base = GEN6_WM_KERNEL_MASKCA;
397
				base = GEN6_WM_KERNEL_MASKCA;
412
		} else
398
		} else
413
			base = GEN6_WM_KERNEL_MASK;
-
 
414
 
399
			base = GEN6_WM_KERNEL_MASK;
415
	} else
400
	} else
Line 416... Line 401...
416
		base = GEN6_WM_KERNEL_NOMASK;
401
		base = GEN6_WM_KERNEL_NOMASK;
417
 
402
 
Line 887... Line 872...
887
		const struct sna_composite_op *op,
872
		const struct sna_composite_op *op,
888
		uint16_t wm_binding_table)
873
		uint16_t wm_binding_table)
889
{
874
{
890
	bool need_stall = wm_binding_table & 1;
875
	bool need_stall = wm_binding_table & 1;
Line -... Line 876...
-
 
876
 
-
 
877
	assert(op->dst.bo->exec);
891
 
878
 
892
	if (gen6_emit_cc(sna, GEN6_BLEND(op->u.gen6.flags)))
879
	if (gen6_emit_cc(sna, GEN6_BLEND(op->u.gen6.flags)))
893
		need_stall = false;
880
		need_stall = false;
894
	gen6_emit_sampler(sna, GEN6_SAMPLER(op->u.gen6.flags));
881
	gen6_emit_sampler(sna, GEN6_SAMPLER(op->u.gen6.flags));
895
	gen6_emit_sf(sna, GEN6_VERTEX(op->u.gen6.flags) >> 2);
882
	gen6_emit_sf(sna, GEN6_VERTEX(op->u.gen6.flags) >> 2);
Line 900... Line 887...
900
	if (gen6_emit_drawing_rectangle(sna, op))
887
	if (gen6_emit_drawing_rectangle(sna, op))
901
		need_stall = false;
888
		need_stall = false;
902
	if (kgem_bo_is_dirty(op->src.bo) || kgem_bo_is_dirty(op->mask.bo)) {
889
	if (kgem_bo_is_dirty(op->src.bo) || kgem_bo_is_dirty(op->mask.bo)) {
903
        gen6_emit_flush(sna);
890
        gen6_emit_flush(sna);
904
        kgem_clear_dirty(&sna->kgem);
891
        kgem_clear_dirty(&sna->kgem);
905
		if (op->dst.bo->exec)
892
		assert(op->dst.bo->exec);
906
		kgem_bo_mark_dirty(op->dst.bo);
893
		kgem_bo_mark_dirty(op->dst.bo);
907
		need_stall = false;
894
		need_stall = false;
908
	}
895
	}
909
	if (need_stall) {
896
	if (need_stall) {
910
		OUT_BATCH(GEN6_PIPE_CONTROL | (4 - 2));
897
		OUT_BATCH(GEN6_PIPE_CONTROL | (4 - 2));
Line 1037... Line 1024...
1037
}
1024
}
Line 1038... Line 1025...
1038
 
1025
 
1039
static uint32_t
1026
static uint32_t
1040
gen6_tiling_bits(uint32_t tiling)
1027
gen6_tiling_bits(uint32_t tiling)
1041
{
-
 
1042
    return 0;
-
 
1043
/*
1028
{
1044
	switch (tiling) {
1029
	switch (tiling) {
1045
	default: assert(0);
1030
	default: assert(0);
1046
	case I915_TILING_NONE: return 0;
1031
	case I915_TILING_NONE: return 0;
1047
	case I915_TILING_X: return GEN6_SURFACE_TILED;
1032
	case I915_TILING_X: return GEN6_SURFACE_TILED;
1048
	case I915_TILING_Y: return GEN6_SURFACE_TILED | GEN6_SURFACE_TILED_Y;
1033
	case I915_TILING_Y: return GEN6_SURFACE_TILED | GEN6_SURFACE_TILED_Y;
1049
	}
-
 
1050
*/
1034
	}
Line 1051... Line 1035...
1051
}
1035
}
1052
 
1036
 
1053
/**
1037
/**
Line 1066... Line 1050...
1066
	uint32_t domains;
1050
	uint32_t domains;
1067
	uint16_t offset;
1051
	uint16_t offset;
1068
	uint32_t is_scanout = is_dst && bo->scanout;
1052
	uint32_t is_scanout = is_dst && bo->scanout;
Line 1069... Line 1053...
1069
 
1053
 
1070
	/* After the first bind, we manage the cache domains within the batch */
1054
	/* After the first bind, we manage the cache domains within the batch */
1071
	offset = kgem_bo_get_binding(bo, format | is_scanout << 31);
1055
	offset = kgem_bo_get_binding(bo, format | is_dst << 30 | is_scanout << 31);
1072
	if (offset) {
1056
	if (offset) {
1073
		DBG(("[%x]  bo(handle=%d), format=%d, reuse %s binding\n",
1057
		DBG(("[%x]  bo(handle=%d), format=%d, reuse %s binding\n",
1074
		     offset, bo->handle, format,
1058
		     offset, bo->handle, format,
1075
		     is_dst ? "render" : "sampler"));
1059
		     is_dst ? "render" : "sampler"));
Line 1082... Line 1066...
1082
		sizeof(struct gen6_surface_state_padded) / sizeof(uint32_t);
1066
		sizeof(struct gen6_surface_state_padded) / sizeof(uint32_t);
1083
	ss = sna->kgem.batch + offset;
1067
	ss = sna->kgem.batch + offset;
1084
	ss[0] = (GEN6_SURFACE_2D << GEN6_SURFACE_TYPE_SHIFT |
1068
	ss[0] = (GEN6_SURFACE_2D << GEN6_SURFACE_TYPE_SHIFT |
1085
		 GEN6_SURFACE_BLEND_ENABLED |
1069
		 GEN6_SURFACE_BLEND_ENABLED |
1086
		 format << GEN6_SURFACE_FORMAT_SHIFT);
1070
		 format << GEN6_SURFACE_FORMAT_SHIFT);
1087
	if (is_dst)
1071
	if (is_dst) {
-
 
1072
		ss[0] |= GEN6_SURFACE_RC_READ_WRITE;
1088
		domains = I915_GEM_DOMAIN_RENDER << 16 |I915_GEM_DOMAIN_RENDER;
1073
		domains = I915_GEM_DOMAIN_RENDER << 16 |I915_GEM_DOMAIN_RENDER;
1089
	else
1074
	} else
1090
		domains = I915_GEM_DOMAIN_SAMPLER << 16;
1075
		domains = I915_GEM_DOMAIN_SAMPLER << 16;
1091
	ss[1] = kgem_add_reloc(&sna->kgem, offset + 1, bo, domains, 0);
1076
	ss[1] = kgem_add_reloc(&sna->kgem, offset + 1, bo, domains, 0);
1092
	ss[2] = ((width - 1)  << GEN6_SURFACE_WIDTH_SHIFT |
1077
	ss[2] = ((width - 1)  << GEN6_SURFACE_WIDTH_SHIFT |
1093
		 (height - 1) << GEN6_SURFACE_HEIGHT_SHIFT);
1078
		 (height - 1) << GEN6_SURFACE_HEIGHT_SHIFT);
1094
	assert(bo->pitch <= (1 << 18));
1079
	assert(bo->pitch <= (1 << 18));
1095
	ss[3] = (gen6_tiling_bits(bo->tiling) |
1080
	ss[3] = (gen6_tiling_bits(bo->tiling) |
1096
		 (bo->pitch - 1) << GEN6_SURFACE_PITCH_SHIFT);
1081
		 (bo->pitch - 1) << GEN6_SURFACE_PITCH_SHIFT);
1097
	ss[4] = 0;
1082
	ss[4] = 0;
1098
	ss[5] = is_scanout ? 0 : 3 << 16;
1083
	ss[5] = (is_scanout || bo->io) ? 0 : 3 << 16;
Line 1099... Line 1084...
1099
 
1084
 
Line 1100... Line 1085...
1100
	kgem_bo_set_binding(bo, format | is_scanout << 31, offset);
1085
	kgem_bo_set_binding(bo, format | is_dst << 30 | is_scanout << 31, offset);
1101
 
1086
 
1102
	DBG(("[%x] bind bo(handle=%d, addr=%d), format=%d, width=%d, height=%d, pitch=%d, tiling=%d -> %s\n",
1087
	DBG(("[%x] bind bo(handle=%d, addr=%d), format=%d, width=%d, height=%d, pitch=%d, tiling=%d -> %s\n",
1103
	     offset, bo->handle, ss[1],
1088
	     offset, bo->handle, ss[1],
Line 1208... Line 1193...
1208
				      int want,
1193
				      int want,
1209
				      void (*emit_state)(struct sna *, const struct sna_composite_op *op))
1194
				      void (*emit_state)(struct sna *, const struct sna_composite_op *op))
1210
{
1195
{
1211
	int rem;
1196
	int rem;
Line -... Line 1197...
-
 
1197
 
-
 
1198
	assert(want);
1212
 
1199
 
1213
start:
1200
start:
1214
	rem = vertex_space(sna);
1201
	rem = vertex_space(sna);
1215
	if (unlikely(rem < op->floats_per_rect)) {
1202
	if (unlikely(rem < op->floats_per_rect)) {
1216
		DBG(("flushing vbo for %s: %d < %d\n",
1203
		DBG(("flushing vbo for %s: %d < %d\n",
1217
		     __FUNCTION__, rem, op->floats_per_rect));
1204
		     __FUNCTION__, rem, op->floats_per_rect));
1218
		rem = gen6_get_rectangles__flush(sna, op);
1205
		rem = gen6_get_rectangles__flush(sna, op);
1219
		if (unlikely(rem == 0))
1206
		if (unlikely(rem == 0))
1220
			goto flush;
1207
			goto flush;
Line 1221... Line 1208...
1221
	}
1208
	}
1222
 
1209
 
1223
	if (unlikely(sna->render.vertex_offset == 0 &&
1210
	if (unlikely(sna->render.vertex_offset == 0)) {
-
 
1211
		if (!gen6_rectangle_begin(sna, op))
-
 
1212
		goto flush;
-
 
1213
		else
Line -... Line 1214...
-
 
1214
			goto start;
-
 
1215
	}
1224
		     !gen6_rectangle_begin(sna, op)))
1216
 
1225
		goto flush;
1217
	assert(rem <= vertex_space(sna));
Line 1226... Line 1218...
1226
 
1218
	assert(op->floats_per_rect <= rem);
1227
	if (want > 1 && want * op->floats_per_rect > rem)
1219
	if (want > 1 && want * op->floats_per_rect > rem)
Line 1338... Line 1330...
1338
		sna->render_state.gen6.floats_per_vertex = op->floats_per_vertex;
1330
		sna->render_state.gen6.floats_per_vertex = op->floats_per_vertex;
1339
	}
1331
	}
1340
	assert((sna->render.vertex_used % op->floats_per_vertex) == 0);
1332
	assert((sna->render.vertex_used % op->floats_per_vertex) == 0);
1341
}
1333
}
Line 1342... Line -...
1342
 
-
 
1343
 
1334
 
1344
fastcall static void
1335
fastcall static void
1345
gen6_render_composite_blt(struct sna *sna,
1336
gen6_render_composite_blt(struct sna *sna,
1346
			  const struct sna_composite_op *op,
1337
			  const struct sna_composite_op *op,
1347
			  const struct sna_composite_rectangles *r)
1338
			  const struct sna_composite_rectangles *r)
1348
{
1339
{
1349
	gen6_get_rectangles(sna, op, 1, gen6_emit_composite_state);
1340
	gen6_get_rectangles(sna, op, 1, gen6_emit_composite_state);
1350
	op->prim_emit(sna, op, r);
1341
	op->prim_emit(sna, op, r);
Line 1351... Line 1342...
1351
}
1342
}
1352
 
-
 
1353
#if 0
1343
 
1354
 
1344
#if 0
1355
fastcall static void
1345
fastcall static void
1356
gen6_render_composite_box(struct sna *sna,
1346
gen6_render_composite_box(struct sna *sna,
1357
			  const struct sna_composite_op *op,
1347
			  const struct sna_composite_op *op,
Line 1460... Line 1450...
1460
		sna_vertex_lock(&sna->render);
1450
		sna_vertex_lock(&sna->render);
1461
		sna_vertex_release__locked(&sna->render);
1451
		sna_vertex_release__locked(&sna->render);
1462
	} while (nbox);
1452
	} while (nbox);
1463
	sna_vertex_unlock(&sna->render);
1453
	sna_vertex_unlock(&sna->render);
1464
}
1454
}
1465
 
-
 
1466
#endif
1455
#endif
Line 1467... Line 1456...
1467
 
1456
 
1468
#ifndef MAX
1457
#ifndef MAX
1469
#define MAX(a,b) ((a) > (b) ? (a) : (b))
1458
#define MAX(a,b) ((a) > (b) ? (a) : (b))
Line 1500... Line 1489...
1500
 
1489
 
1501
	return sna_static_stream_offsetof(stream, base);
1490
	return sna_static_stream_offsetof(stream, base);
Line 1502... Line 1491...
1502
}
1491
}
1503
 
-
 
1504
#if 0
1492
 
1505
 
1493
#if 0
1506
static uint32_t gen6_bind_video_source(struct sna *sna,
1494
static uint32_t gen6_bind_video_source(struct sna *sna,
1507
				       struct kgem_bo *src_bo,
1495
				       struct kgem_bo *src_bo,
1508
				       uint32_t src_offset,
1496
				       uint32_t src_offset,
Line 1604... Line 1592...
1604
static bool
1592
static bool
1605
gen6_render_video(struct sna *sna,
1593
gen6_render_video(struct sna *sna,
1606
		  struct sna_video *video,
1594
		  struct sna_video *video,
1607
		  struct sna_video_frame *frame,
1595
		  struct sna_video_frame *frame,
1608
		  RegionPtr dstRegion,
1596
		  RegionPtr dstRegion,
1609
		  short src_w, short src_h,
-
 
1610
		  short drw_w, short drw_h,
-
 
1611
		  short dx, short dy,
-
 
1612
		  PixmapPtr pixmap)
1597
		  PixmapPtr pixmap)
1613
{
1598
{
1614
	struct sna_composite_op tmp;
1599
	struct sna_composite_op tmp;
-
 
1600
	int dst_width = dstRegion->extents.x2 - dstRegion->extents.x1;
-
 
1601
	int dst_height = dstRegion->extents.y2 - dstRegion->extents.y1;
-
 
1602
	int src_width = frame->src.x2 - frame->src.x1;
-
 
1603
	int src_height = frame->src.y2 - frame->src.y1;
1615
	int nbox, pix_xoff, pix_yoff;
1604
	float src_offset_x, src_offset_y;
1616
	float src_scale_x, src_scale_y;
1605
	float src_scale_x, src_scale_y;
-
 
1606
	int nbox, pix_xoff, pix_yoff;
1617
	struct sna_pixmap *priv;
1607
	struct sna_pixmap *priv;
1618
	unsigned filter;
1608
	unsigned filter;
1619
	BoxPtr box;
1609
	BoxPtr box;
Line 1620... Line 1610...
1620
 
1610
 
-
 
1611
	DBG(("%s: src=(%d, %d), dst=(%d, %d), %ldx[(%d, %d), (%d, %d)...]\n",
1621
	DBG(("%s: src=(%d, %d), dst=(%d, %d), %dx[(%d, %d), (%d, %d)...]\n",
1612
	     __FUNCTION__,
1622
	     __FUNCTION__, src_w, src_h, drw_w, drw_h,
1613
	     src_width, src_height, dst_width, dst_height,
1623
	     REGION_NUM_RECTS(dstRegion),
1614
	     (long)REGION_NUM_RECTS(dstRegion),
1624
	     REGION_EXTENTS(NULL, dstRegion)->x1,
1615
	     REGION_EXTENTS(NULL, dstRegion)->x1,
1625
	     REGION_EXTENTS(NULL, dstRegion)->y1,
1616
	     REGION_EXTENTS(NULL, dstRegion)->y1,
1626
	     REGION_EXTENTS(NULL, dstRegion)->x2,
1617
	     REGION_EXTENTS(NULL, dstRegion)->x2,
Line 1642... Line 1633...
1642
	tmp.mask.bo = NULL;
1633
	tmp.mask.bo = NULL;
Line 1643... Line 1634...
1643
 
1634
 
1644
	tmp.floats_per_vertex = 3;
1635
	tmp.floats_per_vertex = 3;
Line 1645... Line 1636...
1645
	tmp.floats_per_rect = 9;
1636
	tmp.floats_per_rect = 9;
1646
 
1637
 
1647
	if (src_w == drw_w && src_h == drw_h)
1638
	if (src_width == dst_width && src_height == dst_height)
1648
		filter = SAMPLER_FILTER_NEAREST;
1639
		filter = SAMPLER_FILTER_NEAREST;
Line 1649... Line 1640...
1649
	else
1640
	else
Line 1678... Line 1669...
1678
#else
1669
#else
1679
	pix_xoff = 0;
1670
	pix_xoff = 0;
1680
	pix_yoff = 0;
1671
	pix_yoff = 0;
1681
#endif
1672
#endif
Line 1682... Line 1673...
1682
 
1673
 
1683
	/* Use normalized texture coordinates */
1674
	src_scale_x = (float)src_width / dst_width / frame->width;
-
 
1675
	src_offset_x = (float)frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x;
1684
	src_scale_x = ((float)src_w / frame->width) / (float)drw_w;
1676
 
-
 
1677
	src_scale_y = (float)src_height / dst_height / frame->height;
Line 1685... Line 1678...
1685
	src_scale_y = ((float)src_h / frame->height) / (float)drw_h;
1678
	src_offset_y = (float)frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y;
1686
 
1679
 
1687
	box = REGION_RECTS(dstRegion);
1680
	box = REGION_RECTS(dstRegion);
1688
	nbox = REGION_NUM_RECTS(dstRegion);
1681
	nbox = REGION_NUM_RECTS(dstRegion);
Line 1695... Line 1688...
1695
		r.y2 = box->y2 + pix_yoff;
1688
		r.y2 = box->y2 + pix_yoff;
Line 1696... Line 1689...
1696
 
1689
 
Line 1697... Line 1690...
1697
		gen6_get_rectangles(sna, &tmp, 1, gen6_emit_video_state);
1690
		gen6_get_rectangles(sna, &tmp, 1, gen6_emit_video_state);
1698
 
1691
 
1699
		OUT_VERTEX(r.x2, r.y2);
1692
		OUT_VERTEX(r.x2, r.y2);
Line 1700... Line 1693...
1700
		OUT_VERTEX_F((box->x2 - dx) * src_scale_x);
1693
		OUT_VERTEX_F(box->x2 * src_scale_x + src_offset_x);
1701
		OUT_VERTEX_F((box->y2 - dy) * src_scale_y);
1694
		OUT_VERTEX_F(box->y2 * src_scale_y + src_offset_y);
1702
 
1695
 
Line 1703... Line 1696...
1703
		OUT_VERTEX(r.x1, r.y2);
1696
		OUT_VERTEX(r.x1, r.y2);
1704
		OUT_VERTEX_F((box->x1 - dx) * src_scale_x);
1697
		OUT_VERTEX_F(box->x1 * src_scale_x + src_offset_x);
1705
		OUT_VERTEX_F((box->y2 - dy) * src_scale_y);
1698
		OUT_VERTEX_F(box->y2 * src_scale_y + src_offset_y);
Line 1706... Line 1699...
1706
 
1699
 
1707
		OUT_VERTEX(r.x1, r.y1);
1700
		OUT_VERTEX(r.x1, r.y1);
1708
		OUT_VERTEX_F((box->x1 - dx) * src_scale_x);
1701
		OUT_VERTEX_F(box->x1 * src_scale_x + src_offset_x);
1709
		OUT_VERTEX_F((box->y1 - dy) * src_scale_y);
1702
		OUT_VERTEX_F(box->y1 * src_scale_y + src_offset_y);
1710
 
1703
 
1711
		if (!DAMAGE_IS_ALL(priv->gpu_damage)) {
1704
		if (!DAMAGE_IS_ALL(priv->gpu_damage)) {
1712
			sna_damage_add_box(&priv->gpu_damage, &r);
-
 
Line 1713... Line 1705...
1713
			sna_damage_subtract_box(&priv->cpu_damage, &r);
1705
			sna_damage_add_box(&priv->gpu_damage, &r);
1714
		}
1706
			sna_damage_subtract_box(&priv->cpu_damage, &r);
1715
		box++;
1707
		}
Line 1820... Line 1812...
1820
	channel->filter = gen6_filter(channel->filter);
1812
	channel->filter = gen6_filter(channel->filter);
1821
	if (channel->card_format == (unsigned)-1)
1813
	if (channel->card_format == (unsigned)-1)
1822
		channel->card_format = gen6_get_card_format(channel->pict_format);
1814
		channel->card_format = gen6_get_card_format(channel->pict_format);
1823
	assert(channel->card_format != (unsigned)-1);
1815
	assert(channel->card_format != (unsigned)-1);
1824
}
1816
}
1825
 
-
 
1826
#endif
1817
#endif
Line 1827... Line 1818...
1827
 
1818
 
1828
static void gen6_render_composite_done(struct sna *sna,
1819
static void gen6_render_composite_done(struct sna *sna,
1829
                       const struct sna_composite_op *op)
1820
                       const struct sna_composite_op *op)
Line 1835... Line 1826...
1835
		gen4_vertex_flush(sna);
1826
		gen4_vertex_flush(sna);
1836
        gen6_magic_ca_pass(sna, op);
1827
        gen6_magic_ca_pass(sna, op);
1837
    }
1828
    }
Line 1838... Line -...
1838
 
-
 
1839
 
1829
 
Line 1840... Line 1830...
1840
//   sna_render_composite_redirect_done(sna, op);
1830
 
1841
}
-
 
1842
 
1831
}
1843
#if 0
1832
 
1844
 
1833
#if 0
1845
static bool
1834
static bool
1846
gen6_composite_set_target(struct sna *sna,
1835
gen6_composite_set_target(struct sna *sna,
-
 
1836
			  struct sna_composite_op *op,
1847
			  struct sna_composite_op *op,
1837
			  PicturePtr dst,
1848
			  PicturePtr dst,
1838
			  int x, int y, int w, int h,
Line 1849... Line 1839...
1849
			  int x, int y, int w, int h)
1839
			  bool partial)
1850
{
1840
{
Line 1887... Line 1877...
1887
		return false;
1877
		return false;
Line 1888... Line 1878...
1888
 
1878
 
1889
	return true;
1879
	return true;
Line -... Line 1880...
-
 
1880
}
-
 
1881
 
-
 
1882
static bool
-
 
1883
prefer_blt_composite(struct sna *sna, struct sna_composite_op *tmp)
-
 
1884
{
-
 
1885
	if (untiled_tlb_miss(tmp->dst.bo) ||
-
 
1886
	    untiled_tlb_miss(tmp->src.bo))
-
 
1887
		return true;
-
 
1888
 
-
 
1889
	if (kgem_bo_is_render(tmp->dst.bo) ||
-
 
1890
	    kgem_bo_is_render(tmp->src.bo))
-
 
1891
		return false;
-
 
1892
 
-
 
1893
	if (!prefer_blt_ring(sna, tmp->dst.bo, 0))
-
 
1894
		return false;
-
 
1895
 
Line 1890... Line 1896...
1890
}
1896
	return prefer_blt_bo(sna, tmp->dst.bo) || prefer_blt_bo(sna, tmp->src.bo);
1891
 
1897
}
1892
 
1898
 
1893
static bool
1899
static bool
Line 1906... Line 1912...
1906
		return false;
1912
		return false;
Line 1907... Line 1913...
1907
 
1913
 
1908
    DBG(("%s: %dx%d, current mode=%d\n", __FUNCTION__,
1914
    DBG(("%s: %dx%d, current mode=%d\n", __FUNCTION__,
Line -... Line 1915...
-
 
1915
         width, height, sna->kgem.ring));
-
 
1916
 
-
 
1917
	if (mask == NULL &&
-
 
1918
	    try_blt(sna, dst, src, width, height) &&
-
 
1919
	    sna_blt_composite(sna, op,
-
 
1920
			      src, dst,
-
 
1921
			      src_x, src_y,
-
 
1922
			      dst_x, dst_y,
-
 
1923
			      width, height,
-
 
1924
			      tmp, false))
-
 
1925
		return true;
-
 
1926
 
-
 
1927
	if (gen6_composite_fallback(sna, src, mask, dst))
-
 
1928
		return false;
-
 
1929
 
-
 
1930
	if (need_tiling(sna, width, height))
-
 
1931
		return sna_tiling_composite(op, src, mask, dst,
-
 
1932
					    src_x, src_y,
-
 
1933
					    msk_x, msk_y,
-
 
1934
					    dst_x, dst_y,
-
 
1935
					    width, height,
1909
         width, height, sna->kgem.ring));
1936
					    tmp);
1910
 
1937
 
1911
	if (op == PictOpClear)
1938
	if (op == PictOpClear)
1912
		op = PictOpSrc;
1939
		op = PictOpSrc;
1913
	tmp->op = op;
1940
	tmp->op = op;
-
 
1941
	if (!gen6_composite_set_target(sna, tmp, dst,
1914
	if (!gen6_composite_set_target(sna, tmp, dst,
1942
				       dst_x, dst_y, width, height,
Line 1915... Line 1943...
1915
				       dst_x, dst_y, width, height))
1943
				       op > PictOpSrc || dst->pCompositeClip->data))
1916
		return false;
1944
		return false;
1917
 
1945
 
Line 1998... Line 2026...
1998
					      tmp->dst.format),
2026
					      tmp->dst.format),
1999
			       gen6_choose_composite_kernel(tmp->op,
2027
			       gen6_choose_composite_kernel(tmp->op,
2000
							    tmp->mask.bo != NULL,
2028
							    tmp->mask.bo != NULL,
2001
							    tmp->has_component_alpha,
2029
							    tmp->has_component_alpha,
2002
							    tmp->is_affine),
2030
							    tmp->is_affine),
2003
			       gen4_choose_composite_emitter(tmp));
2031
			       gen4_choose_composite_emitter(sna, tmp));
Line 2004... Line 2032...
2004
 
2032
 
2005
//	tmp->blt   = gen6_render_composite_blt;
2033
	tmp->blt   = gen6_render_composite_blt;
2006
//    tmp->box   = gen6_render_composite_box;
2034
	tmp->box   = gen6_render_composite_box;
2007
//	tmp->boxes = gen6_render_composite_boxes__blt;
2035
	tmp->boxes = gen6_render_composite_boxes__blt;
2008
//	if (tmp->emit_boxes) {
2036
	if (tmp->emit_boxes) {
2009
//		tmp->boxes = gen6_render_composite_boxes;
2037
		tmp->boxes = gen6_render_composite_boxes;
2010
//		tmp->thread_boxes = gen6_render_composite_boxes__thread;
2038
		tmp->thread_boxes = gen6_render_composite_boxes__thread;
2011
//	}
2039
	}
Line 2012... Line 2040...
2012
	tmp->done  = gen6_render_composite_done;
2040
	tmp->done  = gen6_render_composite_done;
2013
 
2041
 
2014
	kgem_set_mode(&sna->kgem, KGEM_RENDER, tmp->dst.bo);
2042
	kgem_set_mode(&sna->kgem, KGEM_RENDER, tmp->dst.bo);
Line 2037... Line 2065...
2037
	if (tmp->redirect.real_bo)
2065
	if (tmp->redirect.real_bo)
2038
		kgem_bo_destroy(&sna->kgem, tmp->dst.bo);
2066
		kgem_bo_destroy(&sna->kgem, tmp->dst.bo);
2039
	return false;
2067
	return false;
2040
}
2068
}
Line 2041... Line -...
2041
 
-
 
2042
 
2069
 
2043
#if !NO_COMPOSITE_SPANS
2070
#if !NO_COMPOSITE_SPANS
2044
fastcall static void
2071
fastcall static void
2045
gen6_render_composite_spans_box(struct sna *sna,
2072
gen6_render_composite_spans_box(struct sna *sna,
2046
				const struct sna_composite_spans_op *op,
2073
				const struct sna_composite_spans_op *op,
Line 2205... Line 2232...
2205
						  width, height, flags, tmp);
2232
						  width, height, flags, tmp);
2206
	}
2233
	}
Line 2207... Line 2234...
2207
 
2234
 
2208
	tmp->base.op = op;
2235
	tmp->base.op = op;
2209
	if (!gen6_composite_set_target(sna, &tmp->base, dst,
2236
	if (!gen6_composite_set_target(sna, &tmp->base, dst,
2210
				       dst_x, dst_y, width, height))
2237
				       dst_x, dst_y, width, height, true))
Line 2211... Line 2238...
2211
		return false;
2238
		return false;
2212
 
2239
 
2213
	switch (gen6_composite_picture(sna, src, &tmp->base.src,
2240
	switch (gen6_composite_picture(sna, src, &tmp->base.src,
Line 2235... Line 2262...
2235
					      tmp->base.src.repeat,
2262
					      tmp->base.src.repeat,
2236
					      SAMPLER_FILTER_NEAREST,
2263
					      SAMPLER_FILTER_NEAREST,
2237
					      SAMPLER_EXTEND_PAD),
2264
					      SAMPLER_EXTEND_PAD),
2238
			       gen6_get_blend(tmp->base.op, false, tmp->base.dst.format),
2265
			       gen6_get_blend(tmp->base.op, false, tmp->base.dst.format),
2239
			       GEN6_WM_KERNEL_OPACITY | !tmp->base.is_affine,
2266
			       GEN6_WM_KERNEL_OPACITY | !tmp->base.is_affine,
2240
			       gen4_choose_spans_emitter(tmp));
2267
			       gen4_choose_spans_emitter(sna, tmp));
Line 2241... Line 2268...
2241
 
2268
 
2242
	tmp->box   = gen6_render_composite_spans_box;
2269
	tmp->box   = gen6_render_composite_spans_box;
2243
	tmp->boxes = gen6_render_composite_spans_boxes;
2270
	tmp->boxes = gen6_render_composite_spans_boxes;
2244
	if (tmp->emit_boxes)
2271
	if (tmp->emit_boxes)
Line 2269... Line 2296...
2269
		kgem_bo_destroy(&sna->kgem, tmp->base.dst.bo);
2296
		kgem_bo_destroy(&sna->kgem, tmp->base.dst.bo);
2270
	return false;
2297
	return false;
2271
}
2298
}
2272
#endif
2299
#endif
Line 2273... Line -...
2273
 
-
 
2274
 
2300
 
2275
static void
2301
static void
2276
gen6_emit_copy_state(struct sna *sna,
2302
gen6_emit_copy_state(struct sna *sna,
2277
		     const struct sna_composite_op *op)
2303
		     const struct sna_composite_op *op)
2278
{
2304
{
Line 2302... Line 2328...
2302
	}
2328
	}
Line 2303... Line 2329...
2303
 
2329
 
2304
	gen6_emit_state(sna, op, offset | dirty);
2330
	gen6_emit_state(sna, op, offset | dirty);
Line 2305... Line -...
2305
}
-
 
2306
 
2331
}
2307
 
2332
 
2308
static inline bool prefer_blt_copy(struct sna *sna,
2333
static inline bool prefer_blt_copy(struct sna *sna,
2309
				   struct kgem_bo *src_bo,
2334
				   struct kgem_bo *src_bo,
2310
				   struct kgem_bo *dst_bo,
2335
				   struct kgem_bo *dst_bo,
Line 2324... Line 2349...
2324
 
2349
 
2325
	if (untiled_tlb_miss(src_bo) ||
2350
	if (untiled_tlb_miss(src_bo) ||
2326
	    untiled_tlb_miss(dst_bo))
2351
	    untiled_tlb_miss(dst_bo))
Line -... Line 2352...
-
 
2352
		return true;
-
 
2353
 
-
 
2354
	if (kgem_bo_is_render(dst_bo) ||
-
 
2355
	    kgem_bo_is_render(src_bo))
2327
		return true;
2356
		return false;
2328
 
2357
 
Line 2329... Line 2358...
2329
	if (!prefer_blt_ring(sna, dst_bo, flags))
2358
	if (!prefer_blt_ring(sna, dst_bo, flags))
2330
		return false;
-
 
2331
 
2359
		return false;
Line 2332... Line 2360...
2332
	return (prefer_blt_bo(sna, src_bo) >= 0 &&
2360
 
2333
		prefer_blt_bo(sna, dst_bo) > 0);
2361
	return prefer_blt_bo(sna, src_bo) || prefer_blt_bo(sna, dst_bo);
2334
}
2362
}
Line 2462... Line 2490...
2462
 
2490
 
2463
		if (!sna_render_composite_redirect(sna, &tmp,
2491
		if (!sna_render_composite_redirect(sna, &tmp,
2464
						   extents.x1 + dst_dx,
2492
						   extents.x1 + dst_dx,
2465
						   extents.y1 + dst_dy,
2493
						   extents.y1 + dst_dy,
2466
						   extents.x2 - extents.x1,
2494
						   extents.x2 - extents.x1,
-
 
2495
						   extents.y2 - extents.y1,
2467
						   extents.y2 - extents.y1))
2496
						   n > 1))
Line 2468... Line 2497...
2468
			goto fallback_tiled;
2497
			goto fallback_tiled;
2469
 
2498
 
Line 2477... Line 2506...
2477
	if (too_large(src->drawable.width, src->drawable.height)) {
2506
	if (too_large(src->drawable.width, src->drawable.height)) {
2478
		int i;
2507
		int i;
Line 2479... Line 2508...
2479
 
2508
 
2480
		extents = box[0];
2509
		extents = box[0];
2481
		for (i = 1; i < n; i++) {
2510
		for (i = 1; i < n; i++) {
2482
			if (extents.x1 < box[i].x1)
2511
			if (box[i].x1 < extents.x1)
2483
				extents.x1 = box[i].x1;
2512
				extents.x1 = box[i].x1;
2484
			if (extents.y1 < box[i].y1)
2513
			if (box[i].y1 < extents.y1)
Line 2485... Line 2514...
2485
				extents.y1 = box[i].y1;
2514
				extents.y1 = box[i].y1;
2486
 
2515
 
2487
			if (extents.x2 > box[i].x2)
2516
			if (box[i].x2 > extents.x2)
2488
				extents.x2 = box[i].x2;
2517
				extents.x2 = box[i].x2;
2489
			if (extents.y2 > box[i].y2)
2518
			if (box[i].y2 > extents.y2)
Line 2490... Line 2519...
2490
				extents.y2 = box[i].y2;
2519
				extents.y2 = box[i].y2;
2491
		}
2520
		}
Line 2630... Line 2659...
2630
	DBG(("%s (alu=%d, src=(%dx%d), dst=(%dx%d))\n",
2659
	DBG(("%s (alu=%d, src=(%dx%d), dst=(%dx%d))\n",
2631
	     __FUNCTION__, alu,
2660
	     __FUNCTION__, alu,
2632
	     src->drawable.width, src->drawable.height,
2661
	     src->drawable.width, src->drawable.height,
2633
	     dst->drawable.width, dst->drawable.height));
2662
	     dst->drawable.width, dst->drawable.height));
Line -... Line 2663...
-
 
2663
 
-
 
2664
	if (prefer_blt_copy(sna, src_bo, dst_bo, 0) &&
-
 
2665
	    sna_blt_compare_depth(&src->drawable, &dst->drawable) &&
-
 
2666
	    sna_blt_copy(sna, alu,
-
 
2667
			 src_bo, dst_bo,
-
 
2668
			 dst->drawable.bitsPerPixel,
-
 
2669
			 op))
-
 
2670
		return true;
-
 
2671
 
-
 
2672
	if (!(alu == GXcopy || alu == GXclear) || src_bo == dst_bo ||
-
 
2673
	    too_large(src->drawable.width, src->drawable.height) ||
2634
 
2674
	    too_large(dst->drawable.width, dst->drawable.height)) {
-
 
2675
fallback:
-
 
2676
		if (!sna_blt_compare_depth(&src->drawable, &dst->drawable))
Line -... Line 2677...
-
 
2677
			return false;
-
 
2678
 
-
 
2679
		return sna_blt_copy(sna, alu, src_bo, dst_bo,
-
 
2680
				    dst->drawable.bitsPerPixel,
-
 
2681
				    op);
-
 
2682
	}
2635
fallback:
2683
 
2636
 
2684
	if (dst->drawable.depth == src->drawable.depth) {
-
 
2685
		op->base.dst.format = sna_render_format_for_depth(dst->drawable.depth);
-
 
2686
	op->base.src.pict_format = op->base.dst.format;
-
 
2687
	} else {
-
 
2688
		op->base.dst.format = sna_format_for_depth(dst->drawable.depth);
-
 
2689
		op->base.src.pict_format = sna_format_for_depth(src->drawable.depth);
-
 
2690
	}
Line 2637... Line 2691...
2637
    op->base.dst.format = PIXMAN_a8r8g8b8;
2691
	if (!gen6_check_format(op->base.src.pict_format))
2638
	op->base.src.pict_format = op->base.dst.format;
2692
		goto fallback;
2639
 
2693
 
2640
	op->base.dst.pixmap = dst;
2694
	op->base.dst.pixmap = dst;
Line 2673... Line 2727...
2673
	op->done = gen6_render_copy_done;
2727
	op->done = gen6_render_copy_done;
2674
	return true;
2728
	return true;
2675
}
2729
}
2676
#endif
2730
#endif
Line 2677... Line -...
2677
 
-
 
2678
 
-
 
2679
static bool
-
 
2680
gen6_blit_tex(struct sna *sna,
-
 
2681
              uint8_t op, bool scale,
-
 
2682
		      PixmapPtr src, struct kgem_bo *src_bo,
-
 
2683
		      PixmapPtr mask,struct kgem_bo *mask_bo,
-
 
2684
		      PixmapPtr dst, struct kgem_bo *dst_bo, 
-
 
2685
              int32_t src_x, int32_t src_y,
-
 
2686
              int32_t msk_x, int32_t msk_y,
-
 
2687
              int32_t dst_x, int32_t dst_y,
-
 
2688
              int32_t width, int32_t height,
-
 
2689
              struct sna_composite_op *tmp)
-
 
2690
{
-
 
2691
 
-
 
2692
    DBG(("%s: %dx%d, current mode=%d\n", __FUNCTION__,
-
 
2693
         width, height, sna->kgem.ring));
-
 
2694
 
-
 
2695
    tmp->op = PictOpSrc;
-
 
2696
 
-
 
2697
    tmp->dst.pixmap = dst;
-
 
2698
    tmp->dst.bo     = dst_bo;
-
 
2699
    tmp->dst.width  = dst->drawable.width;
-
 
2700
    tmp->dst.height = dst->drawable.height;
-
 
2701
    tmp->dst.format = PICT_x8r8g8b8;
-
 
2702
 
-
 
2703
 
-
 
2704
	tmp->src.repeat = SAMPLER_EXTEND_NONE;
-
 
2705
    tmp->src.is_affine = true;
-
 
2706
 
-
 
2707
    tmp->src.bo = src_bo;
-
 
2708
	tmp->src.pict_format = PICT_x8r8g8b8;
-
 
2709
    tmp->src.card_format = gen6_get_card_format(tmp->src.pict_format);
-
 
2710
    tmp->src.width  = src->drawable.width;
-
 
2711
    tmp->src.height = src->drawable.height;
-
 
2712
 
-
 
2713
	if ( (tmp->src.width  == width) &&
-
 
2714
         (tmp->src.height == height) )
-
 
2715
		tmp->src.filter = SAMPLER_FILTER_NEAREST;
-
 
2716
	else
-
 
2717
		tmp->src.filter = SAMPLER_FILTER_BILINEAR;
-
 
2718
 
-
 
2719
	tmp->is_affine = tmp->src.is_affine;
-
 
2720
	tmp->has_component_alpha = false;
-
 
2721
	tmp->need_magic_ca_pass = false;
-
 
2722
 
-
 
2723
	tmp->mask.repeat = SAMPLER_EXTEND_NONE;
-
 
2724
	tmp->mask.filter = SAMPLER_FILTER_NEAREST;
-
 
2725
    tmp->mask.is_affine = true;
-
 
2726
 
-
 
2727
    tmp->mask.bo = mask_bo;
-
 
2728
    tmp->mask.pict_format = PIXMAN_a8;
-
 
2729
    tmp->mask.card_format = gen6_get_card_format(tmp->mask.pict_format);
-
 
2730
    tmp->mask.width  = mask->drawable.width;
-
 
2731
    tmp->mask.height = mask->drawable.height;
-
 
2732
 
-
 
2733
 
-
 
2734
    if( scale )
-
 
2735
    {
-
 
2736
        tmp->src.scale[0] = 1.f/width;
-
 
2737
        tmp->src.scale[1] = 1.f/height;
-
 
2738
    }
-
 
2739
    else
-
 
2740
    {
-
 
2741
        tmp->src.scale[0] = 1.f/src->drawable.width;
-
 
2742
        tmp->src.scale[1] = 1.f/src->drawable.height;
-
 
2743
    }
-
 
2744
//    tmp->src.offset[0] = -dst_x;
-
 
2745
//    tmp->src.offset[1] = -dst_y;
-
 
2746
 
-
 
2747
 
-
 
2748
    tmp->mask.scale[0] = 1.f/mask->drawable.width;
-
 
2749
    tmp->mask.scale[1] = 1.f/mask->drawable.height;
-
 
2750
//    tmp->mask.offset[0] = -dst_x;
-
 
2751
//    tmp->mask.offset[1] = -dst_y;
-
 
2752
 
-
 
2753
	tmp->u.gen6.flags =
-
 
2754
		GEN6_SET_FLAGS(SAMPLER_OFFSET(tmp->src.filter,
-
 
2755
					      tmp->src.repeat,
-
 
2756
					      tmp->mask.filter,
-
 
2757
					      tmp->mask.repeat),
-
 
2758
			       gen6_get_blend(tmp->op,
-
 
2759
					      tmp->has_component_alpha,
-
 
2760
					      tmp->dst.format),
-
 
2761
/*			       gen6_choose_composite_kernel(tmp->op,
-
 
2762
							    tmp->mask.bo != NULL,
-
 
2763
							    tmp->has_component_alpha,
-
 
2764
							    tmp->is_affine),
-
 
2765
*/
-
 
2766
                   GEN6_WM_KERNEL_MASK,                 
-
 
2767
			       gen4_choose_composite_emitter(tmp));
-
 
2768
 
-
 
2769
	tmp->blt   = gen6_render_composite_blt;
-
 
2770
//    tmp->box   = gen6_render_composite_box;
-
 
2771
	tmp->done  = gen6_render_composite_done;
-
 
2772
 
-
 
2773
	kgem_set_mode(&sna->kgem, KGEM_RENDER, tmp->dst.bo);
-
 
2774
	if (!kgem_check_bo(&sna->kgem,
-
 
2775
			   tmp->dst.bo, tmp->src.bo, tmp->mask.bo,
-
 
2776
			   NULL)) {
-
 
2777
		kgem_submit(&sna->kgem);
-
 
2778
		_kgem_set_mode(&sna->kgem, KGEM_RENDER);
-
 
2779
	}
-
 
2780
 
-
 
2781
    gen6_emit_composite_state(sna, tmp);
-
 
2782
    gen6_align_vertex(sna, tmp);
-
 
2783
	return true;
-
 
2784
 
-
 
2785
}
-
 
2786
 
-
 
2787
 
-
 
2788
 
2731
 
2789
#if 0
-
 
2790
 
2732
#if 0
2791
static void
2733
static void
2792
gen6_emit_fill_state(struct sna *sna, const struct sna_composite_op *op)
2734
gen6_emit_fill_state(struct sna *sna, const struct sna_composite_op *op)
2793
{
2735
{
2794
	uint32_t *binding_table;
2736
	uint32_t *binding_table;
Line 2824... Line 2766...
2824
				   struct kgem_bo *bo)
2766
				   struct kgem_bo *bo)
2825
{
2767
{
2826
	if (PREFER_RENDER)
2768
	if (PREFER_RENDER)
2827
		return PREFER_RENDER < 0;
2769
		return PREFER_RENDER < 0;
Line -... Line 2770...
-
 
2770
 
-
 
2771
	if (kgem_bo_is_render(bo))
-
 
2772
		return false;
2828
 
2773
 
2829
	if (untiled_tlb_miss(bo))
2774
	if (untiled_tlb_miss(bo))
Line -... Line 2775...
-
 
2775
		return true;
-
 
2776
 
-
 
2777
	if (!prefer_blt_ring(sna, bo, 0))
2830
		return true;
2778
		return false;
2831
 
2779
 
Line 2832... Line 2780...
2832
	return prefer_blt_ring(sna, bo, 0) || prefer_blt_bo(sna, bo) >= 0;
2780
	return prefer_blt_bo(sna, bo);
2833
}
2781
}
2834
 
2782
 
Line 2908... Line 2856...
2908
 
2856
 
2909
		boxes_extents(box, n, &extents);
2857
		boxes_extents(box, n, &extents);
2910
		if (!sna_render_composite_redirect(sna, &tmp,
2858
		if (!sna_render_composite_redirect(sna, &tmp,
2911
						   extents.x1, extents.y1,
2859
						   extents.x1, extents.y1,
2912
						   extents.x2 - extents.x1,
2860
						   extents.x2 - extents.x1,
-
 
2861
						   extents.y2 - extents.y1,
2913
						   extents.y2 - extents.y1))
2862
						   n > 1))
2914
			return sna_tiling_fill_boxes(sna, op, format, color,
2863
			return sna_tiling_fill_boxes(sna, op, format, color,
2915
						     dst, dst_bo, box, n);
2864
						     dst, dst_bo, box, n);
Line 2916... Line 2865...
2916
	}
2865
	}
Line 3383... Line 3332...
3383
    kgem_bo_destroy(&sna->kgem, sna->render_state.gen6.general_bo);
3332
    kgem_bo_destroy(&sna->kgem, sna->render_state.gen6.general_bo);
3384
}
3333
}
Line 3385... Line 3334...
3385
 
3334
 
3386
static bool is_gt2(struct sna *sna)
3335
static bool is_gt2(struct sna *sna)
3387
{
3336
{
3388
	return DEVICE_ID(sna->PciInfo) & 0x30;
3337
	return sna->PciInfo->device_id & 0x30;
Line 3389... Line 3338...
3389
}
3338
}
3390
 
3339
 
3391
static bool is_mobile(struct sna *sna)
3340
static bool is_mobile(struct sna *sna)
3392
{
3341
{
Line 3393... Line 3342...
3393
	return (DEVICE_ID(sna->PciInfo) & 0xf) == 0x6;
3342
	return (sna->PciInfo->device_id & 0xf) == 0x6;
3394
}
3343
}
3395
 
3344
 
Line 3469... Line 3418...
3469
 
3418
 
3470
    state->general_bo = sna_static_stream_fini(sna, &general);
3419
    state->general_bo = sna_static_stream_fini(sna, &general);
3471
    return state->general_bo != NULL;
3420
    return state->general_bo != NULL;
Line 3472... Line 3421...
3472
}
3421
}
3473
 
3422
 
3474
bool gen6_render_init(struct sna *sna)
3423
const char *gen6_render_init(struct sna *sna, const char *backend)
3475
{
3424
{
Line 3476... Line 3425...
3476
    if (!gen6_render_setup(sna))
3425
    if (!gen6_render_setup(sna))
3477
		return false;
3426
		return backend;
3478
 
3427
 
Line -... Line 3428...
-
 
3428
	sna->kgem.context_switch = gen6_render_context_switch;
-
 
3429
	sna->kgem.retire = gen6_render_retire;
3479
	sna->kgem.context_switch = gen6_render_context_switch;
3430
	sna->kgem.expire = gen6_render_expire;
3480
      sna->kgem.retire = gen6_render_retire;
3431
 
-
 
3432
#if 0
Line -... Line 3433...
-
 
3433
#if !NO_COMPOSITE
-
 
3434
	sna->render.composite = gen6_render_composite;
3481
	sna->kgem.expire = gen6_render_expire;
3435
	sna->render.prefer_gpu |= PREFER_GPU_RENDER;
-
 
3436
#endif
-
 
3437
 
-
 
3438
#if !NO_COMPOSITE_SPANS
-
 
3439
	sna->render.check_composite_spans = gen6_check_composite_spans;
Line -... Line 3440...
-
 
3440
	sna->render.composite_spans = gen6_render_composite_spans;
-
 
3441
	if (is_mobile(sna))
-
 
3442
		sna->render.prefer_gpu |= PREFER_GPU_SPANS;
-
 
3443
#endif
3482
 
3444
	sna->render.video = gen6_render_video;
-
 
3445
 
Line -... Line 3446...
-
 
3446
#if !NO_COPY_BOXES
-
 
3447
	sna->render.copy_boxes = gen6_render_copy_boxes;
-
 
3448
#endif
-
 
3449
#if !NO_COPY
-
 
3450
	sna->render.copy = gen6_render_copy;
-
 
3451
#endif
-
 
3452
 
-
 
3453
#if !NO_FILL_BOXES
-
 
3454
	sna->render.fill_boxes = gen6_render_fill_boxes;
-
 
3455
#endif
3483
//    sna->render.composite = gen6_render_composite;
3456
#if !NO_FILL
-
 
3457
	sna->render.fill = gen6_render_fill;
-
 
3458
#endif
Line 3484... Line -...
3484
//    sna->render.video = gen6_render_video;
-
 
3485
 
3459
#if !NO_FILL_ONE
3486
//    sna->render.copy_boxes = gen6_render_copy_boxes;
-
 
3487
 
3460
	sna->render.fill_one = gen6_render_fill_one;
Line 3488... Line 3461...
3488
    sna->render.blit_tex = gen6_blit_tex;
3461
#endif
3489
 
3462
#if !NO_FILL_CLEAR
3490
//    sna->render.copy = gen6_render_copy;
3463
	sna->render.clear = gen6_render_clear;
Line 3491... Line 3464...
3491
 
3464
#endif
3492
//    sna->render.fill_boxes = gen6_render_fill_boxes;
3465
#endif
3493
//    sna->render.fill = gen6_render_fill;
3466
 
-
 
3467
    sna->render.caps = HW_BIT_BLIT | HW_TEX_BLIT;
Line 3494... Line 3468...
3494
//    sna->render.fill_one = gen6_render_fill_one;
3468
    sna->render.blit_tex = gen6_blit_tex;
-
 
3469
 
-
 
3470
    sna->render.flush = gen6_render_flush;
-
 
3471
    sna->render.reset = gen6_render_reset;
-
 
3472
	sna->render.fini = gen6_render_fini;
-
 
3473
 
-
 
3474
    sna->render.max_3d_size = GEN6_MAX_SIZE;
-
 
3475
    sna->render.max_3d_pitch = 1 << 18;
-
 
3476
	return sna->render_state.gen6.info->name;
-
 
3477
}
-
 
3478
 
-
 
3479
static bool
-
 
3480
gen6_blit_tex(struct sna *sna,
-
 
3481
              uint8_t op, bool scale,
-
 
3482
		      PixmapPtr src, struct kgem_bo *src_bo,
-
 
3483
		      PixmapPtr mask,struct kgem_bo *mask_bo,
-
 
3484
		      PixmapPtr dst, struct kgem_bo *dst_bo,
-
 
3485
              int32_t src_x, int32_t src_y,
-
 
3486
              int32_t msk_x, int32_t msk_y,
-
 
3487
              int32_t dst_x, int32_t dst_y,
-
 
3488
              int32_t width, int32_t height,
-
 
3489
              struct sna_composite_op *tmp)
-
 
3490
{
-
 
3491
 
-
 
3492
    DBG(("%s: %dx%d, current mode=%d\n", __FUNCTION__,
-
 
3493
         width, height, sna->kgem.ring));
-
 
3494
 
-
 
3495
    tmp->op = PictOpSrc;
-
 
3496
 
-
 
3497
    tmp->dst.pixmap = dst;
-
 
3498
    tmp->dst.bo     = dst_bo;
-
 
3499
    tmp->dst.width  = dst->drawable.width;
-
 
3500
    tmp->dst.height = dst->drawable.height;
-
 
3501
    tmp->dst.format = PICT_x8r8g8b8;
-
 
3502
 
-
 
3503
 
-
 
3504
	tmp->src.repeat = SAMPLER_EXTEND_NONE;
-
 
3505
    tmp->src.is_affine = true;
-
 
3506
 
-
 
3507
    tmp->src.bo = src_bo;
-
 
3508
	tmp->src.pict_format = PICT_x8r8g8b8;
-
 
3509
    tmp->src.card_format = gen6_get_card_format(tmp->src.pict_format);
-
 
3510
    tmp->src.width  = src->drawable.width;
-
 
3511
    tmp->src.height = src->drawable.height;
-
 
3512
 
-
 
3513
	if ( (tmp->src.width  == width) &&
-
 
3514
         (tmp->src.height == height) )
-
 
3515
		tmp->src.filter = SAMPLER_FILTER_NEAREST;
-
 
3516
	else
-
 
3517
		tmp->src.filter = SAMPLER_FILTER_BILINEAR;
-
 
3518
 
-
 
3519
	tmp->is_affine = tmp->src.is_affine;
-
 
3520
	tmp->has_component_alpha = false;
-
 
3521
	tmp->need_magic_ca_pass = false;
-
 
3522
 
-
 
3523
	tmp->mask.repeat = SAMPLER_EXTEND_NONE;
-
 
3524
	tmp->mask.filter = SAMPLER_FILTER_NEAREST;
-
 
3525
    tmp->mask.is_affine = true;
-
 
3526
 
-
 
3527
    tmp->mask.bo = mask_bo;
-
 
3528
    tmp->mask.pict_format = PIXMAN_a8;
-
 
3529
    tmp->mask.card_format = gen6_get_card_format(tmp->mask.pict_format);
-
 
3530
    tmp->mask.width  = mask->drawable.width;
-
 
3531
    tmp->mask.height = mask->drawable.height;
-
 
3532
 
-
 
3533
 
-
 
3534
    if( scale )
-
 
3535
    {
-
 
3536
        tmp->src.scale[0] = 1.f/width;
-
 
3537
        tmp->src.scale[1] = 1.f/height;
-
 
3538
    }
-
 
3539
    else
-
 
3540
    {
-
 
3541
        tmp->src.scale[0] = 1.f/src->drawable.width;
-
 
3542
        tmp->src.scale[1] = 1.f/src->drawable.height;
-
 
3543
    }
-
 
3544
//    tmp->src.offset[0] = -dst_x;
-
 
3545
//    tmp->src.offset[1] = -dst_y;
-
 
3546
 
-
 
3547
 
-
 
3548
    tmp->mask.scale[0] = 1.f/mask->drawable.width;
-
 
3549
    tmp->mask.scale[1] = 1.f/mask->drawable.height;
-
 
3550
//    tmp->mask.offset[0] = -dst_x;
-
 
3551
//    tmp->mask.offset[1] = -dst_y;
-
 
3552
 
-
 
3553
	tmp->u.gen6.flags =
-
 
3554
		GEN6_SET_FLAGS(SAMPLER_OFFSET(tmp->src.filter,
-
 
3555
					      tmp->src.repeat,
-
 
3556
					      tmp->mask.filter,
-
 
3557
					      tmp->mask.repeat),
-
 
3558
			       gen6_get_blend(tmp->op,
-
 
3559
					      tmp->has_component_alpha,
-
 
3560
					      tmp->dst.format),
-
 
3561
/*			       gen6_choose_composite_kernel(tmp->op,
-
 
3562
							    tmp->mask.bo != NULL,
-
 
3563
							    tmp->has_component_alpha,
-
 
3564
							    tmp->is_affine),
-
 
3565
*/
-
 
3566
                   GEN6_WM_KERNEL_MASK,
-
 
3567
			       gen4_choose_composite_emitter(sna, tmp));
3495
//    sna->render.clear = gen6_render_clear;
3568
 
Line -... Line 3569...
-
 
3569
	tmp->blt   = gen6_render_composite_blt;
-
 
3570
//    tmp->box   = gen6_render_composite_box;
-
 
3571
	tmp->done  = gen6_render_composite_done;
Line -... Line 3572...
-
 
3572