Skip to content

Commit d0d7e90

Browse files
author
Mike Solomon
committed
Adds more efficient bindings for command encoder and compute pass encoder
1 parent 8deef52 commit d0d7e90

22 files changed

+91
-516
lines changed

apply-backend-es-annotations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
elif '::' in l and '->' in l: candidates.append(content[x])
1717
candidates = [x.replace('foreign import','').split('::')[0].strip() for x in candidates]
1818
candidates = [x for x in candidates if '--' not in x]
19+
candidates = [x for x in candidates if 'Impl' not in x] # no ffi yet
1920
arity = {}
2021
for candidate in candidates:
2122
for x in range(len(content)):

src/Web/GPU/GPU.purs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
-- @inline export requestAdapterImpl arity=1
21
-- @inline export requestAdapter arity=1
3-
-- @inline export getPreferredCanvasFormatImpl arity=1
42
-- @inline export getPreferredCanvasFormat arity=1
53
module Web.GPU.GPU
64
( GPU,requestAdapter

src/Web/GPU/GPUAdapter.purs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
-- @inline export featuresImpl arity=2
21
-- @inline export features arity=2
3-
-- @inline export limitsImpl arity=1
42
-- @inline export limits arity=1
5-
-- @inline export isFallbackAdapterImpl arity=1
63
-- @inline export isFallbackAdapter arity=1
7-
-- @inline export requestDeviceImpl arity=1
84
-- @inline export requestDevice arity=1
9-
-- @inline export requestAdapterInfoImpl arity=2
105
-- @inline export requestAdapterInfo arity=2
116
module Web.GPU.GPUAdapter
127
( GPUAdapter(..)

src/Web/GPU/GPUBindGroupLayoutEntry.purs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
-- @inline export gpuBufferBindingLayout arity=3
2-
-- @inline export gpuSamplerBindingLayout arity=3
3-
-- @inline export gpuTextureBindingLayout arity=3
4-
-- @inline export gpuStorageTextureBindingLayout arity=3
5-
-- @inline export gpuExternalTextureBindingLayout arity=3
61
module Web.GPU.GPUBindGroupLayoutEntry where
72

83
import Unsafe.Coerce (unsafeCoerce)

src/Web/GPU/GPUBuffer.purs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
-- @inline export sizeImpl arity=1
21
-- @inline export size arity=1
3-
-- @inline export usageImpl arity=1
42
-- @inline export usage arity=1
5-
-- @inline export mapStateImpl arity=1
63
-- @inline export mapState arity=1
7-
-- @inline export mapAsyncImpl arity=2
84
-- @inline export mapAsync arity=2
9-
-- @inline export mapAsyncWithOffsetImpl arity=3
105
-- @inline export mapAsyncWithOffset arity=3
11-
-- @inline export mapAsyncWithSizeImpl arity=3
126
-- @inline export mapAsyncWithSize arity=3
13-
-- @inline export mapAsyncWithOffsetAndSizeImpl arity=4
147
-- @inline export mapAsyncWithOffsetAndSize arity=4
15-
-- @inline export getMappedRangeImpl arity=1
168
-- @inline export getMappedRange arity=1
17-
-- @inline export getMappedRangeWithOffsetImpl arity=2
189
-- @inline export getMappedRangeWithOffset arity=2
19-
-- @inline export getMappedRangeWithSizeImpl arity=2
2010
-- @inline export getMappedRangeWithSize arity=2
21-
-- @inline export getMappedRangeWithOffsetAndSizeImpl arity=3
2211
-- @inline export getMappedRangeWithOffsetAndSize arity=3
23-
-- @inline export unmapImpl arity=1
2412
-- @inline export unmap arity=1
25-
-- @inline export destroyImpl arity=1
2613
-- @inline export destroy arity=1
2714
module Web.GPU.GPUBuffer
2815
( GPUBuffer

src/Web/GPU/GPUCanvasContext.purs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
-- @inline export canvasImpl arity=1
21
-- @inline export canvas arity=1
3-
-- @inline export configureImpl arity=2
42
-- @inline export configure arity=2
5-
-- @inline export unconfigureImpl arity=1
63
-- @inline export unconfigure arity=1
7-
-- @inline export getCurrentTextureImpl arity=1
84
-- @inline export getCurrentTexture arity=1
95
module Web.GPU.GPUCanvasContext
106
( GPUCanvasContext

src/Web/GPU/GPUCommandEncoder.js

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
export const beginRenderPassImpl = (commandEncoder) => (descriptor) => () =>
1+
export const beginRenderPassImpl = (commandEncoder) => (descriptor) =>
22
commandEncoder.beginRenderPass(descriptor);
3-
export const beginComputePassImpl = (commandEncoder) => (descriptor) => () =>
3+
export const beginComputePassImpl = (commandEncoder) => (descriptor) =>
44
commandEncoder.beginComputePass(descriptor);
55
export const copyBufferToBufferImpl =
66
(commandEncoder) =>
7-
(source) =>
8-
(sourceOffset) =>
9-
(destination) =>
10-
(destinationOffset) =>
11-
(size) =>
12-
() =>
7+
(source, sourceOffset, destination, destinationOffset, size) =>
138
commandEncoder.copyBufferToBuffer(
149
source,
1510
sourceOffset,
@@ -18,36 +13,28 @@ export const copyBufferToBufferImpl =
1813
size
1914
);
2015
export const copyBufferToTextureImpl =
21-
(commandEncoder) => (source) => (destination) => (copySize) => () =>
16+
(commandEncoder) => (source, destination, copySize) =>
2217
commandEncoder.copyBufferToTexture(source, destination, copySize);
2318
export const copyTextureToBufferImpl =
24-
(commandEncoder) => (source) => (destination) => (copySize) => () =>
19+
(commandEncoder) => (source, destination, copySize) =>
2520
commandEncoder.copyTextureToBuffer(source, destination, copySize);
2621
export const copyTextureToTextureImpl =
27-
(commandEncoder) => (source) => (destination) => (copySize) => () =>
22+
(commandEncoder) => (source, destination, copySize) =>
2823
commandEncoder.copyTextureToTexture(source, destination, copySize);
29-
export const clearBufferImpl = (commandEncoder) => (buffer) => () =>
30-
commandEncoder.clearBuffer(buffere);
31-
export const clearBufferWithOffsetImpl =
32-
(commandEncoder) => (buffer) => (offset) => () =>
33-
commandEncoder.clearBuffer(buffer, offset);
34-
export const clearBufferWithSizeImpl =
35-
(commandEncoder) => (buffer) => (size) => () =>
36-
commandEncoder.clearBuffer(buffer, undefined, size);
24+
export const clearBufferImpl = (commandEncoder) => (buffer) =>
25+
commandEncoder.clearBuffer(buffer);
26+
export const clearBufferWithOffsetImpl = (commandEncoder) => (buffer, offset) =>
27+
commandEncoder.clearBuffer(buffer, offset);
28+
export const clearBufferWithSizeImpl = (commandEncoder) => (buffer, size) =>
29+
commandEncoder.clearBuffer(buffer, undefined, size);
3730
export const clearBufferWithOffsetAndSizeImpl =
38-
(commandEncoder) => (buffer) => (offset) => (size) => () =>
31+
(commandEncoder) => (buffer, offset, size) =>
3932
commandEncoder.clearBuffer(buffer, offset, size);
40-
export const writeTimestampImpl =
41-
(commandEncoder) => (querySet) => (queryIndex) => () =>
42-
commandEncoder.writeTimestamp(querySet, queryIndex);
33+
export const writeTimestampImpl = (commandEncoder) => (querySet, queryIndex) =>
34+
commandEncoder.writeTimestamp(querySet, queryIndex);
4335
export const resolveQuerySetImpl =
4436
(commandEncoder) =>
45-
(querySet) =>
46-
(firstQuery) =>
47-
(queryCount) =>
48-
(destination) =>
49-
(destinationOffset) =>
50-
() =>
37+
(querySet, firstQuery, queryCount, destination, destinationOffset) =>
5138
commandEncoder.resolveQuerySet(
5239
querySet,
5340
firstQuery,
@@ -56,9 +43,9 @@ export const resolveQuerySetImpl =
5643
destinationOffset
5744
);
5845
export const finishImpl = (commandEncoder) => () => commandEncoder.finish();
59-
export const pushDebugGroupImpl = (commandEncoder) => (groupLabel) => () =>
46+
export const pushDebugGroupImpl = (commandEncoder) => (groupLabel) =>
6047
commandEncoder.pushDebugGroup(groupLabel);
6148
export const popDebugGroupImpl = (commandEncoder) => () =>
6249
commandEncoder.popDebugGroup();
63-
export const insertDebugMarkerImpl = (commandEncoder) => (markerLabel) => () =>
50+
export const insertDebugMarkerImpl = (commandEncoder) => (markerLabel) =>
6451
commandEncoder.insertDebugMarker(markerLabel);

0 commit comments

Comments
 (0)