summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2020-01-22 02:13:18 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2020-01-22 02:13:18 +0000
commitfdcc03929065b5bf5dd93553db219ea3e05c8c34 (patch)
treeca90dc8d9e89febdcd4160956c1b8ec098a4efc9 /lib/mesa/src/gallium/auxiliary/draw
parent3c9de4a7e13712b5696750bbd59a18c848742022 (diff)
Import Mesa 19.2.8
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/draw')
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_gs.c200
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_gs.h21
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pt.h1
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pt_decompose.h4
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c29
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pt_so_emit.c64
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_vbuf.h1
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_vs.h3
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_vs_llvm.c3
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_vs_variant.c4
10 files changed, 204 insertions, 126 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_gs.c b/lib/mesa/src/gallium/auxiliary/draw/draw_gs.c
index 18af1d906..c752163ee 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_gs.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_gs.c
@@ -75,12 +75,12 @@ draw_gs_should_flush(struct draw_geometry_shader *shader)
/*#define DEBUG_OUTPUTS 1*/
static void
tgsi_fetch_gs_outputs(struct draw_geometry_shader *shader,
+ unsigned stream,
unsigned num_primitives,
float (**p_output)[4])
{
struct tgsi_exec_machine *machine = shader->machine;
unsigned prim_idx, j, slot;
- unsigned current_idx = 0;
float (*output)[4];
output = *p_output;
@@ -89,14 +89,16 @@ tgsi_fetch_gs_outputs(struct draw_geometry_shader *shader,
*/
for (prim_idx = 0; prim_idx < num_primitives; ++prim_idx) {
- unsigned num_verts_per_prim = machine->Primitives[prim_idx];
- shader->primitive_lengths[prim_idx + shader->emitted_primitives] =
- machine->Primitives[prim_idx];
- shader->emitted_vertices += num_verts_per_prim;
- for (j = 0; j < num_verts_per_prim; j++, current_idx++) {
- int idx = current_idx * shader->info.num_outputs;
+ unsigned num_verts_per_prim = machine->Primitives[stream][prim_idx];
+ unsigned prim_offset = machine->PrimitiveOffsets[stream][prim_idx];
+ shader->stream[stream].primitive_lengths[prim_idx + shader->stream[stream].emitted_primitives] =
+ machine->Primitives[stream][prim_idx];
+ shader->stream[stream].emitted_vertices += num_verts_per_prim;
+
+ for (j = 0; j < num_verts_per_prim; j++) {
+ int idx = prim_offset + j * shader->info.num_outputs;
#ifdef DEBUG_OUTPUTS
- debug_printf("%d) Output vert:\n", idx / shader->info.num_outputs);
+ debug_printf("%d/%d) Output vert:\n", stream, idx / shader->info.num_outputs);
#endif
for (slot = 0; slot < shader->info.num_outputs; slot++) {
output[slot][0] = machine->Outputs[idx + slot].xyzw[0].f[0];
@@ -115,7 +117,7 @@ tgsi_fetch_gs_outputs(struct draw_geometry_shader *shader,
}
}
*p_output = output;
- shader->emitted_primitives += num_primitives;
+ shader->stream[stream].emitted_primitives += num_primitives;
}
/*#define DEBUG_INPUTS 1*/
@@ -201,16 +203,40 @@ static void tgsi_gs_prepare(struct draw_geometry_shader *shader,
}
}
-static unsigned tgsi_gs_run(struct draw_geometry_shader *shader,
- unsigned input_primitives)
+static void tgsi_gs_run(struct draw_geometry_shader *shader,
+ unsigned input_primitives,
+ unsigned *out_prims)
{
struct tgsi_exec_machine *machine = shader->machine;
+ int i;
/* run interpreter */
tgsi_exec_machine_run(machine, 0);
- return
- machine->Temps[TGSI_EXEC_TEMP_PRIMITIVE_I].xyzw[TGSI_EXEC_TEMP_PRIMITIVE_C].u[0];
+ for (i = 0; i < 4; i++) {
+ int prim_i;
+ int prim_c;
+ switch (i) {
+ case 0:
+ prim_i = TGSI_EXEC_TEMP_PRIMITIVE_I;
+ prim_c = TGSI_EXEC_TEMP_PRIMITIVE_C;
+ break;
+ case 1:
+ prim_i = TGSI_EXEC_TEMP_PRIMITIVE_S1_I;
+ prim_c = TGSI_EXEC_TEMP_PRIMITIVE_S1_C;
+ break;
+ case 2:
+ prim_i = TGSI_EXEC_TEMP_PRIMITIVE_S2_I;
+ prim_c = TGSI_EXEC_TEMP_PRIMITIVE_S2_C;
+ break;
+ case 3:
+ prim_i = TGSI_EXEC_TEMP_PRIMITIVE_S3_I;
+ prim_c = TGSI_EXEC_TEMP_PRIMITIVE_S3_C;
+ break;
+ };
+
+ out_prims[i] = machine->Temps[prim_i].xyzw[prim_c].u[0];
+ }
}
#ifdef HAVE_LLVM
@@ -287,6 +313,7 @@ llvm_fetch_gs_input(struct draw_geometry_shader *shader,
static void
llvm_fetch_gs_outputs(struct draw_geometry_shader *shader,
+ unsigned stream,
unsigned num_primitives,
float (**p_output)[4])
{
@@ -307,7 +334,7 @@ llvm_fetch_gs_outputs(struct draw_geometry_shader *shader,
total_verts += shader->llvm_emitted_vertices[i];
}
- output_ptr += shader->emitted_vertices * shader->vertex_size;
+ output_ptr += shader->stream[0].emitted_vertices * shader->vertex_size;
for (i = 0; i < shader->vector_length - 1; ++i) {
int current_verts = shader->llvm_emitted_vertices[i];
int next_verts = shader->llvm_emitted_vertices[i + 1];
@@ -354,14 +381,14 @@ llvm_fetch_gs_outputs(struct draw_geometry_shader *shader,
for (j = 0; j < num_prims; ++j) {
int prim_length =
shader->llvm_prim_lengths[j][i];
- shader->primitive_lengths[shader->emitted_primitives + prim_idx] =
+ shader->stream[0].primitive_lengths[shader->stream[0].emitted_primitives + prim_idx] =
prim_length;
++prim_idx;
}
}
- shader->emitted_primitives += total_prims;
- shader->emitted_vertices += total_verts;
+ shader->stream[0].emitted_primitives += total_prims;
+ shader->stream[0].emitted_vertices += total_verts;
}
static void
@@ -371,14 +398,14 @@ llvm_gs_prepare(struct draw_geometry_shader *shader,
{
}
-static unsigned
+static void
llvm_gs_run(struct draw_geometry_shader *shader,
- unsigned input_primitives)
+ unsigned input_primitives, unsigned *out_prims)
{
unsigned ret;
char *input = (char*)shader->gs_output;
- input += (shader->emitted_vertices * shader->vertex_size);
+ input += (shader->stream[0].emitted_vertices * shader->vertex_size);
ret = shader->current_variant->jit_func(
shader->jit_context, shader->gs_input->data,
@@ -388,15 +415,15 @@ llvm_gs_run(struct draw_geometry_shader *shader,
shader->llvm_prim_ids,
shader->invocation_id);
- return ret;
+ *out_prims = ret;
}
#endif
static void gs_flush(struct draw_geometry_shader *shader)
{
- unsigned out_prim_count;
-
+ unsigned out_prim_count[TGSI_MAX_VERTEX_STREAMS];
+ unsigned i;
unsigned input_primitives = shader->fetched_prim_count;
if (shader->draw->collect_statistics) {
@@ -406,14 +433,19 @@ static void gs_flush(struct draw_geometry_shader *shader)
debug_assert(input_primitives > 0 &&
input_primitives <= 4);
- out_prim_count = shader->run(shader, input_primitives);
- shader->fetch_outputs(shader, out_prim_count,
- &shader->tmp_output);
+ shader->run(shader, input_primitives, out_prim_count);
+ for (i = 0; i < shader->num_vertex_streams; i++) {
+ shader->fetch_outputs(shader, i, out_prim_count[i],
+ &shader->stream[i].tmp_output);
+ }
#if 0
- debug_printf("PRIM emitted prims = %d (verts=%d), cur prim count = %d\n",
- shader->emitted_primitives, shader->emitted_vertices,
- out_prim_count);
+ for (i = 0; i < shader->num_vertex_streams; i++) {
+ debug_printf("stream %d: PRIM emitted prims = %d (verts=%d), cur prim count = %d\n",
+ i,
+ shader->stream[i].emitted_primitives, shader->stream[i].emitted_vertices,
+ out_prim_count[i]);
+ }
#endif
shader->fetched_prim_count = 0;
@@ -557,16 +589,19 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader,
unsigned total_verts_per_buffer = shader->primitive_boundary *
num_in_primitives;
unsigned invocation;
+ int i;
//Assume at least one primitive
max_out_prims = MAX2(max_out_prims, 1);
-
- output_verts->vertex_size = vertex_size;
- output_verts->stride = output_verts->vertex_size;
- output_verts->verts =
- (struct vertex_header *)MALLOC(output_verts->vertex_size *
- total_verts_per_buffer * shader->num_invocations);
- debug_assert(output_verts->verts);
+ for (i = 0; i < shader->num_vertex_streams; i++) {
+ /* write all the vertex data into all the streams */
+ output_verts[i].vertex_size = vertex_size;
+ output_verts[i].stride = output_verts[i].vertex_size;
+ output_verts[i].verts =
+ (struct vertex_header *)MALLOC(output_verts[i].vertex_size *
+ total_verts_per_buffer * shader->num_invocations);
+ debug_assert(output_verts[i].verts);
+ }
#if 0
debug_printf("%s count = %d (in prims # = %d)\n",
@@ -584,21 +619,22 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader,
total_verts_per_buffer);
#endif
- shader->emitted_vertices = 0;
- shader->emitted_primitives = 0;
+ for (i = 0; i < shader->num_vertex_streams; i++) {
+ shader->stream[i].emitted_vertices = 0;
+ shader->stream[i].emitted_primitives = 0;
+ FREE(shader->stream[i].primitive_lengths);
+ shader->stream[i].primitive_lengths = MALLOC(max_out_prims * sizeof(unsigned) * shader->num_invocations);
+ shader->stream[i].tmp_output = (float (*)[4])output_verts[i].verts->data;
+ }
shader->vertex_size = vertex_size;
- shader->tmp_output = (float (*)[4])output_verts->verts->data;
shader->fetched_prim_count = 0;
shader->input_vertex_stride = input_stride;
shader->input = input;
shader->input_info = input_info;
- FREE(shader->primitive_lengths);
- shader->primitive_lengths = MALLOC(max_out_prims * sizeof(unsigned) * shader->num_invocations);
-
#ifdef HAVE_LLVM
if (shader->draw->llvm) {
- shader->gs_output = output_verts->verts;
+ shader->gs_output = output_verts[0].verts;
if (max_out_prims > shader->max_out_prims) {
unsigned i;
if (shader->llvm_prim_lengths) {
@@ -646,32 +682,34 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader,
/* Update prim_info:
*/
- output_prims->linear = TRUE;
- output_prims->elts = NULL;
- output_prims->start = 0;
- output_prims->count = shader->emitted_vertices;
- output_prims->prim = shader->output_primitive;
- output_prims->flags = 0x0;
- output_prims->primitive_lengths = shader->primitive_lengths;
- output_prims->primitive_count = shader->emitted_primitives;
- output_verts->count = shader->emitted_vertices;
-
- if (shader->draw->collect_statistics) {
- unsigned i;
- for (i = 0; i < shader->emitted_primitives; ++i) {
- shader->draw->statistics.gs_primitives +=
- u_decomposed_prims_for_vertices(shader->output_primitive,
- shader->primitive_lengths[i]);
+ for (i = 0; i < shader->num_vertex_streams; i++) {
+ output_prims[i].linear = TRUE;
+ output_prims[i].elts = NULL;
+ output_prims[i].start = 0;
+ output_prims[i].count = shader->stream[i].emitted_vertices;
+ output_prims[i].prim = shader->output_primitive;
+ output_prims[i].flags = 0x0;
+ output_prims[i].primitive_lengths = shader->stream[i].primitive_lengths;
+ output_prims[i].primitive_count = shader->stream[i].emitted_primitives;
+ output_verts[i].count = shader->stream[i].emitted_vertices;
+
+ if (shader->draw->collect_statistics) {
+ unsigned j;
+ for (j = 0; j < shader->stream[i].emitted_primitives; ++j) {
+ shader->draw->statistics.gs_primitives +=
+ u_decomposed_prims_for_vertices(shader->output_primitive,
+ shader->stream[i].primitive_lengths[j]);
+ }
}
}
#if 0
- debug_printf("GS finished, prims = %d, verts = %d\n",
- output_prims->primitive_count,
- output_verts->count);
+ debug_printf("GS finished\n");
+ for (i = 0; i < 4; i++)
+ debug_printf("stream %d: prims = %d verts = %d\n", i, output_prims[i].primitive_count, output_verts[i].count);
#endif
- return shader->emitted_vertices;
+ return 0;
}
void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
@@ -693,15 +731,19 @@ draw_gs_init( struct draw_context *draw )
{
if (!draw->llvm) {
draw->gs.tgsi.machine = tgsi_exec_machine_create(PIPE_SHADER_GEOMETRY);
- if (!draw->gs.tgsi.machine)
- return FALSE;
- draw->gs.tgsi.machine->Primitives = align_malloc(
- MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector), 16);
- if (!draw->gs.tgsi.machine->Primitives)
- return FALSE;
- memset(draw->gs.tgsi.machine->Primitives, 0,
- MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector));
+ for (unsigned i = 0; i < TGSI_MAX_VERTEX_STREAMS; i++) {
+ draw->gs.tgsi.machine->Primitives[i] = align_malloc(
+ MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector), 16);
+ draw->gs.tgsi.machine->PrimitiveOffsets[i] = align_malloc(
+ MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector), 16);
+ if (!draw->gs.tgsi.machine->Primitives[i] || !draw->gs.tgsi.machine->PrimitiveOffsets[i])
+ return FALSE;
+ memset(draw->gs.tgsi.machine->Primitives[i], 0,
+ MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector));
+ memset(draw->gs.tgsi.machine->PrimitiveOffsets[i], 0,
+ MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector));
+ }
}
return TRUE;
@@ -709,8 +751,12 @@ draw_gs_init( struct draw_context *draw )
void draw_gs_destroy( struct draw_context *draw )
{
+ int i;
if (draw->gs.tgsi.machine) {
- align_free(draw->gs.tgsi.machine->Primitives);
+ for (i = 0; i < TGSI_MAX_VERTEX_STREAMS; i++) {
+ align_free(draw->gs.tgsi.machine->Primitives[i]);
+ align_free(draw->gs.tgsi.machine->PrimitiveOffsets[i]);
+ }
tgsi_exec_machine_destroy(draw->gs.tgsi.machine);
}
}
@@ -809,6 +855,12 @@ draw_create_geometry_shader(struct draw_context *draw,
gs->machine = draw->gs.tgsi.machine;
+ gs->num_vertex_streams = 1;
+ for (i = 0; i < gs->state.stream_output.num_outputs; i++) {
+ if (gs->state.stream_output.output[i].stream >= gs->num_vertex_streams)
+ gs->num_vertex_streams = gs->state.stream_output.output[i].stream + 1;
+ }
+
#ifdef HAVE_LLVM
if (use_llvm) {
int vector_size = gs->vector_length * sizeof(float);
@@ -864,6 +916,7 @@ void draw_bind_geometry_shader(struct draw_context *draw,
void draw_delete_geometry_shader(struct draw_context *draw,
struct draw_geometry_shader *dgs)
{
+ int i;
if (!dgs) {
return;
}
@@ -896,7 +949,8 @@ void draw_delete_geometry_shader(struct draw_context *draw,
}
#endif
- FREE(dgs->primitive_lengths);
+ for (i = 0; i < TGSI_MAX_VERTEX_STREAMS; i++)
+ FREE(dgs->stream[i].primitive_lengths);
FREE((void*) dgs->state.tokens);
FREE(dgs);
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_gs.h b/lib/mesa/src/gallium/auxiliary/draw/draw_gs.h
index 149278dd0..9a9154969 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_gs.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_gs.h
@@ -57,6 +57,13 @@ struct draw_gs_inputs {
/**
* Private version of the compiled geometry shader
*/
+struct draw_vertex_stream {
+ unsigned *primitive_lengths;
+ unsigned emitted_vertices;
+ unsigned emitted_primitives;
+ float (*tmp_output)[4];
+};
+
struct draw_geometry_shader {
struct draw_context *draw;
@@ -74,14 +81,11 @@ struct draw_geometry_shader {
unsigned primitive_boundary;
unsigned input_primitive;
unsigned output_primitive;
-
- unsigned *primitive_lengths;
- unsigned emitted_vertices;
- unsigned emitted_primitives;
-
- float (*tmp_output)[4];
unsigned vertex_size;
+ struct draw_vertex_stream stream[TGSI_MAX_VERTEX_STREAMS];
+ unsigned num_vertex_streams;
+
unsigned in_prim_idx;
unsigned input_vertex_stride;
unsigned fetched_prim_count;
@@ -109,14 +113,15 @@ struct draw_geometry_shader {
unsigned num_vertices,
unsigned prim_idx);
void (*fetch_outputs)(struct draw_geometry_shader *shader,
+ unsigned vertex_stream,
unsigned num_primitives,
float (**p_output)[4]);
void (*prepare)(struct draw_geometry_shader *shader,
const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS]);
- unsigned (*run)(struct draw_geometry_shader *shader,
- unsigned input_primitives);
+ void (*run)(struct draw_geometry_shader *shader,
+ unsigned input_primitives, unsigned *out_prims);
};
void draw_geometry_shader_new_instance(struct draw_geometry_shader *gs);
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pt.h b/lib/mesa/src/gallium/auxiliary/draw/draw_pt.h
index cb9a1b308..00527527f 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pt.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pt.h
@@ -188,6 +188,7 @@ struct pt_so_emit;
void draw_pt_so_emit_prepare(struct pt_so_emit *emit, boolean use_pre_clip_pos);
void draw_pt_so_emit( struct pt_so_emit *emit,
+ int num_vertex_streams,
const struct draw_vertex_info *vert_info,
const struct draw_prim_info *prim_info );
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_decompose.h b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_decompose.h
index c4fab6548..0b2522c08 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_decompose.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_decompose.h
@@ -3,8 +3,6 @@
const boolean quads_flatshade_last = \
draw->quads_always_flatshade_last; \
const boolean last_vertex_last = \
- !(draw->rasterizer->flatshade && \
- draw->rasterizer->flatshade_first);
-/* FIXME: the draw->rasterizer->flatshade part is really wrong */
+ !draw->rasterizer->flatshade_first;
#include "draw_decompose_tmp.h"
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
index f76e02299..07838fb7e 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
@@ -205,6 +205,7 @@ static void
draw_vertex_shader_run(struct draw_vertex_shader *vshader,
const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
unsigned const_size[PIPE_MAX_CONSTANT_BUFFERS],
+ const struct draw_fetch_info *fetch_info,
const struct draw_vertex_info *input_verts,
struct draw_vertex_info *output_verts)
{
@@ -222,7 +223,8 @@ draw_vertex_shader_run(struct draw_vertex_shader *vshader,
const_size,
input_verts->count,
input_verts->vertex_size,
- input_verts->vertex_size);
+ input_verts->vertex_size,
+ fetch_info->elts);
}
@@ -235,16 +237,17 @@ fetch_pipeline_generic(struct draw_pt_middle_end *middle,
struct draw_context *draw = fpme->draw;
struct draw_vertex_shader *vshader = draw->vs.vertex_shader;
struct draw_geometry_shader *gshader = draw->gs.geometry_shader;
- struct draw_prim_info gs_prim_info;
+ struct draw_prim_info gs_prim_info[TGSI_MAX_VERTEX_STREAMS];
struct draw_vertex_info fetched_vert_info;
struct draw_vertex_info vs_vert_info;
- struct draw_vertex_info gs_vert_info;
+ struct draw_vertex_info gs_vert_info[TGSI_MAX_VERTEX_STREAMS];
struct draw_vertex_info *vert_info;
struct draw_prim_info ia_prim_info;
struct draw_vertex_info ia_vert_info;
const struct draw_prim_info *prim_info = in_prim_info;
boolean free_prim_info = FALSE;
unsigned opt = fpme->opt;
+ int num_vertex_streams = 1;
fetched_vert_info.count = fetch_info->count;
fetched_vert_info.vertex_size = fpme->vertex_size;
@@ -267,18 +270,17 @@ fetch_pipeline_generic(struct draw_pt_middle_end *middle,
*/
fetch( fpme->fetch, fetch_info, (char *)fetched_vert_info.verts );
- /* Finished with fetch:
- */
- fetch_info = NULL;
vert_info = &fetched_vert_info;
/* Run the shader, note that this overwrites the data[] parts of
* the pipeline verts.
+ * Need fetch info to get vertex id correct.
*/
if (fpme->opt & PT_SHADE) {
draw_vertex_shader_run(vshader,
draw->pt.user.vs_constants,
draw->pt.user.vs_constants_size,
+ fetch_info,
vert_info,
&vs_vert_info);
@@ -286,6 +288,10 @@ fetch_pipeline_generic(struct draw_pt_middle_end *middle,
vert_info = &vs_vert_info;
}
+ /* Finished with fetch:
+ */
+ fetch_info = NULL;
+
if ((fpme->opt & PT_SHADE) && gshader) {
draw_geometry_shader_run(gshader,
draw->pt.user.gs_constants,
@@ -293,12 +299,13 @@ fetch_pipeline_generic(struct draw_pt_middle_end *middle,
vert_info,
prim_info,
&vshader->info,
- &gs_vert_info,
- &gs_prim_info);
+ gs_vert_info,
+ gs_prim_info);
FREE(vert_info->verts);
- vert_info = &gs_vert_info;
- prim_info = &gs_prim_info;
+ vert_info = &gs_vert_info[0];
+ prim_info = &gs_prim_info[0];
+ num_vertex_streams = gshader->num_vertex_streams;
/*
* pt emit can only handle ushort number of vertices (see
@@ -338,7 +345,7 @@ fetch_pipeline_generic(struct draw_pt_middle_end *middle,
* XXX: Stream output surely needs to respect the prim_info->elt
* lists.
*/
- draw_pt_so_emit( fpme->so_emit, vert_info, prim_info );
+ draw_pt_so_emit( fpme->so_emit, num_vertex_streams, vert_info, prim_info );
draw_stats_clipper_primitives(draw, prim_info);
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_so_emit.c
index 261bd3467..ea3169f32 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_so_emit.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_so_emit.c
@@ -49,6 +49,7 @@ struct pt_so_emit {
int pos_idx;
unsigned emitted_primitives;
unsigned generated_primitives;
+ unsigned stream;
};
static const struct pipe_stream_output_info *
@@ -144,6 +145,9 @@ static void so_emit_prim(struct pt_so_emit *so,
int ob = state->output[slot].output_buffer;
unsigned dst_offset = state->output[slot].dst_offset * sizeof(float);
unsigned write_size = num_comps * sizeof(float);
+
+ if (state->output[slot].stream != so->stream)
+ continue;
/* If a buffer is missing then that's equivalent to
* an overflow */
if (!draw->so.targets[ob]) {
@@ -175,7 +179,10 @@ static void so_emit_prim(struct pt_so_emit *so,
unsigned idx = state->output[slot].register_index;
unsigned start_comp = state->output[slot].start_component;
unsigned num_comps = state->output[slot].num_components;
+ unsigned stream = state->output[slot].stream;
+ if (stream != so->stream)
+ continue;
ob = state->output[slot].output_buffer;
buffer_written[ob] = TRUE;
@@ -184,7 +191,7 @@ static void so_emit_prim(struct pt_so_emit *so,
draw->so.targets[ob]->internal_offset) +
state->output[slot].dst_offset;
- if (idx == so->pos_idx && pcp_ptr)
+ if (idx == so->pos_idx && pcp_ptr && so->stream == 0)
memcpy(buffer, &pre_clip_pos[start_comp],
num_comps * sizeof(float));
else
@@ -193,8 +200,8 @@ static void so_emit_prim(struct pt_so_emit *so,
#if 0
{
int j;
- debug_printf("VERT[%d], offset = %d, slot[%d] sc = %d, num_c = %d, idx = %d = [",
- i,
+ debug_printf("VERT[%d], stream = %d, offset = %d, slot[%d] sc = %d, num_c = %d, idx = %d = [",
+ i, stream,
draw->so.targets[ob]->internal_offset,
slot, start_comp, num_comps, idx);
for (j = 0; j < num_comps; ++j) {
@@ -258,12 +265,13 @@ static void so_tri(struct pt_so_emit *so, int i0, int i1, int i2)
void draw_pt_so_emit( struct pt_so_emit *emit,
+ int num_vertex_streams,
const struct draw_vertex_info *input_verts,
const struct draw_prim_info *input_prims )
{
struct draw_context *draw = emit->draw;
struct vbuf_render *render = draw->render;
- unsigned start, i;
+ unsigned start, i, stream;
if (!emit->has_so)
return;
@@ -271,34 +279,36 @@ void draw_pt_so_emit( struct pt_so_emit *emit,
if (!draw->so.num_targets)
return;
- emit->emitted_primitives = 0;
- emit->generated_primitives = 0;
- emit->input_vertex_stride = input_verts->stride;
- if (emit->use_pre_clip_pos)
- emit->pre_clip_pos = input_verts->verts->clip_pos;
-
- emit->inputs = (const float (*)[4])input_verts->verts->data;
-
/* XXX: need to flush to get prim_vbuf.c to release its allocation??*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
- for (start = i = 0; i < input_prims->primitive_count;
- start += input_prims->primitive_lengths[i], i++)
- {
- unsigned count = input_prims->primitive_lengths[i];
-
- if (input_prims->linear) {
- so_run_linear(emit, input_prims, input_verts,
- start, count);
- } else {
- so_run_elts(emit, input_prims, input_verts,
- start, count);
+ for (stream = 0; stream < num_vertex_streams; stream++) {
+ emit->emitted_primitives = 0;
+ emit->generated_primitives = 0;
+ if (emit->use_pre_clip_pos)
+ emit->pre_clip_pos = input_verts[stream].verts->clip_pos;
+
+ emit->input_vertex_stride = input_verts[stream].stride;
+ emit->inputs = (const float (*)[4])input_verts[stream].verts->data;
+ emit->stream = stream;
+ for (start = i = 0; i < input_prims[stream].primitive_count;
+ start += input_prims[stream].primitive_lengths[i], i++)
+ {
+ unsigned count = input_prims[stream].primitive_lengths[i];
+
+ if (input_prims->linear) {
+ so_run_linear(emit, &input_prims[stream], &input_verts[stream],
+ start, count);
+ } else {
+ so_run_elts(emit, &input_prims[stream], &input_verts[stream],
+ start, count);
+ }
}
+ render->set_stream_output_info(render,
+ stream,
+ emit->emitted_primitives,
+ emit->generated_primitives);
}
-
- render->set_stream_output_info(render,
- emit->emitted_primitives,
- emit->generated_primitives);
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_vbuf.h b/lib/mesa/src/gallium/auxiliary/draw/draw_vbuf.h
index 8faccda55..6e737ae5b 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_vbuf.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_vbuf.h
@@ -125,6 +125,7 @@ struct vbuf_render {
* Called after writing data to the stream out buffers
*/
void (*set_stream_output_info)( struct vbuf_render *vbufr,
+ unsigned stream,
unsigned primitive_count,
unsigned primitive_generated );
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_vs.h b/lib/mesa/src/gallium/auxiliary/draw/draw_vs.h
index 6a900224c..65520ea6e 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_vs.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_vs.h
@@ -140,7 +140,8 @@ struct draw_vertex_shader {
const unsigned const_size[PIPE_MAX_CONSTANT_BUFFERS],
unsigned count,
unsigned input_stride,
- unsigned output_stride );
+ unsigned output_stride,
+ const unsigned *fetch_elts);
void (*delete)( struct draw_vertex_shader * );
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_vs_llvm.c b/lib/mesa/src/gallium/auxiliary/draw/draw_vs_llvm.c
index c92e43172..15486f8ff 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_vs_llvm.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_vs_llvm.c
@@ -53,7 +53,8 @@ vs_llvm_run_linear( struct draw_vertex_shader *shader,
const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
unsigned count,
unsigned input_stride,
- unsigned output_stride )
+ unsigned output_stride,
+ const unsigned *elts)
{
/* we should never get here since the entire pipeline is
* generated in draw_pt_fetch_shade_pipeline_llvm.c */
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_vs_variant.c b/lib/mesa/src/gallium/auxiliary/draw/draw_vs_variant.c
index af36a8667..44cf29b8e 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_vs_variant.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_vs_variant.c
@@ -179,7 +179,7 @@ static void PIPE_CDECL vsvg_run_elts( struct draw_vs_variant *variant,
vsvg->base.vs->draw->pt.user.vs_constants_size,
count,
temp_vertex_stride,
- temp_vertex_stride);
+ temp_vertex_stride, NULL);
/* FIXME: geometry shading? */
@@ -247,7 +247,7 @@ static void PIPE_CDECL vsvg_run_linear( struct draw_vs_variant *variant,
vsvg->base.vs->draw->pt.user.vs_constants_size,
count,
temp_vertex_stride,
- temp_vertex_stride);
+ temp_vertex_stride, NULL);
if (vsvg->base.key.clip) {
/* not really handling clipping, just do the rhw so we can