@@ -45,14 +45,10 @@ module Web.GPU.Device
4545
4646import Prelude
4747
48- import Data.Reflectable (class Reflectable , reflectType )
4948import Data.Set as Set
5049import Effect (Effect )
5150import Foreign (Foreign )
5251import Foreign.Object (Object )
53- import Prim.Int (class Compare )
54- import Prim.Ordering (LT )
55- import Type.Proxy (Proxy )
5652import Web.GPU.GPUAddressMode (GPUAddressMode )
5753import Web.GPU.GPUBlendFactor (GPUBlendFactor )
5854import Web.GPU.GPUBlendOperation (GPUBlendOperation )
@@ -82,9 +78,9 @@ import Web.GPU.GPUTextureViewDimension (GPUTextureViewDimension)
8278import Web.GPU.GPUVertexFormat (GPUVertexFormat )
8379import Web.GPU.GPUVertexStepMode (GPUVertexStepMode )
8480import Web.GPU.Internal.ConvertibleOptions (class ConvertOption , class ConvertOptionsWithDefaults , convertOptionsWithDefaults )
85- import Web.GPU.Internal.Types (GPUBindGroup , GPUBindGroupDescriptor , GPUBindGroupLayout , GPUBindGroupLayoutDescriptor , GPUBindGroupLayoutEntry , GPUBuffer , GPUBufferBindingLayout , GPUCommandEncoder , GPUComputePipeline , GPUDevice , GPUExternalTexture , GPUExternalTextureBindingLayout , GPUPipelineLayout , GPUPipelineLayoutDescriptor , GPUQuerySet , GPUQueue , GPURenderPipeline , GPUSampler , GPUSamplerBindingLayout , GPUShaderModule , GPUShaderModuleCompilationHint , GPUStorageTextureBindingLayout , GPUTexture , GPUTextureBindingLayout )
81+ import Web.GPU.Internal.Types (GPUBindGroup , GPUBindGroupEntry , GPUBindGroupLayout , GPUBindGroupLayoutEntry , GPUBuffer , GPUCommandEncoder , GPUComputePipeline , GPUDevice , GPUExternalTexture , GPUPipelineLayout , GPUQuerySet , GPUQueue , GPURenderPipeline , GPUSampler , GPUShaderModule , GPUShaderModuleCompilationHint , GPUTexture )
8682import Web.GPU.Internal.Undefinable (Undefinable , defined , undefined )
87- import Web.GPU.Internal.Unsigned (GPUIndex32 , GPUIntegerCoordinate , GPUSampleMask , GPUSize32 , GPUSize64 , GPUStencilValue , UnsignedShort , GPUDepthBias )
83+ import Web.GPU.Internal.Unsigned (GPUDepthBias , GPUIntegerCoordinate , GPUSampleMask , GPUSize32 , GPUSize64 , GPUStencilValue , UnsignedShort , GPUIndex32 )
8884import Web.GPU.PredefinedColorSpace (PredefinedColorSpace )
8985import Web.HTML (HTMLVideoElement )
9086import Web.Promise (Promise )
@@ -329,21 +325,21 @@ importExternalTexture gpuDevice provided = importExternalTextureImpl gpuDevice a
329325
330326-- createBindGroupLayout
331327
332- bindingToGPUIndex32 :: forall i . Reflectable i Int => Proxy i -> GPUIndex32
333- bindingToGPUIndex32 = reflectType
334-
335328type GPUBindGroupLayoutOptions =
336329 { binding :: GPUIndex32
337330 , visibility :: GPUShaderStage
338331 }
339332
340- foreign import createBindGroupLayoutImpl :: forall entries . GPUDevice -> GPUBindGroupLayoutDescriptor entries -> Effect (GPUBindGroupLayout entries )
333+ type GPUBindGroupLayoutDescriptor =
334+ ( entries :: Array GPUBindGroupLayoutEntry
335+ )
336+
337+ foreign import createBindGroupLayoutImpl :: GPUDevice -> { | GPUBindGroupLayoutDescriptor } -> Effect GPUBindGroupLayout
341338
342339createBindGroupLayout
343- :: forall entries
344- . GPUDevice
345- -> GPUBindGroupLayoutDescriptor entries
346- -> Effect (GPUBindGroupLayout entries )
340+ :: GPUDevice
341+ -> { | GPUBindGroupLayoutDescriptor }
342+ -> Effect GPUBindGroupLayout
347343createBindGroupLayout = createBindGroupLayoutImpl
348344
349345-- -- bindGroupLayoutEntryForBuffer
@@ -375,18 +371,16 @@ instance ConvertOption BufferBindingLayout "hasDynamicOffset" Boolean (Undefinab
375371instance ConvertOption BufferBindingLayout " minBindingSize" GPUSize64 (Undefinable GPUSize64 ) where
376372 convertOption _ _ = defined
377373
378- foreign import bindGroupLayoutEntryForBufferImpl :: forall i g . GPUBindGroupLayoutOptions -> { | GPUBufferBindingLayoutAll } -> GPUBindGroupLayoutEntry i g
374+ foreign import bindGroupLayoutEntryForBufferImpl :: GPUBindGroupLayoutOptions -> { | GPUBufferBindingLayoutAll } -> GPUBindGroupLayoutEntry
379375
380376bindGroupLayoutEntryForBuffer
381- :: forall provided i
377+ :: forall provided
382378 . ConvertOptionsWithDefaults BufferBindingLayout { | GPUBufferBindingLayoutOptional } { | provided } { | GPUBufferBindingLayoutAll }
383- => Reflectable i Int
384- => Compare (-1) i LT
385- => Proxy i
379+ => GPUIndex32
386380 -> GPUShaderStage
387381 -> { | provided }
388- -> GPUBindGroupLayoutEntry i GPUBufferBindingLayout
389- bindGroupLayoutEntryForBuffer binding visibility provided = bindGroupLayoutEntryForBufferImpl { binding: bindingToGPUIndex32 binding , visibility } all
382+ -> GPUBindGroupLayoutEntry
383+ bindGroupLayoutEntryForBuffer binding visibility provided = bindGroupLayoutEntryForBufferImpl { binding, visibility } all
390384 where
391385 all :: { | GPUBufferBindingLayoutAll }
392386 all = convertOptionsWithDefaults BufferBindingLayout defaultGPUBufferBindingLayoutOptions provided
@@ -410,18 +404,16 @@ data SamplerBindingLayout = SamplerBindingLayout
410404instance ConvertOption SamplerBindingLayout " type" GPUSamplerBindingType (Undefinable GPUSamplerBindingType ) where
411405 convertOption _ _ = defined
412406
413- foreign import bindGroupLayoutEntryForSamplerImpl :: forall i g . GPUBindGroupLayoutOptions -> { | GPUSamplerBindingLayoutAll } -> GPUBindGroupLayoutEntry i g
407+ foreign import bindGroupLayoutEntryForSamplerImpl :: GPUBindGroupLayoutOptions -> { | GPUSamplerBindingLayoutAll } -> GPUBindGroupLayoutEntry
414408
415409bindGroupLayoutEntryForSampler
416- :: forall provided i
410+ :: forall provided
417411 . ConvertOptionsWithDefaults SamplerBindingLayout { | GPUSamplerBindingLayoutOptional } { | provided } { | GPUSamplerBindingLayoutAll }
418- => Reflectable i Int
419- => Compare (-1) i LT
420- => Proxy i
412+ => GPUIndex32
421413 -> GPUShaderStage
422414 -> { | provided }
423- -> GPUBindGroupLayoutEntry i GPUSamplerBindingLayout
424- bindGroupLayoutEntryForSampler binding visibility provided = bindGroupLayoutEntryForSamplerImpl { binding: bindingToGPUIndex32 binding , visibility } all
415+ -> GPUBindGroupLayoutEntry
416+ bindGroupLayoutEntryForSampler binding visibility provided = bindGroupLayoutEntryForSamplerImpl { binding, visibility } all
425417 where
426418 all :: { | GPUSamplerBindingLayoutAll }
427419 all = convertOptionsWithDefaults SamplerBindingLayout defaultGPUSamplerBindingLayoutOptions provided
@@ -455,18 +447,16 @@ instance ConvertOption TextureBindingLayout "viewDimension" GPUTextureViewDimens
455447instance ConvertOption TextureBindingLayout " multisampled" Boolean (Undefinable Boolean ) where
456448 convertOption _ _ = defined
457449
458- foreign import bindGroupLayoutEntryForTextureImpl :: forall i g . GPUBindGroupLayoutOptions -> { | GPUTextureBindingLayoutAll } -> GPUBindGroupLayoutEntry i g
450+ foreign import bindGroupLayoutEntryForTextureImpl :: GPUBindGroupLayoutOptions -> { | GPUTextureBindingLayoutAll } -> GPUBindGroupLayoutEntry
459451
460452bindGroupLayoutEntryForTexture
461- :: forall provided i
453+ :: forall provided
462454 . ConvertOptionsWithDefaults TextureBindingLayout { | GPUTextureBindingLayoutOptional } { | provided } { | GPUTextureBindingLayoutAll }
463- => Reflectable i Int
464- => Compare (-1) i LT
465- => Proxy i
455+ => GPUIndex32
466456 -> GPUShaderStage
467457 -> { | provided }
468- -> GPUBindGroupLayoutEntry i GPUTextureBindingLayout
469- bindGroupLayoutEntryForTexture binding visibility provided = bindGroupLayoutEntryForTextureImpl { binding: bindingToGPUIndex32 binding , visibility } all
458+ -> GPUBindGroupLayoutEntry
459+ bindGroupLayoutEntryForTexture binding visibility provided = bindGroupLayoutEntryForTextureImpl { binding, visibility } all
470460 where
471461 all :: { | GPUTextureBindingLayoutAll }
472462 all = convertOptionsWithDefaults TextureBindingLayout defaultGPUTextureBindingLayoutOptions provided
@@ -494,18 +484,16 @@ instance ConvertOption StorageTextureBindingLayout "access" GPUStorageTextureAcc
494484instance ConvertOption StorageTextureBindingLayout " viewDimension" GPUTextureViewDimension (Undefinable GPUTextureViewDimension ) where
495485 convertOption _ _ = defined
496486
497- foreign import bindGroupLayoutEntryForStorageTextureImpl :: forall i g . GPUBindGroupLayoutOptions -> { | GPUStorageTextureBindingLayoutAll } -> GPUBindGroupLayoutEntry i g
487+ foreign import bindGroupLayoutEntryForStorageTextureImpl :: GPUBindGroupLayoutOptions -> { | GPUStorageTextureBindingLayoutAll } -> GPUBindGroupLayoutEntry
498488
499489bindGroupLayoutEntryForStorageTexture
500- :: forall provided i
490+ :: forall provided
501491 . ConvertOptionsWithDefaults StorageTextureBindingLayout { | GPUStorageTextureBindingLayoutOptional } { | provided } { | GPUStorageTextureBindingLayoutAll }
502- => Reflectable i Int
503- => Compare (-1) i LT
504- => Proxy i
492+ => GPUIndex32
505493 -> GPUShaderStage
506494 -> { | provided }
507- -> GPUBindGroupLayoutEntry i GPUStorageTextureBindingLayout
508- bindGroupLayoutEntryForStorageTexture binding visibility provided = bindGroupLayoutEntryForStorageTextureImpl { binding: bindingToGPUIndex32 binding , visibility } all
495+ -> GPUBindGroupLayoutEntry
496+ bindGroupLayoutEntryForStorageTexture binding visibility provided = bindGroupLayoutEntryForStorageTextureImpl { binding, visibility } all
509497 where
510498 all :: { | GPUStorageTextureBindingLayoutAll }
511499 all = convertOptionsWithDefaults StorageTextureBindingLayout defaultGPUStorageTextureBindingLayoutOptions provided
@@ -522,38 +510,42 @@ defaultGPUExternalTextureBindingLayoutOptions = {}
522510
523511data ExternalTextureBindingLayout = ExternalTextureBindingLayout
524512
525- foreign import bindGroupLayoutEntryForExternalTextureImpl :: forall i g . GPUBindGroupLayoutOptions -> { | GPUExternalTextureBindingLayoutAll } -> GPUBindGroupLayoutEntry i g
513+ foreign import bindGroupLayoutEntryForExternalTextureImpl :: GPUBindGroupLayoutOptions -> { | GPUExternalTextureBindingLayoutAll } -> GPUBindGroupLayoutEntry
526514
527515bindGroupLayoutEntryForExternalTexture
528- :: forall provided i
516+ :: forall provided
529517 . ConvertOptionsWithDefaults ExternalTextureBindingLayout { | GPUExternalTextureBindingLayoutOptional } { | provided } { | GPUExternalTextureBindingLayoutAll }
530- => Reflectable i Int
531- => Compare (-1) i LT
532- => Proxy i
518+ => GPUIndex32
533519 -> GPUShaderStage
534520 -> { | provided }
535- -> GPUBindGroupLayoutEntry i GPUExternalTextureBindingLayout
536- bindGroupLayoutEntryForExternalTexture binding visibility provided = bindGroupLayoutEntryForExternalTextureImpl { binding: bindingToGPUIndex32 binding , visibility } all
521+ -> GPUBindGroupLayoutEntry
522+ bindGroupLayoutEntryForExternalTexture binding visibility provided = bindGroupLayoutEntryForExternalTextureImpl { binding, visibility } all
537523 where
538524 all :: { | GPUExternalTextureBindingLayoutAll }
539525 all = convertOptionsWithDefaults ExternalTextureBindingLayout defaultGPUExternalTextureBindingLayoutOptions provided
540526
541527-- createPipelineLayout
528+ type GPUPipelineLayoutDescriptor =
529+ { bindGroupLayouts :: Array GPUBindGroupLayout
530+ }
542531
543- foreign import createPipelineLayoutImpl :: forall entries . GPUDevice -> GPUPipelineLayoutDescriptor entries -> Effect ( GPUPipelineLayout entries )
532+ foreign import createPipelineLayoutImpl :: GPUDevice -> GPUPipelineLayoutDescriptor -> Effect GPUPipelineLayout
544533
545534createPipelineLayout
546- :: forall bindingLayouts
547- . GPUDevice
548- -> GPUPipelineLayoutDescriptor bindingLayouts
549- -> Effect (GPUPipelineLayout bindingLayouts )
535+ :: GPUDevice
536+ -> GPUPipelineLayoutDescriptor
537+ -> Effect GPUPipelineLayout
550538createPipelineLayout = createPipelineLayoutImpl
551539
552540-- createBindGroup
541+ type GPUBindGroupDescriptor =
542+ { layout :: GPUBindGroupLayout
543+ , entries :: Array GPUBindGroupEntry
544+ }
553545
554- foreign import createBindGroupImpl :: forall layoutEntries entries . GPUDevice -> GPUBindGroupDescriptor layoutEntries entries -> Effect ( GPUBindGroup layoutEntries entries )
546+ foreign import createBindGroupImpl :: GPUDevice -> GPUBindGroupDescriptor -> Effect GPUBindGroup
555547
556- createBindGroup :: forall layoutEntries entries . GPUDevice -> GPUBindGroupDescriptor layoutEntries entries -> Effect ( GPUBindGroup layoutEntries entries )
548+ createBindGroup :: GPUDevice -> GPUBindGroupDescriptor -> Effect GPUBindGroup
557549createBindGroup = createBindGroupImpl
558550
559551-- createShaderModule
0 commit comments