diff --git a/docs/api-reference/core/device-features.mdx b/docs/api-reference/core/device-features.mdx index 8ee1412b68..cda92f9939 100644 --- a/docs/api-reference/core/device-features.mdx +++ b/docs/api-reference/core/device-features.mdx @@ -50,28 +50,20 @@ be queried on a per-texture basis | `luma.gl Feature` | This
Browser | Description | | ------------------------------------------ | ------------------------------------------------- | -------------------------------------------- | -| **Platform** | -| `webgpu` | | WebGPU device. | -| `webgl` | | WebGL2 device. | -| `glsl` | | GLSL shader language. | -| `wgsl` | | WGSL shader language. | | **Features** | | `depth-clip-control` | | Disable depth clipping `unclippedDepth` | | `indirect-first-instance` | | Specify via GPU buffer | | `timestamp-query` | | | +| **WebGL-only Features** | | `timer-query-webgl` | | GPU timer support | -| `compilation-status-async-webgl` | | Non-blocking compile/link status | +| `compilation-status-async-webgl` | | Non-blocking compile/link status | +| `polygon-mode-webgl` | | Wireframe rendering parameters | | `provoking-vertex-webgl` | | Primitive vertex used for flat shading | -| `polygon-mode-webgl` | | Wireframe rendering parameters | -| `shader-clip-cull-distance-webgl` | | Enable `gl_ClipDistance[]/gl_CullDistance[]` | -| **WebGL-only Features** | -| `transform-feedback-webgl` | | `TransformFeedback` support | -| `uniforms-webgl` | | non-UBO uniforms support | -| `constant-attributes-webgl` | | Constant attributes | | **Shaders** | | `shader-f16` | | WGSL supports `f16` | | `shader-noperspective-interpolation-webgl` | | GLSL `noperspective` interpolation qualifier | | `shader-conservative-depth-webgl` | | GLSL enable early depth test optimizations | +| `shader-clip-cull-distance-webgl` | | Enable `gl_ClipDistance[]/gl_CullDistance[]` | | **Textures** | | `depth24unorm-stencil8` | | `UNSIGNED_INT_24_8_WEBGL` | | `depth32float-stencil8` | | WebGPU only | @@ -103,7 +95,7 @@ if (device.features.has('timer-query-webgl')) { ... } // Alternatively - do the same query using raw WebGL extensions -if (webglDevice.gl.getExtension('EXT_disjoint_timer_query') || webglDevice.gl.getExtension('EXT_disjoint_timer_query_webgl2')) { +if (wwebglDevice.gl.getExtension('EXT_disjoint_timer_query_webgl2')) { ... } ``` diff --git a/docs/api-reference/core/parameters.md b/docs/api-reference/core/parameters.md index 396aa666c0..4739fac1b5 100644 --- a/docs/api-reference/core/parameters.md +++ b/docs/api-reference/core/parameters.md @@ -6,42 +6,41 @@ luma.gl provides a unified API for working with GPU parameters. All parameters listed in a single table -| Function | How to set | Description | Values | WebGL counterpart | -| ---------------------------- | ------------------------------ | --------------------------------------------------------------------- | --------------------------------- | -------------------------- | -| **Rasterization Parameters** | -| `cullMode` | `RenderPipeline` | Which face to cull | **`'none'`**, `'front'`, `'back'` | -| `frontFace` | `RenderPipeline` | Which triangle winding order is front | **`ccw`**, `cw` | -| `viewport` | `RenderPass.setParameters()` | Specifying viewport size | -| `scissor` | `RenderPass.setParameters()` | Specifying scissor rect size | -| **Depth Buffer Parameters** | -| `depthBias` | `RenderPipeline` | Small depth offset for polygons | `float` | `gl.polygonOffset` | -| `depthBiasSlopeScale` | `RenderPipeline` | Small depth factor for polygons | `float` | `gl.polygonOffset` | -| `depthBiasClamp` | `RenderPipeline` | Max depth offset for polygons | `float` | N/A | -| **Stencil Buffer** | -| `stencilReference` | `RenderPass.setParameters()` | -| `stencilReadMask` | `RenderPipeline` | Binary mask for reading stencil values | `number` (**`0xffffffff`**) | -| `stencilWriteMask` | `RenderPipeline` | Binary mask for writing stencil values | `number` (**`0xffffffff`**) | `gl.frontFace` | -| `stencilCompare` | `RenderPipeline` | How the mask is compared | **`always`**, `not-equal`, ... | `gl.stencilFunc` | -| `stencilPassOperation` | `RenderPipeline` | | **`'keep'`** | `gl.stencilOp` | -| `stencilDepthFailOperation` | `RenderPipeline` | | **`'keep'`** | `gl.stencilOp` | -| `stencilFailOperation` | `RenderPipeline` | | **`'keep'`** | `gl.stencilOp` | -| **Blending** | -| `blendConstant` | | Color used by blend factors `constant`, `one-minus-constant` | -| `blendColor` | `RenderPass.setParameters()` | -| `blendEquation` | `RenderPipeline(targets})` | -| `blendOperation` | `RenderPipeline(targets).` | -| `blendSrcFactor` | `RenderPipeline(targets).` | -| `blendDstFactor` | `RenderPipeline(targets).` | -| **Clear color** | -| `clearColor` | `RenderPass(colorAttachments)` | -| **Extension Parameters** | -| `unclippedDepth` | `RenderPipeline` | Disable depth value clipping . Requires `depth-clip-control` | `boolean` | -| `provokingVertex` | `RenderPipeline` | Vertex used for flat shading. Requires `provoking-vertex-webgl` | **`'last'`**, `'first'` | `WEBGL_provoking_vertex` | -| `polygonMode` | `RenderPipeline` | Enable wire frame rendering. Requires `polygon-mode-webgl` | **`'fill'`**, `'line'` | `WEBGL_polygon_mode` | -| `polygonOffsetLine` | `RenderPipeline` | Vertex used for flat shading. Requires `polygon-mode-webgl` | `boolean` | `WEBGL_polygon_mode` | -| `clipDistance0` (`0-7`) | `RenderPipeline` | Enable `gl_ClipDistance, gl_CullDistance`. `shader-clip-cull-distance-webgl` | `boolean` | `WEBGL_clip_cull_distance` | - -## Other types of parameters +| Function | How to set | Description | Values | WebGL counterpart | +| --------------------------- | ------------------------------ | -------------------------------------------------------------------- | --------------------------------- | -------------------------- | +| **Rasterization** | +| `cullMode` | `RenderPipeline` | Which face to cull | **`'none'`**, `'front'`, `'back'` | `gl.cullFace()` | +| `frontFace` | `RenderPipeline` | Which triangle winding order is front | **`ccw`**, `cw` | `gl.frontFace()` | +| `viewport` | `RenderPass.setParameters()` | Specifying viewport size | | `gl.viewpot()` | +| `scissor` | `RenderPass.setParameters()` | Specifying scissor rect size | | `gl.scissor()` | +| `clearColor` | `RenderPass(colorAttachments)` | | | `gl.clearColor()` | +| **Blending** | +| `blendConstant` | | Color used by blend factors `constant`, `one-minus-constant` | +| `blendColor` | `RenderPass.setParameters()` | +| `blendEquation` | `RenderPipeline(targets})` | +| `blendOperation` | `RenderPipeline(targets).` | +| `blendSrcFactor` | `RenderPipeline(targets).` | +| `blendDstFactor` | `RenderPipeline(targets).` | +| **Depth Buffer** | +| `depthBias` | `RenderPipeline` | Small depth offset for polygons | `float` | `gl.polygonOffset` | +| `depthBiasSlopeScale` | `RenderPipeline` | Small depth factor for polygons | `float` | `gl.polygonOffset` | +| `depthBiasClamp` | `RenderPipeline` | Max depth offset for polygons | `float` | N/A | +| **Stencil Buffer** | +| `stencilReference` | `RenderPass.setParameters()` | +| `stencilReadMask` | `RenderPipeline` | Binary mask for reading stencil values | `number` (**`0xffffffff`**) | +| `stencilWriteMask` | `RenderPipeline` | Binary mask for writing stencil values | `number` (**`0xffffffff`**) | `gl.frontFace` | +| `stencilCompare` | `RenderPipeline` | How the mask is compared | **`always`**, `not-equal`, ... | `gl.stencilFunc` | +| `stencilPassOperation` | `RenderPipeline` | Operation on stencil buffer when test passes | **`'keep'`** | `gl.stencilOp` | +| `stencilDepthFailOperation` | `RenderPipeline` | Operation on stencil buffer when depth test fails | **`'keep'`** | `gl.stencilOp` | +| `stencilFailOperation` | `RenderPipeline` | Operation on stencil buffer when test fails | **`'keep'`** | `gl.stencilOp` | +| **Extensions** | +| `unclippedDepth` | `RenderPipeline` | `depth-clip-control`: Disable depth value clipping. | `boolean` | `WEBGL_depth_clamp` | +| `provokingVertex` | `RenderPipeline` | `provoking-vertex-webgl`: Vertex used for flat shading | **`'last'`**, `'first'` | `WEBGL_provoking_vertex` | +| `polygonMode` | `RenderPipeline` | `polygon-mode-webgl`: Enable wire frame rendering. | **`'fill'`**, `'line'` | `WEBGL_polygon_mode` | +| `polygonOffsetLine` | `RenderPipeline` | `polygon-mode-webgl`: Vertex used for flat shading. Requires | `boolean` | `WEBGL_polygon_mode` | +| `clipDistance0` (`0-7`) | `RenderPipeline` | `shader-clip-cull-distance-webgl`: `gl_ClipDistance/gl_CullDistance` | `boolean` | `WEBGL_clip_cull_distance` | + +F## Other types of parameters Note that there are certain types of parameters affecting GPU operation that are not handled by the main parameter system: diff --git a/examples/script/webgl/transform-feedback/app.ts b/examples/script/webgl/transform-feedback/app.ts index 506e301c2f..32460e5dd7 100644 --- a/examples/script/webgl/transform-feedback/app.ts +++ b/examples/script/webgl/transform-feedback/app.ts @@ -63,7 +63,7 @@ export default class AppAnimationLoopTemplate extends AnimationLoopTemplate { constructor({device}: AnimationProps) { super(); - if (!device.features.has('transform-feedback-webgl')) { + if (device.info.type !== 'webgl') { throw new Error(ALT_TEXT); } diff --git a/modules/constants/src/webgl-types.ts b/modules/constants/src/webgl-types.ts index e76ec4ed74..59941df254 100644 --- a/modules/constants/src/webgl-types.ts +++ b/modules/constants/src/webgl-types.ts @@ -264,15 +264,11 @@ export type GLValueParameters = { [GL.STENCIL_BACK_PASS_DEPTH_PASS]?: GLStencilOp; [GL.VIEWPORT]?: [number, number, number, number] | NumberArray; - // WEBGL1 PIXEL PACK/UNPACK MODES [GL.PACK_ALIGNMENT]?: number; [GL.UNPACK_ALIGNMENT]?: number; [GL.UNPACK_FLIP_Y_WEBGL]?: boolean; [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]?: boolean; [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]?: GL.NONE | GL.BROWSER_DEFAULT_WEBGL; - - // WEBGL2 PIXEL PACK/UNPACK MODES - // RASTERIZER_DISCARD ... [GL.PACK_ROW_LENGTH]?: number; [GL.PACK_SKIP_PIXELS]?: number; [GL.PACK_SKIP_ROWS]?: number; diff --git a/modules/core-tests/test/adapter/device-helpers/device-features.spec.ts b/modules/core-tests/test/adapter/device-helpers/device-features.spec.ts index 62905306da..58320e3b1a 100644 --- a/modules/core-tests/test/adapter/device-helpers/device-features.spec.ts +++ b/modules/core-tests/test/adapter/device-helpers/device-features.spec.ts @@ -5,16 +5,9 @@ import test from 'tape-promise/tape'; import {webglDevice} from '@luma.gl/test-utils'; import {DeviceFeature} from '@luma.gl/core'; -// true: always supported in WebGL2, false: never supported in WebGL1 -const WEBGL2_ALWAYS_FEATURES: DeviceFeature[] = [ - 'webgl', - 'glsl', - // api support - 'transform-feedback-webgl' - // features -]; - -const WEBGL2_NEVER_FEATURES: DeviceFeature[] = ['webgpu', 'wgsl']; +// TODO - we are not actually testing any features +const WEBGL2_ALWAYS_FEATURES: DeviceFeature[] = []; +const WEBGL2_NEVER_FEATURES: DeviceFeature[] = []; test('WebGLDevice#features (unknown features)', t => { // @ts-expect-error @@ -25,17 +18,12 @@ test('WebGLDevice#features (unknown features)', t => { }); test('WebGLDevice#hasFeatures (WebGL)', t => { - t.notOk(webglDevice.features.has('webgpu'), 'features.has should return false'); - t.notOk(webglDevice.features.has('wgsl'), 'features.has should return false'); - // t.notOk(webglDevice.features.has('float32-renderable-webgl'), 'features.has should return false'); - - for (const feature of WEBGL2_ALWAYS_FEATURES) { - t.equal(webglDevice.features.has(feature), true, `${feature} is always supported under WebGL2`); + t.equal(webglDevice.features.has(feature), true, `${feature} is always supported under WebGL`); } for (const feature of WEBGL2_NEVER_FEATURES) { - t.equal(webglDevice.features.has(feature), false, `${feature} is never supported under WebGL1`); + t.equal(webglDevice.features.has(feature), false, `${feature} is never supported under WebGL`); } t.end(); }); diff --git a/modules/core-tests/test/adapter/resources/texture.spec.ts b/modules/core-tests/test/adapter/resources/texture.spec.ts index 2624728eb6..34b421ff3d 100644 --- a/modules/core-tests/test/adapter/resources/texture.spec.ts +++ b/modules/core-tests/test/adapter/resources/texture.spec.ts @@ -151,9 +151,6 @@ test.skip('WebGL#Texture format creation with data', t => { test.skip('WebGL#Texture WebGL2 format creation', t => { for (const format in TEXTURE_FORMATS) { - if (!WEBGL1_FORMATS.indexOf(format)) { - } - } let texture = webglDevice.createTexture({}); t.ok(texture instanceof Texture, 'Texture construction successful'); diff --git a/modules/core/src/adapter/device.ts b/modules/core/src/adapter/device.ts index 86a0c6e268..7c48f3793a 100644 --- a/modules/core/src/adapter/device.ts +++ b/modules/core/src/adapter/device.ts @@ -125,23 +125,18 @@ export type WebGPUDeviceFeature = | 'texture-compression-etc2' | 'texture-compression-astc'; -// obsolete... +// Removed WebGPU features... // 'depth-clamping' | // 'pipeline-statistics-query' | export type WebGLDeviceFeature = - // webgl standard features - | 'transform-feedback-webgl' // device.createTransformFeedback() - | 'constant-attributes-webgl' // vertexArray.setConstant() - | 'uniforms-webgl' // Supports non-UBO uniforms: renderPipeline.setUniforms() - // webgl extension features | 'timer-query-webgl' // unify with WebGPU timestamp-query? | 'compilation-status-async-webgl' // Non-blocking shader compile/link status query available | 'provoking-vertex-webgl' // parameters.provokingVertex | 'polygon-mode-webgl' // parameters.polygonMode and parameters.polygonOffsetLine - // GLSL extension features + // GLSL extension feGLatures | 'shader-noperspective-interpolation-webgl' // Vertex outputs & fragment inputs can have a `noperspective` interpolation qualifier. | 'shader-conservative-depth-webgl' // GLSL `gl_FragDepth` qualifiers `depth_unchanged` etc can enable early depth test | 'shader-clip-cull-distance-webgl' // Makes gl_ClipDistance and gl_CullDistance available in shaders @@ -173,11 +168,7 @@ type WebGLCompressedTextureFeatures = export type DeviceFeature = | WebGPUDeviceFeature | WebGLDeviceFeature - | WebGLCompressedTextureFeatures - | 'webgl' - | 'glsl' - | 'webgpu' - | 'wgsl'; + | WebGLCompressedTextureFeatures; /** * WebGPU Device/WebGL context abstraction diff --git a/modules/core/src/adapter/resources/render-pipeline.ts b/modules/core/src/adapter/resources/render-pipeline.ts index 5f4643fb58..a524fccebe 100644 --- a/modules/core/src/adapter/resources/render-pipeline.ts +++ b/modules/core/src/adapter/resources/render-pipeline.ts @@ -85,15 +85,17 @@ export abstract class RenderPipeline extends Resource { return 'RenderPipeline'; } - hash: string = ''; abstract readonly vs: Shader; abstract readonly fs: Shader | null; + /** The merged layout */ shaderLayout: ShaderLayout; /** Buffer map describing buffer interleaving etc */ readonly bufferLayout: BufferLayout[]; /** The linking status of the pipeline. 'pending' if linking is asynchronous, and on production */ linkStatus: 'pending' | 'success' | 'error' = 'pending'; + /** The hash of the pipeline */ + hash: string = ''; constructor(device: Device, props: RenderPipelineProps) { super(device, props, RenderPipeline.defaultProps); @@ -103,12 +105,6 @@ export abstract class RenderPipeline extends Resource { /** Set bindings (stored on pipeline and set before each call) */ abstract setBindings(bindings: Record): void; - /** Uniforms - * @deprecated Only supported on WebGL devices. - * @note textures, samplers and uniform buffers should be set via `setBindings()`, these are not considered uniforms. - * @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing. - */ - abstract setUniforms(bindings: Record): void; /** Draw call */ abstract draw(options: { @@ -132,4 +128,16 @@ export abstract class RenderPipeline extends Resource { /** Transform feedback. WebGL only. */ transformFeedback?: TransformFeedback; }): void; + + // DEPRECATED METHODS + + /** + * Uniforms + * @deprecated Use uniforms buffers + * @note textures, samplers and uniform buffers should be set via `setBindings()`, these are not considered uniforms. + * @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing. + */ + setUniformsWebGL(uniforms: Record): void { + throw new Error('Use uniform blocks'); + } } diff --git a/modules/core/src/adapter/resources/vertex-array.ts b/modules/core/src/adapter/resources/vertex-array.ts index c901534355..c79f3450dc 100644 --- a/modules/core/src/adapter/resources/vertex-array.ts +++ b/modules/core/src/adapter/resources/vertex-array.ts @@ -57,9 +57,14 @@ export abstract class VertexArray extends Resource { abstract setIndexBuffer(indices: Buffer | null): void; /** Set attributes (stored on pipeline and set before each call) */ abstract setBuffer(bufferSlot: number, buffer: Buffer | null): void; - /** Set constant attributes (WebGL only) */ - abstract setConstant(location: number, value: TypedArray | null): void; abstract bindBeforeRender(renderPass: RenderPass): void; abstract unbindAfterRender(renderPass: RenderPass): void; + + // DEPRECATED METHODS + + /** @deprecated Set constant attributes (WebGL only) */ + setConstantWebGL(location: number, value: TypedArray | null): void { + throw new Error('constant attributes not supported'); + } } diff --git a/modules/engine/src/model/model.ts b/modules/engine/src/model/model.ts index 153c8c83ee..84dfb342f4 100644 --- a/modules/engine/src/model/model.ts +++ b/modules/engine/src/model/model.ts @@ -287,9 +287,6 @@ export class Model { this.transformFeedback = props.transformFeedback; } - // TODO - restore? - // this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms - // Catch any access to non-standard props Object.seal(this); } @@ -321,7 +318,7 @@ export class Model { // Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw // Any caching needs to be done inside the pipeline functions this.pipeline.setBindings(this.bindings); - this.pipeline.setUniforms(this.uniforms); + this.pipeline.setUniformsWebGL(this.uniforms); const {indexBuffer} = this.vertexArray; const indexCount = indexBuffer @@ -506,7 +503,7 @@ export class Model { * @returns self for chaining */ setUniforms(uniforms: Record): void { - this.pipeline.setUniforms(uniforms); + this.pipeline.setUniformsWebGL(uniforms); Object.assign(this.uniforms, uniforms); } @@ -574,7 +571,7 @@ export class Model { for (const [attributeName, value] of Object.entries(attributes)) { const attributeInfo = this._attributeInfos[attributeName]; if (attributeInfo) { - this.vertexArray.setConstant(attributeInfo.location, value); + this.vertexArray.setConstantWebGL(attributeInfo.location, value); } else { log.warn( `Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"` diff --git a/modules/engine/src/transform/buffer-transform.ts b/modules/engine/src/transform/buffer-transform.ts index 45b4d5a069..be747927fd 100644 --- a/modules/engine/src/transform/buffer-transform.ts +++ b/modules/engine/src/transform/buffer-transform.ts @@ -1,10 +1,17 @@ // luma.gl, MIT license // Copyright (c) vis.gl contributors -import {Device, Buffer, BufferRange, TransformFeedback, assert, RenderPassProps} from '@luma.gl/core'; +import { + Device, + Buffer, + BufferRange, + TransformFeedback, + assert, + RenderPassProps +} from '@luma.gl/core'; import {getPassthroughFS} from '@luma.gl/shadertools'; import {Model} from '../model/model'; -import type { ModelProps } from '..'; +import type {ModelProps} from '..'; /** * Properties for creating a {@link BufferTransform} @@ -26,11 +33,11 @@ export class BufferTransform { /** @deprecated Use device feature test. */ static isSupported(device: Device): boolean { - return device.features.has('transform-feedback-webgl'); + return device?.info?.type === 'webgl'; } constructor(device: Device, props: BufferTransformProps = Model.defaultProps) { - assert(device.features.has('transform-feedback-webgl'), 'Device must support transform feedback'); + assert(BufferTransform.isSupported(device), 'BufferTransform not yet implemented on WebGPU'); this.device = device; @@ -38,12 +45,12 @@ export class BufferTransform { id: props.id || 'buffer-transform-model', fs: props.fs || getPassthroughFS(), topology: props.topology || 'point-list', - ...props, + ...props }); this.transformFeedback = this.device.createTransformFeedback({ layout: this.model.pipeline.shaderLayout, - buffers: props.feedbackBuffers, + buffers: props.feedbackBuffers }); this.model.setTransformFeedback(this.transformFeedback); diff --git a/modules/shadertools/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts b/modules/shadertools/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts index a46f84c85e..b71c74b8aa 100644 --- a/modules/shadertools/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts +++ b/modules/shadertools/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts @@ -16,9 +16,6 @@ export const fs = glsl`\ # error PBR fragment shader: Derivatives are not available #endif -// TODO - remove we no longer support WebGL1 -#define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR) - precision highp float; uniform bool pbr_uUnlit; @@ -347,7 +344,7 @@ vec4 pbr_filterColor(vec4 colorUnused) color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color); // Apply directional light - SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uDirectionalLightCount, i++) { + for(int i = 0, i < lighting_uDirectionalLightCount, i++) { if (i < lighting_uDirectionalLightCount) { PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction); color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color); @@ -355,7 +352,7 @@ vec4 pbr_filterColor(vec4 colorUnused) } // Apply point light - SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uPointLightCount, i++) { + for(int i = 0, i < lighting_uPointLightCount, i++) { if (i < lighting_uPointLightCount) { PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]); float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition)); diff --git a/modules/shadertools/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts b/modules/shadertools/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts index 45eff29737..6339ee9639 100644 --- a/modules/shadertools/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +++ b/modules/shadertools/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts @@ -16,9 +16,6 @@ export const fs = glsl`\ # error PBR fragment shader: Derivatives are not available #endif -// TODO - remove we only support WebGL2 -#define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR) - precision highp float; uniform Projection { @@ -365,7 +362,7 @@ vec4 pbr_filterColor(vec4 colorUnused) color += calculateFinalColor(pbrInfo, lighting_uAmbientLight.color); // Apply directional light - SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uDirectionalLightCount, i++) { + for(int i = 0, i < lighting_uDirectionalLightCount, i++) { if (i < lighting_uDirectionalLightCount) { PBRInfo_setDirectionalLight(pbrInfo, lighting_uDirectionalLight[i].direction); color += calculateFinalColor(pbrInfo, lighting_uDirectionalLight[i].color); @@ -373,7 +370,7 @@ vec4 pbr_filterColor(vec4 colorUnused) } // Apply point light - SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uPointLightCount, i++) { + for(int i = 0, i < lighting_uPointLightCount, i++) { if (i < lighting_uPointLightCount) { PBRInfo_setPointLight(pbrInfo, lighting_uPointLight[i]); float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition)); diff --git a/modules/webgl/src/adapter/converters/texture-formats.ts b/modules/webgl/src/adapter/converters/texture-formats.ts index 7d2a5603ae..cb1a36591a 100644 --- a/modules/webgl/src/adapter/converters/texture-formats.ts +++ b/modules/webgl/src/adapter/converters/texture-formats.ts @@ -33,19 +33,15 @@ const X_PVRTC = 'WEBGL_compressed_texture_pvrtc'; const X_ATC = 'WEBGL_compressed_texture_atc'; // Define local webgl extension strings to optimize minification -const EXT_TEXTURE_NORM16 = 'EXT_texture_norm16'; -const EXT_FLOAT_RENDER_WEBGL2 = 'EXT_color_buffer_float'; +const EXT_texture_norm16 = 'EXT_texture_norm16'; +const EXT_color_buffer_float = 'EXT_color_buffer_float'; // const EXT_HALF_FLOAT_WEBGL1 = 'EXT_color_buffer_half_float'; -// const DEPTH = 'WEBGL_depth_texture'; - -// WebGL1-only extensions -// const EXT_SRGB = 'EXT_sRGB'; // https://developer.mozilla.org/en-US/docs/Web/API/EXT_sRGB // prettier-ignore const TEXTURE_FEATURE_CHECKS: Partial> = { 'float32-renderable-webgl': ['EXT_color_buffer_float'], // [false, 'EXT_color_buffer_float'], 'float16-renderable-webgl': ['EXT_color_buffer_half_float'], - 'norm16-renderable-webgl': [EXT_TEXTURE_NORM16], + 'norm16-renderable-webgl': [EXT_texture_norm16], 'float32-filterable-linear-webgl': ['OES_texture_float_linear'], 'float16-filterable-linear-webgl': ['OES_texture_half_float_linear'], @@ -151,8 +147,8 @@ export const TEXTURE_FORMATS: Record = { 'r16uint': {gl: GL.R16UI, b: 2, c: 1, renderbuffer: true}, 'r16sint': {gl: GL.R16I, b: 2, c: 1, renderbuffer: true}, 'r16float': {gl: GL.R16F, b: 2, c: 1, render: 'float16-renderable-webgl', filter: 'float16-filterable-linear-webgl', renderbuffer: true}, - 'r16unorm-webgl': {gl: GL.R16_EXT, b:2, c:1, f: 'norm16-renderable-webgl', renderbuffer: true, x: EXT_TEXTURE_NORM16}, - 'r16snorm-webgl': {gl: GL.R16_SNORM_EXT, b:2, c:1, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16}, + 'r16unorm-webgl': {gl: GL.R16_EXT, b:2, c:1, f: 'norm16-renderable-webgl', renderbuffer: true, x: EXT_texture_norm16}, + 'r16snorm-webgl': {gl: GL.R16_SNORM_EXT, b:2, c:1, f: 'norm16-renderable-webgl', x: EXT_texture_norm16}, // Packed 16-bit formats 'rgba4unorm-webgl': {gl: GL.RGBA4, b: 2, c: 4, wgpu: false, renderbuffer: true}, @@ -177,8 +173,8 @@ export const TEXTURE_FORMATS: Record = { 'rg16sint': {gl: GL.RG16I, b: 4, c: 2, bpp: 4}, // When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension 'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render: 'float16-renderable-webgl', filter: 'float16-filterable-linear-webgl', renderbuffer: true}, - 'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16}, - 'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16}, + 'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2, f: 'norm16-renderable-webgl', x: EXT_texture_norm16}, + 'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2, f: 'norm16-renderable-webgl', x: EXT_texture_norm16}, 'r32uint': {gl: GL.R32UI, b: 4, c: 1, bpp: 4, renderbuffer: true}, 'r32sint': {gl: GL.R32I, b: 4, c: 1, bpp: 4, renderbuffer: true}, @@ -191,8 +187,8 @@ export const TEXTURE_FORMATS: Record = { 'rgb10a2unorm-webgl': {b: 4, c: 4, gl: GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true}, // 48-bit formats - 'rgb16unorm-webgl': {gl: GL.RGB16_EXT, b:2, c:3, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16}, - 'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, b:2, c:3, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16}, + 'rgb16unorm-webgl': {gl: GL.RGB16_EXT, b:2, c:3, f: 'norm16-renderable-webgl', x: EXT_texture_norm16}, + 'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, b:2, c:3, f: 'norm16-renderable-webgl', x: EXT_texture_norm16}, // 64-bit formats 'rg32uint': {gl: GL.RG32UI, b: 8, c: 2, renderbuffer: true}, @@ -201,12 +197,12 @@ export const TEXTURE_FORMATS: Record = { 'rgba16uint': {gl: GL.RGBA16UI, b: 8, c: 4, renderbuffer: true}, 'rgba16sint': {gl: GL.RGBA16I, b: 8, c: 4, renderbuffer: true}, 'rgba16float': {gl: GL.RGBA16F, b: 8, c: 4, render: 'float16-renderable-webgl', filter: 'float16-filterable-linear-webgl'}, - 'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, b:2, c:4, f: 'norm16-renderable-webgl', renderbuffer: true, x: EXT_TEXTURE_NORM16}, - 'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT, b:2, c:4, f: 'norm16-renderable-webgl', x: EXT_TEXTURE_NORM16}, + 'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, b:2, c:4, f: 'norm16-renderable-webgl', renderbuffer: true, x: EXT_texture_norm16}, + 'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT, b:2, c:4, f: 'norm16-renderable-webgl', x: EXT_texture_norm16}, // 96-bit formats (deprecated!) 'rgb32float-webgl': {gl: GL.RGB32F, render: 'float32-renderable-webgl', filter: 'float32-filterable-linear-webgl', - gl2ext: EXT_FLOAT_RENDER_WEBGL2, dataFormat: GL.RGB, types: [GL.FLOAT]}, + gl2ext: EXT_color_buffer_float, dataFormat: GL.RGB, types: [GL.FLOAT]}, // 128-bit formats 'rgba32uint': {gl: GL.RGBA32UI, b: 16, c: 4, renderbuffer: true}, @@ -400,7 +396,7 @@ export const RENDERBUFFER_FORMATS: Record = { [GL.RG32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8}, // TODO - can't get WEBGL_color_buffer_float to work on renderbuffers [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 16}, - // [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, gl1: EXT_FLOAT_WEBGL1}, + // [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2}, [GL.R11F_G11F_B10F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4} }; */ diff --git a/modules/webgl/src/adapter/device-helpers/webgl-device-features.ts b/modules/webgl/src/adapter/device-helpers/webgl-device-features.ts index 62a8163fe0..afeef48304 100644 --- a/modules/webgl/src/adapter/device-helpers/webgl-device-features.ts +++ b/modules/webgl/src/adapter/device-helpers/webgl-device-features.ts @@ -55,17 +55,9 @@ function isFeatureSupported(gl: WebGL2RenderingContext, feature: DeviceFeature): * when value is 'string' it is the name of the extension that enables this feature */ const WEBGL_FEATURES: Partial> = { - webgl: true, - glsl: true, - // optional WebGPU features 'depth-clip-control': 'EXT_depth_clamp', - // WebGL only features - 'uniforms-webgl': true, - 'transform-feedback-webgl': true, - 'constant-attributes-webgl': true, - // optional WebGL features 'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2', 'compilation-status-async-webgl': 'KHR_parallel_shader_compile', diff --git a/modules/webgl/src/adapter/resources/webgl-render-pipeline.ts b/modules/webgl/src/adapter/resources/webgl-render-pipeline.ts index 9f594921b7..93bb169017 100644 --- a/modules/webgl/src/adapter/resources/webgl-render-pipeline.ts +++ b/modules/webgl/src/adapter/resources/webgl-render-pipeline.ts @@ -148,20 +148,6 @@ export class WEBGLRenderPipeline extends RenderPipeline { } } - /** This function is @deprecated, use uniform buffers */ - setUniforms(uniforms: Record) { - const {bindings} = splitUniformsAndBindings(uniforms); - Object.keys(bindings).forEach(name => { - log.warn( - `Unsupported value "${JSON.stringify( - bindings[name] - )}" used in setUniforms() for key ${name}. Use setBindings() instead?` - )(); - }); - // TODO - check against layout - Object.assign(this.uniforms, uniforms); - } - /** @todo needed for portable model * @note The WebGL API is offers many ways to draw things * This function unifies those ways into a single call using common parameters with sane defaults @@ -225,31 +211,6 @@ export class WEBGLRenderPipeline extends RenderPipeline { this._applyUniforms(); const webglRenderPass = renderPass as WEBGLRenderPass; - // // TODO - Use polyfilled WebGL2RenderingContext instead of ANGLE extension - // if (isIndexed && isInstanced) { - // // ANGLE_instanced_arrays extension - // this.device.gl.drawElementsInstanced( - // drawMode, - // vertexCount || 0, // indexCount? - // indexType, - // firstVertex, - // instanceCount || 0 - // ); - // // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) { - // // this.device.gldrawRangeElements(drawMode, start, end, vertexCount, indexType, offset); - // } else if (isIndexed) { - // this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex); // indexCount? - // } else if (isInstanced) { - // this.device.gl.drawArraysInstanced( - // drawMode, - // firstVertex, - // vertexCount || 0, - // instanceCount || 0 - // ); - // } else { - // this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0); - // } - // }); withDeviceAndGLParameters( this.device, @@ -257,7 +218,6 @@ export class WEBGLRenderPipeline extends RenderPipeline { webglRenderPass.glParameters, () => { if (isIndexed && isInstanced) { - // ANGLE_instanced_arrays extension this.device.gl.drawElementsInstanced( glDrawMode, vertexCount || 0, // indexCount? @@ -291,6 +251,21 @@ export class WEBGLRenderPipeline extends RenderPipeline { return true; } + // DEPRECATED METHODS + + override setUniformsWebGL(uniforms: Record) { + const {bindings} = splitUniformsAndBindings(uniforms); + Object.keys(bindings).forEach(name => { + log.warn( + `Unsupported value "${JSON.stringify( + bindings[name] + )}" used in setUniforms() for key ${name}. Use setBindings() instead?` + )(); + }); + // TODO - check against layout + Object.assign(this.uniforms, uniforms); + } + // PRIVATE METHODS // setAttributes(attributes: Record): void {} diff --git a/modules/webgl/src/adapter/resources/webgl-vertex-array.ts b/modules/webgl/src/adapter/resources/webgl-vertex-array.ts index 5f623d1490..6827c1202a 100644 --- a/modules/webgl/src/adapter/resources/webgl-vertex-array.ts +++ b/modules/webgl/src/adapter/resources/webgl-vertex-array.ts @@ -106,7 +106,7 @@ export class WEBGLVertexArray extends VertexArray { } /** Set a location in vertex attributes array to a constant value, disables the location */ - override setConstant(location: number, value: TypedArray): void { + override setConstantWebGL(location: number, value: TypedArray): void { this._enable(location, false); this.attributes[location] = value; } @@ -146,7 +146,7 @@ export class WEBGLVertexArray extends VertexArray { const constant = this.attributes[location]; // A typed array means this is a constant if (ArrayBuffer.isView(constant)) { - this.device.setConstantAttribute(location, constant); + this.device.setConstantAttributeWebGL(location, constant); } } } diff --git a/modules/webgl/src/adapter/webgl-device.ts b/modules/webgl/src/adapter/webgl-device.ts index 105bdf1f13..b0b2646c78 100644 --- a/modules/webgl/src/adapter/webgl-device.ts +++ b/modules/webgl/src/adapter/webgl-device.ts @@ -509,11 +509,11 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex * so they need to be updated before every render * @todo - remember/cache values to avoid setting them unnecessarily? */ - setConstantAttribute(location: number, constant: TypedArray): void { + setConstantAttributeWebGL(location: number, constant: TypedArray): void { this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null); const currentConstant = this._constants[location]; if (currentConstant && compareConstantArrayValues(currentConstant, constant)) { - log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)(); + log.info(1, `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`)(); } this._constants[location] = constant; diff --git a/modules/webgl/src/context/parameters/webgl-parameter-tables.ts b/modules/webgl/src/context/parameters/webgl-parameter-tables.ts index 07f2c4cb27..f4f94049bf 100644 --- a/modules/webgl/src/context/parameters/webgl-parameter-tables.ts +++ b/modules/webgl/src/context/parameters/webgl-parameter-tables.ts @@ -64,15 +64,7 @@ export const GL_PARAMETER_DEFAULTS: GLParameters = { [GL.STENCIL_BACK_PASS_DEPTH_PASS]: GL.KEEP, // Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame. [GL.VIEWPORT]: [0, 0, 1024, 1024], - // WEBGL1 PIXEL PACK/UNPACK MODES - [GL.PACK_ALIGNMENT]: 4, - [GL.UNPACK_ALIGNMENT]: 4, - [GL.UNPACK_FLIP_Y_WEBGL]: false, - [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false, - [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: GL.BROWSER_DEFAULT_WEBGL, - // WEBGL2 / EXTENSIONS - // gl1: 'OES_standard_derivatives' [GL.TRANSFORM_FEEDBACK_BINDING]: null, [GL.COPY_READ_BUFFER_BINDING]: null, [GL.COPY_WRITE_BUFFER_BINDING]: null, @@ -81,6 +73,12 @@ export const GL_PARAMETER_DEFAULTS: GLParameters = { [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: GL.DONT_CARE, [GL.READ_FRAMEBUFFER_BINDING]: null, [GL.RASTERIZER_DISCARD]: false, + + [GL.PACK_ALIGNMENT]: 4, + [GL.UNPACK_ALIGNMENT]: 4, + [GL.UNPACK_FLIP_Y_WEBGL]: false, + [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false, + [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: GL.BROWSER_DEFAULT_WEBGL, [GL.PACK_ROW_LENGTH]: 0, [GL.PACK_SKIP_PIXELS]: 0, [GL.PACK_SKIP_ROWS]: 0, diff --git a/modules/webgl/test/adapter/objects/webgl-renderbuffer.spec.ts b/modules/webgl/test/adapter/objects/webgl-renderbuffer.spec.ts index 4effe09a5f..6268855f1d 100644 --- a/modules/webgl/test/adapter/objects/webgl-renderbuffer.spec.ts +++ b/modules/webgl/test/adapter/objects/webgl-renderbuffer.spec.ts @@ -7,8 +7,6 @@ import {getWebGLTestDevices} from '@luma.gl/test-utils'; import {TextureFormat} from '@luma.gl/core'; import {WEBGLRenderbuffer, _TEXTURE_FORMATS} from '@luma.gl/webgl'; -// const WEBGL1_FORMATS = [GL.RGB, GL.RGBA, GL.LUMINANCE_ALPHA, GL.LUMINANCE, GL.ALPHA]; - test('WebGL#WEBGLRenderbuffer construct/delete', (t) => { for (const device of getWebGLTestDevices()) { t.throws( diff --git a/modules/webgl/test/adapter/resources/webgl-transform-feedback.spec.ts b/modules/webgl/test/adapter/resources/webgl-transform-feedback.spec.ts index 3c37a10f72..a391a3e34a 100644 --- a/modules/webgl/test/adapter/resources/webgl-transform-feedback.spec.ts +++ b/modules/webgl/test/adapter/resources/webgl-transform-feedback.spec.ts @@ -27,11 +27,6 @@ void main() } `; -test('WebGL#TransformFeedback feature flag', t => { - t.true(webglDevice.features.has('transform-feedback-webgl'), 'webgl supports transform feedback'); - t.end(); -}); - test('WebGL#TransformFeedback constructor/destroy', t => { const buffer1 = webglDevice.createBuffer({byteLength: 16}); const buffer2 = webglDevice.createBuffer({byteLength: 16}); diff --git a/modules/webgl/test/context/state-tracker/data/sample-enum-settings.ts b/modules/webgl/test/context/state-tracker/data/sample-enum-settings.ts index e59240cfc0..26ea94ab17 100644 --- a/modules/webgl/test/context/state-tracker/data/sample-enum-settings.ts +++ b/modules/webgl/test/context/state-tracker/data/sample-enum-settings.ts @@ -30,17 +30,18 @@ export const ENUM_STYLE_SETTINGS_SET1_PRIMITIVE: GLParameters = { // Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame. // TODO - this triggers test errors with single WebGL2Device // [GL.VIEWPORT]: new Int32Array([0, 0, 100, 100]), - // WEBGL1 PIXEL PACK/UNPACK MODES + + // gl1: 'OES_standard_derivatives' + // [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: GL.FASTEST, + // [GL.RASTERIZER_DISCARD]: true, + + // PIXEL PACK/UNPACK MODES [GL.PACK_ALIGNMENT]: 8, [GL.UNPACK_ALIGNMENT]: 8, [GL.UNPACK_FLIP_Y_WEBGL]: true, [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: true, [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: GL.NONE - - // WEBGL2 / EXTENSIONS - // gl1: 'OES_standard_derivatives' - // [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: GL.FASTEST, - // [GL.RASTERIZER_DISCARD]: true, + // TODO // [GL.PACK_ROW_LENGTH]: 2, // [GL.PACK_SKIP_PIXELS]: 4, // [GL.PACK_SKIP_ROWS]: 8 @@ -127,17 +128,18 @@ export const ENUM_STYLE_SETTINGS_SET2: GLParameters = { [GL.STENCIL_BACK_PASS_DEPTH_PASS]: GL.INCR, // Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame. [GL.VIEWPORT]: new Int32Array([0, 0, 200, 200]), + + // gl1: 'OES_standard_derivatives' + // [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: GL.NICEST, + // [GL.RASTERIZER_DISCARD]: false, + // WEBGL1 PIXEL PACK/UNPACK MODES [GL.PACK_ALIGNMENT]: 2, [GL.UNPACK_ALIGNMENT]: 2, [GL.UNPACK_FLIP_Y_WEBGL]: false, [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false, [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: GL.BROWSER_DEFAULT_WEBGL - - // WEBGL2 / EXTENSIONS - // gl1: 'OES_standard_derivatives' - // [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: GL.NICEST, - // [GL.RASTERIZER_DISCARD]: false, + // TODO // [GL.PACK_ROW_LENGTH]: 64, // [GL.PACK_SKIP_PIXELS]: 128, // [GL.PACK_SKIP_ROWS]: 512, diff --git a/modules/webgl/test/context/state-tracker/data/sample-function-settings.ts b/modules/webgl/test/context/state-tracker/data/sample-function-settings.ts index bd82171b26..340b0f206f 100644 --- a/modules/webgl/test/context/state-tracker/data/sample-function-settings.ts +++ b/modules/webgl/test/context/state-tracker/data/sample-function-settings.ts @@ -35,16 +35,14 @@ export const FUNCTION_STYLE_SETTINGS_SET1: GLParameters = { stencilOp: [GL.REPLACE, GL.INCR, GL.DECR, GL.REPLACE, GL.INCR, GL.DECR], // Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame. viewport: new Int32Array([0, 0, 100, 100]), - // WEBGL1 PIXEL PACK/UNPACK MODES + + derivativeHint: GL.FASTEST, + [GL.PACK_ALIGNMENT]: 8, [GL.UNPACK_ALIGNMENT]: 8, [GL.UNPACK_FLIP_Y_WEBGL]: true, [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: true, [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: GL.NONE, - - // WEBGL2 / EXTENSIONS - // gl1: 'OES_standard_derivatives' - derivativeHint: GL.FASTEST, [GL.RASTERIZER_DISCARD]: true, [GL.PACK_ROW_LENGTH]: 2, [GL.PACK_SKIP_PIXELS]: 4, diff --git a/modules/webgpu/src/adapter/resources/webgpu-render-pipeline.ts b/modules/webgpu/src/adapter/resources/webgpu-render-pipeline.ts index 6226e6bc31..34906b5615 100644 --- a/modules/webgpu/src/adapter/resources/webgpu-render-pipeline.ts +++ b/modules/webgpu/src/adapter/resources/webgpu-render-pipeline.ts @@ -1,7 +1,7 @@ // luma.gl MIT license -import type {Binding, UniformValue, RenderPass, VertexArray} from '@luma.gl/core'; -import {RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/core'; +import type {Binding, RenderPass, VertexArray} from '@luma.gl/core'; +import {RenderPipeline, RenderPipelineProps, cast, log} from '@luma.gl/core'; import {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters'; import {getWebGPUTextureFormat} from '../helpers/convert-texture-format'; import {getBindGroup} from '../helpers/get-bind-group'; @@ -83,10 +83,6 @@ export class WebGPURenderPipeline extends RenderPipeline { } */ - // setConstantAttributes(attributes: Record): void { - // throw new Error('not implemented'); - // } - setBindings(bindings: Record): void { // if (isObjectEmpty(bindings)) { // return; @@ -96,12 +92,6 @@ export class WebGPURenderPipeline extends RenderPipeline { Object.assign(this.props.bindings, bindings); } - setUniforms(uniforms: Record): void { - if (!isObjectEmpty(uniforms)) { - throw new Error('WebGPU does not support uniforms'); - } - } - draw(options: { renderPass: RenderPass; vertexArray: VertexArray; diff --git a/modules/webgpu/src/adapter/resources/webgpu-vertex-array.ts b/modules/webgpu/src/adapter/resources/webgpu-vertex-array.ts index 71659f5350..3897bbcd8c 100644 --- a/modules/webgpu/src/adapter/resources/webgpu-vertex-array.ts +++ b/modules/webgpu/src/adapter/resources/webgpu-vertex-array.ts @@ -1,7 +1,7 @@ // luma.gl, MIT license // Copyright (c) vis.gl contributors -import type {Device, Buffer, VertexArrayProps, RenderPass, TypedArray} from '@luma.gl/core'; +import type {Device, Buffer, VertexArrayProps, RenderPass} from '@luma.gl/core'; import {VertexArray, log} from '@luma.gl/core'; import {getBrowser} from '@probe.gl/env'; @@ -20,14 +20,6 @@ export class WebGPUVertexArray extends VertexArray { /** Vertex Array is a helper class under WebGPU */ readonly handle: never; - /** - * Attribute 0 can not be disable on most desktop OpenGL based browsers - * TODO is this even an issue for WebGPU? - */ - static isConstantAttributeZeroSupported(device: Device): boolean { - return getBrowser() === 'Chrome'; - } - // Create a VertexArray constructor(device: WebGPUDevice, props?: VertexArrayProps) { super(device, props); @@ -55,11 +47,6 @@ export class WebGPUVertexArray extends VertexArray { this.attributes[bufferSlot] = buffer; } - /** Set a location in vertex attributes array to a constant value, disables the location */ - override setConstant(location: number, value: TypedArray): void { - log.warn(`${this.id} constant attributes not supported on WebGPU`) - } - override bindBeforeRender(renderPass: RenderPass, firstIndex?: number, indexCount?: number): void { const webgpuRenderPass = renderPass as WebGPURenderPass; const webgpuIndexBuffer = this.indexBuffer as WebGPUBuffer; @@ -83,4 +70,15 @@ export class WebGPUVertexArray extends VertexArray { // In fact we can't easily do it. setIndexBuffer/setVertexBuffer don't accept null. // Unbinding presumably happens automatically when the render pass is ended. } + + // DEPRECATED METHODS + + /** + * @deprecated is this even an issue for WebGPU? + * Attribute 0 can not be disable on most desktop OpenGL based browsers + */ + static isConstantAttributeZeroSupported(device: Device): boolean { + return getBrowser() === 'Chrome'; + } + } diff --git a/modules/webgpu/src/adapter/webgpu-device.ts b/modules/webgpu/src/adapter/webgpu-device.ts index 1710293edb..fffca1e639 100644 --- a/modules/webgpu/src/adapter/webgpu-device.ts +++ b/modules/webgpu/src/adapter/webgpu-device.ts @@ -295,8 +295,6 @@ export class WebGPUDevice extends Device { } const WEBGPU_ALWAYS_FEATURES: DeviceFeature[] = [ - 'webgpu', - 'wgsl', 'timer-query-webgl', 'float32-filterable-linear-webgl', 'float16-filterable-linear-webgl',