summaryrefslogtreecommitdiff
path: root/src/radeon_vbo.h
blob: a8c70b304891f5a4b0f4c272462722f826c0c56a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

#ifndef RADEON_VBO_H
#define RADEON_VBO_H

extern void r600_vb_no_space(ScrnInfoPtr pScrn, int vert_size);
extern void radeon_vbo_init_lists(ScrnInfoPtr pScrn);
extern void radeon_vbo_free_lists(ScrnInfoPtr pScrn);
extern void radeon_vbo_flush_bos(ScrnInfoPtr pScrn);
extern void radeon_vbo_get(ScrnInfoPtr pScrn);
extern void radeon_vbo_put(ScrnInfoPtr pScrn);

static inline void radeon_vbo_check(ScrnInfoPtr pScrn, int vert_size)
{
    RADEONInfoPtr info = RADEONPTR(pScrn);
    struct radeon_accel_state *accel_state = info->accel_state;

    if ((accel_state->vb_offset + (3 * vert_size)) > accel_state->vb_total) {
	r600_vb_no_space(pScrn, vert_size);
    }
}

static inline void *
radeon_vbo_space(ScrnInfoPtr pScrn, int vert_size)
{
    RADEONInfoPtr info = RADEONPTR(pScrn);
    struct radeon_accel_state *accel_state = info->accel_state;
    void *vb;
    
    /* we've ran out of space in the vertex buffer - need to get a
       new one */
    if ((accel_state->vb_offset + (3 * vert_size)) > accel_state->vb_total) {
	r600_vb_no_space(pScrn, vert_size);
    }
    accel_state->vb_op_vert_size = vert_size;
#if defined(XF86DRM_MODE)
    if (info->cs) {
	int ret;
	struct radeon_bo *bo = accel_state->vb_bo;

	if (!bo->ptr) {
	    ret = radeon_bo_map(bo, 1);
	    if (ret) {
		FatalError("Failed to map vb %d\n", ret);
		return NULL;
	    }
	}
	vb = (pointer)((char *)bo->ptr + accel_state->vb_offset);
    } else
#endif
	vb = (pointer)((char *)accel_state->vb_ptr + accel_state->vb_offset);
    return vb;
}

static inline void radeon_vbo_commit(ScrnInfoPtr pScrn)
{
    RADEONInfoPtr info = RADEONPTR(pScrn);
    struct radeon_accel_state *accel_state = info->accel_state;

    accel_state->vb_offset += 3 * accel_state->vb_op_vert_size;
}

#endif