<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 11, 2019 at 3:15 AM Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
On 4/11/19 3:30 AM, Marek Olšák wrote:<br>
> From: Marek Olšák <<a href="mailto:marek.olsak@amd.com" target="_blank">marek.olsak@amd.com</a>><br>
><br>
> ---<br>
>   src/amd/common/ac_nir_to_llvm.c | 70 +++------------------------------<br>
>   1 file changed, 5 insertions(+), 65 deletions(-)<br>
><br>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c<br>
> index 3d2f738edec..3abde6e0969 100644<br>
> --- a/src/amd/common/ac_nir_to_llvm.c<br>
> +++ b/src/amd/common/ac_nir_to_llvm.c<br>
> @@ -2323,92 +2323,32 @@ static int image_type_to_components_count(enum glsl_sampler_dim dim, bool array)<br>
>       case GLSL_SAMPLER_DIM_SUBPASS:<br>
>               return 2;<br>
>       case GLSL_SAMPLER_DIM_SUBPASS_MS:<br>
>               return 3;<br>
>       default:<br>
>               break;<br>
>       }<br>
>       return 0;<br>
>   }<br>
>   <br>
> -<br>
> -/* Adjust the sample index according to FMASK.<br>
> - *<br>
> - * For uncompressed MSAA surfaces, FMASK should return 0x76543210,<br>
> - * which is the identity mapping. Each nibble says which physical sample<br>
> - * should be fetched to get that sample.<br>
> - *<br>
> - * For example, 0x11111100 means there are only 2 samples stored and<br>
> - * the second sample covers 3/4 of the pixel. When reading samples 0<br>
> - * and 1, return physical sample 0 (determined by the first two 0s<br>
> - * in FMASK), otherwise return physical sample 1.<br>
> - *<br>
> - * The sample index should be adjusted as follows:<br>
> - *   sample_index = (fmask >> (sample_index * 4)) & 0xF;<br>
> - */<br>
>   static LLVMValueRef adjust_sample_index_using_fmask(struct ac_llvm_context *ctx,<br>
>                                                   LLVMValueRef coord_x, LLVMValueRef coord_y,<br>
>                                                   LLVMValueRef coord_z,<br>
>                                                   LLVMValueRef sample_index,<br>
>                                                   LLVMValueRef fmask_desc_ptr)<br>
>   {<br>
> -     struct ac_image_args args = {0};<br>
> -     LLVMValueRef res;<br>
> +     unsigned sample_chan = coord_z ? 3 : 2;<br>
> +     LLVMValueRef addr[4] = {coord_x, coord_y, coord_z};<br>
> +     addr[sample_chan] = sample_index;<br>
>   <br>
> -     args.coords[0] = coord_x;<br>
> -     args.coords[1] = coord_y;<br>
> -     if (coord_z)<br>
> -             args.coords[2] = coord_z;<br>
> -<br>
> -     args.opcode = ac_image_load;<br>
> -     args.dim = coord_z ? ac_image_2darray : ac_image_2d;<br>
> -     args.resource = fmask_desc_ptr;<br>
> -     args.dmask = 0xf;<br>
> -     args.attributes = AC_FUNC_ATTR_READNONE;<br>
> -<br>
> -     res = ac_build_image_opcode(ctx, &args);<br>
> -<br>
> -     res = ac_to_integer(ctx, res);<br>
> -     LLVMValueRef four = LLVMConstInt(ctx->i32, 4, false);<br>
> -     LLVMValueRef F = LLVMConstInt(ctx->i32, 0xf, false);<br>
> -<br>
> -     LLVMValueRef fmask = LLVMBuildExtractElement(ctx->builder,<br>
> -                                                  res,<br>
> -                                                  ctx->i32_0, "");<br>
> -<br>
> -     LLVMValueRef sample_index4 =<br>
> -             LLVMBuildMul(ctx->builder, sample_index, four, "");<br>
> -     LLVMValueRef shifted_fmask =<br>
> -             LLVMBuildLShr(ctx->builder, fmask, sample_index4, "");<br>
> -     LLVMValueRef final_sample =<br>
> -             LLVMBuildAnd(ctx->builder, shifted_fmask, F, "");<br>
<br>
The only difference is the mask (ie. ac_apply_fmask_to_sample uses 0x7) <br>
while this code uses 0xF.<br></blockquote><div><br></div><div>Yes.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
According to the comment in that function, I assume 0x7 is the correct <br>
value?<br></blockquote><div><br></div><div>Yes, it's for EQAA. Only samples 0-7 can occur with MSAA. If EQAA is used, 0x8 means the color of the sample is unknown, which is mapped to sample 0 by the 0x7 mask.</div><div><br></div><div>Marek</div></div></div>