1+ module Web.GPU.GPUCommandEncoder where
2+
3+ import Prelude
4+
5+ import Effect (Effect )
6+ import Web.GPU.GPUComputePassTimestampLocation (GPUComputePassTimestampLocation )
7+ import Web.GPU.GPULoadOp (GPULoadOp )
8+ import Web.GPU.GPURenderPassTimestampLocation (GPURenderPassTimestampLocation )
9+ import Web.GPU.GPUStoreOp (GPUStoreOp )
10+ import Web.GPU.GPUTextureAspect (GPUTextureAspect )
11+ import Web.GPU.Internal.ConvertibleOptions (class ConvertOption , class ConvertOptionsWithDefaults , convertOptionsWithDefaults )
12+ import Web.GPU.Internal.Types (GPUBuffer , GPUColor , GPUCommandBuffer , GPUCommandEncoder , GPUComputePassEncoder , GPUExtent3D , GPUOrigin3D , GPUQuerySet , GPURenderPassEncoder , GPUTexture , GPUTextureView )
13+ import Web.GPU.Internal.Undefinable (Undefinable , defined , undefined )
14+ import Web.GPU.Internal.Unsigned (GPUSize32 , GPUSize64 , GPUStencilValue , GPUIntegerCoordinate )
15+
16+ -- todo
17+ -- convertible options on GPURenderPassDescriptor
18+
19+ type GPURenderPassTimestampWrite =
20+ { querySet :: GPUQuerySet
21+ , queryIndex :: GPUSize32
22+ , location :: GPURenderPassTimestampLocation
23+ }
24+
25+ type GPURenderPassTimestampWrites = Array GPURenderPassTimestampWrite
26+
27+ type GPURenderPassDescriptorOptional :: forall k . k -> Row Type
28+ type GPURenderPassDescriptorOptional gpuRenderPassDepthStencilAttachment =
29+ ( depthStencilAttachment :: Undefinable gpuRenderPassDepthStencilAttachment
30+ , occlusionQuerySet :: Undefinable GPUQuerySet
31+ , timestampWrites :: Undefinable GPURenderPassTimestampWrites
32+ , maxDrawCount :: Undefinable GPUSize64
33+ )
34+
35+ type GPURenderPassColorAttachmentOptional =
36+ ( resolveTarget :: Undefinable GPUTextureView
37+ , clearValue :: Undefinable GPUColor
38+ )
39+
40+ type GPURenderPassColorAttachment =
41+ ( view :: GPUTextureView
42+ , loadOp :: GPULoadOp
43+ , storeOp :: GPUStoreOp
44+ | GPURenderPassColorAttachmentOptional
45+ )
46+
47+ defaultGPURenderPassColorAttachmentOptions :: { | GPURenderPassColorAttachmentOptional }
48+ defaultGPURenderPassColorAttachmentOptions =
49+ { resolveTarget: undefined
50+ , clearValue: undefined
51+ }
52+
53+ data RenderPassColorAttachment = RenderPassColorAttachment
54+
55+ instance ConvertOption RenderPassColorAttachment " resolveTarget" GPUTextureView (Undefinable GPUTextureView ) where
56+ convertOption _ _ = defined
57+
58+ instance ConvertOption RenderPassColorAttachment " clearValue" GPUColor (Undefinable GPUColor ) where
59+ convertOption _ _ = defined
60+
61+ gpuRenderPassColorAttachment
62+ :: forall provided
63+ . ConvertOptionsWithDefaults RenderPassColorAttachment { | GPURenderPassColorAttachmentOptional } { | provided } { | GPURenderPassColorAttachment }
64+ => { | provided }
65+ -> { | GPURenderPassColorAttachment }
66+
67+ gpuRenderPassColorAttachment provided = all
68+ where
69+ all :: { | GPURenderPassColorAttachment }
70+ all = convertOptionsWithDefaults RenderPassColorAttachment defaultGPURenderPassColorAttachmentOptions provided
71+
72+ type GPURenderPassDepthStencilAttachmentOptional =
73+ ( depthClearValue :: Undefinable Number
74+ , depthReadOnly :: Undefinable Boolean
75+ , stencilClearValue :: Undefinable GPUStencilValue
76+ , stencilReadOnly :: Undefinable Boolean
77+ )
78+
79+ type GPURenderPassDepthStencilAttachment =
80+ ( view :: GPUTextureView
81+ , depthLoadOp :: GPULoadOp
82+ , depthStoreOp :: GPUStoreOp
83+ , stencilLoadOp :: GPULoadOp
84+ , stencilStoreOp :: GPUStoreOp
85+ | GPURenderPassDepthStencilAttachmentOptional
86+ )
87+
88+ type GPURenderPassDescriptor :: forall k . k -> Row Type
89+ type GPURenderPassDescriptor gpuRenderPassDepthStencilAttachment =
90+ ( colorAttachments :: Array { | GPURenderPassColorAttachment }
91+ | GPURenderPassDescriptorOptional gpuRenderPassDepthStencilAttachment
92+ )
93+
94+ type GPUComputePassTimestampWrite =
95+ { querySet :: GPUQuerySet
96+ , queryIndex :: GPUSize32
97+ , location :: GPUComputePassTimestampLocation
98+ }
99+
100+ type GPUComputePassTimestampWrites = Array GPUComputePassTimestampWrite
101+ type GPUComputePassDescriptorOptional =
102+ ( timestampWrites :: Undefinable GPUComputePassTimestampWrites
103+ )
104+
105+ type GPUComputePassDescriptor =
106+ (
107+ | GPUComputePassDescriptorOptional
108+ )
109+
110+ foreign import beginRenderPassImpl :: GPUCommandEncoder -> { | GPURenderPassDescriptor GPURenderPassDepthStencilAttachment } -> Effect GPURenderPassEncoder
111+ foreign import beginComputePassImpl :: GPUCommandEncoder -> { | GPUComputePassDescriptor } -> GPUComputePassEncoder
112+ foreign import copyBufferToBufferImpl
113+ :: GPUCommandEncoder
114+ -> GPUBuffer
115+ -> GPUSize64
116+ -> GPUBuffer
117+ -> GPUSize64
118+ -> GPUSize64
119+ -> Effect Unit
120+
121+ type GPUImageCopyBufferOptional =
122+ ( offset :: GPUSize64
123+ , bytesPerRow :: GPUSize32
124+ , rowsPerImage :: GPUSize32
125+ )
126+
127+ type GPUImageCopyBuffer =
128+ ( buffer :: GPUBuffer
129+ | GPUImageCopyBufferOptional
130+ )
131+
132+ type GPUImageCopyTextureOptional =
133+ ( mipLevel :: GPUIntegerCoordinate
134+ , origin :: GPUOrigin3D
135+ , aspect :: GPUTextureAspect
136+ )
137+
138+ type GPUImageCopyTexture =
139+ ( texture :: GPUTexture
140+ | GPUImageCopyTextureOptional
141+ )
142+
143+ foreign import copyBufferToTextureImpl
144+ :: GPUCommandEncoder
145+ -> { | GPUImageCopyBuffer }
146+ -> { | GPUImageCopyTexture }
147+ -> GPUExtent3D
148+ -> Effect Unit
149+
150+ foreign import copyTextureToBufferImpl
151+ :: GPUCommandEncoder
152+ -> { | GPUImageCopyTexture }
153+ -> { | GPUImageCopyBuffer }
154+ -> GPUExtent3D
155+ -> Effect Unit
156+
157+ foreign import copyTextureToTextureImpl
158+ :: GPUCommandEncoder
159+ -> { | GPUImageCopyTexture }
160+ -> { | GPUImageCopyTexture }
161+ -> GPUExtent3D
162+ -> Effect Unit
163+
164+ foreign import clearBufferImpl
165+ :: GPUCommandEncoder
166+ -> GPUBuffer
167+ -> Effect Unit
168+
169+ foreign import clearBufferWithOffsetImpl
170+ :: GPUCommandEncoder
171+ -> GPUBuffer
172+ -> GPUSize64
173+ -> Effect Unit
174+
175+ foreign import clearBufferWithSizeImpl
176+ :: GPUCommandEncoder
177+ -> GPUBuffer
178+ -> GPUSize64
179+ -> Effect Unit
180+
181+ foreign import clearBufferWithOffsetAndSizeImpl
182+ :: GPUCommandEncoder
183+ -> GPUBuffer
184+ -> GPUSize64
185+ -> GPUSize64
186+ -> Effect Unit
187+
188+ foreign import writeTimestampImpl :: GPUCommandEncoder -> GPUQuerySet -> GPUSize32 -> Effect Unit
189+
190+ foreign import resolveQuerySetImpl
191+ :: GPUCommandEncoder
192+ -> GPUQuerySet
193+ -> GPUSize32
194+ -> GPUSize32
195+ -> GPUBuffer
196+ -> GPUSize64
197+ -> Effect Unit
198+
199+ foreign import finishImpl :: GPUCommandEncoder -> Effect GPUCommandBuffer
200+
201+ foreign import pushDebugGroupImpl :: GPUCommandEncoder -> String -> Effect Unit
202+ foreign import popDebugGroupImpl :: GPUCommandEncoder -> Effect Unit
203+ foreign import insertDebugMarkerImpl :: GPUCommandEncoder -> String -> Effect Unit
0 commit comments