Subversion Repositories Kolibri OS

Rev

Rev 4359 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4359 Rev 4501
Line 69... Line 69...
69
 
69
 
70
	struct list list;
70
	struct list list;
71
	struct list request;
71
	struct list request;
Line 72... Line 72...
72
	struct list vma;
72
	struct list vma;
73
 
73
 
74
    void     *map;
-
 
75
#define IS_CPU_MAP(ptr) ((uintptr_t)(ptr) & 1)
74
	void *map__cpu;
Line 76... Line 75...
76
#define IS_GTT_MAP(ptr) (ptr && ((uintptr_t)(ptr) & 1) == 0)
75
	void *map__gtt;
77
#define MAP(ptr) ((void*)((uintptr_t)(ptr) & ~3))
76
#define MAP(ptr) ((void*)((uintptr_t)(ptr) & ~3))
78
 
77
 
79
	struct kgem_bo_binding {
78
	struct kgem_bo_binding {
80
		struct kgem_bo_binding *next;
79
		struct kgem_bo_binding *next;
Line -... Line 80...
-
 
80
		uint32_t format;
81
		uint32_t format;
81
		uint16_t offset;
82
		uint16_t offset;
82
	} binding;
83
	} binding;
83
 
84
 
84
	uint64_t presumed_offset;
85
	uint32_t unique_id;
-
 
86
	uint32_t refcnt;
85
	uint32_t unique_id;
87
	uint32_t handle;
86
	uint32_t refcnt;
88
	uint32_t target_handle;
87
	uint32_t handle;
89
	uint32_t presumed_offset;
88
	uint32_t target_handle;
90
	uint32_t delta;
89
	uint32_t delta;
Line 198... Line 197...
198
	uint32_t has_wt :1;
197
	uint32_t has_wt :1;
199
	uint32_t has_no_reloc :1;
198
	uint32_t has_no_reloc :1;
200
	uint32_t has_handle_lut :1;
199
	uint32_t has_handle_lut :1;
Line 201... Line 200...
201
 
200
 
-
 
201
	uint32_t can_blt_cpu :1;
Line 202... Line 202...
202
	uint32_t can_blt_cpu :1;
202
	uint32_t can_render_y :1;
203
 
203
 
204
	uint16_t fence_max;
204
	uint16_t fence_max;
205
	uint16_t half_cpu_cache_pages;
205
	uint16_t half_cpu_cache_pages;
206
	uint32_t aperture_total, aperture_high, aperture_low, aperture_mappable;
206
	uint32_t aperture_total, aperture_high, aperture_low, aperture_mappable;
207
	uint32_t aperture, aperture_fenced;
207
	uint32_t aperture, aperture_fenced, aperture_max_fence;
208
	uint32_t max_upload_tile_size, max_copy_tile_size;
208
	uint32_t max_upload_tile_size, max_copy_tile_size;
209
	uint32_t max_gpu_size, max_cpu_size;
209
	uint32_t max_gpu_size, max_cpu_size;
Line 311... Line 311...
311
				   int width,
311
				   int width,
312
				   int height,
312
				   int height,
313
				   int bpp,
313
				   int bpp,
314
				   uint32_t flags);
314
				   uint32_t flags);
Line -... Line 315...
-
 
315
 
-
 
316
bool kgem_bo_convert_to_gpu(struct kgem *kgem, struct kgem_bo *bo);
315
 
317
 
316
uint32_t kgem_bo_get_binding(struct kgem_bo *bo, uint32_t format);
318
uint32_t kgem_bo_get_binding(struct kgem_bo *bo, uint32_t format);
Line 317... Line 319...
317
void kgem_bo_set_binding(struct kgem_bo *bo, uint32_t format, uint16_t offset);
319
void kgem_bo_set_binding(struct kgem_bo *bo, uint32_t format, uint16_t offset);
Line 347... Line 349...
347
{
349
{
348
	if (kgem->nbatch)
350
	if (kgem->nbatch)
349
		_kgem_submit(kgem);
351
		_kgem_submit(kgem);
350
}
352
}
Line 351... Line -...
351
 
-
 
352
static inline bool kgem_flush(struct kgem *kgem, bool flush)
-
 
353
{
-
 
354
	if (kgem->nreloc == 0)
-
 
355
		return false;
-
 
356
 
-
 
357
	return (kgem->flush ^ flush) && kgem_ring_is_idle(kgem, kgem->ring);
-
 
358
}
-
 
359
 
353
 
360
static inline void kgem_bo_submit(struct kgem *kgem, struct kgem_bo *bo)
354
static inline void kgem_bo_submit(struct kgem *kgem, struct kgem_bo *bo)
361
{
355
{
362
	if (bo->exec)
356
	if (bo->exec)
363
		_kgem_submit(kgem);
357
		_kgem_submit(kgem);
Line 390... Line 384...
390
 
384
 
391
#if DEBUG_FLUSH_BATCH
385
#if DEBUG_FLUSH_BATCH
392
	kgem_submit(kgem);
386
	kgem_submit(kgem);
Line 393... Line 387...
393
#endif
387
#endif
-
 
388
 
394
 
389
	if (kgem->nreloc && bo->exec == NULL && kgem_ring_is_idle(kgem, kgem->ring)) {
-
 
390
		DBG(("%s: flushing before new bo\n", __FUNCTION__));
Line 395... Line 391...
395
	if (kgem->nreloc && bo->exec == NULL && kgem_ring_is_idle(kgem, kgem->ring))
391
		_kgem_submit(kgem);
396
		_kgem_submit(kgem);
392
	}
Line 397... Line 393...
397
 
393
 
Line 464... Line 460...
464
uint32_t kgem_add_reloc(struct kgem *kgem,
460
uint32_t kgem_add_reloc(struct kgem *kgem,
465
			uint32_t pos,
461
			uint32_t pos,
466
			struct kgem_bo *bo,
462
			struct kgem_bo *bo,
467
			uint32_t read_write_domains,
463
			uint32_t read_write_domains,
468
			uint32_t delta);
464
			uint32_t delta);
-
 
465
uint64_t kgem_add_reloc64(struct kgem *kgem,
-
 
466
			  uint32_t pos,
-
 
467
			  struct kgem_bo *bo,
-
 
468
			  uint32_t read_write_domains,
-
 
469
			  uint64_t delta);
Line 469... Line 470...
469
 
470
 
470
void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo);
471
void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo);
471
void *kgem_bo_map__async(struct kgem *kgem, struct kgem_bo *bo);
472
void *kgem_bo_map__async(struct kgem *kgem, struct kgem_bo *bo);
472
void *kgem_bo_map__gtt(struct kgem *kgem, struct kgem_bo *bo);
473
void *kgem_bo_map__gtt(struct kgem *kgem, struct kgem_bo *bo);
473
void kgem_bo_sync__gtt(struct kgem *kgem, struct kgem_bo *bo);
474
void kgem_bo_sync__gtt(struct kgem *kgem, struct kgem_bo *bo);
474
void *kgem_bo_map__debug(struct kgem *kgem, struct kgem_bo *bo);
475
void *kgem_bo_map__debug(struct kgem *kgem, struct kgem_bo *bo);
475
void *kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo);
476
void *kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo);
476
void kgem_bo_sync__cpu(struct kgem *kgem, struct kgem_bo *bo);
477
void kgem_bo_sync__cpu(struct kgem *kgem, struct kgem_bo *bo);
477
void kgem_bo_sync__cpu_full(struct kgem *kgem, struct kgem_bo *bo, bool write);
-
 
478
void *__kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo);
-
 
479
void __kgem_bo_unmap__cpu(struct kgem *kgem, struct kgem_bo *bo, void *ptr);
478
void kgem_bo_sync__cpu_full(struct kgem *kgem, struct kgem_bo *bo, bool write);
Line 480... Line 479...
480
uint32_t kgem_bo_flink(struct kgem *kgem, struct kgem_bo *bo);
479
uint32_t kgem_bo_flink(struct kgem *kgem, struct kgem_bo *bo);
481
 
480
 
Line 482... Line 481...
482
bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo,
481
bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo,
483
		   const void *data, int length);
482
		   const void *data, int length);
484
 
483
 
Line 485... Line 484...
485
int kgem_bo_fenced_size(struct kgem *kgem, struct kgem_bo *bo);
484
int kgem_bo_fenced_size(struct kgem *kgem, struct kgem_bo *bo);
486
void kgem_get_tile_size(struct kgem *kgem, int tiling,
485
void kgem_get_tile_size(struct kgem *kgem, int tiling, int pitch,
487
			int *tile_width, int *tile_height, int *tile_size);
486
			int *tile_width, int *tile_height, int *tile_size);
Line 496... Line 495...
496
{
495
{
497
	assert(bo->proxy == NULL);
496
	assert(bo->proxy == NULL);
498
	return PAGE_SIZE * bo->size.pages.count;
497
	return PAGE_SIZE * bo->size.pages.count;
499
}
498
}
Line -... Line 499...
-
 
499
 
-
 
500
static inline int __kgem_bo_num_pages(struct kgem_bo *bo)
-
 
501
{
-
 
502
	assert(bo->proxy == NULL);
-
 
503
	return bo->size.pages.count;
-
 
504
}
500
 
505
 
501
static inline int kgem_bo_size(struct kgem_bo *bo)
506
static inline int kgem_bo_size(struct kgem_bo *bo)
502
{
507
{
503
	if (bo->proxy)
508
	if (bo->proxy)
504
		return __kgem_buffer_size(bo);
509
		return __kgem_buffer_size(bo);
505
	else
510
	else
506
		return __kgem_bo_size(bo);
511
		return __kgem_bo_size(bo);
Line 507... Line -...
507
}
-
 
508
 
512
}
509
/*
513
 
510
static inline bool kgem_bo_blt_pitch_is_ok(struct kgem *kgem,
514
static inline bool kgem_bo_blt_pitch_is_ok(struct kgem *kgem,
511
					   struct kgem_bo *bo)
515
					   struct kgem_bo *bo)
512
{
516
{
Line 531... Line 535...
531
		return false;
535
		return false;
532
	}
536
	}
Line 533... Line 537...
533
 
537
 
534
	return kgem_bo_blt_pitch_is_ok(kgem, bo);
538
	return kgem_bo_blt_pitch_is_ok(kgem, bo);
535
}
-
 
536
*/
-
 
537
 
-
 
538
static inline bool __kgem_bo_is_mappable(struct kgem *kgem,
-
 
539
				       struct kgem_bo *bo)
-
 
540
{
-
 
541
	if (bo->domain == DOMAIN_GTT)
-
 
542
		return true;
-
 
543
 
-
 
544
	if (kgem->gen < 040 && bo->tiling &&
-
 
545
	    bo->presumed_offset & (kgem_bo_fenced_size(kgem, bo) - 1))
-
 
546
		return false;
-
 
547
 
-
 
548
	if (kgem->gen == 021 && bo->tiling == I915_TILING_Y)
-
 
549
		return false;
-
 
550
 
-
 
551
	if (kgem->has_llc && bo->tiling == I915_TILING_NONE)
-
 
552
		return true;
-
 
553
 
-
 
554
	if (!bo->presumed_offset)
-
 
555
		return kgem_bo_size(bo) <= kgem->aperture_mappable / 4;
-
 
556
 
-
 
557
	return bo->presumed_offset + kgem_bo_size(bo) <= kgem->aperture_mappable;
-
 
558
}
-
 
559
 
-
 
560
static inline bool kgem_bo_is_mappable(struct kgem *kgem,
-
 
561
				       struct kgem_bo *bo)
-
 
562
{
-
 
563
	DBG(("%s: domain=%d, offset: %d size: %d\n",
-
 
564
	     __FUNCTION__, bo->domain, bo->presumed_offset, kgem_bo_size(bo)));
-
 
565
	assert(bo->refcnt);
-
 
566
	return __kgem_bo_is_mappable(kgem, bo);
-
 
567
}
-
 
568
 
-
 
569
static inline bool kgem_bo_mapped(struct kgem *kgem, struct kgem_bo *bo)
-
 
570
{
-
 
571
	DBG(("%s: map=%p, tiling=%d, domain=%d\n",
-
 
572
	     __FUNCTION__, bo->map, bo->tiling, bo->domain));
-
 
573
	assert(bo->refcnt);
-
 
574
 
-
 
575
	if (bo->map == NULL)
-
 
576
		return bo->tiling == I915_TILING_NONE && bo->domain == DOMAIN_CPU;
-
 
577
 
-
 
578
	return IS_CPU_MAP(bo->map) == !bo->tiling;
-
 
579
}
-
 
580
 
-
 
581
static inline bool kgem_bo_can_map(struct kgem *kgem, struct kgem_bo *bo)
-
 
582
{
-
 
583
	if (kgem_bo_mapped(kgem, bo))
-
 
584
		return true;
-
 
585
 
-
 
586
	if (!bo->tiling && (kgem->has_llc || bo->domain == DOMAIN_CPU))
-
 
587
		return true;
-
 
588
 
-
 
589
	if (kgem->gen == 021 && bo->tiling == I915_TILING_Y)
-
 
590
		return false;
-
 
591
 
-
 
592
	return kgem_bo_size(bo) <= kgem->aperture_mappable / 4;
-
 
593
}
-
 
594
 
-
 
595
static inline bool kgem_bo_can_map__cpu(struct kgem *kgem,
-
 
596
					struct kgem_bo *bo,
-
 
597
					bool write)
-
 
598
{
-
 
599
	if (bo->purged || (bo->scanout && write))
-
 
600
		return false;
-
 
601
 
-
 
602
	if (kgem->has_llc)
-
 
603
		return true;
-
 
604
 
-
 
605
	if (bo->domain != DOMAIN_CPU)
-
 
606
		return false;
-
 
607
 
-
 
608
	return !write || bo->exec == NULL;
-
 
Line 609... Line 539...
609
}
539
}
610
 
540
 
611
static inline bool kgem_bo_is_snoop(struct kgem_bo *bo)
541
static inline bool kgem_bo_is_snoop(struct kgem_bo *bo)
612
{
542
{
Line 650... Line 580...
650
	assert(bo->refcnt);
580
	assert(bo->refcnt);
Line 651... Line 581...
651
 
581
 
652
	if (bo->exec)
582
	if (bo->exec)
Line 653... Line -...
653
		return true;
-
 
654
 
-
 
655
	if (kgem_flush(kgem, bo->flush))
-
 
656
		kgem_submit(kgem);
583
		return true;
657
 
584
 
Line 658... Line 585...
658
	if (bo->rq && !__kgem_busy(kgem, bo->handle))
585
	if (bo->rq && !__kgem_busy(kgem, bo->handle))
659
		__kgem_bo_clear_busy(bo);
586
		__kgem_bo_clear_busy(bo);
Line 721... Line 648...
721
 
648
 
722
		__kgem_bo_mark_dirty(bo);
649
		__kgem_bo_mark_dirty(bo);
723
	} while ((bo = bo->proxy));
650
	} while ((bo = bo->proxy));
Line -... Line 651...
-
 
651
}
-
 
652
 
-
 
653
static inline bool kgem_bo_mapped(struct kgem *kgem, struct kgem_bo *bo)
-
 
654
{
-
 
655
	DBG(("%s: map=%p:%p, tiling=%d, domain=%d\n",
-
 
656
	     __FUNCTION__, bo->map__gtt, bo->map__cpu, bo->tiling, bo->domain));
-
 
657
 
-
 
658
	if (bo->tiling == I915_TILING_NONE && (bo->domain == DOMAIN_CPU || kgem->has_llc))
-
 
659
		return bo->map__cpu != NULL;
-
 
660
 
-
 
661
	return bo->map__gtt != NULL;
-
 
662
}
-
 
663
 
-
 
664
static inline bool kgem_bo_can_map(struct kgem *kgem, struct kgem_bo *bo)
-
 
665
{
-
 
666
	DBG(("%s: map=%p:%p, tiling=%d, domain=%d, offset=%ld\n",
-
 
667
	     __FUNCTION__, bo->map__gtt, bo->map__cpu, bo->tiling, bo->domain, (long)bo->presumed_offset));
-
 
668
 
-
 
669
	if (!bo->tiling && (kgem->has_llc || bo->domain == DOMAIN_CPU))
-
 
670
		return true;
-
 
671
 
-
 
672
	if (bo->map__gtt != NULL)
-
 
673
		return true;
-
 
674
 
-
 
675
	if (kgem->gen == 021 && bo->tiling == I915_TILING_Y)
-
 
676
		return false;
-
 
677
 
-
 
678
	if (!bo->presumed_offset)
-
 
679
		return __kgem_bo_num_pages(bo) <= kgem->aperture_mappable / 4;
-
 
680
 
-
 
681
	return bo->presumed_offset / PAGE_SIZE + __kgem_bo_num_pages(bo) <= kgem->aperture_mappable;
-
 
682
}
-
 
683
 
-
 
684
static inline bool kgem_bo_can_map__cpu(struct kgem *kgem,
-
 
685
					struct kgem_bo *bo,
-
 
686
					bool write)
-
 
687
{
-
 
688
	if (bo->purged || (bo->scanout && write))
-
 
689
		return false;
-
 
690
 
-
 
691
	if (kgem->has_llc)
-
 
692
		return true;
-
 
693
 
-
 
694
	if (bo->domain != DOMAIN_CPU)
-
 
695
		return false;
-
 
696
 
-
 
697
	return !write || bo->exec == NULL;
724
}
698
}
725
 
699
 
726
#define KGEM_BUFFER_WRITE	0x1
700
#define KGEM_BUFFER_WRITE	0x1
Line 727... Line 701...
727
#define KGEM_BUFFER_INPLACE	0x2
701
#define KGEM_BUFFER_INPLACE	0x2
Line 740... Line 714...
740
void kgem_buffer_read_sync(struct kgem *kgem, struct kgem_bo *bo);
714
void kgem_buffer_read_sync(struct kgem *kgem, struct kgem_bo *bo);
Line 741... Line 715...
741
 
715
 
742
void kgem_throttle(struct kgem *kgem);
716
void kgem_throttle(struct kgem *kgem);
743
#define MAX_INACTIVE_TIME 10
717
#define MAX_INACTIVE_TIME 10
744
bool kgem_expire_cache(struct kgem *kgem);
-
 
745
void kgem_purge_cache(struct kgem *kgem);
718
bool kgem_expire_cache(struct kgem *kgem);
Line 746... Line 719...
746
void kgem_cleanup_cache(struct kgem *kgem);
719
bool kgem_cleanup_cache(struct kgem *kgem);
747
 
720
 
Line 748... Line 721...
748
void kgem_clean_scanout_cache(struct kgem *kgem);
721
void kgem_clean_scanout_cache(struct kgem *kgem);
Line 756... Line 729...
756
	(void)kgem;
729
	(void)kgem;
757
	(void)nbatch;
730
	(void)nbatch;
758
}
731
}
759
#endif
732
#endif
Line -... Line 733...
-
 
733
 
-
 
734
void choose_memcpy_tiled_x(struct kgem *kgem, int swizzling);
760
 
735