Exemplo n.º 1
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();
}
Exemplo n.º 2
0
IceTImage icetDrawFrame(const IceTDouble *projection_matrix,
                        const IceTDouble *modelview_matrix,
                        const IceTFloat *background_color)
{
    IceTInt frame_count;
    IceTImage image;
    IceTDouble render_time;
    IceTDouble buf_read_time;
    IceTDouble compose_time;
    IceTDouble total_time;

    icetRaiseDebug("In icetDrawFrame");

    {
        IceTBoolean isDrawing;
        icetGetBooleanv(ICET_IS_DRAWING_FRAME, &isDrawing);
        if (isDrawing) {
            icetRaiseError("Recursive frame draw detected.",
                           ICET_INVALID_OPERATION);
            return icetImageNull();
        }
    }

    icetStateResetTiming();
    icetTimingDrawFrameBegin();

    icetStateSetDoublev(ICET_PROJECTION_MATRIX, 16, projection_matrix);
    icetStateSetDoublev(ICET_MODELVIEW_MATRIX, 16, modelview_matrix);

    drawUseBackgroundColor(background_color);

    icetGetIntegerv(ICET_FRAME_COUNT, &frame_count);
    frame_count++;
    icetStateSetIntegerv(ICET_FRAME_COUNT, 1, &frame_count);

    drawProjectBounds();

    {
        IceTEnum strategy;
        icetGetEnumv(ICET_STRATEGY, &strategy);

        /* drawCollectTileInformation does an allgather to get information
         * about the tiles in other processes.  These variables are
         * ICET_ALL_CONTAINED_TILES_MASKS, ICET_TILE_CONTRIB_COUNTS, and
         * ICET_TOTAL_IMAGE_COUNT.  However, the sequential strategy ignores
         * this information and just uses all processes for all tiles.  When
         * compositing a single tile, this is a fine strategy and we can save
         * a significant proportion of frame time by skipping this step. */
        if (strategy != ICET_STRATEGY_SEQUENTIAL) {
            drawCollectTileInformation();
        }
    }

    {
        IceTInt tile_displayed;
        icetGetIntegerv(ICET_TILE_DISPLAYED, &tile_displayed);

        if (tile_displayed >= 0) {
            const IceTInt *tile_viewports
                = icetUnsafeStateGetInteger(ICET_TILE_VIEWPORTS);
            IceTInt num_pixels = (  tile_viewports[4*tile_displayed+2]
                                  * tile_viewports[4*tile_displayed+3] );
            icetStateSetInteger(ICET_VALID_PIXELS_TILE, tile_displayed);
            icetStateSetInteger(ICET_VALID_PIXELS_OFFSET, 0);
            icetStateSetInteger(ICET_VALID_PIXELS_NUM, num_pixels);
        } else {
            icetStateSetInteger(ICET_VALID_PIXELS_TILE, -1);
            icetStateSetInteger(ICET_VALID_PIXELS_OFFSET, 0);
            icetStateSetInteger(ICET_VALID_PIXELS_NUM, 0);
        }
    }

    image = drawInvokeStrategy();

    /* Calculate times. */
    icetGetDoublev(ICET_RENDER_TIME, &render_time);
    icetGetDoublev(ICET_BUFFER_READ_TIME, &buf_read_time);

    icetTimingDrawFrameEnd();

    icetGetDoublev(ICET_TOTAL_DRAW_TIME, &total_time);

    compose_time = total_time - render_time - buf_read_time;
    icetStateSetDouble(ICET_COMPOSITE_TIME, compose_time);

    icetStateSetDouble(ICET_BUFFER_WRITE_TIME, 0.0);

    icetStateCheckMemory();

    return image;
}
Exemplo n.º 3
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();
}