@@ -339,6 +339,54 @@ var LibraryWebGPU = {
339339 return desc ;
340340 } ,
341341
342+ fillLimitStruct : ( limits , supportedLimitsOutPtr ) = > {
343+ var limitsOutPtr = supportedLimitsOutPtr + { { { C_STRUCTS . WGPUSupportedLimits . limits } } } ;
344+
345+ function setLimitValueU32 ( name , limitOffset ) {
346+ var limitValue = limits [ name ] ;
347+ { { { makeSetValue ( 'limitsOutPtr' , 'limitOffset' , 'limitValue' , 'i32' ) } } } ;
348+ }
349+ function setLimitValueU64 ( name , limitOffset ) {
350+ var limitValue = limits [ name ] ;
351+ { { { makeSetValue ( 'limitsOutPtr' , 'limitOffset' , 'limitValue' , 'i64' ) } } } ;
352+ }
353+
354+ setLimitValueU32 ( 'maxTextureDimension1D' , { { { C_STRUCTS . WGPULimits . maxTextureDimension1D } } } ) ;
355+ setLimitValueU32 ( 'maxTextureDimension2D' , { { { C_STRUCTS . WGPULimits . maxTextureDimension2D } } } ) ;
356+ setLimitValueU32 ( 'maxTextureDimension3D' , { { { C_STRUCTS . WGPULimits . maxTextureDimension3D } } } ) ;
357+ setLimitValueU32 ( 'maxTextureArrayLayers' , { { { C_STRUCTS . WGPULimits . maxTextureArrayLayers } } } ) ;
358+ setLimitValueU32 ( 'maxBindGroups' , { { { C_STRUCTS . WGPULimits . maxBindGroups } } } ) ;
359+ setLimitValueU32 ( 'maxBindGroupsPlusVertexBuffers' , { { { C_STRUCTS . WGPULimits . maxBindGroupsPlusVertexBuffers } } } ) ;
360+ setLimitValueU32 ( 'maxBindingsPerBindGroup' , { { { C_STRUCTS . WGPULimits . maxBindingsPerBindGroup } } } ) ;
361+ setLimitValueU32 ( 'maxDynamicUniformBuffersPerPipelineLayout' , { { { C_STRUCTS . WGPULimits . maxDynamicUniformBuffersPerPipelineLayout } } } ) ;
362+ setLimitValueU32 ( 'maxDynamicStorageBuffersPerPipelineLayout' , { { { C_STRUCTS . WGPULimits . maxDynamicStorageBuffersPerPipelineLayout } } } ) ;
363+ setLimitValueU32 ( 'maxSampledTexturesPerShaderStage' , { { { C_STRUCTS . WGPULimits . maxSampledTexturesPerShaderStage } } } ) ;
364+ setLimitValueU32 ( 'maxSamplersPerShaderStage' , { { { C_STRUCTS . WGPULimits . maxSamplersPerShaderStage } } } ) ;
365+ setLimitValueU32 ( 'maxStorageBuffersPerShaderStage' , { { { C_STRUCTS . WGPULimits . maxStorageBuffersPerShaderStage } } } ) ;
366+ setLimitValueU32 ( 'maxStorageTexturesPerShaderStage' , { { { C_STRUCTS . WGPULimits . maxStorageTexturesPerShaderStage } } } ) ;
367+ setLimitValueU32 ( 'maxUniformBuffersPerShaderStage' , { { { C_STRUCTS . WGPULimits . maxUniformBuffersPerShaderStage } } } ) ;
368+ setLimitValueU32 ( 'minUniformBufferOffsetAlignment' , { { { C_STRUCTS . WGPULimits . minUniformBufferOffsetAlignment } } } ) ;
369+ setLimitValueU32 ( 'minStorageBufferOffsetAlignment' , { { { C_STRUCTS . WGPULimits . minStorageBufferOffsetAlignment } } } ) ;
370+
371+ setLimitValueU64 ( 'maxUniformBufferBindingSize' , { { { C_STRUCTS . WGPULimits . maxUniformBufferBindingSize } } } ) ;
372+ setLimitValueU64 ( 'maxStorageBufferBindingSize' , { { { C_STRUCTS . WGPULimits . maxStorageBufferBindingSize } } } ) ;
373+
374+ setLimitValueU32 ( 'maxVertexBuffers' , { { { C_STRUCTS . WGPULimits . maxVertexBuffers } } } ) ;
375+ setLimitValueU32 ( 'maxBufferSize' , { { { C_STRUCTS . WGPULimits . maxBufferSize } } } ) ;
376+ setLimitValueU32 ( 'maxVertexAttributes' , { { { C_STRUCTS . WGPULimits . maxVertexAttributes } } } ) ;
377+ setLimitValueU32 ( 'maxVertexBufferArrayStride' , { { { C_STRUCTS . WGPULimits . maxVertexBufferArrayStride } } } ) ;
378+ setLimitValueU32 ( 'maxInterStageShaderComponents' , { { { C_STRUCTS . WGPULimits . maxInterStageShaderComponents } } } ) ;
379+ setLimitValueU32 ( 'maxInterStageShaderVariables' , { { { C_STRUCTS . WGPULimits . maxInterStageShaderVariables } } } ) ;
380+ setLimitValueU32 ( 'maxColorAttachments' , { { { C_STRUCTS . WGPULimits . maxColorAttachments } } } ) ;
381+ setLimitValueU32 ( 'maxColorAttachmentBytesPerSample' , { { { C_STRUCTS . WGPULimits . maxColorAttachmentBytesPerSample } } } ) ;
382+ setLimitValueU32 ( 'maxComputeWorkgroupStorageSize' , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupStorageSize } } } ) ;
383+ setLimitValueU32 ( 'maxComputeInvocationsPerWorkgroup' , { { { C_STRUCTS . WGPULimits . maxComputeInvocationsPerWorkgroup } } } ) ;
384+ setLimitValueU32 ( 'maxComputeWorkgroupSizeX' , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupSizeX } } } ) ;
385+ setLimitValueU32 ( 'maxComputeWorkgroupSizeY' , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupSizeY } } } ) ;
386+ setLimitValueU32 ( 'maxComputeWorkgroupSizeZ' , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupSizeZ } } } ) ;
387+ setLimitValueU32 ( 'maxComputeWorkgroupsPerDimension' , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupsPerDimension } } } ) ;
388+ } ,
389+
342390 // Map from enum string back to enum number, for callbacks.
343391 Int_BufferMapState : {
344392 'unmapped ': 0 ,
@@ -768,50 +816,7 @@ var LibraryWebGPU = {
768816
769817 wgpuDeviceGetLimits : ( deviceId , limitsOutPtr ) = > {
770818 var device = WebGPU . mgrDevice . objects [ deviceId ] . object ;
771- var limitsPtr = { { { C_STRUCTS . WGPUSupportedLimits . limits } } } ;
772- function setLimitValueU32 ( name , limitOffset ) {
773- var limitValue = device . limits [ name ] ;
774- { { { makeSetValue ( 'limitsOutPtr' , 'limitsPtr + limitOffset' , 'limitValue' , 'i32' ) } } } ;
775- }
776- function setLimitValueU64 ( name , limitOffset ) {
777- var limitValue = device . limits [ name ] ;
778- { { { makeSetValue ( 'limitsOutPtr' , 'limitsPtr + limitOffset' , 'limitValue' , 'i64' ) } } } ;
779- }
780-
781- setLimitValueU32 ( 'maxTextureDimension1D' , { { { C_STRUCTS . WGPULimits . maxTextureDimension1D } } } ) ;
782- setLimitValueU32 ( 'maxTextureDimension2D' , { { { C_STRUCTS . WGPULimits . maxTextureDimension2D } } } ) ;
783- setLimitValueU32 ( 'maxTextureDimension3D' , { { { C_STRUCTS . WGPULimits . maxTextureDimension3D } } } ) ;
784- setLimitValueU32 ( 'maxTextureArrayLayers' , { { { C_STRUCTS . WGPULimits . maxTextureArrayLayers } } } ) ;
785- setLimitValueU32 ( 'maxBindGroups' , { { { C_STRUCTS . WGPULimits . maxBindGroups } } } ) ;
786- setLimitValueU32 ( 'maxBindGroupsPlusVertexBuffers' , { { { C_STRUCTS . WGPULimits . maxBindGroupsPlusVertexBuffers } } } ) ;
787- setLimitValueU32 ( 'maxBindingsPerBindGroup' , { { { C_STRUCTS . WGPULimits . maxBindingsPerBindGroup } } } ) ;
788- setLimitValueU32 ( 'maxDynamicUniformBuffersPerPipelineLayout' , { { { C_STRUCTS . WGPULimits . maxDynamicUniformBuffersPerPipelineLayout } } } ) ;
789- setLimitValueU32 ( 'maxDynamicStorageBuffersPerPipelineLayout' , { { { C_STRUCTS . WGPULimits . maxDynamicStorageBuffersPerPipelineLayout } } } ) ;
790- setLimitValueU32 ( 'maxSampledTexturesPerShaderStage' , { { { C_STRUCTS . WGPULimits . maxSampledTexturesPerShaderStage } } } ) ;
791- setLimitValueU32 ( 'maxSamplersPerShaderStage' , { { { C_STRUCTS . WGPULimits . maxSamplersPerShaderStage } } } ) ;
792- setLimitValueU32 ( 'maxStorageBuffersPerShaderStage' , { { { C_STRUCTS . WGPULimits . maxStorageBuffersPerShaderStage } } } ) ;
793- setLimitValueU32 ( 'maxStorageTexturesPerShaderStage' , { { { C_STRUCTS . WGPULimits . maxStorageTexturesPerShaderStage } } } ) ;
794- setLimitValueU32 ( 'maxUniformBuffersPerShaderStage' , { { { C_STRUCTS . WGPULimits . maxUniformBuffersPerShaderStage } } } ) ;
795- setLimitValueU32 ( 'minUniformBufferOffsetAlignment' , { { { C_STRUCTS . WGPULimits . minUniformBufferOffsetAlignment } } } ) ;
796- setLimitValueU32 ( 'minStorageBufferOffsetAlignment' , { { { C_STRUCTS . WGPULimits . minStorageBufferOffsetAlignment } } } ) ;
797-
798- setLimitValueU64 ( 'maxUniformBufferBindingSize' , { { { C_STRUCTS . WGPULimits . maxUniformBufferBindingSize } } } ) ;
799- setLimitValueU64 ( 'maxStorageBufferBindingSize' , { { { C_STRUCTS . WGPULimits . maxStorageBufferBindingSize } } } ) ;
800-
801- setLimitValueU32 ( 'maxVertexBuffers' , { { { C_STRUCTS . WGPULimits . maxVertexBuffers } } } ) ;
802- setLimitValueU32 ( 'maxBufferSize' , { { { C_STRUCTS . WGPULimits . maxBufferSize } } } ) ;
803- setLimitValueU32 ( 'maxVertexAttributes' , { { { C_STRUCTS . WGPULimits . maxVertexAttributes } } } ) ;
804- setLimitValueU32 ( 'maxVertexBufferArrayStride' , { { { C_STRUCTS . WGPULimits . maxVertexBufferArrayStride } } } ) ;
805- setLimitValueU32 ( 'maxInterStageShaderComponents' , { { { C_STRUCTS . WGPULimits . maxInterStageShaderComponents } } } ) ;
806- setLimitValueU32 ( 'maxInterStageShaderVariables' , { { { C_STRUCTS . WGPULimits . maxInterStageShaderVariables } } } ) ;
807- setLimitValueU32 ( 'maxColorAttachments' , { { { C_STRUCTS . WGPULimits . maxColorAttachments } } } ) ;
808- setLimitValueU32 ( 'maxColorAttachmentBytesPerSample' , { { { C_STRUCTS . WGPULimits . maxColorAttachmentBytesPerSample } } } ) ;
809- setLimitValueU32 ( 'maxComputeWorkgroupStorageSize' , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupStorageSize } } } ) ;
810- setLimitValueU32 ( 'maxComputeInvocationsPerWorkgroup' , { { { C_STRUCTS . WGPULimits . maxComputeInvocationsPerWorkgroup } } } ) ;
811- setLimitValueU32 ( 'maxComputeWorkgroupSizeX' , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupSizeX } } } ) ;
812- setLimitValueU32 ( 'maxComputeWorkgroupSizeY' , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupSizeY } } } ) ;
813- setLimitValueU32 ( 'maxComputeWorkgroupSizeZ' , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupSizeZ } } } ) ;
814- setLimitValueU32 ( 'maxComputeWorkgroupsPerDimension' , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupsPerDimension } } } ) ;
819+ WebGPU . fillLimitStruct ( device . limits , limitsOutPtr ) ;
815820 return 1 ;
816821 } ,
817822
@@ -2537,8 +2542,9 @@ var LibraryWebGPU = {
25372542 } ,
25382543
25392544 wgpuAdapterGetLimits : ( adapterId , limitsOutPtr ) = > {
2540- abort ( 'TODO: wgpuAdapterGetLimits unimplemented' ) ;
2541- return 0 ;
2545+ var adapter = WebGPU . mgrAdapter . get ( adapterId ) ;
2546+ WebGPU . fillLimitStruct ( adapter . limits , limitsOutPtr ) ;
2547+ return 1 ;
25422548 } ,
25432549
25442550 wgpuAdapterHasFeature : ( adapterId , featureEnumValue ) => {
@@ -2599,11 +2605,13 @@ var LibraryWebGPU = {
25992605 setLimitU64IfDefined ( "maxUniformBufferBindingSize" , { { { C_STRUCTS . WGPULimits . maxUniformBufferBindingSize } } } ) ;
26002606 setLimitU64IfDefined ( "maxStorageBufferBindingSize" , { { { C_STRUCTS . WGPULimits . maxStorageBufferBindingSize } } } ) ;
26012607 setLimitU32IfDefined ( "maxVertexBuffers" , { { { C_STRUCTS . WGPULimits . maxVertexBuffers } } } ) ;
2608+ setLimitU32IfDefined ( "maxBufferSize" , { { { C_STRUCTS . WGPULimits . maxBufferSize } } } ) ;
26022609 setLimitU32IfDefined ( "maxVertexAttributes" , { { { C_STRUCTS . WGPULimits . maxVertexAttributes } } } ) ;
26032610 setLimitU32IfDefined ( "maxVertexBufferArrayStride" , { { { C_STRUCTS . WGPULimits . maxVertexBufferArrayStride } } } ) ;
26042611 setLimitU32IfDefined ( "maxInterStageShaderComponents" , { { { C_STRUCTS . WGPULimits . maxInterStageShaderComponents } } } ) ;
26052612 setLimitU32IfDefined ( "maxInterStageShaderVariables" , { { { C_STRUCTS . WGPULimits . maxInterStageShaderVariables } } } ) ;
26062613 setLimitU32IfDefined ( "maxColorAttachments" , { { { C_STRUCTS . WGPULimits . maxColorAttachments } } } ) ;
2614+ setLimitU32IfDefined ( "maxColorAttachmentBytesPerSample" , { { { C_STRUCTS . WGPULimits . maxColorAttachmentBytesPerSample } } } ) ;
26072615 setLimitU32IfDefined ( "maxComputeWorkgroupStorageSize" , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupStorageSize } } } ) ;
26082616 setLimitU32IfDefined ( "maxComputeInvocationsPerWorkgroup" , { { { C_STRUCTS . WGPULimits . maxComputeInvocationsPerWorkgroup } } } ) ;
26092617 setLimitU32IfDefined ( "maxComputeWorkgroupSizeX" , { { { C_STRUCTS . WGPULimits . maxComputeWorkgroupSizeX } } } ) ;
0 commit comments