Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete deprecated functionality for litShaderArgs #7281

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions src/deprecated/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import {
} from '../framework/components/rigid-body/constants.js';
import { RigidBodyComponent } from '../framework/components/rigid-body/component.js';
import { RigidBodyComponentSystem } from '../framework/components/rigid-body/system.js';
import { LitShader } from '../scene/shader-lib/programs/lit-shader.js';
import { Geometry } from '../scene/geometry/geometry.js';
import { CameraComponent } from '../framework/components/camera/component.js';

Expand Down Expand Up @@ -180,41 +179,6 @@ Object.keys(deprecatedChunks).forEach((chunkName) => {
});
});

// We only provide backwards compatibility in debug builds, production builds have to be
// as fast and small as possible.

// #if _DEBUG

/**
* Helper function to ensure a bit of backwards compatibility.
*
* @example
* toLitArgs('litShaderArgs.sheen.specularity'); // Result: 'litArgs_sheen_specularity'
* @param {string} src - The shader source which may generate shader errors.
* @returns {string} The backwards compatible shader source.
* @ignore
*/
function compatibilityForLitArgs(src) {
if (src.includes('litShaderArgs')) {
// eslint-disable-next-line regexp/no-misleading-capturing-group
src = src.replace(/litShaderArgs([.a-zA-Z]+)+/g, (a, b) => {
const newSource = `litArgs${b.replace(/\./g, '_')}`;
Debug.deprecated(`Nested struct property access is deprecated, because it's crashing some devices. Please update your custom chunks manually. In particular ${a} should be ${newSource} now.`);
return newSource;
});
}
return src;
}

/**
* Add more backwards compatibility functions as needed.
*/
LitShader.prototype.handleCompatibility = function () {
this.fshader = compatibilityForLitArgs(this.fshader);
};

// #endif

// Note: This was never public interface, but has been used in external scripts
Object.defineProperties(RenderTarget.prototype, {
_glFrameBuffer: {
Expand Down
8 changes: 3 additions & 5 deletions src/scene/shader-lib/programs/lit-shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1500,10 +1500,7 @@ class LitShader {
}

/**
* Generates a fragment shader. Please make sure to update src/deprecated/deprecated.js in
* case `this.fshader` does not longer contain the entire fragment shader once this function
* is done because we handle backwards compatibility there for old shaders. This allows us
* to have deprecation-free tree shaking while still fixing shaders for full builds.
* Generates a fragment shader.
*
* @param {string} frontendDecl - Frontend declarations like `float dAlpha;`
* @param {string} frontendCode - Frontend code containing `getOpacity()` etc.
Expand Down Expand Up @@ -1531,7 +1528,8 @@ class LitShader {
} else {
this.fshader = this._fsGetLitPassCode();
}
this.handleCompatibility?.();

Debug.assert(!this.fshader.includes('litShaderArgs'), 'Automatic compatibility with shaders using litShaderArgs has been removed. Please update the shader to use the new system.');
}

getDefinition(options) {
Expand Down
Loading