예제 #1
0
static void DisplayNoDrawInit(void)
{
    printf("Setting tile.");
    icetResetTiles();
    icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);

    icetGLDrawCallback(draw);

    icetSetColorFormat(ICET_IMAGE_COLOR_RGBA_UBYTE);
    icetSetDepthFormat(ICET_IMAGE_DEPTH_FLOAT);

    if (global_rank == 0) {
        icetBoundingBoxd(100.0, 101.0, 100.0, 101.0, 100.0, 101.0);
    } else {
        icetBoundingBoxd(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glDisable(GL_LIGHTING);
    glColor4d(1.0, 1.0, 1.0, 1.0);
}
예제 #2
0
void icetStateSetDefaults(void)
{
    GLint *int_array;
    int i;

    icetDiagnostics(ICET_DIAG_ALL_NODES | ICET_DIAG_WARNINGS);

    icetStateSetInteger(ICET_RANK, ICET_COMM_RANK());
    icetStateSetInteger(ICET_NUM_PROCESSES, ICET_COMM_SIZE());
    icetStateSetInteger(ICET_ABSOLUTE_FAR_DEPTH, 1);
    /*icetStateSetInteger(ICET_ABSOLUTE_FAR_DEPTH, 0xFFFFFFFF);*/
    icetStateSetFloatv(ICET_BACKGROUND_COLOR, 4, black);
    icetStateSetInteger(ICET_BACKGROUND_COLOR_WORD, 0);

    icetResetTiles();
    icetStateSetIntegerv(ICET_DISPLAY_NODES, 0, NULL);

    icetStateSetDoublev(ICET_GEOMETRY_BOUNDS, 0, NULL);
    icetStateSetInteger(ICET_NUM_BOUNDING_VERTS, 0);
    icetStateSetPointer(ICET_STRATEGY_COMPOSE, NULL);
    icetInputOutputBuffers(ICET_COLOR_BUFFER_BIT | ICET_DEPTH_BUFFER_BIT,
                           ICET_COLOR_BUFFER_BIT);
    int_array = malloc(ICET_COMM_SIZE() * sizeof(GLint));
    for (i = 0; i < ICET_COMM_SIZE(); i++) {
        int_array[i] = i;
    }
    icetStateSetIntegerv(ICET_COMPOSITE_ORDER, ICET_COMM_SIZE(), int_array);
    icetStateSetIntegerv(ICET_PROCESS_ORDERS, ICET_COMM_SIZE(), int_array);
    free(int_array);

    icetStateSetInteger(ICET_DATA_REPLICATION_GROUP, ICET_COMM_RANK());
    icetStateSetInteger(ICET_DATA_REPLICATION_GROUP_SIZE, 1);

    icetStateSetPointer(ICET_DRAW_FUNCTION, NULL);
    icetStateSetInteger(ICET_READ_BUFFER, GL_BACK);
#ifdef _WIN32
    icetStateSetInteger(ICET_COLOR_FORMAT, GL_BGRA_EXT);
#else
    icetStateSetInteger(ICET_COLOR_FORMAT, GL_RGBA);
#endif
    icetStateSetInteger(ICET_FRAME_COUNT, 0);

    icetEnable(ICET_FLOATING_VIEWPORT);
    icetDisable(ICET_ORDERED_COMPOSITE);
    icetDisable(ICET_CORRECT_COLORED_BACKGROUND);
    icetEnable(ICET_DISPLAY);
    icetDisable(ICET_DISPLAY_COLORED_BACKGROUND);
    icetDisable(ICET_DISPLAY_INFLATE);
    icetEnable(ICET_DISPLAY_INFLATE_WITH_HARDWARE);

    icetStateSetBoolean(ICET_IS_DRAWING_FRAME, 0);

    icetStateSetPointer(ICET_COLOR_BUFFER, NULL);
    icetStateSetPointer(ICET_DEPTH_BUFFER, NULL);
    icetStateSetBoolean(ICET_COLOR_BUFFER_VALID, 0);
    icetStateSetBoolean(ICET_DEPTH_BUFFER_VALID, 0);

    icetStateResetTiming();
}
예제 #3
0
// ****************************************************************************
//  Method: IceTNetworkManager destructor
//
//  Purpose: Configures IceT for the tiled system we'll be rendering too (note
//           that a lone monitor is a `1x1 tiled display').
//
//  Programmer: Tom Fogal
//  Creation:   June 17, 2008
//
//  Modifications:
//
// ****************************************************************************
void
IceTNetworkManager::TileLayout(size_t width, size_t height) const
{
    debug2 << "IceTNM: configuring " << width << "x" << height
           << " single tile display." << std::endl;

    ICET(icetResetTiles());
    const GLint this_mpi_rank_gets_an_image = 0;
    ICET(icetAddTile(0,0, width, height, this_mpi_rank_gets_an_image));
}
예제 #4
0
static void BackgroundCorrectSetupRender()
{
    IceTInt num_proc;

    icetGetIntegerv(ICET_NUM_PROCESSES, &num_proc);

    icetCompositeMode(ICET_COMPOSITE_MODE_BLEND);
    icetSetColorFormat(ICET_IMAGE_COLOR_RGBA_FLOAT);
    icetSetDepthFormat(ICET_IMAGE_DEPTH_NONE);
    icetDisable(ICET_ORDERED_COMPOSITE);
    icetEnable(ICET_CORRECT_COLORED_BACKGROUND);

    icetDrawCallback(BackgroundCorrectDraw);

    icetResetTiles();
    icetAddTile(0, 0, PROC_REGION_WIDTH, PROC_REGION_HEIGHT*(num_proc+1), 0);
}
예제 #5
0
static int SimpleExampleRun()
{
    float angle;

  /* Normally, the first thing that you do is set up your communication and
   * then create at least one IceT context.  This has already been done in
   * the calling function (i.e. icetTests_mpi.c).  See the init_mpi in
   * test_mpi.h for an example.
   */

  /* If we had set up the communication layer ourselves, we could have
   * gotten these parameters directly from it.  Since we did not, this
   * provides an alternate way. */
    icetGetIntegerv(ICET_RANK, &rank);
    icetGetIntegerv(ICET_NUM_PROCESSES, &num_proc);

  /* We should be able to set any color we want, but we should do it BEFORE
   * icetGLDrawFrame() is called, not in the callback drawing function.
   * There may also be limitations on the background color when performing
   * color blending. */
    glClearColor(0.2f, 0.5f, 0.1f, 1.0f);

  /* Give IceT a function that will issue the OpenGL drawing commands. */
    icetGLDrawCallback(draw);

  /* Give IceT the bounds of the polygons that will be drawn.  Note that
   * we must take into account any transformation that happens within the
   * draw function (but IceT will take care of any transformation that
   * happens before icetGLDrawFrame). */
    icetBoundingBoxd(-0.5+rank, 0.5+rank, -0.5, 0.5, -0.5, 0.5);

  /* Set up the tiled display.  Normally, the display will be fixed for a
   * given installation, but since this is a demo, we give two specific
   * examples. */
    if (num_proc < 4) {
      /* Here is an example of a "1 tile" case.  This is functionally
       * identical to a traditional sort last algorithm. */
        icetResetTiles();
        icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
    } else {
      /* Here is an example of a 4x4 tile layout.  The tiles are displayed
       * with the following ranks:
       *
       *               +---+---+
       *               | 0 | 1 |
       *               +---+---+
       *               | 2 | 3 |
       *               +---+---+
       *
       * Each tile is simply defined by grabing a viewport in an infinite
       * global display screen.  The global viewport projection is
       * automatically set to the smallest region containing all tiles.
       *
       * This example also shows tiles abutted against each other.
       * Mullions and overlaps can be implemented by simply shifting tiles
       * on top of or away from each other.
       */
        icetResetTiles();
        icetAddTile(0, (IceTInt)SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
        icetAddTile((IceTInt)SCREEN_WIDTH,
                    (IceTInt)SCREEN_HEIGHT,
                    SCREEN_WIDTH,
                    SCREEN_HEIGHT,
                    1);
        icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 2);
        icetAddTile((IceTInt)SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 3);
    }

  /* Tell IceT what strategy to use.  The REDUCE strategy is an all-around
   * good performer. */
    icetStrategy(ICET_STRATEGY_REDUCE);

  /* Set up the projection matrix as you normally would. */
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-0.75, 0.75, -0.75, 0.75, -0.75, 0.75);

  /* Other normal OpenGL setup. */
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    if (rank%8 != 0) {
        GLfloat color[4];
        color[0] = (float)(rank%2);
        color[1] = (float)((rank/2)%2);
        color[2] = (float)((rank/4)%2);
        color[3] = 1.0f;
        glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color);
    }

  /* Here is an example of an animation loop. */
    for (angle = 0; angle < 360; angle += 10) {
      /* We can set up a modelview matrix here and IceT will factor this
       * in determining the screen projection of the geometry.  Note that
       * there is further transformation in the draw function that IceT
       * cannot take into account.  That transformation is handled in the
       * application by deforming the bounds before giving them to
       * IceT. */
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glRotated(angle, 0.0, 1.0, 0.0);
        glScaled(1.0f/num_proc, 1.0, 1.0);
        glTranslated(-(num_proc-1)/2.0, 0.0, 0.0);

      /* Instead of calling draw() directly, call it indirectly through
       * icetDrawFrame().  IceT will automatically handle image
       * compositing. */
        icetGLDrawFrame();

      /* For obvious reasons, IceT should be run in double-buffered frame
       * mode.  After calling icetDrawFrame, the application should do a
       * synchronize (a barrier is often about as good as you can do) and
       * then a swap buffers. */
        swap_buffers();
    }

    return TEST_PASSED;
}
예제 #6
0
static int BoundsBehindViewerRun()
{
    float mat[16];
    IceTImage image;

    IceTInt rank;
    icetGetIntegerv(ICET_RANK, &rank);

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    icetGLDrawCallback(draw);
    icetStrategy(ICET_STRATEGY_REDUCE);

    icetBoundingBoxd(-1.0, 1.0, -1.0, 1.0, -0.0, 0.0);

    icetSetColorFormat(ICET_IMAGE_COLOR_RGBA_UBYTE);
    icetSetDepthFormat(ICET_IMAGE_DEPTH_FLOAT);

  /* We're just going to use one tile. */
    icetResetTiles();
    icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);

  /* Set up the transformation such that the quad in draw should cover the
     entire screen, but part of it extends behind the viewpoint.  Furthermore, a
     naive division by w will show all points to the right of the screen (which,
     of course, is wrong). */
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslated(0.0, 0.0, -1.5);
    glRotated(10.0, 0.0, 1.0, 0.0);
    glScaled(10.0, 10.0, 10.0);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 2.0);

    printstat("Modelview matrix:\n");
    glGetFloatv(GL_MODELVIEW_MATRIX, mat);
    PrintMatrix(mat);
    printstat("Projection matrix:\n");
    glGetFloatv(GL_PROJECTION_MATRIX, mat);
    PrintMatrix(mat);

  /* Other normal OpenGL setup. */
    glEnable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);
    glColor3d(1.0, 1.0, 1.0);

  /* All the processes have the same data.  Go ahead and tell IceT. */
    icetDataReplicationGroupColor(0);

    image = icetGLDrawFrame();

  /* Test the resulting image to make sure the polygon was drawn over it. */
    if (rank == 0) {
        IceTUInt *cb = icetImageGetColorui(image);
        if (cb[0] != 0xFFFFFFFF) {
            printstat("First pixel in color buffer wrong: 0x%x\n", cb[0]);
            return TEST_FAILED;
        }
    }

    return TEST_PASSED;
}
예제 #7
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;
}
int BlankTiles(int argc, char *argv[])
{
    int i, j, x, y;
    GLubyte *cb;
    int result = TEST_PASSED;
    GLint rank, num_proc;

    /* To remove warning */
    (void)argc;
    (void)argv;

    icetGetIntegerv(ICET_RANK, &rank);
    icetGetIntegerv(ICET_NUM_PROCESSES, &num_proc);

    glClearColor(0.0, 0.0, 0.0, 0.0);

    icetDrawFunc(draw);
    icetBoundingBoxf(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5);

    for (i = 0; i < STRATEGY_LIST_SIZE; i++) {
        int tile_dim;

        icetStrategy(strategy_list[i]);
        printf("\n\nUsing %s strategy.\n", icetGetStrategyName());

        for (tile_dim = 1; tile_dim*tile_dim <= num_proc; tile_dim++) {
            printf("\nRunning on a %d x %d display.\n", tile_dim, tile_dim);
            icetResetTiles();
            for (y = 0; y < tile_dim; y++) {
                for (x = 0; x < tile_dim; x++) {
                    icetAddTile(x*SCREEN_WIDTH, y*SCREEN_HEIGHT,
                                SCREEN_WIDTH, SCREEN_HEIGHT, y*tile_dim + x);
                }
            }

            printf("Rendering frame.\n");
            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            glOrtho(-1, tile_dim*2-1, -1, tile_dim*2-1, -1, 1);
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();
            icetDrawFrame();
            swap_buffers();

            if (rank == 0) {
                printf("Rank == 0, tile should have stuff in it.\n");
            } else if (rank < tile_dim*tile_dim) {
                printf("Checking returned image.\n");
                cb = icetGetColorBuffer();
                for (j = 0; j < SCREEN_WIDTH*SCREEN_HEIGHT*4; j++) {
                    if (cb[j] != 0) {
                        printf("Found bad pixel!!!!!!!!\n");
                        result = TEST_FAILED;
                        break;
                    }
                }
            } else {
                printf("Not a display node.  Not testing image.\n");
            }
        }
    }

    printf("Cleaning up.\n");

    finalize_test(result);
    return result;
}
int DisplayNoDraw(int argc, char *argv[])
{
    int result = TEST_PASSED;
    int i;
    GLint rank, num_proc;

    /* To remove warning */
    (void)argc;
    (void)argv;

    icetGetIntegerv(ICET_RANK, &rank);
    icetGetIntegerv(ICET_NUM_PROCESSES, &num_proc);

    printf("Starting DisplayNoDraw.\n");

    global_rank = rank;

    printf("Setting tile.");
    icetResetTiles();
    icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);

    icetDrawFunc(draw);

    if (rank == 0) {
        icetBoundingBoxf(100.0, 101.0, 100.0, 101.0, 100.0, 101.0);
    } else {
        icetBoundingBoxf(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glDisable(GL_LIGHTING);
    glColor4f(1.0, 1.0, 1.0, 1.0);

    for (i = 0; i < STRATEGY_LIST_SIZE; i++) {
        GLubyte *color_buffer;

        icetStrategy(strategy_list[i]);
        printf("\n\nUsing %s strategy.\n", icetGetStrategyName());

        for (iteration = 0; iteration < num_proc; iteration++) {
            printf("Blank tile is rank %d\n", iteration);

            icetDrawFrame();
            swap_buffers();

            if (   (rank == 0)
                && (num_proc > 1)
               /* This last case covers when there is only 2 processes,
                * the root, as always, is not drawing anything and the
                * other process is drawing the clear screen. */
                && ((num_proc > 2) || (iteration != 1)) ) {
                int p;
                int bad_count = 0;
                printf("Checking pixels.\n");
                color_buffer = icetGetColorBuffer();
                for (p = 0; p < SCREEN_WIDTH*SCREEN_HEIGHT*4; p++) {
                    if (color_buffer[p] != 255) {
                        char filename[256];
                        printf("BAD PIXEL %d.%d\n", p/4, p%4);
                        printf("    Expected 255, got %d\n", color_buffer[p]);
                        bad_count++;
                        if (bad_count >= 10) {
                            result = TEST_FAILED;
                            sprintf(filename, "DisplayNoDraw_%s_%d.ppm",
                                    icetGetStrategyName(), iteration);
                            write_ppm(filename, color_buffer,
                                      SCREEN_WIDTH, SCREEN_HEIGHT);
                            break;
                        }
                    }
                }
            }
        }
    }

    finalize_test(result);
    return result;
}
예제 #10
0
void icetStateSetDefaults(void)
{
    IceTInt *int_array;
    int i;
    int comm_size, comm_rank;

    icetDiagnostics(ICET_DIAG_ALL_NODES | ICET_DIAG_WARNINGS);

    comm_size = icetCommSize();
    comm_rank = icetCommRank();
    icetStateSetInteger(ICET_RANK, comm_rank);
    icetStateSetInteger(ICET_NUM_PROCESSES, comm_size);
    /* icetStateSetInteger(ICET_ABSOLUTE_FAR_DEPTH, 1); */
  /*icetStateSetInteger(ICET_ABSOLUTE_FAR_DEPTH, 0xFFFFFFFF);*/
    icetStateSetFloatv(ICET_BACKGROUND_COLOR, 4, black);
    icetStateSetInteger(ICET_BACKGROUND_COLOR_WORD, 0);
    icetStateSetInteger(ICET_COLOR_FORMAT, ICET_IMAGE_COLOR_RGBA_UBYTE);
    icetStateSetInteger(ICET_DEPTH_FORMAT, ICET_IMAGE_DEPTH_FLOAT);

    icetResetTiles();
    icetStateSetIntegerv(ICET_DISPLAY_NODES, 0, NULL);

    icetStateSetDoublev(ICET_GEOMETRY_BOUNDS, 0, NULL);
    icetStateSetInteger(ICET_NUM_BOUNDING_VERTS, 0);
    icetStateSetInteger(ICET_STRATEGY, ICET_STRATEGY_UNDEFINED);
    icetSingleImageStrategy(ICET_SINGLE_IMAGE_STRATEGY_AUTOMATIC);
    icetCompositeMode(ICET_COMPOSITE_MODE_Z_BUFFER);
    int_array = icetStateAllocateInteger(ICET_COMPOSITE_ORDER, comm_size);
    for (i = 0; i < comm_size; i++) {
        int_array[i] = i;
    }
    int_array = icetStateAllocateInteger(ICET_PROCESS_ORDERS, comm_size);
    for (i = 0; i < comm_size; i++) {
        int_array[i] = i;
    }

    icetStateSetInteger(ICET_DATA_REPLICATION_GROUP, comm_rank);
    icetStateSetInteger(ICET_DATA_REPLICATION_GROUP_SIZE, 1);
    icetStateSetInteger(ICET_FRAME_COUNT, 0);

    if (getenv("ICET_MAGIC_K") != NULL) {
        IceTInt magic_k = atoi(getenv("ICET_MAGIC_K"));
        if (magic_k > 1) {
            icetStateSetInteger(ICET_MAGIC_K, magic_k);
        } else {
            icetRaiseError("Environment varible ICET_MAGIC_K must be set"
                           " to an integer greater than 1.",
                           ICET_INVALID_VALUE);
            icetStateSetInteger(ICET_MAGIC_K, ICET_MAGIC_K_DEFAULT);
        }
    } else {
        icetStateSetInteger(ICET_MAGIC_K, ICET_MAGIC_K_DEFAULT);
    }

    if (getenv("ICET_MAX_IMAGE_SPLIT") != NULL) {
        IceTInt max_image_split = atoi(getenv("ICET_MAX_IMAGE_SPLIT"));
        if (max_image_split > 0) {
            icetStateSetInteger(ICET_MAX_IMAGE_SPLIT, max_image_split);
        } else {
            icetRaiseError("Environment variable ICET_MAX_IMAGE_SPLIT must be"
                           " set to an integer greater than 0.",
                           ICET_INVALID_VALUE);
            icetStateSetInteger(ICET_MAX_IMAGE_SPLIT,
                                ICET_MAX_IMAGE_SPLIT_DEFAULT);
        }
    } else {
        icetStateSetInteger(ICET_MAX_IMAGE_SPLIT, ICET_MAX_IMAGE_SPLIT_DEFAULT);
    }

    icetStateSetPointer(ICET_DRAW_FUNCTION, NULL);
    icetStateSetPointer(ICET_RENDER_LAYER_DESTRUCTOR, NULL);

    icetEnable(ICET_FLOATING_VIEWPORT);
    icetDisable(ICET_ORDERED_COMPOSITE);
    icetDisable(ICET_CORRECT_COLORED_BACKGROUND);
    icetEnable(ICET_COMPOSITE_ONE_BUFFER);
    icetEnable(ICET_INTERLACE_IMAGES);
    icetEnable(ICET_COLLECT_IMAGES);
    icetDisable(ICET_RENDER_EMPTY_IMAGES);

    icetStateSetBoolean(ICET_IS_DRAWING_FRAME, 0);
    icetStateSetBoolean(ICET_RENDER_BUFFER_SIZE, 0);

    icetStateSetInteger(ICET_VALID_PIXELS_TILE, -1);
    icetStateSetInteger(ICET_VALID_PIXELS_OFFSET, 0);
    icetStateSetInteger(ICET_VALID_PIXELS_NUM, 0);

    icetStateResetTiming();
}
예제 #11
0
static int BlankTilesDoTest(void)
{
    int result = TEST_PASSED;
    int tile_dim;
    IceTInt rank, num_proc;

    icetGetIntegerv(ICET_RANK, &rank);
    icetGetIntegerv(ICET_NUM_PROCESSES, &num_proc);

    for (tile_dim = 1; tile_dim*tile_dim <= num_proc; tile_dim++) {
        int x, y;
        IceTSizeType my_width = -1;
        IceTSizeType my_height = -1;
        IceTImage image;
        printstat("\nRunning on a %d x %d display.\n", tile_dim, tile_dim);
        icetResetTiles();
        for (y = 0; y < tile_dim; y++) {
            for (x = 0; x < tile_dim; x++) {
                int tile_rank = y*tile_dim + x;
              /* Modify the width and height a bit to detect bad image sizes. */
                IceTSizeType tile_width = SCREEN_WIDTH - x;
                IceTSizeType tile_height = SCREEN_HEIGHT - y;
                icetAddTile((IceTInt)(x*SCREEN_WIDTH),
                            (IceTInt)(y*SCREEN_HEIGHT),
                            tile_width,
                            tile_height,
                            tile_rank);
                if (tile_rank == rank) {
                    my_width = tile_width;
                    my_height = tile_height;
                }
            }
        }

        printstat("Rendering frame.\n");
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(-1, tile_dim*2-1, -1, tile_dim*2-1, -1, 1);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        image = icetGLDrawFrame();
        swap_buffers();

        if (rank == 0) {
            /* printrank("Rank == 0, tile should have stuff in it.\n"); */
        } else if (rank < tile_dim*tile_dim) {
            IceTFloat *cb;
            int color_component;

            if (   (my_width != icetImageGetWidth(image))
                || (my_height != icetImageGetHeight(image)) ) {
                printrank("Image size is wrong!!!!!!!!!\n");
                result = TEST_FAILED;
            }

            /* printrank("Checking returned image data.\n"); */
            cb = icetImageGetColorf(image);
            for (color_component = 0;
                 color_component < my_width*my_height*4;
                 color_component++) {
                if (cb[color_component] != 0.25f) {
                    printrank("Found bad pixel!!!!!!!!\n");
                    result = TEST_FAILED;
                    break;
                }
            }
        } else {
            /* printrank("Not a display node.  Not testing image.\n"); */
        }
    }

    return result;
}
int BoundsBehindViewer(int argc, char * argv[])
{
    float mat[16];

    /* To remove warning */
    (void)argc;
    (void)argv;

    GLint rank;
    icetGetIntegerv(ICET_RANK, &rank);

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    icetDrawFunc(draw);
    icetStrategy(ICET_STRATEGY_REDUCE);

    icetBoundingBoxf(-1.0, 1.0, -1.0, 1.0, -0.0, 0.0);

  /* We're just going to use one tile. */
    icetResetTiles();
    icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);

  /* Set up the transformation such that the quad in draw should cover the
     entire screen, but part of it extends behind the viewpoint.  Furthermore, a
     naive division by w will show all points to the right of the screen (which,
     of course, is wrong). */
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0.0, 0.0, -1.5);
    glRotatef(10.0, 0.0, 1.0, 0.0);
    glScalef(10.0, 10.0, 10.0);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 2.0);

    printf("Modelview matrix:\n");
    glGetFloatv(GL_MODELVIEW_MATRIX, mat);
    PrintMatrix(mat);
    printf("Projection matrix:\n");
    glGetFloatv(GL_PROJECTION_MATRIX, mat);
    PrintMatrix(mat);

  /* Other normal OpenGL setup. */
    glEnable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);
    glColor3f(1.0, 1.0, 1.0);

  /* All the processes have the same data.  Go ahead and tell IceT. */
    icetDataReplicationGroupColor(0);

    icetDrawFrame();

  /* Test the resulting image to make sure the polygon was drawn over it. */
    if (rank == 0) {
        GLuint *cb = (GLuint *)icetGetColorBuffer();
        if (cb[0] != 0xFFFFFFFF) {
            printf("First pixel in color buffer wrong: 0x%x\n", cb[0]);
            finalize_test(TEST_FAILED);
            return TEST_FAILED;
        }
    }

    finalize_test(TEST_PASSED);
    return TEST_PASSED;
}