@@ -322,7 +322,9 @@ export type PerStageBindingLimitClass =
322322 | 'storageBuf'
323323 | 'sampler'
324324 | 'sampledTex'
325- | 'storageTex' ;
325+ | 'readonlyStorageTex'
326+ | 'writeonlyStorageTex'
327+ | 'readwriteStorageTex' ;
326328/**
327329 * Classes of `PerPipelineLayout` binding limits. Two bindings with the same class
328330 * count toward the same `PerPipelineLayout` limit(s) in the spec (if any).
@@ -337,7 +339,9 @@ export type ValidBindableResource =
337339 | 'compareSamp'
338340 | 'sampledTex'
339341 | 'sampledTexMS'
340- | 'storageTex' ;
342+ | 'readonlyStorageTex'
343+ | 'writeonlyStorageTex'
344+ | 'readwriteStorageTex' ;
341345type ErrorBindableResource = 'errorBuf' | 'errorSamp' | 'errorTex' ;
342346
343347/**
@@ -353,7 +357,9 @@ export const kBindableResources = [
353357 'compareSamp' ,
354358 'sampledTex' ,
355359 'sampledTexMS' ,
356- 'storageTex' ,
360+ 'readonlyStorageTex' ,
361+ 'writeonlyStorageTex' ,
362+ 'readwriteStorageTex' ,
357363 'errorBuf' ,
358364 'errorSamp' ,
359365 'errorTex' ,
@@ -376,11 +382,13 @@ export const kPerStageBindingLimits: {
376382 } ;
377383} =
378384 /* prettier-ignore */ {
379- 'uniformBuf' : { class : 'uniformBuf' , maxLimit : 'maxUniformBuffersPerShaderStage' , } ,
380- 'storageBuf' : { class : 'storageBuf' , maxLimit : 'maxStorageBuffersPerShaderStage' , } ,
381- 'sampler' : { class : 'sampler' , maxLimit : 'maxSamplersPerShaderStage' , } ,
382- 'sampledTex' : { class : 'sampledTex' , maxLimit : 'maxSampledTexturesPerShaderStage' , } ,
383- 'storageTex' : { class : 'storageTex' , maxLimit : 'maxStorageTexturesPerShaderStage' , } ,
385+ 'uniformBuf' : { class : 'uniformBuf' , maxLimit : 'maxUniformBuffersPerShaderStage' , } ,
386+ 'storageBuf' : { class : 'storageBuf' , maxLimit : 'maxStorageBuffersPerShaderStage' , } ,
387+ 'sampler' : { class : 'sampler' , maxLimit : 'maxSamplersPerShaderStage' , } ,
388+ 'sampledTex' : { class : 'sampledTex' , maxLimit : 'maxSampledTexturesPerShaderStage' , } ,
389+ 'readonlyStorageTex' : { class : 'readonlyStorageTex' , maxLimit : 'maxStorageTexturesPerShaderStage' , } ,
390+ 'writeonlyStorageTex' : { class : 'writeonlyStorageTex' , maxLimit : 'maxStorageTexturesPerShaderStage' , } ,
391+ 'readwriteStorageTex' : { class : 'readwriteStorageTex' , maxLimit : 'maxStorageTexturesPerShaderStage' , } ,
384392} ;
385393
386394/**
@@ -398,11 +406,13 @@ export const kPerPipelineBindingLimits: {
398406 } ;
399407} =
400408 /* prettier-ignore */ {
401- 'uniformBuf' : { class : 'uniformBuf' , maxDynamicLimit : 'maxDynamicUniformBuffersPerPipelineLayout' , } ,
402- 'storageBuf' : { class : 'storageBuf' , maxDynamicLimit : 'maxDynamicStorageBuffersPerPipelineLayout' , } ,
403- 'sampler' : { class : 'sampler' , maxDynamicLimit : '' , } ,
404- 'sampledTex' : { class : 'sampledTex' , maxDynamicLimit : '' , } ,
405- 'storageTex' : { class : 'storageTex' , maxDynamicLimit : '' , } ,
409+ 'uniformBuf' : { class : 'uniformBuf' , maxDynamicLimit : 'maxDynamicUniformBuffersPerPipelineLayout' , } ,
410+ 'storageBuf' : { class : 'storageBuf' , maxDynamicLimit : 'maxDynamicStorageBuffersPerPipelineLayout' , } ,
411+ 'sampler' : { class : 'sampler' , maxDynamicLimit : '' , } ,
412+ 'sampledTex' : { class : 'sampledTex' , maxDynamicLimit : '' , } ,
413+ 'readonlyStorageTex' : { class : 'readonlyStorageTex' , maxDynamicLimit : '' , } ,
414+ 'writeonlyStorageTex' : { class : 'writeonlyStorageTex' , maxDynamicLimit : '' , } ,
415+ 'readwriteStorageTex' : { class : 'readwriteStorageTex' , maxDynamicLimit : '' , } ,
406416} ;
407417
408418interface BindingKindInfo {
@@ -416,14 +426,16 @@ const kBindingKind: {
416426 readonly [ k in ValidBindableResource ] : BindingKindInfo ;
417427} =
418428 /* prettier-ignore */ {
419- uniformBuf : { resource : 'uniformBuf' , perStageLimitClass : kPerStageBindingLimits . uniformBuf , perPipelineLimitClass : kPerPipelineBindingLimits . uniformBuf , } ,
420- storageBuf : { resource : 'storageBuf' , perStageLimitClass : kPerStageBindingLimits . storageBuf , perPipelineLimitClass : kPerPipelineBindingLimits . storageBuf , } ,
421- filtSamp : { resource : 'filtSamp' , perStageLimitClass : kPerStageBindingLimits . sampler , perPipelineLimitClass : kPerPipelineBindingLimits . sampler , } ,
422- nonFiltSamp : { resource : 'nonFiltSamp' , perStageLimitClass : kPerStageBindingLimits . sampler , perPipelineLimitClass : kPerPipelineBindingLimits . sampler , } ,
423- compareSamp : { resource : 'compareSamp' , perStageLimitClass : kPerStageBindingLimits . sampler , perPipelineLimitClass : kPerPipelineBindingLimits . sampler , } ,
424- sampledTex : { resource : 'sampledTex' , perStageLimitClass : kPerStageBindingLimits . sampledTex , perPipelineLimitClass : kPerPipelineBindingLimits . sampledTex , } ,
425- sampledTexMS : { resource : 'sampledTexMS' , perStageLimitClass : kPerStageBindingLimits . sampledTex , perPipelineLimitClass : kPerPipelineBindingLimits . sampledTex , } ,
426- storageTex : { resource : 'storageTex' , perStageLimitClass : kPerStageBindingLimits . storageTex , perPipelineLimitClass : kPerPipelineBindingLimits . storageTex , } ,
429+ uniformBuf : { resource : 'uniformBuf' , perStageLimitClass : kPerStageBindingLimits . uniformBuf , perPipelineLimitClass : kPerPipelineBindingLimits . uniformBuf , } ,
430+ storageBuf : { resource : 'storageBuf' , perStageLimitClass : kPerStageBindingLimits . storageBuf , perPipelineLimitClass : kPerPipelineBindingLimits . storageBuf , } ,
431+ filtSamp : { resource : 'filtSamp' , perStageLimitClass : kPerStageBindingLimits . sampler , perPipelineLimitClass : kPerPipelineBindingLimits . sampler , } ,
432+ nonFiltSamp : { resource : 'nonFiltSamp' , perStageLimitClass : kPerStageBindingLimits . sampler , perPipelineLimitClass : kPerPipelineBindingLimits . sampler , } ,
433+ compareSamp : { resource : 'compareSamp' , perStageLimitClass : kPerStageBindingLimits . sampler , perPipelineLimitClass : kPerPipelineBindingLimits . sampler , } ,
434+ sampledTex : { resource : 'sampledTex' , perStageLimitClass : kPerStageBindingLimits . sampledTex , perPipelineLimitClass : kPerPipelineBindingLimits . sampledTex , } ,
435+ sampledTexMS : { resource : 'sampledTexMS' , perStageLimitClass : kPerStageBindingLimits . sampledTex , perPipelineLimitClass : kPerPipelineBindingLimits . sampledTex , } ,
436+ readonlyStorageTex : { resource : 'readonlyStorageTex' , perStageLimitClass : kPerStageBindingLimits . readonlyStorageTex , perPipelineLimitClass : kPerPipelineBindingLimits . readonlyStorageTex , } ,
437+ writeonlyStorageTex : { resource : 'writeonlyStorageTex' , perStageLimitClass : kPerStageBindingLimits . writeonlyStorageTex , perPipelineLimitClass : kPerPipelineBindingLimits . writeonlyStorageTex , } ,
438+ readwriteStorageTex : { resource : 'readwriteStorageTex' , perStageLimitClass : kPerStageBindingLimits . readwriteStorageTex , perPipelineLimitClass : kPerPipelineBindingLimits . readwriteStorageTex , } ,
427439} ;
428440
429441// Binding type info
@@ -483,11 +495,27 @@ assertTypeTrue<TypeEqual<GPUTextureSampleType, (typeof kTextureSampleTypes)[numb
483495
484496/** Binding type info (including class limits) for the specified GPUStorageTextureBindingLayout. */
485497export function storageTextureBindingTypeInfo ( d : GPUStorageTextureBindingLayout ) {
486- return {
487- usage : GPUConst . TextureUsage . STORAGE_BINDING ,
488- ...kBindingKind . storageTex ,
489- ...kValidStagesStorageWrite ,
490- } ;
498+ switch ( d . access ) {
499+ case undefined :
500+ case 'write-only' :
501+ return {
502+ usage : GPUConst . TextureUsage . STORAGE_BINDING ,
503+ ...kBindingKind . writeonlyStorageTex ,
504+ ...kValidStagesStorageWrite ,
505+ } ;
506+ case 'read-only' :
507+ return {
508+ usage : GPUConst . TextureUsage . STORAGE_BINDING ,
509+ ...kBindingKind . readonlyStorageTex ,
510+ ...kValidStagesAll ,
511+ } ;
512+ case 'read-write' :
513+ return {
514+ usage : GPUConst . TextureUsage . STORAGE_BINDING ,
515+ ...kBindingKind . readwriteStorageTex ,
516+ ...kValidStagesStorageWrite ,
517+ } ;
518+ }
491519}
492520/** List of all GPUStorageTextureAccess values. */
493521export const kStorageTextureAccessValues = [ 'read-only' , 'read-write' , 'write-only' ] as const ;
@@ -539,8 +567,10 @@ export function samplerBindingEntries(includeUndefined: boolean): readonly BGLEn
539567 */
540568export function textureBindingEntries ( includeUndefined : boolean ) : readonly BGLEntry [ ] {
541569 return [
542- ...( includeUndefined ? [ { texture : { multisampled : undefined } } ] : [ ] ) ,
543- { texture : { multisampled : false } } ,
570+ ...( includeUndefined
571+ ? [ { texture : { multisampled : undefined , sampleType : 'unfilterable-float' } } as const ]
572+ : [ ] ) ,
573+ { texture : { multisampled : false , sampleType : 'unfilterable-float' } } ,
544574 { texture : { multisampled : true , sampleType : 'unfilterable-float' } } ,
545575 ] as const ;
546576}
@@ -549,34 +579,29 @@ export function textureBindingEntries(includeUndefined: boolean): readonly BGLEn
549579 *
550580 * Note: Generates different `access` options, but not `format` or `viewDimension` options.
551581 */
552- export function storageTextureBindingEntries ( format : GPUTextureFormat ) : readonly BGLEntry [ ] {
553- return [ { storageTexture : { access : 'write-only' , format } } ] as const ;
554- }
555- /** Generate a list of possible texture-or-storageTexture-typed BGLEntry values. */
556- export function sampledAndStorageBindingEntries (
557- includeUndefined : boolean ,
558- storageTextureFormat : GPUTextureFormat = 'rgba8unorm'
559- ) : readonly BGLEntry [ ] {
582+ export function storageTextureBindingEntries ( ) : readonly BGLEntry [ ] {
560583 return [
561- ...textureBindingEntries ( includeUndefined ) ,
562- ...storageTextureBindingEntries ( storageTextureFormat ) ,
584+ { storageTexture : { access : 'write-only' , format : 'r32float' } } ,
585+ { storageTexture : { access : 'read-only' , format : 'r32float' } } ,
586+ { storageTexture : { access : 'read-write' , format : 'r32float' } } ,
563587 ] as const ;
564588}
589+ /** Generate a list of possible texture-or-storageTexture-typed BGLEntry values. */
590+ export function sampledAndStorageBindingEntries ( includeUndefined : boolean ) : readonly BGLEntry [ ] {
591+ return [ ...textureBindingEntries ( includeUndefined ) , ...storageTextureBindingEntries ( ) ] as const ;
592+ }
565593/**
566594 * Generate a list of possible BGLEntry values of every type, but not variants with different:
567595 * - buffer.hasDynamicOffset
568596 * - texture.sampleType
569597 * - texture.viewDimension
570598 * - storageTexture.viewDimension
571599 */
572- export function allBindingEntries (
573- includeUndefined : boolean ,
574- storageTextureFormat : GPUTextureFormat = 'rgba8unorm'
575- ) : readonly BGLEntry [ ] {
600+ export function allBindingEntries ( includeUndefined : boolean ) : readonly BGLEntry [ ] {
576601 return [
577602 ...bufferBindingEntries ( includeUndefined ) ,
578603 ...samplerBindingEntries ( includeUndefined ) ,
579- ...sampledAndStorageBindingEntries ( includeUndefined , storageTextureFormat ) ,
604+ ...sampledAndStorageBindingEntries ( includeUndefined ) ,
580605 ] as const ;
581606}
582607
0 commit comments