Commit a70bb7f1 authored by Kenneth Moreland's avatar Kenneth Moreland

Add ICET_IMAGE_COLOR_RGB_FLOAT color format

Adds a color format that stores 3 channel RGB colors as floats. This is
really only good for z-buffer compositing.
parent 7feb9460
......@@ -102,6 +102,16 @@ void icetGLDrawCallbackFunction(const IceTDouble *projection_matrix,
GL_FLOAT,
colorBuffer + 4*( readback_viewport[0]
+ width*readback_viewport[1]));
} else if (color_format == ICET_IMAGE_COLOR_RGB_FLOAT) {
IceTFloat *colorBuffer = icetImageGetColorf(result);
glReadPixels((GLint)x_offset,
(GLint)y_offset,
(GLsizei)readback_viewport[2],
(GLsizei)readback_viewport[3],
GL_RGB,
GL_FLOAT,
colorBuffer + 3*( readback_viewport[0]
+ width*readback_viewport[1]));
} else if (color_format != ICET_IMAGE_COLOR_NONE) {
icetRaiseError(ICET_SANITY_CHECK_FAIL,
"Invalid color format 0x%X.", color_format);
......
......@@ -132,6 +132,41 @@
}
#define CCC_PIXEL_SIZE (5*sizeof(IceTFloat))
#include "cc_composite_template_body.h"
#undef UNPACK_PIXEL
} else if (_color_format == ICET_IMAGE_COLOR_RGB_FLOAT) {
#define UNPACK_PIXEL(pointer, color, depth) \
color = (IceTFloat *)pointer; \
pointer += 3*sizeof(IceTUInt); \
depth = (IceTFloat *)pointer; \
pointer += sizeof(IceTFloat);
#define CCC_FRONT_COMPRESSED_IMAGE FRONT_SPARSE_IMAGE
#define CCC_BACK_COMPRESSED_IMAGE BACK_SPARSE_IMAGE
#define CCC_DEST_COMPRESSED_IMAGE DEST_SPARSE_IMAGE
#define CCC_COMPOSITE(src1_pointer, src2_pointer, dest_pointer) \
{ \
const IceTFloat *src1_color; \
const IceTFloat *src1_depth; \
const IceTFloat *src2_color; \
const IceTFloat *src2_depth; \
IceTFloat *dest_color; \
IceTFloat *dest_depth; \
UNPACK_PIXEL(src1_pointer, src1_color, src1_depth); \
UNPACK_PIXEL(src2_pointer, src2_color, src2_depth); \
UNPACK_PIXEL(dest_pointer, dest_color, dest_depth); \
if (src1_depth[0] < src2_depth[0]) { \
dest_color[0] = src1_color[0]; \
dest_color[1] = src1_color[1]; \
dest_color[2] = src1_color[2]; \
dest_depth[0] = src1_depth[0]; \
} else { \
dest_color[0] = src2_color[0]; \
dest_color[1] = src2_color[1]; \
dest_color[2] = src2_color[2]; \
dest_depth[0] = src2_depth[0]; \
} \
}
#define CCC_PIXEL_SIZE (4*sizeof(IceTFloat))
#include "cc_composite_template_body.h"
#undef UNPACK_PIXEL
} else if (_color_format == ICET_IMAGE_COLOR_NONE) {
#define UNPACK_PIXEL(pointer, depth) \
......@@ -216,6 +251,10 @@
#define CCC_PIXEL_SIZE (4*sizeof(IceTFloat))
#include "cc_composite_template_body.h"
#undef UNPACK_PIXEL
} else if (_color_format == ICET_IMAGE_COLOR_RGB_FLOAT) {
icetRaiseError(
ICET_INVALID_VALUE,
"Cannot use blend composite without alpha channel");
} else if (_color_format == ICET_IMAGE_COLOR_NONE) {
icetRaiseWarning(ICET_INVALID_OPERATION,
"Compositing image with no data.");
......
......@@ -207,6 +207,48 @@
#define CT_FULL_WIDTH FULL_WIDTH
#define CT_FULL_HEIGHT FULL_HEIGHT
#endif
#include "compress_template_body.h"
} else if (_color_format == ICET_IMAGE_COLOR_RGB_FLOAT) {
const IceTFloat *_color;
IceTFloat *_out;
#ifdef REGION
IceTSizeType _region_count = 0;
#endif
_color = icetImageGetColorcf(INPUT_IMAGE);
#ifdef OFFSET
_color += 3*(OFFSET);
#endif
#define CT_COMPRESSED_IMAGE OUTPUT_SPARSE_IMAGE
#define CT_COLOR_FORMAT _color_format
#define CT_DEPTH_FORMAT _depth_format
#define CT_PIXEL_COUNT _pixel_count
#define CT_ACTIVE() (_depth[0] < 1.0)
#define CT_WRITE_PIXEL(dest) _out = (IceTFloat *)dest; \
_out[0] = _color[0]; \
_out[1] = _color[1]; \
_out[2] = _color[2]; \
_out[3] = _depth[0]; \
dest += 4*sizeof(IceTFloat);
#ifdef REGION
#define CT_INCREMENT_PIXEL() _color += 3; _depth++; \
_region_count++; \
if (_region_count >= _region_width) { \
_color += 3*_region_x_skip; \
_depth += _region_x_skip; \
_region_count = 0; \
}
#else
#define CT_INCREMENT_PIXEL() _color += 3; _depth++;
#endif
#ifdef PADDING
#define CT_PADDING
#define CT_SPACE_BOTTOM SPACE_BOTTOM
#define CT_SPACE_TOP SPACE_TOP
#define CT_SPACE_LEFT SPACE_LEFT
#define CT_SPACE_RIGHT SPACE_RIGHT
#define CT_FULL_WIDTH FULL_WIDTH
#define CT_FULL_HEIGHT FULL_HEIGHT
#endif
#include "compress_template_body.h"
} else if (_color_format == ICET_IMAGE_COLOR_NONE) {
IceTFloat *_out;
......@@ -341,6 +383,16 @@
#define CT_FULL_HEIGHT FULL_HEIGHT
#endif
#include "compress_template_body.h"
} else if (_color_format == ICET_IMAGE_COLOR_RGB_FLOAT) {
IceTUInt *_out;
icetRaiseError(
ICET_INVALID_VALUE,
"Compressing image for blending with no alpha channel.");
_out = ICET_IMAGE_DATA(OUTPUT_SPARSE_IMAGE);
INACTIVE_RUN_LENGTH(_out) = _pixel_count;
ACTIVE_RUN_LENGTH(_out) = 0;
_out++;
icetSparseImageSetActualSize(OUTPUT_SPARSE_IMAGE, _out);
} else if (_color_format == ICET_IMAGE_COLOR_NONE) {
IceTUInt *_out;
icetRaiseWarning(ICET_INVALID_OPERATION,
......
......@@ -204,6 +204,56 @@
}
#endif
#include "decompress_template_body.h"
#undef COPY_PIXEL
} else if (_color_format == ICET_IMAGE_COLOR_RGB_FLOAT) {
IceTFloat *_color;
const IceTFloat *_c_in;
const IceTFloat *_d_in;
IceTFloat _background_color[4];
_color = icetImageGetColorf(OUTPUT_IMAGE);
#ifdef OFFSET
_color += 3*(OFFSET);
#endif
icetGetFloatv(ICET_BACKGROUND_COLOR, _background_color);
#ifdef COMPOSITE
#define COPY_PIXEL(c_src, c_dest, d_src, d_dest) \
if (d_src[0] < d_dest[0]) { \
c_dest[0] = c_src[0]; \
c_dest[1] = c_src[1]; \
c_dest[2] = c_src[2]; \
d_dest[0] = d_src[0]; \
}
#else
#define COPY_PIXEL(c_src, c_dest, d_src, d_dest) \
c_dest[0] = c_src[0]; \
c_dest[1] = c_src[1]; \
c_dest[2] = c_src[2]; \
d_dest[0] = d_src[0];
#endif
#define DT_COMPRESSED_IMAGE INPUT_SPARSE_IMAGE
#define DT_READ_PIXEL(src) _c_in = (IceTFloat *)src; \
src += 3*sizeof(IceTFloat); \
_d_in = (IceTFloat *)src; \
src += sizeof(IceTFloat); \
COPY_PIXEL(_c_in, _color, \
_d_in, _depth); \
_color += 3; _depth++;
#ifdef COMPOSITE
#define DT_INCREMENT_INACTIVE_PIXELS(count) _color += 3*count; _depth += count;
#else
#define DT_INCREMENT_INACTIVE_PIXELS(count) \
{ \
IceTSizeType __i; \
for (__i = 0; __i < count; __i++) { \
_color[0] =_background_color[0];\
_color[1] =_background_color[1];\
_color[2] =_background_color[2];\
_color += 3; \
*(_depth++) = 1.0f; \
} \
}
#endif
#include "decompress_template_body.h"
#undef COPY_PIXEL
} else if (_color_format == ICET_IMAGE_COLOR_NONE) {
const IceTFloat *_d_in;
......@@ -346,6 +396,44 @@
}
#endif
#include "decompress_template_body.h"
#undef COPY_PIXEL
} else if (_color_format == ICET_IMAGE_COLOR_RGB_FLOAT) {
IceTFloat *_color;
const IceTFloat *_c_in;
IceTFloat _background_color[4];
_color = icetImageGetColorf(OUTPUT_IMAGE);
#ifdef OFFSET
_color += 3*(OFFSET);
#endif
#ifdef CORRECT_BACKGROUND
icetGetFloatv(ICET_TRUE_BACKGROUND_COLOR, _background_color);
#else
icetGetFloatv(ICET_BACKGROUND_COLOR, _background_color);
#endif
#define COPY_PIXEL(c_src, c_dest) \
c_dest[0] = c_src[0]; \
c_dest[1] = c_src[1]; \
c_dest[2] = c_src[2];
#define DT_COMPRESSED_IMAGE INPUT_SPARSE_IMAGE
#define DT_READ_PIXEL(src) _c_in = (IceTFloat *)src; \
src += 3*sizeof(IceTFloat); \
COPY_PIXEL(_c_in, _color); \
_color += 3;
#ifdef COMPOSITE
#define DT_INCREMENT_INACTIVE_PIXELS(count) _color += 3*count;
#else
#define DT_INCREMENT_INACTIVE_PIXELS(count) \
{ \
IceTSizeType __i; \
for (__i = 0; __i < count; __i++) { \
_color[0] =_background_color[0];\
_color[1] =_background_color[1];\
_color[2] =_background_color[2];\
_color += 3; \
} \
}
#endif
#include "decompress_template_body.h"
#undef COPY_PIXEL
} else if (_color_format == ICET_IMAGE_COLOR_NONE) {
icetRaiseWarning(ICET_INVALID_OPERATION,
......
This diff is collapsed.
......@@ -172,6 +172,7 @@ typedef struct { IceTVoid *opaque_internals; } IceTImage;
#define ICET_IMAGE_COLOR_RGBA_UBYTE (IceTEnum)0xC001
#define ICET_IMAGE_COLOR_RGBA_FLOAT (IceTEnum)0xC002
#define ICET_IMAGE_COLOR_RGB_FLOAT (IceTEnum)0xC003
#define ICET_IMAGE_COLOR_NONE (IceTEnum)0xC000
#define ICET_IMAGE_DEPTH_FLOAT (IceTEnum)0xD001
......
......@@ -47,6 +47,7 @@ SET(IceTTestSrcs
BackgroundCorrect.c
CompressionSize.c
FloatingViewport.c
ImageConvert.c
Interlace.c
MaxImageSplit.c
OddImageSizes.c
......
This diff is collapsed.
This diff is collapsed.
......@@ -70,6 +70,20 @@ static void LowerTriangleImage(IceTImage image)
data += 4;
}
}
} else if (icetImageGetColorFormat(image) == ICET_IMAGE_COLOR_RGB_FLOAT) {
IceTFloat *data = icetImageGetColorf(image);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if ((height-y) < x) {
data[0] = (float)x;
data[1] = (float)y;
data[2] = 0.0;
} else {
data[0] = data[1] = data[2] = 0.0;
}
data += 3;
}
}
} else if (icetImageGetColorFormat(image) == ICET_IMAGE_COLOR_NONE) {
/* Do nothing. */
} else {
......@@ -121,6 +135,16 @@ static void FullImage(IceTImage image)
data += 4;
}
}
} else if (icetImageGetColorFormat(image) == ICET_IMAGE_COLOR_RGB_FLOAT) {
IceTFloat *data = icetImageGetColorf(image);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
data[0] = (float)x;
data[1] = (float)y;
data[2] = 0.0;
data += 3;
}
}
} else if (icetImageGetColorFormat(image) == ICET_IMAGE_COLOR_NONE) {
/* Do nothing. */
} else {
......@@ -396,6 +420,10 @@ static int InterlaceRun()
result = InterlaceRunFormat();
if (result != TEST_PASSED) { return result; }
icetSetColorFormat(ICET_IMAGE_COLOR_RGB_FLOAT);
result = InterlaceRunFormat();
if (result != TEST_PASSED) { return result; }
icetSetColorFormat(ICET_IMAGE_COLOR_NONE);
result = InterlaceRunFormat();
if (result != TEST_PASSED) { return result; }
......
......@@ -380,6 +380,14 @@ static void RandomTransformDoRender(IceTBoolean transparent,
GL_FLOAT,
color_buffer);
break;
case ICET_IMAGE_COLOR_RGB_FLOAT:
color_buffer = malloc(width*height*3*sizeof(IceTFloat));
glReadPixels(0, 0,
width, height,
GL_RGB,
GL_FLOAT,
color_buffer);
break;
case ICET_IMAGE_COLOR_NONE:
/* Do nothing. */
break;
......@@ -490,7 +498,7 @@ static void RandomTransformTryStrategy()
RandomTransformTryInterlace(ICET_FALSE, local_width, local_height);
printstat("\nDoing float color buffer.\n");
printstat("\nDoing float RGBA color buffer.\n");
icetSetColorFormat(ICET_IMAGE_COLOR_RGBA_FLOAT);
icetSetDepthFormat(ICET_IMAGE_DEPTH_FLOAT);
icetCompositeMode(ICET_COMPOSITE_MODE_Z_BUFFER);
......@@ -499,6 +507,15 @@ static void RandomTransformTryStrategy()
RandomTransformTryInterlace(ICET_FALSE, local_width, local_height);
printstat("\nDoing float RGB color buffer.\n");
icetSetColorFormat(ICET_IMAGE_COLOR_RGB_FLOAT);
icetSetDepthFormat(ICET_IMAGE_DEPTH_FLOAT);
icetCompositeMode(ICET_COMPOSITE_MODE_Z_BUFFER);
icetEnable(ICET_COMPOSITE_ONE_BUFFER);
icetDisable(ICET_ORDERED_COMPOSITE);
RandomTransformTryInterlace(ICET_FALSE, local_width, local_height);
printstat("\nDoing depth buffer.\n");
icetSetColorFormat(ICET_IMAGE_COLOR_NONE);
icetSetDepthFormat(ICET_IMAGE_DEPTH_FLOAT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment