gallium: No longer allow CPU mapping surfaces directly.

Instead, a new pipe_transfer object has to be created and mapped for
transferring data between the CPU and a texture. This gives the driver more
flexibility for textures in address spaces that aren't CPU accessible.

This is a first pass; softpipe/xlib builds and runs glxgears, but it only shows
a black window. Looks like something's off related to the Z buffer, so the
depth test always fails.
This commit is contained in:
Michel Dänzer
2009-02-05 19:41:18 +01:00
parent e0c3b4970d
commit 4617981ec7
31 changed files with 793 additions and 678 deletions

View File

@@ -93,7 +93,7 @@ struct bitmap_cache
GLfloat color[4];
struct pipe_texture *texture;
struct pipe_surface *surf;
struct pipe_transfer *trans;
GLboolean empty;
@@ -308,7 +308,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
{
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_surface *surface;
struct pipe_transfer *transfer;
ubyte *dest;
struct pipe_texture *pt;
@@ -329,22 +329,21 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
return NULL;
}
surface = screen->get_tex_surface(screen, pt, 0, 0, 0,
PIPE_BUFFER_USAGE_CPU_WRITE);
transfer = screen->get_tex_transfer(screen, pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
0, 0, width, height);
/* map texture surface */
dest = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_WRITE);
dest = screen->transfer_map(screen, transfer);
/* Put image into texture surface */
memset(dest, 0xff, height * surface->stride);
/* Put image into texture transfer */
memset(dest, 0xff, height * transfer->stride);
unpack_bitmap(ctx->st, 0, 0, width, height, unpack, bitmap,
dest, surface->stride);
dest, transfer->stride);
_mesa_unmap_bitmap_pbo(ctx, unpack);
/* Release surface */
screen->surface_unmap(screen, surface);
pipe_surface_reference(&surface, NULL);
/* Release transfer */
screen->transfer_unmap(screen, transfer);
screen->tex_transfer_release(screen, &transfer);
return pt;
}
@@ -569,8 +568,8 @@ reset_cache(struct st_context *st)
cache->ymin = 1000000;
cache->ymax = -1000000;
if (cache->surf)
screen->tex_surface_release(screen, &cache->surf);
if (cache->trans)
screen->tex_transfer_release(screen, &cache->trans);
assert(!cache->texture);
@@ -581,16 +580,17 @@ reset_cache(struct st_context *st)
1, 0,
PIPE_TEXTURE_USAGE_SAMPLER);
/* Map the texture surface.
/* Map the texture transfer.
* Subsequent glBitmap calls will write into the texture image.
*/
cache->surf = screen->get_tex_surface(screen, cache->texture, 0, 0, 0,
PIPE_BUFFER_USAGE_CPU_WRITE);
cache->buffer = screen->surface_map(screen, cache->surf,
PIPE_BUFFER_USAGE_CPU_WRITE);
cache->trans = screen->get_tex_transfer(screen, cache->texture, 0, 0, 0,
PIPE_TRANSFER_WRITE, 0, 0,
BITMAP_CACHE_WIDTH,
BITMAP_CACHE_HEIGHT);
cache->buffer = screen->transfer_map(screen, cache->trans);
/* init image to all 0xff */
memset(cache->buffer, 0xff, BITMAP_CACHE_WIDTH * BITMAP_CACHE_HEIGHT);
memset(cache->buffer, 0xff, cache->trans->stride * BITMAP_CACHE_HEIGHT);
}
@@ -615,13 +615,13 @@ st_flush_bitmap_cache(struct st_context *st)
cache->xpos, cache->ypos);
*/
/* The texture surface has been mapped until now.
* So unmap and release the texture surface before drawing.
/* The texture transfer has been mapped until now.
* So unmap and release the texture transfer before drawing.
*/
screen->surface_unmap(screen, cache->surf);
screen->transfer_unmap(screen, cache->trans);
cache->buffer = NULL;
screen->tex_surface_release(screen, &cache->surf);
screen->tex_transfer_release(screen, &cache->trans);
draw_bitmap_quad(st->ctx,
cache->xpos,
@@ -812,8 +812,8 @@ st_destroy_bitmap(struct st_context *st)
struct pipe_screen *screen = pipe->screen;
struct bitmap_cache *cache = st->bitmap.cache;
screen->surface_unmap(screen, cache->surf);
screen->tex_surface_release(screen, &cache->surf);
screen->transfer_unmap(screen, cache->trans);
screen->tex_transfer_release(screen, &cache->trans);
if (st->bitmap.vs) {
cso_delete_vertex_shader(st->cso_context, st->bitmap.vs);