From 7756aae815a26c533948081c2c319c20bcf5962c Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Fri, 24 May 2013 16:17:26 -0400 Subject: draw: implement support for multiple viewports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds support for multiple viewports to the draw module. Multiple viewports depend on the presence of geometry shaders which can write the viewport index. Signed-off-by: Zack Rusin Reviewed-by: José Fonseca Reviewed-by: Brian Paul Reviewed-by: Roland Scheidegger --- src/gallium/auxiliary/draw/draw_pipe_clip.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_pipe_clip.c') diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c index 8da0c41..b01e519 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_clip.c +++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c @@ -127,6 +127,8 @@ static void interp( const struct clip_stage *clip, const unsigned clip_attr = draw_current_shader_clipvertex_output(clip->stage.draw); unsigned j; float t_nopersp; + unsigned viewport_index_output = + draw_current_shader_viewport_index_output(clip->stage.draw); /* Vertex header. */ @@ -145,9 +147,14 @@ static void interp( const struct clip_stage *clip, * new window coordinates: */ { + int viewport_index = + draw_current_shader_uses_viewport_index(clip->stage.draw) ? + *((unsigned*)in->data[viewport_index_output]) : 0; const float *pos = dst->pre_clip_pos; - const float *scale = clip->stage.draw->viewport.scale; - const float *trans = clip->stage.draw->viewport.translate; + const float *scale = + clip->stage.draw->viewports[viewport_index].scale; + const float *trans = + clip->stage.draw->viewports[viewport_index].translate; const float oow = 1.0f / pos[3]; dst->data[pos_attr][0] = pos[0] * oow * scale[0] + trans[0]; -- cgit v1.1