ccs_size = align64(DIV_ROUND_UP(size, aux_ratio), 4096);
}
- uint32_t gem_handle;
+ const struct intel_memory_class_instance *regions[2];
+ uint32_t nregions = 0, flags = 0;
/* If we have vram size, we have multiple memory regions and should choose
* one of them.
*/
if (anv_physical_device_has_vram(device->physical)) {
- const struct intel_memory_class_instance *regions[2];
- uint32_t nregions = 0;
-
/* This always try to put the object in local memory. Here
* vram_non_mappable & vram_mappable actually are the same region.
*/
* This ensures that if the buffer cannot live in mappable local memory,
* it can be spilled to system memory.
*/
- uint32_t flags = 0;
if (!(alloc_flags & ANV_BO_ALLOC_NO_LOCAL_MEM) &&
((alloc_flags & ANV_BO_ALLOC_MAPPED) ||
(alloc_flags & ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE))) {
if (device->physical->vram_non_mappable.size > 0)
flags |= I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS;
}
-
- gem_handle = anv_gem_create_regions(device, size + ccs_size,
- flags, nregions, regions);
} else {
- gem_handle = anv_gem_create(device, size + ccs_size);
+ regions[nregions++] = device->physical->sys.region;
}
+ uint32_t gem_handle = anv_gem_create_regions(device, size + ccs_size,
+ flags, nregions, regions);
if (gem_handle == 0)
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
#include "anv_private.h"
#include "common/intel_gem.h"
-/**
- * Wrapper around DRM_IOCTL_I915_GEM_CREATE.
- *
- * Return gem handle, or 0 on failure. Gem handles are never 0.
- */
-uint32_t
-anv_gem_create(struct anv_device *device, uint64_t size)
-{
- struct drm_i915_gem_create gem_create = {
- .size = size,
- };
-
- int ret = intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create);
- if (ret != 0) {
- /* FIXME: What do we do if this fails? */
- return 0;
- }
-
- return gem_create.handle;
-}
-
void
anv_gem_close(struct anv_device *device, uint32_t gem_handle)
{
uint32_t flags, uint32_t num_regions,
const struct intel_memory_class_instance **regions)
{
- struct drm_i915_gem_memory_class_instance i915_regions[2];
+ if (unlikely(!device->info->mem.use_class_instance)) {
+ assert(num_regions == 1 &&
+ device->physical->sys.region == regions[0] &&
+ flags == 0);
+ struct drm_i915_gem_create gem_create = {
+ .size = anv_bo_size,
+ };
+ if (intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create))
+ return 0;
+ return gem_create.handle;
+ }
+
+ struct drm_i915_gem_memory_class_instance i915_regions[2];
/* Check for invalid flags */
assert((flags & ~I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS) == 0);
assert(num_regions <= ARRAY_SIZE(i915_regions));
#include "util/anon_file.h"
#include "anv_private.h"
-uint32_t
-anv_gem_create(struct anv_device *device, uint64_t size)
-{
- int fd = os_create_anonymous_file(size, "fake bo");
- if (fd == -1)
- return 0;
-
- assert(fd != 0);
-
- return fd;
-}
-
void
anv_gem_close(struct anv_device *device, uint32_t gem_handle)
{
}
uint32_t
-anv_gem_create_regions(struct anv_device *device, uint64_t anv_bo_size,
+anv_gem_create_regions(struct anv_device *device, uint64_t size,
uint32_t flags, uint32_t num_regions,
const struct intel_memory_class_instance **regions)
{
- return 0;
+ int fd = os_create_anonymous_file(size, "fake bo");
+ if (fd == -1)
+ return 0;
+
+ assert(fd != 0);
+
+ return fd;
}
void*
void* anv_gem_mmap(struct anv_device *device, struct anv_bo *bo,
uint64_t offset, uint64_t size, uint32_t flags);
void anv_gem_munmap(struct anv_device *device, void *p, uint64_t size);
-uint32_t anv_gem_create(struct anv_device *device, uint64_t size);
void anv_gem_close(struct anv_device *device, uint32_t gem_handle);
uint32_t anv_gem_create_regions(struct anv_device *device, uint64_t anv_bo_size,
uint32_t flags, uint32_t num_regions,