commit 91329febb83f8803b3d249fcd02be7dab8e23c5e
parent f650a10c0358aabea7cb49d60b2c1dc660cecab2
Author: Vineet Kumar <git@vineetk.net>
Date: Wed, 25 Nov 2026 02:06:25 +0100
packages/vr: patch monado for better bsb2e support
Diffstat:
1 file changed, 105 insertions(+), 1 deletion(-)
diff --git a/epistemia/packages/vr.scm b/epistemia/packages/vr.scm
@@ -55,7 +55,111 @@ Since the focus is on tracking; it does not independently run the HMD. For an op
(file-name (git-file-name name version))
(sha256
(base32
- "0q4ipjx779ifza0z6wccvh1b36z29xm5lxlbd1iv00iqlj4na4ws"))))
+ "0q4ipjx779ifza0z6wccvh1b36z29xm5lxlbd1iv00iqlj4na4ws"))
+ (patches (list (plain-file "0001-vive-Default-Bigscreen-Beyond-distortion-aspect-rati.patch" "\
+From 8cf925570862f62fdc77d48c6bfc955b9eb28600 Mon Sep 17 00:00:00 2001
+From: Vineet Kumar <git@vineetk.net>
+Date: Wed, 25 Nov 2026 02:01:15 +0100
+Subject: [PATCH 1/2] vive: Default Bigscreen Beyond distortion aspect ratio to
+ 1.0
+
+Signed-off-by: Vineet Kumar <git@vineetk.net>
+---
+ src/xrt/auxiliary/vive/vive_config.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/xrt/auxiliary/vive/vive_config.c b/src/xrt/auxiliary/vive/vive_config.c
+index d46ce7cde..38f0a6cca 100644
+--- a/src/xrt/auxiliary/vive/vive_config.c
++++ b/src/xrt/auxiliary/vive/vive_config.c
+@@ -512,6 +512,9 @@ vive_config_parse(struct vive_config *d, char *json_string, enum u_logging_level
+ success = JSON_FLOAT(device_json, \"physical_aspect_x_over_y\", &d->distortion.values[0].aspect_x_over_y);
+ if (success) {
+ d->distortion.values[1].aspect_x_over_y = d->distortion.values[0].aspect_x_over_y;
++ } else if (d->variant == VIVE_VARIANT_BEYOND) {
++ d->distortion.values[0].aspect_x_over_y = 1.0f;
++ d->distortion.values[1].aspect_x_over_y = 1.0f;
+ }
+ }
+
+--
+2.55.0\n")
+ (plain-file "0002-vive-Add-support-for-DISTORT_POLY3-lens-distortion.patch" "\
+From 3216e6529bdd553a4397b89fa37b48af9723e152 Mon Sep 17 00:00:00 2001
+From: Vineet Kumar <git@vineetk.net>
+Date: Wed, 25 Nov 2026 02:01:31 +0100
+Subject: [PATCH 2/2] vive: Add support for DISTORT_POLY3 lens distortion
+
+Signed-off-by: Vineet Kumar <git@vineetk.net>
+---
+ src/xrt/auxiliary/util/u_distortion_mesh.c | 20 +++++++-------------
+ src/xrt/auxiliary/util/u_distortion_mesh.h | 2 ++
+ src/xrt/auxiliary/vive/vive_config.c | 4 ++++
+ 3 files changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/src/xrt/auxiliary/util/u_distortion_mesh.c b/src/xrt/auxiliary/util/u_distortion_mesh.c
+index 9fab79ead..f37e9f194 100644
+--- a/src/xrt/auxiliary/util/u_distortion_mesh.c
++++ b/src/xrt/auxiliary/util/u_distortion_mesh.c
+@@ -157,21 +157,15 @@ u_compute_distortion_vive(struct u_vive_values *values, float u, float v, struct
+ float k3 = val.coefficients[i][2];
+ float k4 = val.coefficients[i][3];
+
+- /*
+- * 1.0
+- * d = -------------------------------------- + k4
+- * 1.0 + r^2 * k1 + r^4 * k2 + r^6 * k3
++ /*
++ * DISTORT_POLY3:
++ * d = 1 + k1*r² + k2*r⁴ + k3*r⁶
+ *
+- * The variable k4 is the scaled part of DISTORT_DPOLY3_SCALED.
+- *
+- * Optimization to reduce the number of multiplications.
+- * 1.0 + r^2 * k1 + r^4 * k2 + r^6 * k3
+- * 1.0 + r^2 * ((k1 + r^2 * k2) + r^2 * k3)
++ * DISTORT_DPOLY3[_SCALED]:
++ * d = 1 / (1 + k1*r² + k2*r⁴ + k3*r⁶) + k4
+ */
+-
+- float top = 1.f;
+- float bottom = 1.f + r2 * (k1 + r2 * (k2 + r2 * k3));
+- float d = (top / bottom) + k4;
++ float polynomial = 1.f + r2 * (k1 + r2 * (k2 + r2 * k3));
++ float d = (val.use_poly3[i]) ? polynomial : ((1.f / polynomial) + k4);
+
+ struct xrt_vec2 offset = {0.5f, 0.5f};
+
+diff --git a/src/xrt/auxiliary/util/u_distortion_mesh.h b/src/xrt/auxiliary/util/u_distortion_mesh.h
+index 7f704eb3d..24a8df2b0 100644
+--- a/src/xrt/auxiliary/util/u_distortion_mesh.h
++++ b/src/xrt/auxiliary/util/u_distortion_mesh.h
+@@ -80,6 +80,8 @@ struct u_vive_values
+
+ //! r/g/b, a/b/c/d
+ float coefficients[3][4];
++
++ bool use_poly3[3];
+ };
+
+ /*!
+diff --git a/src/xrt/auxiliary/vive/vive_config.c b/src/xrt/auxiliary/vive/vive_config.c
+index 38f0a6cca..17b917c5a 100644
+--- a/src/xrt/auxiliary/vive/vive_config.c
++++ b/src/xrt/auxiliary/vive/vive_config.c
+@@ -133,6 +133,10 @@ _get_distortion_properties(struct vive_config *d, const cJSON *eye_transform_jso
+ continue;
+ }
+
++ const cJSON *type = u_json_get(distortion, \"type\");
++ d->distortion.values[eye].use_poly3[i] = cJSON_IsString(type)
++ && strcmp(type->valuestring, \"DISTORT_POLY3\") == 0;
++
+ JSON_FLOAT(distortion, \"center_x\", &d->distortion.values[eye].center[i].x);
+ JSON_FLOAT(distortion, \"center_y\", &d->distortion.values[eye].center[i].y);
+
+--
+2.55.0\n")))))
(arguments
(substitute-keyword-arguments (package-arguments (@@ (gnu packages machine-learning) ggml))
((#:configure-flags flags #~'())