noop: make noop useable like trace or rbug
authorJerome Glisse <jglisse@redhat.com>
Mon, 10 Jan 2011 02:04:41 +0000 (21:04 -0500)
committerJerome Glisse <jglisse@redhat.com>
Mon, 10 Jan 2011 02:04:41 +0000 (21:04 -0500)
If you want to enable noop set GALLIUM_NOOP=1 as an env variable.
You need first to enable noop wrapping for your driver see change
to src/gallium/targets/dri-r600/ in this commit as an example.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
configs/default
configure.ac
src/gallium/auxiliary/target-helpers/inline_noop_helper.h [new file with mode: 0644]
src/gallium/drivers/noop/noop_pipe.c
src/gallium/drivers/noop/noop_public.h
src/gallium/targets/dri-r600/Makefile
src/gallium/targets/dri-r600/target.c

index 3ce90ef981efebdb7893a7ee92051de2cf19d8e1..394dc17f68db857d2df79c8e6b9ea15ecac56bef 100644 (file)
@@ -107,7 +107,7 @@ EGL_DRIVERS_DIRS = glx
 # Gallium directories and 
 GALLIUM_DIRS = auxiliary drivers state_trackers
 GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
-GALLIUM_DRIVERS_DIRS = softpipe trace rbug identity galahad i915 i965 svga r300 nvfx nv50 failover
+GALLIUM_DRIVERS_DIRS = softpipe trace rbug noop identity galahad i915 i965 svga r300 nvfx nv50 failover
 GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
 GALLIUM_WINSYS_DIRS = sw sw/xlib
 GALLIUM_TARGET_DIRS = libgl-xlib
index bcf7cd38a612f855e38a352363ad6309b1815eb3..ca2a05ca48a4ed674df3b68e11c655ba0e378cdc 100644 (file)
@@ -588,7 +588,7 @@ GLU_DIRS="sgi"
 GALLIUM_DIRS="auxiliary drivers state_trackers"
 GALLIUM_TARGET_DIRS=""
 GALLIUM_WINSYS_DIRS="sw"
-GALLIUM_DRIVERS_DIRS="softpipe failover galahad trace rbug identity"
+GALLIUM_DRIVERS_DIRS="softpipe failover galahad trace rbug noop identity"
 GALLIUM_STATE_TRACKERS_DIRS=""
 
 # build glapi if OpenGL is enabled
diff --git a/src/gallium/auxiliary/target-helpers/inline_noop_helper.h b/src/gallium/auxiliary/target-helpers/inline_noop_helper.h
new file mode 100644 (file)
index 0000000..77c7cfd
--- /dev/null
@@ -0,0 +1,51 @@
+
+#ifndef INLINE_DEBUG_HELPER_H
+#define INLINE_DEBUG_HELPER_H
+
+#include "pipe/p_compiler.h"
+#include "util/u_debug.h"
+
+
+/* Helper function to wrap a screen with
+ * one or more debug driver: rbug, trace.
+ */
+
+#ifdef GALLIUM_TRACE
+#include "trace/tr_public.h"
+#endif
+
+#ifdef GALLIUM_RBUG
+#include "rbug/rbug_public.h"
+#endif
+
+#ifdef GALLIUM_GALAHAD
+#include "galahad/glhd_public.h"
+#endif
+
+#ifdef GALLIUM_NOOP
+#include "noop/noop_public.h"
+#endif
+
+static INLINE struct pipe_screen *
+debug_screen_wrap(struct pipe_screen *screen)
+{
+#if defined(GALLIUM_RBUG)
+   screen = rbug_screen_create(screen);
+#endif
+
+#if defined(GALLIUM_TRACE)
+   screen = trace_screen_create(screen);
+#endif
+
+#if defined(GALLIUM_GALAHAD)
+   screen = galahad_screen_create(screen);
+#endif
+
+#if defined(GALLIUM_NOOP)
+   screen = noop_screen_create(screen);
+#endif
+
+   return screen;
+}
+
+#endif
index c9c463f470f7f848ff41dfe533b9917950fce399..8c9efc2f5368a8bc50108ca2fa813f750f70859c 100644 (file)
 #include <util/u_inlines.h>
 #include <util/u_format.h>
 #include "noop_public.h"
-#include "state_tracker/sw_winsys.h"
+
+DEBUG_GET_ONCE_BOOL_OPTION(noop, "GALLIUM_NOOP", FALSE)
 
 void noop_init_state_functions(struct pipe_context *ctx);
 
+struct noop_pipe_screen {
+       struct pipe_screen      pscreen;
+       struct pipe_screen      *oscreen;
+};
+
 /*
  * query
  */
@@ -108,52 +114,29 @@ static struct pipe_resource *noop_resource_create(struct pipe_screen *screen,
                FREE(nresource);
                return NULL;
        }
-#if 0
-       if (nresource->base.bind & (PIPE_BIND_DISPLAY_TARGET |
-                                       PIPE_BIND_SCANOUT |
-                                       PIPE_BIND_SHARED)) {
-               struct sw_winsys *winsys = (struct sw_winsys *)screen->winsys;
-               unsigned stride;
-
-               nresource->dt = winsys->displaytarget_create(winsys, nresource->base.bind,
-                                                               nresource->base.format,
-                                                               nresource->base.width0, 
-                                                               nresource->base.height0,
-                                                               16, &stride);
-       }
-#endif
        return &nresource->base;
 }
 
-static struct pipe_resource *noop_resource_from_handle(struct pipe_screen * screen,
+static struct pipe_resource *noop_resource_from_handle(struct pipe_screen *screen,
                                                        const struct pipe_resource *templ,
-                                                       struct winsys_handle *whandle)
+                                                       struct winsys_handle *handle)
 {
-       struct sw_winsys *winsys = (struct sw_winsys *)screen->winsys;
-       struct noop_resource *nresource;
-       struct sw_displaytarget *dt;
-       unsigned stride;
+       struct noop_pipe_screen *noop_screen = (struct noop_pipe_screen*)screen;
+       struct pipe_screen *oscreen = noop_screen->oscreen;
+       struct pipe_resource *result;
+       struct noop_resource *noop_resource;
 
-       dt = winsys->displaytarget_from_handle(winsys, templ, whandle, &stride);
-       if (dt == NULL) {
-               return NULL;
-       }
-       nresource = (struct noop_resource *)noop_resource_create(screen, templ);
-       nresource->dt = dt;
-       return &nresource->base;
+       result = oscreen->resource_from_handle(oscreen, templ, handle);
+       noop_resource = noop_resource_create(screen, result);
+       pipe_resource_reference(&result, NULL);
+       return noop_resource;
 }
 
 static boolean noop_resource_get_handle(struct pipe_screen *screen,
                                        struct pipe_resource *resource,
                                        struct winsys_handle *handle)
 {
-       struct sw_winsys *winsys = (struct sw_winsys *)screen->winsys;
-       struct noop_resource *nresource = (struct noop_resource *)resource;
-
-       if (nresource->dt == NULL)
-               return FALSE;
-
-       return winsys->displaytarget_get_handle(winsys, nresource->dt, handle);
+       return FALSE;
 }
 
 static void noop_resource_destroy(struct pipe_screen *screen,
@@ -161,11 +144,6 @@ static void noop_resource_destroy(struct pipe_screen *screen,
 {
        struct noop_resource *nresource = (struct noop_resource *)resource;
 
-       if (nresource->dt) {
-               /* display target */
-               struct sw_winsys *winsys = (struct sw_winsys *)screen->winsys;
-               winsys->displaytarget_destroy(winsys, nresource->dt);
-       }
        free(nresource->data);
        FREE(resource);
 }
@@ -483,19 +461,30 @@ static boolean noop_is_format_supported(struct pipe_screen* screen,
 
 static void noop_destroy_screen(struct pipe_screen *screen)
 {
+       struct noop_pipe_screen *noop_screen = (struct noop_pipe_screen*)screen;
+       struct pipe_screen *oscreen = noop_screen->oscreen;
+
+       oscreen->destroy(oscreen);
        FREE(screen);
 }
 
-struct pipe_screen *noop_screen_create(struct sw_winsys *winsys)
+struct pipe_screen *noop_screen_create(struct pipe_screen *oscreen)
 {
+       struct noop_pipe_screen *noop_screen;
        struct pipe_screen *screen;
 
-       screen = CALLOC_STRUCT(pipe_screen);
-       if (screen == NULL) {
+       if (!debug_get_option_noop()) {
+               return oscreen;
+       }
+
+       noop_screen = CALLOC_STRUCT(noop_pipe_screen);
+       if (noop_screen == NULL) {
                return NULL;
        }
+       noop_screen->oscreen = oscreen;
+       screen = &noop_screen->pscreen;
 
-       screen->winsys = (struct pipe_winsys*)winsys;
+       screen->winsys = oscreen->winsys;
        screen->destroy = noop_destroy_screen;
        screen->get_name = noop_get_name;
        screen->get_vendor = noop_get_vendor;
index 8ce82bec698a13a75dbd6fdc6bc08521ff15573d..180ea597fab10bc6c4002f00584dd9bb617161ca 100644 (file)
@@ -23,8 +23,7 @@
 #ifndef NOOP_PUBLIC_H
 #define NOOP_PUBLIC_H
 
-struct sw_winsys;
-
-struct pipe_screen *noop_screen_create(struct sw_winsys *winsys);
+struct pipe_screen;
+struct pipe_screen *noop_screen_create(struct pipe_screen *screen);
 
 #endif
index 661283de6a837784bb49f7cf33ebf650cf1387b6..c8fae2d85851641bce0f6095f26810b58dc99cd0 100644 (file)
@@ -9,7 +9,8 @@ PIPE_DRIVERS = \
        $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
        $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
        $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/rbug/librbug.a
+       $(TOP)/src/gallium/drivers/rbug/librbug.a \
+       $(TOP)/src/gallium/drivers/noop/libnoop.a
 
 C_SOURCES = \
        target.c \
@@ -17,7 +18,7 @@ C_SOURCES = \
        $(DRIVER_SOURCES)
 
 DRIVER_DEFINES = \
-       -DGALLIUM_RBUG -DGALLIUM_TRACE
+       -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_NOOP
 
 include ../Makefile.dri
 
index 8753e2bab1759bbc7990d45c60f571da16a00ea5..2fe345402de95f157725443f89c45fa6a9ee61e3 100644 (file)
@@ -1,5 +1,5 @@
 #include "state_tracker/drm_driver.h"
-#include "target-helpers/inline_debug_helper.h"
+#include "target-helpers/inline_noop_helper.h"
 #include "r600/drm/r600_drm_public.h"
 #include "r600/r600_public.h"