2 * Copyright © 2006 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 * Eric Anholt <eric@anholt.net>
25 * Keith Packard <keithp@keithp.com>
26 * Xiang Haihao <haihao.xiang@intel.com>
31 * Most of rendering codes are ported from xf86-video-intel/src/i965_video.c
39 #include <va/va_backend.h>
40 #include <va/va_dricommon.h>
42 #include "intel_batchbuffer.h"
43 #include "intel_driver.h"
44 #include "i965_defines.h"
45 #include "i965_drv_video.h"
46 #include "i965_structs.h"
48 #include "i965_render.h"
50 #define SF_KERNEL_NUM_GRF 16
51 #define SF_MAX_THREADS 1
53 static const uint32_t sf_kernel_static[][4] =
55 #include "shaders/render/exa_sf.g4b"
58 #define PS_KERNEL_NUM_GRF 32
59 #define PS_MAX_THREADS 32
61 #define I965_GRF_BLOCKS(nreg) ((nreg + 15) / 16 - 1)
63 static const uint32_t ps_kernel_static[][4] =
65 #include "shaders/render/exa_wm_xy.g4b"
66 #include "shaders/render/exa_wm_src_affine.g4b"
67 #include "shaders/render/exa_wm_src_sample_planar.g4b"
68 #include "shaders/render/exa_wm_yuv_rgb.g4b"
69 #include "shaders/render/exa_wm_write.g4b"
71 static const uint32_t ps_subpic_kernel_static[][4] =
73 #include "shaders/render/exa_wm_xy.g4b"
74 #include "shaders/render/exa_wm_src_affine.g4b"
75 #include "shaders/render/exa_wm_src_sample_argb.g4b"
76 #include "shaders/render/exa_wm_write.g4b"
80 static const uint32_t sf_kernel_static_gen5[][4] =
82 #include "shaders/render/exa_sf.g4b.gen5"
85 static const uint32_t ps_kernel_static_gen5[][4] =
87 #include "shaders/render/exa_wm_xy.g4b.gen5"
88 #include "shaders/render/exa_wm_src_affine.g4b.gen5"
89 #include "shaders/render/exa_wm_src_sample_planar.g4b.gen5"
90 #include "shaders/render/exa_wm_yuv_rgb.g4b.gen5"
91 #include "shaders/render/exa_wm_write.g4b.gen5"
93 static const uint32_t ps_subpic_kernel_static_gen5[][4] =
95 #include "shaders/render/exa_wm_xy.g4b.gen5"
96 #include "shaders/render/exa_wm_src_affine.g4b.gen5"
97 #include "shaders/render/exa_wm_src_sample_argb.g4b.gen5"
98 #include "shaders/render/exa_wm_write.g4b.gen5"
101 /* programs for Sandybridge */
102 static const uint32_t sf_kernel_static_gen6[][4] =
106 static const uint32_t ps_kernel_static_gen6[][4] = {
107 #include "shaders/render/exa_wm_src_affine.g6b"
108 #include "shaders/render/exa_wm_src_sample_planar.g6b"
109 #include "shaders/render/exa_wm_yuv_rgb.g6b"
110 #include "shaders/render/exa_wm_write.g6b"
113 static const uint32_t ps_subpic_kernel_static_gen6[][4] = {
114 #include "shaders/render/exa_wm_src_affine.g6b"
115 #include "shaders/render/exa_wm_src_sample_argb.g6b"
116 #include "shaders/render/exa_wm_write.g6b"
119 /* programs for Ivybridge */
120 static const uint32_t sf_kernel_static_gen7[][4] =
124 static const uint32_t ps_kernel_static_gen7[][4] = {
125 #include "shaders/render/exa_wm_src_affine.g7b"
126 #include "shaders/render/exa_wm_src_sample_planar.g7b"
127 #include "shaders/render/exa_wm_yuv_rgb.g7b"
128 #include "shaders/render/exa_wm_write.g7b"
131 static const uint32_t ps_subpic_kernel_static_gen7[][4] = {
132 #include "shaders/render/exa_wm_src_affine.g7b"
133 #include "shaders/render/exa_wm_src_sample_argb.g7b"
134 #include "shaders/render/exa_wm_write.g7b"
137 #define SURFACE_STATE_PADDED_SIZE_I965 ALIGN(sizeof(struct i965_surface_state), 32)
138 #define SURFACE_STATE_PADDED_SIZE_GEN7 ALIGN(sizeof(struct gen7_surface_state), 32)
139 #define SURFACE_STATE_PADDED_SIZE MAX(SURFACE_STATE_PADDED_SIZE_I965, SURFACE_STATE_PADDED_SIZE_GEN7)
140 #define SURFACE_STATE_OFFSET(index) (SURFACE_STATE_PADDED_SIZE * index)
141 #define BINDING_TABLE_OFFSET SURFACE_STATE_OFFSET(MAX_RENDER_SURFACES)
143 static uint32_t float_to_uint (float f)
161 static struct i965_kernel render_kernels_gen4[] = {
166 sizeof(sf_kernel_static),
173 sizeof(ps_kernel_static),
180 ps_subpic_kernel_static,
181 sizeof(ps_subpic_kernel_static),
186 static struct i965_kernel render_kernels_gen5[] = {
190 sf_kernel_static_gen5,
191 sizeof(sf_kernel_static_gen5),
197 ps_kernel_static_gen5,
198 sizeof(ps_kernel_static_gen5),
205 ps_subpic_kernel_static_gen5,
206 sizeof(ps_subpic_kernel_static_gen5),
211 static struct i965_kernel render_kernels_gen6[] = {
215 sf_kernel_static_gen6,
216 sizeof(sf_kernel_static_gen6),
222 ps_kernel_static_gen6,
223 sizeof(ps_kernel_static_gen6),
230 ps_subpic_kernel_static_gen6,
231 sizeof(ps_subpic_kernel_static_gen6),
236 static struct i965_kernel render_kernels_gen7[] = {
240 sf_kernel_static_gen7,
241 sizeof(sf_kernel_static_gen7),
247 ps_kernel_static_gen7,
248 sizeof(ps_kernel_static_gen7),
255 ps_subpic_kernel_static_gen7,
256 sizeof(ps_subpic_kernel_static_gen7),
261 #define URB_VS_ENTRIES 8
262 #define URB_VS_ENTRY_SIZE 1
264 #define URB_GS_ENTRIES 0
265 #define URB_GS_ENTRY_SIZE 0
267 #define URB_CLIP_ENTRIES 0
268 #define URB_CLIP_ENTRY_SIZE 0
270 #define URB_SF_ENTRIES 1
271 #define URB_SF_ENTRY_SIZE 2
273 #define URB_CS_ENTRIES 1
274 #define URB_CS_ENTRY_SIZE 1
277 i965_render_vs_unit(VADriverContextP ctx)
279 struct i965_driver_data *i965 = i965_driver_data(ctx);
280 struct i965_render_state *render_state = &i965->render_state;
281 struct i965_vs_unit_state *vs_state;
283 dri_bo_map(render_state->vs.state, 1);
284 assert(render_state->vs.state->virtual);
285 vs_state = render_state->vs.state->virtual;
286 memset(vs_state, 0, sizeof(*vs_state));
288 if (IS_IRONLAKE(i965->intel.device_id))
289 vs_state->thread4.nr_urb_entries = URB_VS_ENTRIES >> 2;
291 vs_state->thread4.nr_urb_entries = URB_VS_ENTRIES;
293 vs_state->thread4.urb_entry_allocation_size = URB_VS_ENTRY_SIZE - 1;
294 vs_state->vs6.vs_enable = 0;
295 vs_state->vs6.vert_cache_disable = 1;
297 dri_bo_unmap(render_state->vs.state);
301 i965_render_sf_unit(VADriverContextP ctx)
303 struct i965_driver_data *i965 = i965_driver_data(ctx);
304 struct i965_render_state *render_state = &i965->render_state;
305 struct i965_sf_unit_state *sf_state;
307 dri_bo_map(render_state->sf.state, 1);
308 assert(render_state->sf.state->virtual);
309 sf_state = render_state->sf.state->virtual;
310 memset(sf_state, 0, sizeof(*sf_state));
312 sf_state->thread0.grf_reg_count = I965_GRF_BLOCKS(SF_KERNEL_NUM_GRF);
313 sf_state->thread0.kernel_start_pointer = render_state->render_kernels[SF_KERNEL].bo->offset >> 6;
315 sf_state->sf1.single_program_flow = 1; /* XXX */
316 sf_state->sf1.binding_table_entry_count = 0;
317 sf_state->sf1.thread_priority = 0;
318 sf_state->sf1.floating_point_mode = 0; /* Mesa does this */
319 sf_state->sf1.illegal_op_exception_enable = 1;
320 sf_state->sf1.mask_stack_exception_enable = 1;
321 sf_state->sf1.sw_exception_enable = 1;
323 /* scratch space is not used in our kernel */
324 sf_state->thread2.per_thread_scratch_space = 0;
325 sf_state->thread2.scratch_space_base_pointer = 0;
327 sf_state->thread3.const_urb_entry_read_length = 0; /* no const URBs */
328 sf_state->thread3.const_urb_entry_read_offset = 0; /* no const URBs */
329 sf_state->thread3.urb_entry_read_length = 1; /* 1 URB per vertex */
330 sf_state->thread3.urb_entry_read_offset = 0;
331 sf_state->thread3.dispatch_grf_start_reg = 3;
333 sf_state->thread4.max_threads = SF_MAX_THREADS - 1;
334 sf_state->thread4.urb_entry_allocation_size = URB_SF_ENTRY_SIZE - 1;
335 sf_state->thread4.nr_urb_entries = URB_SF_ENTRIES;
336 sf_state->thread4.stats_enable = 1;
338 sf_state->sf5.viewport_transform = 0; /* skip viewport */
340 sf_state->sf6.cull_mode = I965_CULLMODE_NONE;
341 sf_state->sf6.scissor = 0;
343 sf_state->sf7.trifan_pv = 2;
345 sf_state->sf6.dest_org_vbias = 0x8;
346 sf_state->sf6.dest_org_hbias = 0x8;
348 dri_bo_emit_reloc(render_state->sf.state,
349 I915_GEM_DOMAIN_INSTRUCTION, 0,
350 sf_state->thread0.grf_reg_count << 1,
351 offsetof(struct i965_sf_unit_state, thread0),
352 render_state->render_kernels[SF_KERNEL].bo);
354 dri_bo_unmap(render_state->sf.state);
358 i965_render_sampler(VADriverContextP ctx)
360 struct i965_driver_data *i965 = i965_driver_data(ctx);
361 struct i965_render_state *render_state = &i965->render_state;
362 struct i965_sampler_state *sampler_state;
365 assert(render_state->wm.sampler_count > 0);
366 assert(render_state->wm.sampler_count <= MAX_SAMPLERS);
368 dri_bo_map(render_state->wm.sampler, 1);
369 assert(render_state->wm.sampler->virtual);
370 sampler_state = render_state->wm.sampler->virtual;
371 for (i = 0; i < render_state->wm.sampler_count; i++) {
372 memset(sampler_state, 0, sizeof(*sampler_state));
373 sampler_state->ss0.min_filter = I965_MAPFILTER_LINEAR;
374 sampler_state->ss0.mag_filter = I965_MAPFILTER_LINEAR;
375 sampler_state->ss1.r_wrap_mode = I965_TEXCOORDMODE_CLAMP;
376 sampler_state->ss1.s_wrap_mode = I965_TEXCOORDMODE_CLAMP;
377 sampler_state->ss1.t_wrap_mode = I965_TEXCOORDMODE_CLAMP;
381 dri_bo_unmap(render_state->wm.sampler);
384 i965_subpic_render_wm_unit(VADriverContextP ctx)
386 struct i965_driver_data *i965 = i965_driver_data(ctx);
387 struct i965_render_state *render_state = &i965->render_state;
388 struct i965_wm_unit_state *wm_state;
390 assert(render_state->wm.sampler);
392 dri_bo_map(render_state->wm.state, 1);
393 assert(render_state->wm.state->virtual);
394 wm_state = render_state->wm.state->virtual;
395 memset(wm_state, 0, sizeof(*wm_state));
397 wm_state->thread0.grf_reg_count = I965_GRF_BLOCKS(PS_KERNEL_NUM_GRF);
398 wm_state->thread0.kernel_start_pointer = render_state->render_kernels[PS_SUBPIC_KERNEL].bo->offset >> 6;
400 wm_state->thread1.single_program_flow = 1; /* XXX */
402 if (IS_IRONLAKE(i965->intel.device_id))
403 wm_state->thread1.binding_table_entry_count = 0; /* hardware requirement */
405 wm_state->thread1.binding_table_entry_count = 7;
407 wm_state->thread2.scratch_space_base_pointer = 0;
408 wm_state->thread2.per_thread_scratch_space = 0; /* 1024 bytes */
410 wm_state->thread3.dispatch_grf_start_reg = 3; /* XXX */
411 wm_state->thread3.const_urb_entry_read_length = 0;
412 wm_state->thread3.const_urb_entry_read_offset = 0;
413 wm_state->thread3.urb_entry_read_length = 1; /* XXX */
414 wm_state->thread3.urb_entry_read_offset = 0; /* XXX */
416 wm_state->wm4.stats_enable = 0;
417 wm_state->wm4.sampler_state_pointer = render_state->wm.sampler->offset >> 5;
419 if (IS_IRONLAKE(i965->intel.device_id)) {
420 wm_state->wm4.sampler_count = 0; /* hardware requirement */
421 wm_state->wm5.max_threads = 12 * 6 - 1;
423 wm_state->wm4.sampler_count = (render_state->wm.sampler_count + 3) / 4;
424 wm_state->wm5.max_threads = 10 * 5 - 1;
427 wm_state->wm5.thread_dispatch_enable = 1;
428 wm_state->wm5.enable_16_pix = 1;
429 wm_state->wm5.enable_8_pix = 0;
430 wm_state->wm5.early_depth_test = 1;
432 dri_bo_emit_reloc(render_state->wm.state,
433 I915_GEM_DOMAIN_INSTRUCTION, 0,
434 wm_state->thread0.grf_reg_count << 1,
435 offsetof(struct i965_wm_unit_state, thread0),
436 render_state->render_kernels[PS_SUBPIC_KERNEL].bo);
438 dri_bo_emit_reloc(render_state->wm.state,
439 I915_GEM_DOMAIN_INSTRUCTION, 0,
440 wm_state->wm4.sampler_count << 2,
441 offsetof(struct i965_wm_unit_state, wm4),
442 render_state->wm.sampler);
444 dri_bo_unmap(render_state->wm.state);
449 i965_render_wm_unit(VADriverContextP ctx)
451 struct i965_driver_data *i965 = i965_driver_data(ctx);
452 struct i965_render_state *render_state = &i965->render_state;
453 struct i965_wm_unit_state *wm_state;
455 assert(render_state->wm.sampler);
457 dri_bo_map(render_state->wm.state, 1);
458 assert(render_state->wm.state->virtual);
459 wm_state = render_state->wm.state->virtual;
460 memset(wm_state, 0, sizeof(*wm_state));
462 wm_state->thread0.grf_reg_count = I965_GRF_BLOCKS(PS_KERNEL_NUM_GRF);
463 wm_state->thread0.kernel_start_pointer = render_state->render_kernels[PS_KERNEL].bo->offset >> 6;
465 wm_state->thread1.single_program_flow = 1; /* XXX */
467 if (IS_IRONLAKE(i965->intel.device_id))
468 wm_state->thread1.binding_table_entry_count = 0; /* hardware requirement */
470 wm_state->thread1.binding_table_entry_count = 7;
472 wm_state->thread2.scratch_space_base_pointer = 0;
473 wm_state->thread2.per_thread_scratch_space = 0; /* 1024 bytes */
475 wm_state->thread3.dispatch_grf_start_reg = 2; /* XXX */
476 wm_state->thread3.const_urb_entry_read_length = 1;
477 wm_state->thread3.const_urb_entry_read_offset = 0;
478 wm_state->thread3.urb_entry_read_length = 1; /* XXX */
479 wm_state->thread3.urb_entry_read_offset = 0; /* XXX */
481 wm_state->wm4.stats_enable = 0;
482 wm_state->wm4.sampler_state_pointer = render_state->wm.sampler->offset >> 5;
484 if (IS_IRONLAKE(i965->intel.device_id)) {
485 wm_state->wm4.sampler_count = 0; /* hardware requirement */
486 wm_state->wm5.max_threads = 12 * 6 - 1;
488 wm_state->wm4.sampler_count = (render_state->wm.sampler_count + 3) / 4;
489 wm_state->wm5.max_threads = 10 * 5 - 1;
492 wm_state->wm5.thread_dispatch_enable = 1;
493 wm_state->wm5.enable_16_pix = 1;
494 wm_state->wm5.enable_8_pix = 0;
495 wm_state->wm5.early_depth_test = 1;
497 dri_bo_emit_reloc(render_state->wm.state,
498 I915_GEM_DOMAIN_INSTRUCTION, 0,
499 wm_state->thread0.grf_reg_count << 1,
500 offsetof(struct i965_wm_unit_state, thread0),
501 render_state->render_kernels[PS_KERNEL].bo);
503 dri_bo_emit_reloc(render_state->wm.state,
504 I915_GEM_DOMAIN_INSTRUCTION, 0,
505 wm_state->wm4.sampler_count << 2,
506 offsetof(struct i965_wm_unit_state, wm4),
507 render_state->wm.sampler);
509 dri_bo_unmap(render_state->wm.state);
513 i965_render_cc_viewport(VADriverContextP ctx)
515 struct i965_driver_data *i965 = i965_driver_data(ctx);
516 struct i965_render_state *render_state = &i965->render_state;
517 struct i965_cc_viewport *cc_viewport;
519 dri_bo_map(render_state->cc.viewport, 1);
520 assert(render_state->cc.viewport->virtual);
521 cc_viewport = render_state->cc.viewport->virtual;
522 memset(cc_viewport, 0, sizeof(*cc_viewport));
524 cc_viewport->min_depth = -1.e35;
525 cc_viewport->max_depth = 1.e35;
527 dri_bo_unmap(render_state->cc.viewport);
531 i965_subpic_render_cc_unit(VADriverContextP ctx)
533 struct i965_driver_data *i965 = i965_driver_data(ctx);
534 struct i965_render_state *render_state = &i965->render_state;
535 struct i965_cc_unit_state *cc_state;
537 assert(render_state->cc.viewport);
539 dri_bo_map(render_state->cc.state, 1);
540 assert(render_state->cc.state->virtual);
541 cc_state = render_state->cc.state->virtual;
542 memset(cc_state, 0, sizeof(*cc_state));
544 cc_state->cc0.stencil_enable = 0; /* disable stencil */
545 cc_state->cc2.depth_test = 0; /* disable depth test */
546 cc_state->cc2.logicop_enable = 0; /* disable logic op */
547 cc_state->cc3.ia_blend_enable = 0 ; /* blend alpha just like colors */
548 cc_state->cc3.blend_enable = 1; /* enable color blend */
549 cc_state->cc3.alpha_test = 0; /* disable alpha test */
550 cc_state->cc3.alpha_test_format = 0;//0:ALPHATEST_UNORM8; /*store alpha value with UNORM8 */
551 cc_state->cc3.alpha_test_func = 5;//COMPAREFUNCTION_LESS; /*pass if less than the reference */
552 cc_state->cc4.cc_viewport_state_offset = render_state->cc.viewport->offset >> 5;
554 cc_state->cc5.dither_enable = 0; /* disable dither */
555 cc_state->cc5.logicop_func = 0xc; /* WHITE */
556 cc_state->cc5.statistics_enable = 1;
557 cc_state->cc5.ia_blend_function = I965_BLENDFUNCTION_ADD;
558 cc_state->cc5.ia_src_blend_factor = I965_BLENDFACTOR_DST_ALPHA;
559 cc_state->cc5.ia_dest_blend_factor = I965_BLENDFACTOR_DST_ALPHA;
561 cc_state->cc6.clamp_post_alpha_blend = 0;
562 cc_state->cc6.clamp_pre_alpha_blend =0;
564 /*final color = src_color*src_blend_factor +/- dst_color*dest_color_blend_factor*/
565 cc_state->cc6.blend_function = I965_BLENDFUNCTION_ADD;
566 cc_state->cc6.src_blend_factor = I965_BLENDFACTOR_SRC_ALPHA;
567 cc_state->cc6.dest_blend_factor = I965_BLENDFACTOR_INV_SRC_ALPHA;
569 /*alpha test reference*/
570 cc_state->cc7.alpha_ref.f =0.0 ;
573 dri_bo_emit_reloc(render_state->cc.state,
574 I915_GEM_DOMAIN_INSTRUCTION, 0,
576 offsetof(struct i965_cc_unit_state, cc4),
577 render_state->cc.viewport);
579 dri_bo_unmap(render_state->cc.state);
584 i965_render_cc_unit(VADriverContextP ctx)
586 struct i965_driver_data *i965 = i965_driver_data(ctx);
587 struct i965_render_state *render_state = &i965->render_state;
588 struct i965_cc_unit_state *cc_state;
590 assert(render_state->cc.viewport);
592 dri_bo_map(render_state->cc.state, 1);
593 assert(render_state->cc.state->virtual);
594 cc_state = render_state->cc.state->virtual;
595 memset(cc_state, 0, sizeof(*cc_state));
597 cc_state->cc0.stencil_enable = 0; /* disable stencil */
598 cc_state->cc2.depth_test = 0; /* disable depth test */
599 cc_state->cc2.logicop_enable = 1; /* enable logic op */
600 cc_state->cc3.ia_blend_enable = 0; /* blend alpha just like colors */
601 cc_state->cc3.blend_enable = 0; /* disable color blend */
602 cc_state->cc3.alpha_test = 0; /* disable alpha test */
603 cc_state->cc4.cc_viewport_state_offset = render_state->cc.viewport->offset >> 5;
605 cc_state->cc5.dither_enable = 0; /* disable dither */
606 cc_state->cc5.logicop_func = 0xc; /* WHITE */
607 cc_state->cc5.statistics_enable = 1;
608 cc_state->cc5.ia_blend_function = I965_BLENDFUNCTION_ADD;
609 cc_state->cc5.ia_src_blend_factor = I965_BLENDFACTOR_ONE;
610 cc_state->cc5.ia_dest_blend_factor = I965_BLENDFACTOR_ONE;
612 dri_bo_emit_reloc(render_state->cc.state,
613 I915_GEM_DOMAIN_INSTRUCTION, 0,
615 offsetof(struct i965_cc_unit_state, cc4),
616 render_state->cc.viewport);
618 dri_bo_unmap(render_state->cc.state);
622 i965_render_set_surface_tiling(struct i965_surface_state *ss, unsigned int tiling)
625 case I915_TILING_NONE:
626 ss->ss3.tiled_surface = 0;
627 ss->ss3.tile_walk = 0;
630 ss->ss3.tiled_surface = 1;
631 ss->ss3.tile_walk = I965_TILEWALK_XMAJOR;
634 ss->ss3.tiled_surface = 1;
635 ss->ss3.tile_walk = I965_TILEWALK_YMAJOR;
641 i965_render_set_surface_state(struct i965_surface_state *ss,
642 dri_bo *bo, unsigned long offset,
643 int width, int height,
644 int pitch, int format)
647 unsigned int swizzle;
649 memset(ss, 0, sizeof(*ss));
650 ss->ss0.surface_type = I965_SURFACE_2D;
651 ss->ss0.surface_format = format;
652 ss->ss0.color_blend = 1;
654 ss->ss1.base_addr = bo->offset + offset;
656 ss->ss2.width = width - 1;
657 ss->ss2.height = height - 1;
659 ss->ss3.pitch = pitch - 1;
661 dri_bo_get_tiling(bo, &tiling, &swizzle);
662 i965_render_set_surface_tiling(ss, tiling);
666 gen7_render_set_surface_tiling(struct gen7_surface_state *ss, uint32_t tiling)
669 case I915_TILING_NONE:
670 ss->ss0.tiled_surface = 0;
671 ss->ss0.tile_walk = 0;
674 ss->ss0.tiled_surface = 1;
675 ss->ss0.tile_walk = I965_TILEWALK_XMAJOR;
678 ss->ss0.tiled_surface = 1;
679 ss->ss0.tile_walk = I965_TILEWALK_YMAJOR;
685 gen7_render_set_surface_state(struct gen7_surface_state *ss,
686 dri_bo *bo, unsigned long offset,
687 int width, int height,
688 int pitch, int format)
691 unsigned int swizzle;
693 memset(ss, 0, sizeof(*ss));
695 ss->ss0.surface_type = I965_SURFACE_2D;
696 ss->ss0.surface_format = format;
698 ss->ss1.base_addr = bo->offset + offset;
700 ss->ss2.width = width - 1;
701 ss->ss2.height = height - 1;
703 ss->ss3.pitch = pitch - 1;
705 dri_bo_get_tiling(bo, &tiling, &swizzle);
706 gen7_render_set_surface_tiling(ss, tiling);
710 i965_render_src_surface_state(VADriverContextP ctx,
713 unsigned long offset,
715 int pitch, int format)
717 struct i965_driver_data *i965 = i965_driver_data(ctx);
718 struct i965_render_state *render_state = &i965->render_state;
720 dri_bo *ss_bo = render_state->wm.surface_state_binding_table_bo;
722 assert(index < MAX_RENDER_SURFACES);
724 dri_bo_map(ss_bo, 1);
725 assert(ss_bo->virtual);
726 ss = (char *)ss_bo->virtual + SURFACE_STATE_OFFSET(index);
728 if (IS_GEN7(i965->intel.device_id)) {
729 gen7_render_set_surface_state(ss,
733 dri_bo_emit_reloc(ss_bo,
734 I915_GEM_DOMAIN_SAMPLER, 0,
736 SURFACE_STATE_OFFSET(index) + offsetof(struct gen7_surface_state, ss1),
739 i965_render_set_surface_state(ss,
743 dri_bo_emit_reloc(ss_bo,
744 I915_GEM_DOMAIN_SAMPLER, 0,
746 SURFACE_STATE_OFFSET(index) + offsetof(struct i965_surface_state, ss1),
750 ((unsigned int *)((char *)ss_bo->virtual + BINDING_TABLE_OFFSET))[index] = SURFACE_STATE_OFFSET(index);
752 render_state->wm.sampler_count++;
756 i965_render_src_surfaces_state(VADriverContextP ctx,
759 struct i965_driver_data *i965 = i965_driver_data(ctx);
760 struct object_surface *obj_surface;
765 obj_surface = SURFACE(surface);
768 w = obj_surface->width;
769 h = obj_surface->height;
770 rw = obj_surface->orig_width;
771 rh = obj_surface->orig_height;
772 region = obj_surface->bo;
774 i965_render_src_surface_state(ctx, 1, region, 0, rw, rh, w, I965_SURFACEFORMAT_R8_UNORM); /* Y */
775 i965_render_src_surface_state(ctx, 2, region, 0, rw, rh, w, I965_SURFACEFORMAT_R8_UNORM);
777 if (obj_surface->fourcc == VA_FOURCC('Y','V','1','2')) {
778 int u3 = 5, u4 = 6, v5 = 3, v6 = 4;
780 i965_render_src_surface_state(ctx, u3, region, w * h, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM); /* U */
781 i965_render_src_surface_state(ctx, u4, region, w * h, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM);
782 i965_render_src_surface_state(ctx, v5, region, w * h + w * h / 4, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM); /* V */
783 i965_render_src_surface_state(ctx, v6, region, w * h + w * h / 4, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM);
784 } else if (obj_surface->fourcc == VA_FOURCC('I', 'M', 'C', '1')) {
785 int u3 = 5, u4 = 6, v5 = 3, v6 = 4;
787 i965_render_src_surface_state(ctx, u3, region, w * h, rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8_UNORM); /* U */
788 i965_render_src_surface_state(ctx, u4, region, w * h, rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8_UNORM);
789 i965_render_src_surface_state(ctx, v5, region, w * h + w * ALIGN(h / 2, 32), rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8_UNORM); /* V */
790 i965_render_src_surface_state(ctx, v6, region, w * h + w * ALIGN(h / 2, 32), rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8_UNORM);
791 } else if (obj_surface->fourcc == VA_FOURCC('I', 'M', 'C', '3')) {
792 int u3 = 3, u4 = 4, v5 = 5, v6 = 6;
794 i965_render_src_surface_state(ctx, u3, region, w * h, rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8_UNORM); /* U */
795 i965_render_src_surface_state(ctx, u4, region, w * h, rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8_UNORM);
796 i965_render_src_surface_state(ctx, v5, region, w * h + w * ALIGN(h / 2, 32), rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8_UNORM); /* V */
797 i965_render_src_surface_state(ctx, v6, region, w * h + w * ALIGN(h / 2, 32), rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8_UNORM);
798 } else if (obj_surface->fourcc == VA_FOURCC('N','V','1','2')) {
799 i965_render_src_surface_state(ctx, 3, region, w * h, rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8G8_UNORM); /* UV */
800 i965_render_src_surface_state(ctx, 4, region, w * h, rw / 2, rh / 2, w, I965_SURFACEFORMAT_R8G8_UNORM);
802 int u3 = 3, u4 = 4, v5 = 5, v6 = 6;
804 i965_render_src_surface_state(ctx, u3, region, w * h, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM); /* U */
805 i965_render_src_surface_state(ctx, u4, region, w * h, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM);
806 i965_render_src_surface_state(ctx, v5, region, w * h + w * h / 4, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM); /* V */
807 i965_render_src_surface_state(ctx, v6, region, w * h + w * h / 4, rw / 2, rh / 2, w / 2, I965_SURFACEFORMAT_R8_UNORM);
812 i965_subpic_render_src_surfaces_state(VADriverContextP ctx,
815 struct i965_driver_data *i965 = i965_driver_data(ctx);
816 struct object_surface *obj_surface = SURFACE(surface);
819 dri_bo *subpic_region;
820 struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
821 struct object_image *obj_image = IMAGE(obj_subpic->image);
823 assert(obj_surface->bo);
824 w = obj_surface->width;
825 h = obj_surface->height;
826 region = obj_surface->bo;
827 subpic_region = obj_image->bo;
828 /*subpicture surface*/
829 i965_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format);
830 i965_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format);
834 i965_render_dest_surface_state(VADriverContextP ctx, int index)
836 struct i965_driver_data *i965 = i965_driver_data(ctx);
837 struct i965_render_state *render_state = &i965->render_state;
838 struct intel_region *dest_region = render_state->draw_region;
840 dri_bo *ss_bo = render_state->wm.surface_state_binding_table_bo;
842 assert(index < MAX_RENDER_SURFACES);
844 if (dest_region->cpp == 2) {
845 format = I965_SURFACEFORMAT_B5G6R5_UNORM;
847 format = I965_SURFACEFORMAT_B8G8R8A8_UNORM;
850 dri_bo_map(ss_bo, 1);
851 assert(ss_bo->virtual);
852 ss = (char *)ss_bo->virtual + SURFACE_STATE_OFFSET(index);
854 if (IS_GEN7(i965->intel.device_id)) {
855 gen7_render_set_surface_state(ss,
857 dest_region->width, dest_region->height,
858 dest_region->pitch, format);
859 dri_bo_emit_reloc(ss_bo,
860 I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
862 SURFACE_STATE_OFFSET(index) + offsetof(struct gen7_surface_state, ss1),
865 i965_render_set_surface_state(ss,
867 dest_region->width, dest_region->height,
868 dest_region->pitch, format);
869 dri_bo_emit_reloc(ss_bo,
870 I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
872 SURFACE_STATE_OFFSET(index) + offsetof(struct i965_surface_state, ss1),
876 ((unsigned int *)((char *)ss_bo->virtual + BINDING_TABLE_OFFSET))[index] = SURFACE_STATE_OFFSET(index);
881 i965_subpic_render_upload_vertex(VADriverContextP ctx,
883 const VARectangle *output_rect)
885 struct i965_driver_data *i965 = i965_driver_data(ctx);
886 struct i965_render_state *render_state = &i965->render_state;
887 struct object_surface *obj_surface = SURFACE(surface);
888 struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
889 VARectangle dst_rect;
890 float *vb, tx1, tx2, ty1, ty2, x1, x2, y1, y2;
893 if (obj_subpic->flags & VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD)
894 dst_rect = obj_subpic->dst_rect;
896 const float sx = (float)output_rect->width / obj_surface->orig_width;
897 const float sy = (float)output_rect->height / obj_surface->orig_height;
898 dst_rect.x = output_rect->x + sx * obj_subpic->dst_rect.x;
899 dst_rect.y = output_rect->y + sy * obj_subpic->dst_rect.y;
900 dst_rect.width = sx * obj_subpic->dst_rect.width;
901 dst_rect.height = sy * obj_subpic->dst_rect.height;
904 dri_bo_map(render_state->vb.vertex_buffer, 1);
905 assert(render_state->vb.vertex_buffer->virtual);
906 vb = render_state->vb.vertex_buffer->virtual;
908 tx1 = (float)obj_subpic->src_rect.x / obj_subpic->width;
909 ty1 = (float)obj_subpic->src_rect.y / obj_subpic->height;
910 tx2 = (float)(obj_subpic->src_rect.x + obj_subpic->src_rect.width) / obj_subpic->width;
911 ty2 = (float)(obj_subpic->src_rect.y + obj_subpic->src_rect.height) / obj_subpic->height;
913 x1 = (float)dst_rect.x;
914 y1 = (float)dst_rect.y;
915 x2 = (float)(dst_rect.x + dst_rect.width);
916 y2 = (float)(dst_rect.y + dst_rect.height);
932 dri_bo_unmap(render_state->vb.vertex_buffer);
936 i965_render_upload_vertex(
937 VADriverContextP ctx,
939 const VARectangle *src_rect,
940 const VARectangle *dst_rect
943 struct i965_driver_data *i965 = i965_driver_data(ctx);
944 struct i965_render_state *render_state = &i965->render_state;
945 struct intel_region *dest_region = render_state->draw_region;
946 struct object_surface *obj_surface;
949 float u1, v1, u2, v2;
950 int i, width, height;
951 int box_x1 = dest_region->x + dst_rect->x;
952 int box_y1 = dest_region->y + dst_rect->y;
953 int box_x2 = box_x1 + dst_rect->width;
954 int box_y2 = box_y1 + dst_rect->height;
956 obj_surface = SURFACE(surface);
958 width = obj_surface->orig_width;
959 height = obj_surface->orig_height;
961 u1 = (float)src_rect->x / width;
962 v1 = (float)src_rect->y / height;
963 u2 = (float)(src_rect->x + src_rect->width) / width;
964 v2 = (float)(src_rect->y + src_rect->height) / height;
966 dri_bo_map(render_state->vb.vertex_buffer, 1);
967 assert(render_state->vb.vertex_buffer->virtual);
968 vb = render_state->vb.vertex_buffer->virtual;
973 vb[i++] = (float)box_x2;
974 vb[i++] = (float)box_y2;
978 vb[i++] = (float)box_x1;
979 vb[i++] = (float)box_y2;
983 vb[i++] = (float)box_x1;
984 vb[i++] = (float)box_y1;
986 dri_bo_unmap(render_state->vb.vertex_buffer);
990 i965_render_upload_constants(VADriverContextP ctx,
993 struct i965_driver_data *i965 = i965_driver_data(ctx);
994 struct i965_render_state *render_state = &i965->render_state;
995 unsigned short *constant_buffer;
996 struct object_surface *obj_surface = SURFACE(surface);
998 dri_bo_map(render_state->curbe.bo, 1);
999 assert(render_state->curbe.bo->virtual);
1000 constant_buffer = render_state->curbe.bo->virtual;
1002 if (obj_surface->fourcc == VA_FOURCC('N','V','1','2'))
1003 *constant_buffer = 1;
1005 *constant_buffer = 0;
1007 dri_bo_unmap(render_state->curbe.bo);
1011 i965_surface_render_state_setup(
1012 VADriverContextP ctx,
1013 VASurfaceID surface,
1014 const VARectangle *src_rect,
1015 const VARectangle *dst_rect
1018 i965_render_vs_unit(ctx);
1019 i965_render_sf_unit(ctx);
1020 i965_render_dest_surface_state(ctx, 0);
1021 i965_render_src_surfaces_state(ctx, surface);
1022 i965_render_sampler(ctx);
1023 i965_render_wm_unit(ctx);
1024 i965_render_cc_viewport(ctx);
1025 i965_render_cc_unit(ctx);
1026 i965_render_upload_vertex(ctx, surface, src_rect, dst_rect);
1027 i965_render_upload_constants(ctx, surface);
1030 i965_subpic_render_state_setup(
1031 VADriverContextP ctx,
1032 VASurfaceID surface,
1033 const VARectangle *src_rect,
1034 const VARectangle *dst_rect
1037 i965_render_vs_unit(ctx);
1038 i965_render_sf_unit(ctx);
1039 i965_render_dest_surface_state(ctx, 0);
1040 i965_subpic_render_src_surfaces_state(ctx, surface);
1041 i965_render_sampler(ctx);
1042 i965_subpic_render_wm_unit(ctx);
1043 i965_render_cc_viewport(ctx);
1044 i965_subpic_render_cc_unit(ctx);
1045 i965_subpic_render_upload_vertex(ctx, surface, dst_rect);
1050 i965_render_pipeline_select(VADriverContextP ctx)
1052 struct i965_driver_data *i965 = i965_driver_data(ctx);
1053 struct intel_batchbuffer *batch = i965->batch;
1055 BEGIN_BATCH(batch, 1);
1056 OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_3D);
1057 ADVANCE_BATCH(batch);
1061 i965_render_state_sip(VADriverContextP ctx)
1063 struct i965_driver_data *i965 = i965_driver_data(ctx);
1064 struct intel_batchbuffer *batch = i965->batch;
1066 BEGIN_BATCH(batch, 2);
1067 OUT_BATCH(batch, CMD_STATE_SIP | 0);
1068 OUT_BATCH(batch, 0);
1069 ADVANCE_BATCH(batch);
1073 i965_render_state_base_address(VADriverContextP ctx)
1075 struct i965_driver_data *i965 = i965_driver_data(ctx);
1076 struct intel_batchbuffer *batch = i965->batch;
1077 struct i965_render_state *render_state = &i965->render_state;
1079 if (IS_IRONLAKE(i965->intel.device_id)) {
1080 BEGIN_BATCH(batch, 8);
1081 OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | 6);
1082 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
1083 OUT_RELOC(batch, render_state->wm.surface_state_binding_table_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);
1084 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
1085 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
1086 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
1087 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
1088 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
1089 ADVANCE_BATCH(batch);
1091 BEGIN_BATCH(batch, 6);
1092 OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | 4);
1093 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
1094 OUT_RELOC(batch, render_state->wm.surface_state_binding_table_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);
1095 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
1096 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
1097 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
1098 ADVANCE_BATCH(batch);
1103 i965_render_binding_table_pointers(VADriverContextP ctx)
1105 struct i965_driver_data *i965 = i965_driver_data(ctx);
1106 struct intel_batchbuffer *batch = i965->batch;
1108 BEGIN_BATCH(batch, 6);
1109 OUT_BATCH(batch, CMD_BINDING_TABLE_POINTERS | 4);
1110 OUT_BATCH(batch, 0); /* vs */
1111 OUT_BATCH(batch, 0); /* gs */
1112 OUT_BATCH(batch, 0); /* clip */
1113 OUT_BATCH(batch, 0); /* sf */
1114 OUT_BATCH(batch, BINDING_TABLE_OFFSET);
1115 ADVANCE_BATCH(batch);
1119 i965_render_constant_color(VADriverContextP ctx)
1121 struct i965_driver_data *i965 = i965_driver_data(ctx);
1122 struct intel_batchbuffer *batch = i965->batch;
1124 BEGIN_BATCH(batch, 5);
1125 OUT_BATCH(batch, CMD_CONSTANT_COLOR | 3);
1126 OUT_BATCH(batch, float_to_uint(1.0));
1127 OUT_BATCH(batch, float_to_uint(0.0));
1128 OUT_BATCH(batch, float_to_uint(1.0));
1129 OUT_BATCH(batch, float_to_uint(1.0));
1130 ADVANCE_BATCH(batch);
1134 i965_render_pipelined_pointers(VADriverContextP ctx)
1136 struct i965_driver_data *i965 = i965_driver_data(ctx);
1137 struct intel_batchbuffer *batch = i965->batch;
1138 struct i965_render_state *render_state = &i965->render_state;
1140 BEGIN_BATCH(batch, 7);
1141 OUT_BATCH(batch, CMD_PIPELINED_POINTERS | 5);
1142 OUT_RELOC(batch, render_state->vs.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
1143 OUT_BATCH(batch, 0); /* disable GS */
1144 OUT_BATCH(batch, 0); /* disable CLIP */
1145 OUT_RELOC(batch, render_state->sf.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
1146 OUT_RELOC(batch, render_state->wm.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
1147 OUT_RELOC(batch, render_state->cc.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
1148 ADVANCE_BATCH(batch);
1152 i965_render_urb_layout(VADriverContextP ctx)
1154 struct i965_driver_data *i965 = i965_driver_data(ctx);
1155 struct intel_batchbuffer *batch = i965->batch;
1156 int urb_vs_start, urb_vs_size;
1157 int urb_gs_start, urb_gs_size;
1158 int urb_clip_start, urb_clip_size;
1159 int urb_sf_start, urb_sf_size;
1160 int urb_cs_start, urb_cs_size;
1163 urb_vs_size = URB_VS_ENTRIES * URB_VS_ENTRY_SIZE;
1164 urb_gs_start = urb_vs_start + urb_vs_size;
1165 urb_gs_size = URB_GS_ENTRIES * URB_GS_ENTRY_SIZE;
1166 urb_clip_start = urb_gs_start + urb_gs_size;
1167 urb_clip_size = URB_CLIP_ENTRIES * URB_CLIP_ENTRY_SIZE;
1168 urb_sf_start = urb_clip_start + urb_clip_size;
1169 urb_sf_size = URB_SF_ENTRIES * URB_SF_ENTRY_SIZE;
1170 urb_cs_start = urb_sf_start + urb_sf_size;
1171 urb_cs_size = URB_CS_ENTRIES * URB_CS_ENTRY_SIZE;
1173 BEGIN_BATCH(batch, 3);
1183 ((urb_clip_start + urb_clip_size) << UF1_CLIP_FENCE_SHIFT) |
1184 ((urb_gs_start + urb_gs_size) << UF1_GS_FENCE_SHIFT) |
1185 ((urb_vs_start + urb_vs_size) << UF1_VS_FENCE_SHIFT));
1187 ((urb_cs_start + urb_cs_size) << UF2_CS_FENCE_SHIFT) |
1188 ((urb_sf_start + urb_sf_size) << UF2_SF_FENCE_SHIFT));
1189 ADVANCE_BATCH(batch);
1193 i965_render_cs_urb_layout(VADriverContextP ctx)
1195 struct i965_driver_data *i965 = i965_driver_data(ctx);
1196 struct intel_batchbuffer *batch = i965->batch;
1198 BEGIN_BATCH(batch, 2);
1199 OUT_BATCH(batch, CMD_CS_URB_STATE | 0);
1201 ((URB_CS_ENTRY_SIZE - 1) << 4) | /* URB Entry Allocation Size */
1202 (URB_CS_ENTRIES << 0)); /* Number of URB Entries */
1203 ADVANCE_BATCH(batch);
1207 i965_render_constant_buffer(VADriverContextP ctx)
1209 struct i965_driver_data *i965 = i965_driver_data(ctx);
1210 struct intel_batchbuffer *batch = i965->batch;
1211 struct i965_render_state *render_state = &i965->render_state;
1213 BEGIN_BATCH(batch, 2);
1214 OUT_BATCH(batch, CMD_CONSTANT_BUFFER | (1 << 8) | (2 - 2));
1215 OUT_RELOC(batch, render_state->curbe.bo,
1216 I915_GEM_DOMAIN_INSTRUCTION, 0,
1217 URB_CS_ENTRY_SIZE - 1);
1218 ADVANCE_BATCH(batch);
1222 i965_render_drawing_rectangle(VADriverContextP ctx)
1224 struct i965_driver_data *i965 = i965_driver_data(ctx);
1225 struct intel_batchbuffer *batch = i965->batch;
1226 struct i965_render_state *render_state = &i965->render_state;
1227 struct intel_region *dest_region = render_state->draw_region;
1229 BEGIN_BATCH(batch, 4);
1230 OUT_BATCH(batch, CMD_DRAWING_RECTANGLE | 2);
1231 OUT_BATCH(batch, 0x00000000);
1232 OUT_BATCH(batch, (dest_region->width - 1) | (dest_region->height - 1) << 16);
1233 OUT_BATCH(batch, 0x00000000);
1234 ADVANCE_BATCH(batch);
1238 i965_render_vertex_elements(VADriverContextP ctx)
1240 struct i965_driver_data *i965 = i965_driver_data(ctx);
1241 struct intel_batchbuffer *batch = i965->batch;
1243 if (IS_IRONLAKE(i965->intel.device_id)) {
1244 BEGIN_BATCH(batch, 5);
1245 OUT_BATCH(batch, CMD_VERTEX_ELEMENTS | 3);
1246 /* offset 0: X,Y -> {X, Y, 1.0, 1.0} */
1247 OUT_BATCH(batch, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) |
1249 (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) |
1250 (0 << VE0_OFFSET_SHIFT));
1251 OUT_BATCH(batch, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) |
1252 (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) |
1253 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) |
1254 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT));
1255 /* offset 8: S0, T0 -> {S0, T0, 1.0, 1.0} */
1256 OUT_BATCH(batch, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) |
1258 (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) |
1259 (8 << VE0_OFFSET_SHIFT));
1260 OUT_BATCH(batch, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) |
1261 (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) |
1262 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) |
1263 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT));
1264 ADVANCE_BATCH(batch);
1266 BEGIN_BATCH(batch, 5);
1267 OUT_BATCH(batch, CMD_VERTEX_ELEMENTS | 3);
1268 /* offset 0: X,Y -> {X, Y, 1.0, 1.0} */
1269 OUT_BATCH(batch, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) |
1271 (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) |
1272 (0 << VE0_OFFSET_SHIFT));
1273 OUT_BATCH(batch, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) |
1274 (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) |
1275 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) |
1276 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) |
1277 (0 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT));
1278 /* offset 8: S0, T0 -> {S0, T0, 1.0, 1.0} */
1279 OUT_BATCH(batch, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) |
1281 (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) |
1282 (8 << VE0_OFFSET_SHIFT));
1283 OUT_BATCH(batch, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) |
1284 (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) |
1285 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) |
1286 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) |
1287 (4 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT));
1288 ADVANCE_BATCH(batch);
1293 i965_render_upload_image_palette(
1294 VADriverContextP ctx,
1299 struct i965_driver_data *i965 = i965_driver_data(ctx);
1300 struct intel_batchbuffer *batch = i965->batch;
1303 struct object_image *obj_image = IMAGE(image_id);
1306 if (obj_image->image.num_palette_entries == 0)
1309 BEGIN_BATCH(batch, 1 + obj_image->image.num_palette_entries);
1310 OUT_BATCH(batch, CMD_SAMPLER_PALETTE_LOAD | (obj_image->image.num_palette_entries - 1));
1312 //int32_t out[16]; //0-23:color 23-31:alpha
1313 for (i = 0; i < obj_image->image.num_palette_entries; i++)
1314 OUT_BATCH(batch, (alpha << 24) | obj_image->palette[i]);
1315 ADVANCE_BATCH(batch);
1319 i965_render_startup(VADriverContextP ctx)
1321 struct i965_driver_data *i965 = i965_driver_data(ctx);
1322 struct intel_batchbuffer *batch = i965->batch;
1323 struct i965_render_state *render_state = &i965->render_state;
1325 BEGIN_BATCH(batch, 11);
1326 OUT_BATCH(batch, CMD_VERTEX_BUFFERS | 3);
1328 (0 << VB0_BUFFER_INDEX_SHIFT) |
1330 ((4 * 4) << VB0_BUFFER_PITCH_SHIFT));
1331 OUT_RELOC(batch, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 0);
1333 if (IS_IRONLAKE(i965->intel.device_id))
1334 OUT_RELOC(batch, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 12 * 4);
1336 OUT_BATCH(batch, 3);
1338 OUT_BATCH(batch, 0);
1342 _3DPRIMITIVE_VERTEX_SEQUENTIAL |
1343 (_3DPRIM_RECTLIST << _3DPRIMITIVE_TOPOLOGY_SHIFT) |
1346 OUT_BATCH(batch, 3); /* vertex count per instance */
1347 OUT_BATCH(batch, 0); /* start vertex offset */
1348 OUT_BATCH(batch, 1); /* single instance */
1349 OUT_BATCH(batch, 0); /* start instance location */
1350 OUT_BATCH(batch, 0); /* index buffer offset, ignored */
1351 ADVANCE_BATCH(batch);
1355 i965_clear_dest_region(VADriverContextP ctx)
1357 struct i965_driver_data *i965 = i965_driver_data(ctx);
1358 struct intel_batchbuffer *batch = i965->batch;
1359 struct i965_render_state *render_state = &i965->render_state;
1360 struct intel_region *dest_region = render_state->draw_region;
1361 unsigned int blt_cmd, br13;
1364 blt_cmd = XY_COLOR_BLT_CMD;
1366 pitch = dest_region->pitch;
1368 if (dest_region->cpp == 4) {
1370 blt_cmd |= (XY_COLOR_BLT_WRITE_RGB | XY_COLOR_BLT_WRITE_ALPHA);
1372 assert(dest_region->cpp == 2);
1376 if (dest_region->tiling != I915_TILING_NONE) {
1377 blt_cmd |= XY_COLOR_BLT_DST_TILED;
1383 if (IS_GEN6(i965->intel.device_id) ||
1384 IS_GEN7(i965->intel.device_id)) {
1385 intel_batchbuffer_start_atomic_blt(batch, 24);
1386 BEGIN_BLT_BATCH(batch, 6);
1388 intel_batchbuffer_start_atomic(batch, 24);
1389 BEGIN_BATCH(batch, 6);
1392 OUT_BATCH(batch, blt_cmd);
1393 OUT_BATCH(batch, br13);
1394 OUT_BATCH(batch, (dest_region->y << 16) | (dest_region->x));
1395 OUT_BATCH(batch, ((dest_region->y + dest_region->height) << 16) |
1396 (dest_region->x + dest_region->width));
1397 OUT_RELOC(batch, dest_region->bo,
1398 I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
1400 OUT_BATCH(batch, 0x0);
1401 ADVANCE_BATCH(batch);
1402 intel_batchbuffer_end_atomic(batch);
1406 i965_surface_render_pipeline_setup(VADriverContextP ctx)
1408 struct i965_driver_data *i965 = i965_driver_data(ctx);
1409 struct intel_batchbuffer *batch = i965->batch;
1411 i965_clear_dest_region(ctx);
1412 intel_batchbuffer_start_atomic(batch, 0x1000);
1413 intel_batchbuffer_emit_mi_flush(batch);
1414 i965_render_pipeline_select(ctx);
1415 i965_render_state_sip(ctx);
1416 i965_render_state_base_address(ctx);
1417 i965_render_binding_table_pointers(ctx);
1418 i965_render_constant_color(ctx);
1419 i965_render_pipelined_pointers(ctx);
1420 i965_render_urb_layout(ctx);
1421 i965_render_cs_urb_layout(ctx);
1422 i965_render_constant_buffer(ctx);
1423 i965_render_drawing_rectangle(ctx);
1424 i965_render_vertex_elements(ctx);
1425 i965_render_startup(ctx);
1426 intel_batchbuffer_end_atomic(batch);
1430 i965_subpic_render_pipeline_setup(VADriverContextP ctx)
1432 struct i965_driver_data *i965 = i965_driver_data(ctx);
1433 struct intel_batchbuffer *batch = i965->batch;
1435 intel_batchbuffer_start_atomic(batch, 0x1000);
1436 intel_batchbuffer_emit_mi_flush(batch);
1437 i965_render_pipeline_select(ctx);
1438 i965_render_state_sip(ctx);
1439 i965_render_state_base_address(ctx);
1440 i965_render_binding_table_pointers(ctx);
1441 i965_render_constant_color(ctx);
1442 i965_render_pipelined_pointers(ctx);
1443 i965_render_urb_layout(ctx);
1444 i965_render_cs_urb_layout(ctx);
1445 i965_render_drawing_rectangle(ctx);
1446 i965_render_vertex_elements(ctx);
1447 i965_render_startup(ctx);
1448 intel_batchbuffer_end_atomic(batch);
1453 i965_render_initialize(VADriverContextP ctx)
1455 struct i965_driver_data *i965 = i965_driver_data(ctx);
1456 struct i965_render_state *render_state = &i965->render_state;
1460 dri_bo_unreference(render_state->vb.vertex_buffer);
1461 bo = dri_bo_alloc(i965->intel.bufmgr,
1466 render_state->vb.vertex_buffer = bo;
1469 dri_bo_unreference(render_state->vs.state);
1470 bo = dri_bo_alloc(i965->intel.bufmgr,
1472 sizeof(struct i965_vs_unit_state),
1475 render_state->vs.state = bo;
1480 dri_bo_unreference(render_state->sf.state);
1481 bo = dri_bo_alloc(i965->intel.bufmgr,
1483 sizeof(struct i965_sf_unit_state),
1486 render_state->sf.state = bo;
1489 dri_bo_unreference(render_state->wm.surface_state_binding_table_bo);
1490 bo = dri_bo_alloc(i965->intel.bufmgr,
1491 "surface state & binding table",
1492 (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_RENDER_SURFACES,
1495 render_state->wm.surface_state_binding_table_bo = bo;
1497 dri_bo_unreference(render_state->wm.sampler);
1498 bo = dri_bo_alloc(i965->intel.bufmgr,
1500 MAX_SAMPLERS * sizeof(struct i965_sampler_state),
1503 render_state->wm.sampler = bo;
1504 render_state->wm.sampler_count = 0;
1506 dri_bo_unreference(render_state->wm.state);
1507 bo = dri_bo_alloc(i965->intel.bufmgr,
1509 sizeof(struct i965_wm_unit_state),
1512 render_state->wm.state = bo;
1514 /* COLOR CALCULATOR */
1515 dri_bo_unreference(render_state->cc.state);
1516 bo = dri_bo_alloc(i965->intel.bufmgr,
1518 sizeof(struct i965_cc_unit_state),
1521 render_state->cc.state = bo;
1523 dri_bo_unreference(render_state->cc.viewport);
1524 bo = dri_bo_alloc(i965->intel.bufmgr,
1526 sizeof(struct i965_cc_viewport),
1529 render_state->cc.viewport = bo;
1533 i965_render_put_surface(
1534 VADriverContextP ctx,
1535 VASurfaceID surface,
1536 const VARectangle *src_rect,
1537 const VARectangle *dst_rect,
1541 struct i965_driver_data *i965 = i965_driver_data(ctx);
1542 struct intel_batchbuffer *batch = i965->batch;
1544 i965_render_initialize(ctx);
1545 i965_surface_render_state_setup(ctx, surface, src_rect, dst_rect);
1546 i965_surface_render_pipeline_setup(ctx);
1547 intel_batchbuffer_flush(batch);
1551 i965_render_put_subpicture(
1552 VADriverContextP ctx,
1553 VASurfaceID surface,
1554 const VARectangle *src_rect,
1555 const VARectangle *dst_rect
1558 struct i965_driver_data *i965 = i965_driver_data(ctx);
1559 struct intel_batchbuffer *batch = i965->batch;
1560 struct object_surface *obj_surface = SURFACE(surface);
1561 struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
1565 i965_render_initialize(ctx);
1566 i965_subpic_render_state_setup(ctx, surface, src_rect, dst_rect);
1567 i965_subpic_render_pipeline_setup(ctx);
1568 i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff);
1569 intel_batchbuffer_flush(batch);
1576 gen6_render_initialize(VADriverContextP ctx)
1578 struct i965_driver_data *i965 = i965_driver_data(ctx);
1579 struct i965_render_state *render_state = &i965->render_state;
1583 dri_bo_unreference(render_state->vb.vertex_buffer);
1584 bo = dri_bo_alloc(i965->intel.bufmgr,
1589 render_state->vb.vertex_buffer = bo;
1592 dri_bo_unreference(render_state->wm.surface_state_binding_table_bo);
1593 bo = dri_bo_alloc(i965->intel.bufmgr,
1594 "surface state & binding table",
1595 (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_RENDER_SURFACES,
1598 render_state->wm.surface_state_binding_table_bo = bo;
1600 dri_bo_unreference(render_state->wm.sampler);
1601 bo = dri_bo_alloc(i965->intel.bufmgr,
1603 MAX_SAMPLERS * sizeof(struct i965_sampler_state),
1606 render_state->wm.sampler = bo;
1607 render_state->wm.sampler_count = 0;
1609 /* COLOR CALCULATOR */
1610 dri_bo_unreference(render_state->cc.state);
1611 bo = dri_bo_alloc(i965->intel.bufmgr,
1613 sizeof(struct gen6_color_calc_state),
1616 render_state->cc.state = bo;
1619 dri_bo_unreference(render_state->cc.viewport);
1620 bo = dri_bo_alloc(i965->intel.bufmgr,
1622 sizeof(struct i965_cc_viewport),
1625 render_state->cc.viewport = bo;
1628 dri_bo_unreference(render_state->cc.blend);
1629 bo = dri_bo_alloc(i965->intel.bufmgr,
1631 sizeof(struct gen6_blend_state),
1634 render_state->cc.blend = bo;
1636 /* DEPTH & STENCIL STATE */
1637 dri_bo_unreference(render_state->cc.depth_stencil);
1638 bo = dri_bo_alloc(i965->intel.bufmgr,
1639 "depth & stencil state",
1640 sizeof(struct gen6_depth_stencil_state),
1643 render_state->cc.depth_stencil = bo;
1647 gen6_render_color_calc_state(VADriverContextP ctx)
1649 struct i965_driver_data *i965 = i965_driver_data(ctx);
1650 struct i965_render_state *render_state = &i965->render_state;
1651 struct gen6_color_calc_state *color_calc_state;
1653 dri_bo_map(render_state->cc.state, 1);
1654 assert(render_state->cc.state->virtual);
1655 color_calc_state = render_state->cc.state->virtual;
1656 memset(color_calc_state, 0, sizeof(*color_calc_state));
1657 color_calc_state->constant_r = 1.0;
1658 color_calc_state->constant_g = 0.0;
1659 color_calc_state->constant_b = 1.0;
1660 color_calc_state->constant_a = 1.0;
1661 dri_bo_unmap(render_state->cc.state);
1665 gen6_render_blend_state(VADriverContextP ctx)
1667 struct i965_driver_data *i965 = i965_driver_data(ctx);
1668 struct i965_render_state *render_state = &i965->render_state;
1669 struct gen6_blend_state *blend_state;
1671 dri_bo_map(render_state->cc.blend, 1);
1672 assert(render_state->cc.blend->virtual);
1673 blend_state = render_state->cc.blend->virtual;
1674 memset(blend_state, 0, sizeof(*blend_state));
1675 blend_state->blend1.logic_op_enable = 1;
1676 blend_state->blend1.logic_op_func = 0xc;
1677 dri_bo_unmap(render_state->cc.blend);
1681 gen6_render_depth_stencil_state(VADriverContextP ctx)
1683 struct i965_driver_data *i965 = i965_driver_data(ctx);
1684 struct i965_render_state *render_state = &i965->render_state;
1685 struct gen6_depth_stencil_state *depth_stencil_state;
1687 dri_bo_map(render_state->cc.depth_stencil, 1);
1688 assert(render_state->cc.depth_stencil->virtual);
1689 depth_stencil_state = render_state->cc.depth_stencil->virtual;
1690 memset(depth_stencil_state, 0, sizeof(*depth_stencil_state));
1691 dri_bo_unmap(render_state->cc.depth_stencil);
1695 gen6_render_setup_states(
1696 VADriverContextP ctx,
1697 VASurfaceID surface,
1698 const VARectangle *src_rect,
1699 const VARectangle *dst_rect
1702 i965_render_dest_surface_state(ctx, 0);
1703 i965_render_src_surfaces_state(ctx, surface);
1704 i965_render_sampler(ctx);
1705 i965_render_cc_viewport(ctx);
1706 gen6_render_color_calc_state(ctx);
1707 gen6_render_blend_state(ctx);
1708 gen6_render_depth_stencil_state(ctx);
1709 i965_render_upload_constants(ctx, surface);
1710 i965_render_upload_vertex(ctx, surface, src_rect, dst_rect);
1714 gen6_emit_invarient_states(VADriverContextP ctx)
1716 struct i965_driver_data *i965 = i965_driver_data(ctx);
1717 struct intel_batchbuffer *batch = i965->batch;
1719 OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_3D);
1721 OUT_BATCH(batch, GEN6_3DSTATE_MULTISAMPLE | (3 - 2));
1722 OUT_BATCH(batch, GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_CENTER |
1723 GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_1); /* 1 sample/pixel */
1724 OUT_BATCH(batch, 0);
1726 OUT_BATCH(batch, GEN6_3DSTATE_SAMPLE_MASK | (2 - 2));
1727 OUT_BATCH(batch, 1);
1729 /* Set system instruction pointer */
1730 OUT_BATCH(batch, CMD_STATE_SIP | 0);
1731 OUT_BATCH(batch, 0);
1735 gen6_emit_state_base_address(VADriverContextP ctx)
1737 struct i965_driver_data *i965 = i965_driver_data(ctx);
1738 struct intel_batchbuffer *batch = i965->batch;
1739 struct i965_render_state *render_state = &i965->render_state;
1741 OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | (10 - 2));
1742 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* General state base address */
1743 OUT_RELOC(batch, render_state->wm.surface_state_binding_table_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY); /* Surface state base address */
1744 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Dynamic state base address */
1745 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Indirect object base address */
1746 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Instruction base address */
1747 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* General state upper bound */
1748 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Dynamic state upper bound */
1749 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Indirect object upper bound */
1750 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Instruction access upper bound */
1754 gen6_emit_viewport_state_pointers(VADriverContextP ctx)
1756 struct i965_driver_data *i965 = i965_driver_data(ctx);
1757 struct intel_batchbuffer *batch = i965->batch;
1758 struct i965_render_state *render_state = &i965->render_state;
1760 OUT_BATCH(batch, GEN6_3DSTATE_VIEWPORT_STATE_POINTERS |
1761 GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CC |
1763 OUT_BATCH(batch, 0);
1764 OUT_BATCH(batch, 0);
1765 OUT_RELOC(batch, render_state->cc.viewport, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
1769 gen6_emit_urb(VADriverContextP ctx)
1771 struct i965_driver_data *i965 = i965_driver_data(ctx);
1772 struct intel_batchbuffer *batch = i965->batch;
1774 OUT_BATCH(batch, GEN6_3DSTATE_URB | (3 - 2));
1775 OUT_BATCH(batch, ((1 - 1) << GEN6_3DSTATE_URB_VS_SIZE_SHIFT) |
1776 (24 << GEN6_3DSTATE_URB_VS_ENTRIES_SHIFT)); /* at least 24 on GEN6 */
1777 OUT_BATCH(batch, (0 << GEN6_3DSTATE_URB_GS_SIZE_SHIFT) |
1778 (0 << GEN6_3DSTATE_URB_GS_ENTRIES_SHIFT)); /* no GS thread */
1782 gen6_emit_cc_state_pointers(VADriverContextP ctx)
1784 struct i965_driver_data *i965 = i965_driver_data(ctx);
1785 struct intel_batchbuffer *batch = i965->batch;
1786 struct i965_render_state *render_state = &i965->render_state;
1788 OUT_BATCH(batch, GEN6_3DSTATE_CC_STATE_POINTERS | (4 - 2));
1789 OUT_RELOC(batch, render_state->cc.blend, I915_GEM_DOMAIN_INSTRUCTION, 0, 1);
1790 OUT_RELOC(batch, render_state->cc.depth_stencil, I915_GEM_DOMAIN_INSTRUCTION, 0, 1);
1791 OUT_RELOC(batch, render_state->cc.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 1);
1795 gen6_emit_sampler_state_pointers(VADriverContextP ctx)
1797 struct i965_driver_data *i965 = i965_driver_data(ctx);
1798 struct intel_batchbuffer *batch = i965->batch;
1799 struct i965_render_state *render_state = &i965->render_state;
1801 OUT_BATCH(batch, GEN6_3DSTATE_SAMPLER_STATE_POINTERS |
1802 GEN6_3DSTATE_SAMPLER_STATE_MODIFY_PS |
1804 OUT_BATCH(batch, 0); /* VS */
1805 OUT_BATCH(batch, 0); /* GS */
1806 OUT_RELOC(batch,render_state->wm.sampler, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
1810 gen6_emit_binding_table(VADriverContextP ctx)
1812 struct i965_driver_data *i965 = i965_driver_data(ctx);
1813 struct intel_batchbuffer *batch = i965->batch;
1815 /* Binding table pointers */
1816 OUT_BATCH(batch, CMD_BINDING_TABLE_POINTERS |
1817 GEN6_BINDING_TABLE_MODIFY_PS |
1819 OUT_BATCH(batch, 0); /* vs */
1820 OUT_BATCH(batch, 0); /* gs */
1821 /* Only the PS uses the binding table */
1822 OUT_BATCH(batch, BINDING_TABLE_OFFSET);
1826 gen6_emit_depth_buffer_state(VADriverContextP ctx)
1828 struct i965_driver_data *i965 = i965_driver_data(ctx);
1829 struct intel_batchbuffer *batch = i965->batch;
1831 OUT_BATCH(batch, CMD_DEPTH_BUFFER | (7 - 2));
1832 OUT_BATCH(batch, (I965_SURFACE_NULL << CMD_DEPTH_BUFFER_TYPE_SHIFT) |
1833 (I965_DEPTHFORMAT_D32_FLOAT << CMD_DEPTH_BUFFER_FORMAT_SHIFT));
1834 OUT_BATCH(batch, 0);
1835 OUT_BATCH(batch, 0);
1836 OUT_BATCH(batch, 0);
1837 OUT_BATCH(batch, 0);
1838 OUT_BATCH(batch, 0);
1840 OUT_BATCH(batch, CMD_CLEAR_PARAMS | (2 - 2));
1841 OUT_BATCH(batch, 0);
1845 gen6_emit_drawing_rectangle(VADriverContextP ctx)
1847 i965_render_drawing_rectangle(ctx);
1851 gen6_emit_vs_state(VADriverContextP ctx)
1853 struct i965_driver_data *i965 = i965_driver_data(ctx);
1854 struct intel_batchbuffer *batch = i965->batch;
1856 /* disable VS constant buffer */
1857 OUT_BATCH(batch, GEN6_3DSTATE_CONSTANT_VS | (5 - 2));
1858 OUT_BATCH(batch, 0);
1859 OUT_BATCH(batch, 0);
1860 OUT_BATCH(batch, 0);
1861 OUT_BATCH(batch, 0);
1863 OUT_BATCH(batch, GEN6_3DSTATE_VS | (6 - 2));
1864 OUT_BATCH(batch, 0); /* without VS kernel */
1865 OUT_BATCH(batch, 0);
1866 OUT_BATCH(batch, 0);
1867 OUT_BATCH(batch, 0);
1868 OUT_BATCH(batch, 0); /* pass-through */
1872 gen6_emit_gs_state(VADriverContextP ctx)
1874 struct i965_driver_data *i965 = i965_driver_data(ctx);
1875 struct intel_batchbuffer *batch = i965->batch;
1877 /* disable GS constant buffer */
1878 OUT_BATCH(batch, GEN6_3DSTATE_CONSTANT_GS | (5 - 2));
1879 OUT_BATCH(batch, 0);
1880 OUT_BATCH(batch, 0);
1881 OUT_BATCH(batch, 0);
1882 OUT_BATCH(batch, 0);
1884 OUT_BATCH(batch, GEN6_3DSTATE_GS | (7 - 2));
1885 OUT_BATCH(batch, 0); /* without GS kernel */
1886 OUT_BATCH(batch, 0);
1887 OUT_BATCH(batch, 0);
1888 OUT_BATCH(batch, 0);
1889 OUT_BATCH(batch, 0);
1890 OUT_BATCH(batch, 0); /* pass-through */
1894 gen6_emit_clip_state(VADriverContextP ctx)
1896 struct i965_driver_data *i965 = i965_driver_data(ctx);
1897 struct intel_batchbuffer *batch = i965->batch;
1899 OUT_BATCH(batch, GEN6_3DSTATE_CLIP | (4 - 2));
1900 OUT_BATCH(batch, 0);
1901 OUT_BATCH(batch, 0); /* pass-through */
1902 OUT_BATCH(batch, 0);
1906 gen6_emit_sf_state(VADriverContextP ctx)
1908 struct i965_driver_data *i965 = i965_driver_data(ctx);
1909 struct intel_batchbuffer *batch = i965->batch;
1911 OUT_BATCH(batch, GEN6_3DSTATE_SF | (20 - 2));
1912 OUT_BATCH(batch, (1 << GEN6_3DSTATE_SF_NUM_OUTPUTS_SHIFT) |
1913 (1 << GEN6_3DSTATE_SF_URB_ENTRY_READ_LENGTH_SHIFT) |
1914 (0 << GEN6_3DSTATE_SF_URB_ENTRY_READ_OFFSET_SHIFT));
1915 OUT_BATCH(batch, 0);
1916 OUT_BATCH(batch, GEN6_3DSTATE_SF_CULL_NONE);
1917 OUT_BATCH(batch, 2 << GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT); /* DW4 */
1918 OUT_BATCH(batch, 0);
1919 OUT_BATCH(batch, 0);
1920 OUT_BATCH(batch, 0);
1921 OUT_BATCH(batch, 0);
1922 OUT_BATCH(batch, 0); /* DW9 */
1923 OUT_BATCH(batch, 0);
1924 OUT_BATCH(batch, 0);
1925 OUT_BATCH(batch, 0);
1926 OUT_BATCH(batch, 0);
1927 OUT_BATCH(batch, 0); /* DW14 */
1928 OUT_BATCH(batch, 0);
1929 OUT_BATCH(batch, 0);
1930 OUT_BATCH(batch, 0);
1931 OUT_BATCH(batch, 0);
1932 OUT_BATCH(batch, 0); /* DW19 */
1936 gen6_emit_wm_state(VADriverContextP ctx, int kernel)
1938 struct i965_driver_data *i965 = i965_driver_data(ctx);
1939 struct intel_batchbuffer *batch = i965->batch;
1940 struct i965_render_state *render_state = &i965->render_state;
1942 OUT_BATCH(batch, GEN6_3DSTATE_CONSTANT_PS |
1943 GEN6_3DSTATE_CONSTANT_BUFFER_0_ENABLE |
1946 render_state->curbe.bo,
1947 I915_GEM_DOMAIN_INSTRUCTION, 0,
1949 OUT_BATCH(batch, 0);
1950 OUT_BATCH(batch, 0);
1951 OUT_BATCH(batch, 0);
1953 OUT_BATCH(batch, GEN6_3DSTATE_WM | (9 - 2));
1954 OUT_RELOC(batch, render_state->render_kernels[kernel].bo,
1955 I915_GEM_DOMAIN_INSTRUCTION, 0,
1957 OUT_BATCH(batch, (1 << GEN6_3DSTATE_WM_SAMPLER_COUNT_SHITF) |
1958 (5 << GEN6_3DSTATE_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT));
1959 OUT_BATCH(batch, 0);
1960 OUT_BATCH(batch, (6 << GEN6_3DSTATE_WM_DISPATCH_START_GRF_0_SHIFT)); /* DW4 */
1961 OUT_BATCH(batch, ((40 - 1) << GEN6_3DSTATE_WM_MAX_THREADS_SHIFT) |
1962 GEN6_3DSTATE_WM_DISPATCH_ENABLE |
1963 GEN6_3DSTATE_WM_16_DISPATCH_ENABLE);
1964 OUT_BATCH(batch, (1 << GEN6_3DSTATE_WM_NUM_SF_OUTPUTS_SHIFT) |
1965 GEN6_3DSTATE_WM_PERSPECTIVE_PIXEL_BARYCENTRIC);
1966 OUT_BATCH(batch, 0);
1967 OUT_BATCH(batch, 0);
1971 gen6_emit_vertex_element_state(VADriverContextP ctx)
1973 struct i965_driver_data *i965 = i965_driver_data(ctx);
1974 struct intel_batchbuffer *batch = i965->batch;
1976 /* Set up our vertex elements, sourced from the single vertex buffer. */
1977 OUT_BATCH(batch, CMD_VERTEX_ELEMENTS | (5 - 2));
1978 /* offset 0: X,Y -> {X, Y, 1.0, 1.0} */
1979 OUT_BATCH(batch, (0 << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT) |
1981 (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) |
1982 (0 << VE0_OFFSET_SHIFT));
1983 OUT_BATCH(batch, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) |
1984 (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) |
1985 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) |
1986 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT));
1987 /* offset 8: S0, T0 -> {S0, T0, 1.0, 1.0} */
1988 OUT_BATCH(batch, (0 << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT) |
1990 (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) |
1991 (8 << VE0_OFFSET_SHIFT));
1992 OUT_BATCH(batch, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) |
1993 (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) |
1994 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) |
1995 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT));
1999 gen6_emit_vertices(VADriverContextP ctx)
2001 struct i965_driver_data *i965 = i965_driver_data(ctx);
2002 struct intel_batchbuffer *batch = i965->batch;
2003 struct i965_render_state *render_state = &i965->render_state;
2005 BEGIN_BATCH(batch, 11);
2006 OUT_BATCH(batch, CMD_VERTEX_BUFFERS | 3);
2008 (0 << GEN6_VB0_BUFFER_INDEX_SHIFT) |
2009 GEN6_VB0_VERTEXDATA |
2010 ((4 * 4) << VB0_BUFFER_PITCH_SHIFT));
2011 OUT_RELOC(batch, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 0);
2012 OUT_RELOC(batch, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 12 * 4);
2013 OUT_BATCH(batch, 0);
2017 _3DPRIMITIVE_VERTEX_SEQUENTIAL |
2018 (_3DPRIM_RECTLIST << _3DPRIMITIVE_TOPOLOGY_SHIFT) |
2021 OUT_BATCH(batch, 3); /* vertex count per instance */
2022 OUT_BATCH(batch, 0); /* start vertex offset */
2023 OUT_BATCH(batch, 1); /* single instance */
2024 OUT_BATCH(batch, 0); /* start instance location */
2025 OUT_BATCH(batch, 0); /* index buffer offset, ignored */
2026 ADVANCE_BATCH(batch);
2030 gen6_render_emit_states(VADriverContextP ctx, int kernel)
2032 struct i965_driver_data *i965 = i965_driver_data(ctx);
2033 struct intel_batchbuffer *batch = i965->batch;
2035 intel_batchbuffer_start_atomic(batch, 0x1000);
2036 intel_batchbuffer_emit_mi_flush(batch);
2037 gen6_emit_invarient_states(ctx);
2038 gen6_emit_state_base_address(ctx);
2039 gen6_emit_viewport_state_pointers(ctx);
2041 gen6_emit_cc_state_pointers(ctx);
2042 gen6_emit_sampler_state_pointers(ctx);
2043 gen6_emit_vs_state(ctx);
2044 gen6_emit_gs_state(ctx);
2045 gen6_emit_clip_state(ctx);
2046 gen6_emit_sf_state(ctx);
2047 gen6_emit_wm_state(ctx, kernel);
2048 gen6_emit_binding_table(ctx);
2049 gen6_emit_depth_buffer_state(ctx);
2050 gen6_emit_drawing_rectangle(ctx);
2051 gen6_emit_vertex_element_state(ctx);
2052 gen6_emit_vertices(ctx);
2053 intel_batchbuffer_end_atomic(batch);
2057 gen6_render_put_surface(
2058 VADriverContextP ctx,
2059 VASurfaceID surface,
2060 const VARectangle *src_rect,
2061 const VARectangle *dst_rect,
2065 struct i965_driver_data *i965 = i965_driver_data(ctx);
2066 struct intel_batchbuffer *batch = i965->batch;
2068 gen6_render_initialize(ctx);
2069 gen6_render_setup_states(ctx, surface, src_rect, dst_rect);
2070 i965_clear_dest_region(ctx);
2071 gen6_render_emit_states(ctx, PS_KERNEL);
2072 intel_batchbuffer_flush(batch);
2076 gen6_subpicture_render_blend_state(VADriverContextP ctx)
2078 struct i965_driver_data *i965 = i965_driver_data(ctx);
2079 struct i965_render_state *render_state = &i965->render_state;
2080 struct gen6_blend_state *blend_state;
2082 dri_bo_unmap(render_state->cc.state);
2083 dri_bo_map(render_state->cc.blend, 1);
2084 assert(render_state->cc.blend->virtual);
2085 blend_state = render_state->cc.blend->virtual;
2086 memset(blend_state, 0, sizeof(*blend_state));
2087 blend_state->blend0.dest_blend_factor = I965_BLENDFACTOR_INV_SRC_ALPHA;
2088 blend_state->blend0.source_blend_factor = I965_BLENDFACTOR_SRC_ALPHA;
2089 blend_state->blend0.blend_func = I965_BLENDFUNCTION_ADD;
2090 blend_state->blend0.blend_enable = 1;
2091 blend_state->blend1.post_blend_clamp_enable = 1;
2092 blend_state->blend1.pre_blend_clamp_enable = 1;
2093 blend_state->blend1.clamp_range = 0; /* clamp range [0, 1] */
2094 dri_bo_unmap(render_state->cc.blend);
2098 gen6_subpicture_render_setup_states(
2099 VADriverContextP ctx,
2100 VASurfaceID surface,
2101 const VARectangle *src_rect,
2102 const VARectangle *dst_rect
2105 i965_render_dest_surface_state(ctx, 0);
2106 i965_subpic_render_src_surfaces_state(ctx, surface);
2107 i965_render_sampler(ctx);
2108 i965_render_cc_viewport(ctx);
2109 gen6_render_color_calc_state(ctx);
2110 gen6_subpicture_render_blend_state(ctx);
2111 gen6_render_depth_stencil_state(ctx);
2112 i965_subpic_render_upload_vertex(ctx, surface, dst_rect);
2116 gen6_render_put_subpicture(
2117 VADriverContextP ctx,
2118 VASurfaceID surface,
2119 const VARectangle *src_rect,
2120 const VARectangle *dst_rect
2123 struct i965_driver_data *i965 = i965_driver_data(ctx);
2124 struct intel_batchbuffer *batch = i965->batch;
2125 struct object_surface *obj_surface = SURFACE(surface);
2126 struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
2129 gen6_render_initialize(ctx);
2130 gen6_subpicture_render_setup_states(ctx, surface, src_rect, dst_rect);
2131 gen6_render_emit_states(ctx, PS_SUBPIC_KERNEL);
2132 i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff);
2133 intel_batchbuffer_flush(batch);
2140 gen7_render_initialize(VADriverContextP ctx)
2142 struct i965_driver_data *i965 = i965_driver_data(ctx);
2143 struct i965_render_state *render_state = &i965->render_state;
2147 dri_bo_unreference(render_state->vb.vertex_buffer);
2148 bo = dri_bo_alloc(i965->intel.bufmgr,
2153 render_state->vb.vertex_buffer = bo;
2156 dri_bo_unreference(render_state->wm.surface_state_binding_table_bo);
2157 bo = dri_bo_alloc(i965->intel.bufmgr,
2158 "surface state & binding table",
2159 (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_RENDER_SURFACES,
2162 render_state->wm.surface_state_binding_table_bo = bo;
2164 dri_bo_unreference(render_state->wm.sampler);
2165 bo = dri_bo_alloc(i965->intel.bufmgr,
2167 MAX_SAMPLERS * sizeof(struct gen7_sampler_state),
2170 render_state->wm.sampler = bo;
2171 render_state->wm.sampler_count = 0;
2173 /* COLOR CALCULATOR */
2174 dri_bo_unreference(render_state->cc.state);
2175 bo = dri_bo_alloc(i965->intel.bufmgr,
2177 sizeof(struct gen6_color_calc_state),
2180 render_state->cc.state = bo;
2183 dri_bo_unreference(render_state->cc.viewport);
2184 bo = dri_bo_alloc(i965->intel.bufmgr,
2186 sizeof(struct i965_cc_viewport),
2189 render_state->cc.viewport = bo;
2192 dri_bo_unreference(render_state->cc.blend);
2193 bo = dri_bo_alloc(i965->intel.bufmgr,
2195 sizeof(struct gen6_blend_state),
2198 render_state->cc.blend = bo;
2200 /* DEPTH & STENCIL STATE */
2201 dri_bo_unreference(render_state->cc.depth_stencil);
2202 bo = dri_bo_alloc(i965->intel.bufmgr,
2203 "depth & stencil state",
2204 sizeof(struct gen6_depth_stencil_state),
2207 render_state->cc.depth_stencil = bo;
2211 gen7_render_color_calc_state(VADriverContextP ctx)
2213 struct i965_driver_data *i965 = i965_driver_data(ctx);
2214 struct i965_render_state *render_state = &i965->render_state;
2215 struct gen6_color_calc_state *color_calc_state;
2217 dri_bo_map(render_state->cc.state, 1);
2218 assert(render_state->cc.state->virtual);
2219 color_calc_state = render_state->cc.state->virtual;
2220 memset(color_calc_state, 0, sizeof(*color_calc_state));
2221 color_calc_state->constant_r = 1.0;
2222 color_calc_state->constant_g = 0.0;
2223 color_calc_state->constant_b = 1.0;
2224 color_calc_state->constant_a = 1.0;
2225 dri_bo_unmap(render_state->cc.state);
2229 gen7_render_blend_state(VADriverContextP ctx)
2231 struct i965_driver_data *i965 = i965_driver_data(ctx);
2232 struct i965_render_state *render_state = &i965->render_state;
2233 struct gen6_blend_state *blend_state;
2235 dri_bo_map(render_state->cc.blend, 1);
2236 assert(render_state->cc.blend->virtual);
2237 blend_state = render_state->cc.blend->virtual;
2238 memset(blend_state, 0, sizeof(*blend_state));
2239 blend_state->blend1.logic_op_enable = 1;
2240 blend_state->blend1.logic_op_func = 0xc;
2241 blend_state->blend1.pre_blend_clamp_enable = 1;
2242 dri_bo_unmap(render_state->cc.blend);
2246 gen7_render_depth_stencil_state(VADriverContextP ctx)
2248 struct i965_driver_data *i965 = i965_driver_data(ctx);
2249 struct i965_render_state *render_state = &i965->render_state;
2250 struct gen6_depth_stencil_state *depth_stencil_state;
2252 dri_bo_map(render_state->cc.depth_stencil, 1);
2253 assert(render_state->cc.depth_stencil->virtual);
2254 depth_stencil_state = render_state->cc.depth_stencil->virtual;
2255 memset(depth_stencil_state, 0, sizeof(*depth_stencil_state));
2256 dri_bo_unmap(render_state->cc.depth_stencil);
2260 gen7_render_sampler(VADriverContextP ctx)
2262 struct i965_driver_data *i965 = i965_driver_data(ctx);
2263 struct i965_render_state *render_state = &i965->render_state;
2264 struct gen7_sampler_state *sampler_state;
2267 assert(render_state->wm.sampler_count > 0);
2268 assert(render_state->wm.sampler_count <= MAX_SAMPLERS);
2270 dri_bo_map(render_state->wm.sampler, 1);
2271 assert(render_state->wm.sampler->virtual);
2272 sampler_state = render_state->wm.sampler->virtual;
2273 for (i = 0; i < render_state->wm.sampler_count; i++) {
2274 memset(sampler_state, 0, sizeof(*sampler_state));
2275 sampler_state->ss0.min_filter = I965_MAPFILTER_LINEAR;
2276 sampler_state->ss0.mag_filter = I965_MAPFILTER_LINEAR;
2277 sampler_state->ss3.r_wrap_mode = I965_TEXCOORDMODE_CLAMP;
2278 sampler_state->ss3.s_wrap_mode = I965_TEXCOORDMODE_CLAMP;
2279 sampler_state->ss3.t_wrap_mode = I965_TEXCOORDMODE_CLAMP;
2283 dri_bo_unmap(render_state->wm.sampler);
2287 gen7_render_setup_states(
2288 VADriverContextP ctx,
2289 VASurfaceID surface,
2290 const VARectangle *src_rect,
2291 const VARectangle *dst_rect
2294 i965_render_dest_surface_state(ctx, 0);
2295 i965_render_src_surfaces_state(ctx, surface);
2296 gen7_render_sampler(ctx);
2297 i965_render_cc_viewport(ctx);
2298 gen7_render_color_calc_state(ctx);
2299 gen7_render_blend_state(ctx);
2300 gen7_render_depth_stencil_state(ctx);
2301 i965_render_upload_constants(ctx, surface);
2302 i965_render_upload_vertex(ctx, surface, src_rect, dst_rect);
2306 gen7_emit_invarient_states(VADriverContextP ctx)
2308 struct i965_driver_data *i965 = i965_driver_data(ctx);
2309 struct intel_batchbuffer *batch = i965->batch;
2311 BEGIN_BATCH(batch, 1);
2312 OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_3D);
2313 ADVANCE_BATCH(batch);
2315 BEGIN_BATCH(batch, 4);
2316 OUT_BATCH(batch, GEN6_3DSTATE_MULTISAMPLE | (4 - 2));
2317 OUT_BATCH(batch, GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_CENTER |
2318 GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_1); /* 1 sample/pixel */
2319 OUT_BATCH(batch, 0);
2320 OUT_BATCH(batch, 0);
2321 ADVANCE_BATCH(batch);
2323 BEGIN_BATCH(batch, 2);
2324 OUT_BATCH(batch, GEN6_3DSTATE_SAMPLE_MASK | (2 - 2));
2325 OUT_BATCH(batch, 1);
2326 ADVANCE_BATCH(batch);
2328 /* Set system instruction pointer */
2329 BEGIN_BATCH(batch, 2);
2330 OUT_BATCH(batch, CMD_STATE_SIP | 0);
2331 OUT_BATCH(batch, 0);
2332 ADVANCE_BATCH(batch);
2336 gen7_emit_state_base_address(VADriverContextP ctx)
2338 struct i965_driver_data *i965 = i965_driver_data(ctx);
2339 struct intel_batchbuffer *batch = i965->batch;
2340 struct i965_render_state *render_state = &i965->render_state;
2342 OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | (10 - 2));
2343 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* General state base address */
2344 OUT_RELOC(batch, render_state->wm.surface_state_binding_table_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY); /* Surface state base address */
2345 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Dynamic state base address */
2346 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Indirect object base address */
2347 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Instruction base address */
2348 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* General state upper bound */
2349 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Dynamic state upper bound */
2350 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Indirect object upper bound */
2351 OUT_BATCH(batch, BASE_ADDRESS_MODIFY); /* Instruction access upper bound */
2355 gen7_emit_viewport_state_pointers(VADriverContextP ctx)
2357 struct i965_driver_data *i965 = i965_driver_data(ctx);
2358 struct intel_batchbuffer *batch = i965->batch;
2359 struct i965_render_state *render_state = &i965->render_state;
2361 BEGIN_BATCH(batch, 2);
2362 OUT_BATCH(batch, GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_CC | (2 - 2));
2364 render_state->cc.viewport,
2365 I915_GEM_DOMAIN_INSTRUCTION, 0,
2367 ADVANCE_BATCH(batch);
2369 BEGIN_BATCH(batch, 2);
2370 OUT_BATCH(batch, GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CL | (2 - 2));
2371 OUT_BATCH(batch, 0);
2372 ADVANCE_BATCH(batch);
2376 * URB layout on GEN7
2377 * ----------------------------------------
2378 * | PS Push Constants (8KB) | VS entries |
2379 * ----------------------------------------
2382 gen7_emit_urb(VADriverContextP ctx)
2384 struct i965_driver_data *i965 = i965_driver_data(ctx);
2385 struct intel_batchbuffer *batch = i965->batch;
2387 BEGIN_BATCH(batch, 2);
2388 OUT_BATCH(batch, GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS | (2 - 2));
2389 OUT_BATCH(batch, 8); /* in 1KBs */
2390 ADVANCE_BATCH(batch);
2392 BEGIN_BATCH(batch, 2);
2393 OUT_BATCH(batch, GEN7_3DSTATE_URB_VS | (2 - 2));
2395 (32 << GEN7_URB_ENTRY_NUMBER_SHIFT) | /* at least 32 */
2396 (2 - 1) << GEN7_URB_ENTRY_SIZE_SHIFT |
2397 (1 << GEN7_URB_STARTING_ADDRESS_SHIFT));
2398 ADVANCE_BATCH(batch);
2400 BEGIN_BATCH(batch, 2);
2401 OUT_BATCH(batch, GEN7_3DSTATE_URB_GS | (2 - 2));
2403 (0 << GEN7_URB_ENTRY_SIZE_SHIFT) |
2404 (1 << GEN7_URB_STARTING_ADDRESS_SHIFT));
2405 ADVANCE_BATCH(batch);
2407 BEGIN_BATCH(batch, 2);
2408 OUT_BATCH(batch, GEN7_3DSTATE_URB_HS | (2 - 2));
2410 (0 << GEN7_URB_ENTRY_SIZE_SHIFT) |
2411 (2 << GEN7_URB_STARTING_ADDRESS_SHIFT));
2412 ADVANCE_BATCH(batch);
2414 BEGIN_BATCH(batch, 2);
2415 OUT_BATCH(batch, GEN7_3DSTATE_URB_DS | (2 - 2));
2417 (0 << GEN7_URB_ENTRY_SIZE_SHIFT) |
2418 (2 << GEN7_URB_STARTING_ADDRESS_SHIFT));
2419 ADVANCE_BATCH(batch);
2423 gen7_emit_cc_state_pointers(VADriverContextP ctx)
2425 struct i965_driver_data *i965 = i965_driver_data(ctx);
2426 struct intel_batchbuffer *batch = i965->batch;
2427 struct i965_render_state *render_state = &i965->render_state;
2429 BEGIN_BATCH(batch, 2);
2430 OUT_BATCH(batch, GEN6_3DSTATE_CC_STATE_POINTERS | (2 - 2));
2432 render_state->cc.state,
2433 I915_GEM_DOMAIN_INSTRUCTION, 0,
2435 ADVANCE_BATCH(batch);
2437 BEGIN_BATCH(batch, 2);
2438 OUT_BATCH(batch, GEN7_3DSTATE_BLEND_STATE_POINTERS | (2 - 2));
2440 render_state->cc.blend,
2441 I915_GEM_DOMAIN_INSTRUCTION, 0,
2443 ADVANCE_BATCH(batch);
2445 BEGIN_BATCH(batch, 2);
2446 OUT_BATCH(batch, GEN7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS | (2 - 2));
2448 render_state->cc.depth_stencil,
2449 I915_GEM_DOMAIN_INSTRUCTION, 0,
2451 ADVANCE_BATCH(batch);
2455 gen7_emit_sampler_state_pointers(VADriverContextP ctx)
2457 struct i965_driver_data *i965 = i965_driver_data(ctx);
2458 struct intel_batchbuffer *batch = i965->batch;
2459 struct i965_render_state *render_state = &i965->render_state;
2461 BEGIN_BATCH(batch, 2);
2462 OUT_BATCH(batch, GEN7_3DSTATE_SAMPLER_STATE_POINTERS_PS | (2 - 2));
2464 render_state->wm.sampler,
2465 I915_GEM_DOMAIN_INSTRUCTION, 0,
2467 ADVANCE_BATCH(batch);
2471 gen7_emit_binding_table(VADriverContextP ctx)
2473 struct i965_driver_data *i965 = i965_driver_data(ctx);
2474 struct intel_batchbuffer *batch = i965->batch;
2476 BEGIN_BATCH(batch, 2);
2477 OUT_BATCH(batch, GEN7_3DSTATE_BINDING_TABLE_POINTERS_PS | (2 - 2));
2478 OUT_BATCH(batch, BINDING_TABLE_OFFSET);
2479 ADVANCE_BATCH(batch);
2483 gen7_emit_depth_buffer_state(VADriverContextP ctx)
2485 struct i965_driver_data *i965 = i965_driver_data(ctx);
2486 struct intel_batchbuffer *batch = i965->batch;
2488 BEGIN_BATCH(batch, 7);
2489 OUT_BATCH(batch, GEN7_3DSTATE_DEPTH_BUFFER | (7 - 2));
2491 (I965_DEPTHFORMAT_D32_FLOAT << 18) |
2492 (I965_SURFACE_NULL << 29));
2493 OUT_BATCH(batch, 0);
2494 OUT_BATCH(batch, 0);
2495 OUT_BATCH(batch, 0);
2496 OUT_BATCH(batch, 0);
2497 OUT_BATCH(batch, 0);
2498 ADVANCE_BATCH(batch);
2500 BEGIN_BATCH(batch, 3);
2501 OUT_BATCH(batch, GEN7_3DSTATE_CLEAR_PARAMS | (3 - 2));
2502 OUT_BATCH(batch, 0);
2503 OUT_BATCH(batch, 0);
2504 ADVANCE_BATCH(batch);
2508 gen7_emit_drawing_rectangle(VADriverContextP ctx)
2510 i965_render_drawing_rectangle(ctx);
2514 gen7_emit_vs_state(VADriverContextP ctx)
2516 struct i965_driver_data *i965 = i965_driver_data(ctx);
2517 struct intel_batchbuffer *batch = i965->batch;
2519 /* disable VS constant buffer */
2520 OUT_BATCH(batch, GEN6_3DSTATE_CONSTANT_VS | (7 - 2));
2521 OUT_BATCH(batch, 0);
2522 OUT_BATCH(batch, 0);
2523 OUT_BATCH(batch, 0);
2524 OUT_BATCH(batch, 0);
2525 OUT_BATCH(batch, 0);
2526 OUT_BATCH(batch, 0);
2528 OUT_BATCH(batch, GEN6_3DSTATE_VS | (6 - 2));
2529 OUT_BATCH(batch, 0); /* without VS kernel */
2530 OUT_BATCH(batch, 0);
2531 OUT_BATCH(batch, 0);
2532 OUT_BATCH(batch, 0);
2533 OUT_BATCH(batch, 0); /* pass-through */
2537 gen7_emit_bypass_state(VADriverContextP ctx)
2539 struct i965_driver_data *i965 = i965_driver_data(ctx);
2540 struct intel_batchbuffer *batch = i965->batch;
2543 BEGIN_BATCH(batch, 7);
2544 OUT_BATCH(batch, GEN6_3DSTATE_CONSTANT_GS | (7 - 2));
2545 OUT_BATCH(batch, 0);
2546 OUT_BATCH(batch, 0);
2547 OUT_BATCH(batch, 0);
2548 OUT_BATCH(batch, 0);
2549 OUT_BATCH(batch, 0);
2550 OUT_BATCH(batch, 0);
2551 ADVANCE_BATCH(batch);
2553 BEGIN_BATCH(batch, 7);
2554 OUT_BATCH(batch, GEN6_3DSTATE_GS | (7 - 2));
2555 OUT_BATCH(batch, 0); /* without GS kernel */
2556 OUT_BATCH(batch, 0);
2557 OUT_BATCH(batch, 0);
2558 OUT_BATCH(batch, 0);
2559 OUT_BATCH(batch, 0);
2560 OUT_BATCH(batch, 0); /* pass-through */
2561 ADVANCE_BATCH(batch);
2563 BEGIN_BATCH(batch, 2);
2564 OUT_BATCH(batch, GEN7_3DSTATE_BINDING_TABLE_POINTERS_GS | (2 - 2));
2565 OUT_BATCH(batch, 0);
2566 ADVANCE_BATCH(batch);
2569 BEGIN_BATCH(batch, 7);
2570 OUT_BATCH(batch, GEN7_3DSTATE_CONSTANT_HS | (7 - 2));
2571 OUT_BATCH(batch, 0);
2572 OUT_BATCH(batch, 0);
2573 OUT_BATCH(batch, 0);
2574 OUT_BATCH(batch, 0);
2575 OUT_BATCH(batch, 0);
2576 OUT_BATCH(batch, 0);
2577 ADVANCE_BATCH(batch);
2579 BEGIN_BATCH(batch, 7);
2580 OUT_BATCH(batch, GEN7_3DSTATE_HS | (7 - 2));
2581 OUT_BATCH(batch, 0);
2582 OUT_BATCH(batch, 0);
2583 OUT_BATCH(batch, 0);
2584 OUT_BATCH(batch, 0);
2585 OUT_BATCH(batch, 0);
2586 OUT_BATCH(batch, 0);
2587 ADVANCE_BATCH(batch);
2589 BEGIN_BATCH(batch, 2);
2590 OUT_BATCH(batch, GEN7_3DSTATE_BINDING_TABLE_POINTERS_HS | (2 - 2));
2591 OUT_BATCH(batch, 0);
2592 ADVANCE_BATCH(batch);
2595 BEGIN_BATCH(batch, 4);
2596 OUT_BATCH(batch, GEN7_3DSTATE_TE | (4 - 2));
2597 OUT_BATCH(batch, 0);
2598 OUT_BATCH(batch, 0);
2599 OUT_BATCH(batch, 0);
2600 ADVANCE_BATCH(batch);
2603 BEGIN_BATCH(batch, 7);
2604 OUT_BATCH(batch, GEN7_3DSTATE_CONSTANT_DS | (7 - 2));
2605 OUT_BATCH(batch, 0);
2606 OUT_BATCH(batch, 0);
2607 OUT_BATCH(batch, 0);
2608 OUT_BATCH(batch, 0);
2609 OUT_BATCH(batch, 0);
2610 OUT_BATCH(batch, 0);
2611 ADVANCE_BATCH(batch);
2613 BEGIN_BATCH(batch, 6);
2614 OUT_BATCH(batch, GEN7_3DSTATE_DS | (6 - 2));
2615 OUT_BATCH(batch, 0);
2616 OUT_BATCH(batch, 0);
2617 OUT_BATCH(batch, 0);
2618 OUT_BATCH(batch, 0);
2619 OUT_BATCH(batch, 0);
2620 ADVANCE_BATCH(batch);
2622 BEGIN_BATCH(batch, 2);
2623 OUT_BATCH(batch, GEN7_3DSTATE_BINDING_TABLE_POINTERS_DS | (2 - 2));
2624 OUT_BATCH(batch, 0);
2625 ADVANCE_BATCH(batch);
2627 /* Disable STREAMOUT */
2628 BEGIN_BATCH(batch, 3);
2629 OUT_BATCH(batch, GEN7_3DSTATE_STREAMOUT | (3 - 2));
2630 OUT_BATCH(batch, 0);
2631 OUT_BATCH(batch, 0);
2632 ADVANCE_BATCH(batch);
2636 gen7_emit_clip_state(VADriverContextP ctx)
2638 struct i965_driver_data *i965 = i965_driver_data(ctx);
2639 struct intel_batchbuffer *batch = i965->batch;
2641 OUT_BATCH(batch, GEN6_3DSTATE_CLIP | (4 - 2));
2642 OUT_BATCH(batch, 0);
2643 OUT_BATCH(batch, 0); /* pass-through */
2644 OUT_BATCH(batch, 0);
2648 gen7_emit_sf_state(VADriverContextP ctx)
2650 struct i965_driver_data *i965 = i965_driver_data(ctx);
2651 struct intel_batchbuffer *batch = i965->batch;
2653 BEGIN_BATCH(batch, 14);
2654 OUT_BATCH(batch, GEN7_3DSTATE_SBE | (14 - 2));
2656 (1 << GEN7_SBE_NUM_OUTPUTS_SHIFT) |
2657 (1 << GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT) |
2658 (0 << GEN7_SBE_URB_ENTRY_READ_OFFSET_SHIFT));
2659 OUT_BATCH(batch, 0);
2660 OUT_BATCH(batch, 0);
2661 OUT_BATCH(batch, 0); /* DW4 */
2662 OUT_BATCH(batch, 0);
2663 OUT_BATCH(batch, 0);
2664 OUT_BATCH(batch, 0);
2665 OUT_BATCH(batch, 0);
2666 OUT_BATCH(batch, 0); /* DW9 */
2667 OUT_BATCH(batch, 0);
2668 OUT_BATCH(batch, 0);
2669 OUT_BATCH(batch, 0);
2670 OUT_BATCH(batch, 0);
2671 ADVANCE_BATCH(batch);
2673 BEGIN_BATCH(batch, 7);
2674 OUT_BATCH(batch, GEN6_3DSTATE_SF | (7 - 2));
2675 OUT_BATCH(batch, 0);
2676 OUT_BATCH(batch, GEN6_3DSTATE_SF_CULL_NONE);
2677 OUT_BATCH(batch, 2 << GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT);
2678 OUT_BATCH(batch, 0);
2679 OUT_BATCH(batch, 0);
2680 OUT_BATCH(batch, 0);
2681 ADVANCE_BATCH(batch);
2685 gen7_emit_wm_state(VADriverContextP ctx, int kernel)
2687 struct i965_driver_data *i965 = i965_driver_data(ctx);
2688 struct intel_batchbuffer *batch = i965->batch;
2689 struct i965_render_state *render_state = &i965->render_state;
2691 BEGIN_BATCH(batch, 3);
2692 OUT_BATCH(batch, GEN6_3DSTATE_WM | (3 - 2));
2694 GEN7_WM_DISPATCH_ENABLE |
2695 GEN7_WM_PERSPECTIVE_PIXEL_BARYCENTRIC);
2696 OUT_BATCH(batch, 0);
2697 ADVANCE_BATCH(batch);
2699 BEGIN_BATCH(batch, 7);
2700 OUT_BATCH(batch, GEN6_3DSTATE_CONSTANT_PS | (7 - 2));
2701 OUT_BATCH(batch, 1);
2702 OUT_BATCH(batch, 0);
2704 render_state->curbe.bo,
2705 I915_GEM_DOMAIN_INSTRUCTION, 0,
2707 OUT_BATCH(batch, 0);
2708 OUT_BATCH(batch, 0);
2709 OUT_BATCH(batch, 0);
2710 ADVANCE_BATCH(batch);
2712 BEGIN_BATCH(batch, 8);
2713 OUT_BATCH(batch, GEN7_3DSTATE_PS | (8 - 2));
2715 render_state->render_kernels[kernel].bo,
2716 I915_GEM_DOMAIN_INSTRUCTION, 0,
2719 (1 << GEN7_PS_SAMPLER_COUNT_SHIFT) |
2720 (5 << GEN7_PS_BINDING_TABLE_ENTRY_COUNT_SHIFT));
2721 OUT_BATCH(batch, 0); /* scratch space base offset */
2723 ((86 - 1) << GEN7_PS_MAX_THREADS_SHIFT) |
2724 GEN7_PS_PUSH_CONSTANT_ENABLE |
2725 GEN7_PS_ATTRIBUTE_ENABLE |
2726 GEN7_PS_16_DISPATCH_ENABLE);
2728 (6 << GEN7_PS_DISPATCH_START_GRF_SHIFT_0));
2729 OUT_BATCH(batch, 0); /* kernel 1 pointer */
2730 OUT_BATCH(batch, 0); /* kernel 2 pointer */
2731 ADVANCE_BATCH(batch);
2735 gen7_emit_vertex_element_state(VADriverContextP ctx)
2737 struct i965_driver_data *i965 = i965_driver_data(ctx);
2738 struct intel_batchbuffer *batch = i965->batch;
2740 /* Set up our vertex elements, sourced from the single vertex buffer. */
2741 OUT_BATCH(batch, CMD_VERTEX_ELEMENTS | (5 - 2));
2742 /* offset 0: X,Y -> {X, Y, 1.0, 1.0} */
2743 OUT_BATCH(batch, (0 << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT) |
2745 (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) |
2746 (0 << VE0_OFFSET_SHIFT));
2747 OUT_BATCH(batch, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) |
2748 (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) |
2749 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) |
2750 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT));
2751 /* offset 8: S0, T0 -> {S0, T0, 1.0, 1.0} */
2752 OUT_BATCH(batch, (0 << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT) |
2754 (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) |
2755 (8 << VE0_OFFSET_SHIFT));
2756 OUT_BATCH(batch, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) |
2757 (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) |
2758 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) |
2759 (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT));
2763 gen7_emit_vertices(VADriverContextP ctx)
2765 struct i965_driver_data *i965 = i965_driver_data(ctx);
2766 struct intel_batchbuffer *batch = i965->batch;
2767 struct i965_render_state *render_state = &i965->render_state;
2769 BEGIN_BATCH(batch, 5);
2770 OUT_BATCH(batch, CMD_VERTEX_BUFFERS | (5 - 2));
2772 (0 << GEN6_VB0_BUFFER_INDEX_SHIFT) |
2773 GEN6_VB0_VERTEXDATA |
2774 GEN7_VB0_ADDRESS_MODIFYENABLE |
2775 ((4 * 4) << VB0_BUFFER_PITCH_SHIFT));
2776 OUT_RELOC(batch, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 0);
2777 OUT_RELOC(batch, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 12 * 4);
2778 OUT_BATCH(batch, 0);
2779 ADVANCE_BATCH(batch);
2781 BEGIN_BATCH(batch, 7);
2782 OUT_BATCH(batch, CMD_3DPRIMITIVE | (7 - 2));
2785 GEN7_3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL);
2786 OUT_BATCH(batch, 3); /* vertex count per instance */
2787 OUT_BATCH(batch, 0); /* start vertex offset */
2788 OUT_BATCH(batch, 1); /* single instance */
2789 OUT_BATCH(batch, 0); /* start instance location */
2790 OUT_BATCH(batch, 0);
2791 ADVANCE_BATCH(batch);
2795 gen7_render_emit_states(VADriverContextP ctx, int kernel)
2797 struct i965_driver_data *i965 = i965_driver_data(ctx);
2798 struct intel_batchbuffer *batch = i965->batch;
2800 intel_batchbuffer_start_atomic(batch, 0x1000);
2801 intel_batchbuffer_emit_mi_flush(batch);
2802 gen7_emit_invarient_states(ctx);
2803 gen7_emit_state_base_address(ctx);
2804 gen7_emit_viewport_state_pointers(ctx);
2806 gen7_emit_cc_state_pointers(ctx);
2807 gen7_emit_sampler_state_pointers(ctx);
2808 gen7_emit_bypass_state(ctx);
2809 gen7_emit_vs_state(ctx);
2810 gen7_emit_clip_state(ctx);
2811 gen7_emit_sf_state(ctx);
2812 gen7_emit_wm_state(ctx, kernel);
2813 gen7_emit_binding_table(ctx);
2814 gen7_emit_depth_buffer_state(ctx);
2815 gen7_emit_drawing_rectangle(ctx);
2816 gen7_emit_vertex_element_state(ctx);
2817 gen7_emit_vertices(ctx);
2818 intel_batchbuffer_end_atomic(batch);
2822 gen7_render_put_surface(
2823 VADriverContextP ctx,
2824 VASurfaceID surface,
2825 const VARectangle *src_rect,
2826 const VARectangle *dst_rect,
2830 struct i965_driver_data *i965 = i965_driver_data(ctx);
2831 struct intel_batchbuffer *batch = i965->batch;
2833 gen7_render_initialize(ctx);
2834 gen7_render_setup_states(ctx, surface, src_rect, dst_rect);
2835 i965_clear_dest_region(ctx);
2836 gen7_render_emit_states(ctx, PS_KERNEL);
2837 intel_batchbuffer_flush(batch);
2841 gen7_subpicture_render_blend_state(VADriverContextP ctx)
2843 struct i965_driver_data *i965 = i965_driver_data(ctx);
2844 struct i965_render_state *render_state = &i965->render_state;
2845 struct gen6_blend_state *blend_state;
2847 dri_bo_unmap(render_state->cc.state);
2848 dri_bo_map(render_state->cc.blend, 1);
2849 assert(render_state->cc.blend->virtual);
2850 blend_state = render_state->cc.blend->virtual;
2851 memset(blend_state, 0, sizeof(*blend_state));
2852 blend_state->blend0.dest_blend_factor = I965_BLENDFACTOR_INV_SRC_ALPHA;
2853 blend_state->blend0.source_blend_factor = I965_BLENDFACTOR_SRC_ALPHA;
2854 blend_state->blend0.blend_func = I965_BLENDFUNCTION_ADD;
2855 blend_state->blend0.blend_enable = 1;
2856 blend_state->blend1.post_blend_clamp_enable = 1;
2857 blend_state->blend1.pre_blend_clamp_enable = 1;
2858 blend_state->blend1.clamp_range = 0; /* clamp range [0, 1] */
2859 dri_bo_unmap(render_state->cc.blend);
2863 gen7_subpicture_render_setup_states(
2864 VADriverContextP ctx,
2865 VASurfaceID surface,
2866 const VARectangle *src_rect,
2867 const VARectangle *dst_rect
2870 i965_render_dest_surface_state(ctx, 0);
2871 i965_subpic_render_src_surfaces_state(ctx, surface);
2872 i965_render_sampler(ctx);
2873 i965_render_cc_viewport(ctx);
2874 gen7_render_color_calc_state(ctx);
2875 gen7_subpicture_render_blend_state(ctx);
2876 gen7_render_depth_stencil_state(ctx);
2877 i965_subpic_render_upload_vertex(ctx, surface, dst_rect);
2881 gen7_render_put_subpicture(
2882 VADriverContextP ctx,
2883 VASurfaceID surface,
2884 const VARectangle *src_rect,
2885 const VARectangle *dst_rect
2888 struct i965_driver_data *i965 = i965_driver_data(ctx);
2889 struct intel_batchbuffer *batch = i965->batch;
2890 struct object_surface *obj_surface = SURFACE(surface);
2891 struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic);
2894 gen7_render_initialize(ctx);
2895 gen7_subpicture_render_setup_states(ctx, surface, src_rect, dst_rect);
2896 gen7_render_emit_states(ctx, PS_SUBPIC_KERNEL);
2897 i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff);
2898 intel_batchbuffer_flush(batch);
2906 i965_DestroySurfaces(VADriverContextP ctx,
2907 VASurfaceID *surface_list,
2910 intel_render_put_surface(
2911 VADriverContextP ctx,
2912 VASurfaceID surface,
2913 const VARectangle *src_rect,
2914 const VARectangle *dst_rect,
2918 struct i965_driver_data *i965 = i965_driver_data(ctx);
2919 int has_done_scaling = 0;
2920 VASurfaceID in_surface_id = surface;
2921 VASurfaceID out_surface_id = i965_post_processing(ctx, surface, src_rect, dst_rect, flags, &has_done_scaling);
2923 assert((!has_done_scaling) || (out_surface_id != VA_INVALID_ID));
2925 if (out_surface_id != VA_INVALID_ID)
2926 in_surface_id = out_surface_id;
2928 if (IS_GEN7(i965->intel.device_id))
2929 gen7_render_put_surface(ctx, in_surface_id, has_done_scaling ? dst_rect : src_rect, dst_rect, flags);
2930 else if (IS_GEN6(i965->intel.device_id))
2931 gen6_render_put_surface(ctx, in_surface_id, has_done_scaling ? dst_rect : src_rect, dst_rect, flags);
2933 i965_render_put_surface(ctx, in_surface_id, has_done_scaling ? dst_rect : src_rect, dst_rect, flags);
2935 if (in_surface_id != surface)
2936 i965_DestroySurfaces(ctx, &in_surface_id, 1);
2940 intel_render_put_subpicture(
2941 VADriverContextP ctx,
2942 VASurfaceID surface,
2943 const VARectangle *src_rect,
2944 const VARectangle *dst_rect
2947 struct i965_driver_data *i965 = i965_driver_data(ctx);
2949 if (IS_GEN7(i965->intel.device_id))
2950 gen7_render_put_subpicture(ctx, surface, src_rect, dst_rect);
2951 else if (IS_GEN6(i965->intel.device_id))
2952 gen6_render_put_subpicture(ctx, surface, src_rect, dst_rect);
2954 i965_render_put_subpicture(ctx, surface, src_rect, dst_rect);
2958 i965_render_init(VADriverContextP ctx)
2960 struct i965_driver_data *i965 = i965_driver_data(ctx);
2961 struct i965_render_state *render_state = &i965->render_state;
2965 assert(NUM_RENDER_KERNEL == (sizeof(render_kernels_gen5) /
2966 sizeof(render_kernels_gen5[0])));
2967 assert(NUM_RENDER_KERNEL == (sizeof(render_kernels_gen6) /
2968 sizeof(render_kernels_gen6[0])));
2970 if (IS_GEN7(i965->intel.device_id))
2971 memcpy(render_state->render_kernels, render_kernels_gen7, sizeof(render_state->render_kernels));
2972 else if (IS_GEN6(i965->intel.device_id))
2973 memcpy(render_state->render_kernels, render_kernels_gen6, sizeof(render_state->render_kernels));
2974 else if (IS_IRONLAKE(i965->intel.device_id))
2975 memcpy(render_state->render_kernels, render_kernels_gen5, sizeof(render_state->render_kernels));
2977 memcpy(render_state->render_kernels, render_kernels_gen4, sizeof(render_state->render_kernels));
2979 for (i = 0; i < NUM_RENDER_KERNEL; i++) {
2980 struct i965_kernel *kernel = &render_state->render_kernels[i];
2985 kernel->bo = dri_bo_alloc(i965->intel.bufmgr,
2987 kernel->size, 0x1000);
2989 dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin);
2992 /* constant buffer */
2993 render_state->curbe.bo = dri_bo_alloc(i965->intel.bufmgr,
2996 assert(render_state->curbe.bo);
3002 i965_render_terminate(VADriverContextP ctx)
3005 struct i965_driver_data *i965 = i965_driver_data(ctx);
3006 struct i965_render_state *render_state = &i965->render_state;
3008 dri_bo_unreference(render_state->curbe.bo);
3009 render_state->curbe.bo = NULL;
3011 for (i = 0; i < NUM_RENDER_KERNEL; i++) {
3012 struct i965_kernel *kernel = &render_state->render_kernels[i];
3014 dri_bo_unreference(kernel->bo);
3018 dri_bo_unreference(render_state->vb.vertex_buffer);
3019 render_state->vb.vertex_buffer = NULL;
3020 dri_bo_unreference(render_state->vs.state);
3021 render_state->vs.state = NULL;
3022 dri_bo_unreference(render_state->sf.state);
3023 render_state->sf.state = NULL;
3024 dri_bo_unreference(render_state->wm.sampler);
3025 render_state->wm.sampler = NULL;
3026 dri_bo_unreference(render_state->wm.state);
3027 render_state->wm.state = NULL;
3028 dri_bo_unreference(render_state->wm.surface_state_binding_table_bo);
3029 dri_bo_unreference(render_state->cc.viewport);
3030 render_state->cc.viewport = NULL;
3031 dri_bo_unreference(render_state->cc.state);
3032 render_state->cc.state = NULL;
3033 dri_bo_unreference(render_state->cc.blend);
3034 render_state->cc.blend = NULL;
3035 dri_bo_unreference(render_state->cc.depth_stencil);
3036 render_state->cc.depth_stencil = NULL;
3038 if (render_state->draw_region) {
3039 dri_bo_unreference(render_state->draw_region->bo);
3040 free(render_state->draw_region);
3041 render_state->draw_region = NULL;