Пример #1
0
void icetStateCopy(IceTState dest, const IceTState src)
{
    IceTEnum pname;
    IceTSizeType type_width;
    IceTTimeStamp mod_time;

    mod_time = icetGetTimeStamp();

    for (pname = ICET_STATE_ENGINE_START;
         pname < ICET_STATE_ENGINE_END;
         pname++) {
        if (   (pname == ICET_RANK)
            || (pname == ICET_NUM_PROCESSES)
            || (pname == ICET_DATA_REPLICATION_GROUP)
            || (pname == ICET_DATA_REPLICATION_GROUP_SIZE)
            || (pname == ICET_COMPOSITE_ORDER)
            || (pname == ICET_PROCESS_ORDERS) )
        {
            continue;
        }

        type_width = icetTypeWidth(src[pname].type);

        if (type_width > 0) {
            IceTVoid *data = stateAllocate(pname,
                                           src[pname].num_entries,
                                           src[pname].type,
                                           dest);
            memcpy(data, src[pname].data, src[pname].num_entries * type_width);
        } else {
            stateFree(pname, dest);
        }
        dest[pname].mod_time = mod_time;
    }
}
Пример #2
0
void icetUnsafeStateSet(GLenum pname, GLint size, GLenum type, GLvoid *data)
{
    IceTState state = icetGetState();

    if (state[pname].type != ICET_NULL) {
        free(state[pname].data);
    }

    state[pname].type = type;
    state[pname].size = size;
    state[pname].mod_time = icetGetTimeStamp();
    state[pname].data = data;
}
Пример #3
0
static void stateSet(GLenum pname, GLint size, GLenum type, const GLvoid *data)
{
    IceTState state;
    int type_width;
    void *datacopy;

    state = icetGetState();
    type_width = typeWidth(type);

    if ((size == state[pname].size) && (type == state[pname].type)) {
        /* Save time by just copying data into pre-existing memory. */
        memcpy(state[pname].data, data, size * type_width);
        state[pname].mod_time = icetGetTimeStamp();
    } else {
        datacopy = malloc(size * type_width);
        memcpy(datacopy, data, size * type_width);

        icetUnsafeStateSet(pname, size, type, datacopy);
    }
}
Пример #4
0
void icetStateCopy(IceTState dest, const IceTState src)
{
    GLenum i;
    int type_width;
    IceTTimeStamp mod_time;

    mod_time = icetGetTimeStamp();

    for (i = 0; i < ICET_STATE_SIZE; i++) {
        if (   (i == ICET_RANK) || (i == ICET_NUM_PROCESSES)
                || (i == ICET_DATA_REPLICATION_GROUP)
                || (i == ICET_DATA_REPLICATION_GROUP_SIZE)
                || (i == ICET_COMPOSITE_ORDER) || (i == ICET_PROCESS_ORDERS)
                || (i == ICET_COLOR_BUFFER) || (i == ICET_COLOR_BUFFER_VALID)
                || (i == ICET_DEPTH_BUFFER) || (i == ICET_DEPTH_BUFFER_VALID) )
        {
            continue;
        }

        if (dest[i].type != ICET_NULL) {
            free(dest[i].data);
        }

        type_width = typeWidth(src[i].type);

        dest[i].type = src[i].type;
        dest[i].size = src[i].size;
        if (type_width > 0) {
            dest[i].data = malloc(type_width * dest[i].size);
            memcpy(dest[i].data, src[i].data, src[i].size * type_width);
        } else {
            dest[i].data = NULL;
        }
        dest[i].mod_time = mod_time;
    }
}
Пример #5
0
static IceTVoid *stateAllocate(IceTEnum pname,
                               IceTSizeType num_entries,
                               IceTEnum type,
                               IceTState state)
{
    IceTVoid *buffer;

    stateCheck(pname, state);

    if (   (num_entries == state[pname].num_entries)
        && (type == state[pname].type) ) {
        /* Return the current buffer. */
        state[pname].mod_time = icetGetTimeStamp();
        buffer = state[pname].data;
    } else if (num_entries > 0) {
        stateFree(pname, state);
        /* Create a new buffer. */
        buffer = malloc(STATE_DATA_ALLOCATE(type, num_entries));
        if (buffer == NULL) {
            icetRaiseError("Could not allocate memory for state variable.",
                           ICET_OUT_OF_MEMORY);
            return NULL;
        }
#ifdef ICET_STATE_CHECK_MEM
        /* Skip past padding. */
        buffer = (IceTByte *)buffer + STATE_PADDING_SIZE;
#endif

        state[pname].type = type;
        state[pname].num_entries = num_entries;
        state[pname].data = buffer;
        state[pname].mod_time = icetGetTimeStamp();

#ifdef ICET_STATE_CHECK_MEM
        /* Set padding data. */
        {
            IceTSizeType i;
            IceTByte *padding;
            padding = STATE_DATA_PRE_PADDING(pname, state);
            for (i = 0; i < STATE_PADDING_SIZE; i++) {
                padding[i] = g_pre_padding[i];
            }
            padding = STATE_DATA_POST_PADDING(pname, state);
            for (i = 0; i < STATE_PADDING_SIZE; i++) {
                padding[i] = g_post_padding[i];
            }
        }
#endif
    } else { /* num_entries <= 0 */
        buffer = NULL;

        state[pname].type = type;
        state[pname].num_entries = 0;
        state[pname].data = buffer;
        state[pname].mod_time = icetGetTimeStamp();
    }

#ifdef ICET_STATE_CHECK_MEM
    memset(buffer, 0xDC, STATE_DATA_WIDTH(type, num_entries));
#endif
    return buffer;
}