From 4295740155d325ee6ba64d98bc3c7331e5f530f2 Mon Sep 17 00:00:00 2001 From: wheaney <42350981+wheaney@users.noreply.github.com> Date: Sun, 9 Jun 2024 11:46:36 -0700 Subject: [PATCH] Initial attempt at GNOME SBS support --- .gitmodules | 3 ++- gnome/src/xrEffect.js | 23 +++++++++++------------ modules/XRLinuxDriver | 2 +- modules/sombrero | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.gitmodules b/.gitmodules index 01f2858..3c19e85 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,10 +5,11 @@ [submodule "modules/XRLinuxDriver"] path = modules/XRLinuxDriver url = https://github.com/wheaney/XRLinuxDriver.git - branch = rayneo + branch = sbs [submodule "modules/sombrero"] path = modules/sombrero url = https://github.com/wheaney/sombrero.git + branch = breezy_sbs [submodule "ui/modules/PyXRLinuxDriverIPC"] path = ui/modules/PyXRLinuxDriverIPC url = https://github.com/wheaney/PyXRLinuxDriverIPC.git diff --git a/gnome/src/xrEffect.js b/gnome/src/xrEffect.js index 0c0b15b..d43df3a 100644 --- a/gnome/src/xrEffect.js +++ b/gnome/src/xrEffect.js @@ -50,8 +50,6 @@ const shaderUniformLocations = { 'imu_quat_data': null, 'look_ahead_cfg': null, 'look_ahead_ms': null, - 'stage_aspect_ratio': null, - 'display_aspect_ratio': null, 'trim_width_percent': null, 'trim_height_percent': null, 'display_zoom': null, @@ -59,11 +57,13 @@ const shaderUniformLocations = { 'lens_distance_ratio': null, 'sbs_enabled': null, 'sbs_content': null, + 'sbs_mode_stretched': null, 'custom_banner_enabled': null, 'half_fov_z_rads': null, 'half_fov_y_rads': null, 'screen_distance': null, - 'display_res': null + 'source_resolution': null, + 'display_resolution': null }; function setUniformFloat(effect, locationName, dataViewInfo, value) { @@ -119,22 +119,21 @@ function setIntermittentUniformVariables() { const imuData = dataViewFloatArray(dataView, IMU_QUAT_DATA); const imuResetState = validKeepalive && imuData[0] === 0.0 && imuData[1] === 0.0 && imuData[2] === 0.0 && imuData[3] === 1.0; const enabled = dataViewUint8(dataView, ENABLED) !== 0 && version === DATA_LAYOUT_VERSION && validKeepalive; + const displayRes = dataViewUintArray(dataView, DISPLAY_RES); if (enabled) { - const displayRes = dataViewUintArray(dataView, DISPLAY_RES); const displayFov = dataViewFloat(dataView, DISPLAY_FOV); const lensDistanceRatio = dataViewFloat(dataView, LENS_DISTANCE_RATIO); // compute these values once, they only change when the XR device changes const displayAspectRatio = displayRes[0] / displayRes[1]; - const stageAspectRatio = this.target_monitor.width / this.target_monitor.height; - const diagToVertRatio = Math.sqrt(Math.pow(stageAspectRatio, 2) + 1); + const diagToVertRatio = Math.sqrt(Math.pow(displayAspectRatio, 2) + 1); const halfFovZRads = degreeToRadian(displayFov / diagToVertRatio) / 2; - const halfFovYRads = halfFovZRads * stageAspectRatio; + const halfFovYRads = halfFovZRads * displayAspectRatio; const screenDistance = 1.0 - lensDistanceRatio; // our overlay doesn't quite cover the full screen texture, which allows us to see some of the real desktop - // underneath, so we trim two pixels around the entire edge of the texture + // underneath, so we trim three pixels around the entire edge of the texture const trimWidthPercent = 3.0 / this.target_monitor.width; const trimHeightPercent = 3.0 / this.target_monitor.height; @@ -143,8 +142,6 @@ function setIntermittentUniformVariables() { transferUniformFloat(this, 'lens_distance_ratio', dataView, LENS_DISTANCE_RATIO); // computed values with no dataViewInfo, so we set these manually - setSingleFloat(this, 'stage_aspect_ratio', stageAspectRatio); - setSingleFloat(this, 'display_aspect_ratio', displayAspectRatio); setSingleFloat(this, 'trim_width_percent', trimWidthPercent); setSingleFloat(this, 'trim_height_percent', trimHeightPercent); setSingleFloat(this, 'half_fov_z_rads', halfFovZRads); @@ -158,11 +155,13 @@ function setIntermittentUniformVariables() { // these variables are always in play, even if enabled is false setSingleFloat(this, 'enabled', enabled ? 1.0 : 0.0); setSingleFloat(this, 'show_banner', imuResetState ? 1.0 : 0.0); - setSingleFloat(this, 'sbs_content', 0.0); // TOOD - drive from settings + setSingleFloat(this, 'sbs_content', 0.0); // TODO - drive from settings + setSingleFloat(this, 'sbs_mode_stretched', 1.0); // content always fills the whole display setSingleFloat(this, 'sbs_enabled', dataViewUint8(dataView, SBS_ENABLED) !== 0 ? 1.0 : 0.0); setSingleFloat(this, 'custom_banner_enabled', dataViewUint8(dataView, CUSTOM_BANNER_ENABLED) !== 0 ? 1.0 : 0.0); - this.set_uniform_float(shaderUniformLocations['display_res'], 2, [this.target_monitor.width, this.target_monitor.height]); + this.set_uniform_float(shaderUniformLocations['display_resolution'], 2, displayRes); + this.set_uniform_float(shaderUniformLocations['source_resolution'], 2, [this.target_monitor.width, this.target_monitor.height]); } else if (dataView.byteLength !== 0) { Globals.logger.log(`ERROR: Invalid dataView.byteLength: ${dataView.byteLength} !== ${DATA_VIEW_LENGTH}`) } diff --git a/modules/XRLinuxDriver b/modules/XRLinuxDriver index 828dfe7..d30c512 160000 --- a/modules/XRLinuxDriver +++ b/modules/XRLinuxDriver @@ -1 +1 @@ -Subproject commit 828dfe78d188f5cc07fc50ce2695c694488e36c8 +Subproject commit d30c512e8b7f47953812cefa745038aeaf9c65a8 diff --git a/modules/sombrero b/modules/sombrero index 26ece49..9dc91be 160000 --- a/modules/sombrero +++ b/modules/sombrero @@ -1 +1 @@ -Subproject commit 26ece497d36bbe2a7445ea2f4e1cce31c35daa3a +Subproject commit 9dc91be2d0390a1ce15f02515112fe12c38a30e1