[PATCH i-g-t] tests/intel/kms_ccs: Add Xe2 ccs crc tests
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Tue Feb 6 19:05:02 UTC 2024
Add Xe2 pat index type ccs tests for testing
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
tests/intel/kms_ccs.c | 197 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 187 insertions(+), 10 deletions(-)
diff --git a/tests/intel/kms_ccs.c b/tests/intel/kms_ccs.c
index 74bc78477..cbd80ae5a 100644
--- a/tests/intel/kms_ccs.c
+++ b/tests/intel/kms_ccs.c
@@ -37,6 +37,9 @@
#include "igt.h"
#include "i915/gem_create.h"
+#include "intel_pat.h"
+#include "intel_blt.h"
+#include "intel_mocs.h"
#include "xe/xe_ioctl.h"
#include "xe/xe_query.h"
@@ -248,6 +251,7 @@ static const struct {
{I915_FORMAT_MOD_4_TILED_MTL_RC_CCS, "4-tiled-mtl-rc-ccs"},
{I915_FORMAT_MOD_4_TILED_MTL_MC_CCS, "4-tiled-mtl-mc-ccs"},
{I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC, "4-tiled-mtl-rc-ccs-cc"},
+ {I915_FORMAT_MOD_4_TILED, "4-tiled-xe2-ccs"},
};
static bool check_ccs_planes;
@@ -534,6 +538,143 @@ static void fast_clear_fb(int drm_fd, struct igt_fb *fb, const float *cc_color)
buf_ops_destroy(bops);
}
+static struct blt_copy_object *blt_fb_init(const struct igt_fb *fb,
+ uint32_t plane, uint32_t memregion,
+ uint8_t pat_index)
+{
+ uint32_t name, handle;
+ struct blt_copy_object *blt;
+ uint64_t stride;
+
+ blt = malloc(sizeof(*blt));
+ igt_assert(blt);
+
+ name = gem_flink(fb->fd, fb->gem_handle);
+ handle = gem_open(fb->fd, name);
+
+ stride = fb->strides[plane] / 4;
+
+ blt_set_object(blt, handle, fb->size, memregion,
+ intel_get_uc_mocs_index(fb->fd),
+ pat_index,
+ T_TILE4,
+ COMPRESSION_DISABLED,
+ COMPRESSION_TYPE_3D);
+
+ blt_set_geom(blt, stride, 0, 0, fb->width, fb->plane_height[plane], 0, 0);
+ blt->plane_offset = fb->offsets[plane];
+ blt->ptr = xe_bo_mmap_ext(fb->fd, handle, fb->size,
+ PROT_READ | PROT_WRITE);
+ return blt;
+}
+
+static enum blt_color_depth blt_get_bpp(const struct igt_fb *fb)
+{
+ switch (fb->plane_bpp[0]) {
+ case 8:
+ return CD_8bit;
+ case 16:
+ return CD_16bit;
+ case 32:
+ return CD_32bit;
+ case 64:
+ return CD_64bit;
+ case 96:
+ return CD_96bit;
+ case 128:
+ return CD_128bit;
+ default:
+ igt_assert(0);
+ }
+}
+
+static uint32_t blt_compression_format(struct blt_copy_data *blt,
+ const struct igt_fb *fb)
+{
+ switch (fb->drm_format) {
+ case DRM_FORMAT_XRGB8888:
+ case DRM_FORMAT_P010:
+ case DRM_FORMAT_P012:
+ case DRM_FORMAT_P016:
+ case DRM_FORMAT_YUYV:
+ return 8;
+ case DRM_FORMAT_XYUV8888:
+ case DRM_FORMAT_NV12:
+ return 9;
+ default:
+ igt_assert_f(0, "Unknown format\n");
+ }
+}
+
+static void xe2_ccs_blit(data_t *data, struct igt_fb *fb, struct igt_fb *temp_fb)
+{
+ uint64_t ahnd = 0;
+
+ struct blt_copy_data blt = {};
+ struct blt_copy_object *src, *dst;
+ struct blt_block_copy_data_ext ext = {}, *pext = NULL;
+ uint32_t mem_region;
+ intel_ctx_t *xe_ctx;
+ uint32_t vm, exec_queue;
+ uint32_t xe_bb;
+ uint64_t bb_size = 4096;
+ struct igt_fb *dst_fb = fb, *src_fb = temp_fb;
+
+ struct drm_xe_engine_class_instance inst = {
+ .engine_class = DRM_XE_ENGINE_CLASS_COPY,
+ };
+
+ vm = xe_vm_create(src_fb->fd, 0, 0);
+
+ exec_queue = xe_exec_queue_create(src_fb->fd, vm, &inst, 0);
+ xe_ctx = intel_ctx_xe(src_fb->fd, vm, exec_queue, 0, 0, 0);
+ mem_region = vram_if_possible(src_fb->fd, 0);
+
+ ahnd = intel_allocator_open_full(src_fb->fd, xe_ctx->vm, 0, 0,
+ INTEL_ALLOCATOR_SIMPLE,
+ ALLOC_STRATEGY_LOW_TO_HIGH, 0);
+
+ bb_size = ALIGN(bb_size + xe_cs_prefetch_size(src_fb->fd),
+ xe_get_default_alignment(src_fb->fd));
+ xe_bb = xe_bo_create(src_fb->fd, 0, bb_size,
+ vram_if_possible(dst_fb->fd, 0), 0);
+
+ for (int i = 0; i < dst_fb->num_planes; i++) {
+ src = blt_fb_init(src_fb, i, mem_region, intel_get_pat_idx_uc(src_fb->fd));
+ dst = blt_fb_init(dst_fb, i, mem_region, intel_get_pat_idx_wt(dst_fb->fd));
+
+ blt_copy_init(src_fb->fd, &blt);
+ blt.color_depth = blt_get_bpp(src_fb);
+ blt_set_copy_object(&blt.src, src);
+ blt_set_copy_object(&blt.dst, dst);
+
+ blt_set_object_ext(&ext.src,
+ blt_compression_format(&blt, src_fb),
+ src_fb->width, src_fb->height,
+ SURFACE_TYPE_2D);
+
+ blt_set_object_ext(&ext.dst,
+ blt_compression_format(&blt, dst_fb),
+ dst_fb->width, dst_fb->height,
+ SURFACE_TYPE_2D);
+
+ pext = &ext;
+
+ blt_set_batch(&blt.bb, xe_bb, bb_size, mem_region);
+
+ blt_block_copy(src_fb->fd, xe_ctx, NULL, ahnd, &blt, pext);
+
+ blt_destroy_object(src_fb->fd, src);
+ blt_destroy_object(dst_fb->fd, dst);
+ }
+
+ put_ahnd(ahnd);
+ gem_close(dst_fb->fd, xe_bb);
+ xe_exec_queue_destroy(dst_fb->fd, exec_queue);
+ xe_vm_destroy(dst_fb->fd, vm);
+ free(xe_ctx);
+}
+
static void generate_fb(data_t *data, struct igt_fb *fb,
int width, int height,
enum test_fb_flags fb_flags)
@@ -572,15 +713,37 @@ static void generate_fb(data_t *data, struct igt_fb *fb,
if (do_fast_clear && (fb_flags & FB_COMPRESSED)) {
fast_clear_fb(data->drm_fd, fb, cc_color);
} else {
- cr = igt_get_cairo_ctx(data->drm_fd, fb);
+ if (modifier == I915_FORMAT_MOD_4_TILED) {
+ struct igt_fb temp_fb;
+ /* tile4 is used as ccs modifier
+ * on Xe2 where compression is handled
+ * through PAT indexes.
+ */
+
+ // non compressed temporary pattern image
+ if (do_solid_fill)
+ igt_create_color_fb(data->drm_fd, width, height,
+ fb->drm_format, I915_FORMAT_MOD_4_TILED,
+ colors[c].r, colors[c].g, colors[c].b,
+ &temp_fb);
+ else
+ igt_create_pattern_fb(data->drm_fd, width, height,
+ fb->drm_format, I915_FORMAT_MOD_4_TILED,
+ &temp_fb);
+
+ xe2_ccs_blit(data, fb, &temp_fb);
+ igt_remove_fb(data->drm_fd, &temp_fb);
+ } else {
+ cr = igt_get_cairo_ctx(data->drm_fd, fb);
- if (do_solid_fill)
- igt_paint_color(cr, 0, 0, width, height,
- colors[c].r, colors[c].g, colors[c].b);
- else
- igt_paint_test_pattern(cr, width, height);
+ if (do_solid_fill)
+ igt_paint_color(cr, 0, 0, width, height,
+ colors[c].r, colors[c].g, colors[c].b);
+ else
+ igt_paint_test_pattern(cr, width, height);
- igt_put_cairo_ctx(cr);
+ igt_put_cairo_ctx(cr);
+ }
}
}
@@ -748,8 +911,11 @@ static int test_ccs(data_t *data)
static void test_output(data_t *data, const int testnum)
{
+ uint16_t dev_id;
+
igt_fixture {
bool found = false;
+ dev_id = intel_get_drm_devid(data->drm_fd);
data->flags = tests[testnum].flags;
@@ -767,10 +933,13 @@ static void test_output(data_t *data, const int testnum)
}
for (int i = 0; i < ARRAY_SIZE(ccs_modifiers); i++) {
- if ((ccs_modifiers[i].modifier == I915_FORMAT_MOD_4_TILED_DG2_RC_CCS ||
+ if (((ccs_modifiers[i].modifier == I915_FORMAT_MOD_4_TILED_DG2_RC_CCS ||
ccs_modifiers[i].modifier == I915_FORMAT_MOD_4_TILED_DG2_MC_CCS ||
- ccs_modifiers[i].modifier == I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC) &&
- tests[testnum].flags & TEST_BAD_CCS_PLANE)
+ ccs_modifiers[i].modifier == I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC ||
+ AT_LEAST_GEN(dev_id, 20)) &&
+ tests[testnum].flags & TEST_BAD_CCS_PLANE) ||
+ (tests[testnum].flags & TEST_BAD_PIXEL_FORMAT &&
+ AT_LEAST_GEN(dev_id, 20)))
continue;
data->ccs_modifier = ccs_modifiers[i].modifier;
@@ -780,6 +949,14 @@ static void test_output(data_t *data, const int testnum)
tests[testnum].testname, ccs_modifiers[i].str) {
int valid_tests = 0;
+ if (ccs_modifiers[i].modifier == I915_FORMAT_MOD_4_TILED) {
+ igt_require_f(AT_LEAST_GEN(dev_id, 20),
+ "Xe2 platform needed.\n");
+ } else {
+ igt_require_f(intel_get_device_info(dev_id)->graphics_ver < 20,
+ "Older than Xe2 platform needed.\n");
+ }
+
if (data->flags == TEST_RANDOM)
igt_info("Testing with seed %d\n", data->seed);
--
2.25.1
More information about the igt-dev
mailing list