01b98046462e0959653b10fcbafb152d7145921e
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"
31 // Helper function to resolve the backend filename based on architecture
33 swr_initialize_screen_interface(struct swr_screen
*screen
, const char arch
[])
35 #ifdef HAVE_SWR_BUILTIN
36 screen
->pLibrary
= NULL
;
37 screen
->pfnSwrGetInterface
= SwrGetInterface
;
38 fprintf(stderr
, "(using: builtin).\n");
40 char filename
[256] = { 0 };
41 sprintf(filename
, "%sswr%s%s", UTIL_DL_PREFIX
, arch
, UTIL_DL_EXT
);
43 screen
->pLibrary
= util_dl_open(filename
);
44 if (!screen
->pLibrary
) {
45 fprintf(stderr
, "(skipping: %s).\n", util_dl_error());
49 util_dl_proc pApiProc
= util_dl_get_proc_address(screen
->pLibrary
,
52 fprintf(stderr
, "(skipping: %s).\n", util_dl_error());
53 util_dl_close(screen
->pLibrary
);
54 screen
->pLibrary
= NULL
;
58 screen
->pfnSwrGetInterface
= (PFNSwrGetInterface
)pApiProc
;
59 fprintf(stderr
, "(using: %s).\n", filename
);
66 swr_create_screen(struct sw_winsys
*winsys
)
68 struct pipe_screen
*p_screen
= swr_create_screen_internal(winsys
);
73 struct swr_screen
*screen
= swr_screen(p_screen
);
74 screen
->is_knl
= false;
78 if (util_cpu_caps
.has_avx512f
&& util_cpu_caps
.has_avx512er
) {
79 fprintf(stderr
, "SWR detected KNL instruction support ");
81 fprintf(stderr
, "(skipping: not built).\n");
83 if (swr_initialize_screen_interface(screen
, "KNL")) {
84 screen
->is_knl
= true;
90 if (util_cpu_caps
.has_avx512f
&& util_cpu_caps
.has_avx512bw
) {
91 fprintf(stderr
, "SWR detected SKX instruction support ");
93 fprintf(stderr
, "(skipping not built).\n");
95 if (swr_initialize_screen_interface(screen
, "SKX"))
100 if (util_cpu_caps
.has_avx2
) {
101 fprintf(stderr
, "SWR detected AVX2 instruction support ");
102 #ifndef HAVE_SWR_AVX2
103 fprintf(stderr
, "(skipping not built).\n");
105 if (swr_initialize_screen_interface(screen
, "AVX2"))
110 if (util_cpu_caps
.has_avx
) {
111 fprintf(stderr
, "SWR detected AVX instruction support ");
113 fprintf(stderr
, "(skipping not built).\n");
115 if (swr_initialize_screen_interface(screen
, "AVX"))
120 fprintf(stderr
, "SWR could not initialize a supported CPU architecture.\n");
121 swr_destroy_screen_internal(&screen
);
128 // swap function called from libl_gdi.c
131 swr_gdi_swap(struct pipe_screen
*screen
,
132 struct pipe_resource
*res
,
135 screen
->flush_frontbuffer(screen
,