softpipe: Call surface_alloc_storage to get the pipebuffer for display targets.

Otherwise blitting from display target surfaces to front screen fails in
several platforms.
This commit is contained in:
José Fonseca 2008-12-22 20:20:58 +00:00
parent 5f36c5b2c5
commit fc16ba8553

View file

@ -94,31 +94,50 @@ softpipe_texture_layout(struct pipe_screen *screen,
return spt->buffer != NULL;
}
/* Hack it up to use the old winsys->surface_alloc_storage()
* method for now:
*/
static boolean
softpipe_displaytarget_layout(struct pipe_screen *screen,
struct softpipe_texture * spt)
{
struct pipe_winsys *ws = screen->winsys;
size_t tex_size;
unsigned cpp;
struct pipe_surface surf;
unsigned flags = (PIPE_BUFFER_USAGE_CPU_READ |
PIPE_BUFFER_USAGE_CPU_WRITE |
PIPE_BUFFER_USAGE_GPU_READ |
PIPE_BUFFER_USAGE_GPU_WRITE);
int ret;
switch (spt->base.format) {
case PIPE_FORMAT_R5G6B5_UNORM:
cpp = 2;
break;
case PIPE_FORMAT_Z24S8_UNORM:
case PIPE_FORMAT_A8R8G8B8_UNORM:
default:
cpp = 4;
break;
memset(&surf, 0, sizeof(surf));
ret =ws->surface_alloc_storage( ws,
&surf,
spt->base.width[0],
spt->base.height[0],
spt->base.format,
flags,
spt->base.tex_usage);
if(ret != 0)
return FALSE;
if (!surf.buffer) {
/* allocation failed */
return FALSE;
}
tex_size = spt->base.width[0] * cpp * spt->base.height[0];
spt->buffer = ws->buffer_create(ws, 64, PIPE_BUFFER_USAGE_PIXEL, tex_size);
/* Now extract the goodies:
*/
spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
spt->stride[0] = spt->base.width[0] * cpp;
spt->stride[0] = surf.stride;
/* Transfer the reference:
*/
spt->buffer = surf.buffer;
surf.buffer = NULL;
return spt->buffer != NULL;
}