Commit 819eaf0e authored by Kenneth Moreland's avatar Kenneth Moreland

Merge branch 'better-diagnostic-macros' into 'master'

Update the diagnostics macros

See merge request !6
parents 32515220 ef7bdd67
...@@ -111,8 +111,8 @@ static MPI_Request getMPIRequest(IceTCommRequest icet_request) ...@@ -111,8 +111,8 @@ static MPI_Request getMPIRequest(IceTCommRequest icet_request)
} }
if (icet_request->magic_number != ICET_MPI_REQUEST_MAGIC_NUMBER) { if (icet_request->magic_number != ICET_MPI_REQUEST_MAGIC_NUMBER) {
icetRaiseError("Request object is not from the MPI communicator.", icetRaiseError(ICET_INVALID_VALUE,
ICET_INVALID_VALUE); "Request object is not from the MPI communicator.");
return MPI_REQUEST_NULL; return MPI_REQUEST_NULL;
} }
...@@ -122,14 +122,14 @@ static MPI_Request getMPIRequest(IceTCommRequest icet_request) ...@@ -122,14 +122,14 @@ static MPI_Request getMPIRequest(IceTCommRequest icet_request)
static void setMPIRequest(IceTCommRequest icet_request, MPI_Request mpi_request) static void setMPIRequest(IceTCommRequest icet_request, MPI_Request mpi_request)
{ {
if (icet_request == ICET_COMM_REQUEST_NULL) { if (icet_request == ICET_COMM_REQUEST_NULL) {
icetRaiseError("Cannot set MPI request in null request.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Cannot set MPI request in null request.");
return; return;
} }
if (icet_request->magic_number != ICET_MPI_REQUEST_MAGIC_NUMBER) { if (icet_request->magic_number != ICET_MPI_REQUEST_MAGIC_NUMBER) {
icetRaiseError("Request object is not from the MPI communicator.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Request object is not from the MPI communicator.");
return; return;
} }
...@@ -143,8 +143,8 @@ static IceTCommRequest create_request(void) ...@@ -143,8 +143,8 @@ static IceTCommRequest create_request(void)
request = (IceTCommRequest)malloc(sizeof(struct IceTCommRequestStruct)); request = (IceTCommRequest)malloc(sizeof(struct IceTCommRequestStruct));
if (request == NULL) { if (request == NULL) {
icetRaiseError("Could not allocate memory for IceTCommRequest", icetRaiseError(ICET_OUT_OF_MEMORY,
ICET_OUT_OF_MEMORY); "Could not allocate memory for IceTCommRequest");
return NULL; return NULL;
} }
...@@ -152,8 +152,8 @@ static IceTCommRequest create_request(void) ...@@ -152,8 +152,8 @@ static IceTCommRequest create_request(void)
request->internals=malloc(sizeof(struct IceTMPICommRequestInternalsStruct)); request->internals=malloc(sizeof(struct IceTMPICommRequestInternalsStruct));
if (request->internals == NULL) { if (request->internals == NULL) {
free(request); free(request);
icetRaiseError("Could not allocate memory for IceTCommRequest", icetRaiseError(ICET_OUT_OF_MEMORY,
ICET_OUT_OF_MEMORY); "Could not allocate memory for IceTCommRequest");
return NULL; return NULL;
} }
...@@ -166,9 +166,9 @@ static void destroy_request(IceTCommRequest request) ...@@ -166,9 +166,9 @@ static void destroy_request(IceTCommRequest request)
{ {
MPI_Request mpi_request = getMPIRequest(request); MPI_Request mpi_request = getMPIRequest(request);
if (mpi_request != MPI_REQUEST_NULL) { if (mpi_request != MPI_REQUEST_NULL) {
icetRaiseError("Destroying MPI request that is not NULL." icetRaiseError(ICET_SANITY_CHECK_FAIL,
" Probably leaking MPI requests.", "Destroying MPI request that is not NULL."
ICET_SANITY_CHECK_FAIL); " Probably leaking MPI requests.");
} }
free(request->internals); free(request->internals);
...@@ -178,14 +178,13 @@ static void destroy_request(IceTCommRequest request) ...@@ -178,14 +178,13 @@ static void destroy_request(IceTCommRequest request)
#ifdef BREAK_ON_MPI_ERROR #ifdef BREAK_ON_MPI_ERROR
static void ErrorHandler(MPI_Comm *comm, int *errorno, ...) static void ErrorHandler(MPI_Comm *comm, int *errorno, ...)
{ {
char error_msg[MPI_MAX_ERROR_STRING+16]; char error_msg[MPI_MAX_ERROR_STRING];
int mpi_error_len; int mpi_error_len;
(void)comm; (void)comm;
strcpy(error_msg, "MPI ERROR:\n"); MPI_Error_string(*errorno, error_msg, &mpi_error_len);
MPI_Error_string(*errorno, error_msg + strlen(error_msg), &mpi_error_len);
icetRaiseError(error_msg, ICET_INVALID_OPERATION); icetRaiseError(ICET_INVALID_OPERATION, "MPI ERROR:\n%s", error_msg);
icetDebugBreak(); icetDebugBreak();
} }
#endif #endif
...@@ -203,8 +202,8 @@ IceTCommunicator icetCreateMPICommunicator(MPI_Comm mpi_comm) ...@@ -203,8 +202,8 @@ IceTCommunicator icetCreateMPICommunicator(MPI_Comm mpi_comm)
comm = malloc(sizeof(struct IceTCommunicatorStruct)); comm = malloc(sizeof(struct IceTCommunicatorStruct));
if (comm == NULL) { if (comm == NULL) {
icetRaiseError("Could not allocate memory for IceTCommunicator.", icetRaiseError(ICET_OUT_OF_MEMORY,
ICET_OUT_OF_MEMORY); "Could not allocate memory for IceTCommunicator.");
return NULL; return NULL;
} }
...@@ -229,8 +228,8 @@ IceTCommunicator icetCreateMPICommunicator(MPI_Comm mpi_comm) ...@@ -229,8 +228,8 @@ IceTCommunicator icetCreateMPICommunicator(MPI_Comm mpi_comm)
comm->data = malloc(sizeof(MPI_Comm)); comm->data = malloc(sizeof(MPI_Comm));
if (comm->data == NULL) { if (comm->data == NULL) {
free(comm); free(comm);
icetRaiseError("Could not allocate memory for IceTCommunicator.", icetRaiseError(ICET_OUT_OF_MEMORY,
ICET_OUT_OF_MEMORY); "Could not allocate memory for IceTCommunicator.");
return NULL; return NULL;
} }
MPI_Comm_dup(mpi_comm, (MPI_Comm *)comm->data); MPI_Comm_dup(mpi_comm, (MPI_Comm *)comm->data);
...@@ -315,8 +314,9 @@ static void MPIBarrier(IceTCommunicator self) ...@@ -315,8 +314,9 @@ static void MPIBarrier(IceTCommunicator self)
case ICET_FLOAT: mpi_type = MPI_FLOAT; break; \ case ICET_FLOAT: mpi_type = MPI_FLOAT; break; \
case ICET_DOUBLE: mpi_type = MPI_DOUBLE; break; \ case ICET_DOUBLE: mpi_type = MPI_DOUBLE; break; \
default: \ default: \
icetRaiseError("MPI Communicator received bad data type.", \ icetRaiseError(ICET_INVALID_ENUM, \
ICET_INVALID_ENUM); \ "MPI Communicator received bad data type 0x%X.", \
icet_type); \
mpi_type = MPI_BYTE; \ mpi_type = MPI_BYTE; \
break; \ break; \
} }
...@@ -540,8 +540,8 @@ static int MPIWaitany(IceTCommunicator self, ...@@ -540,8 +540,8 @@ static int MPIWaitany(IceTCommunicator self,
mpi_requests = malloc(sizeof(MPI_Request)*count); mpi_requests = malloc(sizeof(MPI_Request)*count);
if (mpi_requests == NULL) { if (mpi_requests == NULL) {
icetRaiseError("Could not allocate array for MPI requests.", icetRaiseError(ICET_OUT_OF_MEMORY,
ICET_OUT_OF_MEMORY); "Could not allocate array for MPI requests.");
return -1; return -1;
} }
......
...@@ -38,9 +38,9 @@ static void inflateBuffer(IceTUByte *buffer, ...@@ -38,9 +38,9 @@ static void inflateBuffer(IceTUByte *buffer,
void icetGLDrawCallback(IceTGLDrawCallbackType func) void icetGLDrawCallback(IceTGLDrawCallbackType func)
{ {
if (!icetGLIsInitialized()) { if (!icetGLIsInitialized()) {
icetRaiseError("IceT OpenGL layer not initialized." icetRaiseError(ICET_INVALID_OPERATION,
" Call icetGLInitialize.", "IceT OpenGL layer not initialized."
ICET_INVALID_OPERATION); " Call icetGLInitialize.");
return; return;
} }
...@@ -97,9 +97,9 @@ static void setupOpenGLRender(IceTDouble *projection_matrix, ...@@ -97,9 +97,9 @@ static void setupOpenGLRender(IceTDouble *projection_matrix,
*ok_to_proceed = ICET_FALSE; *ok_to_proceed = ICET_FALSE;
if (!icetGLIsInitialized()) { if (!icetGLIsInitialized()) {
icetRaiseError("IceT OpenGL layer not initialized." icetRaiseError(ICET_INVALID_OPERATION,
" Call icetGLInitialize.", "IceT OpenGL layer not initialized."
ICET_INVALID_OPERATION); " Call icetGLInitialize.");
return; return;
} }
...@@ -117,8 +117,8 @@ static void setupOpenGLRender(IceTDouble *projection_matrix, ...@@ -117,8 +117,8 @@ static void setupOpenGLRender(IceTDouble *projection_matrix,
/* Check the GL callback. */ /* Check the GL callback. */
icetGetPointerv(ICET_GL_DRAW_FUNCTION, &value); icetGetPointerv(ICET_GL_DRAW_FUNCTION, &value);
if (value == NULL) { if (value == NULL) {
icetRaiseError("GL Drawing function not set. Call icetGLDrawCallback.", icetRaiseError(ICET_INVALID_OPERATION,
ICET_INVALID_OPERATION); "GL Drawing function not set. Call icetGLDrawCallback.");
return; return;
} }
......
...@@ -29,8 +29,9 @@ void icetGLDrawCallbackFunction(const IceTDouble *projection_matrix, ...@@ -29,8 +29,9 @@ void icetGLDrawCallbackFunction(const IceTDouble *projection_matrix,
/* Check OpenGL state. */ /* Check OpenGL state. */
{ {
if ((gl_viewport[2] != width) || (gl_viewport[3] != height)) { if ((gl_viewport[2] != width) || (gl_viewport[3] != height)) {
icetRaiseError("OpenGL viewport different than expected." icetRaiseError(ICET_SANITY_CHECK_FAIL,
" Was it changed?", ICET_SANITY_CHECK_FAIL); "OpenGL viewport different than expected."
" Was it changed?");
} }
} }
...@@ -102,7 +103,8 @@ void icetGLDrawCallbackFunction(const IceTDouble *projection_matrix, ...@@ -102,7 +103,8 @@ void icetGLDrawCallbackFunction(const IceTDouble *projection_matrix,
colorBuffer + 4*( readback_viewport[0] colorBuffer + 4*( readback_viewport[0]
+ width*readback_viewport[1])); + width*readback_viewport[1]));
} else if (color_format != ICET_IMAGE_COLOR_NONE) { } else if (color_format != ICET_IMAGE_COLOR_NONE) {
icetRaiseError("Invalid color format.", ICET_SANITY_CHECK_FAIL); icetRaiseError(ICET_SANITY_CHECK_FAIL,
"Invalid color format 0x%X.", color_format);
} }
if (depth_format == ICET_IMAGE_DEPTH_FLOAT) { if (depth_format == ICET_IMAGE_DEPTH_FLOAT) {
...@@ -116,7 +118,8 @@ void icetGLDrawCallbackFunction(const IceTDouble *projection_matrix, ...@@ -116,7 +118,8 @@ void icetGLDrawCallbackFunction(const IceTDouble *projection_matrix,
depthBuffer + ( readback_viewport[0] depthBuffer + ( readback_viewport[0]
+ width*readback_viewport[1])); + width*readback_viewport[1]));
} else if (depth_format != ICET_IMAGE_DEPTH_NONE) { } else if (depth_format != ICET_IMAGE_DEPTH_NONE) {
icetRaiseError("Invalid depth format.", ICET_SANITY_CHECK_FAIL); icetRaiseError(ICET_SANITY_CHECK_FAIL,
"Invalid depth format 0x%X.", depth_format);
} }
glPixelStorei(GL_PACK_ROW_LENGTH, 0); glPixelStorei(GL_PACK_ROW_LENGTH, 0);
......
...@@ -17,8 +17,8 @@ static void gl_destroy(void); ...@@ -17,8 +17,8 @@ static void gl_destroy(void);
void icetGLInitialize(void) void icetGLInitialize(void)
{ {
if (icetGLIsInitialized()) { if (icetGLIsInitialized()) {
icetRaiseWarning("icetGLInitialize called multiple times.", icetRaiseWarning(ICET_INVALID_OPERATION,
ICET_INVALID_OPERATION); "icetGLInitialize called multiple times.");
} }
icetStateSetBoolean(ICET_GL_INITIALIZED, ICET_TRUE); icetStateSetBoolean(ICET_GL_INITIALIZED, ICET_TRUE);
...@@ -51,9 +51,9 @@ IceTBoolean icetGLIsInitialized(void) ...@@ -51,9 +51,9 @@ IceTBoolean icetGLIsInitialized(void)
void icetGLSetReadBuffer(GLenum mode) void icetGLSetReadBuffer(GLenum mode)
{ {
if (!icetGLIsInitialized()) { if (!icetGLIsInitialized()) {
icetRaiseError("IceT OpenGL layer not initialized." icetRaiseError(ICET_INVALID_OPERATION,
" Call icetGLInitialize.", "IceT OpenGL layer not initialized."
ICET_INVALID_OPERATION); " Call icetGLInitialize.");
return; return;
} }
...@@ -65,7 +65,7 @@ void icetGLSetReadBuffer(GLenum mode) ...@@ -65,7 +65,7 @@ void icetGLSetReadBuffer(GLenum mode)
{ {
icetStateSetInteger(ICET_GL_READ_BUFFER, GL_BACK); icetStateSetInteger(ICET_GL_READ_BUFFER, GL_BACK);
} else { } else {
icetRaiseError("Invalid OpenGL read buffer.", ICET_INVALID_ENUM); icetRaiseError(ICET_INVALID_ENUM, "Invalid OpenGL read buffer.");
} }
} }
......
...@@ -57,9 +57,9 @@ ...@@ -57,9 +57,9 @@
|| (_depth_format != icetSparseImageGetDepthFormat(BACK_SPARSE_IMAGE)) || (_depth_format != icetSparseImageGetDepthFormat(BACK_SPARSE_IMAGE))
|| (_depth_format != icetSparseImageGetDepthFormat(DEST_SPARSE_IMAGE)) || (_depth_format != icetSparseImageGetDepthFormat(DEST_SPARSE_IMAGE))
) { ) {
icetRaiseError("Input buffers do not agree for compressed-compressed" icetRaiseError(ICET_SANITY_CHECK_FAIL,
" composite.", "Input buffers do not agree for compressed-compressed"
ICET_SANITY_CHECK_FAIL); " composite.");
} }
if (_composite_mode == ICET_COMPOSITE_MODE_Z_BUFFER) { if (_composite_mode == ICET_COMPOSITE_MODE_Z_BUFFER) {
...@@ -158,15 +158,18 @@ ...@@ -158,15 +158,18 @@
#include "cc_composite_template_body.h" #include "cc_composite_template_body.h"
#undef UNPACK_PIXEL #undef UNPACK_PIXEL
} else { } else {
icetRaiseError("Encountered invalid color format.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Encountered invalid color format 0x%X.",
_color_format);
} }
} else if (_depth_format == ICET_IMAGE_DEPTH_NONE) { } else if (_depth_format == ICET_IMAGE_DEPTH_NONE) {
icetRaiseError("Cannot use Z buffer compositing operation with no" icetRaiseError(ICET_INVALID_OPERATION,
" Z buffer.", ICET_INVALID_OPERATION); "Cannot use Z buffer compositing operation with no"
" Z buffer.");
} else { } else {
icetRaiseError("Encountered invalid depth format.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Encountered invalid depth format 0x%X.",
_depth_format);
} }
} else if (_composite_mode == ICET_COMPOSITE_MODE_BLEND) { } else if (_composite_mode == ICET_COMPOSITE_MODE_BLEND) {
/* Use alpha for active pixel and compositing. */ /* Use alpha for active pixel and compositing. */
...@@ -214,20 +217,22 @@ ...@@ -214,20 +217,22 @@
#include "cc_composite_template_body.h" #include "cc_composite_template_body.h"
#undef UNPACK_PIXEL #undef UNPACK_PIXEL
} else if (_color_format == ICET_IMAGE_COLOR_NONE) { } else if (_color_format == ICET_IMAGE_COLOR_NONE) {
icetRaiseWarning("Compositing image with no data.", icetRaiseWarning(ICET_INVALID_OPERATION,
ICET_INVALID_OPERATION); "Compositing image with no data.");
icetClearSparseImage(DEST_SPARSE_IMAGE); icetClearSparseImage(DEST_SPARSE_IMAGE);
} else { } else {
icetRaiseError("Encountered invalid color format.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Encountered invalid color format 0x%X.",
_color_format);
} }
} else { } else {
icetRaiseError("Cannot use blend composite with a depth buffer.", icetRaiseError(ICET_INVALID_VALUE,
ICET_INVALID_VALUE); "Cannot use blend composite with a depth buffer.");
} }
} else { } else {
icetRaiseError("Encountered invalid composite mode.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Encountered invalid composite mode 0x%X.",
_composite_mode);
} }
} }
......
...@@ -55,9 +55,9 @@ ...@@ -55,9 +55,9 @@
_num_pixels = icetSparseImageGetNumPixels(CCC_FRONT_COMPRESSED_IMAGE); _num_pixels = icetSparseImageGetNumPixels(CCC_FRONT_COMPRESSED_IMAGE);
if (_num_pixels != icetSparseImageGetNumPixels(CCC_BACK_COMPRESSED_IMAGE)) { if (_num_pixels != icetSparseImageGetNumPixels(CCC_BACK_COMPRESSED_IMAGE)) {
icetRaiseError("Input buffers do not agree for compressed-compressed" icetRaiseError(ICET_SANITY_CHECK_FAIL,
" composite.", "Input buffers do not agree for compressed-compressed"
ICET_SANITY_CHECK_FAIL); " composite.");
} }
icetSparseImageSetDimensions( icetSparseImageSetDimensions(
CCC_DEST_COMPRESSED_IMAGE, CCC_DEST_COMPRESSED_IMAGE,
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
} }
if (_pixel != _num_pixels) { if (_pixel != _num_pixels) {
icetRaiseError("Corrupt compressed image.", ICET_INVALID_VALUE); icetRaiseError(ICET_INVALID_VALUE, "Corrupt compressed image.");
} }
{ {
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#define icetCommCheckCount(count) \ #define icetCommCheckCount(count) \
if (count > 1073741824) { \ if (count > 1073741824) { \
icetRaiseWarning("Encountered a ridiculously large message.", \ icetRaiseWarning(ICET_INVALID_VALUE, \
ICET_INVALID_VALUE); \ "Encountered a ridiculously large message."); \
} }
IceTCommunicator icetCommDuplicate() IceTCommunicator icetCommDuplicate()
......
...@@ -88,29 +88,29 @@ ...@@ -88,29 +88,29 @@
if ( (icetSparseImageGetColorFormat(OUTPUT_SPARSE_IMAGE) != _color_format) if ( (icetSparseImageGetColorFormat(OUTPUT_SPARSE_IMAGE) != _color_format)
|| (icetSparseImageGetDepthFormat(OUTPUT_SPARSE_IMAGE) != _depth_format) || (icetSparseImageGetDepthFormat(OUTPUT_SPARSE_IMAGE) != _depth_format)
) { ) {
icetRaiseError("Format of input and output to compress do not match.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Format of input and output to compress do not match.");
} }
#ifdef PADDING #ifdef PADDING
if ( icetSparseImageGetNumPixels(OUTPUT_SPARSE_IMAGE) if ( icetSparseImageGetNumPixels(OUTPUT_SPARSE_IMAGE)
!= ( _pixel_count + (FULL_WIDTH)*(SPACE_TOP+SPACE_BOTTOM) != ( _pixel_count + (FULL_WIDTH)*(SPACE_TOP+SPACE_BOTTOM)
+ ((FULL_HEIGHT)-(SPACE_TOP+SPACE_BOTTOM))*(SPACE_LEFT+SPACE_RIGHT)) + ((FULL_HEIGHT)-(SPACE_TOP+SPACE_BOTTOM))*(SPACE_LEFT+SPACE_RIGHT))
) { ) {
icetRaiseError("Size of input and output to compress do not match.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Size of input and output to compress do not match.");
} }
#else /*PADDING*/ #else /*PADDING*/
if (icetSparseImageGetNumPixels(OUTPUT_SPARSE_IMAGE) != _pixel_count) { if (icetSparseImageGetNumPixels(OUTPUT_SPARSE_IMAGE) != _pixel_count) {
icetRaiseError("Size of input and output to compress do not match.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Size of input and output to compress do not match.");
} }
#endif /*PADDING*/ #endif /*PADDING*/
#ifdef REGION #ifdef REGION
if ( (REGION_OFFSET_X < 0) || (REGION_OFFSET_Y < 0) if ( (REGION_OFFSET_X < 0) || (REGION_OFFSET_Y < 0)
|| (REGION_OFFSET_X+REGION_WIDTH > icetImageGetWidth(INPUT_IMAGE)) || (REGION_OFFSET_X+REGION_WIDTH > icetImageGetWidth(INPUT_IMAGE))
|| (REGION_OFFSET_Y+REGION_HEIGHT > icetImageGetHeight(INPUT_IMAGE)) ){ || (REGION_OFFSET_Y+REGION_HEIGHT > icetImageGetHeight(INPUT_IMAGE)) ){
icetRaiseError("Size of input incompatible with region.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Size of input incompatible with region.");
} }
#endif /*REGION*/ #endif /*REGION*/
#endif /*DEBUG*/ #endif /*DEBUG*/
...@@ -242,22 +242,25 @@ ...@@ -242,22 +242,25 @@
#endif #endif
#include "compress_template_body.h" #include "compress_template_body.h"
} else { } else {
icetRaiseError("Encountered invalid color format.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Encountered invalid color format 0x%X.",
_color_format);
} }
} else if (_depth_format == ICET_IMAGE_DEPTH_NONE) { } else if (_depth_format == ICET_IMAGE_DEPTH_NONE) {
icetRaiseError("Cannot use Z buffer compression with no" icetRaiseError(ICET_INVALID_OPERATION,
" Z buffer.", ICET_INVALID_OPERATION); "Cannot use Z buffer compression with no"
" Z buffer.");
} else { } else {
icetRaiseError("Encountered invalid depth format.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Encountered invalid depth format 0x%X.",
_depth_format);
} }
} else if (_composite_mode == ICET_COMPOSITE_MODE_BLEND) { } else if (_composite_mode == ICET_COMPOSITE_MODE_BLEND) {
/* Use alpha for active pixel testing. */ /* Use alpha for active pixel testing. */
if (_depth_format != ICET_IMAGE_DEPTH_NONE) { if (_depth_format != ICET_IMAGE_DEPTH_NONE) {
icetRaiseWarning("Z buffer ignored during blend compress" icetRaiseWarning(ICET_INVALID_VALUE,
" operation. Output z buffer meaningless.", "Z buffer ignored during blend compress"
ICET_INVALID_VALUE); " operation. Output z buffer meaningless.");
} }
if (_color_format == ICET_IMAGE_COLOR_RGBA_UBYTE) { if (_color_format == ICET_IMAGE_COLOR_RGBA_UBYTE) {
const IceTUInt *_color; const IceTUInt *_color;
...@@ -340,23 +343,25 @@ ...@@ -340,23 +343,25 @@
#include "compress_template_body.h" #include "compress_template_body.h"
} else if (_color_format == ICET_IMAGE_COLOR_NONE) { } else if (_color_format == ICET_IMAGE_COLOR_NONE) {
IceTUInt *_out; IceTUInt *_out;
icetRaiseWarning("Compressing image with no data.", icetRaiseWarning(ICET_INVALID_OPERATION,
ICET_INVALID_OPERATION); "Compressing image with no data.");
_out = ICET_IMAGE_DATA(OUTPUT_SPARSE_IMAGE); _out = ICET_IMAGE_DATA(OUTPUT_SPARSE_IMAGE);
INACTIVE_RUN_LENGTH(_out) = _pixel_count; INACTIVE_RUN_LENGTH(_out) = _pixel_count;
ACTIVE_RUN_LENGTH(_out) = 0; ACTIVE_RUN_LENGTH(_out) = 0;
_out++; _out++;
icetSparseImageSetActualSize(OUTPUT_SPARSE_IMAGE, _out); icetSparseImageSetActualSize(OUTPUT_SPARSE_IMAGE, _out);
} else { } else {
icetRaiseError("Encountered invalid color format.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Encountered invalid color format 0x%X.",
_color_format);
} }
} else { } else {
icetRaiseError("Encountered invalid composite mode.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Encountered invalid composite mode 0x%X.",
_composite_mode);
} }
icetRaiseDebug1("Compression: %f%%\n", icetRaiseDebug("Compression: %f%%\n",
100.0f - ( 100.0f*icetSparseImageGetCompressedBufferSize(OUTPUT_SPARSE_IMAGE) 100.0f - ( 100.0f*icetSparseImageGetCompressedBufferSize(OUTPUT_SPARSE_IMAGE)
/ icetImageBufferSizeType(_color_format, _depth_format, / icetImageBufferSizeType(_color_format, _depth_format,
icetSparseImageGetWidth(OUTPUT_SPARSE_IMAGE), icetSparseImageGetWidth(OUTPUT_SPARSE_IMAGE),
......
...@@ -177,10 +177,9 @@ ...@@ -177,10 +177,9 @@
* (CT_SPACE_LEFT+CT_SPACE_RIGHT) ); * (CT_SPACE_LEFT+CT_SPACE_RIGHT) );
#endif /*CT_PADDING*/ #endif /*CT_PADDING*/
if (_totalcount != (IceTSizeType)CT_PIXEL_COUNT) { if (_totalcount != (IceTSizeType)CT_PIXEL_COUNT) {
char msg[256]; icetRaiseError(ICET_SANITY_CHECK_FAIL,
sprintf(msg, "Total run lengths don't equal pixel count: %d != %d", "Total run lengths don't equal pixel count: %d != %d",
(int)_totalcount, (int)(CT_PIXEL_COUNT)); (int)_totalcount, (int)(CT_PIXEL_COUNT));
icetRaiseError(msg, ICET_SANITY_CHECK_FAIL);
} }
#endif /*DEBUG*/ #endif /*DEBUG*/
......
...@@ -32,8 +32,8 @@ IceTContext icetCreateContext(IceTCommunicator comm) ...@@ -32,8 +32,8 @@ IceTContext icetCreateContext(IceTCommunicator comm)
IceTContext context = malloc(sizeof(struct IceTContextStruct)); IceTContext context = malloc(sizeof(struct IceTContextStruct));
if (context == NULL) { if (context == NULL) {
icetRaiseError("Could not allocate memory for IceT context.", icetRaiseError(ICET_OUT_OF_MEMORY,
ICET_OUT_OF_MEMORY); "Could not allocate memory for IceT context.");
return NULL; return NULL;
} }
...@@ -101,7 +101,7 @@ IceTContext icetGetContext(void) ...@@ -101,7 +101,7 @@ IceTContext icetGetContext(void)
void icetSetContext(IceTContext context) void icetSetContext(IceTContext context)
{ {
if (context && (context->magic_number != CONTEXT_MAGIC_NUMBER)) { if (context && (context->magic_number != CONTEXT_MAGIC_NUMBER)) {
icetRaiseError("Invalid context.", ICET_INVALID_VALUE); icetRaiseError(ICET_INVALID_VALUE, "Invalid context.");
return; return;
} }
icet_current_context = context; icet_current_context = context;
......
...@@ -76,28 +76,28 @@ ...@@ -76,28 +76,28 @@
_pixel_count = icetSparseImageGetNumPixels(INPUT_SPARSE_IMAGE); _pixel_count = icetSparseImageGetNumPixels(INPUT_SPARSE_IMAGE);
if (_color_format != icetImageGetColorFormat(OUTPUT_IMAGE)) { if (_color_format != icetImageGetColorFormat(OUTPUT_IMAGE)) {
icetRaiseError("Input/output buffers have different color formats.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Input/output buffers have different color formats.");
} }
if (_depth_format != icetImageGetDepthFormat(OUTPUT_IMAGE)) { if (_depth_format != icetImageGetDepthFormat(OUTPUT_IMAGE)) {
icetRaiseError("Input/output buffers have different depth formats.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Input/output buffers have different depth formats.");
} }
#ifdef PIXEL_COUNT #ifdef PIXEL_COUNT
if (_pixel_count != PIXEL_COUNT) { if (_pixel_count != PIXEL_COUNT) {
icetRaiseError("Unexpected input pixel count.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Unexpected input pixel count.");
} }
#else #else
if (_pixel_count != icetImageGetNumPixels(OUTPUT_IMAGE)) { if (_pixel_count != icetImageGetNumPixels(OUTPUT_IMAGE)) {
icetRaiseError("Unexpected input pixel count.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Unexpected input pixel count.");
} }
#endif #endif
#ifdef OFFSET #ifdef OFFSET
if (_pixel_count > icetImageGetNumPixels(OUTPUT_IMAGE) - OFFSET) { if (_pixel_count > icetImageGetNumPixels(OUTPUT_IMAGE) - OFFSET) {
icetRaiseError("Offset pixels outside range of output image.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Offset pixels outside range of output image.");
} }
#endif #endif
...@@ -235,22 +235,25 @@ ...@@ -235,22 +235,25 @@
#include "decompress_template_body.h" #include "decompress_template_body.h"
#undef COPY_PIXEL #undef COPY_PIXEL
} else { } else {
icetRaiseError("Encountered invalid color format.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Encountered invalid color format 0x%X.",
_color_format);
} }
} else if (_depth_format == ICET_IMAGE_DEPTH_NONE) { } else if (_depth_format == ICET_IMAGE_DEPTH_NONE) {
icetRaiseError("Cannot use Z buffer compositing operation with no" icetRaiseError(ICET_INVALID_OPERATION,
" Z buffer.", ICET_INVALID_OPERATION); "Cannot use Z buffer compositing operation with no"
" Z buffer.");
} else { } else {
icetRaiseError("Encountered invalid depth format.", icetRaiseError(ICET_SANITY_CHECK_FAIL,
ICET_SANITY_CHECK_FAIL); "Encountered invalid depth format 0x%X.",
_depth_format);
} }
} else if (_composite_mode == ICET_COMPOSITE_MODE_BLEND) { } else if (_composite_mode == ICET_COMPOSITE_MODE_BLEND) {
/* Use alpha for active pixel and compositing. */ /* Use alpha for active pixel and compositing. */
if (_depth_format != ICET_IMAGE_DEPTH_NONE) { if (_depth_format != ICET_IMAGE_DEPTH_NONE) {
icetRaiseWarning("Z buffer ignored during blend composite" icetRaiseWarning(ICET_INVALID_VALUE,
" operation. Output z buffer meaningless.", "Z buffer ignored during blend composite"
ICET_INVALID_VALUE); " operation. Output z buffer meaningless.");
} }
if (_color_format == ICET_IMAGE_COLOR_RGBA_UBYTE) { if (_color_format == ICET_IMAGE_COLOR_RGBA_UBYTE) {