[igt-dev] [PATCH i-g-t 1/8] lib: Clear packed YUV formats to black

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Tue Jun 5 10:33:05 UTC 2018


Op 05-06-18 om 12:13 schreef Ville Syrjälä:
> On Tue, Jun 05, 2018 at 11:42:53AM +0200, Maarten Lankhorst wrote:
>> Op 23-05-18 om 20:31 schreef Ville Syrjala:
>>> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>>>
>>> As we do for NV12, let's also clear packed YUV formats to black instead
>>> of zero. Avoids unexpected green screens.
>>>
>>> v2: Nuke the debug messages
>>>
>>> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
>>> ---
>>>  lib/igt_fb.c | 32 ++++++++++++++++++++++++++++----
>>>  1 file changed, 28 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
>>> index a926a08d44e1..4f17f9945419 100644
>>> --- a/lib/igt_fb.c
>>> +++ b/lib/igt_fb.c
>>> @@ -335,6 +335,16 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling)
>>>  	}
>>>  }
>>>  
>>> +static void *memset32(void *s, uint32_t c, size_t n)
>>> +{
>>> +	uint32_t *ptr = s;
>>> +
>>> +	for (int i = 0; i < n; i++)
>>> +		*ptr++ = c;
>>> +
>>> +	return s;
>>> +}
>> Use wmemset?
> Is that actually well defined?
Everywhere except on windows, sizeof(wchar_t) == 4.

There's -fshort-wchar, but is only useful for wine (winehq.org), but it doesn't use it for some reason. :/
>>>  /* helpers to create nice-looking framebuffers */
>>>  static int create_bo_for_fb(int fd, int width, int height,
>>>  			    struct format_desc_struct *format,
>>> @@ -369,6 +379,7 @@ static int create_bo_for_fb(int fd, int width, int height,
>>>  
>>>  		if (is_i915_device(fd)) {
>>>  			uint8_t *ptr;
>>> +			bool full_range = false; /* FIXME */
>>>  
>>>  			bo = gem_create(fd, size);
>>>  			gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), stride);
>>> @@ -377,10 +388,23 @@ static int create_bo_for_fb(int fd, int width, int height,
>>>  			ptr = gem_mmap__gtt(fd, bo, size, PROT_READ | PROT_WRITE);
>>>  			igt_assert(*(uint32_t *)ptr == 0);
>>>  
>>> -			if (format->drm_id == DRM_FORMAT_NV12) {
>>> -				/* component formats have a different zero point */
>>> -				memset(ptr, 16, offsets[1]);
>>> -				memset(ptr + offsets[1], 0x80, (height + 1)/2 * stride);
>>> +			switch (format->drm_id) {
>>> +			case DRM_FORMAT_NV12:
>>> +				memset(ptr + offsets[0], full_range ? 0x00 : 0x10,
>>> +				       calculated_stride * height);
>>> +				memset(ptr + offsets[1], 0x80,
>>> +				       calculated_stride * height/2);
>>> +				break;
>>> +			case DRM_FORMAT_YUYV:
>>> +			case DRM_FORMAT_YVYU:
>>> +				memset32(ptr, full_range ? 0x80008000 : 0x80108010,
>>> +					 calculated_stride * height / 4);
>>> +				break;
>>> +			case DRM_FORMAT_UYVY:
>>> +			case DRM_FORMAT_VYUY:
>>> +				memset32(ptr, full_range ? 0x00800080 : 0x10801080,
>>> +					 calculated_stride * height / 4);
>>> +				break;
>>>  			}
>>>  			gem_munmap(ptr, size);
>>>  




More information about the igt-dev mailing list