Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Mesa 3-D graphics library
  3.  *
  4.  * Copyright (C) 2011 LunarG Inc.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the "Software"),
  8.  * to deal in the Software without restriction, including without limitation
  9.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10.  * and/or sell copies of the Software, and to permit persons to whom the
  11.  * Software is furnished to do so, subject to the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice shall be included
  14.  * in all copies or substantial portions of the Software.
  15.  *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  19.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22.  * DEALINGS IN THE SOFTWARE.
  23.  *
  24.  * Authors:
  25.  *    Chia-I Wu <olv@lunarg.com>
  26.  */
  27. #include "target-helpers/inline_debug_helper.h"
  28. #include "target-helpers/inline_sw_helper.h"
  29. #include "egl_pipe.h"
  30.  
  31. /* for i915 */
  32. #include "i915/drm/i915_drm_public.h"
  33. #include "i915/i915_public.h"
  34. #include "target-helpers/inline_wrapper_sw_helper.h"
  35. /* for ilo */
  36. #include "intel/intel_winsys.h"
  37. #include "ilo/ilo_public.h"
  38. /* for nouveau */
  39. #include "nouveau/drm/nouveau_drm_public.h"
  40. /* for r300 */
  41. #include "radeon/drm/radeon_drm_public.h"
  42. #include "r300/r300_public.h"
  43. /* for r600 */
  44. #include "r600/r600_public.h"
  45. /* for radeonsi */
  46. #include "radeonsi/radeonsi_public.h"
  47. /* for vmwgfx */
  48. #include "svga/drm/svga_drm_public.h"
  49. #include "svga/svga_public.h"
  50. /* for freedreno */
  51. #include "freedreno/drm/freedreno_drm_public.h"
  52.  
  53. static struct pipe_screen *
  54. pipe_i915_create_screen(int fd)
  55. {
  56. #if _EGL_PIPE_I915
  57.    struct i915_winsys *iws;
  58.    struct pipe_screen *screen;
  59.  
  60.    iws = i915_drm_winsys_create(fd);
  61.    if (!iws)
  62.       return NULL;
  63.  
  64.    screen = i915_screen_create(iws);
  65.    if (!screen)
  66.       return NULL;
  67.  
  68.    screen = debug_screen_wrap(screen);
  69.  
  70.    return screen;
  71. #else
  72.    return NULL;
  73. #endif
  74. }
  75.  
  76. static struct pipe_screen *
  77. pipe_ilo_create_screen(int fd)
  78. {
  79. #if _EGL_PIPE_ILO
  80.    struct intel_winsys *iws;
  81.    struct pipe_screen *screen;
  82.  
  83.    iws = intel_winsys_create_for_fd(fd);
  84.    if (!iws)
  85.       return NULL;
  86.  
  87.    screen = ilo_screen_create(iws);
  88.    if (!screen)
  89.       return NULL;
  90.  
  91.    screen = debug_screen_wrap(screen);
  92.  
  93.    return screen;
  94. #else
  95.    return NULL;
  96. #endif
  97. }
  98.  
  99. static struct pipe_screen *
  100. pipe_nouveau_create_screen(int fd)
  101. {
  102. #if _EGL_PIPE_NOUVEAU
  103.    struct pipe_screen *screen;
  104.  
  105.    screen = nouveau_drm_screen_create(fd);
  106.    if (!screen)
  107.       return NULL;
  108.  
  109.    screen = debug_screen_wrap(screen);
  110.  
  111.    return screen;
  112. #else
  113.    return NULL;
  114. #endif
  115. }
  116.  
  117. static struct pipe_screen *
  118. pipe_r300_create_screen(int fd)
  119. {
  120. #if _EGL_PIPE_R300
  121.    struct radeon_winsys *sws;
  122.    struct pipe_screen *screen;
  123.  
  124.    sws = radeon_drm_winsys_create(fd);
  125.    if (!sws)
  126.       return NULL;
  127.  
  128.    screen = r300_screen_create(sws);
  129.    if (!screen)
  130.       return NULL;
  131.  
  132.    screen = debug_screen_wrap(screen);
  133.  
  134.    return screen;
  135. #else
  136.    return NULL;
  137. #endif
  138. }
  139.  
  140. static struct pipe_screen *
  141. pipe_r600_create_screen(int fd)
  142. {
  143. #if _EGL_PIPE_R600
  144.    struct radeon_winsys *rw;
  145.    struct pipe_screen *screen;
  146.  
  147.    rw = radeon_drm_winsys_create(fd);
  148.    if (!rw)
  149.       return NULL;
  150.  
  151.    screen = r600_screen_create(rw);
  152.    if (!screen)
  153.       return NULL;
  154.  
  155.    screen = debug_screen_wrap(screen);
  156.  
  157.    return screen;
  158. #else
  159.    return NULL;
  160. #endif
  161. }
  162.  
  163. static struct pipe_screen *
  164. pipe_radeonsi_create_screen(int fd)
  165. {
  166. #if _EGL_PIPE_RADEONSI
  167.    struct radeon_winsys *rw;
  168.    struct pipe_screen *screen;
  169.  
  170.    rw = radeon_drm_winsys_create(fd);
  171.    if (!rw)
  172.       return NULL;
  173.  
  174.    screen = radeonsi_screen_create(rw);
  175.    if (!screen)
  176.       return NULL;
  177.  
  178.    screen = debug_screen_wrap(screen);
  179.  
  180.    return screen;
  181. #else
  182.    return NULL;
  183. #endif
  184. }
  185.  
  186. static struct pipe_screen *
  187. pipe_vmwgfx_create_screen(int fd)
  188. {
  189. #if _EGL_PIPE_VMWGFX
  190.    struct svga_winsys_screen *sws;
  191.    struct pipe_screen *screen;
  192.  
  193.    sws = svga_drm_winsys_screen_create(fd);
  194.    if (!sws)
  195.       return NULL;
  196.  
  197.    screen = svga_screen_create(sws);
  198.    if (!screen)
  199.       return NULL;
  200.  
  201.    screen = debug_screen_wrap(screen);
  202.  
  203.    return screen;
  204. #else
  205.    return NULL;
  206. #endif
  207. }
  208.  
  209. static struct pipe_screen *
  210. pipe_freedreno_create_screen(int fd)
  211. {
  212. #if _EGL_PIPE_FREEDRENO
  213.    struct pipe_screen *screen;
  214.  
  215.    screen = fd_drm_screen_create(fd);
  216.    if (!screen)
  217.       return NULL;
  218.  
  219.    screen = debug_screen_wrap(screen);
  220.  
  221.    return screen;
  222. #else
  223.    return NULL;
  224. #endif
  225. }
  226.  
  227. struct pipe_screen *
  228. egl_pipe_create_drm_screen(const char *name, int fd)
  229. {
  230.    if (strcmp(name, "i915") == 0)
  231.       return pipe_i915_create_screen(fd);
  232.    else if (strcmp(name, "i965") == 0)
  233.       return pipe_ilo_create_screen(fd);
  234.    else if (strcmp(name, "nouveau") == 0)
  235.       return pipe_nouveau_create_screen(fd);
  236.    else if (strcmp(name, "r300") == 0)
  237.       return pipe_r300_create_screen(fd);
  238.    else if (strcmp(name, "r600") == 0)
  239.       return pipe_r600_create_screen(fd);
  240.    else if (strcmp(name, "radeonsi") == 0)
  241.       return pipe_radeonsi_create_screen(fd);
  242.    else if (strcmp(name, "vmwgfx") == 0)
  243.       return pipe_vmwgfx_create_screen(fd);
  244.    else if (strcmp(name, "kgsl") == 0)
  245.       return pipe_freedreno_create_screen(fd);
  246.    else
  247.       return NULL;
  248. }
  249.  
  250. struct pipe_screen *
  251. egl_pipe_create_swrast_screen(struct sw_winsys *ws)
  252. {
  253.    struct pipe_screen *screen;
  254.  
  255.    screen = sw_screen_create(ws);
  256.    if (screen)
  257.       screen = debug_screen_wrap(screen);
  258.  
  259.    return screen;
  260. }
  261.