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

@luma.gl/webgl

Package Overview
Dependencies
Maintainers
6
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luma.gl/webgl - npm Package Compare versions

Comparing version 9.1.0-beta.8 to 9.1.0-beta.9

2

dist/adapter/converters/webgl-texture-table.js

@@ -105,3 +105,3 @@ // luma.gl

'rgb10a2unorm': { gl: 32857, rb: true },
'rgb10a2uint': { gl: 36975, rb: true },
'rgb10a2uint-webgl': { gl: 36975, rb: true },
// 48-bit formats

@@ -108,0 +108,0 @@ 'rgb16unorm-webgl': { gl: 32852 }, // rgb not renderable

@@ -27,5 +27,3 @@ // luma.gl

this.handle = handle || this.gl.createBuffer();
device._setWebGLDebugMetadata(this.handle, this, {
spector: { ...this.props, data: typeof this.props.data }
});
device.setSpectorMetadata(this.handle, { ...this.props, data: typeof this.props.data });
// - In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers

@@ -32,0 +30,0 @@ // otherwise buffer type will lock to generic (non-element) buffer

@@ -23,4 +23,4 @@ // luma.gl

if (!isDefaultFramebuffer) {
// default framebuffer handle is null, so we can't set debug metadata...
device._setWebGLDebugMetadata(this.handle, this, { spector: this.props });
// default framebuffer handle is null, so we can't set spector metadata...
device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
// Auto create textures for attachments if needed

@@ -27,0 +27,0 @@ this.autoCreateAttachmentTextures();

@@ -26,3 +26,3 @@ // luma.gl

// Instead of using our own book-keeping, we can just read the values from the WebGL context
const [width, height] = device.getDefaultCanvasContext().getDrawingBufferSize();
const [width, height] = device.getCanvasContext().getDrawingBufferSize();
viewport = [0, 0, width, height];

@@ -35,5 +35,3 @@ }

// Specify mapping of draw buffer locations to color attachments
const webglFramebuffer = this.props.framebuffer;
// Default framebuffers can only be set to GL.BACK or GL.NONE
if (webglFramebuffer?.handle) {
if (this.props.framebuffer) {
const drawBuffers = this.props.framebuffer.colorAttachments.map((_, i) => 36064 + i);

@@ -40,0 +38,0 @@ this.device.gl.drawBuffers(drawBuffers);

@@ -26,3 +26,2 @@ import type { RenderPipelineProps, RenderPipelineParameters, PrimitiveTopology, ShaderLayout, UniformValue, Binding, RenderPass, VertexArray } from '@luma.gl/core';

_uniformSetters: Record<string, Function>;
get [Symbol.toStringTag](): string;
constructor(device: WebGLDevice, props: RenderPipelineProps);

@@ -29,0 +28,0 @@ destroy(): void;

@@ -37,5 +37,2 @@ // luma.gl

_uniformSetters = {}; // TODO are these used?
get [Symbol.toStringTag]() {
return 'WEBGLRenderPipeline';
}
constructor(device, props) {

@@ -45,3 +42,3 @@ super(device, props);

this.handle = this.props.handle || this.device.gl.createProgram();
this.device._setWebGLDebugMetadata(this.handle, this, { spector: { id: this.props.id } });
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
// Create shaders if needed

@@ -60,5 +57,5 @@ this.vs = props.vs;

this._linkShaders();
log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
log.time(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);
log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
log.timeEnd(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
// Merge provided layout with introspected layout

@@ -69,9 +66,5 @@ this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);

if (this.handle) {
// log.error(`Deleting program ${this.id}`)();
this.device.gl.useProgram(null);
this.device.gl.deleteProgram(this.handle);
// this.handle = null;
this.destroyed = true;
// @ts-expect-error
this.handle.destroyed = true;
this.handle = null;
}

@@ -78,0 +71,0 @@ }

@@ -26,4 +26,2 @@ // luma.gl

}
// default framebuffer handle is null, so we can't set spector metadata...
device._setWebGLDebugMetadata(this.handle, this, { spector: this.props });
this._compile(this.source);

@@ -35,6 +33,4 @@ }

this.device.gl.deleteShader(this.handle);
// this.handle = null;
this.destroyed = true;
// @ts-expect-error
this.handle.destroyed = true;
// this.handle = null;
}

@@ -41,0 +37,0 @@ }

@@ -71,8 +71,3 @@ // luma.gl

this.handle = this.props.handle || this.gl.createTexture();
this.device._setWebGLDebugMetadata(this.handle, this, {
spector: {
...this.props,
data: propsWithData.data
}
});
this.device.setSpectorMetadata(this.handle, { ...this.props, data: propsWithData.data });
let { width, height } = propsWithData;

@@ -79,0 +74,0 @@ if (!width || !height) {

@@ -1,2 +0,2 @@

import type { CanvasContextProps } from '@luma.gl/core';
import type { CanvasContextProps, TextureFormat } from '@luma.gl/core';
import { CanvasContext } from '@luma.gl/core';

@@ -10,3 +10,5 @@ import { WebGLDevice } from "./webgl-device.js";

readonly device: WebGLDevice;
readonly handle: unknown;
readonly format: TextureFormat;
readonly depthStencilFormat: TextureFormat;
presentationSize: [number, number];
private _framebuffer;

@@ -16,3 +18,4 @@ get [Symbol.toStringTag](): string;

getCurrentFramebuffer(): WEBGLFramebuffer;
updateSize(size: [number, number]): void;
/** Resizes and updates render targets if necessary */
update(): void;
/**

@@ -19,0 +22,0 @@ * Resize the canvas' drawing buffer.

@@ -11,3 +11,5 @@ // luma.gl

device;
handle = null;
format = 'rgba8unorm';
depthStencilFormat = 'depth24plus';
presentationSize;
_framebuffer = null;

@@ -21,7 +23,8 @@ get [Symbol.toStringTag]() {

this.device = device;
// Base class constructor cannot access derived methods/fields, so we need to call these functions in the subclass constructor
this.presentationSize = [-1, -1];
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
this.updateSize([this.drawingBufferWidth, this.drawingBufferHeight]);
this.update();
}
getCurrentFramebuffer() {
this.update();
// Setting handle to null returns a reference to the default framebuffer

@@ -31,3 +34,11 @@ this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, { handle: null });

}
updateSize(size) { }
/** Resizes and updates render targets if necessary */
update() {
const size = this.getPixelSize();
const sizeChanged = size[0] !== this.presentationSize[0] || size[1] !== this.presentationSize[1];
if (sizeChanged) {
this.presentationSize = size;
this.resize();
}
}
/**

@@ -48,6 +59,6 @@ * Resize the canvas' drawing buffer.

return;
// Resize browser context. TODO - this likely needs to be rewritten
// Resize browser context .
if (this.canvas) {
const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);
this._setDevicePixelRatio(devicePixelRatio, options);
this.setDevicePixelRatio(devicePixelRatio, options);
return;

@@ -54,0 +65,0 @@ }

import type { TypedArray } from '@math.gl/types';
import type { DeviceProps, DeviceInfo, DeviceTextureFormatCapabilities, CanvasContextProps, Buffer, Texture, Framebuffer, VertexArray, VertexArrayProps, BufferProps, ShaderProps, SamplerProps, TextureProps, ExternalTexture, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipeline, ComputePipelineProps, RenderPassProps, ComputePass, ComputePassProps, CommandEncoderProps, TransformFeedbackProps, QuerySetProps, Resource } from '@luma.gl/core';
import type { DeviceProps, DeviceInfo, DeviceTextureFormatCapabilities, CanvasContextProps, Buffer, Texture, Framebuffer, VertexArray, VertexArrayProps, BufferProps, ShaderProps, SamplerProps, TextureProps, ExternalTexture, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipeline, ComputePipelineProps, RenderPassProps, ComputePass, ComputePassProps, CommandEncoderProps, TransformFeedbackProps, QuerySetProps } from '@luma.gl/core';
import { Device, CanvasContext } from '@luma.gl/core';

@@ -29,4 +29,2 @@ import type { GLExtensions } from '@luma.gl/constants';

readonly canvasContext: WebGLCanvasContext;
readonly preferredColorFormat = "rgba8unorm";
readonly preferredDepthFormat = "depth24plus";
readonly lost: Promise<{

@@ -117,2 +115,7 @@ reason: 'destroyed';

/**
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
* luma.gl ids and props can be inspected
*/
setSpectorMetadata(handle: unknown, props: Record<string, unknown>): void;
/**
* Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant

@@ -140,10 +143,3 @@ * Be aware that there are some duplicates especially for constants that are 0,

getExtension(name: keyof GLExtensions): GLExtensions;
/**
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
* luma.gl ids and props can be inspected
*/
_setWebGLDebugMetadata(handle: unknown, resource: Resource<any>, options: {
spector: Record<string, unknown>;
}): void;
}
//# sourceMappingURL=webgl-device.d.ts.map

@@ -32,3 +32,5 @@ // luma.gl

export class WebGLDevice extends Device {
//
// Public `Device` API
//
/** type of this device */

@@ -42,4 +44,2 @@ type = 'webgl';

canvasContext;
preferredColorFormat = 'rgba8unorm';
preferredDepthFormat = 'depth24plus';
lost;

@@ -118,2 +118,3 @@ _resolveContextLost;

}
this.canvasContext.resize();
// Install context state tracking

@@ -261,2 +262,11 @@ const glState = new WebGLStateTracker(this.gl, {

/**
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
* luma.gl ids and props can be inspected
*/
setSpectorMetadata(handle, props) {
// @ts-expect-error
// eslint-disable-next-line camelcase
handle.__SPECTOR_Metadata = props;
}
/**
* Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant

@@ -323,15 +333,2 @@ * Be aware that there are some duplicates especially for constants that are 0,

}
// INTERNAL SUPPORT METHODS FOR WEBGL RESOURCES
/**
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
* luma.gl ids and props can be inspected
*/
_setWebGLDebugMetadata(handle, resource, options) {
// @ts-expect-error
handle.luma = resource;
const spectorMetadata = { props: options.spector, id: options.spector.id };
// @ts-expect-error
// eslint-disable-next-line camelcase
handle.__SPECTOR_Metadata = spectorMetadata;
}
}

@@ -338,0 +335,0 @@ /** Set constant float array attribute */

{
"name": "@luma.gl/webgl",
"version": "9.1.0-beta.8",
"version": "9.1.0-beta.9",
"description": "WebGL2 adapter for the luma.gl core API",

@@ -46,7 +46,7 @@ "type": "module",

"dependencies": {
"@luma.gl/constants": "9.1.0-beta.8",
"@luma.gl/constants": "9.1.0-beta.9",
"@math.gl/types": "^4.1.0",
"@probe.gl/env": "^4.0.8"
},
"gitHead": "10846580c7a10c4cc48de01a4e5259cc0a00c249"
"gitHead": "ce90c649e27184c399eaeab814ec21a46f45677b"
}

@@ -151,4 +151,4 @@ // luma.gl

'rgb10a2unorm': {gl: GL.RGB10_A2, rb: true},
'rgb10a2uint': {gl: GL.RGB10_A2UI, rb: true},
'rgb10a2uint-webgl': {gl: GL.RGB10_A2UI, rb: true},
// 48-bit formats

@@ -155,0 +155,0 @@ 'rgb16unorm-webgl': {gl: GL.RGB16_EXT}, // rgb not renderable

@@ -36,5 +36,3 @@ // luma.gl

this.handle = handle || this.gl.createBuffer();
device._setWebGLDebugMetadata(this.handle, this, {
spector: {...this.props, data: typeof this.props.data}
});
device.setSpectorMetadata(this.handle, {...this.props, data: typeof this.props.data});

@@ -41,0 +39,0 @@ // - In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers

@@ -36,4 +36,4 @@ // luma.gl

if (!isDefaultFramebuffer) {
// default framebuffer handle is null, so we can't set debug metadata...
device._setWebGLDebugMetadata(this.handle, this, {spector: this.props});
// default framebuffer handle is null, so we can't set spector metadata...
device.setSpectorMetadata(this.handle, {id: this.props.id, props: this.props});

@@ -40,0 +40,0 @@ // Auto create textures for attachments if needed

@@ -12,3 +12,2 @@ // luma.gl

import {WEBGLQuerySet} from './webgl-query-set';
import {WEBGLFramebuffer} from './webgl-framebuffer';

@@ -36,3 +35,3 @@ const COLOR_CHANNELS = [0x1, 0x2, 0x4, 0x8]; // GPUColorWrite RED, GREEN, BLUE, ALPHA

// Instead of using our own book-keeping, we can just read the values from the WebGL context
const [width, height] = device.getDefaultCanvasContext().getDrawingBufferSize();
const [width, height] = device.getCanvasContext().getDrawingBufferSize();
viewport = [0, 0, width, height];

@@ -47,5 +46,3 @@ }

// Specify mapping of draw buffer locations to color attachments
const webglFramebuffer = this.props.framebuffer as WEBGLFramebuffer;
// Default framebuffers can only be set to GL.BACK or GL.NONE
if (webglFramebuffer?.handle) {
if (this.props.framebuffer) {
const drawBuffers = this.props.framebuffer.colorAttachments.map(

@@ -52,0 +49,0 @@ (_, i) => GL.COLOR_ATTACHMENT0 + i

@@ -60,6 +60,2 @@ // luma.gl

override get [Symbol.toStringTag]() {
return 'WEBGLRenderPipeline';
}
constructor(device: WebGLDevice, props: RenderPipelineProps) {

@@ -69,3 +65,3 @@ super(device, props);

this.handle = this.props.handle || this.device.gl.createProgram();
this.device._setWebGLDebugMetadata(this.handle, this, {spector: {id: this.props.id}});
this.device.setSpectorMetadata(this.handle, {id: this.props.id});

@@ -87,5 +83,6 @@ // Create shaders if needed

this._linkShaders();
log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
log.time(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);
log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
log.timeEnd(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();

@@ -98,9 +95,5 @@ // Merge provided layout with introspected layout

if (this.handle) {
// log.error(`Deleting program ${this.id}`)();
this.device.gl.useProgram(null);
this.device.gl.deleteProgram(this.handle);
// this.handle = null;
this.destroyed = true;
// @ts-expect-error
this.handle.destroyed = true;
this.handle = null;
}

@@ -107,0 +100,0 @@ }

@@ -30,6 +30,2 @@ // luma.gl

}
// default framebuffer handle is null, so we can't set spector metadata...
device._setWebGLDebugMetadata(this.handle, this, {spector: this.props});
this._compile(this.source);

@@ -42,6 +38,4 @@ }

this.device.gl.deleteShader(this.handle);
// this.handle = null;
this.destroyed = true;
// @ts-expect-error
this.handle.destroyed = true;
// this.handle = null;
}

@@ -48,0 +42,0 @@ }

@@ -113,8 +113,3 @@ // luma.gl

this.handle = this.props.handle || this.gl.createTexture();
this.device._setWebGLDebugMetadata(this.handle, this, {
spector: {
...this.props,
data: propsWithData.data
}
});
this.device.setSpectorMetadata(this.handle, {...this.props, data: propsWithData.data});

@@ -121,0 +116,0 @@ let {width, height} = propsWithData;

@@ -5,3 +5,3 @@ // luma.gl

import type {CanvasContextProps} from '@luma.gl/core';
import type {CanvasContextProps, TextureFormat} from '@luma.gl/core';
import {CanvasContext} from '@luma.gl/core';

@@ -16,4 +16,6 @@ import {WebGLDevice} from './webgl-device';

readonly device: WebGLDevice;
readonly handle: unknown = null;
readonly format: TextureFormat = 'rgba8unorm';
readonly depthStencilFormat: TextureFormat = 'depth24plus';
presentationSize: [number, number];
private _framebuffer: WEBGLFramebuffer | null = null;

@@ -29,9 +31,9 @@

this.device = device;
// Base class constructor cannot access derived methods/fields, so we need to call these functions in the subclass constructor
this.presentationSize = [-1, -1];
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
this.updateSize([this.drawingBufferWidth, this.drawingBufferHeight]);
this.update();
}
getCurrentFramebuffer(): WEBGLFramebuffer {
this.update();
// Setting handle to null returns a reference to the default framebuffer

@@ -42,3 +44,12 @@ this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, {handle: null});

updateSize(size: [number, number]): void {}
/** Resizes and updates render targets if necessary */
update() {
const size = this.getPixelSize();
const sizeChanged =
size[0] !== this.presentationSize[0] || size[1] !== this.presentationSize[1];
if (sizeChanged) {
this.presentationSize = size;
this.resize();
}
}

@@ -60,6 +71,6 @@ /**

// Resize browser context. TODO - this likely needs to be rewritten
// Resize browser context .
if (this.canvas) {
const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);
this._setDevicePixelRatio(devicePixelRatio, options);
this.setDevicePixelRatio(devicePixelRatio, options);
return;

@@ -66,0 +77,0 @@ }

@@ -35,4 +35,3 @@ // luma.gl

TransformFeedbackProps,
QuerySetProps,
Resource
QuerySetProps
} from '@luma.gl/core';

@@ -76,3 +75,5 @@ import {Device, CanvasContext, log} from '@luma.gl/core';

export class WebGLDevice extends Device {
//
// Public `Device` API
//

@@ -86,8 +87,6 @@ /** type of this device */

limits: WebGLDeviceLimits;
readonly info: DeviceInfo;
readonly canvasContext: WebGLCanvasContext;
readonly preferredColorFormat = 'rgba8unorm';
readonly preferredDepthFormat = 'depth24plus';
readonly lost: Promise<{reason: 'destroyed'; message: string}>;

@@ -195,2 +194,4 @@

this.canvasContext.resize();
// Install context state tracking

@@ -400,2 +401,12 @@ const glState = new WebGLStateTracker(this.gl, {

/**
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
* luma.gl ids and props can be inspected
*/
setSpectorMetadata(handle: unknown, props: Record<string, unknown>) {
// @ts-expect-error
// eslint-disable-next-line camelcase
handle.__SPECTOR_Metadata = props;
}
/**
* Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant

@@ -470,22 +481,2 @@ * Be aware that there are some duplicates especially for constants that are 0,

}
// INTERNAL SUPPORT METHODS FOR WEBGL RESOURCES
/**
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
* luma.gl ids and props can be inspected
*/
_setWebGLDebugMetadata(
handle: unknown,
resource: Resource<any>,
options: {spector: Record<string, unknown>}
): void {
// @ts-expect-error
handle.luma = resource;
const spectorMetadata = {props: options.spector, id: options.spector.id};
// @ts-expect-error
// eslint-disable-next-line camelcase
handle.__SPECTOR_Metadata = spectorMetadata;
}
}

@@ -492,0 +483,0 @@

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 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 too big to display

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