#include "util/anon_file.h"
#include "anv_private.h"
-uint32_t
-anv_gem_create(struct anv_device *device, uint64_t size)
+static void
+stub_gem_close(struct anv_device *device, struct anv_bo *bo)
+{
+ close(bo->gem_handle);
+}
+
+static uint32_t
+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,
+ uint64_t *actual_size)
{
int fd = os_create_anonymous_file(size, "fake bo");
if (fd == -1)
assert(fd != 0);
+ *actual_size = size;
return fd;
}
-void
-anv_gem_close(struct anv_device *device, uint32_t gem_handle)
+static void *
+stub_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset,
+ uint64_t size, VkMemoryPropertyFlags property_flags)
{
- close(gem_handle);
+ return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->gem_handle,
+ offset);
}
-uint32_t
-anv_gem_create_regions(struct anv_device *device, uint64_t anv_bo_size,
- uint32_t flags, uint32_t num_regions,
- struct drm_i915_gem_memory_class_instance *regions)
+static VkResult
+stub_execute_simple_batch(struct anv_queue *queue,
+ struct anv_bo *batch_bo,
+ uint32_t batch_bo_size)
{
- return 0;
+ return VK_ERROR_UNKNOWN;
+}
+
+static VkResult
+stub_queue_exec_locked(struct anv_queue *queue,
+ uint32_t wait_count,
+ const struct vk_sync_wait *waits,
+ uint32_t cmd_buffer_count,
+ struct anv_cmd_buffer **cmd_buffers,
+ uint32_t signal_count,
+ const struct vk_sync_signal *signals,
+ struct anv_query_pool *perf_query_pool,
+ uint32_t perf_query_pass)
+{
+ return VK_ERROR_UNKNOWN;
}
-void*
-anv_gem_mmap(struct anv_device *device, struct anv_bo *bo,
- uint64_t offset, uint64_t size, uint32_t flags)
+void *
+anv_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset,
+ uint64_t size, VkMemoryPropertyFlags property_flags)
{
- /* Ignore flags, as they're specific to I915_GEM_MMAP. */
- (void) flags;
+ void *map = device->kmd_backend->gem_mmap(device, bo, offset, size,
+ property_flags);
- return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
- bo->gem_handle, offset);
+ if (map != MAP_FAILED)
+ VG(VALGRIND_MALLOCLIKE_BLOCK(map, size, 0, 1));
+
+ return map;
}
/* This is just a wrapper around munmap, but it also notifies valgrind that
- * this map is no longer valid. Pair this with anv_gem_mmap().
+ * this map is no longer valid. Pair this with gem_mmap().
*/
void
anv_gem_munmap(struct anv_device *device, void *p, uint64_t size)
munmap(p, size);
}
-uint32_t
-anv_gem_userptr(struct anv_device *device, void *mem, size_t size)
+static uint32_t
+stub_gem_create_userptr(struct anv_device *device, void *mem, uint64_t size)
{
int fd = os_create_anonymous_file(size, "fake bo");
if (fd == -1)
}
int
-anv_gem_execbuffer(struct anv_device *device,
- struct drm_i915_gem_execbuffer2 *execbuf)
-{
- return 0;
-}
-
-int
anv_gem_set_tiling(struct anv_device *device,
uint32_t gem_handle, uint32_t stride, uint32_t tiling)
{
}
int
-anv_gem_context_get_reset_stats(int fd, int context,
- uint32_t *active, uint32_t *pending)
-{
- unreachable("Unused");
-}
-
-int
anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
{
unreachable("Unused");
unreachable("Unused");
}
-int
-anv_i915_query(int fd, uint64_t query_id, void *buffer,
- int32_t *buffer_len)
+static int
+stub_gem_vm_bind(struct anv_device *device, struct anv_bo *bo)
{
- unreachable("Unused");
+ return 0;
+}
+
+static int
+stub_gem_vm_unbind(struct anv_device *device, struct anv_bo *bo)
+{
+ return 0;
+}
+
+const struct anv_kmd_backend *anv_stub_kmd_backend_get(void)
+{
+ static const struct anv_kmd_backend stub_backend = {
+ .gem_create = stub_gem_create,
+ .gem_create_userptr = stub_gem_create_userptr,
+ .gem_close = stub_gem_close,
+ .gem_mmap = stub_gem_mmap,
+ .gem_vm_bind = stub_gem_vm_bind,
+ .gem_vm_unbind = stub_gem_vm_unbind,
+ .execute_simple_batch = stub_execute_simple_batch,
+ .queue_exec_locked = stub_queue_exec_locked,
+ };
+ return &stub_backend;
}