summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorJakob Bornecrantz <jakob@vmware.com>2009-04-23 05:42:26 +0200
committerJakob Bornecrantz <jakob@vmware.com>2009-04-24 13:02:26 +0200
commitf4a286e5f5ac11b2e5266ef39db5d1d1cb5f77ce (patch)
treefdb917a1c4eb7cb9b1dc9b6f5a12ab9f494a3198 /src/gallium/auxiliary
parenteb5d96968fd37b4598a7b50df1a8f4f7805d897d (diff)
util: Add more entry points for dumping to bmp
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/util/u_debug.c56
-rw-r--r--src/gallium/auxiliary/util/u_debug.h5
2 files changed, 43 insertions, 18 deletions
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index ae47a274a6..18597ef839 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -721,6 +721,7 @@ void
debug_dump_surface_bmp(const char *filename,
struct pipe_surface *surface)
{
+#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
struct pipe_transfer *transfer;
struct pipe_texture *texture = surface->texture;
struct pipe_screen *screen = texture->screen;
@@ -733,6 +734,7 @@ debug_dump_surface_bmp(const char *filename,
debug_dump_transfer_bmp(filename, transfer);
screen->tex_transfer_destroy(transfer);
+#endif
}
void
@@ -740,11 +742,7 @@ debug_dump_transfer_bmp(const char *filename,
struct pipe_transfer *transfer)
{
#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
- struct util_stream *stream;
- struct bmp_file_header bmfh;
- struct bmp_info_header bmih;
float *rgba;
- unsigned x, y;
if (!transfer)
goto error1;
@@ -753,19 +751,47 @@ debug_dump_transfer_bmp(const char *filename,
if(!rgba)
goto error1;
+ pipe_get_tile_rgba(transfer, 0, 0,
+ transfer->width, transfer->height,
+ rgba);
+
+ debug_dump_float_rgba_bmp(filename,
+ transfer->width, transfer->height,
+ rgba, transfer->width);
+
+ FREE(rgba);
+error1:
+ ;
+#endif
+}
+
+void
+debug_dump_float_rgba_bmp(const char *filename,
+ unsigned width, unsigned height,
+ float *rgba, unsigned stride)
+{
+#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
+ struct util_stream *stream;
+ struct bmp_file_header bmfh;
+ struct bmp_info_header bmih;
+ unsigned x, y;
+
+ if(!rgba)
+ goto error1;
+
bmfh.bfType = 0x4d42;
- bmfh.bfSize = 14 + 40 + transfer->height*transfer->width*4;
+ bmfh.bfSize = 14 + 40 + height*width*4;
bmfh.bfReserved1 = 0;
bmfh.bfReserved2 = 0;
bmfh.bfOffBits = 14 + 40;
bmih.biSize = 40;
- bmih.biWidth = transfer->width;
- bmih.biHeight = transfer->height;
+ bmih.biWidth = width;
+ bmih.biHeight = height;
bmih.biPlanes = 1;
bmih.biBitCount = 32;
bmih.biCompression = 0;
- bmih.biSizeImage = transfer->height*transfer->width*4;
+ bmih.biSizeImage = height*width*4;
bmih.biXPelsPerMeter = 0;
bmih.biYPelsPerMeter = 0;
bmih.biClrUsed = 0;
@@ -773,19 +799,15 @@ debug_dump_transfer_bmp(const char *filename,
stream = util_stream_create(filename, bmfh.bfSize);
if(!stream)
- goto error2;
+ goto error1;
util_stream_write(stream, &bmfh, 14);
util_stream_write(stream, &bmih, 40);
- pipe_get_tile_rgba(transfer, 0, 0,
- transfer->width, transfer->height,
- rgba);
-
- y = transfer->height;
+ y = height;
while(y--) {
- float *ptr = rgba + (transfer->width * y * 4);
- for(x = 0; x < transfer->width; ++x)
+ float *ptr = rgba + (stride * y * 4);
+ for(x = 0; x < width; ++x)
{
struct bmp_rgb_quad pixel;
pixel.rgbRed = float_to_ubyte(ptr[x*4 + 0]);
@@ -797,8 +819,6 @@ debug_dump_transfer_bmp(const char *filename,
}
util_stream_close(stream);
-error2:
- FREE(rgba);
error1:
;
#endif
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index 8d703e47fc..bcd8f0f3cf 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -347,10 +347,15 @@ void debug_dump_surface_bmp(const char *filename,
struct pipe_surface *surface);
void debug_dump_transfer_bmp(const char *filename,
struct pipe_transfer *transfer);
+void debug_dump_float_rgba_bmp(const char *filename,
+ unsigned width, unsigned height,
+ float *rgba, unsigned stride);
#else
#define debug_dump_image(prefix, format, cpp, width, height, stride, data) ((void)0)
#define debug_dump_surface(prefix, surface) ((void)0)
#define debug_dump_surface_bmp(filename, surface) ((void)0)
+#define debug_dump_transfer_bmp(filename, transfer) ((void)0)
+#define debug_dump_rgba_float_bmp(filename, width, height, rgba, stride) ((void)0)
#endif