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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
/*
* Copyright © 2014 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#ifndef _INTEL_UXA_H_
#define _INTEL_UXA_H_
#include "intel_video.h"
#include "uxa.h"
struct intel_uxa_pixmap {
dri_bo *bo;
struct list batch;
uint8_t tiling;
int8_t busy :2;
uint8_t dirty :1;
uint8_t offscreen :1;
uint8_t pinned :5;
#define PIN_SCANOUT 0x1
#define PIN_DRI2 0x2
#define PIN_DRI3 0x4
#define PIN_PRIME 0x8
#define PIN_GLAMOR 0x10
};
#if HAS_DEVPRIVATEKEYREC
extern DevPrivateKeyRec uxa_pixmap_index;
#else
extern int uxa_pixmap_index;
#endif
static inline struct intel_uxa_pixmap *intel_uxa_get_pixmap_private(PixmapPtr pixmap)
{
#if HAS_DEVPRIVATEKEYREC
return dixGetPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
#else
return dixLookupPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
#endif
}
static inline Bool intel_uxa_pixmap_is_busy(struct intel_uxa_pixmap *priv)
{
if (priv->busy == -1)
priv->busy = drm_intel_bo_busy(priv->bo);
return priv->busy;
}
static inline void intel_uxa_set_pixmap_private(PixmapPtr pixmap, struct intel_uxa_pixmap *intel)
{
dixSetPrivate(&pixmap->devPrivates, &uxa_pixmap_index, intel);
}
static inline Bool intel_uxa_pixmap_is_dirty(PixmapPtr pixmap)
{
return pixmap && intel_uxa_get_pixmap_private(pixmap)->dirty;
}
static inline Bool intel_uxa_pixmap_tiled(PixmapPtr pixmap)
{
return intel_uxa_get_pixmap_private(pixmap)->tiling != I915_TILING_NONE;
}
dri_bo *intel_uxa_get_pixmap_bo(PixmapPtr pixmap);
void intel_uxa_set_pixmap_bo(PixmapPtr pixmap, dri_bo * bo);
Bool intel_uxa_init(ScreenPtr pScreen);
Bool intel_uxa_create_screen_resources(ScreenPtr pScreen);
void intel_uxa_block_handler(intel_screen_private *intel);
static inline Bool intel_uxa_pixmap_is_offscreen(PixmapPtr pixmap)
{
struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
return priv && priv->offscreen;
}
/* Batchbuffer support macros and functions */
#include "intel_batchbuffer.h"
/* I830 specific functions */
extern void IntelEmitInvarientState(ScrnInfoPtr scrn);
extern void I830EmitInvarientState(ScrnInfoPtr scrn);
extern void I915EmitInvarientState(ScrnInfoPtr scrn);
extern void I830EmitFlush(ScrnInfoPtr scrn);
/* i830_render.c */
Bool i830_check_composite(int op,
PicturePtr sourcec, PicturePtr mask, PicturePtr dest,
int width, int height);
Bool i830_check_composite_target(PixmapPtr pixmap);
Bool i830_check_composite_texture(ScreenPtr screen, PicturePtr picture);
Bool i830_prepare_composite(int op, PicturePtr sourcec, PicturePtr mask,
PicturePtr dest, PixmapPtr sourcecPixmap,
PixmapPtr maskPixmap, PixmapPtr destPixmap);
void i830_composite(PixmapPtr dest, int srcX, int srcY,
int maskX, int maskY, int dstX, int dstY, int w, int h);
void i830_vertex_flush(intel_screen_private *intel);
/* i915_render.c */
Bool i915_check_composite(int op,
PicturePtr sourcec, PicturePtr mask, PicturePtr dest,
int width, int height);
Bool i915_check_composite_target(PixmapPtr pixmap);
Bool i915_check_composite_texture(ScreenPtr screen, PicturePtr picture);
Bool i915_prepare_composite(int op, PicturePtr sourcec, PicturePtr mask,
PicturePtr dest, PixmapPtr sourcecPixmap,
PixmapPtr maskPixmap, PixmapPtr destPixmap);
void i915_composite(PixmapPtr dest, int srcX, int srcY,
int maskX, int maskY, int dstX, int dstY, int w, int h);
void i915_vertex_flush(intel_screen_private *intel);
void i915_batch_commit_notify(intel_screen_private *intel);
void i830_batch_commit_notify(intel_screen_private *intel);
/* i965_render.c */
unsigned int gen4_render_state_size(ScrnInfoPtr scrn);
void gen4_render_state_init(ScrnInfoPtr scrn);
void gen4_render_state_cleanup(ScrnInfoPtr scrn);
Bool i965_check_composite(int op,
PicturePtr sourcec, PicturePtr mask, PicturePtr dest,
int width, int height);
Bool i965_check_composite_texture(ScreenPtr screen, PicturePtr picture);
Bool i965_prepare_composite(int op, PicturePtr sourcec, PicturePtr mask,
PicturePtr dest, PixmapPtr sourcecPixmap,
PixmapPtr maskPixmap, PixmapPtr destPixmap);
void i965_composite(PixmapPtr dest, int srcX, int srcY,
int maskX, int maskY, int dstX, int dstY, int w, int h);
void i965_vertex_flush(intel_screen_private *intel);
void i965_batch_flush(intel_screen_private *intel);
void i965_batch_commit_notify(intel_screen_private *intel);
/* i965_3d.c */
void gen6_upload_invariant_states(intel_screen_private *intel);
void gen6_upload_viewport_state_pointers(intel_screen_private *intel,
drm_intel_bo *cc_vp_bo);
void gen7_upload_viewport_state_pointers(intel_screen_private *intel,
drm_intel_bo *cc_vp_bo);
void gen6_upload_urb(intel_screen_private *intel);
void gen7_upload_urb(intel_screen_private *intel);
void gen6_upload_cc_state_pointers(intel_screen_private *intel,
drm_intel_bo *blend_bo, drm_intel_bo *cc_bo,
drm_intel_bo *depth_stencil_bo,
uint32_t blend_offset);
void gen7_upload_cc_state_pointers(intel_screen_private *intel,
drm_intel_bo *blend_bo, drm_intel_bo *cc_bo,
drm_intel_bo *depth_stencil_bo,
uint32_t blend_offset);
void gen6_upload_sampler_state_pointers(intel_screen_private *intel,
drm_intel_bo *sampler_bo);
void gen7_upload_sampler_state_pointers(intel_screen_private *intel,
drm_intel_bo *sampler_bo);
void gen7_upload_bypass_states(intel_screen_private *intel);
void gen6_upload_gs_state(intel_screen_private *intel);
void gen6_upload_vs_state(intel_screen_private *intel);
void gen6_upload_clip_state(intel_screen_private *intel);
void gen6_upload_sf_state(intel_screen_private *intel, int num_sf_outputs, int read_offset);
void gen7_upload_sf_state(intel_screen_private *intel, int num_sf_outputs, int read_offset);
void gen6_upload_binding_table(intel_screen_private *intel, uint32_t ps_binding_table_offset);
void gen7_upload_binding_table(intel_screen_private *intel, uint32_t ps_binding_table_offset);
void gen6_upload_depth_buffer_state(intel_screen_private *intel);
void gen7_upload_depth_buffer_state(intel_screen_private *intel);
Bool intel_uxa_transform_is_affine(PictTransformPtr t);
Bool
intel_uxa_get_transformed_coordinates(int x, int y, PictTransformPtr transform,
float *x_out, float *y_out);
Bool
intel_uxa_get_transformed_coordinates_3d(int x, int y, PictTransformPtr transform,
float *x_out, float *y_out, float *z_out);
static inline void
intel_uxa_debug_fallback(ScrnInfoPtr scrn, const char *format, ...) _X_ATTRIBUTE_PRINTF(2, 3);
static inline void
intel_uxa_debug_fallback(ScrnInfoPtr scrn, const char *format, ...)
{
intel_screen_private *intel = intel_get_screen_private(scrn);
va_list ap;
va_start(ap, format);
if (intel->fallback_debug) {
xf86DrvMsg(scrn->scrnIndex, X_INFO, "fallback: ");
LogVMessageVerb(X_INFO, 1, format, ap);
}
va_end(ap);
}
static inline Bool
intel_uxa_check_pitch_2d(PixmapPtr pixmap)
{
uint32_t pitch = intel_pixmap_pitch(pixmap);
if (pitch > KB(32)) {
ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
intel_uxa_debug_fallback(scrn, "pitch exceeds 2d limit 32K\n");
return FALSE;
}
return TRUE;
}
/* For pre-965 chip only, as they have 8KB limit for 3D */
static inline Bool
intel_uxa_check_pitch_3d(PixmapPtr pixmap)
{
uint32_t pitch = intel_pixmap_pitch(pixmap);
if (pitch > KB(8)) {
ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
intel_uxa_debug_fallback(scrn, "pitch exceeds 3d limit 8K\n");
return FALSE;
}
return TRUE;
}
/**
* Little wrapper around drm_intel_bo_reloc to return the initial value you
* should stuff into the relocation entry.
*
* If only we'd done this before settling on the library API.
*/
static inline uint32_t
intel_uxa_emit_reloc(drm_intel_bo * bo, uint32_t offset,
drm_intel_bo * target_bo, uint32_t target_offset,
uint32_t read_domains, uint32_t write_domain)
{
drm_intel_bo_emit_reloc(bo, offset, target_bo, target_offset,
read_domains, write_domain);
return target_bo->offset + target_offset;
}
static inline drm_intel_bo *intel_uxa_bo_alloc_for_data(intel_screen_private *intel,
const void *data,
unsigned int size,
const char *name)
{
drm_intel_bo *bo;
int ret;
bo = drm_intel_bo_alloc(intel->bufmgr, name, size, 4096);
assert(bo);
ret = drm_intel_bo_subdata(bo, 0, size, data);
assert(ret == 0);
return bo;
(void)ret;
}
void intel_uxa_debug_flush(ScrnInfoPtr scrn);
Bool intel_uxa_get_aperture_space(ScrnInfoPtr scrn, drm_intel_bo ** bo_table,
int num_bos);
XF86VideoAdaptorPtr intel_uxa_video_setup_image_textured(ScreenPtr screen);
void I915DisplayVideoTextured(ScrnInfoPtr scrn,
intel_adaptor_private *adaptor_priv,
int id, RegionPtr dstRegion, short width,
short height, int video_pitch, int video_pitch2,
short src_w, short src_h,
short drw_w, short drw_h, PixmapPtr pixmap);
void I965DisplayVideoTextured(ScrnInfoPtr scrn,
intel_adaptor_private *adaptor_priv,
int id, RegionPtr dstRegion, short width,
short height, int video_pitch, int video_pitch2,
short src_w, short src_h,
short drw_w, short drw_h, PixmapPtr pixmap);
void Gen6DisplayVideoTextured(ScrnInfoPtr scrn,
intel_adaptor_private *adaptor_priv,
int id, RegionPtr dstRegion, short width,
short height, int video_pitch, int video_pitch2,
short src_w, short src_h,
short drw_w, short drw_h, PixmapPtr pixmap);
void i965_free_video(ScrnInfoPtr scrn);
#endif /* _INTEL_UXA_H_ */
|