1bf215546Sopenharmony_ci/**************************************************************************
2bf215546Sopenharmony_ci *
3bf215546Sopenharmony_ci * Copyright 2012-2021 VMware, Inc.
4bf215546Sopenharmony_ci * All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the
8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to
11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
12bf215546Sopenharmony_ci * the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17bf215546Sopenharmony_ci * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE.
21bf215546Sopenharmony_ci *
22bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
23bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
24bf215546Sopenharmony_ci * of the Software.
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci *
27bf215546Sopenharmony_ci **************************************************************************/
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci#include "util/u_debug.h"
31bf215546Sopenharmony_ci#include "target-helpers/inline_debug_helper.h"
32bf215546Sopenharmony_ci#include "llvmpipe/lp_public.h"
33bf215546Sopenharmony_ci#include "softpipe/sp_public.h"
34bf215546Sopenharmony_ci#include "sw/gdi/gdi_sw_winsys.h"
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_ciextern struct pipe_screen *
38bf215546Sopenharmony_cid3d10_create_screen(void);
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ci
41bf215546Sopenharmony_cistruct pipe_screen *
42bf215546Sopenharmony_cid3d10_create_screen(void)
43bf215546Sopenharmony_ci{
44bf215546Sopenharmony_ci   const char *default_driver;
45bf215546Sopenharmony_ci   const char *driver;
46bf215546Sopenharmony_ci   struct pipe_screen *screen = NULL;
47bf215546Sopenharmony_ci   struct sw_winsys *winsys;
48bf215546Sopenharmony_ci
49bf215546Sopenharmony_ci   winsys = gdi_create_sw_winsys();
50bf215546Sopenharmony_ci   if(!winsys)
51bf215546Sopenharmony_ci      goto no_winsys;
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_ci#ifdef GALLIUM_LLVMPIPE
54bf215546Sopenharmony_ci   default_driver = "llvmpipe";
55bf215546Sopenharmony_ci#else
56bf215546Sopenharmony_ci   default_driver = "softpipe";
57bf215546Sopenharmony_ci#endif
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_ci   driver = debug_get_option("GALLIUM_DRIVER", default_driver);
60bf215546Sopenharmony_ci
61bf215546Sopenharmony_ci#ifdef GALLIUM_LLVMPIPE
62bf215546Sopenharmony_ci   if (strcmp(driver, "llvmpipe") == 0) {
63bf215546Sopenharmony_ci      screen = llvmpipe_create_screen( winsys );
64bf215546Sopenharmony_ci   }
65bf215546Sopenharmony_ci#else
66bf215546Sopenharmony_ci   (void)driver;
67bf215546Sopenharmony_ci#endif
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ci   if (screen == NULL) {
70bf215546Sopenharmony_ci      screen = softpipe_create_screen( winsys );
71bf215546Sopenharmony_ci   }
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ci   if (screen == NULL)
74bf215546Sopenharmony_ci      goto no_screen;
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci   return debug_screen_wrap( screen );
77bf215546Sopenharmony_ci
78bf215546Sopenharmony_cino_screen:
79bf215546Sopenharmony_ci   winsys->destroy(winsys);
80bf215546Sopenharmony_cino_winsys:
81bf215546Sopenharmony_ci   return NULL;
82bf215546Sopenharmony_ci}
83