gallium: New function to dump surfaces.
This commit is contained in:
@@ -50,12 +50,12 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "pipe/p_compiler.h"
|
#include "pipe/p_compiler.h"
|
||||||
#include "pipe/p_util.h"
|
#include "pipe/p_util.h"
|
||||||
#include "pipe/p_debug.h"
|
#include "pipe/p_debug.h"
|
||||||
#include "pipe/p_format.h"
|
#include "pipe/p_format.h"
|
||||||
|
#include "pipe/p_state.h"
|
||||||
|
#include "pipe/p_inlines.h"
|
||||||
#include "util/u_string.h"
|
#include "util/u_string.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -509,7 +509,7 @@ char *pf_sprint_name( char *str, enum pipe_format format )
|
|||||||
void debug_dump_image(const char *prefix,
|
void debug_dump_image(const char *prefix,
|
||||||
unsigned format, unsigned cpp,
|
unsigned format, unsigned cpp,
|
||||||
unsigned width, unsigned height,
|
unsigned width, unsigned height,
|
||||||
unsigned pitch,
|
unsigned stride,
|
||||||
const void *data)
|
const void *data)
|
||||||
{
|
{
|
||||||
#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
|
#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
|
||||||
@@ -530,7 +530,7 @@ void debug_dump_image(const char *prefix,
|
|||||||
for(i = 0; i < sizeof(filename); ++i)
|
for(i = 0; i < sizeof(filename); ++i)
|
||||||
wfilename[i] = (WCHAR)filename[i];
|
wfilename[i] = (WCHAR)filename[i];
|
||||||
|
|
||||||
pMap = (unsigned char *)EngMapFile(wfilename, sizeof(header) + cpp*width*height, &iFile);
|
pMap = (unsigned char *)EngMapFile(wfilename, sizeof(header) + height*width*cpp, &iFile);
|
||||||
if(!pMap)
|
if(!pMap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -542,11 +542,44 @@ void debug_dump_image(const char *prefix,
|
|||||||
pMap += sizeof(header);
|
pMap += sizeof(header);
|
||||||
|
|
||||||
for(i = 0; i < height; ++i) {
|
for(i = 0; i < height; ++i) {
|
||||||
memcpy(pMap, (unsigned char *)data + cpp*pitch*i, cpp*width);
|
memcpy(pMap, (unsigned char *)data + stride*i, cpp*width);
|
||||||
pMap += cpp*width;
|
pMap += cpp*width;
|
||||||
}
|
}
|
||||||
|
|
||||||
EngUnmapFile(iFile);
|
EngUnmapFile(iFile);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debug_dump_surface(const char *prefix,
|
||||||
|
struct pipe_surface *surface)
|
||||||
|
{
|
||||||
|
unsigned surface_usage;
|
||||||
|
void *data;
|
||||||
|
|
||||||
|
if (!surface)
|
||||||
|
goto error1;
|
||||||
|
|
||||||
|
/* XXX: force mappable surface */
|
||||||
|
surface_usage = surface->usage;
|
||||||
|
surface->usage |= PIPE_BUFFER_USAGE_CPU_READ;
|
||||||
|
|
||||||
|
data = pipe_surface_map(surface,
|
||||||
|
PIPE_BUFFER_USAGE_CPU_READ);
|
||||||
|
if(!data)
|
||||||
|
goto error2;
|
||||||
|
|
||||||
|
debug_dump_image(prefix,
|
||||||
|
surface->format,
|
||||||
|
surface->block.size,
|
||||||
|
surface->nblocksx,
|
||||||
|
surface->nblocksy,
|
||||||
|
surface->stride,
|
||||||
|
data);
|
||||||
|
|
||||||
|
pipe_surface_unmap(surface);
|
||||||
|
error2:
|
||||||
|
surface->usage = surface_usage;
|
||||||
|
error1:
|
||||||
|
;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -332,13 +332,17 @@ debug_profile_stop(void);
|
|||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
struct pipe_surface;
|
||||||
void debug_dump_image(const char *prefix,
|
void debug_dump_image(const char *prefix,
|
||||||
unsigned format, unsigned cpp,
|
unsigned format, unsigned cpp,
|
||||||
unsigned width, unsigned height,
|
unsigned width, unsigned height,
|
||||||
unsigned pitch,
|
unsigned stride,
|
||||||
const void *data);
|
const void *data);
|
||||||
|
void debug_dump_surface(const char *prefix,
|
||||||
|
struct pipe_surface *surface);
|
||||||
#else
|
#else
|
||||||
#define debug_dump_image(prefix, format, cpp, width, height, pitch, data) ((void)0)
|
#define debug_dump_image(prefix, format, cpp, width, height, stride, data) ((void)0)
|
||||||
|
#define debug_dump_surface(prefix, surface) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user