On Wed, Jan 3, 2018 at 6:04 AM, Timothy Arceri <tarc...@itsqueeze.com> wrote:
> Reviewed-by: Nicolai Hähnle <nicolai.haeh...@amd.com>
> ---
>  src/gallium/drivers/radeonsi/si_shader.c | 124 
> +++++++++++++++++++++++++++++++
>  1 file changed, 124 insertions(+)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
> b/src/gallium/drivers/radeonsi/si_shader.c
> index 816396bf86..233f161f1c 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -1434,6 +1434,129 @@ static void store_output_tcs(struct 
> lp_build_tgsi_context *bld_base,
>         }
>  }
>
> +static void si_nir_store_output_tcs(struct ac_shader_abi *abi,
> +                                   LLVMValueRef vertex_index,
> +                                   LLVMValueRef param_index,
> +                                   unsigned const_index,
> +                                   unsigned location,
> +                                   unsigned driver_location,
> +                                   LLVMValueRef src,
> +                                   unsigned component,
> +                                   bool is_patch,
> +                                   bool is_compact,
> +                                   unsigned writemask)
> +{
> +       struct si_shader_context *ctx = si_shader_context_from_abi(abi);
> +       struct tgsi_shader_info *info = &ctx->shader->selector->info;
> +       LLVMValueRef dw_addr, stride;
> +       LLVMValueRef buffer, base, addr;
> +       LLVMValueRef values[4];
> +       bool skip_lds_store;
> +       bool is_tess_factor = false, is_tess_inner = false;
> +
> +       driver_location = driver_location / 4;
> +
> +       if (param_index) {
> +               /* Add the constant index to the indirect index */
> +               param_index = LLVMBuildAdd(ctx->ac.builder, param_index,
> +                                          LLVMConstInt(ctx->i32, 
> const_index, 0), "");
> +       } else {
> +               if (const_index != 0)
> +                       param_index = LLVMConstInt(ctx->i32, const_index, 0);
> +       }
> +
> +       if (!is_patch) {
> +               stride = get_tcs_out_vertex_dw_stride(ctx);
> +               dw_addr = get_tcs_out_current_patch_offset(ctx);
> +               dw_addr = get_dw_address_from_generic_indices(ctx, stride, 
> dw_addr,
> +                                                             vertex_index, 
> param_index,
> +                                                             driver_location,
> +                                                             
> info->output_semantic_name,
> +                                                             
> info->output_semantic_index,
> +                                                             is_patch);
> +
> +               skip_lds_store = !info->reads_pervertex_outputs;
> +       } else {
> +               dw_addr = get_tcs_out_current_patch_data_offset(ctx);
> +               dw_addr = get_dw_address_from_generic_indices(ctx, NULL, 
> dw_addr,
> +                                                             vertex_index, 
> param_index,
> +                                                             driver_location,
> +                                                             
> info->output_semantic_name,
> +                                                             
> info->output_semantic_index,
> +                                                             is_patch);
> +
> +               skip_lds_store = !info->reads_perpatch_outputs;
> +
> +               if (!param_index) {
> +                       int name = 
> info->output_semantic_name[driver_location];
> +
> +                       /* Always write tess factors into LDS for the TCS 
> epilog. */
> +                       if (name == TGSI_SEMANTIC_TESSINNER ||
> +                           name == TGSI_SEMANTIC_TESSOUTER) {
> +                               /* The epilog doesn't read LDS if invocation 
> 0 defines tess factors. */
> +                               skip_lds_store = 
> !info->reads_tessfactor_outputs &&
> +                                                
> ctx->shader->selector->tcs_info.tessfactors_are_def_in_all_invocs;
> +                               is_tess_factor = true;
> +                               is_tess_inner = name == 
> TGSI_SEMANTIC_TESSINNER;
> +                       }
> +               }
> +       }
> +
> +       buffer = desc_from_addr_base64k(ctx, 
> ctx->param_tcs_offchip_addr_base64k);
> +
> +       base = LLVMGetParam(ctx->main_fn, ctx->param_tcs_offchip_offset);
> +
> +       addr = get_tcs_tes_buffer_address_from_generic_indices(ctx, 
> vertex_index,
> +                                                              param_index, 
> driver_location,
> +                                                              
> info->output_semantic_name,
> +                                                              
> info->output_semantic_index,
> +                                                              is_patch);
> +
> +       for (unsigned chan = 0; chan < 4; chan++) {
> +               if (!(writemask & (1 << chan)))
> +                       continue;
> +               LLVMValueRef value = ac_llvm_extract_elem(&ctx->ac, src, chan 
> - component);
> +
> +               /* TODO: ??? handle equivalent of tgsis
> +                *
> +                * if(inst->Instruction.Saturate)
> +                *    value = ac_build_clamp(&ctx->ac, value);
> +                */

Does NIR even have saturate on output writes? If not, the TODO can be removed.

Marek
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to