11module Web.GPU.GPUAdapter
22 ( GPUAdapterInfo
3- , GPURequestDevice
43 , features
54 , limits
65 , isFallbackAdapter
@@ -11,16 +10,19 @@ module Web.GPU.GPUAdapter
1110import Data.Maybe (Maybe (..))
1211import Data.Set as Set
1312import Effect (Effect )
14- import Web.GPU.Internal.Types ( GPUAdapter , GPUDevice )
13+ import Web.GPU.GPUDeviceDescriptor ( GPUDeviceDescriptor )
1514import Web.GPU.GPUFeatureName (GPUFeatureName )
16- import Web.GPU.GPUSupportedLimits (GPUSupportedLimits , UndefinableGPUSupportedLimits , defaultGPUSupportedLimits )
17- import Web.GPU.Internal.ConvertibleOptions (class ConvertOption , class ConvertOptionsWithDefaults , convertOptionsWithDefaults )
18- import Web.GPU.Internal.Undefinable (Undefinable , undefined , defined )
19- import Web.Promise (Promise )
15+ import Web.GPU.GPUSupportedLimits (GPUSupportedLimits )
16+ import Web.GPU.Internal.Types (GPUAdapter , GPUDevice )
2017import Web.GPU.UnmaskHint (UnmaskHint )
18+ import Web.Promise (Promise )
2119
2220-- features
23- foreign import featuresImpl :: (GPUFeatureName -> Set.Set GPUFeatureName -> Set.Set GPUFeatureName ) -> Set.Set GPUFeatureName -> GPUAdapter -> Effect (Set.Set GPUFeatureName )
21+ foreign import featuresImpl
22+ :: (GPUFeatureName -> Set.Set GPUFeatureName -> Set.Set GPUFeatureName )
23+ -> Set.Set GPUFeatureName
24+ -> GPUAdapter
25+ -> Effect (Set.Set GPUFeatureName )
2426
2527features :: GPUAdapter -> Effect (Set.Set GPUFeatureName )
2628features = featuresImpl Set .insert Set .empty
@@ -37,63 +39,23 @@ isFallbackAdapter = isFallbackAdapterImpl
3739
3840-- requestDevice
3941
40- foreign import requestDeviceImpl :: (GPUDevice -> Maybe GPUDevice ) -> Maybe GPUDevice -> GPUAdapter -> { | GPURequestDeviceOptions } -> Effect (Promise (Maybe GPUDevice ))
41-
42- type GPUQueueDescriptorOptional =
43- ( label :: Undefinable String
44- )
45-
46- type GPUQueueDescriptor = (| GPUQueueDescriptorOptional )
47-
48- defaultGPUQueueDescriptor :: { | GPUQueueDescriptor }
49- defaultGPUQueueDescriptor = { label: undefined }
50-
51- type GPURequestDeviceOptionsOptional =
52- ( requiredFeatures :: Undefinable (Array GPUFeatureName )
53- , requiredLimits :: Undefinable { | UndefinableGPUSupportedLimits }
54- , defaultQueue :: Undefinable { | GPUQueueDescriptor }
55- )
56-
57- type GPURequestDeviceOptions = (| GPURequestDeviceOptionsOptional )
58-
59- defaultGPURequestDeviceOptions :: { | GPURequestDeviceOptionsOptional }
60- defaultGPURequestDeviceOptions =
61- { requiredFeatures: undefined
62- , requiredLimits: undefined
63- , defaultQueue: undefined
64- }
65-
66- data GPURequestDevice = GPURequestDevice
67-
68- instance ConvertOption GPURequestDevice " requiredFeatures" (Array GPUFeatureName ) (Undefinable (Array GPUFeatureName )) where
69- convertOption _ _ = defined
70-
71- instance ConvertOptionsWithDefaults GPURequestDevice { | UndefinableGPUSupportedLimits } { | provided } { | UndefinableGPUSupportedLimits } => ConvertOption GPURequestDevice " requiredLimits" { | provided } (Undefinable { | UndefinableGPUSupportedLimits } ) where
72- convertOption _ _ provided = defined all
73- where
74- all :: { | UndefinableGPUSupportedLimits }
75- all = convertOptionsWithDefaults GPURequestDevice defaultGPUSupportedLimits provided
76-
77- instance ConvertOptionsWithDefaults GPURequestDevice { | GPUQueueDescriptorOptional } { | provided } { | GPUQueueDescriptor } => ConvertOption GPURequestDevice " defaultQueue" { | provided } (Undefinable { | GPUQueueDescriptor } ) where
78- convertOption _ _ provided = defined all
79- where
80- all :: { | GPUQueueDescriptor }
81- all = convertOptionsWithDefaults GPURequestDevice defaultGPUQueueDescriptor provided
42+ foreign import requestDeviceImpl
43+ :: (GPUDevice -> Maybe GPUDevice )
44+ -> Maybe GPUDevice
45+ -> GPUAdapter
46+ -> GPUDeviceDescriptor
47+ -> Effect (Promise (Maybe GPUDevice ))
8248
8349requestDevice
84- :: forall provided
85- . ConvertOptionsWithDefaults GPURequestDevice { | GPURequestDeviceOptionsOptional } { | provided } { | GPURequestDeviceOptions }
86- => GPUAdapter
87- -> { | provided }
50+ :: GPUAdapter
51+ -> GPUDeviceDescriptor
8852 -> Effect (Promise (Maybe GPUDevice ))
89- requestDevice g provided = requestDeviceImpl Just Nothing g all
90- where
91- all :: { | GPURequestDeviceOptions }
92- all = convertOptionsWithDefaults GPURequestDevice defaultGPURequestDeviceOptions provided
53+ requestDevice = requestDeviceImpl Just Nothing
9354
9455-- requestAdapterInfo
9556
96- foreign import requestAdapterInfoImpl :: GPUAdapter -> Array (UnmaskHint ) -> Effect (Promise GPUAdapterInfo )
57+ foreign import requestAdapterInfoImpl
58+ :: GPUAdapter -> Array (UnmaskHint ) -> Effect (Promise GPUAdapterInfo )
9759
9860type GPUAdapterInfo =
9961 { vendor :: String
@@ -102,5 +64,6 @@ type GPUAdapterInfo =
10264 , description :: String
10365 }
10466
105- requestAdapterInfo :: GPUAdapter -> Array UnmaskHint -> Effect (Promise GPUAdapterInfo )
67+ requestAdapterInfo
68+ :: GPUAdapter -> Array UnmaskHint -> Effect (Promise GPUAdapterInfo )
10669requestAdapterInfo = requestAdapterInfoImpl
0 commit comments