[igt-dev] [PATCH i-g-t 1/3] lib/batchbuffer: Set bpp in igt_buf.

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Tue Nov 20 16:41:02 UTC 2018


Op 16-11-18 om 18:00 schreef Ville Syrjälä:
> On Fri, Nov 16, 2018 at 04:41:47PM +0100, Maarten Lankhorst wrote:
>> We want to allow bpp = 8 or 16, so make sure we set the bpp
>> in igt_buf. This way we can extend rendercopy to support
>> other values for bpp.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
>> ---
>>  lib/igt_draw.c                       | 2 ++
>>  lib/intel_batchbuffer.c              | 7 ++++---
>>  lib/intel_batchbuffer.h              | 2 ++
>>  tests/i915/gem_concurrent_all.c      | 2 ++
>>  tests/i915/gem_gpgpu_fill.c          | 1 +
>>  tests/i915/gem_media_fill.c          | 1 +
>>  tests/i915/gem_ppgtt.c               | 2 ++
>>  tests/i915/gem_read_read_speed.c     | 2 ++
>>  tests/i915/gem_render_copy.c         | 2 ++
>>  tests/i915/gem_render_copy_redux.c   | 1 +
>>  tests/i915/gem_render_linear_blits.c | 6 ++++++
>>  tests/i915/gem_render_tiled_blits.c  | 2 ++
>>  tests/i915/gem_ring_sync_copy.c      | 1 +
>>  tests/i915/gem_stress.c              | 1 +
>>  tests/kms_psr.c                      | 1 +
>>  tests/perf.c                         | 1 +
>>  tests/pm_sseu.c                      | 1 +
>>  17 files changed, 32 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/igt_draw.c b/lib/igt_draw.c
>> index 84dd212c1daf..94f16632730d 100644
>> --- a/lib/igt_draw.c
>> +++ b/lib/igt_draw.c
>> @@ -602,10 +602,12 @@ static void draw_rect_render(int fd, struct cmd_data *cmd_data,
>>  	src_buf.stride = tmp.stride;
>>  	src_buf.tiling = I915_TILING_NONE;
>>  	src_buf.size = tmp.size;
>> +	src_buf.bpp = 32;
>>  	dst_buf.bo = dst;
>>  	dst_buf.stride = buf->stride;
>>  	dst_buf.tiling = tiling;
>>  	dst_buf.size = buf->size;
>> +	dst_buf.bpp = 32;
>>  
>>  	batch = intel_batchbuffer_alloc(cmd_data->bufmgr, devid);
>>  	igt_assert(batch);
>> diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
>> index c13b1dc476a3..ad2e718f898c 100644
>> --- a/lib/intel_batchbuffer.c
>> +++ b/lib/intel_batchbuffer.c
>> @@ -511,7 +511,7 @@ intel_copy_bo(struct intel_batchbuffer *batch,
>>   */
>>  unsigned igt_buf_width(const struct igt_buf *buf)
>>  {
>> -	return buf->stride/sizeof(uint32_t);
>> +	return buf->stride/(buf->bpp / 8);
>>  }
>>  
>>  /**
>> @@ -764,7 +764,6 @@ void igt_blitter_fast_copy__raw(int fd,
>>   * @src_y: source pixel y-coordination
>>   * @width: width of the copied rectangle
>>   * @height: height of the copied rectangle
>> - * @bpp: source and destination bits per pixel
>>   * @dst: destination i-g-t buffer object
>>   * @dst_delta: offset into the destination i-g-t bo
>>   * @dst_x: destination pixel x-coordination
>> @@ -785,10 +784,12 @@ void igt_blitter_fast_copy(struct intel_batchbuffer *batch,
>>  	uint32_t src_pitch, dst_pitch;
>>  	uint32_t dword0, dword1;
>>  
>> +	igt_assert(src->bpp == dst->bpp);
>> +
>>  	src_pitch = fast_copy_pitch(src->stride, src->tiling);
>>  	dst_pitch = fast_copy_pitch(dst->stride, src->tiling);
>>  	dword0 = fast_copy_dword0(src->tiling, dst->tiling);
>> -	dword1 = fast_copy_dword1(src->tiling, dst->tiling, bpp);
>> +	dword1 = fast_copy_dword1(src->tiling, dst->tiling, dst->bpp);
>>  
>>  #define CHECK_RANGE(x)	((x) >= 0 && (x) < (1 << 15))
>>  	assert(CHECK_RANGE(src_x) && CHECK_RANGE(src_y) &&
>> diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
>> index 2dcb09ce8f08..ecc23f08da77 100644
>> --- a/lib/intel_batchbuffer.h
>> +++ b/lib/intel_batchbuffer.h
>> @@ -215,6 +215,7 @@ void intel_copy_bo(struct intel_batchbuffer *batch,
>>   * @bo: underlying libdrm buffer object
>>   * @stride: stride of the buffer
>>   * @tiling: tiling mode bits
>> + * @bpp: bits per pixel, 8, 16 or 32.
>>   * @data: pointer to the memory mapping of the buffer
>>   * @size: size of the buffer object
>>   *
>> @@ -226,6 +227,7 @@ struct igt_buf {
>>  	drm_intel_bo *bo;
>>  	uint32_t stride;
>>  	uint32_t tiling;
>> +	uint32_t bpp;
>>  	uint32_t *data;
>>  	uint32_t size;
>>  	struct {
>> diff --git a/tests/i915/gem_concurrent_all.c b/tests/i915/gem_concurrent_all.c
>> index 4ac08c1b1c90..6049372d1a61 100644
>> --- a/tests/i915/gem_concurrent_all.c
>> +++ b/tests/i915/gem_concurrent_all.c
>> @@ -854,11 +854,13 @@ static void render_copy_bo(struct buffers *b, drm_intel_bo *dst, drm_intel_bo *s
>>  		.size = b->npixels * 4,
>>  		.num_tiles = b->npixels * 4,
>>  		.stride = b->width * 4,
>> +		.bpp = 32,
>>  	}, s = {
>>  		.bo = src,
>>  		.size = b->npixels * 4,
>>  		.num_tiles = b->npixels * 4,
>>  		.stride = b->width * 4,
>> +		.bpp = 32,
>>  	};
>>  	uint32_t swizzle;
>>  
>> diff --git a/tests/i915/gem_gpgpu_fill.c b/tests/i915/gem_gpgpu_fill.c
>> index dfb5816527a7..68918c3e8721 100644
>> --- a/tests/i915/gem_gpgpu_fill.c
>> +++ b/tests/i915/gem_gpgpu_fill.c
>> @@ -78,6 +78,7 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,
>>  	buf->stride = stride;
>>  	buf->tiling = I915_TILING_NONE;
>>  	buf->size = SIZE;
>> +	buf->bpp = 32;
>>  }
>>  
>>  static void
>> diff --git a/tests/i915/gem_media_fill.c b/tests/i915/gem_media_fill.c
>> index 109af12933f6..a7d7708ca2ad 100644
>> --- a/tests/i915/gem_media_fill.c
>> +++ b/tests/i915/gem_media_fill.c
>> @@ -81,6 +81,7 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,
>>  	buf->stride = stride;
>>  	buf->tiling = I915_TILING_NONE;
>>  	buf->size = SIZE;
>> +	buf->bpp = 32;
>>  }
>>  
>>  static void
>> diff --git a/tests/i915/gem_ppgtt.c b/tests/i915/gem_ppgtt.c
>> index 86fe59f21092..c2e4ca679b2b 100644
>> --- a/tests/i915/gem_ppgtt.c
>> +++ b/tests/i915/gem_ppgtt.c
>> @@ -76,6 +76,7 @@ static void scratch_buf_init(struct igt_buf *buf,
>>  	buf->stride = STRIDE;
>>  	buf->tiling = I915_TILING_NONE;
>>  	buf->size = SIZE;
>> +	buf->bpp = 32;
>>  }
>>  
>>  static void scratch_buf_fini(struct igt_buf *buf)
>> @@ -132,6 +133,7 @@ static void fork_rcs_copy(int target, drm_intel_bo **dst, int count, unsigned fl
>>  		buf.stride = STRIDE;
>>  		buf.tiling = I915_TILING_NONE;
>>  		buf.size = SIZE;
>> +		buf.bpp = 32;
>>  
>>  		for (int i = 0; i <= target; i++) {
>>  			struct igt_buf src;
>> diff --git a/tests/i915/gem_read_read_speed.c b/tests/i915/gem_read_read_speed.c
>> index 3dcf440c7f81..5f1356eb9cd3 100644
>> --- a/tests/i915/gem_read_read_speed.c
>> +++ b/tests/i915/gem_read_read_speed.c
>> @@ -56,11 +56,13 @@ static drm_intel_bo *rcs_copy_bo(drm_intel_bo *dst, drm_intel_bo *src)
>>  		.size = width * height * 4,
>>  		.num_tiles = width * height * 4,
>>  		.stride = width * 4,
>> +		.bpp = 32,
>>  	}, s = {
>>  		.bo = src,
>>  		.size = width * height * 4,
>>  		.num_tiles = width * height * 4,
>>  		.stride = width * 4,
>> +		.bpp = 32,
>>  	};
>>  	uint32_t swizzle;
>>  	drm_intel_bo *bo = batch->bo;
>> diff --git a/tests/i915/gem_render_copy.c b/tests/i915/gem_render_copy.c
>> index 17a6656427f8..b7a4f2593ad9 100644
>> --- a/tests/i915/gem_render_copy.c
>> +++ b/tests/i915/gem_render_copy.c
>> @@ -287,6 +287,7 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,
>>  		buf->stride = ALIGN(width * 4, 128);
>>  		buf->size = buf->stride * height;
>>  		buf->tiling = tiling;
>> +		buf->bpp = 32;
>>  
>>  		aux_width = scratch_buf_aux_width(buf);
>>  		aux_height = scratch_buf_aux_height(buf);
>> @@ -309,6 +310,7 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,
>>  		buf->stride = pitch;
>>  		buf->tiling = tiling;
>>  		buf->size = pitch * height;
>> +		buf->bpp = 32;;
> double ;;
>
> Otherwise lgtm
> Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
>>  	}
>>  
>>  	igt_assert(igt_buf_width(buf) == width);
>> diff --git a/tests/i915/gem_render_copy_redux.c b/tests/i915/gem_render_copy_redux.c
>> index a861862d08d0..24b838ba785b 100644
>> --- a/tests/i915/gem_render_copy_redux.c
>> +++ b/tests/i915/gem_render_copy_redux.c
>> @@ -109,6 +109,7 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,
>>  	buf->stride = stride;
>>  	buf->tiling = I915_TILING_NONE;
>>  	buf->size = SIZE;
>> +	buf->bpp = 32;
>>  }
>>  
>>  static void scratch_buf_fini(data_t *data, struct igt_buf *buf)
>> diff --git a/tests/i915/gem_render_linear_blits.c b/tests/i915/gem_render_linear_blits.c
>> index a1a7e0338235..667ee8722f7c 100644
>> --- a/tests/i915/gem_render_linear_blits.c
>> +++ b/tests/i915/gem_render_linear_blits.c
>> @@ -111,11 +111,13 @@ static void run_test (int fd, int count)
>>  		src.stride = STRIDE;
>>  		src.tiling = I915_TILING_NONE;
>>  		src.size = SIZE;
>> +		src.bpp = 32;
>>  
>>  		dst.bo = bo[(i + 1) % count];
>>  		dst.stride = STRIDE;
>>  		dst.tiling = I915_TILING_NONE;
>>  		dst.size = SIZE;
>> +		dst.bpp = 32;
>>  
>>  		render_copy(batch, NULL, &src, 0, 0, WIDTH, HEIGHT, &dst, 0, 0);
>>  		start_val[(i + 1) % count] = start_val[i % count];
>> @@ -134,11 +136,13 @@ static void run_test (int fd, int count)
>>  		src.stride = STRIDE;
>>  		src.tiling = I915_TILING_NONE;
>>  		src.size = SIZE;
>> +		src.bpp = 32;
>>  
>>  		dst.bo = bo[i % count];
>>  		dst.stride = STRIDE;
>>  		dst.tiling = I915_TILING_NONE;
>>  		dst.size = SIZE;
>> +		dst.bpp = 32;
>>  
>>  		render_copy(batch, NULL, &src, 0, 0, WIDTH, HEIGHT, &dst, 0, 0);
>>  		start_val[i % count] = start_val[(i + 1) % count];
>> @@ -159,11 +163,13 @@ static void run_test (int fd, int count)
>>  		src.stride = STRIDE;
>>  		src.tiling = I915_TILING_NONE;
>>  		src.size = SIZE;
>> +		src.bpp = 32;
>>  
>>  		dst.bo = bo[d];
>>  		dst.stride = STRIDE;
>>  		dst.tiling = I915_TILING_NONE;
>>  		dst.size = SIZE;
>> +		dst.bpp = 32;
>>  
>>  		render_copy(batch, NULL, &src, 0, 0, WIDTH, HEIGHT, &dst, 0, 0);
>>  		start_val[d] = start_val[s];
>> diff --git a/tests/i915/gem_render_tiled_blits.c b/tests/i915/gem_render_tiled_blits.c
>> index 3484d561a4b1..3007f2abd655 100644
>> --- a/tests/i915/gem_render_tiled_blits.c
>> +++ b/tests/i915/gem_render_tiled_blits.c
>> @@ -69,6 +69,7 @@ check_bo(struct intel_batchbuffer *batch, struct igt_buf *buf, uint32_t val)
>>  	tmp.stride = STRIDE;
>>  	tmp.tiling = I915_TILING_NONE;
>>  	tmp.size = SIZE;
>> +	tmp.bpp = 32;
>>  
>>  	render_copy(batch, NULL, buf, 0, 0, WIDTH, HEIGHT, &tmp, 0, 0);
>>  	if (snoop) {
>> @@ -134,6 +135,7 @@ static void run_test (int fd, int count)
>>  		buf[i].stride = pitch;
>>  		buf[i].tiling = tiling;
>>  		buf[i].size = SIZE;
>> +		buf[i].bpp = 32;
>>  
>>  		start_val[i] = start;
>>  
>> diff --git a/tests/i915/gem_ring_sync_copy.c b/tests/i915/gem_ring_sync_copy.c
>> index 8d3723559f76..1e5728bce740 100644
>> --- a/tests/i915/gem_ring_sync_copy.c
>> +++ b/tests/i915/gem_ring_sync_copy.c
>> @@ -137,6 +137,7 @@ static void scratch_buf_init_from_bo(struct igt_buf *buf, drm_intel_bo *bo)
>>  	buf->stride = 4 * WIDTH;
>>  	buf->tiling = I915_TILING_NONE;
>>  	buf->size = 4 * WIDTH * HEIGHT;
>> +	buf->bpp = 32;
>>  }
>>  
>>  static void scratch_buf_init(data_t *data, struct igt_buf *buf,
>> diff --git a/tests/i915/gem_stress.c b/tests/i915/gem_stress.c
>> index 225f283e4256..ef8316f2b48e 100644
>> --- a/tests/i915/gem_stress.c
>> +++ b/tests/i915/gem_stress.c
>> @@ -485,6 +485,7 @@ static void init_buffer(struct igt_buf *buf, unsigned size)
>>  	igt_assert(buf->bo);
>>  	buf->tiling = I915_TILING_NONE;
>>  	buf->stride = 4096;
>> +	buf->bpp = 32;
>>  
>>  	sanitize_stride(buf);
>>  
>> diff --git a/tests/kms_psr.c b/tests/kms_psr.c
>> index 9767f475bf23..d00e552fad50 100644
>> --- a/tests/kms_psr.c
>> +++ b/tests/kms_psr.c
>> @@ -153,6 +153,7 @@ static void scratch_buf_init(struct igt_buf *buf, drm_intel_bo *bo,
>>  	buf->stride = stride;
>>  	buf->tiling = I915_TILING_X;
>>  	buf->size = size;
>> +	buf->bpp = 32;
>>  }
>>  
>>  static void fill_render(data_t *data, uint32_t handle, unsigned char color)
>> diff --git a/tests/perf.c b/tests/perf.c
>> index 4f09aef7b028..134d9617b41d 100644
>> --- a/tests/perf.c
>> +++ b/tests/perf.c
>> @@ -501,6 +501,7 @@ scratch_buf_init(drm_intel_bufmgr *bufmgr,
>>  	buf->stride = stride;
>>  	buf->tiling = I915_TILING_NONE;
>>  	buf->size = size;
>> +	buf->bpp = 32;
>>  }
>>  
>>  static void
>> diff --git a/tests/pm_sseu.c b/tests/pm_sseu.c
>> index 5fdcbef223c0..252df7d3a707 100644
>> --- a/tests/pm_sseu.c
>> +++ b/tests/pm_sseu.c
>> @@ -303,6 +303,7 @@ gem_init(void)
>>  	gem.buf.tiling = I915_TILING_NONE;
>>  	gem.buf.size = gem.buf.stride;
>>  	gem.buf.bo = drm_intel_bo_alloc(gem.bufmgr, "", gem.buf.size, 4096);
>> +	gem.buf.bpp = 32;
>>  	igt_assert(gem.buf.bo);
>>  	gem.init = 4;
>>  
>> -- 
>> 2.19.1
>>
>> _______________________________________________
>> igt-dev mailing list
>> igt-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/igt-dev

Thanks, pushed with fixups and assertion added to make sure src->bpp == dst->bpp. :)



More information about the igt-dev mailing list