Exemplo n.º 1
0
static GLboolean
nouveau_bufferobj_data(struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
                       const GLvoid *data, GLenum usage,
                       struct gl_buffer_object *obj)
{
    struct nouveau_bufferobj *nbo = to_nouveau_bufferobj(obj);
    int ret;

    obj->Size = size;
    obj->Usage = usage;

    /* Free previous storage */
    nouveau_bo_ref(NULL, &nbo->bo);
    FREE(nbo->sys);

    if (target == GL_ELEMENT_ARRAY_BUFFER_ARB ||
            (size < 512 && usage == GL_DYNAMIC_DRAW_ARB) ||
            context_chipset(ctx) < 0x10) {
        /* Heuristic: keep it in system ram */
        nbo->sys = MALLOC(size);

    } else {
        /* Get a hardware BO */
        ret = nouveau_bo_new(context_dev(ctx),
                             NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
                             size, &nbo->bo);
        assert(!ret);
    }

    if (data)
        memcpy(get_bufferobj_map(obj, NOUVEAU_BO_WR), data, size);

    return GL_TRUE;
}
Exemplo n.º 2
0
static void
nouveau_bufferobj_get_subdata(struct gl_context *ctx, GLintptrARB offset,
                              GLsizeiptrARB size, GLvoid *data,
                              struct gl_buffer_object *obj)
{
    memcpy(data, get_bufferobj_map(obj, NOUVEAU_BO_RD) + offset, size);
}
Exemplo n.º 3
0
static void *
nouveau_bufferobj_map_range(struct gl_context *ctx, GLintptr offset,
                            GLsizeiptr length, GLbitfield access,
                            struct gl_buffer_object *obj)
{
    unsigned flags = 0;
    char *map;

    assert(!obj->Pointer);

    if (access & GL_MAP_READ_BIT)
        flags |= NOUVEAU_BO_RD;
    if (access & GL_MAP_WRITE_BIT)
        flags |= NOUVEAU_BO_WR;
    if (access & GL_MAP_UNSYNCHRONIZED_BIT)
        flags |= NOUVEAU_BO_NOSYNC;

    map = get_bufferobj_map(obj, flags);
    if (!map)
        return NULL;

    obj->Pointer = map + offset;
    obj->Offset = offset;
    obj->Length = length;
    obj->AccessFlags = access;

    return obj->Pointer;
}
Exemplo n.º 4
0
static void
nouveau_bufferobj_subdata(struct gl_context *ctx, GLintptrARB offset,
			  GLsizeiptrARB size, const GLvoid *data,
			  struct gl_buffer_object *obj)
{
	memcpy(get_bufferobj_map(ctx, obj, NOUVEAU_BO_WR) + offset, data, size);
}