summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw/draw_context.c
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2013-05-24 16:17:26 -0400
committerZack Rusin <[email protected]>2013-05-25 09:49:20 -0400
commit7756aae815a26c533948081c2c319c20bcf5962c (patch)
tree36ca7a4f867101633387215925ce3e0d123f7e94 /src/gallium/auxiliary/draw/draw_context.c
parenteaabb4ead07ae043ecc789024028e225ebd0f318 (diff)
draw: implement support for multiple viewports
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 <[email protected]> Reviewed-by: José Fonseca<[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_context.c')
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c52
1 files changed, 42 insertions, 10 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index b555c65e858..4250f10d13a 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -318,17 +318,24 @@ void draw_set_viewport_states( struct draw_context *draw,
{
const struct pipe_viewport_state *viewport = vps;
draw_do_flush(draw, DRAW_FLUSH_PARAMETER_CHANGE);
- draw->viewport = *viewport; /* struct copy */
- draw->identity_viewport = (viewport->scale[0] == 1.0f &&
- viewport->scale[1] == 1.0f &&
- viewport->scale[2] == 1.0f &&
- viewport->scale[3] == 1.0f &&
- viewport->translate[0] == 0.0f &&
- viewport->translate[1] == 0.0f &&
- viewport->translate[2] == 0.0f &&
- viewport->translate[3] == 0.0f);
- draw_vs_set_viewport( draw, viewport );
+ if (start_slot > PIPE_MAX_VIEWPORTS)
+ return;
+
+ if ((start_slot + num_viewports) > PIPE_MAX_VIEWPORTS)
+ num_viewports = PIPE_MAX_VIEWPORTS - start_slot;
+
+ memcpy(draw->viewports + start_slot, vps,
+ sizeof(struct pipe_viewport_state) * num_viewports);
+ draw->identity_viewport = (num_viewports == 1) &&
+ (viewport->scale[0] == 1.0f &&
+ viewport->scale[1] == 1.0f &&
+ viewport->scale[2] == 1.0f &&
+ viewport->scale[3] == 1.0f &&
+ viewport->translate[0] == 0.0f &&
+ viewport->translate[1] == 0.0f &&
+ viewport->translate[2] == 0.0f &&
+ viewport->translate[3] == 0.0f);
}
@@ -695,6 +702,31 @@ draw_current_shader_position_output(const struct draw_context *draw)
/**
* Return the index of the shader output which will contain the
+ * viewport index.
+ */
+uint
+draw_current_shader_viewport_index_output(const struct draw_context *draw)
+{
+ if (draw->gs.geometry_shader)
+ return draw->gs.geometry_shader->viewport_index_output;
+ return 0;
+}
+
+/**
+ * Returns true if there's a geometry shader bound and the geometry
+ * shader writes out a viewport index.
+ */
+boolean
+draw_current_shader_uses_viewport_index(const struct draw_context *draw)
+{
+ if (draw->gs.geometry_shader)
+ return draw->gs.geometry_shader->info.writes_viewport_index;
+ return FALSE;
+}
+
+
+/**
+ * Return the index of the shader output which will contain the
* vertex position.
*/
uint