summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2008-12-31 13:05:39 +0000
committerJosé Fonseca <jfonseca@vmware.com>2008-12-31 13:06:22 +0000
commite228433823b90127a217950433e31f0ef44df813 (patch)
treedf248b0e85f158d15307a391810a9cc7aca2a0a7 /src/gallium/drivers
parent43d70a12d4cc2b930cc7e1bb1eb68326ed3697e9 (diff)
parent417a78bdad11976f89e7bb12e3de0138995a2b1f (diff)
Merge commit 'origin/gallium-0.1' into gallium-0.2
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 0cb4b2f03c..a64dc89f43 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -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;
-
- 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;
+ 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;
+
+
+ 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;
}
@@ -220,10 +239,8 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
ps->refcount = 1;
- ps->winsys = ws;
if (ps) {
assert(ps->refcount);
- assert(ps->winsys);
pipe_texture_reference(&ps->texture, pt);
pipe_buffer_reference(screen, &ps->buffer, spt->buffer);
ps->format = pt->format;