Skip to content

Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.

C

Metal on Vulkan diagnostics: each distinct stderr line once, shadow.log, a barrier that turns GMEM off

yehorkaa7f9f3427e629
diff --git a/tools/mesa/turnip-darwin.patch b/tools/mesa/turnip-darwin.patch
index 58963d1..c3f2a1c 100644
--- a/tools/mesa/turnip-darwin.patch
+++ b/tools/mesa/turnip-darwin.patch
@@ -38,6 +38,19 @@ index d0a38c9..4f68424 100644
link_depends : vulkan_icd_link_depends,
install : true,
)
+diff --git a/src/freedreno/vulkan/tu_cmd_buffer.cc b/src/freedreno/vulkan/tu_cmd_buffer.cc
+index 2474ad8..74d6f0c 100644
+--- a/src/freedreno/vulkan/tu_cmd_buffer.cc
++++ b/src/freedreno/vulkan/tu_cmd_buffer.cc
+@@ -7296,6 +7296,8 @@ tu_barrier(struct tu_cmd_buffer *cmd,
+ */
+ if ((srcStage & ~framebuffer_space_stages) ||
+ (dstStage & ~framebuffer_space_stages)) {
++ perf_debug(cmd->device, "Disabling gmem due to a barrier in the render pass: stages %#llx -> %#llx",
++ (unsigned long long) srcStage, (unsigned long long) dstStage);
+ cmd->state.rp.disable_gmem = true;
+ }
+ }
diff --git a/src/freedreno/vulkan/tu_device.cc b/src/freedreno/vulkan/tu_device.cc
index 62ebfd0..951a198 100644
--- a/src/freedreno/vulkan/tu_device.cc
diff --git a/userland/src/HakiosMetalCA.m b/userland/src/HakiosMetalCA.m
index 552de6b..15ad59c 100644
--- a/userland/src/HakiosMetalCA.m
+++ b/userland/src/HakiosMetalCA.m
@@ -2077,7 +2077,19 @@ hm_boot_arg_set(const char *what)
int lines = 0;
while (in != NULL && fgets(line, sizeof(line), in) != NULL) {
- if (lines++ < 40 || strstr(line, "metal2vulkan:") != NULL || strstr(line, "TU: ") != NULL) {
+ /* each distinct line once (digits aside), at most 120 of them */
+ static uint32_t seen[512];
+ static int distinct;
+ uint32_t h = 2166136261u;
+ for (const char *c = line; *c; c++) {
+ if (*c < '0' || *c > '9') h = (h ^ (uint8_t)*c) * 16777619u;
+ }
+ bool fresh = true;
+ for (int i = 0; i < distinct; i++) {
+ if (seen[i] == h) { fresh = false; break; }
+ }
+ if (fresh && distinct < 512) seen[distinct++] = h;
+ if (fresh && (lines++ < 40 || ((strstr(line, "metal2vulkan:") != NULL || strstr(line, "TU: ") != NULL) && distinct < 160))) {
hm_print("stderr: %s", line);
}
if (strcasestr(line, "error") || strcasestr(line, "refus") || strcasestr(line, "warn")) {
@@ -2126,6 +2138,24 @@ hm_boot_arg_set(const char *what)
if (hm_m2v_last_stderr[0] != 0) {
hm_print("metal2vulkan: last stderr: %s", hm_m2v_last_stderr);
}
+ /* the textures the runtime keeps a shadow image of, and why (its shadow.log): the first 40 */
+ {
+ static long read_to;
+ static int told;
+ FILE *log = fopen("/private/var/db/m2v/shadow.log", "r");
+ char line[600];
+
+ if (log == NULL) log = fopen("/private/var/tmp/m2v/shadow.log", "r");
+ if (log != NULL) {
+ fseek(log, read_to, SEEK_SET);
+ while (told < 40 && fgets(line, sizeof(line), log) != NULL) {
+ hm_print("metal2vulkan: shadow: %s", line);
+ told++;
+ }
+ read_to = ftell(log);
+ fclose(log);
+ }
+ }
}
});
return [device retain]; /* (self not released: before -init, _MTLDevice's -dealloc reads what -init never set) */