summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/drm/intel/gem/intel_be_device.h
blob: 15916b0b102e6586bc566c499ce17ec71d29fe7a (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

#ifndef INTEL_DRM_DEVICE_H
#define INTEL_DRM_DEVICE_H

#include "pipe/internal/p_winsys_screen.h"
#include "pipe/p_context.h"

#include "drm.h"
#include "intel_bufmgr.h"

struct drm_api;

/*
 * Device
 */

struct intel_be_device
{
	struct pipe_winsys base;

	boolean softpipe;
	boolean dump_cmd;

	int fd; /**< Drm file discriptor */

	unsigned id;

	size_t max_batch_size;
	size_t max_vertex_size;

	struct {
		drm_intel_bufmgr *gem;
	} pools;
};

static INLINE struct intel_be_device *
intel_be_device(struct pipe_winsys *winsys)
{
	return (struct intel_be_device *)winsys;
}

boolean
intel_be_init_device(struct intel_be_device *device, int fd, unsigned id);

/*
 * Buffer
 */

struct intel_be_buffer {
	struct pipe_buffer base;
	void *ptr;
	unsigned map_count;
	boolean map_gtt;

	drm_intel_bo *bo;
	boolean flinked;
	unsigned flink;
};

/**
 * Create a texture from a shared drm handle.
 */
struct pipe_texture *
intel_be_texture_from_shared_handle(struct drm_api *api,
                                    struct pipe_screen *screen,
                                    struct pipe_texture *templ,
                                    const char* name,
                                    unsigned pitch,
                                    unsigned handle);

/**
 * Gets a shared handle from a texture.
 *
 * If texture is destroyed handle may become invalid.
 */
boolean
intel_be_shared_handle_from_texture(struct drm_api *api,
                                    struct pipe_screen *screen,
                                    struct pipe_texture *texture,
                                    unsigned *pitch,
                                    unsigned *handle);

/**
 * Gets the local handle from a texture. As used by KMS.
 *
 * If texture is destroyed handle may become invalid.
 */
boolean
intel_be_local_handle_from_texture(struct drm_api *api,
                                   struct pipe_screen *screen,
                                   struct pipe_texture *texture,
                                   unsigned *pitch,
                                   unsigned *handle);

static INLINE struct intel_be_buffer *
intel_be_buffer(struct pipe_buffer *buf)
{
	return (struct intel_be_buffer *)buf;
}

static INLINE drm_intel_bo *
intel_bo(struct pipe_buffer *buf)
{
	return intel_be_buffer(buf)->bo;
}

#endif