diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-03-02 14:34:23 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-03-02 14:34:23 +0000 |
commit | 1c653786895fc30be0e88455ce5f9caf9adc835d (patch) | |
tree | 88246622b610bb07cf47361bf49f4c383eabc28e /src/sna | |
parent | 29ec36ff063472e0744af99aa81ed5ad8e291a36 (diff) |
sna: Pass usage hint for creating linear buffers
As we wish to immediate map the vertices buffers, it is beneficial to
search the linear cache for an existing mapping to reuse first.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna')
-rw-r--r-- | src/sna/gen3_render.c | 5 | ||||
-rw-r--r-- | src/sna/gen4_render.c | 6 | ||||
-rw-r--r-- | src/sna/gen5_render.c | 6 | ||||
-rw-r--r-- | src/sna/gen6_render.c | 8 | ||||
-rw-r--r-- | src/sna/gen7_render.c | 8 | ||||
-rw-r--r-- | src/sna/kgem.c | 11 | ||||
-rw-r--r-- | src/sna/kgem.h | 2 | ||||
-rw-r--r-- | src/sna/sna_gradient.c | 8 | ||||
-rw-r--r-- | src/sna/sna_stream.c | 2 | ||||
-rw-r--r-- | src/sna/sna_video.c | 3 | ||||
-rw-r--r-- | src/sna/sna_video_textured.c | 3 |
11 files changed, 39 insertions, 23 deletions
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index bd1eddd2..78c7ea0a 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -1642,7 +1642,8 @@ static int gen3_vertex_finish(struct sna *sna) } sna->render.vertices = NULL; - sna->render.vbo = kgem_create_linear(&sna->kgem, 256*1024); + sna->render.vbo = kgem_create_linear(&sna->kgem, + 256*1024, CREATE_GTT_MAP); if (sna->render.vbo) sna->render.vertices = kgem_bo_map(&sna->kgem, sna->render.vbo); if (sna->render.vertices == NULL) { @@ -1702,7 +1703,7 @@ static void gen3_vertex_close(struct sna *sna) DBG(("%s: new vbo: %d\n", __FUNCTION__, sna->render.vertex_used)); bo = kgem_create_linear(&sna->kgem, - 4*sna->render.vertex_used); + 4*sna->render.vertex_used, 0); if (bo) kgem_bo_write(&sna->kgem, bo, sna->render.vertex_data, diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index 6ba59ee6..97af7fc9 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -398,7 +398,8 @@ static int gen4_vertex_finish(struct sna *sna) } sna->render.vertices = NULL; - sna->render.vbo = kgem_create_linear(&sna->kgem, 256*1024); + sna->render.vbo = kgem_create_linear(&sna->kgem, + 256*1024, CREATE_GTT_MAP); if (sna->render.vbo) sna->render.vertices = kgem_bo_map(&sna->kgem, sna->render.vbo); if (sna->render.vertices == NULL) { @@ -442,7 +443,8 @@ static void gen4_vertex_close(struct sna *sna) bo = NULL; sna->kgem.nbatch += sna->render.vertex_used; } else { - bo = kgem_create_linear(&sna->kgem, 4*sna->render.vertex_used); + bo = kgem_create_linear(&sna->kgem, + 4*sna->render.vertex_used, 0); if (bo && !kgem_bo_write(&sna->kgem, bo, sna->render.vertex_data, 4*sna->render.vertex_used)) { diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index bccd3437..18325b51 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -390,7 +390,8 @@ static int gen5_vertex_finish(struct sna *sna) } sna->render.vertices = NULL; - sna->render.vbo = kgem_create_linear(&sna->kgem, 256*1024); + sna->render.vbo = kgem_create_linear(&sna->kgem, + 256*1024, CREATE_GTT_MAP); if (sna->render.vbo) sna->render.vertices = kgem_bo_map(&sna->kgem, sna->render.vbo); if (sna->render.vertices == NULL) { @@ -447,7 +448,8 @@ static void gen5_vertex_close(struct sna *sna) bo = NULL; sna->kgem.nbatch += sna->render.vertex_used; } else { - bo = kgem_create_linear(&sna->kgem, 4*sna->render.vertex_used); + bo = kgem_create_linear(&sna->kgem, + 4*sna->render.vertex_used, 0); if (bo && !kgem_bo_write(&sna->kgem, bo, sna->render.vertex_data, 4*sna->render.vertex_used)) { diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 439fb521..71c0046e 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -964,9 +964,10 @@ static int gen6_vertex_finish(struct sna *sna) } sna->render.vertices = NULL; - sna->render.vbo = kgem_create_linear(&sna->kgem, 256*1024); + sna->render.vbo = kgem_create_linear(&sna->kgem, + 256*1024, CREATE_GTT_MAP); if (sna->render.vbo) - sna->render.vertices = kgem_bo_map__cpu(&sna->kgem, sna->render.vbo); + sna->render.vertices = kgem_bo_map(&sna->kgem, sna->render.vbo); if (sna->render.vertices == NULL) { kgem_bo_destroy(&sna->kgem, sna->render.vbo); sna->render.vbo = NULL; @@ -1024,7 +1025,8 @@ static void gen6_vertex_close(struct sna *sna) bo = NULL; sna->kgem.nbatch += sna->render.vertex_used; } else { - bo = kgem_create_linear(&sna->kgem, 4*sna->render.vertex_used); + bo = kgem_create_linear(&sna->kgem, + 4*sna->render.vertex_used, 0); if (bo && !kgem_bo_write(&sna->kgem, bo, sna->render.vertex_data, 4*sna->render.vertex_used)) { diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index e3d9757d..a401d94b 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -1065,9 +1065,10 @@ static int gen7_vertex_finish(struct sna *sna) } sna->render.vertices = NULL; - sna->render.vbo = kgem_create_linear(&sna->kgem, 256*1024); + sna->render.vbo = kgem_create_linear(&sna->kgem, + 256*1024, CREATE_GTT_MAP); if (sna->render.vbo) - sna->render.vertices = kgem_bo_map__cpu(&sna->kgem, sna->render.vbo); + sna->render.vertices = kgem_bo_map(&sna->kgem, sna->render.vbo); if (sna->render.vertices == NULL) { kgem_bo_destroy(&sna->kgem, sna->render.vbo); sna->render.vbo = NULL; @@ -1121,7 +1122,8 @@ static void gen7_vertex_close(struct sna *sna) bo = NULL; sna->kgem.nbatch += sna->render.vertex_used; } else { - bo = kgem_create_linear(&sna->kgem, 4*sna->render.vertex_used); + bo = kgem_create_linear(&sna->kgem, + 4*sna->render.vertex_used, 0); if (bo && !kgem_bo_write(&sna->kgem, bo, sna->render.vertex_data, 4*sna->render.vertex_used)) { diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 5776a4fe..1ec9fb4c 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1687,7 +1687,7 @@ void _kgem_submit(struct kgem *kgem) size = compact_batch_surface(kgem); else size = kgem->nbatch * sizeof(kgem->batch[0]); - rq->bo = kgem_create_linear(kgem, size); + rq->bo = kgem_create_linear(kgem, size, 0); if (rq->bo) { uint32_t handle = rq->bo->handle; int i; @@ -2188,15 +2188,20 @@ struct kgem_bo *kgem_create_for_name(struct kgem *kgem, uint32_t name) return bo; } -struct kgem_bo *kgem_create_linear(struct kgem *kgem, int size) +struct kgem_bo *kgem_create_linear(struct kgem *kgem, int size, unsigned flags) { struct kgem_bo *bo; uint32_t handle; DBG(("%s(%d)\n", __FUNCTION__, size)); + if (flags & CREATE_GTT_MAP && kgem->has_llc) { + flags &= ~CREATE_GTT_MAP; + flags |= CREATE_CPU_MAP; + } + size = (size + PAGE_SIZE - 1) / PAGE_SIZE; - bo = search_linear_cache(kgem, size, CREATE_INACTIVE); + bo = search_linear_cache(kgem, size, CREATE_INACTIVE | flags); if (bo) return kgem_bo_reference(bo); diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 446ac681..9abb72af 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -192,7 +192,7 @@ struct kgem_bo *kgem_create_map(struct kgem *kgem, struct kgem_bo *kgem_create_for_name(struct kgem *kgem, uint32_t name); -struct kgem_bo *kgem_create_linear(struct kgem *kgem, int size); +struct kgem_bo *kgem_create_linear(struct kgem *kgem, int size, unsigned flags); struct kgem_bo *kgem_create_proxy(struct kgem_bo *target, int offset, int length); diff --git a/src/sna/sna_gradient.c b/src/sna/sna_gradient.c index 96841dd4..943cbf96 100644 --- a/src/sna/sna_gradient.c +++ b/src/sna/sna_gradient.c @@ -168,7 +168,7 @@ sna_render_get_gradient(struct sna *sna, width/2, pixman_image_get_data(image)[width/2], width-1, pixman_image_get_data(image)[width-1])); - bo = kgem_create_linear(&sna->kgem, width*4); + bo = kgem_create_linear(&sna->kgem, width*4, 0); if (!bo) { pixman_image_unref(image); return NULL; @@ -248,7 +248,7 @@ sna_render_finish_solid(struct sna *sna, bool force) DBG(("sna_render_finish_solid reset\n")); - cache->cache_bo = kgem_create_linear(&sna->kgem, sizeof(cache->color)); + cache->cache_bo = kgem_create_linear(&sna->kgem, sizeof(cache->color), 0); cache->bo[0] = kgem_create_proxy(cache->cache_bo, 0, sizeof(uint32_t)); cache->bo[0]->pitch = 4; if (force) @@ -316,7 +316,7 @@ static Bool sna_alpha_cache_init(struct sna *sna) DBG(("%s\n", __FUNCTION__)); - cache->cache_bo = kgem_create_linear(&sna->kgem, sizeof(color)); + cache->cache_bo = kgem_create_linear(&sna->kgem, sizeof(color), 0); if (!cache->cache_bo) return FALSE; @@ -338,7 +338,7 @@ static Bool sna_solid_cache_init(struct sna *sna) DBG(("%s\n", __FUNCTION__)); cache->cache_bo = - kgem_create_linear(&sna->kgem, sizeof(cache->color)); + kgem_create_linear(&sna->kgem, sizeof(cache->color), 0); if (!cache->cache_bo) return FALSE; diff --git a/src/sna/sna_stream.c b/src/sna/sna_stream.c index d6d817d3..7f05d210 100644 --- a/src/sna/sna_stream.c +++ b/src/sna/sna_stream.c @@ -87,7 +87,7 @@ struct kgem_bo *sna_static_stream_fini(struct sna *sna, DBG(("uploaded %d bytes of static state\n", stream->used)); - bo = kgem_create_linear(&sna->kgem, stream->used); + bo = kgem_create_linear(&sna->kgem, stream->used, 0); if (bo && !kgem_bo_write(&sna->kgem, bo, stream->data, stream->used)) { kgem_bo_destroy(&sna->kgem, bo); return NULL; diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index ebc3860f..56cf260f 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -104,7 +104,8 @@ sna_video_buffer(struct sna *sna, sna_video_free_buffers(sna, video); if (video->buf == NULL) - video->buf = kgem_create_linear(&sna->kgem, frame->size); + video->buf = kgem_create_linear(&sna->kgem, frame->size, + CREATE_GTT_MAP); return video->buf; } diff --git a/src/sna/sna_video_textured.c b/src/sna/sna_video_textured.c index 1aaf9723..a71751c6 100644 --- a/src/sna/sna_video_textured.c +++ b/src/sna/sna_video_textured.c @@ -273,7 +273,8 @@ sna_video_textured_put_image(ScrnInfoPtr scrn, assert(kgem_bo_size(frame.bo) >= frame.size); } else { - frame.bo = kgem_create_linear(&sna->kgem, frame.size); + frame.bo = kgem_create_linear(&sna->kgem, frame.size, + CREATE_GTT_MAP); if (frame.bo == NULL) { DBG(("%s: failed to allocate bo\n", __FUNCTION__)); return BadAlloc; |