screen->tex_surface_destroy = i915_tex_surface_destroy;
}
-boolean i915_get_texture_buffer( struct pipe_texture *texture,
+boolean i915_get_texture_buffer( struct drm_api *api,
+ struct pipe_texture *texture,
struct pipe_buffer **buf,
unsigned *stride )
{
struct pipe_fence_handle;
struct pipe_winsys;
struct pipe_screen;
+struct drm_api;
/**
*
* This is needed for example kms.
*/
-boolean i915_get_texture_buffer( struct pipe_texture *texture,
+boolean i915_get_texture_buffer( struct drm_api *api,
+ struct pipe_texture *texture,
struct pipe_buffer **buf,
unsigned *stride );
boolean
-softpipe_get_texture_buffer( struct pipe_texture *texture,
+softpipe_get_texture_buffer( struct drm_api *api,
+ struct pipe_texture *texture,
struct pipe_buffer **buf,
unsigned *stride )
{
extern "C" {
#endif
-
+struct drm_api;
struct pipe_screen;
struct pipe_winsys;
struct pipe_context;
boolean
-softpipe_get_texture_buffer( struct pipe_texture *texture,
+softpipe_get_texture_buffer( struct drm_api *api,
+ struct pipe_texture *texture,
struct pipe_buffer **buf,
unsigned *stride );
* Special buffer functions
*/
/*@{*/
- struct pipe_screen* (*create_screen)(int drm_fd,
- struct drm_create_screen_arg *arg);
- struct pipe_context* (*create_context)(struct pipe_screen *screen);
+ struct pipe_screen* (*create_screen)(struct drm_api *api, int drm_fd,
+ struct drm_create_screen_arg *arg);
+ struct pipe_context* (*create_context)(struct drm_api *api,
+ struct pipe_screen *screen);
/*@}*/
/**
* Special buffer functions
*/
/*@{*/
- boolean (*buffer_from_texture)(struct pipe_texture *texture,
- struct pipe_buffer **buffer,
- unsigned *stride);
- struct pipe_buffer* (*buffer_from_handle)(struct pipe_screen *screen,
+ boolean (*buffer_from_texture)(struct drm_api *api,
+ struct pipe_texture *texture,
+ struct pipe_buffer **buffer,
+ unsigned *stride);
+ struct pipe_buffer* (*buffer_from_handle)(struct drm_api *api,
+ struct pipe_screen *screen,
const char *name,
unsigned handle);
- boolean (*handle_from_buffer)(struct pipe_screen *screen,
- struct pipe_buffer *buffer,
- unsigned *handle);
- boolean (*global_handle_from_buffer)(struct pipe_screen *screen,
- struct pipe_buffer *buffer,
- unsigned *handle);
+ boolean (*handle_from_buffer)(struct drm_api *api,
+ struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle);
+ boolean (*global_handle_from_buffer)(struct drm_api *api,
+ struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle);
/*@}*/
+
+ void (*destroy)(struct drm_api *api);
};
-/**
- * A driver needs to export this symbol
- */
-extern struct drm_api drm_api_hooks;
+extern struct drm_api * drm_api_create(void);
#endif
driParseConfigFiles(&ctx->optionCache,
&screen->optionCache, sPriv->myNum, "dri");
- ctx->pipe = drm_api_hooks.create_context(screen->pipe_screen);
+ ctx->pipe = screen->api->create_context(screen->api, screen->pipe_screen);
if (ctx->pipe == NULL)
goto fail;
}
static struct pipe_surface *
-dri_surface_from_handle(struct pipe_screen *screen,
+dri_surface_from_handle(struct drm_api *api,
+ struct pipe_screen *screen,
unsigned handle,
enum pipe_format format,
unsigned width, unsigned height, unsigned pitch)
struct pipe_texture templat;
struct pipe_buffer *buf = NULL;
- buf = drm_api_hooks.buffer_from_handle(screen, "dri2 buffer", handle);
+ buf = api->buffer_from_handle(api, screen, "dri2 buffer", handle);
if (!buf)
return NULL;
void
dri_get_buffers(__DRIdrawablePrivate * dPriv)
{
+
struct dri_drawable *drawable = dri_drawable(dPriv);
struct pipe_surface *surface = NULL;
struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen;
__DRIbuffer *buffers = NULL;
__DRIscreen *dri_screen = drawable->sPriv;
__DRIdrawable *dri_drawable = drawable->dPriv;
+ struct drm_api *api = ((struct dri_screen*)(dri_screen->private))->api;
boolean have_depth = FALSE;
int i, count;
have_depth = TRUE;
}
- surface = dri_surface_from_handle(screen,
+ surface = dri_surface_from_handle(api,
+ screen,
buffers[i].name,
format,
dri_drawable->w,
if (!screen)
return NULL;
+ screen->api = drm_api_create();
screen->sPriv = sPriv;
screen->fd = sPriv->fd;
screen->drmLock = (drmLock *) & sPriv->pSAREA->lock;
dri_copy_version(&arg.drm_version, &sPriv->drm_version);
arg.api = NULL;
- screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, &arg.base);
+ screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg.base);
if (!screen->pipe_screen || !arg.api) {
debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__);
if (!screen)
goto fail;
+ screen->api = drm_api_create();
screen->sPriv = sPriv;
screen->fd = sPriv->fd;
sPriv->private = (void *)screen;
sPriv->extensions = dri_screen_extensions;
arg.mode = DRM_CREATE_NORMAL;
- screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, &arg);
+ screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg);
if (!screen->pipe_screen) {
debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__);
goto fail;
drmLock *drmLock;
/* gallium */
+ struct drm_api *api;
struct pipe_winsys *pipe_winsys;
struct pipe_screen *pipe_screen;
boolean d_depth_bits_last;
_eglInitContext(drv, dpy, &ctx->base, config, attrib_list);
- ctx->pipe = drm_api_hooks.create_context(dev->screen);
+ ctx->pipe = dev->api->create_context(dev->api, dev->screen);
if (!ctx->pipe)
goto err_pipe;
scrn->front.width = w;
scrn->front.height = h;
scrn->front.pitch = pitch;
- drm_api_hooks.handle_from_buffer(screen, scrn->buffer, &scrn->front.handle);
+ dev->api->handle_from_buffer(dev->api, screen, scrn->buffer, &scrn->front.handle);
if (0)
goto err_handle;
return NULL;
}
+ drm->api = drm_api_create();
+
/* First fill in the dispatch table with defaults */
_eglInitDriverFallbacks(&drm->base);
/* then plug in our Drm-specific functions */
dev->drmFD = fd;
drm_get_device_id(dev);
- dev->screen = drm_api_hooks.create_screen(dev->drmFD, NULL);
+ dev->screen = dev->api->create_screen(dev->api, dev->drmFD, NULL);
if (!dev->screen)
goto err_screen;
dev->winsys = dev->screen->winsys;
dev->screen->destroy(dev->screen);
dev->winsys = NULL;
+ dev->api->destroy(dev->api);
drmClose(dev->drmFD);
* pipe
*/
+ struct drm_api *api;
struct pipe_winsys *winsys;
struct pipe_screen *screen;
static void
crtc_destroy(xf86CrtcPtr crtc)
{
- modesettingPtr ms = modesettingPTR(crtc->scrn);
struct crtc_private *crtcp = crtc->driver_private;
if (crtcp->cursor_buf)
PIPE_BUFFER_USAGE_CPU_WRITE |
PIPE_BUFFER_USAGE_GPU_READ,
64*64*4);
- drm_api_hooks.handle_from_buffer(ms->screen,
- crtcp->cursor_buf,
- &crtcp->cursor_handle);
+ ms->api->handle_from_buffer(ms->api,
+ ms->screen,
+ crtcp->cursor_buf,
+ &crtcp->cursor_handle);
}
ptr = pipe_buffer_map(ms->screen, crtcp->cursor_buf, PIPE_BUFFER_USAGE_CPU_WRITE);
tex = ms->screen->texture_create(ms->screen, &template);
}
- drm_api_hooks.buffer_from_texture(tex, &buf, &stride);
- drm_api_hooks.global_handle_from_buffer(ms->screen, buf, &handle);
+ ms->api->buffer_from_texture(ms->api, tex, &buf, &stride);
+ ms->api->global_handle_from_buffer(ms->api, ms->screen, buf, &handle);
buffers[i].name = handle;
buffers[i].attachment = attachments[i];
ms->PciInfo->dev, ms->PciInfo->func
);
+ ms->api = drm_api_create();
ms->fd = drmOpen(NULL, BusID);
if (ms->fd < 0)
}
if (!ms->screen) {
- ms->screen = drm_api_hooks.create_screen(ms->fd, NULL);
+ ms->screen = ms->api->create_screen(ms->api, ms->fd, NULL);
if (!ms->screen) {
FatalError("Could not init pipe_screen\n");
if (ms->exa)
xorg_exa_close(pScrn);
+ ms->api->destroy(ms->api);
+ ms->api = NULL;
drmClose(ms->fd);
ms->fd = -1;
return 0;
}
- drm_api_hooks.buffer_from_texture(priv->tex, &buffer, &stride);
- drm_api_hooks.handle_from_buffer(ms->screen, buffer, &handle);
+ ms->api->buffer_from_texture(ms->api, priv->tex, &buffer, &stride);
+ ms->api->handle_from_buffer(ms->api, ms->screen, buffer, &handle);
pipe_buffer_reference(&buffer, NULL);
return handle;
}
}
exa->scrn = ms->screen;
- exa->ctx = drm_api_hooks.create_context(exa->scrn);
+ exa->ctx = ms->api->create_context(ms->api, exa->scrn);
/* Share context with DRI */
ms->ctx = exa->ctx;
CreateScreenResourcesProcPtr createScreenResources;
/* gallium */
+ struct drm_api *api;
struct pipe_screen *screen;
struct pipe_context *ctx;
#include "intel_be_api.h"
#include "i915simple/i915_winsys.h"
-#ifdef DEBUG
-#include "trace/trace_drm.h"
+static void destroy(struct drm_api *api)
+{
+
+}
-struct drm_api hooks =
-#else
-struct drm_api drm_api_hooks =
-#endif
+struct drm_api intel_be_drm_api =
{
/* intel_be_context.c */
.create_context = intel_be_create_context,
.buffer_from_handle = intel_be_buffer_from_handle,
.handle_from_buffer = intel_be_handle_from_buffer,
.global_handle_from_buffer = intel_be_global_handle_from_buffer,
+ .destroy = destroy,
};
+
+struct drm_api *
+drm_api_create()
+{
+ return &intel_be_drm_api;
+}
#include "intel_be_device.h"
-struct pipe_screen *intel_be_create_screen(int drmFD,
+extern struct drm_api intel_be_drm_api;
+
+struct pipe_screen *intel_be_create_screen(struct drm_api *api, int drmFD,
struct drm_create_screen_arg *arg);
-struct pipe_context *intel_be_create_context(struct pipe_screen *screen);
+struct pipe_context *intel_be_create_context(struct drm_api *api,
+ struct pipe_screen *screen);
#endif
}
struct pipe_context *
-intel_be_create_context(struct pipe_screen *screen)
+intel_be_create_context(struct drm_api *api, struct pipe_screen *screen)
{
struct intel_be_context *intel;
struct pipe_context *pipe;
}
struct pipe_buffer *
-intel_be_buffer_from_handle(struct pipe_screen *screen,
+intel_be_buffer_from_handle(struct drm_api *api,
+ struct pipe_screen *screen,
const char* name, unsigned handle)
{
struct intel_be_device *dev = intel_be_device(screen->winsys);
}
boolean
-intel_be_handle_from_buffer(struct pipe_screen *screen,
+intel_be_handle_from_buffer(struct drm_api *api,
+ struct pipe_screen *screen,
struct pipe_buffer *buffer,
unsigned *handle)
{
}
boolean
-intel_be_global_handle_from_buffer(struct pipe_screen *screen,
+intel_be_global_handle_from_buffer(struct drm_api *api,
+ struct pipe_screen *screen,
struct pipe_buffer *buffer,
unsigned *handle)
{
{
char path[512];
FILE *file;
+ void *shutup_gcc;
/*
* FIXME: Fix this up to use a drm ioctl or whatever.
return;
}
- fgets(path, sizeof(path), file);
+ shutup_gcc = fgets(path, sizeof(path), file);
sscanf(path, "%x", device_id);
fclose(file);
}
struct pipe_screen *
-intel_be_create_screen(int drmFD, struct drm_create_screen_arg *arg)
+intel_be_create_screen(struct drm_api *api, int drmFD,
+ struct drm_create_screen_arg *arg)
{
struct intel_be_device *dev;
struct pipe_screen *screen;
if (dev->softpipe) {
screen = softpipe_create_screen(&dev->base);
- drm_api_hooks.buffer_from_texture = softpipe_get_texture_buffer;
+ intel_be_drm_api.buffer_from_texture = softpipe_get_texture_buffer;
} else
screen = i915_create_screen(&dev->base, deviceID);
#include "drm.h"
#include "intel_bufmgr.h"
+struct drm_api;
+
/*
* Device
*/
* Takes a reference.
*/
struct pipe_buffer *
-intel_be_buffer_from_handle(struct pipe_screen *screen,
+intel_be_buffer_from_handle(struct drm_api *api,
+ struct pipe_screen *screen,
const char* name, unsigned handle);
/**
* If buffer is destroyed handle may become invalid.
*/
boolean
-intel_be_handle_from_buffer(struct pipe_screen *screen,
+intel_be_handle_from_buffer(struct drm_api *api,
+ struct pipe_screen *screen,
struct pipe_buffer *buffer,
unsigned *handle);
* If buffer is destroyed handle may become invalid.
*/
boolean
-intel_be_global_handle_from_buffer(struct pipe_screen *screen,
+intel_be_global_handle_from_buffer(struct drm_api *api,
+ struct pipe_screen *screen,
struct pipe_buffer *buffer,
unsigned *handle);