diff options
author | Dave Airlie <[email protected]> | 2020-03-20 14:29:46 +1000 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-05-06 06:20:37 +0000 |
commit | 38e81938b65ebc32654f20a65fa8c3673c0c1cf6 (patch) | |
tree | 228a535a00d29af1ea1cb5c7bea22c700ec8d6e3 /src | |
parent | 210d714f46e72c954857ba32ca9ffcffbc264c9c (diff) |
llvmpipe: hook up sample position system value
This creates a global static with the current sample positions,
and passes it to the fragment shader which uses it for interpolation
and sample position support.
Reviewed-by: Roland Scheidegger <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_fs.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 70c28a8c411..7a35960c3c3 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -304,6 +304,7 @@ generate_fs_loop(struct gallivm_state *gallivm, LLVMBuilderRef builder, struct lp_type type, LLVMValueRef context_ptr, + LLVMValueRef sample_pos_array, LLVMValueRef num_loop, struct lp_build_interp_soa_context *interp, const struct lp_build_sampler_soa *sampler, @@ -592,6 +593,8 @@ generate_fs_loop(struct gallivm_state *gallivm, lp_build_interp_soa_update_pos_dyn(interp, gallivm, loop_state.counter, NULL); } + system_values.sample_pos = sample_pos_array; + lp_build_interp_soa_update_inputs_dyn(interp, gallivm, loop_state.counter, NULL, NULL); struct lp_build_tgsi_params params; @@ -2776,6 +2779,26 @@ generate_fragment(struct llvmpipe_context *lp, LLVMValueRef num_loop_samp = lp_build_const_int32(gallivm, num_fs * key->coverage_samples); LLVMValueRef mask_store = lp_build_array_alloca(gallivm, mask_type, num_loop_samp, "mask_store"); + + LLVMTypeRef flt_type = LLVMFloatTypeInContext(gallivm->context); + LLVMValueRef glob_sample_pos = LLVMAddGlobal(gallivm->module, flt_type, ""); + LLVMValueRef sample_pos_array; + + if (key->multisample && key->coverage_samples == 4) { + LLVMValueRef sample_pos_arr[8]; + for (unsigned i = 0; i < 4; i++) { + sample_pos_arr[i * 2] = LLVMConstReal(flt_type, lp_sample_pos_4x[i][0]); + sample_pos_arr[i * 2 + 1] = LLVMConstReal(flt_type, lp_sample_pos_4x[i][1]); + } + sample_pos_array = LLVMConstArray(LLVMFloatTypeInContext(gallivm->context), sample_pos_arr, 8); + } else { + LLVMValueRef sample_pos_arr[2]; + sample_pos_arr[0] = LLVMConstReal(flt_type, 0.5); + sample_pos_arr[1] = LLVMConstReal(flt_type, 0.5); + sample_pos_array = LLVMConstArray(LLVMFloatTypeInContext(gallivm->context), sample_pos_arr, 2); + } + LLVMSetInitializer(glob_sample_pos, sample_pos_array); + LLVMValueRef color_store[PIPE_MAX_COLOR_BUFS][TGSI_NUM_CHANNELS]; boolean pixel_center_integer = shader->info.base.properties[TGSI_PROPERTY_FS_COORD_PIXEL_CENTER]; @@ -2790,7 +2813,8 @@ generate_fragment(struct llvmpipe_context *lp, shader->info.base.num_inputs, inputs, pixel_center_integer, - 1, NULL, num_loop, + key->coverage_samples, glob_sample_pos, + num_loop, key->depth_clamp, builder, fs_type, a0_ptr, dadx_ptr, dady_ptr, @@ -2843,6 +2867,7 @@ generate_fragment(struct llvmpipe_context *lp, builder, fs_type, context_ptr, + glob_sample_pos, num_loop, &interp, sampler, |