[Mesa-dev] [RFC] gallium/u_blitter: support blitting PIPE_BUFFERs

Rob Clark robdclark at gmail.com
Wed Nov 22 15:01:42 UTC 2017


yes, because that ends up being a cpu copy for BUFFER (ie. stall),
which is what I'm trying to avoid in the first place ;-)

Maybe this needs to map things to a linear 2d buffer for larger sizes,
not sure.  One way or another at the hw level this gets treated like a
2d render target (which might have height=1).  I was trying to think
of a way to do this hack in driver, but it is awkward without frob'ing
prsc->target (which isn't really safe to do if the resource is shared
between contexts on different threads).

Or maybe other option is to fall back to memcpy for BUFFERs that are
too large.  In practice, this isn't a problem, at least not with the
games I'm looking at.

BR,
-R

On Wed, Nov 22, 2017 at 9:47 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Are you sure you're not looking for resource_copy_region? BUFFERs can
> be wide (128MB in many impls), 1D textures can't. There are probably
> other differences.
>
> On Wed, Nov 22, 2017 at 9:43 AM, Rob Clark <robdclark at gmail.com> wrote:
>> It is useful for staging/shadow transfers for drivers to be able to blit
>> BUFFERs.  Treat them as R8 1D textures for this purpose.
>>
>> Signed-off-by: Rob Clark <robdclark at gmail.com>
>> ---
>> This works at least if 1D textures are linear, so I suppose might not
>> work for all drivers.  Although I'm not entirely sure what the point
>> of a tiled 1D texture is.  And I guess drivers for which this wouldn't
>> work could continue to just not use u_blitter for BUFFERs.
>>
>>  src/gallium/auxiliary/util/u_blitter.c | 12 ++++++++++--
>>  1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
>> index 476ef08737e..7ba7b5aa57d 100644
>> --- a/src/gallium/auxiliary/util/u_blitter.c
>> +++ b/src/gallium/auxiliary/util/u_blitter.c
>> @@ -1445,7 +1445,10 @@ void util_blitter_default_dst_texture(struct pipe_surface *dst_templ,
>>                                        unsigned dstz)
>>  {
>>     memset(dst_templ, 0, sizeof(*dst_templ));
>> -   dst_templ->format = util_format_linear(dst->format);
>> +   if (dst->target == PIPE_BUFFER)
>> +      dst_templ->format = PIPE_FORMAT_R8_UINT;
>> +   else
>> +      dst_templ->format = util_format_linear(dst->format);
>>     dst_templ->u.tex.level = dstlevel;
>>     dst_templ->u.tex.first_layer = dstz;
>>     dst_templ->u.tex.last_layer = dstz;
>> @@ -1482,7 +1485,12 @@ void util_blitter_default_src_texture(struct blitter_context *blitter,
>>     else
>>        src_templ->target = src->target;
>>
>> -   src_templ->format = util_format_linear(src->format);
>> +   if (src->target  == PIPE_BUFFER) {
>> +      src_templ->target = PIPE_TEXTURE_1D;
>> +      src_templ->format = PIPE_FORMAT_R8_UINT;
>> +   } else {
>> +      src_templ->format = util_format_linear(src->format);
>> +   }
>>     src_templ->u.tex.first_level = srclevel;
>>     src_templ->u.tex.last_level = srclevel;
>>     src_templ->u.tex.first_layer = 0;
>> --
>> 2.13.6
>>
>> _______________________________________________
>> 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