diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-20 12:00:00 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-20 19:11:04 +0000 |
commit | 0f84ecfc3cd7dfe7f43ff99a6498d2ceccd90225 (patch) | |
tree | a78f7d5a969afc132fe838ef6bc7a77c258f26e6 /src/sna/gen6_render.c | |
parent | 1f4ede0ef8f8a8d07e11781ad05617ecdfcd3faf (diff) |
sna/gen4+: Amalgamate all the gen4-7 vertex buffer emission
Having reduced all the vb code for these generations to the same set of
routines, we can refactor them into a single set of functions.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/gen6_render.c')
-rw-r--r-- | src/sna/gen6_render.c | 727 |
1 files changed, 35 insertions, 692 deletions
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 5a60787d..647ef503 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -42,6 +42,7 @@ #include "brw/brw.h" #include "gen6_render.h" +#include "gen4_vertex.h" #define NO_COMPOSITE 0 #define NO_COMPOSITE_SPANS 0 @@ -947,155 +948,6 @@ static void gen6_magic_ca_pass(struct sna *sna, state->last_primitive = sna->kgem.nbatch; } -static void gen6_vertex_flush(struct sna *sna) -{ - assert(sna->render_state.gen6.vertex_offset); - - DBG(("%s[%x] = %d\n", __FUNCTION__, - 4*sna->render_state.gen6.vertex_offset, - sna->render.vertex_index - sna->render.vertex_start)); - sna->kgem.batch[sna->render_state.gen6.vertex_offset] = - sna->render.vertex_index - sna->render.vertex_start; - sna->render_state.gen6.vertex_offset = 0; -} - -static int gen6_vertex_finish(struct sna *sna) -{ - struct kgem_bo *bo; - unsigned int i; - - DBG(("%s: used=%d / %d\n", __FUNCTION__, - sna->render.vertex_used, sna->render.vertex_size)); - assert(sna->render.vertex_used); - assert(sna->render.nvertex_reloc); - - /* Note: we only need dword alignment (currently) */ - - bo = sna->render.vbo; - if (bo) { - if (sna->render_state.gen6.vertex_offset) - gen6_vertex_flush(sna); - - for (i = 0; i < sna->render.nvertex_reloc; i++) { - DBG(("%s: reloc[%d] = %d\n", __FUNCTION__, - i, sna->render.vertex_reloc[i])); - - sna->kgem.batch[sna->render.vertex_reloc[i]] = - kgem_add_reloc(&sna->kgem, - sna->render.vertex_reloc[i], bo, - I915_GEM_DOMAIN_VERTEX << 16, - 0); - } - - sna->render.nvertex_reloc = 0; - sna->render.vertex_used = 0; - sna->render.vertex_index = 0; - sna->render.vbo = NULL; - sna->render_state.gen6.vb_id = 0; - - kgem_bo_destroy(&sna->kgem, bo); - } - - sna->render.vertices = NULL; - 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) { - if (sna->render.vbo) - kgem_bo_destroy(&sna->kgem, sna->render.vbo); - sna->render.vbo = NULL; - return 0; - } - - DBG(("%s: create vbo handle=%d\n", __FUNCTION__, sna->render.vbo->handle)); - - kgem_bo_sync__cpu(&sna->kgem, sna->render.vbo); - if (sna->render.vertex_used) { - DBG(("%s: copying initial buffer x %d to handle=%d\n", - __FUNCTION__, - sna->render.vertex_used, - sna->render.vbo->handle)); - memcpy(sna->render.vertices, - 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; -} - -static void gen6_vertex_close(struct sna *sna) -{ - struct kgem_bo *bo, *free_bo = NULL; - unsigned int i, delta = 0; - - assert(sna->render_state.gen6.vertex_offset == 0); - - if (!sna->render_state.gen6.vb_id) - return; - - DBG(("%s: used=%d, vbo active? %d\n", - __FUNCTION__, sna->render.vertex_used, sna->render.vbo ? sna->render.vbo->handle : 0)); - - bo = sna->render.vbo; - if (bo) { - if (sna->render.vertex_size - sna->render.vertex_used < 64) { - DBG(("%s: discarding vbo (full), handle=%d\n", __FUNCTION__, sna->render.vbo->handle)); - sna->render.vbo = NULL; - sna->render.vertices = sna->render.vertex_data; - sna->render.vertex_size = ARRAY_SIZE(sna->render.vertex_data); - free_bo = bo; - } - } else { - if (sna->kgem.nbatch + sna->render.vertex_used <= sna->kgem.surface) { - DBG(("%s: copy to batch: %d @ %d\n", __FUNCTION__, - sna->render.vertex_used, sna->kgem.nbatch)); - memcpy(sna->kgem.batch + sna->kgem.nbatch, - sna->render.vertex_data, - sna->render.vertex_used * 4); - delta = sna->kgem.nbatch * 4; - bo = NULL; - sna->kgem.nbatch += sna->render.vertex_used; - } else { - bo = kgem_create_linear(&sna->kgem, - 4*sna->render.vertex_used, - CREATE_NO_THROTTLE); - if (bo && !kgem_bo_write(&sna->kgem, bo, - sna->render.vertex_data, - 4*sna->render.vertex_used)) { - kgem_bo_destroy(&sna->kgem, bo); - bo = NULL; - } - DBG(("%s: new vbo: %d\n", __FUNCTION__, - sna->render.vertex_used)); - free_bo = bo; - } - } - - assert(sna->render.nvertex_reloc); - for (i = 0; i < sna->render.nvertex_reloc; i++) { - DBG(("%s: reloc[%d] = %d\n", __FUNCTION__, - i, sna->render.vertex_reloc[i])); - - sna->kgem.batch[sna->render.vertex_reloc[i]] = - kgem_add_reloc(&sna->kgem, - sna->render.vertex_reloc[i], bo, - I915_GEM_DOMAIN_VERTEX << 16, - delta); - } - sna->render.nvertex_reloc = 0; - - if (sna->render.vbo == NULL) { - sna->render.vertex_used = 0; - sna->render.vertex_index = 0; - assert(sna->render.vertices == sna->render.vertex_data); - assert(sna->render.vertex_size == ARRAY_SIZE(sna->render.vertex_data)); - } - - if (free_bo) - kgem_bo_destroy(&sna->kgem, free_bo); -} - typedef struct gen6_surface_state_padded { struct gen6_surface_state state; char pad[32 - sizeof(struct gen6_surface_state)]; @@ -1259,293 +1111,6 @@ gen6_bind_bo(struct sna *sna, return offset * sizeof(uint32_t); } -fastcall static void -gen6_emit_composite_primitive_solid(struct sna *sna, - const struct sna_composite_op *op, - const struct sna_composite_rectangles *r) -{ - float *v; - union { - struct sna_coordinate p; - float f; - } dst; - - DBG(("%s: [%d+9] = (%d, %d)x(%d, %d)\n", __FUNCTION__, - sna->render.vertex_used, r->dst.x, r->dst.y, r->width, r->height)); - - v = sna->render.vertices + sna->render.vertex_used; - sna->render.vertex_used += 9; - assert(sna->render.vertex_used <= sna->render.vertex_size); - assert(!too_large(op->dst.x + r->dst.x + r->width, - op->dst.y + r->dst.y + r->height)); - - dst.p.x = r->dst.x + r->width; - dst.p.y = r->dst.y + r->height; - v[0] = dst.f; - dst.p.x = r->dst.x; - v[3] = dst.f; - dst.p.y = r->dst.y; - v[6] = dst.f; - - v[5] = v[2] = v[1] = 1.; - v[8] = v[7] = v[4] = 0.; -} - -fastcall static void -gen6_emit_composite_primitive_identity_source(struct sna *sna, - const struct sna_composite_op *op, - const struct sna_composite_rectangles *r) -{ - union { - struct sna_coordinate p; - float f; - } dst; - float *v; - - v = sna->render.vertices + sna->render.vertex_used; - sna->render.vertex_used += 9; - - dst.p.x = r->dst.x + r->width; - dst.p.y = r->dst.y + r->height; - v[0] = dst.f; - dst.p.x = r->dst.x; - v[3] = dst.f; - dst.p.y = r->dst.y; - v[6] = dst.f; - - v[7] = v[4] = (r->src.x + op->src.offset[0]) * op->src.scale[0]; - v[1] = v[4] + r->width * op->src.scale[0]; - - v[8] = (r->src.y + op->src.offset[1]) * op->src.scale[1]; - v[5] = v[2] = v[8] + r->height * op->src.scale[1]; -} - -fastcall static void -gen6_emit_composite_primitive_simple_source(struct sna *sna, - const struct sna_composite_op *op, - const struct sna_composite_rectangles *r) -{ - float *v; - union { - struct sna_coordinate p; - float f; - } dst; - - float xx = op->src.transform->matrix[0][0]; - float x0 = op->src.transform->matrix[0][2]; - float yy = op->src.transform->matrix[1][1]; - float y0 = op->src.transform->matrix[1][2]; - float sx = op->src.scale[0]; - float sy = op->src.scale[1]; - int16_t tx = op->src.offset[0]; - int16_t ty = op->src.offset[1]; - - v = sna->render.vertices + sna->render.vertex_used; - sna->render.vertex_used += 3*3; - - dst.p.x = r->dst.x + r->width; - dst.p.y = r->dst.y + r->height; - v[0] = dst.f; - v[1] = ((r->src.x + r->width + tx) * xx + x0) * sx; - v[5] = v[2] = ((r->src.y + r->height + ty) * yy + y0) * sy; - - dst.p.x = r->dst.x; - v[3] = dst.f; - v[7] = v[4] = ((r->src.x + tx) * xx + x0) * sx; - - dst.p.y = r->dst.y; - v[6] = dst.f; - v[8] = ((r->src.y + ty) * yy + y0) * sy; -} - -fastcall static void -gen6_emit_composite_primitive_affine_source(struct sna *sna, - const struct sna_composite_op *op, - const struct sna_composite_rectangles *r) -{ - union { - struct sna_coordinate p; - float f; - } dst; - float *v; - - v = sna->render.vertices + sna->render.vertex_used; - sna->render.vertex_used += 9; - - dst.p.x = r->dst.x + r->width; - dst.p.y = r->dst.y + r->height; - v[0] = dst.f; - _sna_get_transformed_coordinates(op->src.offset[0] + r->src.x + r->width, - op->src.offset[1] + r->src.y + r->height, - op->src.transform, - &v[1], &v[2]); - v[1] *= op->src.scale[0]; - v[2] *= op->src.scale[1]; - - dst.p.x = r->dst.x; - v[3] = dst.f; - _sna_get_transformed_coordinates(op->src.offset[0] + r->src.x, - op->src.offset[1] + r->src.y + r->height, - op->src.transform, - &v[4], &v[5]); - v[4] *= op->src.scale[0]; - v[5] *= op->src.scale[1]; - - dst.p.y = r->dst.y; - v[6] = dst.f; - _sna_get_transformed_coordinates(op->src.offset[0] + r->src.x, - op->src.offset[1] + r->src.y, - op->src.transform, - &v[7], &v[8]); - v[7] *= op->src.scale[0]; - v[8] *= op->src.scale[1]; -} - -fastcall static void -gen6_emit_composite_primitive_identity_mask(struct sna *sna, - const struct sna_composite_op *op, - const struct sna_composite_rectangles *r) -{ - union { - struct sna_coordinate p; - float f; - } dst; - float msk_x, msk_y; - float w, h; - float *v; - - msk_x = r->mask.x + op->mask.offset[0]; - msk_y = r->mask.y + op->mask.offset[1]; - w = r->width; - h = r->height; - - v = sna->render.vertices + sna->render.vertex_used; - sna->render.vertex_used += 15; - - dst.p.x = r->dst.x + r->width; - dst.p.y = r->dst.y + r->height; - v[0] = dst.f; - v[3] = (msk_x + w) * op->mask.scale[0]; - v[9] = v[4] = (msk_y + h) * op->mask.scale[1]; - - dst.p.x = r->dst.x; - v[5] = dst.f; - v[13] = v[8] = msk_x * op->mask.scale[0]; - - dst.p.y = r->dst.y; - v[10] = dst.f; - v[14] = msk_y * op->mask.scale[1]; - - v[7] = v[2] = v[1] = 1; - v[12] = v[11] = v[6] = 0; -} - -fastcall static void -gen6_emit_composite_primitive_identity_source_mask(struct sna *sna, - const struct sna_composite_op *op, - const struct sna_composite_rectangles *r) -{ - union { - struct sna_coordinate p; - float f; - } dst; - float src_x, src_y; - float msk_x, msk_y; - float w, h; - float *v; - - src_x = r->src.x + op->src.offset[0]; - src_y = r->src.y + op->src.offset[1]; - msk_x = r->mask.x + op->mask.offset[0]; - msk_y = r->mask.y + op->mask.offset[1]; - w = r->width; - h = r->height; - - v = sna->render.vertices + sna->render.vertex_used; - sna->render.vertex_used += 15; - - dst.p.x = r->dst.x + r->width; - dst.p.y = r->dst.y + r->height; - v[0] = dst.f; - v[1] = (src_x + w) * op->src.scale[0]; - v[2] = (src_y + h) * op->src.scale[1]; - v[3] = (msk_x + w) * op->mask.scale[0]; - v[4] = (msk_y + h) * op->mask.scale[1]; - - dst.p.x = r->dst.x; - v[5] = dst.f; - v[6] = src_x * op->src.scale[0]; - v[7] = v[2]; - v[8] = msk_x * op->mask.scale[0]; - v[9] = v[4]; - - dst.p.y = r->dst.y; - v[10] = dst.f; - v[11] = v[6]; - v[12] = src_y * op->src.scale[1]; - v[13] = v[8]; - v[14] = msk_y * op->mask.scale[1]; -} - -inline static void -gen6_emit_composite_texcoord(struct sna *sna, - const struct sna_composite_channel *channel, - int16_t x, int16_t y) -{ - x += channel->offset[0]; - y += channel->offset[1]; - - if (channel->is_affine) { - float s, t; - - sna_get_transformed_coordinates(x, y, - channel->transform, - &s, &t); - OUT_VERTEX_F(s * channel->scale[0]); - OUT_VERTEX_F(t * channel->scale[1]); - } else { - float s, t, w; - - sna_get_transformed_coordinates_3d(x, y, - channel->transform, - &s, &t, &w); - OUT_VERTEX_F(s * channel->scale[0]); - OUT_VERTEX_F(t * channel->scale[1]); - OUT_VERTEX_F(w); - } -} - -static void -gen6_emit_composite_vertex(struct sna *sna, - const struct sna_composite_op *op, - int16_t srcX, int16_t srcY, - int16_t mskX, int16_t mskY, - int16_t dstX, int16_t dstY) -{ - OUT_VERTEX(dstX, dstY); - gen6_emit_composite_texcoord(sna, &op->src, srcX, srcY); - gen6_emit_composite_texcoord(sna, &op->mask, mskX, mskY); -} - -fastcall static void -gen6_emit_composite_primitive(struct sna *sna, - const struct sna_composite_op *op, - const struct sna_composite_rectangles *r) -{ - gen6_emit_composite_vertex(sna, op, - r->src.x + r->width, r->src.y + r->height, - r->mask.x + r->width, r->mask.y + r->height, - r->dst.x + r->width, r->dst.y + r->height); - gen6_emit_composite_vertex(sna, op, - r->src.x, r->src.y + r->height, - r->mask.x, r->mask.y + r->height, - r->dst.x, r->dst.y + r->height); - gen6_emit_composite_vertex(sna, op, - r->src.x, r->src.y, - r->mask.x, r->mask.y, - r->dst.x, r->dst.y); -} - static void gen6_emit_vertex_buffer(struct sna *sna, const struct sna_composite_op *op) { @@ -1559,7 +1124,7 @@ static void gen6_emit_vertex_buffer(struct sna *sna, OUT_BATCH(~0); /* max address: disabled */ OUT_BATCH(0); - sna->render_state.gen6.vb_id |= 1 << id; + sna->render.vb_id |= 1 << id; } static void gen6_emit_primitive(struct sna *sna) @@ -1569,7 +1134,7 @@ static void gen6_emit_primitive(struct sna *sna) __FUNCTION__, sna->render.vertex_start, sna->render.vertex_index)); - sna->render_state.gen6.vertex_offset = sna->kgem.nbatch - 5; + sna->render.vertex_offset = sna->kgem.nbatch - 5; return; } @@ -1578,7 +1143,7 @@ static void gen6_emit_primitive(struct sna *sna) _3DPRIM_RECTLIST << GEN6_3DPRIMITIVE_TOPOLOGY_SHIFT | 0 << 9 | 4); - sna->render_state.gen6.vertex_offset = sna->kgem.nbatch; + sna->render.vertex_offset = sna->kgem.nbatch; OUT_BATCH(0); /* vertex count, to be filled in later */ OUT_BATCH(sna->render.vertex_index); OUT_BATCH(1); /* single instance */ @@ -1598,12 +1163,12 @@ static bool gen6_rectangle_begin(struct sna *sna, int ndwords; ndwords = op->need_magic_ca_pass ? 60 : 6; - if ((sna->render_state.gen6.vb_id & id) == 0) + if ((sna->render.vb_id & id) == 0) ndwords += 5; if (!kgem_check_batch(&sna->kgem, ndwords)) return false; - if ((sna->render_state.gen6.vb_id & id) == 0) + if ((sna->render.vb_id & id) == 0) gen6_emit_vertex_buffer(sna, op); gen6_emit_primitive(sna); @@ -1615,15 +1180,15 @@ static int gen6_get_rectangles__flush(struct sna *sna, { if (!kgem_check_batch(&sna->kgem, op->need_magic_ca_pass ? 65 : 5)) return 0; - if (!kgem_check_exec(&sna->kgem, 1)) + if (!kgem_check_exec(&sna->kgem, 2)) return 0; - if (!kgem_check_reloc(&sna->kgem, 2)) + if (!kgem_check_reloc(&sna->kgem, 4)) return 0; if (op->need_magic_ca_pass && sna->render.vbo) return 0; - return gen6_vertex_finish(sna); + return gen4_vertex_finish(sna); } inline static int gen6_get_rectangles(struct sna *sna, @@ -1643,7 +1208,7 @@ start: goto flush; } - if (unlikely(sna->render_state.gen6.vertex_offset == 0 && + if (unlikely(sna->render.vertex_offset == 0 && !gen6_rectangle_begin(sna, op))) goto flush; @@ -1655,8 +1220,8 @@ start: return want; flush: - if (sna->render_state.gen6.vertex_offset) { - gen6_vertex_flush(sna); + if (sna->render.vertex_offset) { + gen4_vertex_flush(sna); gen6_magic_ca_pass(sna, op); } _kgem_submit(&sna->kgem); @@ -1681,16 +1246,6 @@ inline static uint32_t *gen6_composite_get_binding_table(struct sna *sna, return table; } -static uint32_t -gen6_choose_composite_vertex_buffer(const struct sna_composite_op *op) -{ - int id = 2 + !op->is_affine; - if (op->mask.bo) - id |= id << 2; - assert(id > 0 && id < 16); - return id; -} - static bool gen6_get_batch(struct sna *sna, const struct sna_composite_op *op) { @@ -1755,11 +1310,10 @@ static void gen6_emit_composite_state(struct sna *sna, static void gen6_align_vertex(struct sna *sna, const struct sna_composite_op *op) { - assert (sna->render_state.gen6.vertex_offset == 0); + assert (sna->render.vertex_offset == 0); if (op->floats_per_vertex != sna->render_state.gen6.floats_per_vertex) { if (sna->render.vertex_size - sna->render.vertex_used < 2*op->floats_per_rect) - /* XXX propagate failure */ - gen6_vertex_finish(sna); + gen4_vertex_finish(sna); DBG(("aligning vertex: was %d, now %d floats per vertex, %d->%d\n", sna->render_state.gen6.floats_per_vertex, @@ -2085,7 +1639,7 @@ gen6_render_video(struct sna *sna, } priv->clear = false; - gen6_vertex_flush(sna); + gen4_vertex_flush(sna); return true; } @@ -2335,8 +1889,8 @@ static void gen6_render_composite_done(struct sna *sna, { DBG(("%s\n", __FUNCTION__)); - if (sna->render_state.gen6.vertex_offset) { - gen6_vertex_flush(sna); + if (sna->render.vertex_offset) { + gen4_vertex_flush(sna); gen6_magic_ca_pass(sna, op); } @@ -2758,7 +2312,6 @@ gen6_render_composite(struct sna *sna, tmp->mask.filter = SAMPLER_FILTER_NEAREST; tmp->mask.repeat = SAMPLER_EXTEND_NONE; - tmp->prim_emit = gen6_emit_composite_primitive; if (mask) { if (mask->componentAlpha && PICT_FORMAT_RGB(mask->format)) { tmp->has_component_alpha = true; @@ -2798,44 +2351,8 @@ gen6_render_composite(struct sna *sna, } tmp->is_affine &= tmp->mask.is_affine; - - if (tmp->src.transform == NULL && tmp->mask.transform == NULL) { - if (tmp->src.is_solid) - tmp->prim_emit = gen6_emit_composite_primitive_identity_mask; - else - tmp->prim_emit = gen6_emit_composite_primitive_identity_source_mask; - } - - tmp->floats_per_vertex = 5 + 2 * !tmp->is_affine; - } else { - if (tmp->src.is_solid) { - DBG(("%s: choosing gen6_emit_composite_primitive_solid\n", - __FUNCTION__)); - tmp->prim_emit = gen6_emit_composite_primitive_solid; - if (tmp->src.is_opaque && op == PictOpOver) - tmp->op = PictOpSrc; - } else if (tmp->src.transform == NULL) { - DBG(("%s: choosing gen6_emit_composite_primitive_identity_source\n", - __FUNCTION__)); - tmp->prim_emit = gen6_emit_composite_primitive_identity_source; - } else if (tmp->src.is_affine) { - if (tmp->src.transform->matrix[0][1] == 0 && - tmp->src.transform->matrix[1][0] == 0) { - tmp->src.scale[0] /= tmp->src.transform->matrix[2][2]; - tmp->src.scale[1] /= tmp->src.transform->matrix[2][2]; - DBG(("%s: choosing gen6_emit_composite_primitive_simple_source\n", - __FUNCTION__)); - tmp->prim_emit = gen6_emit_composite_primitive_simple_source; - } else { - DBG(("%s: choosing gen6_emit_composite_primitive_affine_source\n", - __FUNCTION__)); - tmp->prim_emit = gen6_emit_composite_primitive_affine_source; - } - } - - tmp->floats_per_vertex = 3 + !tmp->is_affine; } - tmp->floats_per_rect = 3 * tmp->floats_per_vertex; + gen4_choose_composite_emitter(tmp); tmp->u.gen6.flags = GEN6_SET_FLAGS(SAMPLER_OFFSET(tmp->src.filter, @@ -2849,7 +2366,7 @@ gen6_render_composite(struct sna *sna, tmp->mask.bo != NULL, tmp->has_component_alpha, tmp->is_affine), - gen6_choose_composite_vertex_buffer(tmp)); + gen4_choose_composite_vertex_buffer(tmp)); tmp->blt = gen6_render_composite_blt; tmp->box = gen6_render_composite_box; @@ -2885,167 +2402,6 @@ cleanup_dst: } #if !NO_COMPOSITE_SPANS -inline static void -gen6_emit_composite_texcoord_affine(struct sna *sna, - const struct sna_composite_channel *channel, - int16_t x, int16_t y) -{ - float t[2]; - - sna_get_transformed_coordinates(x + channel->offset[0], - y + channel->offset[1], - channel->transform, - &t[0], &t[1]); - OUT_VERTEX_F(t[0] * channel->scale[0]); - OUT_VERTEX_F(t[1] * channel->scale[1]); -} - -inline static void -gen6_emit_composite_spans_vertex(struct sna *sna, - const struct sna_composite_spans_op *op, - int16_t x, int16_t y) -{ - OUT_VERTEX(x, y); - gen6_emit_composite_texcoord(sna, &op->base.src, x, y); -} - -fastcall static void -gen6_emit_composite_spans_primitive(struct sna *sna, - const struct sna_composite_spans_op *op, - const BoxRec *box, - float opacity) -{ - gen6_emit_composite_spans_vertex(sna, op, box->x2, box->y2); - OUT_VERTEX_F(opacity); - - gen6_emit_composite_spans_vertex(sna, op, box->x1, box->y2); - OUT_VERTEX_F(opacity); - - gen6_emit_composite_spans_vertex(sna, op, box->x1, box->y1); - OUT_VERTEX_F(opacity); -} - -fastcall static void -gen6_emit_composite_spans_solid(struct sna *sna, - const struct sna_composite_spans_op *op, - const BoxRec *box, - float opacity) -{ - OUT_VERTEX(box->x2, box->y2); - OUT_VERTEX_F(1); OUT_VERTEX_F(1); - OUT_VERTEX_F(opacity); - - OUT_VERTEX(box->x1, box->y2); - OUT_VERTEX_F(0); OUT_VERTEX_F(1); - OUT_VERTEX_F(opacity); - - OUT_VERTEX(box->x1, box->y1); - OUT_VERTEX_F(0); OUT_VERTEX_F(0); - OUT_VERTEX_F(opacity); -} - -fastcall static void -gen6_emit_composite_spans_identity(struct sna *sna, - const struct sna_composite_spans_op *op, - const BoxRec *box, - float opacity) -{ - float *v; - union { - struct sna_coordinate p; - float f; - } dst; - - float sx = op->base.src.scale[0]; - float sy = op->base.src.scale[1]; - int16_t tx = op->base.src.offset[0]; - int16_t ty = op->base.src.offset[1]; - - v = sna->render.vertices + sna->render.vertex_used; - sna->render.vertex_used += 3*4; - assert(sna->render.vertex_used <= sna->render.vertex_size); - - dst.p.x = box->x2; - dst.p.y = box->y2; - v[0] = dst.f; - v[1] = (box->x2 + tx) * sx; - v[6] = v[2] = (box->y2 + ty) * sy; - - dst.p.x = box->x1; - v[4] = dst.f; - v[9] = v[5] = (box->x1 + tx) * sx; - - dst.p.y = box->y1; - v[8] = dst.f; - v[10] = (box->y1 + ty) * sy; - - v[11] = v[7] = v[3] = opacity; -} - -fastcall static void -gen6_emit_composite_spans_simple(struct sna *sna, - const struct sna_composite_spans_op *op, - const BoxRec *box, - float opacity) -{ - float *v; - union { - struct sna_coordinate p; - float f; - } dst; - - float xx = op->base.src.transform->matrix[0][0]; - float x0 = op->base.src.transform->matrix[0][2]; - float yy = op->base.src.transform->matrix[1][1]; - float y0 = op->base.src.transform->matrix[1][2]; - float sx = op->base.src.scale[0]; - float sy = op->base.src.scale[1]; - int16_t tx = op->base.src.offset[0]; - int16_t ty = op->base.src.offset[1]; - - v = sna->render.vertices + sna->render.vertex_used; - sna->render.vertex_used += 3*4; - assert(sna->render.vertex_used <= sna->render.vertex_size); - - dst.p.x = box->x2; - dst.p.y = box->y2; - v[0] = dst.f; - v[1] = ((box->x2 + tx) * xx + x0) * sx; - v[6] = v[2] = ((box->y2 + ty) * yy + y0) * sy; - - dst.p.x = box->x1; - v[4] = dst.f; - v[9] = v[5] = ((box->x1 + tx) * xx + x0) * sx; - - dst.p.y = box->y1; - v[8] = dst.f; - v[10] = ((box->y1 + ty) * yy + y0) * sy; - - v[11] = v[7] = v[3] = opacity; -} - -fastcall static void -gen6_emit_composite_spans_affine(struct sna *sna, - const struct sna_composite_spans_op *op, - const BoxRec *box, - float opacity) -{ - OUT_VERTEX(box->x2, box->y2); - gen6_emit_composite_texcoord_affine(sna, &op->base.src, - box->x2, box->y2); - OUT_VERTEX_F(opacity); - - OUT_VERTEX(box->x1, box->y2); - gen6_emit_composite_texcoord_affine(sna, &op->base.src, - box->x1, box->y2); - OUT_VERTEX_F(opacity); - - OUT_VERTEX(box->x1, box->y1); - gen6_emit_composite_texcoord_affine(sna, &op->base.src, - box->x1, box->y1); - OUT_VERTEX_F(opacity); -} - fastcall static void gen6_render_composite_spans_box(struct sna *sna, const struct sna_composite_spans_op *op, @@ -3100,8 +2456,8 @@ gen6_render_composite_spans_done(struct sna *sna, { DBG(("%s()\n", __FUNCTION__)); - if (sna->render_state.gen6.vertex_offset) - gen6_vertex_flush(sna); + if (sna->render.vertex_offset) + gen4_vertex_flush(sna); if (op->base.src.bo) kgem_bo_destroy(&sna->kgem, op->base.src.bo); @@ -3200,22 +2556,7 @@ gen6_render_composite_spans(struct sna *sna, tmp->base.is_affine = tmp->base.src.is_affine; tmp->base.need_magic_ca_pass = false; - tmp->prim_emit = gen6_emit_composite_spans_primitive; - if (tmp->base.src.is_solid) { - tmp->prim_emit = gen6_emit_composite_spans_solid; - } else if (tmp->base.src.transform == NULL) { - tmp->prim_emit = gen6_emit_composite_spans_identity; - } else if (tmp->base.is_affine) { - if (tmp->base.src.transform->matrix[0][1] == 0 && - tmp->base.src.transform->matrix[1][0] == 0) { - tmp->base.src.scale[0] /= tmp->base.src.transform->matrix[2][2]; - tmp->base.src.scale[1] /= tmp->base.src.transform->matrix[2][2]; - tmp->prim_emit = gen6_emit_composite_spans_simple; - } else - tmp->prim_emit = gen6_emit_composite_spans_affine; - } - tmp->base.floats_per_vertex = 4 + !tmp->base.is_affine; - tmp->base.floats_per_rect = 3 * tmp->base.floats_per_vertex; + gen4_choose_spans_emitter(tmp); tmp->base.u.gen6.flags = GEN6_SET_FLAGS(SAMPLER_OFFSET(tmp->base.src.filter, @@ -3224,7 +2565,7 @@ gen6_render_composite_spans(struct sna *sna, SAMPLER_EXTEND_PAD), gen6_get_blend(tmp->base.op, false, tmp->base.dst.format), GEN6_WM_KERNEL_OPACITY | !tmp->base.is_affine, - 1 << 2 | (2+!tmp->base.is_affine)); + gen4_choose_spans_vertex_buffer(&tmp->base)); tmp->box = gen6_render_composite_spans_box; tmp->boxes = gen6_render_composite_spans_boxes; @@ -3541,7 +2882,7 @@ fallback_blt: } while (--n_this_time); } while (n); - gen6_vertex_flush(sna); + gen4_vertex_flush(sna); sna_render_composite_redirect_done(sna, &tmp); if (tmp.src.bo != src_bo) kgem_bo_destroy(&sna->kgem, tmp.src.bo); @@ -3588,8 +2929,8 @@ gen6_render_copy_done(struct sna *sna, const struct sna_copy_op *op) { DBG(("%s()\n", __FUNCTION__)); - if (sna->render_state.gen6.vertex_offset) - gen6_vertex_flush(sna); + if (sna->render.vertex_offset) + gen4_vertex_flush(sna); } static bool @@ -3844,7 +3185,7 @@ gen6_render_fill_boxes(struct sna *sna, } while (--n_this_time); } while (n); - gen6_vertex_flush(sna); + gen4_vertex_flush(sna); kgem_bo_destroy(&sna->kgem, tmp.src.bo); sna_render_composite_redirect_done(sna, &tmp); return true; @@ -3937,8 +3278,8 @@ gen6_render_op_fill_done(struct sna *sna, const struct sna_fill_op *op) { DBG(("%s()\n", __FUNCTION__)); - if (sna->render_state.gen6.vertex_offset) - gen6_vertex_flush(sna); + if (sna->render.vertex_offset) + gen4_vertex_flush(sna); kgem_bo_destroy(&sna->kgem, op->base.src.bo); } @@ -4092,7 +3433,7 @@ gen6_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, v[7] = v[2] = v[3] = 1; v[6] = v[10] = v[11] = 0; - gen6_vertex_flush(sna); + gen4_vertex_flush(sna); kgem_bo_destroy(&sna->kgem, tmp.src.bo); return true; @@ -4174,7 +3515,7 @@ gen6_render_clear(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo) v[7] = v[2] = v[3] = 1; v[6] = v[10] = v[11] = 0; - gen6_vertex_flush(sna); + gen4_vertex_flush(sna); kgem_bo_destroy(&sna->kgem, tmp.src.bo); return true; @@ -4182,7 +3523,10 @@ gen6_render_clear(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo) static void gen6_render_flush(struct sna *sna) { - gen6_vertex_close(sna); + gen4_vertex_close(sna); + + assert(sna->render.vb_id == 0); + assert(sna->render.vertex_offset == 0); } static void @@ -4234,7 +3578,6 @@ static void gen6_render_reset(struct sna *sna) { sna->render_state.gen6.needs_invariant = true; sna->render_state.gen6.first_state_packet = true; - sna->render_state.gen6.vb_id = 0; sna->render_state.gen6.ve_id = 3 << 2; sna->render_state.gen6.last_primitive = -1; |