radeonsi: clean up winsys creation
- unify the code - choose radeon or amdgpu based on the DRM version, not based on which one succeeds first
This commit is contained in:
parent
bb5d82bd06
commit
fccced57cf
|
@ -161,23 +161,14 @@ pipe_r600_create_screen(int fd, const struct pipe_screen_config *config)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GALLIUM_RADEONSI
|
#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"
|
#include "radeonsi/si_public.h"
|
||||||
|
|
||||||
struct pipe_screen *
|
struct pipe_screen *
|
||||||
pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config)
|
pipe_radeonsi_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. */
|
return screen ? debug_screen_wrap(screen) : NULL;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *radeonsi_driconf_xml =
|
const char *radeonsi_driconf_xml =
|
||||||
|
|
|
@ -42,6 +42,10 @@
|
||||||
#include "vl/vl_decoder.h"
|
#include "vl/vl_decoder.h"
|
||||||
#include "driver_ddebug/dd_util.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[] = {
|
static const struct debug_named_value debug_options[] = {
|
||||||
/* Shader logging options: */
|
/* Shader logging options: */
|
||||||
{ "vs", DBG(VS), "Print vertex shaders" },
|
{ "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);
|
return util_queue_fence_is_signalled(&sel->ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws,
|
static struct pipe_screen *
|
||||||
const struct pipe_screen_config *config)
|
radeonsi_screen_create_impl(struct radeon_winsys *ws,
|
||||||
|
const struct pipe_screen_config *config)
|
||||||
{
|
{
|
||||||
struct si_screen *sscreen = CALLOC_STRUCT(si_screen);
|
struct si_screen *sscreen = CALLOC_STRUCT(si_screen);
|
||||||
unsigned hw_threads, num_comp_hi_threads, num_comp_lo_threads, i;
|
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;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -25,9 +25,6 @@
|
||||||
#ifndef SI_PUBLIC_H
|
#ifndef SI_PUBLIC_H
|
||||||
#define SI_PUBLIC_H
|
#define SI_PUBLIC_H
|
||||||
|
|
||||||
struct radeon_winsys;
|
struct pipe_screen *radeonsi_screen_create(int fd, const struct pipe_screen_config *config);
|
||||||
|
|
||||||
struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws,
|
|
||||||
const struct pipe_screen_config *config);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,23 +1,14 @@
|
||||||
#include "state_tracker/drm_driver.h"
|
#include "state_tracker/drm_driver.h"
|
||||||
#include "target-helpers/inline_debug_helper.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 "radeonsi/si_public.h"
|
||||||
#include "util/xmlpool.h"
|
#include "util/xmlpool.h"
|
||||||
|
|
||||||
static struct pipe_screen *
|
static struct pipe_screen *
|
||||||
create_screen(int fd, const struct pipe_screen_config *config)
|
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. */
|
return screen ? debug_screen_wrap(screen) : NULL;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *driconf_xml =
|
static const char *driconf_xml =
|
||||||
|
|
|
@ -284,17 +284,9 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
|
||||||
radeon_screen_create_t screen_create)
|
radeon_screen_create_t screen_create)
|
||||||
{
|
{
|
||||||
struct amdgpu_winsys *ws;
|
struct amdgpu_winsys *ws;
|
||||||
drmVersionPtr version = drmGetVersion(fd);
|
|
||||||
amdgpu_device_handle dev;
|
amdgpu_device_handle dev;
|
||||||
uint32_t drm_major, drm_minor, r;
|
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. */
|
/* Look up the winsys from the dev table. */
|
||||||
simple_mtx_lock(&dev_tab_mutex);
|
simple_mtx_lock(&dev_tab_mutex);
|
||||||
if (!dev_tab)
|
if (!dev_tab)
|
||||||
|
|
Loading…
Reference in New Issue