summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/drm/Makefile.egl62
-rw-r--r--src/gallium/winsys/drm/Makefile.template9
-rw-r--r--src/gallium/winsys/drm/i965/egl/Makefile27
-rw-r--r--src/gallium/winsys/drm/i965/egl/dummy.c1
-rw-r--r--src/gallium/winsys/drm/i965/gem/i965_drm_api.c7
-rw-r--r--src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c1
-rw-r--r--src/gallium/winsys/drm/i965/xlib/xlib_i965.c19
-rw-r--r--src/gallium/winsys/drm/i965/xorg/Makefile59
-rw-r--r--src/gallium/winsys/drm/intel/egl/Makefile27
-rw-r--r--src/gallium/winsys/drm/intel/egl/dummy.c1
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_drm_api.c11
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_drm_fence.c3
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h1
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/Makefile3
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c75
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h5
-rw-r--r--src/gallium/winsys/drm/nouveau/egl/Makefile16
-rw-r--r--src/gallium/winsys/drm/nouveau/egl/dummy.c1
-rw-r--r--src/gallium/winsys/drm/nouveau/xorg/Makefile3
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_buffer.c135
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_buffer.h9
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm.c84
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm.h12
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_r300.c13
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_winsys.h8
-rw-r--r--src/gallium/winsys/drm/radeon/dri/Makefile2
-rw-r--r--src/gallium/winsys/drm/radeon/egl/Makefile24
-rw-r--r--src/gallium/winsys/drm/radeon/egl/dummy.c1
-rw-r--r--src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c8
-rw-r--r--src/gallium/winsys/drm/swrast/Makefile12
-rw-r--r--src/gallium/winsys/drm/swrast/core/Makefile10
-rw-r--r--src/gallium/winsys/drm/swrast/core/swrast_drm_api.c13
-rw-r--r--src/gallium/winsys/drm/swrast/egl/Makefile12
-rw-r--r--src/gallium/winsys/drm/swrast/egl/dummy.c1
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_buffer.c2
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_buffer.h2
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_context.c119
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_context.h3
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen.c5
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen.h8
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c111
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c18
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c22
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c2
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_surface.h6
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h55
-rw-r--r--src/gallium/winsys/drm/vmware/egl/Makefile16
-rw-r--r--src/gallium/winsys/drm/vmware/egl/dummy.c1
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_video.c3
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c10
-rw-r--r--src/gallium/winsys/egl_xlib/Makefile89
-rw-r--r--src/gallium/winsys/egl_xlib/egl_xlib.c853
-rw-r--r--src/gallium/winsys/egl_xlib/sw_winsys.c231
-rw-r--r--src/gallium/winsys/egl_xlib/sw_winsys.h40
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/Makefile5
-rw-r--r--src/gallium/winsys/g3dvl/xlib/xsp_winsys.c4
-rw-r--r--src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c8
-rw-r--r--src/gallium/winsys/gdi/gdi_softpipe_winsys.c12
-rw-r--r--src/gallium/winsys/xlib/xlib.c33
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_context.c4
-rw-r--r--src/gallium/winsys/xlib/xlib_cell.c30
-rw-r--r--src/gallium/winsys/xlib/xlib_llvmpipe.c24
-rw-r--r--src/gallium/winsys/xlib/xlib_softpipe.c63
63 files changed, 657 insertions, 1797 deletions
diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl
new file mode 100644
index 0000000000..b1f2038550
--- /dev/null
+++ b/src/gallium/winsys/drm/Makefile.egl
@@ -0,0 +1,62 @@
+# 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
+
+x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a
+x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes
+
+kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a
+kms_LIBS = $(common_LIBS)
+
+##### RULES #####
+
+.c.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+
+##### TARGETS #####
+
+EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so)
+
+EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(TOP)/$(LIB_DIR)/$(drv))
+
+default: $(EGL_DISPLAY_LIBS)
+
+$(EGL_DISPLAY_LIBS): $(TOP)/$(LIB_DIR)/%.so: %.so
+ $(INSTALL) $< $(TOP)/$(LIB_DIR)
+
+define mklib-egl
+$(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+ $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \
+ -Wl,--whole-archive $($(1)_ST) -Wl,--no-whole-archive \
+ $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $($(1)_LIBS) $(EGL_DRIVER_LIBS)
+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)
+
+clean:
+ -rm -f $(EGL_DRIVER_OBJECTS)
+ -rm -f $(EGL_DISPLAY_DRIVERS)
+
+install: $(EGL_DISPLAY_LIBS)
+ $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR)
+ for lib in $(EGL_DISPLAY_LIBS); do \
+ $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \
+ done
+
+depend:
diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template
index 9635c3c50e..960353a73d 100644
--- a/src/gallium/winsys/drm/Makefile.template
+++ b/src/gallium/winsys/drm/Makefile.template
@@ -82,18 +82,11 @@ SHARED_INCLUDES = \
default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
- $(MKLIB) -noprefix -o $@ \
+ $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
$(OBJECTS) $(PIPE_DRIVERS) \
-Wl,--start-group $(MESA_MODULES) -Wl,--end-group \
$(WINOBJ) $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
-$(LIBNAME_EGL): $(WINSYS_OBJECTS) $(LIBS)
- $(MKLIB) -o $(LIBNAME_EGL) \
- -linker "$(CC)" \
- -noprefix \
- $(OBJECTS) $(MKLIB_OPTIONS) $(WINSYS_OBJECTS) $(PIPE_DRIVERS) $(WINOBJ) $(DRI_LIB_DEPS) \
- --whole-archive $(LIBS) $(GALLIUM_AUXILIARIES) --no-whole-archive $(DRIVER_EXTRAS)
-
$(TOP)/$(LIB_DIR)/gallium:
mkdir -p $@
diff --git a/src/gallium/winsys/drm/i965/egl/Makefile b/src/gallium/winsys/drm/i965/egl/Makefile
index a1b32eb2a7..1c13258200 100644
--- a/src/gallium/winsys/drm/i965/egl/Makefile
+++ b/src/gallium/winsys/drm/i965/egl/Makefile
@@ -1,29 +1,14 @@
TOP = ../../../../../..
-GALLIUMDIR = ../../../..
include $(TOP)/configs/current
-LIBNAME = EGL_i965.so
+EGL_DRIVER_NAME = i965
+EGL_DRIVER_SOURCES = dummy.c
+EGL_DRIVER_LIBS = -ldrm_intel
-PIPE_DRIVERS = \
- $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
- $(GALLIUMDIR)/winsys/drm/i965/gem/libi965drm.a \
+EGL_DRIVER_PIPES = \
+ $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
$(TOP)/src/gallium/drivers/trace/libtrace.a \
$(TOP)/src/gallium/drivers/i965/libi965.a
-DRIVER_SOURCES =
-
-C_SOURCES = \
- $(COMMON_GALLIUM_SOURCES) \
- $(DRIVER_SOURCES)
-
-DRIVER_EXTRAS = -ldrm_intel
-
-ASM_SOURCES =
-
-DRIVER_DEFINES = -I../gem $(shell pkg-config libdrm --atleast-version=2.3.1 \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-
-include ../../Makefile.template
-
-symlinks:
+include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/i965/egl/dummy.c b/src/gallium/winsys/drm/i965/egl/dummy.c
new file mode 100644
index 0000000000..4a1bc28b0b
--- /dev/null
+++ b/src/gallium/winsys/drm/i965/egl/dummy.c
@@ -0,0 +1 @@
+/* mklib expects at least one object file */
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c
index fc9678d2b6..a061eef0be 100644
--- a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c
+++ b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c
@@ -212,11 +212,6 @@ i965_libdrm_create_screen(struct drm_api *api, int drmFD,
return brw_create_screen(&idws->base, deviceID);
}
-static struct pipe_context *
-i965_libdrm_create_context(struct drm_api *api, struct pipe_screen *screen)
-{
- return brw_create_context(screen);
-}
static void
destroy(struct drm_api *api)
@@ -228,7 +223,7 @@ destroy(struct drm_api *api)
struct drm_api i965_libdrm_api =
{
- .create_context = i965_libdrm_create_context,
+ .name = "i965",
.create_screen = i965_libdrm_create_screen,
.texture_from_shared_handle = i965_libdrm_texture_from_shared_handle,
.shared_handle_from_texture = i965_libdrm_shared_handle_from_texture,
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
index a4a72b372d..07be1df87f 100644
--- a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
+++ b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
@@ -1,6 +1,7 @@
#include "i965_drm_winsys.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "i915_drm.h"
#include "intel_bufmgr.h"
diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
index d2b9a1ab31..74501eeb16 100644
--- a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
+++ b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
@@ -469,31 +469,12 @@ fail:
}
-static struct pipe_context *
-xlib_create_i965_context( struct pipe_screen *screen,
- void *context_private )
-{
- struct pipe_context *pipe;
-
- pipe = brw_create_context(screen);
- if (pipe == NULL)
- goto fail;
-
- pipe->priv = context_private;
- return pipe;
-
-fail:
- /* Free stuff here */
- return NULL;
-}
-
struct xm_driver xlib_i965_driver =
{
.create_pipe_screen = xlib_create_i965_screen,
- .create_pipe_context = xlib_create_i965_context,
.display_surface = xlib_i965_display_surface
};
diff --git a/src/gallium/winsys/drm/i965/xorg/Makefile b/src/gallium/winsys/drm/i965/xorg/Makefile
index d91d0006ef..c25726b0bb 100644
--- a/src/gallium/winsys/drm/i965/xorg/Makefile
+++ b/src/gallium/winsys/drm/i965/xorg/Makefile
@@ -1,19 +1,25 @@
-TARGET = modesetting_drv.so
-CFILES = $(wildcard ./*.c)
-OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES))
TOP = ../../../../../..
-include $(TOP)/configs/current
-INCLUDES = \
- $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
- -I../gem \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/mesa \
- -I$(TOP)/include \
- -I$(TOP)/src/egl/main
+GALLIUMDIR = $(TOP)/src/gallium
+
+TARGET = i965g_drv.so
+
+CFILES = $(wildcard ./*.c)
+
+include ${TOP}/configs/current
+
+OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES))
+
+CFLAGS = -DHAVE_CONFIG_H \
+ -g -Wall -Wimplicit-function-declaration -fPIC \
+ $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \
+ -I${GALLIUMDIR}/include \
+ -I${GALLIUMDIR}/drivers \
+ -I${GALLIUMDIR}/auxiliary \
+ -I${TOP}/src/mesa \
+ -I$(TOP)/include \
+ -I$(TOP)/src/egl/main
LIBS = \
$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
@@ -23,20 +29,21 @@ LIBS = \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
$(GALLIUM_AUXILIARIES)
-DRIVER_DEFINES = \
- -DHAVE_CONFIG_H
-
-
+TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
#############################################
+all default: $(TARGET) $(TARGET_STAGING)
-
-all default: $(TARGET)
-
-$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS)
+$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a $(LIBS)
$(TOP)/bin/mklib -noprefix -o $@ \
$(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel
+$(TOP)/$(LIB_DIR)/gallium:
+ mkdir -p $@
+
+$(TARGET_STAGING): $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+ $(INSTALL) $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+
clean:
rm -rf $(OBJECTS) $(TARGET)
@@ -44,14 +51,4 @@ install:
$(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
$(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-
-##############################################
-
-
-.c.o:
- $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@
-
-
-##############################################
-
.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/intel/egl/Makefile b/src/gallium/winsys/drm/intel/egl/Makefile
index 1397e9f729..60d675ca73 100644
--- a/src/gallium/winsys/drm/intel/egl/Makefile
+++ b/src/gallium/winsys/drm/intel/egl/Makefile
@@ -1,29 +1,14 @@
TOP = ../../../../../..
-GALLIUMDIR = ../../../..
include $(TOP)/configs/current
-LIBNAME = EGL_i915.so
+EGL_DRIVER_NAME = i915
+EGL_DRIVER_SOURCES = dummy.c
+EGL_DRIVER_LIBS = -ldrm_intel
-PIPE_DRIVERS = \
- $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
- $(GALLIUMDIR)/winsys/drm/intel/gem/libinteldrm.a \
+EGL_DRIVER_PIPES = \
+ $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
$(TOP)/src/gallium/drivers/trace/libtrace.a \
$(TOP)/src/gallium/drivers/i915/libi915.a
-DRIVER_SOURCES =
-
-C_SOURCES = \
- $(COMMON_GALLIUM_SOURCES) \
- $(DRIVER_SOURCES)
-
-DRIVER_EXTRAS = -ldrm_intel
-
-ASM_SOURCES =
-
-DRIVER_DEFINES = -I../gem $(shell pkg-config libdrm --atleast-version=2.3.1 \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-
-include ../../Makefile.template
-
-symlinks:
+include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/intel/egl/dummy.c b/src/gallium/winsys/drm/intel/egl/dummy.c
new file mode 100644
index 0000000000..4a1bc28b0b
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/egl/dummy.c
@@ -0,0 +1 @@
+/* mklib expects at least one object file */
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c
index 5ed2a10af1..377ed25513 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include "state_tracker/drm_api.h"
@@ -175,18 +176,11 @@ intel_drm_create_screen(struct drm_api *api, int drmFD,
idws->pools.gem = drm_intel_bufmgr_gem_init(idws->fd, idws->max_batch_size);
drm_intel_bufmgr_gem_enable_reuse(idws->pools.gem);
- idws->softpipe = FALSE;
idws->dump_cmd = debug_get_bool_option("INTEL_DUMP_CMD", FALSE);
return i915_create_screen(&idws->base, deviceID);
}
-static struct pipe_context *
-intel_drm_create_context(struct drm_api *api, struct pipe_screen *screen)
-{
- return i915_create_context(screen);
-}
-
static void
destroy(struct drm_api *api)
{
@@ -195,7 +189,8 @@ destroy(struct drm_api *api)
struct drm_api intel_drm_api =
{
- .create_context = intel_drm_create_context,
+ .name = "i915",
+ .driver_name = "i915",
.create_screen = intel_drm_create_screen,
.texture_from_shared_handle = intel_drm_texture_from_shared_handle,
.shared_handle_from_texture = intel_drm_shared_handle_from_texture,
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c b/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c
index e8b58742ab..102faedfea 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c
@@ -1,7 +1,8 @@
#include "intel_drm_winsys.h"
#include "util/u_memory.h"
-#include "pipe/p_refcnt.h"
+#include "util/u_atomic.h"
+#include "util/u_inlines.h"
/**
* Because gem does not have fence's we have to create our own fences.
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h b/src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h
index b4a60563ef..9786ee9365 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h
+++ b/src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h
@@ -17,7 +17,6 @@ struct intel_drm_winsys
{
struct intel_winsys base;
- boolean softpipe;
boolean dump_cmd;
int fd; /**< Drm file discriptor */
diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile
index 0937f68c34..7e95f79d03 100644
--- a/src/gallium/winsys/drm/nouveau/dri/Makefile
+++ b/src/gallium/winsys/drm/nouveau/dri/Makefile
@@ -6,9 +6,6 @@ LIBNAME = nouveau_dri.so
PIPE_DRIVERS = \
$(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
- $(TOP)/src/gallium/drivers/nv04/libnv04.a \
- $(TOP)/src/gallium/drivers/nv10/libnv10.a \
- $(TOP)/src/gallium/drivers/nv20/libnv20.a \
$(TOP)/src/gallium/drivers/nv30/libnv30.a \
$(TOP)/src/gallium/drivers/nv40/libnv40.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a \
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
index e5912ef77f..c814d986b1 100644
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
@@ -2,6 +2,7 @@
#include "pipe/p_state.h"
#include "util/u_format.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "nouveau_drm_api.h"
@@ -54,6 +55,15 @@ static struct dri1_api nouveau_dri1_api = {
nouveau_dri1_front_surface,
};
+static void
+nouveau_drm_destroy_winsys(struct pipe_winsys *s)
+{
+ struct nouveau_winsys *nv_winsys = nouveau_winsys(s);
+ struct nouveau_screen *nv_screen= nouveau_screen(nv_winsys->pscreen);
+ nouveau_device_close(&nv_screen->device);
+ FREE(nv_winsys);
+}
+
static struct pipe_screen *
nouveau_drm_create_screen(struct drm_api *api, int fd,
struct drm_create_screen_arg *arg)
@@ -71,15 +81,6 @@ nouveau_drm_create_screen(struct drm_api *api, int fd,
return NULL;
switch (dev->chipset & 0xf0) {
- case 0x00:
- init = nv04_screen_create;
- break;
- case 0x10:
- init = nv10_screen_create;
- break;
- case 0x20:
- init = nv20_screen_create;
- break;
case 0x30:
init = nv30_screen_create;
break;
@@ -105,6 +106,7 @@ nouveau_drm_create_screen(struct drm_api *api, int fd,
return NULL;
}
ws = &nvws->base;
+ ws->destroy = nouveau_drm_destroy_winsys;
nvws->pscreen = init(ws, dev);
if (!nvws->pscreen) {
@@ -140,58 +142,6 @@ nouveau_drm_create_screen(struct drm_api *api, int fd,
return nvws->pscreen;
}
-static struct pipe_context *
-nouveau_drm_create_context(struct drm_api *api, struct pipe_screen *pscreen)
-{
- struct nouveau_winsys *nvws = nouveau_winsys_screen(pscreen);
- struct pipe_context *(*init)(struct pipe_screen *, unsigned);
- unsigned chipset = nouveau_screen(pscreen)->device->chipset;
- int i;
-
- switch (chipset & 0xf0) {
- case 0x00:
- init = nv04_create;
- break;
- case 0x10:
- init = nv10_create;
- break;
- case 0x20:
- init = nv20_create;
- break;
- case 0x30:
- init = nv30_create;
- break;
- case 0x40:
- case 0x60:
- init = nv40_create;
- break;
- case 0x50:
- case 0x80:
- case 0x90:
- case 0xa0:
- init = nv50_create;
- break;
- default:
- debug_printf("%s: unknown chipset nv%02x\n", __func__, chipset);
- return NULL;
- }
-
- /* Find a free slot for a pipe context, allocate a new one if needed */
- for (i = 0; i < nvws->nr_pctx; i++) {
- if (nvws->pctx[i] == NULL)
- break;
- }
-
- if (i == nvws->nr_pctx) {
- nvws->nr_pctx++;
- nvws->pctx = realloc(nvws->pctx,
- sizeof(*nvws->pctx) * nvws->nr_pctx);
- }
-
- nvws->pctx[i] = init(pscreen, i);
- return nvws->pctx[i];
-}
-
static struct pipe_texture *
nouveau_drm_pt_from_name(struct drm_api *api, struct pipe_screen *pscreen,
struct pipe_texture *templ, const char *name,
@@ -254,8 +204,9 @@ nouveau_drm_handle_from_pt(struct drm_api *api, struct pipe_screen *pscreen,
}
struct drm_api drm_api_hooks = {
+ .name = "nouveau",
+ .driver_name = "nouveau",
.create_screen = nouveau_drm_create_screen,
- .create_context = nouveau_drm_create_context,
.texture_from_shared_handle = nouveau_drm_pt_from_name,
.shared_handle_from_texture = nouveau_drm_name_from_pt,
.local_handle_from_texture = nouveau_drm_handle_from_pt,
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
index e61e0e0957..a91aad7df8 100644
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
@@ -4,7 +4,7 @@
#include "state_tracker/drm_api.h"
#include "state_tracker/dri1_api.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "nouveau_dri.h"
@@ -13,9 +13,6 @@ struct nouveau_winsys {
struct pipe_screen *pscreen;
- unsigned nr_pctx;
- struct pipe_context **pctx;
-
struct pipe_surface *front;
};
diff --git a/src/gallium/winsys/drm/nouveau/egl/Makefile b/src/gallium/winsys/drm/nouveau/egl/Makefile
new file mode 100644
index 0000000000..2c35260332
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/egl/Makefile
@@ -0,0 +1,16 @@
+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/drm/nouveau/drm/libnouveaudrm.a \
+ $(TOP)/src/gallium/drivers/nv30/libnv30.a \
+ $(TOP)/src/gallium/drivers/nv40/libnv40.a \
+ $(TOP)/src/gallium/drivers/nv50/libnv50.a \
+ $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
+
+include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/nouveau/egl/dummy.c b/src/gallium/winsys/drm/nouveau/egl/dummy.c
new file mode 100644
index 0000000000..4a1bc28b0b
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/egl/dummy.c
@@ -0,0 +1 @@
+/* mklib expects at least one object file */
diff --git a/src/gallium/winsys/drm/nouveau/xorg/Makefile b/src/gallium/winsys/drm/nouveau/xorg/Makefile
index f0d3b337e8..179b50230b 100644
--- a/src/gallium/winsys/drm/nouveau/xorg/Makefile
+++ b/src/gallium/winsys/drm/nouveau/xorg/Makefile
@@ -18,9 +18,6 @@ INCLUDES = \
LIBS = \
$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
- $(TOP)/src/gallium/drivers/nv04/libnv04.a \
- $(TOP)/src/gallium/drivers/nv10/libnv10.a \
- $(TOP)/src/gallium/drivers/nv20/libnv20.a \
$(TOP)/src/gallium/drivers/nv30/libnv30.a \
$(TOP)/src/gallium/drivers/nv40/libnv40.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a \
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
index 385fa857b5..3b1c3860a4 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
@@ -33,7 +33,6 @@
#include "radeon_buffer.h"
#include "radeon_bo_gem.h"
-#include "softpipe/sp_texture.h"
#include "r300_context.h"
#include "util/u_format.h"
#include "util/u_math.h"
@@ -51,6 +50,26 @@ static const char *radeon_get_name(struct pipe_winsys *ws)
return "Radeon/GEM+KMS";
}
+static uint32_t radeon_domain_from_usage(unsigned usage)
+{
+ uint32_t domain = 0;
+
+ if (usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
+ domain |= RADEON_GEM_DOMAIN_VRAM;
+ }
+ if (usage & PIPE_BUFFER_USAGE_PIXEL) {
+ domain |= RADEON_GEM_DOMAIN_VRAM;
+ }
+ if (usage & PIPE_BUFFER_USAGE_VERTEX) {
+ domain |= RADEON_GEM_DOMAIN_GTT;
+ }
+ if (usage & PIPE_BUFFER_USAGE_INDEX) {
+ domain |= RADEON_GEM_DOMAIN_GTT;
+ }
+
+ return domain;
+}
+
static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
unsigned alignment,
unsigned usage,
@@ -58,6 +77,7 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
{
struct radeon_winsys *radeon_ws = (struct radeon_winsys *)ws;
struct radeon_pipe_buffer *radeon_buffer;
+ struct pb_desc desc;
uint32_t domain;
radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer);
@@ -70,18 +90,16 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
radeon_buffer->base.usage = usage;
radeon_buffer->base.size = size;
- domain = 0;
-
- if (usage & PIPE_BUFFER_USAGE_PIXEL) {
- domain |= RADEON_GEM_DOMAIN_VRAM;
- }
- if (usage & PIPE_BUFFER_USAGE_VERTEX) {
- domain |= RADEON_GEM_DOMAIN_GTT;
- }
- if (usage & PIPE_BUFFER_USAGE_INDEX) {
- domain |= RADEON_GEM_DOMAIN_GTT;
+ if (usage & PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) {
+ /* Don't bother allocating a BO, as it'll never get to the card. */
+ desc.alignment = alignment;
+ desc.usage = usage;
+ radeon_buffer->pb = pb_malloc_buffer_create(size, &desc);
+ return &radeon_buffer->base;
}
+ domain = radeon_domain_from_usage(usage);
+
radeon_buffer->bo = radeon_bo_open(radeon_ws->priv->bom, 0, size,
alignment, domain, 0);
if (radeon_buffer->bo == NULL) {
@@ -133,8 +151,16 @@ static void radeon_buffer_del(struct pipe_buffer *buffer)
struct radeon_pipe_buffer *radeon_buffer =
(struct radeon_pipe_buffer*)buffer;
- radeon_bo_unref(radeon_buffer->bo);
- free(radeon_buffer);
+ if (radeon_buffer->pb) {
+ pipe_reference_init(&radeon_buffer->pb->base.reference, 0);
+ pb_destroy(radeon_buffer->pb);
+ }
+
+ if (radeon_buffer->bo) {
+ radeon_bo_unref(radeon_buffer->bo);
+ }
+
+ FREE(radeon_buffer);
}
static void *radeon_buffer_map(struct pipe_winsys *ws,
@@ -146,6 +172,10 @@ static void *radeon_buffer_map(struct pipe_winsys *ws,
(struct radeon_pipe_buffer*)buffer;
int write = 0;
+ if (radeon_buffer->pb) {
+ return pb_map(radeon_buffer->pb, flags);
+ }
+
if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
uint32_t domain;
@@ -174,7 +204,31 @@ static void radeon_buffer_unmap(struct pipe_winsys *ws,
struct radeon_pipe_buffer *radeon_buffer =
(struct radeon_pipe_buffer*)buffer;
- radeon_bo_unmap(radeon_buffer->bo);
+ if (radeon_buffer->pb) {
+ pb_unmap(radeon_buffer->pb);
+ } else {
+ radeon_bo_unmap(radeon_buffer->bo);
+ }
+}
+
+static void radeon_buffer_set_tiling(struct radeon_winsys *ws,
+ struct pipe_buffer *buffer,
+ uint32_t pitch,
+ boolean microtiled,
+ boolean macrotiled)
+{
+ struct radeon_pipe_buffer *radeon_buffer =
+ (struct radeon_pipe_buffer*)buffer;
+ uint32_t flags = 0;
+
+ if (microtiled) {
+ flags |= RADEON_BO_FLAGS_MICRO_TILE;
+ }
+ if (macrotiled) {
+ flags |= RADEON_BO_FLAGS_MACRO_TILE;
+ }
+
+ radeon_bo_set_tiling(radeon_buffer->bo, flags, pitch);
}
static void radeon_fence_reference(struct pipe_winsys *ws,
@@ -197,55 +251,6 @@ static int radeon_fence_finish(struct pipe_winsys *ws,
return 0;
}
-static void radeon_display_surface(struct pipe_winsys *pws,
- struct pipe_surface *psurf,
- struct radeon_vl_context *rvl_ctx)
-{
- struct r300_texture *r300tex = (struct r300_texture *)(psurf->texture);
- XImage *ximage;
- void *data;
-
- ximage = XCreateImage(rvl_ctx->display,
- XDefaultVisual(rvl_ctx->display, rvl_ctx->screen),
- XDefaultDepth(rvl_ctx->display, rvl_ctx->screen),
- ZPixmap, 0, /* format, offset */
- NULL, /* data */
- 0, 0, /* size */
- 32, /* bitmap_pad */
- 0); /* bytes_per_line */
-
- assert(ximage->format);
- assert(ximage->bitmap_unit);
-
- data = pws->buffer_map(pws, r300tex->buffer, 0);
-
- /* update XImage's fields */
- ximage->data = data;
- ximage->width = psurf->width;
- ximage->height = psurf->height;
- ximage->bytes_per_line = psurf->width * (ximage->bits_per_pixel >> 3);
-
- XPutImage(rvl_ctx->display, rvl_ctx->drawable,
- XDefaultGC(rvl_ctx->display, rvl_ctx->screen),
- ximage, 0, 0, 0, 0, psurf->width, psurf->height);
-
- XSync(rvl_ctx->display, 0);
-
- ximage->data = NULL;
- XDestroyImage(ximage);
-
- pws->buffer_unmap(pws, r300tex->buffer);
-}
-
-static void radeon_flush_frontbuffer(struct pipe_winsys *pipe_winsys,
- struct pipe_surface *pipe_surface,
- void *context_private)
-{
- struct radeon_vl_context *rvl_ctx;
- rvl_ctx = (struct radeon_vl_context *) context_private;
- radeon_display_surface(pipe_winsys, pipe_surface, rvl_ctx);
-}
-
struct radeon_winsys* radeon_pipe_winsys(int fd)
{
struct radeon_winsys* radeon_ws;
@@ -264,7 +269,7 @@ struct radeon_winsys* radeon_pipe_winsys(int fd)
radeon_ws->priv->fd = fd;
radeon_ws->priv->bom = radeon_bo_manager_gem_ctor(fd);
- radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer;
+ radeon_ws->base.flush_frontbuffer = NULL; /* overriden by co-state tracker */
radeon_ws->base.buffer_create = radeon_buffer_create;
radeon_ws->base.user_buffer_create = radeon_buffer_user_create;
@@ -279,5 +284,7 @@ struct radeon_winsys* radeon_pipe_winsys(int fd)
radeon_ws->base.get_name = radeon_get_name;
+ radeon_ws->buffer_set_tiling = radeon_buffer_set_tiling;
+
return radeon_ws;
}
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
index d7f17564a9..f1c8fc2a3b 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
@@ -32,11 +32,11 @@
#include <stdio.h>
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
-//#include "state_tracker/st_public.h"
+#include "pipebuffer/pb_buffer.h"
#include "util/u_memory.h"
@@ -49,7 +49,10 @@
struct radeon_pipe_buffer {
struct pipe_buffer base;
+ /* Pointer to GPU-backed BO. */
struct radeon_bo *bo;
+ /* Pointer to fallback PB buffer. */
+ struct pb_buffer *pb;
boolean flinked;
uint32_t flink;
};
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
index 05194fc52a..0c0e118ba3 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
@@ -29,8 +29,6 @@
* Joakim Sindholt <opensource@zhasha.com>
*/
-#include "softpipe/sp_winsys.h"
-
#include "radeon_drm.h"
/* Helper function to do the ioctls needed for setup and init. */
@@ -40,12 +38,16 @@ static void do_ioctls(int fd, struct radeon_winsys* winsys)
struct drm_radeon_info info = {0};
int target = 0;
int retval;
+ drmVersionPtr version;
info.value = (unsigned long)&target;
/* We do things in a specific order here.
*
- * First, the PCI ID. This is essential and should return usable numbers
+ * DRM version first. We need to be sure we're running on a KMS chipset.
+ * This is also for some features.
+ *
+ * Then, the PCI ID. This is essential and should return usable numbers
* for all Radeons. If this fails, we probably got handed an FD for some
* non-Radeon card.
*
@@ -55,8 +57,18 @@ static void do_ioctls(int fd, struct radeon_winsys* winsys)
*
* The GEM info is actually bogus on the kernel side, as well as our side
* (see radeon_gem_info_ioctl in radeon_gem.c) but that's alright because
- * we don't actually use the info for anything yet.
- * XXX update the above when we can safely use vram_size instead of vram_visible */
+ * we don't actually use the info for anything yet. */
+
+ version = drmGetVersion(fd);
+ if (version->version_major != 2) {
+ fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "
+ "only compatible with 2.x.x\n", __FUNCTION__,
+ version->version_major, version->version_minor,
+ version->version_patchlevel);
+ drmFreeVersion(version);
+ exit(1);
+ }
+
info.request = RADEON_INFO_DEVICE_ID;
retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
if (retval) {
@@ -92,16 +104,18 @@ static void do_ioctls(int fd, struct radeon_winsys* winsys)
exit(1);
}
winsys->gart_size = gem_info.gart_size;
- /* XXX */
- winsys->vram_size = gem_info.vram_visible;
-}
-
-/* Guess at whether this chipset should use r300g.
- *
- * I believe that this check is valid, but I haven't been exhaustive. */
-static boolean is_r3xx(int pciid)
-{
- return (pciid > 0x3150) && (pciid < 0x796f);
+ winsys->vram_size = gem_info.vram_size;
+
+ debug_printf("radeon: Successfully grabbed chipset info from kernel!\n"
+ "radeon: DRM version: %d.%d.%d ID: 0x%04x GB: %d Z: %d\n"
+ "radeon: GART size: %d MB VRAM size: %d MB\n",
+ version->version_major, version->version_minor,
+ version->version_patchlevel, winsys->pci_id,
+ winsys->gb_pipes, winsys->z_pipes,
+ winsys->gart_size / 1024 / 1024,
+ winsys->vram_size / 1024 / 1024);
+
+ drmFreeVersion(version);
}
/* Create a pipe_screen. */
@@ -112,36 +126,27 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api,
struct radeon_winsys* rwinsys = radeon_pipe_winsys(drmFB);
do_ioctls(drmFB, rwinsys);
- if (!is_r3xx(rwinsys->pci_id) ||
- debug_get_bool_option("RADEON_SOFTPIPE", FALSE)) {
- return softpipe_create_screen((struct pipe_winsys*)rwinsys);
- } else {
+ /* The state tracker can organize a softpipe fallback if no hw
+ * driver is found.
+ */
+ if (is_r3xx(rwinsys->pci_id)) {
radeon_setup_winsys(drmFB, rwinsys);
return r300_create_screen(rwinsys);
- }
-}
-
-/* Create a pipe_context. */
-struct pipe_context* radeon_create_context(struct drm_api* api,
- struct pipe_screen* screen)
-{
- struct radeon_winsys* rwinsys = (struct radeon_winsys*)screen->winsys;
-
- if (!is_r3xx(rwinsys->pci_id) ||
- debug_get_bool_option("RADEON_SOFTPIPE", FALSE)) {
- return softpipe_create(screen);
} else {
- return r300_create_context(screen, rwinsys);
+ FREE(rwinsys);
+ return NULL;
}
}
+
boolean radeon_buffer_from_texture(struct drm_api* api,
+ struct pipe_screen* screen,
struct pipe_texture* texture,
struct pipe_buffer** buffer,
unsigned* stride)
{
/* XXX fix this */
- return r300_get_texture_buffer(texture, buffer, stride);
+ return r300_get_texture_buffer(screen, texture, buffer, stride);
}
/* Create a buffer from a handle. */
@@ -208,7 +213,7 @@ static boolean radeon_shared_handle_from_texture(struct drm_api *api,
struct radeon_pipe_buffer* radeon_buffer;
struct pipe_buffer *buffer = NULL;
- if (!radeon_buffer_from_texture(api, texture, &buffer, stride)) {
+ if (!radeon_buffer_from_texture(api, screen, texture, &buffer, stride)) {
return FALSE;
}
@@ -240,7 +245,7 @@ static boolean radeon_local_handle_from_texture(struct drm_api *api,
unsigned *handle)
{
struct pipe_buffer *buffer = NULL;
- if (!radeon_buffer_from_texture(api, texture, &buffer, stride)) {
+ if (!radeon_buffer_from_texture(api, screen, texture, &buffer, stride)) {
return FALSE;
}
@@ -251,12 +256,19 @@ static boolean radeon_local_handle_from_texture(struct drm_api *api,
return TRUE;
}
+static void radeon_drm_api_destroy(struct drm_api *api)
+{
+ return;
+}
+
struct drm_api drm_api_hooks = {
+ .name = "radeon",
+ .driver_name = "radeon",
.create_screen = radeon_create_screen,
- .create_context = radeon_create_context,
.texture_from_shared_handle = radeon_texture_from_shared_handle,
.shared_handle_from_texture = radeon_shared_handle_from_texture,
.local_handle_from_texture = radeon_local_handle_from_texture,
+ .destroy = radeon_drm_api_destroy,
};
struct drm_api* drm_api_create()
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
index bf0e78138d..8d74cbafc2 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
@@ -52,10 +52,9 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api,
int drmFB,
struct drm_create_screen_arg *arg);
-struct pipe_context* radeon_create_context(struct drm_api* api,
- struct pipe_screen* screen);
boolean radeon_buffer_from_texture(struct drm_api* api,
+ struct pipe_screen* screen,
struct pipe_texture* texture,
struct pipe_buffer** buffer,
unsigned* stride);
@@ -76,4 +75,13 @@ boolean radeon_global_handle_from_buffer(struct drm_api* api,
unsigned* handle);
void radeon_destroy_drm_api(struct drm_api* api);
+
+/* Guess at whether this chipset should use r300g.
+ *
+ * I believe that this check is valid, but I haven't been exhaustive. */
+static INLINE boolean is_r3xx(int pciid)
+{
+ return (pciid > 0x3150) && (pciid < 0x796f);
+}
+
#endif
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
index 0875ee41cb..d759beaba1 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
@@ -81,9 +81,13 @@ static void radeon_write_cs_reloc(struct radeon_winsys* winsys,
uint32_t flags)
{
int retval = 0;
+ struct radeon_pipe_buffer* radeon_buffer =
+ (struct radeon_pipe_buffer*)pbuffer;
- retval = radeon_cs_write_reloc(winsys->priv->cs,
- ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags);
+ assert(!radeon_buffer->pb);
+
+ retval = radeon_cs_write_reloc(winsys->priv->cs, radeon_buffer->bo,
+ rd, wd, flags);
if (retval) {
debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n",
@@ -108,6 +112,11 @@ static void radeon_flush_cs(struct radeon_winsys* winsys)
{
int retval;
+ /* Don't flush a zero-sized CS. */
+ if (!winsys->priv->cs->cdw) {
+ return;
+ }
+
/* Emit the CS. */
retval = radeon_cs_emit(winsys->priv->cs);
if (retval) {
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
index 9edc9e038c..4901080ca7 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
@@ -30,7 +30,7 @@
#ifndef RADEON_WINSYS_H
#define RADEON_WINSYS_H
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
struct radeon_winsys_priv;
@@ -100,6 +100,12 @@ struct radeon_winsys {
void (*flush_cb)(void *), void *data);
void (*reset_bos)(struct radeon_winsys *winsys);
+
+ void (*buffer_set_tiling)(struct radeon_winsys* winsys,
+ struct pipe_buffer* buffer,
+ uint32_t pitch,
+ boolean microtiled,
+ boolean macrotiled);
};
#endif
diff --git a/src/gallium/winsys/drm/radeon/dri/Makefile b/src/gallium/winsys/drm/radeon/dri/Makefile
index a9889444de..eaa3418032 100644
--- a/src/gallium/winsys/drm/radeon/dri/Makefile
+++ b/src/gallium/winsys/drm/radeon/dri/Makefile
@@ -2,7 +2,7 @@
TOP = ../../../../../..
include $(TOP)/configs/current
-LIBNAME = radeon_dri.so
+LIBNAME = radeong_dri.so
MINIGLX_SOURCES =
diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile
index 6a1448d1b9..cd4f9b20f0 100644
--- a/src/gallium/winsys/drm/radeon/egl/Makefile
+++ b/src/gallium/winsys/drm/radeon/egl/Makefile
@@ -1,26 +1,14 @@
TOP = ../../../../../..
-GALLIUMDIR = ../../../..
include $(TOP)/configs/current
-LIBNAME = EGL_r300.so
+EGL_DRIVER_NAME = radeon
+EGL_DRIVER_SOURCES = dummy.c
+EGL_DRIVER_LIBS = -ldrm_radeon
-PIPE_DRIVERS = \
- $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
- $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \
+EGL_DRIVER_PIPES = \
+ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
$(TOP)/src/gallium/drivers/trace/libtrace.a \
$(TOP)/src/gallium/drivers/r300/libr300.a
-DRIVER_SOURCES =
-
-C_SOURCES = \
- $(COMMON_GALLIUM_SOURCES) \
- $(DRIVER_SOURCES)
-
-DRIVER_EXTRAS = -ldrm_radeon
-
-ASM_SOURCES =
-
-include ../../Makefile.template
-
-symlinks:
+include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/radeon/egl/dummy.c b/src/gallium/winsys/drm/radeon/egl/dummy.c
new file mode 100644
index 0000000000..4a1bc28b0b
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/egl/dummy.c
@@ -0,0 +1 @@
+/* mklib expects at least one object file */
diff --git a/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c b/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c
index c3ec24aaf7..fc63081a4c 100644
--- a/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c
+++ b/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c
@@ -124,17 +124,9 @@ error:
}
-static struct pipe_context *
-radeon_hardpipe_context_create(struct pipe_screen *screen)
-{
- /* FIXME: create a radon pipe_context from screen */
-
- return NULL;
-}
const struct st_winsys st_hardpipe_winsys = {
&radeon_hardpipe_screen_create,
- &radeon_hardpipe_context_create,
};
diff --git a/src/gallium/winsys/drm/swrast/Makefile b/src/gallium/winsys/drm/swrast/Makefile
new file mode 100644
index 0000000000..363b89584f
--- /dev/null
+++ b/src/gallium/winsys/drm/swrast/Makefile
@@ -0,0 +1,12 @@
+# src/gallium/winsys/drm/swrast/Makefile
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS)
+
+default install clean:
+ @for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
+ fi \
+ done
diff --git a/src/gallium/winsys/drm/swrast/core/Makefile b/src/gallium/winsys/drm/swrast/core/Makefile
new file mode 100644
index 0000000000..93931ae22b
--- /dev/null
+++ b/src/gallium/winsys/drm/swrast/core/Makefile
@@ -0,0 +1,10 @@
+# src/gallium/winsys/drm/swrast/core/Makefile
+
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = swrastdrm
+
+C_SOURCES = swrast_drm_api.c
+
+include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c b/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c
new file mode 100644
index 0000000000..8c9f80e2c1
--- /dev/null
+++ b/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c
@@ -0,0 +1,13 @@
+#include "state_tracker/drm_api.h"
+
+static struct drm_api swrast_drm_api =
+{
+ .name = "swrast",
+};
+
+struct drm_api *
+drm_api_create()
+{
+ (void) swrast_drm_api;
+ return NULL;
+}
diff --git a/src/gallium/winsys/drm/swrast/egl/Makefile b/src/gallium/winsys/drm/swrast/egl/Makefile
new file mode 100644
index 0000000000..26fe2d2805
--- /dev/null
+++ b/src/gallium/winsys/drm/swrast/egl/Makefile
@@ -0,0 +1,12 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+EGL_DRIVER_NAME = swrast
+EGL_DRIVER_SOURCES = dummy.c
+EGL_DRIVER_LIBS =
+
+EGL_DRIVER_PIPES = \
+ $(TOP)/src/gallium/winsys/drm/swrast/core/libswrastdrm.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
+
+include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/swrast/egl/dummy.c b/src/gallium/winsys/drm/swrast/egl/dummy.c
new file mode 100644
index 0000000000..4a1bc28b0b
--- /dev/null
+++ b/src/gallium/winsys/drm/swrast/egl/dummy.c
@@ -0,0 +1 @@
+/* mklib expects at least one object file */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.c b/src/gallium/winsys/drm/vmware/core/vmw_buffer.c
index b812fb59d3..eca174a6c5 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_buffer.c
+++ b/src/gallium/winsys/drm/vmware/core/vmw_buffer.c
@@ -41,7 +41,7 @@
#include "svga_cmd.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "pipebuffer/pb_buffer.h"
#include "pipebuffer/pb_bufmgr.h"
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.h b/src/gallium/winsys/drm/vmware/core/vmw_buffer.h
index 634bdcabd2..41fb4476da 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_buffer.h
+++ b/src/gallium/winsys/drm/vmware/core/vmw_buffer.h
@@ -27,7 +27,7 @@
#ifndef VMW_BUFFER_H_
#define VMW_BUFFER_H_
-
+#include <assert.h>
#include "pipe/p_compiler.h"
struct SVGAGuestPtr;
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.c b/src/gallium/winsys/drm/vmware/core/vmw_context.c
index b6997588de..90ffc4868f 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_context.c
+++ b/src/gallium/winsys/drm/vmware/core/vmw_context.c
@@ -41,9 +41,18 @@
#define VMW_COMMAND_SIZE (64*1024)
#define VMW_SURFACE_RELOCS (1024)
+#define VMW_REGION_RELOCS (512)
#define VMW_MUST_FLUSH_STACK 8
+struct vmw_region_relocation
+{
+ struct SVGAGuestPtr *where;
+ struct pb_buffer *buffer;
+ /* TODO: put offset info inside where */
+ uint32 offset;
+};
+
struct vmw_svga_winsys_context
{
struct svga_winsys_context base;
@@ -69,10 +78,31 @@ struct vmw_svga_winsys_context
uint32_t staged;
uint32_t reserved;
} surface;
+
+ struct {
+ struct vmw_region_relocation relocs[VMW_REGION_RELOCS];
+ uint32_t size;
+ uint32_t used;
+ uint32_t staged;
+ uint32_t reserved;
+ } region;
struct pb_validate *validate;
uint32_t last_fence;
+
+ /**
+ * The amount of GMR that is referred by the commands currently batched
+ * in the context.
+ */
+ uint32_t seen_regions;
+
+ /**
+ * Whether this context should fail to reserve more commands, not because it
+ * ran out of command space, but because a substantial ammount of GMR was
+ * referred.
+ */
+ boolean preemptive_flush;
};
@@ -96,6 +126,19 @@ vmw_swc_flush(struct svga_winsys_context *swc,
ret = pb_validate_validate(vswc->validate);
assert(ret == PIPE_OK);
if(ret == PIPE_OK) {
+
+ /* Apply relocations */
+ for(i = 0; i < vswc->region.used; ++i) {
+ struct vmw_region_relocation *reloc = &vswc->region.relocs[i];
+ struct SVGAGuestPtr ptr;
+
+ if(!vmw_gmr_bufmgr_region_ptr(reloc->buffer, &ptr))
+ assert(0);
+
+ ptr.offset += reloc->offset;
+
+ *reloc->where = ptr;
+ }
if (vswc->command.used)
vmw_ioctl_command(vswc->vws,
@@ -121,9 +164,18 @@ vmw_swc_flush(struct svga_winsys_context *swc,
vswc->surface.used = 0;
vswc->surface.reserved = 0;
+ for(i = 0; i < vswc->region.used + vswc->region.staged; ++i) {
+ pb_reference(&vswc->region.relocs[i].buffer, NULL);
+ }
+
+ vswc->region.used = 0;
+ vswc->region.reserved = 0;
+
#ifdef DEBUG
vswc->must_flush = FALSE;
#endif
+ vswc->preemptive_flush = FALSE;
+ vswc->seen_regions = 0;
if(pfence)
*pfence = fence;
@@ -151,8 +203,10 @@ vmw_swc_reserve(struct svga_winsys_context *swc,
if(nr_bytes > vswc->command.size)
return NULL;
- if(vswc->command.used + nr_bytes > vswc->command.size ||
- vswc->surface.used + nr_relocs > vswc->surface.size) {
+ if(vswc->preemptive_flush ||
+ vswc->command.used + nr_bytes > vswc->command.size ||
+ vswc->surface.used + nr_relocs > vswc->surface.size ||
+ vswc->region.used + nr_relocs > vswc->region.size) {
#ifdef DEBUG
vswc->must_flush = TRUE;
debug_backtrace_capture(vswc->must_flush_stack, 1,
@@ -163,11 +217,14 @@ vmw_swc_reserve(struct svga_winsys_context *swc,
assert(vswc->command.used + nr_bytes <= vswc->command.size);
assert(vswc->surface.used + nr_relocs <= vswc->surface.size);
-
+ assert(vswc->region.used + nr_relocs <= vswc->region.size);
+
vswc->command.reserved = nr_bytes;
vswc->surface.reserved = nr_relocs;
vswc->surface.staged = 0;
-
+ vswc->region.reserved = nr_relocs;
+ vswc->region.staged = 0;
+
return vswc->command.buffer + vswc->command.used;
}
@@ -206,20 +263,41 @@ vmw_swc_region_relocation(struct svga_winsys_context *swc,
unsigned flags)
{
struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
- struct SVGAGuestPtr ptr;
- struct pb_buffer *buf = vmw_pb_buffer(buffer);
+ struct vmw_region_relocation *reloc;
enum pipe_error ret;
+
+ assert(vswc->region.staged < vswc->region.reserved);
- if(!vmw_gmr_bufmgr_region_ptr(buf, &ptr))
- assert(0);
-
- ptr.offset += offset;
+ reloc = &vswc->region.relocs[vswc->region.used + vswc->region.staged];
+ reloc->where = where;
+ pb_reference(&reloc->buffer, vmw_pb_buffer(buffer));
+ reloc->offset = offset;
- *where = ptr;
+ ++vswc->region.staged;
- ret = pb_validate_add_buffer(vswc->validate, buf, flags);
+ ret = pb_validate_add_buffer(vswc->validate, reloc->buffer, flags);
/* TODO: Update pipebuffer to reserve buffers and not fail here */
assert(ret == PIPE_OK);
+
+ /*
+ * Flush preemptively the FIFO commands to keep the GMR working set within
+ * the GMR pool size.
+ *
+ * This is necessary for applications like SPECviewperf that generate huge
+ * amounts of immediate vertex data, so that we don't pile up too much of
+ * that vertex data neither in the guest nor in the host.
+ *
+ * Note that in the current implementation if a region is referred twice in
+ * a command stream, it will be accounted twice. We could detect repeated
+ * regions and count only once, but there is no incentive to do that, since
+ * regions are typically short-lived; always referred in a single command;
+ * and at the worst we just flush the commands a bit sooner, which for the
+ * SVGA virtual device it's not a performance issue since flushing commands
+ * to the FIFO won't cause flushing in the host.
+ */
+ vswc->seen_regions += reloc->buffer->base.size;
+ if(vswc->seen_regions >= VMW_GMR_POOL_SIZE/2)
+ vswc->preemptive_flush = TRUE;
}
@@ -238,6 +316,12 @@ vmw_swc_commit(struct svga_winsys_context *swc)
vswc->surface.used += vswc->surface.staged;
vswc->surface.staged = 0;
vswc->surface.reserved = 0;
+
+ assert(vswc->region.staged <= vswc->region.reserved);
+ assert(vswc->region.used + vswc->region.staged <= vswc->region.size);
+ vswc->region.used += vswc->region.staged;
+ vswc->region.staged = 0;
+ vswc->region.reserved = 0;
}
@@ -246,6 +330,11 @@ vmw_swc_destroy(struct svga_winsys_context *swc)
{
struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
unsigned i;
+
+ for(i = 0; i < vswc->region.used; ++i) {
+ pb_reference(&vswc->region.relocs[i].buffer, NULL);
+ }
+
for(i = 0; i < vswc->surface.used; ++i) {
p_atomic_dec(&vswc->surface.handles[i]->validated);
vmw_svga_winsys_surface_reference(&vswc->surface.handles[i], NULL);
@@ -279,6 +368,7 @@ vmw_svga_winsys_context_create(struct svga_winsys_screen *sws)
vswc->command.size = VMW_COMMAND_SIZE;
vswc->surface.size = VMW_SURFACE_RELOCS;
+ vswc->region.size = VMW_REGION_RELOCS;
vswc->validate = pb_validate_create();
if(!vswc->validate) {
@@ -290,8 +380,3 @@ vmw_svga_winsys_context_create(struct svga_winsys_screen *sws)
}
-struct pipe_context *
-vmw_svga_context_create(struct pipe_screen *screen)
-{
- return svga_context_create(screen);
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.h b/src/gallium/winsys/drm/vmware/core/vmw_context.h
index 305ce9b5be..d4884d24e9 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_context.h
+++ b/src/gallium/winsys/drm/vmware/core/vmw_context.h
@@ -52,8 +52,5 @@ struct pipe_screen;
struct svga_winsys_context *
vmw_svga_winsys_context_create(struct svga_winsys_screen *sws);
-struct pipe_context *
-vmw_svga_context_create(struct pipe_screen *screen);
-
#endif /* VMW_CONTEXT_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.c b/src/gallium/winsys/drm/vmware/core/vmw_screen.c
index 911eec5e25..6cc9b38293 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen.c
+++ b/src/gallium/winsys/drm/vmware/core/vmw_screen.c
@@ -37,13 +37,16 @@
* module.
*/
struct vmw_winsys_screen *
-vmw_winsys_create( int fd )
+vmw_winsys_create( int fd, boolean use_old_scanout_flag )
{
struct vmw_winsys_screen *vws = CALLOC_STRUCT(vmw_winsys_screen);
if (!vws)
goto out_no_vws;
vws->ioctl.drm_fd = fd;
+ vws->use_old_scanout_flag = use_old_scanout_flag;
+ debug_printf("%s: use_old_scanout_flag == %s\n", __FUNCTION__,
+ use_old_scanout_flag ? "true" : "false");
if (!vmw_ioctl_init(vws))
goto out_no_ioctl;
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.h b/src/gallium/winsys/drm/vmware/core/vmw_screen.h
index a875107370..d3f2c2c7f5 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen.h
+++ b/src/gallium/winsys/drm/vmware/core/vmw_screen.h
@@ -40,6 +40,10 @@
#include "svga_winsys.h"
+
+#define VMW_GMR_POOL_SIZE (16*1024*1024)
+
+
struct pb_manager;
struct vmw_region;
@@ -48,6 +52,8 @@ struct vmw_winsys_screen
{
struct svga_winsys_screen base;
+ boolean use_old_scanout_flag;
+
struct {
volatile uint32_t *fifo_map;
uint64_t last_fence;
@@ -127,7 +133,7 @@ boolean vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws);
void vmw_ioctl_cleanup(struct vmw_winsys_screen *vws);
void vmw_pools_cleanup(struct vmw_winsys_screen *vws);
-struct vmw_winsys_screen *vmw_winsys_create(int fd);
+struct vmw_winsys_screen *vmw_winsys_create(int fd, boolean use_old_scanout_flag);
void vmw_winsys_destroy(struct vmw_winsys_screen *sws);
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
index 5995eee34b..1dcbc419db 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
+++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
@@ -25,8 +25,9 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
+#include "util/u_format.h"
#include "vmw_screen.h"
#include "trace/tr_drm.h"
@@ -49,7 +50,8 @@ static struct dri1_api_version ddx_compat = { 0, 0, 0 };
static struct dri1_api_version dri_required = { 4, 0, 0 };
static struct dri1_api_version dri_compat = { 4, 0, 0 };
static struct dri1_api_version drm_required = { 0, 1, 0 };
-static struct dri1_api_version drm_compat = { 0, 0, 0 };
+static struct dri1_api_version drm_compat = { 1, 0, 0 };
+static struct dri1_api_version drm_scanout = { 0, 9, 0 };
static boolean
vmw_dri1_check_version(const struct dri1_api_version *cur,
@@ -84,6 +86,29 @@ vmw_drm_create_screen(struct drm_api *drm_api,
struct vmw_winsys_screen *vws;
struct pipe_screen *screen;
struct dri1_create_screen_arg *dri1;
+ boolean use_old_scanout_flag = FALSE;
+
+ if (!arg || arg->mode == DRM_CREATE_NORMAL) {
+ struct dri1_api_version drm_ver;
+ drmVersionPtr ver;
+
+ ver = drmGetVersion(fd);
+ if (ver == NULL)
+ return NULL;
+
+ drm_ver.major = ver->version_major;
+ drm_ver.minor = ver->version_minor;
+ drm_ver.patch_level = 0; /* ??? */
+
+ drmFreeVersion(ver);
+ if (!vmw_dri1_check_version(&drm_ver, &drm_required,
+ &drm_compat, "vmwgfx drm driver"))
+ return NULL;
+
+ if (!vmw_dri1_check_version(&drm_ver, &drm_scanout,
+ &drm_compat, "use old scanout field (not a error)"))
+ use_old_scanout_flag = TRUE;
+ }
if (arg != NULL) {
switch (arg->mode) {
@@ -100,6 +125,9 @@ vmw_drm_create_screen(struct drm_api *drm_api,
if (!vmw_dri1_check_version(&dri1->drm_version, &drm_required,
&drm_compat, "vmwgfx drm driver"))
return NULL;
+ if (!vmw_dri1_check_version(&dri1->drm_version, &drm_scanout,
+ &drm_compat, "use old scanout field (not a error)"))
+ use_old_scanout_flag = TRUE;
dri1->api = &dri1_api_hooks;
break;
default:
@@ -107,7 +135,7 @@ vmw_drm_create_screen(struct drm_api *drm_api,
}
}
- vws = vmw_winsys_create( fd );
+ vws = vmw_winsys_create( fd, use_old_scanout_flag );
if (!vws)
goto out_no_vws;
@@ -220,22 +248,19 @@ vmw_dri1_present_locked(struct pipe_context *locked_pipe,
vmw_svga_winsys_surface_reference(&vsrf, NULL);
}
-/**
- * FIXME: We'd probably want to cache these buffers in the
- * screen, based on handle.
- */
-
-static struct pipe_buffer *
-vmw_drm_buffer_from_handle(struct drm_api *drm_api,
- struct pipe_screen *screen,
- const char *name,
- unsigned handle)
+static struct pipe_texture *
+vmw_drm_texture_from_handle(struct drm_api *drm_api,
+ struct pipe_screen *screen,
+ struct pipe_texture *templat,
+ const char *name,
+ unsigned stride,
+ unsigned handle)
{
struct vmw_svga_winsys_surface *vsrf;
struct svga_winsys_surface *ssrf;
struct vmw_winsys_screen *vws =
vmw_winsys_screen(svga_winsys_screen(screen));
- struct pipe_buffer *buf;
+ struct pipe_texture *tex;
union drm_vmw_surface_reference_arg arg;
struct drm_vmw_surface_arg *req = &arg.req;
struct drm_vmw_surface_create_req *rep = &arg.rep;
@@ -282,43 +307,28 @@ vmw_drm_buffer_from_handle(struct drm_api *drm_api,
pipe_reference_init(&vsrf->refcnt, 1);
p_atomic_set(&vsrf->validated, 0);
+ vsrf->screen = vws;
vsrf->sid = handle;
ssrf = svga_winsys_surface(vsrf);
- buf = svga_screen_buffer_wrap_surface(screen, rep->format, ssrf);
- if (!buf)
+ tex = svga_screen_texture_wrap_surface(screen, templat, rep->format, ssrf);
+ if (!tex)
vmw_svga_winsys_surface_reference(&vsrf, NULL);
- return buf;
+ return tex;
out_mip:
vmw_ioctl_surface_destroy(vws, handle);
return NULL;
}
-static struct pipe_texture *
-vmw_drm_texture_from_handle(struct drm_api *drm_api,
- struct pipe_screen *screen,
- struct pipe_texture *templat,
- const char *name,
- unsigned stride,
- unsigned handle)
-{
- struct pipe_buffer *buffer;
- buffer = vmw_drm_buffer_from_handle(drm_api, screen, name, handle);
-
- if (!buffer)
- return NULL;
-
- return screen->texture_blanket(screen, templat, &stride, buffer);
-}
-
static boolean
-vmw_drm_handle_from_buffer(struct drm_api *drm_api,
+vmw_drm_handle_from_texture(struct drm_api *drm_api,
struct pipe_screen *screen,
- struct pipe_buffer *buffer,
+ struct pipe_texture *texture,
+ unsigned *stride,
unsigned *handle)
{
struct svga_winsys_surface *surface =
- svga_screen_buffer_get_winsys_surface(buffer);
+ svga_screen_texture_get_winsys_surface(texture);
struct vmw_svga_winsys_surface *vsrf;
if (!surface)
@@ -326,31 +336,13 @@ vmw_drm_handle_from_buffer(struct drm_api *drm_api,
vsrf = vmw_svga_winsys_surface(surface);
*handle = vsrf->sid;
+ *stride = util_format_get_nblocksx(texture->format, texture->width0) *
+ util_format_get_blocksize(texture->format);
+
vmw_svga_winsys_surface_reference(&vsrf, NULL);
return TRUE;
}
-static boolean
-vmw_drm_handle_from_texture(struct drm_api *drm_api,
- struct pipe_screen *screen,
- struct pipe_texture *texture,
- unsigned *stride,
- unsigned *handle)
-{
- struct pipe_buffer *buffer;
-
- if (!svga_screen_buffer_from_texture(texture, &buffer, stride))
- return FALSE;
-
- return vmw_drm_handle_from_buffer(drm_api, screen, buffer, handle);
-}
-
-static struct pipe_context*
-vmw_drm_create_context(struct drm_api *drm_api,
- struct pipe_screen *screen)
-{
- return vmw_svga_context_create(screen);
-}
static struct dri1_api dri1_api_hooks = {
.front_srf_locked = NULL,
@@ -358,8 +350,9 @@ static struct dri1_api dri1_api_hooks = {
};
static struct drm_api vmw_drm_api_hooks = {
+ .name = "vmwgfx",
+ .driver_name = "vmwgfx",
.create_screen = vmw_drm_create_screen,
- .create_context = vmw_drm_create_context,
.texture_from_shared_handle = vmw_drm_texture_from_handle,
.shared_handle_from_texture = vmw_drm_handle_from_texture,
.local_handle_from_texture = vmw_drm_handle_from_texture,
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c
index ccd0b418a1..5d81fa8c4a 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c
+++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c
@@ -57,6 +57,12 @@ struct vmw_region
uint32_t size;
};
+/* XXX: This isn't a real hardware flag, but just a hack for kernel to
+ * know about primary surfaces. In newer versions of the kernel
+ * interface the driver uses a special field.
+ */
+#define SVGA3D_SURFACE_HINT_SCANOUT (1 << 9)
+
static void
vmw_check_last_cmd(struct vmw_winsys_screen *vws)
{
@@ -169,7 +175,17 @@ vmw_ioctl_surface_create(struct vmw_winsys_screen *vws,
vmw_printf("%s flags %d format %d\n", __FUNCTION__, flags, format);
memset(&s_arg, 0, sizeof(s_arg));
- req->flags = (uint32_t) flags;
+ if (vws->use_old_scanout_flag &&
+ (flags & SVGA3D_SURFACE_HINT_SCANOUT)) {
+ req->flags = (uint32_t) flags;
+ req->scanout = false;
+ } else if (flags & SVGA3D_SURFACE_HINT_SCANOUT) {
+ req->flags = (uint32_t) (flags & ~SVGA3D_SURFACE_HINT_SCANOUT);
+ req->scanout = true;
+ } else {
+ req->flags = (uint32_t) flags;
+ req->scanout = false;
+ }
req->format = (uint32_t) format;
req->shareable = 1;
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c
index b1c24b0cb6..b9823d7857 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c
+++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c
@@ -53,14 +53,32 @@ vmw_pools_init(struct vmw_winsys_screen *vws)
goto error;
vws->pools.gmr_mm = mm_bufmgr_create(vws->pools.gmr,
- 16*1024*1024,
+ VMW_GMR_POOL_SIZE,
12 /* 4096 alignment */);
if(!vws->pools.gmr_mm)
goto error;
+ /*
+ * GMR buffers are typically shortlived, but it's possible that at a given
+ * instance a buffer is mapped. So to avoid stalling we tell pipebuffer to
+ * forbid creation of buffers beyond half the GMR pool size,
+ *
+ * XXX: It is unclear weather we want to limit the total amount of temporary
+ * malloc memory used to backup unvalidated GMR buffers. On one hand it is
+ * preferrable to fail an allocation than exhausting the guest memory with
+ * temporary data, but on the other hand it is possible that a stupid
+ * application creates large vertex buffers and does not use them for a long
+ * time -- since the svga pipe driver only emits the DMA uploads when a
+ * buffer is used for drawing this would effectively disabling swapping GMR
+ * buffers to memory. So far, the preemptively flush already seems to keep
+ * total allocated memory within relatively small numbers, so we don't
+ * limit.
+ */
vws->pools.gmr_fenced = fenced_bufmgr_create(
vws->pools.gmr_mm,
- vmw_fence_ops_create(vws));
+ vmw_fence_ops_create(vws),
+ VMW_GMR_POOL_SIZE/2,
+ ~0);
#ifdef DEBUG
vws->pools.gmr_fenced = pb_debug_manager_create(vws->pools.gmr_fenced,
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c
index d7d008859b..2b4e80f003 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c
+++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c
@@ -36,7 +36,7 @@
#include "svga_cmd.h"
#include "svga3d_caps.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "pipebuffer/pb_buffer.h"
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_surface.h b/src/gallium/winsys/drm/vmware/core/vmw_surface.h
index 340cc1532e..3d61595c28 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_surface.h
+++ b/src/gallium/winsys/drm/vmware/core/vmw_surface.h
@@ -36,8 +36,8 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_atomic.h"
-#include "pipe/p_refcnt.h"
+#include "util/u_atomic.h"
+#include "util/u_inlines.h"
#define VMW_MAX_PRESENTS 3
@@ -45,7 +45,7 @@
struct vmw_svga_winsys_surface
{
- struct pipe_atomic validated;
+ int32_t validated; /* atomic */
struct pipe_reference refcnt;
struct vmw_winsys_screen *screen;
diff --git a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
index 2be7e1249b..1457966db8 100644
--- a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
+++ b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
@@ -68,7 +68,8 @@
#define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
#define DRM_VMW_PARAM_3D 2
#define DRM_VMW_PARAM_FIFO_OFFSET 3
-
+#define DRM_VMW_PARAM_HW_CAPS 4
+#define DRM_VMW_PARAM_FIFO_CAPS 5
/**
* struct drm_vmw_getparam_arg
@@ -87,49 +88,6 @@ struct drm_vmw_getparam_arg {
/*************************************************************************/
/**
- * DRM_VMW_EXTENSION - Query device extensions.
- */
-
-/**
- * struct drm_vmw_extension_rep
- *
- * @exists: The queried extension exists.
- * @driver_ioctl_offset: Ioctl number of the first ioctl in the extension.
- * @driver_sarea_offset: Offset to any space in the DRI SAREA
- * used by the extension.
- * @major: Major version number of the extension.
- * @minor: Minor version number of the extension.
- * @pl: Patch level version number of the extension.
- *
- * Output argument to the DRM_VMW_EXTENSION Ioctl.
- */
-
-struct drm_vmw_extension_rep {
- int32_t exists;
- uint32_t driver_ioctl_offset;
- uint32_t driver_sarea_offset;
- uint32_t major;
- uint32_t minor;
- uint32_t pl;
- uint32_t pad64;
-};
-
-/**
- * union drm_vmw_extension_arg
- *
- * @extension - Ascii name of the extension to be queried. //In
- * @rep - Reply as defined above. //Out
- *
- * Argument to the DRM_VMW_EXTENSION Ioctl.
- */
-
-union drm_vmw_extension_arg {
- char extension[DRM_VMW_EXT_NAME_LEN];
- struct drm_vmw_extension_rep rep;
-};
-
-/*************************************************************************/
-/**
* DRM_VMW_CREATE_CONTEXT - Create a host context.
*
* Allocates a device unique context id, and queues a create context command
@@ -181,6 +139,8 @@ struct drm_vmw_context_arg {
* The size of the array should equal the total number of mipmap levels.
* @shareable: Boolean whether other clients (as identified by file descriptors)
* may reference this surface.
+ * @scanout: Boolean whether the surface is intended to be used as a
+ * scanout.
*
* Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
* Output data from the DRM_VMW_REF_SURFACE Ioctl.
@@ -192,7 +152,7 @@ struct drm_vmw_surface_create_req {
uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
uint64_t size_addr;
int32_t shareable;
- uint32_t pad64;
+ int32_t scanout;
};
/**
@@ -295,6 +255,9 @@ union drm_vmw_surface_reference_arg {
*
* @commands: User-space address of a command buffer cast to an uint64_t.
* @command-size: Size in bytes of the command buffer.
+ * @throttle-us: Sleep until software is less than @throttle_us
+ * microseconds ahead of hardware. The driver may round this value
+ * to the nearest kernel tick.
* @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
* uint64_t.
*
@@ -304,7 +267,7 @@ union drm_vmw_surface_reference_arg {
struct drm_vmw_execbuf_arg {
uint64_t commands;
uint32_t command_size;
- uint32_t pad64;
+ uint32_t throttle_us;
uint64_t fence_rep;
};
diff --git a/src/gallium/winsys/drm/vmware/egl/Makefile b/src/gallium/winsys/drm/vmware/egl/Makefile
index 8e2980c318..a3e73131c3 100644
--- a/src/gallium/winsys/drm/vmware/egl/Makefile
+++ b/src/gallium/winsys/drm/vmware/egl/Makefile
@@ -1,18 +1,14 @@
-
TOP = ../../../../../..
include $(TOP)/configs/current
-LIBNAME = EGL_svga.so
+EGL_DRIVER_NAME = vmwgfx
+EGL_DRIVER_SOURCES = dummy.c
+EGL_DRIVER_LIBS =
-PIPE_DRIVERS = \
- $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
+EGL_DRIVER_PIPES = \
$(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
$(TOP)/src/gallium/drivers/trace/libtrace.a \
$(TOP)/src/gallium/drivers/svga/libsvga.a
-C_SOURCES = \
- $(COMMON_GALLIUM_SOURCES)
-
-include ../../Makefile.template
-
-symlinks:
+include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/vmware/egl/dummy.c b/src/gallium/winsys/drm/vmware/egl/dummy.c
new file mode 100644
index 0000000000..4a1bc28b0b
--- /dev/null
+++ b/src/gallium/winsys/drm/vmware/egl/dummy.c
@@ -0,0 +1 @@
+/* mklib expects at least one object file */
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c
index b065b96346..ff3b992d07 100644
--- a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c
@@ -649,7 +649,8 @@ vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
return XvBadAlloc;
}
- port->currBuf = ++port->currBuf & (VMWARE_VID_NUM_BUFFERS - 1);
+ if (++(port->currBuf) >= VMWARE_VID_NUM_BUFFERS)
+ port->currBuf = 0;
return Success;
}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c
index 4b208719ca..cd273d091f 100644
--- a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c
@@ -34,10 +34,10 @@
#include "vmw_hook.h"
static void vmw_xorg_identify(int flags);
-static Bool vmw_xorg_pci_probe(DriverPtr driver,
- int entity_num,
- struct pci_device *device,
- intptr_t match_data);
+_X_EXPORT Bool vmw_xorg_pci_probe(DriverPtr driver,
+ int entity_num,
+ struct pci_device *device,
+ intptr_t match_data);
static const struct pci_id_match vmw_xorg_device_match[] = {
{0x15ad, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
@@ -126,7 +126,7 @@ vmw_xorg_identify(int flags)
vmw_xorg_chipsets);
}
-static Bool
+_X_EXPORT Bool
vmw_xorg_pci_probe(DriverPtr driver,
int entity_num, struct pci_device *device, intptr_t match_data)
{
diff --git a/src/gallium/winsys/egl_xlib/Makefile b/src/gallium/winsys/egl_xlib/Makefile
deleted file mode 100644
index 3efb7ed4af..0000000000
--- a/src/gallium/winsys/egl_xlib/Makefile
+++ /dev/null
@@ -1,89 +0,0 @@
-# src/gallium/winsys/egl_xlib/Makefile
-
-# Build softpipe/xlib/EGL driver library/object: "egl_softpipe.so"
-
-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-
-DRIVER_NAME = egl_softpipe.so
-
-
-INCLUDE_DIRS = \
- -I$(TOP)/include \
- -I$(TOP)/src/egl/main \
- -I$(TOP)/src/mesa \
- -I$(TOP)/src/mesa/main \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/src/gallium/auxiliary
-
-WINSYS_SOURCES = \
- egl_xlib.c \
- sw_winsys.c
-
-WINSYS_OBJECTS = $(WINSYS_SOURCES:.c=.o)
-
-
-LIBS = \
- $(GALLIUM_DRIVERS) \
- $(GALLIUM_AUXILIARIES)
-
-# XXX temporary (should create a separate lib with the GL API funcs and
-# mesa code, as done for ES 1.x, 2.x, OpenVG, etc)
-UNUSED_LIBS = \
- $(TOP)/src/mesa/libglapi.a \
- $(TOP)/src/mesa/libmesagallium.a \
-
-
-LOCAL_CFLAGS =
-
-
-.c.o:
- $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@
-
-
-.PHONY: library
-
-
-default: depend library Makefile
-
-
-library: $(TOP)/$(LIB_DIR)/$(DRIVER_NAME)
-
-
-# Make the egl_softpipe.so library
-$(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(WINSYS_OBJECTS) $(LIBS)
- $(TOP)/bin/mklib -o $(DRIVER_NAME) \
- -linker "$(CC)" \
- -noprefix \
- -install $(TOP)/$(LIB_DIR) \
- $(MKLIB_OPTIONS) $(WINSYS_OBJECTS) \
- -Wl,--whole-archive $(LIBS) -Wl,--no-whole-archive
-
-
-depend: $(ALL_SOURCES)
- @ echo "running $(MKDEP)"
- @ rm -f depend # workaround oops on gutsy?!?
- @ touch depend
- @ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \
- > /dev/null 2>/dev/null
-
-
-install: default
- $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
- @if [ -e $(TOP)/$(LIB_DIR) ]; then \
- $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \
- fi
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
-
-clean:
- -rm -f *.o *~ *.bak
-
-
-include depend
diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c
deleted file mode 100644
index 420dccc92c..0000000000
--- a/src/gallium/winsys/egl_xlib/egl_xlib.c
+++ /dev/null
@@ -1,853 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * 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, sub license, 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 (including the
- * next paragraph) 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
- *
- **************************************************************************/
-
-/**
- * EGL / softpipe / xlib winsys module
- *
- * Authors: Brian Paul
- */
-
-
-#include <dlfcn.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_format.h"
-#include "pipe/p_state.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "util/u_memory.h"
-#include "util/u_math.h"
-#include "softpipe/sp_winsys.h"
-#include "softpipe/sp_texture.h"
-
-#include "eglconfig.h"
-#include "eglconfigutil.h"
-#include "eglcontext.h"
-#include "egldisplay.h"
-#include "egldriver.h"
-#include "eglglobals.h"
-#include "egllog.h"
-#include "eglsurface.h"
-
-#include "state_tracker/st_public.h"
-
-#include "sw_winsys.h"
-
-
-/** subclass of _EGLDriver */
-struct xlib_egl_driver
-{
- _EGLDriver Base; /**< base class */
- EGLint apis;
-};
-
-
-/** driver data of _EGLDisplay */
-struct xlib_egl_display
-{
- Display *Dpy;
-
- struct pipe_winsys *winsys;
- struct pipe_screen *screen;
-};
-
-
-/** subclass of _EGLContext */
-struct xlib_egl_context
-{
- _EGLContext Base; /**< base class */
-
- struct pipe_context *pipe; /**< Gallium driver context */
- struct st_context *Context; /**< Mesa/gallium state tracker context */
-};
-
-
-/** subclass of _EGLSurface */
-struct xlib_egl_surface
-{
- _EGLSurface Base; /**< base class */
-
- /* These are set for window surface */
- Display *Dpy; /**< The X Display of the window */
- Window Win; /**< The user-created window ID */
- GC Gc;
- XVisualInfo VisInfo;
-
- struct pipe_winsys *winsys;
-
- struct st_framebuffer *Framebuffer;
-};
-
-
-static void
-flush_frontbuffer(struct pipe_winsys *pws,
- struct pipe_surface *psurf,
- void *context_private);
-
-
-/** cast wrapper */
-static INLINE struct xlib_egl_driver *
-xlib_egl_driver(_EGLDriver *drv)
-{
- return (struct xlib_egl_driver *) drv;
-}
-
-
-static INLINE struct xlib_egl_display *
-xlib_egl_display(_EGLDisplay *dpy)
-{
- return (struct xlib_egl_display *) dpy->DriverData;
-}
-
-
-static INLINE struct xlib_egl_surface *
-lookup_surface(_EGLSurface *surf)
-{
- return (struct xlib_egl_surface *) surf;
-}
-
-
-static INLINE struct xlib_egl_context *
-lookup_context(_EGLContext *ctx)
-{
- return (struct xlib_egl_context *) ctx;
-}
-
-
-/**
- * Create the EGLConfigs. (one per X visual)
- */
-static void
-create_configs(struct xlib_egl_display *xdpy, _EGLDisplay *disp)
-{
- static const EGLint all_apis = (EGL_OPENGL_ES_BIT |
- EGL_OPENGL_ES2_BIT |
- EGL_OPENVG_BIT |
- EGL_OPENGL_BIT);
- XVisualInfo *visInfo, visTemplate;
- int num_visuals, i;
-
- /* get list of all X visuals, create an EGL config for each */
- visTemplate.screen = DefaultScreen(xdpy->Dpy);
- visInfo = XGetVisualInfo(xdpy->Dpy, VisualScreenMask,
- &visTemplate, &num_visuals);
- if (!visInfo) {
- printf("egl_xlib.c: couldn't get any X visuals\n");
- abort();
- }
-
- for (i = 0; i < num_visuals; i++) {
- _EGLConfig *config = calloc(1, sizeof(_EGLConfig));
- int id = i + 1;
- int rbits = util_bitcount(visInfo[i].red_mask);
- int gbits = util_bitcount(visInfo[i].green_mask);
- int bbits = util_bitcount(visInfo[i].blue_mask);
- int abits = bbits == 8 ? 8 : 0;
- int zbits = 24;
- int sbits = 8;
- int visid = visInfo[i].visualid;
-#if defined(__cplusplus) || defined(c_plusplus)
- int vistype = visInfo[i].c_class;
-#else
- int vistype = visInfo[i].class;
-#endif
-
- _eglInitConfig(config, id);
- SET_CONFIG_ATTRIB(config, EGL_BUFFER_SIZE, rbits + gbits + bbits + abits);
- SET_CONFIG_ATTRIB(config, EGL_RED_SIZE, rbits);
- SET_CONFIG_ATTRIB(config, EGL_GREEN_SIZE, gbits);
- SET_CONFIG_ATTRIB(config, EGL_BLUE_SIZE, bbits);
- SET_CONFIG_ATTRIB(config, EGL_ALPHA_SIZE, abits);
- SET_CONFIG_ATTRIB(config, EGL_DEPTH_SIZE, zbits);
- SET_CONFIG_ATTRIB(config, EGL_STENCIL_SIZE, sbits);
- SET_CONFIG_ATTRIB(config, EGL_NATIVE_VISUAL_ID, visid);
- SET_CONFIG_ATTRIB(config, EGL_NATIVE_VISUAL_TYPE, vistype);
- SET_CONFIG_ATTRIB(config, EGL_NATIVE_RENDERABLE, EGL_FALSE);
- SET_CONFIG_ATTRIB(config, EGL_CONFORMANT, all_apis);
- SET_CONFIG_ATTRIB(config, EGL_RENDERABLE_TYPE, all_apis);
- SET_CONFIG_ATTRIB(config, EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT);
- SET_CONFIG_ATTRIB(config, EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE);
- SET_CONFIG_ATTRIB(config, EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE);
-
- _eglAddConfig(disp, config);
- }
-
- XFree(visInfo);
-}
-
-
-/**
- * Called via eglInitialize(), drv->API.Initialize().
- */
-static EGLBoolean
-xlib_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy,
- EGLint *major, EGLint *minor)
-{
- struct xlib_egl_driver *xdrv = xlib_egl_driver(drv);
- struct xlib_egl_display *xdpy;
-
- xdpy = CALLOC_STRUCT(xlib_egl_display);
- if (!xdpy)
- return _eglError(EGL_BAD_ALLOC, "eglInitialize");
-
- xdpy->Dpy = (Display *) dpy->NativeDisplay;
- if (!xdpy->Dpy) {
- xdpy->Dpy = XOpenDisplay(NULL);
- if (!xdpy->Dpy) {
- free(xdpy);
- return EGL_FALSE;
- }
- }
-
- /* create winsys and pipe screen */
- xdpy->winsys = create_sw_winsys();
- if (!xdpy->winsys) {
- free(xdpy);
- return _eglError(EGL_BAD_ALLOC, "eglInitialize");
- }
- xdpy->winsys->flush_frontbuffer = flush_frontbuffer;
- xdpy->screen = softpipe_create_screen(xdpy->winsys);
- if (!xdpy->screen) {
- free(xdpy->winsys);
- free(xdpy);
- return _eglError(EGL_BAD_ALLOC, "eglInitialize");
- }
-
- dpy->DriverData = (void *) xdpy;
- dpy->ClientAPIsMask = xdrv->apis;
-
- create_configs(xdpy, dpy);
-
- /* we're supporting EGL 1.4 */
- *major = 1;
- *minor = 4;
-
- return EGL_TRUE;
-}
-
-
-/**
- * Called via eglTerminate(), drv->API.Terminate().
- */
-static EGLBoolean
-xlib_eglTerminate(_EGLDriver *drv, _EGLDisplay *dpy)
-{
- struct xlib_egl_display *xdpy = xlib_egl_display(dpy);
-
- _eglReleaseDisplayResources(drv, dpy);
- _eglCleanupDisplay(dpy);
-
- xdpy->screen->destroy(xdpy->screen);
- free(xdpy->winsys);
-
- if (!dpy->NativeDisplay)
- XCloseDisplay(xdpy->Dpy);
- free(xdpy);
-
- return EGL_TRUE;
-}
-
-
-static _EGLProc
-xlib_eglGetProcAddress(const char *procname)
-{
- return (_EGLProc) st_get_proc_address(procname);
-}
-
-
-static void
-get_drawable_visual_info(Display *dpy, Drawable d, XVisualInfo *visInfo)
-{
- XWindowAttributes attr;
- XVisualInfo visTemp, *vis;
- int num_visuals;
-
- XGetWindowAttributes(dpy, d, &attr);
-
- visTemp.screen = DefaultScreen(dpy);
- visTemp.visualid = attr.visual->visualid;
- vis = XGetVisualInfo(dpy,
- (VisualScreenMask | VisualIDMask),
- &visTemp, &num_visuals);
- if (vis)
- *visInfo = *vis;
-
- XFree(vis);
-}
-
-
-
-/** Get size of given window */
-static Status
-get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height)
-{
- Window root;
- Status stat;
- int xpos, ypos;
- unsigned int w, h, bw, depth;
- stat = XGetGeometry(dpy, d, &root, &xpos, &ypos, &w, &h, &bw, &depth);
- *width = w;
- *height = h;
- return stat;
-}
-
-
-static void
-check_and_update_buffer_size(struct xlib_egl_surface *surface)
-{
- uint width, height;
- if (surface->Base.Type == EGL_PBUFFER_BIT) {
- width = surface->Base.Width;
- height = surface->Base.Height;
- }
- else {
- get_drawable_size(surface->Dpy, surface->Win, &width, &height);
- }
- st_resize_framebuffer(surface->Framebuffer, width, height);
- surface->Base.Width = width;
- surface->Base.Height = height;
-}
-
-
-
-static void
-display_surface(struct pipe_winsys *pws,
- struct pipe_surface *psurf,
- struct xlib_egl_surface *xsurf)
-{
- struct softpipe_texture *spt = softpipe_texture(psurf->texture);
- XImage *ximage;
- void *data;
-
- if (xsurf->Base.Type == EGL_PBUFFER_BIT)
- return;
-
- ximage = XCreateImage(xsurf->Dpy,
- xsurf->VisInfo.visual,
- xsurf->VisInfo.depth,
- ZPixmap, 0, /* format, offset */
- NULL, /* data */
- 0, 0, /* size */
- 32, /* bitmap_pad */
- 0); /* bytes_per_line */
-
-
- assert(ximage->format);
- assert(ximage->bitmap_unit);
-
- data = pws->buffer_map(pws, spt->buffer, 0);
-
- /* update XImage's fields */
- ximage->data = data;
- ximage->width = psurf->width;
- ximage->height = psurf->height;
- ximage->bytes_per_line = spt->stride[psurf->level];
-
- XPutImage(xsurf->Dpy, xsurf->Win, xsurf->Gc,
- ximage, 0, 0, 0, 0, psurf->width, psurf->height);
-
- XSync(xsurf->Dpy, 0);
-
- ximage->data = NULL;
- XDestroyImage(ximage);
-
- pws->buffer_unmap(pws, spt->buffer);
-}
-
-
-
-/** Display gallium surface in X window */
-static void
-flush_frontbuffer(struct pipe_winsys *pws,
- struct pipe_surface *psurf,
- void *context_private)
-{
- struct xlib_egl_surface *xsurf = (struct xlib_egl_surface *) context_private;
- display_surface(pws, psurf, xsurf);
-}
-
-
-
-/**
- * Called via eglCreateContext(), drv->API.CreateContext().
- */
-static _EGLContext *
-xlib_eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
- _EGLContext *share_list, const EGLint *attrib_list)
-{
- struct xlib_egl_display *xdpy = xlib_egl_display(dpy);
- struct xlib_egl_context *ctx;
- struct st_context *share_ctx = NULL; /* XXX fix */
- __GLcontextModes visual;
-
- ctx = CALLOC_STRUCT(xlib_egl_context);
- if (!ctx)
- return NULL;
-
- /* let EGL lib init the common stuff */
- if (!_eglInitContext(drv, &ctx->Base, conf, attrib_list)) {
- free(ctx);
- return NULL;
- }
-
- /* API-dependent context creation */
- switch (ctx->Base.ClientAPI) {
- case EGL_OPENVG_API:
- case EGL_OPENGL_ES_API:
- _eglLog(_EGL_DEBUG, "Create Context for ES version %d\n",
- ctx->Base.ClientVersion);
- /* fall-through */
- case EGL_OPENGL_API:
- /* create a softpipe context */
- ctx->pipe = softpipe_create(xdpy->screen);
- /* Now do xlib / state tracker inits here */
- _eglConfigToContextModesRec(conf, &visual);
- ctx->Context = st_create_context(ctx->pipe, &visual, share_ctx);
- break;
- default:
- _eglError(EGL_BAD_MATCH, "eglCreateContext(unsupported API)");
- free(ctx);
- return NULL;
- }
-
- return &ctx->Base;
-}
-
-
-static EGLBoolean
-xlib_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
-{
- struct xlib_egl_context *context = lookup_context(ctx);
-
- if (!_eglIsContextBound(&context->Base)) {
- /* API-dependent clean-up */
- switch (context->Base.ClientAPI) {
- case EGL_OPENGL_ES_API:
- case EGL_OPENVG_API:
- /* fall-through */
- case EGL_OPENGL_API:
- st_destroy_context(context->Context);
- break;
- default:
- assert(0);
- }
- free(context);
- }
- return EGL_TRUE;
-}
-
-
-/**
- * Called via eglMakeCurrent(), drv->API.MakeCurrent().
- */
-static EGLBoolean
-xlib_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy,
- _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx)
-{
- struct xlib_egl_context *context = lookup_context(ctx);
- struct xlib_egl_surface *draw_surf = lookup_surface(draw);
- struct xlib_egl_surface *read_surf = lookup_surface(read);
- struct st_context *oldcontext = NULL;
- _EGLContext *oldctx;
-
- oldctx = _eglGetCurrentContext();
- if (oldctx && _eglIsContextLinked(oldctx))
- oldcontext = st_get_current();
-
- if (!_eglMakeCurrent(drv, dpy, draw, read, ctx))
- return EGL_FALSE;
-
- /* Flush before switching context. Check client API? */
- if (oldcontext)
- st_flush(oldcontext, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
- st_make_current((context ? context->Context : NULL),
- (draw_surf ? draw_surf->Framebuffer : NULL),
- (read_surf ? read_surf->Framebuffer : NULL));
-
- if (draw_surf)
- check_and_update_buffer_size(draw_surf);
- if (read_surf && read_surf != draw_surf)
- check_and_update_buffer_size(draw_surf);
-
- return EGL_TRUE;
-}
-
-
-static enum pipe_format
-choose_color_format(const __GLcontextModes *visual)
-{
- if (visual->redBits == 8 &&
- visual->greenBits == 8 &&
- visual->blueBits == 8 &&
- visual->alphaBits == 8) {
- /* XXX this really also depends on the ordering of R,G,B,A */
- return PIPE_FORMAT_A8R8G8B8_UNORM;
- }
- else {
- assert(0);
- return PIPE_FORMAT_NONE;
- }
-}
-
-
-static enum pipe_format
-choose_depth_format(const __GLcontextModes *visual)
-{
- if (visual->depthBits > 0)
- return PIPE_FORMAT_S8Z24_UNORM;
- else
- return PIPE_FORMAT_NONE;
-}
-
-
-static enum pipe_format
-choose_stencil_format(const __GLcontextModes *visual)
-{
- if (visual->stencilBits > 0)
- return PIPE_FORMAT_S8Z24_UNORM;
- else
- return PIPE_FORMAT_NONE;
-}
-
-
-/**
- * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
- */
-static _EGLSurface *
-xlib_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
- NativeWindowType window, const EGLint *attrib_list)
-{
- struct xlib_egl_display *xdpy = xlib_egl_display(disp);
- struct xlib_egl_surface *surf;
- __GLcontextModes visual;
- uint width, height;
-
- surf = CALLOC_STRUCT(xlib_egl_surface);
- if (!surf)
- return NULL;
-
- /* Let EGL lib init the common stuff */
- if (!_eglInitSurface(drv, &surf->Base, EGL_WINDOW_BIT,
- conf, attrib_list)) {
- free(surf);
- return NULL;
- }
-
- /*
- * Now init the Xlib and gallium stuff
- */
- surf->Win = (Window) window; /* The X window ID */
- surf->Dpy = xdpy->Dpy; /* The X display */
- surf->Gc = XCreateGC(surf->Dpy, surf->Win, 0, NULL);
-
- surf->winsys = xdpy->winsys;
-
- _eglConfigToContextModesRec(conf, &visual);
- get_drawable_size(surf->Dpy, surf->Win, &width, &height);
- get_drawable_visual_info(surf->Dpy, surf->Win, &surf->VisInfo);
-
- surf->Base.Width = width;
- surf->Base.Height = height;
-
- /* Create GL statetracker framebuffer */
- surf->Framebuffer = st_create_framebuffer(&visual,
- choose_color_format(&visual),
- choose_depth_format(&visual),
- choose_stencil_format(&visual),
- width, height,
- (void *) surf);
-
- st_resize_framebuffer(surf->Framebuffer, width, height);
-
- return &surf->Base;
-}
-
-
-static _EGLSurface *
-xlib_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
- const EGLint *attrib_list)
-{
- struct xlib_egl_display *xdpy = xlib_egl_display(disp);
- struct xlib_egl_surface *surf;
- __GLcontextModes visual;
- uint width, height;
- EGLBoolean bind_texture;
-
- surf = CALLOC_STRUCT(xlib_egl_surface);
- if (!surf) {
- _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface");
- return NULL;
- }
-
- if (!_eglInitSurface(drv, &surf->Base, EGL_PBUFFER_BIT,
- conf, attrib_list)) {
- free(surf);
- return NULL;
- }
- if (surf->Base.Width < 0 || surf->Base.Height < 0) {
- _eglError(EGL_BAD_PARAMETER, "eglCreatePbufferSurface");
- free(surf);
- return NULL;
- }
-
- bind_texture = (surf->Base.TextureFormat != EGL_NO_TEXTURE);
- width = (uint) surf->Base.Width;
- height = (uint) surf->Base.Height;
- if ((surf->Base.TextureTarget == EGL_NO_TEXTURE && bind_texture) ||
- (surf->Base.TextureTarget != EGL_NO_TEXTURE && !bind_texture)) {
- _eglError(EGL_BAD_MATCH, "eglCreatePbufferSurface");
- free(surf);
- return NULL;
- }
- /* a framebuffer of zero width or height confuses st */
- if (width == 0 || height == 0) {
- _eglError(EGL_BAD_MATCH, "eglCreatePbufferSurface");
- free(surf);
- return NULL;
- }
- /* no mipmap generation */
- if (surf->Base.MipmapTexture) {
- _eglError(EGL_BAD_MATCH, "eglCreatePbufferSurface");
- free(surf);
- return NULL;
- }
-
- surf->winsys = xdpy->winsys;
-
- _eglConfigToContextModesRec(conf, &visual);
-
- /* Create GL statetracker framebuffer */
- surf->Framebuffer = st_create_framebuffer(&visual,
- choose_color_format(&visual),
- choose_depth_format(&visual),
- choose_stencil_format(&visual),
- width, height,
- (void *) surf);
- st_resize_framebuffer(surf->Framebuffer, width, height);
-
- return &surf->Base;
-}
-
-
-static EGLBoolean
-xlib_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface)
-{
- struct xlib_egl_surface *surf = lookup_surface(surface);
- if (!_eglIsSurfaceBound(&surf->Base)) {
- if (surf->Base.Type != EGL_PBUFFER_BIT)
- XFreeGC(surf->Dpy, surf->Gc);
- st_unreference_framebuffer(surf->Framebuffer);
- free(surf);
- }
- return EGL_TRUE;
-}
-
-
-static EGLBoolean
-xlib_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy,
- _EGLSurface *surface, EGLint buffer)
-{
- struct xlib_egl_surface *xsurf = lookup_surface(surface);
- struct xlib_egl_context *xctx;
- struct pipe_surface *psurf;
- enum pipe_format format;
- int target;
-
- if (!xsurf || xsurf->Base.Type != EGL_PBUFFER_BIT)
- return _eglError(EGL_BAD_SURFACE, "eglBindTexImage");
- if (buffer != EGL_BACK_BUFFER)
- return _eglError(EGL_BAD_PARAMETER, "eglBindTexImage");
- if (xsurf->Base.BoundToTexture)
- return _eglError(EGL_BAD_ACCESS, "eglBindTexImage");
-
- /* this should be updated when choose_color_format is */
- switch (xsurf->Base.TextureFormat) {
- case EGL_TEXTURE_RGB:
- format = PIPE_FORMAT_R8G8B8_UNORM;
- break;
- case EGL_TEXTURE_RGBA:
- format = PIPE_FORMAT_A8R8G8B8_UNORM;
- break;
- default:
- return _eglError(EGL_BAD_MATCH, "eglBindTexImage");
- }
-
- switch (xsurf->Base.TextureTarget) {
- case EGL_TEXTURE_2D:
- target = ST_TEXTURE_2D;
- break;
- default:
- return _eglError(EGL_BAD_MATCH, "eglBindTexImage");
- }
-
- /* flush properly */
- if (eglGetCurrentSurface(EGL_DRAW) == surface) {
- xctx = lookup_context(_eglGetCurrentContext());
- st_flush(xctx->Context, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME,
- NULL);
- }
- else if (_eglIsSurfaceBound(&xsurf->Base)) {
- xctx = lookup_context(xsurf->Base.Binding);
- if (xctx)
- st_finish(xctx->Context);
- }
-
- st_get_framebuffer_surface(xsurf->Framebuffer, ST_SURFACE_BACK_LEFT,
- &psurf);
- st_bind_texture_surface(psurf, target, xsurf->Base.MipmapLevel, format);
- xsurf->Base.BoundToTexture = EGL_TRUE;
-
- return EGL_TRUE;
-}
-
-
-static EGLBoolean
-xlib_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
- EGLint buffer)
-{
- struct xlib_egl_surface *xsurf = lookup_surface(surface);
- struct pipe_surface *psurf;
-
- if (!xsurf || xsurf->Base.Type != EGL_PBUFFER_BIT ||
- !xsurf->Base.BoundToTexture)
- return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage");
- if (buffer != EGL_BACK_BUFFER)
- return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage");
-
- st_get_framebuffer_surface(xsurf->Framebuffer, ST_SURFACE_BACK_LEFT,
- &psurf);
- st_unbind_texture_surface(psurf, ST_TEXTURE_2D, xsurf->Base.MipmapLevel);
- xsurf->Base.BoundToTexture = EGL_FALSE;
-
- return EGL_TRUE;
-}
-
-
-static EGLBoolean
-xlib_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
-{
- struct xlib_egl_surface *xsurf = lookup_surface(draw);
- struct pipe_winsys *pws = xsurf->winsys;
- struct pipe_surface *psurf;
-
- st_get_framebuffer_surface(xsurf->Framebuffer, ST_SURFACE_BACK_LEFT,
- &psurf);
-
- st_notify_swapbuffers(xsurf->Framebuffer);
-
- display_surface(pws, psurf, xsurf);
-
- check_and_update_buffer_size(xsurf);
-
- return EGL_TRUE;
-}
-
-
-/**
- * Determine which API(s) is(are) present by looking for some specific
- * global symbols.
- */
-static EGLint
-find_supported_apis(void)
-{
- EGLint mask = 0;
- void *handle;
-
- handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL);
- if(!handle)
- return mask;
-
- if (dlsym(handle, "st_api_OpenGL_ES1"))
- mask |= EGL_OPENGL_ES_BIT;
-
- if (dlsym(handle, "st_api_OpenGL_ES2"))
- mask |= EGL_OPENGL_ES2_BIT;
-
- if (dlsym(handle, "st_api_OpenGL"))
- mask |= EGL_OPENGL_BIT;
-
- if (dlsym(handle, "st_api_OpenVG"))
- mask |= EGL_OPENVG_BIT;
-
- dlclose(handle);
-
- return mask;
-}
-
-
-static void
-xlib_Unload(_EGLDriver *drv)
-{
- struct xlib_egl_driver *xdrv = xlib_egl_driver(drv);
- free(xdrv);
-}
-
-
-/**
- * This is the main entrypoint into the driver.
- * Called by libEGL to instantiate an _EGLDriver object.
- */
-_EGLDriver *
-_eglMain(const char *args)
-{
- struct xlib_egl_driver *xdrv;
-
- _eglLog(_EGL_INFO, "Entering EGL/Xlib _eglMain(%s)", args);
-
- xdrv = CALLOC_STRUCT(xlib_egl_driver);
- if (!xdrv)
- return NULL;
-
- _eglInitDriverFallbacks(&xdrv->Base);
- xdrv->Base.API.Initialize = xlib_eglInitialize;
- xdrv->Base.API.Terminate = xlib_eglTerminate;
- xdrv->Base.API.GetProcAddress = xlib_eglGetProcAddress;
- xdrv->Base.API.CreateContext = xlib_eglCreateContext;
- xdrv->Base.API.DestroyContext = xlib_eglDestroyContext;
- xdrv->Base.API.CreateWindowSurface = xlib_eglCreateWindowSurface;
- xdrv->Base.API.CreatePbufferSurface = xlib_eglCreatePbufferSurface;
- xdrv->Base.API.DestroySurface = xlib_eglDestroySurface;
- xdrv->Base.API.BindTexImage = xlib_eglBindTexImage;
- xdrv->Base.API.ReleaseTexImage = xlib_eglReleaseTexImage;
- xdrv->Base.API.MakeCurrent = xlib_eglMakeCurrent;
- xdrv->Base.API.SwapBuffers = xlib_eglSwapBuffers;
-
- xdrv->apis = find_supported_apis();
- if (xdrv->apis == 0x0) {
- /* the app isn't directly linked with any EGL-supprted APIs
- * (such as libGLESv2.so) so use an EGL utility to see what
- * APIs might be loaded dynamically on this system.
- */
- xdrv->apis = _eglFindAPIs();
- }
-
- xdrv->Base.Name = "Xlib/softpipe";
- xdrv->Base.Unload = xlib_Unload;
-
- return &xdrv->Base;
-}
diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.c b/src/gallium/winsys/egl_xlib/sw_winsys.c
deleted file mode 100644
index 6ee3ede38c..0000000000
--- a/src/gallium/winsys/egl_xlib/sw_winsys.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * 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, sub license, 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 (including the
- * next paragraph) 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
- *
- **************************************************************************/
-
-/**
- * Totally software-based winsys layer.
- * Note that the one winsys function that we can't implement here
- * is flush_frontbuffer().
- * Whoever uses this code will have to provide that.
- *
- * Authors: Brian Paul
- */
-
-
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-
-#include "sw_winsys.h"
-
-
-
-/** Subclass of pipe_winsys */
-struct sw_pipe_winsys
-{
- struct pipe_winsys Base;
- /* no extra fields for now */
-};
-
-
-/** subclass of pipe_buffer */
-struct sw_pipe_buffer
-{
- struct pipe_buffer Base;
- boolean UserBuffer; /** Is this a user-space buffer? */
- void *Data;
- void *Mapped;
-};
-
-
-/** cast wrapper */
-static INLINE struct sw_pipe_buffer *
-sw_pipe_buffer(struct pipe_buffer *b)
-{
- return (struct sw_pipe_buffer *) b;
-}
-
-
-static const char *
-get_name(struct pipe_winsys *pws)
-{
- return "software";
-}
-
-
-/** Create new pipe_buffer and allocate storage of given size */
-static struct pipe_buffer *
-buffer_create(struct pipe_winsys *pws,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer);
- if (!buffer)
- return NULL;
-
- pipe_reference_init(&buffer->Base.reference, 1);
- buffer->Base.alignment = alignment;
- buffer->Base.usage = usage;
- buffer->Base.size = size;
-
- /* align to 16-byte multiple for Cell */
- buffer->Data = align_malloc(size, MAX2(alignment, 16));
-
- return &buffer->Base;
-}
-
-
-/**
- * Create buffer which wraps user-space data.
- */
-static struct pipe_buffer *
-user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
-{
- struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer);
- if (!buffer)
- return NULL;
-
- pipe_reference_init(&buffer->Base.reference, 1);
- buffer->Base.size = bytes;
- buffer->UserBuffer = TRUE;
- buffer->Data = ptr;
-
- return &buffer->Base;
-}
-
-
-static void *
-buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags)
-{
- struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf);
- buffer->Mapped = buffer->Data;
- return buffer->Mapped;
-}
-
-
-static void
-buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
-{
- struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf);
- buffer->Mapped = NULL;
-}
-
-
-static void
-buffer_destroy(struct pipe_buffer *buf)
-{
- struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf);
-
- if (buffer->Data && !buffer->UserBuffer) {
- align_free(buffer->Data);
- buffer->Data = NULL;
- }
-
- free(buffer);
-}
-
-
-static struct pipe_buffer *
-surface_buffer_create(struct pipe_winsys *winsys,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride)
-{
- const unsigned alignment = 64;
- unsigned nblocksy;
-
- nblocksy = util_format_get_nblocksy(format, height);
- *stride = align(util_format_get_stride(format, width), alignment);
-
- return winsys->buffer_create(winsys, alignment,
- usage,
- *stride * nblocksy);
-}
-
-
-static void
-fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence)
-{
- /* no-op */
-}
-
-
-static int
-fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
- unsigned flag)
-{
- /* no-op */
- return 0;
-}
-
-
-static int
-fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
- unsigned flag)
-{
- /* no-op */
- return 0;
-}
-
-
-/**
- * Create/return a new pipe_winsys object.
- */
-struct pipe_winsys *
-create_sw_winsys(void)
-{
- struct sw_pipe_winsys *ws = CALLOC_STRUCT(sw_pipe_winsys);
- if (!ws)
- return NULL;
-
- /* Fill in this struct with callbacks that pipe will need to
- * communicate with the window system, buffer manager, etc.
- */
- ws->Base.buffer_create = buffer_create;
- ws->Base.user_buffer_create = user_buffer_create;
- ws->Base.buffer_map = buffer_map;
- ws->Base.buffer_unmap = buffer_unmap;
- ws->Base.buffer_destroy = buffer_destroy;
-
- ws->Base.surface_buffer_create = surface_buffer_create;
-
- ws->Base.fence_reference = fence_reference;
- ws->Base.fence_signalled = fence_signalled;
- ws->Base.fence_finish = fence_finish;
-
- ws->Base.flush_frontbuffer = NULL; /* not implemented here! */
-
- ws->Base.get_name = get_name;
-
- return &ws->Base;
-}
diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.h b/src/gallium/winsys/egl_xlib/sw_winsys.h
deleted file mode 100644
index f96c5a14b0..0000000000
--- a/src/gallium/winsys/egl_xlib/sw_winsys.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * 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, sub license, 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 (including the
- * next paragraph) 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
- *
- **************************************************************************/
-
-
-#ifndef SW_WINSYS_H
-#define SW_WINSYS_H
-
-
-struct pipe_winsys;
-
-
-extern struct pipe_winsys *
-create_sw_winsys(void);
-
-
-#endif /* SW_WINSYS_H */
diff --git a/src/gallium/winsys/g3dvl/nouveau/Makefile b/src/gallium/winsys/g3dvl/nouveau/Makefile
index 3965bd949f..f07a7926d6 100644
--- a/src/gallium/winsys/g3dvl/nouveau/Makefile
+++ b/src/gallium/winsys/g3dvl/nouveau/Makefile
@@ -20,14 +20,11 @@ LDFLAGS += -L${DRMDIR}/lib \
-L${DRIDIR}/lib \
-L${GALLIUMDIR}/winsys/drm/nouveau/common \
-L${GALLIUMDIR}/auxiliary \
- -L${GALLIUMDIR}/drivers/nv04 \
- -L${GALLIUMDIR}/drivers/nv10 \
- -L${GALLIUMDIR}/drivers/nv20 \
-L${GALLIUMDIR}/drivers/nv30 \
-L${GALLIUMDIR}/drivers/nv40 \
-L${GALLIUMDIR}/drivers/nv50
-LIBS += -lnouveaudrm -ldriclient -ldrm_nouveau -ldrm -lnv04 -lnv10 -lnv20 -lnv30 -lnv40 -lnv50 -lgallium -lm
+LIBS += -lnouveaudrm -ldriclient -ldrm_nouveau -ldrm -lnv30 -lnv40 -lnv50 -lgallium -lm
#############################################
diff --git a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
index f15bcd37b5..048af62ed3 100644
--- a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
+++ b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
@@ -27,9 +27,9 @@
#include <vl_winsys.h>
#include <X11/Xutil.h>
-#include <pipe/internal/p_winsys_screen.h>
+#include <util/u_simple_screen.h>
#include <pipe/p_state.h>
-#include <pipe/p_inlines.h>
+#include <util/u_inlines.h>
#include <util/u_format.h>
#include <util/u_memory.h>
#include <util/u_math.h>
diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
index 7d076be3a3..03dbd76c37 100644
--- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
+++ b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
@@ -38,7 +38,7 @@
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -216,11 +216,6 @@ no_winsys:
}
-static struct pipe_context *
-gdi_llvmpipe_context_create(struct pipe_screen *screen)
-{
- return llvmpipe_create(screen);
-}
static void
@@ -243,7 +238,6 @@ gdi_llvmpipe_present(struct pipe_screen *screen,
static const struct stw_winsys stw_winsys = {
&gdi_llvmpipe_screen_create,
- &gdi_llvmpipe_context_create,
&gdi_llvmpipe_present,
NULL, /* get_adapter_luid */
NULL, /* shared_surface_open */
diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
index 2ad794c3f0..2078020f8f 100644
--- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
+++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
@@ -38,10 +38,10 @@
#include <windows.h>
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -249,13 +249,6 @@ gdi_softpipe_screen_create(void)
}
-static struct pipe_context *
-gdi_softpipe_context_create(struct pipe_screen *screen)
-{
- return softpipe_create(screen);
-}
-
-
static void
gdi_softpipe_present(struct pipe_screen *screen,
struct pipe_surface *surface,
@@ -291,7 +284,6 @@ gdi_softpipe_present(struct pipe_screen *screen,
static const struct stw_winsys stw_winsys = {
&gdi_softpipe_screen_create,
- &gdi_softpipe_context_create,
&gdi_softpipe_present,
NULL, /* get_adapter_luid */
NULL, /* shared_surface_open */
diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c
index 6dbe05f193..67617a470d 100644
--- a/src/gallium/winsys/xlib/xlib.c
+++ b/src/gallium/winsys/xlib/xlib.c
@@ -47,6 +47,8 @@ enum mode {
MODE_SOFTPIPE
};
+/* advertise OpenGL support */
+PUBLIC const int st_api_OpenGL = 1;
static enum mode get_mode()
{
@@ -103,3 +105,34 @@ extern void (*linker_foo(const unsigned char *procName))()
{
return glXGetProcAddress(procName);
}
+
+
+/**
+ * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
+ * libglapi.a. We need to define them here.
+ */
+#ifdef GLX_INDIRECT_RENDERING
+
+#define GL_GLEXT_PROTOTYPES
+#include "GL/gl.h"
+#include "glapi/glapi.h"
+#include "glapi/glapitable.h"
+#include "glapi/glapidispatch.h"
+
+#if defined(USE_MGL_NAMESPACE)
+#define NAME(func) mgl##func
+#else
+#define NAME(func) gl##func
+#endif
+
+#define DISPATCH(FUNC, ARGS, MESSAGE) \
+ CALL_ ## FUNC(GET_DISPATCH(), ARGS);
+
+#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
+ return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
+
+/* skip normal ones */
+#define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
+#include "glapi/glapitemp.h"
+
+#endif /* GLX_INDIRECT_RENDERING */
diff --git a/src/gallium/winsys/xlib/xlib_brw_context.c b/src/gallium/winsys/xlib/xlib_brw_context.c
index fc9addd09e..22bf41a46f 100644
--- a/src/gallium/winsys/xlib/xlib_brw_context.c
+++ b/src/gallium/winsys/xlib/xlib_brw_context.c
@@ -36,8 +36,8 @@
/* #include "glxheader.h" */
/* #include "xmesaP.h" */
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_inlines.h"
+#include "util/u_simple_screen.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "i965simple/brw_winsys.h"
diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c
index 47ae0519a4..1dc9e8fa11 100644
--- a/src/gallium/winsys/xlib/xlib_cell.c
+++ b/src/gallium/winsys/xlib/xlib_cell.c
@@ -41,10 +41,10 @@
#undef ASSERT
#undef Elements
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -383,35 +383,10 @@ fail:
}
-static struct pipe_context *
-xlib_create_cell_context( struct pipe_screen *screen,
- void *priv )
-{
- struct pipe_context *pipe;
-
-
- /* This takes a cell_winsys pointer, but probably that should be
- * created and stored at screen creation, not context creation.
- *
- * The actual cell_winsys value isn't used for anything, so just
- * passing NULL for now.
- */
- pipe = cell_create_context( screen, NULL);
- if (pipe == NULL)
- goto fail;
-
- pipe->priv = priv;
-
- return pipe;
-
-fail:
- return NULL;
-}
struct xm_driver xlib_cell_driver =
{
.create_pipe_screen = xlib_create_cell_screen,
- .create_pipe_context = xlib_create_cell_context,
.display_surface = xlib_cell_display_surface,
};
@@ -420,7 +395,6 @@ struct xm_driver xlib_cell_driver =
struct xm_driver xlib_cell_driver =
{
.create_pipe_screen = NULL,
- .create_pipe_context = NULL,
.display_surface = NULL,
};
diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c
index 2a434b5fd2..6cebd4c201 100644
--- a/src/gallium/winsys/xlib/xlib_llvmpipe.c
+++ b/src/gallium/winsys/xlib/xlib_llvmpipe.c
@@ -40,10 +40,10 @@
#undef ASSERT
#undef Elements
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -419,25 +419,6 @@ fail:
}
-static struct pipe_context *
-xlib_create_llvmpipe_context( struct pipe_screen *screen,
- void *context_private )
-{
- struct pipe_context *pipe;
-
- pipe = llvmpipe_create(screen);
- if (pipe == NULL)
- goto fail;
-
- pipe->priv = context_private;
- return pipe;
-
-fail:
- /* Free stuff here */
- return NULL;
-}
-
-
static void
xlib_llvmpipe_display_surface(struct xmesa_buffer *xm_buffer,
struct pipe_surface *surf)
@@ -453,7 +434,6 @@ xlib_llvmpipe_display_surface(struct xmesa_buffer *xm_buffer,
struct xm_driver xlib_llvmpipe_driver =
{
.create_pipe_screen = xlib_create_llvmpipe_screen,
- .create_pipe_context = xlib_create_llvmpipe_context,
.display_surface = xlib_llvmpipe_display_surface
};
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c
index f7c0099584..716338aef4 100644
--- a/src/gallium/winsys/xlib/xlib_softpipe.c
+++ b/src/gallium/winsys/xlib/xlib_softpipe.c
@@ -38,10 +38,10 @@
#undef ASSERT
#undef Elements
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -63,7 +63,7 @@ struct xm_buffer
XImage *tempImage;
#ifdef USE_XSHM
- int shm;
+ boolean shm; /** Is this a shared memory buffer? */
XShmSegmentInfo shminfo;
#endif
};
@@ -152,7 +152,7 @@ alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
&b->shminfo,
width, height);
if (b->tempImage == NULL) {
- b->shm = 0;
+ b->shm = FALSE;
return;
}
@@ -169,12 +169,12 @@ alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
mesaXErrorFlag = 0;
XDestroyImage(b->tempImage);
b->tempImage = NULL;
- b->shm = 0;
+ b->shm = FALSE;
(void) XSetErrorHandler(old_handler);
return;
}
- b->shm = 1;
+ b->shm = TRUE;
}
#endif /* USE_XSHM */
@@ -204,6 +204,14 @@ xm_buffer_destroy(struct pipe_buffer *buf)
{
struct xm_buffer *oldBuf = xm_buffer(buf);
+ /*
+ * Note oldBuf->data may point to one of three things:
+ * 1. XShm shared memory image data
+ * 2. User-provided (wrapped) memory, see xm_user_buffer_create()
+ * 3. Regular, malloc'd memory
+ * We need to be careful with freeing that data now.
+ */
+
if (oldBuf->data) {
#ifdef USE_XSHM
if (oldBuf->shminfo.shmid >= 0) {
@@ -213,12 +221,20 @@ xm_buffer_destroy(struct pipe_buffer *buf)
oldBuf->shminfo.shmid = -1;
oldBuf->shminfo.shmaddr = (char *) -1;
}
- else
+
+ if (oldBuf->shm) {
+ oldBuf->data = NULL;
+ }
+
+ if (oldBuf->tempImage) {
+ XDestroyImage(oldBuf->tempImage);
+ oldBuf->tempImage = NULL;
+ }
#endif
- {
- if (!oldBuf->userBuffer) {
- align_free(oldBuf->data);
- }
+
+ if (oldBuf->data && !oldBuf->userBuffer) {
+ /* this was regular malloc'd memory */
+ align_free(oldBuf->data);
}
oldBuf->data = NULL;
@@ -327,10 +343,8 @@ xm_buffer_create(struct pipe_winsys *pws,
buffer->base.usage = usage;
buffer->base.size = size;
- if (buffer->data == NULL) {
- /* align to 16-byte multiple for Cell */
- buffer->data = align_malloc(size, max(alignment, 16));
- }
+ /* align to 16-byte multiple for Cell */
+ buffer->data = align_malloc(size, max(alignment, 16));
return &buffer->base;
}
@@ -484,28 +498,9 @@ fail:
}
-static struct pipe_context *
-xlib_create_softpipe_context( struct pipe_screen *screen,
- void *context_private )
-{
- struct pipe_context *pipe;
-
- pipe = softpipe_create(screen);
- if (pipe == NULL)
- goto fail;
-
- pipe->priv = context_private;
- return pipe;
-
-fail:
- /* Free stuff here */
- return NULL;
-}
-
struct xm_driver xlib_softpipe_driver =
{
.create_pipe_screen = xlib_create_softpipe_screen,
- .create_pipe_context = xlib_create_softpipe_context,
.display_surface = xlib_softpipe_display_surface
};