tests/kms_big_fb: Test planar formats, and CCS
v2 cover tests/kms_big_fb: Test planar formats, and CCS
From: Ville Syrjälä <[email protected]>
While poking around in the i915 display surface address calculations I decided that we should increase our testing coverage to include planar formats, and compressed modifiers.
This series achieves the bare minimum of that; We now test uncompressed NV12 and P016 [1], and compressed RGB on up to TGL (not sure about anything more recent yet).
[1] compressed planar formats would require a mechanism to do the copy_pattern() stuff, and unfortunately the current vebox copy implementation leaves us hanging by not supporting arbitraty coordinates
v2: Hopefully fixed the TGL clear color woes
Ville Syrjälä (15):
lib/rendercopy: Add deltas to all surface relocs tests/kms_big_fb: Use igt_fb_create_intel_buf() lib/igt_fb: Expose igt_fb_is_ccs_modifier() tests/kms_big_fb: Fix async
tests/kms_big_fb: Test async flips + linear on tgl+ tests/kms_big_fb: Determine the max fb size the same way always tests/kms_frontbuffer_tracking: Use igt_create_fb() lib/igt_fb: Make igt_calc_fb_size() somewhat usable tests/kms_big_fb: Nuke fliptab[]
tests/kms_big_fb: Replace 'bpp' with 'name' tests/kms_big_fb: Test planar YCbCr formats tests/kms_big_fb: Also test some CCS modifiers lib/rendercopy: Always setup clear color for TGL tests/kms_big_fb: Enable CCS testing for TGL lib/rendercopy: Enable clear color consistently
lib/igt_fb.c | 94 +++---- lib/igt_fb.h | 4 +- lib/intel_bufops.h | 2 + lib/rendercopy_gen4.c | 11 +- lib/rendercopy_gen6.c | 11 +- lib/rendercopy_gen7.c | 11 +- lib/rendercopy_gen8.c | 13 +- lib/rendercopy_gen9.c | 37 ++- lib/rendercopy_i830.c | 10 +- lib/rendercopy_i915.c | 6 +- tests/intel/gem_pxp.c | 4 +- tests/intel/kms_big_fb.c | 328 +++++++++++++++---------- tests/intel/kms_frontbuffer_tracking.c | 11 +- tests/kms_addfb_basic.c | 14 +- tests/kms_prime.c | 12 +- tests/kms_rotation_crc.c | 10 +- 16 files changed, 333 insertions(+), 245 deletions(-)
Signature · 1 line
2.41.0
PATCH v2 1/15 lib/rendercopy: Add deltas to all surface relocs
From: Ville Syrjälä <[email protected]>
In order to copy stuff not at offset 0 in the BO we need to include the delta in the relocs/etc.
v2: fix the address in the command packets
--- lib/rendercopy_gen4.c | 11 ++++++----- lib/rendercopy_gen6.c | 11 ++++++----- lib/rendercopy_gen7.c | 11 ++++++----- lib/rendercopy_gen8.c | 13 +++++++------ lib/rendercopy_gen9.c | 13 +++++++------ lib/rendercopy_i830.c | 10 +++++++--- lib/rendercopy_i915.c | 6 ++++-- 7 files changed, 43 insertions(+), 32 deletions(-)
lib/rendercopy_gen4.c +6 -5
@@ -148,11 +148,12 @@ gen4_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst) ss->ss0.data_return_format =SURFACERETURNFORMAT_FLOAT32 ; ss->ss0.color_blend =1 ; - address =intel_bb_offset_reloc (ibb, buf->handle, - read_domain, write_domain, -intel_bb_offset (ibb) +4 , - buf->addr.offset); - ss->ss1.base_addr = (uint32_t ) address; + address =intel_bb_offset_reloc_with_delta (ibb, buf->handle, + read_domain, write_domain, + buf->surface[0 ].offset, +intel_bb_offset (ibb) +4 , + buf->addr.offset); + ss->ss1.base_addr = address + buf->surface[0 ].offset; ss->ss2.height =intel_buf_height (buf) -1 ; ss->ss2.width =intel_buf_width (buf) -1 ;
lib/rendercopy_gen6.c +6 -5
@@ -91,11 +91,12 @@ gen6_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst) ss->ss0.data_return_format =SURFACERETURNFORMAT_FLOAT32 ; ss->ss0.color_blend =1 ; - address =intel_bb_offset_reloc (ibb, buf->handle, - read_domain, write_domain, -intel_bb_offset (ibb) +4 , - buf->addr.offset); - ss->ss1.base_addr = (uint32_t ) address; + address =intel_bb_offset_reloc_with_delta (ibb, buf->handle, + read_domain, write_domain, + buf->surface[0 ].offset, +intel_bb_offset (ibb) +4 , + buf->addr.offset); + ss->ss1.base_addr = address + buf->surface[0 ].offset; ss->ss2.height =intel_buf_height (buf) -1 ; ss->ss2.width =intel_buf_width (buf) -1 ;
lib/rendercopy_gen7.c +6 -5
@@ -86,11 +86,12 @@ gen7_bind_buf(struct intel_bb *ibb,gen7_tiling_bits (buf->tiling) | format << GEN7_SURFACE_FORMAT_SHIFT); - address =intel_bb_offset_reloc (ibb, buf->handle, - read_domain, write_domain, -intel_bb_offset (ibb) +4 , - buf->addr.offset); - ss[1 ] = address; + address =intel_bb_offset_reloc_with_delta (ibb, buf->handle, + read_domain, write_domain, +intel_bb_offset (ibb) +4 , + buf->surface[0 ].offset, + buf->addr.offset); + ss[1 ] = address + buf->surface[0 ].offset; ss[2 ] = ((intel_buf_width (buf) -1 ) <<GEN7_SURFACE_WIDTH_SHIFT | (intel_buf_height (buf) -1 ) <<GEN7_SURFACE_HEIGHT_SHIFT ); ss[3 ] = (buf->surface[0 ].stride -1 ) <<GEN7_SURFACE_PITCH_SHIFT ;
lib/rendercopy_gen8.c +7 -6
@@ -109,12 +109,13 @@ gen8_bind_buf(struct intel_bb *ibb, ss->ss1.memory_object_control =BDW_MOCS_PTE |BDW_MOCS_TC_L3_PTE |BDW_MOCS_AGE (0 ); - address =intel_bb_offset_reloc (ibb, buf->handle, - read_domain, write_domain, -intel_bb_offset (ibb) +4 *8 , - buf->addr.offset); - ss->ss8.base_addr = address; - ss->ss9.base_addr_hi = address >>32 ; + address =intel_bb_offset_reloc_with_delta (ibb, buf->handle, + read_domain, write_domain, + buf->surface[0 ].offset, +intel_bb_offset (ibb) +4 *8 , + buf->addr.offset); + ss->ss8.base_addr = (address + buf->surface[0 ].offset); + ss->ss9.base_addr_hi = (address + buf->surface[0 ].offset) >>32 ; ss->ss2.height =intel_buf_height (buf) -1 ; ss->ss2.width =intel_buf_width (buf) -1 ;
lib/rendercopy_gen9.c +7 -6
@@ -194,12 +194,13 @@ gen9_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,else if (buf->tiling == I915_TILING_Ys) ss->ss5.trmode =2 ; - address =intel_bb_offset_reloc (ibb, buf->handle, - read_domain, write_domain, -intel_bb_offset (ibb) +4 *8 , - buf->addr.offset); - ss->ss8.base_addr = address; - ss->ss9.base_addr_hi = address >>32 ; + address =intel_bb_offset_reloc_with_delta (ibb, buf->handle, + read_domain, write_domain, + buf->surface[0 ].offset, +intel_bb_offset (ibb) +4 *8 , + buf->addr.offset); + ss->ss8.base_addr = (address + buf->surface[0 ].offset); + ss->ss9.base_addr_hi = (address + buf->surface[0 ].offset) >>32 ; ss->ss2.height =intel_buf_height (buf) -1 ; ss->ss2.width =intel_buf_width (buf) -1 ;
lib/rendercopy_i830.c +7 -3
@@ -158,8 +158,10 @@ static void gen2_emit_target(struct intel_bb *ibb,intel_bb_out (ibb, _3DSTATE_BUF_INFO_CMD);intel_bb_out (ibb,BUF_3D_ID_COLOR_BACK | tiling |BUF_3D_PITCH (dst->surface[0 ].stride)); -intel_bb_emit_reloc (ibb, dst->handle,I915_GEM_DOMAIN_RENDER , -I915_GEM_DOMAIN_RENDER ,0 , dst->addr.offset); +intel_bb_emit_reloc (ibb, dst->handle, +I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER , + dst->surface[0 ].offset, + dst->addr.offset);intel_bb_out (ibb, _3DSTATE_DST_BUF_VARS_CMD); intel_bb_out(ibb, format |
@@ -199,7 +201,9 @@ static void gen2_emit_texture(struct intel_bb *ibb, tiling |=TM0S1_TILE_WALK ;intel_bb_out (ibb, _3DSTATE_LOAD_STATE_IMMEDIATE_2 |LOAD_TEXTURE_MAP (unit) |4 ); -intel_bb_emit_reloc (ibb, src->handle,I915_GEM_DOMAIN_SAMPLER ,0 ,0 , +intel_bb_emit_reloc (ibb, src->handle, +I915_GEM_DOMAIN_SAMPLER ,0 , + src->surface[0 ].offset, src->addr.offset); intel_bb_out(ibb, (intel_buf_height(src) - 1) << TM0S1_HEIGHT_SHIFT | (intel_buf_width(src) - 1) << TM0S1_WIDTH_SHIFT |
lib/rendercopy_i915.c +4 -2
@@ -112,7 +112,8 @@ void gen3_render_copyfunc(struct intel_bb *ibb,intel_bb_out (ibb, (1 <<TEX_COUNT ) -1 );intel_bb_emit_reloc (ibb, src->handle,I915_GEM_DOMAIN_SAMPLER ,0 , -0 , src->addr.offset); + src->surface[0 ].offset, + src->addr.offset);intel_bb_out (ibb, format_bits | tiling_bits | (intel_buf_height (src) -1 ) <<MS3_HEIGHT_SHIFT | (intel_buf_width (src) -1 ) <<MS3_WIDTH_SHIFT );
@@ -155,7 +156,8 @@ void gen3_render_copyfunc(struct intel_bb *ibb, BUF_3D_PITCH(dst->surface[0].stride));intel_bb_emit_reloc (ibb, dst->handle,I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER , -0 , dst->addr.offset); + dst->surface[0 ].offset, + dst->addr.offset);intel_bb_out (ibb, _3DSTATE_DST_BUF_VARS_CMD); intel_bb_out(ibb, format_bits |
Signature · 1 line
2.41.0
PATCH v2 2/15 tests/kms_big_fb: Use igt_fb_create_intel_buf()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Use igt_fb_create_intel_buf() instead of hand rolling something similar but less capable (igt_fb_create_intel_buf() handles planar and compressed formats, the hand rolled version does not).
--- tests/intel/kms_big_fb.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-)
tests/intel/kms_big_fb.c +1 -26
@@ -187,32 +187,7 @@ static struct intel_buf *init_buf(data_t *data,const struct igt_fb *fb, const char *buf_name) { - struct intel_buf *buf; -enum intel_driver driver =buf_ops_get_driver (data->bops); -uint32_t name, handle, tiling, stride, width, height, bpp, size; -uint64_t region = driver ==INTEL_DRIVER_XE ? -vram_if_possible (data->drm_fd,0 ) :-1 ; - -igt_assert_eq (fb->offsets[0 ],0 ); - - tiling =igt_fb_mod_to_tiling (fb->modifier); - stride = fb->strides[0 ]; - bpp = fb->plane_bpp[0 ]; - size = fb->size; - width = stride / (bpp /8 ); - height = size / stride; - - name =gem_flink (data->drm_fd, fb->gem_handle); - handle =gem_open (data->drm_fd, name); - buf =intel_buf_create_full (data->bops, handle, width, height, - bpp,0 , tiling,0 , size,0 , - region, -intel_get_pat_idx_uc (data->drm_fd)); - -intel_buf_set_name (buf, buf_name); -intel_buf_set_ownership (buf, true); - -return buf; + return igt_fb_create_intel_buf(data->drm_fd, data->bops, fb, buf_name); }static void fini_buf (struct intel_buf *buf)
Signature · 1 line
2.41.0
PATCH v2 3/15 lib/igt_fb: Expose igt_fb_is_ccs_modifier()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
I'm going to need is_ccs_modifier() outside of igt_fb.c. Rename it to igt_fb_is_ccs_modifier() and expose it to everyone.
--- lib/igt_fb.c | 21 ++++++++++++--------- lib/igt_fb.h | 1 + 2 files changed, 13 insertions(+), 9 deletions(-)
lib/igt_fb.c +12 -9
@@ -605,7 +605,7 @@ static bool is_gen12_ccs_modifier(uint64_t modifier) modifier ==I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC ; } -static bool is_ccs_modifier (uint64_t modifier) +bool igt_fb_is_ccs_modifier (uint64_t modifier) {return is_gen12_ccs_modifier (modifier) || modifier == I915_FORMAT_MOD_Y_TILED_CCS ||
@@ -614,7 +614,8 @@ static bool is_ccs_modifier(uint64_t modifier)static bool is_ccs_plane (const struct igt_fb *fb,int plane) { -if (!is_ccs_modifier (fb->modifier) ||HAS_FLATCCS (intel_get_drm_devid (fb->fd))) +if (!igt_fb_is_ccs_modifier (fb->modifier) || +HAS_FLATCCS (intel_get_drm_devid (fb->fd)))return false;return plane >= fb->num_planes /2 ;
@@ -724,7 +725,8 @@ static int fb_num_planes(const struct igt_fb *fb) {int num_planes =lookup_drm_format (fb->drm_format)->num_planes; -if (is_ccs_modifier (fb->modifier) && !HAS_FLATCCS (intel_get_drm_devid (fb->fd))) +if (igt_fb_is_ccs_modifier (fb->modifier) && + !HAS_FLATCCS (intel_get_drm_devid (fb->fd))) num_planes *=2 ; if (fb->modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC ||
@@ -2491,7 +2493,7 @@ static enum blt_tiling_type fb_tile_to_blt_tile(uint64_t tile)static bool fast_blit_ok (const struct igt_fb *fb) {return blt_has_fast_copy (fb->fd) && - !is_ccs_modifier (fb->modifier) && + !igt_fb_is_ccs_modifier (fb->modifier) &&blt_fast_copy_supports_tiling (fb->fd,fb_tile_to_blt_tile (fb->modifier)); }
@@ -2508,7 +2510,7 @@ static bool blitter_ok(const struct igt_fb *fb)if (!is_intel_device (fb->fd))return false; -if ((is_ccs_modifier (fb->modifier) && +if ((igt_fb_is_ccs_modifier (fb->modifier) && !HAS_FLATCCS (intel_get_drm_devid (fb->fd))) ||is_gen12_mc_ccs_modifier (fb->modifier))return false;
@@ -2548,7 +2550,8 @@ static bool use_enginecopy(const struct igt_fb *fb)return false;return fb->modifier == I915_FORMAT_MOD_Yf_TILED || - (!HAS_FLATCCS (intel_get_drm_devid (fb->fd)) &&is_ccs_modifier (fb->modifier)) || + (!HAS_FLATCCS (intel_get_drm_devid (fb->fd)) && +igt_fb_is_ccs_modifier (fb->modifier)) ||is_gen12_mc_ccs_modifier (fb->modifier); }
@@ -2608,7 +2611,7 @@ igt_fb_create_intel_buf(int fd, struct buf_ops *bops,igt_assert_eq (fb->offsets[0 ],0 ); -if (is_ccs_modifier (fb->modifier)) { +if (igt_fb_is_ccs_modifier (fb->modifier)) {igt_assert_eq (fb->strides[0 ] &127 ,0 );if (is_gen12_ccs_modifier (fb->modifier)) {
@@ -2651,7 +2654,7 @@ igt_fb_create_intel_buf(int fd, struct buf_ops *bops,if (buf->format_is_yuv_semiplanar) buf->yuv_semiplanar_bpp =yuv_semiplanar_bpp (fb->drm_format); -if (is_ccs_modifier (fb->modifier)) { +if (igt_fb_is_ccs_modifier (fb->modifier)) { num_surfaces = fb->num_planes / (HAS_FLATCCS (intel_get_drm_devid (fb->fd)) ?1 :2 );for (i =0 ; i < num_surfaces; i++) init_buf_ccs(buf, i,
@@ -2773,7 +2776,7 @@ static struct blt_copy_object *blt_fb_init(const struct igt_fb *fb,intel_get_uc_mocs_index (fb->fd),intel_get_pat_idx_uc (fb->fd), blt_tile, -is_ccs_modifier (fb->modifier) ?COMPRESSION_ENABLED :COMPRESSION_DISABLED , +igt_fb_is_ccs_modifier (fb->modifier) ?COMPRESSION_ENABLED :COMPRESSION_DISABLED , is_gen12_mc_ccs_modifier(fb->modifier) ? COMPRESSION_TYPE_MEDIA : COMPRESSION_TYPE_3D);blt_set_geom (blt, stride,0 ,0 , fb->width, fb->plane_height[plane],0 ,0 );
lib/igt_fb.h +1 -0
@@ -182,6 +182,7 @@ void igt_fb_calc_crc(struct igt_fb *fb, igt_crc_t *crc);uint64_t igt_fb_mod_to_tiling (uint64_t modifier);uint64_t igt_fb_tiling_to_mod (uint64_t tiling); +bool igt_fb_is_ccs_modifier (uint64_t modifier);bool igt_fb_is_ccs_plane (const struct igt_fb *fb,int plane);bool igt_fb_is_gen12_ccs_cc_plane (const struct igt_fb *fb,int plane);int igt_fb_ccs_to_main_plane (const struct igt_fb *fb,int ccs_plane);
Signature · 1 line
2.41.0
PATCH v2 4/15 tests/kms_big_fb: Fix async
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
The 'continue' statement causes us to skip test_cleanup() which means the next iteration of the loop will not re-create the fb, instead attempting to use the previous fb which has the wrong format. The result is that things blow up. Skip the async flip test using igt_require() instead which will let the cleanup fixture do its job.
--- tests/intel/kms_big_fb.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
tests/intel/kms_big_fb.c +24 -9
@@ -75,6 +75,12 @@* and %arg[2]-rotation * Functionality: big_fbs, kms_gem_interop, rotation * +* SUBTEST: linear-max-hw-stride-%dbpp-rotate-%d-async-flip +* Description: Test maximum hardware supported stride length for given combination +* of linear modifier with max hardware stride length, %arg[1]-bpp, +* and %arg[2]-rotation +* Functionality: async_flips, big_fbs, kms_gem_interop, rotation +* * arg[1].values: 32, 64 * arg[2].values: 0, 180 */
@@ -918,6 +924,18 @@ static void test_cleanup(data_t *data) data->output =NULL ; } +static bool has_async_flip (data_t *data) +{ +/* +* TODO: preferably probe all this stuff with +* TEST_ONLY rather than hardcoding it... +*/ +if (data->modifier ==DRM_FORMAT_MOD_LINEAR ) +return false; + +return igt_has_drm_cap (data->drm_fd,DRM_CAP_ASYNC_PAGE_FLIP ); +} +static data_t data = {}; static const struct {
@@ -1108,17 +1126,14 @@ igt_maintest_scanout (&data); } -// async flip doesn't support linear fbs. -if (modifiers[i].modifier ==DRM_FORMAT_MOD_LINEAR ) -continue ; - data.async_flip_test = true;igt_describe ("test async flip on maximum hardware supported stride length for given bpp and modifiers." ); -igt_subtest_f ("%s-max-hw-stride-%dbpp-rotate-%d%s-async-flip" , modifiers[i].name, - formats[j].bpp, rotations[k].angle, fliptab[l].flipname) { -igt_require (igt_has_drm_cap (data.drm_fd,DRM_CAP_ASYNC_PAGE_FLIP )); - data.max_hw_fb_width =min (data.hw_stride / (formats[j].bpp >>3 ), data.max_fb_width); -test_scanout (&data); +igt_subtest_f ("%s-max-hw-stride-%dbpp-rotate-%d%s-async-flip" , + modifiers[i].name, formats[j].bpp, + rotations[k].angle, fliptab[l].flipname) { +igt_require (has_async_flip (&data)); + data.max_hw_fb_width =min (data.hw_stride / (formats[j].bpp >>3 ), data.max_fb_width); +test_scanout (&data); } data.async_flip_test = false;
Signature · 1 line
2.41.0
PATCH v2 5/15 tests/kms_big_fb: Test async flips + linear on tgl+
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
i915 claims to support linear+async flips on TGL+, so let's test that here as well.
--- tests/intel/kms_big_fb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/intel/kms_big_fb.c +2 -1
@@ -930,7 +930,8 @@ static bool has_async_flip(data_t *data)* TODO: preferably probe all this stuff with * TEST_ONLY rather than hardcoding it... */ -if (data->modifier ==DRM_FORMAT_MOD_LINEAR ) +if (intel_display_ver (data->devid) <12 && + data->modifier ==DRM_FORMAT_MOD_LINEAR )return false;return igt_has_drm_cap (data->drm_fd,DRM_CAP_ASYNC_PAGE_FLIP );
Signature · 1 line
2.41.0
PATCH v2 6/15 tests/kms_big_fb: Determine the max fb size the same way always
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Currently the scanout tests and the addfb test may determine the max framebuffer size differently. That may be OK for now, but I have plans to extend the test to cover compressed formats as well, and those can't generally use the reported max fb size. So reuse the same piece of code to always determine the max fb size (to which I can add compressed formats checks later).
--- tests/intel/kms_big_fb.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
tests/intel/kms_big_fb.c +20 -20
@@ -345,6 +345,21 @@ static void max_fb_size(data_t *data, int *width, int *height,uint64_t size;int i =0 ; +if (data->max_hw_stride_test) { +igt_output_t *output; + + *width = data->max_hw_fb_width; + *height =0 ; + +for_each_connected_output (&data->display, output) { +if (*height < output->config.default_mode.vdisplay *2 ) + *height = output->config.default_mode.vdisplay *2 ; + } + }else { + *width = data->max_fb_width; + *height = data->max_fb_height; + } +/* max fence stride is only 8k bytes on gen3 */ if (intel_display_ver (data->devid) <4 && format ==DRM_FORMAT_XRGB8888 )
@@ -690,26 +705,11 @@ max_hw_stride_async_flip_test(data_t *data)static void test_scanout (data_t *data) { -igt_output_t *output; -igt_require (data->format ==DRM_FORMAT_C8 ||igt_fb_supported_format (data->format));igt_require (igt_display_has_format_mod (&data->display, data->format, data->modifier)); -if (data->max_hw_stride_test) { - data->big_fb_width = data->max_hw_fb_width; - data->big_fb_height =0 ; - -for_each_connected_output (&data->display, output) { -if (data->big_fb_height < output->config.default_mode.vdisplay *2 ) - data->big_fb_height = output->config.default_mode.vdisplay *2 ; - } - }else { - data->big_fb_width = data->max_fb_width; - data->big_fb_height = data->max_fb_height; - } -max_fb_size (data, &data->big_fb_width, &data->big_fb_height, data->format, data->modifier);
@@ -844,6 +844,7 @@ test_addfb(data_t *data)uint32_t offsets[4 ] = {};uint32_t strides[4 ] = {};uint32_t format; +int width, height;int ret;/*
@@ -859,9 +860,9 @@ test_addfb(data_t *data)igt_require (igt_display_has_format_mod (&data->display, format, data->modifier)); -igt_calc_fb_size (data->drm_fd, - data->max_fb_width, - data->max_fb_height, +max_fb_size (data, &width, &height, format, data->modifier); + +igt_calc_fb_size (data->drm_fd, width, height, format, data->modifier, &size, &strides[0 ]);
@@ -878,8 +879,7 @@ test_addfb(data_t *data) igt_fb_mod_to_tiling(data->modifier), strides[0]); ret =__kms_addfb (data->drm_fd, bo, - data->max_fb_width, - data->max_fb_height, + width, height, format, data->modifier, strides, offsets,1 ,DRM_MODE_FB_MODIFIERS , &fb_id);
Signature · 1 line
2.41.0
PATCH v2 7/15 tests/kms_frontbuffer_tracking: Use igt_create_fb()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Calling igt_calc_fb_size() and igt_create_fb_with_bo_size() like this back to back is the same as just calling igt_create_fb().
--- tests/intel/kms_frontbuffer_tracking.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
tests/intel/kms_frontbuffer_tracking.c +2 -9
@@ -1615,8 +1615,7 @@ static void create_fb(enum pixel_format pformat, int width, int height, enum tiling_type tiling, int plane, struct igt_fb *fb) { uint32_t format; -uint64_t size, modifier; -unsigned int stride; +uint64_t modifier;switch (pformat) {case FORMAT_RGB888 :
@@ -1650,13 +1649,7 @@ static void create_fb(enum pixel_format pformat, int width, int height,igt_warn_on (plane ==PLANE_CUR && tiling !=TILING_LINEAR ); -igt_calc_fb_size (drm.fd, width, height, format, modifier, &size, - &stride); - -igt_create_fb_with_bo_size (drm.fd, width, height, format, modifier, -IGT_COLOR_YCBCR_BT709 , -IGT_COLOR_YCBCR_LIMITED_RANGE , - fb, size, stride); +igt_create_fb (drm.fd, width, height, format, modifier, fb); }static uint32_t pick_color (struct igt_fb *fb,enum color ecolor)
Signature · 1 line
2.41.0
PATCH v2 8/15 lib/igt_fb: Make igt_calc_fb_size() somewhat usable
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
igt_calc_fb_size() is very awkward to use in combinations with planar/compressed formats. To fix it we either need to add tons of output parameters (strides/offsets/etc.), or we just get rid of it and promote calc_fb_size() to take its place. I chose the latter approach. This does mean that the callers will need to have a struct igt_fb around, but I think that's nicer than adding tons of output parameters.
v2: Fix a misplaced fb->size
--- lib/igt_fb.c | 50 +++++++++++----------------------------- lib/igt_fb.h | 3 +-- tests/intel/gem_pxp.c | 4 +--- tests/intel/kms_big_fb.c | 33 +++++++++++++------------- tests/kms_addfb_basic.c | 14 ++++++----- tests/kms_prime.c | 12 ++++++++-- tests/kms_rotation_crc.c | 10 ++++---- 7 files changed, 55 insertions(+), 71 deletions(-)
lib/igt_fb.c +13 -37
@@ -936,7 +936,15 @@ static unsigned int get_plane_alignment(struct igt_fb *fb, int color_plane)return alignment; } -static uint64_t calc_fb_size (struct igt_fb *fb) +/** +* igt_calc_fb_size: +* @fb: the framebuffer +* +* This function calculates the framebuffer size/strides/offsets/etc. +* appropriately. The framebuffer needs to be sufficiently initialized +* beforehand eg. with igt_init_fb(). +*/ +void igt_calc_fb_size (struct igt_fb *fb) {uint64_t size =0 ;int plane;
@@ -960,36 +968,9 @@ static uint64_t calc_fb_size(struct igt_fb *fb)if (is_xe_device (fb->fd)) size =ALIGN (size,xe_get_default_alignment (fb->fd)); -return size; -} - -/** -* igt_calc_fb_size: -* @fd: the DRM file descriptor -* @width: width of the framebuffer in pixels -* @height: height of the framebuffer in pixels -* @format: drm fourcc pixel format code -* @modifier: tiling layout of the framebuffer (as framebuffer modifier) -* @size_ret: returned size for the framebuffer -* @stride_ret: returned stride for the framebuffer -* -* This function returns valid stride and size values for a framebuffer with the -* specified parameters. -*/ -void igt_calc_fb_size (int fd,int width,int height,uint32_t drm_format,uint64_t modifier, -uint64_t *size_ret,unsigned *stride_ret) -{ -struct igt_fb fb; - -igt_init_fb (&fb, fd, width, height, drm_format, modifier, -IGT_COLOR_YCBCR_BT709 ,IGT_COLOR_YCBCR_LIMITED_RANGE ); - - fb.size =calc_fb_size (&fb); - -if (size_ret) - *size_ret = fb.size; -if (stride_ret) - *stride_ret = fb.strides[0 ]; +/* Respect the size requested by the caller. */ +if (fb->size ==0 ) + fb->size = size; }/**
@@ -1174,7 +1155,6 @@ static int create_bo_for_fb(struct igt_fb *fb, bool prefer_sysmem)unsigned *strides = &fb->strides[0 ];bool device_bo = false;int fd = fb->fd; -uint64_t size;/* * The current dumb buffer allocation API doesn't really allow to
@@ -1189,11 +1169,7 @@ static int create_bo_for_fb(struct igt_fb *fb, bool prefer_sysmem) device_bo = true;/* Sets offets and stride if necessary. */ - size =calc_fb_size (fb); - -/* Respect the size requested by the caller. */ -if (fb->size ==0 ) - fb->size = size; +igt_calc_fb_size (fb);if (device_bo) { fb->is_dumb = false;
lib/igt_fb.h +1 -2
@@ -125,8 +125,7 @@ enum igt_text_align {void igt_get_fb_tile_size (int fd,uint64_t modifier,int fb_bpp,unsigned *width_ret,unsigned *height_ret); -void igt_calc_fb_size (int fd,int width,int height,uint32_t format,uint64_t modifier, -uint64_t *size_ret,unsigned *stride_ret); +void igt_calc_fb_size (struct igt_fb *fb); void igt_init_fb(struct igt_fb *fb, int fd, int width, int height, uint32_t drm_format, uint64_t modifier, enum igt_color_encoding color_encoding,
tests/intel/gem_pxp.c +1 -3
@@ -1128,9 +1128,7 @@ static void setup_protected_fb(int i915, int width, int height, igt_fb_t *fb, uiigt_init_fb (fb, i915, width, height,DRM_FORMAT_XRGB8888 ,DRM_FORMAT_MOD_NONE ,IGT_COLOR_YCBCR_BT709 ,IGT_COLOR_YCBCR_LIMITED_RANGE ); - -igt_calc_fb_size (i915, width, height,DRM_FORMAT_XRGB8888 ,DRM_FORMAT_MOD_NONE , - &fb->size, &fb->strides[0 ]); +igt_calc_fb_size (fb); err =create_bo_ext (i915, fb->size, true, &(fb->gem_handle));igt_assert_eq (err,0 );
tests/intel/kms_big_fb.c +16 -17
@@ -341,8 +341,7 @@ static bool size_ok(data_t *data, uint64_t size)static void max_fb_size (data_t *data,int *width,int *height,uint32_t format,uint64_t modifier) { -unsigned int stride; -uint64_t size; +struct igt_fb fb;int i =0 ;if (data->max_hw_stride_test) {
@@ -365,17 +364,19 @@ static void max_fb_size(data_t *data, int *width, int *height, format == DRM_FORMAT_XRGB8888) *width =min (*width,8192 /4 ); -igt_calc_fb_size (data->drm_fd, *width, *height, - format, modifier, &size, &stride); +igt_init_fb (&fb, data->drm_fd, *width, *height, format, modifier, +IGT_COLOR_YCBCR_BT709 ,IGT_COLOR_YCBCR_LIMITED_RANGE ); +igt_calc_fb_size (&fb); -while (!size_ok (data, size)) { +while (!size_ok (data, fb.size)) {if (i++ &1 ) *width >>=1 ;else *height >>=1 ; -igt_calc_fb_size (data->drm_fd, *width, *height, - format, modifier, &size, &stride); +igt_init_fb (&fb, data->drm_fd, *width, *height, format, modifier, +IGT_COLOR_YCBCR_BT709 ,IGT_COLOR_YCBCR_LIMITED_RANGE ); +igt_calc_fb_size (&fb); } igt_info("Max usable framebuffer size for format "IGT_FORMAT_FMT" / modifier 0x%"PRIx64": %dx%d\n",
@@ -838,11 +839,9 @@ static int rmfb(int fd, uint32_t id)static void test_addfb (data_t *data) { -uint64_t size; +struct igt_fb fb;uint32_t fb_id;uint32_t bo; -uint32_t offsets[4 ] = {}; -uint32_t strides[4 ] = {};uint32_t format;int width, height;int ret;
@@ -862,26 +861,26 @@ test_addfb(data_t *data)max_fb_size (data, &width, &height, format, data->modifier); -igt_calc_fb_size (data->drm_fd, width, height, - format, data->modifier, - &size, &strides[0 ]); +igt_init_fb (&fb, data->drm_fd, width, height, format, data->modifier, +IGT_COLOR_YCBCR_BT709 ,IGT_COLOR_YCBCR_LIMITED_RANGE ); +igt_calc_fb_size (&fb);if (is_i915_device (data->drm_fd)) - bo =gem_buffer_create_fb_obj (data->drm_fd, size); + bo =gem_buffer_create_fb_obj (data->drm_fd, fb.size);else bo =xe_bo_create (data->drm_fd,0 , -ALIGN (size,xe_get_default_alignment (data->drm_fd)), +ALIGN (fb.size,xe_get_default_alignment (data->drm_fd)),vram_if_possible (data->drm_fd,0 ),0 );igt_require (bo);if (is_i915_device (data->drm_fd) &&intel_display_ver (data->devid) <4 )gem_set_tiling (data->drm_fd, bo, -igt_fb_mod_to_tiling (data->modifier), strides[0 ]); +igt_fb_mod_to_tiling (data->modifier), fb.strides[0 ]); ret =__kms_addfb (data->drm_fd, bo, width, height, format, data->modifier, - strides, offsets,1 , + fb.strides, fb.offsets, fb.num_planes,DRM_MODE_FB_MODIFIERS , &fb_id);igt_assert_eq (ret,0 );
tests/kms_addfb_basic.c +8 -6
@@ -294,19 +294,21 @@ static void invalid_tests(int fd)igt_describe ("Check if addfb2 with a system memory gem object " "fails correctly if device requires local memory framebuffers" ); igt_subtest("invalid-smem-bo-on-discrete") { -uint32_t handle, stride; -uint64_t size; +struct igt_fb fb; +uint32_t handle;igt_require_intel (fd); -igt_calc_fb_size (fd, f.width, f.height, -DRM_FORMAT_XRGB8888 ,0 , &size, &stride); +igt_init_fb (&fb, fd, f.width, f.height, +DRM_FORMAT_XRGB8888 ,0 , +IGT_COLOR_YCBCR_BT709 ,IGT_COLOR_YCBCR_LIMITED_RANGE ); +igt_calc_fb_size (&fb);if (is_i915_device (fd)) {igt_require (gem_has_lmem (fd)); - handle =gem_create_in_memory_regions (fd, size,REGION_SMEM ); + handle =gem_create_in_memory_regions (fd, fb.size,REGION_SMEM ); }else {igt_require (xe_has_vram (fd)); - handle =xe_bo_create (fd,0 , size,system_memory (fd),0 ); + handle =xe_bo_create (fd,0 , fb.size,system_memory (fd),0 ); } f.handles[0 ] = handle;
tests/kms_prime.c +10 -2
@@ -149,8 +149,16 @@ static void prepare_scratch(int exporter_fd, struct dumb_bo *scratch, ptr =kmstest_dumb_map_buffer (exporter_fd, scratch->handle, scratch->size,PROT_WRITE ); }else { -igt_calc_fb_size (exporter_fd, mode->hdisplay, mode->vdisplay,DRM_FORMAT_XRGB8888 , -DRM_FORMAT_MOD_LINEAR , &scratch->size, &scratch->pitch); +struct igt_fb fb; + +igt_init_fb (&fb, exporter_fd, mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 ,DRM_FORMAT_MOD_LINEAR , +IGT_COLOR_YCBCR_BT709 ,IGT_COLOR_YCBCR_LIMITED_RANGE ); +igt_calc_fb_size (&fb); + + scratch->size = fb.size; + scratch->pitch = fb.strides[0 ]; +if (gem_has_lmem (exporter_fd)) scratch->handle =gem_create_in_memory_regions (exporter_fd, scratch->size,REGION_LMEM (0 ),REGION_SMEM );
tests/kms_rotation_crc.c +6 -4
@@ -1091,8 +1091,8 @@ static void test_plane_rotation_exhaust_fences(data_t *data,int fd = data->gfx_fd;drmModeModeInfo *mode;struct igt_fb fb[MAX_FENCES +1 ] = {}; -uint64_t size; -unsigned int stride, w, h; +struct igt_fb tmp_fb; +unsigned int w, h;uint64_t total_aperture_size, total_fbs_size;int i;
@@ -1106,13 +1106,15 @@ static void test_plane_rotation_exhaust_fences(data_t *data, w = mode->hdisplay; h = mode->vdisplay; -igt_calc_fb_size (fd, w, h, format, modifier, &size, &stride); +igt_init_fb (&tmp_fb, fd, w, h, format, modifier, +IGT_COLOR_YCBCR_BT709 ,IGT_COLOR_YCBCR_LIMITED_RANGE ); +igt_calc_fb_size (&tmp_fb);/* * Make sure there is atleast 90% of the available GTT space left * for creating (MAX_FENCES+1) framebuffers. */ - total_fbs_size = size * (MAX_FENCES +1 ); + total_fbs_size = tmp_fb.size * (MAX_FENCES +1 ); total_aperture_size =gem_available_aperture_size (fd);igt_require (total_fbs_size < total_aperture_size *0.9 );
Signature · 1 line
2.41.0
PATCH v2 9/15 tests/kms_big_fb: Nuke fliptab[]
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Let's just stuff the full transformation into rotations[] and get rid of fliptab[] and yet another nested loop.
This also extends the hflip tests to be done universally (as opposed to just in combination with the max-hw-stride tests).
--- tests/intel/kms_big_fb.c | 135 ++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 60 deletions(-)
tests/intel/kms_big_fb.c +75 -60
@@ -47,6 +47,11 @@* of Linear modifier with %arg[1]-bpp & %arg[2]-rotation * Functionality: big_fbs, kms_gem_interop, rotation * +* SUBTEST: linear-%dbpp-rotate-%d-hflip +* Description: Sanity check if addfb ioctl works correctly for given combination +* of Linear modifier with %arg[1]-bpp & %arg[2]-rotation +* Functionality: big_fbs, kms_gem_interop, rotation +* * arg[1].values: 8, 16, 32, 64 * arg[2].values: 0, 90, 180, 270 */
@@ -57,6 +62,11 @@* of %arg[1] with %arg[2]-bpp & %arg[3]-rotation * Functionality: big_fbs, kms_gem_interop, rotation, tiling * +* SUBTEST: %s-%dbpp-rotate-%d-hflip +* Description: Sanity check if addfb ioctl works correctly for given combination +* of %arg[1] with %arg[2]-bpp & %arg[3]-rotation +* Functionality: big_fbs, kms_gem_interop, rotation, tiling +* * arg[1]: * * @4-tiled: TILE-4 modifier
@@ -66,6 +76,8 @@* * arg[2].values: 8, 16, 32, 64 * arg[3].values: 0, 90, 180, 270 +* +* arg[4]: */ /**
@@ -959,23 +971,22 @@ static const struct { { DRM_FORMAT_XBGR16161616F, 64, }, }; -static const struct { -igt_rotation_t rotation; -uint16_t angle; -} rotations[] = { - {IGT_ROTATION_0 ,0 , }, - {IGT_ROTATION_90 ,90 , }, - {IGT_ROTATION_180 ,180 , }, - {IGT_ROTATION_270 ,270 , }, +static const igt_rotation_t rotations[] = { +IGT_ROTATION_0 , +IGT_ROTATION_90 , +IGT_ROTATION_180 , +IGT_ROTATION_270 , +IGT_ROTATION_0 |IGT_REFLECT_X , +IGT_ROTATION_90 |IGT_REFLECT_X , +IGT_ROTATION_180 |IGT_REFLECT_X , +IGT_ROTATION_270 |IGT_REFLECT_X , }; -static const struct { -igt_rotation_t flip; -const char *flipname; -} fliptab[] = { - {0 ,"" }, - {IGT_REFLECT_X ,"-hflip" }, -}; +static const char *rotation_flip_str (igt_rotation_t rotation) +{ +return rotation &IGT_REFLECT_X ?"-hflip" :"" ; +} +igt_main { igt_fixture {
@@ -1075,12 +1086,15 @@ igt_main data.format = formats[j].format;for (int k =0 ; k <ARRAY_SIZE (rotations); k++) { - data.rotation = rotations[k].rotation; + data.rotation = rotations[k]; -igt_describe ("Sanity check if addfb ioctl works correctly for given " -"combination of modifier formats and rotation" ); -igt_subtest_f ("%s-%dbpp-rotate-%d" , modifiers[i].name, - formats[j].bpp, rotations[k].angle) +igt_describe ("Sanity check if scanout of big framebuffers works " +"correctly for given combination of modifier formats " +"and rotation" ); +igt_subtest_f ("%s-%dbpp-rotate-%s%s" , modifiers[i].name, + formats[j].bpp, +igt_plane_rotation_name (data.rotation), + rotation_flip_str(data.rotation))test_scanout (&data); }
@@ -1096,50 +1110,51 @@ igt_mainset_max_hw_stride (&data); -for (int l =0 ; l <ARRAY_SIZE (fliptab); l++) { -for (int j =0 ; j <ARRAY_SIZE (formats); j++) { -/* -* try only those formats which can show full length. -* Here 32K is used to have CI test results consistent -* for all platforms, 32K is smallest number possbily -* coming to data.hw_stride from above set_max_hw_stride() -*/ -if (32768 / (formats[j].bpp >>3 ) >8192 ) +for (int j =0 ; j <ARRAY_SIZE (formats); j++) { +/* +* try only those formats which can show full length. +* Here 32K is used to have CI test results consistent +* for all platforms, 32K is smallest number possbily +* coming to data.hw_stride from above set_max_hw_stride() +*/ +if (32768 / (formats[j].bpp >>3 ) >8192 ) +continue ; + + data.format = formats[j].format; + +for (int k =0 ; k <ARRAY_SIZE (rotations); k++) { + data.rotation = rotations[k]; + +// this combination will never happen. +if (igt_rotation_90_or_270 (data.rotation) || + (data.rotation &IGT_REFLECT_X && + modifiers[i].modifier ==DRM_FORMAT_MOD_LINEAR ))continue ; - data.format = formats[j].format; - -for (int k =0 ; k <ARRAY_SIZE (rotations); k++) { - data.rotation = rotations[k].rotation | fliptab[l].flip; - -// this combination will never happen. -if (igt_rotation_90_or_270 (data.rotation) || - (fliptab[l].flip ==IGT_REFLECT_X && modifiers[i].modifier ==DRM_FORMAT_MOD_LINEAR )) -continue ; - -igt_describe ("test maximum hardware supported stride length for given bpp and modifiers." ); -igt_subtest_f ("%s-max-hw-stride-%dbpp-rotate-%d%s" , modifiers[i].name, - formats[j].bpp, rotations[k].angle, fliptab[l].flipname) { -igt_require (intel_display_ver (intel_get_drm_devid (data.drm_fd)) >=5 ); - data.max_hw_fb_width =min (data.hw_stride / (formats[j].bpp >>3 ), data.max_fb_width); - -test_scanout (&data); - } - - data.async_flip_test = true; -igt_describe ("test async flip on maximum hardware supported stride length for given bpp and modifiers." ); -igt_subtest_f ("%s-max-hw-stride-%dbpp-rotate-%d%s-async-flip" , - modifiers[i].name, formats[j].bpp, - rotations[k].angle, fliptab[l].flipname) { -igt_require (has_async_flip (&data)); - data.max_hw_fb_width =min (data.hw_stride / (formats[j].bpp >>3 ), data.max_fb_width); -test_scanout (&data); - } - data.async_flip_test = false; +igt_describe ("test maximum hardware supported stride length for given bpp and modifiers." ); +igt_subtest_f ("%s-max-hw-stride-%dbpp-rotate-%s%s" , + modifiers[i].name, formats[j].bpp, +igt_plane_rotation_name (data.rotation), + rotation_flip_str(data.rotation)) { +igt_require (intel_display_ver (intel_get_drm_devid (data.drm_fd)) >=5 ); + data.max_hw_fb_width =min (data.hw_stride / (formats[j].bpp >>3 ), data.max_fb_width); +test_scanout (&data); + } -igt_fixture - test_cleanup(&data); + data.async_flip_test = true; +igt_describe ("test async flip on maximum hardware supported stride length for given bpp and modifiers." ); +igt_subtest_f ("%s-max-hw-stride-%dbpp-rotate-%s%s-async-flip" , + modifiers[i].name, formats[j].bpp, +igt_plane_rotation_name (data.rotation), + rotation_flip_str(data.rotation)) { +igt_require (has_async_flip (&data)); + data.max_hw_fb_width =min (data.hw_stride / (formats[j].bpp >>3 ), data.max_fb_width); +test_scanout (&data); } + data.async_flip_test = false; + +igt_fixture + test_cleanup(&data); } } }
Signature · 1 line
2.41.0
PATCH v2 10/15 tests/kms_big_fb: Replace 'bpp' with 'name'
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Instead of storing the bpp in the formats[] array let's instead store a string represtantion. I want to add planar YCbCr tests to the mix, and so a simple bpp value will no logner cut it.
A bunch of stuff is using the numerical bpp value for some things, but we can replace those with igt_drm_format_to_bpp().
--- tests/intel/kms_big_fb.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
tests/intel/kms_big_fb.c +16 -14
@@ -963,12 +963,12 @@ static const struct {static const struct {uint32_t format; -uint8_t bpp; +const char *name; } formats[] = { - {DRM_FORMAT_C8 ,8 , }, - {DRM_FORMAT_RGB565 ,16 , }, - {DRM_FORMAT_XRGB8888 ,32 , }, - {DRM_FORMAT_XBGR16161616F ,64 , }, + {DRM_FORMAT_C8 ,"8bpp" , }, + {DRM_FORMAT_RGB565 ,"16bpp" , }, + {DRM_FORMAT_XRGB8888 ,"32bpp" , }, + {DRM_FORMAT_XBGR16161616F ,"64bpp" , }, };static const igt_rotation_t rotations[] = {
@@ -1091,8 +1091,8 @@ igt_mainigt_describe ("Sanity check if scanout of big framebuffers works " "correctly for given combination of modifier formats " "and rotation" ); -igt_subtest_f ("%s-%dbpp-rotate-%s%s" , modifiers[i].name, - formats[j].bpp, +igt_subtest_f ("%s-%s-rotate-%s%s" , modifiers[i].name, + formats[j].name,igt_plane_rotation_name (data.rotation), rotation_flip_str(data.rotation))test_scanout (&data);
@@ -1111,13 +1111,15 @@ igt_mainset_max_hw_stride (&data);for (int j =0 ; j <ARRAY_SIZE (formats); j++) { +int bpp =igt_drm_format_to_bpp (formats[j].format); +/* * try only those formats which can show full length. * Here 32K is used to have CI test results consistent * for all platforms, 32K is smallest number possbily * coming to data.hw_stride from above set_max_hw_stride() */ -if (32768 / (formats[j].bpp >>3 ) >8192 ) +if (32768 / (bpp >>3 ) >8192 )continue ; data.format = formats[j].format;
@@ -1132,23 +1134,23 @@ igt_maincontinue ;igt_describe ("test maximum hardware supported stride length for given bpp and modifiers." ); -igt_subtest_f ("%s-max-hw-stride-%dbpp-rotate-%s%s" , - modifiers[i].name, formats[j].bpp, +igt_subtest_f ("%s-max-hw-stride-%s-rotate-%s%s" , + modifiers[i].name, formats[j].name,igt_plane_rotation_name (data.rotation), rotation_flip_str(data.rotation)) {igt_require (intel_display_ver (intel_get_drm_devid (data.drm_fd)) >=5 ); - data.max_hw_fb_width =min (data.hw_stride / (formats[j].bpp >>3 ), data.max_fb_width); + data.max_hw_fb_width =min (data.hw_stride / (bpp >>3 ), data.max_fb_width);test_scanout (&data); } data.async_flip_test = true;igt_describe ("test async flip on maximum hardware supported stride length for given bpp and modifiers." ); -igt_subtest_f ("%s-max-hw-stride-%dbpp-rotate-%s%s-async-flip" , - modifiers[i].name, formats[j].bpp, +igt_subtest_f ("%s-max-hw-stride-%s-rotate-%s%s-async-flip" , + modifiers[i].name, formats[j].name,igt_plane_rotation_name (data.rotation), rotation_flip_str(data.rotation)) {igt_require (has_async_flip (&data)); - data.max_hw_fb_width =min (data.hw_stride / (formats[j].bpp >>3 ), data.max_fb_width); + data.max_hw_fb_width =min (data.hw_stride / (bpp >>3 ), data.max_fb_width);test_scanout (&data); } data.async_flip_test = false;
Signature · 1 line
2.41.0
PATCH v2 11/15 tests/kms_big_fb: Test planar YCbCr formats
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Panning around inside planar YCbCr framebuffers is a bit more involved that the RGB counterpart. It seems prudent to test that we are correctly handling these case.
We'll manually trick rendercopy to also copy the chroma plane for us. It might be nice to make rendercopy eventually handle this entirely on its own, but for now we'll take this slight shortcut.
--- tests/intel/kms_big_fb.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)
tests/intel/kms_big_fb.c +30 -8
@@ -42,27 +42,27 @@#include "xe/xe_query.h" /** -* SUBTEST: linear-%dbpp-rotate-%d +* SUBTEST: linear-%s-rotate-%d * Description: Sanity check if addfb ioctl works correctly for given combination * of Linear modifier with %arg[1]-bpp & %arg[2]-rotation * Functionality: big_fbs, kms_gem_interop, rotation * -* SUBTEST: linear-%dbpp-rotate-%d-hflip +* SUBTEST: linear-%s-rotate-%d-hflip * Description: Sanity check if addfb ioctl works correctly for given combination * of Linear modifier with %arg[1]-bpp & %arg[2]-rotation * Functionality: big_fbs, kms_gem_interop, rotation * -* arg[1].values: 8, 16, 32, 64 +* arg[1].values: 8bpp, 16bpp, 32bpp, 64bpp, nv12, p016 * arg[2].values: 0, 90, 180, 270 */ /** -* SUBTEST: %s-%dbpp-rotate-%d +* SUBTEST: %s-%s-rotate-%d * Description: Sanity check if addfb ioctl works correctly for given combination * of %arg[1] with %arg[2]-bpp & %arg[3]-rotation * Functionality: big_fbs, kms_gem_interop, rotation, tiling * -* SUBTEST: %s-%dbpp-rotate-%d-hflip +* SUBTEST: %s-%s-rotate-%d-hflip * Description: Sanity check if addfb ioctl works correctly for given combination * of %arg[1] with %arg[2]-bpp & %arg[3]-rotation * Functionality: big_fbs, kms_gem_interop, rotation, tiling
@@ -74,7 +74,7 @@* @y-tiled: TILE-Y modifier * @yf-tiled: TILE-YF modifier * -* arg[2].values: 8, 16, 32, 64 +* arg[2].values: 8bpp, 16bpp, 32bpp, 64bpp, nv12, p016 * arg[3].values: 0, 90, 180, 270 * * arg[4]:
@@ -237,6 +237,18 @@ static void copy_pattern(data_t *data,*/ if (data->render_copy) { data->render_copy (data->ibb, src, sx, sy, w, h, dst, dx, dy); + +/* FIXME rendercopy should do this for us perhaps? */ +if (igt_format_is_yuv_semiplanar (data->format)) { +igt_assert (!igt_fb_is_ccs_modifier (data->modifier)); + + src->bpp *=2 ; + src->surface[0 ] = src->surface[1 ]; + dst->bpp *=2 ; + dst->surface[0 ] = dst->surface[1 ]; + + data->render_copy (data->ibb, src, sx/2 , sy/2 , w/2 , h/2 , dst, dx/2 , dy/2 ); + } }else { w =min (w, src_fb->width - sx); w =min (w, dst_fb->width - dx);
@@ -320,6 +332,10 @@ static void generate_pattern(data_t *data, pat_fb.width, pat_fb.height); w++; h++; +if (igt_format_is_yuv_semiplanar (data->format)) { + w++; + h++; + } } }
@@ -479,8 +495,9 @@ static bool test_plane(data_t *data)int y = coords[i].y;/* Hardware limitation */ -if (data->format ==DRM_FORMAT_RGB565 && -igt_rotation_90_or_270 (data->rotation)) { +if ((data->format ==DRM_FORMAT_RGB565 && +igt_rotation_90_or_270 (data->rotation)) || +igt_format_is_yuv_semiplanar (data->format)) { x &= ~1 ; y &= ~1 ; }
@@ -941,6 +958,9 @@ static bool has_async_flip(data_t *data)* TODO: preferably probe all this stuff with * TEST_ONLY rather than hardcoding it... */ +if (igt_format_is_yuv_semiplanar (data->format)) +return false; +if (intel_display_ver (data->devid) <12 && data->modifier ==DRM_FORMAT_MOD_LINEAR )return false;
@@ -969,6 +989,8 @@ static const struct { { DRM_FORMAT_RGB565, "16bpp", }, { DRM_FORMAT_XRGB8888, "32bpp", }, { DRM_FORMAT_XBGR16161616F, "64bpp", }, + { DRM_FORMAT_NV12, "nv12", }, + { DRM_FORMAT_P016, "p016", }, }; static const igt_rotation_t rotations[] = {
Signature · 1 line
2.41.0
PATCH v2 12/15 tests/kms_big_fb: Also test some CCS modifiers
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Panning inside compressed framebuffers has similar challenges as planar YCbCr framebuffers. So let's test this as well. The difference is that i915 can't do GGTT remapping for CCS, so we must limit the fb size to fit insie the hw limits.
Only enable this for the pre-TGL modifiers for now as testing on TGL didn't go well. I suspect the problem lies with rendercopy but until that is sorted let's not add tons of failures to CI.
--- tests/intel/kms_big_fb.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
tests/intel/kms_big_fb.c +18 -1
@@ -73,6 +73,8 @@* @x-tiled: TILE-X modifier * @y-tiled: TILE-Y modifier * @yf-tiled: TILE-YF modifier +* @y-tiled-ccs: TILE-Y+CCS modifier +* @yf-tiled-ccs: TILE-YF+CCS modifier * * arg[2].values: 8bpp, 16bpp, 32bpp, 64bpp, nv12, p016 * arg[3].values: 0, 90, 180, 270
@@ -110,6 +112,8 @@* @x-tiled: TILE-X modifier * @y-tiled: TILE-Y modifier * @yf-tiled: TILE-YF modifier +* @y-tiled-ccs: TILE-Y+CCS modifier +* @yf-tiled-ccs: TILE-YF+CCS modifier * * arg[2].values: 32, 64 * arg[3].values: 0, 180
@@ -134,6 +138,8 @@* @x-tiled: TILE-X modifier * @y-tiled: TILE-Y modifier * @yf-tiled: TILE-YF modifier +* @y-tiled-ccs: TILE-Y+CCS modifier +* @yf-tiled-ccs: TILE-YF+CCS modifier * * arg[2].values: 32, 64 * arg[3].values: 0, 180
@@ -171,6 +177,8 @@* @x-tiled: TILE-X * @y-tiled: TILE-Y * @yf-tiled: TILE-YF +* @y-tiled-ccs: TILE-Y+CCS modifier +* @yf-tiled-ccs: TILE-YF+CCS modifier */ IGT_TEST_DESCRIPTION ("Test big framebuffers" );
@@ -372,7 +380,11 @@ static void max_fb_size(data_t *data, int *width, int *height,struct igt_fb fb;int i =0 ; -if (data->max_hw_stride_test) { +if (igt_fb_is_ccs_modifier (data->modifier)) { +/* FIXME figure out what's correct */ + *width =8192 ; + *height =8192 ; + }else if (data->max_hw_stride_test) {igt_output_t *output; *width = data->max_hw_fb_width;
@@ -958,6 +970,9 @@ static bool has_async_flip(data_t *data)* TODO: preferably probe all this stuff with * TEST_ONLY rather than hardcoding it... */ +if (igt_fb_is_ccs_modifier (data->modifier)) +return false; +if (igt_format_is_yuv_semiplanar (data->format))return false;
@@ -979,6 +994,8 @@ static const struct { { I915_FORMAT_MOD_Y_TILED, "y-tiled", }, { I915_FORMAT_MOD_Yf_TILED, "yf-tiled", }, { I915_FORMAT_MOD_4_TILED, "4-tiled", }, + { I915_FORMAT_MOD_Y_TILED_CCS, "y-tiled-ccs", }, + { I915_FORMAT_MOD_Yf_TILED_CCS, "yf-tiled-ccs", }, }; static const struct {
Signature · 1 line
2.41.0
PATCH v2 13/15 lib/rendercopy: Always setup clear color for TGL
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
TGL apparently automagically converts regular output to fast clears when the output matches the configured clear color. And if we don't enable the clear color packet at all then we just get some rainbow gibberish on all black parts of the output.
To avoid always set up the clear color packet, and when we don't want fast clear (when not using a _CC modifier) we'll just stich a bunch of NaNs into the clear value so it'll never match any legitimate output.
TODO: Hide this better inside rendercopy_gen9.c without
requring extra allocation in the FB BO
TODO: Figure out if other platforms need this sort stuff
--- lib/igt_fb.c | 23 +++++++++++++++++++++++ lib/intel_bufops.h | 2 ++ lib/rendercopy_gen9.c | 14 +++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-)
lib/igt_fb.c +23 -0
@@ -965,6 +965,16 @@ void igt_calc_fb_size(struct igt_fb *fb) size +=calc_plane_size (fb, plane); } +/* +* We always need a clear color on TGL, make some extra +* room for one it if it's not explicit in the modifier. +* +* TODO: probably better to allocate this as part of the +* batch instead so the fb size doesn't need to change... +*/ +if (fb->modifier ==I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS ) + size =ALIGN (size +64 ,64 ); +if (is_xe_device (fb->fd)) size =ALIGN (size,xe_get_default_alignment (fb->fd));
@@ -2656,6 +2666,19 @@ igt_fb_create_intel_buf(int fd, struct buf_ops *bops,if (fb->modifier ==I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC ) buf->cc.offset = fb->offsets[1 ]; +/* +* TGL appears to do automagic fast clear when rendering +* black and the clear color isn't specified. Always specify +* one. It doesn't appear to do fast clears anymore even +* if the clear color is black. +* +* TODO: figure out if other platforms are affected... +*/ +if (fb->modifier ==I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS ) { + buf->cc.disable = true; + buf->cc.offset = fb->size -64 ; + } +return buf; }
lib/intel_bufops.h +2 -0
@@ -32,6 +32,7 @@ struct intel_buf {enum intel_buf_mocs mocs;bool format_is_yuv;bool format_is_yuv_semiplanar; +bool disable_clear_color;struct {uint32_t offset;uint32_t stride;
@@ -43,6 +44,7 @@ struct intel_buf { } ccs[2 ];struct {uint32_t offset; +bool disable; } cc;struct {uint64_t offset;
lib/rendercopy_gen9.c +11 -3
@@ -1078,15 +1078,23 @@ void _gen9_render_op(struct intel_bb *ibb,gen12_emit_aux_pgtable_state (ibb, aux_pgtable_state, true); -if (fast_clear) { +if (fast_clear || dst->cc.disable) {for (int i =0 ; i <4 ; i++) {intel_bb_out (ibb,MI_STORE_DWORD_IMM_GEN4 );intel_bb_emit_reloc (ibb, dst->handle,I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER , dst->cc.offset + i*sizeof (float ), dst->addr.offset); -intel_bb_out (ibb, *(uint32_t *)&clear_color[i]); - } +if (fast_clear) { +intel_bb_out (ibb, *(uint32_t *)&clear_color[i]); + }else { +/* +* Emit NaN so it'll match nothing and thus prevent +* TGL from doing its automagic fast clear tricks. +*/ +intel_bb_out (ibb,0xffffffff ); + } + } }
Signature · 1 line
2.41.0
PATCH v2 14/15 tests/kms_big_fb: Enable CCS testing for TGL
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
With the TGL clear color/fast clear nonsense sorted we can finally test big CCS fbs on TGL. Make it so.
--- tests/intel/kms_big_fb.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
tests/intel/kms_big_fb.c +10 -0
@@ -75,6 +75,8 @@* @yf-tiled: TILE-YF modifier * @y-tiled-ccs: TILE-Y+CCS modifier * @yf-tiled-ccs: TILE-YF+CCS modifier +* @y-tiled-rc-ccs: TILE-Y+CCS modifier +* @y-tiled-rc-ccs-cc: TILE-Y+CCS+CC modifier * * arg[2].values: 8bpp, 16bpp, 32bpp, 64bpp, nv12, p016 * arg[3].values: 0, 90, 180, 270
@@ -114,6 +116,8 @@* @yf-tiled: TILE-YF modifier * @y-tiled-ccs: TILE-Y+CCS modifier * @yf-tiled-ccs: TILE-YF+CCS modifier +* @y-tiled-rc-ccs: TILE-Y+CCS modifier +* @y-tiled-rc-ccs-cc: TILE-Y+CCS+CC modifier * * arg[2].values: 32, 64 * arg[3].values: 0, 180
@@ -140,6 +144,8 @@* @yf-tiled: TILE-YF modifier * @y-tiled-ccs: TILE-Y+CCS modifier * @yf-tiled-ccs: TILE-YF+CCS modifier +* @y-tiled-rc-ccs: TILE-Y+CCS modifier +* @y-tiled-rc-ccs-cc: TILE-Y+CCS+CC modifier * * arg[2].values: 32, 64 * arg[3].values: 0, 180
@@ -179,6 +185,8 @@* @yf-tiled: TILE-YF * @y-tiled-ccs: TILE-Y+CCS modifier * @yf-tiled-ccs: TILE-YF+CCS modifier +* @y-tiled-rc-ccs: TILE-Y+CCS modifier +* @y-tiled-rc-ccs-cc: TILE-Y+CCS+CC modifier */ IGT_TEST_DESCRIPTION ("Test big framebuffers" );
@@ -996,6 +1004,8 @@ static const struct { { I915_FORMAT_MOD_4_TILED, "4-tiled", }, { I915_FORMAT_MOD_Y_TILED_CCS, "y-tiled-ccs", }, { I915_FORMAT_MOD_Yf_TILED_CCS, "yf-tiled-ccs", }, + { I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS, "y-tiled-rc-ccs", }, + { I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC, "y-tiled-rc-ccs-cc", }, }; static const struct {
Signature · 1 line
2.41.0
PATCH v2 15/15 lib/rendercopy: Enable clear color consistently
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We are computing the clear color enable bit differently for the reloc vs. what we stuff into the surface state directly. Unify.
--- lib/rendercopy_gen9.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
lib/rendercopy_gen9.c +8 -2
@@ -136,6 +136,12 @@ static const uint32_t gen12p71_render_copy[][4] = { { 0x80041131, 0x00000004, 0x50007144, 0x00c40000 }, }; +static bool cc_enable (struct intel_bb *ibb, +const struct intel_buf *buf,bool fast_clear) +{ +return fast_clear || (buf->cc.offset && !HAS_FLATCCS (ibb->devid)); +} +/* Mostly copy+paste from gen6, except height, width, pitch moved */ static uint32_t gen9_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,
@@ -222,7 +228,7 @@ gen9_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst, address =intel_bb_offset_reloc_with_delta (ibb, buf->handle, read_domain, write_domain, - (buf->cc.offset ? (1 <<10 ) :0 ) + (cc_enable (ibb, buf, fast_clear) ? (1 <<10 ) :0 ) | buf->ccs[0 ].offset,intel_bb_offset (ibb) +4 *10 , buf->addr.offset);
@@ -230,7 +236,7 @@ gen9_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst, ss->ss11.aux_base_addr_hi = (address + buf->ccs[0 ].offset) >>32 ; } -if (fast_clear || (buf->cc.offset && !HAS_FLATCCS (ibb->devid))) { +if (cc_enable (ibb, buf, fast_clear)) {igt_assert (buf->compression ==I915_COMPRESSION_RENDER ); ss->ss10.clearvalue_addr_enable =1 ;
Signature · 1 line
2.41.0