Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@webgpu/types

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webgpu/types - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

327

index.d.ts

@@ -1,4 +0,3 @@

// https://github.com/gpuweb/gpuweb/blob/15dadf3f218f1c51ff31ce1976653a99189b41d1/design/sketch.webidl
// plus #249 (pre-land)
// plus #261 (pre-land)
// https://github.com/gpuweb/gpuweb/blob/e0516e6bf994c23915462da3b5f434d7b85f72c5/spec/index.bs
// except #280 setSubData (TODO)

@@ -9,2 +8,30 @@ export {};

export interface GPUColorDict {
a: number;
b: number;
g: number;
r: number;
}
export type GPUColor = [number, number, number, number] | GPUColorDict;
export interface GPUOrigin2DDict {
x?: number;
y?: number;
}
export type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
export interface GPUOrigin3DDict {
x?: number;
y?: number;
z?: number;
}
export type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
export interface GPUExtent3DDict {
width: number;
height: number;
depth: number;
}
export type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
export type GPUBindingResource = GPUSampler | GPUTextureView | GPUBufferBinding;

@@ -18,7 +45,7 @@

| "uniform-buffer"
| "dynamic-uniform-buffer"
| "storage-buffer"
| "readonly-storage-buffer"
| "sampler"
| "sampled-texture"
| "storage-buffer"
| "dynamic-storage-buffer";
| "storage-texture";
export type GPUBlendFactor =

@@ -95,3 +122,2 @@ | "zero"

| "r8unorm"
| "r8unorm-srgb"
| "r8snorm"

@@ -106,7 +132,5 @@ | "r8uint"

| "rg8unorm"
| "rg8unorm-srgb"
| "rg8snorm"
| "rg8uint"
| "rg8sint"
| "b5g6r5unorm"
| "r32uint"

@@ -141,3 +165,5 @@ | "r32sint"

| "depth32float"
| "depth32float-stencil8";
| "depth32float-stencil8"
| "depth24plus"
| "depth24plus-stencil8";
export type GPUTextureViewDimension =

@@ -184,29 +210,29 @@ | "1d"

export enum GPUBufferUsage {
NONE = 0,
MAP_READ = 1,
MAP_WRITE = 2,
TRANSFER_SRC = 4,
TRANSFER_DST = 8,
INDEX = 16,
VERTEX = 32,
UNIFORM = 64,
STORAGE = 128,
NONE = 0x0000,
MAP_READ = 0x0001,
MAP_WRITE = 0x0002,
COPY_SRC = 0x0004,
COPY_DST = 0x0008,
INDEX = 0x0010,
VERTEX = 0x0020,
UNIFORM = 0x0040,
STORAGE = 0x0080,
}
export type GPUColorWriteFlags = number;
export enum GPUColorWriteBits {
NONE = 0,
RED = 1,
GREEN = 2,
BLUE = 4,
ALPHA = 8,
ALL = 15,
export enum GPUColorWrite {
NONE = 0x0,
RED = 0x1,
GREEN = 0x2,
BLUE = 0x4,
ALPHA = 0x8,
ALL = 0xF,
}
export type GPUShaderStageFlags = number;
export enum GPUShaderStageBit {
NONE = 0,
VERTEX = 1,
FRAGMENT = 2,
COMPUTE = 4,
export enum GPUShaderStage {
NONE = 0x0,
VERTEX = 0x1,
FRAGMENT = 0x2,
COMPUTE = 0x4,
}

@@ -223,8 +249,8 @@

export enum GPUTextureUsage {
NONE = 0,
TRANSFER_SRC = 1,
TRANSFER_DST = 2,
SAMPLED = 4,
STORAGE = 8,
OUTPUT_ATTACHMENT = 16,
NONE = 0x00,
COPY_SRC = 0x01,
COPY_DST = 0x02,
SAMPLED = 0x04,
STORAGE = 0x08,
OUTPUT_ATTACHMENT = 0x10,
}

@@ -237,3 +263,3 @@

export interface GPUBindGroupDescriptor {
export interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
layout: GPUBindGroupLayout;

@@ -247,5 +273,8 @@ bindings: GPUBindGroupBinding[];

type: GPUBindingType;
textureDimension?: GPUTextureViewDimension;
multisampled?: boolean;
dynamic?: boolean;
}
export interface GPUBindGroupLayoutDescriptor {
export interface GPUBindGroupLayoutDescriptor extends GPUObjectDescriptorBase {
bindings?: GPUBindGroupLayoutBinding[];

@@ -263,4 +292,4 @@ }

alphaBlend: GPUBlendDescriptor;
colorBlend: GPUBlendDescriptor;
alphaBlend?: GPUBlendDescriptor;
colorBlend?: GPUBlendDescriptor;
writeMask?: GPUColorWriteFlags;

@@ -272,3 +301,3 @@ }

offset?: number;
size: number;
size?: number;
}

@@ -283,3 +312,15 @@

export interface GPUBufferDescriptor {
export interface GPUTextureCopyView {
texture: GPUTexture;
mipLevel?: number;
arrayLayer?: number;
origin?: GPUOrigin3D;
}
export interface GPUImageBitmapCopyView {
imageBitmap: ImageBitmap;
origin?: GPUOrigin2D;
}
export interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
size: number;

@@ -289,10 +330,3 @@ usage: GPUBufferUsageFlags;

export interface GPUColor {
a: number;
b: number;
g: number;
r: number;
}
export interface GPUCommandEncoderDescriptor {
export interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
label?: string;

@@ -302,3 +336,3 @@ }

export interface GPUComputePipelineDescriptor extends GPUPipelineDescriptorBase {
computeStage: GPUPipelineStageDescriptor;
computeStage: GPUProgrammableStageDescriptor;
}

@@ -319,3 +353,3 @@

export interface GPUDeviceDescriptor {
export interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
extensions?: GPUExtensions;

@@ -329,9 +363,3 @@ limits?: GPULimits;

export interface GPUExtent3D {
width: number;
height: number;
depth: number;
}
export interface GPUFenceDescriptor {
export interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
initialValue?: number;

@@ -355,4 +383,4 @@ label?: string;

export interface GPUVertexInputDescriptor {
indexFormat: GPUIndexFormat;
vertexBuffers: GPUVertexBufferDescriptor[];
indexFormat?: GPUIndexFormat;
vertexBuffers: GPUVertexAttributeDescriptor[];
}

@@ -364,8 +392,2 @@

export interface GPUOrigin3D {
x?: number;
y?: number;
z?: number;
}
export interface GPUPipelineDescriptorBase {

@@ -376,7 +398,7 @@ label?: string;

export interface GPUPipelineLayoutDescriptor {
export interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
bindGroupLayouts: GPUBindGroupLayout[];
}
export interface GPUPipelineStageDescriptor {
export interface GPUProgrammableStageDescriptor {
module: GPUShaderModule;

@@ -387,3 +409,3 @@ entryPoint: string;

export interface GPURasterizationStateDescriptor {
frontFace: GPUFrontFace;
frontFace?: GPUFrontFace;
cullMode?: GPUCullMode;

@@ -397,3 +419,3 @@ depthBias?: number;

attachment: GPUTextureView;
resolveTarget?: GPUTextureView;
resolveTarget?: GPUTextureView | null;

@@ -417,22 +439,24 @@ loadOp: GPULoadOp;

export interface GPURenderPassDescriptor {
export interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
colorAttachments: GPURenderPassColorAttachmentDescriptor[];
depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor | null;
}
export interface GPURenderPipelineDescriptor extends GPUPipelineDescriptorBase {
vertexStage: GPUPipelineStageDescriptor;
fragmentStage?: GPUPipelineStageDescriptor;
vertexStage: GPUProgrammableStageDescriptor;
fragmentStage?: GPUProgrammableStageDescriptor | null;
primitiveTopology: GPUPrimitiveTopology;
rasterizationState: GPURasterizationStateDescriptor;
rasterizationState?: GPURasterizationStateDescriptor;
colorStates: GPUColorStateDescriptor[];
depthStencilState?: GPUDepthStencilStateDescriptor;
depthStencilState?: GPUDepthStencilStateDescriptor | null;
vertexInput: GPUVertexInputDescriptor;
sampleCount?: number;
sampleMask?: number;
alphaToCoverageEnabled?: boolean;
}
export interface GPUSamplerDescriptor {
compareFunction?: GPUCompareFunction;
export interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
compare?: GPUCompareFunction;
lodMaxClamp?: number;

@@ -449,4 +473,4 @@ lodMinClamp?: number;

export interface GPUShaderModuleDescriptor {
code: ArrayBufferView | string;
export interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
code: Uint32Array | string;
label?: string;

@@ -462,3 +486,3 @@ }

export interface GPUSwapChainDescriptor {
export interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
device: GPUDevice;

@@ -469,10 +493,3 @@ format: GPUTextureFormat;

export interface GPUTextureCopyView {
texture: GPUTexture;
mipLevel?: number;
arrayLayer?: number;
origin?: GPUOrigin3D;
}
export interface GPUTextureDescriptor {
export interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
size: GPUExtent3D;

@@ -487,3 +504,3 @@ arrayLayerCount?: number;

export interface GPUTextureViewDescriptor {
export interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
aspect: GPUTextureAspectFlags;

@@ -498,15 +515,15 @@ baseArrayLayer?: number;

export interface GPUAdapter {
export interface GPUAdapter extends GPUObjectBase {
readonly extensions: GPUExtensions;
readonly name: string;
requestDevice(descriptor: GPUDeviceDescriptor): Promise<GPUDevice>;
requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice>;
}
export interface GPUBindGroup extends GPUDebugLabel {
export interface GPUBindGroup extends GPUObjectBase {
}
export interface GPUBindGroupLayout extends GPUDebugLabel {
export interface GPUBindGroupLayout extends GPUObjectBase {
}
export interface GPUBuffer extends GPUDebugLabel {
export interface GPUBuffer extends GPUObjectBase {
//readonly mapping: ArrayBuffer | null;

@@ -518,16 +535,28 @@ destroy(): void;

mapReadAsync(): Promise<ArrayBuffer>;
// TODO: Remove setSubData (#280)
setSubData(offset: number, src: ArrayBufferView, srcOffset?: number, byteLength?: number): void;
}
export interface GPUCommandEncoder extends GPUDebugLabel {
beginComputePass(): GPUComputePassEncoder;
export interface GPUCommandBuffer extends GPUObjectBase {
}
export interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase {
}
export interface GPUCommandEncoder extends GPUObjectBase {
beginComputePass(descriptor?: GPUComputePassDescriptor): GPUComputePassEncoder;
beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
copyBufferToBuffer(src: GPUBuffer, srcOffset: number, dst: GPUBuffer, dstOffset: number, size: number): void;
copyBufferToBuffer(source: GPUBuffer, sourceOffset: number, destination: GPUBuffer, destinationOffset: number, size: number): void;
copyBufferToTexture(source: GPUBufferCopyView, destination: GPUTextureCopyView, copySize: GPUExtent3D): void;
copyTextureToBuffer(source: GPUTextureCopyView, destination: GPUBufferCopyView, copySize: GPUExtent3D): void;
copyTextureToTexture(source: GPUTextureCopyView, destination: GPUTextureCopyView, copySize: GPUExtent3D): void;
finish(): GPUCommandBuffer;
copyImageBitmapToTexture(source: GPUImageBitmapCopyView, destination: GPUTextureCopyView, copySize: GPUExtent3D): void;
finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
popDebugGroup(): void;
pushDebugGroup(groupLabel: string): void;
insertDebugMarker(markerLabel: string): void;
}
export interface GPUCommandBuffer extends GPUDebugLabel {
export interface GPUComputePassDescriptor extends GPUObjectDescriptorBase {
}

@@ -537,12 +566,19 @@

setPipeline(pipeline: GPUComputePipeline): void;
dispatch(x: number, y: number, z: number): void;
dispatch(x: number, y?: number, z?: number): void;
dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
endPass(): void;
}
export interface GPUComputePipeline extends GPUDebugLabel {
export interface GPUComputePipeline extends GPUObjectBase {
}
export interface GPUDebugLabel {
export interface GPUObjectBase {
label: string | undefined;
}
export interface GPUObjectDescriptorBase {
label?: string;
}
// SwapChain / CanvasContext

@@ -555,3 +591,3 @@ export interface GPUCanvasContext {

export interface GPUDevice {
export interface GPUDevice extends GPUObjectBase {
readonly adapter: GPUAdapter;

@@ -564,12 +600,14 @@ readonly extensions: GPUExtensions;

createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
//createBufferMapped(descriptor: GPUBufferDescriptor): GPUBuffer;
//createBufferMappedAsync(descriptor: GPUBufferDescriptor): GPUBuffer;
createCommandEncoder(descriptor: GPUCommandEncoderDescriptor): GPUCommandEncoder;
createBufferMapped(descriptor: GPUBufferDescriptor): [GPUBuffer, ArrayBuffer];
createBufferMappedAsync(descriptor: GPUBufferDescriptor): Promise<[GPUBuffer, ArrayBuffer]>;
createComputePipeline(descriptor: GPUComputePipelineDescriptor): GPUComputePipeline;
createPipelineLayout(descriptor: GPUPipelineLayoutDescriptor): GPUPipelineLayout;
createRenderPipeline(descriptor: GPURenderPipelineDescriptor): GPURenderPipeline;
createSampler(descriptor: GPUSamplerDescriptor): GPUSampler;
createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
createCommandEncoder(descriptor?: GPUCommandEncoderDescriptor): GPUCommandEncoder;
createRenderBundleEncoder(descriptor: GPURenderBundleEncoderDescriptor): GPURenderBundleEncoder;
getQueue(): GPUQueue;

@@ -580,3 +618,3 @@

export interface GPUFence extends GPUDebugLabel {
export interface GPUFence extends GPUObjectBase {
getCompletedValue(): number;

@@ -586,51 +624,78 @@ onCompletion(completionValue: number): Promise<void>;

export interface GPUPipelineLayout extends GPUDebugLabel {
export interface GPUPipelineLayout extends GPUObjectBase {
}
export interface GPUProgrammablePassEncoder extends GPUDebugLabel {
endPass(): void;
insertDebugMarker(markerLabel: string): void;
export interface GPUProgrammablePassEncoder extends GPUObjectBase {
setBindGroup(index: number, bindGroup: GPUBindGroup): void;
popDebugGroup(): void;
pushDebugGroup(groupLabel: string): void;
setBindGroup(index: number, bindGroup: GPUBindGroup): void;
insertDebugMarker(markerLabel: string): void;
}
export interface GPUQueue extends GPUDebugLabel {
export interface GPUQueue extends GPUObjectBase {
signal(fence: GPUFence, signalValue: number): void;
submit(buffers: GPUCommandBuffer[]): void;
createFence(descriptor: GPUFenceDescriptor): GPUFence;
createFence(descriptor?: GPUFenceDescriptor): GPUFence;
}
export interface GPURenderPassEncoder extends GPUProgrammablePassEncoder {
export interface GPURenderEncoderBase extends GPUProgrammablePassEncoder {
setPipeline(pipeline: GPURenderPipeline): void;
setIndexBuffer(buffer: GPUBuffer, offset: number): void;
setVertexBuffers(startSlot: number, buffers: GPUBuffer[], offsets: number[]): void;
draw(vertexCount: number, instanceCount: number, firstVertex: number, firstInstance: number): void;
drawIndexed(indexCount: number, instanceCount: number, firstIndex: number, baseVertex: number, firstInstance: number): void;
drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
}
export interface GPURenderPassEncoder extends GPURenderEncoderBase {
setViewport(x: number, y: number, width: number, height: number, minDepth: number, maxDepth: number): void;
setScissorRect(x: number, y: number, width: number, height: number): void;
setBlendColor(color: GPUColor): void;
setIndexBuffer(buffer: GPUBuffer, offset: number): void;
setScissorRect(x: number, y: number, width: number, height: number): void;
setStencilReference(reference: number): void;
setVertexBuffers(startSlot: number, buffers: GPUBuffer[], offsets: number[]): void;
setViewport(x: number, y: number, width: number, height: number, minDepth: number, maxDepth: number): void;
executeBundles(bundles: GPURenderBundle[]): void;
endPass(): void;
}
export interface GPURenderPipeline extends GPUDebugLabel {
export interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase {
}
export interface GPUSampler extends GPUDebugLabel {
export interface GPURenderBundle extends GPUObjectBase {
}
export interface GPUShaderModule extends GPUDebugLabel {
export interface GPURenderBundleEncoder extends GPURenderEncoderBase {
}
export interface GPUSwapChain {
export interface GPURenderBundleEncoderDescriptor extends GPUObjectDescriptorBase {
colorFormats: GPUTextureFormat[];
depthStencilFormat: GPUTextureFormat;
sampleCount?: number;
}
export interface GPURenderPipeline extends GPUObjectBase {
}
export interface GPUSampler extends GPUObjectBase {
}
export interface GPUShaderModule extends GPUObjectBase {
}
export interface GPUSwapChain extends GPUObjectBase {
getCurrentTexture(): GPUTexture;
}
export interface GPUTexture extends GPUDebugLabel {
export interface GPUTexture extends GPUObjectBase {
createDefaultView(): GPUTextureView;
createView(desc: GPUTextureViewDescriptor): GPUTextureView;
createView(descriptor: GPUTextureViewDescriptor): GPUTextureView;
destroy(): void;
}
export interface GPUTextureView extends GPUDebugLabel {
export interface GPUTextureView extends GPUObjectBase {
}

@@ -676,2 +741,3 @@

// ****************************************************************************
export interface GPUUncapturedErrorEvent extends Event {

@@ -685,3 +751,2 @@ readonly error: GPUError;

// TODO: is it possible to expose the EventTarget only on the main thread?
export interface GPUDevice extends EventTarget {

@@ -688,0 +753,0 @@ onuncapturederror: Event | undefined;

{
"name": "@webgpu/types",
"version": "0.0.4",
"version": "0.0.5",
"main": "",
"license": "Apache-2.0"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc