blob: e70bfe7b44e336911701a9c69db734d748236702 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#include "intel_drm_winsys.h"
#include "util/u_memory.h"
#include "pipe/p_refcnt.h"
/**
* Because gem does not have fence's we have to create our own fences.
*
* They work by keeping the batchbuffer around and checking if that has
* been idled. If bo is NULL fence has expired.
*/
struct intel_drm_fence
{
struct pipe_reference reference;
drm_intel_bo *bo;
};
struct pipe_fence_handle *
intel_drm_fence_create(drm_intel_bo *bo)
{
struct intel_drm_fence *fence = CALLOC_STRUCT(intel_drm_fence);
pipe_reference_init(&fence->reference, 1);
/* bo is null if fence already expired */
if (bo) {
drm_intel_bo_reference(bo);
fence->bo = bo;
}
return (struct pipe_fence_handle *)fence;
}
static void
intel_drm_fence_reference(struct intel_winsys *iws,
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *fence)
{
struct intel_drm_fence *old = (struct intel_drm_fence *)*ptr;
struct intel_drm_fence *f = (struct intel_drm_fence *)fence;
if (pipe_reference((struct pipe_reference**)ptr, &f->reference)) {
if (old->bo)
drm_intel_bo_unreference(old->bo);
FREE(old);
}
}
static int
intel_drm_fence_signalled(struct intel_winsys *iws,
struct pipe_fence_handle *fence)
{
assert(0);
return 0;
}
static int
intel_drm_fence_finish(struct intel_winsys *iws,
struct pipe_fence_handle *fence)
{
struct intel_drm_fence *f = (struct intel_drm_fence *)fence;
/* fence already expired */
if (!f->bo)
return 0;
drm_intel_bo_wait_rendering(f->bo);
drm_intel_bo_unreference(f->bo);
f->bo = NULL;
return 0;
}
void
intel_drm_winsys_init_fence_functions(struct intel_drm_winsys *idws)
{
idws->base.fence_reference = intel_drm_fence_reference;
idws->base.fence_signalled = intel_drm_fence_signalled;
idws->base.fence_finish = intel_drm_fence_finish;
}
|