Subversion Repositories Kolibri OS

Rev

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

Rev 4245 Rev 4251
Line 105... Line 105...
105
} gen3_tex_formats[] = {
105
} gen3_tex_formats[] = {
106
	{PICT_a8, 0, MAPSURF_8BIT | MT_8BIT_A8, false},
106
	{PICT_a8, 0, MAPSURF_8BIT | MT_8BIT_A8, false},
107
	{PICT_a8r8g8b8, 0, MAPSURF_32BIT | MT_32BIT_ARGB8888, false},
107
	{PICT_a8r8g8b8, 0, MAPSURF_32BIT | MT_32BIT_ARGB8888, false},
108
	{PICT_x8r8g8b8, 0, MAPSURF_32BIT | MT_32BIT_XRGB8888, false},
108
	{PICT_x8r8g8b8, 0, MAPSURF_32BIT | MT_32BIT_XRGB8888, false},
109
	{PICT_a8b8g8r8, 0, MAPSURF_32BIT | MT_32BIT_ABGR8888, false},
109
	{PICT_a8b8g8r8, 0, MAPSURF_32BIT | MT_32BIT_ABGR8888, false},
110
	{PICT_x8b8g8r8, 0, MAPSURF_32BIT | MT_32BIT_XBGR8888, false}
110
	{PICT_x8b8g8r8, 0, MAPSURF_32BIT | MT_32BIT_XBGR8888, false},
-
 
111
	{PICT_a2r10g10b10, PICT_x2r10g10b10, MAPSURF_32BIT | MT_32BIT_ARGB2101010, false},
-
 
112
	{PICT_a2b10g10r10, PICT_x2b10g10r10, MAPSURF_32BIT | MT_32BIT_ABGR2101010, false},
-
 
113
	{PICT_r5g6b5, 0, MAPSURF_16BIT | MT_16BIT_RGB565, false},
-
 
114
	{PICT_b5g6r5, 0, MAPSURF_16BIT | MT_16BIT_RGB565, true},
-
 
115
	{PICT_a1r5g5b5, PICT_x1r5g5b5, MAPSURF_16BIT | MT_16BIT_ARGB1555, false},
-
 
116
	{PICT_a1b5g5r5, PICT_x1b5g5r5, MAPSURF_16BIT | MT_16BIT_ARGB1555, true},
-
 
117
	{PICT_a4r4g4b4, PICT_x4r4g4b4, MAPSURF_16BIT | MT_16BIT_ARGB4444, false},
-
 
118
	{PICT_a4b4g4r4, PICT_x4b4g4r4, MAPSURF_16BIT | MT_16BIT_ARGB4444, true},
111
};
119
};
Line 112... Line 120...
112
 
120
 
Line 113... Line 121...
113
#define xFixedToDouble(f) pixman_fixed_to_double(f)
121
#define xFixedToDouble(f) pixman_fixed_to_double(f)
Line 185... Line 193...
185
static bool gen3_dst_rb_reversed(uint32_t format)
193
static bool gen3_dst_rb_reversed(uint32_t format)
186
{
194
{
187
	switch (format) {
195
	switch (format) {
188
	case PICT_a8r8g8b8:
196
	case PICT_a8r8g8b8:
189
	case PICT_x8r8g8b8:
197
	case PICT_x8r8g8b8:
-
 
198
	case PICT_r5g6b5:
-
 
199
	case PICT_a1r5g5b5:
-
 
200
	case PICT_x1r5g5b5:
-
 
201
	case PICT_a2r10g10b10:
-
 
202
	case PICT_x2r10g10b10:
190
	case PICT_a8:
203
	case PICT_a8:
-
 
204
	case PICT_a4r4g4b4:
-
 
205
	case PICT_x4r4g4b4:
191
		return false;
206
		return false;
192
	default:
207
	default:
193
		return true;
208
		return true;
194
	}
209
	}
195
}
210
}
Line 205... Line 220...
205
	case PICT_a8r8g8b8:
220
	case PICT_a8r8g8b8:
206
	case PICT_x8r8g8b8:
221
	case PICT_x8r8g8b8:
207
	case PICT_a8b8g8r8:
222
	case PICT_a8b8g8r8:
208
	case PICT_x8b8g8r8:
223
	case PICT_x8b8g8r8:
209
		return BIAS | COLR_BUF_ARGB8888;
224
		return BIAS | COLR_BUF_ARGB8888;
-
 
225
	case PICT_r5g6b5:
-
 
226
	case PICT_b5g6r5:
-
 
227
		return BIAS | COLR_BUF_RGB565;
-
 
228
	case PICT_a1r5g5b5:
-
 
229
	case PICT_x1r5g5b5:
-
 
230
	case PICT_a1b5g5r5:
-
 
231
	case PICT_x1b5g5r5:
-
 
232
		return BIAS | COLR_BUF_ARGB1555;
-
 
233
	case PICT_a2r10g10b10:
-
 
234
	case PICT_x2r10g10b10:
-
 
235
	case PICT_a2b10g10r10:
-
 
236
	case PICT_x2b10g10r10:
-
 
237
		return BIAS | COLR_BUF_ARGB2AAA;
210
	case PICT_a8:
238
	case PICT_a8:
211
		return BIAS | COLR_BUF_8BIT;
239
		return BIAS | COLR_BUF_8BIT;
-
 
240
	case PICT_a4r4g4b4:
-
 
241
	case PICT_x4r4g4b4:
-
 
242
	case PICT_a4b4g4r4:
-
 
243
	case PICT_x4b4g4r4:
-
 
244
		return BIAS | COLR_BUF_ARGB4444;
212
	}
245
	}
213
#undef BIAS
246
#undef BIAS
214
}
247
}
Line -... Line 248...
-
 
248
 
-
 
249
 
-
 
250
#if 0
-
 
251
static bool gen3_check_repeat(PicturePtr p)
-
 
252
{
-
 
253
	if (!p->repeat)
-
 
254
		return true;
-
 
255
 
-
 
256
	switch (p->repeatType) {
-
 
257
	case RepeatNone:
-
 
258
	case RepeatNormal:
-
 
259
	case RepeatPad:
-
 
260
	case RepeatReflect:
-
 
261
		return true;
-
 
262
	default:
-
 
263
		return false;
-
 
264
	}
-
 
265
}
-
 
266
 
-
 
267
static uint32_t gen3_filter(uint32_t filter)
-
 
268
{
-
 
269
	switch (filter) {
-
 
270
	default:
-
 
271
		assert(0);
-
 
272
	case PictFilterNearest:
-
 
273
		return (FILTER_NEAREST << SS2_MAG_FILTER_SHIFT |
-
 
274
			FILTER_NEAREST << SS2_MIN_FILTER_SHIFT |
-
 
275
			MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT);
-
 
276
	case PictFilterBilinear:
-
 
277
		return (FILTER_LINEAR  << SS2_MAG_FILTER_SHIFT |
-
 
278
			FILTER_LINEAR  << SS2_MIN_FILTER_SHIFT |
-
 
279
			MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT);
-
 
280
	}
-
 
281
}
-
 
282
 
-
 
283
static bool gen3_check_filter(PicturePtr p)
-
 
284
{
-
 
285
	switch (p->filter) {
-
 
286
	case PictFilterNearest:
-
 
287
	case PictFilterBilinear:
-
 
288
		return true;
-
 
289
	default:
-
 
290
		return false;
-
 
291
	}
-
 
292
}
-
 
293
fastcall static void
-
 
294
gen3_emit_composite_primitive_identity_gradient(struct sna *sna,
-
 
295
						const struct sna_composite_op *op,
-
 
296
						const struct sna_composite_rectangles *r)
-
 
297
{
-
 
298
	int16_t dst_x, dst_y;
-
 
299
	int16_t src_x, src_y;
-
 
300
 
-
 
301
	dst_x = r->dst.x + op->dst.x;
-
 
302
	dst_y = r->dst.y + op->dst.y;
-
 
303
	src_x = r->src.x + op->src.offset[0];
-
 
304
	src_y = r->src.y + op->src.offset[1];
-
 
305
 
-
 
306
	gen3_emit_composite_dstcoord(sna, dst_x + r->width, dst_y + r->height);
-
 
307
	OUT_VERTEX(src_x + r->width);
-
 
308
	OUT_VERTEX(src_y + r->height);
-
 
309
 
-
 
310
	gen3_emit_composite_dstcoord(sna, dst_x, dst_y + r->height);
-
 
311
	OUT_VERTEX(src_x);
-
 
312
	OUT_VERTEX(src_y + r->height);
-
 
313
 
-
 
314
	gen3_emit_composite_dstcoord(sna, dst_x, dst_y);
-
 
315
	OUT_VERTEX(src_x);
-
 
316
	OUT_VERTEX(src_y);
-
 
317
}
-
 
318
 
-
 
319
fastcall static void
-
 
320
gen3_emit_composite_boxes_identity_gradient(const struct sna_composite_op *op,
-
 
321
					    const BoxRec *box, int nbox,
-
 
322
					    float *v)
-
 
323
{
-
 
324
	do {
-
 
325
		v[0] = box->x2;
-
 
326
		v[1] = box->y2;
-
 
327
		v[2] = box->x2 + op->src.offset[0];
-
 
328
		v[3] = box->y2 + op->src.offset[1];
-
 
329
 
-
 
330
		v[4] = box->x1;
-
 
331
		v[5] = box->y2;
-
 
332
		v[6] = box->x1 + op->src.offset[0];
-
 
333
		v[7] = box->y2 + op->src.offset[1];
-
 
334
 
-
 
335
		v[8] = box->x1;
-
 
336
		v[9] = box->y1;
-
 
337
		v[10] = box->x1 + op->src.offset[0];
-
 
338
		v[11] = box->y1 + op->src.offset[1];
-
 
339
 
-
 
340
		v += 12;
-
 
341
		box++;
-
 
342
	} while (--nbox);
-
 
343
}
-
 
344
fastcall static void
-
 
345
gen3_emit_composite_boxes_affine_gradient(const struct sna_composite_op *op,
-
 
346
					  const BoxRec *box, int nbox,
-
 
347
					  float *v)
-
 
348
{
-
 
349
	const PictTransform *transform = op->src.transform;
-
 
350
 
-
 
351
	do {
-
 
352
		v[0] = box->x2;
-
 
353
		v[1] = box->y2;
-
 
354
		_sna_get_transformed_scaled(box->x2 + op->src.offset[0],
-
 
355
					    box->y2 + op->src.offset[1],
-
 
356
					    transform, op->src.scale,
-
 
357
					    &v[2], &v[3]);
-
 
358
 
-
 
359
		v[4] = box->x1;
-
 
360
		v[5] = box->y2;
-
 
361
		_sna_get_transformed_scaled(box->x1 + op->src.offset[0],
-
 
362
					    box->y2 + op->src.offset[1],
-
 
363
					    transform, op->src.scale,
-
 
364
					    &v[6], &v[7]);
-
 
365
 
-
 
366
		v[8] = box->x1;
-
 
367
		v[9] = box->y1;
-
 
368
		_sna_get_transformed_scaled(box->x1 + op->src.offset[0],
-
 
369
					    box->y1 + op->src.offset[1],
-
 
370
					    transform, op->src.scale,
-
 
371
					    &v[10], &v[11]);
-
 
372
 
-
 
373
		box++;
-
 
374
		v += 12;
-
 
375
	} while (--nbox);
-
 
376
}
-
 
377
 
-
 
378
fastcall static void
-
 
379
gen3_emit_composite_primitive_identity_source(struct sna *sna,
-
 
380
					      const struct sna_composite_op *op,
-
 
381
					      const struct sna_composite_rectangles *r)
-
 
382
{
-
 
383
	float w = r->width;
-
 
384
	float h = r->height;
-
 
385
	float *v;
-
 
386
 
-
 
387
	v = sna->render.vertices + sna->render.vertex_used;
-
 
388
	sna->render.vertex_used += 12;
-
 
389
 
-
 
390
	v[8] = v[4] = r->dst.x + op->dst.x;
-
 
391
	v[0] = v[4] + w;
-
 
392
 
-
 
393
	v[9] = r->dst.y + op->dst.y;
-
 
394
	v[5] = v[1] = v[9] + h;
-
 
395
 
-
 
396
	v[10] = v[6] = (r->src.x + op->src.offset[0]) * op->src.scale[0];
-
 
397
	v[2] = v[6] + w * op->src.scale[0];
-
 
398
 
-
 
399
	v[11] = (r->src.y + op->src.offset[1]) * op->src.scale[1];
-
 
400
	v[7] = v[3] = v[11] + h * op->src.scale[1];
-
 
401
}
-
 
402
 
-
 
403
fastcall static void
-
 
404
gen3_emit_composite_boxes_identity_source(const struct sna_composite_op *op,
-
 
405
					  const BoxRec *box, int nbox,
-
 
406
					  float *v)
-
 
407
{
-
 
408
	do {
-
 
409
		v[0] = box->x2 + op->dst.x;
-
 
410
		v[8] = v[4] = box->x1 + op->dst.x;
-
 
411
		v[5] = v[1] = box->y2 + op->dst.y;
-
 
412
		v[9] = box->y1 + op->dst.y;
-
 
413
 
-
 
414
		v[10] = v[6] = (box->x1 + op->src.offset[0]) * op->src.scale[0];
-
 
415
		v[2] = (box->x2 + op->src.offset[0]) * op->src.scale[0];
-
 
416
 
-
 
417
		v[11] = (box->y1 + op->src.offset[1]) * op->src.scale[1];
-
 
418
		v[7] = v[3] = (box->y2 + op->src.offset[1]) * op->src.scale[1];
-
 
419
 
-
 
420
		v += 12;
-
 
421
		box++;
-
 
422
	} while (--nbox);
-
 
423
}
-
 
424
 
-
 
425
fastcall static void
-
 
426
gen3_emit_composite_primitive_identity_source_no_offset(struct sna *sna,
-
 
427
							const struct sna_composite_op *op,
-
 
428
							const struct sna_composite_rectangles *r)
-
 
429
{
-
 
430
	float w = r->width;
-
 
431
	float h = r->height;
-
 
432
	float *v;
-
 
433
 
-
 
434
	v = sna->render.vertices + sna->render.vertex_used;
-
 
435
	sna->render.vertex_used += 12;
-
 
436
 
-
 
437
	v[8] = v[4] = r->dst.x;
-
 
438
	v[9] = r->dst.y;
-
 
439
 
-
 
440
	v[0] = v[4] + w;
-
 
441
	v[5] = v[1] = v[9] + h;
-
 
442
 
-
 
443
	v[10] = v[6] = r->src.x * op->src.scale[0];
-
 
444
	v[11] = r->src.y * op->src.scale[1];
-
 
445
 
-
 
446
	v[2] = v[6] + w * op->src.scale[0];
-
 
447
	v[7] = v[3] = v[11] + h * op->src.scale[1];
-
 
448
}
-
 
449
fastcall static void
-
 
450
gen3_emit_composite_primitive_constant_identity_mask(struct sna *sna,
-
 
451
						     const struct sna_composite_op *op,
-
 
452
						     const struct sna_composite_rectangles *r)
-
 
453
{
-
 
454
	float w = r->width;
-
 
455
	float h = r->height;
-
 
456
	float *v;
-
 
457
 
-
 
458
	v = sna->render.vertices + sna->render.vertex_used;
-
 
459
	sna->render.vertex_used += 12;
-
 
460
 
-
 
461
	v[8] = v[4] = r->dst.x + op->dst.x;
-
 
462
	v[0] = v[4] + w;
-
 
463
 
-
 
464
	v[9] = r->dst.y + op->dst.y;
-
 
465
	v[5] = v[1] = v[9] + h;
-
 
466
 
-
 
467
	v[10] = v[6] = (r->mask.x + op->mask.offset[0]) * op->mask.scale[0];
-
 
468
	v[2] = v[6] + w * op->mask.scale[0];
-
 
469
 
-
 
470
	v[11] = (r->mask.y + op->mask.offset[1]) * op->mask.scale[1];
-
 
471
	v[7] = v[3] = v[11] + h * op->mask.scale[1];
Line 215... Line 472...
215
 
472
}
216
 
473
#endif
217
 
474
 
218
fastcall static void
475
fastcall static void
Line 882... Line 1139...
882
			state->last_drawrect_limit = v;
1139
			state->last_drawrect_limit = v;
883
		}
1140
		}
Line 884... Line 1141...
884
 
1141
 
885
		state->current_dst = bo->unique_id;
1142
		state->current_dst = bo->unique_id;
-
 
1143
	}
886
	}
1144
	assert(bo->exec);
887
	kgem_bo_mark_dirty(bo);
1145
	kgem_bo_mark_dirty(bo);
Line 888... Line 1146...
888
}
1146
}
889
 
1147
 
Line 936... Line 1194...
936
	case SHADER_RADIAL:
1194
	case SHADER_RADIAL:
937
	case SHADER_TEXTURE:
1195
	case SHADER_TEXTURE:
938
		ss2 &= ~S2_TEXCOORD_FMT(tex_count, TEXCOORDFMT_NOT_PRESENT);
1196
		ss2 &= ~S2_TEXCOORD_FMT(tex_count, TEXCOORDFMT_NOT_PRESENT);
939
		ss2 |= S2_TEXCOORD_FMT(tex_count,
1197
		ss2 |= S2_TEXCOORD_FMT(tex_count,
940
				       op->src.is_affine ? TEXCOORDFMT_2D : TEXCOORDFMT_4D);
1198
				       op->src.is_affine ? TEXCOORDFMT_2D : TEXCOORDFMT_4D);
-
 
1199
		assert(op->src.card_format);
941
		map[tex_count * 2 + 0] =
1200
		map[tex_count * 2 + 0] =
942
			op->src.card_format |
1201
			op->src.card_format |
943
			gen3_ms_tiling(op->src.bo->tiling) |
1202
			gen3_ms_tiling(op->src.bo->tiling) |
944
			(op->src.height - 1) << MS3_HEIGHT_SHIFT |
1203
			(op->src.height - 1) << MS3_HEIGHT_SHIFT |
945
			(op->src.width - 1) << MS3_WIDTH_SHIFT;
1204
			(op->src.width - 1) << MS3_WIDTH_SHIFT;
Line 971... Line 1230...
971
	case SHADER_RADIAL:
1230
	case SHADER_RADIAL:
972
	case SHADER_TEXTURE:
1231
	case SHADER_TEXTURE:
973
		ss2 &= ~S2_TEXCOORD_FMT(tex_count, TEXCOORDFMT_NOT_PRESENT);
1232
		ss2 &= ~S2_TEXCOORD_FMT(tex_count, TEXCOORDFMT_NOT_PRESENT);
974
		ss2 |= S2_TEXCOORD_FMT(tex_count,
1233
		ss2 |= S2_TEXCOORD_FMT(tex_count,
975
				       op->mask.is_affine ? TEXCOORDFMT_2D : TEXCOORDFMT_4D);
1234
				       op->mask.is_affine ? TEXCOORDFMT_2D : TEXCOORDFMT_4D);
-
 
1235
		assert(op->mask.card_format);
976
		map[tex_count * 2 + 0] =
1236
		map[tex_count * 2 + 0] =
977
			op->mask.card_format |
1237
			op->mask.card_format |
978
			gen3_ms_tiling(op->mask.bo->tiling) |
1238
			gen3_ms_tiling(op->mask.bo->tiling) |
979
			(op->mask.height - 1) << MS3_HEIGHT_SHIFT |
1239
			(op->mask.height - 1) << MS3_HEIGHT_SHIFT |
980
			(op->mask.width - 1) << MS3_WIDTH_SHIFT;
1240
			(op->mask.width - 1) << MS3_WIDTH_SHIFT;
Line 1355... Line 1615...
1355
			goto flush;
1615
			goto flush;
1356
		else
1616
		else
1357
			goto start;
1617
			goto start;
1358
	}
1618
	}
Line 1359... Line -...
1359
 
-
 
1360
	assert(op->floats_per_rect >= vertex_space(sna));
1619
 
-
 
1620
	assert(rem <= vertex_space(sna));
1361
	assert(rem <= vertex_space(sna));
1621
	assert(op->floats_per_rect <= rem);
1362
	if (want > 1 && want * op->floats_per_rect > rem)
1622
	if (want > 1 && want * op->floats_per_rect > rem)
1363
		want = rem / op->floats_per_rect;
1623
		want = rem / op->floats_per_rect;
Line 1364... Line 1624...
1364
	sna->render.vertex_index += 3*want;
1624
	sna->render.vertex_index += 3*want;
Line 1492... Line 1752...
1492
		}
1752
		}
1493
	}
1753
	}
1494
	return false;
1754
	return false;
1495
}
1755
}
Line -... Line 1756...
-
 
1756
 
-
 
1757
#if 0
-
 
1758
static int
-
 
1759
gen3_composite_picture(struct sna *sna,
-
 
1760
		       PicturePtr picture,
-
 
1761
		       struct sna_composite_op *op,
-
 
1762
		       struct sna_composite_channel *channel,
-
 
1763
		       int16_t x, int16_t y,
-
 
1764
		       int16_t w, int16_t h,
-
 
1765
		       int16_t dst_x, int16_t dst_y,
-
 
1766
		       bool precise)
-
 
1767
{
-
 
1768
	PixmapPtr pixmap;
-
 
1769
	uint32_t color;
-
 
1770
	int16_t dx, dy;
-
 
1771
 
-
 
1772
	DBG(("%s: (%d, %d)x(%d, %d), dst=(%d, %d)\n",
-
 
1773
	     __FUNCTION__, x, y, w, h, dst_x, dst_y));
-
 
1774
 
-
 
1775
	channel->card_format = 0;
-
 
1776
 
-
 
1777
	if (picture->pDrawable == NULL) {
-
 
1778
		SourcePict *source = picture->pSourcePict;
-
 
1779
		int ret = -1;
-
 
1780
 
-
 
1781
		switch (source->type) {
-
 
1782
		case SourcePictTypeSolidFill:
-
 
1783
			DBG(("%s: solid fill [%08x], format %08x\n",
-
 
1784
			     __FUNCTION__,
-
 
1785
			     (unsigned)source->solidFill.color,
-
 
1786
			     (unsigned)picture->format));
-
 
1787
			ret = gen3_init_solid(channel, source->solidFill.color);
Line -... Line 1788...
-
 
1788
			break;
-
 
1789
 
-
 
1790
		case SourcePictTypeLinear:
-
 
1791
			ret = gen3_init_linear(sna, picture, op, channel,
Line -... Line 1792...
-
 
1792
					       x - dst_x, y - dst_y);
-
 
1793
			break;
-
 
1794
 
-
 
1795
		case SourcePictTypeRadial:
-
 
1796
			ret = gen3_init_radial(sna, picture, op, channel,
Line -... Line 1797...
-
 
1797
					       x - dst_x, y - dst_y);
-
 
1798
			break;
-
 
1799
		}
-
 
1800
 
-
 
1801
		if (ret == -1) {
-
 
1802
			if (!precise)
-
 
1803
				ret = sna_render_picture_approximate_gradient(sna, picture, channel,
-
 
1804
									      x, y, w, h, dst_x, dst_y);
-
 
1805
			if (ret == -1)
-
 
1806
				ret = sna_render_picture_fixup(sna, picture, channel,
Line -... Line 1807...
-
 
1807
							       x, y, w, h, dst_x, dst_y);
-
 
1808
		}
-
 
1809
		return ret;
-
 
1810
	}
-
 
1811
 
Line -... Line 1812...
-
 
1812
	if (picture->alphaMap) {
-
 
1813
		DBG(("%s -- fallback, alphamap\n", __FUNCTION__));
-
 
1814
		return sna_render_picture_fixup(sna, picture, channel,
-
 
1815
						x, y, w, h, dst_x, dst_y);
Line -... Line 1816...
-
 
1816
	}
-
 
1817
 
-
 
1818
	if (sna_picture_is_solid(picture, &color)) {
-
 
1819
		DBG(("%s: solid drawable [%08x]\n", __FUNCTION__, color));
Line -... Line 1820...
-
 
1820
		return gen3_init_solid(channel, color);
-
 
1821
	}
-
 
1822
 
Line -... Line 1823...
-
 
1823
	if (sna_picture_is_clear(picture, x, y, w, h, &color)) {
-
 
1824
		DBG(("%s: clear drawable [%08x]\n", __FUNCTION__, color));
-
 
1825
		return gen3_init_solid(channel, color_convert(color, picture->format, PICT_a8r8g8b8));
Line -... Line 1826...
-
 
1826
	}
-
 
1827
 
-
 
1828
	if (!gen3_check_repeat(picture))
Line -... Line 1829...
-
 
1829
		return sna_render_picture_fixup(sna, picture, channel,
-
 
1830
						x, y, w, h, dst_x, dst_y);
Line -... Line 1831...
-
 
1831
 
-
 
1832
	if (!gen3_check_filter(picture))
Line -... Line 1833...
-
 
1833
		return sna_render_picture_fixup(sna, picture, channel,
-
 
1834
						x, y, w, h, dst_x, dst_y);
-
 
1835
 
-
 
1836
	channel->repeat = picture->repeat ? picture->repeatType : RepeatNone;
-
 
1837
	channel->filter = picture->filter;
-
 
1838
	channel->pict_format = picture->format;
-
 
1839
 
-
 
1840
	pixmap = get_drawable_pixmap(picture->pDrawable);
-
 
1841
	get_drawable_deltas(picture->pDrawable, pixmap, &dx, &dy);
-
 
1842
 
-
 
1843
	x += dx + picture->pDrawable->x;
Line -... Line 1844...
-
 
1844
	y += dy + picture->pDrawable->y;
-
 
1845
 
-
 
1846
	if (sna_transform_is_integer_translation(picture->transform, &dx, &dy)) {
-
 
1847
		DBG(("%s: integer translation (%d, %d), removing\n",
-
 
1848
		     __FUNCTION__, dx, dy));
-
 
1849
		x += dx;
Line -... Line 1850...
-
 
1850
		y += dy;
-
 
1851
		channel->transform = NULL;
-
 
1852
		channel->filter = PictFilterNearest;
-
 
1853
	} else {
-
 
1854
		channel->transform = picture->transform;
-
 
1855
		channel->is_affine = sna_transform_is_affine(picture->transform);
-
 
1856
	}
-
 
1857
 
Line -... Line 1858...
-
 
1858
	if (!gen3_composite_channel_set_format(channel, picture->format) &&
-
 
1859
	    !gen3_composite_channel_set_xformat(picture, channel, x, y, w, h))
-
 
1860
		return sna_render_picture_convert(sna, picture, channel, pixmap,
Line -... Line 1861...
-
 
1861
						  x, y, w, h, dst_x, dst_y,
-
 
1862
						  false);
-
 
1863
	assert(channel->card_format);
-
 
1864
 
-
 
1865
	if (too_large(pixmap->drawable.width, pixmap->drawable.height)) {
-
 
1866
		DBG(("%s: pixmap too large (%dx%d), extracting (%d, %d)x(%d,%d)\n",
Line -... Line 1867...
-
 
1867
		     __FUNCTION__,
-
 
1868
		     pixmap->drawable.width, pixmap->drawable.height,
-
 
1869
		     x, y, w, h));
-
 
1870
		return sna_render_picture_extract(sna, picture, channel,
Line -... Line 1871...
-
 
1871
						  x, y, w, h, dst_x, dst_y);
-
 
1872
	}
Line -... Line 1873...
-
 
1873
 
-
 
1874
	return sna_render_pixmap_bo(sna, channel, pixmap,
Line -... Line 1875...
-
 
1875
				    x, y, w, h, dst_x, dst_y);
-
 
1876
}
-
 
1877
 
-
 
1878
static inline bool
-
 
1879
source_use_blt(struct sna *sna, PicturePtr picture)
-
 
1880
{
-
 
1881
	/* If it is a solid, try to use the BLT paths */
-
 
1882
	if (!picture->pDrawable)
-
 
1883
		return picture->pSourcePict->type == SourcePictTypeSolidFill;
-
 
1884
 
Line -... Line 1885...
-
 
1885
	if (picture->pDrawable->width  == 1 &&
-
 
1886
	    picture->pDrawable->height == 1 &&
-
 
1887
	    picture->repeat)
-
 
1888
		return true;
-
 
1889
 
Line -... Line 1890...
-
 
1890
	if (too_large(picture->pDrawable->width, picture->pDrawable->height))
-
 
1891
		return true;
-
 
1892
 
-
 
1893
	return !is_gpu(sna, picture->pDrawable, PREFER_GPU_RENDER);
-
 
1894
}
-
 
1895
 
Line -... Line 1896...
-
 
1896
static bool
-
 
1897
try_blt(struct sna *sna,
-
 
1898
	PicturePtr dst,
-
 
1899
	PicturePtr src,
Line -... Line 1900...
-
 
1900
	int width, int height)
-
 
1901
{
-
 
1902
	if (sna->kgem.mode != KGEM_RENDER) {
-
 
1903
		DBG(("%s: already performing BLT\n", __FUNCTION__));
-
 
1904
		return true;
-
 
1905
	}
-
 
1906
 
Line -... Line 1907...
-
 
1907
	if (too_large(width, height)) {
-
 
1908
		DBG(("%s: operation too large for 3D pipe (%d, %d)\n",
-
 
1909
		     __FUNCTION__, width, height));
-
 
1910
		return true;
-
 
1911
	}
-
 
1912
 
-
 
1913
	if (too_large(dst->pDrawable->width, dst->pDrawable->height)) {
-
 
1914
		DBG(("%s: target too large for 3D pipe (%d, %d)\n",
-
 
1915
		     __FUNCTION__,
-
 
1916
		     dst->pDrawable->width, dst->pDrawable->height));
-
 
1917
		return true;
Line -... Line 1918...
-
 
1918
	}
-
 
1919
 
-
 
1920
	/* is the source picture only in cpu memory e.g. a shm pixmap? */
-
 
1921
	return source_use_blt(sna, src);
-
 
1922
}
-
 
1923
#endif
-
 
1924
 
-
 
1925
static void
-
 
1926
gen3_align_vertex(struct sna *sna,
-
 
1927
		  const struct sna_composite_op *op)
-
 
1928
{
-
 
1929
	if (op->floats_per_vertex != sna->render_state.gen3.last_floats_per_vertex) {
-
 
1930
		if (sna->render.vertex_size - sna->render.vertex_used < 2*op->floats_per_rect)
Line -... Line 1931...
-
 
1931
			gen3_vertex_finish(sna);
-
 
1932
 
-
 
1933
		DBG(("aligning vertex: was %d, now %d floats per vertex, %d->%d\n",
-
 
1934
		     sna->render_state.gen3.last_floats_per_vertex,
-
 
1935
		     op->floats_per_vertex,
-
 
1936
		     sna->render.vertex_index,
-
 
1937
		     (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex));
-
 
1938
		sna->render.vertex_index = (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex;
-
 
1939
		sna->render.vertex_used = sna->render.vertex_index * op->floats_per_vertex;
-
 
1940
		assert(sna->render.vertex_used < sna->render.vertex_size - op->floats_per_rect);
-
 
1941
		sna->render_state.gen3.last_floats_per_vertex = op->floats_per_vertex;
-
 
1942
	}
-
 
1943
}
-
 
1944
 
-
 
1945
static inline bool is_constant_ps(uint32_t type)
-
 
1946
{
-
 
1947
	switch (type) {
-
 
1948
	case SHADER_NONE: /* be warned! */
Line -... Line 1949...
-
 
1949
	case SHADER_ZERO:
Line -... Line 1950...
-
 
1950
	case SHADER_BLACK:
-
 
1951
	case SHADER_WHITE:
-
 
1952
	case SHADER_CONSTANT:
Line -... Line 1953...
-
 
1953
		return true;
-
 
1954
	default:
-
 
1955
		return false;
-
 
1956
	}
-
 
1957
}
-
 
1958
 
-
 
1959
#if 0
-
 
1960
static bool
Line -... Line 1961...
-
 
1961
gen3_composite_fallback(struct sna *sna,
-
 
1962
			uint8_t op,
-
 
1963
			PicturePtr src,
-
 
1964
			PicturePtr mask,
-
 
1965
			PicturePtr dst)
-
 
1966
{
-
 
1967
	PixmapPtr src_pixmap;
-
 
1968
	PixmapPtr mask_pixmap;
-
 
1969
	PixmapPtr dst_pixmap;
-
 
1970
	bool src_fallback, mask_fallback;
-
 
1971
 
-
 
1972
	if (!gen3_check_dst_format(dst->format)) {
Line -... Line 1973...
-
 
1973
		DBG(("%s: unknown destination format: %d\n",
-
 
1974
		     __FUNCTION__, dst->format));
-
 
1975
		return true;
-
 
1976
	}
-
 
1977
 
-
 
1978
	dst_pixmap = get_drawable_pixmap(dst->pDrawable);
-
 
1979
 
-
 
1980
	src_pixmap = src->pDrawable ? get_drawable_pixmap(src->pDrawable) : NULL;
-
 
1981
	src_fallback = source_fallback(src, src_pixmap,
Line -... Line 1982...
-
 
1982
				       dst->polyMode == PolyModePrecise);
-
 
1983
 
-
 
1984
	if (mask) {
-
 
1985
		mask_pixmap = mask->pDrawable ? get_drawable_pixmap(mask->pDrawable) : NULL;
-
 
1986
		mask_fallback = source_fallback(mask, mask_pixmap,
-
 
1987
						dst->polyMode == PolyModePrecise);
Line -... Line 1988...
-
 
1988
	} else {
-
 
1989
		mask_pixmap = NULL;
-
 
1990
		mask_fallback = false;
-
 
1991
	}
-
 
1992
 
-
 
1993
	/* If we are using the destination as a source and need to
-
 
1994
	 * readback in order to upload the source, do it all
-
 
1995
	 * on the cpu.
-
 
1996
	 */
-
 
1997
	if (src_pixmap == dst_pixmap && src_fallback) {
Line -... Line 1998...
-
 
1998
		DBG(("%s: src is dst and will fallback\n",__FUNCTION__));
-
 
1999
		return true;
-
 
2000
	}
-
 
2001
	if (mask_pixmap == dst_pixmap && mask_fallback) {
-
 
2002
		DBG(("%s: mask is dst and will fallback\n",__FUNCTION__));
-
 
2003
		return true;
-
 
2004
	}
-
 
2005
 
-
 
2006
	if (mask &&
Line -... Line 2007...
-
 
2007
	    mask->componentAlpha && PICT_FORMAT_RGB(mask->format) &&
-
 
2008
	    gen3_blend_op[op].src_alpha &&
-
 
2009
	    gen3_blend_op[op].src_blend != BLENDFACT_ZERO &&
-
 
2010
	    op != PictOpOver) {
-
 
2011
		DBG(("%s: component-alpha mask with op=%d, should fallback\n",
Line -... Line 2012...
-
 
2012
		     __FUNCTION__, op));
-
 
2013
		return true;
-
 
2014
	}
-
 
2015
 
-
 
2016
	/* If anything is on the GPU, push everything out to the GPU */
-
 
2017
	if (dst_use_gpu(dst_pixmap)) {
Line -... Line 2018...
-
 
2018
		DBG(("%s: dst is already on the GPU, try to use GPU\n",
-
 
2019
		     __FUNCTION__));
-
 
2020
		return false;
-
 
2021
	}
Line -... Line 2022...
-
 
2022
 
-
 
2023
	if (src_pixmap && !src_fallback) {
-
 
2024
		DBG(("%s: src is already on the GPU, try to use GPU\n",
-
 
2025
		     __FUNCTION__));
-
 
2026
		return false;
-
 
2027
	}
-
 
2028
	if (mask_pixmap && !mask_fallback) {
-
 
2029
		DBG(("%s: mask is already on the GPU, try to use GPU\n",
-
 
2030
		     __FUNCTION__));
-
 
2031
		return false;
-
 
2032
	}
-
 
2033
 
-
 
2034
	/* However if the dst is not on the GPU and we need to
Line -... Line 2035...
-
 
2035
	 * render one of the sources using the CPU, we may
-
 
2036
	 * as well do the entire operation in place onthe CPU.
-
 
2037
	 */
-
 
2038
	if (src_fallback) {
-
 
2039
		DBG(("%s: dst is on the CPU and src will fallback\n",
Line -... Line 2040...
-
 
2040
		     __FUNCTION__));
-
 
2041
		return true;
-
 
2042
	}
-
 
2043
 
-
 
2044
	if (mask && mask_fallback) {
-
 
2045
		DBG(("%s: dst is on the CPU and mask will fallback\n",
-
 
2046
		     __FUNCTION__));
-
 
2047
		return true;
-
 
2048
	}
-
 
2049
 
-
 
2050
	if (too_large(dst_pixmap->drawable.width,
-
 
2051
		      dst_pixmap->drawable.height) &&
Line -... Line 2052...
-
 
2052
	    dst_is_cpu(dst_pixmap)) {
-
 
2053
		DBG(("%s: dst is on the CPU and too large\n", __FUNCTION__));
Line -... Line 2054...
-
 
2054
		return true;
-
 
2055
	}
-
 
2056
 
-
 
2057
	DBG(("%s: dst is not on the GPU and the operation should not fallback: use-cpu? %d\n",
-
 
2058
	     __FUNCTION__, dst_use_cpu(dst_pixmap)));
-
 
2059
	return dst_use_cpu(dst_pixmap);
-
 
2060
}
-
 
2061
 
-
 
2062
static bool
-
 
2063
gen3_render_composite(struct sna *sna,
-
 
2064
		      uint8_t op,
-
 
2065
		      PicturePtr src,
-
 
2066
		      PicturePtr mask,
-
 
2067
		      PicturePtr dst,
Line -... Line 2068...
-
 
2068
		      int16_t src_x,  int16_t src_y,
-
 
2069
		      int16_t mask_x, int16_t mask_y,
-
 
2070
		      int16_t dst_x,  int16_t dst_y,
-
 
2071
		      int16_t width,  int16_t height,
-
 
2072
		      struct sna_composite_op *tmp)
-
 
2073
{
-
 
2074
	DBG(("%s()\n", __FUNCTION__));
-
 
2075
 
-
 
2076
	if (op >= ARRAY_SIZE(gen3_blend_op)) {
Line -... Line 2077...
-
 
2077
		DBG(("%s: fallback due to unhandled blend op: %d\n",
-
 
2078
		     __FUNCTION__, op));
-
 
2079
		return false;
-
 
2080
	}
-
 
2081
 
-
 
2082
	/* Try to use the BLT engine unless it implies a
-
 
2083
	 * 3D -> 2D context switch.
-
 
2084
	 */
-
 
2085
	if (mask == NULL &&
-
 
2086
	    try_blt(sna, dst, src, width, height) &&
-
 
2087
	    sna_blt_composite(sna,
-
 
2088
			      op, src, dst,
-
 
2089
			      src_x, src_y,
-
 
2090
			      dst_x, dst_y,
-
 
2091
			      width, height,
-
 
2092
			      tmp, false))
-
 
2093
		return true;
-
 
2094
 
-
 
2095
	if (gen3_composite_fallback(sna, op, src, mask, dst))
-
 
2096
		return false;
Line -... Line 2097...
-
 
2097
 
-
 
2098
	if (need_tiling(sna, width, height))
-
 
2099
		return sna_tiling_composite(op, src, mask, dst,
-
 
2100
					    src_x,  src_y,
Line -... Line 2101...
-
 
2101
					    mask_x, mask_y,
-
 
2102
					    dst_x,  dst_y,
-
 
2103
					    width,  height,
-
 
2104
					    tmp);
-
 
2105
 
-
 
2106
	if (!gen3_composite_set_target(sna, tmp, dst,
-
 
2107
				       dst_x, dst_y, width, height)) {
-
 
2108
		DBG(("%s: unable to set render target\n",
-
 
2109
		     __FUNCTION__));
-
 
2110
		return false;
-
 
2111
	}
-
 
2112
 
-
 
2113
	tmp->op = op;
-
 
2114
	tmp->rb_reversed = gen3_dst_rb_reversed(tmp->dst.format);
-
 
2115
	if (too_large(tmp->dst.width, tmp->dst.height) ||
-
 
2116
	    !gen3_check_pitch_3d(tmp->dst.bo)) {
-
 
2117
		if (!sna_render_composite_redirect(sna, tmp,
-
 
2118
						   dst_x, dst_y, width, height,
-
 
2119
						   op > PictOpSrc || dst->pCompositeClip->data))
-
 
2120
			return false;
-
 
2121
	}
-
 
2122
 
-
 
2123
	tmp->u.gen3.num_constants = 0;
-
 
2124
	tmp->src.u.gen3.type = SHADER_TEXTURE;
-
 
2125
	tmp->src.is_affine = true;
-
 
2126
	DBG(("%s: preparing source\n", __FUNCTION__));
-
 
2127
	switch (gen3_composite_picture(sna, src, tmp, &tmp->src,
-
 
2128
				       src_x, src_y,
-
 
2129
				       width, height,
-
 
2130
				       dst_x, dst_y,
-
 
2131
				       dst->polyMode == PolyModePrecise)) {
-
 
2132
	case -1:
-
 
2133
		goto cleanup_dst;
-
 
2134
	case 0:
-
 
2135
		tmp->src.u.gen3.type = SHADER_ZERO;
-
 
2136
		break;
-
 
2137
	case 1:
-
 
2138
		if (mask == NULL && tmp->src.bo &&
-
 
2139
		    sna_blt_composite__convert(sna,
-
 
2140
					       dst_x, dst_y, width, height,
-
 
2141
					       tmp))
-
 
2142
			return true;
-
 
2143
 
-
 
2144
		gen3_composite_channel_convert(&tmp->src);
-
 
2145
		break;
-
 
2146
	}
-
 
2147
	DBG(("%s: source type=%d\n", __FUNCTION__, tmp->src.u.gen3.type));
-
 
2148
 
-
 
2149
	tmp->mask.u.gen3.type = SHADER_NONE;
-
 
2150
	tmp->mask.is_affine = true;
-
 
2151
	tmp->need_magic_ca_pass = false;
-
 
2152
	tmp->has_component_alpha = false;
Line -... Line 2153...
-
 
2153
	if (mask && tmp->src.u.gen3.type != SHADER_ZERO) {
-
 
2154
		if (!reuse_source(sna,
-
 
2155
				  src, &tmp->src, src_x, src_y,
-
 
2156
				  mask, &tmp->mask, mask_x, mask_y)) {
-
 
2157
			tmp->mask.u.gen3.type = SHADER_TEXTURE;
-
 
2158
			DBG(("%s: preparing mask\n", __FUNCTION__));
-
 
2159
			switch (gen3_composite_picture(sna, mask, tmp, &tmp->mask,
-
 
2160
						       mask_x, mask_y,
-
 
2161
						       width,  height,
Line -... Line 2162...
-
 
2162
						       dst_x,  dst_y,
-
 
2163
						       dst->polyMode == PolyModePrecise)) {
-
 
2164
			case -1:
-
 
2165
				goto cleanup_src;
-
 
2166
			case 0:
-
 
2167
				tmp->mask.u.gen3.type = SHADER_ZERO;
-
 
2168
				break;
-
 
2169
			case 1:
-
 
2170
				gen3_composite_channel_convert(&tmp->mask);
-
 
2171
				break;
-
 
2172
			}
-
 
2173
		}
Line -... Line 2174...
-
 
2174
		DBG(("%s: mask type=%d\n", __FUNCTION__, tmp->mask.u.gen3.type));
-
 
2175
		if (tmp->mask.u.gen3.type == SHADER_ZERO) {
-
 
2176
			if (tmp->src.bo) {
-
 
2177
				kgem_bo_destroy(&sna->kgem,
-
 
2178
						tmp->src.bo);
Line -... Line 2179...
-
 
2179
				tmp->src.bo = NULL;
-
 
2180
			}
-
 
2181
			tmp->src.u.gen3.type = SHADER_ZERO;
Line -... Line 2182...
-
 
2182
			tmp->mask.u.gen3.type = SHADER_NONE;
-
 
2183
		}
-
 
2184
 
-
 
2185
		if (tmp->mask.u.gen3.type != SHADER_NONE) {
-
 
2186
			if (mask->componentAlpha && PICT_FORMAT_RGB(mask->format)) {
-
 
2187
				/* Check if it's component alpha that relies on a source alpha
-
 
2188
				 * and on the source value.  We can only get one of those
-
 
2189
				 * into the single source value that we get to blend with.
Line -... Line 2190...
-
 
2190
				 */
-
 
2191
				DBG(("%s: component-alpha mask: %d\n",
-
 
2192
				     __FUNCTION__, tmp->mask.u.gen3.type));
-
 
2193
				tmp->has_component_alpha = true;
-
 
2194
				if (tmp->mask.u.gen3.type == SHADER_WHITE) {
-
 
2195
					tmp->mask.u.gen3.type = SHADER_NONE;
-
 
2196
					tmp->has_component_alpha = false;
-
 
2197
				} else if (gen3_blend_op[op].src_alpha &&
-
 
2198
					   gen3_blend_op[op].src_blend != BLENDFACT_ZERO) {
-
 
2199
					if (op != PictOpOver)
-
 
2200
						goto cleanup_mask;
-
 
2201
 
-
 
2202
					tmp->need_magic_ca_pass = true;
-
 
2203
					tmp->op = PictOpOutReverse;
-
 
2204
				}
-
 
2205
			} else {
-
 
2206
				if (tmp->mask.is_opaque) {
-
 
2207
					tmp->mask.u.gen3.type = SHADER_NONE;
Line -... Line 2208...
-
 
2208
				} else if (is_constant_ps(tmp->src.u.gen3.type) &&
-
 
2209
					   is_constant_ps(tmp->mask.u.gen3.type)) {
-
 
2210
					uint32_t v;
-
 
2211
 
-
 
2212
					v = multa(tmp->src.u.gen3.mode,
-
 
2213
						  tmp->mask.u.gen3.mode,
-
 
2214
						  24);
-
 
2215
					v |= multa(tmp->src.u.gen3.mode,
-
 
2216
						   tmp->mask.u.gen3.mode,
-
 
2217
						   16);
-
 
2218
					v |= multa(tmp->src.u.gen3.mode,
-
 
2219
						   tmp->mask.u.gen3.mode,
-
 
2220
						   8);
-
 
2221
					v |= multa(tmp->src.u.gen3.mode,
-
 
2222
						   tmp->mask.u.gen3.mode,
-
 
2223
						   0);
-
 
2224
 
-
 
2225
					DBG(("%s: combining constant source/mask: %x x %x -> %x\n",
-
 
2226
					     __FUNCTION__,
-
 
2227
					     tmp->src.u.gen3.mode,
-
 
2228
					     tmp->mask.u.gen3.mode,
-
 
2229
					     v));
-
 
2230
 
-
 
2231
					tmp->src.u.gen3.type = SHADER_CONSTANT;
-
 
2232
					tmp->src.u.gen3.mode = v;
-
 
2233
					tmp->src.is_opaque = false;
-
 
2234
 
-
 
2235
					tmp->mask.u.gen3.type = SHADER_NONE;
-
 
2236
				}
-
 
2237
			}
-
 
2238
		}
-
 
2239
	}
-
 
2240
	DBG(("%s: final src/mask type=%d/%d, affine=%d/%d\n", __FUNCTION__,
-
 
2241
	     tmp->src.u.gen3.type, tmp->mask.u.gen3.type,
-
 
2242
	     tmp->src.is_affine, tmp->mask.is_affine));
-
 
2243
 
-
 
2244
	tmp->prim_emit = gen3_emit_composite_primitive;
-
 
2245
	if (is_constant_ps(tmp->mask.u.gen3.type)) {
-
 
2246
		switch (tmp->src.u.gen3.type) {
-
 
2247
		case SHADER_NONE:
-
 
2248
		case SHADER_ZERO:
-
 
2249
		case SHADER_BLACK:
-
 
2250
		case SHADER_WHITE:
-
 
2251
		case SHADER_CONSTANT:
-
 
2252
#if defined(sse2) && !defined(__x86_64__)
-
 
2253
			if (sna->cpu_features & SSE2) {
-
 
2254
				tmp->prim_emit = gen3_emit_composite_primitive_constant__sse2;
-
 
2255
				tmp->emit_boxes = gen3_emit_composite_boxes_constant__sse2;
-
 
2256
			} else
-
 
2257
#endif
-
 
2258
			{
-
 
2259
				tmp->prim_emit = gen3_emit_composite_primitive_constant;
-
 
2260
				tmp->emit_boxes = gen3_emit_composite_boxes_constant;
-
 
2261
			}
-
 
2262
 
-
 
2263
			break;
-
 
2264
		case SHADER_LINEAR:
-
 
2265
		case SHADER_RADIAL:
-
 
2266
			if (tmp->src.transform == NULL) {
-
 
2267
#if defined(sse2) && !defined(__x86_64__)
-
 
2268
				if (sna->cpu_features & SSE2) {
-
 
2269
					tmp->prim_emit = gen3_emit_composite_primitive_identity_gradient__sse2;
-
 
2270
					tmp->emit_boxes = gen3_emit_composite_boxes_identity_gradient__sse2;
-
 
2271
				} else
-
 
2272
#endif
-
 
2273
				{
-
 
2274
					tmp->prim_emit = gen3_emit_composite_primitive_identity_gradient;
-
 
2275
					tmp->emit_boxes = gen3_emit_composite_boxes_identity_gradient;
-
 
2276
				}
-
 
2277
			} else if (tmp->src.is_affine) {
-
 
2278
				tmp->src.scale[1] = tmp->src.scale[0] = 1. / tmp->src.transform->matrix[2][2];
-
 
2279
#if defined(sse2) && !defined(__x86_64__)
-
 
2280
				if (sna->cpu_features & SSE2) {
-
 
2281
					tmp->prim_emit = gen3_emit_composite_primitive_affine_gradient__sse2;
-
 
2282
					tmp->emit_boxes = gen3_emit_composite_boxes_affine_gradient__sse2;
-
 
2283
				} else
-
 
2284
#endif
-
 
2285
				{
-
 
2286
					tmp->prim_emit = gen3_emit_composite_primitive_affine_gradient;
-
 
2287
					tmp->emit_boxes = gen3_emit_composite_boxes_affine_gradient;
-
 
2288
				}
-
 
2289
			}
-
 
2290
			break;
-
 
2291
		case SHADER_TEXTURE:
-
 
2292
			if (tmp->src.transform == NULL) {
-
 
2293
				if ((tmp->src.offset[0]|tmp->src.offset[1]|tmp->dst.x|tmp->dst.y) == 0) {
-
 
2294
#if defined(sse2) && !defined(__x86_64__)
-
 
2295
					if (sna->cpu_features & SSE2) {
-
 
2296
						tmp->prim_emit = gen3_emit_composite_primitive_identity_source_no_offset__sse2;
-
 
2297
						tmp->emit_boxes = gen3_emit_composite_boxes_identity_source_no_offset__sse2;
-
 
2298
					} else
-
 
2299
#endif
-
 
2300
					{
-
 
2301
						tmp->prim_emit = gen3_emit_composite_primitive_identity_source_no_offset;
-
 
2302
						tmp->emit_boxes = gen3_emit_composite_boxes_identity_source_no_offset;
-
 
2303
					}
-
 
2304
				} else {
-
 
2305
#if defined(sse2) && !defined(__x86_64__)
-
 
2306
					if (sna->cpu_features & SSE2) {
-
 
2307
						tmp->prim_emit = gen3_emit_composite_primitive_identity_source__sse2;
-
 
2308
						tmp->emit_boxes = gen3_emit_composite_boxes_identity_source__sse2;
-
 
2309
					} else
-
 
2310
#endif
-
 
2311
					{
-
 
2312
						tmp->prim_emit = gen3_emit_composite_primitive_identity_source;
-
 
2313
						tmp->emit_boxes = gen3_emit_composite_boxes_identity_source;
-
 
2314
					}
-
 
2315
				}
-
 
2316
			} else if (tmp->src.is_affine) {
-
 
2317
				tmp->src.scale[0] /= tmp->src.transform->matrix[2][2];
-
 
2318
				tmp->src.scale[1] /= tmp->src.transform->matrix[2][2];
-
 
2319
#if defined(sse2) && !defined(__x86_64__)
-
 
2320
				if (sna->cpu_features & SSE2) {
-
 
2321
					tmp->prim_emit = gen3_emit_composite_primitive_affine_source__sse2;
Line -... Line 2322...
-
 
2322
					tmp->emit_boxes = gen3_emit_composite_boxes_affine_source__sse2;
-
 
2323
				} else
-
 
2324
#endif
-
 
2325
				{
-
 
2326
					tmp->prim_emit = gen3_emit_composite_primitive_affine_source;
-
 
2327
					tmp->emit_boxes = gen3_emit_composite_boxes_affine_source;
-
 
2328
				}
-
 
2329
			}
-
 
2330
			break;
-
 
2331
		}
-
 
2332
	} else if (tmp->mask.u.gen3.type == SHADER_TEXTURE) {
Line -... Line 2333...
-
 
2333
		if (tmp->mask.transform == NULL) {
-
 
2334
			if (is_constant_ps(tmp->src.u.gen3.type)) {
-
 
2335
				if ((tmp->mask.offset[0]|tmp->mask.offset[1]|tmp->dst.x|tmp->dst.y) == 0) {
-
 
2336
#if defined(sse2) && !defined(__x86_64__)
-
 
2337
					if (sna->cpu_features & SSE2) {
-
 
2338
						tmp->prim_emit = gen3_emit_composite_primitive_constant_identity_mask_no_offset__sse2;
-
 
2339
					} else
-
 
2340
#endif
Line -... Line 2341...
-
 
2341
					{
-
 
2342
						tmp->prim_emit = gen3_emit_composite_primitive_constant_identity_mask_no_offset;
-
 
2343
					}
-
 
2344
				} else {
-
 
2345
#if defined(sse2) && !defined(__x86_64__)
-
 
2346
					if (sna->cpu_features & SSE2) {
-
 
2347
						tmp->prim_emit = gen3_emit_composite_primitive_constant_identity_mask__sse2;
-
 
2348
					} else
-
 
2349
#endif
Line 1496... Line -...
1496
 
-
 
1497
 
2350
					{
1498
 
2351
						tmp->prim_emit = gen3_emit_composite_primitive_constant_identity_mask;
1499
 
-
 
1500
 
-
 
1501
 
-
 
1502
 
2352
					}
Line -... Line 2353...
-
 
2353
				}
1503
 
2354
			} else if (tmp->src.transform == NULL) {
1504
 
2355
#if defined(sse2) && !defined(__x86_64__)
1505
 
2356
				if (sna->cpu_features & SSE2) {
1506
 
2357
					tmp->prim_emit = gen3_emit_composite_primitive_identity_source_mask__sse2;
1507
 
2358
				} else
1508
 
-
 
1509
 
2359
#endif
1510
 
2360
				{
1511
 
2361
					tmp->prim_emit = gen3_emit_composite_primitive_identity_source_mask;
1512
 
2362
				}
1513
 
2363
			} else if (tmp->src.is_affine) {
-
 
2364
				tmp->src.scale[0] /= tmp->src.transform->matrix[2][2];
Line 1708... Line -...
1708
 
-
 
1709
 
-
 
1710
 
-
 
1711
 
-
 
1712
 
-
 
1713
static inline bool is_constant_ps(uint32_t type)
-
 
1714
{
-
 
1715
	switch (type) {
-
 
1716
	case SHADER_NONE: /* be warned! */
-
 
1717
	case SHADER_ZERO:
-
 
1718
	case SHADER_BLACK:
-
 
1719
	case SHADER_WHITE:
-
 
1720
	case SHADER_CONSTANT:
-
 
Line -... Line 2656...
-
 
2656
 
-
 
2657
 
-
 
2658
 
Line -... Line 2659...
-
 
2659
 
-
 
2660
 
-
 
2661
static void gen3_render_flush(struct sna *sna)
Line -... Line 2662...
-
 
2662
{
-
 
2663
	gen3_vertex_close(sna);
-
 
2664
 
-
 
2665
	assert(sna->render.vertex_reloc[0] == 0);
Line -... Line 2666...
-
 
2666
	assert(sna->render.vertex_offset == 0);
-
 
2667
}
-
 
2668
 
Line -... Line 2669...
-
 
2669
static void
-
 
2670
gen3_render_fini(struct sna *sna)
-
 
2671
{
-
 
2672
}
-
 
2673
 
-
 
2674
const char *gen3_render_init(struct sna *sna, const char *backend)
-
 
2675
{
-
 
2676
	struct sna_render *render = &sna->render;
-
 
2677
 
-
 
2678
#if 0
Line -... Line 2679...
-
 
2679
#if !NO_COMPOSITE
Line -... Line 2680...
-
 
2680
	render->composite = gen3_render_composite;
-
 
2681
	render->prefer_gpu |= PREFER_GPU_RENDER;
Line -... Line 2682...
-
 
2682
#endif
-
 
2683
#if !NO_COMPOSITE_SPANS
-
 
2684
	render->check_composite_spans = gen3_check_composite_spans;
-
 
2685
	render->composite_spans = gen3_render_composite_spans;
Line -... Line 2686...
-
 
2686
	render->prefer_gpu |= PREFER_GPU_SPANS;
-
 
2687
#endif
Line -... Line 2688...
-
 
2688
 
-
 
2689
	render->video = gen3_render_video;
-
 
2690
 
Line -... Line 2691...
-
 
2691
	render->copy_boxes = gen3_render_copy_boxes;
-
 
2692
	render->copy = gen3_render_copy;
Line -... Line 2693...
-
 
2693
 
-
 
2694
	render->fill_boxes = gen3_render_fill_boxes;
-
 
2695
	render->fill = gen3_render_fill;
-
 
2696
	render->fill_one = gen3_render_fill_one;
Line 1818... Line 2697...
1818
 
2697
#endif
1819
 
2698
 
1820
 
2699
    render->blit_tex = gen3_blit_tex;
1821
 
2700
    render->caps = HW_BIT_BLIT | HW_TEX_BLIT;
Line 1931... Line 2810...
1931
 
2810
 
1932
	gen3_emit_composite_state(sna, tmp);
2811
	gen3_emit_composite_state(sna, tmp);
1933
	gen3_align_vertex(sna, tmp);
2812
	gen3_align_vertex(sna, tmp);
1934
	return true;
2813
	return true;
1935
}
-
 
1936
 
-
 
1937
static void gen3_render_flush(struct sna *sna)
-
 
1938
{
-
 
1939
	gen3_vertex_close(sna);
-
 
1940
 
-
 
1941
	assert(sna->render.vertex_reloc[0] == 0);
-
 
1942
	assert(sna->render.vertex_offset == 0);
-
 
1943
}
-
 
1944
 
-
 
1945
static void
-
 
1946
gen3_render_fini(struct sna *sna)
-
 
1947
{
-
 
1948
}
-
 
1949
 
-
 
1950
bool gen3_render_init(struct sna *sna)
-
 
1951
{
-
 
1952
	struct sna_render *render = &sna->render;
-
 
1953
 
-
 
1954
 
-
 
1955
//	render->video = gen3_render_video;
-
 
1956
 
-
 
1957
    render->blit_tex = gen3_blit_tex;
-
 
1958
 
-
 
1959
	render->reset = gen3_render_reset;
-
 
1960
	render->flush = gen3_render_flush;
-
 
1961
	render->fini = gen3_render_fini;
-
 
1962
 
-
 
1963
	render->max_3d_size = MAX_3D_SIZE;
-
 
1964
	render->max_3d_pitch = MAX_3D_PITCH;
-
 
1965
 
-
 
1966
    render->caps = HW_BIT_BLIT | HW_TEX_BLIT;
-
 
1967
 
-
 
1968
	sna->kgem.retire = gen3_render_retire;
-
 
1969
	sna->kgem.expire = gen3_render_expire;
-
 
1970
	return true;
-