1 /****************************************************************************
2 * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
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:
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
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
22 ***************************************************************************/
24 #include "util/u_cpu_detect.h"
25 #include "util/u_dl.h"
26 #include "swr_public.h"
27 #include "swr_screen.h"
32 swr_create_screen(struct sw_winsys
*winsys
)
34 char filename
[256] = { 0 };
35 fprintf(stderr
, "SWR detected ");
37 util_dl_library
*pLibrary
= nullptr;
43 if (!strlen(filename
) &&
44 util_cpu_caps
.has_avx512f
&& util_cpu_caps
.has_avx512er
) {
46 fprintf(stderr
, "KNL ");
47 sprintf(filename
, "%s%s%s", UTIL_DL_PREFIX
, "swrKNL", UTIL_DL_EXT
);
50 fprintf(stderr
, "KNL (not built) ");
54 if (!strlen(filename
) &&
55 util_cpu_caps
.has_avx512f
&& util_cpu_caps
.has_avx512bw
) {
57 fprintf(stderr
, "SKX ");
58 sprintf(filename
, "%s%s%s", UTIL_DL_PREFIX
, "swrSKX", UTIL_DL_EXT
);
60 fprintf(stderr
, "SKX (not built) ");
64 if (!strlen(filename
) && util_cpu_caps
.has_avx2
) {
66 fprintf(stderr
, "AVX2 ");
67 sprintf(filename
, "%s%s%s", UTIL_DL_PREFIX
, "swrAVX2", UTIL_DL_EXT
);
69 fprintf(stderr
, "AVX2 (not built) ");
73 if (!strlen(filename
) && util_cpu_caps
.has_avx
) {
75 fprintf(stderr
, "AVX ");
76 sprintf(filename
, "%s%s%s", UTIL_DL_PREFIX
, "swrAVX", UTIL_DL_EXT
);
78 fprintf(stderr
, "AVX (not built) ");
82 if (!strlen(filename
)) {
83 fprintf(stderr
, "- no appropriate swr architecture library. Aborting!\n");
86 fprintf(stderr
, "\n");
89 pLibrary
= util_dl_open(filename
);
92 fprintf(stderr
, "SWR library load failure: %s\n", util_dl_error());
96 util_dl_proc pApiProc
= util_dl_get_proc_address(pLibrary
, "SwrGetInterface");
99 fprintf(stderr
, "SWR library search failure: %s\n", util_dl_error());
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
;
112 // swap function called from libl_gdi.c
115 swr_gdi_swap(struct pipe_screen
*screen
,
116 struct pipe_resource
*res
,
119 screen
->flush_frontbuffer(screen
,