Exemplo n.º 1
0
static void
nv04_surface_copy_cpu(struct gl_context *ctx,
                      struct nouveau_surface *dst,
                      struct nouveau_surface *src,
                      int dx, int dy, int sx, int sy,
                      int w, int h)
{
    int x, y;
    get_offset_t get_dst = (dst->layout == SWIZZLED ?
                            get_swizzled_offset : get_linear_offset);
    get_offset_t get_src = (src->layout == SWIZZLED ?
                            get_swizzled_offset : get_linear_offset);
    void *dp, *sp;

    nouveau_bo_map(dst->bo, NOUVEAU_BO_WR, context_client(ctx));
    nouveau_bo_map(src->bo, NOUVEAU_BO_RD, context_client(ctx));

    dp = dst->bo->map + dst->offset;
    sp = src->bo->map + src->offset;

    for (y = 0; y < h; y++) {
        for (x = 0; x < w; x++) {
            memcpy(dp + get_dst(dst, dx + x, dy + y),
                   sp + get_src(src, sx + x, sy + y), dst->cpp);
        }
    }
}
Exemplo n.º 2
0
static void
nouveau_renderbuffer_map(struct gl_context *ctx,
			 struct gl_renderbuffer *rb,
			 GLuint x, GLuint y, GLuint w, GLuint h,
			 GLbitfield mode,
			 GLubyte **out_map,
			 GLint *out_stride)
{
	struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
	GLubyte *map;
	int stride;
	int flags = 0;

	if (mode & GL_MAP_READ_BIT)
		flags |= NOUVEAU_BO_RD;
	if (mode & GL_MAP_WRITE_BIT)
		flags |= NOUVEAU_BO_WR;

	nouveau_bo_map(s->bo, flags, context_client(ctx));

	map = s->bo->map;
	stride = s->pitch;

	if (rb->Name == 0) {
		map += stride * (rb->Height - 1);
		stride = -stride;
	}

	map += x * s->cpp;
	map += (int)y * stride;

	*out_map = map;
	*out_stride = stride;
}
Exemplo n.º 3
0
static void
renderbuffer_map_unmap(struct gl_context *ctx, struct gl_renderbuffer *rb,
		       GLboolean map)
{
	struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;

	if (map)
		nouveau_bo_map(s->bo, NOUVEAU_BO_RDWR, context_client(ctx));
}
Exemplo n.º 4
0
static void
init_dummy_texture(struct gl_context *ctx)
{
	struct nouveau_surface *s = &to_nv04_context(ctx)->dummy_texture;

	nouveau_surface_alloc(ctx, s, SWIZZLED,
			      NOUVEAU_BO_MAP | NOUVEAU_BO_VRAM,
			      MESA_FORMAT_ARGB8888, 1, 1);

	nouveau_bo_map(s->bo, NOUVEAU_BO_WR, context_client(ctx));
	*(uint32_t *)s->bo->map = 0xffffffff;
}
Exemplo n.º 5
0
static inline char *
get_bufferobj_map(struct gl_context *ctx, struct gl_buffer_object *obj,
		  unsigned flags)
{
	struct nouveau_bufferobj *nbo = to_nouveau_bufferobj(obj);
	void *map = NULL;

	if (nbo->sys) {
		map = nbo->sys;
	} else if (nbo->bo) {
		nouveau_bo_map(nbo->bo, flags, context_client(ctx));
		map = nbo->bo->map;
	}

	return map;
}
Exemplo n.º 6
0
static void
nouveau_finish(struct gl_context *ctx)
{
	struct nouveau_context *nctx = to_nouveau_context(ctx);
	struct nouveau_pushbuf *push = context_push(ctx);
	struct nouveau_pushbuf_refn refn =
		{ nctx->fence, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR };

	nouveau_flush(ctx);

	if (!nouveau_pushbuf_space(push, 16, 0, 0) &&
	    !nouveau_pushbuf_refn(push, &refn, 1)) {
		PUSH_DATA(push, 0);
		PUSH_KICK(push);
	}

	nouveau_bo_wait(nctx->fence, NOUVEAU_BO_RDWR, context_client(ctx));
}