Lines Matching full:fence
34 nouveau_fence_new(struct nouveau_screen *screen, struct nouveau_fence **fence,
37 *fence = CALLOC_STRUCT(nouveau_fence);
38 if (!*fence)
41 (*fence)->screen = screen;
42 (*fence)->ref = 1;
43 LIST_INITHEAD(&(*fence)->work);
46 nouveau_fence_emit(*fence);
52 nouveau_fence_trigger_work(struct nouveau_fence *fence)
56 LIST_FOR_EACH_ENTRY_SAFE(work, tmp, &fence->work, list) {
64 nouveau_fence_work(struct nouveau_fence *fence,
69 if (!fence || fence->state == NOUVEAU_FENCE_STATE_SIGNALLED) {
79 LIST_ADD(&work->list, &fence->work);
84 nouveau_fence_emit(struct nouveau_fence *fence)
86 struct nouveau_screen *screen = fence->screen;
88 assert(fence->state == NOUVEAU_FENCE_STATE_AVAILABLE);
90 /* set this now, so that if fence.emit triggers a flush we don't recurse */
91 fence->state = NOUVEAU_FENCE_STATE_EMITTING;
93 ++fence->ref;
95 if (screen->fence.tail)
96 screen->fence.tail->next = fence;
98 screen->fence.head = fence;
100 screen->fence.tail = fence;
102 screen->fence.emit(&screen->base, &fence->sequence);
104 assert(fence->state == NOUVEAU_FENCE_STATE_EMITTING);
105 fence->state = NOUVEAU_FENCE_STATE_EMITTED;
109 nouveau_fence_del(struct nouveau_fence *fence)
112 struct nouveau_screen *screen = fence->screen;
114 if (fence->state == NOUVEAU_FENCE_STATE_EMITTED ||
115 fence->state == NOUVEAU_FENCE_STATE_FLUSHED) {
116 if (fence == screen->fence.head) {
117 screen->fence.head = fence->next;
118 if (!screen->fence.head)
119 screen->fence.tail = NULL;
121 for (it = screen->fence.head; it && it->next != fence; it = it->next);
122 it->next = fence->next;
123 if (screen->fence.tail == fence)
124 screen->fence.tail = it;
128 if (!LIST_IS_EMPTY(&fence->work)) {
129 debug_printf("WARNING: deleting fence with work still pending !\n");
130 nouveau_fence_trigger_work(fence);
133 FREE(fence);
139 struct nouveau_fence *fence;
141 u32 sequence = screen->fence.update(&screen->base);
143 if (screen->fence.sequence_ack == sequence)
145 screen->fence.sequence_ack = sequence;
147 for (fence = screen->fence.head; fence; fence = next) {
148 next = fence->next;
149 sequence = fence->sequence;
151 fence->state = NOUVEAU_FENCE_STATE_SIGNALLED;
153 nouveau_fence_trigger_work(fence);
154 nouveau_fence_ref(NULL, &fence);
156 if (sequence == screen->fence.sequence_ack)
159 screen->fence.head = next;
161 screen->fence.tail = NULL;
164 for (fence = next; fence; fence = fence->next)
165 if (fence->state == NOUVEAU_FENCE_STATE_EMITTED)
166 fence->state = NOUVEAU_FENCE_STATE_FLUSHED;
173 nouveau_fence_signalled(struct nouveau_fence *fence)
175 struct nouveau_screen *screen = fence->screen;
177 if (fence->state >= NOUVEAU_FENCE_STATE_EMITTED)
180 return fence->state == NOUVEAU_FENCE_STATE_SIGNALLED;
184 nouveau_fence_wait(struct nouveau_fence *fence)
186 struct nouveau_screen *screen = fence->screen;
189 /* wtf, someone is waiting on a fence in flush_notify handler? */
190 assert(fence->state != NOUVEAU_FENCE_STATE_EMITTING);
192 if (fence->state < NOUVEAU_FENCE_STATE_EMITTED) {
193 nouveau_fence_emit(fence);
195 if (fence == screen->fence.current)
196 nouveau_fence_new(screen, &screen->fence.current, FALSE);
198 if (fence->state < NOUVEAU_FENCE_STATE_FLUSHED)
204 if (fence->state == NOUVEAU_FENCE_STATE_SIGNALLED)
213 debug_printf("Wait on fence %u (ack = %u, next = %u) timed out !\n",
214 fence->sequence,
215 screen->fence.sequence_ack, screen->fence.sequence);
223 if (screen->fence.current->state < NOUVEAU_FENCE_STATE_EMITTING)
224 nouveau_fence_emit(screen->fence.current);
226 nouveau_fence_ref(NULL, &screen->fence.current);
228 nouveau_fence_new(screen, &screen->fence.current, FALSE);