static struct i915_winsys_buffer * i915_drm_buffer_create_tiled(struct i915_winsys *iws, unsigned *stride, unsigned height, enum i915_winsys_buffer_tile *tiling, enum i915_winsys_buffer_type type) { struct i915_drm_buffer *buf = CALLOC_STRUCT(i915_drm_buffer); struct i915_drm_winsys *idws = i915_drm_winsys(iws); unsigned long pitch = 0; uint32_t tiling_mode = *tiling; if (!buf) return NULL; buf->magic = 0xDEAD1337; buf->flinked = FALSE; buf->flink = 0; buf->bo = drm_intel_bo_alloc_tiled(idws->gem_manager, i915_drm_type_to_name(type), *stride, height, 1, &tiling_mode, &pitch, 0); if (!buf->bo) goto err; *stride = pitch; *tiling = tiling_mode; return (struct i915_winsys_buffer *)buf; err: assert(0); FREE(buf); return NULL; }
static struct i915_winsys_buffer * i915_drm_buffer_create(struct i915_winsys *iws, unsigned size, enum i915_winsys_buffer_type type) { struct i915_drm_buffer *buf = CALLOC_STRUCT(i915_drm_buffer); struct i915_drm_winsys *idws = i915_drm_winsys(iws); if (!buf) return NULL; buf->magic = 0xDEAD1337; buf->flinked = FALSE; buf->flink = 0; buf->bo = drm_intel_bo_alloc(idws->gem_manager, i915_drm_type_to_name(type), size, 0); if (!buf->bo) goto err; return (struct i915_winsys_buffer *)buf; err: assert(0); FREE(buf); return NULL; }
static void i915_drm_winsys_destroy(struct i915_winsys *iws) { struct i915_drm_winsys *idws = i915_drm_winsys(iws); drm_intel_bufmgr_destroy(idws->gem_manager); FREE(idws); }
static void i915_drm_winsys_destroy(struct i915_winsys *iws) { struct i915_drm_winsys *idws = i915_drm_winsys(iws); drm_intel_bufmgr_destroy(idws->pools.gem); FREE(idws); }
static struct i915_winsys_buffer * i915_drm_buffer_from_handle(struct i915_winsys *iws, struct winsys_handle *whandle, enum i915_winsys_buffer_tile *tiling, unsigned *stride) { struct i915_drm_winsys *idws = i915_drm_winsys(iws); struct i915_drm_buffer *buf; uint32_t tile = 0, swizzle = 0; if (whandle->type != DRM_API_HANDLE_TYPE_SHARED) return NULL; buf = CALLOC_STRUCT(i915_drm_buffer); if (!buf) return NULL; buf->magic = 0xDEAD1337; buf->bo = drm_intel_bo_gem_create_from_name(idws->gem_manager, "gallium3d_from_handle", whandle->handle); buf->flinked = TRUE; buf->flink = whandle->handle; if (!buf->bo) goto err; drm_intel_bo_get_tiling(buf->bo, &tile, &swizzle); *stride = whandle->stride; *tiling = tile; return (struct i915_winsys_buffer *)buf; err: FREE(buf); return NULL; }