aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie2009-12-16 22:11:55 -0600
committerDave Airlie2009-12-20 16:05:16 -0600
commit125994ab30d4f0f126c62fa741ec62a52d69d7a8 (patch)
treee641a13ec8e32c2322ebe1f1480581d58ad815e8 /radeon/radeon_cs.h
parentf1660c249198b5cc14ebbb75107da7bcb6972033 (diff)
downloadexternal-libgbm-125994ab30d4f0f126c62fa741ec62a52d69d7a8.tar.gz
external-libgbm-125994ab30d4f0f126c62fa741ec62a52d69d7a8.tar.xz
external-libgbm-125994ab30d4f0f126c62fa741ec62a52d69d7a8.zip
radeon: straighten out the API insanity.
as Michel pointed out we are exposing too much info for these object for this to be maintainable going forward. This patch set minimises the exposed parts of the radeon_bo and radeon_cs objects to the piece necessary for ddx/mesa to operate at a decent speed. The major problem is mesa contains a legacy BO/CS managers which we still need to expose functionality to, and we really cannot change the API until we can drop the non-KMS codepaths. Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'radeon/radeon_cs.h')
-rw-r--r--radeon/radeon_cs.h213
1 files changed, 54 insertions, 159 deletions
diff --git a/radeon/radeon_cs.h b/radeon/radeon_cs.h
index 1117a850..0954ca07 100644
--- a/radeon/radeon_cs.h
+++ b/radeon/radeon_cs.h
@@ -50,172 +50,41 @@ struct radeon_cs_reloc {
50#define RADEON_CS_SPACE_OP_TO_BIG 1 50#define RADEON_CS_SPACE_OP_TO_BIG 1
51#define RADEON_CS_SPACE_FLUSH 2 51#define RADEON_CS_SPACE_FLUSH 2
52 52
53struct radeon_cs_space_check {
54 struct radeon_bo *bo;
55 uint32_t read_domains;
56 uint32_t write_domain;
57 uint32_t new_accounted;
58};
59
60#define MAX_SPACE_BOS (32)
61
62struct radeon_cs_manager;
63
64struct radeon_cs { 53struct radeon_cs {
65 struct radeon_cs_manager *csm; 54 uint32_t *packets;
66 void *relocs; 55 unsigned cdw;
67 uint32_t *packets; 56 unsigned ndw;
68 unsigned crelocs;
69 unsigned relocs_total_size;
70 unsigned cdw;
71 unsigned ndw;
72 int section;
73 unsigned section_ndw; 57 unsigned section_ndw;
74 unsigned section_cdw; 58 unsigned section_cdw;
75 const char *section_file;
76 const char *section_func;
77 int section_line;
78 struct radeon_cs_space_check bos[MAX_SPACE_BOS];
79 int bo_count;
80 void (*space_flush_fn)(void *);
81 void *space_flush_data;
82};
83
84/* cs functions */
85struct radeon_cs_funcs {
86 struct radeon_cs *(*cs_create)(struct radeon_cs_manager *csm,
87 uint32_t ndw);
88 int (*cs_write_reloc)(struct radeon_cs *cs,
89 struct radeon_bo *bo,
90 uint32_t read_domain,
91 uint32_t write_domain,
92 uint32_t flags);
93 int (*cs_begin)(struct radeon_cs *cs,
94 uint32_t ndw,
95 const char *file,
96 const char *func,
97 int line);
98 int (*cs_end)(struct radeon_cs *cs,
99 const char *file,
100 const char *func,
101 int line);
102 int (*cs_emit)(struct radeon_cs *cs);
103 int (*cs_destroy)(struct radeon_cs *cs);
104 int (*cs_erase)(struct radeon_cs *cs);
105 int (*cs_need_flush)(struct radeon_cs *cs);
106 void (*cs_print)(struct radeon_cs *cs, FILE *file);
107};
108
109struct radeon_cs_manager {
110 struct radeon_cs_funcs *funcs;
111 int fd;
112 int32_t vram_limit, gart_limit;
113 int32_t vram_write_used, gart_write_used;
114 int32_t read_used;
115}; 59};
116 60
117static inline struct radeon_cs *radeon_cs_create(struct radeon_cs_manager *csm, 61#define MAX_SPACE_BOS (32)
118 uint32_t ndw)
119{
120 return csm->funcs->cs_create(csm, ndw);
121}
122
123static inline int radeon_cs_write_reloc(struct radeon_cs *cs,
124 struct radeon_bo *bo,
125 uint32_t read_domain,
126 uint32_t write_domain,
127 uint32_t flags)
128{
129 return cs->csm->funcs->cs_write_reloc(cs,
130 bo,
131 read_domain,
132 write_domain,
133 flags);
134}
135
136static inline int radeon_cs_begin(struct radeon_cs *cs,
137 uint32_t ndw,
138 const char *file,
139 const char *func,
140 int line)
141{
142 return cs->csm->funcs->cs_begin(cs, ndw, file, func, line);
143}
144
145static inline int radeon_cs_end(struct radeon_cs *cs,
146 const char *file,
147 const char *func,
148 int line)
149{
150 return cs->csm->funcs->cs_end(cs, file, func, line);
151}
152
153static inline int radeon_cs_emit(struct radeon_cs *cs)
154{
155 return cs->csm->funcs->cs_emit(cs);
156}
157
158static inline int radeon_cs_destroy(struct radeon_cs *cs)
159{
160 return cs->csm->funcs->cs_destroy(cs);
161}
162
163static inline int radeon_cs_erase(struct radeon_cs *cs)
164{
165 return cs->csm->funcs->cs_erase(cs);
166}
167
168static inline int radeon_cs_need_flush(struct radeon_cs *cs)
169{
170 return cs->csm->funcs->cs_need_flush(cs);
171}
172
173static inline void radeon_cs_print(struct radeon_cs *cs, FILE *file)
174{
175 cs->csm->funcs->cs_print(cs, file);
176}
177
178static inline void radeon_cs_set_limit(struct radeon_cs *cs, uint32_t domain, uint32_t limit)
179{
180
181 if (domain == RADEON_GEM_DOMAIN_VRAM)
182 cs->csm->vram_limit = limit;
183 else
184 cs->csm->gart_limit = limit;
185}
186
187static inline void radeon_cs_write_dword(struct radeon_cs *cs, uint32_t dword)
188{
189 cs->packets[cs->cdw++] = dword;
190 if (cs->section) {
191 cs->section_cdw++;
192 }
193}
194
195static inline void radeon_cs_write_qword(struct radeon_cs *cs, uint64_t qword)
196{
197 memcpy(cs->packets + cs->cdw, &qword, sizeof(uint64_t));
198 cs->cdw += 2;
199 if (cs->section) {
200 cs->section_cdw += 2;
201 }
202}
203
204static inline void radeon_cs_write_table(struct radeon_cs *cs, void *data, uint32_t size)
205{
206 memcpy(cs->packets + cs->cdw, data, size * 4);
207 cs->cdw += size;
208 if (cs->section) {
209 cs->section_cdw += size;
210 }
211}
212 62
213static inline void radeon_cs_space_set_flush(struct radeon_cs *cs, void (*fn)(void *), void *data) 63struct radeon_cs_manager;
214{
215 cs->space_flush_fn = fn;
216 cs->space_flush_data = data;
217}
218 64
65extern struct radeon_cs *radeon_cs_create(struct radeon_cs_manager *csm,
66 uint32_t ndw);
67
68extern int radeon_cs_begin(struct radeon_cs *cs,
69 uint32_t ndw,
70 const char *file,
71 const char *func, int line);
72extern int radeon_cs_end(struct radeon_cs *cs,
73 const char *file,
74 const char *func,
75 int line);
76extern int radeon_cs_emit(struct radeon_cs *cs);
77extern int radeon_cs_destroy(struct radeon_cs *cs);
78extern int radeon_cs_erase(struct radeon_cs *cs);
79extern int radeon_cs_need_flush(struct radeon_cs *cs);
80extern void radeon_cs_print(struct radeon_cs *cs, FILE *file);
81extern void radeon_cs_set_limit(struct radeon_cs *cs, uint32_t domain, uint32_t limit);
82extern void radeon_cs_space_set_flush(struct radeon_cs *cs, void (*fn)(void *), void *data);
83extern int radeon_cs_write_reloc(struct radeon_cs *cs,
84 struct radeon_bo *bo,
85 uint32_t read_domain,
86 uint32_t write_domain,
87 uint32_t flags);
219 88
220/* 89/*
221 * add a persistent BO to the list 90 * add a persistent BO to the list
@@ -243,4 +112,30 @@ int radeon_cs_space_check_with_bo(struct radeon_cs *cs,
243 uint32_t read_domains, 112 uint32_t read_domains,
244 uint32_t write_domain); 113 uint32_t write_domain);
245 114
115static inline void radeon_cs_write_dword(struct radeon_cs *cs, uint32_t dword)
116{
117 cs->packets[cs->cdw++] = dword;
118 if (cs->section_ndw) {
119 cs->section_cdw++;
120 }
121}
122
123static inline void radeon_cs_write_qword(struct radeon_cs *cs, uint64_t qword)
124{
125 memcpy(cs->packets + cs->cdw, &qword, sizeof(uint64_t));
126 cs->cdw += 2;
127 if (cs->section_ndw) {
128 cs->section_cdw += 2;
129 }
130}
131
132static inline void radeon_cs_write_table(struct radeon_cs *cs,
133 void *data, uint32_t size)
134{
135 memcpy(cs->packets + cs->cdw, data, size * 4);
136 cs->cdw += size;
137 if (cs->section_ndw) {
138 cs->section_cdw += size;
139 }
140}
246#endif 141#endif