[Mesa-dev] [PATCH v2 2/2] main/format: skip format conversion if src and dst format are equal
Kenneth Graunke
kenneth at whitecape.org
Sun Oct 8 21:07:15 UTC 2017
On Sunday, October 8, 2017 9:44:34 AM PDT Karol Herbst wrote:
> thanks for improving that Patch for me. Currently a bit occupied with
> other things, but hopefully I can back to fixing bugs for CTS next
> month!
>
> Anyhow, test is passing for me on Nouveau and i965 with the updated patches.
Great :)
> On Sat, Oct 7, 2017 at 10:42 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> > From: Karol Herbst <karolherbst at gmail.com>
> >
> > Fixes 'KHR-GL45.copy_image.functional' on Nouveau and i965.
> >
> > v2: (by Kenneth Graunke)
> > Rewrite patch according to Jason Ekstrand's review feedback.
> > This makes it handle differing strides, which i965 needed.
> >
> > Signed-off-by: Karol Herbst <karolherbst at gmail.com>
> > ---
> > src/mesa/main/format_utils.c | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c
> > index d16d69c3795..31580750bd4 100644
> > --- a/src/mesa/main/format_utils.c
> > +++ b/src/mesa/main/format_utils.c
> > @@ -312,6 +312,20 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,
> > * enable it for specific combinations that are known to work.
> > */
> > if (!rebase_swizzle) {
> > + /* Do a direct memcpy where possible */
> > + if ((dst_format_is_mesa_array_format &&
> > + src_format_is_mesa_array_format &&
> > + src_array_format == dst_array_format) ||
> > + src_format == dst_format) {
> > + int format_size = _mesa_get_format_bytes(src_format);
> > + for (row = 0; row < height; row++) {
> > + memcpy(dst, src, width * format_size);
> > + src += src_stride;
> > + dst += dst_stride;
> > + }
>
> in my first draft I actually had a for loop like that, but I was using
> width * src_stride and then came up with the idea of doing just one
> memcpy. But I guess it isn't possible now and maybe it was even wrong
> before.
That would work when src_stride == dst_stride. If stride > width *
format_size, then it would also copy padding at the end of each row
unnecessarily. But, in the case where they match, and there isn't
padding, it would probably be better...
I think your original patch worked fine, it just only handled a very
specific case. For i965, I needed to handle mismatched strides - one
was larger, presumably due to tiling...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171008/0c12d9a5/attachment.sig>
More information about the mesa-dev
mailing list