summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/pipe-loader
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2015-10-14 19:35:51 +0100
committerEmil Velikov <[email protected]>2015-11-21 12:52:18 +0000
commit4e3c06a501cbba8cc463c3c244d6cb838e3be782 (patch)
tree07a1214bba3020948a1ac01a3949f4c8b105ccd6 /src/gallium/auxiliary/pipe-loader
parent6d68d714c0ef6afa9666b6ed5f45bf998024805f (diff)
pipe-loader: add pipe_loader_sw_probe_init_common() helper
Allows us to fold the duplication in pipe_loader_sw_probe_*(). Cc: Tom Stellard <[email protected]> Cc: Francisco Jerez <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Acked-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/pipe-loader')
-rw-r--r--src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index c79f7c9ee34..4b6e884cd9f 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -50,6 +50,19 @@ static struct sw_winsys *(*backends[])() = {
null_sw_create
};
+static bool
+pipe_loader_sw_probe_init_common(struct pipe_loader_sw_device *sdev)
+{
+ if (!sdev->ws)
+ return false;
+
+ sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
+ sdev->base.driver_name = "swrast";
+ sdev->base.ops = &pipe_loader_sw_ops;
+
+ return true;
+}
+
#ifdef HAVE_PIPE_LOADER_DRI
bool
pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, struct drisw_loader_funcs *drisw_lf)
@@ -59,11 +72,8 @@ pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, struct drisw_loader_f
if (!sdev)
return false;
- sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
- sdev->base.driver_name = "swrast";
- sdev->base.ops = &pipe_loader_sw_ops;
sdev->ws = dri_create_sw_winsys(drisw_lf);
- if (!sdev->ws) {
+ if (!pipe_loader_sw_probe_init_common(sdev)) {
FREE(sdev);
return false;
}
@@ -82,11 +92,8 @@ pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd)
if (!sdev)
return false;
- sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
- sdev->base.driver_name = "swrast";
- sdev->base.ops = &pipe_loader_sw_ops;
sdev->ws = kms_dri_create_winsys(fd);
- if (!sdev->ws) {
+ if (!pipe_loader_sw_probe_init_common(sdev)) {
FREE(sdev);
return false;
}
@@ -104,11 +111,8 @@ pipe_loader_sw_probe_null(struct pipe_loader_device **devs)
if (!sdev)
return false;
- sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
- sdev->base.driver_name = "swrast";
- sdev->base.ops = &pipe_loader_sw_ops;
sdev->ws = null_sw_create();
- if (!sdev->ws) {
+ if (!pipe_loader_sw_probe_init_common(sdev)) {
FREE(sdev);
return false;
}
@@ -127,10 +131,8 @@ pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev)
struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
/* TODO: handle CALLOC_STRUCT failure */
- sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
- sdev->base.driver_name = "swrast";
- sdev->base.ops = &pipe_loader_sw_ops;
sdev->ws = backends[i]();
+ pipe_loader_sw_probe_init_common(sdev);
devs[i] = &sdev->base;
}
}
@@ -147,12 +149,8 @@ pipe_loader_sw_probe_wrapped(struct pipe_loader_device **dev,
if (!sdev)
return false;
- sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
- sdev->base.driver_name = "swrast";
- sdev->base.ops = &pipe_loader_sw_ops;
sdev->ws = wrapper_sw_winsys_wrap_pipe_screen(screen);
-
- if (!sdev->ws) {
+ if (!pipe_loader_sw_probe_init_common(sdev)) {
FREE(sdev);
return false;
}