diff options
author | Jakob Bornecrantz <[email protected]> | 2009-08-27 18:57:29 +0100 |
---|---|---|
committer | Jakob Bornecrantz <[email protected]> | 2009-08-28 13:38:23 +0100 |
commit | 1e5014f7dfabcaf1f4b5608eb08e97179446eb09 (patch) | |
tree | 75ab693e5e07467c36fd3593c440143d62ce907e /src/gallium/state_trackers | |
parent | 7d9af52bc59bfeb19d9bdb55258f4a830a1b0d04 (diff) |
drm_api: Operate on textures instead of buffers
Most use cases just got the buffer from the texture
and then called into one of the get_handle functions.
Also with this patch it would be easier to move to a
generic function for getting handles from textures
and textures from handles, that is exposed via the screen.
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/dri/dri_drawable.c | 13 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/egl_surface.c | 9 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_crtc.c | 64 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_dri2.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_exa.c | 5 |
5 files changed, 47 insertions, 50 deletions
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 2265187880b..bcfd1c06fec 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -56,13 +56,6 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_surface *surface = NULL; struct pipe_texture *texture = NULL; struct pipe_texture templat; - struct pipe_buffer *buf = NULL; - - buf = api->buffer_from_handle(api, screen, "dri2 buffer", handle); - if (!buf) { - debug_printf("%s: Failed to get buffer from handle\n", __func__); - return NULL; - } memset(&templat, 0, sizeof(templat)); templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; @@ -74,10 +67,8 @@ dri_surface_from_handle(struct drm_api *api, templat.height[0] = height; pf_get_block(templat.format, &templat.block); - texture = screen->texture_blanket(screen, &templat, &pitch, buf); - - /* we don't need the buffer from this point on */ - pipe_buffer_reference(&buf, NULL); + texture = api->texture_from_shared_handle(api, screen, &templat, + "dri2 buffer", pitch, handle); if (!texture) { debug_printf("%s: Failed to blanket the buffer with a texture\n", __func__); diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c index 3ef1945b93c..69e2d6b7081 100644 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ b/src/gallium/state_trackers/egl/egl_surface.c @@ -96,10 +96,6 @@ drm_create_texture(_EGLDisplay *dpy, if (!texture) goto err_tex; - dev->api->buffer_from_texture(dev->api, texture, &buf, &pitch); - if (!buf) - goto err_buf; - surface = screen->get_tex_surface(screen, texture, 0, @@ -112,11 +108,11 @@ drm_create_texture(_EGLDisplay *dpy, scrn->tex = texture; scrn->surface = surface; - scrn->buffer = buf; scrn->front.width = w; scrn->front.height = h; scrn->front.pitch = pitch; - dev->api->handle_from_buffer(dev->api, screen, scrn->buffer, &scrn->front.handle); + dev->api->local_handle_from_texture(dev->api, screen, texture, + &scrn->front.pitch, &scrn->front.handle); if (0) goto err_handle; @@ -126,7 +122,6 @@ err_handle: pipe_surface_reference(&surface, NULL); err_surf: pipe_texture_reference(&texture, NULL); -err_buf: err_tex: pipe_buffer_reference(&buf, NULL); return; diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 2110c878dca..fe08bde9efc 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -46,13 +46,14 @@ #include <X11/extensions/dpms.h> #include "pipe/p_inlines.h" +#include "util/u_rect.h" struct crtc_private { drmModeCrtcPtr drm_crtc; /* hwcursor */ - struct pipe_buffer *cursor_buf; + struct pipe_texture *cursor_tex; unsigned cursor_handle; }; @@ -173,8 +174,8 @@ crtc_destroy(xf86CrtcPtr crtc) { struct crtc_private *crtcp = crtc->driver_private; - if (crtcp->cursor_buf) - pipe_buffer_reference(&crtcp->cursor_buf, NULL); + if (crtcp->cursor_tex) + pipe_texture_reference(&crtcp->cursor_tex, NULL); drmModeFreeCrtc(crtcp->drm_crtc); xfree(crtcp); @@ -186,25 +187,42 @@ crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image) unsigned char *ptr; modesettingPtr ms = modesettingPTR(crtc->scrn); struct crtc_private *crtcp = crtc->driver_private; - - if (!crtcp->cursor_buf) { - crtcp->cursor_buf = pipe_buffer_create(ms->screen, - 0, - PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_GPU_READ, - 64*64*4); - ms->api->handle_from_buffer(ms->api, - ms->screen, - crtcp->cursor_buf, - &crtcp->cursor_handle); + struct pipe_transfer *transfer; + + if (!crtcp->cursor_tex) { + struct pipe_texture templat; + unsigned pitch; + + memset(&templat, 0, sizeof(templat)); + templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; + templat.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; + templat.target = PIPE_TEXTURE_2D; + templat.last_level = 0; + templat.depth[0] = 1; + templat.format = PIPE_FORMAT_A8R8G8B8_UNORM; + templat.width[0] = 64; + templat.height[0] = 64; + pf_get_block(templat.format, &templat.block); + + crtcp->cursor_tex = ms->screen->texture_create(ms->screen, + &templat); + ms->api->local_handle_from_texture(ms->api, + ms->screen, + crtcp->cursor_tex, + &pitch, + &crtcp->cursor_handle); } - ptr = pipe_buffer_map(ms->screen, crtcp->cursor_buf, PIPE_BUFFER_USAGE_CPU_WRITE); - - if (ptr) - memcpy(ptr, image, 64 * 64 * 4); - - pipe_buffer_unmap(ms->screen, crtcp->cursor_buf); + transfer = ms->screen->get_tex_transfer(ms->screen, crtcp->cursor_tex, + 0, 0, 0, + PIPE_TRANSFER_WRITE, + 0, 0, 64, 64); + ptr = ms->screen->transfer_map(ms->screen, transfer); + util_copy_rect(ptr, &crtcp->cursor_tex->block, + transfer->stride, 0, 0, + 64, 64, (void*)image, 64 * 4, 0, 0); + ms->screen->transfer_unmap(ms->screen, transfer); + ms->screen->tex_transfer_destroy(transfer); } static void @@ -222,7 +240,7 @@ crtc_show_cursor(xf86CrtcPtr crtc) modesettingPtr ms = modesettingPTR(crtc->scrn); struct crtc_private *crtcp = crtc->driver_private; - if (crtcp->cursor_buf) + if (crtcp->cursor_tex) drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, crtcp->cursor_handle, 64, 64); } @@ -264,8 +282,8 @@ crtc_cursor_destroy(xf86CrtcPtr crtc) { struct crtc_private *crtcp = crtc->driver_private; - if (crtcp->cursor_buf) { - pipe_buffer_reference(&crtcp->cursor_buf, NULL); + if (crtcp->cursor_tex) { + pipe_texture_reference(&crtcp->cursor_tex, NULL); } } diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index c48fb30e7d5..3b90421de9f 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -44,7 +44,6 @@ typedef struct { PixmapPtr pPixmap; struct pipe_texture *tex; - struct pipe_buffer *buf; struct pipe_fence_handle *fence; } *BufferPrivatePtr; @@ -133,8 +132,7 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count) if (!tex) FatalError("NO TEXTURE IN DRI2\n"); - ms->api->buffer_from_texture(ms->api, tex, &buf, &stride); - ms->api->global_handle_from_buffer(ms->api, ms->screen, buf, &handle); + ms->api->shared_handle_from_texture(ms->api, ms->screen, tex, &stride, &handle); buffers[i].name = handle; buffers[i].attachment = attachments[i]; @@ -143,7 +141,6 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count) buffers[i].driverPrivate = &privates[i]; buffers[i].flags = 0; /* not tiled */ privates[i].pPixmap = pPixmap; - privates[i].buf = buf; privates[i].tex = tex; } @@ -169,7 +166,6 @@ driDestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count) private = buffers[i].driverPrivate; pipe_texture_reference(&private->tex, NULL); - pipe_buffer_reference(&private->buf, NULL); ms->screen->fence_reference(ms->screen, &private->fence, NULL); if (private->pPixmap) diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 9bd28a8c84b..acc49f4c2b1 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -396,7 +396,6 @@ xorg_exa_get_pixmap_handle(PixmapPtr pPixmap, unsigned *stride_out) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; modesettingPtr ms = modesettingPTR(pScrn); struct exa_pixmap_priv *priv; - struct pipe_buffer *buffer = NULL; unsigned handle; unsigned stride; @@ -412,9 +411,7 @@ xorg_exa_get_pixmap_handle(PixmapPtr pPixmap, unsigned *stride_out) return 0; } - 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); + ms->api->local_handle_from_texture(ms->api, ms->screen, priv->tex, &stride, &handle); if (stride_out) *stride_out = stride; |