summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nouveau/nouveau_context.c
blob: 15174983e7ffae78acbdbccb435e5a4525a26530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "pipe/p_defines.h"
#include "pipe/p_context.h"

#include "nouveau/nouveau_screen.h"
#include "nouveau/nouveau_context.h"

#include "nouveau/nouveau_bo.h"

static unsigned int
nouveau_reference_flags(struct nouveau_bo *bo)
{
	uint32_t bo_flags;
	int flags = 0;

	bo_flags = nouveau_bo_pending(bo);
	if (bo_flags & NOUVEAU_BO_RD)
		flags |= PIPE_REFERENCED_FOR_READ;
	if (bo_flags & NOUVEAU_BO_WR)
		flags |= PIPE_REFERENCED_FOR_WRITE;

	return flags;
}

unsigned int
nouveau_is_texture_referenced(struct pipe_context *pipe,
			      struct pipe_texture *pt,
			      unsigned face, unsigned level)
{
	struct nouveau_miptree *mt = nouveau_miptree(pt);

	return nouveau_reference_flags(mt->bo);
}

unsigned int
nouveau_is_buffer_referenced(struct pipe_context *pipe, struct pipe_buffer *pb)
{
	struct nouveau_bo *bo = nouveau_bo(pb);

	return nouveau_reference_flags(bo);
}