<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 8, 2017 at 4:16 PM, Chad Versace <span dir="ltr"><<a href="mailto:chadversary@chromium.org" target="_blank">chadversary@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon 06 Mar 2017, Jason Ekstrand wrote:<br>
> On Mon, Mar 6, 2017 at 10:12 AM, Chad Versace <<a href="mailto:chadversary@chromium.org">chadversary@chromium.org</a>><br>
> wrote:<br>
><br>
> > The caller does so by setting the new field<br>
> > isl_surf_init_info::row_pitch, which overrides isl's row pitch<br>
> > calculation.<br>
> > ---<br>
> > src/intel/isl/isl.c | 11 ++++++++++-<br>
> > src/intel/isl/isl.h | 9 +++++++++<br>
> > 2 files changed, 19 insertions(+), 1 deletion(-)<br>
> ><br>
> > diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c<br>
> > index a91c3f92bcf..b3ac305b81b 100644<br>
> > --- a/src/intel/isl/isl.c<br>
> > +++ b/src/intel/isl/isl.c<br>
> > @@ -1005,6 +1005,9 @@ isl_calc_linear_row_pitch(<wbr>const struct isl_device<br>
> > *dev,<br>
> > {<br>
> > const struct isl_format_layout *fmtl = isl_format_get_layout(info-><br>
> > format);<br>
> ><br>
> > + /* Any override of row_pitch should happen earlier. */<br>
> > + assert(info->row_pitch == 0);<br>
> > +<br>
> > uint32_t row_pitch = info->min_row_pitch;<br>
> ><br>
> > /* First, align the surface to a cache line boundary, as the PRM<br>
> > explains<br>
> > @@ -1088,6 +1091,9 @@ isl_calc_tiled_row_pitch(const struct isl_device<br>
> > *dev,<br>
> > {<br>
> > const struct isl_format_layout *fmtl = isl_format_get_layout(info-><br>
> > format);<br>
> ><br>
> > + /* Any override of row_pitch should happen earlier. */<br>
> > + assert(info->row_pitch == 0);<br>
> > +<br>
> > assert(fmtl->bpb % tile_info->format_bpb == 0);<br>
> > assert(phys_slice0_sa->w % fmtl->bw == 0);<br>
> ><br>
> > @@ -1112,7 +1118,10 @@ isl_calc_row_pitch(const struct isl_device *dev,<br>
> > const struct isl_tile_info *tile_info,<br>
> > const struct isl_extent2d *phys_slice0_sa)<br>
> > {<br>
> > - if (tile_info->tiling == ISL_TILING_LINEAR) {<br>
> > + if (info->row_pitch != 0) {<br>
> > + /* Override the usual calculation and validation. */<br>
> > + return info->row_pitch;<br>
> > + } else if (tile_info->tiling == ISL_TILING_LINEAR) {<br>
> > return isl_calc_linear_row_pitch(dev, info, phys_slice0_sa);<br>
> > } else {<br>
> > return isl_calc_tiled_row_pitch(dev, info, tile_info,<br>
> > phys_slice0_sa);<br>
> > diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h<br>
> > index e517f11cf5e..5f73639fb48 100644<br>
> > --- a/src/intel/isl/isl.h<br>
> > +++ b/src/intel/isl/isl.h<br>
> > @@ -813,6 +813,15 @@ struct isl_surf_init_info {<br>
> > /** Lower bound for isl_surf::row_pitch, in bytes. */<br>
> > uint32_t min_row_pitch;<br>
> ><br>
> > + /**<br>
> > + * Exact value for isl_surf::row_pitch. Ignored if zero.<br>
> > + *<br>
> > + * WARNING: If set, then isl_surf_init() skips many calculations and<br>
> > + * validations. If the given row pitch is incompatible with the<br>
> > requested<br>
> > + * surface, then behavior is undefined.<br>
> ><br>
><br>
> I'm not a fan. I would much rather supplying a row_pitch mean "please<br>
> validate and use this" rather than "trust me". I don't want isl_surf_init<br>
> to succeed and still give you a bad surface. Sorry if that means real<br>
> work. :-/<br>
<br>
</div></div>Ok. Here's my suggestion.<br>
<br>
I can fix this patch so that isl_surf_init() continues to calculate the<br>
row pitch, just as it always has. But treat that calculated row pitch as<br>
the minimum required pitch. If the requested row pitch is 0, use the min<br>
pitch. If the user actually requests a row pitch, then check that the<br>
requested row pitch is aligned correctly and meets the min pitch<br>
requirement.<br>
<br>
Do you see a cleaner way?<br>
</blockquote></div><br></div><div class="gmail_extra">Row pitch, in general, is defined by a minimum and an alignment. When you want to choose a row pitch, you allign the minimum to the alignment. If you want to validate a row pitch, you check that it's large enough and aligned. Am I missing something?<br></div></div>