aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorCorbin Simpson <[email protected]>2009-03-03 21:14:33 -0800
committerCorbin Simpson <[email protected]>2009-03-03 22:16:24 -0800
commit9e67b0a1745e50fe34efedb0a3191b4a27e10724 (patch)
tree8179c969551ccc59b0402bd4ac8d558fb43734d2 /src/gallium/winsys
parenta255472ee789d13c07174e385c7d40f965916e7b (diff)
r300-gallium, radeon-gallium: Begin migration to DRI2 state tracker, part 1.
s/migration/migrane/ , actually. Anyway, this has working glxinfo...
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/drm/radeon/Makefile3
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_buffer.c90
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_buffer.h11
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_drm.c80
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_drm.h30
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_r300.c8
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_r300.h2
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c9
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h2
9 files changed, 177 insertions, 58 deletions
diff --git a/src/gallium/winsys/drm/radeon/Makefile b/src/gallium/winsys/drm/radeon/Makefile
index 784686ffb68..8721f2cb5d4 100644
--- a/src/gallium/winsys/drm/radeon/Makefile
+++ b/src/gallium/winsys/drm/radeon/Makefile
@@ -7,15 +7,14 @@ LIBNAME = radeon_dri.so
MINIGLX_SOURCES =
PIPE_DRIVERS = \
+ $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
$(TOP)/src/gallium/drivers/r300/libr300.a
DRIVER_SOURCES = \
radeon_buffer.c \
- radeon_context.c \
radeon_drm.c \
radeon_r300.c \
- radeon_screen.c \
radeon_winsys_softpipe.c
C_SOURCES = \
diff --git a/src/gallium/winsys/drm/radeon/radeon_buffer.c b/src/gallium/winsys/drm/radeon/radeon_buffer.c
index 918d2f98e2a..79b8f777ca8 100644
--- a/src/gallium/winsys/drm/radeon/radeon_buffer.c
+++ b/src/gallium/winsys/drm/radeon/radeon_buffer.c
@@ -1,5 +1,6 @@
/*
* Copyright © 2008 Jérôme Glisse
+ * 2009 Corbin Simpson
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -26,10 +27,14 @@
/*
* Authors:
* Jérôme Glisse <[email protected]>
+ * Corbin Simpson <[email protected]>
*/
#include <stdio.h>
-#include "dri_util.h"
+
#include "state_tracker/st_public.h"
+
+#include "util/u_memory.h"
+
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "radeon_buffer.h"
@@ -38,24 +43,26 @@
#include "radeon_bo.h"
#include "radeon_drm.h"
+
static const char *radeon_get_name(struct pipe_winsys *ws)
{
- return "RADEON/DRI2";
+ return "Radeon/GEM+KMS";
}
static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
- unsigned alignment,
- unsigned usage,
- unsigned size)
+ unsigned alignment,
+ unsigned usage,
+ unsigned size)
{
- struct radeon_pipe_winsys *radeon_ws = (struct radeon_pipe_winsys *)ws;
+ struct radeon_winsys *radeon_ws = (struct radeon_winsys *)ws;
struct radeon_pipe_buffer *radeon_buffer;
uint32_t domain;
- radeon_buffer = calloc(1, sizeof(*radeon_buffer));
+ radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer);
if (radeon_buffer == NULL) {
return NULL;
}
+
radeon_buffer->base.refcount = 1;
radeon_buffer->base.alignment = alignment;
radeon_buffer->base.usage = usage;
@@ -69,21 +76,21 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
if (usage & PIPE_BUFFER_USAGE_VERTEX) {
domain |= RADEON_GEM_DOMAIN_GTT;
}
-
if (usage & PIPE_BUFFER_USAGE_INDEX) {
domain |= RADEON_GEM_DOMAIN_GTT;
}
- radeon_buffer->bo = radeon_bo_open(radeon_ws->radeon_screen->bom, 0,
- size, alignment, domain, 0);
+
+ radeon_buffer->bo = radeon_bo_open(radeon_ws->bom, 0, size, alignment,
+ domain, 0);
if (radeon_buffer->bo == NULL) {
- free(radeon_buffer);
+ FREE(radeon_buffer);
}
return &radeon_buffer->base;
}
static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws,
- void *ptr,
- unsigned bytes)
+ void *ptr,
+ unsigned bytes)
{
struct radeon_pipe_buffer *radeon_buffer;
@@ -106,21 +113,20 @@ static void radeon_buffer_del(struct pipe_winsys *ws, struct pipe_buffer *buffer
}
static void *radeon_buffer_map(struct pipe_winsys *ws,
- struct pipe_buffer *buffer,
- unsigned flags)
+ struct pipe_buffer *buffer,
+ unsigned flags)
{
struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer;
int write = 0;
if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
- /* Remove this when radeon_bo_map supports DONTBLOCK
- */
+ /* XXX Remove this when radeon_bo_map supports DONTBLOCK */
return NULL;
}
-
if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
write = 1;
}
+
if (radeon_bo_map(radeon_buffer->bo, write))
return NULL;
return radeon_buffer->bo->ptr;
@@ -134,59 +140,58 @@ static void radeon_buffer_unmap(struct pipe_winsys *ws, struct pipe_buffer *buff
}
static void radeon_fence_reference(struct pipe_winsys *ws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *pfence)
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *pfence)
{
}
static int radeon_fence_signalled(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence,
- unsigned flag)
+ struct pipe_fence_handle *pfence,
+ unsigned flag)
{
return 1;
}
static int radeon_fence_finish(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence,
- unsigned flag)
+ struct pipe_fence_handle *pfence,
+ unsigned flag)
{
return 0;
}
static void radeon_flush_frontbuffer(struct pipe_winsys *pipe_winsys,
- struct pipe_surface *pipe_surface,
- void *context_private)
+ struct pipe_surface *pipe_surface,
+ void *context_private)
{
/* TODO: call dri2CopyRegion */
}
-struct pipe_winsys *radeon_pipe_winsys(struct radeon_screen *radeon_screen)
+struct pipe_winsys *radeon_pipe_winsys()
{
- struct radeon_pipe_winsys *radeon_ws;
+ struct pipe_winsys *radeon_ws;
- radeon_ws = calloc(1, sizeof(struct radeon_pipe_winsys));
+ radeon_ws = CALLOC_STRUCT(pipe_winsys);
if (radeon_ws == NULL) {
return NULL;
}
- radeon_ws->radeon_screen = radeon_screen;
- radeon_ws->winsys.flush_frontbuffer = radeon_flush_frontbuffer;
+ radeon_ws->flush_frontbuffer = radeon_flush_frontbuffer;
- radeon_ws->winsys.buffer_create = radeon_buffer_create;
- radeon_ws->winsys.buffer_destroy = radeon_buffer_del;
- radeon_ws->winsys.user_buffer_create = radeon_buffer_user_create;
- radeon_ws->winsys.buffer_map = radeon_buffer_map;
- radeon_ws->winsys.buffer_unmap = radeon_buffer_unmap;
+ radeon_ws->buffer_create = radeon_buffer_create;
+ radeon_ws->buffer_destroy = radeon_buffer_del;
+ radeon_ws->user_buffer_create = radeon_buffer_user_create;
+ radeon_ws->buffer_map = radeon_buffer_map;
+ radeon_ws->buffer_unmap = radeon_buffer_unmap;
- radeon_ws->winsys.fence_reference = radeon_fence_reference;
- radeon_ws->winsys.fence_signalled = radeon_fence_signalled;
- radeon_ws->winsys.fence_finish = radeon_fence_finish;
+ radeon_ws->fence_reference = radeon_fence_reference;
+ radeon_ws->fence_signalled = radeon_fence_signalled;
+ radeon_ws->fence_finish = radeon_fence_finish;
- radeon_ws->winsys.get_name = radeon_get_name;
+ radeon_ws->get_name = radeon_get_name;
- return &radeon_ws->winsys;
+ return radeon_ws;
}
-
+#if 0
static struct pipe_buffer *radeon_buffer_from_handle(struct radeon_screen *radeon_screen,
uint32_t handle)
{
@@ -243,3 +248,4 @@ struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_co
PIPE_BUFFER_USAGE_GPU_WRITE);
return ps;
}
+#endif \ No newline at end of file
diff --git a/src/gallium/winsys/drm/radeon/radeon_buffer.h b/src/gallium/winsys/drm/radeon/radeon_buffer.h
index c626c20229b..e062308f440 100644
--- a/src/gallium/winsys/drm/radeon/radeon_buffer.h
+++ b/src/gallium/winsys/drm/radeon/radeon_buffer.h
@@ -40,12 +40,15 @@ struct radeon_pipe_buffer {
struct radeon_bo *bo;
};
-struct radeon_pipe_winsys {
- struct pipe_winsys winsys;
- struct radeon_screen *radeon_screen;
+struct radeon_winsys {
+ /* Parent class. */
+ struct pipe_winsys base;
+
+ /* Radeon BO manager. This corresponds to void* radeon_winsys in r300_winsys. */
+ struct radeon_bo_manager* bom;
};
-struct pipe_winsys *radeon_pipe_winsys(struct radeon_screen *radeon_screen);
+struct pipe_winsys *radeon_pipe_winsys();
struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_context,
uint32_t handle,
enum pipe_format format,
diff --git a/src/gallium/winsys/drm/radeon/radeon_drm.c b/src/gallium/winsys/drm/radeon/radeon_drm.c
index 839b0bf0bd4..9cd178f944a 100644
--- a/src/gallium/winsys/drm/radeon/radeon_drm.c
+++ b/src/gallium/winsys/drm/radeon/radeon_drm.c
@@ -27,4 +27,84 @@
* Authors:
* Corbin Simpson <[email protected]>
*/
+
#include "radeon_drm.h"
+
+/* Create a pipe_screen. */
+struct pipe_screen* radeon_create_screen(int drmFB, int pciID)
+{
+ struct radeon_context* radeon = CALLOC_STRUCT(radeon_context);
+ struct pipe_winsys* winsys = radeon_pipe_winsys(radeon);
+
+ if (getenv("RADEON_SOFTPIPE")) {
+ return softpipe_create_screen(winsys);
+ } else {
+ struct r300_winsys* r300 = radeon_create_r300_winsys(drmFB, winsys);
+ FREE(winsys);
+ return r300_create_screen(r300);
+ }
+}
+
+/* Create a pipe_context. */
+struct pipe_context* radeon_create_context(struct pipe_screen* screen)
+{
+ if (getenv("RADEON_SOFTPIPE")) {
+ return radeon_create_softpipe(screen->winsys);
+ } else {
+ return r300_create_context(screen, screen->winsys);
+ }
+}
+
+boolean radeon_buffer_from_texture(struct pipe_texture* texture,
+ struct pipe_buffer** buffer,
+ unsigned* stride)
+{
+}
+
+/* Create a buffer from a handle. */
+/* XXX what's up with name? */
+struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen,
+ const char* name,
+ unsigned handle)
+{
+ struct radeon_bo_manager* bom = ((struct radeon_winsys*)screen->winsys)->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;
+ }
+
+ radeon_buffer->base.refcount = 1;
+ radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL;
+ radeon_buffer->bo = bo;
+ return &radeon_buffer->base;
+}
+
+boolean radeon_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle)
+{
+}
+
+boolean radeon_global_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle)
+{
+}
+
+struct drm_api drm_api_hooks = {
+ .create_screen = radeon_create_screen,
+ .create_context = radeon_create_context,
+ .buffer_from_texture = radeon_buffer_from_texture,
+ .buffer_from_handle = radeon_buffer_from_handle,
+ .handle_from_buffer = radeon_handle_from_buffer,
+ .global_handle_from_buffer = radeon_global_handle_from_buffer,
+}; \ No newline at end of file
diff --git a/src/gallium/winsys/drm/radeon/radeon_drm.h b/src/gallium/winsys/drm/radeon/radeon_drm.h
index 8ccbc818959..e434106cb5b 100644
--- a/src/gallium/winsys/drm/radeon/radeon_drm.h
+++ b/src/gallium/winsys/drm/radeon/radeon_drm.h
@@ -30,6 +30,36 @@
#ifndef RADEON_DRM_H
#define RADEON_DRM_H
+#include "pipe/p_screen.h"
+
+#include "util/u_memory.h"
+
#include "state_tracker/drm_api.h"
+#include "radeon_buffer.h"
+#include "radeon_context.h"
+#include "radeon_r300.h"
+#include "radeon_screen.h"
+#include "radeon_winsys_softpipe.h"
+
+struct pipe_screen* radeon_create_screen(int drmFB, int pciID);
+
+struct pipe_context* radeon_create_context(struct pipe_screen* screen);
+
+boolean radeon_buffer_from_texture(struct pipe_texture* texture,
+ struct pipe_buffer** buffer,
+ unsigned* stride);
+
+struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen,
+ const char* name,
+ unsigned handle);
+
+boolean radeon_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle);
+
+boolean radeon_global_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle);
+
#endif
diff --git a/src/gallium/winsys/drm/radeon/radeon_r300.c b/src/gallium/winsys/drm/radeon/radeon_r300.c
index 8fe2375e34d..e9b96b1ee93 100644
--- a/src/gallium/winsys/drm/radeon/radeon_r300.c
+++ b/src/gallium/winsys/drm/radeon/radeon_r300.c
@@ -75,14 +75,16 @@ static void do_ioctls(struct r300_winsys* winsys, int fd)
}
-struct r300_winsys* radeon_create_r300_winsys(int fd)
+struct r300_winsys* radeon_create_r300_winsys(int fd, struct pipe_winsys* old_winsys)
{
- struct r300_winsys* winsys = calloc(1, sizeof(struct r300_winsys));
+ struct r300_winsys* winsys = CALLOC_STRUCT(r300_winsys);
do_ioctls(winsys, fd);
+ struct radeon_bo_manager* bom = radeon_bo_manager_gem_ctor(fd);
struct radeon_cs_manager* csm = radeon_cs_manager_gem_ctor(fd);
+ winsys->radeon_winsys = bom;
winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4);
winsys->check_cs = radeon_r300_check_cs;
@@ -92,5 +94,7 @@ struct r300_winsys* radeon_create_r300_winsys(int fd)
winsys->end_cs = radeon_cs_end;
winsys->flush_cs = radeon_r300_flush_cs;
+ winsys->base = *old_winsys;
+
return winsys;
}
diff --git a/src/gallium/winsys/drm/radeon/radeon_r300.h b/src/gallium/winsys/drm/radeon/radeon_r300.h
index 8ed95a3a9b1..432b7b18331 100644
--- a/src/gallium/winsys/drm/radeon/radeon_r300.h
+++ b/src/gallium/winsys/drm/radeon/radeon_r300.h
@@ -31,4 +31,4 @@
#include "radeon_buffer.h"
-struct r300_winsys* radeon_create_r300_winsys(int fd);
+struct r300_winsys* radeon_create_r300_winsys(int fd, struct pipe_winsys* old_winsys);
diff --git a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c b/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c
index 8402e1fa5a8..75e975f5e28 100644
--- a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c
+++ b/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c
@@ -29,7 +29,6 @@
* Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
*/
#include <stdio.h>
-#include "imports.h"
#include "pipe/p_defines.h"
#include "pipe/p_format.h"
#include "softpipe/sp_winsys.h"
@@ -57,21 +56,19 @@ static boolean radeon_is_format_supported(struct softpipe_winsys *sws, uint form
return FALSE;
}
-struct pipe_context *radeon_create_softpipe(struct radeon_context *radeon_context)
+struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys)
{
struct radeon_softpipe_winsys *radeon_sp_ws;
struct pipe_screen *pipe_screen;
- pipe_screen = softpipe_create_screen(radeon_context->pipe_winsys);
+ pipe_screen = softpipe_create_screen(winsys);
radeon_sp_ws = CALLOC_STRUCT(radeon_softpipe_winsys);
if (radeon_sp_ws == NULL) {
return NULL;
}
- radeon_context->pipe_screen = pipe_screen;
- radeon_sp_ws->radeon_context = radeon_context;
radeon_sp_ws->sp_winsys.is_format_supported = radeon_is_format_supported;
return softpipe_create(pipe_screen,
- radeon_context->pipe_winsys,
+ winsys,
&radeon_sp_ws->sp_winsys);
}
diff --git a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h b/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h
index 519eab769c8..093693eddfa 100644
--- a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h
+++ b/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h
@@ -32,6 +32,6 @@
#include "radeon_context.h"
-struct pipe_context *radeon_create_softpipe(struct radeon_context *radeon_context);
+struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys);
#endif