diff options
author | Igor Oliveira <itrindade.oliveira@gmail.com> | 2010-06-20 22:28:09 -0400 |
---|---|---|
committer | Igor Oliveira <igor.oliveira@openbossa.org> | 2010-06-20 22:28:09 -0400 |
commit | 6056a3a2ee5741a48d88713a4b9ca8e272658745 (patch) | |
tree | 2e16588ff855299e78c7b7527cdc7b9b2f47db70 | |
parent | c48515f704656c65f2a9fb9cc328ef851e40f41d (diff) |
Initial Fixes: get_tile_rgba and other fixes
-rw-r--r-- | src/drm/cairo-drm-gallium-surface.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/drm/cairo-drm-gallium-surface.c b/src/drm/cairo-drm-gallium-surface.c index 40446277..a284e5f8 100644 --- a/src/drm/cairo-drm-gallium-surface.c +++ b/src/drm/cairo-drm-gallium-surface.c @@ -53,6 +53,8 @@ #include <util/u_simple_shaders.h> #include <util/u_draw_quad.h> +#include <util/u_debug.h> + #include <tgsi/tgsi_ureg.h> #include <tgsi/tgsi_build.h> #include <tgsi/tgsi_parse.h> @@ -302,6 +304,7 @@ shader_create(gallium_device_t *device) shader = malloc (sizeof(gallium_shader_t)); shader->device = device; shader->fs = cso_hash_create(); + shader->cbuf = NULL; return shader; } @@ -318,18 +321,18 @@ static void setup_constant_buffer(gallium_shader_t *shader, float *constants, int size) { struct pipe_context *ctx = shader->device->pipe; - struct pipe_resource *buffer = shader->cbuf; + struct pipe_resource **buffer = &shader->cbuf; - pipe_resource_reference (&buffer, NULL); + pipe_resource_reference (buffer, NULL); memcpy (shader->constants, constants, size); - buffer = pipe_user_buffer_create (ctx->screen, - &shader->constants, + *buffer = pipe_user_buffer_create (ctx->screen, + &shader->constants[0], sizeof(shader->constants), PIPE_BIND_VERTEX_BUFFER); - ctx->set_constant_buffer (ctx, PIPE_SHADER_FRAGMENT, 0, buffer); + ctx->set_constant_buffer (ctx, PIPE_SHADER_FRAGMENT, 0, *buffer); } static void * @@ -443,11 +446,12 @@ unpack_color (const unsigned *src, unsigned char *pRow = p; for (j = 0; j < w; j++, pRow += 4) { const unsigned pixel = *src++; - pRow[0] = (pixel >> 0) & 0xff; - pRow[1] = (pixel >> 8) & 0xff; - pRow[2] = (pixel >> 16) & 0xff; - pRow[3] = (pixel >> 24) & 0xff; + pRow[3] = (pixel >> 0) & 0xff; + pRow[2] = (pixel >> 8) & 0xff; + pRow[1] = (pixel >> 16) & 0xff; + pRow[0] = (pixel >> 24) & 0xff; } + p += dst_stride; } } @@ -505,8 +509,6 @@ gallium_surface_acquire_source_image (void *abstract_surface, surface->drm.height) * util_format_get_blocksize(surface->texture->format)); - rgba_packed = malloc (surface->drm.width*surface->drm.height*4); - stride = util_format_get_stride(surface->texture->format, surface->drm.width); pipe_get_tile_raw (device->pipe, @@ -517,13 +519,15 @@ gallium_surface_acquire_source_image (void *abstract_surface, rgba_packed, stride); + color_unpacked = malloc(surface->drm.width*surface->drm.height*4); + unpack_color (rgba_packed, surface->drm.width, surface->drm.height, color_unpacked, stride); cairo_device_release (&device->drm.base); image = cairo_image_surface_create_for_data (color_unpacked, format, surface->drm.width, surface->drm.height, - surface->drm.stride); + stride); if (unlikely (image->status)) return image->status; @@ -556,6 +560,7 @@ gallium_surface_flush (void *abstract_surface) gallium_device_t *device = gallium_device (surface); cairo_status_t status; + printf("fudeo"); { cso_set_framebuffer (device->cso, &device->framebuffer); @@ -577,6 +582,7 @@ gallium_surface_flush (void *abstract_surface) device->pipe->flush (device->pipe, PIPE_FLUSH_RENDER_CACHE, NULL); + printf("flush\n"); return CAIRO_STATUS_SUCCESS; } @@ -593,10 +599,14 @@ gallium_surface_flush (void *abstract_surface) cairo_device_release (&device->drm.base); } + printf("flushing"); + status = cairo_surface_status (surface->fallback); cairo_surface_destroy (surface->fallback); surface->fallback = NULL; + debug_dump_surface_bmp(device->pipe, "result.bmp", device->framebuffer.cbufs[0]); + return status; } @@ -922,6 +932,8 @@ gallium_surface_paint (void *abstract_surface, status = _cairo_surface_paint (surface->fallback, op, source, clip); } + gallium_surface_flush(abstract_surface); + return status; } @@ -1205,6 +1217,8 @@ gallium_surface_create_internal (gallium_device_t *device, device->pipe->set_constant_buffer(device->pipe, PIPE_SHADER_VERTEX, 0, surface->vbuf); } + device->cso = cso_create_context(device->pipe); + memset(&device->framebuffer, 0, sizeof(device->framebuffer)); device->framebuffer.width = width; device->framebuffer.height = height; |