diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c index ac304232361..68989fe702d 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c @@ -1652,7 +1652,7 @@ static bool amdgpu_bo_get_handle(struct radeon_winsys *rws, type = amdgpu_bo_handle_type_gem_flink_name; break; case WINSYS_HANDLE_TYPE_KMS: - if (sws->fd == aws->fd) { + if (sws->fd == aws->input_fd) { whandle->handle = bo->kms_handle; if (bo->is_shared) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c index d2143d44ab3..33f56b4e7c1 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c @@ -427,13 +427,14 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config, goto fail; aws->dev = dev; + aws->fd = amdgpu_device_get_fd(dev); + /* The device fd might be different from the one we passed because of * libdrm_amdgpu device dedup logic. This can happen if radv is initialized * first. * Get the correct fd or the buffer sharing will not work (see #3424). */ - int device_fd = amdgpu_device_get_fd(dev); - if (!are_file_descriptions_equal(device_fd, fd)) { + if (!are_file_descriptions_equal(aws->fd, fd)) { sws->kms_handles = _mesa_hash_table_create(NULL, kms_handle_hash, kms_handle_equals); if (!sws->kms_handles) @@ -442,9 +443,9 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config, * we need it but we'd have to use os_same_file_description() to * compare the fds. */ - aws->fd = device_fd; + aws->input_fd = aws->fd; } else { - aws->fd = sws->fd; + aws->input_fd = sws->fd; } aws->info.drm_major = drm_major; aws->info.drm_minor = drm_minor; diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h index 8baa8ec8ced..630d15b240a 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h @@ -50,7 +50,7 @@ struct amdgpu_cs; * * This fd tracking is useful for buffer sharing. As an example, if an app * wants to use drmModeAddFB it'll need a KMS handle valid for its - * fd (== amdgpu_screen_winsys::fd). If both fds are identical, there's + * fd (== amdgpu_screen_winsys::input_fd). If both fds are identical, there's * nothing to do: bo->u.real.kms_handle can be used directly * (see amdgpu_bo_get_handle). If they're different, the BO has to be exported * from the device fd as a dma-buf, then imported to the app fd to get the @@ -188,8 +188,10 @@ static_assert(sizeof(((struct amdgpu_seq_no_fences*)NULL)->valid_fence_mask) * 8 /* One struct amdgpu_winsys is created for one gpu in amdgpu_winsys_create(). */ struct amdgpu_winsys { struct pipe_reference reference; - /* See comment above */ + /* Returned by amdgpu_device_get_fd. */ int fd; + /* See comment above */ + int input_fd; /* Protected by bo_fence_lock. */ struct amdgpu_queue queues[AMDGPU_MAX_QUEUES];