[Mesa-dev] [PATCH 2/2] ac: use the common helper ac_apply_fmask_to_sample
Marek Olšák
maraeo at gmail.com
Fri Apr 12 15:04:09 UTC 2019
On Thu, Apr 11, 2019 at 3:15 AM Samuel Pitoiset <samuel.pitoiset at gmail.com>
wrote:
>
> On 4/11/19 3:30 AM, Marek Olšák wrote:
> > From: Marek Olšák <marek.olsak at amd.com>
> >
> > ---
> > src/amd/common/ac_nir_to_llvm.c | 70 +++------------------------------
> > 1 file changed, 5 insertions(+), 65 deletions(-)
> >
> > diff --git a/src/amd/common/ac_nir_to_llvm.c
> b/src/amd/common/ac_nir_to_llvm.c
> > index 3d2f738edec..3abde6e0969 100644
> > --- a/src/amd/common/ac_nir_to_llvm.c
> > +++ b/src/amd/common/ac_nir_to_llvm.c
> > @@ -2323,92 +2323,32 @@ static int image_type_to_components_count(enum
> glsl_sampler_dim dim, bool array)
> > case GLSL_SAMPLER_DIM_SUBPASS:
> > return 2;
> > case GLSL_SAMPLER_DIM_SUBPASS_MS:
> > return 3;
> > default:
> > break;
> > }
> > return 0;
> > }
> >
> > -
> > -/* Adjust the sample index according to FMASK.
> > - *
> > - * For uncompressed MSAA surfaces, FMASK should return 0x76543210,
> > - * which is the identity mapping. Each nibble says which physical sample
> > - * should be fetched to get that sample.
> > - *
> > - * For example, 0x11111100 means there are only 2 samples stored and
> > - * the second sample covers 3/4 of the pixel. When reading samples 0
> > - * and 1, return physical sample 0 (determined by the first two 0s
> > - * in FMASK), otherwise return physical sample 1.
> > - *
> > - * The sample index should be adjusted as follows:
> > - * sample_index = (fmask >> (sample_index * 4)) & 0xF;
> > - */
> > static LLVMValueRef adjust_sample_index_using_fmask(struct
> ac_llvm_context *ctx,
> > LLVMValueRef coord_x,
> LLVMValueRef coord_y,
> > LLVMValueRef coord_z,
> > LLVMValueRef
> sample_index,
> > LLVMValueRef
> fmask_desc_ptr)
> > {
> > - struct ac_image_args args = {0};
> > - LLVMValueRef res;
> > + unsigned sample_chan = coord_z ? 3 : 2;
> > + LLVMValueRef addr[4] = {coord_x, coord_y, coord_z};
> > + addr[sample_chan] = sample_index;
> >
> > - args.coords[0] = coord_x;
> > - args.coords[1] = coord_y;
> > - if (coord_z)
> > - args.coords[2] = coord_z;
> > -
> > - args.opcode = ac_image_load;
> > - args.dim = coord_z ? ac_image_2darray : ac_image_2d;
> > - args.resource = fmask_desc_ptr;
> > - args.dmask = 0xf;
> > - args.attributes = AC_FUNC_ATTR_READNONE;
> > -
> > - res = ac_build_image_opcode(ctx, &args);
> > -
> > - res = ac_to_integer(ctx, res);
> > - LLVMValueRef four = LLVMConstInt(ctx->i32, 4, false);
> > - LLVMValueRef F = LLVMConstInt(ctx->i32, 0xf, false);
> > -
> > - LLVMValueRef fmask = LLVMBuildExtractElement(ctx->builder,
> > - res,
> > - ctx->i32_0, "");
> > -
> > - LLVMValueRef sample_index4 =
> > - LLVMBuildMul(ctx->builder, sample_index, four, "");
> > - LLVMValueRef shifted_fmask =
> > - LLVMBuildLShr(ctx->builder, fmask, sample_index4, "");
> > - LLVMValueRef final_sample =
> > - LLVMBuildAnd(ctx->builder, shifted_fmask, F, "");
>
> The only difference is the mask (ie. ac_apply_fmask_to_sample uses 0x7)
> while this code uses 0xF.
>
Yes.
>
> According to the comment in that function, I assume 0x7 is the correct
> value?
>
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.
Marek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190412/5ee0d4db/attachment.html>
More information about the mesa-dev
mailing list