summaryrefslogtreecommitdiff
path: root/src/gallium/targets
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-07-26 17:47:59 -0700
committerEric Anholt <eric@anholt.net>2010-07-26 17:53:27 -0700
commitafe125e0a18ac3886c45c7e6b02b122fb2d327b5 (patch)
tree78621707e71154c0b388b0baacffc26432b7e992 /src/gallium/targets
parentd64343f1ae84979bd154475badf11af8a9bfc2eb (diff)
parent5403ca79b225605c79f49866a6497c97da53be3b (diff)
Merge remote branch 'origin/master' into glsl2
This pulls in multiple i965 driver fixes which will help ensure better testing coverage during development, and also gets past the conflicts of the src/mesa/shader -> src/mesa/program move. Conflicts: src/mesa/Makefile src/mesa/main/shaderapi.c src/mesa/main/shaderobj.h
Diffstat (limited to 'src/gallium/targets')
-rw-r--r--src/gallium/targets/Makefile.egl108
-rw-r--r--src/gallium/targets/Makefile.xorg15
-rw-r--r--src/gallium/targets/SConscript3
-rw-r--r--src/gallium/targets/SConscript.dri1
-rw-r--r--src/gallium/targets/dri-i915/Makefile13
-rw-r--r--src/gallium/targets/dri-i915/SConscript5
-rw-r--r--src/gallium/targets/dri-i915/dummy.c0
-rw-r--r--src/gallium/targets/dri-i915/target.c30
-rw-r--r--src/gallium/targets/dri-i965/Makefile15
-rw-r--r--src/gallium/targets/dri-i965/SConscript9
-rw-r--r--src/gallium/targets/dri-i965/dummy.c0
-rw-r--r--src/gallium/targets/dri-i965/target.c30
-rw-r--r--src/gallium/targets/dri-nouveau/Makefile6
-rw-r--r--src/gallium/targets/dri-nouveau/target.c20
-rw-r--r--src/gallium/targets/dri-r600/Makefile4
-rw-r--r--src/gallium/targets/dri-r600/SConscript4
-rw-r--r--src/gallium/targets/dri-r600/dummy.c0
-rw-r--r--src/gallium/targets/dri-r600/target.c26
-rw-r--r--src/gallium/targets/dri-radeong/Makefile5
-rw-r--r--src/gallium/targets/dri-radeong/SConscript5
-rw-r--r--src/gallium/targets/dri-radeong/dummy.c0
-rw-r--r--src/gallium/targets/dri-radeong/target.c26
-rw-r--r--src/gallium/targets/dri-swrast/Makefile4
-rw-r--r--src/gallium/targets/dri-swrast/SConscript6
-rw-r--r--src/gallium/targets/dri-swrast/swrast_drm_api.c58
-rw-r--r--src/gallium/targets/dri-vmwgfx/Makefile4
-rw-r--r--src/gallium/targets/dri-vmwgfx/SConscript4
-rw-r--r--src/gallium/targets/dri-vmwgfx/dummy.c0
-rw-r--r--src/gallium/targets/dri-vmwgfx/target.c26
-rw-r--r--src/gallium/targets/egl-apis/Makefile77
-rw-r--r--src/gallium/targets/egl-apis/SConscript33
-rw-r--r--src/gallium/targets/egl-apis/api_GLESv2.c8
-rw-r--r--src/gallium/targets/egl-gdi/SConscript47
-rw-r--r--src/gallium/targets/egl-gdi/egl-static.c148
-rw-r--r--src/gallium/targets/egl-i915/Makefile14
-rw-r--r--src/gallium/targets/egl-i915/dummy.c3
-rw-r--r--src/gallium/targets/egl-i965/Makefile17
-rw-r--r--src/gallium/targets/egl-i965/dummy.c3
-rw-r--r--src/gallium/targets/egl-nouveau/Makefile14
-rw-r--r--src/gallium/targets/egl-nouveau/dummy.c3
-rw-r--r--src/gallium/targets/egl-radeon/Makefile14
-rw-r--r--src/gallium/targets/egl-radeon/dummy.c3
-rw-r--r--src/gallium/targets/egl-swrast/Makefile12
-rw-r--r--src/gallium/targets/egl-swrast/SConscript30
-rw-r--r--src/gallium/targets/egl-swrast/swrast_glue.c11
-rw-r--r--src/gallium/targets/egl-vmwgfx/Makefile14
-rw-r--r--src/gallium/targets/egl-vmwgfx/dummy.c3
-rw-r--r--src/gallium/targets/egl/Makefile229
-rw-r--r--src/gallium/targets/egl/egl.c428
-rw-r--r--src/gallium/targets/egl/pipe_i915.c28
-rw-r--r--src/gallium/targets/egl/pipe_i965.c31
-rw-r--r--src/gallium/targets/egl/pipe_nouveau.c21
-rw-r--r--src/gallium/targets/egl/pipe_radeon.c27
-rw-r--r--src/gallium/targets/egl/pipe_swrast.c22
-rw-r--r--src/gallium/targets/egl/pipe_vmwgfx.c27
-rw-r--r--src/gallium/targets/egl/st_GL.c25
-rw-r--r--src/gallium/targets/egl/st_GLESv1_CM.c (renamed from src/gallium/targets/egl-apis/api_GL.c)4
-rw-r--r--src/gallium/targets/egl/st_GLESv2.c (renamed from src/gallium/targets/egl-apis/api_GLESv1_CM.c)4
-rw-r--r--src/gallium/targets/egl/st_OpenVG.c (renamed from src/gallium/targets/egl-apis/api_OpenVG.c)2
-rw-r--r--src/gallium/targets/libgl-xlib/Makefile2
-rw-r--r--src/gallium/targets/xorg-i915/Makefile12
-rw-r--r--src/gallium/targets/xorg-i915/intel_target.c26
-rw-r--r--src/gallium/targets/xorg-i965/Makefile12
-rw-r--r--src/gallium/targets/xorg-i965/intel_target.c30
-rw-r--r--src/gallium/targets/xorg-nouveau/Makefile10
-rw-r--r--src/gallium/targets/xorg-nouveau/nouveau_target.c20
-rw-r--r--src/gallium/targets/xorg-radeon/Makefile20
-rw-r--r--src/gallium/targets/xorg-radeon/radeon_target.c26
-rw-r--r--src/gallium/targets/xorg-vmwgfx/Makefile15
-rw-r--r--src/gallium/targets/xorg-vmwgfx/vmw_ctrl.c3
-rw-r--r--src/gallium/targets/xorg-vmwgfx/vmw_driver.h1
-rw-r--r--src/gallium/targets/xorg-vmwgfx/vmw_screen.c45
-rw-r--r--src/gallium/targets/xorg-vmwgfx/vmw_target.c26
73 files changed, 1500 insertions, 477 deletions
diff --git a/src/gallium/targets/Makefile.egl b/src/gallium/targets/Makefile.egl
deleted file mode 100644
index 315856014b..0000000000
--- a/src/gallium/targets/Makefile.egl
+++ /dev/null
@@ -1,108 +0,0 @@
-# src/gallium/winsys/drm/Makefile.egl
-
-# The driver Makefile should define
-#
-# EGL_DRIVER_NAME, the name of the driver
-# EGL_DRIVER_SOURCES, the sources of the driver
-# EGL_DRIVER_LIBS, extra libraries needed by the driver
-# EGL_DRIVER_PIPES, the pipe drivers of the driver
-#
-# before including this file.
-
-EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o)
-
-common_LIBS = -ldrm -lm -ldl
-
-# ximage backend calls gallium_wrap_screen, which requires libidentity.a and
-# libtrace.a
-x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a \
- $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(TOP)/src/gallium/drivers/identity/libidentity.a \
- $(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/drivers/rbug/librbug.a
-
-x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes
-
-kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a
-kms_LIBS = $(common_LIBS)
-
-fbdev_ST = \
- $(TOP)/src/gallium/state_trackers/egl/libeglfbdev.a \
- $(TOP)/src/gallium/winsys/sw/fbdev/libfbdev.a \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(TOP)/src/gallium/drivers/identity/libidentity.a \
- $(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/drivers/rbug/librbug.a
-fbdev_LIBS = $(common_LIBS)
-
-ifeq ($(MESA_LLVM),1)
-x11_ST += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
-x11_LIBS += $(LLVM_LIBS)
-fbdev_ST += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
-fbdev_LIBS += $(LLVM_LIBS)
-LDFLAGS += $(LLVM_LDFLAGS)
-endif
-
-### Include directories
-INCLUDES = \
- -I$(TOP)/include \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/src/gallium/winsys \
- -I$(TOP)/src/egl/main \
- $(LIBDRM_CFLAGS)
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(EGL_DRIVER_DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-ifeq ($(EGL_DRIVER_NAME),swrast)
-EGL_PLATFORMS := $(filter-out kms, $(EGL_PLATFORMS))
-else
-EGL_PLATFORMS := $(filter-out fbdev, $(EGL_PLATFORMS))
-endif
-
-EGL_PLATFORM_DRIVERS = $(foreach plat, $(EGL_PLATFORMS), egl_$(plat)_$(EGL_DRIVER_NAME).so)
-
-EGL_PLATFORM_LIBS = $(foreach drv, $(EGL_PLATFORM_DRIVERS), $(TOP)/$(LIB_DIR)/egl/$(drv))
-
-default: $(EGL_PLATFORM_LIBS)
-
-$(EGL_PLATFORM_LIBS): $(TOP)/$(LIB_DIR)/egl/%.so: %.so
- @$(INSTALL) -d $(TOP)/$(LIB_DIR)/egl
- $(INSTALL) $< $(TOP)/$(LIB_DIR)/egl
-
-define mklib-egl
-$(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
- $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \
- -Wl,--start-group $($(1)_ST) $(EGL_DRIVER_PIPES) \
- $(GALLIUM_AUXILIARIES) -Wl,--end-group \
- $($(1)_LIBS) $(EGL_DRIVER_LIBS) -L$(TOP)/$(LIB_DIR) -l$(EGL_LIB)
-endef
-
-egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile
- $(call mklib-egl,x11)
-
-egl_kms_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(kms_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile
- $(call mklib-egl,kms)
-
-egl_fbdev_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(fbdev_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile
- $(call mklib-egl,fbdev)
-
-clean:
- -rm -f $(EGL_DRIVER_OBJECTS)
- -rm -f $(EGL_PLATFORM_DRIVERS)
-
-install: $(EGL_PLATFORM_LIBS)
- $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR)
- for lib in $(EGL_PLATFORM_LIBS); do \
- $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \
- done
-
-depend:
diff --git a/src/gallium/targets/Makefile.xorg b/src/gallium/targets/Makefile.xorg
index 4237f944e0..762c905985 100644
--- a/src/gallium/targets/Makefile.xorg
+++ b/src/gallium/targets/Makefile.xorg
@@ -9,7 +9,8 @@
# Optional defines:
# DRIVER_INCLUDES are appended to the list of includes directories.
# DRIVER_DEFINES is not used for makedepend, but for compilation.
-# DRIVER_LINKS are flags given to the linker
+# DRIVER_PIPES are pipe drivers and modules that the driver depends on.
+# DRIVER_LINKS are flags given to the linker.
### Basic defines ###
@@ -27,13 +28,21 @@ INCLUDES = \
LIBNAME_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
+ifeq ($(MESA_LLVM),1)
+LD = g++
+LDFLAGS += $(LLVM_LDFLAGS)
+USE_CXX=1
+DRIVER_PIPES += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
+DRIVER_LINKS += $(LLVM_LIBS) -lm -ldl
+endif
+
##### TARGETS #####
default: depend $(TOP)/$(LIB_DIR)/gallium $(LIBNAME) $(LIBNAME_STAGING)
-$(LIBNAME): $(OBJECTS) Makefile $(LIBS)
- $(MKLIB) -noprefix -o $@ $(OBJECTS) $(DRIVER_LINKS)
+$(LIBNAME): $(OBJECTS) Makefile ../Makefile.xorg $(LIBS) $(DRIVER_PIPES)
+ $(MKLIB) -noprefix -o $@ $(LDFLAGS) $(OBJECTS) $(DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $(DRIVER_LINKS)
depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURCES)
rm -f depend
diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript
index 97187030ab..f8276b1555 100644
--- a/src/gallium/targets/SConscript
+++ b/src/gallium/targets/SConscript
@@ -32,8 +32,7 @@ if 'xorg' in env['statetrackers']:
if 'egl' in env['statetrackers']:
SConscript([
- 'egl-swrast/SConscript',
- 'egl-apis/SConscript',
+ 'egl-gdi/SConscript',
])
# Ideally all non-target directories would produce convenience
diff --git a/src/gallium/targets/SConscript.dri b/src/gallium/targets/SConscript.dri
index 74b53e5023..e5981c2461 100644
--- a/src/gallium/targets/SConscript.dri
+++ b/src/gallium/targets/SConscript.dri
@@ -13,6 +13,7 @@ drienv.Replace(CPPPATH = [
'#src/gallium/include',
'#src/gallium/auxiliary',
'#src/gallium/drivers',
+ '#src/gallium/winsys',
'#src/mesa',
'#src/mesa/main',
'#src/mesa/glapi',
diff --git a/src/gallium/targets/dri-i915/Makefile b/src/gallium/targets/dri-i915/Makefile
index fdcfd08c22..9c10d71a4a 100644
--- a/src/gallium/targets/dri-i915/Makefile
+++ b/src/gallium/targets/dri-i915/Makefile
@@ -6,16 +6,25 @@ LIBNAME = i915_dri.so
PIPE_DRIVERS = \
$(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
$(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
+ $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/drivers/galahad/libgalahad.a \
$(TOP)/src/gallium/drivers/trace/libtrace.a \
$(TOP)/src/gallium/drivers/rbug/librbug.a \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(TOP)/src/gallium/drivers/identity/libidentity.a \
$(TOP)/src/gallium/drivers/i915/libi915.a
C_SOURCES = \
+ target.c \
$(COMMON_GALLIUM_SOURCES) \
$(DRIVER_SOURCES)
+DRIVER_DEFINES = \
+ -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD -DGALLIUM_SOFTPIPE
+
+ifeq ($(MESA_LLVM),1)
+DRIVER_DEFINES += -DGALLIUM_LLVMPIPE
+endif
+
include ../Makefile.dri
DRI_LIB_DEPS += -ldrm_intel
diff --git a/src/gallium/targets/dri-i915/SConscript b/src/gallium/targets/dri-i915/SConscript
index 65c4239887..6f9336b5ac 100644
--- a/src/gallium/targets/dri-i915/SConscript
+++ b/src/gallium/targets/dri-i915/SConscript
@@ -8,10 +8,13 @@ env = drienv.Clone()
env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
+env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE', 'GALLIUM_GALAHAD'])
+
env.Prepend(LIBS = [
st_dri,
i915drm,
i915,
+ galahad,
trace,
rbug,
mesa,
@@ -22,6 +25,6 @@ env.Prepend(LIBS = [
env.LoadableModule(
target = 'i915_dri.so',
- source = 'dummy.c',
+ source = 'target.c',
SHLIBPREFIX = '',
)
diff --git a/src/gallium/targets/dri-i915/dummy.c b/src/gallium/targets/dri-i915/dummy.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/src/gallium/targets/dri-i915/dummy.c
+++ /dev/null
diff --git a/src/gallium/targets/dri-i915/target.c b/src/gallium/targets/dri-i915/target.c
new file mode 100644
index 0000000000..5ae6ca367d
--- /dev/null
+++ b/src/gallium/targets/dri-i915/target.c
@@ -0,0 +1,30 @@
+
+#include "state_tracker/drm_driver.h"
+#include "target-helpers/inline_wrapper_sw_helper.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "i915/drm/i915_drm_public.h"
+#include "i915/i915_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct i915_winsys *iws;
+ struct pipe_screen *screen;
+
+ iws = i915_drm_winsys_create(fd);
+ if (!iws)
+ return NULL;
+
+ screen = i915_screen_create(iws);
+ if (!screen)
+ return NULL;
+
+ if (debug_get_bool_option("I915_SOFTWARE", FALSE))
+ screen = sw_screen_wrap(screen);
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("i915", "i915", create_screen)
diff --git a/src/gallium/targets/dri-i965/Makefile b/src/gallium/targets/dri-i965/Makefile
index 13987c643e..4b50d04255 100644
--- a/src/gallium/targets/dri-i965/Makefile
+++ b/src/gallium/targets/dri-i965/Makefile
@@ -6,18 +6,25 @@ LIBNAME = i965_dri.so
PIPE_DRIVERS = \
$(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
$(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
- $(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/drivers/rbug/librbug.a \
- $(TOP)/src/gallium/winsys/sw/drm/libswdrm.a \
$(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(TOP)/src/gallium/drivers/identity/libidentity.a \
+ $(TOP)/src/gallium/drivers/galahad/libgalahad.a \
+ $(TOP)/src/gallium/drivers/trace/libtrace.a \
+ $(TOP)/src/gallium/drivers/rbug/librbug.a \
$(TOP)/src/gallium/drivers/i965/libi965.a
C_SOURCES = \
+ target.c \
$(COMMON_GALLIUM_SOURCES) \
$(DRIVER_SOURCES)
+DRIVER_DEFINES = \
+ -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD -DGALLIUM_SOFTPIPE
+
+ifeq ($(MESA_LLVM),1)
+DRIVER_DEFINES += -DGALLIUM_LLVMPIPE
+endif
+
include ../Makefile.dri
DRI_LIB_DEPS += -ldrm_intel
diff --git a/src/gallium/targets/dri-i965/SConscript b/src/gallium/targets/dri-i965/SConscript
index 13ac5a2d8e..684e3488f7 100644
--- a/src/gallium/targets/dri-i965/SConscript
+++ b/src/gallium/targets/dri-i965/SConscript
@@ -8,10 +8,15 @@ env = drienv.Clone()
env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
+env.Append(CPPDEFINES = [
+ 'GALLIUM_SOFTPIPE',
+ 'GALLIUM_RBUG',
+ 'GALLIUM_TRACE'
+])
+
env.Prepend(LIBS = [
st_dri,
i965drm,
- ws_drm,
ws_wrapper,
i965,
trace,
@@ -24,6 +29,6 @@ env.Prepend(LIBS = [
env.LoadableModule(
target = 'i965_dri.so',
- source = 'dummy.c',
+ source = 'target.c',
SHLIBPREFIX = '',
)
diff --git a/src/gallium/targets/dri-i965/dummy.c b/src/gallium/targets/dri-i965/dummy.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/src/gallium/targets/dri-i965/dummy.c
+++ /dev/null
diff --git a/src/gallium/targets/dri-i965/target.c b/src/gallium/targets/dri-i965/target.c
new file mode 100644
index 0000000000..ce97f82027
--- /dev/null
+++ b/src/gallium/targets/dri-i965/target.c
@@ -0,0 +1,30 @@
+
+#include "target-helpers/inline_wrapper_sw_helper.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "i965/drm/i965_drm_public.h"
+#include "i965/brw_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct brw_winsys_screen *bws;
+ struct pipe_screen *screen;
+
+ bws = i965_drm_winsys_screen_create(fd);
+ if (!bws)
+ return NULL;
+
+ screen = brw_screen_create(bws);
+ if (!screen)
+ return NULL;
+
+ if (debug_get_bool_option("BRW_SOFTPIPE", FALSE))
+ screen = sw_screen_wrap(screen);
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("i915", "i965", create_screen)
diff --git a/src/gallium/targets/dri-nouveau/Makefile b/src/gallium/targets/dri-nouveau/Makefile
index 74d352c6a7..2f64f312b8 100644
--- a/src/gallium/targets/dri-nouveau/Makefile
+++ b/src/gallium/targets/dri-nouveau/Makefile
@@ -6,14 +6,20 @@ LIBNAME = nouveau_dri.so
PIPE_DRIVERS = \
$(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
$(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
+ $(TOP)/src/gallium/drivers/trace/libtrace.a \
+ $(TOP)/src/gallium/drivers/rbug/librbug.a \
$(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a \
$(TOP)/src/gallium/drivers/nouveau/libnouveau.a
C_SOURCES = \
+ target.c \
$(COMMON_GALLIUM_SOURCES) \
$(DRIVER_SOURCES)
+DRIVER_DEFINES = \
+ -DGALLIUM_RBUG -DGALLIUM_TRACE
+
include ../Makefile.dri
DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
diff --git a/src/gallium/targets/dri-nouveau/target.c b/src/gallium/targets/dri-nouveau/target.c
new file mode 100644
index 0000000000..e725a4d9b7
--- /dev/null
+++ b/src/gallium/targets/dri-nouveau/target.c
@@ -0,0 +1,20 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "nouveau/drm/nouveau_drm_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct pipe_screen *screen;
+
+ screen = nouveau_drm_screen_create(fd);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("nouveau", "nouveau", create_screen)
diff --git a/src/gallium/targets/dri-r600/Makefile b/src/gallium/targets/dri-r600/Makefile
index 0213200fbc..932303d194 100644
--- a/src/gallium/targets/dri-r600/Makefile
+++ b/src/gallium/targets/dri-r600/Makefile
@@ -12,9 +12,13 @@ PIPE_DRIVERS = \
$(TOP)/src/gallium/drivers/r600/libr600.a
C_SOURCES = \
+ target.c \
$(COMMON_GALLIUM_SOURCES) \
$(DRIVER_SOURCES)
+DRIVER_DEFINES = \
+ -DGALLIUM_RBUG -DGALLIUM_TRACE
+
include ../Makefile.dri
DRI_LIB_DEPS += -ldrm_radeon
diff --git a/src/gallium/targets/dri-r600/SConscript b/src/gallium/targets/dri-r600/SConscript
index 6c23c050eb..97c5df01fe 100644
--- a/src/gallium/targets/dri-r600/SConscript
+++ b/src/gallium/targets/dri-r600/SConscript
@@ -8,6 +8,8 @@ env = drienv.Clone()
env.ParseConfig('pkg-config --cflags --libs libdrm_radeon')
+env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE'])
+
env.Prepend(LIBS = [
st_dri,
r600drm,
@@ -22,6 +24,6 @@ env.Prepend(LIBS = [
env.SharedLibrary(
target ='r600_dri.so',
- source = 'dummy.c',
+ source = 'target.c',
SHLIBPREFIX = '',
)
diff --git a/src/gallium/targets/dri-r600/dummy.c b/src/gallium/targets/dri-r600/dummy.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/src/gallium/targets/dri-r600/dummy.c
+++ /dev/null
diff --git a/src/gallium/targets/dri-r600/target.c b/src/gallium/targets/dri-r600/target.c
new file mode 100644
index 0000000000..a01f4ed49f
--- /dev/null
+++ b/src/gallium/targets/dri-r600/target.c
@@ -0,0 +1,26 @@
+
+#include "state_tracker/drm_driver.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "r600/drm/r600_drm_public.h"
+#include "r600/r600_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct radeon *rw;
+ struct pipe_screen *screen;
+
+ rw = r600_drm_winsys_create(fd);
+ if (!rw)
+ return NULL;
+
+ screen = r600_screen_create(rw);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("r600", "radeon", create_screen)
diff --git a/src/gallium/targets/dri-radeong/Makefile b/src/gallium/targets/dri-radeong/Makefile
index 8ef24c0821..3f9ec36166 100644
--- a/src/gallium/targets/dri-radeong/Makefile
+++ b/src/gallium/targets/dri-radeong/Makefile
@@ -7,14 +7,19 @@ PIPE_DRIVERS = \
$(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
$(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/drivers/galahad/libgalahad.a \
$(TOP)/src/gallium/drivers/trace/libtrace.a \
$(TOP)/src/gallium/drivers/rbug/librbug.a \
$(TOP)/src/gallium/drivers/r300/libr300.a
C_SOURCES = \
+ target.c \
$(COMMON_GALLIUM_SOURCES) \
$(DRIVER_SOURCES)
+DRIVER_DEFINES = \
+ -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD
+
include ../Makefile.dri
DRI_LIB_DEPS += -ldrm_radeon
diff --git a/src/gallium/targets/dri-radeong/SConscript b/src/gallium/targets/dri-radeong/SConscript
index 4c6cfb84eb..1402c3bd12 100644
--- a/src/gallium/targets/dri-radeong/SConscript
+++ b/src/gallium/targets/dri-radeong/SConscript
@@ -8,10 +8,13 @@ env = drienv.Clone()
env.ParseConfig('pkg-config --cflags --libs libdrm_radeon')
+env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE', 'GALLIUM_GALAHAD'])
+
env.Prepend(LIBS = [
st_dri,
radeonwinsys,
r300,
+ galahad,
trace,
rbug,
mesa,
@@ -22,6 +25,6 @@ env.Prepend(LIBS = [
env.SharedLibrary(
target ='radeon_dri.so',
- source = 'dummy.c',
+ source = 'target.c',
SHLIBPREFIX = '',
)
diff --git a/src/gallium/targets/dri-radeong/dummy.c b/src/gallium/targets/dri-radeong/dummy.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/src/gallium/targets/dri-radeong/dummy.c
+++ /dev/null
diff --git a/src/gallium/targets/dri-radeong/target.c b/src/gallium/targets/dri-radeong/target.c
new file mode 100644
index 0000000000..5a0a8dc573
--- /dev/null
+++ b/src/gallium/targets/dri-radeong/target.c
@@ -0,0 +1,26 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "radeon/drm/radeon_drm_public.h"
+#include "r300/r300_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct r300_winsys_screen *sws;
+ struct pipe_screen *screen;
+
+ sws = r300_drm_winsys_screen_create(fd);
+ if (!sws)
+ return NULL;
+
+ screen = r300_screen_create(sws);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("radeon", "radeon", create_screen)
diff --git a/src/gallium/targets/dri-swrast/Makefile b/src/gallium/targets/dri-swrast/Makefile
index 0a53eb56c4..948c45abe5 100644
--- a/src/gallium/targets/dri-swrast/Makefile
+++ b/src/gallium/targets/dri-swrast/Makefile
@@ -3,7 +3,9 @@ include $(TOP)/configs/current
LIBNAME = swrastg_dri.so
-DRIVER_DEFINES = -D__NOT_HAVE_DRM_H -DGALLIUM_SOFTPIPE
+DRIVER_DEFINES = \
+ -D__NOT_HAVE_DRM_H -DGALLIUM_SOFTPIPE \
+ -DGALLIUM_RBUG -DGALLIUM_TRACE
PIPE_DRIVERS = \
$(TOP)/src/gallium/state_trackers/dri/sw/libdrisw.a \
diff --git a/src/gallium/targets/dri-swrast/SConscript b/src/gallium/targets/dri-swrast/SConscript
index 679afab41c..d814347119 100644
--- a/src/gallium/targets/dri-swrast/SConscript
+++ b/src/gallium/targets/dri-swrast/SConscript
@@ -18,7 +18,11 @@ env.Prepend(LIBS = [
])
if True:
- env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
+ env.Append(CPPDEFINES = [
+ 'GALLIUM_SOFTPIPE',
+ 'GALLIUM_RBUG',
+ 'GALLIUM_TRACE',
+ ])
env.Prepend(LIBS = [softpipe])
if env['llvm']:
diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c
index 84142be80c..8d741c6343 100644
--- a/src/gallium/targets/dri-swrast/swrast_drm_api.c
+++ b/src/gallium/targets/dri-swrast/swrast_drm_api.c
@@ -28,61 +28,11 @@
#include "pipe/p_compiler.h"
#include "util/u_memory.h"
-#include "state_tracker/drm_api.h"
-#include "state_tracker/sw_winsys.h"
#include "dri_sw_winsys.h"
-#include "trace/tr_public.h"
-/* Copied from targets/libgl-xlib */
+#include "target-helpers/inline_debug_helper.h"
+#include "target-helpers/inline_sw_helper.h"
-#ifdef GALLIUM_SOFTPIPE
-#include "softpipe/sp_public.h"
-#endif
-
-#ifdef GALLIUM_LLVMPIPE
-#include "llvmpipe/lp_public.h"
-#endif
-
-#ifdef GALLIUM_CELL
-#include "cell/ppu/cell_public.h"
-#endif
-
-static struct pipe_screen *
-swrast_create_screen(struct sw_winsys *winsys)
-{
- const char *default_driver;
- const char *driver;
- struct pipe_screen *screen = NULL;
-
-#if defined(GALLIUM_CELL)
- default_driver = "cell";
-#elif defined(GALLIUM_LLVMPIPE)
- default_driver = "llvmpipe";
-#elif defined(GALLIUM_SOFTPIPE)
- default_driver = "softpipe";
-#else
- default_driver = "";
-#endif
-
- driver = debug_get_option("GALLIUM_DRIVER", default_driver);
-
-#if defined(GALLIUM_CELL)
- if (screen == NULL && strcmp(driver, "cell") == 0)
- screen = cell_create_screen( winsys );
-#endif
-
-#if defined(GALLIUM_LLVMPIPE)
- if (screen == NULL && strcmp(driver, "llvmpipe") == 0)
- screen = llvmpipe_create_screen( winsys );
-#endif
-
-#if defined(GALLIUM_SOFTPIPE)
- if (screen == NULL)
- screen = softpipe_create_screen( winsys );
-#endif
-
- return trace_screen_create(screen);;
-}
struct pipe_screen *
drisw_create_screen(struct drisw_loader_funcs *lf)
@@ -94,10 +44,12 @@ drisw_create_screen(struct drisw_loader_funcs *lf)
if (winsys == NULL)
return NULL;
- screen = swrast_create_screen(winsys);
+ screen = sw_screen_create(winsys);
if (!screen)
goto fail;
+ screen = debug_screen_wrap(screen);
+
return screen;
fail:
diff --git a/src/gallium/targets/dri-vmwgfx/Makefile b/src/gallium/targets/dri-vmwgfx/Makefile
index b5b679f3c7..97c703b373 100644
--- a/src/gallium/targets/dri-vmwgfx/Makefile
+++ b/src/gallium/targets/dri-vmwgfx/Makefile
@@ -11,8 +11,12 @@ PIPE_DRIVERS = \
$(TOP)/src/gallium/drivers/svga/libsvga.a
C_SOURCES = \
+ target.c \
$(COMMON_GALLIUM_SOURCES)
+DRIVER_DEFINES = \
+ -DGALLIUM_RBUG -DGALLIUM_TRACE
+
include ../Makefile.dri
symlinks:
diff --git a/src/gallium/targets/dri-vmwgfx/SConscript b/src/gallium/targets/dri-vmwgfx/SConscript
index 09a0c254c3..7afabc7429 100644
--- a/src/gallium/targets/dri-vmwgfx/SConscript
+++ b/src/gallium/targets/dri-vmwgfx/SConscript
@@ -6,6 +6,8 @@ if not 'svga' in env['drivers']:
env = drienv.Clone()
+env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE'])
+
env.Prepend(LIBS = [
st_dri,
svgadrm,
@@ -20,6 +22,6 @@ env.Prepend(LIBS = [
env.LoadableModule(
target = 'vmwgfx_dri.so',
- source = 'dummy.c',
+ source = 'target.c',
SHLIBPREFIX = '',
)
diff --git a/src/gallium/targets/dri-vmwgfx/dummy.c b/src/gallium/targets/dri-vmwgfx/dummy.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/src/gallium/targets/dri-vmwgfx/dummy.c
+++ /dev/null
diff --git a/src/gallium/targets/dri-vmwgfx/target.c b/src/gallium/targets/dri-vmwgfx/target.c
new file mode 100644
index 0000000000..15089d6db2
--- /dev/null
+++ b/src/gallium/targets/dri-vmwgfx/target.c
@@ -0,0 +1,26 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "svga/drm/svga_drm_public.h"
+#include "svga/svga_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct svga_winsys_screen *sws;
+ struct pipe_screen *screen;
+
+ sws = svga_drm_winsys_screen_create(fd);
+ if (!sws)
+ return NULL;
+
+ screen = svga_screen_create(sws);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("vmwgfx", "vmwgfx", create_screen)
diff --git a/src/gallium/targets/egl-apis/Makefile b/src/gallium/targets/egl-apis/Makefile
deleted file mode 100644
index 88915bfc5e..0000000000
--- a/src/gallium/targets/egl-apis/Makefile
+++ /dev/null
@@ -1,77 +0,0 @@
-# src/gallium/targets/egl-apis
-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-OUTPUT_PREFIX := api_
-OUTPUT_PATH := $(TOP)/$(LIB_DIR)/egl
-
-OUTPUTS := $(addsuffix .so, $(EGL_CLIENT_APIS))
-OUTPUTS := $(addprefix $(OUTPUT_PATH)/$(OUTPUT_PREFIX), $(OUTPUTS))
-
-# include dirs
-GL_INCLUDES := -I$(TOP)/src/mesa -I$(TOP)/src/gallium/include
-GLESv1_CM_INCLUDES := $(GL_INCLUDES)
-GLESv2_INCLUDES := $(GL_INCLUDES)
-OpenVG_INCLUDES := -I$(TOP)/src/gallium/state_trackers/vega -I$(TOP)/src/gallium/include
-
-# system libs
-GL_SYS := -lpthread -lm -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
-GLESv1_CM_SYS := -lpthread -lm -L$(TOP)/$(LIB_DIR) -l$(GLESv1_CM_LIB)
-GLESv2_SYS := -lpthread -lm -L$(TOP)/$(LIB_DIR) -l$(GLESv2_LIB)
-OpenVG_SYS := -lm -L$(TOP)/$(LIB_DIR) -l$(VG_LIB)
-
-# $(LLVM_LIBS) will be discarded except for OpenGL, which creates a private
-# draw context for selection/feedback mode.
-ifeq ($(MESA_LLVM),1)
-GL_SYS += $(LLVM_LIBS)
-GLESv1_CM_SYS += $(LLVM_LIBS)
-GLESv2_SYS += $(LLVM_LIBS)
-OpenVG_SYS += $(LLVM_LIBS)
-LDFLAGS += $(LLVM_LDFLAGS)
-endif
-
-# project libs
-GL_LIBS := $(TOP)/src/mesa/libmesagallium.a
-GLESv1_CM_LIBS := $(TOP)/src/mesa/libes1gallium.a
-GLESv2_LIBS := $(TOP)/src/mesa/libes2gallium.a
-OpenVG_LIBS := $(TOP)/src/gallium/state_trackers/vega/libvega.a
-
-# objects
-GL_OBJECTS := api_GL.o
-GLESv1_CM_OBJECTS := api_GLESv1_CM.o
-GLESv2_OBJECTS := api_GLESv2.o
-OpenVG_OBJECTS := api_OpenVG.o
-
-default: $(OUTPUTS)
-
-api_%.o: api_%.c
- $(CC) -c -o $@ $< $($*_INCLUDES) $(DEFINES) $(CFLAGS)
-
-define mklib
-$(MKLIB) -o $(notdir $@) -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
- -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) \
- $($(1)_OBJECTS) $($(1)_LIBS) $(GALLIUM_AUXILIARIES) $($(1)_SYS)
-endef
-
-$(OUTPUT_PATH)/$(OUTPUT_PREFIX)$(GL_LIB).so: $(GL_OBJECTS) $(GL_LIBS)
- $(call mklib,GL)
-
-$(OUTPUT_PATH)/$(OUTPUT_PREFIX)$(GLESv1_CM_LIB).so: $(GLESv1_CM_OBJECTS) $(GLESv1_CM_LIBS)
- $(call mklib,GLESv1_CM)
-
-$(OUTPUT_PATH)/$(OUTPUT_PREFIX)$(GLESv2_LIB).so: $(GLESv2_OBJECTS) $(GLESv2_LIBS)
- $(call mklib,GLESv2)
-
-$(OUTPUT_PATH)/$(OUTPUT_PREFIX)$(VG_LIB).so: $(OpenVG_OBJECTS) $(OpenVG_LIBS)
- $(call mklib,OpenVG)
-
-install: $(OUTPUTS)
- $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR)
- for out in $(OUTPUTS); do \
- $(MINSTALL) -m 755 "$$out" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \
- done
-
-clean:
- -rm -f $(OUTPUTS)
- -rm -f *.o
diff --git a/src/gallium/targets/egl-apis/SConscript b/src/gallium/targets/egl-apis/SConscript
deleted file mode 100644
index 0ca3d1fb9e..0000000000
--- a/src/gallium/targets/egl-apis/SConscript
+++ /dev/null
@@ -1,33 +0,0 @@
-#######################################################################
-# SConscript for egl-apis target
-
-Import('*')
-
-if env['platform'] == 'windows':
-
- env = env.Clone()
-
- env.Append(CPPPATH = [
- '#/src/gallium/state_trackers/vega',
- ])
-
- env.Append(LIBS = [
- 'gdi32',
- 'user32',
- 'kernel32',
- 'ws2_32',
- ])
-
- env['no_import_lib'] = 1
-
- api_libs = {
- 'OpenVG': vgapi + st_vega,
- }
-
- for name in api_libs.keys():
- api = env.SharedLibrary(
- target = 'api_' + name,
- source = ['api_' + name + '.c'],
- LIBS = api_libs[name] + gallium + env['LIBS'],
- )
- env.InstallSharedLibrary(api)
diff --git a/src/gallium/targets/egl-apis/api_GLESv2.c b/src/gallium/targets/egl-apis/api_GLESv2.c
deleted file mode 100644
index 5c773aaf93..0000000000
--- a/src/gallium/targets/egl-apis/api_GLESv2.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "state_tracker/st_gl_api.h"
-
-PUBLIC struct st_api *
-st_api_create_OpenGL_ES2()
-{
- /* linker magic creates different versions */
- return st_gl_api_create();
-}
diff --git a/src/gallium/targets/egl-gdi/SConscript b/src/gallium/targets/egl-gdi/SConscript
new file mode 100644
index 0000000000..8f8b28ef67
--- /dev/null
+++ b/src/gallium/targets/egl-gdi/SConscript
@@ -0,0 +1,47 @@
+#######################################################################
+# SConscript for egl-gdi target
+
+Import('*')
+
+if env['platform'] == 'windows':
+
+ env = env.Clone()
+
+ env.Append(CPPPATH = [
+ '#/src/gallium/state_trackers/egl',
+ '#/src/gallium/state_trackers/vega',
+ '#/src/egl/main',
+ '#/src/mesa',
+ ])
+
+ env.Append(CPPDEFINES = [
+ 'FEATURE_VG=1',
+ 'GALLIUM_SOFTPIPE',
+ 'GALLIUM_RBUG',
+ 'GALLIUM_TRACE',
+ ])
+
+ env.Append(LIBS = [
+ 'gdi32',
+ 'user32',
+ 'kernel32',
+ 'ws2_32',
+ ])
+
+ env['no_import_lib'] = 1
+
+ drivers = [softpipe]
+ if env['llvm']:
+ env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+ drivers += [llvmpipe]
+ drivers += [identity, trace, rbug]
+
+ apis = [vgapi, st_vega]
+
+ egl_gallium = env.SharedLibrary(
+ target ='egl_gallium',
+ source = 'egl-static.c',
+ LIBS = st_egl_gdi + ws_gdi + drivers + apis + gallium + egl + env['LIBS'],
+ )
+
+ env.InstallSharedLibrary(egl_gallium)
diff --git a/src/gallium/targets/egl-gdi/egl-static.c b/src/gallium/targets/egl-gdi/egl-static.c
new file mode 100644
index 0000000000..ec2f865c31
--- /dev/null
+++ b/src/gallium/targets/egl-gdi/egl-static.c
@@ -0,0 +1,148 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.9
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#include "common/egl_g3d_loader.h"
+#include "state_tracker/st_gl_api.h"
+#include "vg_api.h"
+#include "target-helpers/inline_sw_helper.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "egldriver.h"
+
+static uint
+get_api_mask(void)
+{
+ uint api_mask = 0x0;
+
+#if FEATURE_GL
+ api_mask |= 1 << ST_API_OPENGL;
+#endif
+#if FEATURE_ES1
+ api_mask |= 1 << ST_API_OPENGL_ES1;
+#endif
+#if FEATURE_ES2
+ api_mask |= 1 << ST_API_OPENGL_ES2;
+#endif
+#if FEATURE_VG
+ api_mask |= 1 << ST_API_OPENVG;
+#endif
+
+ return api_mask;
+}
+
+static struct st_api *
+get_st_api(enum st_api_type api)
+{
+ struct st_api *stapi = NULL;
+
+ switch (api) {
+#if FEATURE_GL
+ case ST_API_OPENGL:
+ stapi = st_gl_api_create();
+ break;
+#endif
+#if FEATURE_ES1
+ case ST_API_OPENGL_ES1:
+ stapi = st_gl_api_create_es1();
+ break;
+#endif
+#if FEATURE_ES2
+ case ST_API_OPENGL_ES2:
+ stapi = st_gl_api_create_es2();
+ break;
+#endif
+#if FEATURE_VG
+ case ST_API_OPENVG:
+ stapi = (struct st_api *) vg_api_get();
+ break;
+#endif
+ default:
+ break;
+ }
+
+ return stapi;
+}
+
+static struct st_api *
+guess_gl_api(void)
+{
+ return NULL;
+}
+
+static struct pipe_screen *
+create_drm_screen(const char *name, int fd)
+{
+ return NULL;
+}
+
+static struct pipe_screen *
+create_sw_screen(struct sw_winsys *ws)
+{
+ struct pipe_screen *screen;
+
+ screen = sw_screen_create(ws);
+ if (screen)
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+static void
+init_loader(struct egl_g3d_loader *loader)
+{
+ if (loader->api_mask)
+ return;
+
+ loader->api_mask = get_api_mask();
+ loader->get_st_api = get_st_api;
+ loader->guess_gl_api = guess_gl_api;
+ loader->create_drm_screen = create_drm_screen;
+ loader->create_sw_screen = create_sw_screen;
+}
+
+static void
+egl_g3d_unload(_EGLDriver *drv)
+{
+ egl_g3d_destroy_driver(drv);
+}
+
+static struct egl_g3d_loader loader;
+
+_EGLDriver *
+_eglMain(const char *args)
+{
+ _EGLDriver *drv;
+
+ init_loader(&loader);
+ drv = egl_g3d_create_driver(&loader);
+ if (drv) {
+ drv->Name = "Gallium";
+ drv->Unload = egl_g3d_unload;
+ }
+
+ return drv;
+}
diff --git a/src/gallium/targets/egl-i915/Makefile b/src/gallium/targets/egl-i915/Makefile
deleted file mode 100644
index a4b41842ff..0000000000
--- a/src/gallium/targets/egl-i915/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = i915
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS = -ldrm_intel
-
-EGL_DRIVER_PIPES = \
- $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
- $(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/drivers/rbug/librbug.a \
- $(TOP)/src/gallium/drivers/i915/libi915.a
-
-include ../Makefile.egl
diff --git a/src/gallium/targets/egl-i915/dummy.c b/src/gallium/targets/egl-i915/dummy.c
deleted file mode 100644
index 3181d0ba7e..0000000000
--- a/src/gallium/targets/egl-i915/dummy.c
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl-i965/Makefile b/src/gallium/targets/egl-i965/Makefile
deleted file mode 100644
index d4730824a5..0000000000
--- a/src/gallium/targets/egl-i965/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = i965
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS = -ldrm_intel
-
-EGL_DRIVER_PIPES = \
- $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
- $(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/drivers/rbug/librbug.a \
- $(TOP)/src/gallium/drivers/i965/libi965.a \
- $(TOP)/src/gallium/winsys/sw/drm/libswdrm.a \
- $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
-
-include ../Makefile.egl
diff --git a/src/gallium/targets/egl-i965/dummy.c b/src/gallium/targets/egl-i965/dummy.c
deleted file mode 100644
index 3181d0ba7e..0000000000
--- a/src/gallium/targets/egl-i965/dummy.c
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl-nouveau/Makefile b/src/gallium/targets/egl-nouveau/Makefile
deleted file mode 100644
index e3fa8937e8..0000000000
--- a/src/gallium/targets/egl-nouveau/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = nouveau
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS = -ldrm_nouveau
-
-EGL_DRIVER_PIPES = \
- $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
- $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
- $(TOP)/src/gallium/drivers/nv50/libnv50.a \
- $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
-
-include ../Makefile.egl
diff --git a/src/gallium/targets/egl-nouveau/dummy.c b/src/gallium/targets/egl-nouveau/dummy.c
deleted file mode 100644
index 3181d0ba7e..0000000000
--- a/src/gallium/targets/egl-nouveau/dummy.c
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl-radeon/Makefile b/src/gallium/targets/egl-radeon/Makefile
deleted file mode 100644
index 8fcca26826..0000000000
--- a/src/gallium/targets/egl-radeon/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = radeon
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS = -ldrm_radeon
-
-EGL_DRIVER_PIPES = \
- $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
- $(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/drivers/rbug/librbug.a \
- $(TOP)/src/gallium/drivers/r300/libr300.a
-
-include ../Makefile.egl
diff --git a/src/gallium/targets/egl-radeon/dummy.c b/src/gallium/targets/egl-radeon/dummy.c
deleted file mode 100644
index 3181d0ba7e..0000000000
--- a/src/gallium/targets/egl-radeon/dummy.c
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl-swrast/Makefile b/src/gallium/targets/egl-swrast/Makefile
deleted file mode 100644
index 7d4f505498..0000000000
--- a/src/gallium/targets/egl-swrast/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-# Do propperly
-CFLAGS+="-I$(TOP)/src/gallium/include"
-
-EGL_DRIVER_NAME = swrast
-EGL_DRIVER_SOURCES = swrast_glue.c
-EGL_DRIVER_LIBS =
-EGL_DRIVER_PIPES =
-
-include ../Makefile.egl
diff --git a/src/gallium/targets/egl-swrast/SConscript b/src/gallium/targets/egl-swrast/SConscript
deleted file mode 100644
index 213e5b3e6c..0000000000
--- a/src/gallium/targets/egl-swrast/SConscript
+++ /dev/null
@@ -1,30 +0,0 @@
-#######################################################################
-# SConscript for egl-swrast target
-
-Import('*')
-
-if env['platform'] == 'windows':
-
- env = env.Clone()
-
- env.Append(LIBS = [
- 'gdi32',
- 'user32',
- 'kernel32',
- 'ws2_32',
- ])
-
- drivers = [softpipe]
- if env['llvm']:
- drivers += [llvmpipe]
- drivers += [identity, trace, rbug]
-
- env['no_import_lib'] = 1
-
- egl_gdi_swrast = env.SharedLibrary(
- target ='egl_gdi_swrast',
- source = 'swrast_glue.c',
- LIBS = st_egl_gdi + ws_gdi + drivers + gallium + egl + env['LIBS'],
- )
-
- env.InstallSharedLibrary(egl_gdi_swrast)
diff --git a/src/gallium/targets/egl-swrast/swrast_glue.c b/src/gallium/targets/egl-swrast/swrast_glue.c
deleted file mode 100644
index defd11c687..0000000000
--- a/src/gallium/targets/egl-swrast/swrast_glue.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "state_tracker/drm_api.h"
-
-struct drm_api *
-drm_api_create()
-{
- return NULL;
-}
-
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl-vmwgfx/Makefile b/src/gallium/targets/egl-vmwgfx/Makefile
deleted file mode 100644
index a9f6874b98..0000000000
--- a/src/gallium/targets/egl-vmwgfx/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = vmwgfx
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS =
-
-EGL_DRIVER_PIPES = \
- $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
- $(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/drivers/rbug/librbug.a \
- $(TOP)/src/gallium/drivers/svga/libsvga.a
-
-include ../Makefile.egl
diff --git a/src/gallium/targets/egl-vmwgfx/dummy.c b/src/gallium/targets/egl-vmwgfx/dummy.c
deleted file mode 100644
index 3181d0ba7e..0000000000
--- a/src/gallium/targets/egl-vmwgfx/dummy.c
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl/Makefile b/src/gallium/targets/egl/Makefile
new file mode 100644
index 0000000000..1e4bb4d94c
--- /dev/null
+++ b/src/gallium/targets/egl/Makefile
@@ -0,0 +1,229 @@
+# src/gallium/targets/egl/Makefile
+#
+# This is the Makefile for EGL Gallium driver package. The package consists of
+#
+# egl_gallium.so - EGL driver
+# pipe_<HW>.so - pipe drivers
+# st_<API>.so - client API state trackers
+#
+# The following variables are examined
+#
+# EGL_PLATFORMS - platforms to support
+# GALLIUM_WINSYS_DIRS - pipe drivers to support
+# EGL_CLIENT_APIS - state trackers to support
+#
+
+TOP = ../../../..
+include $(TOP)/configs/current
+
+ST_PREFIX := st_
+PIPE_PREFIX := pipe_
+
+common_CPPFLAGS := \
+ -I$(TOP)/include \
+ -I$(TOP)/src/gallium/auxiliary \
+ -I$(TOP)/src/gallium/drivers \
+ -I$(TOP)/src/gallium/include \
+ -I$(TOP)/src/gallium/winsys
+common_SYS :=
+common_LIBS := \
+ $(TOP)/src/gallium/drivers/identity/libidentity.a \
+ $(TOP)/src/gallium/drivers/trace/libtrace.a \
+ $(TOP)/src/gallium/drivers/rbug/librbug.a \
+ $(GALLIUM_AUXILIARIES)
+
+# EGL driver
+egl_CPPFLAGS := \
+ -I$(TOP)/src/gallium/state_trackers/egl \
+ -I$(TOP)/src/egl/main \
+ -DPIPE_PREFIX=\"$(PIPE_PREFIX)\" -DST_PREFIX=\"$(ST_PREFIX)\"
+egl_SYS := -lm $(DLOPEN_LIBS) -L$(TOP)/$(LIB_DIR) -lEGL
+egl_LIBS := $(TOP)/src/gallium/state_trackers/egl/libegl.a
+
+ifneq ($(findstring x11, $(EGL_PLATFORMS)),)
+egl_SYS += -lX11 -lXext -lXfixes
+egl_LIBS += $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a
+endif
+ifneq ($(findstring kms, $(EGL_PLATFORMS)),)
+egl_SYS += -ldrm
+endif
+ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),)
+egl_LIBS += $(TOP)/src/gallium/winsys/sw/fbdev/libfbdev.a
+endif
+
+# EGL_RENDERABLE_TYPE is a compile time attribute
+egl_CPPFLAGS += $(API_DEFINES)
+ifneq ($(filter $(GL_LIB), $(EGL_CLIENT_APIS)),)
+egl_CPPFLAGS += -DFEATURE_GL=1
+endif
+ifneq ($(filter $(GLESv1_CM_LIB), $(EGL_CLIENT_APIS)),)
+egl_CPPFLAGS += -DFEATURE_ES1=1
+endif
+ifneq ($(filter $(GLESv2_LIB), $(EGL_CLIENT_APIS)),)
+egl_CPPFLAGS += -DFEATURE_ES2=1
+endif
+ifneq ($(filter $(VG_LIB), $(EGL_CLIENT_APIS)),)
+egl_CPPFLAGS += -DFEATURE_VG=1
+endif
+egl_CPPFLAGS := $(sort $(egl_CPPFLAGS))
+
+# i915 pipe driver
+i915_CPPFLAGS :=
+i915_SYS := -ldrm_intel
+i915_LIBS := \
+ $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
+ $(TOP)/src/gallium/drivers/i915/libi915.a
+
+# i965 pipe driver
+i965_CPPFLAGS :=
+i965_SYS := -ldrm_intel
+i965_LIBS := \
+ $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
+ $(TOP)/src/gallium/drivers/i965/libi965.a
+
+# nouveau pipe driver
+nouveau_CPPFLAGS :=
+nouveau_SYS := -ldrm_nouveau
+nouveau_LIBS := \
+ $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
+ $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
+ $(TOP)/src/gallium/drivers/nv50/libnv50.a \
+ $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
+
+# radeon pipe driver
+radeon_CPPFLAGS :=
+radeon_SYS := -ldrm -ldrm_radeon
+radeon_LIBS := \
+ $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
+ $(TOP)/src/gallium/drivers/r300/libr300.a
+
+# vmwgfx pipe driver
+vmwgfx_CPPFLAGS :=
+vmwgfx_SYS :=
+vmwgfx_LIBS := \
+ $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
+ $(TOP)/src/gallium/drivers/svga/libsvga.a
+
+# swrast (pseudo) pipe driver
+swrast_CPPFLAGS := -DGALLIUM_SOFTPIPE -DGALLIUM_RBUG -DGALLIUM_TRACE
+swrast_SYS := -lm
+swrast_LIBS := $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
+
+# LLVM
+ifeq ($(MESA_LLVM),1)
+common_SYS += $(LLVM_LIBS)
+swrast_CPPFLAGS += -DGALLIUM_LLVMPIPE
+swrast_LIBS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
+LDFLAGS += $(LLVM_LDFLAGS)
+endif
+
+# OpenGL state tracker
+GL_CPPFLAGS := -I$(TOP)/src/mesa $(API_DEFINES)
+GL_SYS := -lpthread -lm -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
+GL_LIBS := $(TOP)/src/mesa/libmesagallium.a
+
+# OpenGL ES 1.x state tracker
+GLESv1_CM_CPPFLAGS := -I$(TOP)/src/mesa
+GLESv1_CM_SYS := -lpthread -lm -L$(TOP)/$(LIB_DIR) -l$(GLESv1_CM_LIB)
+GLESv1_CM_LIBS := $(TOP)/src/mesa/libes1gallium.a
+
+# OpenGL ES 2.x state tracker
+GLESv2_CPPFLAGS := -I$(TOP)/src/mesa
+GLESv2_SYS := -lpthread -lm -L$(TOP)/$(LIB_DIR) -l$(GLESv2_LIB)
+GLESv2_LIBS := $(TOP)/src/mesa/libes2gallium.a
+
+# OpenVG state tracker
+OpenVG_CPPFLAGS := -I$(TOP)/src/gallium/state_trackers/vega
+OpenVG_SYS := -lm -L$(TOP)/$(LIB_DIR) -l$(VG_LIB)
+OpenVG_LIBS := $(TOP)/src/gallium/state_trackers/vega/libvega.a
+
+
+OUTPUT_PATH := $(TOP)/$(LIB_DIR)/egl
+
+# determine the outputs
+ifneq ($(findstring i915/drm,$(GALLIUM_WINSYS_DIRS)),)
+OUTPUTS += i915
+endif
+ifneq ($(findstring i965/drm,$(GALLIUM_WINSYS_DIRS)),)
+OUTPUTS += i965
+endif
+ifneq ($(findstring nouveau/drm,$(GALLIUM_WINSYS_DIRS)),)
+OUTPUTS += nouveau
+endif
+ifneq ($(findstring radeon/drm,$(GALLIUM_WINSYS_DIRS)),)
+OUTPUTS += radeon
+endif
+ifneq ($(findstring svga/drm,$(GALLIUM_WINSYS_DIRS)),)
+OUTPUTS += vmwgfx
+endif
+OUTPUTS += swrast
+OUTPUTS := $(addprefix $(PIPE_PREFIX), $(OUTPUTS))
+
+# EGL driver and state trackers
+OUTPUTS += egl_gallium $(addprefix $(ST_PREFIX), $(EGL_CLIENT_APIS))
+
+OUTPUTS := $(addsuffix .so, $(OUTPUTS))
+OUTPUTS := $(addprefix $(OUTPUT_PATH)/, $(OUTPUTS))
+
+default: $(OUTPUTS)
+
+define mklib
+$(MKLIB) -o $(notdir $@) -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+ -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) $< \
+ -Wl,--start-group $(common_LIBS) $($(1)_LIBS) -Wl,--end-group \
+ $(common_SYS) $($(1)_SYS)
+endef
+
+# EGL driver
+$(OUTPUT_PATH)/egl_gallium.so: egl.o $(egl_LIBS)
+ $(call mklib,egl)
+
+# pipe drivers
+$(OUTPUT_PATH)/$(PIPE_PREFIX)i915.so: pipe_i915.o $(i915_LIBS)
+ $(call mklib,i915)
+
+$(OUTPUT_PATH)/$(PIPE_PREFIX)i965.so: pipe_i965.o $(i965_LIBS)
+ $(call mklib,i965)
+
+$(OUTPUT_PATH)/$(PIPE_PREFIX)nouveau.so: pipe_nouveau.o $(nouveau_LIBS)
+ $(call mklib,nouveau)
+
+$(OUTPUT_PATH)/$(PIPE_PREFIX)radeon.so: pipe_radeon.o $(radeon_LIBS)
+ $(call mklib,radeon)
+
+$(OUTPUT_PATH)/$(PIPE_PREFIX)vmwgfx.so: pipe_vmwgfx.o $(vmwgfx_LIBS)
+ $(call mklib,vmwgfx)
+
+$(OUTPUT_PATH)/$(PIPE_PREFIX)swrast.so: pipe_swrast.o $(swrast_LIBS)
+ $(call mklib,swrast)
+
+# state trackers
+$(OUTPUT_PATH)/$(ST_PREFIX)$(GL_LIB).so: st_GL.o $(GL_LIBS)
+ $(call mklib,GL)
+
+$(OUTPUT_PATH)/$(ST_PREFIX)$(GLESv1_CM_LIB).so: st_GLESv1_CM.o $(GLESv1_CM_LIBS)
+ $(call mklib,GLESv1_CM)
+
+$(OUTPUT_PATH)/$(ST_PREFIX)$(GLESv2_LIB).so: st_GLESv2.o $(GLESv2_LIBS)
+ $(call mklib,GLESv2)
+
+$(OUTPUT_PATH)/$(ST_PREFIX)$(VG_LIB).so: st_OpenVG.o $(OpenVG_LIBS)
+ $(call mklib,OpenVG)
+
+egl.o: egl.c
+ $(CC) -c -o $@ $< $(common_CPPFLAGS) $(egl_CPPFLAGS) $(DEFINES) $(CFLAGS)
+
+pipe_%.o: pipe_%.c
+ $(CC) -c -o $@ $< $(common_CPPFLAGS) $($*_CPPFLAGS) $(DEFINES) $(CFLAGS)
+
+st_%.o: st_%.c
+ $(CC) -c -o $@ $< $(common_CPPFLAGS) $($*_CPPFLAGS) $(DEFINES) $(CFLAGS)
+
+install: $(OUTPUTS)
+ $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR)
+ for out in $(OUTPUTS); do \
+ $(MINSTALL) -m 755 "$$out" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \
+ done
+
+clean:
+ rm -f *.o
diff --git a/src/gallium/targets/egl/egl.c b/src/gallium/targets/egl/egl.c
new file mode 100644
index 0000000000..d9d89485c3
--- /dev/null
+++ b/src/gallium/targets/egl/egl.c
@@ -0,0 +1,428 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.9
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#include "util/u_debug.h"
+#include "util/u_string.h"
+#include "util/u_memory.h"
+#include "util/u_dl.h"
+#include "egldriver.h"
+#include "egllog.h"
+
+#include "state_tracker/st_api.h"
+#include "state_tracker/drm_driver.h"
+#include "common/egl_g3d_loader.h"
+
+struct egl_g3d_loader egl_g3d_loader;
+
+static struct st_module {
+ boolean initialized;
+ char *name;
+ struct util_dl_library *lib;
+ struct st_api *stapi;
+} st_modules[ST_API_COUNT];
+
+static struct pipe_module {
+ boolean initialized;
+ char *name;
+ struct util_dl_library *lib;
+ const struct drm_driver_descriptor *drmdd;
+ struct pipe_screen *(*swrast_create_screen)(struct sw_winsys *);
+} pipe_modules[16];
+
+static char *
+loader_strdup(const char *s)
+{
+ size_t len = (s) ? strlen(s) : 0;
+ char *t = MALLOC(len + 1);
+ if (t) {
+ memcpy(t, s, len);
+ t[len] = '\0';
+ }
+ return t;
+}
+
+static EGLBoolean
+dlopen_st_module_cb(const char *dir, size_t len, void *callback_data)
+{
+ struct st_module *stmod =
+ (struct st_module *) callback_data;
+ char path[1024];
+ int ret;
+
+ if (len) {
+ ret = util_snprintf(path, sizeof(path),
+ "%.*s/" ST_PREFIX "%s" UTIL_DL_EXT, len, dir, stmod->name);
+ }
+ else {
+ ret = util_snprintf(path, sizeof(path),
+ ST_PREFIX "%s" UTIL_DL_EXT, stmod->name);
+ }
+
+ if (ret > 0 && ret < sizeof(path)) {
+ stmod->lib = util_dl_open(path);
+ if (stmod->lib)
+ _eglLog(_EGL_DEBUG, "loaded %s", path);
+ }
+
+ return !(stmod->lib);
+}
+
+static boolean
+load_st_module(struct st_module *stmod,
+ const char *name, const char *procname)
+{
+ struct st_api *(*create_api)(void);
+
+ stmod->name = loader_strdup(name);
+ if (stmod->name)
+ _eglSearchPathForEach(dlopen_st_module_cb, (void *) stmod);
+ else
+ stmod->lib = util_dl_open(NULL);
+
+ if (stmod->lib) {
+ create_api = (struct st_api *(*)(void))
+ util_dl_get_proc_address(stmod->lib, procname);
+ if (create_api)
+ stmod->stapi = create_api();
+
+ if (!stmod->stapi) {
+ util_dl_close(stmod->lib);
+ stmod->lib = NULL;
+ }
+ }
+
+ if (!stmod->stapi) {
+ FREE(stmod->name);
+ stmod->name = NULL;
+ }
+
+ return (stmod->stapi != NULL);
+}
+
+static EGLBoolean
+dlopen_pipe_module_cb(const char *dir, size_t len, void *callback_data)
+{
+ struct pipe_module *pmod = (struct pipe_module *) callback_data;
+ char path[1024];
+ int ret;
+
+ if (len) {
+ ret = util_snprintf(path, sizeof(path),
+ "%.*s/" PIPE_PREFIX "%s" UTIL_DL_EXT, len, dir, pmod->name);
+ }
+ else {
+ ret = util_snprintf(path, sizeof(path),
+ PIPE_PREFIX "%s" UTIL_DL_EXT, pmod->name);
+ }
+ if (ret > 0 && ret < sizeof(path)) {
+ pmod->lib = util_dl_open(path);
+ if (pmod->lib)
+ _eglLog(_EGL_DEBUG, "loaded %s", path);
+ }
+
+ return !(pmod->lib);
+}
+
+static boolean
+load_pipe_module(struct pipe_module *pmod, const char *name)
+{
+ pmod->name = loader_strdup(name);
+ if (!pmod->name)
+ return FALSE;
+
+ _eglSearchPathForEach(dlopen_pipe_module_cb, (void *) pmod);
+ if (pmod->lib) {
+ pmod->drmdd = (const struct drm_driver_descriptor *)
+ util_dl_get_proc_address(pmod->lib, "driver_descriptor");
+ if (pmod->drmdd) {
+ if (pmod->drmdd->driver_name) {
+ /* driver name mismatch */
+ if (strcmp(pmod->drmdd->driver_name, pmod->name) != 0)
+ pmod->drmdd = NULL;
+ }
+ else {
+ /* swrast */
+ pmod->swrast_create_screen =
+ (struct pipe_screen *(*)(struct sw_winsys *))
+ util_dl_get_proc_address(pmod->lib, "swrast_create_screen");
+ if (!pmod->swrast_create_screen)
+ pmod->drmdd = NULL;
+ }
+ }
+
+ if (!pmod->drmdd) {
+ util_dl_close(pmod->lib);
+ pmod->lib = NULL;
+ }
+ }
+
+ if (!pmod->drmdd)
+ pmod->name = NULL;
+
+ return (pmod->drmdd != NULL);
+}
+
+static struct st_api *
+get_st_api(enum st_api_type api)
+{
+ struct st_module *stmod = &st_modules[api];
+ const char *names[8], *symbol;
+ int i, count = 0;
+
+ if (stmod->initialized)
+ return stmod->stapi;
+
+ switch (api) {
+ case ST_API_OPENGL:
+ symbol = ST_CREATE_OPENGL_SYMBOL;
+ names[count++] = "GL";
+ break;
+ case ST_API_OPENGL_ES1:
+ symbol = ST_CREATE_OPENGL_ES1_SYMBOL;
+ names[count++] = "GLESv1_CM";
+ names[count++] = "GL";
+ break;
+ case ST_API_OPENGL_ES2:
+ symbol = ST_CREATE_OPENGL_ES2_SYMBOL;
+ names[count++] = "GLESv2";
+ names[count++] = "GL";
+ break;
+ case ST_API_OPENVG:
+ symbol = ST_CREATE_OPENVG_SYMBOL;
+ names[count++] = "OpenVG";
+ break;
+ default:
+ symbol = NULL;
+ assert(!"Unknown API Type\n");
+ break;
+ }
+
+ /* NULL means the process itself */
+ names[count++] = NULL;
+
+ for (i = 0; i < count; i++) {
+ if (load_st_module(stmod, names[i], symbol))
+ break;
+ }
+
+ if (!stmod->stapi) {
+ EGLint level = (egl_g3d_loader.api_mask & (1 << api)) ?
+ _EGL_WARNING : _EGL_DEBUG;
+ _eglLog(level, "unable to load " ST_PREFIX "%s" UTIL_DL_EXT, names[0]);
+ }
+
+ stmod->initialized = TRUE;
+
+ return stmod->stapi;
+}
+
+static struct st_api *
+guess_gl_api(void)
+{
+ struct st_api *stapi;
+ int gl_apis[] = {
+ ST_API_OPENGL,
+ ST_API_OPENGL_ES1,
+ ST_API_OPENGL_ES2,
+ -1
+ };
+ int i, api = -1;
+
+ /* determine the api from the loaded libraries */
+ for (i = 0; gl_apis[i] != -1; i++) {
+ if (st_modules[gl_apis[i]].stapi) {
+ api = gl_apis[i];
+ break;
+ }
+ }
+ /* determine the api from the linked libraries */
+ if (api == -1) {
+ struct util_dl_library *self = util_dl_open(NULL);
+
+ if (self) {
+ if (util_dl_get_proc_address(self, "glColor4d"))
+ api = ST_API_OPENGL;
+ else if (util_dl_get_proc_address(self, "glColor4x"))
+ api = ST_API_OPENGL_ES1;
+ else if (util_dl_get_proc_address(self, "glShaderBinary"))
+ api = ST_API_OPENGL_ES2;
+ util_dl_close(self);
+ }
+ }
+
+ stapi = (api != -1) ? get_st_api(api) : NULL;
+ if (!stapi) {
+ for (i = 0; gl_apis[i] != -1; i++) {
+ api = gl_apis[i];
+ stapi = get_st_api(api);
+ if (stapi)
+ break;
+ }
+ }
+
+ return stapi;
+}
+
+static struct pipe_module *
+get_pipe_module(const char *name)
+{
+ struct pipe_module *pmod = NULL;
+ int i;
+
+ if (!name)
+ return NULL;
+
+ for (i = 0; i < Elements(pipe_modules); i++) {
+ if (!pipe_modules[i].initialized ||
+ strcmp(pipe_modules[i].name, name) == 0) {
+ pmod = &pipe_modules[i];
+ break;
+ }
+ }
+ if (!pmod)
+ return NULL;
+
+ if (!pmod->initialized) {
+ load_pipe_module(pmod, name);
+ pmod->initialized = TRUE;
+ }
+
+ return pmod;
+}
+
+static struct pipe_screen *
+create_drm_screen(const char *name, int fd)
+{
+ struct pipe_module *pmod = get_pipe_module(name);
+ return (pmod && pmod->drmdd->create_screen) ?
+ pmod->drmdd->create_screen(fd) : NULL;
+}
+
+static struct pipe_screen *
+create_sw_screen(struct sw_winsys *ws)
+{
+ struct pipe_module *pmod = get_pipe_module("swrast");
+ return (pmod && pmod->swrast_create_screen) ?
+ pmod->swrast_create_screen(ws) : NULL;
+}
+
+static const struct egl_g3d_loader *
+loader_init(void)
+{
+ uint api_mask = 0x0;
+
+ /* TODO detect at runtime? */
+#if FEATURE_GL
+ api_mask |= 1 << ST_API_OPENGL;
+#endif
+#if FEATURE_ES1
+ api_mask |= 1 << ST_API_OPENGL_ES1;
+#endif
+#if FEATURE_ES2
+ api_mask |= 1 << ST_API_OPENGL_ES2;
+#endif
+#if FEATURE_VG
+ api_mask |= 1 << ST_API_OPENVG;
+#endif
+
+ egl_g3d_loader.api_mask = api_mask;
+ egl_g3d_loader.get_st_api = get_st_api;
+ egl_g3d_loader.guess_gl_api = guess_gl_api;
+ egl_g3d_loader.create_drm_screen = create_drm_screen;
+ egl_g3d_loader.create_sw_screen = create_sw_screen;
+
+ return &egl_g3d_loader;
+}
+
+static void
+loader_fini(void)
+{
+ int i;
+
+ for (i = 0; i < ST_API_COUNT; i++) {
+ struct st_module *stmod = &st_modules[i];
+
+ if (stmod->stapi) {
+ stmod->stapi->destroy(stmod->stapi);
+ stmod->stapi = NULL;
+ }
+ if (stmod->lib) {
+ util_dl_close(stmod->lib);
+ stmod->lib = NULL;
+ }
+ if (stmod->name) {
+ FREE(stmod->name);
+ stmod->name = NULL;
+ }
+ stmod->initialized = FALSE;
+ }
+ for (i = 0; i < Elements(pipe_modules); i++) {
+ struct pipe_module *pmod = &pipe_modules[i];
+
+ if (!pmod->initialized)
+ break;
+
+ pmod->drmdd = NULL;
+ pmod->swrast_create_screen = NULL;
+ if (pmod->lib) {
+ util_dl_close(pmod->lib);
+ pmod->lib = NULL;
+ }
+ if (pmod->name) {
+ FREE(pmod->name);
+ pmod->name = NULL;
+ }
+ pmod->initialized = FALSE;
+ }
+}
+
+static void
+egl_g3d_unload(_EGLDriver *drv)
+{
+ egl_g3d_destroy_driver(drv);
+ loader_fini();
+}
+
+_EGLDriver *
+_eglMain(const char *args)
+{
+ const struct egl_g3d_loader *loader;
+ _EGLDriver *drv;
+
+ loader = loader_init();
+ drv = egl_g3d_create_driver(loader);
+ if (!drv) {
+ loader_fini();
+ return NULL;
+ }
+
+ drv->Name = "Gallium";
+ drv->Unload = egl_g3d_unload;
+
+ return drv;
+}
diff --git a/src/gallium/targets/egl/pipe_i915.c b/src/gallium/targets/egl/pipe_i915.c
new file mode 100644
index 0000000000..758a921b48
--- /dev/null
+++ b/src/gallium/targets/egl/pipe_i915.c
@@ -0,0 +1,28 @@
+
+#include "target-helpers/inline_wrapper_sw_helper.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "i915/drm/i915_drm_public.h"
+#include "i915/i915_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct i915_winsys *iws;
+ struct pipe_screen *screen;
+
+ iws = i915_drm_winsys_create(fd);
+ if (!iws)
+ return NULL;
+
+ screen = i915_screen_create(iws);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+PUBLIC
+DRM_DRIVER_DESCRIPTOR("i915", "i915", create_screen)
diff --git a/src/gallium/targets/egl/pipe_i965.c b/src/gallium/targets/egl/pipe_i965.c
new file mode 100644
index 0000000000..43bf646e82
--- /dev/null
+++ b/src/gallium/targets/egl/pipe_i965.c
@@ -0,0 +1,31 @@
+
+#include "target-helpers/inline_wrapper_sw_helper.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "i965/drm/i965_drm_public.h"
+#include "i965/brw_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct brw_winsys_screen *bws;
+ struct pipe_screen *screen;
+
+ bws = i965_drm_winsys_screen_create(fd);
+ if (!bws)
+ return NULL;
+
+ screen = brw_screen_create(bws);
+ if (!screen)
+ return NULL;
+
+ if (debug_get_bool_option("BRW_SOFTPIPE", FALSE))
+ screen = sw_screen_wrap(screen);
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+PUBLIC
+DRM_DRIVER_DESCRIPTOR("i965", "i965", create_screen)
diff --git a/src/gallium/targets/egl/pipe_nouveau.c b/src/gallium/targets/egl/pipe_nouveau.c
new file mode 100644
index 0000000000..0c9081bc71
--- /dev/null
+++ b/src/gallium/targets/egl/pipe_nouveau.c
@@ -0,0 +1,21 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "nouveau/drm/nouveau_drm_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct pipe_screen *screen;
+
+ screen = nouveau_drm_screen_create(fd);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+PUBLIC
+DRM_DRIVER_DESCRIPTOR("nouveau", "nouveau", create_screen)
diff --git a/src/gallium/targets/egl/pipe_radeon.c b/src/gallium/targets/egl/pipe_radeon.c
new file mode 100644
index 0000000000..35550bcb26
--- /dev/null
+++ b/src/gallium/targets/egl/pipe_radeon.c
@@ -0,0 +1,27 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "radeon/drm/radeon_drm_public.h"
+#include "r300/r300_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct r300_winsys_screen *sws;
+ struct pipe_screen *screen;
+
+ sws = r300_drm_winsys_screen_create(fd);
+ if (!sws)
+ return NULL;
+
+ screen = r300_screen_create(sws);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+PUBLIC
+DRM_DRIVER_DESCRIPTOR("radeon", "radeon", create_screen)
diff --git a/src/gallium/targets/egl/pipe_swrast.c b/src/gallium/targets/egl/pipe_swrast.c
new file mode 100644
index 0000000000..b2e3289c5d
--- /dev/null
+++ b/src/gallium/targets/egl/pipe_swrast.c
@@ -0,0 +1,22 @@
+
+#include "target-helpers/inline_sw_helper.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+
+PUBLIC struct pipe_screen *
+swrast_create_screen(struct sw_winsys *ws);
+
+PUBLIC
+DRM_DRIVER_DESCRIPTOR("swrast", NULL, NULL)
+
+struct pipe_screen *
+swrast_create_screen(struct sw_winsys *ws)
+{
+ struct pipe_screen *screen;
+
+ screen = sw_screen_create(ws);
+ if (screen)
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
diff --git a/src/gallium/targets/egl/pipe_vmwgfx.c b/src/gallium/targets/egl/pipe_vmwgfx.c
new file mode 100644
index 0000000000..22a28fa858
--- /dev/null
+++ b/src/gallium/targets/egl/pipe_vmwgfx.c
@@ -0,0 +1,27 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "svga/drm/svga_drm_public.h"
+#include "svga/svga_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct svga_winsys_screen *sws;
+ struct pipe_screen *screen;
+
+ sws = svga_drm_winsys_screen_create(fd);
+ if (!sws)
+ return NULL;
+
+ screen = svga_screen_create(sws);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+PUBLIC
+DRM_DRIVER_DESCRIPTOR("vmwgfx", "vmwgfx", create_screen)
diff --git a/src/gallium/targets/egl/st_GL.c b/src/gallium/targets/egl/st_GL.c
new file mode 100644
index 0000000000..676300b0cc
--- /dev/null
+++ b/src/gallium/targets/egl/st_GL.c
@@ -0,0 +1,25 @@
+#include "state_tracker/st_gl_api.h"
+
+#if FEATURE_GL
+PUBLIC struct st_api *
+st_api_create_OpenGL(void)
+{
+ return st_gl_api_create();
+}
+#endif
+
+#if FEATURE_ES1
+PUBLIC struct st_api *
+st_api_create_OpenGL_ES1(void)
+{
+ return st_gl_api_create_es1();
+}
+#endif
+
+#if FEATURE_ES2
+PUBLIC struct st_api *
+st_api_create_OpenGL_ES2(void)
+{
+ return st_gl_api_create_es2();
+}
+#endif
diff --git a/src/gallium/targets/egl-apis/api_GL.c b/src/gallium/targets/egl/st_GLESv1_CM.c
index 6d172745c0..0c8de8992f 100644
--- a/src/gallium/targets/egl-apis/api_GL.c
+++ b/src/gallium/targets/egl/st_GLESv1_CM.c
@@ -1,7 +1,7 @@
#include "state_tracker/st_gl_api.h"
PUBLIC struct st_api *
-st_api_create_OpenGL()
+st_api_create_OpenGL_ES1(void)
{
- return st_gl_api_create();
+ return st_gl_api_create_es1();
}
diff --git a/src/gallium/targets/egl-apis/api_GLESv1_CM.c b/src/gallium/targets/egl/st_GLESv2.c
index 825fdac215..87b3e65e23 100644
--- a/src/gallium/targets/egl-apis/api_GLESv1_CM.c
+++ b/src/gallium/targets/egl/st_GLESv2.c
@@ -1,7 +1,7 @@
#include "state_tracker/st_gl_api.h"
PUBLIC struct st_api *
-st_api_create_OpenGL_ES1()
+st_api_create_OpenGL_ES2(void)
{
- return st_gl_api_create();
+ return st_gl_api_create_es2();
}
diff --git a/src/gallium/targets/egl-apis/api_OpenVG.c b/src/gallium/targets/egl/st_OpenVG.c
index f85ebea8a1..e29a237479 100644
--- a/src/gallium/targets/egl-apis/api_OpenVG.c
+++ b/src/gallium/targets/egl/st_OpenVG.c
@@ -2,7 +2,7 @@
#include "vg_api.h"
PUBLIC struct st_api *
-st_api_create_OpenVG()
+st_api_create_OpenVG(void)
{
return (struct st_api *) vg_api_get();
}
diff --git a/src/gallium/targets/libgl-xlib/Makefile b/src/gallium/targets/libgl-xlib/Makefile
index b173ceb994..e745023ba5 100644
--- a/src/gallium/targets/libgl-xlib/Makefile
+++ b/src/gallium/targets/libgl-xlib/Makefile
@@ -97,7 +97,7 @@ tags:
etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
clean:
- -rm -f *.o
+ -rm -f *.o depend
include depend
diff --git a/src/gallium/targets/xorg-i915/Makefile b/src/gallium/targets/xorg-i915/Makefile
index 18f07d6d8f..865240404c 100644
--- a/src/gallium/targets/xorg-i915/Makefile
+++ b/src/gallium/targets/xorg-i915/Makefile
@@ -4,19 +4,21 @@ include $(TOP)/configs/current
LIBNAME = modesetting_drv.so
C_SOURCES = \
+ intel_target.c \
intel_xorg.c
DRIVER_DEFINES = \
- -DHAVE_CONFIG_H
+ -DHAVE_CONFIG_H -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD
-DRIVER_LINKS = \
+DRIVER_PIPES = \
$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
$(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
$(TOP)/src/gallium/drivers/i915/libi915.a \
+ $(TOP)/src/gallium/drivers/galahad/libgalahad.a \
$(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/drivers/rbug/librbug.a \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(GALLIUM_AUXILIARIES) \
+ $(TOP)/src/gallium/drivers/rbug/librbug.a
+
+DRIVER_LINKS = \
$(shell pkg-config --libs libdrm libdrm_intel)
include ../Makefile.xorg
diff --git a/src/gallium/targets/xorg-i915/intel_target.c b/src/gallium/targets/xorg-i915/intel_target.c
new file mode 100644
index 0000000000..8c8ef7e02b
--- /dev/null
+++ b/src/gallium/targets/xorg-i915/intel_target.c
@@ -0,0 +1,26 @@
+
+#include "state_tracker/drm_driver.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "i915/drm/i915_drm_public.h"
+#include "i915/i915_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct i915_winsys *iws;
+ struct pipe_screen *screen;
+
+ iws = i915_drm_winsys_create(fd);
+ if (!iws)
+ return NULL;
+
+ screen = i915_screen_create(iws);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("i915", "i915", create_screen)
diff --git a/src/gallium/targets/xorg-i965/Makefile b/src/gallium/targets/xorg-i965/Makefile
index 2b0c7d6fdf..494dce41c8 100644
--- a/src/gallium/targets/xorg-i965/Makefile
+++ b/src/gallium/targets/xorg-i965/Makefile
@@ -4,19 +4,23 @@ include $(TOP)/configs/current
LIBNAME = i965g_drv.so
C_SOURCES = \
+ intel_target.c \
intel_xorg.c
DRIVER_DEFINES = \
- -DHAVE_CONFIG_H
+ -DHAVE_CONFIG_H -DGALLIUM_SOFTPIPE \
+ -DGALLIUM_RBUG -DGALLIUM_TRACE
-DRIVER_LINKS = \
+DRIVER_PIPES = \
$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
$(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
$(TOP)/src/gallium/drivers/i965/libi965.a \
$(TOP)/src/gallium/drivers/trace/libtrace.a \
$(TOP)/src/gallium/drivers/rbug/librbug.a \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(GALLIUM_AUXILIARIES) \
+ $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
+
+DRIVER_LINKS = \
$(shell pkg-config --libs libdrm libdrm_intel)
include ../Makefile.xorg
diff --git a/src/gallium/targets/xorg-i965/intel_target.c b/src/gallium/targets/xorg-i965/intel_target.c
new file mode 100644
index 0000000000..ce97f82027
--- /dev/null
+++ b/src/gallium/targets/xorg-i965/intel_target.c
@@ -0,0 +1,30 @@
+
+#include "target-helpers/inline_wrapper_sw_helper.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "i965/drm/i965_drm_public.h"
+#include "i965/brw_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct brw_winsys_screen *bws;
+ struct pipe_screen *screen;
+
+ bws = i965_drm_winsys_screen_create(fd);
+ if (!bws)
+ return NULL;
+
+ screen = brw_screen_create(bws);
+ if (!screen)
+ return NULL;
+
+ if (debug_get_bool_option("BRW_SOFTPIPE", FALSE))
+ screen = sw_screen_wrap(screen);
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("i915", "i965", create_screen)
diff --git a/src/gallium/targets/xorg-nouveau/Makefile b/src/gallium/targets/xorg-nouveau/Makefile
index f50872362f..2fcd9ffb7d 100644
--- a/src/gallium/targets/xorg-nouveau/Makefile
+++ b/src/gallium/targets/xorg-nouveau/Makefile
@@ -4,18 +4,22 @@ include $(TOP)/configs/current
LIBNAME = modesetting_drv.so
C_SOURCES = \
+ nouveau_target.c \
nouveau_xorg.c
DRIVER_DEFINES = \
- -DHAVE_CONFIG_H
+ -DHAVE_CONFIG_H -DGALLIUM_RBUG -DGALLIUM_TRACE
-DRIVER_LINKS = \
+DRIVER_PIPES = \
$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
$(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
$(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a \
$(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
- $(GALLIUM_AUXILIARIES) \
+ $(TOP)/src/gallium/drivers/trace/libtrace.a \
+ $(TOP)/src/gallium/drivers/rbug/librbug.a
+
+DRIVER_LINKS = \
$(shell pkg-config --libs libdrm libdrm_nouveau)
include ../Makefile.xorg
diff --git a/src/gallium/targets/xorg-nouveau/nouveau_target.c b/src/gallium/targets/xorg-nouveau/nouveau_target.c
new file mode 100644
index 0000000000..e725a4d9b7
--- /dev/null
+++ b/src/gallium/targets/xorg-nouveau/nouveau_target.c
@@ -0,0 +1,20 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "nouveau/drm/nouveau_drm_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct pipe_screen *screen;
+
+ screen = nouveau_drm_screen_create(fd);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("nouveau", "nouveau", create_screen)
diff --git a/src/gallium/targets/xorg-radeon/Makefile b/src/gallium/targets/xorg-radeon/Makefile
index a4951c4bba..d3bc356992 100644
--- a/src/gallium/targets/xorg-radeon/Makefile
+++ b/src/gallium/targets/xorg-radeon/Makefile
@@ -4,19 +4,21 @@ include $(TOP)/configs/current
LIBNAME = radeon_drv.so
C_SOURCES = \
+ radeon_target.c \
radeon_xorg.c
DRIVER_DEFINES = \
- -DHAVE_CONFIG_H
+ -DHAVE_CONFIG_H -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD
+
+DRIVER_PIPES = \
+ $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
+ $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
+ $(TOP)/src/gallium/drivers/r300/libr300.a \
+ $(TOP)/src/gallium/drivers/galahad/libgalahad.a \
+ $(TOP)/src/gallium/drivers/trace/libtrace.a \
+ $(TOP)/src/gallium/drivers/rbug/librbug.a
DRIVER_LINKS = \
- $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
- $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
- $(TOP)/src/gallium/drivers/r300/libr300.a \
- $(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/drivers/rbug/librbug.a \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(GALLIUM_AUXILIARIES) \
- $(shell pkg-config --libs libdrm libdrm_intel)
+ $(shell pkg-config --libs libdrm libdrm_radeon)
include ../Makefile.xorg
diff --git a/src/gallium/targets/xorg-radeon/radeon_target.c b/src/gallium/targets/xorg-radeon/radeon_target.c
new file mode 100644
index 0000000000..5a0a8dc573
--- /dev/null
+++ b/src/gallium/targets/xorg-radeon/radeon_target.c
@@ -0,0 +1,26 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "radeon/drm/radeon_drm_public.h"
+#include "r300/r300_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct r300_winsys_screen *sws;
+ struct pipe_screen *screen;
+
+ sws = r300_drm_winsys_screen_create(fd);
+ if (!sws)
+ return NULL;
+
+ screen = r300_screen_create(sws);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("radeon", "radeon", create_screen)
diff --git a/src/gallium/targets/xorg-vmwgfx/Makefile b/src/gallium/targets/xorg-vmwgfx/Makefile
index c0ff999116..04a444f5e9 100644
--- a/src/gallium/targets/xorg-vmwgfx/Makefile
+++ b/src/gallium/targets/xorg-vmwgfx/Makefile
@@ -8,6 +8,7 @@ C_SOURCES = \
vmw_video.c \
vmw_ioctl.c \
vmw_ctrl.c \
+ vmw_target.c \
vmw_screen.c
DRIVER_INCLUDES = \
@@ -15,16 +16,18 @@ DRIVER_INCLUDES = \
DRIVER_DEFINES = \
-std=gnu99 \
+ -DGALLIUM_RBUG \
+ -DGALLIUM_TRACE \
-DHAVE_CONFIG_H
-DRIVER_LINKS = \
+DRIVER_PIPES = \
$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
$(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
- $(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/drivers/rbug/librbug.a \
$(TOP)/src/gallium/drivers/svga/libsvga.a \
- $(GALLIUM_AUXILIARIES) \
- $(shell pkg-config --libs --silence-errors libkms) \
- $(shell pkg-config --libs libdrm)
+ $(TOP)/src/gallium/drivers/trace/libtrace.a \
+ $(TOP)/src/gallium/drivers/rbug/librbug.a
+
+DRIVER_LINKS = \
+ $(shell pkg-config --libs libdrm libkms)
include ../Makefile.xorg
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_ctrl.c b/src/gallium/targets/xorg-vmwgfx/vmw_ctrl.c
index 1cc8ddaac3..237b308ae3 100644
--- a/src/gallium/targets/xorg-vmwgfx/vmw_ctrl.c
+++ b/src/gallium/targets/xorg-vmwgfx/vmw_ctrl.c
@@ -32,9 +32,6 @@
* allows X clients to communicate with the driver.
*/
-
-#define NEED_REPLIES
-#define NEED_EVENTS
#include "dixstruct.h"
#include "extnsionst.h"
#include <X11/X.h>
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_driver.h b/src/gallium/targets/xorg-vmwgfx/vmw_driver.h
index d6e3620cd3..8dfc9d2efb 100644
--- a/src/gallium/targets/xorg-vmwgfx/vmw_driver.h
+++ b/src/gallium/targets/xorg-vmwgfx/vmw_driver.h
@@ -59,6 +59,7 @@ struct vmw_customizer
/* vmw_video.c */
void *video_priv;
+ uint64_t max_fb_size;
};
static INLINE struct vmw_customizer *
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_screen.c b/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
index 64934d53f6..8173908f55 100644
--- a/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
+++ b/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
@@ -35,6 +35,7 @@
#include <pipe/p_context.h>
#include "cursorstr.h"
+#include "../../winsys/svga/drm/vmwgfx_drm.h"
void vmw_winsys_screen_set_throttling(struct pipe_screen *screen,
uint32_t throttle_us);
@@ -111,13 +112,29 @@ vmw_context_no_throttle(CustomizerPtr cust,
}
static Bool
-vmw_screen_init(CustomizerPtr cust, int fd)
+vmw_check_fb_size(CustomizerPtr cust,
+ unsigned long pitch,
+ unsigned long height)
+{
+ struct vmw_customizer *vmw = vmw_customizer(cust);
+
+ /**
+ * 1) Is there a pitch alignment?
+ * 2) The 1024 byte pad is an arbitrary value to be on
+ */
+
+ return ((uint64_t) pitch * height + 1024ULL < vmw->max_fb_size);
+}
+
+static Bool
+vmw_pre_init(CustomizerPtr cust, int fd)
{
struct vmw_customizer *vmw = vmw_customizer(cust);
drmVersionPtr ver;
vmw->fd = fd;
- ver = drmGetVersion(fd);
+
+ ver = drmGetVersion(vmw->fd);
if (ver == NULL ||
(ver->version_major == 1 && ver->version_minor < 1)) {
cust->swap_throttling = TRUE;
@@ -128,11 +145,34 @@ vmw_screen_init(CustomizerPtr cust, int fd)
cust->dirty_throttling = FALSE;
cust->winsys_context_throttle = vmw_context_throttle;
debug_printf("%s: Enabling kernel throttling.\n", __func__);
+
+ if (ver->version_major > 1 ||
+ (ver->version_major == 1 && ver->version_minor >= 3)) {
+ struct drm_vmw_getparam_arg arg;
+ int ret;
+
+ arg.param = DRM_VMW_PARAM_MAX_FB_SIZE;
+ ret = drmCommandWriteRead(fd, DRM_VMW_GET_PARAM, &arg,
+ sizeof(arg));
+ if (!ret) {
+ vmw->max_fb_size = arg.value;
+ cust->winsys_check_fb_size = vmw_check_fb_size;
+ debug_printf("%s: Enabling fb size check.\n", __func__);
+ }
+ }
}
if (ver)
drmFreeVersion(ver);
+ return TRUE;
+}
+
+static Bool
+vmw_screen_init(CustomizerPtr cust)
+{
+ struct vmw_customizer *vmw = vmw_customizer(cust);
+
vmw_screen_cursor_init(vmw);
vmw_ctrl_ext_init(vmw);
@@ -199,6 +239,7 @@ vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags)
cust = &vmw->base;
+ cust->winsys_pre_init = vmw_pre_init;
cust->winsys_screen_init = vmw_screen_init;
cust->winsys_screen_close = vmw_screen_close;
cust->winsys_enter_vt = vmw_screen_enter_vt;
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_target.c b/src/gallium/targets/xorg-vmwgfx/vmw_target.c
new file mode 100644
index 0000000000..15089d6db2
--- /dev/null
+++ b/src/gallium/targets/xorg-vmwgfx/vmw_target.c
@@ -0,0 +1,26 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "svga/drm/svga_drm_public.h"
+#include "svga/svga_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+ struct svga_winsys_screen *sws;
+ struct pipe_screen *screen;
+
+ sws = svga_drm_winsys_screen_create(fd);
+ if (!sws)
+ return NULL;
+
+ screen = svga_screen_create(sws);
+ if (!screen)
+ return NULL;
+
+ screen = debug_screen_wrap(screen);
+
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("vmwgfx", "vmwgfx", create_screen)