• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #ifndef __NOUVEAU_FENCE_H__
3 #define __NOUVEAU_FENCE_H__
4 
5 #include "util/u_inlines.h"
6 #include "util/list.h"
7 
8 #define NOUVEAU_FENCE_STATE_AVAILABLE 0
9 #define NOUVEAU_FENCE_STATE_EMITTING  1
10 #define NOUVEAU_FENCE_STATE_EMITTED   2
11 #define NOUVEAU_FENCE_STATE_FLUSHED   3
12 #define NOUVEAU_FENCE_STATE_SIGNALLED 4
13 
14 struct pipe_debug_callback;
15 
16 struct nouveau_fence_work {
17    struct list_head list;
18    void (*func)(void *);
19    void *data;
20 };
21 
22 struct nouveau_fence {
23    struct nouveau_fence *next;
24    struct nouveau_screen *screen;
25    int state;
26    int ref;
27    uint32_t sequence;
28    uint32_t work_count;
29    struct list_head work;
30 };
31 
32 void nouveau_fence_emit(struct nouveau_fence *);
33 void nouveau_fence_del(struct nouveau_fence *);
34 
35 bool nouveau_fence_new(struct nouveau_screen *, struct nouveau_fence **);
36 bool nouveau_fence_work(struct nouveau_fence *, void (*)(void *), void *);
37 void nouveau_fence_update(struct nouveau_screen *, bool flushed);
38 void nouveau_fence_next(struct nouveau_screen *);
39 bool nouveau_fence_wait(struct nouveau_fence *, struct pipe_debug_callback *);
40 bool nouveau_fence_signalled(struct nouveau_fence *);
41 
42 void nouveau_fence_unref_bo(void *data); /* generic unref bo callback */
43 
44 
45 static inline void
nouveau_fence_ref(struct nouveau_fence * fence,struct nouveau_fence ** ref)46 nouveau_fence_ref(struct nouveau_fence *fence, struct nouveau_fence **ref)
47 {
48    if (fence)
49       ++fence->ref;
50 
51    if (*ref) {
52       if (--(*ref)->ref == 0)
53          nouveau_fence_del(*ref);
54    }
55 
56    *ref = fence;
57 }
58 
59 static inline struct nouveau_fence *
nouveau_fence(struct pipe_fence_handle * fence)60 nouveau_fence(struct pipe_fence_handle *fence)
61 {
62    return (struct nouveau_fence *)fence;
63 }
64 
65 #endif // __NOUVEAU_FENCE_H__
66