mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 14:26:00 +00:00
fix(quest): correct desktop and Steam display corruption across sessions (#733)
fix(quest): stabilize desktop and Steam layer presentation Keep Quest SDR scenes and the black backdrop off the Android Vulkan swapchain regardless of session order or HDR preferences. Only report the first frame after client content is submitted. Add backdrop lifecycle and first-frame regression coverage. Record the user's successful Quest 3 Test 2 result. Co-authored-by: xXJsonDeruloXx <danielhimebauch@gmail.com>
This commit is contained in:
1 parent
c3cd955686
commit
a692436f67
11 files changed
+510
-10
No files matched your search
@@ -0,0 +1,74 @@
|
||||
/* Exercise the production vkp_render entrypoint without Android/Vulkan hardware.
|
||||
* The Python runner extracts that function verbatim into the included file. */
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct vkp_draw { int unused; };
|
||||
static int quest, framegen, cardboard, pass_result, base_result, pass_shown;
|
||||
static int first_frames, pass_calls, base_calls, fallback_calls;
|
||||
static int vkp_quest_layer_presentation(void) { return quest; }
|
||||
static int vkp_framegen_active(void) { return framegen; }
|
||||
static int vkp_cardboard_active(void) { return cardboard; }
|
||||
static void vkp_apply_window_request(void) {}
|
||||
static void sc_layer_hide_overlay(void) {}
|
||||
static void sc_layer_hide(void) {}
|
||||
static void droiddeck_log(const char *tag, const char *message, ...) {}
|
||||
static void vkp_signal_first_frame(void) { first_frames++; }
|
||||
static int vkp_base_black(int w, int h) { base_calls++; return base_result; }
|
||||
static int sc_layer_present_pass(const struct vkp_draw *draws, int n, int w, int h) {
|
||||
pass_calls++;
|
||||
/* Production sc_layer_present_pass signals only after a content submission.
|
||||
* Its no-op results (off-screen geometry or pool exhaustion) also return 0. */
|
||||
if (pass_result == 0 && pass_shown) vkp_signal_first_frame();
|
||||
return pass_result;
|
||||
}
|
||||
static int render_impl(int w, int h, const struct vkp_draw *draws, int n,
|
||||
const void *hdr, int *how) { fallback_calls++; return 17; }
|
||||
|
||||
#include "vkp_render_under_test.inc"
|
||||
|
||||
static void reset(void) {
|
||||
quest = 1;
|
||||
framegen = cardboard = pass_result = base_result = pass_shown = 0;
|
||||
first_frames = pass_calls = base_calls = fallback_calls = 0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
const struct vkp_draw draw = {0};
|
||||
reset();
|
||||
for (int i = 0; i < 3; i++) assert(vkp_render(1280, 720, NULL, 0) == 0);
|
||||
assert(base_calls == 3 && pass_calls == 0 && first_frames == 0);
|
||||
|
||||
/* An accepted layer operation is not necessarily a displayed client frame. */
|
||||
reset();
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
assert(pass_calls == 1 && base_calls == 1 && first_frames == 0);
|
||||
|
||||
/* Content is the sole owner of the notification, with no second backdrop event. */
|
||||
reset(); pass_shown = 1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
assert(first_frames == 1);
|
||||
assert(vkp_render(1280, 720, NULL, 0) == 0);
|
||||
assert(first_frames == 1);
|
||||
|
||||
reset(); pass_result = -1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == -1);
|
||||
assert(first_frames == 0 && base_calls == 0);
|
||||
reset(); base_result = -1;
|
||||
assert(vkp_render(1280, 720, NULL, 0) == -1);
|
||||
assert(first_frames == 0);
|
||||
|
||||
/* Existing routes remain responsible for their own notifications. */
|
||||
for (int mode = 0; mode < 3; mode++) {
|
||||
reset();
|
||||
if (mode == 0) quest = 0;
|
||||
if (mode == 1) framegen = 1;
|
||||
if (mode == 2) cardboard = 1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 17);
|
||||
assert(fallback_calls == 1 && pass_calls == 0 && base_calls == 0);
|
||||
assert(first_frames == 0);
|
||||
}
|
||||
puts("PASS: Quest first-frame notification waits for client content");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/* Exercise the production backdrop with mock Android buffers/transactions. */
|
||||
#include "../../app/src/main/cpp/waylandcomp/src/sc_layer.c"
|
||||
#include "../../app/src/main/cpp/waylandcomp/src/quest_device.h"
|
||||
#include <assert.h>
|
||||
|
||||
struct AHardwareBuffer { unsigned char pixels[20 * 16 * 4]; };
|
||||
static struct AHardwareBuffer buffer;
|
||||
static int fail_alloc, fail_lock, fail_unlock, fail_tx;
|
||||
static int allocs, locks, unlocks, buffers, applies, creates, releases, retirements;
|
||||
static int visible, zorder, opacity;
|
||||
static ARect destination;
|
||||
static ANativeWindow *window = (ANativeWindow *)1;
|
||||
ANativeWindow *vkp_window(void) { return window; }
|
||||
void droiddeck_log(const char *kind, const char *fmt, ...) { (void)kind; (void)fmt; }
|
||||
int AHardwareBuffer_allocate(const AHardwareBuffer_Desc *d, AHardwareBuffer **b) {
|
||||
assert(d->width == 16 && d->height == 16);
|
||||
assert(d->usage & AHARDWAREBUFFER_USAGE_CPU_WRITE_RARELY);
|
||||
allocs++;
|
||||
if (fail_alloc) return -1;
|
||||
memset(&buffer, 0xa5, sizeof(buffer)); *b = &buffer; return 0;
|
||||
}
|
||||
void AHardwareBuffer_describe(const AHardwareBuffer *b, AHardwareBuffer_Desc *d) {
|
||||
assert(b == &buffer); *d = (AHardwareBuffer_Desc){.width=16,.height=16,.stride=20};
|
||||
}
|
||||
int AHardwareBuffer_lock(AHardwareBuffer *b, uint64_t usage, int32_t fd, const ARect *r, void **p) {
|
||||
(void)usage; (void)fd; (void)r; assert(b == &buffer); locks++;
|
||||
if (fail_lock) return -1;
|
||||
*p = buffer.pixels; return 0;
|
||||
}
|
||||
int AHardwareBuffer_unlock(AHardwareBuffer *b, int32_t *f) {
|
||||
assert(b == &buffer && f == NULL); unlocks++; return fail_unlock ? -1 : 0;
|
||||
}
|
||||
void AHardwareBuffer_release(AHardwareBuffer *b) { assert(b == &buffer); releases++; }
|
||||
static ASurfaceControl *create(ANativeWindow *w, const char *n) {
|
||||
assert(w == window && strcmp(n, "droiddeck_wayland_black") == 0); creates++;
|
||||
return (ASurfaceControl *)(uintptr_t)(100 + creates);
|
||||
}
|
||||
static ASurfaceTransaction *tx_create(void) { return fail_tx ? NULL : (ASurfaceTransaction *)2; }
|
||||
static void tx_delete(ASurfaceTransaction *t) { assert(t == (ASurfaceTransaction *)2); }
|
||||
static void tx_apply(ASurfaceTransaction *t) { (void)t; applies++; }
|
||||
static void set_buffer(ASurfaceTransaction *t, ASurfaceControl *s, AHardwareBuffer *b, int fd) {
|
||||
(void)t; (void)s; assert(b == &buffer && fd == -1);
|
||||
/* No garbage, including padded row bytes, reaches the display. */
|
||||
for (unsigned i=0; i<sizeof(buffer.pixels); i++) assert(buffer.pixels[i] == 0);
|
||||
assert(unlocks > 0); buffers++;
|
||||
}
|
||||
static void visibility(ASurfaceTransaction *t, ASurfaceControl *s, int8_t v) { (void)t; (void)s; visible=v; }
|
||||
static void z(ASurfaceTransaction *t, ASurfaceControl *s, int32_t v) { (void)t; (void)s; zorder=v; }
|
||||
static void transparency(ASurfaceTransaction *t, ASurfaceControl *s, int8_t v) { (void)t; (void)s; opacity=v; }
|
||||
static void geometry(ASurfaceTransaction *t, ASurfaceControl *s, const ARect *src, const ARect *dst, int32_t rotation) {
|
||||
(void)t; (void)s; assert(src->right==16 && src->bottom==16 && rotation==0); destination=*dst;
|
||||
}
|
||||
static void reparent(ASurfaceTransaction *t, ASurfaceControl *s, ASurfaceControl *parent) {
|
||||
(void)t; (void)s; assert(parent==NULL); retirements++;
|
||||
}
|
||||
static void release(ASurfaceControl *s) { assert(s); }
|
||||
static void reset(void) {
|
||||
base_hide(1); g_blank=NULL;
|
||||
fail_alloc=fail_lock=fail_unlock=fail_tx=0;
|
||||
allocs=locks=unlocks=buffers=applies=creates=releases=retirements=0;
|
||||
window=(ANativeWindow *)1;
|
||||
}
|
||||
int main(void) {
|
||||
assert(quest_device_matches("Quest 2", "", ""));
|
||||
assert(quest_device_matches("quest 3", "", ""));
|
||||
assert(quest_device_matches("Quest 3S", "", ""));
|
||||
assert(quest_device_matches("unknown", "hollywood", "Oculus"));
|
||||
assert(quest_device_matches("unknown", "eureka", "Meta"));
|
||||
assert(quest_device_matches("unknown", "panther", "Oculus"));
|
||||
assert(!quest_device_matches("Pixel", "panther", "Google"));
|
||||
assert(!quest_device_matches("Quest Pro", "seacliff", "Meta"));
|
||||
assert(!quest_device_matches("", "", ""));
|
||||
api.state=1; api.createFromWindow=create; api.txCreate=tx_create; api.txDelete=tx_delete;
|
||||
api.txApply=tx_apply; api.setBuffer=set_buffer; api.setVisibility=visibility;
|
||||
api.setZOrder=z; api.setBufferTransparency=transparency; api.setGeometry=geometry;
|
||||
api.reparent=reparent; api.release=release;
|
||||
reset();
|
||||
assert(sc_layer_base_black(1920,1080)==0);
|
||||
assert(visible==ASC_VISIBILITY_SHOW && zorder==0 && opacity==ASC_TRANSPARENCY_OPAQUE);
|
||||
assert(destination.right==1920 && destination.bottom==1080);
|
||||
assert(allocs==1 && locks==1 && buffers==1 && creates==1);
|
||||
assert(sc_layer_base_black(1920,1080)==0 && applies==1); /* retained, not redrawn */
|
||||
assert(sc_layer_base_black(1440,1080)==0 && destination.right==1440 && allocs==1);
|
||||
sc_layer_hide_base(); assert(!visible && !g_base_shown);
|
||||
assert(sc_layer_base_black(1440,1080)==0 && visible && allocs==1);
|
||||
base_hide(1); assert(!g_base_sc && !g_base_shown && retirements==1);
|
||||
window=(ANativeWindow *)3;
|
||||
assert(sc_layer_base_black(1280,720)==0 && creates==2 && allocs==1 && locks==1);
|
||||
reset(); fail_alloc=1;
|
||||
assert(sc_layer_base_black(1920,1080)==-1 && buffers==0 && locks==0);
|
||||
reset(); fail_lock=1;
|
||||
assert(sc_layer_base_black(1920,1080)==-1 && buffers==0 && releases==1 && g_blank==NULL);
|
||||
reset(); fail_unlock=1;
|
||||
assert(sc_layer_base_black(1920,1080)==-1 && buffers==0 && releases==1 && g_blank==NULL);
|
||||
reset(); fail_tx=1;
|
||||
assert(sc_layer_base_black(1920,1080)==-1 && buffers==0 && !g_base_shown);
|
||||
fail_tx=0; assert(sc_layer_base_black(1920,1080)==0 && creates==1 && locks==1);
|
||||
reset(); window=NULL;
|
||||
assert(sc_layer_base_black(1920,1080)==-1 && allocs==0);
|
||||
window=(ANativeWindow *)1;
|
||||
assert(sc_layer_base_black(0,1080)==-1 && allocs==0);
|
||||
puts("PASS: Quest backdrop initialization, padding, reuse, resize, retire and failure recovery");
|
||||
}
|
||||
Reference in new issue
Block a user