[Mesa-dev] [PATCH 14/15] gallium/tests/trivial: Switch to the winsys loader.

Francisco Jerez currojerez at riseup.net
Thu Mar 22 17:43:18 PDT 2012


It simplifies things slightly, and besides, it makes possible to
execute the trivial tests on a hardware device instead of being
limited to software rendering.
---
 configure.ac                         |   11 +++++++++++
 src/gallium/tests/trivial/Makefile   |   24 ++++++++++--------------
 src/gallium/tests/trivial/quad-tex.c |   24 +++++++++++++-----------
 src/gallium/tests/trivial/tri.c      |   24 +++++++++++++-----------
 4 files changed, 47 insertions(+), 36 deletions(-)

diff --git a/configure.ac b/configure.ac
index a28052c..fe689f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -645,6 +645,12 @@ AC_ARG_ENABLE([gallium_gbm],
     [enable_gallium_gbm="$enableval"],
     [enable_gallium_gbm=auto])
 
+AC_ARG_ENABLE([gallium_tests],
+    [AS_HELP_STRING([--enable-gallium-tests],
+        [Enable optional Gallium tests) @<:@default=disable@:>@])],
+    [enable_gallium_tests="$enableval"],
+    [enable_gallium_tests=no])
+
 # Option for Gallium drivers
 GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast"
 
@@ -1936,6 +1942,11 @@ if test "x$NEED_G3DVL_DRI" = xyes; then
     GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS g3dvl/dri"
 fi
 
+if test "x$enable_gallium_tests" = xyes; then
+    SRC_DIRS="$SRC_DIRS gallium/tests/trivial"
+    enable_gallium_loader=yes
+fi
+
 if test "x$enable_gallium_loader" = xyes; then
     GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS loader/"
 fi
diff --git a/src/gallium/tests/trivial/Makefile b/src/gallium/tests/trivial/Makefile
index 4ddbb0b..8e91d9b 100644
--- a/src/gallium/tests/trivial/Makefile
+++ b/src/gallium/tests/trivial/Makefile
@@ -11,19 +11,10 @@ INCLUDES = \
 	-I$(TOP)/src/gallium/winsys \
 	$(PROG_INCLUDES)
 
-ifeq ($(MESA_LLVM),1)
-LINKS = $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
-LDFLAGS += $(LLVM_LDFLAGS)
-endif
-
 LINKS += \
-	$(TOP)/src/gallium/drivers/rbug/librbug.a \
-	$(TOP)/src/gallium/drivers/trace/libtrace.a \
-	$(TOP)/src/gallium/drivers/galahad/libgalahad.a \
-	$(TOP)/src/gallium/winsys/sw/null/libws_null.a \
-	$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+	$(TOP)/src/gallium/winsys/loader/.libs/libws_loader.a \
 	$(GALLIUM_AUXILIARIES) \
-	$(PROG_LINKS)
+	$(PROG_LINKS) $(LIBUDEV_LIBS)
 
 SOURCES = \
 	tri.c \
@@ -33,17 +24,22 @@ OBJECTS = $(SOURCES:.c=.o)
 
 PROGS = $(OBJECTS:.o=)
 
-PROG_DEFINES = \
-	-DGALLIUM_SOFTPIPE -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD
+PROG_DEFINES = -DPIPE_SEARCH_DIR=\"$(PIPE_SRC_DIR)\"
+
+PIPE_SRC_DIR = $(TOP)/src/gallium/targets/pipe-loader
 
 ##### TARGETS #####
 
-default: $(PROGS)
+default: $(PROGS) pipes
 
 clean:
 	-rm -f $(PROGS)
 	-rm -f *.o
 	-rm -f result.bmp
+	@$(MAKE) -C $(PIPE_SRC_DIR) clean
+
+pipes:
+	@$(MAKE) -C $(PIPE_SRC_DIR)
 
 ##### RULES #####
 
diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c
index cc19e8d..1c9a820 100644
--- a/src/gallium/tests/trivial/quad-tex.c
+++ b/src/gallium/tests/trivial/quad-tex.c
@@ -57,16 +57,12 @@
 #include "util/u_memory.h"
 /* util_make_[fragment|vertex]_passthrough_shader */
 #include "util/u_simple_shaders.h"
-
-/* sw_screen_create: to get a software pipe driver */
-#include "target-helpers/inline_sw_helper.h"
-/* debug_screen_wrap: to wrap with debug pipe drivers */
-#include "target-helpers/inline_debug_helper.h"
-/* null software winsys */
-#include "sw/null/null_sw_winsys.h"
+/* to get a hardware pipe driver */
+#include "loader/ws_loader.h"
 
 struct program
 {
+	struct ws_loader_device *dev;
 	struct pipe_screen *screen;
 	struct pipe_context *pipe;
 	struct cso_context *cso;
@@ -93,10 +89,15 @@ struct program
 static void init_prog(struct program *p)
 {
 	struct pipe_surface surf_tmpl;
-	/* create the software rasterizer */
-	p->screen = sw_screen_create(null_sw_create());
-	/* wrap the screen with any debugger */
-	p->screen = debug_screen_wrap(p->screen);
+	int ret;
+
+	/* find a hardware device */
+	ret = ws_loader_probe(&p->dev, 1);
+	assert(ret);
+
+	/* init a pipe screen */
+	p->screen = ws_loader_create_screen(p->dev, PIPE_SEARCH_DIR);
+	assert(p->screen);
 
 	/* create the pipe driver context and cso context */
 	p->pipe = p->screen->context_create(p->screen, NULL);
@@ -298,6 +299,7 @@ static void close_prog(struct program *p)
 	cso_destroy_context(p->cso);
 	p->pipe->destroy(p->pipe);
 	p->screen->destroy(p->screen);
+	ws_loader_release(&p->dev, 1);
 
 	FREE(p);
 }
diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c
index 9190f78..c402a00 100644
--- a/src/gallium/tests/trivial/tri.c
+++ b/src/gallium/tests/trivial/tri.c
@@ -55,16 +55,12 @@
 #include "util/u_memory.h"
 /* util_make_[fragment|vertex]_passthrough_shader */
 #include "util/u_simple_shaders.h"
-
-/* sw_screen_create: to get a software pipe driver */
-#include "target-helpers/inline_sw_helper.h"
-/* debug_screen_wrap: to wrap with debug pipe drivers */
-#include "target-helpers/inline_debug_helper.h"
-/* null software winsys */
-#include "sw/null/null_sw_winsys.h"
+/* to get a hardware pipe driver */
+#include "loader/ws_loader.h"
 
 struct program
 {
+	struct ws_loader_device *dev;
 	struct pipe_screen *screen;
 	struct pipe_context *pipe;
 	struct cso_context *cso;
@@ -88,10 +84,15 @@ struct program
 static void init_prog(struct program *p)
 {
 	struct pipe_surface surf_tmpl;
-	/* create the software rasterizer */
-	p->screen = sw_screen_create(null_sw_create());
-	/* wrap the screen with any debugger */
-	p->screen = debug_screen_wrap(p->screen);
+	int ret;
+
+	/* find a hardware device */
+	ret = ws_loader_probe(&p->dev, 1);
+	assert(ret);
+
+	/* init a pipe screen */
+	p->screen = ws_loader_create_screen(p->dev, PIPE_SEARCH_DIR);
+	assert(p->screen);
 
 	/* create the pipe driver context and cso context */
 	p->pipe = p->screen->context_create(p->screen, NULL);
@@ -234,6 +235,7 @@ static void close_prog(struct program *p)
 	cso_destroy_context(p->cso);
 	p->pipe->destroy(p->pipe);
 	p->screen->destroy(p->screen);
+	ws_loader_release(&p->dev, 1);
 
 	FREE(p);
 }
-- 
1.7.9.2



More information about the mesa-dev mailing list