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 43... | Line 43... | ||
43 | #include "brw/brw.h" |
43 | #include "brw/brw.h" |
44 | #include "gen7_render.h" |
44 | #include "gen7_render.h" |
45 | #include "gen4_source.h" |
45 | #include "gen4_source.h" |
46 | #include "gen4_vertex.h" |
46 | #include "gen4_vertex.h" |
Line -... | Line 47... | ||
- | 47 | ||
- | 48 | #define ALWAYS_FLUSH 0 |
|
47 | 49 | ||
48 | #define NO_COMPOSITE 0 |
50 | #define NO_COMPOSITE 0 |
49 | #define NO_COMPOSITE_SPANS 0 |
51 | #define NO_COMPOSITE_SPANS 0 |
50 | #define NO_COPY 0 |
52 | #define NO_COPY 0 |
51 | #define NO_COPY_BOXES 0 |
53 | #define NO_COPY_BOXES 0 |
Line 73... | Line 75... | ||
73 | */ |
75 | */ |
Line 74... | Line 76... | ||
74 | 76 | ||
Line 75... | Line 77... | ||
75 | #define is_aligned(x, y) (((x) & ((y) - 1)) == 0) |
77 | #define is_aligned(x, y) (((x) & ((y) - 1)) == 0) |
- | 78 | ||
76 | 79 | struct gt_info { |
|
77 | struct gt_info { |
80 | const char *name; |
78 | uint32_t max_vs_threads; |
81 | uint32_t max_vs_threads; |
79 | uint32_t max_gs_threads; |
82 | uint32_t max_gs_threads; |
80 | uint32_t max_wm_threads; |
83 | uint32_t max_wm_threads; |
81 | struct { |
84 | struct { |
82 | int size; |
85 | int size; |
- | 86 | int max_vs_entries; |
|
83 | int max_vs_entries; |
87 | int max_gs_entries; |
- | 88 | int push_ps_size; /* in 1KBs */ |
|
84 | int max_gs_entries; |
89 | } urb; |
Line 85... | Line 90... | ||
85 | } urb; |
90 | int gt; |
- | 91 | }; |
|
86 | }; |
92 | |
87 | 93 | static const struct gt_info ivb_gt_info = { |
|
88 | static const struct gt_info ivb_gt_info = { |
94 | .name = "Ivybridge (gen7)", |
89 | .max_vs_threads = 16, |
95 | .max_vs_threads = 16, |
- | 96 | .max_gs_threads = 16, |
|
90 | .max_gs_threads = 16, |
97 | .max_wm_threads = (16-1) << IVB_PS_MAX_THREADS_SHIFT, |
Line 91... | Line 98... | ||
91 | .max_wm_threads = (16-1) << IVB_PS_MAX_THREADS_SHIFT, |
98 | .urb = { 128, 64, 64, 8 }, |
- | 99 | .gt = 0, |
|
92 | .urb = { 128, 64, 64 }, |
100 | }; |
93 | }; |
101 | |
94 | 102 | static const struct gt_info ivb_gt1_info = { |
|
95 | static const struct gt_info ivb_gt1_info = { |
103 | .name = "Ivybridge (gen7, gt1)", |
- | 104 | .max_vs_threads = 36, |
|
96 | .max_vs_threads = 36, |
105 | .max_gs_threads = 36, |
Line 97... | Line 106... | ||
97 | .max_gs_threads = 36, |
106 | .max_wm_threads = (48-1) << IVB_PS_MAX_THREADS_SHIFT, |
- | 107 | .urb = { 128, 512, 192, 8 }, |
|
98 | .max_wm_threads = (48-1) << IVB_PS_MAX_THREADS_SHIFT, |
108 | .gt = 1, |
99 | .urb = { 128, 512, 192 }, |
109 | }; |
100 | }; |
110 | |
101 | 111 | static const struct gt_info ivb_gt2_info = { |
|
- | 112 | .name = "Ivybridge (gen7, gt2)", |
|
- | 113 | .max_vs_threads = 128, |
|
- | 114 | .max_gs_threads = 128, |
|
- | 115 | .max_wm_threads = (172-1) << IVB_PS_MAX_THREADS_SHIFT, |
|
- | 116 | .urb = { 256, 704, 320, 8 }, |
|
- | 117 | .gt = 2, |
|
- | 118 | }; |
|
- | 119 | ||
- | 120 | static const struct gt_info byt_gt_info = { |
|
- | 121 | .name = "Baytrail (gen7)", |
|
- | 122 | .urb = { 128, 64, 64 }, |
|
102 | static const struct gt_info ivb_gt2_info = { |
123 | .max_vs_threads = 36, |
Line 103... | Line 124... | ||
103 | .max_vs_threads = 128, |
124 | .max_gs_threads = 36, |
- | 125 | .max_wm_threads = (48-1) << IVB_PS_MAX_THREADS_SHIFT, |
|
104 | .max_gs_threads = 128, |
126 | .urb = { 128, 512, 192, 8 }, |
105 | .max_wm_threads = (172-1) << IVB_PS_MAX_THREADS_SHIFT, |
127 | .gt = 1, |
106 | .urb = { 256, 704, 320 }, |
128 | }; |
107 | }; |
129 | |
108 | 130 | static const struct gt_info hsw_gt_info = { |
|
109 | static const struct gt_info hsw_gt_info = { |
131 | .name = "Haswell (gen7.5)", |
- | 132 | .max_vs_threads = 8, |
|
110 | .max_vs_threads = 8, |
133 | .max_gs_threads = 8, |
Line 111... | Line 134... | ||
111 | .max_gs_threads = 8, |
134 | .max_wm_threads = |
- | 135 | (8 - 1) << HSW_PS_MAX_THREADS_SHIFT | |
|
112 | .max_wm_threads = |
136 | 1 << HSW_PS_SAMPLE_MASK_SHIFT, |
113 | (8 - 1) << HSW_PS_MAX_THREADS_SHIFT | |
137 | .urb = { 128, 64, 64, 8 }, |
114 | 1 << HSW_PS_SAMPLE_MASK_SHIFT, |
138 | .gt = 0, |
115 | .urb = { 128, 64, 64 }, |
139 | }; |
116 | }; |
140 | |
117 | 141 | static const struct gt_info hsw_gt1_info = { |
|
- | 142 | .name = "Haswell (gen7.5, gt1)", |
|
118 | static const struct gt_info hsw_gt1_info = { |
143 | .max_vs_threads = 70, |
Line 119... | Line 144... | ||
119 | .max_vs_threads = 70, |
144 | .max_gs_threads = 70, |
- | 145 | .max_wm_threads = |
|
- | 146 | (102 - 1) << HSW_PS_MAX_THREADS_SHIFT | |
|
- | 147 | 1 << HSW_PS_SAMPLE_MASK_SHIFT, |
|
- | 148 | .urb = { 128, 640, 256, 8 }, |
|
- | 149 | .gt = 1, |
|
- | 150 | }; |
|
- | 151 | ||
- | 152 | static const struct gt_info hsw_gt2_info = { |
|
- | 153 | .name = "Haswell (gen7.5, gt2)", |
|
- | 154 | .max_vs_threads = 140, |
|
- | 155 | .max_gs_threads = 140, |
|
- | 156 | .max_wm_threads = |
|
120 | .max_gs_threads = 70, |
157 | (140 - 1) << HSW_PS_MAX_THREADS_SHIFT | |
121 | .max_wm_threads = |
158 | 1 << HSW_PS_SAMPLE_MASK_SHIFT, |
122 | (102 - 1) << HSW_PS_MAX_THREADS_SHIFT | |
159 | .urb = { 256, 1664, 640, 8 }, |
123 | 1 << HSW_PS_SAMPLE_MASK_SHIFT, |
160 | .gt = 2, |
124 | .urb = { 128, 640, 256 }, |
161 | }; |
125 | }; |
162 | |
- | 163 | static const struct gt_info hsw_gt3_info = { |
|
126 | 164 | .name = "Haswell (gen7.5, gt3)", |
|
Line -... | Line 165... | ||
- | 165 | .max_vs_threads = 280, |
|
- | 166 | .max_gs_threads = 280, |
|
- | 167 | .max_wm_threads = |
|
- | 168 | (280 - 1) << HSW_PS_MAX_THREADS_SHIFT | |
|
- | 169 | 1 << HSW_PS_SAMPLE_MASK_SHIFT, |
|
- | 170 | .urb = { 512, 3328, 1280, 16 }, |
|
- | 171 | .gt = 3, |
|
- | 172 | }; |
|
- | 173 | ||
- | 174 | inline static bool is_ivb(struct sna *sna) |
|
- | 175 | { |
|
- | 176 | return sna->kgem.gen == 070; |
|
- | 177 | } |
|
- | 178 | ||
- | 179 | inline static bool is_byt(struct sna *sna) |
|
127 | static const struct gt_info hsw_gt2_info = { |
180 | { |
128 | .max_vs_threads = 280, |
181 | return sna->kgem.gen == 071; |
129 | .max_gs_threads = 280, |
182 | } |
130 | .max_wm_threads = |
183 | |
131 | (204 - 1) << HSW_PS_MAX_THREADS_SHIFT | |
184 | inline static bool is_hsw(struct sna *sna) |
Line 292... | Line 345... | ||
292 | return -1; |
345 | return -1; |
293 | case PICT_a8r8g8b8: |
346 | case PICT_a8r8g8b8: |
294 | return GEN7_SURFACEFORMAT_B8G8R8A8_UNORM; |
347 | return GEN7_SURFACEFORMAT_B8G8R8A8_UNORM; |
295 | case PICT_x8r8g8b8: |
348 | case PICT_x8r8g8b8: |
296 | return GEN7_SURFACEFORMAT_B8G8R8X8_UNORM; |
349 | return GEN7_SURFACEFORMAT_B8G8R8X8_UNORM; |
- | 350 | case PICT_a8b8g8r8: |
|
- | 351 | return GEN7_SURFACEFORMAT_R8G8B8A8_UNORM; |
|
- | 352 | case PICT_x8b8g8r8: |
|
- | 353 | return GEN7_SURFACEFORMAT_R8G8B8X8_UNORM; |
|
- | 354 | case PICT_a2r10g10b10: |
|
- | 355 | return GEN7_SURFACEFORMAT_B10G10R10A2_UNORM; |
|
- | 356 | case PICT_x2r10g10b10: |
|
- | 357 | return GEN7_SURFACEFORMAT_B10G10R10X2_UNORM; |
|
- | 358 | case PICT_r8g8b8: |
|
- | 359 | return GEN7_SURFACEFORMAT_R8G8B8_UNORM; |
|
- | 360 | case PICT_r5g6b5: |
|
- | 361 | return GEN7_SURFACEFORMAT_B5G6R5_UNORM; |
|
- | 362 | case PICT_a1r5g5b5: |
|
- | 363 | return GEN7_SURFACEFORMAT_B5G5R5A1_UNORM; |
|
297 | case PICT_a8: |
364 | case PICT_a8: |
298 | return GEN7_SURFACEFORMAT_A8_UNORM; |
365 | return GEN7_SURFACEFORMAT_A8_UNORM; |
- | 366 | case PICT_a4r4g4b4: |
|
- | 367 | return GEN7_SURFACEFORMAT_B4G4R4A4_UNORM; |
|
299 | } |
368 | } |
300 | } |
369 | } |
Line 301... | Line 370... | ||
301 | 370 | ||
302 | static uint32_t gen7_get_dest_format(PictFormat format) |
371 | static uint32_t gen7_get_dest_format(PictFormat format) |
Line 305... | Line 374... | ||
305 | default: |
374 | default: |
306 | return -1; |
375 | return -1; |
307 | case PICT_a8r8g8b8: |
376 | case PICT_a8r8g8b8: |
308 | case PICT_x8r8g8b8: |
377 | case PICT_x8r8g8b8: |
309 | return GEN7_SURFACEFORMAT_B8G8R8A8_UNORM; |
378 | return GEN7_SURFACEFORMAT_B8G8R8A8_UNORM; |
- | 379 | case PICT_a8b8g8r8: |
|
- | 380 | case PICT_x8b8g8r8: |
|
- | 381 | return GEN7_SURFACEFORMAT_R8G8B8A8_UNORM; |
|
- | 382 | case PICT_a2r10g10b10: |
|
- | 383 | case PICT_x2r10g10b10: |
|
- | 384 | return GEN7_SURFACEFORMAT_B10G10R10A2_UNORM; |
|
- | 385 | case PICT_r5g6b5: |
|
- | 386 | return GEN7_SURFACEFORMAT_B5G6R5_UNORM; |
|
- | 387 | case PICT_x1r5g5b5: |
|
- | 388 | case PICT_a1r5g5b5: |
|
- | 389 | return GEN7_SURFACEFORMAT_B5G5R5A1_UNORM; |
|
310 | case PICT_a8: |
390 | case PICT_a8: |
311 | return GEN7_SURFACEFORMAT_A8_UNORM; |
391 | return GEN7_SURFACEFORMAT_A8_UNORM; |
- | 392 | case PICT_a4r4g4b4: |
|
- | 393 | case PICT_x4r4g4b4: |
|
- | 394 | return GEN7_SURFACEFORMAT_B4G4R4A4_UNORM; |
|
312 | } |
395 | } |
313 | } |
396 | } |
Line 314... | Line 397... | ||
314 | 397 | ||
315 | static int |
398 | static int |
Line 333... | Line 416... | ||
333 | 416 | ||
334 | static void |
417 | static void |
335 | gen7_emit_urb(struct sna *sna) |
418 | gen7_emit_urb(struct sna *sna) |
336 | { |
419 | { |
337 | OUT_BATCH(GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS | (2 - 2)); |
420 | OUT_BATCH(GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS | (2 - 2)); |
Line 338... | Line 421... | ||
338 | OUT_BATCH(8); /* in 1KBs */ |
421 | OUT_BATCH(sna->render_state.gen7.info->urb.push_ps_size); |
339 | 422 | ||
340 | /* num of VS entries must be divisible by 8 if size < 9 */ |
423 | /* num of VS entries must be divisible by 8 if size < 9 */ |
341 | OUT_BATCH(GEN7_3DSTATE_URB_VS | (2 - 2)); |
424 | OUT_BATCH(GEN7_3DSTATE_URB_VS | (2 - 2)); |
Line 357... | Line 440... | ||
357 | } |
440 | } |
Line 358... | Line 441... | ||
358 | 441 | ||
359 | static void |
442 | static void |
360 | gen7_emit_state_base_address(struct sna *sna) |
443 | gen7_emit_state_base_address(struct sna *sna) |
- | 444 | { |
|
- | 445 | uint32_t mocs; |
|
- | 446 | ||
- | 447 | mocs = is_hsw(sna) ? 5 << 8 : 3 << 8; |
|
361 | { |
448 | |
362 | OUT_BATCH(GEN7_STATE_BASE_ADDRESS | (10 - 2)); |
449 | OUT_BATCH(GEN7_STATE_BASE_ADDRESS | (10 - 2)); |
363 | OUT_BATCH(0); /* general */ |
450 | OUT_BATCH(0); /* general */ |
364 | OUT_BATCH(kgem_add_reloc(&sna->kgem, /* surface */ |
451 | OUT_BATCH(kgem_add_reloc(&sna->kgem, /* surface */ |
365 | sna->kgem.nbatch, |
452 | sna->kgem.nbatch, |
366 | NULL, |
453 | NULL, |
367 | I915_GEM_DOMAIN_INSTRUCTION << 16, |
454 | I915_GEM_DOMAIN_INSTRUCTION << 16, |
368 | BASE_ADDRESS_MODIFY)); |
455 | BASE_ADDRESS_MODIFY)); |
369 | OUT_BATCH(kgem_add_reloc(&sna->kgem, /* instruction */ |
456 | OUT_BATCH(kgem_add_reloc(&sna->kgem, /* dynamic */ |
370 | sna->kgem.nbatch, |
457 | sna->kgem.nbatch, |
371 | sna->render_state.gen7.general_bo, |
458 | sna->render_state.gen7.general_bo, |
372 | I915_GEM_DOMAIN_INSTRUCTION << 16, |
459 | I915_GEM_DOMAIN_INSTRUCTION << 16, |
373 | BASE_ADDRESS_MODIFY)); |
460 | mocs | BASE_ADDRESS_MODIFY)); |
374 | OUT_BATCH(0); /* indirect */ |
461 | OUT_BATCH(0); /* indirect */ |
375 | OUT_BATCH(kgem_add_reloc(&sna->kgem, |
462 | OUT_BATCH(kgem_add_reloc(&sna->kgem, /* instruction */ |
376 | sna->kgem.nbatch, |
463 | sna->kgem.nbatch, |
377 | sna->render_state.gen7.general_bo, |
464 | sna->render_state.gen7.general_bo, |
378 | I915_GEM_DOMAIN_INSTRUCTION << 16, |
465 | I915_GEM_DOMAIN_INSTRUCTION << 16, |
Line 379... | Line 466... | ||
379 | BASE_ADDRESS_MODIFY)); |
466 | mocs | BASE_ADDRESS_MODIFY)); |
380 | 467 | ||
381 | /* upper bounds, disable */ |
468 | /* upper bounds, disable */ |
382 | OUT_BATCH(0); |
469 | OUT_BATCH(0); |
Line 903... | Line 990... | ||
903 | OUT_BATCH(0); |
990 | OUT_BATCH(0); |
904 | OUT_BATCH(0); |
991 | OUT_BATCH(0); |
905 | } |
992 | } |
Line 906... | Line 993... | ||
906 | 993 | ||
907 | inline static void |
994 | inline static void |
908 | gen7_emit_pipe_flush(struct sna *sna) |
995 | gen7_emit_pipe_flush(struct sna *sna, bool need_stall) |
- | 996 | { |
|
- | 997 | unsigned stall; |
|
- | 998 | ||
- | 999 | stall = 0; |
|
- | 1000 | if (need_stall) |
|
- | 1001 | stall = (GEN7_PIPE_CONTROL_CS_STALL | |
|
- | 1002 | GEN7_PIPE_CONTROL_STALL_AT_SCOREBOARD); |
|
909 | { |
1003 | |
910 | OUT_BATCH(GEN7_PIPE_CONTROL | (4 - 2)); |
1004 | OUT_BATCH(GEN7_PIPE_CONTROL | (4 - 2)); |
911 | OUT_BATCH(GEN7_PIPE_CONTROL_WC_FLUSH); |
1005 | OUT_BATCH(GEN7_PIPE_CONTROL_WC_FLUSH | stall); |
912 | OUT_BATCH(0); |
1006 | OUT_BATCH(0); |
913 | OUT_BATCH(0); |
1007 | OUT_BATCH(0); |
Line 914... | Line 1008... | ||
914 | } |
1008 | } |
Line 928... | Line 1022... | ||
928 | const struct sna_composite_op *op, |
1022 | const struct sna_composite_op *op, |
929 | uint16_t wm_binding_table) |
1023 | uint16_t wm_binding_table) |
930 | { |
1024 | { |
931 | bool need_stall; |
1025 | bool need_stall; |
Line 932... | Line -... | ||
932 | - | ||
933 | if (sna->render_state.gen7.emit_flush) |
1026 | |
Line 934... | Line 1027... | ||
934 | gen7_emit_pipe_flush(sna); |
1027 | assert(op->dst.bo->exec); |
935 | 1028 | ||
936 | gen7_emit_cc(sna, GEN7_BLEND(op->u.gen7.flags)); |
1029 | gen7_emit_cc(sna, GEN7_BLEND(op->u.gen7.flags)); |
937 | gen7_emit_sampler(sna, GEN7_SAMPLER(op->u.gen7.flags)); |
1030 | gen7_emit_sampler(sna, GEN7_SAMPLER(op->u.gen7.flags)); |
938 | gen7_emit_sf(sna, GEN7_VERTEX(op->u.gen7.flags) >> 2); |
1031 | gen7_emit_sf(sna, GEN7_VERTEX(op->u.gen7.flags) >> 2); |
Line 939... | Line 1032... | ||
939 | gen7_emit_wm(sna, GEN7_KERNEL(op->u.gen7.flags)); |
1032 | gen7_emit_wm(sna, GEN7_KERNEL(op->u.gen7.flags)); |
940 | gen7_emit_vertex_elements(sna, op); |
1033 | gen7_emit_vertex_elements(sna, op); |
Line 941... | Line 1034... | ||
941 | 1034 | ||
942 | need_stall = gen7_emit_binding_table(sna, wm_binding_table); |
1035 | need_stall = gen7_emit_binding_table(sna, wm_binding_table); |
943 | need_stall &= gen7_emit_drawing_rectangle(sna, op); |
1036 | need_stall &= gen7_emit_drawing_rectangle(sna, op); |
944 | 1037 | ||
945 | if (kgem_bo_is_dirty(op->src.bo) || kgem_bo_is_dirty(op->mask.bo)) { |
1038 | if (ALWAYS_FLUSH || kgem_bo_is_dirty(op->src.bo) || kgem_bo_is_dirty(op->mask.bo)) { |
- | 1039 | gen7_emit_pipe_invalidate(sna); |
|
- | 1040 | kgem_clear_dirty(&sna->kgem); |
|
- | 1041 | assert(op->dst.bo->exec); |
|
- | 1042 | kgem_bo_mark_dirty(op->dst.bo); |
|
- | 1043 | sna->render_state.gen7.emit_flush = false; |
|
946 | gen7_emit_pipe_invalidate(sna); |
1044 | need_stall = false; |
947 | kgem_clear_dirty(&sna->kgem); |
1045 | } |
948 | if (op->dst.bo->exec) |
1046 | if (sna->render_state.gen7.emit_flush) { |
949 | kgem_bo_mark_dirty(op->dst.bo); |
1047 | gen7_emit_pipe_flush(sna, need_stall); |
Line 1089... | Line 1187... | ||
1089 | uint32_t is_scanout = is_dst && bo->scanout; |
1187 | uint32_t is_scanout = is_dst && bo->scanout; |
Line 1090... | Line 1188... | ||
1090 | 1188 | ||
Line 1091... | Line 1189... | ||
1091 | COMPILE_TIME_ASSERT(sizeof(struct gen7_surface_state) == 32); |
1189 | COMPILE_TIME_ASSERT(sizeof(struct gen7_surface_state) == 32); |
1092 | 1190 | ||
1093 | /* After the first bind, we manage the cache domains within the batch */ |
1191 | /* After the first bind, we manage the cache domains within the batch */ |
1094 | offset = kgem_bo_get_binding(bo, format | is_scanout << 31); |
1192 | offset = kgem_bo_get_binding(bo, format | is_dst << 30 | is_scanout << 31); |
1095 | if (offset) { |
1193 | if (offset) { |
1096 | if (is_dst) |
1194 | if (is_dst) |
1097 | kgem_bo_mark_dirty(bo); |
1195 | kgem_bo_mark_dirty(bo); |
Line 1102... | Line 1200... | ||
1102 | sizeof(struct gen7_surface_state) / sizeof(uint32_t); |
1200 | sizeof(struct gen7_surface_state) / sizeof(uint32_t); |
1103 | ss = sna->kgem.batch + offset; |
1201 | ss = sna->kgem.batch + offset; |
1104 | ss[0] = (GEN7_SURFACE_2D << GEN7_SURFACE_TYPE_SHIFT | |
1202 | ss[0] = (GEN7_SURFACE_2D << GEN7_SURFACE_TYPE_SHIFT | |
1105 | gen7_tiling_bits(bo->tiling) | |
1203 | gen7_tiling_bits(bo->tiling) | |
1106 | format << GEN7_SURFACE_FORMAT_SHIFT); |
1204 | format << GEN7_SURFACE_FORMAT_SHIFT); |
- | 1205 | if (bo->tiling == I915_TILING_Y) |
|
- | 1206 | ss[0] |= GEN7_SURFACE_VALIGN_4; |
|
1107 | if (is_dst) |
1207 | if (is_dst) { |
- | 1208 | ss[0] |= GEN7_SURFACE_RC_READ_WRITE; |
|
1108 | domains = I915_GEM_DOMAIN_RENDER << 16 |I915_GEM_DOMAIN_RENDER; |
1209 | domains = I915_GEM_DOMAIN_RENDER << 16 |I915_GEM_DOMAIN_RENDER; |
1109 | else |
1210 | } else |
1110 | domains = I915_GEM_DOMAIN_SAMPLER << 16; |
1211 | domains = I915_GEM_DOMAIN_SAMPLER << 16; |
1111 | ss[1] = kgem_add_reloc(&sna->kgem, offset + 1, bo, domains, 0); |
1212 | ss[1] = kgem_add_reloc(&sna->kgem, offset + 1, bo, domains, 0); |
1112 | ss[2] = ((width - 1) << GEN7_SURFACE_WIDTH_SHIFT | |
1213 | ss[2] = ((width - 1) << GEN7_SURFACE_WIDTH_SHIFT | |
1113 | (height - 1) << GEN7_SURFACE_HEIGHT_SHIFT); |
1214 | (height - 1) << GEN7_SURFACE_HEIGHT_SHIFT); |
1114 | ss[3] = (bo->pitch - 1) << GEN7_SURFACE_PITCH_SHIFT; |
1215 | ss[3] = (bo->pitch - 1) << GEN7_SURFACE_PITCH_SHIFT; |
1115 | ss[4] = 0; |
1216 | ss[4] = 0; |
1116 | ss[5] = is_scanout ? 0 : 3 << 16; |
1217 | ss[5] = (is_scanout || bo->io) ? 0 : is_hsw(sna) ? 5 << 16 : 3 << 16; |
1117 | ss[6] = 0; |
1218 | ss[6] = 0; |
1118 | ss[7] = 0; |
1219 | ss[7] = 0; |
1119 | if (sna->kgem.gen == 075) |
1220 | if (is_hsw(sna)) |
1120 | ss[7] |= HSW_SURFACE_SWIZZLE(RED, GREEN, BLUE, ALPHA); |
1221 | ss[7] |= HSW_SURFACE_SWIZZLE(RED, GREEN, BLUE, ALPHA); |
Line 1121... | Line 1222... | ||
1121 | 1222 | ||
Line 1122... | Line 1223... | ||
1122 | kgem_bo_set_binding(bo, format | is_scanout << 31, offset); |
1223 | kgem_bo_set_binding(bo, format | is_dst << 30 | is_scanout << 31, offset); |
1123 | 1224 | ||
1124 | DBG(("[%x] bind bo(handle=%d, addr=%d), format=%d, width=%d, height=%d, pitch=%d, tiling=%d -> %s\n", |
1225 | DBG(("[%x] bind bo(handle=%d, addr=%d), format=%d, width=%d, height=%d, pitch=%d, tiling=%d -> %s\n", |
1125 | offset, bo->handle, ss[1], |
1226 | offset, bo->handle, ss[1], |
Line 1240... | Line 1341... | ||
1240 | goto flush; |
1341 | goto flush; |
1241 | else |
1342 | else |
1242 | goto start; |
1343 | goto start; |
1243 | } |
1344 | } |
Line 1244... | Line -... | ||
1244 | - | ||
1245 | assert(op->floats_per_rect >= vertex_space(sna)); |
1345 | |
- | 1346 | assert(rem <= vertex_space(sna)); |
|
1246 | assert(rem <= vertex_space(sna)); |
1347 | assert(op->floats_per_rect <= rem); |
1247 | if (want > 1 && want * op->floats_per_rect > rem) |
1348 | if (want > 1 && want * op->floats_per_rect > rem) |
Line 1248... | Line 1349... | ||
1248 | want = rem / op->floats_per_rect; |
1349 | want = rem / op->floats_per_rect; |
1249 | 1350 | ||
Line 1396... | Line 1497... | ||
1396 | } |
1497 | } |
Line 1397... | Line 1498... | ||
1397 | 1498 | ||
1398 | return sna_static_stream_offsetof(stream, base); |
1499 | return sna_static_stream_offsetof(stream, base); |
Line -... | Line 1500... | ||
- | 1500 | } |
|
- | 1501 | ||
- | 1502 | #if 0 |
|
- | 1503 | static uint32_t gen7_bind_video_source(struct sna *sna, |
|
- | 1504 | struct kgem_bo *bo, |
|
- | 1505 | uint32_t offset, |
|
- | 1506 | int width, |
|
- | 1507 | int height, |
|
- | 1508 | int pitch, |
|
- | 1509 | uint32_t format) |
|
- | 1510 | { |
|
- | 1511 | uint32_t *ss, bind; |
|
- | 1512 | ||
Line -... | Line 1513... | ||
- | 1513 | bind = sna->kgem.surface -= |
|
Line -... | Line 1514... | ||
- | 1514 | sizeof(struct gen7_surface_state) / sizeof(uint32_t); |
|
- | 1515 | ||
- | 1516 | assert(bo->tiling == I915_TILING_NONE); |
|
- | 1517 | ||
- | 1518 | ss = sna->kgem.batch + bind; |
|
- | 1519 | ss[0] = (GEN7_SURFACE_2D << GEN7_SURFACE_TYPE_SHIFT | |
|
- | 1520 | format << GEN7_SURFACE_FORMAT_SHIFT); |
|
- | 1521 | ss[1] = kgem_add_reloc(&sna->kgem, bind + 1, bo, |
|
- | 1522 | I915_GEM_DOMAIN_SAMPLER << 16, |
|
- | 1523 | offset); |
|
- | 1524 | ss[2] = ((width - 1) << GEN7_SURFACE_WIDTH_SHIFT | |
|
- | 1525 | (height - 1) << GEN7_SURFACE_HEIGHT_SHIFT); |
|
- | 1526 | ss[3] = (pitch - 1) << GEN7_SURFACE_PITCH_SHIFT; |
|
- | 1527 | ss[4] = 0; |
|
- | 1528 | ss[5] = 0; |
|
- | 1529 | ss[6] = 0; |
|
- | 1530 | ss[7] = 0; |
|
- | 1531 | if (is_hsw(sna)) |
|
- | 1532 | ss[7] |= HSW_SURFACE_SWIZZLE(RED, GREEN, BLUE, ALPHA); |
|
- | 1533 | ||
- | 1534 | DBG(("[%x] bind bo(handle=%d, addr=%d), format=%d, width=%d, height=%d, pitch=%d, offset=%d\n", |
|
- | 1535 | bind, bo->handle, ss[1], |
|
- | 1536 | format, width, height, pitch, offset)); |
|
1399 | } |
1537 | |
1400 | 1538 | return bind * sizeof(uint32_t); |
|
1401 | 1539 | } |
|
1402 | 1540 | ||
- | 1541 | static void gen7_emit_video_state(struct sna *sna, |
|
- | 1542 | const struct sna_composite_op *op) |
|
- | 1543 | { |
|
1403 | static void gen7_render_composite_done(struct sna *sna, |
1544 | struct sna_video_frame *frame = op->priv; |
- | 1545 | uint32_t src_surf_format; |
|
- | 1546 | uint32_t src_surf_base[6]; |
|
- | 1547 | int src_width[6]; |
|
- | 1548 | int src_height[6]; |
|
- | 1549 | int src_pitch[6]; |
|
1404 | const struct sna_composite_op *op) |
1550 | uint32_t *binding_table; |
- | 1551 | uint16_t offset; |
|
- | 1552 | int n_src, n; |
|
- | 1553 | ||
- | 1554 | gen7_get_batch(sna, op); |
|
- | 1555 | ||
- | 1556 | src_surf_base[0] = 0; |
|
- | 1557 | src_surf_base[1] = 0; |
|
- | 1558 | src_surf_base[2] = frame->VBufOffset; |
|
- | 1559 | src_surf_base[3] = frame->VBufOffset; |
|
- | 1560 | src_surf_base[4] = frame->UBufOffset; |
|
- | 1561 | src_surf_base[5] = frame->UBufOffset; |
|
- | 1562 | ||
- | 1563 | if (is_planar_fourcc(frame->id)) { |
|
- | 1564 | src_surf_format = GEN7_SURFACEFORMAT_R8_UNORM; |
|
- | 1565 | src_width[1] = src_width[0] = frame->width; |
|
- | 1566 | src_height[1] = src_height[0] = frame->height; |
|
- | 1567 | src_pitch[1] = src_pitch[0] = frame->pitch[1]; |
|
- | 1568 | src_width[4] = src_width[5] = src_width[2] = src_width[3] = |
|
- | 1569 | frame->width / 2; |
|
- | 1570 | src_height[4] = src_height[5] = src_height[2] = src_height[3] = |
|
- | 1571 | frame->height / 2; |
|
- | 1572 | src_pitch[4] = src_pitch[5] = src_pitch[2] = src_pitch[3] = |
|
- | 1573 | frame->pitch[0]; |
|
- | 1574 | n_src = 6; |
|
- | 1575 | } else { |
|
- | 1576 | if (frame->id == FOURCC_UYVY) |
|
- | 1577 | src_surf_format = GEN7_SURFACEFORMAT_YCRCB_SWAPY; |
|
- | 1578 | else |
|
- | 1579 | src_surf_format = GEN7_SURFACEFORMAT_YCRCB_NORMAL; |
|
- | 1580 | ||
1405 | { |
1581 | src_width[0] = frame->width; |
- | 1582 | src_height[0] = frame->height; |
|
- | 1583 | src_pitch[0] = frame->pitch[0]; |
|
- | 1584 | n_src = 1; |
|
- | 1585 | } |
|
- | 1586 | ||
- | 1587 | binding_table = gen7_composite_get_binding_table(sna, &offset); |
|
- | 1588 | ||
- | 1589 | binding_table[0] = |
|
- | 1590 | gen7_bind_bo(sna, |
|
- | 1591 | op->dst.bo, op->dst.width, op->dst.height, |
|
- | 1592 | gen7_get_dest_format(op->dst.format), |
|
- | 1593 | true); |
|
- | 1594 | for (n = 0; n < n_src; n++) { |
|
- | 1595 | binding_table[1+n] = |
|
- | 1596 | gen7_bind_video_source(sna, |
|
- | 1597 | frame->bo, |
|
- | 1598 | src_surf_base[n], |
|
1406 | if (sna->render.vertex_offset) { |
1599 | src_width[n], |
Line -... | Line 1600... | ||
- | 1600 | src_height[n], |
|
- | 1601 | src_pitch[n], |
|
Line 1407... | Line 1602... | ||
1407 | gen4_vertex_flush(sna); |
1602 | src_surf_format); |
1408 | gen7_magic_ca_pass(sna, op); |
1603 | } |
1409 | } |
1604 | |
1410 | } |
1605 | gen7_emit_state(sna, op, offset); |
1411 | 1606 | } |
|
1412 | 1607 | ||
- | 1608 | static bool |
|
- | 1609 | gen7_render_video(struct sna *sna, |
|
- | 1610 | struct sna_video *video, |
|
- | 1611 | struct sna_video_frame *frame, |
|
1413 | static bool |
1612 | RegionPtr dstRegion, |
1414 | gen7_blit_tex(struct sna *sna, |
1613 | PixmapPtr pixmap) |
1415 | uint8_t op, bool scale, |
1614 | { |
- | 1615 | struct sna_composite_op tmp; |
|
1416 | PixmapPtr src, struct kgem_bo *src_bo, |
1616 | int dst_width = dstRegion->extents.x2 - dstRegion->extents.x1; |
1417 | PixmapPtr mask,struct kgem_bo *mask_bo, |
1617 | int dst_height = dstRegion->extents.y2 - dstRegion->extents.y1; |
- | 1618 | int src_width = frame->src.x2 - frame->src.x1; |
|
1418 | PixmapPtr dst, struct kgem_bo *dst_bo, |
1619 | int src_height = frame->src.y2 - frame->src.y1; |
Line -... | Line 1620... | ||
- | 1620 | float src_offset_x, src_offset_y; |
|
- | 1621 | float src_scale_x, src_scale_y; |
|
- | 1622 | int nbox, pix_xoff, pix_yoff; |
|
- | 1623 | struct sna_pixmap *priv; |
|
- | 1624 | unsigned filter; |
|
- | 1625 | BoxPtr box; |
|
- | 1626 | ||
- | 1627 | DBG(("%s: src=(%d, %d), dst=(%d, %d), %ldx[(%d, %d), (%d, %d)...]\n", |
|
Line -... | Line 1628... | ||
- | 1628 | __FUNCTION__, |
|
1419 | int32_t src_x, int32_t src_y, |
1629 | src_width, src_height, dst_width, dst_height, |
- | 1630 | (long)REGION_NUM_RECTS(dstRegion), |
|
Line 1420... | Line -... | ||
1420 | int32_t msk_x, int32_t msk_y, |
- | |
1421 | int32_t dst_x, int32_t dst_y, |
1631 | REGION_EXTENTS(NULL, dstRegion)->x1, |
1422 | int32_t width, int32_t height, |
- | |
1423 | struct sna_composite_op *tmp) |
- | |
1424 | { |
- | |
Line -... | Line 1632... | ||
- | 1632 | REGION_EXTENTS(NULL, dstRegion)->y1, |
|
- | 1633 | REGION_EXTENTS(NULL, dstRegion)->x2, |
|
- | 1634 | REGION_EXTENTS(NULL, dstRegion)->y2)); |
|
- | 1635 | ||
- | 1636 | priv = sna_pixmap_force_to_gpu(pixmap, MOVE_READ | MOVE_WRITE); |
|
Line 1425... | Line 1637... | ||
1425 | 1637 | if (priv == NULL) |
|
1426 | - | ||
1427 | tmp->op = PictOpSrc; |
1638 | return false; |
Line 1428... | Line 1639... | ||
1428 | 1639 | ||
1429 | tmp->dst.pixmap = dst; |
1640 | memset(&tmp, 0, sizeof(tmp)); |
1430 | tmp->dst.bo = dst_bo; |
- | |
1431 | tmp->dst.width = dst->drawable.width; |
- | |
1432 | tmp->dst.height = dst->drawable.height; |
- | |
Line -... | Line 1641... | ||
- | 1641 | ||
- | 1642 | tmp.dst.pixmap = pixmap; |
|
- | 1643 | tmp.dst.width = pixmap->drawable.width; |
|
- | 1644 | tmp.dst.height = pixmap->drawable.height; |
|
Line -... | Line 1645... | ||
- | 1645 | tmp.dst.format = sna_render_format_for_depth(pixmap->drawable.depth); |
|
- | 1646 | tmp.dst.bo = priv->gpu_bo; |
|
- | 1647 | ||
- | 1648 | tmp.src.bo = frame->bo; |
|
1433 | tmp->dst.format = PICT_x8r8g8b8; |
1649 | tmp.mask.bo = NULL; |
1434 | 1650 | ||
- | 1651 | tmp.floats_per_vertex = 3; |
|
- | 1652 | tmp.floats_per_rect = 9; |
|
1435 | 1653 | ||
Line 1436... | Line 1654... | ||
1436 | tmp->src.repeat = RepeatNone; |
1654 | if (src_width == dst_width && src_height == dst_height) |
1437 | tmp->src.filter = PictFilterNearest; |
1655 | filter = SAMPLER_FILTER_NEAREST; |
1438 | tmp->src.is_affine = true; |
1656 | else |
- | 1657 | filter = SAMPLER_FILTER_BILINEAR; |
|
- | 1658 | ||
- | 1659 | tmp.u.gen7.flags = |
|
Line 1439... | Line 1660... | ||
1439 | 1660 | GEN7_SET_FLAGS(SAMPLER_OFFSET(filter, SAMPLER_EXTEND_PAD, |
|
1440 | tmp->src.bo = src_bo; |
1661 | SAMPLER_FILTER_NEAREST, SAMPLER_EXTEND_NONE), |
1441 | tmp->src.pict_format = PICT_x8r8g8b8; |
- | |
1442 | tmp->src.card_format = gen7_get_card_format(tmp->src.pict_format); |
- | |
1443 | tmp->src.width = src->drawable.width; |
- | |
Line -... | Line 1662... | ||
- | 1662 | NO_BLEND, |
|
1444 | tmp->src.height = src->drawable.height; |
1663 | is_planar_fourcc(frame->id) ? |
1445 | 1664 | GEN7_WM_KERNEL_VIDEO_PLANAR : |
|
- | 1665 | GEN7_WM_KERNEL_VIDEO_PACKED, |
|
1446 | 1666 | 2); |
|
1447 | tmp->is_affine = tmp->src.is_affine; |
1667 | tmp.priv = frame; |
1448 | tmp->has_component_alpha = false; |
1668 | |
1449 | tmp->need_magic_ca_pass = false; |
1669 | kgem_set_mode(&sna->kgem, KGEM_RENDER, tmp.dst.bo); |
1450 | 1670 | if (!kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL)) { |
|
1451 | tmp->mask.repeat = SAMPLER_EXTEND_NONE; |
- | |
1452 | tmp->mask.filter = SAMPLER_FILTER_NEAREST; |
- | |
1453 | tmp->mask.is_affine = true; |
1671 | kgem_submit(&sna->kgem); |
Line -... | Line 1672... | ||
- | 1672 | assert(kgem_check_bo(&sna->kgem, tmp.dst.bo, frame->bo, NULL)); |
|
- | 1673 | _kgem_set_mode(&sna->kgem, KGEM_RENDER); |
|
1454 | 1674 | } |
|
- | 1675 | ||
- | 1676 | gen7_emit_video_state(sna, &tmp); |
|
1455 | tmp->mask.bo = mask_bo; |
1677 | gen7_align_vertex(sna, &tmp); |
Line -... | Line 1678... | ||
- | 1678 | ||
- | 1679 | /* Set up the offset for translating from the given region (in screen |
|
Line -... | Line 1680... | ||
- | 1680 | * coordinates) to the backing pixmap. |
|
- | 1681 | */ |
|
Line 1456... | Line -... | ||
1456 | tmp->mask.pict_format = PIXMAN_a8; |
- | |
1457 | tmp->mask.card_format = gen7_get_card_format(tmp->mask.pict_format); |
1682 | #ifdef COMPOSITE |
1458 | tmp->mask.width = mask->drawable.width; |
1683 | pix_xoff = -pixmap->screen_x + pixmap->drawable.x; |
1459 | tmp->mask.height = mask->drawable.height; |
- | |
1460 | - | ||
1461 | if( scale ) |
- | |
1462 | { |
1684 | pix_yoff = -pixmap->screen_y + pixmap->drawable.y; |
1463 | tmp->src.scale[0] = 1.f/width; |
- | |
1464 | tmp->src.scale[1] = 1.f/height; |
- | |
1465 | } |
- | |
1466 | else |
- | |
1467 | { |
- | |
1468 | tmp->src.scale[0] = 1.f/src->drawable.width; |
- | |
1469 | tmp->src.scale[1] = 1.f/src->drawable.height; |
1685 | #else |
Line 1470... | Line 1686... | ||
1470 | } |
1686 | pix_xoff = 0; |
1471 | 1687 | pix_yoff = 0; |
|
1472 | tmp->mask.scale[0] = 1.f/mask->drawable.width; |
1688 | #endif |
- | 1689 | ||
Line 1473... | Line 1690... | ||
1473 | tmp->mask.scale[1] = 1.f/mask->drawable.height; |
1690 | DBG(("%s: src=(%d, %d)x(%d, %d); frame=(%dx%d), dst=(%dx%d)\n", |
- | 1691 | __FUNCTION__, |
|
1474 | 1692 | frame->src.x1, frame->src.y1, |
|
1475 | 1693 | src_width, src_height, |
|
1476 | 1694 | dst_width, dst_height, |
|
- | 1695 | frame->width, frame->height)); |
|
- | 1696 | ||
- | 1697 | src_scale_x = (float)src_width / dst_width / frame->width; |
|
- | 1698 | src_offset_x = (float)frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x; |
|
- | 1699 | ||
- | 1700 | src_scale_y = (float)src_height / dst_height / frame->height; |
|
- | 1701 | src_offset_y = (float)frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y; |
|
- | 1702 | ||
- | 1703 | DBG(("%s: scale=(%f, %f), offset=(%f, %f)\n", |
|
- | 1704 | __FUNCTION__, |
|
- | 1705 | src_scale_x, src_scale_y, |
|
- | 1706 | src_offset_x, src_offset_y)); |
|
- | 1707 | ||
- | 1708 | box = REGION_RECTS(dstRegion); |
|
- | 1709 | nbox = REGION_NUM_RECTS(dstRegion); |
|
- | 1710 | while (nbox--) { |
|
- | 1711 | BoxRec r; |
|
- | 1712 | ||
- | 1713 | DBG(("%s: dst=(%d, %d), (%d, %d) + (%d, %d); src=(%f, %f), (%f, %f)\n", |
|
- | 1714 | __FUNCTION__, |
|
1477 | tmp->u.gen7.flags = |
1715 | box->x1, box->y1, |
- | 1716 | box->x2, box->y2, |
|
- | 1717 | pix_xoff, pix_yoff, |
|
- | 1718 | box->x1 * src_scale_x + src_offset_x, |
|
- | 1719 | box->y1 * src_scale_y + src_offset_y, |
|
1478 | GEN7_SET_FLAGS(SAMPLER_OFFSET(tmp->src.filter, |
1720 | box->x2 * src_scale_x + src_offset_x, |
- | 1721 | box->y2 * src_scale_y + src_offset_y)); |
|
- | 1722 | ||
- | 1723 | r.x1 = box->x1 + pix_xoff; |
|
1479 | tmp->src.repeat, |
1724 | r.x2 = box->x2 + pix_xoff; |
Line 1480... | Line -... | ||
1480 | tmp->mask.filter, |
- | |
1481 | tmp->mask.repeat), |
1725 | r.y1 = box->y1 + pix_yoff; |
1482 | gen7_get_blend(tmp->op, |
1726 | r.y2 = box->y2 + pix_yoff; |
1483 | tmp->has_component_alpha, |
1727 | |
- | 1728 | gen7_get_rectangles(sna, &tmp, 1, gen7_emit_video_state); |
|
- | 1729 | ||
- | 1730 | OUT_VERTEX(r.x2, r.y2); |
|
- | 1731 | OUT_VERTEX_F(box->x2 * src_scale_x + src_offset_x); |
|
- | 1732 | OUT_VERTEX_F(box->y2 * src_scale_y + src_offset_y); |
|
- | 1733 | ||
- | 1734 | OUT_VERTEX(r.x1, r.y2); |
|
- | 1735 | OUT_VERTEX_F(box->x1 * src_scale_x + src_offset_x); |
|
- | 1736 | OUT_VERTEX_F(box->y2 * src_scale_y + src_offset_y); |
|
- | 1737 | ||
- | 1738 | OUT_VERTEX(r.x1, r.y1); |
|
- | 1739 | OUT_VERTEX_F(box->x1 * src_scale_x + src_offset_x); |
|
- | 1740 | OUT_VERTEX_F(box->y1 * src_scale_y + src_offset_y); |
|
- | 1741 | ||
- | 1742 | if (!DAMAGE_IS_ALL(priv->gpu_damage)) { |
|
- | 1743 | sna_damage_add_box(&priv->gpu_damage, &r); |
|
- | 1744 | sna_damage_subtract_box(&priv->cpu_damage, &r); |
|
Line -... | Line 1850... | ||
- | 1850 | ||
- | 1851 | ||
- | 1852 | ||
- | 1853 | ||
- | 1854 | ||
- | 1855 | #if 0 |
|
- | 1856 | static bool |
|
- | 1857 | gen7_render_fill_boxes(struct sna *sna, |
|
- | 1858 | CARD8 op, |
|
- | 1859 | PictFormat format, |
|
- | 1860 | const xRenderColor *color, |
|
- | 1861 | PixmapPtr dst, struct kgem_bo *dst_bo, |
|
- | 1862 | const BoxRec *box, int n) |
|
- | 1863 | { |
|
- | 1864 | struct sna_composite_op tmp; |
|
- | 1865 | uint32_t pixel; |
|
- | 1866 | ||
- | 1867 | DBG(("%s (op=%d, color=(%04x, %04x, %04x, %04x) [%08x])\n", |
|
- | 1868 | __FUNCTION__, op, |
|
- | 1869 | color->red, color->green, color->blue, color->alpha, (int)format)); |
|
- | 1870 | ||
- | 1871 | if (op >= ARRAY_SIZE(gen7_blend_op)) { |
|
- | 1872 | DBG(("%s: fallback due to unhandled blend op: %d\n", |
|
- | 1873 | __FUNCTION__, op)); |
|
- | 1874 | return false; |
|
- | 1875 | } |
|
- | 1876 | ||
- | 1877 | if (prefer_blt_fill(sna, dst_bo) || !gen7_check_dst_format(format)) { |
|
- | 1878 | uint8_t alu = GXinvalid; |
|
- | 1879 | ||
- | 1880 | if (op <= PictOpSrc) { |
|
- | 1881 | pixel = 0; |
|
- | 1882 | if (op == PictOpClear) |
|
- | 1883 | alu = GXclear; |
|
- | 1884 | else if (sna_get_pixel_from_rgba(&pixel, |
|
- | 1885 | color->red, |
|
- | 1886 | color->green, |
|
- | 1887 | color->blue, |
|
- | 1888 | color->alpha, |
|
- | 1889 | format)) |
|
- | 1890 | alu = GXcopy; |
|
- | 1891 | } |
|
- | 1892 | ||
Line -... | Line 1893... | ||
- | 1893 | if (alu != GXinvalid && |
|
- | 1894 | sna_blt_fill_boxes(sna, alu, |
|
- | 1895 | dst_bo, dst->drawable.bitsPerPixel, |
|
- | 1896 | pixel, box, n)) |
|
- | 1897 | return true; |
|
- | 1898 | ||
- | 1899 | if (!gen7_check_dst_format(format)) |
|
- | 1900 | return false; |
|
- | 1901 | } |
|
- | 1902 | ||
- | 1903 | if (op == PictOpClear) { |
|
- | 1904 | pixel = 0; |
|
- | 1905 | op = PictOpSrc; |
|
- | 1906 | } else if (!sna_get_pixel_from_rgba(&pixel, |
|
- | 1907 | color->red, |
|
- | 1908 | color->green, |
|
- | 1909 | color->blue, |
|
- | 1910 | color->alpha, |
|
- | 1911 | PICT_a8r8g8b8)) |
|
- | 1912 | return false; |
|
- | 1913 | ||
- | 1914 | DBG(("%s(%08x x %d [(%d, %d), (%d, %d) ...])\n", |
|
- | 1915 | __FUNCTION__, pixel, n, |
|
- | 1916 | box[0].x1, box[0].y1, box[0].x2, box[0].y2)); |
|
- | 1917 | ||
- | 1918 | tmp.dst.pixmap = dst; |
|
- | 1919 | tmp.dst.width = dst->drawable.width; |
|
- | 1920 | tmp.dst.height = dst->drawable.height; |
|
- | 1921 | tmp.dst.format = format; |
|
- | 1922 | tmp.dst.bo = dst_bo; |
|
- | 1923 | tmp.dst.x = tmp.dst.y = 0; |
|
- | 1924 | tmp.damage = NULL; |
|
- | 1925 | ||
- | 1926 | sna_render_composite_redirect_init(&tmp); |
|
- | 1927 | if (too_large(dst->drawable.width, dst->drawable.height)) { |
|
- | 1928 | BoxRec extents; |
|
- | 1929 | ||
- | 1930 | boxes_extents(box, n, &extents); |
|
- | 1931 | if (!sna_render_composite_redirect(sna, &tmp, |
|
- | 1932 | extents.x1, extents.y1, |
|
- | 1933 | extents.x2 - extents.x1, |
|
- | 1934 | extents.y2 - extents.y1, |
|
- | 1935 | n > 1)) |
|
- | 1936 | return sna_tiling_fill_boxes(sna, op, format, color, |
|
- | 1937 | dst, dst_bo, box, n); |
|
- | 1938 | } |
|
- | 1939 | ||
Line -... | Line 1940... | ||
- | 1940 | tmp.src.bo = sna_render_get_solid(sna, pixel); |
|
Line -... | Line 1941... | ||
- | 1941 | tmp.mask.bo = NULL; |
|
- | 1942 | ||
- | 1943 | tmp.floats_per_vertex = 2; |
|
- | 1944 | tmp.floats_per_rect = 6; |
|
- | 1945 | tmp.need_magic_ca_pass = false; |
|
- | 1946 | ||
- | 1947 | tmp.u.gen7.flags = FILL_FLAGS(op, format); |
|
- | 1948 | ||
Line -... | Line 1949... | ||
- | 1949 | kgem_set_mode(&sna->kgem, KGEM_RENDER, dst_bo); |
|
- | 1950 | if (!kgem_check_bo(&sna->kgem, dst_bo, NULL)) { |
|
- | 1951 | kgem_submit(&sna->kgem); |
|
- | 1952 | assert(kgem_check_bo(&sna->kgem, dst_bo, NULL)); |
|
- | 1953 | } |
|
- | 1954 | ||
- | 1955 | gen7_emit_fill_state(sna, &tmp); |
|
- | 1956 | gen7_align_vertex(sna, &tmp); |
|
- | 1957 | ||
- | 1958 | do { |
|
- | 1959 | int n_this_time; |
|
- | 1960 | int16_t *v; |
|
- | 1961 | ||
- | 1962 | n_this_time = gen7_get_rectangles(sna, &tmp, n, |
|
- | 1963 | gen7_emit_fill_state); |
|
- | 1964 | n -= n_this_time; |
|
- | 1965 | ||
- | 1966 | v = (int16_t *)(sna->render.vertices + sna->render.vertex_used); |
|
- | 1967 | sna->render.vertex_used += 6 * n_this_time; |
|
- | 1968 | assert(sna->render.vertex_used <= sna->render.vertex_size); |
|
- | 1969 | do { |
|
- | 1970 | DBG((" (%d, %d), (%d, %d)\n", |
|
- | 1971 | box->x1, box->y1, box->x2, box->y2)); |
|
- | 1972 | ||
Line -... | Line 1973... | ||
- | 1973 | v[0] = box->x2; |
|
- | 1974 | v[5] = v[1] = box->y2; |
|
- | 1975 | v[8] = v[4] = box->x1; |
|
- | 1976 | v[9] = box->y1; |
|
- | 1977 | v[2] = v[3] = v[7] = 1; |
|
- | 1978 | v[6] = v[10] = v[11] = 0; |
|
Line 1589... | Line 1979... | ||
1589 | 1979 | v += 12; box++; |
|
1590 | 1980 | } while (--n_this_time); |
|
1591 | 1981 | } while (n); |
|
Line 1674... | Line 2064... | ||
1674 | static void gen7_render_fini(struct sna *sna) |
2064 | static void gen7_render_fini(struct sna *sna) |
1675 | { |
2065 | { |
1676 | kgem_bo_destroy(&sna->kgem, sna->render_state.gen7.general_bo); |
2066 | kgem_bo_destroy(&sna->kgem, sna->render_state.gen7.general_bo); |
1677 | } |
2067 | } |
Line -... | Line 2068... | ||
- | 2068 | ||
- | 2069 | static bool is_gt3(struct sna *sna) |
|
- | 2070 | { |
|
- | 2071 | assert(sna->kgem.gen == 075); |
|
- | 2072 | return sna->PciInfo->device_id & 0x20; |
|
- | 2073 | } |
|
1678 | 2074 | ||
1679 | static bool is_gt2(struct sna *sna) |
2075 | static bool is_gt2(struct sna *sna) |
1680 | { |
2076 | { |
1681 | return DEVICE_ID(sna->PciInfo) & 0x20; |
2077 | return sna->PciInfo->device_id & (is_hsw(sna)? 0x30 : 0x20); |
Line 1682... | Line 2078... | ||
1682 | } |
2078 | } |
1683 | 2079 | ||
1684 | static bool is_mobile(struct sna *sna) |
2080 | static bool is_mobile(struct sna *sna) |
1685 | { |
2081 | { |
Line 1686... | Line 2082... | ||
1686 | return (DEVICE_ID(sna->PciInfo) & 0xf) == 0x6; |
2082 | return (sna->PciInfo->device_id & 0xf) == 0x6; |
1687 | } |
2083 | } |
1688 | 2084 | ||
1689 | static bool gen7_render_setup(struct sna *sna) |
2085 | static bool gen7_render_setup(struct sna *sna) |
1690 | { |
2086 | { |
1691 | struct gen7_render_state *state = &sna->render_state.gen7; |
2087 | struct gen7_render_state *state = &sna->render_state.gen7; |
Line 1692... | Line 2088... | ||
1692 | struct sna_static_stream general; |
2088 | struct sna_static_stream general; |
1693 | struct gen7_sampler_state *ss; |
2089 | struct gen7_sampler_state *ss; |
1694 | int i, j, k, l, m; |
2090 | int i, j, k, l, m; |
1695 | 2091 | ||
1696 | if (sna->kgem.gen == 070) { |
2092 | if (is_ivb(sna)) { |
1697 | state->info = &ivb_gt_info; |
2093 | state->info = &ivb_gt_info; |
1698 | if (DEVICE_ID(sna->PciInfo) & 0xf) { |
2094 | if (sna->PciInfo->device_id & 0xf) { |
- | 2095 | state->info = &ivb_gt1_info; |
|
- | 2096 | if (is_gt2(sna)) |
|
1699 | state->info = &ivb_gt1_info; |
2097 | state->info = &ivb_gt2_info; /* XXX requires GT_MODE WiZ disabled */ |
1700 | if (is_gt2(sna)) |
2098 | } |
1701 | state->info = &ivb_gt2_info; /* XXX requires GT_MODE WiZ disabled */ |
2099 | } else if (is_byt(sna)) { |
- | 2100 | state->info = &byt_gt_info; |
|
1702 | } |
2101 | } else if (is_hsw(sna)) { |
1703 | } else if (sna->kgem.gen == 075) { |
2102 | state->info = &hsw_gt_info; |
1704 | state->info = &hsw_gt_info; |
2103 | if (sna->PciInfo->device_id & 0xf) { |
- | 2104 | if (is_gt3(sna)) |
|
- | 2105 | state->info = &hsw_gt3_info; |
|
1705 | if (DEVICE_ID(sna->PciInfo) & 0xf) { |
2106 | else if (is_gt2(sna)) |
1706 | state->info = &hsw_gt1_info; |
2107 | state->info = &hsw_gt2_info; |
1707 | if (is_gt2(sna)) |
2108 | else |
Line 1708... | Line 2109... | ||
1708 | state->info = &hsw_gt2_info; |
2109 | state->info = &hsw_gt1_info; |
Line 1770... | Line 2171... | ||
1770 | 2171 | ||
1771 | state->general_bo = sna_static_stream_fini(sna, &general); |
2172 | state->general_bo = sna_static_stream_fini(sna, &general); |
1772 | return state->general_bo != NULL; |
2173 | return state->general_bo != NULL; |
Line 1773... | Line 2174... | ||
1773 | } |
2174 | } |
1774 | 2175 | ||
1775 | bool gen7_render_init(struct sna *sna) |
2176 | const char *gen7_render_init(struct sna *sna, const char *backend) |
1776 | { |
2177 | { |
Line 1777... | Line 2178... | ||
1777 | if (!gen7_render_setup(sna)) |
2178 | if (!gen7_render_setup(sna)) |
1778 | return false; |
2179 | return backend; |
1779 | 2180 | ||
Line -... | Line 2181... | ||
- | 2181 | sna->kgem.context_switch = gen7_render_context_switch; |
|
- | 2182 | sna->kgem.retire = gen7_render_retire; |
|
- | 2183 | sna->kgem.expire = gen7_render_expire; |
|
- | 2184 | ||
- | 2185 | #if 0 |
|
- | 2186 | #if !NO_COMPOSITE |
|
- | 2187 | sna->render.composite = gen7_render_composite; |
|
- | 2188 | sna->render.prefer_gpu |= PREFER_GPU_RENDER; |
|
- | 2189 | #endif |
|
- | 2190 | #if !NO_COMPOSITE_SPANS |
|
- | 2191 | sna->render.check_composite_spans = gen7_check_composite_spans; |
|
- | 2192 | sna->render.composite_spans = gen7_render_composite_spans; |
|
- | 2193 | if (is_mobile(sna) || is_gt2(sna) || is_byt(sna)) |
|
- | 2194 | sna->render.prefer_gpu |= PREFER_GPU_SPANS; |
|
- | 2195 | #endif |
|
- | 2196 | sna->render.video = gen7_render_video; |
|
- | 2197 | ||
- | 2198 | #if !NO_COPY_BOXES |
|
- | 2199 | sna->render.copy_boxes = gen7_render_copy_boxes; |
|
- | 2200 | #endif |
|
- | 2201 | #if !NO_COPY |
|
- | 2202 | sna->render.copy = gen7_render_copy; |
|
- | 2203 | #endif |
|
- | 2204 | ||
- | 2205 | #if !NO_FILL_BOXES |
|
- | 2206 | sna->render.fill_boxes = gen7_render_fill_boxes; |
|
- | 2207 | #endif |
|
- | 2208 | #if !NO_FILL |
|
- | 2209 | sna->render.fill = gen7_render_fill; |
|
- | 2210 | #endif |
|
- | 2211 | #if !NO_FILL_ONE |
|
- | 2212 | sna->render.fill_one = gen7_render_fill_one; |
|
- | 2213 | #endif |
|
- | 2214 | #if !NO_FILL_CLEAR |
|
1780 | sna->kgem.context_switch = gen7_render_context_switch; |
2215 | sna->render.clear = gen7_render_clear; |
- | 2216 | #endif |
|
Line 1781... | Line 2217... | ||
1781 | sna->kgem.retire = gen7_render_retire; |
2217 | #endif |
1782 | sna->kgem.expire = gen7_render_expire; |
2218 | |
1783 | 2219 | sna->render.blit_tex = gen7_blit_tex; |
|
Line 1784... | Line 2220... | ||
1784 | sna->render.blit_tex = gen7_blit_tex; |
2220 | sna->render.caps = HW_BIT_BLIT | HW_TEX_BLIT; |
1785 | 2221 | ||
1786 | sna->render.flush = gen7_render_flush; |
2222 | sna->render.flush = gen7_render_flush; |
- | 2223 | sna->render.reset = gen7_render_reset; |
|
Line -... | Line 2224... | ||
- | 2224 | sna->render.fini = gen7_render_fini; |
|
- | 2225 | ||
- | 2226 | sna->render.max_3d_size = GEN7_MAX_SIZE; |
|
- | 2227 | sna->render.max_3d_pitch = 1 << 18; |
|
- | 2228 | return sna->render_state.gen7.info->name; |
|
- | 2229 | } |
|
- | 2230 | ||
- | 2231 | ||
- | 2232 | static bool |
|
- | 2233 | gen7_blit_tex(struct sna *sna, |
|
- | 2234 | uint8_t op, bool scale, |
|
- | 2235 | PixmapPtr src, struct kgem_bo *src_bo, |
|
- | 2236 | PixmapPtr mask,struct kgem_bo *mask_bo, |
|
- | 2237 | PixmapPtr dst, struct kgem_bo *dst_bo, |
|
- | 2238 | int32_t src_x, int32_t src_y, |
|
- | 2239 | int32_t msk_x, int32_t msk_y, |
|
- | 2240 | int32_t dst_x, int32_t dst_y, |
|
- | 2241 | int32_t width, int32_t height, |
|
- | 2242 | struct sna_composite_op *tmp) |
|
- | 2243 | { |
|
- | 2244 | ||
- | 2245 | ||
- | 2246 | tmp->op = PictOpSrc; |
|
- | 2247 | ||
- | 2248 | tmp->dst.pixmap = dst; |
|
- | 2249 | tmp->dst.bo = dst_bo; |
|
- | 2250 | tmp->dst.width = dst->drawable.width; |
|
- | 2251 | tmp->dst.height = dst->drawable.height; |
|
- | 2252 | tmp->dst.format = PICT_x8r8g8b8; |
|
- | 2253 | ||
- | 2254 | ||
- | 2255 | tmp->src.repeat = RepeatNone; |
|
- | 2256 | tmp->src.filter = PictFilterNearest; |
|
- | 2257 | tmp->src.is_affine = true; |
|
- | 2258 | ||
- | 2259 | tmp->src.bo = src_bo; |
|
- | 2260 | tmp->src.pict_format = PICT_x8r8g8b8; |
|
- | 2261 | tmp->src.card_format = gen7_get_card_format(tmp->src.pict_format); |
|
- | 2262 | tmp->src.width = src->drawable.width; |
|
- | 2263 | tmp->src.height = src->drawable.height; |
|
- | 2264 | ||
- | 2265 | ||
- | 2266 | tmp->is_affine = tmp->src.is_affine; |
|
- | 2267 | tmp->has_component_alpha = false; |
|
- | 2268 | tmp->need_magic_ca_pass = false; |
|
- | 2269 | ||
- | 2270 | tmp->mask.repeat = SAMPLER_EXTEND_NONE; |
|
- | 2271 | tmp->mask.filter = SAMPLER_FILTER_NEAREST; |
|
- | 2272 | tmp->mask.is_affine = true; |
|
1787 | sna->render.reset = gen7_render_reset; |
2273 | |
- | 2274 | tmp->mask.bo = mask_bo; |
|
- | 2275 | tmp->mask.pict_format = PIXMAN_a8; |
|
- | 2276 | tmp->mask.card_format = gen7_get_card_format(tmp->mask.pict_format); |
|
- | 2277 | tmp->mask.width = mask->drawable.width; |
|
- | 2278 | tmp->mask.height = mask->drawable.height; |
|
- | 2279 | ||
- | 2280 | if( scale ) |
|
- | 2281 | { |
|
1788 | sna->render.fini = gen7_render_fini; |
2282 | tmp->src.scale[0] = 1.f/width; |
Line -... | Line 2283... | ||
- | 2283 | tmp->src.scale[1] = 1.f/height; |
|
- | 2284 | } |
|
- | 2285 | else |
|
Line -... | Line 2286... | ||
- | 2286 | { |
|
- | 2287 | tmp->src.scale[0] = 1.f/src->drawable.width; |
|
- | 2288 | tmp->src.scale[1] = 1.f/src->drawable.height; |
|
- | 2289 | } |
|
- | 2290 | ||
- | 2291 | tmp->mask.scale[0] = 1.f/mask->drawable.width; |
|
- | 2292 | tmp->mask.scale[1] = 1.f/mask->drawable.height; |
|
- | 2293 | ||
- | 2294 | ||
- | 2295 | ||
- | 2296 | tmp->u.gen7.flags = |
|
- | 2297 | GEN7_SET_FLAGS(SAMPLER_OFFSET(tmp->src.filter, |
|
- | 2298 | tmp->src.repeat, |
|
- | 2299 | tmp->mask.filter, |
|
- | 2300 | tmp->mask.repeat), |
|
- | 2301 | gen7_get_blend(tmp->op, |
|
- | 2302 | tmp->has_component_alpha, |
|
- | 2303 | tmp->dst.format), |
|
- | 2304 | /* gen7_choose_composite_kernel(tmp->op, |
|
- | 2305 | tmp->mask.bo != NULL, |
|
- | 2306 | tmp->has_component_alpha, |
|
- | 2307 | tmp->is_affine), */ |
|
- | 2308 | GEN7_WM_KERNEL_MASK, |
|
- | 2309 | gen4_choose_composite_emitter(sna, tmp)); |
|
- | 2310 | ||
- | 2311 | tmp->blt = gen7_render_composite_blt; |
|
- | 2312 | // tmp->box = gen7_render_composite_box; |
|
- | 2313 | tmp->done = gen7_render_composite_done; |
|
- | 2314 | ||
- | 2315 | kgem_set_mode(&sna->kgem, KGEM_RENDER, tmp->dst.bo); |
|
- | 2316 | if (!kgem_check_bo(&sna->kgem, |
|
- | 2317 | tmp->dst.bo, tmp->src.bo, tmp->mask.bo, |