summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2014-09-28 00:41:42 +0800
committerChia-I Wu <[email protected]>2014-09-30 16:41:31 +0800
commit343b014b57ecc5431477e090100e6a26edbda540 (patch)
tree1d375a3baabd41c00dd7836f9ca45c79084a161f
parent46537f1d03ba6de83be70ac574f633bb4342a327 (diff)
ilo: use dynamic bo for rectlist vertices
The size is always 24 bytes. We can upload them to the dynamic buffer. Signed-off-by: Chia-I Wu <[email protected]>
-rw-r--r--src/gallium/drivers/ilo/ilo_blitter.c5
-rw-r--r--src/gallium/drivers/ilo/ilo_blitter.h7
-rw-r--r--src/gallium/drivers/ilo/ilo_blitter_rectlist.c51
-rw-r--r--src/gallium/drivers/ilo/ilo_builder.h3
-rw-r--r--src/gallium/drivers/ilo/ilo_builder_3d_top.h45
-rw-r--r--src/gallium/drivers/ilo/ilo_render.c7
-rw-r--r--src/gallium/drivers/ilo/ilo_render_dynamic.c10
-rw-r--r--src/gallium/drivers/ilo/ilo_render_gen.h21
-rw-r--r--src/gallium/drivers/ilo/ilo_render_gen6.c8
-rw-r--r--src/gallium/drivers/ilo/ilo_render_gen7.c8
10 files changed, 92 insertions, 73 deletions
diff --git a/src/gallium/drivers/ilo/ilo_blitter.c b/src/gallium/drivers/ilo/ilo_blitter.c
index d08563da436..10335920364 100644
--- a/src/gallium/drivers/ilo/ilo_blitter.c
+++ b/src/gallium/drivers/ilo/ilo_blitter.c
@@ -70,10 +70,5 @@ ilo_blitter_destroy(struct ilo_blitter *blitter)
if (blitter->pipe_blitter)
util_blitter_destroy(blitter->pipe_blitter);
- if (blitter->buffer.res) {
- struct pipe_screen *screen = blitter->ilo->base.screen;
- screen->resource_destroy(screen, blitter->buffer.res);
- }
-
FREE(blitter);
}
diff --git a/src/gallium/drivers/ilo/ilo_blitter.h b/src/gallium/drivers/ilo/ilo_blitter.h
index 1c36e361a76..4284f415c1c 100644
--- a/src/gallium/drivers/ilo/ilo_blitter.h
+++ b/src/gallium/drivers/ilo/ilo_blitter.h
@@ -62,13 +62,8 @@ struct ilo_blitter {
bool initialized;
- struct {
- struct pipe_resource *res;
- unsigned offset, size;
- } buffer;
-
+ float vertices[3][2];
struct ilo_ve_state ve;
- struct ilo_vb_state vb;
struct pipe_draw_info draw;
struct ilo_viewport_cso viewport;
diff --git a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c
index aafb5f10443..699a7decbef 100644
--- a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c
+++ b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c
@@ -41,32 +41,13 @@
static bool
ilo_blitter_set_invariants(struct ilo_blitter *blitter)
{
- struct pipe_screen *screen = blitter->ilo->base.screen;
- struct pipe_resource templ;
struct pipe_vertex_element velems[2];
struct pipe_viewport_state vp;
if (blitter->initialized)
return true;
- blitter->buffer.size = 4096;
-
- /* allocate the vertex buffer */
- memset(&templ, 0, sizeof(templ));
- templ.target = PIPE_BUFFER;
- templ.width0 = blitter->buffer.size;
- templ.usage = PIPE_USAGE_STREAM;
- templ.bind = PIPE_BIND_VERTEX_BUFFER;
- blitter->buffer.res = screen->resource_create(screen, &templ);
- if (!blitter->buffer.res)
- return false;
-
- /* do not increase reference count */
- blitter->vb.states[0].buffer = blitter->buffer.res;
-
/* only vertex X and Y */
- blitter->vb.states[0].stride = 2 * sizeof(float);
- blitter->vb.enabled_mask = 0x1;
memset(&velems, 0, sizeof(velems));
velems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
ilo_gpe_init_ve(blitter->ilo->dev, 2, velems, &blitter->ve);
@@ -120,10 +101,6 @@ ilo_blitter_set_rectlist(struct ilo_blitter *blitter,
unsigned x, unsigned y,
unsigned width, unsigned height)
{
- unsigned usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_UNSYNCHRONIZED;
- float vertices[3][2];
- struct pipe_box box;
-
/*
* From the Sandy Bridge PRM, volume 2 part 1, page 11:
*
@@ -132,28 +109,12 @@ ilo_blitter_set_rectlist(struct ilo_blitter *blitter,
* by the definition of a rectangle. V0=LowerRight, V1=LowerLeft,
* V2=UpperLeft. Implied V3 = V0- V1+V2."
*/
- vertices[0][0] = (float) (x + width);
- vertices[0][1] = (float) (y + height);
- vertices[1][0] = (float) x;
- vertices[1][1] = (float) (y + height);
- vertices[2][0] = (float) x;
- vertices[2][1] = (float) y;
-
- /* buffer is full */
- if (blitter->buffer.offset + sizeof(vertices) > blitter->buffer.size) {
- if (!ilo_buffer_rename_bo(ilo_buffer(blitter->buffer.res)))
- usage &= ~PIPE_TRANSFER_UNSYNCHRONIZED;
-
- blitter->buffer.offset = 0;
- }
-
- u_box_1d(blitter->buffer.offset, sizeof(vertices), &box);
-
- blitter->ilo->base.transfer_inline_write(&blitter->ilo->base,
- blitter->buffer.res, 0, usage, &box, vertices, 0, 0);
-
- blitter->vb.states[0].buffer_offset = blitter->buffer.offset;
- blitter->buffer.offset += sizeof(vertices);
+ blitter->vertices[0][0] = (float) (x + width);
+ blitter->vertices[0][1] = (float) (y + height);
+ blitter->vertices[1][0] = (float) x;
+ blitter->vertices[1][1] = (float) (y + height);
+ blitter->vertices[2][0] = (float) x;
+ blitter->vertices[2][1] = (float) y;
}
static void
diff --git a/src/gallium/drivers/ilo/ilo_builder.h b/src/gallium/drivers/ilo/ilo_builder.h
index 259487e1346..38b1c836840 100644
--- a/src/gallium/drivers/ilo/ilo_builder.h
+++ b/src/gallium/drivers/ilo/ilo_builder.h
@@ -283,7 +283,8 @@ ilo_builder_dynamic_pointer(struct ilo_builder *builder,
struct ilo_builder_writer *writer = &builder->writers[which];
/* all states are at least aligned to 32-bytes */
- assert(alignment % 32 == 0);
+ if (item != ILO_BUILDER_ITEM_BLOB)
+ assert(alignment % 32 == 0);
*dw = (uint32_t *) ((char *) writer->ptr + offset);
diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_top.h b/src/gallium/drivers/ilo/ilo_builder_3d_top.h
index fb7b92740f3..4d0750f8753 100644
--- a/src/gallium/drivers/ilo/ilo_builder_3d_top.h
+++ b/src/gallium/drivers/ilo/ilo_builder_3d_top.h
@@ -408,6 +408,36 @@ gen6_3DSTATE_VERTEX_BUFFERS(struct ilo_builder *builder,
}
}
+/* the user vertex buffer must be uploaded with gen6_user_vertex_buffer() */
+static inline void
+gen6_user_3DSTATE_VERTEX_BUFFERS(struct ilo_builder *builder,
+ uint32_t vb_begin, uint32_t vb_end,
+ uint32_t stride)
+{
+ const struct ilo_builder_writer *bat =
+ &builder->writers[ILO_BUILDER_WRITER_BATCH];
+ const uint8_t cmd_len = 1 + 4;
+ uint32_t *dw;
+ unsigned pos;
+
+ ILO_DEV_ASSERT(builder->dev, 6, 7.5);
+
+ pos = ilo_builder_batch_pointer(builder, cmd_len, &dw);
+
+ dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_BUFFERS) | (cmd_len - 2);
+ dw++;
+ pos++;
+
+ /* VERTEX_BUFFER_STATE */
+ dw[0] = 0 << GEN6_VB_STATE_DW0_INDEX__SHIFT |
+ GEN6_VB_STATE_DW0_ACCESS_VERTEXDATA |
+ stride << GEN6_VB_STATE_DW0_PITCH__SHIFT;
+ dw[3] = 0;
+
+ ilo_builder_batch_reloc(builder, pos + 1, bat->bo, vb_begin, 0);
+ ilo_builder_batch_reloc(builder, pos + 2, bat->bo, vb_end, 0);
+}
+
static inline void
ve_init_cso_with_components(const struct ilo_dev_info *dev,
int comp0, int comp1, int comp2, int comp3,
@@ -1619,4 +1649,19 @@ gen6_push_constant_buffer(struct ilo_builder *builder,
return state_offset;
}
+static inline uint32_t
+gen6_user_vertex_buffer(struct ilo_builder *builder,
+ int size, const void *vertices)
+{
+ const int state_align = 8;
+ const int state_len = size / 4;
+
+ ILO_DEV_ASSERT(builder->dev, 6, 7.5);
+
+ assert(size % 4 == 0);
+
+ return ilo_builder_dynamic_write(builder, ILO_BUILDER_ITEM_BLOB,
+ state_align, state_len, vertices);
+}
+
#endif /* ILO_BUILDER_3D_TOP_H */
diff --git a/src/gallium/drivers/ilo/ilo_render.c b/src/gallium/drivers/ilo/ilo_render.c
index ae778584972..945d4cdb5aa 100644
--- a/src/gallium/drivers/ilo/ilo_render.c
+++ b/src/gallium/drivers/ilo/ilo_render.c
@@ -367,10 +367,13 @@ void
ilo_render_emit_rectlist(struct ilo_render *render,
const struct ilo_blitter *blitter)
{
+ struct ilo_render_rectlist_session session;
+
ILO_DEV_ASSERT(render->dev, 6, 7.5);
- ilo_render_emit_rectlist_dynamic_states(render, blitter);
- ilo_render_emit_rectlist_commands(render, blitter);
+ memset(&session, 0, sizeof(session));
+ ilo_render_emit_rectlist_dynamic_states(render, blitter, &session);
+ ilo_render_emit_rectlist_commands(render, blitter, &session);
}
int
diff --git a/src/gallium/drivers/ilo/ilo_render_dynamic.c b/src/gallium/drivers/ilo/ilo_render_dynamic.c
index 74d788dd515..dfd29c3c3ac 100644
--- a/src/gallium/drivers/ilo/ilo_render_dynamic.c
+++ b/src/gallium/drivers/ilo/ilo_render_dynamic.c
@@ -395,17 +395,23 @@ ilo_render_get_rectlist_dynamic_states_len(const struct ilo_render *render,
{
ILO_DEV_ASSERT(render->dev, 6, 7.5);
- return 64;
+ return 96;
}
void
ilo_render_emit_rectlist_dynamic_states(struct ilo_render *render,
- const struct ilo_blitter *blitter)
+ const struct ilo_blitter *blitter,
+ struct ilo_render_rectlist_session *session)
{
const unsigned dynamic_used = ilo_builder_dynamic_used(render->builder);
ILO_DEV_ASSERT(render->dev, 6, 7.5);
+ /* both are inclusive */
+ session->vb_start = gen6_user_vertex_buffer(render->builder,
+ sizeof(blitter->vertices), (const void *) blitter->vertices);
+ session->vb_end = session->vb_start + sizeof(blitter->vertices) - 1;
+
if (blitter->uses & ILO_BLITTER_USE_DSA) {
render->state.DEPTH_STENCIL_STATE =
gen6_DEPTH_STENCIL_STATE(render->builder, &blitter->dsa);
diff --git a/src/gallium/drivers/ilo/ilo_render_gen.h b/src/gallium/drivers/ilo/ilo_render_gen.h
index 8c874979cac..f21df4a5a2c 100644
--- a/src/gallium/drivers/ilo/ilo_render_gen.h
+++ b/src/gallium/drivers/ilo/ilo_render_gen.h
@@ -157,6 +157,11 @@ struct ilo_render_draw_session {
int num_surfaces[PIPE_SHADER_TYPES];
};
+struct ilo_render_rectlist_session {
+ uint32_t vb_start;
+ uint32_t vb_end;
+};
+
int
ilo_render_get_draw_commands_len_gen6(const struct ilo_render *render,
const struct ilo_state_vector *vec);
@@ -214,22 +219,25 @@ ilo_render_get_rectlist_commands_len(const struct ilo_render *render,
void
ilo_render_emit_rectlist_commands_gen6(struct ilo_render *r,
- const struct ilo_blitter *blitter);
+ const struct ilo_blitter *blitter,
+ const struct ilo_render_rectlist_session *session);
void
ilo_render_emit_rectlist_commands_gen7(struct ilo_render *r,
- const struct ilo_blitter *blitter);
+ const struct ilo_blitter *blitter,
+ const struct ilo_render_rectlist_session *session);
static inline void
ilo_render_emit_rectlist_commands(struct ilo_render *render,
- const struct ilo_blitter *blitter)
+ const struct ilo_blitter *blitter,
+ const struct ilo_render_rectlist_session *session)
{
const unsigned batch_used = ilo_builder_batch_used(render->builder);
if (ilo_dev_gen(render->dev) >= ILO_GEN(7))
- ilo_render_emit_rectlist_commands_gen7(render, blitter);
+ ilo_render_emit_rectlist_commands_gen7(render, blitter, session);
else
- ilo_render_emit_rectlist_commands_gen6(render, blitter);
+ ilo_render_emit_rectlist_commands_gen6(render, blitter, session);
assert(ilo_builder_batch_used(render->builder) <= batch_used +
ilo_render_get_rectlist_commands_len(render, blitter));
@@ -250,7 +258,8 @@ ilo_render_get_rectlist_dynamic_states_len(const struct ilo_render *render,
void
ilo_render_emit_rectlist_dynamic_states(struct ilo_render *render,
- const struct ilo_blitter *blitter);
+ const struct ilo_blitter *blitter,
+ struct ilo_render_rectlist_session *session);
int
ilo_render_get_draw_surface_states_len(const struct ilo_render *render,
diff --git a/src/gallium/drivers/ilo/ilo_render_gen6.c b/src/gallium/drivers/ilo/ilo_render_gen6.c
index cd84e0ceace..9369f6326d5 100644
--- a/src/gallium/drivers/ilo/ilo_render_gen6.c
+++ b/src/gallium/drivers/ilo/ilo_render_gen6.c
@@ -963,7 +963,8 @@ ilo_render_get_rectlist_commands_len_gen6(const struct ilo_render *render,
void
ilo_render_emit_rectlist_commands_gen6(struct ilo_render *r,
- const struct ilo_blitter *blitter)
+ const struct ilo_blitter *blitter,
+ const struct ilo_render_rectlist_session *session)
{
ILO_DEV_ASSERT(r->dev, 6, 6);
@@ -973,8 +974,9 @@ ilo_render_emit_rectlist_commands_gen6(struct ilo_render *r,
gen6_state_base_address(r->builder, true);
- gen6_3DSTATE_VERTEX_BUFFERS(r->builder,
- &blitter->ve, &blitter->vb);
+ gen6_user_3DSTATE_VERTEX_BUFFERS(r->builder,
+ session->vb_start, session->vb_end,
+ sizeof(blitter->vertices[0]));
gen6_3DSTATE_VERTEX_ELEMENTS(r->builder,
&blitter->ve, false, false);
diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c
index 6714c80c877..a39944e67b2 100644
--- a/src/gallium/drivers/ilo/ilo_render_gen7.c
+++ b/src/gallium/drivers/ilo/ilo_render_gen7.c
@@ -826,7 +826,8 @@ gen7_rectlist_wm_multisample(struct ilo_render *r,
void
ilo_render_emit_rectlist_commands_gen7(struct ilo_render *r,
- const struct ilo_blitter *blitter)
+ const struct ilo_blitter *blitter,
+ const struct ilo_render_rectlist_session *session)
{
ILO_DEV_ASSERT(r->dev, 7, 7.5);
@@ -834,8 +835,9 @@ ilo_render_emit_rectlist_commands_gen7(struct ilo_render *r,
gen6_state_base_address(r->builder, true);
- gen6_3DSTATE_VERTEX_BUFFERS(r->builder,
- &blitter->ve, &blitter->vb);
+ gen6_user_3DSTATE_VERTEX_BUFFERS(r->builder,
+ session->vb_start, session->vb_end,
+ sizeof(blitter->vertices[0]));
gen6_3DSTATE_VERTEX_ELEMENTS(r->builder,
&blitter->ve, false, false);