mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
On some Adreno devices (the Retroid Pocket Duo) SELinux hides kgsl's sysfs nodes from apps, so the HUD showed no GPU % and no GPU clock. Devices whose nodes are readable keep using them; nothing changes there or on GPUs without kgsl. Where the nodes are blocked: - GPU %: a native reader maps kgsl's memstore read-only (any kgsl client may) and samples the ringbuffer start/end timestamps once a millisecond while a HUD is shown. That covers all GPU work, Android's own composition included. - Backup for GPU %: an implicit Vulkan layer in the guest (tools/gpuload) and the compositor time their own GPU work with timestamp queries. It runs until the memstore stamps are seen moving, and for the whole session if they never move. - GPU clock: a small GPU job of our own reads the always-on and RBBM cycle counters (libgpuclock). The HUD diagnostics export lists which source each GPU value came from. tools/gpuload/build.sh takes the Vulkan headers from build_local.sh's NDK first and keeps NDK paths with spaces intact.
57 lines
1.6 KiB
C
57 lines
1.6 KiB
C
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "kgsl_busy.h"
|
|
|
|
#define ENTRIES 819
|
|
|
|
static uint32_t memstore[ENTRIES * KGSL_BUSY_ENTRY_WORDS];
|
|
|
|
static void stamp(int entry, uint32_t sop, uint32_t eop) {
|
|
memstore[entry * KGSL_BUSY_ENTRY_WORDS + KGSL_BUSY_SOP] = sop;
|
|
memstore[entry * KGSL_BUSY_ENTRY_WORDS + KGSL_BUSY_EOP] = eop;
|
|
}
|
|
|
|
int main(void) {
|
|
assert(kgsl_busy_first_slot(8 * 4096) == 813);
|
|
assert(kgsl_busy_first_slot(8 * 16384) == 3270);
|
|
assert(kgsl_busy_first_slot(7 * 40) == -1);
|
|
|
|
int first = kgsl_busy_first_slot(sizeof(memstore));
|
|
uint32_t last[KGSL_BUSY_SLOTS] = {0};
|
|
int moved = 0;
|
|
|
|
stamp(first, 100, 100);
|
|
stamp(first + 2, 7, 7);
|
|
assert(kgsl_busy_sample(memstore, first, last, &moved) == 0);
|
|
assert(moved == 1 && last[0] == 100 && last[2] == 7);
|
|
|
|
moved = 0;
|
|
assert(kgsl_busy_sample(memstore, first, last, &moved) == 0);
|
|
assert(moved == 0);
|
|
|
|
stamp(first + 2, 8, 7);
|
|
assert(kgsl_busy_sample(memstore, first, last, &moved) == 1);
|
|
assert(moved == 1);
|
|
|
|
moved = 0;
|
|
stamp(first + 2, 8, 8);
|
|
assert(kgsl_busy_sample(memstore, first, last, &moved) == 0);
|
|
assert(moved == 0);
|
|
|
|
stamp(first + 4, 3, 2);
|
|
assert(kgsl_busy_sample(memstore, first, last, &moved) == 1);
|
|
|
|
memset(memstore, 0, sizeof(memstore));
|
|
stamp(first - 1, 5, 4);
|
|
stamp(first + KGSL_BUSY_SLOTS, 9, 8);
|
|
memset(last, 0, sizeof(last));
|
|
moved = 0;
|
|
assert(kgsl_busy_sample(memstore, first, last, &moved) == 0);
|
|
assert(moved == 0);
|
|
|
|
puts("PASS: kgsl memstore busy");
|
|
return 0;
|
|
}
|