diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-06-24 14:36:32 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-06-24 14:37:53 +0100 |
commit | 990499c6d98306b4eafeb6405ed209988da301a6 (patch) | |
tree | 42df610bab629b0d5e360a6fc88c2da9639784ab /src/sna/gen3_render.c | |
parent | f414ed4e40292e91e9c6850fb01a26334e6b43c7 (diff) |
sna/gen3: Allow gen3 to use smaller vbo if already available in cache
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/gen3_render.c')
-rw-r--r-- | src/sna/gen3_render.c | 73 |
1 files changed, 66 insertions, 7 deletions
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index c3134f44..3c87b366 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -531,6 +531,7 @@ gen3_emit_composite_primitive_affine_gradient(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = dst_x + r->width; v[1] = dst_y + r->height; @@ -596,6 +597,7 @@ gen3_emit_composite_primitive_identity_source(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[8] = v[4] = r->dst.x + op->dst.x; v[0] = v[4] + w; @@ -643,6 +645,7 @@ gen3_emit_composite_primitive_identity_source_no_offset(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[8] = v[4] = r->dst.x; v[9] = r->dst.y; @@ -693,6 +696,7 @@ gen3_emit_composite_primitive_affine_source(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = dst_x + r->width; v[5] = v[1] = dst_y + r->height; @@ -756,6 +760,7 @@ gen3_emit_composite_primitive_constant_identity_mask(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[8] = v[4] = r->dst.x + op->dst.x; v[0] = v[4] + w; @@ -781,6 +786,7 @@ gen3_emit_composite_primitive_constant_identity_mask_no_offset(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[8] = v[4] = r->dst.x; v[9] = r->dst.y; @@ -817,6 +823,7 @@ gen3_emit_composite_primitive_identity_source_mask(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 18; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = dst_x + w; v[1] = dst_y + h; @@ -862,6 +869,7 @@ gen3_emit_composite_primitive_affine_source_mask(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 18; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = dst_x + w; v[1] = dst_y + h; @@ -978,6 +986,7 @@ gen3_emit_composite_primitive_constant__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 6; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[4] = v[2] = r->dst.x + op->dst.x; v[5] = r->dst.y + op->dst.y; @@ -1013,6 +1022,7 @@ gen3_emit_composite_primitive_identity_gradient__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); x = r->dst.x + op->dst.x; y = r->dst.y + op->dst.y; @@ -1067,6 +1077,7 @@ gen3_emit_composite_primitive_affine_gradient__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = dst_x + r->width; v[1] = dst_y + r->height; @@ -1132,6 +1143,7 @@ gen3_emit_composite_primitive_identity_source__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[8] = v[4] = r->dst.x + op->dst.x; v[0] = v[4] + w; @@ -1179,6 +1191,7 @@ gen3_emit_composite_primitive_identity_source_no_offset__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[8] = v[4] = r->dst.x; v[9] = r->dst.y; @@ -1229,6 +1242,7 @@ gen3_emit_composite_primitive_affine_source__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = dst_x + r->width; v[5] = v[1] = dst_y + r->height; @@ -1292,6 +1306,7 @@ gen3_emit_composite_primitive_constant_identity_mask__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[8] = v[4] = r->dst.x + op->dst.x; v[0] = v[4] + w; @@ -1317,6 +1332,7 @@ gen3_emit_composite_primitive_constant_identity_mask_no_offset__sse2(struct sna v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 12; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[8] = v[4] = r->dst.x; v[9] = r->dst.y; @@ -1353,6 +1369,7 @@ gen3_emit_composite_primitive_identity_source_mask__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 18; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = dst_x + w; v[1] = dst_y + h; @@ -1398,6 +1415,7 @@ gen3_emit_composite_primitive_affine_source_mask__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 18; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = dst_x + w; v[1] = dst_y + h; @@ -2233,6 +2251,7 @@ static void gen3_vertex_flush(struct sna *sna) static int gen3_vertex_finish(struct sna *sna) { struct kgem_bo *bo; + unsigned hint, size; DBG(("%s: used=%d/%d, vbo active? %d\n", __FUNCTION__, sna->render.vertex_used, sna->render.vertex_size, @@ -2243,6 +2262,7 @@ static int gen3_vertex_finish(struct sna *sna) sna_vertex_wait__locked(&sna->render); + hint = CREATE_GTT_MAP; bo = sna->render.vbo; if (bo) { DBG(("%s: reloc = %d\n", __FUNCTION__, @@ -2260,17 +2280,29 @@ static int gen3_vertex_finish(struct sna *sna) sna->render.vbo = NULL; kgem_bo_destroy(&sna->kgem, bo); + hint |= CREATE_CACHED | CREATE_NO_THROTTLE; } + size = 256*1024; sna->render.vertices = NULL; - sna->render.vbo = kgem_create_linear(&sna->kgem, - 256*1024, CREATE_GTT_MAP); - if (sna->render.vbo) + sna->render.vbo = kgem_create_linear(&sna->kgem, size, hint); + while (sna->render.vbo == NULL && size > sizeof(sna->render.vertex_data)) { + size /= 2; + sna->render.vbo = kgem_create_linear(&sna->kgem, size, hint); + } + if (sna->render.vbo == NULL) + sna->render.vbo = kgem_create_linear(&sna->kgem, + 256*1024, CREATE_GTT_MAP); + if (sna->render.vbo && + kgem_check_bo(&sna->kgem, sna->render.vbo, NULL)) sna->render.vertices = kgem_bo_map(&sna->kgem, sna->render.vbo); if (sna->render.vertices == NULL) { - if (sna->render.vbo) + if (sna->render.vbo) { kgem_bo_destroy(&sna->kgem, sna->render.vbo); - sna->render.vbo = NULL; + sna->render.vbo = NULL; + } + sna->render.vertices = sna->render.vertex_data; + sna->render.vertex_size = ARRAY_SIZE(sna->render.vertex_data); return 0; } assert(sna->render.vbo->snoop == false); @@ -2280,8 +2312,14 @@ static int gen3_vertex_finish(struct sna *sna) sna->render.vertex_data, sizeof(float)*sna->render.vertex_used); } - sna->render.vertex_size = 64 * 1024 - 1; - return sna->render.vertex_size - sna->render.vertex_used; + + size = __kgem_bo_size(sna->render.vbo)/4; + if (size >= UINT16_MAX) + size = UINT16_MAX - 1; + assert(size > sna->render.vertex_used); + + sna->render.vertex_size = size; + return size - sna->render.vertex_used; } static void gen3_vertex_close(struct sna *sna) @@ -2580,6 +2618,7 @@ gen3_render_composite_boxes(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += nbox_this_time * op->floats_per_rect; + assert(sna->render.vertex_used <= sna->render.vertex_size); op->emit_boxes(op, box, nbox_this_time, v); box += nbox_this_time; @@ -2604,6 +2643,7 @@ gen3_render_composite_boxes__thread(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += nbox_this_time * op->floats_per_rect; + assert(sna->render.vertex_used <= sna->render.vertex_size); sna_vertex_acquire__locked(&sna->render); sna_vertex_unlock(&sna->render); @@ -3862,6 +3902,7 @@ gen3_emit_composite_spans_primitive_zero(struct sna *sna, { float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 6; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[1] = op->base.dst.y + box->y2; @@ -3901,6 +3942,7 @@ gen3_emit_composite_spans_primitive_zero_no_offset(struct sna *sna, { float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 6; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = box->x2; v[3] = v[1] = box->y2; @@ -3932,6 +3974,7 @@ gen3_emit_composite_spans_primitive_constant(struct sna *sna, { float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 9; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[6] = v[3] = op->base.dst.x + box->x1; @@ -3966,6 +4009,7 @@ gen3_emit_composite_spans_primitive_constant_no_offset(struct sna *sna, { float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 9; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = box->x2; v[6] = v[3] = box->x1; @@ -3999,6 +4043,7 @@ gen3_emit_composite_spans_primitive_identity_source(struct sna *sna, { float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 15; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[1] = op->base.dst.y + box->y2; @@ -4060,6 +4105,7 @@ gen3_emit_composite_spans_primitive_affine_source(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 15; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[6] = v[1] = op->base.dst.y + box->y2; @@ -4125,6 +4171,7 @@ gen3_emit_composite_spans_primitive_identity_gradient(struct sna *sna, { float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 15; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[1] = op->base.dst.y + box->y2; @@ -4184,6 +4231,7 @@ gen3_emit_composite_spans_primitive_constant__sse2(struct sna *sna, { float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 9; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[6] = v[3] = op->base.dst.x + box->x1; @@ -4229,6 +4277,7 @@ gen3_render_composite_spans_constant_box__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 9; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = box->x2; v[6] = v[3] = box->x1; @@ -4259,6 +4308,7 @@ gen3_render_composite_spans_constant_thread__sse2__boxes(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += nbox_this_time * 9; + assert(sna->render.vertex_used <= sna->render.vertex_size); sna_vertex_acquire__locked(&sna->render); sna_vertex_unlock(&sna->render); @@ -4287,6 +4337,7 @@ gen3_emit_composite_spans_primitive_constant__sse2__no_offset(struct sna *sna, { float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 9; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = box->x2; v[6] = v[3] = box->x1; @@ -4320,6 +4371,7 @@ gen3_emit_composite_spans_primitive_identity_source__sse2(struct sna *sna, { float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 15; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[1] = op->base.dst.y + box->y2; @@ -4380,6 +4432,7 @@ gen3_emit_composite_spans_primitive_affine_source__sse2(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 15; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[6] = v[1] = op->base.dst.y + box->y2; @@ -4445,6 +4498,7 @@ gen3_emit_composite_spans_primitive_identity_gradient__sse2(struct sna *sna, { float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 15; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[1] = op->base.dst.y + box->y2; @@ -4504,6 +4558,7 @@ gen3_emit_composite_spans_primitive_affine_gradient__sse2(struct sna *sna, PictTransform *transform = op->base.src.transform; float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 15; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[1] = op->base.dst.y + box->y2; @@ -4577,6 +4632,7 @@ gen3_emit_composite_spans_primitive_affine_gradient(struct sna *sna, PictTransform *transform = op->base.src.transform; float *v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 15; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = op->base.dst.x + box->x2; v[1] = op->base.dst.y + box->y2; @@ -4676,6 +4732,7 @@ gen3_render_composite_spans_constant_box(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += 9; + assert(sna->render.vertex_used <= sna->render.vertex_size); v[0] = box->x2; v[6] = v[3] = box->x1; @@ -4706,6 +4763,7 @@ gen3_render_composite_spans_constant_thread_boxes(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += nbox_this_time * 9; + assert(sna->render.vertex_used <= sna->render.vertex_size); sna_vertex_acquire__locked(&sna->render); sna_vertex_unlock(&sna->render); @@ -4795,6 +4853,7 @@ gen3_render_composite_spans_boxes__thread(struct sna *sna, v = sna->render.vertices + sna->render.vertex_used; sna->render.vertex_used += nbox_this_time * op->base.floats_per_rect; + assert(sna->render.vertex_used <= sna->render.vertex_size); sna_vertex_acquire__locked(&sna->render); sna_vertex_unlock(&sna->render); |