if (flags & BO_ALLOC_ZEROED)
zeroed = true;
+ if ((flags & BO_ALLOC_COHERENT) && !bufmgr->has_llc) {
+ bo_size = MAX2(ALIGN(size, page_size), page_size);
+ bucket = NULL;
+ goto skip_cache;
+ }
+
/* Round the allocated size up to a power of two number of pages. */
bucket = bucket_for_size(bufmgr, size);
bo->gtt_offset = 0ull;
}
} else {
+skip_cache:
bo = bo_calloc();
if (!bo)
goto err;
mtx_unlock(&bufmgr->lock);
+ if ((flags & BO_ALLOC_COHERENT) && !bo->cache_coherent) {
+ struct drm_i915_gem_caching arg = {
+ .handle = bo->gem_handle,
+ .caching = 1,
+ };
+ if (drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &arg) == 0) {
+ bo->cache_coherent = true;
+ bo->reusable = false;
+ }
+ }
+
DBG("bo_create: buf %d (%s) %llub\n", bo->gem_handle, bo->name,
(unsigned long long) size);
const char *name = "miptree";
enum iris_memory_zone memzone = IRIS_MEMZONE_OTHER;
+ unsigned int flags = 0;
+ if (templ->usage == PIPE_USAGE_STAGING)
+ flags |= BO_ALLOC_COHERENT;
+
/* These are for u_upload_mgr buffers only */
assert(!(templ->flags & (IRIS_RESOURCE_FLAG_SHADER_MEMZONE |
IRIS_RESOURCE_FLAG_SURFACE_MEMZONE |
res->bo = iris_bo_alloc_tiled(screen->bufmgr, name, res->surf.size_B,
memzone,
isl_tiling_to_i915_tiling(res->surf.tiling),
- res->surf.row_pitch_B, 0);
+ res->surf.row_pitch_B, flags);
if (!res->bo)
goto fail;