Skip to content

Commit ee75cfe

Browse files
author
Mike Solomon
committed
Removes type-level machinery
1 parent a5a2b8a commit ee75cfe

10 files changed

Lines changed: 64 additions & 214 deletions

src/Web/GPU/GPUBindGroupDescriptor.purs

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/Web/GPU/GPUBindGroupEntry.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/Web/GPU/GPUBindGroupEntry.purs

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
module Web.GPU.GPUBindGroupEntry
22
( BufferBinding
33
, GPUBufferBinding
4-
, add
54
, bindGroupEntryForBufferBinding
65
, bindGroupEntryForExternalTexture
76
, bindGroupEntryForSampler
87
, bindGroupEntryForTextureView
9-
, empty
108
, gpuBufferBinding
119
) where
1210

13-
import Data.Reflectable (class Reflectable, reflectType)
14-
import Prim.Int (class ToString, class Compare)
15-
import Prim.Ordering (LT)
16-
import Prim.Row (class Cons, class Lacks)
17-
import Type.Proxy (Proxy)
1811
import Unsafe.Coerce (unsafeCoerce)
1912
import Web.GPU.Internal.ConvertibleOptions (class ConvertOption, class ConvertOptionsWithDefaults, convertOptionsWithDefaults)
20-
import Web.GPU.Internal.Types (GPUBindGroupEntries, GPUBindGroupEntry, GPUBuffer, GPUExternalTexture, GPUSampler, GPUTextureView)
13+
import Web.GPU.Internal.Types (GPUBindGroupEntry, GPUBuffer, GPUExternalTexture, GPUSampler, GPUTextureView)
2114
import Web.GPU.Internal.Undefinable (Undefinable, defined, undefined)
2215
import Web.GPU.Internal.Unsigned (GPUSize64)
2316

@@ -59,32 +52,14 @@ gpuBufferBinding provided = GPUBufferBinding all
5952
all :: { | GPUBufferBindingAll }
6053
all = convertOptionsWithDefaults BufferBinding defaultGPUBufferBinding provided
6154

62-
bindGroupEntryForBufferBinding :: forall (i :: Int). Reflectable i Int => Proxy i -> GPUBufferBinding -> GPUBindGroupEntry i GPUBufferBinding
63-
bindGroupEntryForBufferBinding binding resource = unsafeCoerce { binding: reflectType binding, resource }
55+
bindGroupEntryForBufferBinding :: Int -> GPUBufferBinding -> GPUBindGroupEntry
56+
bindGroupEntryForBufferBinding binding resource = unsafeCoerce { binding, resource }
6457

65-
bindGroupEntryForSampler :: forall (i :: Int). Reflectable i Int => Proxy i -> GPUSampler -> GPUBindGroupEntry i GPUSampler
66-
bindGroupEntryForSampler binding resource = unsafeCoerce { binding: reflectType binding, resource }
58+
bindGroupEntryForSampler :: Int -> GPUSampler -> GPUBindGroupEntry
59+
bindGroupEntryForSampler binding resource = unsafeCoerce { binding, resource }
6760

68-
bindGroupEntryForTextureView :: forall (i :: Int). Reflectable i Int => Proxy i -> GPUTextureView -> GPUBindGroupEntry i GPUTextureView
69-
bindGroupEntryForTextureView binding resource = unsafeCoerce { binding: reflectType binding, resource }
61+
bindGroupEntryForTextureView :: Int -> GPUTextureView -> GPUBindGroupEntry
62+
bindGroupEntryForTextureView binding resource = unsafeCoerce { binding, resource }
7063

71-
bindGroupEntryForExternalTexture :: forall (i :: Int). Reflectable i Int => Proxy i -> GPUExternalTexture -> GPUBindGroupEntry i GPUExternalTexture
72-
bindGroupEntryForExternalTexture binding resource = unsafeCoerce { binding: reflectType binding, resource }
73-
74-
empty :: GPUBindGroupEntries ()
75-
empty = unsafeCoerce []
76-
77-
foreign import unsafeAdd :: forall x y z. x -> y -> z
78-
79-
add
80-
:: forall i key binding prev current
81-
. Compare (-1) i LT
82-
=> ToString i key
83-
=> Lacks key prev
84-
=> Cons key binding prev current
85-
=> GPUBindGroupEntry i binding
86-
-> GPUBindGroupEntries prev
87-
-> GPUBindGroupEntries current
88-
add = unsafeAdd
89-
90-
infixr 5 add as :+.
64+
bindGroupEntryForExternalTexture :: Int -> GPUExternalTexture -> GPUBindGroupEntry
65+
bindGroupEntryForExternalTexture binding resource = unsafeCoerce { binding, resource }

src/Web/GPU/GPUBindGroupLayoutDescriptor.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/Web/GPU/GPUBindGroupLayoutDescriptor.purs

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/Web/GPU/GPUDevice.purs

Lines changed: 48 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,10 @@ module Web.GPU.Device
4545

4646
import Prelude
4747

48-
import Data.Reflectable (class Reflectable, reflectType)
4948
import Data.Set as Set
5049
import Effect (Effect)
5150
import Foreign (Foreign)
5251
import Foreign.Object (Object)
53-
import Prim.Int (class Compare)
54-
import Prim.Ordering (LT)
55-
import Type.Proxy (Proxy)
5652
import Web.GPU.GPUAddressMode (GPUAddressMode)
5753
import Web.GPU.GPUBlendFactor (GPUBlendFactor)
5854
import Web.GPU.GPUBlendOperation (GPUBlendOperation)
@@ -82,9 +78,9 @@ import Web.GPU.GPUTextureViewDimension (GPUTextureViewDimension)
8278
import Web.GPU.GPUVertexFormat (GPUVertexFormat)
8379
import Web.GPU.GPUVertexStepMode (GPUVertexStepMode)
8480
import 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)
8682
import 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)
8884
import Web.GPU.PredefinedColorSpace (PredefinedColorSpace)
8985
import Web.HTML (HTMLVideoElement)
9086
import 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-
335328
type 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

342339
createBindGroupLayout
343-
:: forall entries
344-
. GPUDevice
345-
-> GPUBindGroupLayoutDescriptor entries
346-
-> Effect (GPUBindGroupLayout entries)
340+
:: GPUDevice
341+
-> { | GPUBindGroupLayoutDescriptor }
342+
-> Effect GPUBindGroupLayout
347343
createBindGroupLayout = createBindGroupLayoutImpl
348344

349345
---- bindGroupLayoutEntryForBuffer
@@ -375,18 +371,16 @@ instance ConvertOption BufferBindingLayout "hasDynamicOffset" Boolean (Undefinab
375371
instance 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

380376
bindGroupLayoutEntryForBuffer
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
410404
instance 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

415409
bindGroupLayoutEntryForSampler
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
455447
instance 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

460452
bindGroupLayoutEntryForTexture
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
494484
instance 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

499489
bindGroupLayoutEntryForStorageTexture
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

523511
data ExternalTextureBindingLayout = ExternalTextureBindingLayout
524512

525-
foreign import bindGroupLayoutEntryForExternalTextureImpl :: forall i g. GPUBindGroupLayoutOptions -> { | GPUExternalTextureBindingLayoutAll } -> GPUBindGroupLayoutEntry i g
513+
foreign import bindGroupLayoutEntryForExternalTextureImpl :: GPUBindGroupLayoutOptions -> { | GPUExternalTextureBindingLayoutAll } -> GPUBindGroupLayoutEntry
526514

527515
bindGroupLayoutEntryForExternalTexture
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

545534
createPipelineLayout
546-
:: forall bindingLayouts
547-
. GPUDevice
548-
-> GPUPipelineLayoutDescriptor bindingLayouts
549-
-> Effect (GPUPipelineLayout bindingLayouts)
535+
:: GPUDevice
536+
-> GPUPipelineLayoutDescriptor
537+
-> Effect GPUPipelineLayout
550538
createPipelineLayout = 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
557549
createBindGroup = createBindGroupImpl
558550

559551
-- createShaderModule

src/Web/GPU/GPUPipelineLayoutDescriptor.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/Web/GPU/GPUPipelineLayoutDescriptor.purs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Web/GPU/GPUShaderModuleCompilationHint.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import Web.GPU.Internal.Types (GPUPipelineLayout, GPUShaderModuleCompilationHint
66
auto :: GPUShaderModuleCompilationHint
77
auto = unsafeCoerce "auto"
88

9-
hintFromPipelineLayout :: forall layout. GPUPipelineLayout layout -> GPUShaderModuleCompilationHint
9+
hintFromPipelineLayout :: GPUPipelineLayout -> GPUShaderModuleCompilationHint
1010
hintFromPipelineLayout = unsafeCoerce

0 commit comments

Comments
 (0)