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

@luma.gl/api

Package Overview
Dependencies
Maintainers
7
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luma.gl/api - npm Package Compare versions

Comparing version 9.0.0-alpha.27 to 9.0.0-alpha.29

107

dist/adapter/types/shader-layout.d.ts

@@ -12,32 +12,13 @@ import { TextureFormat } from '../types/texture-formats';

* ```
const SHADER_LAYOUTS = {
attributes: [
{name: 'instancePositions', location: 0, format: 'float32x2', stepMode: 'instance'},
{name: 'instanceVelocities', location: 1, format: 'float32x2', stepMode: 'instance'},
{name: 'vertexPositions', location: 2, format: 'float32x2', stepMode: 'vertex'}
],
```
* @example
device.createRenderPipeline({
layout: [
attributes: [
{name: 'instancePositions', location: 0, format: 'float32x2', stepMode: 'instance'},
{name: 'instanceVelocities', location: 1, format: 'float32x2', stepMode: 'instance'},
{name: 'vertexPositions', location: 2, format: 'float32x2', stepMode: 'vertex'}
],
bindings: [...]
]
})
* ```
device.createRenderPipeline({
shaderLayouts,
// interleaved bindings, auto offset
bufferMap: {
particles: [
{name: 'instancePositions', location: 0},
{name: 'instanceVelocities', location: 1}
]
}
];
const bufferMap = [
// single buffer per binding
{name: 'vertexPositions', location: 2, accessor: {format: 'float32x2'}}
// interleaved bindings, auto offset
{name: 'particles', stepMode: 'instance', fields: [
{name: 'instancePositions', location: 0, format: 'float32x4'},
{name: 'instanceVelocities', location: 1, format: 'float32x4'}
]},
]
```
*/

@@ -54,5 +35,7 @@ export type ShaderLayout = {

export type AttributeLayout = {
/** The name of this attribute in the shader */
name: string;
/** The index into the GPU's vertex array buffer bank (usually between 0-15) */
location: number;
/** WebGPU-style `format` string **/
/** WebGPU-style format, such as float32x3 or uint8x4 */
format: VertexFormat;

@@ -65,14 +48,30 @@ /** @note defaults to vertex */

*
```
bufferMap: [
{name: 'interleavedPositions', attributes: [...]}
{name: 'position', byteOffset: 1024}
]
```
* @example
* ```
device.createRenderPipeline({
layout: shaderLayout,
// interleaved bindings, auto offset
bufferMap: [
{name: 'interleavedPositions', attributes: [...]}
{name: 'position', byteOffset: 1024}
// single buffer per binding
{name: 'vertexPositions', location: 2, accessor: {format: 'float32x2'}}
// interleaved bindings, auto offset
{name: 'particles', stepMode: 'instance', fields: [
{name: 'instancePositions', location: 0, format: 'float32x4'},
{name: 'instanceVelocities', location: 1, format: 'float32x4'}
]},
]
];
```
*/
export type BufferMapping = SingleBufferMapping | InterleavedBufferMapping;
/** @note Not public: not exported outside of api module */
/** Specify stride and offset for a buffer that only handles one attribute*/
export type SingleBufferMapping = {
/** Mark this as interleaved */
type?: 'override';
/** Name of attribute to adjust */
name: string;
/** vertex format override, when using formats other than float32, uint32, sint32 */
format: VertexFormat;
/** bytes between successive elements @note `stride` is auto calculated if omitted */

@@ -83,7 +82,9 @@ byteStride?: number;

};
/** @note Not public: not exported outside of api module */
/** Map an interleaved buffer */
export type InterleavedBufferMapping = {
/** Name of buffer () */
/** Mark this as interleaved */
type: 'interleave';
/** Name of buffer (to which the multiple attributes are to be bound) */
name: string;
/** bytes between successive elements @note `stride` is auto calculated if omitted */
/** bytes between successive elements. Assumes tight packing if omitted */
byteStride?: number;

@@ -94,8 +95,17 @@ /** offset into buffer Defaults to `0` */

attributes: InterleavedAttribute[];
/** @deprecated Dummy for typing */
format?: VertexFormat;
};
/** @note Not public: not exported outside of api module */
export type InterleavedAttribute = {
/** Name of buffer to map */
name?: string;
/** offset into one stride. @note `offset` is auto calculated starting from zero */
/** Name of attribute that maps to an interleaved "view" of this buffer */
name: string;
/** vertex format override, when using formats other than float32 (& uint32, sint32) */
format?: VertexFormat;
/**
* offset into one stride.
* @note additive to the parent's buffer byteOffset
* @note if not supplied, offset for each attribute is auto calculated starting
* from zero assuming aligned packing
*/
byteOffset?: number;

@@ -162,12 +172,5 @@ };

/**
* Holds metadata describing attribute configurations for a program's shaders
* @deprecated - unify witb ShaderLayout
* Describes a varying binding for a program
* @deprecated Varyings are WebGL-only
*/
export type ProgramBindings = {
readonly attributes: AttributeBinding[];
readonly varyings: VaryingBinding[];
readonly uniformBlocks: UniformBlockBinding[];
readonly uniforms: UniformBinding[];
};
/** @deprecated Describes a varying binding for a program */
export type VaryingBinding = {

@@ -174,0 +177,0 @@ location: number;

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

/** Basic data types signed and unsigned integers, and floats, of varying sizes */
export type DataType = 'uint8' | 'sint8' | 'uint16' | 'sint16' | 'uint32' | 'sint32' | 'float16' | 'float32';
/** Vertex and Pixel data types. */
/** Vertex and Pixel data types. Include normalized integers */
export type NormalizedDataType = 'uint8' | 'sint8' | 'unorm8' | 'snorm8' | 'uint16' | 'sint16' | 'unorm16' | 'snorm16' | 'float16' | 'float32' | 'uint32' | 'sint32';

@@ -4,0 +5,0 @@ export type VertexType = NormalizedDataType;

import { DataType, NormalizedDataType } from '../types/vertex-formats';
/** Decodes a vertex type, returning byte length and flags (integer, signed, normalized) */
export declare function decodeVertexType(type: NormalizedDataType): {
export type DecodedVertexType = {
/** WebGPU data type */
dataType: DataType;
/** Length in bytes of the data for one vertex */
byteLength: number;
/** Whether this is for integer or float vert */
integer: boolean;
/** Whether this data type is signed */
signed: boolean;
/** Whether this is a normalized integer (that must be used as float) */
normalized: boolean;
};
/** Decodes a vertex type, returning byte length and flags (integer, signed, normalized) */
export declare function decodeVertexType(type: NormalizedDataType): DecodedVertexType;
//# sourceMappingURL=decode-data-type.d.ts.map
export function decodeVertexType(type) {
const dataType = TYPE_MAP[type];
const bytes = getDataTypeBytes(dataType);
const integer = !type.startsWith('float');
const normalized = type.includes('norm');
const integer = !normalized && !type.startsWith('float');
const signed = type.startsWith('s');

@@ -7,0 +7,0 @@ return {

@@ -39,3 +39,3 @@ export { VERSION } from './init';

export type { ColorAttachment, DepthStencilAttachment } from './adapter/types/types';
export type { ShaderLayout, ProgramBindings, AttributeLayout, BindingLayout, Binding, BufferMapping, AttributeBinding, UniformBinding, UniformBlockBinding, VaryingBinding } from './adapter/types/shader-layout';
export type { ShaderLayout, AttributeLayout, BindingLayout, Binding, BufferMapping, AttributeBinding, UniformBinding, UniformBlockBinding, VaryingBinding } from './adapter/types/shader-layout';
export { UniformBufferLayout } from './lib/uniform-buffer-layout';

@@ -42,0 +42,0 @@ export { UniformBlock } from './lib/uniform-block';

{
"name": "@luma.gl/api",
"version": "9.0.0-alpha.27",
"version": "9.0.0-alpha.29",
"description": "luma.gl API",

@@ -45,3 +45,3 @@ "license": "MIT",

},
"gitHead": "4052244031cb80c27fa0e3fd4c3d5514daa08b78"
"gitHead": "1aee1ad82fd09d441172f5ef490ebc083a7fa239"
}

@@ -22,17 +22,2 @@ // luma.gl, MIT license

mappedAtCreation?: boolean;
/** @deprecated *
accessor?: any; // AccessorObject;
/** @deprecated Use BufferProps.usage = VERTEX | INDEX | UNIFORM *
target?: number;
/** @deprecated Bind separately *
index?: number;
/** @deprecated *
offset?: number;
/** @deprecated *
size?: number;
/** @deprecated *
type?: number;
*/
}

@@ -39,0 +24,0 @@

@@ -14,49 +14,21 @@ // luma.gl, MIT license

* ```
const SHADER_LAYOUTS = {
attributes: [
{name: 'instancePositions', location: 0, format: 'float32x2', stepMode: 'instance'},
{name: 'instanceVelocities', location: 1, format: 'float32x2', stepMode: 'instance'},
{name: 'vertexPositions', location: 2, format: 'float32x2', stepMode: 'vertex'}
],
```
* @example
device.createRenderPipeline({
layout: [
attributes: [
{name: 'instancePositions', location: 0, format: 'float32x2', stepMode: 'instance'},
{name: 'instanceVelocities', location: 1, format: 'float32x2', stepMode: 'instance'},
{name: 'vertexPositions', location: 2, format: 'float32x2', stepMode: 'vertex'}
],
bindings: [...]
]
})
* ```
device.createRenderPipeline({
shaderLayouts,
// interleaved bindings, auto offset
bufferMap: {
particles: [
{name: 'instancePositions', location: 0},
{name: 'instanceVelocities', location: 1}
]
}
];
const bufferMap = [
// single buffer per binding
{name: 'vertexPositions', location: 2, accessor: {format: 'float32x2'}}
// interleaved bindings, auto offset
{name: 'particles', stepMode: 'instance', fields: [
{name: 'instancePositions', location: 0, format: 'float32x4'},
{name: 'instanceVelocities', location: 1, format: 'float32x4'}
]},
]
```
*/
export type ShaderLayout = {
// vs: Shader,
// vsEntryPoint?: string;
// vsConstants?: Record<string, number>;
// fs?: Shader,
// fsEntryPoint?: string;
// fsConstants?: Record<string, number>;
// cs: Shader,
// csEntryPoint?: string;
// csConstants?: Record<string, number>;
attributes: AttributeLayout[];
bindings: BindingLayout[];
/** WebGL only (WebGPU use bindings and uniform buffers) */
uniforms?: any[]
uniforms?: any[];
/** WebGL2 only (WebGPU use compute shaders) */
varyings?: any[]
varyings?: any[];
};

@@ -66,5 +38,7 @@

export type AttributeLayout = {
/** The name of this attribute in the shader */
name: string;
/** The index into the GPU's vertex array buffer bank (usually between 0-15) */
location: number;
/** WebGPU-style `format` string **/
/** WebGPU-style format, such as float32x3 or uint8x4 */
format: VertexFormat;

@@ -80,15 +54,31 @@ /** @note defaults to vertex */

*
```
bufferMap: [
{name: 'interleavedPositions', attributes: [...]}
{name: 'position', byteOffset: 1024}
]
```
* @example
* ```
device.createRenderPipeline({
layout: shaderLayout,
// interleaved bindings, auto offset
bufferMap: [
{name: 'interleavedPositions', attributes: [...]}
{name: 'position', byteOffset: 1024}
// single buffer per binding
{name: 'vertexPositions', location: 2, accessor: {format: 'float32x2'}}
// interleaved bindings, auto offset
{name: 'particles', stepMode: 'instance', fields: [
{name: 'instancePositions', location: 0, format: 'float32x4'},
{name: 'instanceVelocities', location: 1, format: 'float32x4'}
]},
]
];
```
*/
export type BufferMapping = SingleBufferMapping | InterleavedBufferMapping;
/** @note Not public: not exported outside of api module */
/** Specify stride and offset for a buffer that only handles one attribute*/
export type SingleBufferMapping = {
/** Mark this as interleaved */
type?: 'override';
/** Name of attribute to adjust */
name: string;
/** vertex format override, when using formats other than float32, uint32, sint32 */
format: VertexFormat;
/** bytes between successive elements @note `stride` is auto calculated if omitted */

@@ -100,7 +90,9 @@ byteStride?: number;

/** @note Not public: not exported outside of api module */
/** Map an interleaved buffer */
export type InterleavedBufferMapping = {
/** Name of buffer () */
/** Mark this as interleaved */
type: 'interleave';
/** Name of buffer (to which the multiple attributes are to be bound) */
name: string;
/** bytes between successive elements @note `stride` is auto calculated if omitted */
/** bytes between successive elements. Assumes tight packing if omitted */
byteStride?: number;

@@ -111,2 +103,4 @@ /** offset into buffer Defaults to `0` */

attributes: InterleavedAttribute[];
/** @deprecated Dummy for typing */
format?: VertexFormat;
};

@@ -116,5 +110,12 @@

export type InterleavedAttribute = {
/** Name of buffer to map */
name?: string;
/** offset into one stride. @note `offset` is auto calculated starting from zero */
/** Name of attribute that maps to an interleaved "view" of this buffer */
name: string;
/** vertex format override, when using formats other than float32 (& uint32, sint32) */
format?: VertexFormat;
/**
* offset into one stride.
* @note additive to the parent's buffer byteOffset
* @note if not supplied, offset for each attribute is auto calculated starting
* from zero assuming aligned packing
*/
byteOffset?: number;

@@ -220,17 +221,8 @@ };

// ATTRIBUTE LAYOUTS
// SHADER LAYOUTS
/**
* Holds metadata describing attribute configurations for a program's shaders
* @deprecated - unify witb ShaderLayout
/**
* Describes a varying binding for a program
* @deprecated Varyings are WebGL-only
*/
export type ProgramBindings = {
readonly attributes: AttributeBinding[];
readonly varyings: VaryingBinding[];
readonly uniformBlocks: UniformBlockBinding[];
// Note - samplers are always in unform bindings, even if uniform blocks are used
readonly uniforms: UniformBinding[];
};
/** @deprecated Describes a varying binding for a program */
export type VaryingBinding = {

@@ -237,0 +229,0 @@ location: number;

// luma.gl, MIT license
/** Basic data types signed and unsigned integers, and floats, of varying sizes */
export type DataType =

@@ -15,3 +16,3 @@ 'uint8' |

/** Vertex and Pixel data types. */
/** Vertex and Pixel data types. Include normalized integers */
export type NormalizedDataType =

@@ -18,0 +19,0 @@ 'uint8' |

import {DataType, NormalizedDataType} from '../types/vertex-formats';
/** Decodes a vertex type, returning byte length and flags (integer, signed, normalized) */
export function decodeVertexType(type: NormalizedDataType): {
export type DecodedVertexType = {
/** WebGPU data type */
dataType: DataType,
/** Length in bytes of the data for one vertex */
byteLength: number;
/** Whether this is for integer or float vert */
integer: boolean;
/** Whether this data type is signed */
signed: boolean;
/** Whether this is a normalized integer (that must be used as float) */
normalized: boolean;
} {
};
/** Decodes a vertex type, returning byte length and flags (integer, signed, normalized) */
export function decodeVertexType(type: NormalizedDataType): DecodedVertexType {
const dataType = TYPE_MAP[type];
const bytes = getDataTypeBytes(dataType);
const integer: boolean = !type.startsWith('float');
const normalized: boolean = type.includes('norm');
const integer: boolean = !normalized && !type.startsWith('float');
const signed: boolean = type.startsWith('s');

@@ -16,0 +23,0 @@ return {

@@ -74,7 +74,5 @@ // luma.gl, MIT license

ShaderLayout,
ProgramBindings,
AttributeLayout,
BindingLayout,
Binding,
//
BufferMapping,

@@ -81,0 +79,0 @@ // Deprecated, todo

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 not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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 not supported yet

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