s/migration/migrane/ , actually. Anyway, this has working glxinfo...
}
struct pipe_context* r300_create_context(struct pipe_screen* screen,
- struct pipe_winsys* winsys,
struct r300_winsys* r300_winsys)
{
struct r300_context* r300 = CALLOC_STRUCT(r300_context);
if (!r300)
return NULL;
+ /* XXX this could be refactored now? */
r300->winsys = r300_winsys;
- r300->context.winsys = winsys;
- r300->context.screen = r300_create_screen(winsys, r300_winsys);
+
+ r300->context.winsys = (struct pipe_winsys*)r300_winsys;
+ r300->context.screen = r300_screen(screen);
r300->context.destroy = r300_destroy_context;
* We'll just step out in that case... */
#ifndef R300_WINSYS_H
struct pipe_context* r300_create_context(struct pipe_screen* screen,
- struct pipe_winsys* winsys,
struct r300_winsys* r300_winsys);
#endif
FREE(r300screen);
}
-struct pipe_screen* r300_create_screen(struct pipe_winsys* winsys,
- struct r300_winsys* r300_winsys)
+struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys)
{
struct r300_screen* r300screen = CALLOC_STRUCT(r300_screen);
struct r300_capabilities* caps = CALLOC_STRUCT(r300_capabilities);
r300_parse_chipset(caps);
r300screen->caps = caps;
- r300screen->screen.winsys = winsys;
+ r300screen->screen.winsys = (struct pipe_winsys*)r300_winsys;
r300screen->screen.destroy = r300_destroy_screen;
r300screen->screen.get_name = r300_get_name;
r300screen->screen.get_vendor = r300_get_vendor;
}
/* Creates a new r300 screen. */
-struct pipe_screen* r300_create_screen(struct pipe_winsys* winsys,
- struct r300_winsys* r300_winsys);
+struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys);
#endif /* R300_SCREEN_H */
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
+#include "pipe/internal/p_winsys_screen.h"
struct radeon_cs;
struct r300_winsys {
+ /* Parent class */
+ struct pipe_winsys base;
+
+ /* Opaque Radeon-specific winsys object. */
+ void* radeon_winsys;
/* PCI ID */
uint32_t pci_id;
/* CS object. This is very much like Intel's batchbuffer.
* Fill it full of dwords and relocs and then submit.
* Repeat as needed. */
- /* Note: Unlike Mesa's version of this, we don't keep a copy of the CSM
- * that was used to create this CS. Is this a good idea? */
- /* Note: The pipe driver doesn't know how to use this. This is purely
- * for the winsys. */
struct radeon_cs* cs;
/* Check to see if there's room for commands. */
};
struct pipe_context* r300_create_context(struct pipe_screen* screen,
- struct pipe_winsys* winsys,
struct r300_winsys* r300_winsys);
#ifdef __cplusplus
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 = \
/*
* Copyright © 2008 Jérôme Glisse
+ * 2009 Corbin Simpson
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
/*
* Authors:
* Jérôme Glisse <glisse@freedesktop.org>
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
*/
#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"
#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;
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;
}
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;
}
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)
{
PIPE_BUFFER_USAGE_GPU_WRITE);
return ps;
}
+#endif
\ No newline at end of file
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,
* Authors:
* Corbin Simpson <MostAwesomeDude@gmail.com>
*/
+
#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
#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
}
-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;
winsys->end_cs = radeon_cs_end;
winsys->flush_cs = radeon_r300_flush_cs;
+ winsys->base = *old_winsys;
+
return winsys;
}
#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);
* 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"
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);
}
#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