xref: /haiku/src/add-ons/accelerants/nvidia/Acceleration.c (revision 893988af824e65e49e55f517b157db8386e8002b)
1 /*
2 	Copyright 1999, Be Incorporated.   All Rights Reserved.
3 	This file may be used under the terms of the Be Sample Code License.
4 
5 	Other authors:
6 	Rudolf Cornelissen 9/2003-2/2005.
7 */
8 
9 /*
10 	note:
11 	moved DMA acceleration 'top-level' routines to be integrated in the engine:
12 	it is costly to call the engine for every single function within a loop!
13 	(measured with BeRoMeter 1.2.6: upto 15% speed increase on all CPU's.)
14 	Leaving PIO acceleration as it is for now, for the purpose of benchmarking :-)
15 
16 	note also:
17 	attempting DMA on NV40 and higher because without it I can't get them going ATM.
18 	Maybe later we can forget about PIO mode acceleration totally (depends on 3D
19 	acceleration attempts).
20 */
21 
22 #define MODULE_BIT 0x40000000
23 
24 #include "acc_std.h"
25 
26 void SCREEN_TO_SCREEN_BLIT_PIO(engine_token *et, blit_params *list, uint32 count)
27 {
28 	int i;
29 
30 	/* init acc engine for blit function */
31 	nv_acc_setup_blit();
32 
33 	/* do each blit */
34 	i=0;
35 	while (count--)
36 	{
37 		nv_acc_blit
38 		(
39 			list[i].src_left,
40 			list[i].src_top,
41 			list[i].dest_left,
42 			list[i].dest_top,
43 			list[i].width,
44 			list[i].height
45 		);
46 		i++;
47 	}
48 }
49 
50 void SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT_PIO(engine_token *et, scaled_blit_params *list, uint32 count)
51 {
52 	int i;
53 
54 	/* do each blit */
55 	i=0;
56 	while (count--)
57 	{
58 		nv_acc_video_blit
59 		(
60 			list[i].src_left,
61 			list[i].src_top,
62 			list[i].src_width,
63 			list[i].src_height,
64 			list[i].dest_left,
65 			list[i].dest_top,
66 			list[i].dest_width,
67 			list[i].dest_height
68 		);
69 		i++;
70 	}
71 }
72 
73 void SCREEN_TO_SCREEN_TRANSPARENT_BLIT_PIO(engine_token *et, uint32 transparent_colour, blit_params *list, uint32 count)
74 {
75 	int i;
76 
77 	/* do each blit */
78 	i=0;
79 	while (count--)
80 	{
81 		nv_acc_transparent_blit
82 		(
83 			list[i].src_left,
84 			list[i].src_top,
85 			list[i].dest_left,
86 			list[i].dest_top,
87 			list[i].width,
88 			list[i].height,
89 			transparent_colour
90 		);
91 		i++;
92 	}
93 }
94 
95 void FILL_RECTANGLE_PIO(engine_token *et, uint32 colorIndex, fill_rect_params *list, uint32 count)
96 {
97 	int i;
98 
99 	/* init acc engine for fill function */
100 	nv_acc_setup_rectangle(colorIndex);
101 
102 	/* draw each rectangle */
103 	i=0;
104 	while (count--)
105 	{
106 		nv_acc_rectangle
107 		(
108 			list[i].left,
109 			(list[i].right)+1,
110 			list[i].top,
111 			(list[i].bottom-list[i].top)+1
112 		);
113 		i++;
114 	}
115 }
116 
117 void INVERT_RECTANGLE_PIO(engine_token *et, fill_rect_params *list, uint32 count)
118 {
119 	int i;
120 
121 	/* init acc engine for invert function */
122 	nv_acc_setup_rect_invert();
123 
124 	/* invert each rectangle */
125 	i=0;
126 	while (count--)
127 	{
128 		nv_acc_rectangle_invert
129 		(
130 			list[i].left,
131 			(list[i].right)+1,
132 			list[i].top,
133 			(list[i].bottom-list[i].top)+1
134 		);
135 		i++;
136 	}
137 }
138 
139 void FILL_SPAN_PIO(engine_token *et, uint32 colorIndex, uint16 *list, uint32 count)
140 {
141 	int i;
142 
143 	/* init acc engine for fill function */
144 	nv_acc_setup_rectangle(colorIndex);
145 
146 	/* draw each span */
147 	i=0;
148 	while (count--)
149 	{
150 		nv_acc_rectangle
151 		(
152 			list[i+1],
153 			list[i+2]+1,
154 			list[i],
155 			1
156 		);
157 		i+=3;
158 	}
159 }
160