diff options
Diffstat (limited to 'src/gallium/winsys')
53 files changed, 1578 insertions, 4584 deletions
diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl index 8363de6e975..bc5dd3a53b8 100644 --- a/src/gallium/winsys/drm/Makefile.egl +++ b/src/gallium/winsys/drm/Makefile.egl @@ -13,7 +13,8 @@ EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o) common_LIBS = -ldrm -lm -ldl -x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a +x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a \ + $(TOP)/src/gallium/winsys/xlib/libws_xlib.a x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a @@ -38,8 +39,10 @@ $(EGL_DISPLAY_LIBS): $(TOP)/$(LIB_DIR)/%.so: %.so define mklib-egl $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) $($(1)_ST) \ - $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $($(1)_LIBS) $(EGL_DRIVER_LIBS) + $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \ + -Wl,--start-group $($(1)_ST) $(EGL_DRIVER_PIPES) \ + $(GALLIUM_AUXILIARIES) -Wl,--end-group \ + $($(1)_LIBS) $(EGL_DRIVER_LIBS) endef egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template index 960353a73d9..f4cc0def471 100644 --- a/src/gallium/winsys/drm/Makefile.template +++ b/src/gallium/winsys/drm/Makefile.template @@ -19,30 +19,12 @@ COMMON_BM_SOURCES = \ $(TOP)/src/mesa/drivers/dri/common/dri_bufmgr.c \ $(TOP)/src/mesa/drivers/dri/common/dri_drmpool.c - -ifeq ($(WINDOW_SYSTEM),dri) -WINOBJ= -WINLIB= INCLUDES = $(SHARED_INCLUDES) $(EXPAT_INCLUDES) OBJECTS = \ $(C_SOURCES:.c=.o) \ $(ASM_SOURCES:.S=.o) -else -# miniglx -WINOBJ= -WINLIB=-L$(MESA)/src/glx/mini -MINIGLX_INCLUDES = -I$(TOP)/src/glx/mini -INCLUDES = $(MINIGLX_INCLUDES) \ - $(SHARED_INCLUDES) \ - $(PCIACCESS_CFLAGS) - -OBJECTS = $(C_SOURCES:.c=.o) \ - $(MINIGLX_SOURCES:.c=.o) \ - $(ASM_SOURCES:.S=.o) -endif - ### Include directories SHARED_INCLUDES = \ @@ -74,18 +56,19 @@ SHARED_INCLUDES = \ $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ .S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ ##### TARGETS ##### default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME) -$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template +$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \ + $(TOP)/src/mesa/drivers/dri/Makefile.template $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ $(OBJECTS) $(PIPE_DRIVERS) \ -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \ - $(WINOBJ) $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) + $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) $(TOP)/$(LIB_DIR)/gallium: mkdir -p $@ 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 a061eef0beb..21e82303f72 100644 --- a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c +++ b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c @@ -37,129 +37,6 @@ i965_libdrm_get_device_id(unsigned int *device_id) fclose(file); } -static struct i965_libdrm_buffer * -i965_libdrm_buffer_from_handle(struct i965_libdrm_winsys *idws, - const char* name, unsigned handle) -{ - struct i965_libdrm_buffer *buf = CALLOC_STRUCT(i965_libdrm_buffer); - uint32_t swizzle = 0; - - if (BRW_DUMP) - debug_printf("%s\n", __FUNCTION__); - - if (!buf) - return NULL; - pipe_reference_init(&buf->base.reference, 1); - buf->bo = drm_intel_bo_gem_create_from_name(idws->gem, name, handle); - buf->base.size = buf->bo->size; - buf->base.sws = &idws->base; - buf->flinked = TRUE; - buf->flink = handle; - - - if (!buf->bo) - goto err; - - drm_intel_bo_get_tiling(buf->bo, &buf->tiling, &swizzle); - if (buf->tiling != 0) - buf->map_gtt = TRUE; - - return buf; - -err: - FREE(buf); - return NULL; -} - - -/* - * Exported functions - */ - - -static struct pipe_texture * -i965_libdrm_texture_from_shared_handle(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *template, - const char* name, - unsigned pitch, - unsigned handle) -{ - /* XXX: this is silly -- there should be a way to get directly from - * the "drm_api" struct to ourselves, without peering into - * unrelated code: - */ - struct i965_libdrm_winsys *idws = i965_libdrm_winsys(brw_screen(screen)->sws); - struct i965_libdrm_buffer *buffer; - - if (BRW_DUMP) - debug_printf("%s %s pitch %d handle 0x%x\n", __FUNCTION__, - name, pitch, handle); - - buffer = i965_libdrm_buffer_from_handle(idws, name, handle); - if (!buffer) - return NULL; - - return brw_texture_blanket_winsys_buffer(screen, template, pitch, - buffer->tiling, - &buffer->base); -} - - -static boolean -i965_libdrm_shared_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *pitch, - unsigned *handle) -{ - struct i965_libdrm_buffer *buf = NULL; - struct brw_winsys_buffer *buffer = NULL; - - if (BRW_DUMP) - debug_printf("%s\n", __FUNCTION__); - - if (!brw_texture_get_winsys_buffer(texture, &buffer, pitch)) - return FALSE; - - buf = i965_libdrm_buffer(buffer); - if (!buf->flinked) { - if (drm_intel_bo_flink(buf->bo, &buf->flink)) - return FALSE; - buf->flinked = TRUE; - } - - *handle = buf->flink; - - if (BRW_DUMP) - debug_printf(" -> pitch %d handle 0x%x\n", *pitch, *handle); - - return TRUE; -} - -static boolean -i965_libdrm_local_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *pitch, - unsigned *handle) -{ - struct brw_winsys_buffer *buffer = NULL; - - if (BRW_DUMP) - debug_printf("%s\n", __FUNCTION__); - - if (!brw_texture_get_winsys_buffer(texture, &buffer, pitch)) - return FALSE; - - *handle = i965_libdrm_buffer(buffer)->bo->handle; - - if (BRW_DUMP) - debug_printf(" -> pitch %d handle 0x%x\n", *pitch, *handle); - - return TRUE; -} - static void i965_libdrm_winsys_destroy(struct brw_winsys_screen *iws) { @@ -225,9 +102,6 @@ struct drm_api i965_libdrm_api = { .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, - .local_handle_from_texture = i965_libdrm_local_handle_from_texture, .destroy = destroy, }; 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 07be1df87f0..33a17496b2b 100644 --- a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c +++ b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c @@ -1,4 +1,5 @@ +#include "state_tracker/drm_api.h" #include "i965_drm_winsys.h" #include "util/u_memory.h" #include "util/u_inlines.h" @@ -122,6 +123,78 @@ err: return PIPE_ERROR_OUT_OF_MEMORY; } +static enum pipe_error +i965_libdrm_bo_from_handle(struct brw_winsys_screen *sws, + struct winsys_handle *whandle, + unsigned *stride, + unsigned *tile, + struct brw_winsys_buffer **bo_out) +{ + struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws); + struct i965_libdrm_buffer *buf = CALLOC_STRUCT(i965_libdrm_buffer); + uint32_t swizzle = 0; + + if (BRW_DUMP) + debug_printf("%s\n", __FUNCTION__); + + if (!buf) + return PIPE_ERROR_OUT_OF_MEMORY; + + pipe_reference_init(&buf->base.reference, 1); + buf->bo = drm_intel_bo_gem_create_from_name(idws->gem, "FROM_HANDLE", whandle->handle); + buf->base.size = buf->bo->size; + buf->base.sws = &idws->base; + buf->flinked = TRUE; + buf->flink = whandle->handle; + + + if (!buf->bo) + goto err; + + drm_intel_bo_get_tiling(buf->bo, &buf->tiling, &swizzle); + if (buf->tiling != 0) + buf->map_gtt = TRUE; + + *tile = buf->tiling; + *stride = whandle->stride; + + *bo_out = &buf->base; + return PIPE_OK; + +err: + FREE(buf); + return PIPE_ERROR_OUT_OF_MEMORY; +} + +static enum pipe_error +i965_libdrm_bo_get_handle(struct brw_winsys_buffer *buffer, + struct winsys_handle *whandle, + unsigned stride) +{ + struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer); + + if (BRW_DUMP) + debug_printf("%s\n", __FUNCTION__); + + if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { + if (!buf->flinked) { + if (drm_intel_bo_flink(buf->bo, &buf->flink)) + return PIPE_ERROR_BAD_INPUT; + buf->flinked = TRUE; + } + + whandle->handle = buf->flink; + } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { + whandle->handle = buf->bo->handle; + } else { + assert(!"unknown usage"); + return PIPE_ERROR_BAD_INPUT; + } + + whandle->stride = stride; + return PIPE_OK; +} + static void i965_libdrm_bo_destroy(struct brw_winsys_buffer *buffer) { @@ -415,6 +488,8 @@ void i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws) { idws->base.bo_alloc = i965_libdrm_bo_alloc; + idws->base.bo_from_handle = i965_libdrm_bo_from_handle; + idws->base.bo_get_handle = i965_libdrm_bo_get_handle; idws->base.bo_destroy = i965_libdrm_bo_destroy; idws->base.bo_emit_reloc = i965_libdrm_bo_emit_reloc; idws->base.bo_exec = i965_libdrm_bo_exec; diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c index 74501eeb16f..063e9f600b9 100644 --- a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c +++ b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c @@ -38,7 +38,7 @@ #include "pipe/p_error.h" #include "pipe/p_context.h" -#include "xm_winsys.h" +#include "xm_public.h" #include "i965/brw_winsys.h" #include "i965/brw_screen.h" 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 377ed255131..e3b980a832b 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c +++ b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c @@ -38,99 +38,6 @@ intel_drm_get_device_id(unsigned int *device_id) fclose(file); } -static struct intel_buffer * -intel_drm_buffer_from_handle(struct intel_drm_winsys *idws, - const char* name, unsigned handle) -{ - struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer); - uint32_t tile = 0, swizzle = 0; - - if (!buf) - return NULL; - - buf->magic = 0xDEAD1337; - buf->bo = drm_intel_bo_gem_create_from_name(idws->pools.gem, name, handle); - buf->flinked = TRUE; - buf->flink = handle; - - if (!buf->bo) - goto err; - - drm_intel_bo_get_tiling(buf->bo, &tile, &swizzle); - if (tile != INTEL_TILE_NONE) - buf->map_gtt = TRUE; - - return (struct intel_buffer *)buf; - -err: - FREE(buf); - return NULL; -} - - -/* - * Exported functions - */ - - -static struct pipe_texture * -intel_drm_texture_from_shared_handle(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *templ, - const char* name, - unsigned pitch, - unsigned handle) -{ - struct intel_drm_winsys *idws = intel_drm_winsys(i915_screen(screen)->iws); - struct intel_buffer *buffer; - - buffer = intel_drm_buffer_from_handle(idws, name, handle); - if (!buffer) - return NULL; - - return i915_texture_blanket_intel(screen, templ, pitch, buffer); -} - -static boolean -intel_drm_shared_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *pitch, - unsigned *handle) -{ - struct intel_drm_buffer *buf = NULL; - struct intel_buffer *buffer = NULL; - if (!i915_get_texture_buffer_intel(texture, &buffer, pitch)) - return FALSE; - - buf = intel_drm_buffer(buffer); - if (!buf->flinked) { - if (drm_intel_bo_flink(buf->bo, &buf->flink)) - return FALSE; - buf->flinked = TRUE; - } - - *handle = buf->flink; - - return TRUE; -} - -static boolean -intel_drm_local_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *pitch, - unsigned *handle) -{ - struct intel_buffer *buffer = NULL; - if (!i915_get_texture_buffer_intel(texture, &buffer, pitch)) - return FALSE; - - *handle = intel_drm_buffer(buffer)->bo->handle; - - return TRUE; -} - static void intel_drm_winsys_destroy(struct intel_winsys *iws) { @@ -192,9 +99,6 @@ struct drm_api intel_drm_api = .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, - .local_handle_from_texture = intel_drm_local_handle_from_texture, .destroy = destroy, }; diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c b/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c index ac4dd6e00e9..cb4f92a3b17 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c +++ b/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c @@ -1,4 +1,5 @@ +#include "state_tracker/drm_api.h" #include "intel_drm_winsys.h" #include "util/u_memory.h" @@ -52,6 +53,66 @@ err: return NULL; } +static struct intel_buffer * +intel_drm_buffer_from_handle(struct intel_winsys *iws, + struct winsys_handle *whandle, + unsigned *stride) +{ + struct intel_drm_winsys *idws = intel_drm_winsys(iws); + struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer); + uint32_t tile = 0, swizzle = 0; + + if (!buf) + return NULL; + + buf->magic = 0xDEAD1337; + buf->bo = drm_intel_bo_gem_create_from_name(idws->pools.gem, "gallium3d_from_handle", whandle->handle); + buf->flinked = TRUE; + buf->flink = whandle->handle; + + if (!buf->bo) + goto err; + + drm_intel_bo_get_tiling(buf->bo, &tile, &swizzle); + if (tile != INTEL_TILE_NONE) + buf->map_gtt = TRUE; + + *stride = whandle->stride; + + return (struct intel_buffer *)buf; + +err: + FREE(buf); + return NULL; +} + +static boolean +intel_drm_buffer_get_handle(struct intel_winsys *iws, + struct intel_buffer *buffer, + struct winsys_handle *whandle, + unsigned stride) +{ + struct intel_drm_buffer *buf = intel_drm_buffer(buffer); + + if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { + if (!buf->flinked) { + if (drm_intel_bo_flink(buf->bo, &buf->flink)) + return FALSE; + buf->flinked = TRUE; + } + + whandle->handle = buf->flink; + } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { + whandle->handle = buf->bo->handle; + } else { + assert(!"unknown usage"); + return FALSE; + } + + whandle->stride = stride; + return TRUE; +} + static int intel_drm_buffer_set_fence_reg(struct intel_winsys *iws, struct intel_buffer *buffer, @@ -146,6 +207,8 @@ void intel_drm_winsys_init_buffer_functions(struct intel_drm_winsys *idws) { idws->base.buffer_create = intel_drm_buffer_create; + idws->base.buffer_from_handle = intel_drm_buffer_from_handle; + idws->base.buffer_get_handle = intel_drm_buffer_get_handle; idws->base.buffer_set_fence_reg = intel_drm_buffer_set_fence_reg; idws->base.buffer_map = intel_drm_buffer_map; idws->base.buffer_unmap = intel_drm_buffer_unmap; diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile index 7e95f79d03c..50ac3f203e5 100644 --- a/src/gallium/winsys/drm/nouveau/dri/Makefile +++ b/src/gallium/winsys/drm/nouveau/dri/Makefile @@ -6,8 +6,7 @@ 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/nv30/libnv30.a \ - $(TOP)/src/gallium/drivers/nv40/libnv40.a \ + $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ $(TOP)/src/gallium/drivers/nouveau/libnouveau.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 c814d986b1d..716d4bacd3b 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -21,9 +21,10 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen, struct pipe_surface *ps = NULL; struct pipe_texture *pt = NULL; struct pipe_texture tmpl; + struct winsys_handle whandle; memset(&tmpl, 0, sizeof(tmpl)); - tmpl.tex_usage = PIPE_TEXTURE_USAGE_PRIMARY; + tmpl.tex_usage = PIPE_TEXTURE_USAGE_SCANOUT; tmpl.target = PIPE_TEXTURE_2D; tmpl.last_level = 0; tmpl.depth0 = 1; @@ -31,8 +32,11 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen, tmpl.width0 = width; tmpl.height0 = height; - pt = api->texture_from_shared_handle(api, pscreen, &tmpl, - "front buffer", pitch, handle); + memset(&whandle, 0, sizeof(whandle)); + whandle.stride = pitch; + whandle.handle = handle; + + pt = pscreen->texture_from_handle(pscreen, &tmpl, &whandle); if (!pt) return NULL; @@ -82,11 +86,9 @@ nouveau_drm_create_screen(struct drm_api *api, int fd, switch (dev->chipset & 0xf0) { case 0x30: - init = nv30_screen_create; - break; case 0x40: case 0x60: - init = nv40_screen_create; + init = nvfx_screen_create; break; case 0x50: case 0x80: @@ -119,9 +121,9 @@ nouveau_drm_create_screen(struct drm_api *api, int fd, enum pipe_format format; if (nvdri->bpp == 16) - format = PIPE_FORMAT_R5G6B5_UNORM; + format = PIPE_FORMAT_B5G6R5_UNORM; else - format = PIPE_FORMAT_A8R8G8B8_UNORM; + format = PIPE_FORMAT_B8G8R8A8_UNORM; nvws->front = dri_surface_from_handle(api, nvws->pscreen, nvdri->front_offset, @@ -142,74 +144,10 @@ nouveau_drm_create_screen(struct drm_api *api, int fd, return nvws->pscreen; } -static struct pipe_texture * -nouveau_drm_pt_from_name(struct drm_api *api, struct pipe_screen *pscreen, - struct pipe_texture *templ, const char *name, - unsigned stride, unsigned handle) -{ - struct nouveau_device *dev = nouveau_screen(pscreen)->device; - struct pipe_texture *pt; - struct pipe_buffer *pb; - int ret; - - pb = CALLOC(1, sizeof(struct pipe_buffer) + sizeof(struct nouveau_bo*)); - if (!pb) - return NULL; - - ret = nouveau_bo_handle_ref(dev, handle, (struct nouveau_bo**)(pb+1)); - if (ret) { - debug_printf("%s: ref name 0x%08x failed with %d\n", - __func__, handle, ret); - FREE(pb); - return NULL; - } - - pipe_reference_init(&pb->reference, 1); - pb->screen = pscreen; - pb->alignment = 0; - pb->usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE | - PIPE_BUFFER_USAGE_CPU_READ_WRITE; - pb->size = nouveau_bo(pb)->size; - pt = pscreen->texture_blanket(pscreen, templ, &stride, pb); - pipe_buffer_reference(&pb, NULL); - return pt; -} - -static boolean -nouveau_drm_name_from_pt(struct drm_api *api, struct pipe_screen *pscreen, - struct pipe_texture *pt, unsigned *stride, - unsigned *handle) -{ - struct nouveau_miptree *mt = nouveau_miptree(pt); - - if (!mt || !mt->bo) - return false; - - return nouveau_bo_handle_get(mt->bo, handle) == 0; -} - -static boolean -nouveau_drm_handle_from_pt(struct drm_api *api, struct pipe_screen *pscreen, - struct pipe_texture *pt, unsigned *stride, - unsigned *handle) -{ - struct nouveau_miptree *mt = nouveau_miptree(pt); - - if (!mt || !mt->bo) - return false; - - *handle = mt->bo->handle; - *stride = util_format_get_stride(mt->base.format, mt->base.width0); - return true; -} - struct drm_api drm_api_hooks = { .name = "nouveau", .driver_name = "nouveau", .create_screen = nouveau_drm_create_screen, - .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, }; struct drm_api * diff --git a/src/gallium/winsys/drm/nouveau/egl/Makefile b/src/gallium/winsys/drm/nouveau/egl/Makefile index 2c352603320..47d11276155 100644 --- a/src/gallium/winsys/drm/nouveau/egl/Makefile +++ b/src/gallium/winsys/drm/nouveau/egl/Makefile @@ -7,8 +7,7 @@ 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/nvfx/libnvfx.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a diff --git a/src/gallium/winsys/drm/nouveau/xorg/Makefile b/src/gallium/winsys/drm/nouveau/xorg/Makefile index 179b50230b5..f7f6fe17dd6 100644 --- a/src/gallium/winsys/drm/nouveau/xorg/Makefile +++ b/src/gallium/winsys/drm/nouveau/xorg/Makefile @@ -18,8 +18,7 @@ INCLUDES = \ LIBS = \ $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ $(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/nvfx/libnvfx.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ $(GALLIUM_AUXILIARIES) diff --git a/src/gallium/winsys/drm/radeon/core/Makefile b/src/gallium/winsys/drm/radeon/core/Makefile index 860cbb6dbf8..13bbbf730d6 100644 --- a/src/gallium/winsys/drm/radeon/core/Makefile +++ b/src/gallium/winsys/drm/radeon/core/Makefile @@ -5,7 +5,7 @@ include $(TOP)/configs/current LIBNAME = radeonwinsys C_SOURCES = \ - radeon_buffer.c \ + radeon_drm_buffer.c \ radeon_drm.c \ radeon_r300.c diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 5cbf0dd2c54..25b58b2926c 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -31,11 +31,13 @@ */ #include "radeon_buffer.h" +#include "radeon_drm.h" -#include "radeon_bo_gem.h" -#include "r300_context.h" #include "util/u_format.h" #include "util/u_math.h" +#include "util/u_memory.h" + +#include "radeon_bo_gem.h" #include <X11/Xutil.h> struct radeon_vl_context @@ -211,6 +213,18 @@ static void radeon_buffer_unmap(struct pipe_winsys *ws, } } +static boolean radeon_is_buffer_referenced(struct radeon_winsys *ws, + struct pipe_buffer *buffer) +{ + struct radeon_pipe_buffer *radeon_buffer = + (struct radeon_pipe_buffer*)buffer; + uint32_t domain; + + /* Referenced by CS or HW. */ + return radeon_bo_is_referenced_by_cs(radeon_buffer->bo, ws->priv->cs) || + radeon_bo_is_busy(radeon_buffer->bo, &domain); +} + static void radeon_buffer_set_tiling(struct radeon_winsys *ws, struct pipe_buffer *buffer, uint32_t pitch, @@ -262,6 +276,75 @@ static int radeon_fence_finish(struct pipe_winsys *ws, return 0; } +/* Create a buffer from a handle. */ +static struct pipe_buffer* radeon_buffer_from_handle(struct radeon_winsys *radeon_ws, + struct pipe_screen *screen, + struct winsys_handle *whandle, + unsigned *stride) +{ + struct radeon_bo_manager* bom = radeon_ws->priv->bom; + struct radeon_pipe_buffer* radeon_buffer; + struct radeon_bo* bo = NULL; + + bo = radeon_bo_open(bom, whandle->handle, 0, 0, 0, 0); + if (bo == NULL) { + return NULL; + } + + radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer); + if (radeon_buffer == NULL) { + radeon_bo_unref(bo); + return NULL; + } + + pipe_reference_init(&radeon_buffer->base.reference, 1); + radeon_buffer->base.screen = screen; + radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL; + radeon_buffer->bo = bo; + + *stride = whandle->stride; + + return &radeon_buffer->base; +} + +static boolean radeon_buffer_get_handle(struct radeon_winsys *radeon_ws, + struct pipe_buffer *buffer, + unsigned stride, + struct winsys_handle *whandle) +{ + int retval, fd; + struct drm_gem_flink flink; + struct radeon_pipe_buffer* radeon_buffer; + + radeon_buffer = (struct radeon_pipe_buffer*)buffer; + + + if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { + if (!radeon_buffer->flinked) { + fd = radeon_ws->priv->fd; + + flink.handle = radeon_buffer->bo->handle; + + retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink); + if (retval) { + debug_printf("radeon: DRM_IOCTL_GEM_FLINK failed, error %d\n", + retval); + return FALSE; + } + + radeon_buffer->flink = flink.name; + radeon_buffer->flinked = TRUE; + } + + whandle->handle = radeon_buffer->flink; + } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { + whandle->handle = ((struct radeon_pipe_buffer*)buffer)->bo->handle; + } + whandle->stride = stride; + + return TRUE; +} + struct radeon_winsys* radeon_pipe_winsys(int fd) { struct radeon_winsys* radeon_ws; @@ -296,6 +379,10 @@ 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; + radeon_ws->buffer_from_handle = radeon_buffer_from_handle; + radeon_ws->buffer_get_handle = radeon_buffer_get_handle; + + radeon_ws->is_buffer_referenced = radeon_is_buffer_referenced; 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 f1c8fc2a3b1..e1fcfcfccaa 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -32,56 +32,54 @@ #include <stdio.h> -#include "util/u_simple_screen.h" #include "pipe/p_defines.h" #include "util/u_inlines.h" #include "pipebuffer/pb_buffer.h" - -#include "util/u_memory.h" +#include "pipebuffer/pb_bufmgr.h" #include "radeon_bo.h" #include "radeon_cs.h" -#include "radeon_drm.h" - #include "radeon_winsys.h" -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; -}; #define RADEON_MAX_BOS 24 -struct radeon_winsys_priv { - /* DRM FD */ - int fd; +static INLINE struct pb_buffer * +radeon_pb_buffer(struct r300_winsys_buffer *buffer) +{ + return (struct pb_buffer *)buffer; +} - /* Radeon BO manager. */ - struct radeon_bo_manager* bom; +static INLINE struct r300_winsys_buffer * +radeon_libdrm_winsys_buffer(struct pb_buffer *buffer) +{ + return (struct r300_winsys_buffer *)buffer; +} - /* Radeon CS manager. */ - struct radeon_cs_manager* csm; +struct pb_manager * +radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws); - /* Current CS. */ - struct radeon_cs* cs; +boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf, + uint32_t rd, uint32_t wd); - /* Flush CB */ - void (*flush_cb)(void *); - void *flush_data; -}; -struct radeon_winsys* radeon_pipe_winsys(int fb); -#if 0 -struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_context, - uint32_t handle, - enum pipe_format format, - int w, int h, int pitch); -#endif +void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf, + uint32_t rd, uint32_t wd, + uint32_t flags); + +struct radeon_libdrm_winsys* radeon_pipe_winsys(int fd); + +struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr, + uint32_t handle); + +void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, boolean microtiled, boolean macrotiled, uint32_t pitch); + +void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr); + +boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf, + struct winsys_handle *whandle); + +boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf); #endif diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 0c0e118ba3a..d70173e805d 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -30,9 +30,33 @@ */ #include "radeon_drm.h" +#include "radeon_r300.h" +#include "radeon_buffer.h" + +#include "r300_winsys.h" +#include "trace/tr_drm.h" + +#include "util/u_memory.h" + +#include "xf86drm.h" +#include <sys/ioctl.h> + +static struct radeon_libdrm_winsys * +radeon_winsys_create(int fd) +{ + struct radeon_libdrm_winsys *rws; + + rws = CALLOC_STRUCT(radeon_libdrm_winsys); + if (rws == NULL) { + return NULL; + } + + rws->fd = fd; + return rws; +} /* Helper function to do the ioctls needed for setup and init. */ -static void do_ioctls(int fd, struct radeon_winsys* winsys) +static void do_ioctls(int fd, struct radeon_libdrm_winsys* winsys) { struct drm_radeon_gem_info gem_info = {0}; struct drm_radeon_info info = {0}; @@ -123,137 +147,28 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api, int drmFB, struct drm_create_screen_arg *arg) { - struct radeon_winsys* rwinsys = radeon_pipe_winsys(drmFB); - do_ioctls(drmFB, rwinsys); + struct radeon_libdrm_winsys* rws; + boolean ret; + + rws = radeon_winsys_create(drmFB); + if (!rws) + return NULL; + + do_ioctls(drmFB, rws); /* 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); - } else { - FREE(rwinsys); - return NULL; + if (is_r3xx(rws->pci_id)) { + ret = radeon_setup_winsys(drmFB, rws); + if (ret == FALSE) + goto fail; + return r300_create_screen(&rws->base); } -} - - -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(screen, texture, buffer, stride); -} - -/* Create a buffer from a handle. */ -/* XXX what's up with name? */ -struct pipe_buffer* radeon_buffer_from_handle(struct drm_api* api, - struct pipe_screen* screen, - const char* name, - unsigned handle) -{ - struct radeon_bo_manager* bom = - ((struct radeon_winsys*)screen->winsys)->priv->bom; - struct radeon_pipe_buffer* radeon_buffer; - struct radeon_bo* bo = NULL; - - bo = radeon_bo_open(bom, handle, 0, 0, 0, 0); - if (bo == NULL) { - return NULL; - } - - radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer); - if (radeon_buffer == NULL) { - radeon_bo_unref(bo); - return NULL; - } - - pipe_reference_init(&radeon_buffer->base.reference, 1); - radeon_buffer->base.screen = screen; - radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL; - radeon_buffer->bo = bo; - return &radeon_buffer->base; -} - -static struct pipe_texture* -radeon_texture_from_shared_handle(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *templ, - const char *name, - unsigned stride, - unsigned handle) -{ - struct pipe_buffer *buffer; - struct pipe_texture *blanket; - - buffer = radeon_buffer_from_handle(api, screen, name, handle); - if (!buffer) { - return NULL; - } - - blanket = screen->texture_blanket(screen, templ, &stride, buffer); - - pipe_buffer_reference(&buffer, NULL); - - return blanket; -} - -static boolean radeon_shared_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle) -{ - int retval, fd; - struct drm_gem_flink flink; - struct radeon_pipe_buffer* radeon_buffer; - struct pipe_buffer *buffer = NULL; - - if (!radeon_buffer_from_texture(api, screen, texture, &buffer, stride)) { - return FALSE; - } - - radeon_buffer = (struct radeon_pipe_buffer*)buffer; - if (!radeon_buffer->flinked) { - fd = ((struct radeon_winsys*)screen->winsys)->priv->fd; - - flink.handle = radeon_buffer->bo->handle; - - retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink); - if (retval) { - debug_printf("radeon: DRM_IOCTL_GEM_FLINK failed, error %d\n", - retval); - return FALSE; - } - - radeon_buffer->flink = flink.name; - radeon_buffer->flinked = TRUE; - } - - *handle = radeon_buffer->flink; - return TRUE; -} - -static boolean radeon_local_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle) -{ - struct pipe_buffer *buffer = NULL; - if (!radeon_buffer_from_texture(api, screen, texture, &buffer, stride)) { - return FALSE; - } - - *handle = ((struct radeon_pipe_buffer*)buffer)->bo->handle; - - pipe_buffer_reference(&buffer, NULL); - return TRUE; +fail: + FREE(rws); + return NULL; } static void radeon_drm_api_destroy(struct drm_api *api) @@ -265,9 +180,6 @@ struct drm_api drm_api_hooks = { .name = "radeon", .driver_name = "radeon", .create_screen = radeon_create_screen, - .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, }; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index 8d74cbafc2f..2dc077c0521 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -30,40 +30,19 @@ #ifndef RADEON_DRM_H #define RADEON_DRM_H -#include <sys/ioctl.h> - -#include "xf86drm.h" - -#include "pipe/p_screen.h" - -#include "trace/tr_drm.h" -#include "util/u_debug.h" -#include "util/u_memory.h" - #include "state_tracker/drm_api.h" -#include "radeon_buffer.h" -#include "radeon_r300.h" - -/* XXX */ -#include "r300_screen.h" struct pipe_screen* radeon_create_screen(struct drm_api* api, int drmFB, struct drm_create_screen_arg *arg); - boolean radeon_buffer_from_texture(struct drm_api* api, struct pipe_screen* screen, struct pipe_texture* texture, struct pipe_buffer** buffer, unsigned* stride); -struct pipe_buffer* radeon_buffer_from_handle(struct drm_api* api, - struct pipe_screen* screen, - const char* name, - unsigned handle); - boolean radeon_handle_from_buffer(struct drm_api* api, struct pipe_screen* screen, struct pipe_buffer* buffer, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c new file mode 100644 index 00000000000..cc56a2bb8fd --- /dev/null +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -0,0 +1,368 @@ + +#include <sys/ioctl.h> +#include "radeon_drm.h" +#include "radeon_bo_gem.h" +#include "radeon_cs_gem.h" +#include "radeon_buffer.h" + +#include "util/u_inlines.h" +#include "util/u_memory.h" +#include "util/u_simple_list.h" +#include "pipebuffer/pb_buffer.h" +#include "pipebuffer/pb_bufmgr.h" + +#include "radeon_winsys.h" +struct radeon_drm_bufmgr; + +struct radeon_drm_buffer { + struct pb_buffer base; + struct radeon_drm_bufmgr *mgr; + + struct radeon_bo *bo; + + boolean flinked; + uint32_t flink; + + boolean mapped; + struct radeon_drm_buffer *next, *prev; +}; + +extern const struct pb_vtbl radeon_drm_buffer_vtbl; + + +static INLINE struct radeon_drm_buffer * +radeon_drm_buffer(struct pb_buffer *buf) +{ + assert(buf); + assert(buf->vtbl == &radeon_drm_buffer_vtbl); + return (struct radeon_drm_buffer *)buf; +} + +struct radeon_drm_bufmgr { + struct pb_manager base; + struct radeon_libdrm_winsys *rws; + struct radeon_drm_buffer buffer_map_list; +}; + +static INLINE struct radeon_drm_bufmgr * +radeon_drm_bufmgr(struct pb_manager *mgr) +{ + assert(mgr); + return (struct radeon_drm_bufmgr *)mgr; +} + +static void +radeon_drm_buffer_destroy(struct pb_buffer *_buf) +{ + struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf); + + if (buf->mapped) { + remove_from_list(buf); + radeon_bo_unmap(buf->bo); + buf->mapped = false; + } + radeon_bo_unref(buf->bo); + + FREE(buf); +} + +static void * +radeon_drm_buffer_map(struct pb_buffer *_buf, + unsigned flags) +{ + struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf); + int write; + + if (buf->mapped) + return buf->bo->ptr; + + if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { + uint32_t domain; + + if (radeon_bo_is_busy(buf->bo, &domain)) + return NULL; + } + + + if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) { + buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data); + } + + if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) { + write = 1; + } + + if (radeon_bo_map(buf->bo, write)) { + return NULL; + } + buf->mapped = true; + insert_at_tail(&buf->mgr->buffer_map_list, buf); + return buf->bo->ptr; +} + +static void +radeon_drm_buffer_unmap(struct pb_buffer *_buf) +{ + (void)_buf; +} + +static void +radeon_drm_buffer_get_base_buffer(struct pb_buffer *buf, + struct pb_buffer **base_buf, + unsigned *offset) +{ + *base_buf = buf; + *offset = 0; +} + + +static enum pipe_error +radeon_drm_buffer_validate(struct pb_buffer *_buf, + struct pb_validate *vl, + unsigned flags) +{ + /* Always pinned */ + return PIPE_OK; +} + +static void +radeon_drm_buffer_fence(struct pb_buffer *buf, + struct pipe_fence_handle *fence) +{ +} + +const struct pb_vtbl radeon_drm_buffer_vtbl = { + radeon_drm_buffer_destroy, + radeon_drm_buffer_map, + radeon_drm_buffer_unmap, + radeon_drm_buffer_validate, + radeon_drm_buffer_fence, + radeon_drm_buffer_get_base_buffer, +}; + + +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; +} + +struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr, + uint32_t handle) +{ + struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr); + struct radeon_libdrm_winsys *rws = mgr->rws; + struct radeon_drm_buffer *buf; + struct radeon_bo *bo; + + bo = radeon_bo_open(rws->bom, handle, 0, + 0, 0, 0); + if (bo == NULL) + return NULL; + + buf = CALLOC_STRUCT(radeon_drm_buffer); + if (!buf) { + radeon_bo_unref(bo); + return NULL; + } + + make_empty_list(buf); + + pipe_reference_init(&buf->base.base.reference, 1); + buf->base.base.alignment = 0; + buf->base.base.usage = PIPE_BUFFER_USAGE_PIXEL; + buf->base.base.size = 0; + buf->base.vtbl = &radeon_drm_buffer_vtbl; + buf->mgr = mgr; + + buf->bo = bo; + + return &buf->base; +} + +static struct pb_buffer * +radeon_drm_bufmgr_create_buffer(struct pb_manager *_mgr, + pb_size size, + const struct pb_desc *desc) +{ + struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr); + struct radeon_libdrm_winsys *rws = mgr->rws; + struct radeon_drm_buffer *buf; + uint32_t domain; + + buf = CALLOC_STRUCT(radeon_drm_buffer); + if (!buf) + goto error1; + + pipe_reference_init(&buf->base.base.reference, 1); + buf->base.base.alignment = desc->alignment; + buf->base.base.usage = desc->usage; + buf->base.base.size = size; + buf->base.vtbl = &radeon_drm_buffer_vtbl; + buf->mgr = mgr; + + make_empty_list(buf); + domain = radeon_domain_from_usage(desc->usage); + buf->bo = radeon_bo_open(rws->bom, 0, size, + desc->alignment, domain, 0); + if (buf->bo == NULL) + goto error2; + + return &buf->base; + + error2: + FREE(buf); + error1: + return NULL; +} + +static void +radeon_drm_bufmgr_flush(struct pb_manager *mgr) +{ + /* NOP */ +} + +static void +radeon_drm_bufmgr_destroy(struct pb_manager *_mgr) +{ + struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr); + FREE(mgr); +} + +struct pb_manager * +radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws) +{ + struct radeon_drm_bufmgr *mgr; + + mgr = CALLOC_STRUCT(radeon_drm_bufmgr); + if (!mgr) + return NULL; + + mgr->base.destroy = radeon_drm_bufmgr_destroy; + mgr->base.create_buffer = radeon_drm_bufmgr_create_buffer; + mgr->base.flush = radeon_drm_bufmgr_flush; + + mgr->rws = rws; + make_empty_list(&mgr->buffer_map_list); + return &mgr->base; +} + +static struct radeon_drm_buffer *get_drm_buffer(struct pb_buffer *_buf) +{ + struct radeon_drm_buffer *buf; + if (_buf->vtbl == &radeon_drm_buffer_vtbl) { + buf = radeon_drm_buffer(_buf); + } else { + struct pb_buffer *base_buf; + pb_size offset; + pb_get_base_buffer(_buf, &base_buf, &offset); + + buf = radeon_drm_buffer(base_buf); + } + return buf; +} + +boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf, + struct winsys_handle *whandle) +{ + int retval, fd; + struct drm_gem_flink flink; + struct radeon_drm_buffer *buf = get_drm_buffer(_buf); + if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { + if (!buf->flinked) { + fd = buf->mgr->rws->fd; + flink.handle = buf->bo->handle; + + retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink); + if (retval) { + return false; + } + + buf->flinked = TRUE; + buf->flink = flink.name; + } + whandle->handle = buf->flink; + } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { + whandle->handle = buf->bo->handle; + } + return TRUE; +} + + +void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, boolean microtiled, boolean macrotiled, uint32_t pitch) +{ + struct radeon_drm_buffer *buf = get_drm_buffer(_buf); + uint32_t flags = 0; + + if (microtiled) + flags |= RADEON_BO_FLAGS_MICRO_TILE; + if (macrotiled) + flags |= RADEON_BO_FLAGS_MACRO_TILE; + + radeon_bo_set_tiling(buf->bo, flags, pitch); + +} + +boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf, + uint32_t rd, uint32_t wd) +{ + struct radeon_drm_buffer *buf = get_drm_buffer(_buf); + radeon_cs_space_add_persistent_bo(buf->mgr->rws->cs, buf->bo, + rd, wd); + return true; +} + +void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf, + uint32_t rd, uint32_t wd, + uint32_t flags) +{ + struct radeon_drm_buffer *buf = get_drm_buffer(_buf); + int retval; + + retval = radeon_cs_write_reloc(buf->mgr->rws->cs, + buf->bo, rd, wd, flags); + if (retval) { + debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n", + buf, rd, wd, flags); + } +} + +boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf) +{ + struct radeon_drm_buffer *buf = get_drm_buffer(_buf); + uint32_t domain; + + return (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs) || + radeon_bo_is_busy(buf->bo, &domain)); +} + + +void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr) +{ + struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr); + struct radeon_drm_buffer *rpb, *t_rpb; + + foreach_s(rpb, t_rpb, &mgr->buffer_map_list) { + rpb->mapped = 0; + radeon_bo_unmap(rpb->bo); + remove_from_list(rpb); + } + + make_empty_list(&mgr->buffer_map_list); + + +} diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index d759beaba13..5b82a776a81 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -21,30 +21,141 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "radeon_r300.h" +#include "radeon_buffer.h" -static void radeon_set_flush_cb(struct radeon_winsys *winsys, +#include "radeon_bo_gem.h" +#include "radeon_cs_gem.h" +#include "state_tracker/drm_api.h" + +static struct r300_winsys_buffer * +radeon_r300_winsys_buffer_create(struct r300_winsys_screen *rws, + unsigned alignment, + unsigned usage, + unsigned size) +{ + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); + struct pb_desc desc; + struct pb_manager *provider; + struct pb_buffer *buffer; + + memset(&desc, 0, sizeof(desc)); + desc.alignment = alignment; + desc.usage = usage; + + if (usage & PIPE_BUFFER_USAGE_CONSTANT) + provider = ws->mman; + else + provider = ws->kman; + buffer = provider->create_buffer(provider, size, &desc); + if (!buffer) + return NULL; + + return radeon_libdrm_winsys_buffer(buffer); +} + +static void radeon_r300_winsys_buffer_destroy(struct r300_winsys_buffer *buf) +{ + struct pb_buffer *_buf = radeon_pb_buffer(buf); + + pb_destroy(_buf); +} +static void radeon_r300_winsys_buffer_set_tiling(struct r300_winsys_screen *rws, + struct r300_winsys_buffer *buf, + uint32_t pitch, + boolean microtiled, + boolean macrotiled) +{ + struct pb_buffer *_buf = radeon_pb_buffer(buf); + radeon_drm_bufmgr_set_tiling(_buf, microtiled, macrotiled, pitch); +} + +static void *radeon_r300_winsys_buffer_map(struct r300_winsys_screen *ws, + struct r300_winsys_buffer *buf, + unsigned usage) +{ + struct pb_buffer *_buf = radeon_pb_buffer(buf); + + return pb_map(_buf, usage); +} + +static void radeon_r300_winsys_buffer_unmap(struct r300_winsys_screen *ws, + struct r300_winsys_buffer *buf) +{ + struct pb_buffer *_buf = radeon_pb_buffer(buf); + + pb_unmap(_buf); +} + +static void radeon_r300_winsys_buffer_reference(struct r300_winsys_screen *rws, + struct r300_winsys_buffer **pdst, + struct r300_winsys_buffer *src) +{ + struct pb_buffer *_src = radeon_pb_buffer(src); + struct pb_buffer *_dst = radeon_pb_buffer(*pdst); + + pb_reference(&_dst, _src); + + *pdst = radeon_libdrm_winsys_buffer(_dst); +} + +static boolean radeon_r300_winsys_is_buffer_referenced(struct r300_winsys_screen *rws, + struct r300_winsys_buffer *buf) +{ + struct pb_buffer *_buf = radeon_pb_buffer(buf); + + return radeon_drm_bufmgr_is_buffer_referenced(_buf); +} + +static struct r300_winsys_buffer *radeon_r300_winsys_buffer_from_handle(struct r300_winsys_screen *rws, + struct pipe_screen *screen, + struct winsys_handle *whandle, + unsigned *stride) +{ + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); + struct pb_buffer *_buf; + + _buf = radeon_drm_bufmgr_create_buffer_from_handle(ws->kman, whandle->handle); + *stride = whandle->stride; + return radeon_libdrm_winsys_buffer(_buf); +} + +static boolean radeon_r300_winsys_buffer_get_handle(struct r300_winsys_screen *rws, + struct r300_winsys_buffer *buffer, + unsigned stride, + struct winsys_handle *whandle) +{ + struct pb_buffer *_buf = radeon_pb_buffer(buffer); + boolean ret; + ret = radeon_drm_bufmgr_get_handle(_buf, whandle); + if (ret) + whandle->stride = stride; + return ret; +} + +static void radeon_set_flush_cb(struct r300_winsys_screen *rws, void (*flush_cb)(void *), void *data) { - winsys->priv->flush_cb = flush_cb; - winsys->priv->flush_data = data; - radeon_cs_space_set_flush(winsys->priv->cs, flush_cb, data); + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); + ws->flush_cb = flush_cb; + ws->flush_data = data; + radeon_cs_space_set_flush(ws->cs, flush_cb, data); } -static boolean radeon_add_buffer(struct radeon_winsys* winsys, - struct pipe_buffer* pbuffer, +static boolean radeon_add_buffer(struct r300_winsys_screen *rws, + struct r300_winsys_buffer *buf, uint32_t rd, uint32_t wd) { - struct radeon_bo* bo = ((struct radeon_pipe_buffer*)pbuffer)->bo; + struct pb_buffer *_buf = radeon_pb_buffer(buf); - radeon_cs_space_add_persistent_bo(winsys->priv->cs, bo, rd, wd); - return TRUE; + return radeon_drm_bufmgr_add_buffer(_buf, rd, wd); } -static boolean radeon_validate(struct radeon_winsys* winsys) +static boolean radeon_validate(struct r300_winsys_screen *rws) { - if (radeon_cs_space_check(winsys->priv->cs) < 0) { + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); + if (radeon_cs_space_check(ws->cs) < 0) { return FALSE; } @@ -52,108 +163,175 @@ static boolean radeon_validate(struct radeon_winsys* winsys) return TRUE; } -static boolean radeon_check_cs(struct radeon_winsys* winsys, int size) +static boolean radeon_check_cs(struct r300_winsys_screen *rws, int size) { - struct radeon_cs* cs = winsys->priv->cs; + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); + struct radeon_cs *cs = ws->cs; - return radeon_validate(winsys) && cs->cdw + size <= cs->ndw; + return radeon_validate(rws) && cs->cdw + size <= cs->ndw; } -static void radeon_begin_cs(struct radeon_winsys* winsys, +static void radeon_begin_cs(struct r300_winsys_screen *rws, int size, const char* file, const char* function, int line) { - radeon_cs_begin(winsys->priv->cs, size, file, function, line); + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); + radeon_cs_begin(ws->cs, size, file, function, line); } -static void radeon_write_cs_dword(struct radeon_winsys* winsys, +static void radeon_write_cs_dword(struct r300_winsys_screen *rws, uint32_t dword) { - radeon_cs_write_dword(winsys->priv->cs, dword); + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); + radeon_cs_write_dword(ws->cs, dword); } -static void radeon_write_cs_reloc(struct radeon_winsys* winsys, - struct pipe_buffer* pbuffer, +static void radeon_write_cs_reloc(struct r300_winsys_screen *rws, + struct r300_winsys_buffer *buf, uint32_t rd, uint32_t wd, uint32_t flags) { - int retval = 0; - struct radeon_pipe_buffer* radeon_buffer = - (struct radeon_pipe_buffer*)pbuffer; - - 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", - pbuffer, rd, wd, flags); - } + struct pb_buffer *_buf = radeon_pb_buffer(buf); + radeon_drm_bufmgr_write_reloc(_buf, rd, wd, flags); } -static void radeon_reset_bos(struct radeon_winsys *winsys) +static void radeon_reset_bos(struct r300_winsys_screen *rws) { - radeon_cs_space_reset_bos(winsys->priv->cs); + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); + radeon_cs_space_reset_bos(ws->cs); } -static void radeon_end_cs(struct radeon_winsys* winsys, +static void radeon_end_cs(struct r300_winsys_screen *rws, const char* file, const char* function, int line) { - radeon_cs_end(winsys->priv->cs, file, function, line); + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); + radeon_cs_end(ws->cs, file, function, line); } -static void radeon_flush_cs(struct radeon_winsys* winsys) +static void radeon_flush_cs(struct r300_winsys_screen *rws) { + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); int retval; /* Don't flush a zero-sized CS. */ - if (!winsys->priv->cs->cdw) { + if (!ws->cs->cdw) { return; } + radeon_drm_bufmgr_flush_maps(ws->kman); /* Emit the CS. */ - retval = radeon_cs_emit(winsys->priv->cs); + retval = radeon_cs_emit(ws->cs); if (retval) { debug_printf("radeon: Bad CS, dumping...\n"); - radeon_cs_print(winsys->priv->cs, stderr); + radeon_cs_print(ws->cs, stderr); } /* Reset CS. * Someday, when we care about performance, we should really find a way * to rotate between two or three CS objects so that the GPU can be * spinning through one CS while another one is being filled. */ - radeon_cs_erase(winsys->priv->cs); + radeon_cs_erase(ws->cs); +} + +static uint32_t radeon_get_value(struct r300_winsys_screen *rws, + enum r300_value_id id) +{ + struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws; + + switch(id) { + case R300_VID_PCI_ID: + return ws->pci_id; + case R300_VID_GB_PIPES: + return ws->gb_pipes; + case R300_VID_Z_PIPES: + return ws->z_pipes; + } + return 0; +} + +static void +radeon_winsys_destroy(struct r300_winsys_screen *rws) +{ + struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws; + radeon_cs_destroy(ws->cs); + + ws->kman->destroy(ws->kman); + ws->mman->destroy(ws->mman); + + radeon_bo_manager_gem_dtor(ws->bom); + radeon_cs_manager_gem_dtor(ws->csm); } -void -radeon_setup_winsys(int fd, struct radeon_winsys* winsys) +boolean +radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws) { - struct radeon_winsys_priv* priv = winsys->priv; + + ws->csm = radeon_cs_manager_gem_ctor(fd); + if (!ws->csm) + goto fail; + ws->bom = radeon_bo_manager_gem_ctor(fd); + if (!ws->bom) + goto fail; + ws->kman = radeon_drm_bufmgr_create(ws); + if (!ws->kman) + goto fail; - priv->csm = radeon_cs_manager_gem_ctor(fd); + ws->mman = pb_malloc_bufmgr_create(); + if (!ws->mman) + goto fail; /* Size limit on IBs is 64 kibibytes. */ - priv->cs = radeon_cs_create(priv->csm, 1024 * 64 / 4); - radeon_cs_set_limit(priv->cs, - RADEON_GEM_DOMAIN_GTT, winsys->gart_size); - radeon_cs_set_limit(priv->cs, - RADEON_GEM_DOMAIN_VRAM, winsys->vram_size); - - winsys->add_buffer = radeon_add_buffer; - winsys->validate = radeon_validate; - - winsys->check_cs = radeon_check_cs; - winsys->begin_cs = radeon_begin_cs; - winsys->write_cs_dword = radeon_write_cs_dword; - winsys->write_cs_reloc = radeon_write_cs_reloc; - winsys->end_cs = radeon_end_cs; - winsys->flush_cs = radeon_flush_cs; - winsys->reset_bos = radeon_reset_bos; - winsys->set_flush_cb = radeon_set_flush_cb; + ws->cs = radeon_cs_create(ws->csm, 1024 * 64 / 4); + if (!ws->cs) + goto fail; + radeon_cs_set_limit(ws->cs, + RADEON_GEM_DOMAIN_GTT, ws->gart_size); + radeon_cs_set_limit(ws->cs, + RADEON_GEM_DOMAIN_VRAM, ws->vram_size); + + ws->base.add_buffer = radeon_add_buffer; + ws->base.validate = radeon_validate; + ws->base.destroy = radeon_winsys_destroy; + ws->base.check_cs = radeon_check_cs; + ws->base.begin_cs = radeon_begin_cs; + ws->base.write_cs_dword = radeon_write_cs_dword; + ws->base.write_cs_reloc = radeon_write_cs_reloc; + ws->base.end_cs = radeon_end_cs; + ws->base.flush_cs = radeon_flush_cs; + ws->base.reset_bos = radeon_reset_bos; + ws->base.set_flush_cb = radeon_set_flush_cb; + ws->base.get_value = radeon_get_value; + + ws->base.buffer_create = radeon_r300_winsys_buffer_create; + ws->base.buffer_destroy = radeon_r300_winsys_buffer_destroy; + ws->base.buffer_set_tiling = radeon_r300_winsys_buffer_set_tiling; + ws->base.buffer_map = radeon_r300_winsys_buffer_map; + ws->base.buffer_unmap = radeon_r300_winsys_buffer_unmap; + ws->base.buffer_reference = radeon_r300_winsys_buffer_reference; + ws->base.buffer_from_handle = radeon_r300_winsys_buffer_from_handle; + ws->base.buffer_get_handle = radeon_r300_winsys_buffer_get_handle; + ws->base.is_buffer_referenced = radeon_r300_winsys_is_buffer_referenced; + return TRUE; + +fail: + if (ws->csm) + radeon_cs_manager_gem_dtor(ws->csm); + + if (ws->bom) + radeon_bo_manager_gem_dtor(ws->bom); + + + if (ws->kman) + ws->kman->destroy(ws->kman); + if (ws->mman) + ws->mman->destroy(ws->mman); + + if (ws->cs) + radeon_cs_destroy(ws->cs); + return FALSE; } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h index cfbdb302661..2703464ad8f 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.h @@ -23,17 +23,8 @@ #ifndef RADEON_R300_H #define RADEON_R300_H -/* XXX WTF is this! I shouldn't have to include those first three! FUCK! */ -#include <stdint.h> -#include <stdlib.h> -#include "drm.h" -#include "radeon_drm.h" -#include "radeon_cs_gem.h" +#include "radeon_winsys.h" -#include "r300_winsys.h" - -#include "radeon_buffer.h" - -void radeon_setup_winsys(int fd, struct radeon_winsys* winsys); +boolean radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* winsys); #endif /* RADEON_R300_H */ diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h index 4901080ca7b..16cc701ad6f 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h @@ -30,16 +30,15 @@ #ifndef RADEON_WINSYS_H #define RADEON_WINSYS_H -#include "util/u_simple_screen.h" +#include "r300_winsys.h" -struct radeon_winsys_priv; - -struct radeon_winsys { +struct radeon_libdrm_winsys { /* Parent class. */ - struct pipe_winsys base; + struct r300_winsys_screen base; + + struct pb_manager *kman; - /* Winsys private */ - struct radeon_winsys_priv* priv; + struct pb_manager *mman; /* PCI ID */ uint32_t pci_id; @@ -56,56 +55,27 @@ struct radeon_winsys { /* VRAM size. */ uint32_t vram_size; - /* Add a pipe_buffer to the list of buffer objects to validate. */ - boolean (*add_buffer)(struct radeon_winsys* winsys, - struct pipe_buffer* pbuffer, - uint32_t rd, - uint32_t wd); - - /* Revalidate all currently setup pipe_buffers. - * Returns TRUE if a flush is required. */ - boolean (*validate)(struct radeon_winsys* winsys); - - /* Check to see if there's room for commands. */ - boolean (*check_cs)(struct radeon_winsys* winsys, int size); - - /* Start a command emit. */ - void (*begin_cs)(struct radeon_winsys* winsys, - int size, - const char* file, - const char* function, - int line); - - /* Write a dword to the command buffer. */ - void (*write_cs_dword)(struct radeon_winsys* winsys, uint32_t dword); - - /* Write a relocated dword to the command buffer. */ - void (*write_cs_reloc)(struct radeon_winsys* winsys, - struct pipe_buffer* bo, - uint32_t rd, - uint32_t wd, - uint32_t flags); - - /* Finish a command emit. */ - void (*end_cs)(struct radeon_winsys* winsys, - const char* file, - const char* function, - int line); - - /* Flush the CS. */ - void (*flush_cs)(struct radeon_winsys* winsys); - - /* winsys flush - callback from winsys when flush required */ - void (*set_flush_cb)(struct radeon_winsys *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); + /* DRM FD */ + int fd; + + /* Radeon BO manager. */ + struct radeon_bo_manager *bom; + + /* Radeon CS manager. */ + struct radeon_cs_manager *csm; + + /* Current CS. */ + struct radeon_cs *cs; + + /* Flush CB */ + void (*flush_cb)(void *); + void *flush_data; }; +static INLINE struct radeon_libdrm_winsys * +radeon_winsys_screen(struct r300_winsys_screen *base) +{ + return (struct radeon_libdrm_winsys *)base; +} + #endif diff --git a/src/gallium/winsys/drm/radeon/dri/Makefile b/src/gallium/winsys/drm/radeon/dri/Makefile index eaa34180321..d75f7dd6da7 100644 --- a/src/gallium/winsys/drm/radeon/dri/Makefile +++ b/src/gallium/winsys/drm/radeon/dri/Makefile @@ -4,8 +4,6 @@ include $(TOP)/configs/current LIBNAME = radeong_dri.so -MINIGLX_SOURCES = - PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ diff --git a/src/gallium/winsys/drm/radeon/python/README b/src/gallium/winsys/drm/radeon/python/README deleted file mode 100644 index 339836a592b..00000000000 --- a/src/gallium/winsys/drm/radeon/python/README +++ /dev/null @@ -1,15 +0,0 @@ -Python bindings for the radeon gallium driver. - - -See gallium/src/gallium/state_trackers/python/README for more information. - - -Build as: - - scons debug=1 statetrackers=python winsys=drm/radeon/python - -Run as: - - export PYTHONPATH=$PWD/build/linux-x86-debug/gallium/winsys/drm/radeon/python:$PWD/build/linux-x86-debug/gallium/state_trackers/python - - python progs/gallium/python/samples/tri.py diff --git a/src/gallium/winsys/drm/radeon/python/SConscript b/src/gallium/winsys/drm/radeon/python/SConscript deleted file mode 100644 index 91cae986975..00000000000 --- a/src/gallium/winsys/drm/radeon/python/SConscript +++ /dev/null @@ -1,33 +0,0 @@ -import os.path - -Import('*') - -if env['platform'] == 'linux': - - env = env.Clone() - - env.Tool('python') - - env.ParseConfig('pkg-config --cflags --libs libdrm') - - env.Prepend(CPPPATH = [ - '#src/gallium/state_trackers/python', - '../core', - ]) - - drivers = [ - softpipe, - radeon, - trace, - ] - - sources = [ - 'radeon_hardpipe_winsys.c', - 'xf86dri.c', - ] - - env.SharedLibrary( - target ='_gallium', - source = sources, - LIBS = [pyst] + drivers + gallium + env['LIBS'], - ) diff --git a/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c b/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c deleted file mode 100644 index fc63081a4cc..00000000000 --- a/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c +++ /dev/null @@ -1,132 +0,0 @@ - /************************************************************************** - * - * Copyright 2009 VMware, Inc. - * 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 VMWARE 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. - * - **************************************************************************/ - - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include <X11/X.h> -#include <X11/Xlib.h> -#include <drm/drm.h> - -#include "pipe/p_screen.h" -#include "pipe/p_context.h" - -#include "st_winsys.h" - -#include "radeon_winsys.h" - -#include "xf86dri.h" - - -/* XXX: Force init_gallium symbol to be linked */ -extern void init_gallium(void); -void (*force_init_gallium_linkage)(void) = &init_gallium; - - -static struct pipe_screen * -radeon_hardpipe_screen_create(void) -{ - Display *dpy; - Window rootWin; - XWindowAttributes winAttr; - int isCapable; - int screen; - char *driverName; - char *curBusID; - unsigned magic; - int ddxDriverMajor; - int ddxDriverMinor; - int ddxDriverPatch; - drm_handle_t sAreaOffset; - int ret; - int drmFD; - drm_context_t hHWContext; - XID id; - - dpy = XOpenDisplay(":0"); - if (!dpy) { - fprintf(stderr, "Open Display Failed\n"); - return NULL; - } - - screen = DefaultScreen(dpy); - rootWin = RootWindow(dpy, screen); - XGetWindowAttributes(dpy, rootWin, &winAttr); - - ret = uniDRIQueryDirectRenderingCapable(dpy, screen, &isCapable); - if (!ret || !isCapable) { - fprintf(stderr, "No DRI on this display:sceen\n"); - goto error; - } - - if (!uniDRIOpenConnection(dpy, screen, &sAreaOffset, - &curBusID)) { - fprintf(stderr, "Could not open DRI connection.\n"); - goto error; - } - - if (!uniDRIGetClientDriverName(dpy, screen, &ddxDriverMajor, - &ddxDriverMinor, &ddxDriverPatch, - &driverName)) { - fprintf(stderr, "Could not get DRI driver name.\n"); - goto error; - } - - if ((drmFD = drmOpen(NULL, curBusID)) < 0) { - perror("DRM Device could not be opened"); - goto error; - } - - drmGetMagic(drmFD, &magic); - if (!uniDRIAuthConnection(dpy, screen, magic)) { - fprintf(stderr, "Could not get X server to authenticate us.\n"); - goto error; - } - - if (!uniDRICreateContext(dpy, screen, winAttr.visual, - &id, &hHWContext)) { - fprintf(stderr, "Could not create DRI context.\n"); - goto error; - } - - /* FIXME: create a radeon pipe_screen from drmFD and hHWContext */ - - return NULL; - -error: - return NULL; -} - - - - -const struct st_winsys st_hardpipe_winsys = { - &radeon_hardpipe_screen_create, -}; - diff --git a/src/gallium/winsys/drm/radeon/python/xf86dri.c b/src/gallium/winsys/drm/radeon/python/xf86dri.c deleted file mode 100644 index 1736f1e54f8..00000000000 --- a/src/gallium/winsys/drm/radeon/python/xf86dri.c +++ /dev/null @@ -1,605 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -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 PRECISION INSIGHT 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. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin <[email protected]> - * Jens Owen <[email protected]> - * Rickard E. (Rik) Faith <[email protected]> - * - */ - -/* THIS IS NOT AN X CONSORTIUM STANDARD */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define NEED_REPLIES -#include <X11/Xlibint.h> -#include <X11/extensions/Xext.h> -#include <X11/extensions/extutil.h> -#include "xf86dristr.h" - -static XExtensionInfo _xf86dri_info_data; -static XExtensionInfo *xf86dri_info = &_xf86dri_info_data; -static char xf86dri_extension_name[] = XF86DRINAME; - -#define uniDRICheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, xf86dri_extension_name, val) - -/***************************************************************************** - * * - * private utility routines * - * * - *****************************************************************************/ - -static int close_display(Display * dpy, XExtCodes * extCodes); -static /* const */ XExtensionHooks xf86dri_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - close_display, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static -XEXT_GENERATE_FIND_DISPLAY(find_display, xf86dri_info, - xf86dri_extension_name, &xf86dri_extension_hooks, - 0, NULL) - - static XEXT_GENERATE_CLOSE_DISPLAY(close_display, xf86dri_info) - -/***************************************************************************** - * * - * public XFree86-DRI Extension routines * - * * - *****************************************************************************/ -#if 0 -#include <stdio.h> -#define TRACE(msg) fprintf(stderr,"uniDRI%s\n", msg); -#else -#define TRACE(msg) -#endif - Bool uniDRIQueryExtension(dpy, event_basep, error_basep) - Display *dpy; - int *event_basep, *error_basep; -{ - XExtDisplayInfo *info = find_display(dpy); - - TRACE("QueryExtension..."); - if (XextHasExtension(info)) { - *event_basep = info->codes->first_event; - *error_basep = info->codes->first_error; - TRACE("QueryExtension... return True"); - return True; - } else { - TRACE("QueryExtension... return False"); - return False; - } -} - -Bool -uniDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion) - Display *dpy; - int *majorVersion; - int *minorVersion; - int *patchVersion; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIQueryVersionReply rep; - xXF86DRIQueryVersionReq *req; - - TRACE("QueryVersion..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIQueryVersion, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIQueryVersion; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryVersion... return False"); - return False; - } - *majorVersion = rep.majorVersion; - *minorVersion = rep.minorVersion; - *patchVersion = rep.patchVersion; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryVersion... return True"); - return True; -} - -Bool -uniDRIQueryDirectRenderingCapable(dpy, screen, isCapable) - Display *dpy; - int screen; - Bool *isCapable; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIQueryDirectRenderingCapableReply rep; - xXF86DRIQueryDirectRenderingCapableReq *req; - - TRACE("QueryDirectRenderingCapable..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIQueryDirectRenderingCapable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIQueryDirectRenderingCapable; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryDirectRenderingCapable... return False"); - return False; - } - *isCapable = rep.isCapable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryDirectRenderingCapable... return True"); - return True; -} - -Bool -uniDRIOpenConnection(dpy, screen, hSAREA, busIdString) - Display *dpy; - int screen; - drm_handle_t *hSAREA; - char **busIdString; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIOpenConnectionReply rep; - xXF86DRIOpenConnectionReq *req; - - TRACE("OpenConnection..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIOpenConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIOpenConnection; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return False"); - return False; - } - - *hSAREA = rep.hSAREALow; -#ifdef LONG64 - if (sizeof(drm_handle_t) == 8) { - *hSAREA |= ((unsigned long)rep.hSAREAHigh) << 32; - } -#endif - if (rep.length) { - if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) { - _XEatData(dpy, ((rep.busIdStringLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return False"); - return False; - } - _XReadPad(dpy, *busIdString, rep.busIdStringLength); - } else { - *busIdString = NULL; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return True"); - return True; -} - -Bool -uniDRIAuthConnection(dpy, screen, magic) - Display *dpy; - int screen; - drm_magic_t magic; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIAuthConnectionReq *req; - xXF86DRIAuthConnectionReply rep; - - TRACE("AuthConnection..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIAuthConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIAuthConnection; - req->screen = screen; - req->magic = magic; - rep.authenticated = 0; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("AuthConnection... return False"); - return False; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("AuthConnection... return True"); - return True; -} - -Bool -uniDRICloseConnection(dpy, screen) - Display *dpy; - int screen; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICloseConnectionReq *req; - - TRACE("CloseConnection..."); - - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICloseConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICloseConnection; - req->screen = screen; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CloseConnection... return True"); - return True; -} - -Bool -uniDRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, - ddxDriverMinorVersion, ddxDriverPatchVersion, - clientDriverName) - Display *dpy; - int screen; - int *ddxDriverMajorVersion; - int *ddxDriverMinorVersion; - int *ddxDriverPatchVersion; - char **clientDriverName; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetClientDriverNameReply rep; - xXF86DRIGetClientDriverNameReq *req; - - TRACE("GetClientDriverName..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetClientDriverName, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetClientDriverName; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return False"); - return False; - } - - *ddxDriverMajorVersion = rep.ddxDriverMajorVersion; - *ddxDriverMinorVersion = rep.ddxDriverMinorVersion; - *ddxDriverPatchVersion = rep.ddxDriverPatchVersion; - - if (rep.length) { - if (!(*clientDriverName = - (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) { - _XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return False"); - return False; - } - _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength); - } else { - *clientDriverName = NULL; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return True"); - return True; -} - -Bool -uniDRICreateContextWithConfig(dpy, screen, configID, context, hHWContext) - Display *dpy; - int screen; - int configID; - XID *context; - drm_context_t *hHWContext; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICreateContextReply rep; - xXF86DRICreateContextReq *req; - - TRACE("CreateContext..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICreateContext, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICreateContext; - req->visual = configID; - req->screen = screen; - *context = XAllocID(dpy); - req->context = *context; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateContext... return False"); - return False; - } - *hHWContext = rep.hHWContext; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateContext... return True"); - return True; -} - -Bool -uniDRICreateContext(dpy, screen, visual, context, hHWContext) - Display *dpy; - int screen; - Visual *visual; - XID *context; - drm_context_t *hHWContext; -{ - return uniDRICreateContextWithConfig(dpy, screen, visual->visualid, - context, hHWContext); -} - -Bool -uniDRIDestroyContext(Display * ndpy, int screen, XID context) -{ - Display *const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIDestroyContextReq *req; - - TRACE("DestroyContext..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIDestroyContext, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIDestroyContext; - req->screen = screen; - req->context = context; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("DestroyContext... return True"); - return True; -} - -Bool -uniDRICreateDrawable(Display * ndpy, int screen, - Drawable drawable, drm_drawable_t * hHWDrawable) -{ - Display *const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICreateDrawableReply rep; - xXF86DRICreateDrawableReq *req; - - TRACE("CreateDrawable..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICreateDrawable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICreateDrawable; - req->screen = screen; - req->drawable = drawable; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateDrawable... return False"); - return False; - } - *hHWDrawable = rep.hHWDrawable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateDrawable... return True"); - return True; -} - -Bool -uniDRIDestroyDrawable(Display * ndpy, int screen, Drawable drawable) -{ - Display *const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIDestroyDrawableReq *req; - - TRACE("DestroyDrawable..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIDestroyDrawable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIDestroyDrawable; - req->screen = screen; - req->drawable = drawable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("DestroyDrawable... return True"); - return True; -} - -Bool -uniDRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, - unsigned int *index, unsigned int *stamp, - int *X, int *Y, int *W, int *H, - int *numClipRects, drm_clip_rect_t ** pClipRects, - int *backX, int *backY, - int *numBackClipRects, - drm_clip_rect_t ** pBackClipRects) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetDrawableInfoReply rep; - xXF86DRIGetDrawableInfoReq *req; - int total_rects; - - TRACE("GetDrawableInfo..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetDrawableInfo, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetDrawableInfo; - req->screen = screen; - req->drawable = drawable; - - if (!_XReply(dpy, (xReply *) & rep, 1, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return False"); - return False; - } - *index = rep.drawableTableIndex; - *stamp = rep.drawableTableStamp; - *X = (int)rep.drawableX; - *Y = (int)rep.drawableY; - *W = (int)rep.drawableWidth; - *H = (int)rep.drawableHeight; - *numClipRects = rep.numClipRects; - total_rects = *numClipRects; - - *backX = rep.backX; - *backY = rep.backY; - *numBackClipRects = rep.numBackClipRects; - total_rects += *numBackClipRects; - -#if 0 - /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks - * backwards compatibility (Because of the >> 2 shift) but the fix - * enables multi-threaded apps to work. - */ - if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - - SIZEOF(xGenericReply) + - total_rects * sizeof(drm_clip_rect_t)) + - 3) & ~3) >> 2)) { - _XEatData(dpy, rep.length); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return False"); - return False; - } -#endif - - if (*numClipRects) { - int len = sizeof(drm_clip_rect_t) * (*numClipRects); - - *pClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); - if (*pClipRects) - _XRead(dpy, (char *)*pClipRects, len); - } else { - *pClipRects = NULL; - } - - if (*numBackClipRects) { - int len = sizeof(drm_clip_rect_t) * (*numBackClipRects); - - *pBackClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); - if (*pBackClipRects) - _XRead(dpy, (char *)*pBackClipRects, len); - } else { - *pBackClipRects = NULL; - } - - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return True"); - return True; -} - -Bool -uniDRIGetDeviceInfo(dpy, screen, hFrameBuffer, - fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate) - Display *dpy; - int screen; - drm_handle_t *hFrameBuffer; - int *fbOrigin; - int *fbSize; - int *fbStride; - int *devPrivateSize; - void **pDevPrivate; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetDeviceInfoReply rep; - xXF86DRIGetDeviceInfoReq *req; - - TRACE("GetDeviceInfo..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetDeviceInfo, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetDeviceInfo; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return False"); - return False; - } - - *hFrameBuffer = rep.hFrameBufferLow; -#ifdef LONG64 - if (sizeof(drm_handle_t) == 8) { - *hFrameBuffer |= ((unsigned long)rep.hFrameBufferHigh) << 32; - } -#endif - - *fbOrigin = rep.framebufferOrigin; - *fbSize = rep.framebufferSize; - *fbStride = rep.framebufferStride; - *devPrivateSize = rep.devPrivateSize; - - if (rep.length) { - if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) { - _XEatData(dpy, ((rep.devPrivateSize + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return False"); - return False; - } - _XRead(dpy, (char *)*pDevPrivate, rep.devPrivateSize); - } else { - *pDevPrivate = NULL; - } - - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return True"); - return True; -} diff --git a/src/gallium/winsys/drm/radeon/python/xf86dri.h b/src/gallium/winsys/drm/radeon/python/xf86dri.h deleted file mode 100644 index bf6de37d9dd..00000000000 --- a/src/gallium/winsys/drm/radeon/python/xf86dri.h +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -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 PRECISION INSIGHT 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. - -**************************************************************************/ - -/** - * \file xf86dri.h - * Protocol numbers and function prototypes for DRI X protocol. - * - * \author Kevin E. Martin <[email protected]> - * \author Jens Owen <[email protected]> - * \author Rickard E. (Rik) Faith <[email protected]> - */ - -#ifndef _XF86DRI_H_ -#define _XF86DRI_H_ - -#include <stdint.h> -#include <X11/Xfuncproto.h> -#include <drm/drm.h> - -#define X_XF86DRIQueryVersion 0 -#define X_XF86DRIQueryDirectRenderingCapable 1 -#define X_XF86DRIOpenConnection 2 -#define X_XF86DRICloseConnection 3 -#define X_XF86DRIGetClientDriverName 4 -#define X_XF86DRICreateContext 5 -#define X_XF86DRIDestroyContext 6 -#define X_XF86DRICreateDrawable 7 -#define X_XF86DRIDestroyDrawable 8 -#define X_XF86DRIGetDrawableInfo 9 -#define X_XF86DRIGetDeviceInfo 10 -#define X_XF86DRIAuthConnection 11 -#define X_XF86DRIOpenFullScreen 12 /* Deprecated */ -#define X_XF86DRICloseFullScreen 13 /* Deprecated */ - -#define XF86DRINumberEvents 0 - -#define XF86DRIClientNotLocal 0 -#define XF86DRIOperationNotSupported 1 -#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1) - -#ifndef _XF86DRI_SERVER_ - -_XFUNCPROTOBEGIN - Bool uniDRIQueryExtension(Display * dpy, int *event_base, - int *error_base); - -Bool uniDRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion, - int *patchVersion); - -Bool uniDRIQueryDirectRenderingCapable(Display * dpy, int screen, - Bool * isCapable); - -Bool uniDRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, - char **busIDString); - -Bool uniDRIAuthConnection(Display * dpy, int screen, drm_magic_t magic); - -Bool uniDRICloseConnection(Display * dpy, int screen); - -Bool uniDRIGetClientDriverName(Display * dpy, int screen, - int *ddxDriverMajorVersion, - int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, - char **clientDriverName); - -Bool uniDRICreateContext(Display * dpy, int screen, Visual * visual, - XID * ptr_to_returned_context_id, - drm_context_t * hHWContext); - -Bool uniDRICreateContextWithConfig(Display * dpy, int screen, int configID, - XID * ptr_to_returned_context_id, - drm_context_t * hHWContext); - -extern Bool uniDRIDestroyContext(Display * dpy, int screen, XID context_id); - -extern Bool uniDRICreateDrawable(Display * dpy, int screen, - Drawable drawable, - drm_drawable_t * hHWDrawable); - -extern Bool uniDRIDestroyDrawable(Display * dpy, int screen, - Drawable drawable); - -Bool uniDRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, - unsigned int *index, unsigned int *stamp, - int *X, int *Y, int *W, int *H, - int *numClipRects, drm_clip_rect_t ** pClipRects, - int *backX, int *backY, - int *numBackClipRects, - drm_clip_rect_t ** pBackClipRects); - -Bool uniDRIGetDeviceInfo(Display * dpy, int screen, - drm_handle_t * hFrameBuffer, int *fbOrigin, - int *fbSize, int *fbStride, int *devPrivateSize, - void **pDevPrivate); - -_XFUNCPROTOEND -#endif /* _XF86DRI_SERVER_ */ -#endif /* _XF86DRI_H_ */ diff --git a/src/gallium/winsys/drm/radeon/python/xf86dristr.h b/src/gallium/winsys/drm/radeon/python/xf86dristr.h deleted file mode 100644 index d8989963609..00000000000 --- a/src/gallium/winsys/drm/radeon/python/xf86dristr.h +++ /dev/null @@ -1,389 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -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 PRECISION INSIGHT 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. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin <[email protected]> - * Jens Owen <[email protected]> - * Rickard E. (Rik) Fiath <[email protected]> - * - */ - -#ifndef _XF86DRISTR_H_ -#define _XF86DRISTR_H_ - -#include "xf86dri.h" - -#define XF86DRINAME "XFree86-DRI" - -/* The DRI version number. This was originally set to be the same of the - * XFree86 version number. However, this version is really indepedent of - * the XFree86 version. - * - * Version History: - * 4.0.0: Original - * 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02 - * 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02 - */ -#define XF86DRI_MAJOR_VERSION 4 -#define XF86DRI_MINOR_VERSION 1 -#define XF86DRI_PATCH_VERSION 0 - -typedef struct _XF86DRIQueryVersion -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIQueryVersion */ - CARD16 length B16; -} xXF86DRIQueryVersionReq; - -#define sz_xXF86DRIQueryVersionReq 4 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 majorVersion B16; /* major version of DRI protocol */ - CARD16 minorVersion B16; /* minor version of DRI protocol */ - CARD32 patchVersion B32; /* patch version of DRI protocol */ - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIQueryVersionReply; - -#define sz_xXF86DRIQueryVersionReply 32 - -typedef struct _XF86DRIQueryDirectRenderingCapable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIQueryDirectRenderingCapableReq; - -#define sz_xXF86DRIQueryDirectRenderingCapableReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - BOOL isCapable; - BOOL pad2; - BOOL pad3; - BOOL pad4; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; - CARD32 pad9 B32; -} xXF86DRIQueryDirectRenderingCapableReply; - -#define sz_xXF86DRIQueryDirectRenderingCapableReply 32 - -typedef struct _XF86DRIOpenConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIOpenConnection */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIOpenConnectionReq; - -#define sz_xXF86DRIOpenConnectionReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hSAREALow B32; - CARD32 hSAREAHigh B32; - CARD32 busIdStringLength B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xXF86DRIOpenConnectionReply; - -#define sz_xXF86DRIOpenConnectionReply 32 - -typedef struct _XF86DRIAuthConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseConnection */ - CARD16 length B16; - CARD32 screen B32; - CARD32 magic B32; -} xXF86DRIAuthConnectionReq; - -#define sz_xXF86DRIAuthConnectionReq 12 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 authenticated B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIAuthConnectionReply; - -#define zx_xXF86DRIAuthConnectionReply 32 - -typedef struct _XF86DRICloseConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseConnection */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRICloseConnectionReq; - -#define sz_xXF86DRICloseConnectionReq 8 - -typedef struct _XF86DRIGetClientDriverName -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetClientDriverName */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIGetClientDriverNameReq; - -#define sz_xXF86DRIGetClientDriverNameReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 ddxDriverMajorVersion B32; - CARD32 ddxDriverMinorVersion B32; - CARD32 ddxDriverPatchVersion B32; - CARD32 clientDriverNameLength B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIGetClientDriverNameReply; - -#define sz_xXF86DRIGetClientDriverNameReply 32 - -typedef struct _XF86DRICreateContext -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICreateContext */ - CARD16 length B16; - CARD32 screen B32; - CARD32 visual B32; - CARD32 context B32; -} xXF86DRICreateContextReq; - -#define sz_xXF86DRICreateContextReq 16 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hHWContext B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRICreateContextReply; - -#define sz_xXF86DRICreateContextReply 32 - -typedef struct _XF86DRIDestroyContext -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIDestroyContext */ - CARD16 length B16; - CARD32 screen B32; - CARD32 context B32; -} xXF86DRIDestroyContextReq; - -#define sz_xXF86DRIDestroyContextReq 12 - -typedef struct _XF86DRICreateDrawable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICreateDrawable */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRICreateDrawableReq; - -#define sz_xXF86DRICreateDrawableReq 12 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hHWDrawable B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRICreateDrawableReply; - -#define sz_xXF86DRICreateDrawableReply 32 - -typedef struct _XF86DRIDestroyDrawable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIDestroyDrawable */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIDestroyDrawableReq; - -#define sz_xXF86DRIDestroyDrawableReq 12 - -typedef struct _XF86DRIGetDrawableInfo -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetDrawableInfo */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIGetDrawableInfoReq; - -#define sz_xXF86DRIGetDrawableInfoReq 12 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 drawableTableIndex B32; - CARD32 drawableTableStamp B32; - INT16 drawableX B16; - INT16 drawableY B16; - INT16 drawableWidth B16; - INT16 drawableHeight B16; - CARD32 numClipRects B32; - INT16 backX B16; - INT16 backY B16; - CARD32 numBackClipRects B32; -} xXF86DRIGetDrawableInfoReply; - -#define sz_xXF86DRIGetDrawableInfoReply 36 - -typedef struct _XF86DRIGetDeviceInfo -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetDeviceInfo */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIGetDeviceInfoReq; - -#define sz_xXF86DRIGetDeviceInfoReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hFrameBufferLow B32; - CARD32 hFrameBufferHigh B32; - CARD32 framebufferOrigin B32; - CARD32 framebufferSize B32; - CARD32 framebufferStride B32; - CARD32 devPrivateSize B32; -} xXF86DRIGetDeviceInfoReply; - -#define sz_xXF86DRIGetDeviceInfoReply 32 - -typedef struct _XF86DRIOpenFullScreen -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIOpenFullScreen */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIOpenFullScreenReq; - -#define sz_xXF86DRIOpenFullScreenReq 12 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 isFullScreen B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIOpenFullScreenReply; - -#define sz_xXF86DRIOpenFullScreenReply 32 - -typedef struct _XF86DRICloseFullScreen -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseFullScreen */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRICloseFullScreenReq; - -#define sz_xXF86DRICloseFullScreenReq 12 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; -} xXF86DRICloseFullScreenReply; - -#define sz_xXF86DRICloseFullScreenReply 32 - -#endif /* _XF86DRISTR_H_ */ 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 1dcbc419dbb..657544dcb21 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c @@ -44,12 +44,22 @@ #include <stdio.h> +static struct svga_winsys_surface * +vmw_drm_surface_from_handle(struct svga_winsys_screen *sws, + struct winsys_handle *whandle, + SVGA3dSurfaceFormat *format); +static boolean +vmw_drm_surface_get_handle(struct svga_winsys_screen *sws, + struct svga_winsys_surface *surface, + unsigned stride, + struct winsys_handle *whandle); + static struct dri1_api dri1_api_hooks; static struct dri1_api_version ddx_required = { 0, 1, 0 }; 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_required = { 1, 0, 0 }; static struct dri1_api_version drm_compat = { 1, 0, 0 }; static struct dri1_api_version drm_scanout = { 0, 9, 0 }; @@ -129,7 +139,12 @@ vmw_drm_create_screen(struct drm_api *drm_api, &drm_compat, "use old scanout field (not a error)")) use_old_scanout_flag = TRUE; dri1->api = &dri1_api_hooks; +#if 0 break; +#else + assert(!"No dri 1 support for now\n"); + return NULL; +#endif default: return NULL; } @@ -139,6 +154,10 @@ vmw_drm_create_screen(struct drm_api *drm_api, if (!vws) goto out_no_vws; + /* XXX do this properly */ + vws->base.surface_from_handle = vmw_drm_surface_from_handle; + vws->base.surface_get_handle = vmw_drm_surface_get_handle; + screen = svga_screen_create( &vws->base ); if (!screen) goto out_no_screen; @@ -200,6 +219,7 @@ vmw_dri1_present_locked(struct pipe_context *locked_pipe, const struct drm_clip_rect *bbox, struct pipe_fence_handle **p_fence) { +#if 0 struct svga_winsys_surface *srf = svga_screen_texture_get_winsys_surface(surf->texture); struct vmw_svga_winsys_surface *vsrf = vmw_svga_winsys_surface(srf); @@ -246,21 +266,19 @@ vmw_dri1_present_locked(struct pipe_context *locked_pipe, *p_fence = (visible) ? vmw_pipe_fence(fence_seq) : NULL; vmw_svga_winsys_surface_reference(&vsrf, NULL); +#else + assert(!"No dri 1 support for now\n"); +#endif } -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) +static struct svga_winsys_surface * +vmw_drm_surface_from_handle(struct svga_winsys_screen *sws, + struct winsys_handle *whandle, + SVGA3dSurfaceFormat *format) { 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_texture *tex; + struct vmw_winsys_screen *vws = vmw_winsys_screen(sws); union drm_vmw_surface_reference_arg arg; struct drm_vmw_surface_arg *req = &arg.req; struct drm_vmw_surface_create_req *rep = &arg.rep; @@ -273,7 +291,7 @@ vmw_drm_texture_from_handle(struct drm_api *drm_api, */ memset(&arg, 0, sizeof(arg)); - req->sid = handle; + req->sid = whandle->handle; ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_REF_SURFACE, &arg, sizeof(arg)); @@ -281,14 +299,14 @@ vmw_drm_texture_from_handle(struct drm_api *drm_api, if (ret) { fprintf(stderr, "Failed referencing shared surface. SID %d.\n" "Error %d (%s).\n", - handle, ret, strerror(-ret)); + whandle->handle, ret, strerror(-ret)); return NULL; } if (rep->mip_levels[0] != 1) { fprintf(stderr, "Incorrect number of mipmap levels on shared surface." " SID %d, levels %d\n", - handle, rep->mip_levels[0]); + whandle->handle, rep->mip_levels[0]); goto out_mip; } @@ -296,7 +314,7 @@ vmw_drm_texture_from_handle(struct drm_api *drm_api, if (rep->mip_levels[i] != 0) { fprintf(stderr, "Incorrect number of faces levels on shared surface." " SID %d, face %d present.\n", - handle, i); + whandle->handle, i); goto out_mip; } } @@ -308,38 +326,32 @@ vmw_drm_texture_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; + vsrf->sid = whandle->handle; ssrf = svga_winsys_surface(vsrf); - tex = svga_screen_texture_wrap_surface(screen, templat, rep->format, ssrf); - if (!tex) - vmw_svga_winsys_surface_reference(&vsrf, NULL); + *format = rep->format; + + return ssrf; - return tex; - out_mip: - vmw_ioctl_surface_destroy(vws, handle); +out_mip: + vmw_ioctl_surface_destroy(vws, whandle->handle); return NULL; } static boolean -vmw_drm_handle_from_texture(struct drm_api *drm_api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle) +vmw_drm_surface_get_handle(struct svga_winsys_screen *sws, + struct svga_winsys_surface *surface, + unsigned stride, + struct winsys_handle *whandle) { - struct svga_winsys_surface *surface = - svga_screen_texture_get_winsys_surface(texture); struct vmw_svga_winsys_surface *vsrf; if (!surface) return FALSE; vsrf = vmw_svga_winsys_surface(surface); - *handle = vsrf->sid; - *stride = util_format_get_nblocksx(texture->format, texture->width0) * - util_format_get_blocksize(texture->format); + whandle->handle = vsrf->sid; + whandle->stride = stride; - vmw_svga_winsys_surface_reference(&vsrf, NULL); return TRUE; } @@ -353,9 +365,6 @@ static struct drm_api vmw_drm_api_hooks = { .name = "vmwgfx", .driver_name = "vmwgfx", .create_screen = vmw_drm_create_screen, - .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, }; struct drm_api* drm_api_create() diff --git a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h index 1457966db81..47914bdb711 100644 --- a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h +++ b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h @@ -260,15 +260,23 @@ union drm_vmw_surface_reference_arg { * to the nearest kernel tick. * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an * uint64_t. + * @version: Allows expanding the execbuf ioctl parameters without breaking + * backwards compatibility, since user-space will always tell the kernel + * which version it uses. + * @flags: Execbuf flags. None currently. * * Argument to the DRM_VMW_EXECBUF Ioctl. */ +#define DRM_VMW_EXECBUF_VERSION 0 + struct drm_vmw_execbuf_arg { uint64_t commands; uint32_t command_size; uint32_t throttle_us; uint64_t fence_rep; + uint32_t version; + uint32_t flags; }; /** diff --git a/src/gallium/winsys/drm/vmware/dri/SConscript b/src/gallium/winsys/drm/vmware/dri/SConscript index 84319f91ff1..d26d0cd7483 100644 --- a/src/gallium/winsys/drm/vmware/dri/SConscript +++ b/src/gallium/winsys/drm/vmware/dri/SConscript @@ -48,6 +48,7 @@ if env['platform'] == 'linux': svgadrm, svga, mesa, + glsl, gallium, ]) diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h b/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h index 3efe851a4be..ba754b51e47 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h @@ -40,8 +40,11 @@ struct vmw_dma_buffer; -struct vmw_driver +struct vmw_customizer { + CustomizerRec base; + ScrnInfoPtr pScrn; + int fd; void *cursor_priv; @@ -50,11 +53,10 @@ struct vmw_driver void *video_priv; }; -static INLINE struct vmw_driver * -vmw_driver(ScrnInfoPtr pScrn) +static INLINE struct vmw_customizer * +vmw_customizer(CustomizerPtr cust) { - modesettingPtr ms = modesettingPTR(pScrn); - return ms ? (struct vmw_driver *)ms->winsys_priv : NULL; + return cust ? (struct vmw_customizer *) cust : NULL; } @@ -62,40 +64,40 @@ vmw_driver(ScrnInfoPtr pScrn) * vmw_video.c */ -Bool vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw); +Bool vmw_video_init(struct vmw_customizer *vmw); -Bool vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw); +Bool vmw_video_close(struct vmw_customizer *vmw); -void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw); +void vmw_video_stop_all(struct vmw_customizer *vmw); /*********************************************************************** * vmw_ioctl.c */ -int vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot); +int vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot); -struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_driver *vmw, +struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_customizer *vmw, uint32_t size, unsigned *handle); -void * vmw_ioctl_buffer_map(struct vmw_driver *vmw, +void * vmw_ioctl_buffer_map(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf); -void vmw_ioctl_buffer_unmap(struct vmw_driver *vmw, +void vmw_ioctl_buffer_unmap(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf); -void vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, +void vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf); -int vmw_ioctl_supports_streams(struct vmw_driver *vmw); +int vmw_ioctl_supports_streams(struct vmw_customizer *vmw); -int vmw_ioctl_num_streams(struct vmw_driver *vmw, +int vmw_ioctl_num_streams(struct vmw_customizer *vmw, uint32_t *ntot, uint32_t *nfree); -int vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id); +int vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id); -int vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out); +int vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out); #endif diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c b/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c index ab2b5fadc49..521578ab35d 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c @@ -57,7 +57,7 @@ struct vmw_dma_buffer }; static int -vmw_ioctl_get_param(struct vmw_driver *vmw, uint32_t param, uint64_t *out) +vmw_ioctl_get_param(struct vmw_customizer *vmw, uint32_t param, uint64_t *out) { struct drm_vmw_getparam_arg gp_arg; int ret; @@ -75,7 +75,7 @@ vmw_ioctl_get_param(struct vmw_driver *vmw, uint32_t param, uint64_t *out) } int -vmw_ioctl_supports_streams(struct vmw_driver *vmw) +vmw_ioctl_supports_streams(struct vmw_customizer *vmw) { uint64_t value; int ret; @@ -88,7 +88,7 @@ vmw_ioctl_supports_streams(struct vmw_driver *vmw) } int -vmw_ioctl_num_streams(struct vmw_driver *vmw, +vmw_ioctl_num_streams(struct vmw_customizer *vmw, uint32_t *ntot, uint32_t *nfree) { uint64_t v1, v2; @@ -109,7 +109,7 @@ vmw_ioctl_num_streams(struct vmw_driver *vmw, } int -vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out) +vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out) { struct drm_vmw_stream_arg s_arg; int ret; @@ -125,7 +125,7 @@ vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out) } int -vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id) +vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id) { struct drm_vmw_stream_arg s_arg; int ret; @@ -140,7 +140,7 @@ vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id) } int -vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot) +vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot) { struct drm_vmw_cursor_bypass_arg arg; int ret; @@ -157,7 +157,7 @@ vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot) } struct vmw_dma_buffer * -vmw_ioctl_buffer_create(struct vmw_driver *vmw, uint32_t size, unsigned *handle) +vmw_ioctl_buffer_create(struct vmw_customizer *vmw, uint32_t size, unsigned *handle) { struct vmw_dma_buffer *buf; union drm_vmw_alloc_dmabuf_arg arg; @@ -198,7 +198,7 @@ err: } void -vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) +vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf) { struct drm_vmw_unref_dmabuf_arg arg; @@ -215,7 +215,7 @@ vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) } void * -vmw_ioctl_buffer_map(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) +vmw_ioctl_buffer_map(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf) { void *map; @@ -236,7 +236,7 @@ vmw_ioctl_buffer_map(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) } void -vmw_ioctl_buffer_unmap(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) +vmw_ioctl_buffer_unmap(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf) { --buf->map_count; } diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c index 7c9757cce95..f43f91e5c0d 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c @@ -41,7 +41,8 @@ xf86CrtcFuncsRec vmw_screen_crtc_funcs; static void vmw_screen_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image) { - struct vmw_driver *vmw = modesettingPTR(crtc->scrn)->winsys_priv; + struct vmw_customizer *vmw = + vmw_customizer(xorg_customizer(crtc->scrn)); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); xf86CrtcFuncsPtr funcs = vmw->cursor_priv; CursorPtr c = config->cursor; @@ -53,8 +54,9 @@ vmw_screen_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image) } static void -vmw_screen_cursor_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +vmw_screen_cursor_init(struct vmw_customizer *vmw) { + ScrnInfoPtr pScrn = vmw->pScrn; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); int i; @@ -70,9 +72,9 @@ vmw_screen_cursor_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw) } static void -vmw_screen_cursor_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +vmw_screen_cursor_close(struct vmw_customizer *vmw) { - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(vmw->pScrn); int i; vmw_ioctl_cursor_bypass(vmw, 0, 0); @@ -82,50 +84,39 @@ vmw_screen_cursor_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw) } static Bool -vmw_screen_init(ScrnInfoPtr pScrn) +vmw_screen_init(CustomizerPtr cust, int fd) { - modesettingPtr ms = modesettingPTR(pScrn); - struct vmw_driver *vmw; - - vmw = xnfcalloc(sizeof(*vmw), 1); - if (!vmw) - return FALSE; + struct vmw_customizer *vmw = vmw_customizer(cust); - vmw->fd = ms->fd; - ms->winsys_priv = vmw; - - vmw_screen_cursor_init(pScrn, vmw); + vmw->fd = fd; + vmw_screen_cursor_init(vmw); /* if gallium is used then we don't need to do anything more. */ - if (ms->screen) + if (xorg_has_gallium(vmw->pScrn)) return TRUE; - vmw_video_init(pScrn, vmw); + vmw_video_init(vmw); return TRUE; } static Bool -vmw_screen_close(ScrnInfoPtr pScrn) +vmw_screen_close(CustomizerPtr cust) { - modesettingPtr ms = modesettingPTR(pScrn); - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(cust); if (!vmw) return TRUE; - vmw_screen_cursor_close(pScrn, vmw); - - vmw_video_close(pScrn, vmw); + vmw_screen_cursor_close(vmw); - ms->winsys_priv = NULL; - xfree(vmw); + vmw_video_close(vmw); return TRUE; } static Bool -vmw_screen_enter_vt(ScrnInfoPtr pScrn) +vmw_screen_enter_vt(CustomizerPtr cust) { debug_printf("%s: enter\n", __func__); @@ -133,13 +124,13 @@ vmw_screen_enter_vt(ScrnInfoPtr pScrn) } static Bool -vmw_screen_leave_vt(ScrnInfoPtr pScrn) +vmw_screen_leave_vt(CustomizerPtr cust) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(cust); debug_printf("%s: enter\n", __func__); - vmw_video_stop_all(pScrn, vmw); + vmw_video_stop_all(vmw); return TRUE; } @@ -153,18 +144,27 @@ static Bool (*vmw_screen_pre_init_saved)(ScrnInfoPtr pScrn, int flags) = NULL; static Bool vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags) { - modesettingPtr ms; + struct vmw_customizer *vmw; + CustomizerPtr cust; + + vmw = xnfcalloc(1, sizeof(*vmw)); + if (!vmw) + return FALSE; + + cust = &vmw->base; + + cust->winsys_screen_init = vmw_screen_init; + cust->winsys_screen_close = vmw_screen_close; + cust->winsys_enter_vt = vmw_screen_enter_vt; + cust->winsys_leave_vt = vmw_screen_leave_vt; + vmw->pScrn = pScrn; + + pScrn->driverPrivate = cust; pScrn->PreInit = vmw_screen_pre_init_saved; if (!pScrn->PreInit(pScrn, flags)) return FALSE; - ms = modesettingPTR(pScrn); - ms->winsys_screen_init = vmw_screen_init; - ms->winsys_screen_close = vmw_screen_close; - ms->winsys_enter_vt = vmw_screen_enter_vt; - ms->winsys_leave_vt = vmw_screen_leave_vt; - return TRUE; } diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c index ff3b992d078..de28f06a475 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c @@ -226,7 +226,7 @@ static void vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion, /* * Local functions. */ -static XF86VideoAdaptorPtr vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_driver *vmw); +static XF86VideoAdaptorPtr vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw); static int vmw_video_port_init(ScrnInfoPtr pScrn, struct vmw_video_port *port, @@ -243,9 +243,9 @@ static int vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port, short height, RegionPtr clipBoxes); static void vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port); -static int vmw_video_buffer_alloc(struct vmw_driver *vmw, int size, +static int vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size, struct vmw_video_buffer *out); -static int vmw_video_buffer_free(struct vmw_driver *vmw, +static int vmw_video_buffer_free(struct vmw_customizer *vmw, struct vmw_video_buffer *out); @@ -267,8 +267,9 @@ static int vmw_video_buffer_free(struct vmw_driver *vmw, */ Bool -vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +vmw_video_init(struct vmw_customizer *vmw) { + ScrnInfoPtr pScrn = vmw->pScrn; ScreenPtr pScreen = pScrn->pScreen; XF86VideoAdaptorPtr *overlayAdaptors, *newAdaptors = NULL; XF86VideoAdaptorPtr newAdaptor = NULL; @@ -345,8 +346,9 @@ vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw) */ Bool -vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +vmw_video_close(struct vmw_customizer *vmw) { + ScrnInfoPtr pScrn = vmw->pScrn; struct vmw_video_private *video; int i; @@ -387,8 +389,9 @@ vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw) *----------------------------------------------------------------------------- */ -void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +void vmw_video_stop_all(struct vmw_customizer *vmw) { + ScrnInfoPtr pScrn = vmw->pScrn; struct vmw_video_private *video = vmw->video_priv; int i; @@ -421,7 +424,7 @@ void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw) */ static XF86VideoAdaptorPtr -vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw) { XF86VideoAdaptorPtr adaptor; struct vmw_video_private *video; @@ -515,7 +518,7 @@ vmw_video_port_init(ScrnInfoPtr pScrn, struct vmw_video_port *port, unsigned char *buf, short width, short height, RegionPtr clipBoxes) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn)); unsigned short w, h; int i, ret; @@ -583,7 +586,7 @@ vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port, unsigned char *buf, short width, short height, RegionPtr clipBoxes) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn)); struct drm_vmw_control_stream_arg arg; unsigned short w, h; int size; @@ -675,7 +678,7 @@ vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port, static void vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn)); uint32 id, colorKey, flags; Bool isAutoPaintColorkey; int i; @@ -721,7 +724,7 @@ vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port) */ static int -vmw_video_buffer_alloc(struct vmw_driver *vmw, int size, +vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size, struct vmw_video_buffer *out) { out->buf = vmw_ioctl_buffer_create(vmw, size, &out->handle); @@ -764,7 +767,7 @@ vmw_video_buffer_alloc(struct vmw_driver *vmw, int size, */ static int -vmw_video_buffer_free(struct vmw_driver *vmw, +vmw_video_buffer_free(struct vmw_customizer *vmw, struct vmw_video_buffer *out) { if (out->size == 0) @@ -814,7 +817,7 @@ vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y, Bool sync, RegionPtr clipBoxes, pointer data, DrawablePtr dst) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn)); struct vmw_video_port *port = data; debug_printf("%s: enter (%u, %u) (%ux%u) (%u, %u) (%ux%u) (%ux%u)\n", __func__, @@ -852,7 +855,7 @@ vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y, static void vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn)); struct vmw_video_port *port = data; struct drm_vmw_control_stream_arg arg; int ret; diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c index cd273d091fe..87aad25b24f 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c @@ -33,12 +33,50 @@ #include "vmw_hook.h" + +/* + * Defines and modinfo + */ + +#define VMWGFX_DRIVER_NAME "vmwgfx" + +#define VMW_STRING_INNER(s) #s +#define VMW_STRING(str) VMW_STRING_INNER(str) + +#define VMWGFX_VERSION_MAJOR 11 +#define VMWGFX_VERSION_MINOR 0 +#define VMWGFX_VERSION_PATCH 0 +#define VMWGFX_VERSION_STRING_MAJOR VMW_STRING(VMWGFX_VERSION_MAJOR) +#define VMWGFX_VERSION_STRING_MINOR VMW_STRING(VMWGFX_VERSION_MINOR) +#define VMWGFX_VERSION_STRING_PATCH VMW_STRING(VMWGFX_VERSION_PATCH) + +#define VMWGFX_DRIVER_VERSION \ + (VMWGFX_VERSION_MAJOR * 65536 + VMWGFX_VERSION_MINOR * 256 + VMWGFX_VERSION_PATCH) +#define VMWGFX_DRIVER_VERSION_STRING \ + VMWGFX_VERSION_STRING_MAJOR "." VMWGFX_VERSION_STRING_MINOR \ + "." VMWGFX_VERSION_STRING_PATCH + +/* + * Standard four digit version string expected by VMware Tools installer. + * As the driver's version is only {major, minor, patchlevel}, simply append an + * extra zero for the fourth digit. + */ +#ifdef __GNUC__ +_X_EXPORT const char vmwgfx_drv_modinfo[] __attribute__((section(".modinfo"),unused)) = + "version=" VMWGFX_DRIVER_VERSION_STRING ".0"; +#endif + static void vmw_xorg_identify(int flags); _X_EXPORT Bool vmw_xorg_pci_probe(DriverPtr driver, int entity_num, struct pci_device *device, intptr_t match_data); + +/* + * Tables + */ + static const struct pci_id_match vmw_xorg_device_match[] = { {0x15ad, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, @@ -55,12 +93,12 @@ static PciChipsets vmw_xorg_pci_devices[] = { }; static XF86ModuleVersionInfo vmw_xorg_version = { - "vmwgfx", + VMWGFX_DRIVER_NAME, MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, XORG_VERSION_CURRENT, - 0, 1, 0, /* major, minor, patch */ + VMWGFX_VERSION_MAJOR, VMWGFX_VERSION_MINOR, VMWGFX_VERSION_PATCH, ABI_CLASS_VIDEODRV, ABI_VIDEODRV_VERSION, MOD_CLASS_VIDEODRV, @@ -73,7 +111,7 @@ static XF86ModuleVersionInfo vmw_xorg_version = { _X_EXPORT DriverRec vmwgfx = { 1, - "vmwgfx", + VMWGFX_DRIVER_NAME, vmw_xorg_identify, NULL, xorg_tracker_available_options, @@ -92,6 +130,7 @@ _X_EXPORT XF86ModuleData vmwgfxModuleData = { NULL }; + /* * Xorg driver functions */ diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript index 4cbc86f3311..1267fc6eea4 100644 --- a/src/gallium/winsys/gdi/SConscript +++ b/src/gallium/winsys/gdi/SConscript @@ -1,5 +1,6 @@ ####################################################################### -# SConscript for gdi winsys +# SConscript for xlib winsys + Import('*') @@ -8,44 +9,15 @@ if env['platform'] == 'windows': env = env.Clone() env.Append(CPPPATH = [ - '#src/gallium/state_trackers/wgl', - ]) - - env.Append(LIBS = [ - 'gdi32', - 'user32', - 'kernel32', - 'ws2_32', + '#/src/gallium/include', + '#/src/gallium/auxiliary', + '#/src/gallium/drivers', ]) - sources = [] - drivers = [] - - if 'softpipe' in env['drivers']: - sources = ['gdi_softpipe_winsys.c'] - drivers = [softpipe] - - if 'llvmpipe' in env['drivers']: - env.Tool('llvm') - if 'LLVM_VERSION' in env: - sources = ['gdi_llvmpipe_winsys.c'] - drivers = [llvmpipe] - - if not sources or not drivers: - print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled' - Return() - - if env['gcc']: - sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def'] - else: - sources += ['#src/gallium/state_trackers/wgl/opengl32.def'] - - drivers += [trace] - - env['no_import_lib'] = 1 - - env.SharedLibrary( - target ='opengl32', - source = sources, - LIBS = wgl + glapi + mesa + drivers + gallium + glsl + env['LIBS'], + ws_gdi = env.ConvenienceLibrary( + target = 'ws_gdi', + source = [ + 'gdi_sw_winsys.c', + ] ) + Export('ws_gdi') diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c deleted file mode 100644 index 71360e55aac..00000000000 --- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c +++ /dev/null @@ -1,318 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/** - * @file - * Softpipe support. - * - * @author Keith Whitwell - * @author Brian Paul - * @author Jose Fonseca - */ - - -#include <windows.h> - -#include "util/u_simple_screen.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "softpipe/sp_winsys.h" -#include "softpipe/sp_texture.h" -#include "stw_winsys.h" - - -struct gdi_softpipe_buffer -{ - struct pipe_buffer base; - boolean userBuffer; /** Is this a user-space buffer? */ - void *data; - void *mapped; -}; - - -/** Cast wrapper */ -static INLINE struct gdi_softpipe_buffer * -gdi_softpipe_buffer( struct pipe_buffer *buf ) -{ - return (struct gdi_softpipe_buffer *)buf; -} - - -static void * -gdi_softpipe_buffer_map(struct pipe_winsys *winsys, - struct pipe_buffer *buf, - unsigned flags) -{ - struct gdi_softpipe_buffer *gdi_softpipe_buf = gdi_softpipe_buffer(buf); - gdi_softpipe_buf->mapped = gdi_softpipe_buf->data; - return gdi_softpipe_buf->mapped; -} - - -static void -gdi_softpipe_buffer_unmap(struct pipe_winsys *winsys, - struct pipe_buffer *buf) -{ - struct gdi_softpipe_buffer *gdi_softpipe_buf = gdi_softpipe_buffer(buf); - gdi_softpipe_buf->mapped = NULL; -} - - -static void -gdi_softpipe_buffer_destroy(struct pipe_buffer *buf) -{ - struct gdi_softpipe_buffer *oldBuf = gdi_softpipe_buffer(buf); - - if (oldBuf->data) { - if (!oldBuf->userBuffer) - align_free(oldBuf->data); - - oldBuf->data = NULL; - } - - FREE(oldBuf); -} - - -static const char * -gdi_softpipe_get_name(struct pipe_winsys *winsys) -{ - return "softpipe"; -} - - -static struct pipe_buffer * -gdi_softpipe_buffer_create(struct pipe_winsys *winsys, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct gdi_softpipe_buffer *buffer = CALLOC_STRUCT(gdi_softpipe_buffer); - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.alignment = alignment; - buffer->base.usage = usage; - buffer->base.size = size; - - buffer->data = align_malloc(size, alignment); - - return &buffer->base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -gdi_softpipe_user_buffer_create(struct pipe_winsys *winsys, - void *ptr, - unsigned bytes) -{ - struct gdi_softpipe_buffer *buffer; - - buffer = CALLOC_STRUCT(gdi_softpipe_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 struct pipe_buffer * -gdi_softpipe_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 -gdi_softpipe_dummy_flush_frontbuffer(struct pipe_winsys *winsys, - struct pipe_surface *surface, - void *context_private) -{ - assert(0); -} - - -static void -gdi_softpipe_fence_reference(struct pipe_winsys *winsys, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ -} - - -static int -gdi_softpipe_fence_signalled(struct pipe_winsys *winsys, - struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static int -gdi_softpipe_fence_finish(struct pipe_winsys *winsys, - struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static void -gdi_softpipe_destroy(struct pipe_winsys *winsys) -{ - FREE(winsys); -} - - -static struct pipe_screen * -gdi_softpipe_screen_create(void) -{ - static struct pipe_winsys *winsys; - struct pipe_screen *screen; - - winsys = CALLOC_STRUCT(pipe_winsys); - if(!winsys) - return NULL; - - winsys->destroy = gdi_softpipe_destroy; - - winsys->buffer_create = gdi_softpipe_buffer_create; - winsys->user_buffer_create = gdi_softpipe_user_buffer_create; - winsys->buffer_map = gdi_softpipe_buffer_map; - winsys->buffer_unmap = gdi_softpipe_buffer_unmap; - winsys->buffer_destroy = gdi_softpipe_buffer_destroy; - - winsys->surface_buffer_create = gdi_softpipe_surface_buffer_create; - - winsys->fence_reference = gdi_softpipe_fence_reference; - winsys->fence_signalled = gdi_softpipe_fence_signalled; - winsys->fence_finish = gdi_softpipe_fence_finish; - - winsys->flush_frontbuffer = gdi_softpipe_dummy_flush_frontbuffer; - winsys->get_name = gdi_softpipe_get_name; - - screen = softpipe_create_screen(winsys); - if(!screen) - gdi_softpipe_destroy(winsys); - - return screen; -} - - -static void -gdi_softpipe_present(struct pipe_screen *screen, - struct pipe_surface *surface, - HDC hDC) -{ - struct softpipe_texture *texture; - struct gdi_softpipe_buffer *buffer; - BITMAPINFO bmi; - - texture = softpipe_texture(surface->texture); - - buffer = gdi_softpipe_buffer(texture->buffer); - - memset(&bmi, 0, sizeof(BITMAPINFO)); - bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi.bmiHeader.biWidth = texture->stride[surface->level] / util_format_get_blocksize(surface->format); - bmi.bmiHeader.biHeight= -(long)surface->height; - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biBitCount = util_format_get_blocksizebits(surface->format); - bmi.bmiHeader.biCompression = BI_RGB; - bmi.bmiHeader.biSizeImage = 0; - bmi.bmiHeader.biXPelsPerMeter = 0; - bmi.bmiHeader.biYPelsPerMeter = 0; - bmi.bmiHeader.biClrUsed = 0; - bmi.bmiHeader.biClrImportant = 0; - - StretchDIBits(hDC, - 0, 0, surface->width, surface->height, - 0, 0, surface->width, surface->height, - buffer->data, &bmi, 0, SRCCOPY); -} - - -static const struct stw_winsys stw_winsys = { - &gdi_softpipe_screen_create, - &gdi_softpipe_present, - NULL, /* get_adapter_luid */ - NULL, /* shared_surface_open */ - NULL, /* shared_surface_close */ - NULL /* compose */ -}; - - -BOOL WINAPI -DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) -{ - switch (fdwReason) { - case DLL_PROCESS_ATTACH: - stw_init(&stw_winsys); - stw_init_thread(); - break; - - case DLL_THREAD_ATTACH: - stw_init_thread(); - break; - - case DLL_THREAD_DETACH: - stw_cleanup_thread(); - break; - - case DLL_PROCESS_DETACH: - stw_cleanup_thread(); - stw_cleanup(); - break; - } - return TRUE; -} diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_sw_winsys.c index e9e5990cf53..f5c0b7d56ec 100644 --- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_sw_winsys.c @@ -28,7 +28,7 @@ /** * @file - * LLVMpipe support. + * GDI software rasterizer support. * * @author Jose Fonseca <[email protected]> */ @@ -42,12 +42,11 @@ #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" -#include "llvmpipe/lp_winsys.h" -#include "llvmpipe/lp_texture.h" -#include "stw_winsys.h" +#include "state_tracker/sw_winsys.h" +#include "gdi_sw_winsys.h" -struct gdi_llvmpipe_displaytarget +struct gdi_sw_displaytarget { enum pipe_format format; unsigned width; @@ -63,20 +62,20 @@ struct gdi_llvmpipe_displaytarget /** Cast wrapper */ -static INLINE struct gdi_llvmpipe_displaytarget * -gdi_llvmpipe_displaytarget( struct llvmpipe_displaytarget *buf ) +static INLINE struct gdi_sw_displaytarget * +gdi_sw_displaytarget( struct sw_displaytarget *buf ) { - return (struct gdi_llvmpipe_displaytarget *)buf; + return (struct gdi_sw_displaytarget *)buf; } static boolean -gdi_llvmpipe_is_displaytarget_format_supported( struct llvmpipe_winsys *ws, +gdi_sw_is_displaytarget_format_supported( struct sw_winsys *ws, enum pipe_format format ) { switch(format) { - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return TRUE; /* TODO: Support other formats possible with BMPs, as described in @@ -89,47 +88,47 @@ gdi_llvmpipe_is_displaytarget_format_supported( struct llvmpipe_winsys *ws, static void * -gdi_llvmpipe_displaytarget_map(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt, +gdi_sw_displaytarget_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, unsigned flags ) { - struct gdi_llvmpipe_displaytarget *gdt = gdi_llvmpipe_displaytarget(dt); + struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt); return gdt->data; } static void -gdi_llvmpipe_displaytarget_unmap(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt ) +gdi_sw_displaytarget_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt ) { } static void -gdi_llvmpipe_displaytarget_destroy(struct llvmpipe_winsys *winsys, - struct llvmpipe_displaytarget *dt) +gdi_sw_displaytarget_destroy(struct sw_winsys *winsys, + struct sw_displaytarget *dt) { - struct gdi_llvmpipe_displaytarget *gdt = gdi_llvmpipe_displaytarget(dt); + struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt); align_free(gdt->data); FREE(gdt); } -static struct llvmpipe_displaytarget * -gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys, +static struct sw_displaytarget * +gdi_sw_displaytarget_create(struct sw_winsys *winsys, enum pipe_format format, unsigned width, unsigned height, unsigned alignment, unsigned *stride) { - struct gdi_llvmpipe_displaytarget *gdt; + struct gdi_sw_displaytarget *gdt; unsigned cpp; unsigned bpp; - gdt = CALLOC_STRUCT(gdi_llvmpipe_displaytarget); + gdt = CALLOC_STRUCT(gdi_sw_displaytarget); if(!gdt) goto no_gdt; @@ -160,7 +159,7 @@ gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys, gdt->bmi.bmiHeader.biClrImportant = 0; *stride = gdt->stride; - return (struct llvmpipe_displaytarget *)gdt; + return (struct sw_displaytarget *)gdt; no_data: FREE(gdt); @@ -169,104 +168,55 @@ no_gdt: } -static void -gdi_llvmpipe_displaytarget_display(struct llvmpipe_winsys *winsys, - struct llvmpipe_displaytarget *dt, - void *context_private) +void +gdi_sw_display( struct sw_winsys *winsys, + struct sw_displaytarget *dt, + HDC hDC ) { - assert(0); -} - + struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt); -static void -gdi_llvmpipe_destroy(struct llvmpipe_winsys *winsys) -{ - FREE(winsys); + StretchDIBits(hDC, + 0, 0, gdt->width, gdt->height, + 0, 0, gdt->width, gdt->height, + gdt->data, &gdt->bmi, 0, SRCCOPY); } - -static struct pipe_screen * -gdi_llvmpipe_screen_create(void) +static void +gdi_sw_displaytarget_display(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + void *context_private) { - static struct llvmpipe_winsys *winsys; - struct pipe_screen *screen; - - winsys = CALLOC_STRUCT(llvmpipe_winsys); - if(!winsys) - goto no_winsys; - - winsys->destroy = gdi_llvmpipe_destroy; - winsys->is_displaytarget_format_supported = gdi_llvmpipe_is_displaytarget_format_supported; - winsys->displaytarget_create = gdi_llvmpipe_displaytarget_create; - winsys->displaytarget_map = gdi_llvmpipe_displaytarget_map; - winsys->displaytarget_unmap = gdi_llvmpipe_displaytarget_unmap; - winsys->displaytarget_display = gdi_llvmpipe_displaytarget_display; - winsys->displaytarget_destroy = gdi_llvmpipe_displaytarget_destroy; + /* nasty: + */ + HDC hDC = (HDC)context_private; - screen = llvmpipe_create_screen(winsys); - if(!screen) - goto no_screen; - - return screen; - -no_screen: - FREE(winsys); -no_winsys: - return NULL; + gdi_sw_display(winsys, dt, hDC); } - - static void -gdi_llvmpipe_present(struct pipe_screen *screen, - struct pipe_surface *surface, - HDC hDC) +gdi_sw_destroy(struct sw_winsys *winsys) { - struct llvmpipe_texture *texture; - struct gdi_llvmpipe_displaytarget *gdt; - - texture = llvmpipe_texture(surface->texture); - gdt = gdi_llvmpipe_displaytarget(texture->dt); - - StretchDIBits(hDC, - 0, 0, gdt->width, gdt->height, - 0, 0, gdt->width, gdt->height, - gdt->data, &gdt->bmi, 0, SRCCOPY); + FREE(winsys); } +struct sw_winsys * +gdi_create_sw_winsys(void) +{ + static struct sw_winsys *winsys; -static const struct stw_winsys stw_winsys = { - &gdi_llvmpipe_screen_create, - &gdi_llvmpipe_present, - NULL, /* get_adapter_luid */ - NULL, /* shared_surface_open */ - NULL, /* shared_surface_close */ - NULL /* compose */ -}; + winsys = CALLOC_STRUCT(sw_winsys); + if(!winsys) + return NULL; + winsys->destroy = gdi_sw_destroy; + winsys->is_displaytarget_format_supported = gdi_sw_is_displaytarget_format_supported; + winsys->displaytarget_create = gdi_sw_displaytarget_create; + winsys->displaytarget_map = gdi_sw_displaytarget_map; + winsys->displaytarget_unmap = gdi_sw_displaytarget_unmap; + winsys->displaytarget_display = gdi_sw_displaytarget_display; + winsys->displaytarget_destroy = gdi_sw_displaytarget_destroy; -BOOL WINAPI -DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) -{ - switch (fdwReason) { - case DLL_PROCESS_ATTACH: - stw_init(&stw_winsys); - stw_init_thread(); - break; - - case DLL_THREAD_ATTACH: - stw_init_thread(); - break; - - case DLL_THREAD_DETACH: - stw_cleanup_thread(); - break; - - case DLL_PROCESS_DETACH: - stw_cleanup_thread(); - stw_cleanup(); - break; - } - return TRUE; + return winsys; } + diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.h b/src/gallium/winsys/gdi/gdi_sw_winsys.h new file mode 100644 index 00000000000..4bbcb47848b --- /dev/null +++ b/src/gallium/winsys/gdi/gdi_sw_winsys.h @@ -0,0 +1,16 @@ +#ifndef GDI_SW_WINSYS_H +#define GDI_SW_WINSYS_H + +#include <windows.h> + +#include "pipe/p_compiler.h" +#include "state_tracker/sw_winsys.h" + +void gdi_sw_display( struct sw_winsys *winsys, + struct sw_displaytarget *dt, + HDC hDC ); + +struct sw_winsys * +gdi_create_sw_winsys(void); + +#endif diff --git a/src/gallium/winsys/null/Makefile b/src/gallium/winsys/null/Makefile new file mode 100644 index 00000000000..3a3fb75ab36 --- /dev/null +++ b/src/gallium/winsys/null/Makefile @@ -0,0 +1,16 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = ws_null + +LIBRARY_INCLUDES = \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/gallium/auxiliary + +C_SOURCES = \ + null_sw_winsys.c + +include ../../Makefile.template + + diff --git a/src/gallium/winsys/null/SConscript b/src/gallium/winsys/null/SConscript new file mode 100644 index 00000000000..21837dc60c2 --- /dev/null +++ b/src/gallium/winsys/null/SConscript @@ -0,0 +1,21 @@ +####################################################################### +# SConscript for xlib winsys + + +Import('*') + +env = env.Clone() + +env.Append(CPPPATH = [ + '#/src/gallium/include', + '#/src/gallium/auxiliary', + '#/src/gallium/drivers', +]) + +ws_null = env.ConvenienceLibrary( + target = 'ws_null', + source = [ + 'null_sw_winsys.c', + ] +) +Export('ws_null') diff --git a/src/gallium/winsys/null/null_sw_winsys.c b/src/gallium/winsys/null/null_sw_winsys.c new file mode 100644 index 00000000000..d961d34860e --- /dev/null +++ b/src/gallium/winsys/null/null_sw_winsys.c @@ -0,0 +1,124 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + +/** + * @file + * Null software rasterizer winsys. + * + * There is no present support. Framebuffer data needs to be obtained via + * transfers. + * + * @author Jose Fonseca + */ + + +#include "pipe/p_format.h" +#include "util/u_memory.h" +#include "state_tracker/sw_winsys.h" +#include "null_sw_winsys.h" + + +static boolean +null_sw_is_displaytarget_format_supported(struct sw_winsys *ws, + enum pipe_format format ) +{ + return FALSE; +} + + +static void * +null_sw_displaytarget_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, + unsigned flags ) +{ + assert(0); + return NULL; +} + + +static void +null_sw_displaytarget_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt ) +{ + assert(0); +} + + +static void +null_sw_displaytarget_destroy(struct sw_winsys *winsys, + struct sw_displaytarget *dt) +{ + assert(0); +} + + +static struct sw_displaytarget * +null_sw_displaytarget_create(struct sw_winsys *winsys, + enum pipe_format format, + unsigned width, unsigned height, + unsigned alignment, + unsigned *stride) +{ + return NULL; +} + + +static void +null_sw_displaytarget_display(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + void *context_private) +{ + assert(0); +} + + +static void +null_sw_destroy(struct sw_winsys *winsys) +{ + FREE(winsys); +} + + +struct sw_winsys * +null_sw_create(void) +{ + static struct sw_winsys *winsys; + + winsys = CALLOC_STRUCT(sw_winsys); + if (!winsys) + return NULL; + + winsys->destroy = null_sw_destroy; + winsys->is_displaytarget_format_supported = null_sw_is_displaytarget_format_supported; + winsys->displaytarget_create = null_sw_displaytarget_create; + winsys->displaytarget_map = null_sw_displaytarget_map; + winsys->displaytarget_unmap = null_sw_displaytarget_unmap; + winsys->displaytarget_display = null_sw_displaytarget_display; + winsys->displaytarget_destroy = null_sw_displaytarget_destroy; + + return winsys; +} diff --git a/src/gallium/winsys/null/null_sw_winsys.h b/src/gallium/winsys/null/null_sw_winsys.h new file mode 100644 index 00000000000..1986186febe --- /dev/null +++ b/src/gallium/winsys/null/null_sw_winsys.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + + +#ifndef NULL_SW_WINSYS_H_ +#define NULL_SW_WINSYS_H_ + + +struct sw_winsys; + + +struct sw_winsys * +null_sw_create(void); + + +#endif /* NULL_SW_WINSYS_H_ */ diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index 9482e8f9b11..18357a41127 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -1,100 +1,17 @@ -# src/gallium/winsys/xlib/Makefile - -# This makefile produces a "stand-alone" libGL.so which is based on -# Xlib (no DRI HW acceleration) - - TOP = ../../../.. include $(TOP)/configs/current +LIBNAME = ws_xlib -GL_MAJOR = 1 -GL_MINOR = 5 -GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY) - - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main \ +LIBRARY_INCLUDES = \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/gallium/state_trackers/glx/xlib \ - -I$(TOP)/src/gallium/auxiliary - -DEFINES += \ - -DGALLIUM_SOFTPIPE -#-DGALLIUM_CELL will be defined by the config */ - -XLIB_WINSYS_SOURCES = \ - xlib.c \ - xlib_cell.c \ - xlib_llvmpipe.c \ - xlib_softpipe.c - - -XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o) - - -# Note: CELL_SPU_LIB is only defined for cell configs - -LIBS = \ - $(GALLIUM_DRIVERS) \ - $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \ - $(TOP)/src/mesa/libglapi.a \ - $(TOP)/src/mesa/libmesagallium.a \ - $(GALLIUM_AUXILIARIES) \ - $(CELL_SPU_LIB) \ - - -.SUFFIXES : .cpp - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(DEFINES) $(CFLAGS) $< -o $@ - -.cpp.o: - $(CXX) -c $(INCLUDE_DIRS) $(DEFINES) $(CXXFLAGS) $< -o $@ - - - -default: $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME) - -$(TOP)/$(LIB_DIR)/gallium: - @ mkdir -p $(TOP)/$(LIB_DIR)/gallium - -# Make the libGL.so library -$(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME): $(XLIB_WINSYS_OBJECTS) $(LIBS) Makefile - $(TOP)/bin/mklib -o $(GL_LIB) \ - -linker "$(CC)" \ - -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \ - -install $(TOP)/$(LIB_DIR)/gallium \ - $(MKLIB_OPTIONS) $(XLIB_WINSYS_OBJECTS) \ - -Wl,--start-group $(LIBS) -Wl,--end-group $(GL_LIB_DEPS) - - -depend: $(XLIB_WINSYS_SOURCES) - @ echo "running $(MKDEP)" - @ rm -f depend # workaround oops on gutsy?!? - @ touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(XLIB_WINSYS_SOURCES) \ - > /dev/null 2>/dev/null - - -install: default - $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL - $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(DESTDIR)$(INSTALL_DIR)/include/GL - @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \ - $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \ - fi - + -I$(TOP)/src/gallium/auxiliary \ + $(X_CFLAGS) -# Emacs tags -tags: - etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h +C_SOURCES = \ + xlib_sw_winsys.c -clean: - -rm -f *.o +include ../../Makefile.template -include depend diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript index a4dabb7804c..2af6153b4c7 100644 --- a/src/gallium/winsys/xlib/SConscript +++ b/src/gallium/winsys/xlib/SConscript @@ -1,68 +1,23 @@ ####################################################################### # SConscript for xlib winsys -Import('*') - -if env['platform'] != 'linux': - Return() - -if 'mesa' not in env['statetrackers']: - print 'warning: Mesa state tracker disabled: skipping build of xlib libGL.so' - Return() - -if env['dri']: - print 'warning: DRI enabled: skipping build of xlib libGL.so' - Return() - -if 'trace' not in env['drivers']: - print 'warning: trace pipe driver disabled: skipping build of xlib libGL.so' - Return() -if not set(('softpipe', 'llvmpipe', 'trace')).intersection(env['drivers']): - print 'warning: no supported pipe driver: skipping build of xlib libGL.so' - Return() - -env = env.Clone() - -env.Append(CPPPATH = [ - '#/src/mesa', - '#/src/mesa/main', - '#src/gallium/state_trackers/glx/xlib', -]) - -env.Append(CPPDEFINES = ['USE_XSHM']) - -sources = [ - 'xlib.c', -] +Import('*') -drivers = [trace] - -if 'softpipe' in env['drivers']: - env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') - sources += ['xlib_softpipe.c'] - drivers += [softpipe] +if env['platform'] == 'linux': -if 'llvmpipe' in env['drivers']: - env.Tool('llvm') - if 'LLVM_VERSION' in env: - env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') - sources += ['xlib_llvmpipe.c'] - drivers += [llvmpipe] - -if 'cell' in env['drivers']: - env.Append(CPPDEFINES = 'GALLIUM_CELL') - sources += ['xlib_cell.c'] - drivers += [cell] + env = env.Clone() -# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions -libgl = env.SharedLibrary( - target ='GL', - source = sources, - LIBS = st_xlib + glapi + mesa + glsl + drivers + gallium + env['LIBS'], -) + env.Append(CPPPATH = [ + '#/src/gallium/include', + '#/src/gallium/auxiliary', + '#/src/gallium/drivers', + ]) -if not env['dri']: - # Only install this libGL.so if DRI not enabled - env.InstallSharedLibrary(libgl, version=(1, 5)) + ws_xlib = env.ConvenienceLibrary( + target = 'ws_xlib', + source = [ + 'xlib_sw_winsys.c', + ] + ) + Export('ws_xlib') diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c deleted file mode 100644 index 67617a470d6..00000000000 --- a/src/gallium/winsys/xlib/xlib.c +++ /dev/null @@ -1,138 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - */ - -#include "xlib.h" -#include "xm_winsys.h" - -#include <stdlib.h> -#include <assert.h> - -/* Todo, replace all this with callback-structs provided by the - * individual implementations. - */ - -enum mode { - MODE_CELL, - MODE_LLVMPIPE, - MODE_SOFTPIPE -}; - -/* advertise OpenGL support */ -PUBLIC const int st_api_OpenGL = 1; - -static enum mode get_mode() -{ -#ifdef GALLIUM_CELL - if (!getenv("GALLIUM_NOCELL")) - return MODE_CELL; -#endif - -#if defined(GALLIUM_LLVMPIPE) - return MODE_LLVMPIPE; -#else - return MODE_SOFTPIPE; -#endif -} - -static void _init( void ) __attribute__((constructor)); - -static void _init( void ) -{ - enum mode xlib_mode = get_mode(); - - switch (xlib_mode) { - case MODE_CELL: -#if defined(GALLIUM_CELL) - xmesa_set_driver( &xlib_cell_driver ); -#endif - break; - case MODE_LLVMPIPE: -#if defined(GALLIUM_LLVMPIPE) - xmesa_set_driver( &xlib_llvmpipe_driver ); -#endif - break; - case MODE_SOFTPIPE: -#if defined(GALLIUM_SOFTPIPE) - xmesa_set_driver( &xlib_softpipe_driver ); -#endif - break; - default: - assert(0); - break; - } -} - - -/*********************************************************************** - * - * Butt-ugly hack to convince the linker not to throw away public GL - * symbols (they are all referenced from getprocaddress, I guess). - */ -extern void (*linker_foo(const unsigned char *procName))(); -extern void (*glXGetProcAddress(const unsigned char *procName))(); - -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.h b/src/gallium/winsys/xlib/xlib.h deleted file mode 100644 index 8e091d0c084..00000000000 --- a/src/gallium/winsys/xlib/xlib.h +++ /dev/null @@ -1,13 +0,0 @@ - -#ifndef XLIB_H -#define XLIB_H - -#include "pipe/p_compiler.h" -#include "xm_winsys.h" - -extern struct xm_driver xlib_softpipe_driver; -extern struct xm_driver xlib_llvmpipe_driver; -extern struct xm_driver xlib_cell_driver; - - -#endif diff --git a/src/gallium/winsys/xlib/xlib_brw_context.c b/src/gallium/winsys/xlib/xlib_brw_context.c deleted file mode 100644 index 22bf41a46f7..00000000000 --- a/src/gallium/winsys/xlib/xlib_brw_context.c +++ /dev/null @@ -1,209 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - * Brian Paul - */ - - -/* #include "glxheader.h" */ -/* #include "xmesaP.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" -#include "xlib_brw_aub.h" -#include "xlib_brw.h" - - - - -#define XBCWS_BATCHBUFFER_SIZE 1024 - - -/* The backend to the brw driver (ie struct brw_winsys) is actually a - * per-context entity. - */ -struct xlib_brw_context_winsys { - struct brw_winsys brw_context_winsys; /**< batch buffer funcs */ - struct aub_context *aub; - - struct pipe_winsys *pipe_winsys; - - unsigned batch_data[XBCWS_BATCHBUFFER_SIZE]; - unsigned batch_nr; - unsigned batch_size; - unsigned batch_alloc; -}; - - -/* Turn a brw_winsys into an xlib_brw_context_winsys: - */ -static inline struct xlib_brw_context_winsys * -xlib_brw_context_winsys( struct brw_winsys *sws ) -{ - return (struct xlib_brw_context_winsys *)sws; -} - - -/* Simple batchbuffer interface: - */ - -static unsigned *xbcws_batch_start( struct brw_winsys *sws, - unsigned dwords, - unsigned relocs ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - if (xbcws->batch_size < xbcws->batch_nr + dwords) - return NULL; - - xbcws->batch_alloc = xbcws->batch_nr + dwords; - return (void *)1; /* not a valid pointer! */ -} - -static void xbcws_batch_dword( struct brw_winsys *sws, - unsigned dword ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - assert(xbcws->batch_nr < xbcws->batch_alloc); - xbcws->batch_data[xbcws->batch_nr++] = dword; -} - -static void xbcws_batch_reloc( struct brw_winsys *sws, - struct pipe_buffer *buf, - unsigned access_flags, - unsigned delta ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - assert(xbcws->batch_nr < xbcws->batch_alloc); - xbcws->batch_data[xbcws->batch_nr++] = - ( xlib_brw_get_buffer_offset( NULL, buf, access_flags ) + - delta ); -} - -static void xbcws_batch_end( struct brw_winsys *sws ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - assert(xbcws->batch_nr <= xbcws->batch_alloc); - xbcws->batch_alloc = 0; -} - -static void xbcws_batch_flush( struct brw_winsys *sws, - struct pipe_fence_handle **fence ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - assert(xbcws->batch_nr <= xbcws->batch_size); - - if (xbcws->batch_nr) { - xlib_brw_commands_aub( xbcws->pipe_winsys, - xbcws->batch_data, - xbcws->batch_nr ); - } - - xbcws->batch_nr = 0; -} - - - -/* Really a per-device function, just pass through: - */ -static unsigned xbcws_get_buffer_offset( struct brw_winsys *sws, - struct pipe_buffer *buf, - unsigned access_flags ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - return xlib_brw_get_buffer_offset( xbcws->pipe_winsys, - buf, - access_flags ); -} - - -/* Really a per-device function, just pass through: - */ -static void xbcws_buffer_subdata_typed( struct brw_winsys *sws, - struct pipe_buffer *buf, - unsigned long offset, - unsigned long size, - const void *data, - unsigned data_type ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - xlib_brw_buffer_subdata_typed( xbcws->pipe_winsys, - buf, - offset, - size, - data, - data_type ); -} - - -/** - * Create i965 hardware rendering context, but plugged into a - * dump-to-aubfile backend. - */ -struct pipe_context * -xlib_create_brw_context( struct pipe_screen *screen, - void *unused ) -{ - struct xlib_brw_context_winsys *xbcws = CALLOC_STRUCT( xlib_brw_context_winsys ); - - /* Fill in this struct with callbacks that i965simple will need to - * communicate with the window system, buffer manager, etc. - */ - xbcws->brw_context_winsys.batch_start = xbcws_batch_start; - xbcws->brw_context_winsys.batch_dword = xbcws_batch_dword; - xbcws->brw_context_winsys.batch_reloc = xbcws_batch_reloc; - xbcws->brw_context_winsys.batch_end = xbcws_batch_end; - xbcws->brw_context_winsys.batch_flush = xbcws_batch_flush; - xbcws->brw_context_winsys.buffer_subdata_typed = xbcws_buffer_subdata_typed; - xbcws->brw_context_winsys.get_buffer_offset = xbcws_get_buffer_offset; - - xbcws->pipe_winsys = screen->winsys; /* redundant */ - - xbcws->batch_size = XBCWS_BATCHBUFFER_SIZE; - - /* Create the i965simple context: - */ -#ifdef GALLIUM_CELL - return NULL; -#else - return brw_create( screen, - &xbcws->brw_context_winsys, - 0 ); -#endif -} diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c deleted file mode 100644 index 1dc9e8fa11f..00000000000 --- a/src/gallium/winsys/xlib/xlib_cell.c +++ /dev/null @@ -1,401 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - * Brian Paul - */ - -#include "xlib.h" - -#ifdef GALLIUM_CELL - -#include "xm_api.h" - -#undef ASSERT -#undef Elements - -#include "util/u_simple_screen.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" - -#include "cell/ppu/cell_context.h" -#include "cell/ppu/cell_screen.h" -#include "cell/ppu/cell_winsys.h" -#include "cell/ppu/cell_texture.h" - - -/** - * Subclass of pipe_buffer for Xlib winsys. - * Low-level OS/window system memory buffer - */ -struct xm_buffer -{ - struct pipe_buffer base; - boolean userBuffer; /** Is this a user-space buffer? */ - void *data; - void *mapped; - - XImage *tempImage; - int shm; -}; - - -/** - * Subclass of pipe_winsys for Xlib winsys - */ -struct xmesa_pipe_winsys -{ - struct pipe_winsys base; -}; - - - -/** Cast wrapper */ -static INLINE struct xm_buffer * -xm_buffer( struct pipe_buffer *buf ) -{ - return (struct xm_buffer *)buf; -} - - -/* Most callbacks map direcly onto dri_bufmgr operations: - */ -static void * -xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, - unsigned flags) -{ - struct xm_buffer *xm_buf = xm_buffer(buf); - xm_buf->mapped = xm_buf->data; - return xm_buf->mapped; -} - -static void -xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct xm_buffer *xm_buf = xm_buffer(buf); - xm_buf->mapped = NULL; -} - -static void -xm_buffer_destroy(/*struct pipe_winsys *pws,*/ - struct pipe_buffer *buf) -{ - struct xm_buffer *oldBuf = xm_buffer(buf); - - if (oldBuf) { - if (oldBuf->data) { - if (!oldBuf->userBuffer) { - align_free(oldBuf->data); - } - - oldBuf->data = NULL; - } - free(oldBuf); - } -} - - -/** - * For Cell. Basically, rearrange the pixels/quads from this layout: - * +--+--+--+--+ - * |p0|p1|p2|p3|.... - * +--+--+--+--+ - * - * to this layout: - * +--+--+ - * |p0|p1|.... - * +--+--+ - * |p2|p3| - * +--+--+ - */ -static void -twiddle_tile(const uint *tileIn, uint *tileOut) -{ - int y, x; - - for (y = 0; y < TILE_SIZE; y+=2) { - for (x = 0; x < TILE_SIZE; x+=2) { - int k = 4 * (y/2 * TILE_SIZE/2 + x/2); - tileOut[y * TILE_SIZE + (x + 0)] = tileIn[k]; - tileOut[y * TILE_SIZE + (x + 1)] = tileIn[k+1]; - tileOut[(y + 1) * TILE_SIZE + (x + 0)] = tileIn[k+2]; - tileOut[(y + 1) * TILE_SIZE + (x + 1)] = tileIn[k+3]; - } - } -} - - - -/** - * Display a surface that's in a tiled configuration. That is, all the - * pixels for a TILE_SIZExTILE_SIZE block are contiguous in memory. - */ -static void -xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf) -{ - XImage *ximage; - struct xm_buffer *xm_buf = xm_buffer( - cell_texture(surf->texture)->buffer); - const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE; - uint x, y; - - ximage = b->tempImage; - - /* check that the XImage has been previously initialized */ - assert(ximage->format); - assert(ximage->bitmap_unit); - - /* update XImage's fields */ - ximage->width = TILE_SIZE; - ximage->height = TILE_SIZE; - ximage->bytes_per_line = TILE_SIZE * 4; - - for (y = 0; y < surf->height; y += TILE_SIZE) { - for (x = 0; x < surf->width; x += TILE_SIZE) { - uint tmpTile[TILE_SIZE * TILE_SIZE]; - int tx = x / TILE_SIZE; - int ty = y / TILE_SIZE; - int offset = ty * tilesPerRow + tx; - int w = TILE_SIZE; - int h = TILE_SIZE; - - if (y + h > surf->height) - h = surf->height - y; - if (x + w > surf->width) - w = surf->width - x; - - /* offset in pixels */ - offset *= TILE_SIZE * TILE_SIZE; - - /* twiddle from ximage buffer to temp tile */ - twiddle_tile((uint *) xm_buf->data + offset, tmpTile); - /* display temp tile data */ - ximage->data = (char *) tmpTile; - XPutImage(b->xm_visual->display, b->drawable, b->gc, - ximage, 0, 0, x, y, w, h); - } - } -} - - - - - -static void -xm_flush_frontbuffer(struct pipe_winsys *pws, - struct pipe_surface *surf, - void *context_private) -{ - /* - * The front color buffer is actually just another XImage buffer. - * This function copies that XImage to the actual X Window. - */ - XMesaContext xmctx = (XMesaContext) context_private; - if (xmctx) - xlib_cell_display_surface(xmctx->xm_buffer, surf); -} - - - -static const char * -xm_get_name(struct pipe_winsys *pws) -{ - return "Xlib/Cell"; -} - - -static struct pipe_buffer * -xm_buffer_create(struct pipe_winsys *pws, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.alignment = alignment; - buffer->base.usage = usage; - buffer->base.size = size; - - - if (buffer->data == NULL) { - buffer->shm = 0; - - /* align to 16-byte multiple for Cell */ - buffer->data = align_malloc(size, max(alignment, 16)); - } - - return &buffer->base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) -{ - struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.size = bytes; - buffer->userBuffer = TRUE; - buffer->data = ptr; - buffer->shm = 0; - - return &buffer->base; -} - - - -static struct pipe_buffer * -xm_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, - /* XXX a bit of a hack */ - *stride * align(nblocksy, TILE_SIZE)); -} - - -/* - * Fence functions - basically nothing to do, as we don't create any actual - * fence objects. - */ - -static void -xm_fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ -} - - -static int -xm_fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static int -xm_fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - - -static struct pipe_winsys * -xlib_create_cell_winsys( void ) -{ - static struct xmesa_pipe_winsys *ws = NULL; - - if (!ws) { - ws = CALLOC_STRUCT(xmesa_pipe_winsys); - - /* Fill in this struct with callbacks that pipe will need to - * communicate with the window system, buffer manager, etc. - */ - ws->base.buffer_create = xm_buffer_create; - ws->base.user_buffer_create = xm_user_buffer_create; - ws->base.buffer_map = xm_buffer_map; - ws->base.buffer_unmap = xm_buffer_unmap; - ws->base.buffer_destroy = xm_buffer_destroy; - - ws->base.surface_buffer_create = xm_surface_buffer_create; - - ws->base.fence_reference = xm_fence_reference; - ws->base.fence_signalled = xm_fence_signalled; - ws->base.fence_finish = xm_fence_finish; - - ws->base.flush_frontbuffer = xm_flush_frontbuffer; - ws->base.get_name = xm_get_name; - } - - return &ws->base; -} - - -static struct pipe_screen * -xlib_create_cell_screen( void ) -{ - struct pipe_winsys *winsys; - struct pipe_screen *screen; - - winsys = xlib_create_cell_winsys(); - if (winsys == NULL) - return NULL; - - screen = cell_create_screen(winsys); - if (screen == NULL) - goto fail; - - return screen; - -fail: - if (winsys) - winsys->destroy( winsys ); - - return NULL; -} - - - -struct xm_driver xlib_cell_driver = -{ - .create_pipe_screen = xlib_create_cell_screen, - .display_surface = xlib_cell_display_surface, -}; - -#else - -struct xm_driver xlib_cell_driver = -{ - .create_pipe_screen = NULL, - .display_surface = NULL, -}; - -#endif diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c deleted file mode 100644 index 716338aef47..00000000000 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ /dev/null @@ -1,508 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - * Brian Paul - */ - - -#include "xm_api.h" - -#undef ASSERT -#undef Elements - -#include "util/u_simple_screen.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "softpipe/sp_winsys.h" -#include "softpipe/sp_texture.h" - -#include "xlib.h" - -/** - * Subclass of pipe_buffer for Xlib winsys. - * Low-level OS/window system memory buffer - */ -struct xm_buffer -{ - struct pipe_buffer base; - boolean userBuffer; /** Is this a user-space buffer? */ - void *data; - void *mapped; - - XImage *tempImage; -#ifdef USE_XSHM - boolean shm; /** Is this a shared memory buffer? */ - XShmSegmentInfo shminfo; -#endif -}; - - -/** - * Subclass of pipe_winsys for Xlib winsys - */ -struct xmesa_pipe_winsys -{ - struct pipe_winsys base; -/* struct xmesa_visual *xm_visual; */ -}; - - - -/** Cast wrapper */ -static INLINE struct xm_buffer * -xm_buffer( struct pipe_buffer *buf ) -{ - return (struct xm_buffer *)buf; -} - - -/** - * X Shared Memory Image extension code - */ - -#ifdef USE_XSHM - -static volatile int mesaXErrorFlag = 0; - -/** - * Catches potential Xlib errors. - */ -static int -mesaHandleXError(Display *dpy, XErrorEvent *event) -{ - (void) dpy; - (void) event; - mesaXErrorFlag = 1; - return 0; -} - - -static char *alloc_shm(struct xm_buffer *buf, unsigned size) -{ - XShmSegmentInfo *const shminfo = & buf->shminfo; - - shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777); - if (shminfo->shmid < 0) { - return NULL; - } - - shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); - if (shminfo->shmaddr == (char *) -1) { - shmctl(shminfo->shmid, IPC_RMID, 0); - return NULL; - } - - shminfo->readOnly = False; - return shminfo->shmaddr; -} - - -/** - * Allocate a shared memory XImage back buffer for the given XMesaBuffer. - */ -static void -alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb, - unsigned width, unsigned height) -{ - /* - * We have to do a _lot_ of error checking here to be sure we can - * really use the XSHM extension. It seems different servers trigger - * errors at different points if the extension won't work. Therefore - * we have to be very careful... - */ - int (*old_handler)(Display *, XErrorEvent *); - - b->tempImage = XShmCreateImage(xmb->xm_visual->display, - xmb->xm_visual->visinfo->visual, - xmb->xm_visual->visinfo->depth, - ZPixmap, - NULL, - &b->shminfo, - width, height); - if (b->tempImage == NULL) { - b->shm = FALSE; - return; - } - - - mesaXErrorFlag = 0; - old_handler = XSetErrorHandler(mesaHandleXError); - /* This may trigger the X protocol error we're ready to catch: */ - XShmAttach(xmb->xm_visual->display, &b->shminfo); - XSync(xmb->xm_visual->display, False); - - if (mesaXErrorFlag) { - /* we are on a remote display, this error is normal, don't print it */ - XFlush(xmb->xm_visual->display); - mesaXErrorFlag = 0; - XDestroyImage(b->tempImage); - b->tempImage = NULL; - b->shm = FALSE; - (void) XSetErrorHandler(old_handler); - return; - } - - b->shm = TRUE; -} - -#endif /* USE_XSHM */ - - - -/* Most callbacks map direcly onto dri_bufmgr operations: - */ -static void * -xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, - unsigned flags) -{ - struct xm_buffer *xm_buf = xm_buffer(buf); - xm_buf->mapped = xm_buf->data; - return xm_buf->mapped; -} - -static void -xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct xm_buffer *xm_buf = xm_buffer(buf); - xm_buf->mapped = NULL; -} - -static void -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) { - shmdt(oldBuf->shminfo.shmaddr); - shmctl(oldBuf->shminfo.shmid, IPC_RMID, 0); - - oldBuf->shminfo.shmid = -1; - oldBuf->shminfo.shmaddr = (char *) -1; - } - - if (oldBuf->shm) { - oldBuf->data = NULL; - } - - if (oldBuf->tempImage) { - XDestroyImage(oldBuf->tempImage); - oldBuf->tempImage = NULL; - } -#endif - - if (oldBuf->data && !oldBuf->userBuffer) { - /* this was regular malloc'd memory */ - align_free(oldBuf->data); - } - - oldBuf->data = NULL; - } - - free(oldBuf); -} - - -/** - * Display/copy the image in the surface into the X window specified - * by the XMesaBuffer. - */ -static void -xlib_softpipe_display_surface(struct xmesa_buffer *b, - struct pipe_surface *surf) -{ - XImage *ximage; - struct softpipe_texture *spt = softpipe_texture(surf->texture); - struct xm_buffer *xm_buf = xm_buffer(spt->buffer); - static boolean no_swap = 0; - static boolean firsttime = 1; - - if (firsttime) { - no_swap = getenv("SP_NO_RAST") != NULL; - firsttime = 0; - } - - if (no_swap) - return; - -#ifdef USE_XSHM - if (xm_buf->shm) - { - if (xm_buf->tempImage == NULL) - { - assert(util_format_get_blockwidth(surf->texture->format) == 1); - assert(util_format_get_blockheight(surf->texture->format) == 1); - alloc_shm_ximage(xm_buf, b, spt->stride[surf->level] / - util_format_get_blocksize(surf->texture->format), surf->height); - } - - ximage = xm_buf->tempImage; - ximage->data = xm_buf->data; - - /* _debug_printf("XSHM\n"); */ - XShmPutImage(b->xm_visual->display, b->drawable, b->gc, - ximage, 0, 0, 0, 0, surf->width, surf->height, False); - } - else -#endif - { - /* display image in Window */ - ximage = b->tempImage; - ximage->data = xm_buf->data; - - /* check that the XImage has been previously initialized */ - assert(ximage->format); - assert(ximage->bitmap_unit); - - /* update XImage's fields */ - ximage->width = surf->width; - ximage->height = surf->height; - ximage->bytes_per_line = spt->stride[surf->level]; - - /* _debug_printf("XPUT\n"); */ - XPutImage(b->xm_visual->display, b->drawable, b->gc, - ximage, 0, 0, 0, 0, surf->width, surf->height); - } -} - - -static void -xm_flush_frontbuffer(struct pipe_winsys *pws, - struct pipe_surface *surf, - void *context_private) -{ - /* - * The front color buffer is actually just another XImage buffer. - * This function copies that XImage to the actual X Window. - */ - XMesaContext xmctx = (XMesaContext) context_private; - xlib_softpipe_display_surface(xmctx->xm_buffer, surf); - xmesa_check_and_update_buffer_size(xmctx, xmctx->xm_buffer); -} - - - -static const char * -xm_get_name(struct pipe_winsys *pws) -{ - return "Xlib"; -} - - -static struct pipe_buffer * -xm_buffer_create(struct pipe_winsys *pws, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - - 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, max(alignment, 16)); - - return &buffer->base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) -{ - struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.size = bytes; - buffer->userBuffer = TRUE; - buffer->data = ptr; - - return &buffer->base; -} - - -static struct pipe_buffer * -xm_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, size; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - size = *stride * nblocksy; - -#ifdef USE_XSHM - if (!debug_get_bool_option("XLIB_NO_SHM", FALSE)) - { - struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.alignment = alignment; - buffer->base.usage = usage; - buffer->base.size = size; - buffer->userBuffer = FALSE; - buffer->shminfo.shmid = -1; - buffer->shminfo.shmaddr = (char *) -1; - buffer->shm = TRUE; - - buffer->data = alloc_shm(buffer, size); - if (!buffer->data) - goto out; - - return &buffer->base; - - out: - if (buffer) - FREE(buffer); - } -#endif - - - return winsys->buffer_create(winsys, alignment, - usage, - size); -} - - -/* - * Fence functions - basically nothing to do, as we don't create any actual - * fence objects. - */ - -static void -xm_fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ -} - - -static int -xm_fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static int -xm_fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - - -static struct pipe_winsys * -xlib_create_softpipe_winsys( void ) -{ - static struct xmesa_pipe_winsys *ws = NULL; - - if (!ws) { - ws = CALLOC_STRUCT(xmesa_pipe_winsys); - - /* Fill in this struct with callbacks that pipe will need to - * communicate with the window system, buffer manager, etc. - */ - ws->base.buffer_create = xm_buffer_create; - ws->base.user_buffer_create = xm_user_buffer_create; - ws->base.buffer_map = xm_buffer_map; - ws->base.buffer_unmap = xm_buffer_unmap; - ws->base.buffer_destroy = xm_buffer_destroy; - - ws->base.surface_buffer_create = xm_surface_buffer_create; - - ws->base.fence_reference = xm_fence_reference; - ws->base.fence_signalled = xm_fence_signalled; - ws->base.fence_finish = xm_fence_finish; - - ws->base.flush_frontbuffer = xm_flush_frontbuffer; - ws->base.get_name = xm_get_name; - } - - return &ws->base; -} - - -static struct pipe_screen * -xlib_create_softpipe_screen( void ) -{ - struct pipe_winsys *winsys; - struct pipe_screen *screen; - - winsys = xlib_create_softpipe_winsys(); - if (winsys == NULL) - return NULL; - - screen = softpipe_create_screen(winsys); - if (screen == NULL) - goto fail; - - return screen; - -fail: - if (winsys) - winsys->destroy( winsys ); - - return NULL; -} - - -struct xm_driver xlib_softpipe_driver = -{ - .create_pipe_screen = xlib_create_softpipe_screen, - .display_surface = xlib_softpipe_display_surface -}; - - - diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index 6cebd4c2012..cecfa4a53d4 100644 --- a/src/gallium/winsys/xlib/xlib_llvmpipe.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -32,25 +32,21 @@ * Brian Paul */ - -#if defined(GALLIUM_LLVMPIPE) - -#include "xm_api.h" - -#undef ASSERT -#undef Elements - -#include "util/u_simple_screen.h" #include "pipe/p_format.h" #include "pipe/p_context.h" #include "util/u_inlines.h" #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" -#include "llvmpipe/lp_winsys.h" -#include "llvmpipe/lp_texture.h" -#include "xlib.h" +#include "state_tracker/xlib_sw_winsys.h" + +#include <X11/Xlib.h> +#include <X11/Xlibint.h> +#include <X11/Xutil.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <X11/extensions/XShm.h> /** * Subclass of pipe_buffer for Xlib winsys. @@ -66,28 +62,38 @@ struct xm_displaytarget void *data; void *mapped; + Display *display; + Visual *visual; XImage *tempImage; -#ifdef USE_XSHM - int shm; + GC gc; + + /* This is the last drawable that this display target was presented + * against. May need to recreate gc, tempImage when this changes?? + */ + Drawable drawable; + XShmSegmentInfo shminfo; -#endif + int shm; }; /** - * Subclass of llvmpipe_winsys for Xlib winsys + * Subclass of sw_winsys for Xlib winsys */ -struct xmesa_llvmpipe_winsys +struct xlib_sw_winsys { - struct llvmpipe_winsys base; -/* struct xmesa_visual *xm_visual; */ + struct sw_winsys base; + + + + Display *display; }; /** Cast wrapper */ static INLINE struct xm_displaytarget * -xm_displaytarget( struct llvmpipe_displaytarget *dt ) +xm_displaytarget( struct sw_displaytarget *dt ) { return (struct xm_displaytarget *)dt; } @@ -97,8 +103,6 @@ xm_displaytarget( struct llvmpipe_displaytarget *dt ) * X Shared Memory Image extension code */ -#ifdef USE_XSHM - static volatile int mesaXErrorFlag = 0; /** @@ -138,8 +142,8 @@ static char *alloc_shm(struct xm_displaytarget *buf, unsigned size) * Allocate a shared memory XImage back buffer for the given XMesaBuffer. */ static void -alloc_shm_ximage(struct xm_displaytarget *xm_buffer, - struct xmesa_buffer *xmb, +alloc_shm_ximage(struct xm_displaytarget *xm_dt, + struct xlib_drawable *xmb, unsigned width, unsigned height) { /* @@ -150,15 +154,15 @@ alloc_shm_ximage(struct xm_displaytarget *xm_buffer, */ int (*old_handler)(Display *, XErrorEvent *); - xm_buffer->tempImage = XShmCreateImage(xmb->xm_visual->display, - xmb->xm_visual->visinfo->visual, - xmb->xm_visual->visinfo->depth, - ZPixmap, - NULL, - &xm_buffer->shminfo, - width, height); - if (xm_buffer->tempImage == NULL) { - xm_buffer->shm = 0; + xm_dt->tempImage = XShmCreateImage(xm_dt->display, + xmb->visual, + xmb->depth, + ZPixmap, + NULL, + &xm_dt->shminfo, + width, height); + if (xm_dt->tempImage == NULL) { + xm_dt->shm = 0; return; } @@ -166,27 +170,44 @@ alloc_shm_ximage(struct xm_displaytarget *xm_buffer, mesaXErrorFlag = 0; old_handler = XSetErrorHandler(mesaHandleXError); /* This may trigger the X protocol error we're ready to catch: */ - XShmAttach(xmb->xm_visual->display, &xm_buffer->shminfo); - XSync(xmb->xm_visual->display, False); + XShmAttach(xm_dt->display, &xm_dt->shminfo); + XSync(xm_dt->display, False); if (mesaXErrorFlag) { /* we are on a remote display, this error is normal, don't print it */ - XFlush(xmb->xm_visual->display); + XFlush(xm_dt->display); mesaXErrorFlag = 0; - XDestroyImage(xm_buffer->tempImage); - xm_buffer->tempImage = NULL; - xm_buffer->shm = 0; + XDestroyImage(xm_dt->tempImage); + xm_dt->tempImage = NULL; + xm_dt->shm = 0; (void) XSetErrorHandler(old_handler); return; } - xm_buffer->shm = 1; + xm_dt->shm = 1; } -#endif /* USE_XSHM */ + +static void +alloc_ximage(struct xm_displaytarget *xm_dt, + struct xlib_drawable *xmb, + unsigned width, unsigned height) +{ + if (xm_dt->shm) { + alloc_shm_ximage(xm_dt, xmb, width, height); + return; + } + + xm_dt->tempImage = XCreateImage(xm_dt->display, + xmb->visual, + xmb->depth, + ZPixmap, 0, + NULL, width, height, + 8, 0); +} static boolean -xm_is_displaytarget_format_supported( struct llvmpipe_winsys *ws, +xm_is_displaytarget_format_supported( struct sw_winsys *ws, enum pipe_format format ) { /* TODO: check visuals or other sensible thing here */ @@ -195,8 +216,8 @@ xm_is_displaytarget_format_supported( struct llvmpipe_winsys *ws, static void * -xm_displaytarget_map(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt, +xm_displaytarget_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, unsigned flags) { struct xm_displaytarget *xm_dt = xm_displaytarget(dt); @@ -205,21 +226,20 @@ xm_displaytarget_map(struct llvmpipe_winsys *ws, } static void -xm_displaytarget_unmap(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt) +xm_displaytarget_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt) { struct xm_displaytarget *xm_dt = xm_displaytarget(dt); xm_dt->mapped = NULL; } static void -xm_displaytarget_destroy(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt) +xm_displaytarget_destroy(struct sw_winsys *ws, + struct sw_displaytarget *dt) { struct xm_displaytarget *xm_dt = xm_displaytarget(dt); if (xm_dt->data) { -#ifdef USE_XSHM if (xm_dt->shminfo.shmid >= 0) { shmdt(xm_dt->shminfo.shmaddr); shmctl(xm_dt->shminfo.shmid, IPC_RMID, 0); @@ -227,11 +247,17 @@ xm_displaytarget_destroy(struct llvmpipe_winsys *ws, xm_dt->shminfo.shmid = -1; xm_dt->shminfo.shmaddr = (char *) -1; } - else -#endif + else { FREE(xm_dt->data); + } } + if (xm_dt->tempImage) + XDestroyImage(xm_dt->tempImage); + + if (xm_dt->gc) + XFreeGC(xm_dt->display, xm_dt->gc); + FREE(xm_dt); } @@ -241,13 +267,14 @@ xm_displaytarget_destroy(struct llvmpipe_winsys *ws, * by the XMesaBuffer. */ static void -xm_llvmpipe_display(struct xmesa_buffer *xm_buffer, - struct llvmpipe_displaytarget *dt) +xlib_sw_display(struct xlib_drawable *xlib_drawable, + struct sw_displaytarget *dt) { - XImage *ximage; - struct xm_displaytarget *xm_dt = xm_displaytarget(dt); static boolean no_swap = 0; static boolean firsttime = 1; + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + Display *display = xm_dt->display; + XImage *ximage; if (firsttime) { no_swap = getenv("SP_NO_RAST") != NULL; @@ -257,28 +284,45 @@ xm_llvmpipe_display(struct xmesa_buffer *xm_buffer, if (no_swap) return; -#ifdef USE_XSHM - if (xm_dt->shm) - { - if (xm_dt->tempImage == NULL) - { - assert(util_format_get_blockwidth(xm_dt->format) == 1); - assert(util_format_get_blockheight(xm_dt->format) == 1); - alloc_shm_ximage(xm_dt, xm_buffer, - xm_dt->stride / util_format_get_blocksize(xm_dt->format), - xm_dt->height); + if (xm_dt->drawable != xlib_drawable->drawable) { + if (xm_dt->gc) { + XFreeGC( display, xm_dt->gc ); + xm_dt->gc = NULL; + } + + if (xm_dt->tempImage) { + XDestroyImage( xm_dt->tempImage ); + xm_dt->tempImage = NULL; } + xm_dt->drawable = xlib_drawable->drawable; + } + + if (xm_dt->tempImage == NULL) { + assert(util_format_get_blockwidth(xm_dt->format) == 1); + assert(util_format_get_blockheight(xm_dt->format) == 1); + alloc_ximage(xm_dt, xlib_drawable, + xm_dt->stride / util_format_get_blocksize(xm_dt->format), + xm_dt->height); + if (!xm_dt->tempImage) + return; + } + + if (xm_dt->gc == NULL) { + xm_dt->gc = XCreateGC( display, xlib_drawable->drawable, 0, NULL ); + XSetFunction( display, xm_dt->gc, GXcopy ); + } + + if (xm_dt->shm) + { ximage = xm_dt->tempImage; ximage->data = xm_dt->data; /* _debug_printf("XSHM\n"); */ - XShmPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc, + XShmPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc, ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False); } - else -#endif - { + else { /* display image in Window */ ximage = xm_dt->tempImage; ximage->data = xm_dt->data; @@ -293,7 +337,7 @@ xm_llvmpipe_display(struct xmesa_buffer *xm_buffer, ximage->bytes_per_line = xm_dt->stride; /* _debug_printf("XPUT\n"); */ - XPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc, + XPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc, ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height); } } @@ -303,30 +347,30 @@ xm_llvmpipe_display(struct xmesa_buffer *xm_buffer, * by the XMesaBuffer. */ static void -xm_displaytarget_display(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt, +xm_displaytarget_display(struct sw_winsys *ws, + struct sw_displaytarget *dt, void *context_private) { - XMesaContext xmctx = (XMesaContext) context_private; - struct xmesa_buffer *xm_buffer = xmctx->xm_buffer; - xm_llvmpipe_display(xm_buffer, dt); + struct xlib_drawable *xlib_drawable = (struct xlib_drawable *)context_private; + xlib_sw_display(xlib_drawable, dt); } -static struct llvmpipe_displaytarget * -xm_displaytarget_create(struct llvmpipe_winsys *winsys, +static struct sw_displaytarget * +xm_displaytarget_create(struct sw_winsys *winsys, enum pipe_format format, unsigned width, unsigned height, unsigned alignment, unsigned *stride) { - struct xm_displaytarget *xm_dt = CALLOC_STRUCT(xm_displaytarget); + struct xm_displaytarget *xm_dt; unsigned nblocksy, size; xm_dt = CALLOC_STRUCT(xm_displaytarget); if(!xm_dt) goto no_xm_dt; + xm_dt->display = ((struct xlib_sw_winsys *)winsys)->display; xm_dt->format = format; xm_dt->width = width; xm_dt->height = height; @@ -335,7 +379,6 @@ xm_displaytarget_create(struct llvmpipe_winsys *winsys, xm_dt->stride = align(util_format_get_stride(format, width), alignment); size = xm_dt->stride * nblocksy; -#ifdef USE_XSHM if (!debug_get_bool_option("XLIB_NO_SHM", FALSE)) { xm_dt->shminfo.shmid = -1; @@ -346,7 +389,6 @@ xm_displaytarget_create(struct llvmpipe_winsys *winsys, if(!xm_dt->data) goto no_data; } -#endif if(!xm_dt->data) { xm_dt->data = align_malloc(size, alignment); @@ -355,7 +397,7 @@ xm_displaytarget_create(struct llvmpipe_winsys *winsys, } *stride = xm_dt->stride; - return (struct llvmpipe_displaytarget *)xm_dt; + return (struct sw_displaytarget *)xm_dt; no_data: FREE(xm_dt); @@ -365,21 +407,22 @@ no_xm_dt: static void -xm_destroy( struct llvmpipe_winsys *ws ) +xm_destroy( struct sw_winsys *ws ) { FREE(ws); } -static struct llvmpipe_winsys * -xlib_create_llvmpipe_winsys( void ) +struct sw_winsys * +xlib_create_sw_winsys( Display *display ) { - struct xmesa_llvmpipe_winsys *ws; + struct xlib_sw_winsys *ws; - ws = CALLOC_STRUCT(xmesa_llvmpipe_winsys); + ws = CALLOC_STRUCT(xlib_sw_winsys); if (!ws) return NULL; + ws->display = display; ws->base.destroy = xm_destroy; ws->base.is_displaytarget_format_supported = xm_is_displaytarget_format_supported; @@ -394,49 +437,3 @@ xlib_create_llvmpipe_winsys( void ) return &ws->base; } - -static struct pipe_screen * -xlib_create_llvmpipe_screen( void ) -{ - struct llvmpipe_winsys *winsys; - struct pipe_screen *screen; - - winsys = xlib_create_llvmpipe_winsys(); - if (winsys == NULL) - return NULL; - - screen = llvmpipe_create_screen(winsys); - if (screen == NULL) - goto fail; - - return screen; - -fail: - if (winsys) - winsys->destroy( winsys ); - - return NULL; -} - - -static void -xlib_llvmpipe_display_surface(struct xmesa_buffer *xm_buffer, - struct pipe_surface *surf) -{ - struct llvmpipe_texture *texture = llvmpipe_texture(surf->texture); - - assert(texture->dt); - if (texture->dt) - xm_llvmpipe_display(xm_buffer, texture->dt); -} - - -struct xm_driver xlib_llvmpipe_driver = -{ - .create_pipe_screen = xlib_create_llvmpipe_screen, - .display_surface = xlib_llvmpipe_display_surface -}; - - - -#endif /* GALLIUM_LLVMPIPE */ diff --git a/src/gallium/winsys/xlib/xmesa.h b/src/gallium/winsys/xlib/xmesa.h deleted file mode 100644 index 98139af8336..00000000000 --- a/src/gallium/winsys/xlib/xmesa.h +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul 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, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - - -/* - * Mesa/X11 interface. This header file serves as the documentation for - * the Mesa/X11 interface functions. - * - * Note: this interface isn't intended for user programs. It's primarily - * just for implementing the pseudo-GLX interface. - */ - - -/* Sample Usage: - -In addition to the usual X calls to select a visual, create a colormap -and create a window, you must do the following to use the X/Mesa interface: - -1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo. - -2. Call XMesaCreateContext() to create an X/Mesa rendering context, given - the XMesaVisual. - -3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window - and XMesaVisual. - -4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and - to make the context the current one. - -5. Make gl* calls to render your graphics. - -6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers. - -7. Before the X window is destroyed, call XMesaDestroyBuffer(). - -8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext. - -*/ - - - - -#ifndef XMESA_H -#define XMESA_H - -#ifdef __VMS -#include <GL/vms_x_fix.h> -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef XFree86Server -#include "xmesa_xf86.h" -#else -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include "xmesa_x.h" -#endif -#include "GL/gl.h" - -#ifdef AMIWIN -#include <pragmas/xlib_pragmas.h> -extern struct Library *XLibBase; -#endif - - -#define XMESA_MAJOR_VERSION 6 -#define XMESA_MINOR_VERSION 3 - - - -/* - * Values passed to XMesaGetString: - */ -#define XMESA_VERSION 1 -#define XMESA_EXTENSIONS 2 - - -/* - * Values passed to XMesaSetFXmode: - */ -#define XMESA_FX_WINDOW 1 -#define XMESA_FX_FULLSCREEN 2 - - - -typedef struct xmesa_context *XMesaContext; - -typedef struct xmesa_visual *XMesaVisual; - -typedef struct xmesa_buffer *XMesaBuffer; - - - -/* - * Create a new X/Mesa visual. - * Input: display - X11 display - * visinfo - an XVisualInfo pointer - * rgb_flag - GL_TRUE = RGB mode, - * GL_FALSE = color index mode - * alpha_flag - alpha buffer requested? - * db_flag - GL_TRUE = double-buffered, - * GL_FALSE = single buffered - * stereo_flag - stereo visual? - * ximage_flag - GL_TRUE = use an XImage for back buffer, - * GL_FALSE = use an off-screen pixmap for back buffer - * depth_size - requested bits/depth values, or zero - * stencil_size - requested bits/stencil values, or zero - * accum_red_size - requested bits/red accum values, or zero - * accum_green_size - requested bits/green accum values, or zero - * accum_blue_size - requested bits/blue accum values, or zero - * accum_alpha_size - requested bits/alpha accum values, or zero - * num_samples - number of samples/pixel if multisampling, or zero - * level - visual level, usually 0 - * visualCaveat - ala the GLX extension, usually GLX_NONE_EXT - * Return; a new XMesaVisual or 0 if error. - */ -extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_red_size, - GLint accum_green_size, - GLint accum_blue_size, - GLint accum_alpha_size, - GLint num_samples, - GLint level, - GLint visualCaveat ); - -/* - * Destroy an XMesaVisual, but not the associated XVisualInfo. - */ -extern void XMesaDestroyVisual( XMesaVisual v ); - - - -/* - * Create a new XMesaContext for rendering into an X11 window. - * - * Input: visual - an XMesaVisual - * share_list - another XMesaContext with which to share display - * lists or NULL if no sharing is wanted. - * Return: an XMesaContext or NULL if error. - */ -extern XMesaContext XMesaCreateContext( XMesaVisual v, - XMesaContext share_list ); - - -/* - * Destroy a rendering context as returned by XMesaCreateContext() - */ -extern void XMesaDestroyContext( XMesaContext c ); - - -#ifdef XFree86Server -/* - * These are the extra routines required for integration with XFree86. - * None of these routines should be user visible. -KEM - */ -extern GLboolean XMesaForceCurrent( XMesaContext c ); - -extern GLboolean XMesaLoseCurrent( XMesaContext c ); - -extern GLboolean XMesaCopyContext( XMesaContext src, - XMesaContext dst, - GLuint mask ); -#endif /* XFree86Server */ - - -/* - * Create an XMesaBuffer from an X window. - */ -extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, XMesaWindow w ); - - -/* - * Create an XMesaBuffer from an X pixmap. - */ -extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v, - XMesaPixmap p, - XMesaColormap cmap ); - - -/* - * Destroy an XMesaBuffer, but not the corresponding window or pixmap. - */ -extern void XMesaDestroyBuffer( XMesaBuffer b ); - - -/* - * Return the XMesaBuffer handle which corresponds to an X drawable, if any. - * - * New in Mesa 2.3. - */ -extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy, - XMesaDrawable d ); - - - -/* - * Bind a buffer to a context and make the context the current one. - */ -extern GLboolean XMesaMakeCurrent( XMesaContext c, - XMesaBuffer b ); - - -/* - * Bind two buffers (read and draw) to a context and make the - * context the current one. - * New in Mesa 3.3 - */ -extern GLboolean XMesaMakeCurrent2( XMesaContext c, - XMesaBuffer drawBuffer, - XMesaBuffer readBuffer ); - - -/* - * Unbind the current context from its buffer. - */ -extern GLboolean XMesaUnbindContext( XMesaContext c ); - - -/* - * Return a handle to the current context. - */ -extern XMesaContext XMesaGetCurrentContext( void ); - - -/* - * Return handle to the current (draw) buffer. - */ -extern XMesaBuffer XMesaGetCurrentBuffer( void ); - - -/* - * Return handle to the current read buffer. - * New in Mesa 3.3 - */ -extern XMesaBuffer XMesaGetCurrentReadBuffer( void ); - - -/* - * Swap the front and back buffers for the given buffer. No action is - * taken if the buffer is not double buffered. - */ -extern void XMesaSwapBuffers( XMesaBuffer b ); - - -/* - * Copy a sub-region of the back buffer to the front buffer. - * - * New in Mesa 2.6 - */ -extern void XMesaCopySubBuffer( XMesaBuffer b, - int x, - int y, - int width, - int height ); - - -/* - * Return a pointer to the the Pixmap or XImage being used as the back - * color buffer of an XMesaBuffer. This function is a way to get "under - * the hood" of X/Mesa so one can manipulate the back buffer directly. - * Input: b - the XMesaBuffer - * Output: pixmap - pointer to back buffer's Pixmap, or 0 - * ximage - pointer to back buffer's XImage, or NULL - * Return: GL_TRUE = context is double buffered - * GL_FALSE = context is single buffered - */ -extern GLboolean XMesaGetBackBuffer( XMesaBuffer b, - XMesaPixmap *pixmap, - XMesaImage **ximage ); - - - -/* - * Return the depth buffer associated with an XMesaBuffer. - * Input: b - the XMesa buffer handle - * Output: width, height - size of buffer in pixels - * bytesPerValue - bytes per depth value (2 or 4) - * buffer - pointer to depth buffer values - * Return: GL_TRUE or GL_FALSE to indicate success or failure. - * - * New in Mesa 2.4. - */ -extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b, - GLint *width, - GLint *height, - GLint *bytesPerValue, - void **buffer ); - - - -/* - * Flush/sync a context - */ -extern void XMesaFlush( XMesaContext c ); - - - -/* - * Get an X/Mesa-specific string. - * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS - */ -extern const char *XMesaGetString( XMesaContext c, int name ); - - - -/* - * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free - * any memory used by that buffer. - * - * New in Mesa 2.3. - */ -extern void XMesaGarbageCollect( void ); - - - -/* - * Return a dithered pixel value. - * Input: c - XMesaContext - * x, y - window coordinate - * red, green, blue, alpha - color components in [0,1] - * Return: pixel value - * - * New in Mesa 2.3. - */ -extern unsigned long XMesaDitherColor( XMesaContext xmesa, - GLint x, - GLint y, - GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha ); - - - -/* - * 3Dfx Glide driver only! - * Set 3Dfx/Glide full-screen or window rendering mode. - * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or - * XMESA_FX_FULLSCREEN (full-screen rendering mode) - * Return: GL_TRUE if success - * GL_FALSE if invalid mode or if not using 3Dfx driver - * - * New in Mesa 2.6. - */ -extern GLboolean XMesaSetFXmode( GLint mode ); - - - -/* - * Reallocate the back/depth/stencil/accum/etc/ buffers associated with - * buffer <b> if its size has changed. - * - * New in Mesa 4.0.2 - */ -extern void XMesaResizeBuffers( XMesaBuffer b ); - - - -/* - * Create a pbuffer. - * New in Mesa 4.1 - */ -extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap, - unsigned int width, unsigned int height); - - - -/* - * Texture from Pixmap - * New in Mesa 7.1 - */ -extern void -XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer, - const int *attrib_list); - -extern void -XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer); - - -extern XMesaBuffer -XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap cmap, - int format, int target, int mipmap); - - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/src/gallium/winsys/xlib/xmesa_x.h b/src/gallium/winsys/xlib/xmesa_x.h deleted file mode 100644 index 865bab4313b..00000000000 --- a/src/gallium/winsys/xlib/xmesa_x.h +++ /dev/null @@ -1,86 +0,0 @@ - -/************************************************************************** - -Copyright 1998-1999 Precision Insight, 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 PRECISION INSIGHT 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. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin <[email protected]> - * - * When we're building the XMesa driver for stand-alone Mesa we - * include this file when building the xm_*.c files. - * We need to define some types and macros differently when building - * in the Xserver vs. stand-alone Mesa. - */ - -#ifndef _XMESA_X_H_ -#define _XMESA_X_H_ - -typedef Display XMesaDisplay; -typedef Pixmap XMesaPixmap; -typedef Colormap XMesaColormap; -typedef Drawable XMesaDrawable; -typedef Window XMesaWindow; -typedef GC XMesaGC; -typedef XVisualInfo *XMesaVisualInfo; -typedef XImage XMesaImage; -typedef XPoint XMesaPoint; -typedef XColor XMesaColor; - -#define XMesaDestroyImage XDestroyImage - -#define XMesaPutPixel XPutPixel -#define XMesaGetPixel XGetPixel - -#define XMesaSetForeground XSetForeground -#define XMesaSetBackground XSetBackground -#define XMesaSetPlaneMask XSetPlaneMask -#define XMesaSetFunction XSetFunction -#define XMesaSetFillStyle XSetFillStyle -#define XMesaSetTile XSetTile - -#define XMesaDrawPoint XDrawPoint -#define XMesaDrawPoints XDrawPoints -#define XMesaDrawLine XDrawLine -#define XMesaFillRectangle XFillRectangle -#define XMesaGetImage XGetImage -#define XMesaPutImage XPutImage -#define XMesaCopyArea XCopyArea - -#define XMesaCreatePixmap XCreatePixmap -#define XMesaFreePixmap XFreePixmap -#define XMesaFreeGC XFreeGC - -#define GET_COLORMAP_SIZE(__v) __v->visinfo->colormap_size -#define GET_REDMASK(__v) __v->mesa_visual.redMask -#define GET_GREENMASK(__v) __v->mesa_visual.greenMask -#define GET_BLUEMASK(__v) __v->mesa_visual.blueMask -#define GET_VISUAL_DEPTH(__v) __v->visinfo->depth -#define GET_BLACK_PIXEL(__v) BlackPixel(__v->display, __v->mesa_visual.screen) -#define CHECK_BYTE_ORDER(__v) host_byte_order()==ImageByteOrder(__v->display) -#define CHECK_FOR_HPCR(__v) XInternAtom(__v->display, "_HP_RGB_SMOOTH_MAP_LIST", True) - -#endif |