380
380
#define URB_CS_ENTRIES 0
381
381
#define URB_CS_ENTRY_SIZE 0
384
intel_alloc_and_map(intel_screen_private *intel, char *name, int size,
385
drm_intel_bo ** bop, void *virtualp)
389
bo = drm_intel_bo_alloc(intel->bufmgr, name, size, 4096);
392
if (drm_intel_bo_map(bo, TRUE) != 0) {
393
drm_intel_bo_unreference(bo);
397
*(void **)virtualp = bo->virtual;
398
memset(bo->virtual, 0, size);
402
383
static void i965_create_dst_surface_state(ScrnInfoPtr scrn,
403
384
PixmapPtr pixmap,
404
385
drm_intel_bo *surf_bo,
407
388
intel_screen_private *intel = intel_get_screen_private(scrn);
408
struct brw_surface_state *dest_surf_state;
389
struct brw_surface_state dest_surf_state;
409
390
drm_intel_bo *pixmap_bo = intel_get_pixmap_bo(pixmap);
411
if (drm_intel_bo_map(surf_bo, TRUE) != 0)
414
dest_surf_state = (struct brw_surface_state *)((char *)surf_bo->virtual + offset);
415
memset(dest_surf_state, 0, sizeof(*dest_surf_state));
417
dest_surf_state->ss0.surface_type = BRW_SURFACE_2D;
418
dest_surf_state->ss0.data_return_format =
392
memset(&dest_surf_state, 0, sizeof(dest_surf_state));
394
dest_surf_state.ss0.surface_type = BRW_SURFACE_2D;
395
dest_surf_state.ss0.data_return_format =
419
396
BRW_SURFACERETURNFORMAT_FLOAT32;
420
397
if (intel->cpp == 2) {
421
dest_surf_state->ss0.surface_format =
398
dest_surf_state.ss0.surface_format =
422
399
BRW_SURFACEFORMAT_B5G6R5_UNORM;
424
dest_surf_state->ss0.surface_format =
401
dest_surf_state.ss0.surface_format =
425
402
BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
427
dest_surf_state->ss0.writedisable_alpha = 0;
428
dest_surf_state->ss0.writedisable_red = 0;
429
dest_surf_state->ss0.writedisable_green = 0;
430
dest_surf_state->ss0.writedisable_blue = 0;
431
dest_surf_state->ss0.color_blend = 1;
432
dest_surf_state->ss0.vert_line_stride = 0;
433
dest_surf_state->ss0.vert_line_stride_ofs = 0;
434
dest_surf_state->ss0.mipmap_layout_mode = 0;
435
dest_surf_state->ss0.render_cache_read_mode = 0;
404
dest_surf_state.ss0.writedisable_alpha = 0;
405
dest_surf_state.ss0.writedisable_red = 0;
406
dest_surf_state.ss0.writedisable_green = 0;
407
dest_surf_state.ss0.writedisable_blue = 0;
408
dest_surf_state.ss0.color_blend = 1;
409
dest_surf_state.ss0.vert_line_stride = 0;
410
dest_surf_state.ss0.vert_line_stride_ofs = 0;
411
dest_surf_state.ss0.mipmap_layout_mode = 0;
412
dest_surf_state.ss0.render_cache_read_mode = 0;
437
dest_surf_state->ss1.base_addr =
414
dest_surf_state.ss1.base_addr =
438
415
intel_emit_reloc(surf_bo, offset + offsetof(struct brw_surface_state, ss1),
439
pixmap_bo, 0, I915_GEM_DOMAIN_SAMPLER, 0);
441
dest_surf_state->ss2.height = pixmap->drawable.height - 1;
442
dest_surf_state->ss2.width = pixmap->drawable.width - 1;
443
dest_surf_state->ss2.mip_count = 0;
444
dest_surf_state->ss2.render_target_rotation = 0;
445
dest_surf_state->ss3.pitch = intel_pixmap_pitch(pixmap) - 1;
446
dest_surf_state->ss3.tiled_surface = intel_pixmap_tiled(pixmap);
447
dest_surf_state->ss3.tile_walk = 0; /* TileX */
449
drm_intel_bo_unmap(surf_bo);
416
pixmap_bo, 0, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
418
dest_surf_state.ss2.height = pixmap->drawable.height - 1;
419
dest_surf_state.ss2.width = pixmap->drawable.width - 1;
420
dest_surf_state.ss2.mip_count = 0;
421
dest_surf_state.ss2.render_target_rotation = 0;
422
dest_surf_state.ss3.pitch = intel_pixmap_pitch(pixmap) - 1;
423
dest_surf_state.ss3.tiled_surface = intel_pixmap_tiled(pixmap);
424
dest_surf_state.ss3.tile_walk = 0; /* TileX */
426
dri_bo_subdata(surf_bo,
427
offset, sizeof(dest_surf_state),
452
431
static void i965_create_src_surface_state(ScrnInfoPtr scrn,
459
438
drm_intel_bo *surface_bo,
462
struct brw_surface_state *src_surf_state;
464
if (drm_intel_bo_map(surface_bo, TRUE) != 0)
467
src_surf_state = (struct brw_surface_state *)((char *)surface_bo->virtual + offset);
468
memset(src_surf_state, 0, sizeof(*src_surf_state));
441
struct brw_surface_state src_surf_state;
443
memset(&src_surf_state, 0, sizeof(src_surf_state));
470
445
/* Set up the source surface state buffer */
471
src_surf_state->ss0.surface_type = BRW_SURFACE_2D;
472
src_surf_state->ss0.surface_format = src_surf_format;
473
src_surf_state->ss0.writedisable_alpha = 0;
474
src_surf_state->ss0.writedisable_red = 0;
475
src_surf_state->ss0.writedisable_green = 0;
476
src_surf_state->ss0.writedisable_blue = 0;
477
src_surf_state->ss0.color_blend = 1;
478
src_surf_state->ss0.vert_line_stride = 0;
479
src_surf_state->ss0.vert_line_stride_ofs = 0;
480
src_surf_state->ss0.mipmap_layout_mode = 0;
481
src_surf_state->ss0.render_cache_read_mode = 0;
446
src_surf_state.ss0.surface_type = BRW_SURFACE_2D;
447
src_surf_state.ss0.surface_format = src_surf_format;
448
src_surf_state.ss0.writedisable_alpha = 0;
449
src_surf_state.ss0.writedisable_red = 0;
450
src_surf_state.ss0.writedisable_green = 0;
451
src_surf_state.ss0.writedisable_blue = 0;
452
src_surf_state.ss0.color_blend = 1;
453
src_surf_state.ss0.vert_line_stride = 0;
454
src_surf_state.ss0.vert_line_stride_ofs = 0;
455
src_surf_state.ss0.mipmap_layout_mode = 0;
456
src_surf_state.ss0.render_cache_read_mode = 0;
483
src_surf_state->ss2.width = src_width - 1;
484
src_surf_state->ss2.height = src_height - 1;
485
src_surf_state->ss2.mip_count = 0;
486
src_surf_state->ss2.render_target_rotation = 0;
487
src_surf_state->ss3.pitch = src_pitch - 1;
458
src_surf_state.ss2.width = src_width - 1;
459
src_surf_state.ss2.height = src_height - 1;
460
src_surf_state.ss2.mip_count = 0;
461
src_surf_state.ss2.render_target_rotation = 0;
462
src_surf_state.ss3.pitch = src_pitch - 1;
490
src_surf_state->ss1.base_addr =
465
src_surf_state.ss1.base_addr =
491
466
intel_emit_reloc(surface_bo,
492
467
offset + offsetof(struct brw_surface_state, ss1),
493
468
src_bo, src_offset,
494
469
I915_GEM_DOMAIN_SAMPLER, 0);
496
src_surf_state->ss1.base_addr = src_offset;
471
src_surf_state.ss1.base_addr = src_offset;
499
drm_intel_bo_unmap(surface_bo);
474
dri_bo_subdata(surface_bo,
475
offset, sizeof(src_surf_state),
502
479
static void gen7_create_dst_surface_state(ScrnInfoPtr scrn,
507
484
intel_screen_private *intel = intel_get_screen_private(scrn);
508
struct gen7_surface_state *dest_surf_state;
485
struct gen7_surface_state dest_surf_state;
509
486
drm_intel_bo *pixmap_bo = intel_get_pixmap_bo(pixmap);
511
if (drm_intel_bo_map(surf_bo, TRUE) != 0)
514
dest_surf_state = (struct gen7_surface_state *)((char *)surf_bo->virtual + offset);
515
memset(dest_surf_state, 0, sizeof(*dest_surf_state));
517
dest_surf_state->ss0.surface_type = BRW_SURFACE_2D;
518
dest_surf_state->ss0.tiled_surface = intel_pixmap_tiled(pixmap);
519
dest_surf_state->ss0.tile_walk = 0; /* TileX */
488
memset(&dest_surf_state, 0, sizeof(dest_surf_state));
490
dest_surf_state.ss0.surface_type = BRW_SURFACE_2D;
491
dest_surf_state.ss0.tiled_surface = intel_pixmap_tiled(pixmap);
492
dest_surf_state.ss0.tile_walk = 0; /* TileX */
521
494
if (intel->cpp == 2) {
522
dest_surf_state->ss0.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM;
495
dest_surf_state.ss0.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM;
524
dest_surf_state->ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
497
dest_surf_state.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
527
dest_surf_state->ss1.base_addr =
528
intel_emit_reloc(surf_bo,
500
dest_surf_state.ss1.base_addr =
501
intel_emit_reloc(surf_bo,
529
502
offset + offsetof(struct gen7_surface_state, ss1),
531
504
I915_GEM_DOMAIN_SAMPLER, 0);
533
dest_surf_state->ss2.height = pixmap->drawable.height - 1;
534
dest_surf_state->ss2.width = pixmap->drawable.width - 1;
536
dest_surf_state->ss3.pitch = intel_pixmap_pitch(pixmap) - 1;
538
drm_intel_bo_unmap(surf_bo);
506
dest_surf_state.ss2.height = pixmap->drawable.height - 1;
507
dest_surf_state.ss2.width = pixmap->drawable.width - 1;
509
dest_surf_state.ss3.pitch = intel_pixmap_pitch(pixmap) - 1;
511
dri_bo_subdata(surf_bo,
512
offset, sizeof(dest_surf_state),
541
516
static void gen7_create_src_surface_state(ScrnInfoPtr scrn,
548
523
drm_intel_bo *surface_bo,
551
struct gen7_surface_state *src_surf_state;
553
if (drm_intel_bo_map(surface_bo, TRUE) != 0)
556
src_surf_state = (struct gen7_surface_state *)((char *)surface_bo->virtual + offset);
557
memset(src_surf_state, 0, sizeof(*src_surf_state));
559
src_surf_state->ss0.surface_type = BRW_SURFACE_2D;
560
src_surf_state->ss0.surface_format = src_surf_format;
526
struct gen7_surface_state src_surf_state;
528
memset(&src_surf_state, 0, sizeof(src_surf_state));
530
src_surf_state.ss0.surface_type = BRW_SURFACE_2D;
531
src_surf_state.ss0.surface_format = src_surf_format;
563
src_surf_state->ss1.base_addr =
534
src_surf_state.ss1.base_addr =
564
535
intel_emit_reloc(surface_bo,
565
536
offset + offsetof(struct gen7_surface_state, ss1),
566
537
src_bo, src_offset,
567
538
I915_GEM_DOMAIN_SAMPLER, 0);
569
src_surf_state->ss1.base_addr = src_offset;
540
src_surf_state.ss1.base_addr = src_offset;
572
src_surf_state->ss2.width = src_width - 1;
573
src_surf_state->ss2.height = src_height - 1;
575
src_surf_state->ss3.pitch = src_pitch - 1;
577
drm_intel_bo_unmap(surface_bo);
543
src_surf_state.ss2.width = src_width - 1;
544
src_surf_state.ss2.height = src_height - 1;
546
src_surf_state.ss3.pitch = src_pitch - 1;
548
dri_bo_subdata(surface_bo,
549
offset, sizeof(src_surf_state),
580
553
static void i965_create_binding_table(ScrnInfoPtr scrn,
581
drm_intel_bo *bind_bo,
554
drm_intel_bo *bind_bo,
584
uint32_t *binding_table;
557
uint32_t binding_table[n_surf];
587
560
/* Set up a binding table for our surfaces. Only the PS will use it */
588
if (drm_intel_bo_map(bind_bo, TRUE) != 0)
591
binding_table = (uint32_t*)((char *)bind_bo->virtual + n_surf * SURFACE_STATE_PADDED_SIZE);
593
561
for (i = 0; i < n_surf; i++)
594
562
binding_table[i] = i * SURFACE_STATE_PADDED_SIZE;
596
drm_intel_bo_unmap(bind_bo);
564
dri_bo_subdata(bind_bo,
565
n_surf * SURFACE_STATE_PADDED_SIZE,
566
sizeof(binding_table), binding_table);
599
569
static drm_intel_bo *i965_create_sampler_state(ScrnInfoPtr scrn)
601
571
intel_screen_private *intel = intel_get_screen_private(scrn);
602
drm_intel_bo *sampler_bo;
603
struct brw_sampler_state *sampler_state;
605
if (intel_alloc_and_map(intel, "textured video sampler state", 4096,
606
&sampler_bo, &sampler_state) != 0)
609
sampler_state->ss0.min_filter = BRW_MAPFILTER_LINEAR;
610
sampler_state->ss0.mag_filter = BRW_MAPFILTER_LINEAR;
611
sampler_state->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
612
sampler_state->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
613
sampler_state->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
615
drm_intel_bo_unmap(sampler_bo);
572
struct brw_sampler_state sampler_state;
574
memset(&sampler_state, 0, sizeof(sampler_state));
575
sampler_state.ss0.min_filter = BRW_MAPFILTER_LINEAR;
576
sampler_state.ss0.mag_filter = BRW_MAPFILTER_LINEAR;
577
sampler_state.ss1.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
578
sampler_state.ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
579
sampler_state.ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
581
return intel_bo_alloc_for_data(intel,
582
&sampler_state, sizeof(sampler_state),
583
"textured video sampler state");
619
586
static drm_intel_bo *gen7_create_sampler_state(ScrnInfoPtr scrn)
621
588
intel_screen_private *intel = intel_get_screen_private(scrn);
622
drm_intel_bo *sampler_bo;
623
struct gen7_sampler_state *sampler_state;
625
if (intel_alloc_and_map(intel, "textured video sampler state", 4096,
626
&sampler_bo, &sampler_state) != 0)
629
sampler_state->ss0.min_filter = BRW_MAPFILTER_LINEAR;
630
sampler_state->ss0.mag_filter = BRW_MAPFILTER_LINEAR;
631
sampler_state->ss3.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
632
sampler_state->ss3.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
633
sampler_state->ss3.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
635
drm_intel_bo_unmap(sampler_bo);
589
struct gen7_sampler_state sampler_state;
591
memset(&sampler_state, 0, sizeof(sampler_state));
592
sampler_state.ss0.min_filter = BRW_MAPFILTER_LINEAR;
593
sampler_state.ss0.mag_filter = BRW_MAPFILTER_LINEAR;
594
sampler_state.ss3.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
595
sampler_state.ss3.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
596
sampler_state.ss3.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
598
return intel_bo_alloc_for_data(intel,
599
&sampler_state, sizeof(sampler_state),
600
"textured video sampler state");
639
603
static drm_intel_bo *i965_create_vs_state(ScrnInfoPtr scrn)
641
605
intel_screen_private *intel = intel_get_screen_private(scrn);
643
struct brw_vs_unit_state *vs_state;
645
if (intel_alloc_and_map(intel, "textured video vs state", 4096,
646
&vs_bo, &vs_state) != 0)
606
struct brw_vs_unit_state vs_state;
649
608
/* Set up the vertex shader to be disabled (passthrough) */
609
memset(&vs_state, 0, sizeof(vs_state));
650
610
if (IS_GEN5(intel))
651
vs_state->thread4.nr_urb_entries = URB_VS_ENTRIES >> 2;
611
vs_state.thread4.nr_urb_entries = URB_VS_ENTRIES >> 2;
653
vs_state->thread4.nr_urb_entries = URB_VS_ENTRIES;
654
vs_state->thread4.urb_entry_allocation_size = URB_VS_ENTRY_SIZE - 1;
655
vs_state->vs6.vs_enable = 0;
656
vs_state->vs6.vert_cache_disable = 1;
613
vs_state.thread4.nr_urb_entries = URB_VS_ENTRIES;
614
vs_state.thread4.urb_entry_allocation_size = URB_VS_ENTRY_SIZE - 1;
615
vs_state.vs6.vs_enable = 0;
616
vs_state.vs6.vert_cache_disable = 1;
658
drm_intel_bo_unmap(vs_bo);
618
return intel_bo_alloc_for_data(intel,
619
&vs_state, sizeof(vs_state),
620
"textured video vs state");
662
623
static drm_intel_bo *i965_create_program(ScrnInfoPtr scrn,
664
625
unsigned int program_size)
666
627
intel_screen_private *intel = intel_get_screen_private(scrn);
667
drm_intel_bo *prog_bo;
669
prog_bo = drm_intel_bo_alloc(intel->bufmgr, "textured video program",
674
drm_intel_bo_subdata(prog_bo, 0, program_size, program);
628
return intel_bo_alloc_for_data(intel,
629
program, program_size,
630
"textured video program");
679
633
static drm_intel_bo *i965_create_sf_state(ScrnInfoPtr scrn)
681
635
intel_screen_private *intel = intel_get_screen_private(scrn);
682
636
drm_intel_bo *sf_bo, *kernel_bo;
683
struct brw_sf_unit_state *sf_state;
637
struct brw_sf_unit_state sf_state;
685
639
if (IS_GEN5(intel))
687
i965_create_program(scrn, &sf_kernel_static_gen5[0][0],
688
sizeof(sf_kernel_static_gen5));
640
kernel_bo = i965_create_program(scrn,
641
&sf_kernel_static_gen5[0][0],
642
sizeof(sf_kernel_static_gen5));
690
kernel_bo = i965_create_program(scrn, &sf_kernel_static[0][0],
644
kernel_bo = i965_create_program(scrn,
645
&sf_kernel_static[0][0],
691
646
sizeof(sf_kernel_static));
696
if (intel_alloc_and_map(intel, "textured video sf state", 4096,
697
&sf_bo, &sf_state) != 0) {
650
sf_bo = drm_intel_bo_alloc(intel->bufmgr,
651
"textured video sf state", 4096,
698
654
drm_intel_bo_unreference(kernel_bo);
703
659
* calculate dA/dx and dA/dy. Hand these interpolation coefficients
704
660
* back to SF which then hands pixels off to WM.
706
sf_state->thread0.grf_reg_count = BRW_GRF_BLOCKS(SF_KERNEL_NUM_GRF);
707
sf_state->thread0.kernel_start_pointer =
662
memset(&sf_state, 0, sizeof(sf_state));
663
sf_state.thread0.grf_reg_count = BRW_GRF_BLOCKS(SF_KERNEL_NUM_GRF);
664
sf_state.thread0.kernel_start_pointer =
708
665
intel_emit_reloc(sf_bo, offsetof(struct brw_sf_unit_state, thread0),
709
kernel_bo, sf_state->thread0.grf_reg_count << 1,
666
kernel_bo, sf_state.thread0.grf_reg_count << 1,
710
667
I915_GEM_DOMAIN_INSTRUCTION, 0) >> 6;
711
sf_state->sf1.single_program_flow = 1; /* XXX */
712
sf_state->sf1.binding_table_entry_count = 0;
713
sf_state->sf1.thread_priority = 0;
714
sf_state->sf1.floating_point_mode = 0; /* Mesa does this */
715
sf_state->sf1.illegal_op_exception_enable = 1;
716
sf_state->sf1.mask_stack_exception_enable = 1;
717
sf_state->sf1.sw_exception_enable = 1;
718
sf_state->thread2.per_thread_scratch_space = 0;
668
sf_state.sf1.single_program_flow = 1; /* XXX */
669
sf_state.sf1.binding_table_entry_count = 0;
670
sf_state.sf1.thread_priority = 0;
671
sf_state.sf1.floating_point_mode = 0; /* Mesa does this */
672
sf_state.sf1.illegal_op_exception_enable = 1;
673
sf_state.sf1.mask_stack_exception_enable = 1;
674
sf_state.sf1.sw_exception_enable = 1;
675
sf_state.thread2.per_thread_scratch_space = 0;
719
676
/* scratch space is not used in our kernel */
720
sf_state->thread2.scratch_space_base_pointer = 0;
721
sf_state->thread3.const_urb_entry_read_length = 0; /* no const URBs */
722
sf_state->thread3.const_urb_entry_read_offset = 0; /* no const URBs */
723
sf_state->thread3.urb_entry_read_length = 1; /* 1 URB per vertex */
724
sf_state->thread3.urb_entry_read_offset = 0;
725
sf_state->thread3.dispatch_grf_start_reg = 3;
726
sf_state->thread4.max_threads = SF_MAX_THREADS - 1;
727
sf_state->thread4.urb_entry_allocation_size = URB_SF_ENTRY_SIZE - 1;
728
sf_state->thread4.nr_urb_entries = URB_SF_ENTRIES;
729
sf_state->thread4.stats_enable = 1;
730
sf_state->sf5.viewport_transform = FALSE; /* skip viewport */
731
sf_state->sf6.cull_mode = BRW_CULLMODE_NONE;
732
sf_state->sf6.scissor = 0;
733
sf_state->sf7.trifan_pv = 2;
734
sf_state->sf6.dest_org_vbias = 0x8;
735
sf_state->sf6.dest_org_hbias = 0x8;
677
sf_state.thread2.scratch_space_base_pointer = 0;
678
sf_state.thread3.const_urb_entry_read_length = 0; /* no const URBs */
679
sf_state.thread3.const_urb_entry_read_offset = 0; /* no const URBs */
680
sf_state.thread3.urb_entry_read_length = 1; /* 1 URB per vertex */
681
sf_state.thread3.urb_entry_read_offset = 0;
682
sf_state.thread3.dispatch_grf_start_reg = 3;
683
sf_state.thread4.max_threads = SF_MAX_THREADS - 1;
684
sf_state.thread4.urb_entry_allocation_size = URB_SF_ENTRY_SIZE - 1;
685
sf_state.thread4.nr_urb_entries = URB_SF_ENTRIES;
686
sf_state.thread4.stats_enable = 1;
687
sf_state.sf5.viewport_transform = FALSE; /* skip viewport */
688
sf_state.sf6.cull_mode = BRW_CULLMODE_NONE;
689
sf_state.sf6.scissor = 0;
690
sf_state.sf7.trifan_pv = 2;
691
sf_state.sf6.dest_org_vbias = 0x8;
692
sf_state.sf6.dest_org_hbias = 0x8;
737
drm_intel_bo_unmap(sf_bo);
694
dri_bo_subdata(sf_bo, 0, sizeof(sf_state), &sf_state);
781
if (intel_alloc_and_map
782
(intel, "textured video wm state", sizeof(*wm_state), &wm_bo,
738
wm_bo = drm_intel_bo_alloc(intel->bufmgr,
739
"textured video wm state",
740
sizeof(wm_state), 0);
784
742
drm_intel_bo_unreference(kernel_bo);
788
wm_state->thread0.grf_reg_count = BRW_GRF_BLOCKS(PS_KERNEL_NUM_GRF);
789
wm_state->thread0.kernel_start_pointer =
746
memset(&wm_state, 0, sizeof(wm_state));
747
wm_state.thread0.grf_reg_count = BRW_GRF_BLOCKS(PS_KERNEL_NUM_GRF);
748
wm_state.thread0.kernel_start_pointer =
790
749
intel_emit_reloc(wm_bo, offsetof(struct brw_wm_unit_state, thread0),
791
kernel_bo, wm_state->thread0.grf_reg_count << 1,
750
kernel_bo, wm_state.thread0.grf_reg_count << 1,
792
751
I915_GEM_DOMAIN_INSTRUCTION, 0) >> 6;
793
wm_state->thread1.single_program_flow = 1; /* XXX */
752
wm_state.thread1.single_program_flow = 1; /* XXX */
795
wm_state->thread1.binding_table_entry_count = 2;
754
wm_state.thread1.binding_table_entry_count = 2;
797
wm_state->thread1.binding_table_entry_count = 7;
756
wm_state.thread1.binding_table_entry_count = 7;
799
758
/* binding table entry count is only used for prefetching, and it has to
800
759
* be set 0 for Ironlake
802
761
if (IS_GEN5(intel))
803
wm_state->thread1.binding_table_entry_count = 0;
762
wm_state.thread1.binding_table_entry_count = 0;
805
764
/* Though we never use the scratch space in our WM kernel, it has to be
806
765
* set, and the minimum allocation is 1024 bytes.
808
wm_state->thread2.scratch_space_base_pointer = 0;
809
wm_state->thread2.per_thread_scratch_space = 0; /* 1024 bytes */
810
wm_state->thread3.dispatch_grf_start_reg = 3; /* XXX */
811
wm_state->thread3.const_urb_entry_read_length = 0;
812
wm_state->thread3.const_urb_entry_read_offset = 0;
813
wm_state->thread3.urb_entry_read_length = 1; /* XXX */
814
wm_state->thread3.urb_entry_read_offset = 0; /* XXX */
815
wm_state->wm4.stats_enable = 1;
816
wm_state->wm4.sampler_state_pointer =
767
wm_state.thread2.scratch_space_base_pointer = 0;
768
wm_state.thread2.per_thread_scratch_space = 0; /* 1024 bytes */
769
wm_state.thread3.dispatch_grf_start_reg = 3; /* XXX */
770
wm_state.thread3.const_urb_entry_read_length = 0;
771
wm_state.thread3.const_urb_entry_read_offset = 0;
772
wm_state.thread3.urb_entry_read_length = 1; /* XXX */
773
wm_state.thread3.urb_entry_read_offset = 0; /* XXX */
774
wm_state.wm4.stats_enable = 1;
775
wm_state.wm4.sampler_state_pointer =
817
776
intel_emit_reloc(wm_bo, offsetof(struct brw_wm_unit_state, wm4),
819
778
I915_GEM_DOMAIN_INSTRUCTION, 0) >> 5;
820
779
if (IS_GEN5(intel))
821
wm_state->wm4.sampler_count = 0;
780
wm_state.wm4.sampler_count = 0;
823
wm_state->wm4.sampler_count = 1; /* 1-4 samplers used */
824
wm_state->wm5.max_threads = PS_MAX_THREADS - 1;
825
wm_state->wm5.thread_dispatch_enable = 1;
826
wm_state->wm5.enable_16_pix = 1;
827
wm_state->wm5.enable_8_pix = 0;
828
wm_state->wm5.early_depth_test = 1;
782
wm_state.wm4.sampler_count = 1; /* 1-4 samplers used */
783
wm_state.wm5.max_threads = PS_MAX_THREADS - 1;
784
wm_state.wm5.thread_dispatch_enable = 1;
785
wm_state.wm5.enable_16_pix = 1;
786
wm_state.wm5.enable_8_pix = 0;
787
wm_state.wm5.early_depth_test = 1;
789
dri_bo_subdata(wm_bo, 0, sizeof(wm_state), &wm_state);
830
790
drm_intel_bo_unreference(kernel_bo);
832
drm_intel_bo_unmap(wm_bo);
836
794
static drm_intel_bo *i965_create_cc_vp_state(ScrnInfoPtr scrn)
838
796
intel_screen_private *intel = intel_get_screen_private(scrn);
839
drm_intel_bo *cc_vp_bo;
840
struct brw_cc_viewport *cc_viewport;
842
if (intel_alloc_and_map(intel, "textured video cc viewport", 4096,
843
&cc_vp_bo, &cc_viewport) != 0)
846
cc_viewport->min_depth = -1.e35;
847
cc_viewport->max_depth = 1.e35;
849
drm_intel_bo_unmap(cc_vp_bo);
797
struct brw_cc_viewport cc_viewport;
799
memset(&cc_viewport, 0, sizeof(cc_viewport));
800
cc_viewport.min_depth = -1.e35;
801
cc_viewport.max_depth = 1.e35;
803
return intel_bo_alloc_for_data(intel,
804
&cc_viewport, sizeof(cc_viewport),
805
"textured video cc viewport");
853
808
static drm_intel_bo *i965_create_cc_state(ScrnInfoPtr scrn)
855
810
intel_screen_private *intel = intel_get_screen_private(scrn);
856
811
drm_intel_bo *cc_bo, *cc_vp_bo;
857
struct brw_cc_unit_state *cc_state;
812
struct brw_cc_unit_state cc_state;
859
814
cc_vp_bo = i965_create_cc_vp_state(scrn);
863
if (intel_alloc_and_map
864
(intel, "textured video cc state", sizeof(*cc_state), &cc_bo,
818
cc_bo = drm_intel_bo_alloc(intel->bufmgr,
819
"textured video cc state",
820
sizeof(cc_state), 0);
866
822
drm_intel_bo_unreference(cc_vp_bo);
870
826
/* Color calculator state */
871
memset(cc_state, 0, sizeof(*cc_state));
872
cc_state->cc0.stencil_enable = 0; /* disable stencil */
873
cc_state->cc2.depth_test = 0; /* disable depth test */
874
cc_state->cc2.logicop_enable = 1; /* enable logic op */
875
cc_state->cc3.ia_blend_enable = 1; /* blend alpha just like colors */
876
cc_state->cc3.blend_enable = 0; /* disable color blend */
877
cc_state->cc3.alpha_test = 0; /* disable alpha test */
878
cc_state->cc4.cc_viewport_state_offset =
827
memset(&cc_state, 0, sizeof(cc_state));
828
cc_state.cc0.stencil_enable = 0; /* disable stencil */
829
cc_state.cc2.depth_test = 0; /* disable depth test */
830
cc_state.cc2.logicop_enable = 1; /* enable logic op */
831
cc_state.cc3.ia_blend_enable = 1; /* blend alpha just like colors */
832
cc_state.cc3.blend_enable = 0; /* disable color blend */
833
cc_state.cc3.alpha_test = 0; /* disable alpha test */
834
cc_state.cc4.cc_viewport_state_offset =
879
835
intel_emit_reloc(cc_bo, offsetof(struct brw_cc_unit_state, cc4),
880
836
cc_vp_bo, 0, I915_GEM_DOMAIN_INSTRUCTION, 0) >> 5;
881
cc_state->cc5.dither_enable = 0; /* disable dither */
882
cc_state->cc5.logicop_func = 0xc; /* WHITE */
883
cc_state->cc5.statistics_enable = 1;
884
cc_state->cc5.ia_blend_function = BRW_BLENDFUNCTION_ADD;
885
cc_state->cc5.ia_src_blend_factor = BRW_BLENDFACTOR_ONE;
886
cc_state->cc5.ia_dest_blend_factor = BRW_BLENDFACTOR_ONE;
888
drm_intel_bo_unmap(cc_bo);
837
cc_state.cc5.dither_enable = 0; /* disable dither */
838
cc_state.cc5.logicop_func = 0xc; /* WHITE */
839
cc_state.cc5.statistics_enable = 1;
840
cc_state.cc5.ia_blend_function = BRW_BLENDFUNCTION_ADD;
841
cc_state.cc5.ia_src_blend_factor = BRW_BLENDFACTOR_ONE;
842
cc_state.cc5.ia_dest_blend_factor = BRW_BLENDFACTOR_ONE;
844
dri_bo_subdata(cc_bo, 0, sizeof(cc_state), &cc_state);
890
845
drm_intel_bo_unreference(cc_vp_bo);
1409
1361
gen6_create_cc_state(ScrnInfoPtr scrn)
1411
1363
intel_screen_private *intel = intel_get_screen_private(scrn);
1412
struct gen6_color_calc_state *cc_state;
1413
drm_intel_bo *cc_bo;
1415
if (intel_alloc_and_map(
1417
"textured video cc state",
1423
cc_state->constant_r = 1.0;
1424
cc_state->constant_g = 0.0;
1425
cc_state->constant_b = 1.0;
1426
cc_state->constant_a = 1.0;
1428
drm_intel_bo_unmap(cc_bo);
1364
struct gen6_color_calc_state cc_state;
1366
memset(&cc_state, 0, sizeof(cc_state));
1367
cc_state.constant_r = 1.0;
1368
cc_state.constant_g = 0.0;
1369
cc_state.constant_b = 1.0;
1370
cc_state.constant_a = 1.0;
1372
return intel_bo_alloc_for_data(intel,
1373
&cc_state, sizeof(cc_state),
1374
"textured video cc state");
1432
1377
static drm_intel_bo *
1433
1378
gen6_create_blend_state(ScrnInfoPtr scrn)
1435
1380
intel_screen_private *intel = intel_get_screen_private(scrn);
1436
struct gen6_blend_state *blend_state;
1437
drm_intel_bo *blend_bo;
1439
if (intel_alloc_and_map(
1441
"textured video blend state",
1442
sizeof(*blend_state),
1447
blend_state->blend1.logic_op_enable = 1;
1448
blend_state->blend1.logic_op_func = 0xc;
1449
blend_state->blend1.pre_blend_clamp_enable = 1;
1451
drm_intel_bo_unmap(blend_bo);
1381
struct gen6_blend_state blend_state;
1383
memset(&blend_state, 0, sizeof(blend_state));
1384
blend_state.blend1.logic_op_enable = 1;
1385
blend_state.blend1.logic_op_func = 0xc;
1386
blend_state.blend1.pre_blend_clamp_enable = 1;
1388
return intel_bo_alloc_for_data(intel,
1389
&blend_state, sizeof(blend_state),
1390
"textured video blend state");
1455
1393
static drm_intel_bo *
1456
1394
gen6_create_depth_stencil_state(ScrnInfoPtr scrn)
1458
1396
intel_screen_private *intel = intel_get_screen_private(scrn);
1459
struct gen6_depth_stencil_state *depth_stencil_state;
1460
drm_intel_bo *depth_stencil_bo;
1462
if (intel_alloc_and_map(
1464
"textured video blend state",
1465
sizeof(*depth_stencil_state),
1467
&depth_stencil_state) != 0)
1470
drm_intel_bo_unmap(depth_stencil_bo);
1471
return depth_stencil_bo;
1397
struct gen6_depth_stencil_state depth_stencil_state;
1399
memset(&depth_stencil_state, 0, sizeof(depth_stencil_state));
1400
return intel_bo_alloc_for_data(intel,
1401
&depth_stencil_state,
1402
sizeof(depth_stencil_state),
1403
"textured video blend state");