summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2013-03-12 13:41:35 -0700
committerZack Rusin <[email protected]>2013-03-12 16:22:26 -0700
commit42c1b33f6d5ee1ab4ab7fdc8a7ab2c1dcd9e43e6 (patch)
treedde9000298c2889dba997facc15c333a50662ef2 /src
parent57cd1d1454653f778837eec0ee5d4060bc59c5ba (diff)
draw/so: Fix stream output with geometry shaders
If geometry shader is present its stream output info should be used instead of the vs and we shouldn't use the pre-clipped corrdinates. Signed-off-by: Zack Rusin <[email protected]> Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_so_emit.c37
2 files changed, 31 insertions, 8 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
index 5fc94364b4e..288b5242ae8 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
@@ -102,7 +102,7 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle,
(boolean)draw->rasterizer->gl_rasterization_rules,
(draw->vs.edgeflag_output ? TRUE : FALSE) );
- draw_pt_so_emit_prepare( fpme->so_emit, TRUE );
+ draw_pt_so_emit_prepare( fpme->so_emit, gs == NULL );
if (!(opt & PT_PIPELINE)) {
draw_pt_emit_prepare( fpme->emit,
diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
index 13d8470e4ec..64ed5441e7c 100644
--- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
@@ -27,6 +27,7 @@
#include "draw/draw_private.h"
#include "draw/draw_vs.h"
+#include "draw/draw_gs.h"
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
#include "draw/draw_vertex.h"
@@ -51,13 +52,37 @@ struct pt_so_emit {
unsigned generated_primitives;
};
+static const struct pipe_stream_output_info *
+draw_so_info(const struct draw_context *draw)
+{
+ const struct pipe_stream_output_info *state = NULL;
+
+ if (draw->gs.geometry_shader) {
+ state = &draw->gs.geometry_shader->state.stream_output;
+ } else {
+ state = &draw->vs.vertex_shader->state.stream_output;
+ }
+
+ return state;
+}
+
+static INLINE boolean
+draw_has_so(const struct draw_context *draw)
+{
+ const struct pipe_stream_output_info *state = draw_so_info(draw);
+
+ if (state && state->num_outputs > 0)
+ return TRUE;
+
+ return FALSE;
+}
void draw_pt_so_emit_prepare(struct pt_so_emit *emit, boolean use_pre_clip_pos)
{
struct draw_context *draw = emit->draw;
emit->use_pre_clip_pos = use_pre_clip_pos;
- emit->has_so = (draw->vs.vertex_shader->state.stream_output.num_outputs > 0);
+ emit->has_so = draw_has_so(draw);
if (use_pre_clip_pos)
emit->pos_idx = draw_current_shader_position_output(draw);
@@ -92,8 +117,7 @@ static void so_emit_prim(struct pt_so_emit *so,
struct draw_context *draw = so->draw;
const float (*input_ptr)[4];
const float (*pcp_ptr)[4] = NULL;
- const struct pipe_stream_output_info *state =
- &draw->vs.vertex_shader->state.stream_output;
+ const struct pipe_stream_output_info *state = draw_so_info(draw);
float *buffer;
int buffer_total_bytes[PIPE_MAX_SO_BUFFERS];
@@ -125,9 +149,8 @@ static void so_emit_prim(struct pt_so_emit *so,
for (i = 0; i < num_vertices; ++i) {
const float (*input)[4];
const float (*pre_clip_pos)[4];
- unsigned total_written_compos = 0;
int ob;
- /*debug_printf("%d) vertex index = %d (prim idx = %d)\n", i, indices[i], prim_idx);*/
+
input = (const float (*)[4])(
(const char *)input_ptr + (indices[i] * input_vertex_stride));
@@ -145,11 +168,11 @@ static void so_emit_prim(struct pt_so_emit *so,
buffer = (float *)((char *)draw->so.targets[ob]->mapping +
draw->so.targets[ob]->target.buffer_offset +
draw->so.targets[ob]->internal_offset) + state->output[slot].dst_offset;
+
if (idx == so->pos_idx && pcp_ptr)
- memcpy(buffer, &pre_clip_pos[start_comp], num_comps * sizeof(float));
+ memcpy(buffer, &pre_clip_pos[idx][start_comp], num_comps * sizeof(float));
else
memcpy(buffer, &input[idx][start_comp], num_comps * sizeof(float));
- total_written_compos += num_comps;
}
for (ob = 0; ob < draw->so.num_targets; ++ob)
draw->so.targets[ob]->internal_offset += state->stride[ob] * sizeof(float);