15174983e7ffae78acbdbccb435e5a4525a26530
[profile/ivi/mesa.git] / src / gallium / drivers / nouveau / nouveau_context.c
1 #include "pipe/p_defines.h"
2 #include "pipe/p_context.h"
3
4 #include "nouveau/nouveau_screen.h"
5 #include "nouveau/nouveau_context.h"
6
7 #include "nouveau/nouveau_bo.h"
8
9 static unsigned int
10 nouveau_reference_flags(struct nouveau_bo *bo)
11 {
12         uint32_t bo_flags;
13         int flags = 0;
14
15         bo_flags = nouveau_bo_pending(bo);
16         if (bo_flags & NOUVEAU_BO_RD)
17                 flags |= PIPE_REFERENCED_FOR_READ;
18         if (bo_flags & NOUVEAU_BO_WR)
19                 flags |= PIPE_REFERENCED_FOR_WRITE;
20
21         return flags;
22 }
23
24 unsigned int
25 nouveau_is_texture_referenced(struct pipe_context *pipe,
26                               struct pipe_texture *pt,
27                               unsigned face, unsigned level)
28 {
29         struct nouveau_miptree *mt = nouveau_miptree(pt);
30
31         return nouveau_reference_flags(mt->bo);
32 }
33
34 unsigned int
35 nouveau_is_buffer_referenced(struct pipe_context *pipe, struct pipe_buffer *pb)
36 {
37         struct nouveau_bo *bo = nouveau_bo(pb);
38
39         return nouveau_reference_flags(bo);
40 }
41