[Mesa-dev] [PATCH] i965: fix dma_buf import with non-zero offset.

Gwenole Beauchesne gb.devel at gmail.com
Tue Mar 11 22:00:14 PDT 2014


Hi,

2014-03-11 19:06 GMT+01:00 Eric Anholt <eric at anholt.net>:
> Gwenole Beauchesne <gb.devel at gmail.com> writes:
>
>> Fix eglCreateImage() from a packed dma_buf surface with a non-zero offset
>> to pixels data. In particular, this fixes support for planar YUV surfaces
>> when they are individually mapped on a per-plane basis, i.e. when the
>> OES_EGL_image_external is not used and user application wants to use its
>> own shader code for composition, or processing on individual plane (OCL).
>>
>> Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
>> ---
>>  src/mesa/drivers/dri/i965/intel_screen.c |    9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
>> index 05cf6b1..81a8330 100644
>> --- a/src/mesa/drivers/dri/i965/intel_screen.c
>> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
>> @@ -651,6 +651,7 @@ intel_create_image_from_fds(__DRIscreen *screen,
>>  {
>>     struct intel_screen *intelScreen = screen->driverPrivate;
>>     struct intel_image_format *f;
>> +   uint32_t mask_x, mask_y;
>>     __DRIimage *image;
>>     int i, index;
>>
>> @@ -684,6 +685,14 @@ intel_create_image_from_fds(__DRIscreen *screen,
>>        image->strides[index] = strides[index];
>>     }
>>
>> +   if (f->nplanes == 1) {
>> +      image->offset = image->offsets[0];
>> +      intel_region_get_tile_masks(image->region, &mask_x, &mask_y, false);
>> +      if (image->offset & mask_x)
>> +         _mesa_warning(NULL,
>> +                       "intel_create_image_from_fds: offset not on tile boundary");
>> +   }
>
> I'm confused here.  offset is a byte offset, right?  If so, then a tile
> boundary is 4096, not the byte width of a row in a tile.
>
> Are you planning on supporting non-4096-aligned imports?  I'm hoping
> not.

You are right.

Would the following be OK then?

image->offset = image->offsets[0];
if (image->region->tiling != I915_TILING_NONE && (image->offset & 0xfff))
   _mesa_warning(NULL, "intel_create_image_from_fds: offset not on
tile boundary");

(and we might also fix from_planar() along the way?)

Thanks,
Gwenole.


More information about the mesa-dev mailing list