From 30ad228bee3a27a0b0cbcdc6ac4d2a92ffad4251 Mon Sep 17 00:00:00 2001 From: Ib Green Date: Wed, 6 Mar 2024 14:50:33 -0500 Subject: [PATCH] chore: remove moduleSettings --- examples/tutorials/hello-gltf/app.ts | 4 +-- examples/tutorials/lighting/app-old.ts | 32 +++++++++---------- modules/core/src/index.ts | 2 +- .../adapter-utils/is-uniform-value.spec.ts | 21 +----------- modules/engine/src/model/model.ts | 28 ++-------------- .../resources/webgl-render-pipeline.ts | 7 ++-- 6 files changed, 26 insertions(+), 68 deletions(-) diff --git a/examples/tutorials/hello-gltf/app.ts b/examples/tutorials/hello-gltf/app.ts index 345b67a4e8..3395f41bc5 100644 --- a/examples/tutorials/hello-gltf/app.ts +++ b/examples/tutorials/hello-gltf/app.ts @@ -66,7 +66,7 @@ export default class AppAnimationLoopTemplate extends AnimationLoopTemplate { u_NormalMatrix: new Matrix4(worldMatrix).invert().transpose() }); - model.updateModuleSettings({lightSources}); + // model.updateModuleSettings({lightSources}); model.draw(renderPass); }); renderPass.end(); @@ -102,7 +102,7 @@ export default class AppAnimationLoopTemplate extends AnimationLoopTemplate { } } -const lightSources: LightingProps = { +export const lightSources: LightingProps = { ambientLight: { color: [255, 133, 133], intensity: 1, diff --git a/examples/tutorials/lighting/app-old.ts b/examples/tutorials/lighting/app-old.ts index 46c9237026..a6d7c399a3 100644 --- a/examples/tutorials/lighting/app-old.ts +++ b/examples/tutorials/lighting/app-old.ts @@ -131,22 +131,22 @@ export default class AppAnimationLoopTemplate extends AnimationLoopTemplate { fs, geometry: new CubeGeometry(), modules: [phongMaterial], - moduleSettings: { - // material: { - // specularColor: [255, 255, 255] - // }, - // lights: [ - // { - // type: 'ambient', - // color: [255, 255, 255] - // }, - // { - // type: 'point', - // color: [255, 255, 255], - // position: [1, 2, 1] - // } - // ] - }, + // moduleSettings: { + // material: { + // specularColor: [255, 255, 255] + // }, + // lights: [ + // { + // type: 'ambient', + // color: [255, 255, 255] + // }, + // { + // type: 'point', + // color: [255, 255, 255], + // position: [1, 2, 1] + // } + // ] + // }, bindings: { uTexture: texture, app: this.uniformStore.getManagedUniformBuffer(device, 'app'), diff --git a/modules/core/src/index.ts b/modules/core/src/index.ts index 3838a464fe..3c43673d5d 100644 --- a/modules/core/src/index.ts +++ b/modules/core/src/index.ts @@ -164,7 +164,7 @@ export {isObjectEmpty} from './utils/is-object-empty'; // ADAPTER UTILS - for implementing Device adapters (@luma.gl/webgl and @luma.gl/webgpu) -export {isUniformValue, splitUniformsAndBindings} from './adapter-utils/is-uniform-value'; +export {isUniformValue} from './adapter-utils/is-uniform-value'; export type {AttributeInfo} from './adapter-utils/get-attribute-from-layouts'; export { getAttributeInfosFromLayouts, diff --git a/modules/core/test/adapter-utils/is-uniform-value.spec.ts b/modules/core/test/adapter-utils/is-uniform-value.spec.ts index c4084a6cda..fabcb1b2ce 100644 --- a/modules/core/test/adapter-utils/is-uniform-value.spec.ts +++ b/modules/core/test/adapter-utils/is-uniform-value.spec.ts @@ -1,4 +1,4 @@ -import {isUniformValue, splitUniformsAndBindings} from '@luma.gl/core'; +import {isUniformValue} from '@luma.gl/core'; import {WEBGLSampler, WEBGLTexture} from '@luma.gl/webgl'; import {webglDevice as device} from '@luma.gl/test-utils'; import test from 'tape-promise/tape'; @@ -16,22 +16,3 @@ test('isUniformValue', t => { t.notOk(isUniformValue(new WEBGLSampler(device, {})), 'WEBGLSampler is not a uniform value'); t.end(); }); - -test('splitUniformsAndBindings', t => { - const mixed: Parameters[0] = { - array: [1, 2, 3, 4], - boolean: true, - float32array: new Float32Array([1, 2, 3, 4]), - number: 123, - sampler: new WEBGLSampler(device, {}), - texture: new WEBGLTexture(device, {}) - }; - const {bindings, uniforms} = splitUniformsAndBindings(mixed); - t.deepEquals(Object.keys(bindings), ['sampler', 'texture'], 'bindings correctly extracted'); - t.deepEquals( - Object.keys(uniforms), - ['array', 'boolean', 'float32array', 'number'], - 'bindings correctly extracted' - ); - t.end(); -}); diff --git a/modules/engine/src/model/model.ts b/modules/engine/src/model/model.ts index 6d39e9fa93..53f70c0b9c 100644 --- a/modules/engine/src/model/model.ts +++ b/modules/engine/src/model/model.ts @@ -9,7 +9,7 @@ import type {BufferLayout, Shader, VertexArray, TransformFeedback} from '@luma.g import type {AttributeInfo, Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core'; import {Device, DeviceFeature, Buffer, Texture, TextureView, Sampler} from '@luma.gl/core'; import {RenderPipeline, RenderPass, UniformStore} from '@luma.gl/core'; -import {log, uid, isObjectEmpty, splitUniformsAndBindings} from '@luma.gl/core'; +import {log, uid, isObjectEmpty} from '@luma.gl/core'; import {getTypedArrayFromDataType, getAttributeInfosFromLayouts} from '@luma.gl/core'; import type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools'; @@ -65,9 +65,6 @@ export type ModelProps = Omit & { transformFeedback?: TransformFeedback; - /** Mapped uniforms for shadertool modules */ - moduleSettings?: Record>; - /** Show shader source in browser? */ debugShaders?: 'never' | 'errors' | 'warnings' | 'always'; @@ -98,7 +95,6 @@ export class Model { userData: {}, defines: {}, modules: [], - moduleSettings: undefined!, geometry: null, indexBuffer: null, attributes: {}, @@ -172,7 +168,6 @@ export class Model { _attributeInfos: Record = {}; _gpuGeometry: GPUGeometry | null = null; - private _getModuleUniforms: (props?: Record>) => Record; private props: Required; _pipelineNeedsUpdate: string | false = 'newly created'; @@ -211,16 +206,15 @@ export class Model { if (isWebGPU && this.props.source) { // WGSL this.props.shaderLayout ||= getShaderLayoutFromWGSL(this.props.source); - const {source, getUniforms} = this.props.shaderAssembler.assembleShader({ + const {source} = this.props.shaderAssembler.assembleShader({ platformInfo, ...this.props, modules }); this.source = source; - this._getModuleUniforms = getUniforms; } else { // GLSL - const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaderPair({ + const {vs, fs} = this.props.shaderAssembler.assembleShaderPair({ platformInfo, ...this.props, modules @@ -228,7 +222,6 @@ export class Model { this.vs = vs; this.fs = fs; - this._getModuleUniforms = getUniforms; } this.vertexCount = this.props.vertexCount; @@ -288,10 +281,6 @@ export class Model { if (props.uniforms) { this.setUniforms(props.uniforms); } - if (props.moduleSettings) { - log.warn('Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()')(); - this.updateModuleSettings(props.moduleSettings); - } if (props.transformFeedback) { this.transformFeedback = props.transformFeedback; } @@ -593,17 +582,6 @@ export class Model { this.setNeedsRedraw('uniforms'); } - /** - * @deprecated Updates shader module settings (which results in uniforms being set) - */ - updateModuleSettings(props: Record): void { - log.warn('Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()')(); - const {bindings, uniforms} = splitUniformsAndBindings(this._getModuleUniforms(props)); - Object.assign(this.bindings, bindings); - Object.assign(this.uniforms, uniforms); - this.setNeedsRedraw('moduleSettings'); - } - // Internal methods /** Get the timestamp of the latest updated bound GPU memory resource (buffer/texture). */ diff --git a/modules/webgl/src/adapter/resources/webgl-render-pipeline.ts b/modules/webgl/src/adapter/resources/webgl-render-pipeline.ts index 147fbc39d0..753438a8b5 100644 --- a/modules/webgl/src/adapter/resources/webgl-render-pipeline.ts +++ b/modules/webgl/src/adapter/resources/webgl-render-pipeline.ts @@ -5,7 +5,7 @@ import type {UniformValue, RenderPipelineProps, Binding} from '@luma.gl/core'; import type {ShaderLayout} from '@luma.gl/core'; import type {RenderPass, VertexArray} from '@luma.gl/core'; -import {RenderPipeline, splitUniformsAndBindings, log} from '@luma.gl/core'; +import {RenderPipeline, log} from '@luma.gl/core'; import {mergeShaderLayout} from '@luma.gl/core'; // import {mergeShaderLayout, getAttributeInfosFromLayouts} from '@luma.gl/core'; import {GL} from '@luma.gl/constants'; @@ -271,11 +271,10 @@ export class WEBGLRenderPipeline extends RenderPipeline { // DEPRECATED METHODS override setUniformsWebGL(uniforms: Record) { - const {bindings} = splitUniformsAndBindings(uniforms); - Object.keys(bindings).forEach(name => { + Object.keys(uniforms).forEach(name => { log.warn( `Unsupported value "${JSON.stringify( - bindings[name] + uniforms[name] )}" used in setUniforms() for key ${name}. Use setBindings() instead?` )(); });