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

@antv/g-device-api

Package Overview
Dependencies
Maintainers
64
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-device-api - npm Package Compare versions

Comparing version 1.4.4 to 1.4.5

11

dist/webgl/Device.d.ts

@@ -5,2 +5,13 @@ import { Bindings, BindingsDescriptor, Buffer, BufferDescriptor, ComputePass, ComputePipeline, ComputePipelineDescriptor, Device, DeviceLimits, IndexBufferDescriptor, InputLayout, InputLayoutDescriptor, PlatformFramebuffer, Program, ProgramDescriptor, QueryPool, QueryPoolType, Readback, RenderPass, RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor, RenderTarget, RenderTargetDescriptor, Resource, Sampler, SamplerDescriptor, SwapChain, Texture, TextureDescriptor, VendorInfo, VertexBufferDescriptor } from '../api';

import { Program_GL } from './Program';
/**
* Extract uniform blocks from shader source.
*
* @example
* ```glsl
* layout(std140) uniform CommonUniforms {
float u_blur;
};
* ```
*/
export declare const UNIFROM_BLOCK_REGEXP: RegExp;
export declare class Device_GL implements SwapChain, Device {

@@ -7,0 +18,0 @@ private shaderDebug;

@@ -5,2 +5,13 @@ import { Bindings, BindingsDescriptor, Buffer, BufferDescriptor, ComputePass, ComputePipeline, ComputePipelineDescriptor, Device, DeviceLimits, IndexBufferDescriptor, InputLayout, InputLayoutDescriptor, PlatformFramebuffer, Program, ProgramDescriptor, QueryPool, QueryPoolType, Readback, RenderPass, RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor, RenderTarget, RenderTargetDescriptor, Resource, Sampler, SamplerDescriptor, SwapChain, Texture, TextureDescriptor, VendorInfo, VertexBufferDescriptor } from '../api';

import { Program_GL } from './Program';
/**
* Extract uniform blocks from shader source.
*
* @example
* ```glsl
* layout(std140) uniform CommonUniforms {
float u_blur;
};
* ```
*/
export declare const UNIFROM_BLOCK_REGEXP: RegExp;
export declare class Device_GL implements SwapChain, Device {

@@ -7,0 +18,0 @@ private shaderDebug;

@@ -5,2 +5,13 @@ import { Bindings, BindingsDescriptor, Buffer, BufferDescriptor, ComputePass, ComputePipeline, ComputePipelineDescriptor, Device, DeviceLimits, IndexBufferDescriptor, InputLayout, InputLayoutDescriptor, PlatformFramebuffer, Program, ProgramDescriptor, QueryPool, QueryPoolType, Readback, RenderPass, RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor, RenderTarget, RenderTargetDescriptor, Resource, Sampler, SamplerDescriptor, SwapChain, Texture, TextureDescriptor, VendorInfo, VertexBufferDescriptor } from '../api';

import { Program_GL } from './Program';
/**
* Extract uniform blocks from shader source.
*
* @example
* ```glsl
* layout(std140) uniform CommonUniforms {
float u_blur;
};
* ```
*/
export declare const UNIFROM_BLOCK_REGEXP: RegExp;
export declare class Device_GL implements SwapChain, Device {

@@ -7,0 +18,0 @@ private shaderDebug;

2

package.json
{
"name": "@antv/g-device-api",
"version": "1.4.4",
"version": "1.4.5",
"description": "A Device API references WebGPU implementations",

@@ -5,0 +5,0 @@ "keywords": [

@@ -12,5 +12,6 @@ # @antv/g-device-api

- [API](#api)
- [Shader Language](#shader-language)
- [Observable Examples](https://observablehq.com/@antv/g-device-api)
- [API](#api)
- [Shader Language](#shader-language)
- [Observable Examples](https://observablehq.com/@antv/g-device-api)
- [Limitations](#limitations)

@@ -25,68 +26,68 @@ ## Installing

- [Create a device](#createDevice)
- Resource Creation
- [Create a device](#createDevice)
- Resource Creation
- [createBuffer](#createBuffer)
- [createTexture](#createTexture)
- [createSampler](#createSampler)
- [createRenderTarget](#createRenderTarget)
- [createRenderTargetFromTexture](#createRenderTargetFromTexture)
- [createProgram](#createProgram)
- [createBindings](#createBindings)
- [createInputLayout](#createInputLayout)
- [createRenderPipeline](#createRenderPipeline)
- [createComputePipeline](#createComputePipeline)
- [createReadback](#createReadback)
- [createQueryPool](#createQueryPool)
- [createRenderPass](#createRenderPass)
- [createComputePass](#createComputePass)
- [createBuffer](#createBuffer)
- [createTexture](#createTexture)
- [createSampler](#createSampler)
- [createRenderTarget](#createRenderTarget)
- [createRenderTargetFromTexture](#createRenderTargetFromTexture)
- [createProgram](#createProgram)
- [createBindings](#createBindings)
- [createInputLayout](#createInputLayout)
- [createRenderPipeline](#createRenderPipeline)
- [createComputePipeline](#createComputePipeline)
- [createReadback](#createReadback)
- [createQueryPool](#createQueryPool)
- [createRenderPass](#createRenderPass)
- [createComputePass](#createComputePass)
- Submit
- [submitPass](#submitPass)
- [copySubTexture2D](#copySubTexture2D)
- Query
- [queryLimits](#queryLimits)
- [queryTextureFormatSupported](#queryTextureFormatSupported)
- [queryPlatformAvailable](#queryPlatformAvailable)
- [queryVendorInfo](#queryVendorInfo)
- Debug
- Submit
- [submitPass](#submitPass)
- [copySubTexture2D](#copySubTexture2D)
- Query
- [queryLimits](#queryLimits)
- [queryTextureFormatSupported](#queryTextureFormatSupported)
- [queryPlatformAvailable](#queryPlatformAvailable)
- [queryVendorInfo](#queryVendorInfo)
- Debug
- [setResourceName](#setResourceName)
- [checkForLeaks](#checkForLeaks)
- [pushDebugGroup](#pushDebugGroup)
- [popDebugGroup](#popDebugGroup)
- [setResourceName](#setResourceName)
- [checkForLeaks](#checkForLeaks)
- [pushDebugGroup](#pushDebugGroup)
- [popDebugGroup](#popDebugGroup)
- GPU Resources
- [Buffer](#buffer)
- [setSubData](#setSubData)
- [Texture](#texture)
- [setImageData](#setImageData)
- [Sampler](#sampler)
- [RenderTarget](#renderTarget)
- [RenderPass](#renderPass)
- [setViewport](#setViewport)
- [setScissorRect](#setScissorRect)
- [setPipeline](#setPipeline)
- [setBindings](#setBindings)
- [setVertexInput](#setVertexInput)
- [setStencilReference](#setStencilReference)
- [draw](#draw)
- [drawIndexed](#drawIndexed)
- [drawIndirect](#drawIndirect)
- [drawIndexedIndirect](#drawIndexedIndirect)
- [beginOcclusionQuery](#beginOcclusionQuery)
- [endOcclusionQuery](#endOcclusionQuery)
- [ComputePass](#computePass)
- [setPipeline](#setPipeline)
- [setBindings](#setBindings)
- [dispatchWorkgroups](#dispatchWorkgroups)
- [dispatchWorkgroupsIndirect](#dispatchWorkgroupsIndirect)
- Program
- [setUniformsLegacy](#setUniformsLegacy)
- QueryPool
- queryResultOcclusion
- [Readback](#readback)
- [readTexture](#readTexture)
- [readTextureSync](#readTextureSync)
- [readBuffer](#readBuffer)
- GPU Resources
- [Buffer](#buffer)
- [setSubData](#setSubData)
- [Texture](#texture)
- [setImageData](#setImageData)
- [Sampler](#sampler)
- [RenderTarget](#renderTarget)
- [RenderPass](#renderPass)
- [setViewport](#setViewport)
- [setScissorRect](#setScissorRect)
- [setPipeline](#setPipeline)
- [setBindings](#setBindings)
- [setVertexInput](#setVertexInput)
- [setStencilReference](#setStencilReference)
- [draw](#draw)
- [drawIndexed](#drawIndexed)
- [drawIndirect](#drawIndirect)
- [drawIndexedIndirect](#drawIndexedIndirect)
- [beginOcclusionQuery](#beginOcclusionQuery)
- [endOcclusionQuery](#endOcclusionQuery)
- [ComputePass](#computePass)
- [setPipeline](#setPipeline)
- [setBindings](#setBindings)
- [dispatchWorkgroups](#dispatchWorkgroups)
- [dispatchWorkgroupsIndirect](#dispatchWorkgroupsIndirect)
- Program
- [setUniformsLegacy](#setUniformsLegacy)
- QueryPool
- queryResultOcclusion
- [Readback](#readback)
- [readTexture](#readTexture)
- [readTextureSync](#readTextureSync)
- [readBuffer](#readBuffer)

@@ -99,6 +100,6 @@ ### <a id='createDevice' />Create Device

import {
Device,
BufferUsage,
WebGLDeviceContribution,
WebGPUDeviceContribution,
Device,
BufferUsage,
WebGLDeviceContribution,
WebGPUDeviceContribution,
} from '@antv/g-device-api';

@@ -108,7 +109,7 @@

const deviceContribution = new WebGLDeviceContribution({
targets: ['webgl2', 'webgl1'],
targets: ['webgl2', 'webgl1'],
});
// Or create a WebGPU based device contribution.
const deviceContribution = new WebGPUDeviceContribution({
shaderCompilerPath: '/glsl_wgsl_compiler_bg.wasm',
shaderCompilerPath: '/glsl_wgsl_compiler_bg.wasm',
});

@@ -133,11 +134,11 @@

- viewOrSize `required` Set buffer data directly or allocate fixed length(in bytes).
- usage `required` The allowed usage for this buffer.
- hint `optional` Known as hint when calling [bufferData](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData#usage) in WebGL.
- viewOrSize `required` Set buffer data directly or allocate fixed length(in bytes).
- usage `required` The allowed usage for this buffer.
- hint `optional` Known as hint when calling [bufferData](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData#usage) in WebGL.
```ts
interface BufferDescriptor {
viewOrSize: ArrayBufferView | number;
usage: BufferUsage;
hint?: BufferFrequencyHint;
viewOrSize: ArrayBufferView | number;
usage: BufferUsage;
hint?: BufferFrequencyHint;
}

@@ -150,4 +151,4 @@ ```

const buffer = device.createBuffer({
viewOrSize: new Float32Array([1, 2, 3, 4]),
usage: BufferUsage.VERTEX,
viewOrSize: new Float32Array([1, 2, 3, 4]),
usage: BufferUsage.VERTEX,
});

@@ -157,4 +158,4 @@

const buffer = device.createBuffer({
viewOrSize: 4 * Float32Array.BYTES_PER_ELEMENT, // in bytes
usage: BufferUsage.VERTEX,
viewOrSize: 4 * Float32Array.BYTES_PER_ELEMENT, // in bytes
usage: BufferUsage.VERTEX,
});

@@ -169,12 +170,12 @@ buffer.setSubData(0, new Uint8Array(new Float32Array([1, 2, 3, 4]).buffer));

enum BufferUsage {
MAP_READ = 0x0001,
MAP_WRITE = 0x0002,
COPY_SRC = 0x0004,
COPY_DST = 0x0008,
INDEX = 0x0010,
VERTEX = 0x0020,
UNIFORM = 0x0040,
STORAGE = 0x0080,
INDIRECT = 0x0100,
QUERY_RESOLVE = 0x0200,
MAP_READ = 0x0001,
MAP_WRITE = 0x0002,
COPY_SRC = 0x0004,
COPY_DST = 0x0008,
INDEX = 0x0010,
VERTEX = 0x0020,
UNIFORM = 0x0040,
STORAGE = 0x0080,
INDIRECT = 0x0100,
QUERY_RESOLVE = 0x0200,
}

@@ -187,4 +188,4 @@ ```

enum BufferFrequencyHint {
Static = 0x01,
Dynamic = 0x02,
Static = 0x01,
Dynamic = 0x02,
}

@@ -205,28 +206,28 @@ ```

interface TextureDescriptor {
usage: TextureUsage;
format: Format;
width: number;
height: number;
depthOrArrayLayers?: number;
dimension?: TextureDimension;
mipLevelCount?: number;
pixelStore?: Partial<{
packAlignment: number;
unpackAlignment: number;
unpackFlipY: boolean;
}>;
usage: TextureUsage;
format: Format;
width: number;
height: number;
depthOrArrayLayers?: number;
dimension?: TextureDimension;
mipLevelCount?: number;
pixelStore?: Partial<{
packAlignment: number;
unpackAlignment: number;
unpackFlipY: boolean;
}>;
}
```
- usage `required` The allowed usages for this GPUTexture.
- format `required` The format of this GPUTexture.
- width `required` The width of this GPUTexture.
- height `required` The height of this GPUTexture.
- depthOrArrayLayers `optional` The depth or layer count of this GPUTexture. Defaulting to `1`.
- dimension `optional` The dimension of the set of texel for each of this GPUTexture's subresources. Defaulting to `TextureDimension.TEXTURE_2D`
- mipLevelCount `optional` The number of mip levels of this GPUTexture. Defaulting to `1`.
- pixelStore `optional` Specifies the [pixel storage modes](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/pixelStorei) in WebGL.
- packAlignment Packing of pixel data into memory. `gl.PACK_ALIGNMENT`
- unpackAlignment Unpacking of pixel data from memory. `gl.UNPACK_ALIGNMENT`
- unpackFlipY Flips the source data along its vertical axis if true. `gl.UNPACK_FLIP_Y_WEBGL`
- usage `required` The allowed usages for this GPUTexture.
- format `required` The format of this GPUTexture.
- width `required` The width of this GPUTexture.
- height `required` The height of this GPUTexture.
- depthOrArrayLayers `optional` The depth or layer count of this GPUTexture. Defaulting to `1`.
- dimension `optional` The dimension of the set of texel for each of this GPUTexture's subresources. Defaulting to `TextureDimension.TEXTURE_2D`
- mipLevelCount `optional` The number of mip levels of this GPUTexture. Defaulting to `1`.
- pixelStore `optional` Specifies the [pixel storage modes](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/pixelStorei) in WebGL.
- packAlignment Packing of pixel data into memory. `gl.PACK_ALIGNMENT`
- unpackAlignment Unpacking of pixel data from memory. `gl.UNPACK_ALIGNMENT`
- unpackFlipY Flips the source data along its vertical axis if true. `gl.UNPACK_FLIP_Y_WEBGL`

@@ -237,4 +238,4 @@ The `TextureUsage` enum is as follows:

enum TextureUsage {
SAMPLED,
RENDER_TARGET, // When rendering to texture, choose this usage.
SAMPLED,
RENDER_TARGET, // When rendering to texture, choose this usage.
}

@@ -247,6 +248,6 @@ ```

enum TextureDimension {
TEXTURE_2D,
TEXTURE_2D_ARRAY,
TEXTURE_3D,
TEXTURE_CUBE_MAP,
TEXTURE_2D,
TEXTURE_2D_ARRAY,
TEXTURE_3D,
TEXTURE_CUBE_MAP,
}

@@ -267,12 +268,12 @@ ```

interface SamplerDescriptor {
addressModeU: AddressMode;
addressModeV: AddressMode;
addressModeW?: AddressMode;
minFilter: FilterMode;
magFilter: FilterMode;
mipmapFilter: MipmapFilterMode;
lodMinClamp?: number;
lodMaxClamp?: number;
maxAnisotropy?: number;
compareFunction?: CompareFunction;
addressModeU: AddressMode;
addressModeV: AddressMode;
addressModeW?: AddressMode;
minFilter: FilterMode;
magFilter: FilterMode;
mipmapFilter: MipmapFilterMode;
lodMinClamp?: number;
lodMaxClamp?: number;
maxAnisotropy?: number;
compareFunction?: CompareFunction;
}

@@ -285,5 +286,5 @@ ```

enum AddressMode {
CLAMP_TO_EDGE,
REPEAT,
MIRRORED_REPEAT,
CLAMP_TO_EDGE,
REPEAT,
MIRRORED_REPEAT,
}

@@ -296,9 +297,9 @@ ```

enum FilterMode {
POINT,
BILINEAR,
POINT,
BILINEAR,
}
enum MipmapFilterMode {
NO_MIP,
NEAREST,
LINEAR,
NO_MIP,
NEAREST,
LINEAR,
}

@@ -311,10 +312,10 @@ ```

enum CompareFunction {
NEVER = GL.NEVER,
LESS = GL.LESS,
EQUAL = GL.EQUAL,
LEQUAL = GL.LEQUAL,
GREATER = GL.GREATER,
NOTEQUAL = GL.NOTEQUAL,
GEQUAL = GL.GEQUAL,
ALWAYS = GL.ALWAYS,
NEVER = GL.NEVER,
LESS = GL.LESS,
EQUAL = GL.EQUAL,
LEQUAL = GL.LEQUAL,
GREATER = GL.GREATER,
NOTEQUAL = GL.NOTEQUAL,
GEQUAL = GL.GEQUAL,
ALWAYS = GL.ALWAYS,
}

@@ -331,7 +332,7 @@ ```

interface RenderTargetDescriptor {
format: Format;
width: number;
height: number;
sampleCount: number;
texture?: Texture;
format: Format;
width: number;
height: number;
sampleCount: number;
texture?: Texture;
}

@@ -357,13 +358,13 @@ ```

interface ProgramDescriptor {
vertex?: {
glsl?: string;
wgsl?: string;
};
fragment?: {
glsl?: string;
wgsl?: string;
};
compute?: {
wgsl: string;
};
vertex?: {
glsl?: string;
wgsl?: string;
};
fragment?: {
glsl?: string;
wgsl?: string;
};
compute?: {
wgsl: string;
};
}

@@ -380,7 +381,7 @@ ```

interface BindingsDescriptor {
bindingLayout: BindingLayoutDescriptor;
pipeline?: RenderPipeline | ComputePipeline;
uniformBufferBindings?: BufferBinding[];
samplerBindings?: SamplerBinding[];
storageBufferBindings?: BufferBinding[];
bindingLayout: BindingLayoutDescriptor;
pipeline?: RenderPipeline | ComputePipeline;
uniformBufferBindings?: BufferBinding[];
samplerBindings?: SamplerBinding[];
storageBufferBindings?: BufferBinding[];
}

@@ -391,13 +392,13 @@ ```

- binding `required` Should match the `binding` in shader.
- buffer `required`
- offset `optional` The offset, in bytes, from the beginning of buffer to the beginning of the range exposed to the shader by the buffer binding. Defaulting to `0`.
- size `optional` The size, in bytes, of the buffer binding. If not provided, specifies the range starting at offset and ending at the end of buffer.
- binding `required` Should match the `binding` in shader.
- buffer `required`
- offset `optional` The offset, in bytes, from the beginning of buffer to the beginning of the range exposed to the shader by the buffer binding. Defaulting to `0`.
- size `optional` The size, in bytes, of the buffer binding. If not provided, specifies the range starting at offset and ending at the end of buffer.
```ts
interface BufferBinding {
binding: number;
buffer: Buffer;
offset?: number;
size?: number;
binding: number;
buffer: Buffer;
offset?: number;
size?: number;
}

@@ -412,3 +413,3 @@ ```

createInputLayout: (inputLayoutDescriptor: InputLayoutDescriptor) =>
InputLayout;
InputLayout;
```

@@ -420,25 +421,25 @@

interface InputLayoutDescriptor {
vertexBufferDescriptors: (InputLayoutBufferDescriptor | null)[];
indexBufferFormat: Format | null;
program: Program;
vertexBufferDescriptors: (InputLayoutBufferDescriptor | null)[];
indexBufferFormat: Format | null;
program: Program;
}
interface InputLayoutBufferDescriptor {
arrayStride: number; // in bytes
stepMode: VertexStepMode; // per vertex or instance
attributes: VertexAttributeDescriptor[];
arrayStride: number; // in bytes
stepMode: VertexStepMode; // per vertex or instance
attributes: VertexAttributeDescriptor[];
}
interface VertexAttributeDescriptor {
shaderLocation: number;
format: Format;
offset: number;
divisor?: number;
shaderLocation: number;
format: Format;
offset: number;
divisor?: number;
}
```
- shaderLocation `required` The numeric location associated with this attribute, which will correspond with a "@location" attribute declared in the vertex.module.
- format `required` The VertexFormat of the attribute.
- offset `required` The offset, in bytes, from the beginning of the element to the data for the attribute.
- divisor `optional`
- shaderLocation `required` The numeric location associated with this attribute, which will correspond with a "@location" attribute declared in the vertex.module.
- format `required` The VertexFormat of the attribute.
- offset `required` The offset, in bytes, from the beginning of the element to the data for the attribute.
- divisor `optional`

@@ -455,7 +456,7 @@ ### <a id="createReadback" />createReadback

readBuffer: (
b: Buffer,
srcByteOffset?: number,
dst?: ArrayBufferView,
dstOffset?: number,
length?: number,
b: Buffer,
srcByteOffset?: number,
dst?: ArrayBufferView,
dstOffset?: number,
length?: number,
) => Promise<ArrayBufferView>;

@@ -491,15 +492,15 @@ ```

- colorAttachmentFormats `required` The formats of color attachment.
- topology `optional` The type of primitive to be constructed from the vertex inputs. Defaulting to `TRIANGLES`:
- megaStateDescriptor `optional`
- depthStencilAttachmentFormat `optional` The format of depth & stencil attachment.
- sampleCount `optional` Used in MSAA, defaulting to `1`.
- colorAttachmentFormats `required` The formats of color attachment.
- topology `optional` The type of primitive to be constructed from the vertex inputs. Defaulting to `TRIANGLES`:
- megaStateDescriptor `optional`
- depthStencilAttachmentFormat `optional` The format of depth & stencil attachment.
- sampleCount `optional` Used in MSAA, defaulting to `1`.
```ts
interface RenderPipelineDescriptor extends PipelineDescriptor {
topology?: PrimitiveTopology;
megaStateDescriptor?: MegaStateDescriptor;
colorAttachmentFormats: (Format | null)[];
depthStencilAttachmentFormat?: Format | null;
sampleCount?: number;
topology?: PrimitiveTopology;
megaStateDescriptor?: MegaStateDescriptor;
colorAttachmentFormats: (Format | null)[];
depthStencilAttachmentFormat?: Format | null;
sampleCount?: number;
}

@@ -510,7 +511,7 @@ ```

enum PrimitiveTopology {
POINTS,
TRIANGLES,
TRIANGLE_STRIP,
LINES,
LINE_STRIP,
POINTS,
TRIANGLES,
TRIANGLE_STRIP,
LINES,
LINE_STRIP,
}

@@ -521,12 +522,12 @@ ```

interface MegaStateDescriptor {
attachmentsState: AttachmentState[];
blendConstant?: Color;
depthCompare?: CompareFunction;
depthWrite?: boolean;
stencilFront?: Partial<StencilFaceState>;
stencilBack?: Partial<StencilFaceState>;
stencilWrite?: boolean;
cullMode?: CullMode;
frontFace?: FrontFace;
polygonOffset?: boolean;
attachmentsState: AttachmentState[];
blendConstant?: Color;
depthCompare?: CompareFunction;
depthWrite?: boolean;
stencilFront?: Partial<StencilFaceState>;
stencilBack?: Partial<StencilFaceState>;
stencilWrite?: boolean;
cullMode?: CullMode;
frontFace?: FrontFace;
polygonOffset?: boolean;
}

@@ -539,3 +540,3 @@ ```

createComputePipeline: (descriptor: ComputePipelineDescriptor) =>
ComputePipeline;
ComputePipeline;
```

@@ -546,5 +547,5 @@

interface PipelineDescriptor {
bindingLayouts: BindingLayoutDescriptor[];
inputLayout: InputLayout | null;
program: Program;
bindingLayouts: BindingLayoutDescriptor[];
inputLayout: InputLayout | null;
program: Program;
}

@@ -563,14 +564,14 @@ ```

export interface RenderPassDescriptor {
colorAttachment: (RenderTarget | null)[];
colorAttachmentLevel?: number[];
colorClearColor?: (Color | 'load')[];
colorResolveTo: (Texture | null)[];
colorResolveToLevel?: number[];
colorStore?: boolean[];
depthStencilAttachment?: RenderTarget | null;
depthStencilResolveTo?: Texture | null;
depthStencilStore?: boolean;
depthClearValue?: number | 'load';
stencilClearValue?: number | 'load';
occlusionQueryPool?: QueryPool | null;
colorAttachment: (RenderTarget | null)[];
colorAttachmentLevel?: number[];
colorClearColor?: (Color | 'load')[];
colorResolveTo: (Texture | null)[];
colorResolveToLevel?: number[];
colorStore?: boolean[];
depthStencilAttachment?: RenderTarget | null;
depthStencilResolveTo?: Texture | null;
depthStencilStore?: boolean;
depthClearValue?: number | 'load';
stencilClearValue?: number | 'load';
occlusionQueryPool?: QueryPool | null;
}

@@ -608,5 +609,5 @@ ```

- ⚠️WebGL 1 not supported
- WebGL 2 uses [blitFramebuffer](https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/blitFramebuffer)
- WebGPU uses [copyTextureToTexture](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToTexture)
- ⚠️WebGL 1 not supported
- WebGL 2 uses [blitFramebuffer](https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/blitFramebuffer)
- WebGPU uses [copyTextureToTexture](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToTexture)

@@ -622,7 +623,7 @@ ### <a id="queryLimits" />queryLimits

interface DeviceLimits {
uniformBufferWordAlignment: number;
uniformBufferMaxPageWordSize: number;
supportedSampleCounts: number[];
occlusionQueriesRecommended: boolean;
computeShadersSupported: boolean;
uniformBufferWordAlignment: number;
uniformBufferMaxPageWordSize: number;
supportedSampleCounts: number[];
occlusionQueriesRecommended: boolean;
computeShadersSupported: boolean;
}

@@ -653,5 +654,5 @@ ```

const shadowsSupported = device.queryTextureFormatSupported(
Format.U16_RG_NORM,
0,
0,
Format.U16_RG_NORM,
0,
0,
);

@@ -670,9 +671,9 @@ ```

interface VendorInfo {
readonly platformString: string;
readonly glslVersion: string;
readonly explicitBindingLocations: boolean;
readonly separateSamplerTextures: boolean;
readonly viewportOrigin: ViewportOrigin;
readonly clipSpaceNearZ: ClipSpaceNearZ;
readonly supportMRT: boolean;
readonly platformString: string;
readonly glslVersion: string;
readonly explicitBindingLocations: boolean;
readonly separateSamplerTextures: boolean;
readonly viewportOrigin: ViewportOrigin;
readonly clipSpaceNearZ: ClipSpaceNearZ;
readonly supportMRT: boolean;
}

@@ -720,7 +721,7 @@ ```

interface DebugGroup {
name: string;
drawCallCount: number;
textureBindCount: number;
bufferUploadCount: number;
triangleCount: number;
name: string;
drawCallCount: number;
textureBindCount: number;
bufferUploadCount: number;
triangleCount: number;
}

@@ -741,6 +742,6 @@ ```

- dstByteOffset `required` Offset of dest buffer in bytes.
- src `required` Source buffer data, must use Uint8Array.
- srcByteOffset `optional` Offset of src buffer in bytes. Defaulting to `0`.
- byteLength `optional` Defaulting to the whole length of the src buffer.
- dstByteOffset `required` Offset of dest buffer in bytes.
- src `required` Source buffer data, must use Uint8Array.
- srcByteOffset `optional` Offset of src buffer in bytes. Defaulting to `0`.
- byteLength `optional` Defaulting to the whole length of the src buffer.

@@ -764,4 +765,4 @@ ```ts

- data `required` Array of TexImageSource or ArrayBufferView.
- lod `optional` Lod. Defaulting to `0`.
- data `required` Array of TexImageSource or ArrayBufferView.
- lod `optional` Lod. Defaulting to `0`.

@@ -780,18 +781,18 @@ ```ts

const imageBitmaps = await Promise.all(
[
'/images/posx.jpg',
'/images/negx.jpg',
'/images/posy.jpg',
'/images/negy.jpg',
'/images/posz.jpg',
'/images/negz.jpg',
].map(async (src) => loadImage(src)),
[
'/images/posx.jpg',
'/images/negx.jpg',
'/images/posy.jpg',
'/images/negy.jpg',
'/images/posz.jpg',
'/images/negz.jpg',
].map(async (src) => loadImage(src)),
);
const texture = device.createTexture({
format: Format.U8_RGBA_NORM,
width: imageBitmaps[0].width,
height: imageBitmaps[0].height,
depthOrArrayLayers: 6,
dimension: TextureDimension.TEXTURE_CUBE_MAP,
usage: TextureUsage.SAMPLED,
format: Format.U8_RGBA_NORM,
width: imageBitmaps[0].width,
height: imageBitmaps[0].height,
depthOrArrayLayers: 6,
dimension: TextureDimension.TEXTURE_CUBE_MAP,
usage: TextureUsage.SAMPLED,
});

@@ -813,8 +814,8 @@ texture.setImageData(imageBitmaps);

- x `required` Minimum X value of the viewport in pixels.
- y `required` Minimum Y value of the viewport in pixels.
- w `required` Width of the viewport in pixels.
- h `required` Height of the viewport in pixels.
- minDepth `optional` Minimum depth value of the viewport.
- maxDepth `optional` Minimum depth value of the viewport.
- x `required` Minimum X value of the viewport in pixels.
- y `required` Minimum Y value of the viewport in pixels.
- w `required` Width of the viewport in pixels.
- h `required` Height of the viewport in pixels.
- minDepth `optional` Minimum depth value of the viewport.
- maxDepth `optional` Minimum depth value of the viewport.

@@ -836,6 +837,6 @@ ```ts

- x `required` Minimum X value of the scissor rectangle in pixels.
- y `required` Minimum Y value of the scissor rectangle in pixels.
- w `required` Width of the scissor rectangle in pixels.
- h `required` Height of the scissor rectangle in pixels.
- x `required` Minimum X value of the scissor rectangle in pixels.
- y `required` Minimum Y value of the scissor rectangle in pixels.
- w `required` Width of the scissor rectangle in pixels.
- h `required` Height of the scissor rectangle in pixels.

@@ -876,4 +877,4 @@ ```ts

interface VertexBufferDescriptor {
buffer: Buffer;
offset?: number; // in bytes
buffer: Buffer;
offset?: number; // in bytes
}

@@ -895,6 +896,6 @@ type IndexBufferDescriptor = VertexBufferDescriptor;

- vertexCount `required` The number of vertices to draw.
- instanceCount `optional` The number of instances to draw.
- firstVertex `optional` Offset into the vertex buffers, in vertices, to begin drawing from.
- firstInstance `optional` First instance to draw.
- vertexCount `required` The number of vertices to draw.
- instanceCount `optional` The number of instances to draw.
- firstVertex `optional` Offset into the vertex buffers, in vertices, to begin drawing from.
- firstInstance `optional` First instance to draw.

@@ -914,7 +915,7 @@ ```ts

- indexCount `required` The number of indices to draw.
- instanceCount `optional` The number of instances to draw.
- firstIndex `optional` Offset into the index buffer, in indices, begin drawing from.
- baseVertex `optional` Added to each index value before indexing into the vertex buffers.
- firstInstance `optional` First instance to draw.
- indexCount `required` The number of indices to draw.
- instanceCount `optional` The number of instances to draw.
- firstIndex `optional` Offset into the index buffer, in indices, begin drawing from.
- baseVertex `optional` Added to each index value before indexing into the vertex buffers.
- firstInstance `optional` First instance to draw.

@@ -1014,4 +1015,4 @@ ```ts

program.setUniformsLegacy({
u_ModelViewProjectionMatrix: modelViewProjectionMatrix,
u_Texture: texture,
u_ModelViewProjectionMatrix: modelViewProjectionMatrix,
u_Texture: texture,
});

@@ -1028,20 +1029,20 @@ ```

- t `required` Texture.
- x `required` X coordinate.
- y `required` Y coordinate.
- width `required` Width of dimension.
- height `required` Height of dimension.
- dst `required` Dst buffer view.
- length `optional`
- t `required` Texture.
- x `required` X coordinate.
- y `required` Y coordinate.
- width `required` Width of dimension.
- height `required` Height of dimension.
- dst `required` Dst buffer view.
- length `optional`
```ts
readTexture: (
t: Texture,
x: number,
y: number,
width: number,
height: number,
dst: ArrayBufferView,
dstOffset?: number,
length?: number,
t: Texture,
x: number,
y: number,
width: number,
height: number,
dst: ArrayBufferView,
dstOffset?: number,
length?: number,
) => Promise<ArrayBufferView>;

@@ -1054,6 +1055,6 @@ ```

const texture = device.createTexture({
format: Format.U8_RGBA_NORM,
width: 1,
height: 1,
usage: TextureUsage.SAMPLED,
format: Format.U8_RGBA_NORM,
width: 1,
height: 1,
usage: TextureUsage.SAMPLED,
});

@@ -1079,10 +1080,10 @@ texture.setImageData([new Uint8Array([1, 2, 3, 4])]);

readTextureSync: (
t: Texture,
x: number,
y: number,
width: number,
height: number,
dst: ArrayBufferView,
dstOffset?: number,
length?: number,
t: Texture,
x: number,
y: number,
width: number,
height: number,
dst: ArrayBufferView,
dstOffset?: number,
length?: number,
) => ArrayBufferView;

@@ -1097,15 +1098,15 @@ ```

- src `required` Source buffer.
- srcOffset `required` Offset in bytes of src buffer. Defaulting to `0`.
- dst `required` Dest buffer view.
- dstOffset `optional` Offset in bytes of dst buffer. Defaulting to `0`.
- length `optional` Length in bytes of dst buffer. Defaulting to its whole size.
- src `required` Source buffer.
- srcOffset `required` Offset in bytes of src buffer. Defaulting to `0`.
- dst `required` Dest buffer view.
- dstOffset `optional` Offset in bytes of dst buffer. Defaulting to `0`.
- length `optional` Length in bytes of dst buffer. Defaulting to its whole size.
```ts
readBuffer: (
src: Buffer,
srcOffset: number,
dst: ArrayBufferView,
dstOffset?: number,
length?: number,
src: Buffer,
srcOffset: number,
dst: ArrayBufferView,
dstOffset?: number,
length?: number,
) => Promise<ArrayBufferView>;

@@ -1118,5 +1119,5 @@ ```

const vertexBuffer = device.createBuffer({
viewOrSize: new Float32Array([0, 0.5, -0.5, -0.5, 0.5, -0.5]),
usage: BufferUsage.VERTEX | BufferUsage.COPY_SRC,
hint: BufferFrequencyHint.DYNAMIC,
viewOrSize: new Float32Array([0, 0.5, -0.5, -0.5, 0.5, -0.5]),
usage: BufferUsage.VERTEX | BufferUsage.COPY_SRC,
hint: BufferFrequencyHint.DYNAMIC,
});

@@ -1132,15 +1133,15 @@ const data = await readback.readBuffer(vertexBuffer, 0, new Float32Array(6));

- WebGL1. Downgrade to GLSL 100.
- WebGL2. Almost keep the same which means GLSL 300.
- WebGPU. Transpile to GLSL 440 and then use [gfx-naga]() WASM to generate WGSL.
- WebGL1. Downgrade to GLSL 100.
- WebGL2. Almost keep the same which means GLSL 300.
- WebGPU. Transpile to GLSL 440 and then use [gfx-naga]() WASM to generate WGSL.
Syntax as follows:
- [Attribute](#attribute)
- [Varying](#varying)
- [Sampler](#sampler)
- [Uniform](#uniform)
- [gl_Position](#gl_Position)
- [gl_FragColor](#gl_FragColor)
- [Define](#define)
- [Attribute](#attribute)
- [Varying](#varying)
- [Sampler](#sampler)
- [Uniform](#uniform)
- [gl_Position](#gl_Position)
- [gl_FragColor](#gl_FragColor)
- [Define](#define)

@@ -1252,2 +1253,12 @@ ### <a id='attribute' />Attribute

⚠️ We don't allow `instance_name` for now:
```glsl
// wrong
layout(std140) uniform Uniforms {
mat4 projection;
mat4 modelview;
} matrices;
```
### <a id='gl_Position' />gl_Position

@@ -1311,1 +1322,5 @@

```
## <a id='limitations' /> Limitations
We can only use `@group(0)` in WGSL for now.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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