[Mesa-dev] [PATCH 3/4] Mesa changes for adding OpenSWR
Tim Rowley
timothy.o.rowley at intel.com
Thu Feb 18 01:53:44 UTC 2016
C++ protection on gallium functions needed for a C++ driver.
Add swr driver as a software target.
---
src/gallium/auxiliary/gallivm/lp_bld_flow.h | 7 ++++++
src/gallium/auxiliary/gallivm/lp_bld_init.h | 7 ++++++
src/gallium/auxiliary/gallivm/lp_bld_sample.h | 6 +++++
src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 8 +++++++
.../auxiliary/target-helpers/inline_sw_helper.h | 13 +++++++++-
.../target-helpers/inline_wrapper_sw_helper.h | 2 +-
src/gallium/auxiliary/util/u_dl.h | 6 +++++
src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 ++++++++++++++++++----
8 files changed, 71 insertions(+), 6 deletions(-)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.h b/src/gallium/auxiliary/gallivm/lp_bld_flow.h
index 0da849b..083b0ad 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_flow.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.h
@@ -37,6 +37,9 @@
#include "gallivm/lp_bld.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
struct lp_type;
@@ -198,4 +201,8 @@ lp_build_array_alloca(struct gallivm_state *gallivm,
LLVMValueRef count,
const char *name);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* !LP_BLD_FLOW_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h
index 9e50f88..ab44661 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h
@@ -35,6 +35,9 @@
#include "lp_bld.h"
#include <llvm-c/ExecutionEngine.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
struct gallivm_state
{
@@ -82,4 +85,8 @@ void
lp_set_store_alignment(LLVMValueRef Inst,
unsigned Align);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* !LP_BLD_INIT_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index a6f0eff..902ae41 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -42,6 +42,9 @@
#include "gallivm/lp_bld_type.h"
#include "gallivm/lp_bld_swizzle.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
struct pipe_resource;
struct pipe_sampler_view;
@@ -625,5 +628,8 @@ lp_build_minify(struct lp_build_context *bld,
LLVMValueRef level,
boolean lod_scalar);
+#ifdef __cplusplus
+}
+#endif
#endif /* LP_BLD_SAMPLE_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index cc45497..b005d7a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -48,6 +48,10 @@
#include "tgsi/tgsi_scan.h"
#include "tgsi/tgsi_info.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define LP_CHAN_ALL ~0
#define LP_MAX_INSTRUCTIONS 256
@@ -663,4 +667,8 @@ lp_build_tgsi_llvm(
struct lp_build_tgsi_context * bld_base,
const struct tgsi_token *tokens);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LP_BLD_TGSI_H */
diff --git a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
index a9ab16f..7576bfd 100644
--- a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
@@ -6,6 +6,10 @@
#include "util/u_debug.h"
#include "state_tracker/sw_winsys.h"
+#ifdef GALLIUM_SWR
+#include "swr/swr_public.h"
+#endif
+
/* Helper function to choose and instantiate one of the software rasterizers:
* llvmpipe, softpipe.
@@ -42,6 +46,11 @@ sw_screen_create_named(struct sw_winsys *winsys, const char *driver)
}
#endif
+#if defined(GALLIUM_SWR)
+ if (screen == NULL && strcmp(driver, "swr") == 0)
+ screen = swr_create_screen(winsys);
+#endif
+
#if defined(GALLIUM_SOFTPIPE)
if (screen == NULL)
screen = softpipe_create_screen(winsys);
@@ -57,7 +66,9 @@ sw_screen_create(struct sw_winsys *winsys)
const char *default_driver;
const char *driver;
-#if defined(GALLIUM_LLVMPIPE)
+#if defined(GALLIUM_SWR)
+ default_driver = "swr";
+#elif defined(GALLIUM_LLVMPIPE)
default_driver = "llvmpipe";
#elif defined(GALLIUM_SOFTPIPE)
default_driver = "softpipe";
diff --git a/src/gallium/auxiliary/target-helpers/inline_wrapper_sw_helper.h b/src/gallium/auxiliary/target-helpers/inline_wrapper_sw_helper.h
index 4f38ba9..d707b8b 100644
--- a/src/gallium/auxiliary/target-helpers/inline_wrapper_sw_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_wrapper_sw_helper.h
@@ -12,7 +12,7 @@
static inline struct pipe_screen *
sw_screen_wrap(struct pipe_screen *screen)
{
-#if defined(GALLIUM_SOFTPIPE) || defined(GALLIUM_LLVMPIPE)
+#if defined(GALLIUM_SOFTPIPE) || defined(GALLIUM_LLVMPIPE) || defined(GALLIUM_SWR)
struct sw_winsys *sws;
struct pipe_screen *sw_screen = NULL;
const char *driver;
diff --git a/src/gallium/auxiliary/util/u_dl.h b/src/gallium/auxiliary/util/u_dl.h
index 80a00ed..d2f4737 100644
--- a/src/gallium/auxiliary/util/u_dl.h
+++ b/src/gallium/auxiliary/util/u_dl.h
@@ -32,6 +32,9 @@
#include "pipe/p_config.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
#if defined(PIPE_OS_WINDOWS)
# define UTIL_DL_EXT ".dll"
@@ -79,5 +82,8 @@ util_dl_close(struct util_dl_library *library);
const char *
util_dl_error(void);
+#ifdef __cplusplus
+}
+#endif
#endif /* U_DL_H_ */
diff --git a/src/gallium/targets/libgl-gdi/libgl_gdi.c b/src/gallium/targets/libgl-gdi/libgl_gdi.c
index 922c186..3af0248 100644
--- a/src/gallium/targets/libgl-gdi/libgl_gdi.c
+++ b/src/gallium/targets/libgl-gdi/libgl_gdi.c
@@ -51,8 +51,12 @@
#include "llvmpipe/lp_public.h"
#endif
+#ifdef HAVE_SWR
+#include "swr/swr_public.h"
+#endif
static boolean use_llvmpipe = FALSE;
+static boolean use_swr = FALSE;
static struct pipe_screen *
@@ -69,6 +73,8 @@ gdi_screen_create(void)
#ifdef HAVE_LLVMPIPE
default_driver = "llvmpipe";
+#elif HAVE_SWR
+ default_driver = "swr";
#else
default_driver = "softpipe";
#endif
@@ -78,16 +84,21 @@ gdi_screen_create(void)
#ifdef HAVE_LLVMPIPE
if (strcmp(driver, "llvmpipe") == 0) {
screen = llvmpipe_create_screen( winsys );
+ if (screen)
+ use_llvmpipe = TRUE;
+ }
+#elif HAVE_SWR
+ if (strcmp(driver, "swr") == 0) {
+ screen = swr_create_screen( winsys );
+ if (screen)
+ use_swr = TRUE;
}
-#else
(void) driver;
#endif
if (screen == NULL) {
screen = softpipe_create_screen( winsys );
- } else {
- use_llvmpipe = TRUE;
- }
+ }
if(!screen)
goto no_screen;
@@ -128,6 +139,15 @@ gdi_present(struct pipe_screen *screen,
}
#endif
+#ifdef HAVE_SWR
+ if (use_swr) {
+ winsys = swr_get_winsys(screen);
+ dt = swr_get_displaytarget(res);
+ gdi_sw_display(winsys, dt, hDC);
+ return;
+ }
+#endif
+
winsys = softpipe_screen(screen)->winsys,
dt = softpipe_resource(res)->dt,
gdi_sw_display(winsys, dt, hDC);
--
1.9.1
More information about the mesa-dev
mailing list