diff options
author | Matthew McClure <[email protected]> | 2013-11-26 10:50:27 -0800 |
---|---|---|
committer | José Fonseca <[email protected]> | 2013-12-09 12:57:02 +0000 |
commit | 0319ea9ff6a9cc2eba4879fbe09c6fac137d6ce1 (patch) | |
tree | af651e31eae395fb14550a9e2c3d38a61013135b /src/gallium/drivers/llvmpipe/lp_setup.c | |
parent | 992a2dbba80aba35efe83202e1013bd6143f0dba (diff) |
llvmpipe: clamp fragment shader depth write to the current viewport depth range.
With this patch, generate_fs_loop will clamp any fragment shader depth writes
to the viewport's min and max depth values. Viewport selection is determined
by the geometry shader output for the viewport array index. If no index is
specified, then the default viewport index is zero. Semantics for this path
can be found in draw_clamp_viewport_idx and lp_clamp_viewport_idx.
lp_jit_viewport was created to store viewport information visible to JIT code,
and is validated when the LP_NEW_VIEWPORT dirty flag is set.
lp_rast_shader_inputs is responsible for passing the viewport_index through
the rasterizer stage to fragment stage (via lp_jit_thread_data).
Reviewed-by: Roland Scheidegger <[email protected]>
Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_setup.c')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 9b277d32ddc..31aaf963fe9 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -649,6 +649,41 @@ lp_setup_set_vertex_info( struct lp_setup_context *setup, /** + * Called during state validation when LP_NEW_VIEWPORT is set. + */ +void +lp_setup_set_viewports(struct lp_setup_context *setup, + unsigned num_viewports, + const struct pipe_viewport_state *viewports) +{ + unsigned i; + + LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__); + + assert(num_viewports <= PIPE_MAX_VIEWPORTS); + assert(viewports); + + /* + * For use in lp_state_fs.c, propagate the viewport values for all viewports. + */ + for (i = 0; i < num_viewports; i++) { + float min_depth; + float max_depth; + + min_depth = viewports[i].translate[2]; + max_depth = viewports[i].translate[2] + viewports[i].scale[2]; + + if (setup->viewports[i].min_depth != min_depth || + setup->viewports[i].max_depth != max_depth) { + setup->viewports[i].min_depth = min_depth; + setup->viewports[i].max_depth = max_depth; + setup->dirty |= LP_SETUP_NEW_VIEWPORTS; + } + } +} + + +/** * Called during state validation when LP_NEW_SAMPLER_VIEW is set. */ void @@ -863,6 +898,15 @@ lp_setup_is_resource_referenced( const struct lp_setup_context *setup, /** * Called by vbuf code when we're about to draw something. + * + * This function stores all dirty state in the current scene's display list + * memory, via lp_scene_alloc(). We can not pass pointers of mutable state to + * the JIT functions, as the JIT functions will be called later on, most likely + * on a different thread. + * + * When processing dirty state it is imperative that we don't refer to any + * pointers previously allocated with lp_scene_alloc() in this function (or any + * function) as they may belong to a scene freed since then. */ static boolean try_update_scene_state( struct lp_setup_context *setup ) @@ -873,6 +917,29 @@ try_update_scene_state( struct lp_setup_context *setup ) assert(scene); + if (setup->dirty & LP_SETUP_NEW_VIEWPORTS) { + /* + * Record new depth range state for changes due to viewport updates. + * + * TODO: Collapse the existing viewport and depth range information + * into one structure, for access by JIT. + */ + struct lp_jit_viewport *stored; + + stored = (struct lp_jit_viewport *) + lp_scene_alloc(scene, sizeof setup->viewports); + + if (!stored) { + assert(!new_scene); + return FALSE; + } + + memcpy(stored, setup->viewports, sizeof setup->viewports); + + setup->fs.current.jit_context.viewports = stored; + setup->dirty |= LP_SETUP_NEW_FS; + } + if(setup->dirty & LP_SETUP_NEW_BLEND_COLOR) { uint8_t *stored; float* fstored; |