Unify FX and GLSL shader implementations

This commit is contained in:
wheaney 2024-09-04 14:16:08 -07:00
parent 57ced2168a
commit 8e772dd05e
3 changed files with 9 additions and 10 deletions

1
.gitmodules vendored
View File

@ -8,6 +8,7 @@
[submodule "modules/sombrero"]
path = modules/sombrero
url = https://github.com/wheaney/sombrero.git
branch = unified_shader
[submodule "ui/modules/PyXRLinuxDriverIPC"]
path = ui/modules/PyXRLinuxDriverIPC
url = https://github.com/wheaney/PyXRLinuxDriverIPC.git

View File

@ -52,8 +52,7 @@ const shaderUniformLocations = {
'imu_quat_data': null,
'look_ahead_cfg': null,
'look_ahead_ms': null,
'trim_width_percent': null,
'trim_height_percent': null,
'trim_percent': null,
'display_size': null,
'display_north_offset': null,
'lens_vector': null,
@ -171,8 +170,7 @@ function setIntermittentUniformVariables() {
transferUniformFloat(this, 'lens_distance_ratio', dataView, LENS_DISTANCE_RATIO);
// computed values with no dataViewInfo, so we set these manually
setSingleFloat(this, 'trim_width_percent', trimWidthPercent);
setSingleFloat(this, 'trim_height_percent', trimHeightPercent);
this.set_uniform_float(shaderUniformLocations['trim_percent'], 2, [trimWidthPercent, trimHeightPercent]);
setSingleFloat(this, 'half_fov_z_rads', halfFovZRads);
setSingleFloat(this, 'half_fov_y_rads', halfFovYRads);
this.set_uniform_float(shaderUniformLocations['fov_half_widths'], 2, fovHalfWidths);
@ -191,7 +189,7 @@ function setIntermittentUniformVariables() {
if (enabled && this.widescreen_mode_state !== sbsEnabled) this.widescreen_mode_state = sbsEnabled;
// these variables are always in play, even if enabled is false
setSingleFloat(this, 'enabled', enabled ? 1.0 : 0.0);
setSingleFloat(this, 'virtual_display_enabled', enabled ? 1.0 : 0.0);
setSingleFloat(this, 'show_banner', imuResetState ? 1.0 : 0.0);
setSingleFloat(this, 'sbs_enabled', sbsEnabled ? 1.0 : 0.0);
setSingleFloat(this, 'custom_banner_enabled', dataViewUint8(dataView, CUSTOM_BANNER_ENABLED) !== 0 ? 1.0 : 0.0);
@ -346,7 +344,7 @@ export const XREffect = GObject.registerClass({
vfunc_build_pipeline() {
const code = getShaderSource(`${Globals.extension_dir}/IMUAdjust.frag`);
const main = 'PS_IMU_Transform(vec4(0, 0, 0, 0), cogl_tex_coord_in[0].xy, cogl_color_out);';
const main = 'PS_IMU_Transform(cogl_tex_coord_in[0].xy, cogl_color_out);';
this.add_glsl_snippet(Shell.SnippetHook.FRAGMENT, code, main, false);
}
@ -358,12 +356,12 @@ export const XREffect = GObject.registerClass({
let buffer = new Uint8Array(data[1]).buffer;
this._dataView = new DataView(buffer);
if (!this._initialized) {
this.set_uniform_float(this.get_uniform_location('uDesktopTexture'), 1, [0]);
this.set_uniform_float(this.get_uniform_location('screenTexture'), 1, [0]);
this.get_pipeline().set_layer_texture(1, calibratingImage.get_texture());
this.get_pipeline().set_layer_texture(2, customBannerImage.get_texture());
this.get_pipeline().set_uniform_1i(this.get_uniform_location('uCalibratingTexture'), 1);
this.get_pipeline().set_uniform_1i(this.get_uniform_location('uCustomBannerTexture'), 2);
this.get_pipeline().set_uniform_1i(this.get_uniform_location('calibratingTexture'), 1);
this.get_pipeline().set_uniform_1i(this.get_uniform_location('customBannerTexture'), 2);
for (let key in shaderUniformLocations) {
shaderUniformLocations[key] = this.get_uniform_location(key);

@ -1 +1 @@
Subproject commit ec3f82aa4834847adf1f0c640eba4b87b6f3ff65
Subproject commit 0bc7f2ef1f63030ccedaf4f0f6c88b4ee558cb25