[Mesa-dev] [PATCH 16/34] i965: Separate image allocation with modifiers
Ben Widawsky
ben at bwidawsk.net
Mon Feb 6 05:04:51 UTC 2017
On 17-01-31 13:01:11, Jason Ekstrand wrote:
>On Mon, Jan 23, 2017 at 10:21 PM, Ben Widawsky <ben at bwidawsk.net> wrote:
>
>> Since the code doesn't support modifiers yet, this patch should do
>> nothing other than prepare for more patches.
>>
>> Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
>> Acked-by: Daniel Stone <daniels at collabora.com>
>> ---
>> src/mesa/drivers/dri/i965/intel_screen.c | 64
>> ++++++++++++++++++++++++--------
>> 1 file changed, 49 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c
>> b/src/mesa/drivers/dri/i965/intel_screen.c
>> index b7c0a55231..e3fe2a468f 100644
>> --- a/src/mesa/drivers/dri/i965/intel_screen.c
>> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
>> @@ -599,6 +599,48 @@ select_best_modifier(struct gen_device_info *devinfo,
>> #undef YTILE
>> }
>>
>> +static int
>> +create_image_with_modifier(struct intel_screen *screen,
>> + __DRIimage *image, uint64_t modifier,
>> + int width, int height, int cpp)
>> +{
>> + uint32_t tiling = I915_TILING_X;
>> + unsigned long pitch;
>> +
>> + switch (modifier) {
>> + case I915_FORMAT_MOD_Y_TILED:
>> + tiling = I915_TILING_Y;
>> + break;
>> + case I915_FORMAT_MOD_X_TILED:
>> + assert(tiling == I915_TILING_X);
>> + break;
>> + case DRM_FORMAT_MOD_LINEAR:
>> + tiling = I915_TILING_NONE;
>> + break;
>> + case DRM_FORMAT_MOD_INVALID:
>> + default:
>> + break;
>> + }
>> +
>> + image->bo = drm_intel_bo_alloc_tiled(screen->bufmgr, "image+mod",
>> + width, height, cpp, &tiling,
>> + &pitch, 0);
>> + if (image->bo == NULL)
>> + return false;
>> +
>> + if (tiling != I915_TILING_Y) {
>> + drm_intel_bo_unreference(image->bo);
>> + return false;
>>
>
>Why only Y-tiled?
>
>
This is a relic that should have been deleted (before X tile and LINEAR were
explicit modifier requests that I supported). Thanks (could have sworn I got rid
of it before... ah, I fixed it in a later patch - I moved that to here).
>> + }
>> +
>> + image->width = width;
>> + image->height = height;
>> + image->pitch = pitch;
>> + image->modifier = modifier;
>> +
>> + return true;
>> +}
>> +
>> static __DRIimage *
>> __intel_create_image(__DRIscreen *dri_screen,
>> int width, int height, int format,
>> @@ -623,20 +665,6 @@ __intel_create_image(__DRIscreen *dri_screen,
>> assert(!(use && count));
>>
>> uint64_t modifier = select_best_modifier(&screen->devinfo, modifiers,
>> count);
>> - switch (modifier) {
>> - case I915_FORMAT_MOD_X_TILED:
>> - assert(tiling == I915_TILING_X);
>> - break;
>> - case DRM_FORMAT_MOD_LINEAR:
>> - tiling = I915_TILING_NONE;
>> - break;
>> - case I915_FORMAT_MOD_Y_TILED:
>> - tiling = I915_TILING_Y;
>> - break;
>> - case DRM_FORMAT_MOD_INVALID:
>> - default:
>> - break;
>> - }
>>
>> if (use & __DRI_IMAGE_USE_CURSOR) {
>> if (width != 64 || height != 64)
>> @@ -652,6 +680,13 @@ __intel_create_image(__DRIscreen *dri_screen,
>> return NULL;
>>
>> cpp = _mesa_get_format_bytes(image->format);
>> + if (modifier != DRM_FORMAT_MOD_INVALID) {
>> + if (create_image_with_modifier(screen, image, modifier, width,
>> + height, cpp)) {
>> + return image;
>>
>
>Yeah, this is a good way to do it.
>
>
>> + }
>> + }
>> +
>> image->bo = drm_intel_bo_alloc_tiled(screen->bufmgr, "image",
>> width, height, cpp, &tiling,
>> &pitch, 0);
>> @@ -662,7 +697,6 @@ __intel_create_image(__DRIscreen *dri_screen,
>> image->width = width;
>> image->height = height;
>> image->pitch = pitch;
>> - image->modifier = modifier;
>>
>> return image;
>> }
>> --
>> 2.11.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