summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2014-03-06 18:43:44 -0500
committerZack Rusin <[email protected]>2014-03-07 12:49:33 -0500
commitdfa25ea5cd19d5a050a1c94bd7370a2259b9f007 (patch)
tree8ce2db3ceab01311df710c2d7f307f5b708312c5 /src/gallium/auxiliary
parent7d5903980ed7c4405e20dbc4f5ade9d202c559cb (diff)
gallium: allow setting of the internal stream output offset
D3D10 allows setting of the internal offset of a buffer, which is in general only incremented via actual stream output writes. By allowing setting of the internal offset draw_auto is capable of rendering from buffers which have not been actually streamed out to. Our interface didn't allow. This change functionally shouldn't make any difference to OpenGL where instead of an append_bitmask you just get a real array where -1 means append (like in D3D) and 0 means do not append. Signed-off-by: Zack Rusin <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Jose Fonseca <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c13
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h2
-rw-r--r--src/gallium/auxiliary/draw/draw_context.h3
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_so_emit.c3
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c2
-rw-r--r--src/gallium/auxiliary/postprocess/pp_run.c2
-rw-r--r--src/gallium/auxiliary/util/u_blit.c2
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c13
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c2
10 files changed, 29 insertions, 21 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 2dcf01d68c4..91466842c2e 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -332,7 +332,7 @@ void cso_release_all( struct cso_context *ctx )
ctx->pipe->bind_vertex_elements_state( ctx->pipe, NULL );
if (ctx->pipe->set_stream_output_targets)
- ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, 0);
+ ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, NULL);
}
/* free fragment sampler views */
@@ -1241,7 +1241,7 @@ void
cso_set_stream_outputs(struct cso_context *ctx,
unsigned num_targets,
struct pipe_stream_output_target **targets,
- unsigned append_bitmask)
+ const unsigned *offsets)
{
struct pipe_context *pipe = ctx->pipe;
uint i;
@@ -1266,7 +1266,7 @@ cso_set_stream_outputs(struct cso_context *ctx,
}
pipe->set_stream_output_targets(pipe, num_targets, targets,
- append_bitmask);
+ offsets);
ctx->nr_so_targets = num_targets;
}
@@ -1292,6 +1292,7 @@ cso_restore_stream_outputs(struct cso_context *ctx)
{
struct pipe_context *pipe = ctx->pipe;
uint i;
+ unsigned offset[PIPE_MAX_SO_BUFFERS];
if (!ctx->has_streamout) {
return;
@@ -1302,19 +1303,21 @@ cso_restore_stream_outputs(struct cso_context *ctx)
return;
}
+ assert(ctx->nr_so_targets_saved <= PIPE_MAX_SO_BUFFERS);
for (i = 0; i < ctx->nr_so_targets_saved; i++) {
pipe_so_target_reference(&ctx->so_targets[i], NULL);
/* move the reference from one pointer to another */
ctx->so_targets[i] = ctx->so_targets_saved[i];
ctx->so_targets_saved[i] = NULL;
+ /* -1 means append */
+ offset[i] = (unsigned)-1;
}
for (; i < ctx->nr_so_targets; i++) {
pipe_so_target_reference(&ctx->so_targets[i], NULL);
}
- /* ~0 means append */
pipe->set_stream_output_targets(pipe, ctx->nr_so_targets_saved,
- ctx->so_targets, ~0);
+ ctx->so_targets, offset);
ctx->nr_so_targets = ctx->nr_so_targets_saved;
ctx->nr_so_targets_saved = 0;
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index 822e2dfa899..1aa99986f54 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -115,7 +115,7 @@ unsigned cso_get_aux_vertex_buffer_slot(struct cso_context *ctx);
void cso_set_stream_outputs(struct cso_context *ctx,
unsigned num_targets,
struct pipe_stream_output_target **targets,
- unsigned append_bitmask);
+ const unsigned *offsets);
void cso_save_stream_outputs(struct cso_context *ctx);
void cso_restore_stream_outputs(struct cso_context *ctx);
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index c9f933c7017..f114f503546 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -53,14 +53,13 @@ struct tgsi_sampler;
* structure to contain driver internal information
* for stream out support. mapping stores the pointer
* to the buffer contents, and internal offset stores
- * stores an internal counter to how much of the stream
+ * an internal counter to how much of the stream
* out buffer is used (in bytes).
*/
struct draw_so_target {
struct pipe_stream_output_target target;
void *mapping;
int internal_offset;
- int emitted_vertices;
};
struct draw_context *draw_create( struct pipe_context *pipe );
diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c
index e2ff7f9fe9f..3236e523a94 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -431,14 +431,16 @@ draw_pt_arrays_restart(struct draw_context *draw,
*/
static void
resolve_draw_info(const struct pipe_draw_info *raw_info,
- struct pipe_draw_info *info)
+ struct pipe_draw_info *info,
+ struct pipe_vertex_buffer *vertex_buffer)
{
memcpy(info, raw_info, sizeof(struct pipe_draw_info));
if (raw_info->count_from_stream_output) {
struct draw_so_target *target =
(struct draw_so_target *)info->count_from_stream_output;
- info->count = target->emitted_vertices;
+ assert(vertex_buffer != NULL);
+ info->count = target->internal_offset / vertex_buffer->stride;
/* Stream output draw can not be indexed */
debug_assert(!info->indexed);
@@ -467,7 +469,7 @@ draw_vbo(struct draw_context *draw,
*/
util_fpstate_set_denorms_to_zero(fpstate);
- resolve_draw_info(info, &resolved_info);
+ resolve_draw_info(info, &resolved_info, &(draw->pt.vertex_buffer[0]));
info = &resolved_info;
assert(info->instance_count > 0);
diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
index 7cef17c7cf9..bd49d0adec6 100644
--- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
@@ -194,7 +194,7 @@ static void so_emit_prim(struct pt_so_emit *so,
{
int j;
debug_printf("VERT[%d], offset = %d, slot[%d] sc = %d, num_c = %d, idx = %d = [",
- i + draw->so.targets[ob]->emitted_vertices,
+ i,
draw->so.targets[ob]->internal_offset,
slot, start_comp, num_comps, idx);
for (j = 0; j < num_comps; ++j) {
@@ -209,7 +209,6 @@ static void so_emit_prim(struct pt_so_emit *so,
struct draw_so_target *target = draw->so.targets[ob];
if (target && buffer_written[ob]) {
target->internal_offset += state->stride[ob] * sizeof(float);
- target->emitted_vertices += 1;
}
}
}
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 465013cb8f2..ccf020bed16 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -454,7 +454,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
cso_set_depth_stencil_alpha(cso, &hud->dsa);
cso_set_rasterizer(cso, &hud->rasterizer);
cso_set_viewport(cso, &viewport);
- cso_set_stream_outputs(cso, 0, NULL, 0);
+ cso_set_stream_outputs(cso, 0, NULL, NULL);
cso_set_geometry_shader_handle(cso, NULL);
cso_set_vertex_shader_handle(cso, hud->vs);
cso_set_vertex_elements(cso, 2, hud->velems);
diff --git a/src/gallium/auxiliary/postprocess/pp_run.c b/src/gallium/auxiliary/postprocess/pp_run.c
index a4dc75dd71c..7d9330c745f 100644
--- a/src/gallium/auxiliary/postprocess/pp_run.c
+++ b/src/gallium/auxiliary/postprocess/pp_run.c
@@ -136,7 +136,7 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
/* set default state */
cso_set_sample_mask(cso, ~0);
- cso_set_stream_outputs(cso, 0, NULL, 0);
+ cso_set_stream_outputs(cso, 0, NULL, NULL);
cso_set_geometry_shader_handle(cso, NULL);
cso_set_render_condition(cso, NULL, FALSE, 0);
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index dd33eb0835b..4b25b93dd17 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -537,7 +537,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_set_sample_mask(ctx->cso, ~0);
cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
- cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
+ cso_set_stream_outputs(ctx->cso, 0, NULL, NULL);
/* sampler */
ctx->sampler.normalized_coords = normalized;
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 66b511eb536..1e7f374abff 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -472,9 +472,12 @@ static void blitter_restore_vertex_states(struct blitter_context_priv *ctx)
/* Stream outputs. */
if (ctx->has_stream_out) {
+ unsigned offsets[PIPE_MAX_SO_BUFFERS];
+ for (i = 0; i < ctx->base.saved_num_so_targets; i++)
+ offsets[i] = (unsigned)-1;
pipe->set_stream_output_targets(pipe,
ctx->base.saved_num_so_targets,
- ctx->base.saved_so_targets, ~0);
+ ctx->base.saved_so_targets, offsets);
for (i = 0; i < ctx->base.saved_num_so_targets; i++)
pipe_so_target_reference(&ctx->base.saved_so_targets[i], NULL);
@@ -1013,7 +1016,7 @@ static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx,
if (ctx->has_geometry_shader)
pipe->bind_gs_state(pipe, NULL);
if (ctx->has_stream_out)
- pipe->set_stream_output_targets(pipe, 0, NULL, 0);
+ pipe->set_stream_output_targets(pipe, 0, NULL, NULL);
}
static void blitter_draw(struct blitter_context_priv *ctx,
@@ -1806,6 +1809,7 @@ void util_blitter_copy_buffer(struct blitter_context *blitter,
struct pipe_context *pipe = ctx->base.pipe;
struct pipe_vertex_buffer vb;
struct pipe_stream_output_target *so_target;
+ unsigned offsets[PIPE_MAX_SO_BUFFERS] = {0};
if (srcx >= src->width0 ||
dstx >= dst->width0) {
@@ -1847,7 +1851,7 @@ void util_blitter_copy_buffer(struct blitter_context *blitter,
pipe->bind_rasterizer_state(pipe, ctx->rs_discard_state);
so_target = pipe->create_stream_output_target(pipe, dst, dstx, size);
- pipe->set_stream_output_targets(pipe, 1, &so_target, 0);
+ pipe->set_stream_output_targets(pipe, 1, &so_target, offsets);
util_draw_arrays(pipe, PIPE_PRIM_POINTS, 0, size / 4);
@@ -1867,6 +1871,7 @@ void util_blitter_clear_buffer(struct blitter_context *blitter,
struct pipe_context *pipe = ctx->base.pipe;
struct pipe_vertex_buffer vb = {0};
struct pipe_stream_output_target *so_target;
+ unsigned offsets[PIPE_MAX_SO_BUFFERS] = {0};
assert(num_channels >= 1);
assert(num_channels <= 4);
@@ -1906,7 +1911,7 @@ void util_blitter_clear_buffer(struct blitter_context *blitter,
pipe->bind_rasterizer_state(pipe, ctx->rs_discard_state);
so_target = pipe->create_stream_output_target(pipe, dst, offset, size);
- pipe->set_stream_output_targets(pipe, 1, &so_target, 0);
+ pipe->set_stream_output_targets(pipe, 1, &so_target, offsets);
util_draw_arrays(pipe, PIPE_PRIM_POINTS, 0, size / 4);
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index d3401a6cd33..dad3ad2ec1d 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -1578,7 +1578,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
cso_set_sample_mask(ctx->cso, ~0);
cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
- cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
+ cso_set_stream_outputs(ctx->cso, 0, NULL, NULL);
cso_set_render_condition(ctx->cso, NULL, FALSE, 0);
set_fragment_shader(ctx, type, is_depth);