From: Chia-I Wu Date: Mon, 26 Jan 2015 08:37:38 +0000 (+0800) Subject: ilo: update streamout related functions for Gen8 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b64aeebbcce996ab7057a9af39a97e32689df13f;p=mesa.git ilo: update streamout related functions for Gen8 --- diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_top.h b/src/gallium/drivers/ilo/ilo_builder_3d_top.h index 6c07e253321..2b7ddfc4dc8 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_top.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_top.h @@ -830,50 +830,62 @@ static inline void gen7_3DSTATE_STREAMOUT(struct ilo_builder *builder, int render_stream, bool render_disable, - unsigned buffer_mask, - int vertex_attrib_count) + int vertex_attrib_count, + const int *buf_strides) { - const uint8_t cmd_len = 3; - uint32_t dw1, dw2, *dw; + const uint8_t cmd_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 5 : 3; + uint32_t *dw; + int buf_mask; - ILO_DEV_ASSERT(builder->dev, 7, 7.5); + ILO_DEV_ASSERT(builder->dev, 7, 8); - dw1 = render_stream << GEN7_SO_DW1_RENDER_STREAM_SELECT__SHIFT; - if (render_disable) - dw1 |= GEN7_SO_DW1_RENDER_DISABLE; + ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw2 = 0; + dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_STREAMOUT) | (cmd_len - 2); + + dw[1] = render_stream << GEN7_SO_DW1_RENDER_STREAM_SELECT__SHIFT; + if (render_disable) + dw[1] |= GEN7_SO_DW1_RENDER_DISABLE; + + if (buf_strides) { + buf_mask = ((bool) buf_strides[3]) << 3 | + ((bool) buf_strides[2]) << 2 | + ((bool) buf_strides[1]) << 1 | + ((bool) buf_strides[0]); + if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { + dw[3] = buf_strides[1] << 16 | buf_strides[0]; + dw[4] = buf_strides[3] << 16 | buf_strides[1]; + } + } else { + buf_mask = 0; + } - if (buffer_mask) { + if (buf_mask) { int read_len; + dw[1] |= GEN7_SO_DW1_SO_ENABLE | + GEN7_SO_DW1_STATISTICS; + /* API_OPENGL */ + if (true) + dw[1] |= GEN7_SO_DW1_REORDER_TRAILING; + if (ilo_dev_gen(builder->dev) < ILO_GEN(8)) + dw[1] |= buf_mask << GEN7_SO_DW1_BUFFER_ENABLES__SHIFT; + read_len = (vertex_attrib_count + 1) / 2; if (!read_len) read_len = 1; - dw1 |= GEN7_SO_DW1_SO_ENABLE | - GEN7_SO_DW1_STATISTICS | - buffer_mask << GEN7_SO_DW1_BUFFER_ENABLES__SHIFT; - - /* API_OPENGL */ - if (true) - dw1 |= GEN7_SO_DW1_REORDER_TRAILING; - - dw2 = 0 << GEN7_SO_DW2_STREAM3_READ_OFFSET__SHIFT | - (read_len - 1) << GEN7_SO_DW2_STREAM3_READ_LEN__SHIFT | - 0 << GEN7_SO_DW2_STREAM2_READ_OFFSET__SHIFT | - (read_len - 1) << GEN7_SO_DW2_STREAM2_READ_LEN__SHIFT | - 0 << GEN7_SO_DW2_STREAM1_READ_OFFSET__SHIFT | - (read_len - 1) << GEN7_SO_DW2_STREAM1_READ_LEN__SHIFT | - 0 << GEN7_SO_DW2_STREAM0_READ_OFFSET__SHIFT | - (read_len - 1) << GEN7_SO_DW2_STREAM0_READ_LEN__SHIFT; + dw[2] = 0 << GEN7_SO_DW2_STREAM3_READ_OFFSET__SHIFT | + (read_len - 1) << GEN7_SO_DW2_STREAM3_READ_LEN__SHIFT | + 0 << GEN7_SO_DW2_STREAM2_READ_OFFSET__SHIFT | + (read_len - 1) << GEN7_SO_DW2_STREAM2_READ_LEN__SHIFT | + 0 << GEN7_SO_DW2_STREAM1_READ_OFFSET__SHIFT | + (read_len - 1) << GEN7_SO_DW2_STREAM1_READ_LEN__SHIFT | + 0 << GEN7_SO_DW2_STREAM0_READ_OFFSET__SHIFT | + (read_len - 1) << GEN7_SO_DW2_STREAM0_READ_LEN__SHIFT; + } else { + dw[2] = 0; } - - ilo_builder_batch_pointer(builder, cmd_len, &dw); - - dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_STREAMOUT) | (cmd_len - 2); - dw[1] = dw1; - dw[2] = dw2; } static inline void @@ -894,7 +906,7 @@ gen7_3DSTATE_SO_DECL_LIST(struct ilo_builder *builder, int hw_decl_count, i; uint32_t *dw; - ILO_DEV_ASSERT(builder->dev, 7, 7.5); + ILO_DEV_ASSERT(builder->dev, 7, 8); memset(streams, 0, sizeof(streams)); memset(buf_offsets, 0, sizeof(buf_offsets)); @@ -978,13 +990,13 @@ static inline void gen7_3DSTATE_SO_BUFFER(struct ilo_builder *builder, int index, int stride, const struct pipe_stream_output_target *so_target) { - const uint8_t cmd_len = 4; + const uint8_t cmd_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 8 : 4; struct ilo_buffer *buf; int start, end; uint32_t *dw; unsigned pos; - ILO_DEV_ASSERT(builder->dev, 7, 7.5); + ILO_DEV_ASSERT(builder->dev, 7, 8); buf = ilo_buffer(so_target->buffer); @@ -1002,19 +1014,29 @@ gen7_3DSTATE_SO_BUFFER(struct ilo_builder *builder, int index, int stride, dw[1] = index << GEN7_SO_BUF_DW1_INDEX__SHIFT | stride; - ilo_builder_batch_reloc(builder, pos + 2, - buf->bo, start, INTEL_RELOC_WRITE); - ilo_builder_batch_reloc(builder, pos + 3, - buf->bo, end, INTEL_RELOC_WRITE); + if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { + dw[4] = end - start; + dw[5] = 0; + dw[6] = 0; + dw[7] = 0; + + ilo_builder_batch_reloc64(builder, pos + 2, + buf->bo, start, INTEL_RELOC_WRITE); + } else { + ilo_builder_batch_reloc(builder, pos + 2, + buf->bo, start, INTEL_RELOC_WRITE); + ilo_builder_batch_reloc(builder, pos + 3, + buf->bo, end, INTEL_RELOC_WRITE); + } } static inline void gen7_disable_3DSTATE_SO_BUFFER(struct ilo_builder *builder, int index) { - const uint8_t cmd_len = 4; + const uint8_t cmd_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 8 : 4; uint32_t *dw; - ILO_DEV_ASSERT(builder->dev, 7, 7.5); + ILO_DEV_ASSERT(builder->dev, 7, 8); ilo_builder_batch_pointer(builder, cmd_len, &dw); @@ -1022,6 +1044,13 @@ gen7_disable_3DSTATE_SO_BUFFER(struct ilo_builder *builder, int index) dw[1] = index << GEN7_SO_BUF_DW1_INDEX__SHIFT; dw[2] = 0; dw[3] = 0; + + if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { + dw[4] = 0; + dw[5] = 0; + dw[6] = 0; + dw[7] = 0; + } } static inline void diff --git a/src/gallium/drivers/ilo/ilo_draw.c b/src/gallium/drivers/ilo/ilo_draw.c index 1c9c4226650..9d1c419dd2a 100644 --- a/src/gallium/drivers/ilo/ilo_draw.c +++ b/src/gallium/drivers/ilo/ilo_draw.c @@ -296,8 +296,9 @@ draw_vbo(struct ilo_context *ilo, const struct ilo_state_vector *vec) bool success = true; int max_len, before_space; - /* on GEN7+, we need SOL_RESET to reset the SO write offsets */ + /* on Gen7 and Gen7.5, we need SOL_RESET to reset the SO write offsets */ if (ilo_dev_gen(ilo->dev) >= ILO_GEN(7) && + ilo_dev_gen(ilo->dev) <= ILO_GEN(7.5) && (vec->dirty & ILO_DIRTY_SO) && vec->so.enabled && !vec->so.append_bitmask) { ilo_cp_submit(ilo->cp, "SOL_RESET"); diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c index ae3ff5fde4b..5fe6995ef8c 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen7.c +++ b/src/gallium/drivers/ilo/ilo_render_gen7.c @@ -472,13 +472,17 @@ gen7_draw_sol(struct ilo_render *r, /* 3DSTATE_STREAMOUT */ if (DIRTY(SO) || DIRTY(RASTERIZER) || dirty_sh) { - const unsigned buffer_mask = (1 << vec->so.count) - 1; const int output_count = ilo_shader_get_kernel_param(shader, ILO_KERNEL_OUTPUT_COUNT); + int buf_strides[4] = { 0, 0, 0, 0 }; + int i; + + for (i = 0; i < vec->so.count; i++) + buf_strides[i] = so_info->stride[i] * 4; gen7_3DSTATE_STREAMOUT(r->builder, 0, vec->rasterizer->state.rasterizer_discard, - buffer_mask, output_count); + output_count, buf_strides); } }