Skip to content

Commit

Permalink
Merge 6285a55 into 8947329
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen committed Feb 26, 2024
2 parents 8947329 + 6285a55 commit 1056710
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 87 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference/core/device-features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
WebGLExtensions
} from '@site/src/react-luma';

# Device Features
# DeviceFeatures

The luma.gl `Device` provides a device "feature" system that allows applications
to check whether specific advanced capabilities are present on the current browser or GPU.
Expand Down
18 changes: 16 additions & 2 deletions docs/api-reference/core/device-info.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import {DeviceTabs, Info} from '@site/src/react-luma';

### Device.info
# DeviceInfo

Holds a `DeviceInfo` object that describes the device, providing information about the driver, GPU, shading language etc.
The `device.info` field holds a small `DeviceInfo` object that provides information about the device, such as driver, GPU, shading language etc.

## Usage

```typescript
import {Device} from '@luma.gl/core';

const device: Device = ...;
console.log(device.info);
if (device.info.gpu === 'nvidia') {
...
}
```

## Device

<DeviceTabs />

Expand Down
65 changes: 37 additions & 28 deletions docs/api-reference/core/device-limits.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import {DeviceTabs, Feature as F, Limit as L, WebGLLimit as WL} from '@site/src/

The `device.limits` field contains limits object that indicates what the current platform supports.

## Background

Each platform (GPU, driver, browser etc) has different limitations. To avoid limiting applications to a common
minimal set of limits, the device limits API lets the application discover what the current platform supports.

## Usage

Access the current `Device` limits using the `device.limits` field

```typescript
import type {DeviceLimits} from '@luma.gl/core';
import {Device} from '@luma.gl/core';
Expand All @@ -21,35 +28,37 @@ if (limits.maxTextureDimension2D > 2048) {

<DeviceTabs />

| Limit | Value | WebGL parameter |
| ------------------------------------------- | --------------------------------------------------- | -------------------------------------- |
| `maxTextureDimension1D` | <L f="maxTextureDimension1D" /> | WebGL does not support 1D textures |
| `maxTextureDimension2D` | <L f="maxTextureDimension2D" /> | `GL.MAX_TEXTURE_SIZE` |
| `maxTextureDimension3D` | <L f="maxTextureDimension3D" /> | `GL.MAX_3D_TEXTURE_SIZE` |
| `maxTextureArrayLayers` | <L f="maxTextureArrayLayers" /> | `GL.MAX_ARRAY_TEXTURE_LAYERS` |
| `maxBindGroups` | <L f="maxBindGroups" /> | WebGPU only |
| `maxDynamicUniformBuffersPerPipelineLayout` | <L f="maxDynamicUniformBuffersPerPipelineLayout" /> | WebGPU only |
| `maxDynamicStorageBuffersPerPipelineLayout` | <L f="maxDynamicStorageBuffersPerPipelineLayout" /> | WebGPU only |
| `maxSampledTexturesPerShaderStage` | <L f="maxSampledTexturesPerShaderStage" /> | `GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS` |
| `maxSamplersPerShaderStage` | <L f="maxSamplersPerShaderStage" /> | `GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS` |
| `maxStorageBuffersPerShaderStage` | <L f="maxStorageBuffersPerShaderStage" /> | WebGPU only |
| `maxStorageTexturesPerShaderStage` | <L f="maxStorageTexturesPerShaderStage" /> | WebGPU only |
| `maxUniformBuffersPerShaderStage` | <L f="maxUniformBuffersPerShaderStage" /> | `GL.MAX_UNIFORM_BUFFER_BINDINGS` |
| `maxUniformBufferBindingSize` | <L f="maxUniformBufferBindingSize" /> | `GL.MAX_UNIFORM_BLOCK_SIZE` |
| `maxStorageBufferBindingSize` | <L f="maxStorageBufferBindingSize" /> | WebGPU only |
| `minUniformBufferOffsetAlignment` | <L f="minUniformBufferOffsetAlignment" /> | `GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT` |
| `minStorageBufferOffsetAlignment` | <L f="minStorageBufferOffsetAlignment" /> | WebGPU only |
| `maxVertexBuffers` | <L f="maxVertexBuffers" /> | |
| `maxVertexAttributes` | <L f="maxVertexAttributes" /> | `GL.MAX_VERTEX_ATTRIBS` |
| `maxVertexBufferArrayStride` | <L f="maxVertexBufferArrayStride" /> | Cant be reliably determined on WebGL |
| `maxInterStageShaderComponents` | <L f="maxInterStageShaderComponents" /> | `GL.MAX_VARYING_COMPONENTS` |
| `maxComputeWorkgroupStorageSize` | <L f="maxComputeWorkgroupStorageSize" /> | WebGL does not support compute shaders |
| `maxComputeInvocationsPerWorkgroup` | <L f="maxComputeInvocationsPerWorkgroup" /> | WebGL does not support compute shaders |
| `maxComputeWorkgroupSizeX` | <L f="maxComputeWorkgroupSizeX" /> | WebGL does not support compute shaders |
| `maxComputeWorkgroupSizeY` | <L f="maxComputeWorkgroupSizeY" /> | WebGL does not support compute shaders |
| `maxComputeWorkgroupSizeZ` | <L f="maxComputeWorkgroupSizeZ" /> | WebGL does not support compute shaders |
| `maxComputeWorkgroupsPerDimension` | <L f="maxComputeWorkgroupsPerDimension" /> | WebGL does not support compute shaders |
| Limit | Value | WebGL parameter |
| ------------------------------------------- | --------------------------------------------------- | ------------------------------------- |
| `maxTextureDimension1D` | <L f="maxTextureDimension1D" /> | WebGL2 does not support 1D textures |
| `maxTextureDimension2D` | <L f="maxTextureDimension2D" /> | `GL.MAX_TEXTURE_SIZE` |
| `maxTextureDimension3D` | <L f="maxTextureDimension3D" /> | `GL.MAX_3D_TEXTURE_SIZE` |
| `maxTextureArrayLayers` | <L f="maxTextureArrayLayers" /> | `GL.MAX_ARRAY_TEXTURE_LAYERS` |
| `maxBindGroups` | <L f="maxBindGroups" /> | WebGL2 has no bind groups |
| `maxDynamicUniformBuffersPerPipelineLayout` | <L f="maxDynamicUniformBuffersPerPipelineLayout" /> | WebGPU only |
| `maxDynamicStorageBuffersPerPipelineLayout` | <L f="maxDynamicStorageBuffersPerPipelineLayout" /> | WebGL2 has no storage buffers |
| `maxSampledTexturesPerShaderStage` | <L f="maxSampledTexturesPerShaderStage" /> | `GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS` |
| `maxSamplersPerShaderStage` | <L f="maxSamplersPerShaderStage" /> | `GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS` |
| `maxStorageBuffersPerShaderStage` | <L f="maxStorageBuffersPerShaderStage" /> | WebGL2 has no storage buffers |
| `maxStorageTexturesPerShaderStage` | <L f="maxStorageTexturesPerShaderStage" /> | WebGL2 has no storage buffers |
| `maxUniformBuffersPerShaderStage` | <L f="maxUniformBuffersPerShaderStage" /> | `GL.MAX_UNIFORM_BUFFER_BINDINGS` |
| `maxUniformBufferBindingSize` | <L f="maxUniformBufferBindingSize" /> | `GL.MAX_UNIFORM_BLOCK_SIZE` |
| `maxStorageBufferBindingSize` | <L f="maxStorageBufferBindingSize" /> | WebGL2 has no storage buffers |
| `minUniformBufferOffsetAlignment` | <L f="minUniformBufferOffsetAlignment" /> | `GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT` |
| `minStorageBufferOffsetAlignment` | <L f="minStorageBufferOffsetAlignment" /> | WebGPU only |
| `maxVertexBuffers` | <L f="maxVertexBuffers" /> | See [WebGPU issue][gpuweb4284] |
| `maxVertexAttributes` | <L f="maxVertexAttributes" /> | `GL.MAX_VERTEX_ATTRIBS` |
| `maxVertexBufferArrayStride` | <L f="maxVertexBufferArrayStride" /> | Cant be reliably determined on WebGL |
| `maxInterStageShaderComponents` | <L f="maxInterStageShaderComponents" /> | `GL.MAX_VARYING_COMPONENTS` |
| `maxComputeWorkgroupStorageSize` | <L f="maxComputeWorkgroupStorageSize" /> | WebGL2 has no compute shaders |
| `maxComputeInvocationsPerWorkgroup` | <L f="maxComputeInvocationsPerWorkgroup" /> | WebGL2 has no compute shaders |
| `maxComputeWorkgroupSizeX` | <L f="maxComputeWorkgroupSizeX" /> | WebGL2 has no compute shaders |
| `maxComputeWorkgroupSizeY` | <L f="maxComputeWorkgroupSizeY" /> | WebGL2 has no compute shaders |
| `maxComputeWorkgroupSizeZ` | <L f="maxComputeWorkgroupSizeZ" /> | WebGL2 has no compute shaders |
| `maxComputeWorkgroupsPerDimension` | <L f="maxComputeWorkgroupsPerDimension" /> | WebGL2 has no compute shaders |

['ext_texture_filter_anisotropic']: https://developer.mozilla.org/en-US/docs/Web/API/EXT_texture_filter_anisotropic

- Given that queries to driver and GPU are typically expensive in WebGL, the Device will cache any queried limits.

[gpuweb4284]: https://github.com/gpuweb/gpuweb/issues/4284
2 changes: 1 addition & 1 deletion examples/showcase/instancing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import {WebGLDevice} from '@luma.gl/webgl';
import {WebGPUDevice} from '@luma.gl/webgpu';
import AnimationLoopTemplate from './app.ts';
luma.registerDevices([WebGLDevice]);
luma.registerDevices([WebGPUDevice]);
makeAnimationLoop(AnimationLoopTemplate).start();
</script>
<body>
Expand Down
2 changes: 1 addition & 1 deletion modules/core-tests/test/adapter/resources/buffer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ test('Buffer#readAsync', async t => {
receivedData = await buffer.readAsync(Float32Array.BYTES_PER_ELEMENT);
f32Data = new Float32Array(receivedData.buffer);
expectedData = new Float32Array([2, 3]);
t.deepEqual(f32Data, expectedData, "Buffer.readAsync: with 'dstData' parameter successful");
t.deepEqual(f32Data, expectedData, 'Buffer.readAsync: with dstData parameter successful');

// receivedData = await buffer.readAsync({
// Float32Array.BYTES_PER_ELEMENT,
Expand Down
5 changes: 5 additions & 0 deletions modules/core/src/adapter/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ export type DeviceProps = {
width?: number /** width is only used when creating a new canvas */;
height?: number /** height is only used when creating a new canvas */;

/** Request a Device with the highest limits supported by platform. */
requestMaximalLimits?: boolean;

// WebGLContext PARAMETERS - Can only be set on context creation...
// alpha?: boolean; // Default render target has an alpha buffer.
// depth?: boolean; // Default render target has a depth buffer of at least 16 bits.
Expand Down Expand Up @@ -229,6 +232,8 @@ export abstract class Device {
manageState: true,
width: 800, // width are height are only used by headless gl
height: 600,

requestMaximalLimits: true,
debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance)
spector: Boolean(log.get('spector')), // Initialize the SpectorJS WebGL debugger
break: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export class WebGLDeviceLimits extends DeviceLimits {
get maxUniformBufferBindingSize() { return this.getParameter(GL.MAX_UNIFORM_BLOCK_SIZE); }
get maxStorageBufferBindingSize() { return 0; }
get minUniformBufferOffsetAlignment() { return this.getParameter(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT); }
get minStorageBufferOffsetAlignment() { return 0; } // TBD
get maxVertexBuffers() { return 0; }
get minStorageBufferOffsetAlignment() { return 0; }
get maxVertexBuffers() { return 16; } // WebGL 2 supports 16 buffers, see https://github.com/gpuweb/gpuweb/issues/4284
get maxVertexAttributes() { return this.getParameter(GL.MAX_VERTEX_ATTRIBS); }
get maxVertexBufferArrayStride() { return 2048; } // TBD, this is just the default value from WebGPU
get maxInterStageShaderComponents() { return this.getParameter(GL.MAX_VARYING_COMPONENTS); }
Expand Down
18 changes: 15 additions & 3 deletions modules/webgpu/src/adapter/webgpu-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,23 @@ export class WebGPUDevice extends Device {
const adapterInfo = await adapter.requestAdapterInfo();
log.probe(2, 'Adapter available', adapterInfo)();

const requiredFeatures: GPUFeatureName[] = [];
const requiredLimits: Record<string, number> = {};

if (props.requestMaximalLimits) {
requiredFeatures.push(...(Array.from(adapter.features) as GPUFeatureName[]));
for (const key in adapter.limits) {
requiredLimits[key] = adapter.limits[key];
}
delete requiredLimits.minSubgroupSize;
delete requiredLimits.maxSubgroupSize;
}

const gpuDevice = await adapter.requestDevice({
requiredFeatures: adapter.features as ReadonlySet<GPUFeatureName>
// TODO ensure we obtain best limits
// requiredLimits: adapter.limits
requiredFeatures,
requiredLimits
});

log.probe(1, 'GPUDevice available')();

if (typeof props.canvas === 'string') {
Expand Down
Binary file modified website/.yarn/install-state.gz
Binary file not shown.
14 changes: 7 additions & 7 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "npx tsc --noEmit",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"check": "yarn docusaurus-mdx-checker ../docs",
"check": "yarn docusaurus-mdx-checker ../docs",
"clear": "docusaurus clear",
"clean": "docusaurus clear",
"serve": "docusaurus serve",
Expand All @@ -21,12 +21,12 @@
"@algolia/autocomplete-js": "^1.8.3",
"@docusaurus/core": "^3.1.1",
"@docusaurus/preset-classic": "^3.1.1",
"@luma.gl/constants": "9.0.0-beta.4",
"@luma.gl/core": "9.0.0-beta.4",
"@luma.gl/engine": "9.0.0-beta.4",
"@luma.gl/shadertools": "9.0.0-beta.4",
"@luma.gl/webgl": "9.0.0-beta.4",
"@luma.gl/webgpu": "9.0.0-beta.4",
"@luma.gl/constants": "9.0.0-beta.5",
"@luma.gl/core": "9.0.0-beta.5",
"@luma.gl/engine": "9.0.0-beta.5",
"@luma.gl/shadertools": "9.0.0-beta.5",
"@luma.gl/webgl": "9.0.0-beta.5",
"@luma.gl/webgpu": "9.0.0-beta.5",
"@mdx-js/react": "^3.0.0",
"clsx": "^1.1.1",
"react": "^18.2.0",
Expand Down
83 changes: 41 additions & 42 deletions website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2658,71 +2658,70 @@ __metadata:
languageName: node
linkType: hard

"@luma.gl/constants@npm:9.0.0-beta.4":
version: 9.0.0-beta.4
resolution: "@luma.gl/constants@npm:9.0.0-beta.4"
checksum: 10c0/b9ea47a3a6a49f30cc3b6ea3e8d503b15765240a9d46c8b41ff6dbee990221cc809a8fdbc6a7e838a8ccca62e5eab5e37981b847e51f81c08595fce7babac446
"@luma.gl/constants@npm:9.0.0-beta.5":
version: 9.0.0-beta.5
resolution: "@luma.gl/constants@npm:9.0.0-beta.5"
checksum: 10c0/bfca2ec4a96868c0301d9c204d89d395541a27ae478875e369e0a5d21d98db20b9235dae288d0c16acb4e3a9765418c35f348c751ef4309df0200f03e38b42c6
languageName: node
linkType: hard

"@luma.gl/core@npm:9.0.0-beta.4":
version: 9.0.0-beta.4
resolution: "@luma.gl/core@npm:9.0.0-beta.4"
"@luma.gl/core@npm:9.0.0-beta.5":
version: 9.0.0-beta.5
resolution: "@luma.gl/core@npm:9.0.0-beta.5"
dependencies:
"@babel/runtime": "npm:^7.0.0"
"@types/offscreencanvas": "npm:^2019.6.4"
checksum: 10c0/977ef30c9bfa7f892ac937ec4f6f162c7dccf3b21377c8dd42b9d52f1a435be65c459bed65b597a30a2af5344227c62bdddbf6cf10668551e0f65e21cfdc9957
checksum: 10c0/eabb7ffd0fbed5d24108be99f8ad5a79a8a65e5468f5602fd56b49d3f6d2f8018f373c09a6d6fd0ec09388b09779c96360ffe161ba7a1f20a213b8d08cdc59d5
languageName: node
linkType: hard

"@luma.gl/engine@npm:9.0.0-beta.4":
version: 9.0.0-beta.4
resolution: "@luma.gl/engine@npm:9.0.0-beta.4"
"@luma.gl/engine@npm:9.0.0-beta.5":
version: 9.0.0-beta.5
resolution: "@luma.gl/engine@npm:9.0.0-beta.5"
dependencies:
"@babel/runtime": "npm:^7.0.0"
"@luma.gl/constants": "npm:9.0.0-beta.4"
"@luma.gl/core": "npm:9.0.0-beta.4"
"@luma.gl/shadertools": "npm:9.0.0-beta.4"
"@math.gl/core": "npm:^4.0.0"
"@probe.gl/log": "npm:^4.0.2"
"@probe.gl/stats": "npm:^4.0.2"
checksum: 10c0/735bb417424c1f7b45a3f65ef1e265d98a2157bdcc8424b2321accaf9663014bc6620385f05dc16c1ea44acfda781e71fbc3cdb5d65aa155413acac0f9d98648
peerDependencies:
"@luma.gl/core": ^9.0.0-beta.4
"@luma.gl/shadertools": ^9.0.0-beta.4
checksum: 10c0/05927d693909bad38b3d6d6505d799f380961743859725b39657c1f8ebce1e65fc97e3186fc869ed8a0dc5a509f56b0ce663780ca556bc7008f135eaaecff201
languageName: node
linkType: hard

"@luma.gl/shadertools@npm:9.0.0-beta.4":
version: 9.0.0-beta.4
resolution: "@luma.gl/shadertools@npm:9.0.0-beta.4"
"@luma.gl/shadertools@npm:9.0.0-beta.5":
version: 9.0.0-beta.5
resolution: "@luma.gl/shadertools@npm:9.0.0-beta.5"
dependencies:
"@babel/runtime": "npm:^7.0.0"
"@luma.gl/core": "npm:9.0.0-beta.4"
"@math.gl/core": "npm:^4.0.0"
"@math.gl/types": "npm:^4.0.0"
checksum: 10c0/ab89b3f2680ff7cabb1d634e1ced86c418bb867562b0a7212905997fcf51b437545892d29834c06948fe25ee5f53fe66c4b8845569f1cebf7123dbcff872abb5
peerDependencies:
"@luma.gl/core": ^9.0.0-beta.4
checksum: 10c0/520f4dbfacfed70933928808678f2a5b46d78dd998ce41f8d2ca552457374959dcf6d2138e526adb00429ecd2a6d5f8da48276f617086e94b0d1598785caba11
languageName: node
linkType: hard

"@luma.gl/webgl@npm:9.0.0-beta.4":
version: 9.0.0-beta.4
resolution: "@luma.gl/webgl@npm:9.0.0-beta.4"
"@luma.gl/webgl@npm:9.0.0-beta.5":
version: 9.0.0-beta.5
resolution: "@luma.gl/webgl@npm:9.0.0-beta.5"
dependencies:
"@babel/runtime": "npm:^7.0.0"
"@luma.gl/constants": "npm:9.0.0-beta.4"
"@luma.gl/core": "npm:9.0.0-beta.4"
"@luma.gl/constants": "npm:9.0.0-beta.5"
"@luma.gl/core": "npm:9.0.0-beta.5"
"@probe.gl/env": "npm:^4.0.2"
checksum: 10c0/708593774eefc2bf945312b58692f830623a9a6de13b933df6e8cda1af9e8ee344691c1422a284f3532c38c4cb0810f20161c045057567198272dd5e0fbdaccb
peerDependencies:
"@luma.gl/constants": ^9.0.0-beta.4
checksum: 10c0/eb2ebd3f7d8a42360fe929041616ce0d46005a4a95df525eb8941b5adadcd4d5532991b1e76d195779b8b6242f15fd8dc50d318aaee9f0d3e50f2af76c52eab5
languageName: node
linkType: hard

"@luma.gl/webgpu@npm:9.0.0-beta.4":
version: 9.0.0-beta.4
resolution: "@luma.gl/webgpu@npm:9.0.0-beta.4"
"@luma.gl/webgpu@npm:9.0.0-beta.5":
version: 9.0.0-beta.5
resolution: "@luma.gl/webgpu@npm:9.0.0-beta.5"
dependencies:
"@babel/runtime": "npm:^7.0.0"
"@luma.gl/core": "npm:9.0.0-beta.4"
"@probe.gl/env": "npm:^4.0.2"
"@webgpu/types": "npm:^0.1.34"
checksum: 10c0/aa22725102e2424b9e9b2f7ea9711f7fc7ed599677f6fbe1273a987eadbf95df4f62916da56e15c4bd2e15d4fb28eac4d1643e695a76737a08d97e21d16e70f6
peerDependencies:
"@luma.gl/core": ^9.0.0-beta.4
checksum: 10c0/d72fdada1242b74a71d82e8ec2a71dd349ab136fbf5b472162f413714f77fb76eb26d864cc88537bf5244d73a78c6d3a4cdd2121e941ae11eda381174877e8a8
languageName: node
linkType: hard

Expand Down Expand Up @@ -13017,12 +13016,12 @@ __metadata:
"@docusaurus/plugin-content-docs": "npm:^3.1.1"
"@docusaurus/preset-classic": "npm:^3.1.1"
"@docusaurus/tsconfig": "npm:^3.1.1"
"@luma.gl/constants": "npm:9.0.0-beta.4"
"@luma.gl/core": "npm:9.0.0-beta.4"
"@luma.gl/engine": "npm:9.0.0-beta.4"
"@luma.gl/shadertools": "npm:9.0.0-beta.4"
"@luma.gl/webgl": "npm:9.0.0-beta.4"
"@luma.gl/webgpu": "npm:9.0.0-beta.4"
"@luma.gl/constants": "npm:9.0.0-beta.5"
"@luma.gl/core": "npm:9.0.0-beta.5"
"@luma.gl/engine": "npm:9.0.0-beta.5"
"@luma.gl/shadertools": "npm:9.0.0-beta.5"
"@luma.gl/webgl": "npm:9.0.0-beta.5"
"@luma.gl/webgpu": "npm:9.0.0-beta.5"
"@mdx-js/react": "npm:^3.0.0"
babel-plugin-styled-components: "npm:^2.0.0"
clsx: "npm:^1.1.1"
Expand Down

0 comments on commit 1056710

Please sign in to comment.