Bug 60143

Summary: gbm_dri_bo_create fails to initialize bo->base.base.format
Product: Mesa Reporter: Daniel van Vugt <daniel.van.vugt>
Component: OtherAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: 9.0   
Hardware: Other   
OS: All   
See Also: https://launchpad.net/bugs/1112147
Whiteboard:
i915 platform: i915 features:
Attachments: gbm_dri_bo_create: Remember to initialize format
[PATCH] gbm: Remember to init format on gbm_dri_bo_create

Description Daniel van Vugt 2013-02-01 05:42:28 UTC
Calling gbm_bo_create() with format == GBM_BO_FORMAT_ARGB8888 completes successfully. However reading back the format via gbm_bo_get_format() returns GBM_BO_FORMAT_XRGB8888.

The problem seems to be that the bo internal structure is initialized to zero by calloc, but the format field is never set by gbm_dri_bo_create, so it stays zero (GBM_BO_FORMAT_XRGB8888) even when the real image format is something different.

Should be a simple fix in gbm_dri_bo_create(). Just add:
  bo->base.base.format = gbm_dri_to_gbm_format(dri_format);
Comment 1 Daniel van Vugt 2013-02-01 06:42:29 UTC
Or even simpler fix...
  bo->base.base.format = format;
Comment 2 Daniel van Vugt 2013-02-06 09:31:23 UTC
Created attachment 74279 [details] [review]
gbm_dri_bo_create: Remember to initialize format
Comment 3 Kristian Høgsberg 2013-02-06 21:26:46 UTC
(In reply to comment #2)
> Created attachment 74279 [details] [review] [review]
> gbm_dri_bo_create: Remember to initialize format

That looks good, but please also fix create_dumb() and attach output of git format-patch -1 so I can git am it.  Thanks!
Comment 4 Daniel van Vugt 2013-02-07 05:12:50 UTC
Created attachment 74319 [details] [review]
[PATCH] gbm: Remember to init format on gbm_dri_bo_create
Comment 5 Kristian Høgsberg 2013-02-08 01:02:14 UTC
Pushed to master.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.