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_jit.h | |
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_jit.h')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_jit.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 30cfaaef5d6..8eefa7c8479 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -70,6 +70,13 @@ struct lp_jit_sampler }; +struct lp_jit_viewport +{ + float min_depth; + float max_depth; +}; + + enum { LP_JIT_TEXTURE_WIDTH = 0, LP_JIT_TEXTURE_HEIGHT, @@ -93,6 +100,13 @@ enum { }; +enum { + LP_JIT_VIEWPORT_MIN_DEPTH, + LP_JIT_VIEWPORT_MAX_DEPTH, + LP_JIT_VIEWPORT_NUM_FIELDS /* number of fields above */ +}; + + /** * This structure is passed directly to the generated fragment shader. * @@ -115,6 +129,8 @@ struct lp_jit_context uint8_t *u8_blend_color; float *f_blend_color; + struct lp_jit_viewport *viewports; + struct lp_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS]; struct lp_jit_sampler samplers[PIPE_MAX_SAMPLERS]; }; @@ -131,6 +147,7 @@ enum { LP_JIT_CTX_STENCIL_REF_BACK, LP_JIT_CTX_U8_BLEND_COLOR, LP_JIT_CTX_F_BLEND_COLOR, + LP_JIT_CTX_VIEWPORTS, LP_JIT_CTX_TEXTURES, LP_JIT_CTX_SAMPLERS, LP_JIT_CTX_COUNT @@ -155,6 +172,9 @@ enum { #define lp_jit_context_f_blend_color(_gallivm, _ptr) \ lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_F_BLEND_COLOR, "f_blend_color") +#define lp_jit_context_viewports(_gallivm, _ptr) \ + lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_VIEWPORTS, "viewports") + #define lp_jit_context_textures(_gallivm, _ptr) \ lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_TEXTURES, "textures") @@ -165,11 +185,19 @@ enum { struct lp_jit_thread_data { uint64_t vis_counter; + + /* + * Non-interpolated rasterizer state passed through to the fragment shader. + */ + struct { + uint32_t viewport_index; + } raster_state; }; enum { LP_JIT_THREAD_DATA_COUNTER = 0, + LP_JIT_THREAD_DATA_RASTER_STATE_VIEWPORT_INDEX, LP_JIT_THREAD_DATA_COUNT }; @@ -177,7 +205,11 @@ enum { #define lp_jit_thread_data_counter(_gallivm, _ptr) \ lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_THREAD_DATA_COUNTER, "counter") - +#define lp_jit_thread_data_raster_state_viewport_index(_gallivm, _ptr) \ + lp_build_struct_get(_gallivm, _ptr, \ + LP_JIT_THREAD_DATA_RASTER_STATE_VIEWPORT_INDEX, \ + "raster_state.viewport_index") + /** * typedef for fragment shader function * |