summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/drm
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/winsys/drm')
-rw-r--r--src/gallium/winsys/drm/Makefile.template2
-rw-r--r--src/gallium/winsys/drm/intel/xorg/Makefile2
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/Makefile3
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/Makefile4
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c93
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h27
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c94
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c204
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h54
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_buffer.c26
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_r300.c34
-rw-r--r--src/gallium/winsys/drm/radeon/xorg/Makefile2
12 files changed, 131 insertions, 414 deletions
diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template
index 9f92cb4207..985e5a861f 100644
--- a/src/gallium/winsys/drm/Makefile.template
+++ b/src/gallium/winsys/drm/Makefile.template
@@ -118,7 +118,7 @@ clean:
install: $(LIBNAME)
$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
- $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
+ $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
include depend
diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile b/src/gallium/winsys/drm/intel/xorg/Makefile
index b1b6b9362b..d9aa5d54e1 100644
--- a/src/gallium/winsys/drm/intel/xorg/Makefile
+++ b/src/gallium/winsys/drm/intel/xorg/Makefile
@@ -39,6 +39,6 @@ clean:
install:
$(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
- $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+ $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile
index 024ab150cb..0937f68c34 100644
--- a/src/gallium/winsys/drm/nouveau/dri/Makefile
+++ b/src/gallium/winsys/drm/nouveau/dri/Makefile
@@ -11,7 +11,8 @@ PIPE_DRIVERS = \
$(TOP)/src/gallium/drivers/nv20/libnv20.a \
$(TOP)/src/gallium/drivers/nv30/libnv30.a \
$(TOP)/src/gallium/drivers/nv40/libnv40.a \
- $(TOP)/src/gallium/drivers/nv50/libnv50.a
+ $(TOP)/src/gallium/drivers/nv50/libnv50.a \
+ $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
DRIVER_SOURCES =
diff --git a/src/gallium/winsys/drm/nouveau/drm/Makefile b/src/gallium/winsys/drm/nouveau/drm/Makefile
index 2da78d8690..54c3b26c75 100644
--- a/src/gallium/winsys/drm/nouveau/drm/Makefile
+++ b/src/gallium/winsys/drm/nouveau/drm/Makefile
@@ -3,9 +3,7 @@ include $(TOP)/configs/current
LIBNAME = nouveaudrm
-C_SOURCES = nouveau_drm_api.c \
- nouveau_winsys_pipe.c \
- nouveau_winsys.c
+C_SOURCES = nouveau_drm_api.c
LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I)
LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other)
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 b355a1391d..395b21ec7a 100644
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
@@ -1,12 +1,16 @@
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
#include "util/u_memory.h"
#include "nouveau_drm_api.h"
-#include "nouveau_winsys_pipe.h"
#include "nouveau_drmif.h"
#include "nouveau_channel.h"
#include "nouveau_bo.h"
+#include "nouveau/nouveau_winsys.h"
+#include "nouveau/nouveau_screen.h"
+
static struct pipe_surface *
dri_surface_from_handle(struct pipe_screen *screen,
unsigned handle,
@@ -58,7 +62,7 @@ dri_surface_from_handle(struct pipe_screen *screen,
static struct pipe_surface *
nouveau_dri1_front_surface(struct pipe_context *pipe)
{
- return nouveau_screen(pipe->screen)->front;
+ return nouveau_winsys_screen(pipe->screen)->front;
}
static struct dri1_api nouveau_dri1_api = {
@@ -69,11 +73,11 @@ static struct pipe_screen *
nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg)
{
struct dri1_create_screen_arg *dri1 = (void *)arg;
- struct pipe_winsys *ws;
struct nouveau_winsys *nvws;
+ struct pipe_winsys *ws;
struct nouveau_device *dev = NULL;
struct pipe_screen *(*init)(struct pipe_winsys *,
- struct nouveau_winsys *);
+ struct nouveau_device *);
int ret;
ret = nouveau_device_open_existing(&dev, 0, fd, 0);
@@ -108,26 +112,20 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg)
return NULL;
}
- ws = nouveau_pipe_winsys_new(dev);
- if (!ws) {
- nouveau_device_close(&dev);
- return NULL;
- }
-
- nvws = nouveau_winsys_new(ws);
+ nvws = CALLOC_STRUCT(nouveau_winsys);
if (!nvws) {
- ws->destroy(ws);
+ nouveau_device_close(&dev);
return NULL;
}
+ ws = &nvws->base;
- nouveau_pipe_winsys(ws)->pscreen = init(ws, nvws);
- if (!nouveau_pipe_winsys(ws)->pscreen) {
+ nvws->pscreen = init(ws, dev);
+ if (!nvws->pscreen) {
ws->destroy(ws);
return NULL;
}
if (arg->mode == DRM_CREATE_DRI1) {
- struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
struct nouveau_dri *nvdri = dri1->ddx_info;
enum pipe_format format;
@@ -136,14 +134,14 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg)
else
format = PIPE_FORMAT_A8R8G8B8_UNORM;
- nvpws->front = dri_surface_from_handle(nvpws->pscreen,
+ nvws->front = dri_surface_from_handle(nvws->pscreen,
nvdri->front_offset,
format,
nvdri->width,
nvdri->height,
nvdri->front_pitch *
(nvdri->bpp / 8));
- if (!nvpws->front) {
+ if (!nvws->front) {
debug_printf("%s: error referencing front buffer\n",
__func__);
ws->destroy(ws);
@@ -153,15 +151,15 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg)
dri1->api = &nouveau_dri1_api;
}
- return nouveau_pipe_winsys(ws)->pscreen;
+ return nvws->pscreen;
}
static struct pipe_context *
nouveau_drm_create_context(struct pipe_screen *pscreen)
{
- struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen);
+ struct nouveau_winsys *nvws = nouveau_winsys_screen(pscreen);
struct pipe_context *(*init)(struct pipe_screen *, unsigned);
- unsigned chipset = nvpws->channel->device->chipset;
+ unsigned chipset = nouveau_screen(pscreen)->device->chipset;
int i;
switch (chipset & 0xf0) {
@@ -192,19 +190,19 @@ nouveau_drm_create_context(struct pipe_screen *pscreen)
}
/* Find a free slot for a pipe context, allocate a new one if needed */
- for (i = 0; i < nvpws->nr_pctx; i++) {
- if (nvpws->pctx[i] == NULL)
+ for (i = 0; i < nvws->nr_pctx; i++) {
+ if (nvws->pctx[i] == NULL)
break;
}
- if (i == nvpws->nr_pctx) {
- nvpws->nr_pctx++;
- nvpws->pctx = realloc(nvpws->pctx,
- sizeof(*nvpws->pctx) * nvpws->nr_pctx);
+ if (i == nvws->nr_pctx) {
+ nvws->nr_pctx++;
+ nvws->pctx = realloc(nvws->pctx,
+ sizeof(*nvws->pctx) * nvws->nr_pctx);
}
- nvpws->pctx[i] = init(pscreen, i);
- return nvpws->pctx[i];
+ nvws->pctx[i] = init(pscreen, i);
+ return nvws->pctx[i];
}
static boolean
@@ -218,42 +216,41 @@ static struct pipe_buffer *
nouveau_drm_pb_from_handle(struct pipe_screen *pscreen, const char *name,
unsigned handle)
{
- struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen);
- struct nouveau_device *dev = nvpws->channel->device;
- struct nouveau_pipe_buffer *nvpb;
+ struct nouveau_device *dev = nouveau_screen(pscreen)->device;
+ struct pipe_buffer *pb;
int ret;
- nvpb = CALLOC_STRUCT(nouveau_pipe_buffer);
- if (!nvpb)
+ pb = CALLOC(1, sizeof(struct pipe_buffer) + sizeof(struct nouveau_bo*));
+ if (!pb)
return NULL;
- ret = nouveau_bo_handle_ref(dev, handle, &nvpb->bo);
+ 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(nvpb);
+ FREE(pb);
return NULL;
}
- pipe_reference_init(&nvpb->base.reference, 1);
- nvpb->base.screen = pscreen;
- nvpb->base.alignment = 0;
- nvpb->base.usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE |
- PIPE_BUFFER_USAGE_CPU_READ_WRITE;
- nvpb->base.size = nvpb->bo->size;
- return &nvpb->base;
+ 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;
+ return pb;
}
static boolean
nouveau_drm_handle_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb,
unsigned *handle)
{
- struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb);
+ struct nouveau_bo *bo = nouveau_bo(pb);
- if (!nvpb)
+ if (!bo)
return FALSE;
- *handle = nvpb->bo->handle;
+ *handle = bo->handle;
return TRUE;
}
@@ -261,12 +258,12 @@ static boolean
nouveau_drm_name_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb,
unsigned *handle)
{
- struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb);
+ struct nouveau_bo *bo = nouveau_bo(pb);
- if (!nvpb)
+ if (!bo)
return FALSE;
- return nouveau_bo_handle_get(nvpb->bo, handle) == 0;
+ return nouveau_bo_handle_get(bo, handle) == 0;
}
struct drm_api drm_api_hooks = {
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
index cc237bfc13..e61e0e0957 100644
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
@@ -1,7 +1,34 @@
#ifndef __NOUVEAU_DRM_API_H__
#define __NOUVEAU_DRM_API_H__
+
#include "state_tracker/drm_api.h"
#include "state_tracker/dri1_api.h"
+
+#include "pipe/internal/p_winsys_screen.h"
+
#include "nouveau_dri.h"
+struct nouveau_winsys {
+ struct pipe_winsys base;
+
+ struct pipe_screen *pscreen;
+
+ unsigned nr_pctx;
+ struct pipe_context **pctx;
+
+ struct pipe_surface *front;
+};
+
+static INLINE struct nouveau_winsys *
+nouveau_winsys(struct pipe_winsys *ws)
+{
+ return (struct nouveau_winsys *)ws;
+}
+
+static INLINE struct nouveau_winsys *
+nouveau_winsys_screen(struct pipe_screen *pscreen)
+{
+ return nouveau_winsys(pscreen->winsys);
+}
+
#endif
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c
deleted file mode 100644
index e3175fd775..0000000000
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "util/u_memory.h"
-
-#include "nouveau_winsys_pipe.h"
-
-static int
-nouveau_pipe_notifier_alloc(struct nouveau_winsys *nvws, int count,
- struct nouveau_notifier **notify)
-{
- struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws);
-
- return nouveau_notifier_alloc(nvpws->channel, nvpws->next_handle++,
- count, notify);
-}
-
-static int
-nouveau_pipe_grobj_alloc(struct nouveau_winsys *nvws, int grclass,
- struct nouveau_grobj **grobj)
-{
- struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws);
- struct nouveau_channel *chan = nvpws->channel;
- int ret;
-
- ret = nouveau_grobj_alloc(chan, nvpws->next_handle++, grclass, grobj);
- if (ret)
- return ret;
-
- BEGIN_RING(chan, *grobj, 0x0000, 1);
- OUT_RING (chan, (*grobj)->handle);
- (*grobj)->bound = NOUVEAU_GROBJ_BOUND_EXPLICIT;
- return 0;
-}
-
-static int
-nouveau_pipe_push_reloc(struct nouveau_winsys *nvws, void *ptr,
- struct pipe_buffer *buf, uint32_t data,
- uint32_t flags, uint32_t vor, uint32_t tor)
-{
- struct nouveau_bo *bo = nouveau_pipe_buffer(buf)->bo;
-
- return nouveau_pushbuf_emit_reloc(nvws->channel, ptr, bo,
- data, flags, vor, tor);
-}
-
-static int
-nouveau_pipe_push_flush(struct nouveau_winsys *nvws, unsigned size,
- struct pipe_fence_handle **fence)
-{
- if (fence)
- *fence = NULL;
-
- return nouveau_pushbuf_flush(nvws->channel, size);
-}
-
-static struct nouveau_bo *
-nouveau_pipe_get_bo(struct pipe_buffer *pb)
-{
- return nouveau_pipe_buffer(pb)->bo;
-}
-
-struct nouveau_winsys *
-nouveau_winsys_new(struct pipe_winsys *ws)
-{
- struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
- struct nouveau_winsys *nvws;
-
- nvws = CALLOC_STRUCT(nouveau_winsys);
- if (!nvws)
- return NULL;
-
- nvws->ws = ws;
- nvws->channel = nvpws->channel;
-
- nvws->res_init = nouveau_resource_init;
- nvws->res_alloc = nouveau_resource_alloc;
- nvws->res_free = nouveau_resource_free;
-
- nvws->push_reloc = nouveau_pipe_push_reloc;
- nvws->push_flush = nouveau_pipe_push_flush;
-
- nvws->grobj_alloc = nouveau_pipe_grobj_alloc;
- nvws->grobj_free = nouveau_grobj_free;
-
- nvws->notifier_alloc = nouveau_pipe_notifier_alloc;
- nvws->notifier_free = nouveau_notifier_free;
- nvws->notifier_reset = nouveau_notifier_reset;
- nvws->notifier_status = nouveau_notifier_status;
- nvws->notifier_retval = nouveau_notifier_return_val;
- nvws->notifier_wait = nouveau_notifier_wait_status;
-
- nvws->get_bo = nouveau_pipe_get_bo;
-
- return nvws;
-}
-
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c
deleted file mode 100644
index 9e03a9f5db..0000000000
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c
+++ /dev/null
@@ -1,204 +0,0 @@
-#include "pipe/internal/p_winsys_screen.h"
-#include <pipe/p_defines.h>
-#include <pipe/p_inlines.h>
-#include <util/u_memory.h>
-
-#include "nouveau_winsys_pipe.h"
-
-#include "nouveau_drmif.h"
-#include "nouveau_bo.h"
-
-static const char *
-nouveau_get_name(struct pipe_winsys *pws)
-{
- return "Nouveau/DRI";
-}
-
-static uint32_t
-nouveau_flags_from_usage(struct pipe_winsys *ws, unsigned usage)
-{
- struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
- struct pipe_screen *pscreen = nvpws->pscreen;
- uint32_t flags = NOUVEAU_BO_LOCAL;
-
- if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER)
- flags |= NOUVEAU_BO_GART;
-
- if (usage & PIPE_BUFFER_USAGE_PIXEL) {
- if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
- flags |= NOUVEAU_BO_GART;
- if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE))
- flags |= NOUVEAU_BO_VRAM;
-
- switch (nvpws->channel->device->chipset & 0xf0) {
- case 0x50:
- case 0x80:
- case 0x90:
- flags |= NOUVEAU_BO_TILED;
- if (usage & NOUVEAU_BUFFER_USAGE_ZETA)
- flags |= NOUVEAU_BO_ZTILE;
- break;
- default:
- break;
- }
- }
-
- if (usage & PIPE_BUFFER_USAGE_VERTEX) {
- if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF))
- flags |= NOUVEAU_BO_GART;
- }
-
- if (usage & PIPE_BUFFER_USAGE_INDEX) {
- if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF))
- flags |= NOUVEAU_BO_GART;
- }
-
- return flags;
-}
-
-static struct pipe_buffer *
-nouveau_pipe_bo_create(struct pipe_winsys *ws, unsigned alignment,
- unsigned usage, unsigned size)
-{
- struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
- struct nouveau_device *dev = nvpws->channel->device;
- struct nouveau_pipe_buffer *nvbuf;
- uint32_t flags;
-
- nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
- if (!nvbuf)
- return NULL;
- pipe_reference_init(&nvbuf->base.reference, 1);
- nvbuf->base.alignment = alignment;
- nvbuf->base.usage = usage;
- nvbuf->base.size = size;
-
- flags = nouveau_flags_from_usage(ws, usage);
- if (nouveau_bo_new(dev, flags, alignment, size, &nvbuf->bo)) {
- FREE(nvbuf);
- return NULL;
- }
-
- return &nvbuf->base;
-}
-
-static struct pipe_buffer *
-nouveau_pipe_bo_user_create(struct pipe_winsys *ws, void *ptr, unsigned bytes)
-{
- struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
- struct nouveau_device *dev = nvpws->channel->device;
- struct nouveau_pipe_buffer *nvbuf;
-
- nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
- if (!nvbuf)
- return NULL;
- pipe_reference_init(&nvbuf->base.reference, 1);
- nvbuf->base.size = bytes;
-
- if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) {
- FREE(nvbuf);
- return NULL;
- }
-
- return &nvbuf->base;
-}
-
-static void
-nouveau_pipe_bo_del(struct pipe_buffer *buf)
-{
- struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
-
- nouveau_bo_ref(NULL, &nvbuf->bo);
- FREE(nvbuf);
-}
-
-static void *
-nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
- unsigned flags)
-{
- struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
- uint32_t map_flags = 0;
-
- if (flags & PIPE_BUFFER_USAGE_CPU_READ)
- map_flags |= NOUVEAU_BO_RD;
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
- map_flags |= NOUVEAU_BO_WR;
-
- if (nouveau_bo_map(nvbuf->bo, map_flags))
- return NULL;
- return nvbuf->bo->map;
-}
-
-static void
-nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
-{
- struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
-
- nouveau_bo_unmap(nvbuf->bo);
-}
-
-static void
-nouveau_pipe_fence_reference(struct pipe_winsys *ws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *pfence)
-{
- *ptr = pfence;
-}
-
-static int
-nouveau_pipe_fence_signalled(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence, unsigned flag)
-{
- return 0;
-}
-
-static int
-nouveau_pipe_fence_finish(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence, unsigned flag)
-{
- return 0;
-}
-
-static void
-nouveau_destroy(struct pipe_winsys *ws)
-{
- struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
-
- nouveau_device_close(&nvpws->channel->device);
- FREE(nvpws);
-}
-
-struct pipe_winsys *
-nouveau_pipe_winsys_new(struct nouveau_device *dev)
-{
- struct nouveau_pipe_winsys *nvpws;
- int ret;
-
- nvpws = CALLOC_STRUCT(nouveau_pipe_winsys);
- if (!nvpws)
- return NULL;
-
- ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202,
- &nvpws->channel);
- if (ret) {
- debug_printf("%s: error opening GPU channel: %d\n",
- __func__, ret);
- FREE(nvpws);
- return NULL;
- }
- nvpws->next_handle = 0x77000000;
-
- nvpws->base.buffer_create = nouveau_pipe_bo_create;
- nvpws->base.buffer_destroy = nouveau_pipe_bo_del;
- nvpws->base.user_buffer_create = nouveau_pipe_bo_user_create;
- nvpws->base.buffer_map = nouveau_pipe_bo_map;
- nvpws->base.buffer_unmap = nouveau_pipe_bo_unmap;
-
- nvpws->base.fence_reference = nouveau_pipe_fence_reference;
- nvpws->base.fence_signalled = nouveau_pipe_fence_signalled;
- nvpws->base.fence_finish = nouveau_pipe_fence_finish;
-
- nvpws->base.get_name = nouveau_get_name;
- nvpws->base.destroy = nouveau_destroy;
- return &nvpws->base;
-}
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h
deleted file mode 100644
index ec10f1e00c..0000000000
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef NOUVEAU_PIPE_WINSYS_H
-#define NOUVEAU_PIPE_WINSYS_H
-
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_context.h"
-
-#include "nouveau/nouveau_winsys.h"
-
-#include "nouveau_device.h"
-
-struct nouveau_pipe_buffer {
- struct pipe_buffer base;
- struct nouveau_bo *bo;
-};
-
-static INLINE struct nouveau_pipe_buffer *
-nouveau_pipe_buffer(struct pipe_buffer *buf)
-{
- return (struct nouveau_pipe_buffer *)buf;
-}
-
-struct nouveau_pipe_winsys {
- struct pipe_winsys base;
-
- struct pipe_screen *pscreen;
-
- struct nouveau_channel *channel;
- uint32_t next_handle;
-
- unsigned nr_pctx;
- struct pipe_context **pctx;
-
- struct pipe_surface *front;
-};
-
-static INLINE struct nouveau_pipe_winsys *
-nouveau_pipe_winsys(struct pipe_winsys *ws)
-{
- return (struct nouveau_pipe_winsys *)ws;
-}
-
-static INLINE struct nouveau_pipe_winsys *
-nouveau_screen(struct pipe_screen *pscreen)
-{
- return nouveau_pipe_winsys(pscreen->winsys);
-}
-
-struct pipe_winsys *
-nouveau_pipe_winsys_new(struct nouveau_device *);
-
-struct nouveau_winsys *
-nouveau_winsys_new(struct pipe_winsys *ws);
-
-#endif
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
index a15487352b..0d0fdc5bd8 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
@@ -93,6 +93,29 @@ static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws,
return &radeon_buffer->base;
}
+static struct pipe_buffer *radeon_surface_buffer_create(struct pipe_winsys *ws,
+ unsigned width,
+ unsigned height,
+ enum pipe_format format,
+ unsigned usage,
+ unsigned *stride)
+{
+ struct pipe_format_block block;
+ unsigned nblocksx, nblocksy, size;
+
+ pf_get_block(format, &block);
+
+ nblocksx = pf_get_nblocksx(&block, width);
+ nblocksy = pf_get_nblocksy(&block, height);
+
+ /* Radeons enjoy things in multiples of 32. */
+ /* XXX this can be 32 when POT */
+ *stride = (nblocksx * block.size + 63) & ~63;
+ size = *stride * nblocksy;
+
+ return radeon_buffer_create(ws, 64, usage, size);
+}
+
static void radeon_buffer_del(struct pipe_buffer *buffer)
{
struct radeon_pipe_buffer *radeon_buffer =
@@ -180,10 +203,11 @@ struct radeon_winsys* radeon_pipe_winsys(int fd)
radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer;
radeon_ws->base.buffer_create = radeon_buffer_create;
- radeon_ws->base.buffer_destroy = radeon_buffer_del;
radeon_ws->base.user_buffer_create = radeon_buffer_user_create;
+ radeon_ws->base.surface_buffer_create = radeon_surface_buffer_create;
radeon_ws->base.buffer_map = radeon_buffer_map;
radeon_ws->base.buffer_unmap = radeon_buffer_unmap;
+ radeon_ws->base.buffer_destroy = radeon_buffer_del;
radeon_ws->base.fence_reference = radeon_fence_reference;
radeon_ws->base.fence_signalled = radeon_fence_signalled;
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
index 65366e242c..63aa3179ac 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
@@ -22,10 +22,10 @@
#include "radeon_r300.h"
-static void radeon_r300_add_buffer(struct r300_winsys* winsys,
- struct pipe_buffer* pbuffer,
- uint32_t rd,
- uint32_t wd)
+static boolean radeon_r300_add_buffer(struct r300_winsys* winsys,
+ struct pipe_buffer* pbuffer,
+ uint32_t rd,
+ uint32_t wd)
{
int i;
struct radeon_winsys_priv* priv =
@@ -35,7 +35,6 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys,
/* Check to see if this BO is already in line for validation;
* find a slot for it otherwise. */
- assert(priv->bo_count <= RADEON_MAX_BOS);
for (i = 0; i < priv->bo_count; i++) {
if (sc[i].bo == bo) {
sc[i].read_domains |= rd;
@@ -44,10 +43,17 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys,
}
}
+ if (priv->bo_count >= RADEON_MAX_BOS) {
+ /* Dohoho. Not falling for that one again. Request a flush. */
+ return FALSE;
+ }
+
sc[priv->bo_count].bo = bo;
sc[priv->bo_count].read_domains = rd;
sc[priv->bo_count].write_domain = wd;
priv->bo_count++;
+
+ return TRUE;
}
static boolean radeon_r300_validate(struct r300_winsys* winsys)
@@ -69,6 +75,16 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys)
return TRUE;
}
+ /* XXX should probably be its own function */
+ for (i = 0; i < priv->bo_count; i++) {
+ if (sc[i].read_domains && sc[i].write_domain) {
+ /* Cute, cute. We need to flush first. */
+ debug_printf("radeon: BO %p can't be read and written; "
+ "requesting flush.\n", sc[i].bo);
+ return TRUE;
+ }
+ }
+
/* Things are fine, we can proceed as normal. */
return FALSE;
}
@@ -109,9 +125,15 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys,
{
struct radeon_winsys_priv* priv =
(struct radeon_winsys_priv*)winsys->radeon_winsys;
+ int retval = 0;
- radeon_cs_write_reloc(priv->cs,
+ retval = radeon_cs_write_reloc(priv->cs,
((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags);
+
+ if (retval) {
+ debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n",
+ pbuffer, rd, wd, flags);
+ }
}
static void radeon_r300_end_cs(struct r300_winsys* winsys,
diff --git a/src/gallium/winsys/drm/radeon/xorg/Makefile b/src/gallium/winsys/drm/radeon/xorg/Makefile
index 6ffd4a3a54..0241625f69 100644
--- a/src/gallium/winsys/drm/radeon/xorg/Makefile
+++ b/src/gallium/winsys/drm/radeon/xorg/Makefile
@@ -37,6 +37,6 @@ clean:
install:
$(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
- $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+ $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
.PHONY = all clean install