Limit number of foveation samples per pixel

This commit is contained in:
Patrick Nicolas
2025-08-31 17:08:45 +02:00
parent 74ff55d5cb
commit 5ff85ef7a7
8 changed files with 57 additions and 11 deletions
@@ -1,7 +1,7 @@
From 5a4505efc60c9252176b73775278b6f5b775fe8e Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Tue, 22 Oct 2024 15:23:19 +0200
Subject: [PATCH 1/7] c/multi: early wake of compositor
Subject: [PATCH 1/8] c/multi: early wake of compositor
---
.../compositor/multi/comp_multi_compositor.c | 14 +++++++++
@@ -1,7 +1,7 @@
From e118393925294a3b57cbf149fdc28685b27aec94 Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Tue, 2 Apr 2024 17:14:42 +0200
Subject: [PATCH 2/7] ipc/server: Always listen to stdin
Subject: [PATCH 2/8] ipc/server: Always listen to stdin
---
src/xrt/ipc/server/ipc_server_mainloop_linux.c | 2 +-
@@ -1,7 +1,7 @@
From d4b4c209e9106edf5e6b1c3efbcac2b88364518b Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Tue, 8 Oct 2024 22:13:15 +0200
Subject: [PATCH 3/7] Use extern socket fd
Subject: [PATCH 3/8] Use extern socket fd
---
src/xrt/ipc/server/ipc_server_mainloop_linux.c | 8 ++++++++
@@ -1,7 +1,7 @@
From 6dc7053efd13536ba81e8261c183ac0ae54321e2 Mon Sep 17 00:00:00 2001
From a0eafb7370e319386bdd790059e2f13147706a9f Mon Sep 17 00:00:00 2001
From: galister <85970-galister@users.noreply.gitlab.freedesktop.org>
Date: Sat, 23 Nov 2024 02:42:12 +0900
Subject: [PATCH 4/7] change environment blend mode selection logic
Subject: [PATCH 4/8] change environment blend mode selection logic
---
src/xrt/compositor/multi/comp_multi_system.c | 26 +++++++++++++-------
@@ -1,7 +1,7 @@
From b9be14a7b106595ac1e6e350dcaaf93c906d0d0b Mon Sep 17 00:00:00 2001
From 406114aa32a71e04b43b44b0aec04472f9fa82c3 Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Thu, 27 Feb 2025 22:45:36 +0100
Subject: [PATCH 5/7] c/main: allow custom pacing app factory
Subject: [PATCH 5/8] c/main: allow custom pacing app factory
---
src/xrt/compositor/main/comp_compositor.c | 10 ++++++----
@@ -1,7 +1,7 @@
From bbf1e184d62cfb0dbafe5cfa1c1851baebf6be58 Mon Sep 17 00:00:00 2001
From aa73e7d05747374760b22333495cde8c3d9d3f10 Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Sat, 15 Mar 2025 22:19:48 +0100
Subject: [PATCH 6/7] st/oxr: forward 0 refresh rate
Subject: [PATCH 6/8] st/oxr: forward 0 refresh rate
---
src/xrt/state_trackers/oxr/oxr_api_session.c | 6 +-----
@@ -1,7 +1,7 @@
From d8385cab2e585d9bb1f9a392a22ecf3be3f714fe Mon Sep 17 00:00:00 2001
From 3172d537740d2a334dbb009f63c6e6f039554181 Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Wed, 11 Sep 2024 22:56:29 +0200
Subject: [PATCH 7/7] Replace distortion with foveation
Subject: [PATCH 7/8] Replace distortion with foveation
---
src/xrt/compositor/CMakeLists.txt | 4 +-
@@ -0,0 +1,46 @@
From 4de55a9bc2ab7d3931d38b6697268af5421c0328 Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Sun, 31 Aug 2025 17:05:49 +0200
Subject: [PATCH 8/8] Limit foveation samples per pixel
---
src/xrt/compositor/shaders/distortion.comp | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/xrt/compositor/shaders/distortion.comp b/src/xrt/compositor/shaders/distortion.comp
index cd1828ac9..41de849e6 100644
--- a/src/xrt/compositor/shaders/distortion.comp
+++ b/src/xrt/compositor/shaders/distortion.comp
@@ -12,6 +12,7 @@
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
#define MAX_DIM 4097
+#define MAX_SAMPLES 4
layout(set = 0, binding = 0) uniform sampler2D source[2];
layout(set = 0, binding = 1, std430) buffer restrict Foveation
@@ -67,13 +68,18 @@ void main()
if (xmin == xmax)
return;
+ uint xstep = (xmax - xmin + MAX_SAMPLES - 1) / MAX_SAMPLES;
+ uint ystep = (ymax - ymin + MAX_SAMPLES - 1) / MAX_SAMPLES;
+
vec4 colour = vec4(0);
- for (uint y = ymin ; y < ymax; y += 1) {
- for (uint x = xmin ; x < xmax; x += 1) {
+ uint count = 0;
+ for (uint y = ymin ; y < ymax; y += ystep) {
+ for (uint x = xmin ; x < xmax; x += xstep) {
colour += texelFetch(source[iz], ivec2(x, y), 0);
+ ++count;
}
}
- colour /= (xmax - xmin) * (ymax - ymin);
+ colour /= count;
colour.xyz = rgb_to_ycbcr(from_linear_to_srgb(colour.rgb));
imageStore(luma, ivec3(offset.x + ix, offset.y + iy, 0), vec4(colour.x));
--
2.51.0