broadcom/vc5: Use u_transfer_helper for MSAA mappings.
[mesa.git] / src / gallium / drivers / swr / swr_loader.cpp
1 /****************************************************************************
2 * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 ***************************************************************************/
23
24 #include "util/u_cpu_detect.h"
25 #include "util/u_dl.h"
26 #include "swr_public.h"
27 #include "swr_screen.h"
28
29 #include <stdio.h>
30
31 struct pipe_screen *
32 swr_create_screen(struct sw_winsys *winsys)
33 {
34 char filename[256] = { 0 };
35 fprintf(stderr, "SWR detected ");
36
37 util_dl_library *pLibrary = nullptr;
38
39 util_cpu_detect();
40
41 bool is_knl = false;
42
43 if (!strlen(filename) &&
44 util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512er) {
45 #if HAVE_SWR_KNL
46 fprintf(stderr, "KNL ");
47 sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrKNL", UTIL_DL_EXT);
48 is_knl = true;
49 #else
50 fprintf(stderr, "KNL (not built) ");
51 #endif
52 }
53
54 if (!strlen(filename) &&
55 util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512bw) {
56 #if HAVE_SWR_SKX
57 fprintf(stderr, "SKX ");
58 sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrSKX", UTIL_DL_EXT);
59 #else
60 fprintf(stderr, "SKX (not built) ");
61 #endif
62 }
63
64 if (!strlen(filename) && util_cpu_caps.has_avx2) {
65 #if HAVE_SWR_AVX2
66 fprintf(stderr, "AVX2 ");
67 sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX2", UTIL_DL_EXT);
68 #else
69 fprintf(stderr, "AVX2 (not built) ");
70 #endif
71 }
72
73 if (!strlen(filename) && util_cpu_caps.has_avx) {
74 #if HAVE_SWR_AVX
75 fprintf(stderr, "AVX ");
76 sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX", UTIL_DL_EXT);
77 #else
78 fprintf(stderr, "AVX (not built) ");
79 #endif
80 }
81
82 if (!strlen(filename)) {
83 fprintf(stderr, "- no appropriate swr architecture library. Aborting!\n");
84 exit(-1);
85 } else {
86 fprintf(stderr, "\n");
87 }
88
89 pLibrary = util_dl_open(filename);
90
91 if (!pLibrary) {
92 fprintf(stderr, "SWR library load failure: %s\n", util_dl_error());
93 exit(-1);
94 }
95
96 util_dl_proc pApiProc = util_dl_get_proc_address(pLibrary, "SwrGetInterface");
97
98 if (!pApiProc) {
99 fprintf(stderr, "SWR library search failure: %s\n", util_dl_error());
100 exit(-1);
101 }
102
103 struct pipe_screen *screen = swr_create_screen_internal(winsys);
104 swr_screen(screen)->pfnSwrGetInterface = (PFNSwrGetInterface)pApiProc;
105 swr_screen(screen)->is_knl = is_knl;
106
107 return screen;
108 }
109
110
111 #ifdef _WIN32
112 // swap function called from libl_gdi.c
113
114 void
115 swr_gdi_swap(struct pipe_screen *screen,
116 struct pipe_resource *res,
117 void *hDC)
118 {
119 screen->flush_frontbuffer(screen,
120 res,
121 0, 0,
122 hDC,
123 NULL);
124 }
125
126 #endif /* _WIN32 */