Home | History | Annotate | Download | only in target-helpers
      1 
      2 #ifndef INLINE_WRAPPER_SW_HELPER_H
      3 #define INLINE_WRAPPER_SW_HELPER_H
      4 
      5 #include "target-helpers/inline_sw_helper.h"
      6 #include "sw/wrapper/wrapper_sw_winsys.h"
      7 
      8 /**
      9  * Try to wrap a hw screen with a software screen.
     10  * On failure will return given screen.
     11  */
     12 static INLINE struct pipe_screen *
     13 sw_screen_wrap(struct pipe_screen *screen)
     14 {
     15 #if defined(GALLIUM_SOFTPIPE) || defined(GALLIUM_LLVMPIPE)
     16    struct sw_winsys *sws;
     17    struct pipe_screen *sw_screen = NULL;
     18    const char *driver;
     19 
     20    driver = debug_get_option("GALLIUM_DRIVER", "native");
     21    if (strcmp(driver, "native") == 0)
     22       return screen;
     23 
     24    sws = wrapper_sw_winsys_wrap_pipe_screen(screen);
     25    if (!sws)
     26       goto err;
     27 
     28    sw_screen = sw_screen_create_named(sws, driver);
     29 
     30    if (!sw_screen)
     31       goto err_winsys;
     32 
     33    return sw_screen;
     34 
     35 err_winsys:
     36    return wrapper_sw_winsys_dewrap_pipe_screen(sws);
     37 err:
     38 #endif
     39    return screen;
     40 }
     41 
     42 #endif
     43