-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move limits from capability_info.ts to limits.ts
This is because navigator_gpu.ts needs the limits.
- Loading branch information
Showing
14 changed files
with
122 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* eslint-disable no-sparse-arrays */ | ||
|
||
import { keysOf, makeTableRenameAndFilter } from './data_tables.js'; | ||
|
||
export const kMaxUnsignedLongValue = 4294967295; | ||
export const kMaxUnsignedLongLongValue = Number.MAX_SAFE_INTEGER; | ||
|
||
/** Info for each entry of GPUSupportedLimits */ | ||
const [kLimitInfoKeys, kLimitInfoDefaults, kLimitInfoData] = | ||
/* prettier-ignore */ [ | ||
[ 'class', 'core', 'compatibility', 'maximumValue'] as const, | ||
[ 'maximum', , , kMaxUnsignedLongValue] as const, { | ||
'maxTextureDimension1D': [ , 8192, 4096, ], | ||
'maxTextureDimension2D': [ , 8192, 4096, ], | ||
'maxTextureDimension3D': [ , 2048, 1024, ], | ||
'maxTextureArrayLayers': [ , 256, 256, ], | ||
|
||
'maxBindGroups': [ , 4, 4, ], | ||
'maxBindGroupsPlusVertexBuffers': [ , 24, 24, ], | ||
'maxBindingsPerBindGroup': [ , 1000, 1000, ], | ||
'maxDynamicUniformBuffersPerPipelineLayout': [ , 8, 8, ], | ||
'maxDynamicStorageBuffersPerPipelineLayout': [ , 4, 4, ], | ||
'maxSampledTexturesPerShaderStage': [ , 16, 16, ], | ||
'maxSamplersPerShaderStage': [ , 16, 16, ], | ||
'maxStorageBuffersPerShaderStage': [ , 8, 4, ], | ||
'maxStorageTexturesPerShaderStage': [ , 4, 4, ], | ||
'maxUniformBuffersPerShaderStage': [ , 12, 12, ], | ||
|
||
'maxUniformBufferBindingSize': [ , 65536, 16384, kMaxUnsignedLongLongValue], | ||
'maxStorageBufferBindingSize': [ , 134217728, 134217728, kMaxUnsignedLongLongValue], | ||
'minUniformBufferOffsetAlignment': ['alignment', 256, 256, ], | ||
'minStorageBufferOffsetAlignment': ['alignment', 256, 256, ], | ||
|
||
'maxVertexBuffers': [ , 8, 8, ], | ||
'maxBufferSize': [ , 268435456, 268435456, kMaxUnsignedLongLongValue], | ||
'maxVertexAttributes': [ , 16, 16, ], | ||
'maxVertexBufferArrayStride': [ , 2048, 2048, ], | ||
'maxInterStageShaderVariables': [ , 16, 15, ], | ||
|
||
'maxColorAttachments': [ , 8, 4, ], | ||
'maxColorAttachmentBytesPerSample': [ , 32, 32, ], | ||
|
||
'maxComputeWorkgroupStorageSize': [ , 16384, 16384, ], | ||
'maxComputeInvocationsPerWorkgroup': [ , 256, 128, ], | ||
'maxComputeWorkgroupSizeX': [ , 256, 128, ], | ||
'maxComputeWorkgroupSizeY': [ , 256, 128, ], | ||
'maxComputeWorkgroupSizeZ': [ , 64, 64, ], | ||
'maxComputeWorkgroupsPerDimension': [ , 65535, 65535, ], | ||
} as const]; | ||
|
||
/** | ||
* Feature levels corresponding to core WebGPU and WebGPU | ||
* in compatibility mode. They can be passed to | ||
* getDefaultLimits though if you have access to an adapter | ||
* it's preferred to use getDefaultLimitsForAdapter. | ||
*/ | ||
export const kFeatureLevels = ['core', 'compatibility'] as const; | ||
export type FeatureLevel = (typeof kFeatureLevels)[number]; | ||
|
||
const kLimitKeys = ['class', 'default', 'maximumValue'] as const; | ||
|
||
const kLimitInfoCore = makeTableRenameAndFilter( | ||
{ default: 'core' }, | ||
kLimitKeys, | ||
kLimitInfoKeys, | ||
kLimitInfoDefaults, | ||
kLimitInfoData | ||
); | ||
|
||
const kLimitInfoCompatibility = makeTableRenameAndFilter( | ||
{ default: 'compatibility' }, | ||
kLimitKeys, | ||
kLimitInfoKeys, | ||
kLimitInfoDefaults, | ||
kLimitInfoData | ||
); | ||
|
||
const kLimitInfos = { | ||
core: kLimitInfoCore, | ||
compatibility: kLimitInfoCompatibility, | ||
} as const; | ||
|
||
export const kLimitClasses = Object.fromEntries( | ||
Object.entries(kLimitInfoCore).map(([k, { class: c }]) => [k, c]) | ||
); | ||
|
||
export function getDefaultLimits(featureLevel: FeatureLevel) { | ||
return kLimitInfos[featureLevel]; | ||
} | ||
|
||
export function getDefaultLimitsForAdapter(adapter: GPUAdapter) { | ||
// MAINTENANCE_TODO: Remove casts when GPUAdapter IDL has isCompatibilityMode. | ||
return getDefaultLimits( | ||
(adapter as unknown as { isCompatibilityMode: boolean }).isCompatibilityMode | ||
? 'compatibility' | ||
: 'core' | ||
); | ||
} | ||
|
||
/** List of all entries of GPUSupportedLimits. */ | ||
export const kLimits = keysOf(kLimitInfoCore); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/webgpu/api/validation/capability_checks/limits/limit_utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters