1b8e80941Smrg 2b8e80941Smrg#ifndef SW_HELPER_H 3b8e80941Smrg#define SW_HELPER_H 4b8e80941Smrg 5b8e80941Smrg#include "pipe/p_compiler.h" 6b8e80941Smrg#include "util/u_debug.h" 7b8e80941Smrg#include "target-helpers/sw_helper_public.h" 8b8e80941Smrg#include "state_tracker/sw_winsys.h" 9b8e80941Smrg 10b8e80941Smrg 11b8e80941Smrg/* Helper function to choose and instantiate one of the software rasterizers: 12b8e80941Smrg * llvmpipe, softpipe, swr. 13b8e80941Smrg */ 14b8e80941Smrg 15b8e80941Smrg#ifdef GALLIUM_SOFTPIPE 16b8e80941Smrg#include "softpipe/sp_public.h" 17b8e80941Smrg#endif 18b8e80941Smrg 19b8e80941Smrg#ifdef GALLIUM_LLVMPIPE 20b8e80941Smrg#include "llvmpipe/lp_public.h" 21b8e80941Smrg#endif 22b8e80941Smrg 23b8e80941Smrg#ifdef GALLIUM_SWR 24b8e80941Smrg#include "swr/swr_public.h" 25b8e80941Smrg#endif 26b8e80941Smrg 27b8e80941Smrg#ifdef GALLIUM_VIRGL 28b8e80941Smrg#include "virgl/virgl_public.h" 29b8e80941Smrg#include "virgl/vtest/virgl_vtest_public.h" 30b8e80941Smrg#endif 31b8e80941Smrg 32b8e80941Smrgstatic inline struct pipe_screen * 33b8e80941Smrgsw_screen_create_named(struct sw_winsys *winsys, const char *driver) 34b8e80941Smrg{ 35b8e80941Smrg struct pipe_screen *screen = NULL; 36b8e80941Smrg 37b8e80941Smrg#if defined(GALLIUM_LLVMPIPE) 38b8e80941Smrg if (screen == NULL && strcmp(driver, "llvmpipe") == 0) 39b8e80941Smrg screen = llvmpipe_create_screen(winsys); 40b8e80941Smrg#endif 41b8e80941Smrg 42b8e80941Smrg#if defined(GALLIUM_VIRGL) 43b8e80941Smrg if (screen == NULL && strcmp(driver, "virpipe") == 0) { 44b8e80941Smrg struct virgl_winsys *vws; 45b8e80941Smrg vws = virgl_vtest_winsys_wrap(winsys); 46b8e80941Smrg screen = virgl_create_screen(vws); 47b8e80941Smrg } 48b8e80941Smrg#endif 49b8e80941Smrg 50b8e80941Smrg#if defined(GALLIUM_SOFTPIPE) 51b8e80941Smrg if (screen == NULL && strcmp(driver, "softpipe") == 0) 52b8e80941Smrg screen = softpipe_create_screen(winsys); 53b8e80941Smrg#endif 54b8e80941Smrg 55b8e80941Smrg#if defined(GALLIUM_SWR) 56b8e80941Smrg if (screen == NULL && strcmp(driver, "swr") == 0) 57b8e80941Smrg screen = swr_create_screen(winsys); 58b8e80941Smrg#endif 59b8e80941Smrg 60b8e80941Smrg return screen; 61b8e80941Smrg} 62b8e80941Smrg 63b8e80941Smrg 64b8e80941Smrgstruct pipe_screen * 65b8e80941Smrgsw_screen_create(struct sw_winsys *winsys) 66b8e80941Smrg{ 67b8e80941Smrg const char *default_driver; 68b8e80941Smrg const char *driver; 69b8e80941Smrg 70b8e80941Smrg#if defined(GALLIUM_LLVMPIPE) 71b8e80941Smrg default_driver = "llvmpipe"; 72b8e80941Smrg#elif defined(GALLIUM_SOFTPIPE) 73b8e80941Smrg default_driver = "softpipe"; 74b8e80941Smrg#elif defined(GALLIUM_SWR) 75b8e80941Smrg default_driver = "swr"; 76b8e80941Smrg#else 77b8e80941Smrg default_driver = ""; 78b8e80941Smrg#endif 79b8e80941Smrg 80b8e80941Smrg driver = debug_get_option("GALLIUM_DRIVER", default_driver); 81b8e80941Smrg return sw_screen_create_named(winsys, driver); 82b8e80941Smrg} 83b8e80941Smrg 84b8e80941Smrg#endif 85