diff options
author | Marek Olšák <[email protected]> | 2019-05-17 15:36:57 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-05-27 15:26:06 -0400 |
commit | fccced57cf484c6836e6637c0f9df90f09b344b6 (patch) | |
tree | d18d16358a72f9d1d9f16fcca0c10c419c1e04d6 | |
parent | bb5d82bd06b168f8f641516e6d695c97e84888ca (diff) |
radeonsi: clean up winsys creation
- unify the code
- choose radeon or amdgpu based on the DRM version, not based on which one
succeeds first
-rw-r--r-- | src/gallium/auxiliary/target-helpers/drm_helper.h | 13 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.c | 27 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_public.h | 5 | ||||
-rw-r--r-- | src/gallium/targets/pipe-loader/pipe_radeonsi.c | 13 | ||||
-rw-r--r-- | src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 8 |
5 files changed, 30 insertions, 36 deletions
diff --git a/src/gallium/auxiliary/target-helpers/drm_helper.h b/src/gallium/auxiliary/target-helpers/drm_helper.h index ac891d1d307..6bdd1a008db 100644 --- a/src/gallium/auxiliary/target-helpers/drm_helper.h +++ b/src/gallium/auxiliary/target-helpers/drm_helper.h @@ -161,23 +161,14 @@ pipe_r600_create_screen(int fd, const struct pipe_screen_config *config) #endif #ifdef GALLIUM_RADEONSI -#include "radeon/radeon_winsys.h" -#include "radeon/drm/radeon_drm_public.h" -#include "amdgpu/drm/amdgpu_public.h" #include "radeonsi/si_public.h" struct pipe_screen * pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config) { - struct radeon_winsys *rw; - - /* First, try amdgpu. */ - rw = amdgpu_winsys_create(fd, config, radeonsi_screen_create); + struct pipe_screen *screen = radeonsi_screen_create(fd, config); - if (!rw) - rw = radeon_drm_winsys_create(fd, config, radeonsi_screen_create); - - return rw ? debug_screen_wrap(rw->screen) : NULL; + return screen ? debug_screen_wrap(screen) : NULL; } const char *radeonsi_driconf_xml = diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 9ddf7802746..c19a2cd97d3 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -42,6 +42,10 @@ #include "vl/vl_decoder.h" #include "driver_ddebug/dd_util.h" +#include "gallium/winsys/radeon/drm/radeon_drm_public.h" +#include "gallium/winsys/amdgpu/drm/amdgpu_public.h" +#include <xf86drm.h> + static const struct debug_named_value debug_options[] = { /* Shader logging options: */ { "vs", DBG(VS), "Print vertex shaders" }, @@ -879,8 +883,9 @@ static bool si_is_parallel_shader_compilation_finished(struct pipe_screen *scree return util_queue_fence_is_signalled(&sel->ready); } -struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws, - const struct pipe_screen_config *config) +static struct pipe_screen * +radeonsi_screen_create_impl(struct radeon_winsys *ws, + const struct pipe_screen_config *config) { struct si_screen *sscreen = CALLOC_STRUCT(si_screen); unsigned hw_threads, num_comp_hi_threads, num_comp_lo_threads, i; @@ -1225,3 +1230,21 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws, return &sscreen->b; } + +struct pipe_screen *radeonsi_screen_create(int fd, const struct pipe_screen_config *config) +{ + drmVersionPtr version = drmGetVersion(fd); + struct radeon_winsys *rw = NULL; + + switch (version->version_major) { + case 2: + rw = radeon_drm_winsys_create(fd, config, radeonsi_screen_create_impl); + break; + case 3: + rw = amdgpu_winsys_create(fd, config, radeonsi_screen_create_impl); + break; + } + + drmFreeVersion(version); + return rw ? rw->screen : NULL; +} diff --git a/src/gallium/drivers/radeonsi/si_public.h b/src/gallium/drivers/radeonsi/si_public.h index c8721babb05..8a1f6e1d93b 100644 --- a/src/gallium/drivers/radeonsi/si_public.h +++ b/src/gallium/drivers/radeonsi/si_public.h @@ -25,9 +25,6 @@ #ifndef SI_PUBLIC_H #define SI_PUBLIC_H -struct radeon_winsys; - -struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws, - const struct pipe_screen_config *config); +struct pipe_screen *radeonsi_screen_create(int fd, const struct pipe_screen_config *config); #endif diff --git a/src/gallium/targets/pipe-loader/pipe_radeonsi.c b/src/gallium/targets/pipe-loader/pipe_radeonsi.c index 5657595af19..9d925c727f1 100644 --- a/src/gallium/targets/pipe-loader/pipe_radeonsi.c +++ b/src/gallium/targets/pipe-loader/pipe_radeonsi.c @@ -1,23 +1,14 @@ #include "state_tracker/drm_driver.h" #include "target-helpers/inline_debug_helper.h" -#include "radeon/drm/radeon_drm_public.h" -#include "radeon/radeon_winsys.h" -#include "amdgpu/drm/amdgpu_public.h" #include "radeonsi/si_public.h" #include "util/xmlpool.h" static struct pipe_screen * create_screen(int fd, const struct pipe_screen_config *config) { - struct radeon_winsys *rw; + struct pipe_screen *screen = radeonsi_screen_create(fd, config); - /* First, try amdgpu. */ - rw = amdgpu_winsys_create(fd, config, radeonsi_screen_create); - - if (!rw) - rw = radeon_drm_winsys_create(fd, config, radeonsi_screen_create); - - return rw ? debug_screen_wrap(rw->screen) : NULL; + return screen ? debug_screen_wrap(screen) : NULL; } static const char *driconf_xml = diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c index 1430c94d3e4..d2776b347cb 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c @@ -284,17 +284,9 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config, radeon_screen_create_t screen_create) { struct amdgpu_winsys *ws; - drmVersionPtr version = drmGetVersion(fd); amdgpu_device_handle dev; uint32_t drm_major, drm_minor, r; - /* The DRM driver version of amdgpu is 3.x.x. */ - if (version->version_major != 3) { - drmFreeVersion(version); - return NULL; - } - drmFreeVersion(version); - /* Look up the winsys from the dev table. */ simple_mtx_lock(&dev_tab_mutex); if (!dev_tab) |