drm_api: Operate on textures instead of buffers
[mesa.git] / src / gallium / winsys / drm / intel / gem / intel_be_device.h
1
2 #ifndef INTEL_DRM_DEVICE_H
3 #define INTEL_DRM_DEVICE_H
4
5 #include "pipe/internal/p_winsys_screen.h"
6 #include "pipe/p_context.h"
7
8 #include "drm.h"
9 #include "intel_bufmgr.h"
10
11 struct drm_api;
12
13 /*
14 * Device
15 */
16
17 struct intel_be_device
18 {
19 struct pipe_winsys base;
20
21 boolean softpipe;
22 boolean dump_cmd;
23
24 int fd; /**< Drm file discriptor */
25
26 unsigned id;
27
28 size_t max_batch_size;
29 size_t max_vertex_size;
30
31 struct {
32 drm_intel_bufmgr *gem;
33 } pools;
34 };
35
36 static INLINE struct intel_be_device *
37 intel_be_device(struct pipe_winsys *winsys)
38 {
39 return (struct intel_be_device *)winsys;
40 }
41
42 boolean
43 intel_be_init_device(struct intel_be_device *device, int fd, unsigned id);
44
45 /*
46 * Buffer
47 */
48
49 struct intel_be_buffer {
50 struct pipe_buffer base;
51 void *ptr;
52 unsigned map_count;
53 boolean map_gtt;
54
55 drm_intel_bo *bo;
56 boolean flinked;
57 unsigned flink;
58 };
59
60 /**
61 * Create a texture from a shared drm handle.
62 */
63 struct pipe_texture *
64 intel_be_texture_from_shared_handle(struct drm_api *api,
65 struct pipe_screen *screen,
66 struct pipe_texture *templ,
67 const char* name,
68 unsigned pitch,
69 unsigned handle);
70
71 /**
72 * Gets a shared handle from a texture.
73 *
74 * If texture is destroyed handle may become invalid.
75 */
76 boolean
77 intel_be_shared_handle_from_texture(struct drm_api *api,
78 struct pipe_screen *screen,
79 struct pipe_texture *texture,
80 unsigned *pitch,
81 unsigned *handle);
82
83 /**
84 * Gets the local handle from a texture. As used by KMS.
85 *
86 * If texture is destroyed handle may become invalid.
87 */
88 boolean
89 intel_be_local_handle_from_texture(struct drm_api *api,
90 struct pipe_screen *screen,
91 struct pipe_texture *texture,
92 unsigned *pitch,
93 unsigned *handle);
94
95 static INLINE struct intel_be_buffer *
96 intel_be_buffer(struct pipe_buffer *buf)
97 {
98 return (struct intel_be_buffer *)buf;
99 }
100
101 static INLINE drm_intel_bo *
102 intel_bo(struct pipe_buffer *buf)
103 {
104 return intel_be_buffer(buf)->bo;
105 }
106
107 #endif