blob: 1af39674f495123f49a6471ccbb510497d98a888 (
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
 | 
/*
 * Authors: Jakob Bornecrantz <jakob-at-tungstengraphics.com>
 */
#include "ws_dri_fencemgr.h"
#include "intel_be_device.h"
#include "intel_be_context.h"
#include "intel_be_batchbuffer.h"
static INLINE struct intel_be_context *
intel_be_context(struct i915_winsys *sws)
{
	return (struct intel_be_context *)sws;
}
/* Simple batchbuffer interface:
 */
static struct i915_batchbuffer*
intel_i915_batch_get(struct i915_winsys *sws)
{
	struct intel_be_context *intel = intel_be_context(sws);
	return &intel->batch->base;
}
static void intel_i915_batch_reloc(struct i915_winsys *sws,
				   struct pipe_buffer *buf,
				   unsigned access_flags,
				   unsigned delta)
{
	struct intel_be_context *intel = intel_be_context(sws);
	unsigned flags = DRM_BO_FLAG_MEM_TT;
	unsigned mask = DRM_BO_MASK_MEM;
	if (access_flags & I915_BUFFER_ACCESS_WRITE) {
		flags |= DRM_BO_FLAG_WRITE;
		mask |= DRM_BO_FLAG_WRITE;
	}
	if (access_flags & I915_BUFFER_ACCESS_READ) {
		flags |= DRM_BO_FLAG_READ;
		mask |= DRM_BO_FLAG_READ;
	}
	intel_be_offset_relocation(intel->batch,
				delta,
				dri_bo(buf),
				flags,
				mask);
}
static void intel_i915_batch_flush(struct i915_winsys *sws,
				   struct pipe_fence_handle **fence)
{
	struct intel_be_context *intel = intel_be_context(sws);
	union {
		struct _DriFenceObject *dri;
		struct pipe_fence_handle *pipe;
	} fu;
	if (fence)
		assert(!*fence);
	fu.dri = intel_be_batchbuffer_flush(intel->batch);
	if (!fu.dri) {
		assert(0);
		*fence = NULL;
		return;
	}
	if (fu.dri) {
		if (fence)
			*fence = fu.pipe;
		else
			driFenceUnReference(&fu.dri);
	}
}
boolean
intel_be_init_context(struct intel_be_context *intel, struct intel_be_device *device)
{
	assert(intel);
	assert(device);
	intel->device = device;
	/* TODO move framebuffer createion to the driver */
	intel->base.batch_get = intel_i915_batch_get;
	intel->base.batch_reloc = intel_i915_batch_reloc;
	intel->base.batch_flush = intel_i915_batch_flush;
	intel->batch = intel_be_batchbuffer_alloc(intel);
	return true;
}
void
intel_be_destroy_context(struct intel_be_context *intel)
{
	intel_be_batchbuffer_free(intel->batch);
}
 |