struct ilo_screen *is = ilo_screen(tex->base.screen);
const char *name;
struct intel_bo *bo;
+ enum intel_tiling_mode tiling;
+ unsigned long pitch;
switch (tex->base.target) {
case PIPE_TEXTURE_1D:
}
if (handle) {
- bo = intel_winsys_import_handle(is->winsys, name,
- tex->bo_width, tex->bo_height, tex->bo_cpp, handle);
+ bo = intel_winsys_import_handle(is->winsys, name, handle,
+ tex->bo_width, tex->bo_height, tex->bo_cpp,
+ &tiling, &pitch);
}
else {
- bo = intel_winsys_alloc(is->winsys, name,
+ bo = intel_winsys_alloc_texture(is->winsys, name,
tex->bo_width, tex->bo_height, tex->bo_cpp,
- tex->tiling, tex->bo_flags);
+ tex->tiling, tex->bo_flags, &pitch);
+
+ tiling = tex->tiling;
}
if (!bo)
intel_bo_unreference(tex->bo);
tex->bo = bo;
- tex->tiling = intel_bo_get_tiling(bo);
- tex->bo_stride = intel_bo_get_pitch(bo);
+ tex->tiling = tiling;
+ tex->bo_stride = pitch;
return true;
}
static bool
tex_get_handle(struct ilo_texture *tex, struct winsys_handle *handle)
{
+ struct ilo_screen *is = ilo_screen(tex->base.screen);
int err;
- err = intel_bo_export_handle(tex->bo, handle);
+ err = intel_winsys_export_handle(is->winsys, tex->bo,
+ tex->tiling, tex->bo_stride, handle);
return !err;
}
struct pipe_reference reference;
drm_intel_bo *bo;
- enum intel_tiling_mode tiling;
- unsigned long pitch;
};
int
-intel_bo_export_handle(struct intel_bo *bo, struct winsys_handle *handle)
+intel_winsys_export_handle(struct intel_winsys *winsys,
+ struct intel_bo *bo,
+ enum intel_tiling_mode tiling,
+ unsigned long pitch,
+ struct winsys_handle *handle)
{
int err = 0;
if (err)
return err;
- handle->stride = bo->pitch;
+ handle->stride = pitch;
return 0;
}
return drm_intel_gem_bo_map_unsynchronized(bo->bo);
}
-int
+void
intel_bo_unmap(struct intel_bo *bo)
{
- return drm_intel_bo_unmap(bo->bo);
+ int err;
+
+ err = drm_intel_bo_unmap(bo->bo);
+ assert(!err);
}
int
return bo->bo->virtual;
}
-enum intel_tiling_mode
-intel_bo_get_tiling(const struct intel_bo *bo)
-{
- return bo->tiling;
-}
-
-unsigned long
-intel_bo_get_pitch(const struct intel_bo *bo)
-{
- return bo->pitch;
-}
-
void
intel_bo_reference(struct intel_bo *bo)
{
return NULL;
pipe_reference_init(&bo->reference, 1);
- bo->tiling = INTEL_TILING_NONE;
- bo->pitch = 0;
return bo;
}
struct intel_bo *
-intel_winsys_alloc(struct intel_winsys *winsys,
- const char *name,
- int width, int height, int cpp,
- enum intel_tiling_mode tiling,
- unsigned long flags)
+intel_winsys_alloc_texture(struct intel_winsys *winsys,
+ const char *name,
+ int width, int height, int cpp,
+ enum intel_tiling_mode tiling,
+ unsigned long flags,
+ unsigned long *pitch)
{
struct intel_bo *bo;
uint32_t real_tiling = tiling;
- unsigned long pitch;
bo = create_bo();
if (!bo)
return NULL;
bo->bo = drm_intel_bo_alloc_tiled(winsys->bufmgr, name,
- width, height, cpp, &real_tiling, &pitch, flags);
+ width, height, cpp, &real_tiling, pitch, flags);
if (!bo->bo) {
FREE(bo);
return NULL;
}
- bo->tiling = real_tiling;
- bo->pitch = pitch;
+ if (tiling != real_tiling) {
+ assert(!"tiling mis-match");
+ drm_intel_bo_unreference(bo->bo);
+ FREE(bo);
+ return NULL;
+ }
return bo;
}
struct intel_bo *
intel_winsys_import_handle(struct intel_winsys *winsys,
const char *name,
+ const struct winsys_handle *handle,
int width, int height, int cpp,
- const struct winsys_handle *handle)
+ enum intel_tiling_mode *tiling,
+ unsigned long *pitch)
{
struct intel_bo *bo;
- const unsigned long pitch = handle->stride;
- uint32_t tiling, swizzle;
+ uint32_t real_tiling, swizzle;
int err;
bo = create_bo();
{
const int fd = (int) handle->handle;
bo->bo = drm_intel_bo_gem_create_from_prime(winsys->bufmgr,
- fd, height * pitch);
+ fd, height * handle->stride);
}
break;
#endif
return NULL;
}
- err = drm_intel_bo_get_tiling(bo->bo, &tiling, &swizzle);
+ err = drm_intel_bo_get_tiling(bo->bo, &real_tiling, &swizzle);
if (err) {
drm_intel_bo_unreference(bo->bo);
FREE(bo);
return NULL;
}
- bo->tiling = tiling;
- bo->pitch = pitch;
+ *tiling = real_tiling;
+ *pitch = handle->stride;
return bo;
}
unsigned long flags);
struct intel_bo *
-intel_winsys_alloc(struct intel_winsys *winsys,
- const char *name,
- int width, int height, int cpp,
- enum intel_tiling_mode tiling,
- unsigned long flags);
+intel_winsys_alloc_texture(struct intel_winsys *winsys,
+ const char *name,
+ int width, int height, int cpp,
+ enum intel_tiling_mode tiling,
+ unsigned long flags,
+ unsigned long *pitch);
struct intel_bo *
intel_winsys_import_handle(struct intel_winsys *winsys,
const char *name,
+ const struct winsys_handle *handle,
int width, int height, int cpp,
- const struct winsys_handle *handle);
+ enum intel_tiling_mode *tiling,
+ unsigned long *pitch);
+
+/**
+ * Export a handle for inter-process sharing.
+ */
+int
+intel_winsys_export_handle(struct intel_winsys *winsys,
+ struct intel_bo *bo,
+ enum intel_tiling_mode tiling,
+ unsigned long pitch,
+ struct winsys_handle *handle);
int
intel_winsys_check_aperture_space(struct intel_winsys *winsys,
void *
intel_bo_get_virtual(const struct intel_bo *bo);
-enum intel_tiling_mode
-intel_bo_get_tiling(const struct intel_bo *bo);
-
-unsigned long
-intel_bo_get_pitch(const struct intel_bo *bo);
-
/**
* Map/unmap \p bo for CPU access.
*
int
intel_bo_map_unsynchronized(struct intel_bo *bo);
-int
+void
intel_bo_unmap(struct intel_bo *bo);
/**
int
intel_bo_wait(struct intel_bo *bo, int64_t timeout);
-/**
- * Export a handle for inter-process sharing.
- */
-int
-intel_bo_export_handle(struct intel_bo *bo,
- struct winsys_handle *handle);
-
/**
* Return true if \p bo is busy.
*/