[Mesa-dev] [PATCH 11/13] i965/miptree: Refactor miptree_create
Nanley Chery
nanleychery at gmail.com
Wed Jun 13 16:32:22 UTC 2018
On Wed, Jun 13, 2018 at 09:44:14AM +0300, Pohjolainen, Topi wrote:
> On Tue, Jun 12, 2018 at 12:22:03PM -0700, Nanley Chery wrote:
> > Enable a future patch to create the r8stencil_mt in this function.
> > ---
> > src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 48 +++++--------------
> > 1 file changed, 12 insertions(+), 36 deletions(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > index 5e00da86d32..b078c759243 100644
> > --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > @@ -726,48 +726,24 @@ miptree_create(struct brw_context *brw,
> > intel_depth_format_for_depthstencil_format(format);
> > }
> >
> > - if (format == MESA_FORMAT_S_UINT8)
> > - return make_surface(brw, target, mt_fmt, first_level, last_level,
> > - width0, height0, depth0, num_samples,
> > - tiling_flags,
> > - mt_surf_usage(mt_fmt),
> > - alloc_flags,
> > - 0,
> > - NULL);
> > + struct intel_mipmap_tree *mt =
> > + make_surface(brw, target, mt_fmt, first_level, last_level,
> > + width0, height0, depth0, num_samples,
> > + tiling_flags, mt_surf_usage(mt_fmt),
> > + alloc_flags, 0, NULL);
> >
> > - const GLenum base_format = _mesa_get_format_base_format(format);
> > - if ((base_format == GL_DEPTH_COMPONENT ||
> > - base_format == GL_DEPTH_STENCIL)) {
> > - struct intel_mipmap_tree *mt = make_surface(
> > - brw, target, mt_fmt,
> > - first_level, last_level,
> > - width0, height0, depth0, num_samples, tiling_flags,
> > - mt_surf_usage(mt_fmt),
> > - alloc_flags, 0, NULL);
> > -
> > - if (needs_separate_stencil(brw, mt, format) &&
> > - !make_separate_stencil_surface(brw, mt)) {
> > + if (mt == NULL)
> > + return NULL;
> > +
> > + if (needs_separate_stencil(brw, mt, format)) {
> > + if (!make_separate_stencil_surface(brw, mt)) {
> > intel_miptree_release(&mt);
> > return NULL;
> > }
> > -
> > - if (!(flags & MIPTREE_CREATE_NO_AUX))
> > - intel_miptree_choose_aux_usage(brw, mt);
> > -
> > - return mt;
> > }
> >
> > - struct intel_mipmap_tree *mt = make_surface(
> > - brw, target, mt_fmt,
> > - first_level, last_level,
> > - width0, height0, depth0,
> > - num_samples, tiling_flags,
> > - mt_surf_usage(mt_fmt),
> > - alloc_flags, 0, NULL);
> > - if (!mt)
> > - return NULL;
> > -
> > - mt->etc_format = (mt_fmt != format) ? format : MESA_FORMAT_NONE;
> > + if (_mesa_is_format_color_format(format) && mt_fmt != format)
> > + mt->etc_format = format;
>
> This relies on MESA_FORMAT_NONE == 0 and make_surface() to use calloc().
> Should we play safe and:
>
> else
> mt->etc_format = MESA_FORMAT_NONE;
>
Sure, I plan to change it to this:
mt->etc_format = (_mesa_is_format_color_format(format) && mt_fmt != format) ?
format : MESA_FORMAT_NONE;
v2: Explicitly set etc_format to MESA_FORMAT_NONE (Topi)
> >
> > if (!(flags & MIPTREE_CREATE_NO_AUX))
> > intel_miptree_choose_aux_usage(brw, mt);
> > --
> > 2.17.0
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list