@@ -322,7 +322,9 @@ export type PerStageBindingLimitClass =
322
322
| 'storageBuf'
323
323
| 'sampler'
324
324
| 'sampledTex'
325
- | 'storageTex' ;
325
+ | 'readonlyStorageTex'
326
+ | 'writeonlyStorageTex'
327
+ | 'readwriteStorageTex' ;
326
328
/**
327
329
* Classes of `PerPipelineLayout` binding limits. Two bindings with the same class
328
330
* count toward the same `PerPipelineLayout` limit(s) in the spec (if any).
@@ -337,7 +339,9 @@ export type ValidBindableResource =
337
339
| 'compareSamp'
338
340
| 'sampledTex'
339
341
| 'sampledTexMS'
340
- | 'storageTex' ;
342
+ | 'readonlyStorageTex'
343
+ | 'writeonlyStorageTex'
344
+ | 'readwriteStorageTex' ;
341
345
type ErrorBindableResource = 'errorBuf' | 'errorSamp' | 'errorTex' ;
342
346
343
347
/**
@@ -353,7 +357,9 @@ export const kBindableResources = [
353
357
'compareSamp' ,
354
358
'sampledTex' ,
355
359
'sampledTexMS' ,
356
- 'storageTex' ,
360
+ 'readonlyStorageTex' ,
361
+ 'writeonlyStorageTex' ,
362
+ 'readwriteStorageTex' ,
357
363
'errorBuf' ,
358
364
'errorSamp' ,
359
365
'errorTex' ,
@@ -376,11 +382,13 @@ export const kPerStageBindingLimits: {
376
382
} ;
377
383
} =
378
384
/* 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' , } ,
384
392
} ;
385
393
386
394
/**
@@ -398,11 +406,13 @@ export const kPerPipelineBindingLimits: {
398
406
} ;
399
407
} =
400
408
/* 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 : '' , } ,
406
416
} ;
407
417
408
418
interface BindingKindInfo {
@@ -416,14 +426,16 @@ const kBindingKind: {
416
426
readonly [ k in ValidBindableResource ] : BindingKindInfo ;
417
427
} =
418
428
/* 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 , } ,
427
439
} ;
428
440
429
441
// Binding type info
@@ -483,11 +495,27 @@ assertTypeTrue<TypeEqual<GPUTextureSampleType, (typeof kTextureSampleTypes)[numb
483
495
484
496
/** Binding type info (including class limits) for the specified GPUStorageTextureBindingLayout. */
485
497
export 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
+ }
491
519
}
492
520
/** List of all GPUStorageTextureAccess values. */
493
521
export const kStorageTextureAccessValues = [ 'read-only' , 'read-write' , 'write-only' ] as const ;
@@ -539,8 +567,10 @@ export function samplerBindingEntries(includeUndefined: boolean): readonly BGLEn
539
567
*/
540
568
export function textureBindingEntries ( includeUndefined : boolean ) : readonly BGLEntry [ ] {
541
569
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' } } ,
544
574
{ texture : { multisampled : true , sampleType : 'unfilterable-float' } } ,
545
575
] as const ;
546
576
}
@@ -549,34 +579,29 @@ export function textureBindingEntries(includeUndefined: boolean): readonly BGLEn
549
579
*
550
580
* Note: Generates different `access` options, but not `format` or `viewDimension` options.
551
581
*/
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 [ ] {
560
583
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' } } ,
563
587
] as const ;
564
588
}
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
+ }
565
593
/**
566
594
* Generate a list of possible BGLEntry values of every type, but not variants with different:
567
595
* - buffer.hasDynamicOffset
568
596
* - texture.sampleType
569
597
* - texture.viewDimension
570
598
* - storageTexture.viewDimension
571
599
*/
572
- export function allBindingEntries (
573
- includeUndefined : boolean ,
574
- storageTextureFormat : GPUTextureFormat = 'rgba8unorm'
575
- ) : readonly BGLEntry [ ] {
600
+ export function allBindingEntries ( includeUndefined : boolean ) : readonly BGLEntry [ ] {
576
601
return [
577
602
...bufferBindingEntries ( includeUndefined ) ,
578
603
...samplerBindingEntries ( includeUndefined ) ,
579
- ...sampledAndStorageBindingEntries ( includeUndefined , storageTextureFormat ) ,
604
+ ...sampledAndStorageBindingEntries ( includeUndefined ) ,
580
605
] as const ;
581
606
}
582
607
0 commit comments