anv: Use an anv_address in anv_buffer
[mesa.git] / src / intel / vulkan / anv_gem.c
index 34c0989108653edd60a31663da905563208d98bd..3ba6d198a8a801427123b52892799c7327029b76 100644 (file)
@@ -30,6 +30,7 @@
 #include <fcntl.h>
 
 #include "anv_private.h"
+#include "common/gen_defines.h"
 
 static int
 anv_ioctl(int fd, unsigned long request, void *arg)
@@ -302,6 +303,13 @@ close_and_return:
    return swizzled;
 }
 
+bool
+anv_gem_has_context_priority(int fd)
+{
+   return !anv_gem_set_context_param(fd, 0, I915_CONTEXT_PARAM_PRIORITY,
+                                     GEN_CONTEXT_MEDIUM_PRIORITY);
+}
+
 int
 anv_gem_create_context(struct anv_device *device)
 {
@@ -324,6 +332,21 @@ anv_gem_destroy_context(struct anv_device *device, int context)
    return anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
 }
 
+int
+anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
+{
+   struct drm_i915_gem_context_param p = {
+      .ctx_id = context,
+      .param = param,
+      .value = value,
+   };
+   int err = 0;
+
+   if (anv_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p))
+      err = -errno;
+   return err;
+}
+
 int
 anv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value)
 {
@@ -354,24 +377,6 @@ anv_gem_get_aperture(int fd, uint64_t *size)
    return 0;
 }
 
-bool
-anv_gem_supports_48b_addresses(int fd)
-{
-   struct drm_i915_gem_exec_object2 obj = {
-      .flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS,
-   };
-
-   struct drm_i915_gem_execbuffer2 execbuf = {
-      .buffers_ptr = (uintptr_t)&obj,
-      .buffer_count = 1,
-      .rsvd1 = 0xffffffu,
-   };
-
-   int ret = anv_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
-
-   return ret == -1 && errno == ENOENT;
-}
-
 int
 anv_gem_gpu_get_reset_stats(struct anv_device *device,
                             uint32_t *active, uint32_t *pending)