Skip to content
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
14 changes: 14 additions & 0 deletions src/platform/graphics/graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,19 @@ class GraphicsDevice extends EventHandler {
*/
supportsLinearIndexing = false;

/**
* True if the device supports the WGSL `pointer_composite_access` language feature, which
* provides syntactic sugar for dereferencing pointers to composite types: `p.field` and
* `p[i]` may be written instead of `(*p).field` and `(*p)[i]`. The
* `requires pointer_composite_access;` directive is automatically injected into WGSL
* shaders when this feature is available, and the shader define
* `CAPS_POINTER_COMPOSITE_ACCESS` is set for conditional compilation.
*
* @type {boolean}
* @readonly
*/
supportsPointerCompositeAccess = false;

/**
* True if the device supports the WGSL `unrestricted_pointer_parameters` language feature,
* which allows passing pointers in the `storage`, `uniform`, and `workgroup` address spaces
Expand Down Expand Up @@ -697,6 +710,7 @@ class GraphicsDevice extends EventHandler {
if (this.supportsSubgroupId) capsDefines.set('CAPS_SUBGROUP_ID', '');
if (this.supportsLinearIndexing) capsDefines.set('CAPS_LINEAR_INDEXING', '');
if (this.supportsUnrestrictedPointerParameters) capsDefines.set('CAPS_UNRESTRICTED_POINTER_PARAMETERS', '');
if (this.supportsPointerCompositeAccess) capsDefines.set('CAPS_POINTER_COMPOSITE_ACCESS', '');
if (this.supportsStorageTextureRead) capsDefines.set('CAPS_STORAGE_TEXTURE_READ', '');

// Platform defines
Expand Down
3 changes: 3 additions & 0 deletions src/platform/graphics/shader-definition-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ class ShaderDefinitionUtils {
if (device.supportsUnrestrictedPointerParameters) {
code += 'requires unrestricted_pointer_parameters;\n';
}
if (device.supportsPointerCompositeAccess) {
code += 'requires pointer_composite_access;\n';
}
return code;
}

Expand Down
1 change: 1 addition & 0 deletions src/platform/graphics/webgpu/webgpu-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
this.supportsSubgroupId = wgslFeatures?.has('subgroup_id');
this.supportsLinearIndexing = wgslFeatures?.has('linear_indexing');
this.supportsUnrestrictedPointerParameters = wgslFeatures?.has('unrestricted_pointer_parameters');
this.supportsPointerCompositeAccess = wgslFeatures?.has('pointer_composite_access');

this.initCapsDefines();
}
Expand Down