1#ifndef SNA_RENDER_H 2#define SNA_RENDER_H 3 4#include "compiler.h" 5 6#include <picturestr.h> 7 8#include <stdbool.h> 9#include <stdint.h> 10#include <pthread.h> 11#include "atomic.h" 12 13#define GRADIENT_CACHE_SIZE 16 14 15#define GXinvalid 0xff 16 17struct sna; 18struct sna_glyph; 19struct sna_video; 20struct sna_video_frame; 21struct brw_compile; 22 23struct sna_composite_rectangles { 24 struct sna_coordinate { 25 int16_t x, y; 26 } src, mask, dst; 27 int16_t width, height; 28}; 29 30struct sna_composite_op { 31 fastcall void (*blt)(struct sna *sna, const struct sna_composite_op *op, 32 const struct sna_composite_rectangles *r); 33 fastcall void (*box)(struct sna *sna, 34 const struct sna_composite_op *op, 35 const BoxRec *box); 36 void (*boxes)(struct sna *sna, const struct sna_composite_op *op, 37 const BoxRec *box, int nbox); 38 void (*thread_boxes)(struct sna *sna, const struct sna_composite_op *op, 39 const BoxRec *box, int nbox); 40 void (*done)(struct sna *sna, const struct sna_composite_op *op); 41 42 struct sna_damage **damage; 43 44 uint32_t op; 45 46 struct { 47 PixmapPtr pixmap; /* XXX */ 48 CARD32 format; 49 struct kgem_bo *bo; 50 int16_t x, y; 51 uint16_t width, height; 52 } dst; 53 54 struct sna_composite_channel { 55 struct kgem_bo *bo; 56 PictTransform *transform; 57 uint16_t width; 58 uint16_t height; 59 uint32_t pict_format; 60 uint32_t card_format; 61 uint32_t filter; 62 uint32_t repeat; 63 uint32_t is_affine : 1; 64 uint32_t is_solid : 1; 65 uint32_t is_linear : 1; 66 uint32_t is_opaque : 1; 67 uint32_t alpha_fixup : 1; 68 uint32_t rb_reversed : 1; 69 int16_t offset[2]; 70 float scale[2]; 71 72 pixman_transform_t embedded_transform; 73 74 union { 75 struct { 76 float dx, dy, offset; 77 } linear; 78 struct { 79 uint32_t pixel; 80 } gen2; 81 struct gen3_shader_channel { 82 int type; 83 uint32_t mode; 84 uint32_t constants; 85 } gen3; 86 } u; 87 } src, mask; 88 uint32_t is_affine : 1; 89 uint32_t has_component_alpha : 1; 90 uint32_t need_magic_ca_pass : 1; 91 uint32_t rb_reversed : 1; 92 93 int16_t floats_per_vertex; 94 int16_t floats_per_rect; 95 fastcall void (*prim_emit)(struct sna *sna, 96 const struct sna_composite_op *op, 97 const struct sna_composite_rectangles *r); 98 fastcall void (*emit_boxes)(const struct sna_composite_op *op, 99 const BoxRec *box, int nbox, 100 float *v); 101 102 struct sna_composite_redirect { 103 struct kgem_bo *real_bo; 104 struct sna_damage **real_damage, *damage; 105 BoxRec box; 106 } redirect; 107 108 union { 109 struct sna_blt_state { 110 PixmapPtr src_pixmap; 111 int16_t sx, sy; 112 113 uint32_t inplace :1; 114 uint32_t overwrites:1; 115 uint32_t bpp : 6; 116 uint32_t alu : 4; 117 118 uint32_t cmd; 119 uint32_t br13; 120 uint32_t pitch[2]; 121 uint32_t pixel; 122 struct kgem_bo *bo[2]; 123 } blt; 124 125 struct { 126 float constants[8]; 127 uint32_t num_constants; 128 } gen3; 129 130 struct { 131 int wm_kernel; 132 int ve_id; 133 } gen4; 134 135 struct { 136 int16_t wm_kernel; 137 int16_t ve_id; 138 } gen5; 139 140 struct { 141 uint32_t flags; 142 } gen6; 143 144 struct { 145 uint32_t flags; 146 } gen7; 147 148 struct { 149 uint32_t flags; 150 } gen8; 151 152 struct { 153 uint32_t flags; 154 uint8_t wm_kernel; 155 } gen9; 156 } u; 157 158 void *priv; 159}; 160 161struct sna_opacity_box { 162 BoxRec box; 163 float alpha; 164} tightly_packed; 165 166struct sna_composite_spans_op { 167 struct sna_composite_op base; 168 169 fastcall void (*box)(struct sna *sna, 170 const struct sna_composite_spans_op *op, 171 const BoxRec *box, 172 float opacity); 173 void (*boxes)(struct sna *sna, 174 const struct sna_composite_spans_op *op, 175 const BoxRec *box, int nbox, 176 float opacity); 177 178 fastcall void (*thread_boxes)(struct sna *sna, 179 const struct sna_composite_spans_op *op, 180 const struct sna_opacity_box *box, 181 int nbox); 182 183 fastcall void (*done)(struct sna *sna, 184 const struct sna_composite_spans_op *op); 185 186 fastcall void (*prim_emit)(struct sna *sna, 187 const struct sna_composite_spans_op *op, 188 const BoxRec *box, 189 float opacity); 190 fastcall void (*emit_boxes)(const struct sna_composite_spans_op *op, 191 const struct sna_opacity_box *box, int nbox, 192 float *v); 193}; 194 195struct sna_fill_op { 196 struct sna_composite_op base; 197 198 void (*blt)(struct sna *sna, const struct sna_fill_op *op, 199 int16_t x, int16_t y, int16_t w, int16_t h); 200 fastcall void (*box)(struct sna *sna, 201 const struct sna_fill_op *op, 202 const BoxRec *box); 203 fastcall void (*boxes)(struct sna *sna, 204 const struct sna_fill_op *op, 205 const BoxRec *box, 206 int count); 207 fastcall void (*points)(struct sna *sna, 208 const struct sna_fill_op *op, 209 int16_t dx, int16_t dy, 210 const DDXPointRec *points, 211 int count); 212 void (*done)(struct sna *sna, const struct sna_fill_op *op); 213}; 214 215struct sna_copy_op { 216 struct sna_composite_op base; 217 218 void (*blt)(struct sna *sna, const struct sna_copy_op *op, 219 int16_t sx, int16_t sy, 220 int16_t w, int16_t h, 221 int16_t dx, int16_t dy); 222 void (*done)(struct sna *sna, const struct sna_copy_op *op); 223}; 224 225struct sna_render { 226 pthread_mutex_t lock; 227 pthread_cond_t wait; 228 int active; 229 230 int max_3d_size; 231 int max_3d_pitch; 232 233 unsigned prefer_gpu; 234#define PREFER_GPU_BLT 0x1 235#define PREFER_GPU_RENDER 0x2 236#define PREFER_GPU_SPANS 0x4 237 238 bool (*composite)(struct sna *sna, uint8_t op, 239 PicturePtr dst, PicturePtr src, PicturePtr mask, 240 int16_t src_x, int16_t src_y, 241 int16_t msk_x, int16_t msk_y, 242 int16_t dst_x, int16_t dst_y, 243 int16_t w, int16_t h, 244 unsigned flags, 245 struct sna_composite_op *tmp); 246#define COMPOSITE_PARTIAL 0x1 247#define COMPOSITE_UPLOAD 0x40000000 248#define COMPOSITE_FALLBACK 0x80000000 249 250 bool (*check_composite_spans)(struct sna *sna, uint8_t op, 251 PicturePtr dst, PicturePtr src, 252 int16_t w, int16_t h, unsigned flags); 253 bool (*composite_spans)(struct sna *sna, uint8_t op, 254 PicturePtr dst, PicturePtr src, 255 int16_t src_x, int16_t src_y, 256 int16_t dst_x, int16_t dst_y, 257 int16_t w, int16_t h, 258 unsigned flags, 259 struct sna_composite_spans_op *tmp); 260#define COMPOSITE_SPANS_RECTILINEAR 0x1 261#define COMPOSITE_SPANS_INPLACE_HINT 0x2 262 263 bool (*video)(struct sna *sna, 264 struct sna_video *video, 265 struct sna_video_frame *frame, 266 RegionPtr dstRegion, 267 PixmapPtr pixmap); 268 269 bool (*fill_boxes)(struct sna *sna, 270 CARD8 op, 271 PictFormat format, 272 const xRenderColor *color, 273 const DrawableRec *dst, struct kgem_bo *dst_bo, 274 const BoxRec *box, int n); 275 bool (*fill)(struct sna *sna, uint8_t alu, 276 PixmapPtr dst, struct kgem_bo *dst_bo, 277 uint32_t color, unsigned flags, 278 struct sna_fill_op *tmp); 279#define FILL_BOXES 0x1 280#define FILL_POINTS 0x2 281#define FILL_SPANS 0x4 282 bool (*fill_one)(struct sna *sna, PixmapPtr dst, struct kgem_bo *dst_bo, 283 uint32_t color, 284 int16_t x1, int16_t y1, int16_t x2, int16_t y2, 285 uint8_t alu); 286 bool (*clear)(struct sna *sna, PixmapPtr dst, struct kgem_bo *dst_bo); 287 288 bool (*copy_boxes)(struct sna *sna, uint8_t alu, 289 const DrawableRec *src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy, 290 const DrawableRec *dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy, 291 const BoxRec *box, int n, unsigned flags); 292#define COPY_LAST 0x1 293#define COPY_SYNC 0x2 294#define COPY_NO_OVERLAP 0x4 295#define COPY_SMALL 0x8 296#define COPY_DRI 0x10 297 298 bool (*copy)(struct sna *sna, uint8_t alu, 299 PixmapPtr src, struct kgem_bo *src_bo, 300 PixmapPtr dst, struct kgem_bo *dst_bo, 301 struct sna_copy_op *op); 302 303 void (*flush)(struct sna *sna); 304 void (*reset)(struct sna *sna); 305 void (*fini)(struct sna *sna); 306 307 struct sna_alpha_cache { 308 struct kgem_bo *cache_bo; 309 struct kgem_bo *bo[256+7]; 310 } alpha_cache; 311 312 struct sna_solid_cache { 313 struct kgem_bo *cache_bo; 314 struct kgem_bo *bo[1024]; 315 uint32_t color[1024]; 316 int last; 317 int size; 318 int dirty; 319 } solid_cache; 320 321 struct { 322 struct sna_gradient_cache { 323 struct kgem_bo *bo; 324 int nstops; 325 PictGradientStop *stops; 326 } cache[GRADIENT_CACHE_SIZE]; 327 int size; 328 } gradient_cache; 329 330 struct sna_glyph_cache{ 331 PicturePtr picture; 332 struct sna_glyph **glyphs; 333 uint16_t count; 334 uint16_t evict; 335 } glyph[2]; 336 pixman_image_t *white_image; 337 PicturePtr white_picture; 338 339 uint16_t vb_id; 340 uint16_t vertex_offset; 341 uint16_t vertex_start; 342 uint16_t vertex_index; 343 uint16_t vertex_used; 344 uint16_t vertex_size; 345 uint16_t vertex_reloc[16]; 346 int nvertex_reloc; 347 348 struct kgem_bo *vbo; 349 float *vertices; 350 351 float vertex_data[1024]; 352}; 353 354struct gen2_render_state { 355 uint32_t target; 356 bool need_invariant; 357 uint32_t logic_op_enabled; 358 uint32_t ls1, ls2, vft; 359 uint32_t diffuse; 360 uint32_t specular; 361}; 362 363struct gen3_render_state { 364 uint32_t current_dst; 365 bool need_invariant; 366 uint32_t tex_count; 367 uint32_t last_drawrect_limit; 368 uint32_t last_target; 369 uint32_t last_blend; 370 uint32_t last_constants; 371 uint32_t last_sampler; 372 uint32_t last_shader; 373 uint32_t last_diffuse; 374 uint32_t last_specular; 375 376 uint16_t last_vertex_offset; 377 uint16_t floats_per_vertex; 378 uint16_t last_floats_per_vertex; 379 380 uint32_t tex_map[4]; 381 uint32_t tex_handle[2]; 382 uint32_t tex_delta[2]; 383}; 384 385struct gen4_render_state { 386 struct kgem_bo *general_bo; 387 388 uint32_t vs; 389 uint32_t sf; 390 uint32_t wm; 391 uint32_t cc; 392 393 int ve_id; 394 uint32_t drawrect_offset; 395 uint32_t drawrect_limit; 396 uint32_t last_pipelined_pointers; 397 uint16_t last_primitive; 398 int16_t floats_per_vertex; 399 uint16_t surface_table; 400 401 bool needs_invariant; 402 bool needs_urb; 403}; 404 405struct gen5_render_state { 406 struct kgem_bo *general_bo; 407 408 uint32_t vs; 409 uint32_t sf[2]; 410 uint32_t wm; 411 uint32_t cc; 412 413 int ve_id; 414 uint32_t drawrect_offset; 415 uint32_t drawrect_limit; 416 uint32_t last_pipelined_pointers; 417 uint16_t last_primitive; 418 int16_t floats_per_vertex; 419 uint16_t surface_table; 420 421 bool needs_invariant; 422}; 423 424enum { 425 GEN6_WM_KERNEL_NOMASK = 0, 426 GEN6_WM_KERNEL_NOMASK_P, 427 428 GEN6_WM_KERNEL_MASK, 429 GEN6_WM_KERNEL_MASK_P, 430 431 GEN6_WM_KERNEL_MASKCA, 432 GEN6_WM_KERNEL_MASKCA_P, 433 434 GEN6_WM_KERNEL_MASKSA, 435 GEN6_WM_KERNEL_MASKSA_P, 436 437 GEN6_WM_KERNEL_OPACITY, 438 GEN6_WM_KERNEL_OPACITY_P, 439 440 GEN6_WM_KERNEL_VIDEO_PLANAR_BT601, 441 GEN6_WM_KERNEL_VIDEO_NV12_BT601, 442 GEN6_WM_KERNEL_VIDEO_PACKED_BT601, 443 444 GEN6_WM_KERNEL_VIDEO_PLANAR_BT709, 445 GEN6_WM_KERNEL_VIDEO_NV12_BT709, 446 GEN6_WM_KERNEL_VIDEO_PACKED_BT709, 447 448 GEN6_KERNEL_COUNT 449}; 450 451struct gen6_render_state { 452 unsigned gt; 453 const struct gt_info *info; 454 struct kgem_bo *general_bo; 455 456 uint32_t vs_state; 457 uint32_t sf_state; 458 uint32_t sf_mask_state; 459 uint32_t wm_state; 460 uint32_t wm_kernel[GEN6_KERNEL_COUNT][3]; 461 462 uint32_t cc_blend; 463 464 uint32_t drawrect_offset; 465 uint32_t drawrect_limit; 466 uint32_t blend; 467 uint32_t samplers; 468 uint32_t kernel; 469 470 uint16_t num_sf_outputs; 471 uint16_t ve_id; 472 uint16_t last_primitive; 473 int16_t floats_per_vertex; 474 uint16_t surface_table; 475 476 bool needs_invariant; 477 bool first_state_packet; 478}; 479 480enum { 481 GEN7_WM_KERNEL_NOMASK = 0, 482 GEN7_WM_KERNEL_NOMASK_P, 483 484 GEN7_WM_KERNEL_MASK, 485 GEN7_WM_KERNEL_MASK_P, 486 487 GEN7_WM_KERNEL_MASKCA, 488 GEN7_WM_KERNEL_MASKCA_P, 489 490 GEN7_WM_KERNEL_MASKSA, 491 GEN7_WM_KERNEL_MASKSA_P, 492 493 GEN7_WM_KERNEL_OPACITY, 494 GEN7_WM_KERNEL_OPACITY_P, 495 496 GEN7_WM_KERNEL_VIDEO_PLANAR_BT601, 497 GEN7_WM_KERNEL_VIDEO_NV12_BT601, 498 GEN7_WM_KERNEL_VIDEO_PACKED_BT601, 499 500 GEN7_WM_KERNEL_VIDEO_PLANAR_BT709, 501 GEN7_WM_KERNEL_VIDEO_NV12_BT709, 502 GEN7_WM_KERNEL_VIDEO_PACKED_BT709, 503 504 GEN7_WM_KERNEL_VIDEO_RGB, 505 GEN7_WM_KERNEL_COUNT 506}; 507 508struct gen7_render_state { 509 unsigned gt; 510 const struct gt_info *info; 511 struct kgem_bo *general_bo; 512 513 uint32_t vs_state; 514 uint32_t sf_state; 515 uint32_t sf_mask_state; 516 uint32_t wm_state; 517 uint32_t wm_kernel[GEN7_WM_KERNEL_COUNT][3]; 518 519 uint32_t cc_blend; 520 521 uint32_t drawrect_offset; 522 uint32_t drawrect_limit; 523 uint32_t blend; 524 uint32_t samplers; 525 uint32_t kernel; 526 527 uint16_t num_sf_outputs; 528 uint16_t ve_id; 529 uint16_t last_primitive; 530 int16_t floats_per_vertex; 531 uint16_t surface_table; 532 uint16_t pipe_controls_since_stall; 533 534 bool needs_invariant; 535 bool emit_flush; 536}; 537 538 539enum { 540 GEN8_WM_KERNEL_NOMASK = 0, 541 GEN8_WM_KERNEL_NOMASK_P, 542 543 GEN8_WM_KERNEL_MASK, 544 GEN8_WM_KERNEL_MASK_P, 545 546 GEN8_WM_KERNEL_MASKCA, 547 GEN8_WM_KERNEL_MASKCA_P, 548 549 GEN8_WM_KERNEL_MASKSA, 550 GEN8_WM_KERNEL_MASKSA_P, 551 552 GEN8_WM_KERNEL_OPACITY, 553 GEN8_WM_KERNEL_OPACITY_P, 554 555 GEN8_WM_KERNEL_VIDEO_PLANAR_BT601, 556 GEN8_WM_KERNEL_VIDEO_NV12_BT601, 557 GEN8_WM_KERNEL_VIDEO_PACKED_BT601, 558 559 GEN8_WM_KERNEL_VIDEO_PLANAR_BT709, 560 GEN8_WM_KERNEL_VIDEO_NV12_BT709, 561 GEN8_WM_KERNEL_VIDEO_PACKED_BT709, 562 563 GEN8_WM_KERNEL_VIDEO_RGB, 564 GEN8_WM_KERNEL_COUNT 565}; 566 567struct gen8_render_state { 568 unsigned gt; 569 const struct gt_info *info; 570 struct kgem_bo *general_bo; 571 572 uint32_t vs_state; 573 uint32_t sf_state; 574 uint32_t sf_mask_state; 575 uint32_t wm_state; 576 uint32_t wm_kernel[GEN8_WM_KERNEL_COUNT][3]; 577 578 uint32_t cc_blend; 579 580 uint32_t drawrect_offset; 581 uint32_t drawrect_limit; 582 uint32_t blend; 583 uint32_t samplers; 584 uint32_t kernel; 585 586 uint16_t num_sf_outputs; 587 uint16_t ve_id; 588 uint16_t last_primitive; 589 int16_t floats_per_vertex; 590 uint16_t surface_table; 591 592 bool needs_invariant; 593 bool emit_flush; 594}; 595 596enum { 597 GEN9_WM_KERNEL_NOMASK = 0, 598 GEN9_WM_KERNEL_NOMASK_P, 599 600 GEN9_WM_KERNEL_MASK, 601 GEN9_WM_KERNEL_MASK_P, 602 603 GEN9_WM_KERNEL_MASKCA, 604 GEN9_WM_KERNEL_MASKCA_P, 605 606 GEN9_WM_KERNEL_MASKSA, 607 GEN9_WM_KERNEL_MASKSA_P, 608 609 GEN9_WM_KERNEL_OPACITY, 610 GEN9_WM_KERNEL_OPACITY_P, 611 612 GEN9_WM_KERNEL_VIDEO_PLANAR_BT601, 613 GEN9_WM_KERNEL_VIDEO_NV12_BT601, 614 GEN9_WM_KERNEL_VIDEO_PACKED_BT601, 615 616 GEN9_WM_KERNEL_VIDEO_PLANAR_BT709, 617 GEN9_WM_KERNEL_VIDEO_NV12_BT709, 618 GEN9_WM_KERNEL_VIDEO_PACKED_BT709, 619 620 GEN9_WM_KERNEL_VIDEO_AYUV_BT601, 621 GEN9_WM_KERNEL_VIDEO_AYUV_BT709, 622 623 GEN9_WM_KERNEL_VIDEO_RGB, 624 GEN9_WM_KERNEL_COUNT 625}; 626 627struct gen9_render_state { 628 unsigned gt; 629 const struct gt_info *info; 630 struct kgem_bo *general_bo; 631 632 uint32_t vs_state; 633 uint32_t sf_state; 634 uint32_t sf_mask_state; 635 uint32_t wm_state; 636 uint32_t wm_kernel[GEN9_WM_KERNEL_COUNT][3]; 637 638 uint32_t cc_blend; 639 640 uint32_t drawrect_offset; 641 uint32_t drawrect_limit; 642 uint32_t blend; 643 uint32_t samplers; 644 uint32_t kernel; 645 646 uint16_t num_sf_outputs; 647 uint16_t ve_id; 648 uint16_t last_primitive; 649 int16_t floats_per_vertex; 650 uint16_t surface_table; 651 652 bool needs_invariant; 653 bool emit_flush; 654 bool ve_dirty; 655}; 656 657struct sna_static_stream { 658 uint32_t size, used; 659 uint8_t *data; 660}; 661 662int sna_static_stream_init(struct sna_static_stream *stream); 663uint32_t sna_static_stream_add(struct sna_static_stream *stream, 664 const void *data, uint32_t len, uint32_t align); 665void *sna_static_stream_map(struct sna_static_stream *stream, 666 uint32_t len, uint32_t align); 667uint32_t sna_static_stream_offsetof(struct sna_static_stream *stream, 668 void *ptr); 669unsigned sna_static_stream_compile_sf(struct sna *sna, 670 struct sna_static_stream *stream, 671 bool (*compile)(struct brw_compile *)); 672 673unsigned sna_static_stream_compile_wm(struct sna *sna, 674 struct sna_static_stream *stream, 675 bool (*compile)(struct brw_compile *, int), 676 int width); 677struct kgem_bo *sna_static_stream_fini(struct sna *sna, 678 struct sna_static_stream *stream); 679 680struct kgem_bo * 681sna_render_get_solid(struct sna *sna, 682 uint32_t color); 683 684void 685sna_render_flush_solid(struct sna *sna); 686 687struct kgem_bo * 688sna_render_get_gradient(struct sna *sna, 689 PictGradient *pattern); 690 691bool 692sna_gradient_is_opaque(const PictGradient *gradient); 693 694uint32_t sna_rgba_for_color(uint32_t color, int depth); 695uint32_t sna_rgba_to_color(uint32_t rgba, uint32_t format); 696bool sna_get_rgba_from_pixel(uint32_t pixel, 697 uint16_t *red, 698 uint16_t *green, 699 uint16_t *blue, 700 uint16_t *alpha, 701 uint32_t format); 702bool sna_picture_is_solid(PicturePtr picture, uint32_t *color); 703 704const char *no_render_init(struct sna *sna); 705const char *gen2_render_init(struct sna *sna, const char *backend); 706const char *gen3_render_init(struct sna *sna, const char *backend); 707const char *gen4_render_init(struct sna *sna, const char *backend); 708const char *gen5_render_init(struct sna *sna, const char *backend); 709const char *gen6_render_init(struct sna *sna, const char *backend); 710const char *gen7_render_init(struct sna *sna, const char *backend); 711const char *gen8_render_init(struct sna *sna, const char *backend); 712const char *gen9_render_init(struct sna *sna, const char *backend); 713 714void sna_render_mark_wedged(struct sna *sna); 715 716bool sna_tiling_composite(uint32_t op, 717 PicturePtr src, 718 PicturePtr mask, 719 PicturePtr dst, 720 int16_t src_x, int16_t src_y, 721 int16_t mask_x, int16_t mask_y, 722 int16_t dst_x, int16_t dst_y, 723 int16_t width, int16_t height, 724 struct sna_composite_op *tmp); 725bool sna_tiling_composite_spans(uint32_t op, 726 PicturePtr src, 727 PicturePtr dst, 728 int16_t src_x, int16_t src_y, 729 int16_t dst_x, int16_t dst_y, 730 int16_t width, int16_t height, 731 unsigned flags, 732 struct sna_composite_spans_op *tmp); 733bool sna_tiling_fill_boxes(struct sna *sna, 734 CARD8 op, 735 PictFormat format, 736 const xRenderColor *color, 737 const DrawableRec *dst, struct kgem_bo *dst_bo, 738 const BoxRec *box, int n); 739 740bool sna_tiling_copy_boxes(struct sna *sna, uint8_t alu, 741 const DrawableRec *src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy, 742 const DrawableRec *dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy, 743 const BoxRec *box, int n); 744 745bool sna_tiling_blt_copy_boxes(struct sna *sna, uint8_t alu, 746 struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy, 747 struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy, 748 int bpp, const BoxRec *box, int nbox); 749 750bool sna_tiling_blt_composite(struct sna *sna, 751 struct sna_composite_op *op, 752 struct kgem_bo *bo, 753 int bpp, 754 uint32_t alpha_fixup); 755 756bool sna_blt_composite(struct sna *sna, 757 uint32_t op, 758 PicturePtr src, 759 PicturePtr dst, 760 int16_t src_x, int16_t src_y, 761 int16_t dst_x, int16_t dst_y, 762 int16_t width, int16_t height, 763 unsigned flags, 764 struct sna_composite_op *tmp); 765bool sna_blt_composite__convert(struct sna *sna, 766 int x, int y, 767 int width, int height, 768 struct sna_composite_op *tmp); 769 770bool sna_blt_fill(struct sna *sna, uint8_t alu, 771 struct kgem_bo *bo, 772 int bpp, 773 uint32_t pixel, 774 struct sna_fill_op *fill); 775 776bool sna_blt_copy(struct sna *sna, uint8_t alu, 777 struct kgem_bo *src, 778 struct kgem_bo *dst, 779 int bpp, 780 struct sna_copy_op *copy); 781 782bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, 783 struct kgem_bo *bo, 784 int bpp, 785 uint32_t pixel, 786 const BoxRec *box, int n); 787 788bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu, 789 struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy, 790 struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy, 791 int bpp, 792 const BoxRec *box, int n); 793bool sna_blt_copy_boxes__with_alpha(struct sna *sna, uint8_t alu, 794 struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy, 795 struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy, 796 int bpp, int alpha_fixup, 797 const BoxRec *box, int nbox); 798bool sna_blt_copy_boxes_fallback(struct sna *sna, uint8_t alu, 799 const DrawableRec *src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy, 800 const DrawableRec *dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy, 801 const BoxRec *box, int nbox); 802 803bool memcpy_copy_boxes(struct sna *sna, uint8_t op, 804 const DrawableRec *src_draw, struct kgem_bo *src_bo, int16_t sx, int16_t sy, 805 const DrawableRec *dst_draw, struct kgem_bo *dst_bo, int16_t dx, int16_t dy, 806 const BoxRec *box, int n, unsigned flags); 807 808bool _sna_get_pixel_from_rgba(uint32_t *pixel, 809 uint16_t red, 810 uint16_t green, 811 uint16_t blue, 812 uint16_t alpha, 813 uint32_t format); 814 815static inline bool 816sna_get_pixel_from_rgba(uint32_t * pixel, 817 uint16_t red, 818 uint16_t green, 819 uint16_t blue, 820 uint16_t alpha, 821 uint32_t format) 822{ 823 switch (format) { 824 case PICT_x8r8g8b8: 825 alpha = 0xffff; 826 /* fall through to re-use a8r8g8b8 expansion */ 827 case PICT_a8r8g8b8: 828 *pixel = ((alpha >> 8 << 24) | 829 (red >> 8 << 16) | 830 (green & 0xff00) | 831 (blue >> 8)); 832 return TRUE; 833 case PICT_a8: 834 *pixel = alpha >> 8; 835 return TRUE; 836 } 837 838 return _sna_get_pixel_from_rgba(pixel, red, green, blue, alpha, format); 839} 840 841struct kgem_bo * 842__sna_render_pixmap_bo(struct sna *sna, 843 PixmapPtr pixmap, 844 const BoxRec *box, 845 bool blt); 846 847int 848sna_render_pixmap_bo(struct sna *sna, 849 struct sna_composite_channel *channel, 850 PixmapPtr pixmap, 851 int16_t x, int16_t y, 852 int16_t w, int16_t h, 853 int16_t dst_x, int16_t dst_y); 854 855bool 856sna_render_pixmap_partial(struct sna *sna, 857 const DrawableRec *draw, 858 struct kgem_bo *bo, 859 struct sna_composite_channel *channel, 860 int16_t x, int16_t y, 861 int16_t w, int16_t h); 862 863int 864sna_render_picture_extract(struct sna *sna, 865 PicturePtr picture, 866 struct sna_composite_channel *channel, 867 int16_t x, int16_t y, 868 int16_t w, int16_t h, 869 int16_t dst_x, int16_t dst_y); 870 871int 872sna_render_picture_approximate_gradient(struct sna *sna, 873 PicturePtr picture, 874 struct sna_composite_channel *channel, 875 int16_t x, int16_t y, 876 int16_t w, int16_t h, 877 int16_t dst_x, int16_t dst_y); 878 879int 880sna_render_picture_fixup(struct sna *sna, 881 PicturePtr picture, 882 struct sna_composite_channel *channel, 883 int16_t x, int16_t y, 884 int16_t w, int16_t h, 885 int16_t dst_x, int16_t dst_y); 886 887int 888sna_render_picture_convert(struct sna *sna, 889 PicturePtr picture, 890 struct sna_composite_channel *channel, 891 PixmapPtr pixmap, 892 int16_t x, int16_t y, 893 int16_t w, int16_t h, 894 int16_t dst_x, int16_t dst_y, 895 bool fixup_alpha); 896 897inline static void sna_render_composite_redirect_init(struct sna_composite_op *op) 898{ 899 struct sna_composite_redirect *t = &op->redirect; 900 t->real_bo = NULL; 901 t->damage = NULL; 902} 903 904bool 905sna_render_composite_redirect(struct sna *sna, 906 struct sna_composite_op *op, 907 int x, int y, int width, int height, 908 bool partial); 909 910void 911sna_render_composite_redirect_done(struct sna *sna, 912 const struct sna_composite_op *op); 913 914bool 915sna_render_copy_boxes__overlap(struct sna *sna, uint8_t alu, 916 const DrawableRec *draw, struct kgem_bo *bo, 917 int16_t src_dx, int16_t src_dy, 918 int16_t dst_dx, int16_t dst_dy, 919 const BoxRec *box, int n, const BoxRec *extents); 920 921bool 922sna_composite_mask_is_opaque(PicturePtr mask); 923 924void sna_vertex_init(struct sna *sna); 925 926static inline void sna_vertex_lock(struct sna_render *r) 927{ 928 pthread_mutex_lock(&r->lock); 929} 930 931static inline void sna_vertex_acquire__locked(struct sna_render *r) 932{ 933 r->active++; 934} 935 936static inline void sna_vertex_unlock(struct sna_render *r) 937{ 938 pthread_mutex_unlock(&r->lock); 939} 940 941static inline void sna_vertex_release__locked(struct sna_render *r) 942{ 943 assert(r->active > 0); 944 if (--r->active == 0) 945 pthread_cond_signal(&r->wait); 946} 947 948static inline bool sna_vertex_wait__locked(struct sna_render *r) 949{ 950 bool was_active = r->active; 951 while (r->active) 952 pthread_cond_wait(&r->wait, &r->lock); 953 return was_active; 954} 955 956#define alphaless(format) PICT_FORMAT(PICT_FORMAT_BPP(format), \ 957 PICT_FORMAT_TYPE(format), \ 958 0, \ 959 PICT_FORMAT_R(format), \ 960 PICT_FORMAT_G(format), \ 961 PICT_FORMAT_B(format)) 962 963#endif /* SNA_RENDER_H */ 964