summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/target-helpers/inline_wrapper_sw_helper.h
blob: e4effa713e9ff8f9f9291ea99ef494ed9c1b478c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

#ifndef INLINE_WRAPPER_SW_HELPER_H
#define INLINE_WRAPPER_SW_HELPER_H

#include "target-helpers/inline_sw_helper.h"
#include "sw/wrapper/wrapper_sw_winsys.h"

/**
 * Try to wrap a hw screen with a software screen.
 * On failure will return given screen.
 */
static INLINE struct pipe_screen *
sw_screen_wrap(struct pipe_screen *screen)
{
   struct sw_winsys *sws;
   struct pipe_screen *sw_screen = NULL;
   const char *driver;

   driver = debug_get_option("GALLIUM_DRIVER", "native");
   if (strcmp(driver, "native") == 0)
      return screen;

   sws = wrapper_sw_winsys_wrap_pipe_screen(screen);
   if (!sws)
      goto err;

   sw_screen = sw_screen_create_named(sws, driver);

   if (!sw_screen)
      goto err_winsys;

   return sw_screen;

err_winsys:
   return wrapper_sw_winsys_dewrap_pipe_screen(sws);
err:
   return screen;
}

#endif