regions[nregions++] = device->physical->sys.region;
}
+ uint64_t actual_size;
uint32_t gem_handle = device->kmd_backend->gem_create(device, regions,
nregions,
size + ccs_size,
- alloc_flags);
+ alloc_flags,
+ &actual_size);
if (gem_handle == 0)
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
.offset = -1,
.size = size,
._ccs_size = ccs_size,
+ .actual_size = actual_size,
.flags = bo_flags,
.is_external = (alloc_flags & ANV_BO_ALLOC_EXTERNAL),
.has_client_visible_address =
.refcount = 1,
.offset = -1,
.size = size,
+ .actual_size = size,
.map = host_ptr,
.flags = bo_flags,
.is_external = true,
.refcount = 1,
.offset = -1,
.size = size,
+ .actual_size = size,
.flags = bo_flags,
.is_external = true,
.has_client_visible_address =
stub_gem_create(struct anv_device *device,
const struct intel_memory_class_instance **regions,
uint16_t num_regions, uint64_t size,
- enum anv_bo_alloc_flags alloc_flags)
+ enum anv_bo_alloc_flags alloc_flags,
+ uint64_t *actual_size)
{
int fd = os_create_anonymous_file(size, "fake bo");
if (fd == -1)
assert(fd != 0);
+ *actual_size = size;
return fd;
}
uint32_t (*gem_create)(struct anv_device *device,
const struct intel_memory_class_instance **regions,
uint16_t num_regions, uint64_t size,
- enum anv_bo_alloc_flags alloc_flags);
+ enum anv_bo_alloc_flags alloc_flags,
+ uint64_t *actual_size);
void (*gem_close)(struct anv_device *device, uint32_t handle);
/* Returns MAP_FAILED on error */
void *(*gem_mmap)(struct anv_device *device, struct anv_bo *bo,
*/
uint32_t _ccs_size;
+ /* The actual size of bo allocated by kmd, basically:
+ * align(size + _ccs_size, mem_alignment)
+ */
+ uint64_t actual_size;
+
/** Flags to pass to the kernel through drm_i915_exec_object2::flags */
uint32_t flags;
i915_gem_create(struct anv_device *device,
const struct intel_memory_class_instance **regions,
uint16_t num_regions, uint64_t size,
- enum anv_bo_alloc_flags alloc_flags)
+ enum anv_bo_alloc_flags alloc_flags,
+ uint64_t *actual_size)
{
if (unlikely(!device->info->mem.use_class_instance)) {
assert(num_regions == 1 &&
};
if (intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create))
return 0;
+
+ *actual_size = gem_create.size;
return gem_create.handle;
}
if (intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &gem_create))
return 0;
+ *actual_size = gem_create.size;
return gem_create.handle;
}
xe_gem_create(struct anv_device *device,
const struct intel_memory_class_instance **regions,
uint16_t regions_count, uint64_t size,
- enum anv_bo_alloc_flags alloc_flags)
+ enum anv_bo_alloc_flags alloc_flags,
+ uint64_t *actual_size)
{
struct drm_xe_gem_create gem_create = {
/* From xe_drm.h: If a VM is specified, this BO must:
if (intel_ioctl(device->fd, DRM_IOCTL_XE_GEM_CREATE, &gem_create))
return 0;
+ *actual_size = gem_create.size;
return gem_create.handle;
}
.num_binds = 1,
.bind.obj = op == XE_VM_BIND_OP_UNMAP ? 0 : bo->gem_handle,
.bind.obj_offset = 0,
- .bind.range = align64(bo->size + bo->_ccs_size, device->info->mem_alignment),
+ .bind.range = bo->actual_size,
.bind.addr = intel_48b_address(bo->offset),
.bind.op = op,
.num_syncs = 1,