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.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_jit.c')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_jit.c | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index fa0f128ee3f..fa36fd3512e 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -45,7 +45,33 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) { struct gallivm_state *gallivm = lp->gallivm; LLVMContextRef lc = gallivm->context; - LLVMTypeRef texture_type, sampler_type; + LLVMTypeRef viewport_type, texture_type, sampler_type; + + /* struct lp_jit_viewport */ + { + LLVMTypeRef elem_types[LP_JIT_VIEWPORT_NUM_FIELDS]; + + elem_types[LP_JIT_VIEWPORT_MIN_DEPTH] = + elem_types[LP_JIT_VIEWPORT_MAX_DEPTH] = LLVMFloatTypeInContext(lc); + + viewport_type = LLVMStructTypeInContext(lc, elem_types, + Elements(elem_types), 0); + +#if HAVE_LLVM < 0x0300 + LLVMAddTypeName(gallivm->module, "viewport", viewport_type); + + LLVMInvalidateStructLayout(gallivm->target, viewport_type); +#endif + + LP_CHECK_MEMBER_OFFSET(struct lp_jit_viewport, min_depth, + gallivm->target, viewport_type, + LP_JIT_VIEWPORT_MIN_DEPTH); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_viewport, max_depth, + gallivm->target, viewport_type, + LP_JIT_VIEWPORT_MAX_DEPTH); + LP_CHECK_STRUCT_SIZE(struct lp_jit_viewport, + gallivm->target, viewport_type); + } /* struct lp_jit_texture */ { @@ -101,8 +127,8 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) gallivm->target, texture_type); } - { /* struct lp_jit_sampler */ + { LLVMTypeRef elem_types[LP_JIT_SAMPLER_NUM_FIELDS]; elem_types[LP_JIT_SAMPLER_MIN_LOD] = elem_types[LP_JIT_SAMPLER_MAX_LOD] = @@ -113,22 +139,22 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) sampler_type = LLVMStructTypeInContext(lc, elem_types, Elements(elem_types), 0); #if HAVE_LLVM < 0x0300 - LLVMAddTypeName(gallivm->module, "texture", texture_type); + LLVMAddTypeName(gallivm->module, "sampler", sampler_type); - LLVMInvalidateStructLayout(gallivm->target, texture_type); + LLVMInvalidateStructLayout(gallivm->target, sampler_type); #endif LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, min_lod, - gallivm->target, texture_type, + gallivm->target, sampler_type, LP_JIT_SAMPLER_MIN_LOD); LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, max_lod, - gallivm->target, texture_type, + gallivm->target, sampler_type, LP_JIT_SAMPLER_MAX_LOD); LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, lod_bias, - gallivm->target, texture_type, + gallivm->target, sampler_type, LP_JIT_SAMPLER_LOD_BIAS); LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, border_color, - gallivm->target, texture_type, + gallivm->target, sampler_type, LP_JIT_SAMPLER_BORDER_COLOR); LP_CHECK_STRUCT_SIZE(struct lp_jit_sampler, gallivm->target, sampler_type); @@ -146,6 +172,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) elem_types[LP_JIT_CTX_STENCIL_REF_BACK] = LLVMInt32TypeInContext(lc); elem_types[LP_JIT_CTX_U8_BLEND_COLOR] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0); elem_types[LP_JIT_CTX_F_BLEND_COLOR] = LLVMPointerType(LLVMFloatTypeInContext(lc), 0); + elem_types[LP_JIT_CTX_VIEWPORTS] = LLVMPointerType(viewport_type, 0); elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type, PIPE_MAX_SHADER_SAMPLER_VIEWS); elem_types[LP_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type, @@ -178,6 +205,9 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, f_blend_color, gallivm->target, context_type, LP_JIT_CTX_F_BLEND_COLOR); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, viewports, + gallivm->target, context_type, + LP_JIT_CTX_VIEWPORTS); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, textures, gallivm->target, context_type, LP_JIT_CTX_TEXTURES); @@ -196,6 +226,8 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) LLVMTypeRef thread_data_type; elem_types[LP_JIT_THREAD_DATA_COUNTER] = LLVMInt64TypeInContext(lc); + elem_types[LP_JIT_THREAD_DATA_RASTER_STATE_VIEWPORT_INDEX] = + LLVMInt32TypeInContext(lc); thread_data_type = LLVMStructTypeInContext(lc, elem_types, Elements(elem_types), 0); |