~ubuntu-branches/debian/sid/xserver-xorg-video-intel/sid

« back to all changes in this revision

Viewing changes to src/sna/sna_render.h

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2011-08-27 18:55:26 UTC
  • mfrom: (12.1.15 upstream) (0.1.21 experimental)
  • Revision ID: james.westby@ubuntu.com-20110827185526-rl9lvyqwv217gwwx
Tags: 2:2.16.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SNA_RENDER_H
 
2
#define SNA_RENDER_H
 
3
 
 
4
#define GRADIENT_CACHE_SIZE 16
 
5
 
 
6
#define fastcall __attribute__((regparm(3)))
 
7
 
 
8
struct sna;
 
9
struct sna_glyph;
 
10
struct sna_video;
 
11
struct sna_video_frame;
 
12
 
 
13
struct sna_composite_rectangles {
 
14
        struct sna_coordinate {
 
15
                int16_t x, y;
 
16
        } src, mask, dst;
 
17
        int16_t width, height;
 
18
};
 
19
 
 
20
struct sna_composite_op {
 
21
        fastcall void (*blt)(struct sna *sna, const struct sna_composite_op *op,
 
22
                             const struct sna_composite_rectangles *r);
 
23
        void (*boxes)(struct sna *sna, const struct sna_composite_op *op,
 
24
                      const BoxRec *box, int nbox);
 
25
        void (*done)(struct sna *sna, const struct sna_composite_op *op);
 
26
 
 
27
        struct sna_damage **damage;
 
28
 
 
29
        uint32_t op;
 
30
 
 
31
        struct {
 
32
                PixmapPtr pixmap;
 
33
                CARD32 format;
 
34
                struct kgem_bo *bo;
 
35
                int16_t x, y;
 
36
                uint16_t width, height;
 
37
        } dst;
 
38
 
 
39
        struct sna_composite_channel {
 
40
                struct kgem_bo *bo;
 
41
                PictTransform *transform;
 
42
                uint16_t width;
 
43
                uint16_t height;
 
44
                uint32_t pict_format;
 
45
                uint32_t card_format;
 
46
                uint32_t filter;
 
47
                uint32_t repeat;
 
48
                uint32_t is_affine : 1;
 
49
                uint32_t is_solid : 1;
 
50
                uint32_t is_opaque : 1;
 
51
                uint32_t alpha_fixup : 1;
 
52
                uint32_t rb_reversed : 1;
 
53
                int16_t offset[2];
 
54
                float scale[2];
 
55
 
 
56
                union {
 
57
                        struct {
 
58
                                uint32_t pixel;
 
59
                        } gen2;
 
60
                        struct gen3_shader_channel {
 
61
                                int type;
 
62
                                uint32_t mode;
 
63
                                uint32_t constants;
 
64
                        } gen3;
 
65
                } u;
 
66
        } src, mask;
 
67
        uint32_t is_affine : 1;
 
68
        uint32_t has_component_alpha : 1;
 
69
        uint32_t need_magic_ca_pass : 1;
 
70
        uint32_t rb_reversed : 1;
 
71
 
 
72
        int floats_per_vertex;
 
73
        fastcall void (*prim_emit)(struct sna *sna,
 
74
                                   const struct sna_composite_op *op,
 
75
                                   const struct sna_composite_rectangles *r);
 
76
 
 
77
        struct sna_composite_redirect {
 
78
                struct kgem_bo *real_bo;
 
79
                BoxRec box;
 
80
        } redirect;
 
81
 
 
82
        union {
 
83
                struct sna_blt_state {
 
84
                        PixmapPtr src_pixmap;
 
85
                        int16_t sx, sy;
 
86
 
 
87
                        uint32_t inplace :1;
 
88
                        uint32_t overwrites:1;
 
89
 
 
90
                        uint32_t cmd;
 
91
                        uint32_t br13;
 
92
                        uint32_t pitch[2];
 
93
                        uint32_t pixel;
 
94
                        struct kgem_bo *bo[2];
 
95
                } blt;
 
96
 
 
97
                struct {
 
98
                        uint32_t pixel;
 
99
                } gen2;
 
100
 
 
101
                struct {
 
102
                        float constants[8];
 
103
                        uint32_t num_constants;
 
104
                } gen3;
 
105
 
 
106
                struct {
 
107
                        int wm_kernel;
 
108
                        int ve_id;
 
109
                } gen4;
 
110
 
 
111
                struct {
 
112
                        int wm_kernel;
 
113
                        int ve_id;
 
114
                } gen5;
 
115
 
 
116
                struct {
 
117
                        int wm_kernel;
 
118
                        int nr_surfaces;
 
119
                        int nr_inputs;
 
120
                        int ve_id;
 
121
                } gen6;
 
122
 
 
123
                struct {
 
124
                        int wm_kernel;
 
125
                        int nr_surfaces;
 
126
                        int nr_inputs;
 
127
                        int ve_id;
 
128
                } gen7;
 
129
 
 
130
                void *priv;
 
131
        } u;
 
132
};
 
133
 
 
134
struct sna_composite_spans_op {
 
135
        struct sna_composite_op base;
 
136
 
 
137
        void (*box)(struct sna *sna, const struct sna_composite_spans_op *op,
 
138
                    const BoxRec *box, float opacity);
 
139
        void (*boxes)(struct sna *sna, const struct sna_composite_spans_op *op,
 
140
                      const BoxRec *box, int nbox,
 
141
                      float opacity);
 
142
        void (*done)(struct sna *sna, const struct sna_composite_spans_op *op);
 
143
 
 
144
        void (*prim_emit)(struct sna *sna,
 
145
                          const struct sna_composite_spans_op *op,
 
146
                          const BoxRec *box,
 
147
                          float opacity);
 
148
};
 
149
 
 
150
struct sna_fill_op {
 
151
        struct sna_composite_op base;
 
152
 
 
153
        void (*blt)(struct sna *sna, const struct sna_fill_op *op,
 
154
                    int16_t x, int16_t y, int16_t w, int16_t h);
 
155
        void (*done)(struct sna *sna, const struct sna_fill_op *op);
 
156
};
 
157
 
 
158
struct sna_copy_op {
 
159
        struct sna_composite_op base;
 
160
 
 
161
        void (*blt)(struct sna *sna, const struct sna_copy_op *op,
 
162
                    int16_t sx, int16_t sy,
 
163
                    int16_t w, int16_t h,
 
164
                    int16_t dx, int16_t dy);
 
165
        void (*done)(struct sna *sna, const struct sna_copy_op *op);
 
166
};
 
167
 
 
168
struct sna_render {
 
169
        int max_3d_size;
 
170
 
 
171
        Bool (*composite)(struct sna *sna, uint8_t op,
 
172
                          PicturePtr dst, PicturePtr src, PicturePtr mask,
 
173
                          int16_t src_x, int16_t src_y,
 
174
                          int16_t msk_x, int16_t msk_y,
 
175
                          int16_t dst_x, int16_t dst_y,
 
176
                          int16_t w, int16_t h,
 
177
                          struct sna_composite_op *tmp);
 
178
 
 
179
        Bool (*composite_spans)(struct sna *sna, uint8_t op,
 
180
                                PicturePtr dst, PicturePtr src,
 
181
                                int16_t src_x, int16_t src_y,
 
182
                                int16_t dst_x, int16_t dst_y,
 
183
                                int16_t w, int16_t h,
 
184
                                struct sna_composite_spans_op *tmp);
 
185
 
 
186
        Bool (*video)(struct sna *sna,
 
187
                      struct sna_video *video,
 
188
                      struct sna_video_frame *frame,
 
189
                      RegionPtr dstRegion,
 
190
                      short src_w, short src_h,
 
191
                      short drw_w, short drw_h,
 
192
                      PixmapPtr pixmap);
 
193
 
 
194
        Bool (*fill_boxes)(struct sna *sna,
 
195
                           CARD8 op,
 
196
                           PictFormat format,
 
197
                           const xRenderColor *color,
 
198
                           PixmapPtr dst, struct kgem_bo *dst_bo,
 
199
                           const BoxRec *box, int n);
 
200
        Bool (*fill)(struct sna *sna, uint8_t alu,
 
201
                     PixmapPtr dst, struct kgem_bo *dst_bo,
 
202
                     uint32_t color,
 
203
                     struct sna_fill_op *tmp);
 
204
 
 
205
        Bool (*copy_boxes)(struct sna *sna, uint8_t alu,
 
206
                           PixmapPtr src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
 
207
                           PixmapPtr dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
 
208
                           const BoxRec *box, int n);
 
209
        Bool (*copy)(struct sna *sna, uint8_t alu,
 
210
                     PixmapPtr src, struct kgem_bo *src_bo,
 
211
                     PixmapPtr dst, struct kgem_bo *dst_bo,
 
212
                     struct sna_copy_op *op);
 
213
 
 
214
        void (*flush)(struct sna *sna);
 
215
        void (*reset)(struct sna *sna);
 
216
        void (*fini)(struct sna *sna);
 
217
 
 
218
        struct sna_solid_cache {
 
219
                struct kgem_bo *cache_bo;
 
220
                uint32_t color[1024];
 
221
                struct kgem_bo *bo[1024];
 
222
                int last;
 
223
                int size;
 
224
                int dirty;
 
225
        } solid_cache;
 
226
 
 
227
        struct {
 
228
                struct sna_gradient_cache {
 
229
                        struct kgem_bo *bo;
 
230
                        int nstops;
 
231
                        PictGradientStop *stops;
 
232
                } cache[GRADIENT_CACHE_SIZE];
 
233
                int size;
 
234
        } gradient_cache;
 
235
 
 
236
        struct sna_glyph_cache{
 
237
                PicturePtr picture;
 
238
                struct sna_glyph **glyphs;
 
239
                uint16_t count;
 
240
                uint16_t evict;
 
241
        } glyph[2];
 
242
 
 
243
        uint16_t vertex_start;
 
244
        uint16_t vertex_index;
 
245
        uint16_t vertex_used;
 
246
        uint16_t vertex_reloc[8];
 
247
 
 
248
        float vertex_data[16*1024];
 
249
        const struct sna_composite_op *op;
 
250
};
 
251
 
 
252
struct gen2_render_state {
 
253
        uint32_t target;
 
254
        Bool need_invariant;
 
255
        Bool logic_op_enabled;
 
256
        uint16_t vertex_offset;
 
257
};
 
258
 
 
259
struct gen3_render_state {
 
260
        uint32_t current_dst;
 
261
        Bool need_invariant;
 
262
        uint32_t tex_count;
 
263
        uint32_t last_drawrect_limit;
 
264
        uint32_t last_target;
 
265
        uint32_t last_blend;
 
266
        uint32_t last_constants;
 
267
        uint32_t last_sampler;
 
268
        uint32_t last_shader;
 
269
        uint32_t last_diffuse;
 
270
        uint32_t last_specular;
 
271
 
 
272
        uint16_t vertex_offset;
 
273
        uint16_t last_vertex_offset;
 
274
        uint16_t floats_per_vertex;
 
275
        uint16_t last_floats_per_vertex;
 
276
 
 
277
        uint32_t tex_map[4];
 
278
        uint32_t tex_handle[2];
 
279
        uint32_t tex_delta[2];
 
280
};
 
281
 
 
282
struct gen4_render_state {
 
283
        struct kgem_bo *general_bo;
 
284
 
 
285
        uint32_t vs;
 
286
        uint32_t sf[2];
 
287
        uint32_t wm;
 
288
        uint32_t cc;
 
289
 
 
290
        int ve_id;
 
291
        uint32_t drawrect_offset;
 
292
        uint32_t drawrect_limit;
 
293
        uint32_t vb_id;
 
294
        uint16_t vertex_offset;
 
295
        uint16_t last_primitive;
 
296
        int16_t floats_per_vertex;
 
297
        uint16_t surface_table;
 
298
        uint16_t last_pipelined_pointers;
 
299
 
 
300
        Bool needs_invariant;
 
301
        Bool needs_urb;
 
302
};
 
303
 
 
304
struct gen5_render_state {
 
305
        struct kgem_bo *general_bo;
 
306
 
 
307
        uint32_t vs;
 
308
        uint32_t sf[2];
 
309
        uint32_t wm;
 
310
        uint32_t cc;
 
311
 
 
312
        int ve_id;
 
313
        uint32_t drawrect_offset;
 
314
        uint32_t drawrect_limit;
 
315
        uint32_t vb_id;
 
316
        uint16_t vertex_offset;
 
317
        uint16_t last_primitive;
 
318
        int16_t floats_per_vertex;
 
319
        uint16_t surface_table;
 
320
        uint16_t last_pipelined_pointers;
 
321
 
 
322
        Bool needs_invariant;
 
323
};
 
324
 
 
325
enum {
 
326
        GEN6_WM_KERNEL_NOMASK = 0,
 
327
        GEN6_WM_KERNEL_NOMASK_PROJECTIVE,
 
328
 
 
329
        GEN6_WM_KERNEL_MASK,
 
330
        GEN6_WM_KERNEL_MASK_PROJECTIVE,
 
331
 
 
332
        GEN6_WM_KERNEL_MASKCA,
 
333
        GEN6_WM_KERNEL_MASKCA_PROJECTIVE,
 
334
 
 
335
        GEN6_WM_KERNEL_MASKCA_SRCALPHA,
 
336
        GEN6_WM_KERNEL_MASKCA_SRCALPHA_PROJECTIVE,
 
337
 
 
338
        GEN6_WM_KERNEL_VIDEO_PLANAR,
 
339
        GEN6_WM_KERNEL_VIDEO_PACKED,
 
340
        GEN6_KERNEL_COUNT
 
341
};
 
342
 
 
343
struct gen6_render_state {
 
344
        struct kgem_bo *general_bo;
 
345
 
 
346
        uint32_t vs_state;
 
347
        uint32_t sf_state;
 
348
        uint32_t sf_mask_state;
 
349
        uint32_t wm_state;
 
350
        uint32_t wm_kernel[GEN6_KERNEL_COUNT];
 
351
 
 
352
        uint32_t cc_vp;
 
353
        uint32_t cc_blend;
 
354
 
 
355
        uint32_t drawrect_offset;
 
356
        uint32_t drawrect_limit;
 
357
        uint32_t blend;
 
358
        uint32_t samplers;
 
359
        uint32_t kernel;
 
360
 
 
361
        uint16_t num_sf_outputs;
 
362
        uint16_t vb_id;
 
363
        uint16_t ve_id;
 
364
        uint16_t vertex_offset;
 
365
        uint16_t last_primitive;
 
366
        int16_t floats_per_vertex;
 
367
        uint16_t surface_table;
 
368
 
 
369
        Bool needs_invariant;
 
370
};
 
371
 
 
372
enum {
 
373
        GEN7_WM_KERNEL_NOMASK = 0,
 
374
        GEN7_WM_KERNEL_NOMASK_PROJECTIVE,
 
375
 
 
376
        GEN7_WM_KERNEL_MASK,
 
377
        GEN7_WM_KERNEL_MASK_PROJECTIVE,
 
378
 
 
379
        GEN7_WM_KERNEL_MASKCA,
 
380
        GEN7_WM_KERNEL_MASKCA_PROJECTIVE,
 
381
 
 
382
        GEN7_WM_KERNEL_MASKCA_SRCALPHA,
 
383
        GEN7_WM_KERNEL_MASKCA_SRCALPHA_PROJECTIVE,
 
384
 
 
385
        GEN7_WM_KERNEL_VIDEO_PLANAR,
 
386
        GEN7_WM_KERNEL_VIDEO_PACKED,
 
387
        GEN7_KERNEL_COUNT
 
388
};
 
389
 
 
390
struct gen7_render_state {
 
391
        struct kgem_bo *general_bo;
 
392
 
 
393
        uint32_t vs_state;
 
394
        uint32_t sf_state;
 
395
        uint32_t sf_mask_state;
 
396
        uint32_t wm_state;
 
397
        uint32_t wm_kernel[GEN6_KERNEL_COUNT];
 
398
 
 
399
        uint32_t cc_vp;
 
400
        uint32_t cc_blend;
 
401
 
 
402
        uint32_t drawrect_offset;
 
403
        uint32_t drawrect_limit;
 
404
        uint32_t blend;
 
405
        uint32_t samplers;
 
406
        uint32_t kernel;
 
407
 
 
408
        uint16_t num_sf_outputs;
 
409
        uint16_t vb_id;
 
410
        uint16_t ve_id;
 
411
        uint16_t vertex_offset;
 
412
        uint16_t last_primitive;
 
413
        int16_t floats_per_vertex;
 
414
        uint16_t surface_table;
 
415
 
 
416
        Bool needs_invariant;
 
417
};
 
418
 
 
419
struct sna_static_stream {
 
420
        uint32_t size, used;
 
421
        uint8_t *data;
 
422
};
 
423
 
 
424
int sna_static_stream_init(struct sna_static_stream *stream);
 
425
uint32_t sna_static_stream_add(struct sna_static_stream *stream,
 
426
                               const void *data, uint32_t len, uint32_t align);
 
427
void *sna_static_stream_map(struct sna_static_stream *stream,
 
428
                            uint32_t len, uint32_t align);
 
429
uint32_t sna_static_stream_offsetof(struct sna_static_stream *stream,
 
430
                                    void *ptr);
 
431
struct kgem_bo *sna_static_stream_fini(struct sna *sna,
 
432
                                       struct sna_static_stream *stream);
 
433
 
 
434
struct kgem_bo *
 
435
sna_render_get_solid(struct sna *sna,
 
436
                     uint32_t color);
 
437
 
 
438
void
 
439
sna_render_flush_solid(struct sna *sna);
 
440
 
 
441
struct kgem_bo *
 
442
sna_render_get_gradient(struct sna *sna,
 
443
                        PictGradient *pattern);
 
444
 
 
445
uint32_t sna_rgba_for_color(uint32_t color, int depth);
 
446
Bool sna_picture_is_solid(PicturePtr picture, uint32_t *color);
 
447
 
 
448
void no_render_init(struct sna *sna);
 
449
 
 
450
Bool gen2_render_init(struct sna *sna);
 
451
Bool gen3_render_init(struct sna *sna);
 
452
Bool gen4_render_init(struct sna *sna);
 
453
Bool gen5_render_init(struct sna *sna);
 
454
Bool gen6_render_init(struct sna *sna);
 
455
Bool gen7_render_init(struct sna *sna);
 
456
 
 
457
Bool sna_tiling_composite(struct sna *sna,
 
458
                          uint32_t op,
 
459
                          PicturePtr src,
 
460
                          PicturePtr mask,
 
461
                          PicturePtr dst,
 
462
                          int16_t src_x, int16_t src_y,
 
463
                          int16_t mask_x, int16_t mask_y,
 
464
                          int16_t dst_x, int16_t dst_y,
 
465
                          int16_t width, int16_t height,
 
466
                          struct sna_composite_op *tmp);
 
467
 
 
468
Bool sna_blt_composite(struct sna *sna,
 
469
                       uint32_t op,
 
470
                       PicturePtr src,
 
471
                       PicturePtr dst,
 
472
                       int16_t src_x, int16_t src_y,
 
473
                       int16_t dst_x, int16_t dst_y,
 
474
                       int16_t width, int16_t height,
 
475
                       struct sna_composite_op *tmp);
 
476
 
 
477
bool sna_blt_fill(struct sna *sna, uint8_t alu,
 
478
                  struct kgem_bo *bo,
 
479
                  int bpp,
 
480
                  uint32_t pixel,
 
481
                  struct sna_fill_op *fill);
 
482
 
 
483
bool sna_blt_copy(struct sna *sna, uint8_t alu,
 
484
                  struct kgem_bo *src,
 
485
                  struct kgem_bo *dst,
 
486
                  int bpp,
 
487
                  struct sna_copy_op *copy);
 
488
 
 
489
Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu,
 
490
                        struct kgem_bo *bo,
 
491
                        int bpp,
 
492
                        uint32_t pixel,
 
493
                        const BoxRec *box, int n);
 
494
 
 
495
Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu,
 
496
                        struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
 
497
                        struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
 
498
                        int bpp,
 
499
                        const BoxRec *box, int n);
 
500
 
 
501
Bool sna_get_pixel_from_rgba(uint32_t *pixel,
 
502
                             uint16_t red,
 
503
                             uint16_t green,
 
504
                             uint16_t blue,
 
505
                             uint16_t alpha,
 
506
                             uint32_t format);
 
507
 
 
508
int
 
509
sna_render_pixmap_bo(struct sna *sna,
 
510
                     struct sna_composite_channel *channel,
 
511
                     PixmapPtr pixmap,
 
512
                     int16_t x, int16_t y,
 
513
                     int16_t w, int16_t h,
 
514
                     int16_t dst_x, int16_t dst_y);
 
515
 
 
516
int
 
517
sna_render_picture_extract(struct sna *sna,
 
518
                           PicturePtr picture,
 
519
                           struct sna_composite_channel *channel,
 
520
                           int16_t x, int16_t y,
 
521
                           int16_t w, int16_t h,
 
522
                           int16_t dst_x, int16_t dst_y);
 
523
 
 
524
int
 
525
sna_render_picture_fixup(struct sna *sna,
 
526
                         PicturePtr picture,
 
527
                         struct sna_composite_channel *channel,
 
528
                         int16_t x, int16_t y,
 
529
                         int16_t w, int16_t h,
 
530
                         int16_t dst_x, int16_t dst_y);
 
531
 
 
532
int
 
533
sna_render_picture_convert(struct sna *sna,
 
534
                           PicturePtr picture,
 
535
                           struct sna_composite_channel *channel,
 
536
                           PixmapPtr pixmap,
 
537
                           int16_t x, int16_t y,
 
538
                           int16_t w, int16_t h,
 
539
                           int16_t dst_x, int16_t dst_y);
 
540
 
 
541
Bool
 
542
sna_render_composite_redirect(struct sna *sna,
 
543
                              struct sna_composite_op *op,
 
544
                              int x, int y, int width, int height);
 
545
 
 
546
void
 
547
sna_render_composite_redirect_done(struct sna *sna,
 
548
                                   const struct sna_composite_op *op);
 
549
 
 
550
#endif /* SNA_RENDER_H */