Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Changes formatting
  • Loading branch information
Mike Solomon committed Apr 25, 2023
commit 6a388ec66c065a84bb7da1fdbf33a91c07963a6d
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"sandbox": "spago -x sandbox.dhall build && vite build sandbox/",
"sandbox-dev": "spago -x sandbox-dev.dhall build && vite dev sandbox/",
"format": "purs-tidy format-in-place \"src/**/*.purs sandbox/**/*.purs\" && prettier --write \"src/**/*.js\""
"format": "purs-tidy format-in-place \"src/**/*.purs sandbox/**/*.purs\" && prettier --arrow-parens avoid --write \"src/**/*.js\""
},
"keywords": [],
"author": "",
Expand Down
1 change: 1 addition & 0 deletions src/Web/GPU/BufferSource.purs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Data.ArrayBuffer.Types (ArrayBuffer, DataView, Float32Array, Float64Array
import Unsafe.Coerce (unsafeCoerce)

data BufferSource

fromArrayBuffer :: ArrayBuffer -> BufferSource
fromArrayBuffer = unsafeCoerce

Expand Down
7 changes: 3 additions & 4 deletions src/Web/GPU/GPU.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const requestAdapterImpl =
(just) => (nothing) => (gpu) => (options) => () =>
gpu.requestAdapter(options).then((o) => (o ? just(o) : nothing));
export const requestAdapterImpl = just => nothing => gpu => options => () =>
gpu.requestAdapter(options).then(o => (o ? just(o) : nothing));

export const getPreferredCanvasFormatImpl = (gpu) => () =>
export const getPreferredCanvasFormatImpl = gpu => () =>
gpu.getPreferredCanvasFormat();
6 changes: 4 additions & 2 deletions src/Web/GPU/GPU.purs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
-- @inline export requestAdapter arity=1
-- @inline export getPreferredCanvasFormat arity=1
module Web.GPU.GPU
( GPU,requestAdapter
( GPU
, requestAdapter
, getPreferredCanvasFormat
) where

Expand All @@ -10,9 +11,10 @@ import Effect (Effect)
import Web.GPU.GPURequestAdapterOptions (GPURequestAdapterOptions)
import Web.GPU.GPUTextureFormat (GPUTextureFormat)
import Web.Promise (Promise)
import Web.GPU.GPUAdapter(GPUAdapter)
import Web.GPU.GPUAdapter (GPUAdapter)

data GPU

-- requestAdapter

foreign import requestAdapterImpl
Expand Down
14 changes: 6 additions & 8 deletions src/Web/GPU/GPUAdapter.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
export const featuresImpl = (insert) => (empty) => (adapter) => () => {
export const featuresImpl = insert => empty => adapter => () => {
const iterator1 = adapter.features.entries();
let out = empty;
for (const entry of iterator1) {
out = insert(entry)(out);
}
return out;
};
export const limitsImpl = (adapter) => () => adapter.limits;
export const isFallbackAdapterImpl = (adapter) => () =>
adapter.isFallbackAdapter;
export const requestDeviceImpl =
(just) => (nothing) => (adapter) => (options) => () =>
adapter.requestDevice(options).then((o) => (o ? just(o) : nothing));
export const requestAdapterInfoImpl = (adapter) => (unmaskHints) => () =>
export const limitsImpl = adapter => () => adapter.limits;
export const isFallbackAdapterImpl = adapter => () => adapter.isFallbackAdapter;
export const requestDeviceImpl = just => nothing => adapter => options => () =>
adapter.requestDevice(options).then(o => (o ? just(o) : nothing));
export const requestAdapterInfoImpl = adapter => unmaskHints => () =>
adapter.requestAdapterInfo(unmaskHints);
5 changes: 2 additions & 3 deletions src/Web/GPU/GPUAdapter.purs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ module Web.GPU.GPUAdapter
, limits
, requestAdapterInfo
, requestDevice
)
where
) where

import Data.Maybe (Maybe(..))
import Data.Set as Set
import Effect (Effect)
import Web.GPU.GPUDeviceDescriptor (GPUDeviceDescriptor)
import Web.GPU.GPUFeatureName (GPUFeatureName)
import Web.GPU.GPUDevice(GPUDevice)
import Web.GPU.GPUDevice (GPUDevice)
import Web.GPU.GPUSupportedLimits (GPUSupportedLimits)
import Web.GPU.UnmaskHint (UnmaskHint)
import Web.Promise (Promise)
Expand Down
3 changes: 1 addition & 2 deletions src/Web/GPU/GPUBindGroup.purs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Web.GPU.GPUBindGroup
( GPUBindGroup
)
where
) where

data GPUBindGroup
3 changes: 1 addition & 2 deletions src/Web/GPU/GPUBindGroupLayout.purs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Web.GPU.GPUBindGroupLayout
( GPUBindGroupLayout
)
where
) where

data GPUBindGroupLayout
26 changes: 13 additions & 13 deletions src/Web/GPU/GPUBuffer.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
export const sizeImpl = (buffer) => () => buffer.size;
export const usageImpl = (buffer) => () => buffer.usage;
export const mapStateImpl = (buffer) => () => buffer.mapState;
export const mapAsyncImpl = (buffer) => (mode) => () => buffer.mapAsync(mode);
export const mapAsyncWithOffsetImpl = (buffer) => (mode) => (offset) => () =>
export const sizeImpl = buffer => () => buffer.size;
export const usageImpl = buffer => () => buffer.usage;
export const mapStateImpl = buffer => () => buffer.mapState;
export const mapAsyncImpl = buffer => mode => () => buffer.mapAsync(mode);
export const mapAsyncWithOffsetImpl = buffer => mode => offset => () =>
buffer.mapAsync(mode, offset);
export const mapAsyncWithSizeImpl = (buffer) => (mode) => (size) => () =>
export const mapAsyncWithSizeImpl = buffer => mode => size => () =>
buffer.mapAsync(mode, undefined, size);
export const mapAsyncWithOffsetAndSizeImpl =
(buffer) => (mode) => (offset) => (size) => () =>
buffer => mode => offset => size => () =>
buffer.mapAsync(mode, offset, size);
export const getMappedRangeImpl = (buffer) => () => buffer.getMappedRange();
export const getMappedRangeWithOffsetImpl = (buffer) => (offset) => () =>
export const getMappedRangeImpl = buffer => () => buffer.getMappedRange();
export const getMappedRangeWithOffsetImpl = buffer => offset => () =>
buffer.getMappedRange(offset);
export const getMappedRangeWithSizeImpl = (buffer) => (size) => () =>
export const getMappedRangeWithSizeImpl = buffer => size => () =>
buffer.getMappedRange(undefined, size);
export const getMappedRangeWithOffsetAndSizeImpl =
(buffer) => (offset) => (size) => () =>
buffer => offset => size => () =>
buffer.getMappedRange(offset, size);
export const unmapImpl = (buffer) => () => buffer.unmap();
export const destroyImpl = (buffer) => () => buffer.destroy();
export const unmapImpl = buffer => () => buffer.unmap();
export const destroyImpl = buffer => () => buffer.destroy();
4 changes: 2 additions & 2 deletions src/Web/GPU/GPUBuffer.purs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ module Web.GPU.GPUBuffer
, size
, unmap
, usage
)
where
) where

import Prelude

Expand All @@ -40,6 +39,7 @@ import Web.GPU.Internal.Types (GPUSize64)
import Web.Promise (Promise)

data GPUBuffer

foreign import sizeImpl :: GPUBuffer -> Effect GPUSize64

size :: GPUBuffer -> Effect GPUSize64
Expand Down
1 change: 1 addition & 0 deletions src/Web/GPU/GPUCanvasConfiguration.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Web.GPU.GPUTextureUsage (GPUTextureUsageFlags)
import Web.GPU.Internal.RequiredAndOptional (RequiredAndOptional)
import Web.GPU.PredefinedColorSpace (PredefinedColorSpace)
import Web.GPU.GPUDevice (GPUDevice)

newtype GPUCanvasConfiguration = GPUCanvasConfiguration
( RequiredAndOptional
( device :: GPUDevice
Expand Down
8 changes: 4 additions & 4 deletions src/Web/GPU/GPUCanvasContext.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const canvasImpl = (context) => () => context.canvas;
export const configureImpl = (context) => (descriptor) => () =>
export const canvasImpl = context => () => context.canvas;
export const configureImpl = context => descriptor => () =>
context.configure(descriptor);
export const unconfigureImpl = (context) => () => context.unconfigure();
export const getCurrentTextureImpl = (context) => () =>
export const unconfigureImpl = context => () => context.unconfigure();
export const getCurrentTextureImpl = context => () =>
context.getCurrentTexture();
4 changes: 3 additions & 1 deletion src/Web/GPU/GPUColor.purs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
-- @inline export gpuColorRGBA arity=4
module Web.GPU.GPUColor
( GPUColor,gpuColorDict
( GPUColor
, gpuColorDict
, gpuColorRGBA
) where

import Unsafe.Coerce (unsafeCoerce)

data GPUColor

gpuColorRGBA :: Number -> Number -> Number -> Number -> GPUColor
gpuColorRGBA r g b a = unsafeCoerce [ r, g, b, a ]

Expand Down
106 changes: 64 additions & 42 deletions src/Web/GPU/GPUCommandEncoder.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,73 @@
export const beginRenderPassImpl = (commandEncoder) => (descriptor) =>
export const beginRenderPassImpl = (commandEncoder, descriptor) =>
commandEncoder.beginRenderPass(descriptor);
export const beginComputePassImpl = (commandEncoder) => (descriptor) =>
export const beginComputePassImpl = (commandEncoder, descriptor) =>
commandEncoder.beginComputePass(descriptor);
export const copyBufferToBufferImpl =
(commandEncoder) =>
(source, sourceOffset, destination, destinationOffset, size) =>
commandEncoder.copyBufferToBuffer(
source,
sourceOffset,
destination,
destinationOffset,
size
);
export const copyBufferToTextureImpl =
(commandEncoder) => (source, destination, copySize) =>
commandEncoder.copyBufferToTexture(source, destination, copySize);
export const copyTextureToBufferImpl =
(commandEncoder) => (source, destination, copySize) =>
commandEncoder.copyTextureToBuffer(source, destination, copySize);
export const copyTextureToTextureImpl =
(commandEncoder) => (source, destination, copySize) =>
commandEncoder.copyTextureToTexture(source, destination, copySize);
export const clearBufferImpl = (commandEncoder) => (buffer) =>
export const copyBufferToBufferImpl = (
commandEncoder,
source,
sourceOffset,
destination,
destinationOffset,
size
) =>
commandEncoder.copyBufferToBuffer(
source,
sourceOffset,
destination,
destinationOffset,
size
);
export const copyBufferToTextureImpl = (
commandEncoder,
source,
destination,
copySize
) => commandEncoder.copyBufferToTexture(source, destination, copySize);
export const copyTextureToBufferImpl = (
commandEncoder,
source,
destination,
copySize
) => commandEncoder.copyTextureToBuffer(source, destination, copySize);
export const copyTextureToTextureImpl = (
commandEncoder,
source,
destination,
copySize
) => commandEncoder.copyTextureToTexture(source, destination, copySize);
export const clearBufferImpl = (commandEncoder, buffer) =>
commandEncoder.clearBuffer(buffer);
export const clearBufferWithOffsetImpl = (commandEncoder) => (buffer, offset) =>
export const clearBufferWithOffsetImpl = (commandEncoder, buffer, offset) =>
commandEncoder.clearBuffer(buffer, offset);
export const clearBufferWithSizeImpl = (commandEncoder) => (buffer, size) =>
export const clearBufferWithSizeImpl = (commandEncoder, buffer, size) =>
commandEncoder.clearBuffer(buffer, undefined, size);
export const clearBufferWithOffsetAndSizeImpl =
(commandEncoder) => (buffer, offset, size) =>
commandEncoder.clearBuffer(buffer, offset, size);
export const writeTimestampImpl = (commandEncoder) => (querySet, queryIndex) =>
export const clearBufferWithOffsetAndSizeImpl = (
commandEncoder,
buffer,
offset,
size
) => commandEncoder.clearBuffer(buffer, offset, size);
export const writeTimestampImpl = (commandEncoder, querySet, queryIndex) =>
commandEncoder.writeTimestamp(querySet, queryIndex);
export const resolveQuerySetImpl =
(commandEncoder) =>
(querySet, firstQuery, queryCount, destination, destinationOffset) =>
commandEncoder.resolveQuerySet(
querySet,
firstQuery,
queryCount,
destination,
destinationOffset
);
export const finishImpl = (commandEncoder) => () => commandEncoder.finish();
export const pushDebugGroupImpl = (commandEncoder) => (groupLabel) =>
export const resolveQuerySetImpl = (
commandEncoder,
querySet,
firstQuery,
queryCount,
destination,
destinationOffset
) =>
commandEncoder.resolveQuerySet(
querySet,
firstQuery,
queryCount,
destination,
destinationOffset
);
export const finishImpl = commandEncoder => () => commandEncoder.finish();
export const pushDebugGroupImpl = (commandEncoder, groupLabel) =>
commandEncoder.pushDebugGroup(groupLabel);
export const popDebugGroupImpl = (commandEncoder) => () =>
export const popDebugGroupImpl = commandEncoder => () =>
commandEncoder.popDebugGroup();
export const insertDebugMarkerImpl = (commandEncoder) => (markerLabel) =>
export const insertDebugMarkerImpl = (commandEncoder, markerLabel) =>
commandEncoder.insertDebugMarker(markerLabel);
Loading