Exemplo n.º 1
0
static void do_send_receive(struct node_info *my_info, int tile_held,
                            GLint max_pixels, GLint num_tiles,
                            GLint *  tile_viewports,
                            GLboolean *all_contained_tmasks,
                            IceTImage imageBuffer,
                            IceTSparseImage inImage, IceTSparseImage outImage)
{
    GLint outImageSize = 0;

    /* To remove warning */
    (void)tile_viewports;
    
    if (my_info->tile_sending != -1) {
        icetRaiseDebug2("Sending tile %d to node %d.", my_info->tile_sending,
                        my_info->send_dest);
        if (tile_held == my_info->tile_sending) {
            outImageSize = icetCompressImage(imageBuffer, outImage);
            tile_held = -1;
        } else {
            outImageSize = icetGetCompressedTileImage(my_info->tile_sending,
                                                      outImage);
        }
    }

    if (my_info->tile_receiving != -1) {
        icetRaiseDebug2("Receiving tile %d from node %d.",
                        my_info->tile_receiving, my_info->recv_src);
        if (   (tile_held != my_info->tile_receiving)
            && all_contained_tmasks[my_info->rank*num_tiles
                                   +my_info->tile_receiving])
        {
            icetGetTileImage(my_info->tile_receiving, imageBuffer);
            tile_held = my_info->tile_receiving;
        }

        if (my_info->tile_sending != -1) {
            icetAddSentBytes(outImageSize);
            ICET_COMM_SENDRECV(outImage, outImageSize, ICET_BYTE,
                               my_info->send_dest, VTREE_IMAGE_DATA,
                               inImage, icetSparseImageSize(max_pixels),
                               ICET_BYTE, my_info->recv_src, VTREE_IMAGE_DATA);
        } else {
            ICET_COMM_RECV(inImage, icetSparseImageSize(max_pixels),
                           ICET_BYTE, my_info->recv_src, VTREE_IMAGE_DATA);
        }

        if (tile_held == my_info->tile_receiving) {
            icetCompressedComposite(imageBuffer, inImage, 1);
        } else {
            icetDecompressImage(inImage, imageBuffer);
        }

    } else if (my_info->tile_sending != -1) {
        icetAddSentBytes(outImageSize);
        ICET_COMM_SEND(outImage, outImageSize, ICET_BYTE,
                       my_info->send_dest, VTREE_IMAGE_DATA);
    }
}
Exemplo n.º 2
0
static IceTVoid *rtsi_generateDataFunc(IceTInt id, IceTInt dest,
                                       IceTSizeType *size) {
    IceTInt rank;
    const IceTInt *tile_list
        = icetUnsafeStateGetInteger(ICET_CONTAINED_TILES_LIST);
    IceTVoid *outBuffer;

    icetGetIntegerv(ICET_RANK, &rank);
    if (dest == rank) {
      /* Special case: sending to myself.
         Just get directly to color and depth buffers. */
        icetGetCompressedTileImage(tile_list[id], rtsi_workingImage);
        *size = 0;
        return NULL;
    }
    icetGetCompressedTileImage(tile_list[id], rtsi_outSparseImage);
    icetSparseImagePackageForSend(rtsi_outSparseImage, &outBuffer, size);
    return outBuffer;
}
Exemplo n.º 3
0
static int DoCompressionTest(IceTEnum color_format, IceTEnum depth_format,
                             IceTEnum composite_mode)
{
    IceTInt viewport[4];
    IceTSizeType pixels;
    IceTImage image;
    IceTVoid *imagebuffer;
    IceTSizeType imagesize;
    IceTSparseImage compressedimage;
    IceTVoid *compressedbuffer;
    IceTSparseImage interlacedimage;
    IceTVoid *interlacedbuffer;
    IceTSizeType compressedsize;
    IceTSizeType color_pixel_size;
    IceTSizeType depth_pixel_size;
    IceTSizeType pixel_size;
    IceTSizeType size;
    int result;

    result = TEST_PASSED;

    printstat("Using color format of 0x%x\n", (int)color_format);
    printstat("Using depth format of 0x%x\n", (int)depth_format);
    printstat("Using composite mode of 0x%x\n", (int)composite_mode);

    icetSetColorFormat(color_format);
    icetSetDepthFormat(depth_format);
    icetCompositeMode(composite_mode);

    pixels = SCREEN_WIDTH*SCREEN_HEIGHT;

    printstat("Allocating memory for %dx%d pixel image.\n",
              (int)SCREEN_WIDTH, (int)SCREEN_HEIGHT);
    imagesize = icetImageBufferSize(SCREEN_WIDTH, SCREEN_HEIGHT);
    imagebuffer = malloc(imagesize);
    image = icetImageAssignBuffer(imagebuffer, SCREEN_WIDTH, SCREEN_HEIGHT);

    compressedsize = icetSparseImageBufferSize(SCREEN_WIDTH, SCREEN_HEIGHT);
    compressedbuffer = malloc(compressedsize);
    compressedimage = icetSparseImageAssignBuffer(compressedbuffer,
                                                  SCREEN_WIDTH,
                                                  SCREEN_HEIGHT);

    interlacedbuffer = malloc(compressedsize);
    interlacedimage = icetSparseImageAssignBuffer(interlacedbuffer,
                                                  SCREEN_WIDTH,
                                                  SCREEN_HEIGHT);

  /* Get the number of bytes per pixel.  This is used in checking the
     size of compressed images. */
    icetImageGetColorVoid(image, &color_pixel_size);
    icetImageGetDepthVoid(image, &depth_pixel_size);
    pixel_size = color_pixel_size + depth_pixel_size;
    printstat("Pixel size: color=%d, depth=%d, total=%d\n",
              (int)color_pixel_size, (int)depth_pixel_size, (int)pixel_size);

    printstat("\nCreating worst possible image"
              " (with respect to compression).\n");
    InitPathologicalImage(image);

    printstat("Compressing image.\n");
    icetCompressImage(image, compressedimage);
    size = icetSparseImageGetCompressedBufferSize(compressedimage);
    printstat("Expected size: %d.  Actual size: %d\n",
              (int)(pixel_size*(pixels/2) + 2*sizeof(IceTUShort)*(pixels/2)),
              (int)size);
    if (   (size > compressedsize)
        || (size < pixel_size*(pixels/2)) ) {
        printrank("*** Size differs from expected size!\n");
        result = TEST_FAILED;
    }

    printstat("Interlacing image.\n");
    icetSparseImageInterlace(compressedimage,
                             97,
                             ICET_SI_STRATEGY_BUFFER_0,
                             interlacedimage);
    size = icetSparseImageGetCompressedBufferSize(compressedimage);
    printstat("Expected size: %d.  Actual size: %d\n",
              (int)(pixel_size*(pixels/2) + 2*sizeof(IceTUShort)*(pixels/2)),
              (int)size);
    if (   (size > compressedsize)
        || (size < pixel_size*(pixels/2)) ) {
        printrank("*** Size differs from expected size!\n");
        result = TEST_FAILED;
    }

    printstat("\nCreating a different worst possible image.\n");
    InitActiveImage(image);
    printstat("Compressing image.\n");
    icetCompressImage(image, compressedimage);
    size = icetSparseImageGetCompressedBufferSize(compressedimage);
    printstat("Expected size: %d.  Actual size: %d\n",
           (int)compressedsize, (int)size);
    if ((size > compressedsize) || (size < pixel_size*pixels)) {
        printrank("*** Size differs from expected size!\n");
        result = TEST_FAILED;
    }

    printstat("Interlacing image.\n");
    icetSparseImageInterlace(compressedimage,
                             97,
                             ICET_SI_STRATEGY_BUFFER_0,
                             interlacedimage);
    size = icetSparseImageGetCompressedBufferSize(compressedimage);
    printstat("Expected size: %d.  Actual size: %d\n",
           (int)(pixel_size*(pixels/2) + 2*sizeof(IceTUShort)*(pixels/2)),
           (int)size);
    if (   (size > compressedsize)
        || (size < pixel_size*(pixels/2)) ) {
        printrank("*** Size differs from expected size!\n");
        result = TEST_FAILED;
    }

    printstat("\nCompressing zero size image.\n");
    icetImageSetDimensions(image, 0, 0);
    icetCompressImage(image, compressedimage);
    size = icetSparseImageGetCompressedBufferSize(compressedimage);
    printstat("Expected size: %d.  Actual size: %d\n",
           (int)icetSparseImageBufferSize(0, 0), (int)size);
    if (size > icetSparseImageBufferSize(0, 0)) {
        printrank("*** Size differs from expected size!\n");
        result = TEST_FAILED;
    }

  /* This test can be a little volatile.  The icetGetCompressedTileImage
   * expects certain things to be set correctly by the icetDrawFrame
   * function.  Since we want to call icetGetCompressedTileImage directly,
   * we try to set up these parameters by hand.  It is possible for this
   * test to incorrectly fail if the two functions are mutually changed and
   * this scaffolding is not updated correctly. */
    printstat("\nSetup for actual render.\n");
    icetResetTiles();
    icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
    icetDrawCallback(drawCallback);
  /* Do a perfunctory draw to set other state variables. */
    icetDrawFrame(IdentityMatrix, IdentityMatrix, Black);
    viewport[0] = viewport[1] = 0;
    viewport[2] = (IceTInt)SCREEN_WIDTH;  viewport[3] = (IceTInt)SCREEN_HEIGHT;
    icetStateSetIntegerv(ICET_CONTAINED_VIEWPORT, 4, viewport);
    printstat("Now render and get compressed image.\n");
    icetGetCompressedTileImage(0, compressedimage);
    size = icetSparseImageGetCompressedBufferSize(compressedimage);
    printstat("Expected size: %d.  Actual size: %d\n",
              (int)compressedsize, (int)size);
    if ((size > compressedsize) || (size < pixel_size*pixels)) {
        printrank("*** Size differs from expected size!\n");
        result = TEST_FAILED;
    }

    printstat("Cleaning up.\n");
    free(imagebuffer);
    free(compressedbuffer);
    free(interlacedbuffer);
    return result;
}