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 35... | Line 35... | ||
35 | */ |
35 | */ |
Line 36... | Line 36... | ||
36 | 36 | ||
37 | #ifndef _SNA_H_ |
37 | #ifndef _SNA_H_ |
Line -... | Line 38... | ||
- | 38 | #define _SNA_H_ |
|
- | 39 | ||
38 | #define _SNA_H_ |
40 | #include |
39 | 41 | ||
40 | #ifdef HAVE_CONFIG_H |
42 | #ifdef HAVE_CONFIG_H |
Line 41... | Line 43... | ||
41 | #include "config.h" |
43 | #include "config.h" |
- | 44 | #endif |
|
- | 45 | ||
42 | #endif |
46 | #include "compiler.h" |
43 | 47 | ||
44 | #include |
48 | |
- | 49 | #include |
|
Line 45... | Line 50... | ||
45 | #include |
50 | #include |
46 | #include |
51 | #include |
Line -... | Line 52... | ||
- | 52 | #include |
|
- | 53 | ||
- | 54 | #include "intel_driver.h" |
|
- | 55 | #include "pciaccess.h" |
|
47 | #include |
56 | |
- | 57 | #include |
|
Line 48... | Line 58... | ||
48 | 58 | #include |
|
- | 59 | ||
- | 60 | #ifdef HAVE_DRI2_H |
|
- | 61 | #include |
|
- | 62 | #endif |
|
- | 63 | ||
- | 64 | #if HAVE_UDEV |
|
- | 65 | #include |
|
- | 66 | #endif |
|
49 | #include "intel_driver.h" |
67 | |
- | 68 | #if 0 |
|
- | 69 | #include |
|
- | 70 | ||
- | 71 | #include |
|
- | 72 | #if XF86_CRTC_VERSION >= 5 |
|
- | 73 | #define HAS_PIXMAP_SHARING 1 |
|
- | 74 | #endif |
|
- | 75 | ||
Line 50... | Line 76... | ||
50 | #include "pciaccess.h" |
76 | #include |
- | 77 | #include |
|
- | 78 | #include |
|
- | 79 | #include |
|
- | 80 | #include |
|
- | 81 | #include |
|
- | 82 | ||
Line -... | Line 83... | ||
- | 83 | #include |
|
- | 84 | ||
- | 85 | #include |
|
- | 86 | ||
- | 87 | #include "../compat-api.h" |
|
- | 88 | ||
- | 89 | #endif |
|
- | 90 | ||
- | 91 | #include |
|
- | 92 | ||
- | 93 | #define ErrorF printf |
|
- | 94 | ||
- | 95 | #if HAS_DEBUG_FULL |
|
- | 96 | #define DBG(x) ErrorF x |
|
- | 97 | #else |
|
- | 98 | #define DBG(x) |
|
- | 99 | #endif |
|
- | 100 | ||
- | 101 | #define DEBUG_NO_BLT 0 |
|
- | 102 | ||
- | 103 | #define DEBUG_FLUSH_BATCH 0 |
|
- | 104 | ||
- | 105 | #define TEST_ALL 0 |
|
- | 106 | #define TEST_ACCEL (TEST_ALL || 0) |
|
- | 107 | #define TEST_BATCH (TEST_ALL || 0) |
|
Line 51... | Line 108... | ||
51 | 108 | #define TEST_BLT (TEST_ALL || 0) |
|
Line 52... | Line 109... | ||
52 | #include "compiler.h" |
109 | #define TEST_COMPOSITE (TEST_ALL || 0) |
Line 92... | Line 149... | ||
92 | PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10), |
149 | PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10), |
93 | PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10), |
150 | PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10), |
94 | PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10), |
151 | PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10), |
95 | PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10), |
152 | PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10), |
Line -... | Line 153... | ||
- | 153 | ||
- | 154 | /* sRGB formats */ |
|
- | 155 | PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8), |
|
- | 156 | ||
- | 157 | /* 24bpp formats */ |
|
- | 158 | PIXMAN_r8g8b8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8), |
|
- | 159 | PIXMAN_b8g8r8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8), |
|
- | 160 | ||
- | 161 | /* 16bpp formats */ |
|
- | 162 | PIXMAN_r5g6b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5), |
|
- | 163 | PIXMAN_b5g6r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5), |
|
- | 164 | ||
- | 165 | PIXMAN_a1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5), |
|
- | 166 | PIXMAN_x1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5), |
|
- | 167 | PIXMAN_a1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5), |
|
- | 168 | PIXMAN_x1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5), |
|
- | 169 | PIXMAN_a4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4), |
|
- | 170 | PIXMAN_x4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4), |
|
- | 171 | PIXMAN_a4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4), |
|
- | 172 | PIXMAN_x4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4), |
|
- | 173 | ||
96 | 174 | /* 8bpp formats */ |
|
- | 175 | PIXMAN_a8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0), |
|
- | 176 | PIXMAN_r3g3b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2), |
|
- | 177 | PIXMAN_b2g3r3 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2), |
|
- | 178 | PIXMAN_a2r2g2b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2), |
|
- | 179 | PIXMAN_a2b2g2r2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2), |
|
- | 180 | ||
- | 181 | PIXMAN_c8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), |
|
- | 182 | PIXMAN_g8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), |
|
- | 183 | ||
- | 184 | PIXMAN_x4a4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0), |
|
- | 185 | ||
- | 186 | PIXMAN_x4c4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), |
|
- | 187 | PIXMAN_x4g4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), |
|
- | 188 | ||
- | 189 | /* 4bpp formats */ |
|
- | 190 | PIXMAN_a4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0), |
|
- | 191 | PIXMAN_r1g2b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1), |
|
- | 192 | PIXMAN_b1g2r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1), |
|
- | 193 | PIXMAN_a1r1g1b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1), |
|
- | 194 | PIXMAN_a1b1g1r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1), |
|
- | 195 | ||
- | 196 | PIXMAN_c4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0), |
|
- | 197 | PIXMAN_g4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0), |
|
- | 198 | ||
- | 199 | /* 1bpp formats */ |
|
- | 200 | PIXMAN_a1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0), |
|
- | 201 | ||
- | 202 | PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0), |
|
- | 203 | ||
- | 204 | /* YUV formats */ |
|
- | 205 | PIXMAN_yuy2 = PIXMAN_FORMAT(16,PIXMAN_TYPE_YUY2,0,0,0,0), |
|
Line 97... | Line 206... | ||
97 | PIXMAN_a8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0) |
206 | PIXMAN_yv12 = PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0) |
Line 98... | Line 207... | ||
98 | 207 | ||
Line -... | Line 208... | ||
- | 208 | } pixman_format_code_t; |
|
- | 209 | ||
- | 210 | typedef enum _PictFormatShort { |
|
- | 211 | ||
- | 212 | PICT_a2r10g10b10 = PIXMAN_a2r10g10b10, |
|
99 | } pixman_format_code_t; |
213 | PICT_x2r10g10b10 = PIXMAN_x2r10g10b10, |
100 | 214 | PICT_a2b10g10r10 = PIXMAN_a2b10g10r10, |
|
101 | typedef enum _PictFormatShort { |
215 | PICT_x2b10g10r10 = PIXMAN_x2b10g10r10, |
102 | 216 | ||
103 | PICT_a8r8g8b8 = PIXMAN_a8r8g8b8, |
217 | PICT_a8r8g8b8 = PIXMAN_a8r8g8b8, |
104 | PICT_x8r8g8b8 = PIXMAN_x8r8g8b8, |
218 | PICT_x8r8g8b8 = PIXMAN_x8r8g8b8, |
Line -... | Line 219... | ||
- | 219 | PICT_a8b8g8r8 = PIXMAN_a8b8g8r8, |
|
- | 220 | PICT_x8b8g8r8 = PIXMAN_x8b8g8r8, |
|
- | 221 | PICT_b8g8r8a8 = PIXMAN_b8g8r8a8, |
|
- | 222 | PICT_b8g8r8x8 = PIXMAN_b8g8r8x8, |
|
- | 223 | ||
- | 224 | /* 24bpp formats */ |
|
- | 225 | PICT_r8g8b8 = PIXMAN_r8g8b8, |
|
- | 226 | PICT_b8g8r8 = PIXMAN_b8g8r8, |
|
- | 227 | ||
- | 228 | /* 16bpp formats */ |
|
- | 229 | PICT_r5g6b5 = PIXMAN_r5g6b5, |
|
- | 230 | PICT_b5g6r5 = PIXMAN_b5g6r5, |
|
- | 231 | ||
- | 232 | PICT_a1r5g5b5 = PIXMAN_a1r5g5b5, |
|
- | 233 | PICT_x1r5g5b5 = PIXMAN_x1r5g5b5, |
|
- | 234 | PICT_a1b5g5r5 = PIXMAN_a1b5g5r5, |
|
- | 235 | PICT_x1b5g5r5 = PIXMAN_x1b5g5r5, |
|
105 | PICT_a8b8g8r8 = PIXMAN_a8b8g8r8, |
236 | PICT_a4r4g4b4 = PIXMAN_a4r4g4b4, |
106 | PICT_x8b8g8r8 = PIXMAN_x8b8g8r8, |
237 | PICT_x4r4g4b4 = PIXMAN_x4r4g4b4, |
- | 238 | PICT_a4b4g4r4 = PIXMAN_a4b4g4r4, |
|
- | 239 | PICT_x4b4g4r4 = PIXMAN_x4b4g4r4, |
|
- | 240 | ||
- | 241 | /* 8bpp formats */ |
|
- | 242 | PICT_a8 = PIXMAN_a8, |
|
- | 243 | PICT_r3g3b2 = PIXMAN_r3g3b2, |
|
- | 244 | PICT_b2g3r3 = PIXMAN_b2g3r3, |
|
- | 245 | PICT_a2r2g2b2 = PIXMAN_a2r2g2b2, |
|
- | 246 | PICT_a2b2g2r2 = PIXMAN_a2b2g2r2, |
|
- | 247 | ||
- | 248 | PICT_c8 = PIXMAN_c8, |
|
- | 249 | PICT_g8 = PIXMAN_g8, |
|
Line 107... | Line 250... | ||
107 | PICT_b8g8r8a8 = PIXMAN_b8g8r8a8, |
250 | |
- | 251 | PICT_x4a4 = PIXMAN_x4a4, |
|
- | 252 | ||
- | 253 | PICT_x4c4 = PIXMAN_x4c4, |
|
- | 254 | PICT_x4g4 = PIXMAN_x4g4, |
|
- | 255 | ||
- | 256 | /* 4bpp formats */ |
|
- | 257 | PICT_a4 = PIXMAN_a4, |
|
- | 258 | PICT_r1g2b1 = PIXMAN_r1g2b1, |
|
- | 259 | PICT_b1g2r1 = PIXMAN_b1g2r1, |
|
- | 260 | PICT_a1r1g1b1 = PIXMAN_a1r1g1b1, |
|
- | 261 | PICT_a1b1g1r1 = PIXMAN_a1b1g1r1, |
|
- | 262 | ||
- | 263 | PICT_c4 = PIXMAN_c4, |
|
108 | PICT_b8g8r8x8 = PIXMAN_b8g8r8x8, |
264 | PICT_g4 = PIXMAN_g4, |
Line 109... | Line 265... | ||
109 | 265 | ||
110 | /* 8bpp formats */ |
266 | /* 1bpp formats */ |
Line 264... | Line 420... | ||
264 | #define PictOpAdd 12 |
420 | #define PictOpAdd 12 |
265 | #define PictOpSaturate 13 |
421 | #define PictOpSaturate 13 |
266 | #define PictOpMaximum 13 |
422 | #define PictOpMaximum 13 |
Line -... | Line 423... | ||
- | 423 | ||
- | 424 | ||
- | 425 | #define SNA_CURSOR_X 64 |
|
- | 426 | #define SNA_CURSOR_Y SNA_CURSOR_X |
|
- | 427 | ||
- | 428 | struct sna_client { |
|
- | 429 | int is_compositor; /* only 4 bits used */ |
|
- | 430 | }; |
|
- | 431 | ||
- | 432 | ||
Line 267... | Line 433... | ||
267 | 433 | //#define assert(x) |
|
- | 434 | ||
- | 435 | ||
- | 436 | struct sna { |
|
- | 437 | struct kgem kgem; |
|
268 | 438 | ||
269 | 439 | unsigned scrn; |
|
270 | struct sna { |
440 | |
271 | unsigned flags; |
441 | unsigned flags; |
272 | #define SNA_NO_WAIT 0x1 |
442 | #define SNA_NO_WAIT 0x1 |
273 | #define SNA_NO_FLIP 0x2 |
443 | #define SNA_NO_FLIP 0x2 |
- | 444 | #define SNA_TRIPLE_BUFFER 0x4 |
|
- | 445 | #define SNA_TEAR_FREE 0x10 |
|
- | 446 | #define SNA_FORCE_SHADOW 0x20 |
|
- | 447 | #define SNA_FLUSH_GTT 0x40 |
|
- | 448 | #define SNA_IS_HOSTED 0x80 |
|
- | 449 | #define SNA_PERFORMANCE 0x100 |
|
- | 450 | #define SNA_POWERSAVE 0x200 |
|
- | 451 | #define SNA_REPROBE 0x80000000 |
|
- | 452 | ||
- | 453 | unsigned cpu_features; |
|
- | 454 | #define MMX 0x1 |
|
- | 455 | #define SSE 0x2 |
|
- | 456 | #define SSE2 0x4 |
|
- | 457 | #define SSE3 0x8 |
|
- | 458 | #define SSSE3 0x10 |
|
- | 459 | #define SSE4_1 0x20 |
|
Line 274... | Line 460... | ||
274 | #define SNA_TRIPLE_BUFFER 0x4 |
460 | #define SSE4_2 0x40 |
275 | #define SNA_TEAR_FREE 0x10 |
461 | #define AVX 0x80 |
Line 276... | Line -... | ||
276 | #define SNA_FORCE_SHADOW 0x20 |
- | |
Line 277... | Line -... | ||
277 | - | ||
278 | struct list flush_pixmaps; |
- | |
279 | struct list active_pixmaps; |
- | |
280 | - | ||
Line 281... | Line 462... | ||
281 | 462 | #define AVX2 0x100 |
|
282 | - | ||
283 | // int vblank_interval; |
463 | |
284 | 464 | struct list flush_pixmaps; |
|
285 | // struct list deferred_free; |
465 | struct list active_pixmaps; |
Line 286... | Line 466... | ||
286 | // struct list dirty_pixmaps; |
466 | |
Line 301... | Line 481... | ||
301 | uint32_t fill_bo; |
481 | uint32_t fill_bo; |
302 | uint32_t fill_pixel; |
482 | uint32_t fill_pixel; |
303 | uint32_t fill_alu; |
483 | uint32_t fill_alu; |
304 | } blt_state; |
484 | } blt_state; |
305 | union { |
485 | union { |
306 | // struct gen2_render_state gen2; |
- | |
307 | struct gen3_render_state gen3; |
486 | struct gen3_render_state gen3; |
308 | struct gen4_render_state gen4; |
487 | struct gen4_render_state gen4; |
309 | struct gen5_render_state gen5; |
488 | struct gen5_render_state gen5; |
310 | struct gen6_render_state gen6; |
489 | struct gen6_render_state gen6; |
311 | struct gen7_render_state gen7; |
490 | struct gen7_render_state gen7; |
Line 316... | Line 495... | ||
316 | // OptionInfoPtr Options; |
495 | // OptionInfoPtr Options; |
Line 317... | Line 496... | ||
317 | 496 | ||
318 | /* Driver phase/state information */ |
497 | /* Driver phase/state information */ |
Line 319... | Line -... | ||
319 | // Bool suspended; |
- | |
320 | 498 | // Bool suspended; |
|
Line 321... | Line 499... | ||
321 | struct kgem kgem; |
499 | |
322 | struct sna_render render; |
500 | struct sna_render render; |
323 | 501 | ||
324 | #if DEBUG_MEMORY |
502 | #if DEBUG_MEMORY |
325 | struct { |
503 | struct { |
326 | int shadow_pixels_allocs; |
504 | int pixmap_allocs; |
327 | int cpu_bo_allocs; |
505 | int cpu_bo_allocs; |
328 | size_t shadow_pixels_bytes; |
506 | size_t shadow_pixels_bytes; |
Line 350... | Line 528... | ||
350 | #endif |
528 | #endif |
Line 351... | Line 529... | ||
351 | 529 | ||
352 | #ifndef MAX |
530 | #ifndef MAX |
353 | #define MAX(a,b) ((a) >= (b) ? (a) : (b)) |
531 | #define MAX(a,b) ((a) >= (b) ? (a) : (b)) |
- | 532 | #endif |
|
- | 533 | static inline bool |
|
- | 534 | _sna_transform_point(const PictTransform *transform, |
|
- | 535 | int64_t x, int64_t y, int64_t result[3]) |
|
- | 536 | { |
|
- | 537 | int j; |
|
- | 538 | ||
- | 539 | for (j = 0; j < 3; j++) |
|
- | 540 | result[j] = (transform->matrix[j][0] * x + |
|
- | 541 | transform->matrix[j][1] * y + |
|
- | 542 | transform->matrix[j][2]); |
|
- | 543 | ||
- | 544 | return result[2] != 0; |
|
- | 545 | } |
|
- | 546 | ||
- | 547 | static inline void |
|
- | 548 | _sna_get_transformed_coordinates(int x, int y, |
|
- | 549 | const PictTransform *transform, |
|
- | 550 | float *x_out, float *y_out) |
|
- | 551 | { |
|
- | 552 | ||
- | 553 | int64_t result[3]; |
|
- | 554 | ||
- | 555 | _sna_transform_point(transform, x, y, result); |
|
- | 556 | *x_out = result[0] / (double)result[2]; |
|
- | 557 | *y_out = result[1] / (double)result[2]; |
|
- | 558 | } |
|
- | 559 | ||
- | 560 | static inline void |
|
- | 561 | _sna_get_transformed_scaled(int x, int y, |
|
- | 562 | const PictTransform *transform, const float *sf, |
|
- | 563 | float *x_out, float *y_out) |
|
- | 564 | { |
|
- | 565 | *x_out = sf[0] * (transform->matrix[0][0] * x + |
|
- | 566 | transform->matrix[0][1] * y + |
|
- | 567 | transform->matrix[0][2]); |
|
- | 568 | ||
- | 569 | *y_out = sf[1] * (transform->matrix[1][0] * x + |
|
- | 570 | transform->matrix[1][1] * y + |
|
- | 571 | transform->matrix[1][2]); |
|
- | 572 | } |
|
- | 573 | ||
- | 574 | void |
|
- | 575 | sna_get_transformed_coordinates(int x, int y, |
|
- | 576 | const PictTransform *transform, |
|
- | 577 | float *x_out, float *y_out); |
|
- | 578 | ||
- | 579 | void |
|
- | 580 | sna_get_transformed_coordinates_3d(int x, int y, |
|
- | 581 | const PictTransform *transform, |
|
- | 582 | float *x_out, float *y_out, float *z_out); |
|
- | 583 | ||
- | 584 | bool sna_transform_is_affine(const PictTransform *t); |
|
- | 585 | bool sna_transform_is_integer_translation(const PictTransform *t, |
|
- | 586 | int16_t *tx, int16_t *ty); |
|
- | 587 | bool sna_transform_is_translation(const PictTransform *t, |
|
- | 588 | pixman_fixed_t *tx, pixman_fixed_t *ty); |
|
- | 589 | static inline bool |
|
- | 590 | sna_affine_transform_is_rotation(const PictTransform *t) |
|
- | 591 | { |
|
- | 592 | assert(sna_transform_is_affine(t)); |
|
- | 593 | return t->matrix[0][1] | t->matrix[1][0]; |
|
- | 594 | } |
|
- | 595 | ||
- | 596 | static inline bool |
|
- | 597 | sna_transform_equal(const PictTransform *a, const PictTransform *b) |
|
- | 598 | { |
|
- | 599 | if (a == b) |
|
- | 600 | return true; |
|
- | 601 | ||
- | 602 | if (a == NULL || b == NULL) |
|
- | 603 | return false; |
|
- | 604 | ||
- | 605 | return memcmp(a, b, sizeof(*a)) == 0; |
|
354 | #endif |
606 | } |