r300/r600/radeon_si: Add support for `get_screen_fd`
authorLucas Fryzek <lfryzek@igalia.com>
Thu, 2 Mar 2023 19:51:08 +0000 (14:51 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 31 Mar 2023 13:39:07 +0000 (13:39 +0000)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21654>

src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r600/r600_pipe_common.c
src/gallium/drivers/radeonsi/si_get.c
src/gallium/include/winsys/radeon_winsys.h
src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c

index c033ccb..82e5e7e 100644 (file)
@@ -812,6 +812,13 @@ static bool r300_fence_finish(struct pipe_screen *screen,
     return rws->fence_wait(rws, fence, timeout);
 }
 
+static int r300_screen_get_fd(struct pipe_screen *screen)
+{
+    struct radeon_winsys *rws = r300_screen(screen)->rws;
+
+    return rws->get_fd(rws);
+}
+
 struct pipe_screen* r300_screen_create(struct radeon_winsys *rws,
                                        const struct pipe_screen_config *config)
 {
@@ -841,6 +848,7 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws,
     r300screen->screen.get_compiler_options = r300_get_compiler_options;
     r300screen->screen.get_device_vendor = r300_get_device_vendor;
     r300screen->screen.get_disk_shader_cache = r300_get_disk_shader_cache;
+    r300screen->screen.get_screen_fd = r300_screen_get_fd;
     r300screen->screen.get_param = r300_get_param;
     r300screen->screen.get_shader_param = r300_get_shader_param;
     r300screen->screen.get_paramf = r300_get_paramf;
index 38fbb66..4eb2ac7 100644 (file)
@@ -1205,6 +1205,13 @@ static void r600_resource_destroy(struct pipe_screen *screen,
        }
 }
 
+static int r600_get_screen_fd(struct pipe_screen *screen)
+{
+       struct radeon_winsys *ws = ((struct r600_common_screen*)screen)->ws;
+
+       return ws->get_fd(ws);
+}
+
 bool r600_common_screen_init(struct r600_common_screen *rscreen,
                             struct radeon_winsys *ws)
 {
@@ -1236,6 +1243,7 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen,
        rscreen->b.get_device_vendor = r600_get_device_vendor;
        rscreen->b.get_disk_shader_cache = r600_get_disk_shader_cache;
        rscreen->b.get_compute_param = r600_get_compute_param;
+       rscreen->b.get_screen_fd = r600_get_screen_fd;
        rscreen->b.get_paramf = r600_get_paramf;
        rscreen->b.get_timestamp = r600_get_timestamp;
        rscreen->b.get_compiler_options = r600_get_compiler_options;
index 3ac326a..26f36bb 100644 (file)
@@ -1136,11 +1136,20 @@ static void si_init_renderer_string(struct si_screen *sscreen)
             sscreen->info.drm_major, sscreen->info.drm_minor, kernel_version);
 }
 
+static int si_get_screen_fd(struct pipe_screen *screen)
+{
+   struct si_screen *sscreen = (struct si_screen *)screen;
+   struct radeon_winsys *ws = sscreen->ws;
+
+   return ws->get_fd(ws);
+}
+
 void si_init_screen_get_functions(struct si_screen *sscreen)
 {
    sscreen->b.get_name = si_get_name;
    sscreen->b.get_vendor = si_get_vendor;
    sscreen->b.get_device_vendor = si_get_device_vendor;
+   sscreen->b.get_screen_fd = si_get_screen_fd;
    sscreen->b.get_param = si_get_param;
    sscreen->b.get_paramf = si_get_paramf;
    sscreen->b.get_compute_param = si_get_compute_param;
index c1d7f6d..ad58108 100644 (file)
@@ -316,6 +316,11 @@ struct radeon_winsys {
    void (*destroy)(struct radeon_winsys *ws);
 
    /**
+    * Get FD for winsys if winsys provides one
+    */
+   int (*get_fd)(struct radeon_winsys *ws);
+
+   /**
     * Query an info structure from winsys.
     *
     * \param ws        The winsys this function is called from.
index 23e1903..addd319 100644 (file)
@@ -407,6 +407,14 @@ are_file_descriptions_equal(int fd1, int fd2)
    return false;
 }
 
+static int
+amdgpu_drm_winsys_get_fd(struct radeon_winsys *rws)
+{
+   struct amdgpu_screen_winsys *sws = amdgpu_screen_winsys(rws);
+
+   return sws->fd;
+}
+
 PUBLIC struct radeon_winsys *
 amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
                     radeon_screen_create_t screen_create)
@@ -576,6 +584,7 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
    /* Set functions. */
    ws->base.unref = amdgpu_winsys_unref;
    ws->base.destroy = amdgpu_winsys_destroy;
+   ws->base.get_fd = amdgpu_drm_winsys_get_fd;
    ws->base.query_info = amdgpu_winsys_query_info;
    ws->base.cs_request_feature = amdgpu_cs_request_feature;
    ws->base.query_value = amdgpu_query_value;
index b0e9442..12db4f2 100644 (file)
@@ -795,6 +795,14 @@ static bool radeon_cs_set_pstate(struct radeon_cmdbuf* cs, enum radeon_ctx_pstat
     return false;
 }
 
+static int
+radeon_drm_winsys_get_fd(struct radeon_winsys *ws)
+{
+   struct radeon_drm_winsys *rws = (struct radeon_drm_winsys*)ws;
+
+   return rws->fd;
+}
+
 PUBLIC struct radeon_winsys *
 radeon_drm_winsys_create(int fd, const struct pipe_screen_config *config,
                          radeon_screen_create_t screen_create)
@@ -861,6 +869,7 @@ radeon_drm_winsys_create(int fd, const struct pipe_screen_config *config,
    /* Set functions. */
    ws->base.unref = radeon_winsys_unref;
    ws->base.destroy = radeon_winsys_destroy;
+   ws->base.get_fd = radeon_drm_winsys_get_fd;
    ws->base.query_info = radeon_query_info;
    ws->base.pin_threads_to_L3_cache = radeon_pin_threads_to_L3_cache;
    ws->base.cs_request_feature = radeon_cs_request_feature;