|
|
|
@ -579,143 +579,6 @@ void debug_dump_texture(struct pipe_context *pipe, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma pack(push,2) |
|
|
|
|
struct bmp_file_header { |
|
|
|
|
uint16_t bfType; |
|
|
|
|
uint32_t bfSize; |
|
|
|
|
uint16_t bfReserved1; |
|
|
|
|
uint16_t bfReserved2; |
|
|
|
|
uint32_t bfOffBits; |
|
|
|
|
}; |
|
|
|
|
#pragma pack(pop) |
|
|
|
|
|
|
|
|
|
struct bmp_info_header { |
|
|
|
|
uint32_t biSize; |
|
|
|
|
int32_t biWidth; |
|
|
|
|
int32_t biHeight; |
|
|
|
|
uint16_t biPlanes; |
|
|
|
|
uint16_t biBitCount; |
|
|
|
|
uint32_t biCompression; |
|
|
|
|
uint32_t biSizeImage; |
|
|
|
|
int32_t biXPelsPerMeter; |
|
|
|
|
int32_t biYPelsPerMeter; |
|
|
|
|
uint32_t biClrUsed; |
|
|
|
|
uint32_t biClrImportant; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct bmp_rgb_quad { |
|
|
|
|
uint8_t rgbBlue; |
|
|
|
|
uint8_t rgbGreen; |
|
|
|
|
uint8_t rgbRed; |
|
|
|
|
uint8_t rgbAlpha; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
debug_dump_surface_bmp(struct pipe_context *pipe, |
|
|
|
|
const char *filename, |
|
|
|
|
struct pipe_surface *surface) |
|
|
|
|
{ |
|
|
|
|
struct pipe_transfer *transfer; |
|
|
|
|
struct pipe_resource *texture = surface->texture; |
|
|
|
|
void *ptr; |
|
|
|
|
|
|
|
|
|
ptr = pipe_transfer_map(pipe, texture, surface->u.tex.level, |
|
|
|
|
surface->u.tex.first_layer, PIPE_TRANSFER_READ, |
|
|
|
|
0, 0, surface->width, surface->height, &transfer); |
|
|
|
|
|
|
|
|
|
debug_dump_transfer_bmp(pipe, filename, transfer, ptr); |
|
|
|
|
|
|
|
|
|
pipe->transfer_unmap(pipe, transfer); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
debug_dump_transfer_bmp(struct pipe_context *pipe, |
|
|
|
|
const char *filename, |
|
|
|
|
struct pipe_transfer *transfer, void *ptr) |
|
|
|
|
{ |
|
|
|
|
float *rgba; |
|
|
|
|
|
|
|
|
|
if (!transfer) |
|
|
|
|
goto error1; |
|
|
|
|
|
|
|
|
|
rgba = MALLOC(transfer->box.width * |
|
|
|
|
transfer->box.height * |
|
|
|
|
transfer->box.depth * |
|
|
|
|
4*sizeof(float)); |
|
|
|
|
if(!rgba) |
|
|
|
|
goto error1; |
|
|
|
|
|
|
|
|
|
pipe_get_tile_rgba(transfer, ptr, 0, 0, |
|
|
|
|
transfer->box.width, transfer->box.height, |
|
|
|
|
rgba); |
|
|
|
|
|
|
|
|
|
debug_dump_float_rgba_bmp(filename, |
|
|
|
|
transfer->box.width, transfer->box.height, |
|
|
|
|
rgba, transfer->box.width); |
|
|
|
|
|
|
|
|
|
FREE(rgba); |
|
|
|
|
error1: |
|
|
|
|
; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
debug_dump_float_rgba_bmp(const char *filename, |
|
|
|
|
unsigned width, unsigned height, |
|
|
|
|
float *rgba, unsigned stride) |
|
|
|
|
{ |
|
|
|
|
FILE *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 + height*width*4; |
|
|
|
|
bmfh.bfReserved1 = 0; |
|
|
|
|
bmfh.bfReserved2 = 0; |
|
|
|
|
bmfh.bfOffBits = 14 + 40; |
|
|
|
|
|
|
|
|
|
bmih.biSize = 40; |
|
|
|
|
bmih.biWidth = width; |
|
|
|
|
bmih.biHeight = height; |
|
|
|
|
bmih.biPlanes = 1; |
|
|
|
|
bmih.biBitCount = 32; |
|
|
|
|
bmih.biCompression = 0; |
|
|
|
|
bmih.biSizeImage = height*width*4; |
|
|
|
|
bmih.biXPelsPerMeter = 0; |
|
|
|
|
bmih.biYPelsPerMeter = 0; |
|
|
|
|
bmih.biClrUsed = 0; |
|
|
|
|
bmih.biClrImportant = 0; |
|
|
|
|
|
|
|
|
|
stream = fopen(filename, "wb"); |
|
|
|
|
if(!stream) |
|
|
|
|
goto error1; |
|
|
|
|
|
|
|
|
|
fwrite(&bmfh, 14, 1, stream); |
|
|
|
|
fwrite(&bmih, 40, 1, stream); |
|
|
|
|
|
|
|
|
|
y = height; |
|
|
|
|
while(y--) { |
|
|
|
|
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]); |
|
|
|
|
pixel.rgbGreen = float_to_ubyte(ptr[x*4 + 1]); |
|
|
|
|
pixel.rgbBlue = float_to_ubyte(ptr[x*4 + 2]); |
|
|
|
|
pixel.rgbAlpha = float_to_ubyte(ptr[x*4 + 3]); |
|
|
|
|
fwrite(&pixel, 1, 4, stream); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fclose(stream); |
|
|
|
|
error1: |
|
|
|
|
; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Print PIPE_TRANSFER_x flags with a message. |
|
|
|
|
*/ |
|
|
|
|