[Mesa-dev] [PATCH v2 7/8] swr: Added swr windows support
George Kyriazis
george.kyriazis at intel.com
Wed Nov 9 23:18:45 UTC 2016
- moving some header files around for proper inclusion of windows.h
- OS agnostic loading of arch-specific loadable modules
- PUBLIC function declaration
- better handling on NOMINMAX around windows.h inclusion.
---
src/gallium/drivers/swr/rasterizer/common/os.h | 5 ++++-
src/gallium/drivers/swr/swr_context.cpp | 16 +++++++--------
src/gallium/drivers/swr/swr_context.h | 2 ++
src/gallium/drivers/swr/swr_loader.cpp | 28 +++++++++++++++++++++++---
src/gallium/drivers/swr/swr_public.h | 11 ++++++----
src/gallium/drivers/swr/swr_screen.cpp | 25 +++++++----------------
6 files changed, 53 insertions(+), 34 deletions(-)
diff --git a/src/gallium/drivers/swr/rasterizer/common/os.h b/src/gallium/drivers/swr/rasterizer/common/os.h
index ac52b60..28e7ff5 100644
--- a/src/gallium/drivers/swr/rasterizer/common/os.h
+++ b/src/gallium/drivers/swr/rasterizer/common/os.h
@@ -33,8 +33,11 @@
#ifndef NOMINMAX
#define NOMINMAX
-#endif
#include <windows.h>
+#undef NOMINMAX
+#else
+#include <windows.h>
+#endif
#include <intrin.h>
#include <cstdint>
diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp
index cbc60e0..27273e0 100644
--- a/src/gallium/drivers/swr/swr_context.cpp
+++ b/src/gallium/drivers/swr/swr_context.cpp
@@ -21,6 +21,14 @@
* IN THE SOFTWARE.
***************************************************************************/
+#include "swr_context.h"
+#include "swr_memory.h"
+#include "swr_screen.h"
+#include "swr_resource.h"
+#include "swr_scratch.h"
+#include "swr_query.h"
+#include "swr_fence.h"
+
#include "util/u_memory.h"
#include "util/u_inlines.h"
#include "util/u_format.h"
@@ -31,14 +39,6 @@ extern "C" {
#include "util/u_surface.h"
}
-#include "swr_context.h"
-#include "swr_memory.h"
-#include "swr_screen.h"
-#include "swr_resource.h"
-#include "swr_scratch.h"
-#include "swr_query.h"
-#include "swr_fence.h"
-
#include "api.h"
#include "backend.h"
diff --git a/src/gallium/drivers/swr/swr_context.h b/src/gallium/drivers/swr/swr_context.h
index eecfe0d..04e11fe 100644
--- a/src/gallium/drivers/swr/swr_context.h
+++ b/src/gallium/drivers/swr/swr_context.h
@@ -24,6 +24,8 @@
#ifndef SWR_CONTEXT_H
#define SWR_CONTEXT_H
+#include "common/os.h"
+
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "util/u_blitter.h"
diff --git a/src/gallium/drivers/swr/swr_loader.cpp b/src/gallium/drivers/swr/swr_loader.cpp
index 2113c37..4f3329e 100644
--- a/src/gallium/drivers/swr/swr_loader.cpp
+++ b/src/gallium/drivers/swr/swr_loader.cpp
@@ -25,14 +25,17 @@
#include "util/u_dl.h"
#include "swr_public.h"
+#include "swr_screen.h"
+#include "swr_resource.h"
+
#include <stdio.h>
-#include <dlfcn.h>
typedef pipe_screen *(*screen_create_proc)(struct sw_winsys *winsys);
struct pipe_screen *
swr_create_screen(struct sw_winsys *winsys)
{
+ char filename[256];
fprintf(stderr, "SWR detected ");
util_dl_library *pLibrary = nullptr;
@@ -40,14 +43,15 @@ swr_create_screen(struct sw_winsys *winsys)
util_cpu_detect();
if (util_cpu_caps.has_avx2) {
fprintf(stderr, "AVX2\n");
- pLibrary = util_dl_open("libswrAVX2.so");
+ sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX2", UTIL_DL_EXT);
} else if (util_cpu_caps.has_avx) {
fprintf(stderr, "AVX\n");
- pLibrary = util_dl_open("libswrAVX.so");
+ sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX", UTIL_DL_EXT);
} else {
fprintf(stderr, "no AVX/AVX2 support. Aborting!\n");
exit(-1);
}
+ pLibrary = util_dl_open(filename);
if (!pLibrary) {
fprintf(stderr, "SWR library load failure: %s\n", util_dl_error());
@@ -65,3 +69,21 @@ swr_create_screen(struct sw_winsys *winsys)
return pScreenCreate(winsys);
}
+
+
+#ifdef _WIN32
+// swap function called from libl_gdi.c
+
+void
+swr_gdi_swap(struct pipe_screen *screen,
+ struct pipe_resource *res,
+ void *hDC)
+{
+ screen->flush_frontbuffer(screen,
+ res,
+ 0, 0,
+ hDC,
+ NULL);
+}
+
+#endif /* _WIN32 */
diff --git a/src/gallium/drivers/swr/swr_public.h b/src/gallium/drivers/swr/swr_public.h
index 0814c3b..fede820 100644
--- a/src/gallium/drivers/swr/swr_public.h
+++ b/src/gallium/drivers/swr/swr_public.h
@@ -32,12 +32,15 @@ struct sw_displaytarget;
extern "C" {
#endif
-struct pipe_screen *swr_create_screen(struct sw_winsys *winsys);
+PUBLIC struct pipe_screen *swr_create_screen(struct sw_winsys *winsys);
-struct sw_winsys *swr_get_winsys(struct pipe_screen *pipe);
-
-struct sw_displaytarget *swr_get_displaytarget(struct pipe_resource *resource);
+#ifdef _WIN32
+void
+swr_gdi_swap(struct pipe_screen *screen,
+ struct pipe_resource *res,
+ void *hDC);
+#endif /* _WIN32 */
#ifdef __cplusplus
}
diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp
index fa16edd..04a1d36 100644
--- a/src/gallium/drivers/swr/swr_screen.cpp
+++ b/src/gallium/drivers/swr/swr_screen.cpp
@@ -21,6 +21,13 @@
* IN THE SOFTWARE.
***************************************************************************/
+#include "swr_context.h"
+#include "swr_public.h"
+#include "swr_screen.h"
+#include "swr_resource.h"
+#include "swr_fence.h"
+#include "gen_knobs.h"
+
#include "pipe/p_screen.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
@@ -35,13 +42,6 @@ extern "C" {
#include "gallivm/lp_bld_limits.h"
}
-#include "swr_public.h"
-#include "swr_screen.h"
-#include "swr_context.h"
-#include "swr_resource.h"
-#include "swr_fence.h"
-#include "gen_knobs.h"
-
#include "jit_api.h"
#include <stdio.h>
@@ -1021,14 +1021,3 @@ swr_create_screen(struct sw_winsys *winsys)
return &screen->base;
}
-struct sw_winsys *
-swr_get_winsys(struct pipe_screen *pipe)
-{
- return ((struct swr_screen *)pipe)->winsys;
-}
-
-struct sw_displaytarget *
-swr_get_displaytarget(struct pipe_resource *resource)
-{
- return ((struct swr_resource *)resource)->display_target;
-}
--
2.10.0.windows.1
More information about the mesa-dev
mailing list