Subversion Repositories Kolibri OS

Rev

Rev 4359 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4359 Rev 4501
Line 39... Line 39...
39
#include "sna_render.h"
39
#include "sna_render.h"
40
#include "sna_render_inline.h"
40
#include "sna_render_inline.h"
41
//#include "sna_video.h"
41
//#include "sna_video.h"
Line 42... Line 42...
42
 
42
 
-
 
43
#include "brw/brw.h"
43
#include "brw/brw.h"
44
#include "gen4_common.h"
44
#include "gen4_render.h"
45
#include "gen4_render.h"
45
#include "gen4_source.h"
46
#include "gen4_source.h"
Line 46... Line 47...
46
#include "gen4_vertex.h"
47
#include "gen4_vertex.h"
Line 547... Line 548...
547
			      2*FORCE_FLUSH + (op->need_magic_ca_pass ? 25 : 6)))
548
			      2*FORCE_FLUSH + (op->need_magic_ca_pass ? 25 : 6)))
548
		return 0;
549
		return 0;
549
	if (!kgem_check_reloc_and_exec(&sna->kgem, 2))
550
	if (!kgem_check_reloc_and_exec(&sna->kgem, 2))
550
		return 0;
551
		return 0;
Line 551... Line -...
551
 
-
 
552
	if (op->need_magic_ca_pass && sna->render.vbo)
-
 
553
		return 0;
-
 
554
 
552
 
555
	if (sna->render.vertex_offset) {
553
	if (sna->render.vertex_offset) {
556
		gen4_vertex_flush(sna);
554
		gen4_vertex_flush(sna);
557
		if (gen4_magic_ca_pass(sna, op))
555
		if (gen4_magic_ca_pass(sna, op))
558
			gen4_emit_pipelined_pointers(sna, op, op->op,
556
			gen4_emit_pipelined_pointers(sna, op, op->op,
Line 745... Line 743...
745
static void
743
static void
746
gen4_align_vertex(struct sna *sna, const struct sna_composite_op *op)
744
gen4_align_vertex(struct sna *sna, const struct sna_composite_op *op)
747
{
745
{
748
	assert(op->floats_per_rect == 3*op->floats_per_vertex);
746
	assert(op->floats_per_rect == 3*op->floats_per_vertex);
749
	if (op->floats_per_vertex != sna->render_state.gen4.floats_per_vertex) {
747
	if (op->floats_per_vertex != sna->render_state.gen4.floats_per_vertex) {
750
		if (sna->render.vertex_size - sna->render.vertex_used < 2*op->floats_per_rect)
-
 
751
			gen4_vertex_finish(sna);
-
 
752
 
-
 
753
		DBG(("aligning vertex: was %d, now %d floats per vertex, %d->%d\n",
748
		DBG(("aligning vertex: was %d, now %d floats per vertex\n",
754
		     sna->render_state.gen4.floats_per_vertex,
749
		     sna->render_state.gen4.floats_per_vertex,
755
		     op->floats_per_vertex,
750
		     op->floats_per_vertex));
756
		     sna->render.vertex_index,
751
		gen4_vertex_align(sna, op);
757
		     (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex));
-
 
758
		sna->render.vertex_index = (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex;
-
 
759
		sna->render.vertex_used = sna->render.vertex_index * op->floats_per_vertex;
-
 
760
		sna->render_state.gen4.floats_per_vertex = op->floats_per_vertex;
752
		sna->render_state.gen4.floats_per_vertex = op->floats_per_vertex;
761
	}
753
	}
762
}
754
}
Line 763... Line 755...
763
 
755
 
Line 1312... Line 1304...
1312
	tmp.floats_per_rect = 9;
1304
	tmp.floats_per_rect = 9;
1313
	tmp.priv = frame;
1305
	tmp.priv = frame;
Line 1314... Line 1306...
1314
 
1306
 
1315
	if (!kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL)) {
1307
	if (!kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL)) {
1316
		kgem_submit(&sna->kgem);
1308
		kgem_submit(&sna->kgem);
-
 
1309
		if (!kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL))
1317
		assert(kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL));
1310
			return false;
Line 1318... Line -...
1318
	}
-
 
1319
 
1311
	}
-
 
1312
 
Line 1320... Line 1313...
1320
	gen4_video_bind_surfaces(sna, &tmp);
1313
	gen4_align_vertex(sna, &tmp);
1321
	gen4_align_vertex(sna, &tmp);
1314
	gen4_video_bind_surfaces(sna, &tmp);
1322
 
1315
 
1323
	/* Set up the offset for translating from the given region (in screen
1316
	/* Set up the offset for translating from the given region (in screen
Line 1547... Line 1540...
1547
 
1540
 
1548
	return true;
1541
	return true;
Line 1549... Line 1542...
1549
}
1542
}
1550
 
-
 
1551
static bool
-
 
1552
try_blt(struct sna *sna,
-
 
1553
	PicturePtr dst, PicturePtr src,
-
 
1554
	int width, int height)
-
 
1555
{
-
 
1556
	if (sna->kgem.mode != KGEM_RENDER) {
-
 
1557
		DBG(("%s: already performing BLT\n", __FUNCTION__));
-
 
1558
		return true;
-
 
1559
	}
-
 
1560
 
-
 
1561
	if (too_large(width, height)) {
-
 
1562
		DBG(("%s: operation too large for 3D pipe (%d, %d)\n",
-
 
1563
		     __FUNCTION__, width, height));
-
 
1564
		return true;
-
 
1565
	}
-
 
1566
 
-
 
1567
	if (too_large(dst->pDrawable->width, dst->pDrawable->height))
-
 
1568
		return true;
-
 
1569
 
-
 
1570
	/* The blitter is much faster for solids */
-
 
1571
	if (sna_picture_is_solid(src, NULL))
-
 
1572
		return true;
-
 
1573
 
-
 
1574
	/* is the source picture only in cpu memory e.g. a shm pixmap? */
-
 
1575
	return picture_is_cpu(sna, src);
-
 
1576
}
-
 
1577
 
1543
 
1578
static bool
1544
static bool
1579
check_gradient(PicturePtr picture, bool precise)
1545
check_gradient(PicturePtr picture, bool precise)
1580
{
1546
{
1581
	switch (picture->pSourcePict->type) {
1547
	switch (picture->pSourcePict->type) {
Line 1801... Line 1767...
1801
 
1767
 
1802
	if (op >= ARRAY_SIZE(gen4_blend_op))
1768
	if (op >= ARRAY_SIZE(gen4_blend_op))
Line 1803... Line 1769...
1803
		return false;
1769
		return false;
1804
 
-
 
1805
	if (mask == NULL &&
1770
 
1806
	    try_blt(sna, dst, src, width, height) &&
1771
	if (mask == NULL &&
1807
	    sna_blt_composite(sna, op,
1772
	    sna_blt_composite(sna, op,
1808
			      src, dst,
1773
			      src, dst,
1809
			      src_x, src_y,
1774
			      src_x, src_y,
Line 1930... Line 1895...
1930
				     tmp->dst.bo, tmp->src.bo, tmp->mask.bo,
1895
				     tmp->dst.bo, tmp->src.bo, tmp->mask.bo,
1931
				     NULL))
1896
				     NULL))
1932
			goto cleanup_mask;
1897
			goto cleanup_mask;
1933
	}
1898
	}
Line 1934... Line -...
1934
 
-
 
1935
	gen4_bind_surfaces(sna, tmp);
1899
 
-
 
1900
	gen4_align_vertex(sna, tmp);
1936
	gen4_align_vertex(sna, tmp);
1901
	gen4_bind_surfaces(sna, tmp);
Line 1937... Line 1902...
1937
	return true;
1902
	return true;
1938
 
1903
 
1939
cleanup_mask:
1904
cleanup_mask:
Line 1988... Line -...
1988
 
-
 
1989
 
-
 
1990
 
-
 
1991
 
-
 
1992
 
-
 
1993
static void
-
 
1994
gen4_render_flush(struct sna *sna)
-
 
1995
{
-
 
1996
	gen4_vertex_close(sna);
-
 
1997
 
-
 
1998
	assert(sna->render.vb_id == 0);
-
 
1999
	assert(sna->render.vertex_offset == 0);
-
 
2000
}
-
 
2001
 
-
 
2002
static void
-
 
2003
discard_vbo(struct sna *sna)
-
 
2004
{
-
 
2005
	kgem_bo_destroy(&sna->kgem, sna->render.vbo);
-
 
2006
	sna->render.vbo = NULL;
-
 
2007
	sna->render.vertices = sna->render.vertex_data;
-
 
2008
	sna->render.vertex_size = ARRAY_SIZE(sna->render.vertex_data);
-
 
2009
	sna->render.vertex_used = 0;
-
 
2010
	sna->render.vertex_index = 0;
-
 
2011
}
-
 
2012
 
-
 
2013
static void
-
 
2014
gen4_render_retire(struct kgem *kgem)
-
 
2015
{
-
 
2016
	struct sna *sna;
-
 
2017
 
-
 
2018
	sna = container_of(kgem, struct sna, kgem);
-
 
2019
	if (kgem->nbatch == 0 && sna->render.vbo && !kgem_bo_is_busy(sna->render.vbo)) {
-
 
2020
		DBG(("%s: resetting idle vbo\n", __FUNCTION__));
-
 
2021
		sna->render.vertex_used = 0;
-
 
2022
		sna->render.vertex_index = 0;
-
 
2023
	}
-
 
2024
}
-
 
2025
 
-
 
2026
static void
-
 
2027
gen4_render_expire(struct kgem *kgem)
-
 
2028
{
-
 
2029
	struct sna *sna;
-
 
2030
 
-
 
2031
	sna = container_of(kgem, struct sna, kgem);
-
 
2032
	if (sna->render.vbo && !sna->render.vertex_used) {
-
 
2033
		DBG(("%s: discarding vbo\n", __FUNCTION__));
1953
 
2034
		discard_vbo(sna);
1954
 
2035
	}
1955
 
2036
}
1956
 
2037
 
1957
 
Line 2045... Line 1965...
2045
 
1965
 
2046
	sna->render_state.gen4.drawrect_offset = -1;
1966
	sna->render_state.gen4.drawrect_offset = -1;
2047
	sna->render_state.gen4.drawrect_limit = -1;
1967
	sna->render_state.gen4.drawrect_limit = -1;
Line 2048... Line -...
2048
	sna->render_state.gen4.surface_table = -1;
-
 
2049
 
1968
	sna->render_state.gen4.surface_table = -1;
2050
	if (sna->render.vbo &&
1969
 
2051
	    !kgem_bo_is_mappable(&sna->kgem, sna->render.vbo)) {
1970
	if (sna->render.vbo && !kgem_bo_can_map(&sna->kgem, sna->render.vbo)) {
2052
		DBG(("%s: discarding unmappable vbo\n", __FUNCTION__));
1971
		DBG(("%s: discarding unmappable vbo\n", __FUNCTION__));
Line 2053... Line 1972...
2053
		discard_vbo(sna);
1972
		discard_vbo(sna);
Line 2405... Line 2324...
2405
			   tmp->dst.bo, tmp->src.bo, tmp->mask.bo,
2324
			   tmp->dst.bo, tmp->src.bo, tmp->mask.bo,
2406
			   NULL)) {
2325
			   NULL)) {
2407
		kgem_submit(&sna->kgem);
2326
		kgem_submit(&sna->kgem);
2408
	}
2327
	}
Line 2409... Line -...
2409
 
-
 
2410
	gen4_bind_surfaces(sna, tmp);
2328
 
-
 
2329
	gen4_align_vertex(sna, tmp);
2411
	gen4_align_vertex(sna, tmp);
2330
	gen4_bind_surfaces(sna, tmp);
2412
	return true;
2331
	return true;