[Mesa-dev] [PATCH] st/mesa: use transfer_inline_write for memcpy TexSubImage path
Marek Olšák
maraeo at gmail.com
Mon May 23 22:49:50 UTC 2016
On Mon, May 23, 2016 at 10:31 PM, Miklós Máté <mtmkls at gmail.com> wrote:
> On 05/20/2016 05:42 PM, Ilia Mirkin wrote:
>>
>> On Fri, May 20, 2016 at 11:39 AM, Rob Herring <robh at kernel.org> wrote:
>>>
>>> On Mon, May 9, 2016 at 6:38 AM, Marek Olšák <maraeo at gmail.com> wrote:
>>>>
>>>> From: Marek Olšák <marek.olsak at amd.com>
>>>>
>>>> This allows drivers to use their own fast path for texture uploads.
>>>> ---
>>>> src/mesa/state_tracker/st_cb_texture.c | 43
>>>> ++++++++++++++++++++++++++++++----
>>>> 1 file changed, 39 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/src/mesa/state_tracker/st_cb_texture.c
>>>> b/src/mesa/state_tracker/st_cb_texture.c
>>>> index f181266..446a6d9 100644
>>>> --- a/src/mesa/state_tracker/st_cb_texture.c
>>>> +++ b/src/mesa/state_tracker/st_cb_texture.c
>>>> @@ -1698,15 +1698,50 @@ st_TexSubImage(struct gl_context *ctx, GLuint
>>>> dims,
>>>> GLenum gl_target = texImage->TexObject->Target;
>>>> unsigned bind;
>>>> GLubyte *map;
>>>> + unsigned dstz = texImage->Face + texImage->TexObject->MinLayer;
>>>> + unsigned dst_level = 0;
>>>> +
>>>> + if (stObj->pt == stImage->pt)
>>>> + dst_level = texImage->TexObject->MinLevel + texImage->Level;
>>>>
>>>> assert(!_mesa_is_format_etc2(texImage->TexFormat) &&
>>>> texImage->TexFormat != MESA_FORMAT_ETC1_RGB8);
>>>>
>>>> - if (!st->prefer_blit_based_texture_transfer) {
>>>> + if (!dst)
>>>> goto fallback;
>>>> +
>>>> + /* Try transfer_inline_write, which should be the fastest memcpy
>>>> path. */
>>>> + if (pixels &&
>>>> + !_mesa_is_bufferobj(unpack->BufferObj) &&
>>>> + _mesa_texstore_can_use_memcpy(ctx, texImage->_BaseFormat,
>>>> + texImage->TexFormat, format, type,
>>>> + unpack)) {
>>>> + struct pipe_box box;
>>>> + unsigned stride, layer_stride;
>>>> + void *data;
>>>> +
>>>> + stride = _mesa_image_row_stride(unpack, width, format, type);
>>>> + layer_stride = _mesa_image_image_stride(unpack, width, height,
>>>> format,
>>>> + type);
>>>> + data = _mesa_image_address(dims, unpack, pixels, width, height,
>>>> format,
>>>> + type, 0, 0, 0);
>>>> +
>>>> + /* Convert to Gallium coordinates. */
>>>> + if (gl_target == GL_TEXTURE_1D_ARRAY) {
>>>> + zoffset = yoffset;
>>>> + yoffset = 0;
>>>> + depth = height;
>>>> + height = 1;
>>>> + layer_stride = stride;
>>>> + }
>>>> +
>>>> + u_box_3d(xoffset, yoffset, zoffset + dstz, width, height, depth,
>>>> &box);
>>>> + pipe->transfer_inline_write(pipe, dst, dst_level, 0,
>>>> + &box, data, stride, layer_stride);
>>>
>>> This crashes with a NULL ptr on Android+virgl for me.
>>> transfer_inline_write is NULL for textures on virgl. It is not obvious
>>> to me how to fix this as pipe->transfer_inline_write itself is not
>>> NULL.
>>
>> virgl has to support transfer_inline_write... it's not legal to just
>> leave that out. I'm surprised this is the only place that's hitting
>> that path. Normally one uses the default implementation for this,
>> which just does a map + write + unmap.
>>
>> -ilia
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
> I'd like to add that it's generally undocumented in Mesa which callbacks are
> allowed to be NULL.
It's hinted by the code though. If some code compares a callback
against NULL, it can be NULL, otherwise it can't.
Marek
More information about the mesa-dev
mailing list