summaryrefslogtreecommitdiff
path: root/intel/tests/gen4-3d.batch
blob: e6911a438e740c493b1c7f3670cf1bc650f32e34 (plain)
ofshex dumpascii
0000 00 00 04 61 00 00 09 79 00 00 00 00 00 00 02 61 00 00 00 00 00 00 0b 78 04 00 01 61 01 00 00 00 ...a...y.......a.......x...a....
0020 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 04 00 01 78 20 7e 00 00 00 00 00 00 00 00 00 00 ...................x.~..........
0040 00 00 00 00 20 7e 00 00 03 00 01 79 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 05 79 .....~.....y...................y
0060 ff 05 08 2c 00 00 00 00 c0 4a 58 09 00 00 00 00 05 00 00 78 60 7d 00 00 00 00 00 00 21 7d 00 00 ...,.....JX........x`}......!}..
0080 80 7d 00 00 e0 7d 00 00 c0 7f 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 00 01 60 24 00 00 00 .}...}.......?.`....B......`$...
00a0 02 00 00 79 00 00 00 00 2b 01 2b 01 00 00 00 00 03 00 08 78 0c 00 00 00 00 00 00 00 00 00 00 00 ...y....+.+........x............
00c0 00 00 00 00 01 00 09 78 00 00 40 04 00 00 13 11 00 01 02 60 01 00 00 00 04 18 00 7b 04 00 00 00 .......x..@........`.......{....
00e0 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04 00 01 78 40 7b 00 00 00 00 00 00 00 00 00 00 ...................x@{..........
0100 00 00 00 00 40 7b 00 00 05 00 00 78 a0 7a 00 00 41 7a 00 00 61 7a 00 00 c0 7a 00 00 00 7b 00 00 ....@{.....x.z..Az..az...z...{..
0120 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 03 00 08 78 0c 00 00 00 00 00 00 00 00 00 00 00 .|...?.`....B......x............
0140 00 00 00 00 00 01 02 60 82 00 00 00 04 20 00 7b 52 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 .......`.......{R...............
0160 00 00 00 00 05 00 00 78 a0 7a 00 00 21 7a 00 00 61 7a 00 00 c0 7a 00 00 00 7b 00 00 c0 7c 00 00 .......x.z..!z..az...z...{...|..
0180 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 82 00 00 00 04 1c 00 7b 50 00 00 00 52 00 00 00 .?.`....B......`.......{P...R...
01a0 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 a0 7a 00 00 01 7a 00 00 61 7a 00 00 c0 7a 00 00 ...............x.z...z..az...z..
01c0 00 7b 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 42 01 00 00 04 20 00 7b .{...|...?.`....B......`B......{
01e0 52 00 00 00 a2 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 a0 7a 00 00 e1 79 00 00 R......................x.z...y..
0200 61 7a 00 00 c0 7a 00 00 00 7b 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 az...z...{...|...?.`....B......`
0220 42 01 00 00 04 1c 00 7b 50 00 00 00 f4 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 B......{P......................x
0240 a0 7a 00 00 c1 79 00 00 61 7a 00 00 c0 7a 00 00 00 7b 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 .z...y..az...z...{...|...?.`....
0260 42 00 00 10 00 01 02 60 42 01 00 00 05 00 00 78 a0 79 00 00 c1 79 00 00 61 7a 00 00 c0 7a 00 00 B......`B......x.y...y..az...z..
0280 00 7b 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 03 00 08 78 18 00 00 00 48 0f 00 00 .{...|...?.`....B......x....H...
02a0 00 00 00 00 00 00 00 00 03 00 09 78 00 00 40 04 00 00 13 11 0c 00 40 04 04 00 13 11 00 01 02 60 ...........x..@.......@........`
02c0 02 02 00 00 04 20 00 7b a2 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 .......{.......................x
02e0 a0 79 00 00 00 00 00 00 01 79 00 00 40 79 00 00 60 79 00 00 c0 7c 00 00 00 00 00 00 00 00 00 00 .y.......y..@y..`y...|..........
0300 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 02 02 00 00 04 14 00 7b 2a 00 00 00 a2 00 00 00 .?.`....B......`.......{*.......
0320 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 60 78 00 00 01 78 00 00 21 78 00 00 80 78 00 00 ...............x`x...x..!x...x..
0340 a0 78 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 03 00 08 78 0c 00 00 00 68 22 00 00 .x...|...?.`....B......x....h"..
0360 00 00 00 00 00 00 00 00 01 00 09 78 00 00 40 04 00 00 13 11 00 01 02 60 c2 02 00 00 04 20 00 7b ...........x..@........`.......{
0380 2a 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 60 78 00 00 e1 77 00 00 *......................x`x...w..
03a0 21 78 00 00 80 78 00 00 a0 78 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 !x...x...x...|...?.`....B......`
03c0 c2 02 00 00 04 1c 00 7b 28 00 00 00 2a 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 .......{(...*..................x
03e0 60 78 00 00 c1 77 00 00 21 78 00 00 80 78 00 00 a0 78 00 00 c0 7c 00 00 00 00 00 00 00 00 00 00 `x...w..!x...x...x...|..........
0400 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 82 03 00 00 04 20 00 7b 2a 00 00 00 52 00 00 00 .?.`....B......`.......{*...R...
0420 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 60 78 00 00 a1 77 00 00 21 78 00 00 80 78 00 00 ...............x`x...w..!x...x..
0440 a0 78 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 82 03 00 00 04 1c 00 7b .x...|...?.`....B......`.......{
0460 28 00 00 00 7c 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 60 78 00 00 81 77 00 00 (...|..................x`x...w..
0480 21 78 00 00 80 78 00 00 a0 78 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 !x...x...x...|...?.`....B......`
04a0 82 03 00 00 05 00 00 78 60 77 00 00 81 77 00 00 21 78 00 00 80 78 00 00 a0 78 00 00 c0 7c 00 00 .......x`w...w..!x...x...x...|..
04c0 01 3f 00 60 20 a0 20 03 42 00 00 10 03 00 08 78 18 00 00 00 30 2a 00 00 00 00 00 00 00 00 00 00 .?.`....B......x....0*..........
04e0 03 00 09 78 00 00 40 04 00 00 13 11 0c 00 40 04 04 00 13 11 00 01 02 60 42 04 00 00 04 20 00 7b ...x..@.......@........`B......{
0500 52 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 60 77 00 00 00 00 00 00 R......................x`w......
0520 c1 76 00 00 00 77 00 00 20 77 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 .v...w...w...|...?.`....B......`
0540 42 04 00 00 04 14 00 7b 16 00 00 00 52 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 B......{....R..................x
0560 20 76 00 00 c1 75 00 00 e1 75 00 00 40 76 00 00 60 76 00 00 c0 7c 00 00 00 00 00 00 00 00 00 00 .v...u...u..@v..`v...|..........
0580 01 3f 00 60 20 a0 20 03 42 00 00 10 03 00 08 78 0c 00 00 00 f0 33 00 00 00 00 00 00 00 00 00 00 .?.`....B......x.....3..........
05a0 01 00 09 78 00 00 40 04 00 00 13 11 00 01 02 60 02 05 00 00 04 20 00 7b 2a 00 00 00 00 00 00 00 ...x..@........`.......{*.......
05c0 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 20 76 00 00 a1 75 00 00 e1 75 00 00 40 76 00 00 ...............x.v...u...u..@v..
05e0 60 76 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 02 05 00 00 04 1c 00 7b `v...|...?.`....B......`.......{
0600 28 00 00 00 2a 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 20 76 00 00 81 75 00 00 (...*..................x.v...u..
0620 e1 75 00 00 40 76 00 00 60 76 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 .u..@v..`v...|...?.`....B......`
0640 c2 05 00 00 04 20 00 7b 2a 00 00 00 52 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 .......{*...R..................x
0660 20 76 00 00 61 75 00 00 e1 75 00 00 40 76 00 00 60 76 00 00 c0 7c 00 00 00 00 00 00 00 00 00 00 .v..au...u..@v..`v...|..........
0680 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 c2 05 00 00 04 1c 00 7b 28 00 00 00 7c 00 00 00 .?.`....B......`.......{(...|...
06a0 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 20 76 00 00 41 75 00 00 e1 75 00 00 40 76 00 00 ...............x.v..Au...u..@v..
06c0 60 76 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 c2 05 00 00 05 00 00 78 `v...|...?.`....B......`.......x
06e0 20 75 00 00 41 75 00 00 e1 75 00 00 40 76 00 00 60 76 00 00 c0 7c 00 00 00 00 00 00 00 00 00 00 .u..Au...u..@v..`v...|..........
0700 01 3f 00 60 20 a0 20 03 42 00 00 10 03 00 08 78 18 00 00 00 b8 3b 00 00 00 00 00 00 00 00 00 00 .?.`....B......x.....;..........
0720 03 00 09 78 00 00 40 04 00 00 13 11 0c 00 40 04 04 00 13 11 00 01 02 60 82 06 00 00 04 20 00 7b ...x..@.......@........`.......{
0740 52 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 05 00 00 78 20 75 00 00 00 00 00 00 R......................x.u......
0760 81 74 00 00 c0 74 00 00 e0 74 00 00 c0 7c 00 00 01 3f 00 60 20 a0 20 03 42 00 00 10 00 01 02 60 .t...t...t...|...?.`....B......`
0780 82 06 00 00 04 14 00 7b 16 00 00 00 52 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 .......{....R...................
='n398' href='#n398'>398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771
/*
 * Copyright 2012 Red Hat Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors: Ben Skeggs
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#include <errno.h>

#include <xf86drm.h>
#include <xf86atomic.h>
#include "libdrm_lists.h"
#include "nouveau_drm.h"

#include "nouveau.h"
#include "private.h"

struct nouveau_pushbuf_krec {
	struct nouveau_pushbuf_krec *next;
	struct drm_nouveau_gem_pushbuf_bo buffer[NOUVEAU_GEM_MAX_BUFFERS];
	struct drm_nouveau_gem_pushbuf_reloc reloc[NOUVEAU_GEM_MAX_RELOCS];
	struct drm_nouveau_gem_pushbuf_push push[NOUVEAU_GEM_MAX_PUSH];
	int nr_buffer;
	int nr_reloc;
	int nr_push;
	uint64_t vram_used;
	uint64_t gart_used;
};

struct nouveau_pushbuf_priv {
	struct nouveau_pushbuf base;
	struct nouveau_pushbuf_krec *list;
	struct nouveau_pushbuf_krec *krec;
	struct nouveau_list bctx_list;
	struct nouveau_bo *bo;
	uint32_t type;
	uint32_t suffix0;
	uint32_t suffix1;
	uint32_t *ptr;
	uint32_t *bgn;
	int bo_next;
	int bo_nr;
	struct nouveau_bo *bos[];
};

static inline struct nouveau_pushbuf_priv *
nouveau_pushbuf(struct nouveau_pushbuf *push)
{
	return (struct nouveau_pushbuf_priv *)push;
}

static int pushbuf_validate(struct nouveau_pushbuf *, bool);
static int pushbuf_flush(struct nouveau_pushbuf *);

static bool
pushbuf_kref_fits(struct nouveau_pushbuf *push, struct nouveau_bo *bo,
		  uint32_t *domains)
{
	struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(push);
	struct nouveau_pushbuf_krec *krec = nvpb->krec;
	struct nouveau_device *dev = push->client->device;
	struct nouveau_bo *kbo;
	struct drm_nouveau_gem_pushbuf_bo *kref;
	int i;

	/* VRAM is the only valid domain.  GART and VRAM|GART buffers
	 * are all accounted to GART, so if this doesn't fit in VRAM
	 * straight up, a flush is needed.
	 */
	if (*domains == NOUVEAU_GEM_DOMAIN_VRAM) {
		if (krec->vram_used + bo->size > dev->vram_limit)
			return false;
		krec->vram_used += bo->size;
		return true;
	}

	/* GART or VRAM|GART buffer.  Account both of these buffer types
	 * to GART only for the moment, which simplifies things.  If the
	 * buffer can fit already, we're done here.
	 */
	if (krec->gart_used + bo->size <= dev->gart_limit) {
		krec->gart_used += bo->size;
		return true;
	}

	/* Ran out of GART space, if it's a VRAM|GART buffer and it'll
	 * fit into available VRAM, turn it into a VRAM buffer
	 */
	if ((*domains & NOUVEAU_GEM_DOMAIN_VRAM) &&
	    krec->vram_used + bo->size <= dev->vram_limit) {
		*domains &= NOUVEAU_GEM_DOMAIN_VRAM;
		krec->vram_used += bo->size;
		return true;
	}

	/* Still couldn't fit the buffer in anywhere, so as a last resort;
	 * scan the buffer list for VRAM|GART buffers and turn them into
	 * VRAM buffers until we have enough space in GART for this one
	 */
	kref = krec->buffer;
	for (i = 0; i < krec->nr_buffer; i++, kref++) {
		if (!(kref->valid_domains & NOUVEAU_GEM_DOMAIN_GART))
			continue;

		kbo = (void *)(unsigned long)kref->user_priv;
		if (!(kref->valid_domains & NOUVEAU_GEM_DOMAIN_VRAM) ||
		    krec->vram_used + kbo->size > dev->vram_limit)
			continue;

		kref->valid_domains &= NOUVEAU_GEM_DOMAIN_VRAM;
		krec->gart_used -= kbo->size;
		krec->vram_used += kbo->size;
		if (krec->gart_used + bo->size <= dev->gart_limit) {
			krec->gart_used += bo->size;
			return true;
		}
	}

	/* Couldn't resolve a placement, need to force a flush */
	return false;
}

static struct drm_nouveau_gem_pushbuf_bo *
pushbuf_kref(struct nouveau_pushbuf *push, struct nouveau_bo *bo,
	     uint32_t flags)
{
	struct nouveau_device *dev = push->client->device;
	struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(push);
	struct nouveau_pushbuf_krec *krec = nvpb->krec;
	struct nouveau_pushbuf *fpush;
	struct drm_nouveau_gem_pushbuf_bo *kref;
	uint32_t domains, domains_wr, domains_rd;

	domains = 0;
	if (flags & NOUVEAU_BO_VRAM)
		domains |= NOUVEAU_GEM_DOMAIN_VRAM;
	if (flags & NOUVEAU_BO_GART)