intel/mi_builder: Create a context in the tests
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 18 Feb 2021 02:00:53 +0000 (20:00 -0600)
committerMarge Bot <eric+marge@anholt.net>
Thu, 18 Feb 2021 21:28:40 +0000 (21:28 +0000)
This makes them work on the simulator

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9116>

src/intel/common/tests/gen_mi_builder_test.cpp

index 4002619dc8e8bc8faa7ac1f00450f41c359b7530..f99e5efd46e26fdb8b3b6b13890b680a81bb2289 100644 (file)
@@ -125,6 +125,7 @@ public:
    }
 
    int fd;
+   int ctx_id;
    gen_device_info devinfo;
 
    uint32_t batch_bo_handle;
@@ -196,6 +197,11 @@ gen_mi_builder_test::SetUp()
    }
    ASSERT_TRUE(i < max_devices) << "Failed to find a DRM device";
 
+   drm_i915_gem_context_create ctx_create = drm_i915_gem_context_create();
+   ASSERT_EQ(drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE,
+                      (void *)&ctx_create), 0) << strerror(errno);
+   ctx_id = ctx_create.ctx_id;
+
    // Create the batch buffer
    drm_i915_gem_create gem_create = drm_i915_gem_create();
    gem_create.size = BATCH_BO_SIZE;
@@ -295,6 +301,7 @@ gen_mi_builder_test::submit_batch()
    execbuf.batch_start_offset = 0;
    execbuf.batch_len = batch_offset;
    execbuf.flags = I915_EXEC_HANDLE_LUT | I915_EXEC_RENDER;
+   execbuf.rsvd1 = ctx_id;
 
    ASSERT_EQ(drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2,
                       (void *)&execbuf), 0) << strerror(errno);