From: "Maíra Canal" <mcanal@igalia.com>
To: "Melissa Wen" <mwen@igalia.com>,
"André Almeida" <andrealmeid@igalia.com>,
"Petri Latvala" <petri.latvala@intel.com>,
"Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
"Tomeu Vizoso" <tomeu.vizoso@collabora.com>,
"Emma Anholt" <emma@anholt.net>,
"Iago Toral Quiroga" <itoral@igalia.com>,
"Rob Clark" <robdclark@chromium.org>
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 1/3] lib/v3d: Add a helper to create a empty shader
Date: Fri, 13 Jan 2023 09:44:51 -0300 [thread overview]
Message-ID: <20230113124453.196280-2-mcanal@igalia.com> (raw)
In-Reply-To: <20230113124453.196280-1-mcanal@igalia.com>
In order to submit a compute dispatch job, a BO must contain the
assembly shader that corresponds to the job. Therefore, create a helper
to encapsulate a simple compute dispatch job. This helper sets the
configurations (cfg) needed for the job and has the assembled instructions
necessary to process an empty shader, just like the following one:
#version 310 es
layout (local_size_x = 1) in;
void main (void) {}
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
lib/igt_v3d.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
lib/igt_v3d.h | 20 +++++++++++++++++
2 files changed, 80 insertions(+)
diff --git a/lib/igt_v3d.c b/lib/igt_v3d.c
index cc8f410d..dd5ebb6d 100644
--- a/lib/igt_v3d.c
+++ b/lib/igt_v3d.c
@@ -341,3 +341,63 @@ void igt_v3d_free_cl_job(int fd, struct v3d_cl_job *job)
free(job->submit);
free(job);
}
+
+struct v3d_csd_job *igt_v3d_empty_shader(int fd)
+{
+ struct v3d_csd_job *job;
+ uint32_t *bos;
+
+ /* Reproduce an empty shader */
+ const uint32_t assembly[] = { 0xbb800000, 0x3c203186,
+ 0xbb800000, 0x3c003186,
+ 0xbb800000, 0x3c003186 };
+ const uint32_t group_count_x = 1, group_count_y = 1, group_count_z = 1;
+ const uint32_t num_batches = 1, wgs_per_sg = 1, batches_per_sg = 1, wg_size = 1;
+
+ job = calloc(1, sizeof(*job));
+
+ job->shader_assembly = igt_v3d_create_bo(fd, PAGE_SIZE);
+ job->cl = igt_v3d_create_bo(fd, PAGE_SIZE);
+ job->submit = calloc(1, sizeof(*job->submit));
+
+ igt_v3d_bo_mmap(fd, job->shader_assembly);
+ igt_v3d_bo_mmap(fd, job->cl);
+
+ memset(job->shader_assembly->map, 0, sizeof(*job->shader_assembly->map));
+ memcpy(job->shader_assembly->map, assembly, sizeof(assembly));
+ memset(job->cl->map, 0, sizeof(*job->cl->map));
+
+ job->submit->bo_handle_count = 2;
+ bos = malloc(sizeof(*bos) * job->submit->bo_handle_count);
+ bos[0] = job->shader_assembly->handle;
+ bos[1] = job->cl->handle;
+
+ job->submit->bo_handles = to_user_pointer(bos);
+
+ job->submit->cfg[0] |= group_count_x << V3D_CSD_CFG012_WG_COUNT_SHIFT;
+ job->submit->cfg[1] |= group_count_y << V3D_CSD_CFG012_WG_COUNT_SHIFT;
+ job->submit->cfg[2] |= group_count_z << V3D_CSD_CFG012_WG_COUNT_SHIFT;
+
+ job->submit->cfg[3] |= (wgs_per_sg & 0xf) << V3D_CSD_CFG3_WGS_PER_SG_SHIFT;
+ job->submit->cfg[3] |= (batches_per_sg - 1) << V3D_CSD_CFG3_BATCHES_PER_SG_M1_SHIFT;
+ job->submit->cfg[3] |= (wg_size & 0xff) << V3D_CSD_CFG3_WG_SIZE_SHIFT;
+
+ job->submit->cfg[4] = num_batches - 1;
+
+ job->submit->cfg[5] = job->shader_assembly->offset | V3D_CSD_CFG5_PROPAGATE_NANS;
+ job->submit->cfg[5] |= V3D_CSD_CFG5_SINGLE_SEG;
+ job->submit->cfg[5] |= V3D_CSD_CFG5_THREADING;
+
+ job->submit->cfg[6] = job->cl->offset;
+
+ return job;
+}
+
+void igt_v3d_free_csd_job(int fd, struct v3d_csd_job *job)
+{
+ free(from_user_pointer(job->submit->bo_handles));
+ igt_v3d_free_bo(fd, job->shader_assembly);
+ igt_v3d_free_bo(fd, job->cl);
+ free(job->submit);
+ free(job);
+}
diff --git a/lib/igt_v3d.h b/lib/igt_v3d.h
index 2cf7fbd8..b96a3b43 100644
--- a/lib/igt_v3d.h
+++ b/lib/igt_v3d.h
@@ -28,6 +28,17 @@
#define PAGE_SIZE 4096
+#define V3D_CSD_CFG012_WG_COUNT_SHIFT 16
+/* Batches per supergroup minus 1. 8 bits. */
+#define V3D_CSD_CFG3_BATCHES_PER_SG_M1_SHIFT 12
+/* Workgroups per supergroup, 0 means 16 */
+#define V3D_CSD_CFG3_WGS_PER_SG_SHIFT 8
+#define V3D_CSD_CFG3_WG_SIZE_SHIFT 0
+
+#define V3D_CSD_CFG5_PROPAGATE_NANS (1 << 2)
+#define V3D_CSD_CFG5_SINGLE_SEG (1 << 1)
+#define V3D_CSD_CFG5_THREADING (1 << 0)
+
struct v3d_cl;
struct v3d_bo {
@@ -46,6 +57,12 @@ struct v3d_cl_job {
struct v3d_bo *tile_state;
};
+struct v3d_csd_job {
+ struct drm_v3d_submit_csd *submit;
+ struct v3d_bo *shader_assembly;
+ struct v3d_bo *cl;
+};
+
struct v3d_bo *igt_v3d_create_bo(int fd, size_t size);
void igt_v3d_free_bo(int fd, struct v3d_bo *bo);
@@ -67,4 +84,7 @@ void igt_v3d_set_multisync(struct drm_v3d_multi_sync *ms, enum v3d_queue wait_st
struct v3d_cl_job *igt_v3d_noop_job(int fd);
void igt_v3d_free_cl_job(int fd, struct v3d_cl_job *job);
+struct v3d_csd_job *igt_v3d_empty_shader(int fd);
+void igt_v3d_free_csd_job(int fd, struct v3d_csd_job *job);
+
#endif /* IGT_V3D_H */
--
2.39.0
next prev parent reply other threads:[~2023-01-13 12:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-13 12:44 [igt-dev] [PATCH i-g-t 0/3] V3D Mixed Job Submission Tests Maíra Canal
2023-01-13 12:44 ` Maíra Canal [this message]
2023-02-10 13:31 ` [igt-dev] [PATCH i-g-t 1/3] lib/v3d: Add a helper to create a empty shader Kamil Konieczny
2023-01-13 12:44 ` [igt-dev] [PATCH i-g-t 2/3] tests/v3d_submit_csd: Create test for V3D's Submit CSD IOCTL Maíra Canal
2023-01-13 12:44 ` [igt-dev] [PATCH i-g-t 3/3] tests/v3d_job_submission: Create tests to mix CL and CSD jobs Maíra Canal
2023-02-08 10:27 ` Melissa Wen
2023-01-13 13:23 ` [igt-dev] ✗ Fi.CI.BUILD: failure for V3D Mixed Job Submission Tests Patchwork
2023-02-07 14:17 ` [igt-dev] ✓ Fi.CI.BAT: success for V3D Mixed Job Submission Tests (rev2) Patchwork
2023-02-07 16:11 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-02-08 10:31 ` [igt-dev] [PATCH i-g-t 0/3] V3D Mixed Job Submission Tests Melissa Wen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230113124453.196280-2-mcanal@igalia.com \
--to=mcanal@igalia.com \
--cc=andrealmeid@igalia.com \
--cc=boris.brezillon@collabora.com \
--cc=emma@anholt.net \
--cc=igt-dev@lists.freedesktop.org \
--cc=itoral@igalia.com \
--cc=kamil.konieczny@linux.intel.com \
--cc=mwen@igalia.com \
--cc=petri.latvala@intel.com \
--cc=robdclark@chromium.org \
--cc=tomeu.vizoso@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox