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

@luma.gl/webgpu

Package Overview
Dependencies
Maintainers
7
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luma.gl/webgpu - npm Package Compare versions

Comparing version 9.0.0-alpha.33 to 9.0.0-alpha.34

24

dist/adapter/helpers/generate-mipmaps.js

@@ -1,9 +0,21 @@

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
const VS_GEN_MIPMAP = "#version 450\nconst vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\nlayout(location = 0) out vec2 vTex;\nvoid main() {\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n vTex = gl_Position / 2.0f + vec2(0.5f);\n}";
const FS_GEN_MIPMAP = "#version 450\nlayout(set = 0, binding = 0) uniform sampler imgSampler;\nlayout(set = 0, binding = 1) uniform texture2D img;\nlayout(location = 0) in vec2 vTex;\nlayout(location = 0) out vec4 outColor;\nvoid main() {\n outColor = texture(sampler2D(img, imgSampler), vTex);\n}";
const VS_GEN_MIPMAP = `\#version 450
const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));
layout(location = 0) out vec2 vTex;
void main() {
gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
vTex = gl_Position / 2.0f + vec2(0.5f);
}`;
const FS_GEN_MIPMAP = `#version 450
layout(set = 0, binding = 0) uniform sampler imgSampler;
layout(set = 0, binding = 1) uniform texture2D img;
layout(location = 0) in vec2 vTex;
layout(location = 0) out vec4 outColor;
void main() {
outColor = texture(sampler2D(img, imgSampler), vTex);
}`;
export class WebGPUMipmapGenerator {
constructor(device, glslang) {
_defineProperty(this, "device", void 0);
_defineProperty(this, "mipmapSampler", void 0);
_defineProperty(this, "mipmapPipeline", void 0);
this.device = void 0;
this.mipmapSampler = void 0;
this.mipmapPipeline = void 0;
this.device = device;

@@ -10,0 +22,0 @@ this.mipmapSampler = device.createSampler({

@@ -15,3 +15,3 @@ import { Buffer, Sampler, Texture, log, cast } from '@luma.gl/core';

if (!bindingLayout) {
log.warn("Binding ".concat(bindingName, " not set: Not found in shader layout."))();
log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
}

@@ -18,0 +18,0 @@ return bindingLayout;

@@ -1,5 +0,5 @@

import { decodeVertexFormat } from '@luma.gl/core';
import { getAttributeInfosFromLayouts, decodeVertexFormat } from '@luma.gl/core';
function getWebGPUVertexFormat(format) {
if (format.endsWith('-webgl')) {
throw new Error("WebGPU does not support vertex format ".concat(format));
throw new Error(`WebGPU does not support vertex format ${format}`);
}

@@ -9,2 +9,3 @@ return format;

export function getVertexBufferLayout(shaderLayout, bufferLayout) {
const attributeInfos = getAttributeInfosFromLayouts(shaderLayout, bufferLayout);
const vertexBufferLayouts = [];

@@ -16,10 +17,10 @@ const usedAttributes = new Set();

let byteStride = 0;
const byteOffset = mapping.byteOffset || 0;
if (mapping.attributes) {
for (const interleaved of mapping.attributes) {
const attributeLayout = findAttributeLayout(shaderLayout, interleaved.name, usedAttributes);
for (const attributeMapping of mapping.attributes) {
const attributeName = attributeMapping.attribute;
const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);
stepMode = attributeLayout.stepMode || 'vertex';
vertexAttributes.push({
format: getWebGPUVertexFormat(interleaved.format || mapping.format),
offset: byteOffset + byteStride,
format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),
offset: attributeMapping.byteOffset,
shaderLocation: attributeLayout.location

@@ -35,3 +36,3 @@ });

format: getWebGPUVertexFormat(mapping.format),
offset: byteOffset,
offset: 0,
shaderLocation: attributeLayout.location

@@ -68,3 +69,3 @@ });

for (const interleaved of mapping.attributes) {
usedAttributes.add(interleaved.name);
usedAttributes.add(interleaved.attribute);
}

@@ -86,6 +87,6 @@ } else {

if (!attribute) {
throw new Error("Unknown attribute ".concat(name));
throw new Error(`Unknown attribute ${name}`);
}
if (attributeNames.has(name)) {
throw new Error("Duplicate attribute ".concat(name));
throw new Error(`Duplicate attribute ${name}`);
}

@@ -92,0 +93,0 @@ attributeNames.add(name);

@@ -120,3 +120,3 @@ function addDepthStencil(descriptor) {

if (!setterFunction) {
throw new Error("Illegal parameter ".concat(key));
throw new Error(`Illegal parameter ${key}`);
}

@@ -123,0 +123,0 @@ setterFunction(key, value, pipelineDescriptor);

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { Buffer } from '@luma.gl/core';

@@ -10,5 +9,5 @@ function getByteLength(props) {

super(device, props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "handle", void 0);
_defineProperty(this, "byteLength", void 0);
this.device = void 0;
this.handle = void 0;
this.byteLength = void 0;
this.device = device;

@@ -15,0 +14,0 @@ this.byteLength = getByteLength(props);

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { CommandEncoder, cast } from '@luma.gl/core';

@@ -6,4 +5,4 @@ export class WebGPUCommandEncoder extends CommandEncoder {

super(device, props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "handle", void 0);
this.device = void 0;
this.handle = void 0;
this.device = device;

@@ -10,0 +9,0 @@ this.handle = props.handle || this.device.handle.createCommandEncoder({});

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { ComputePass, cast } from '@luma.gl/core';

@@ -7,5 +6,5 @@ export class WebGPUComputePass extends ComputePass {

super(device, props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "handle", void 0);
_defineProperty(this, "_bindGroupLayout", null);
this.device = void 0;
this.handle = void 0;
this._bindGroupLayout = null;
this.device = device;

@@ -12,0 +11,0 @@ this.handle = this.props.handle || ((_device$commandEncode = device.commandEncoder) === null || _device$commandEncode === void 0 ? void 0 : _device$commandEncode.beginComputePass({

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { ComputePipeline, cast } from '@luma.gl/core';

@@ -6,4 +5,4 @@ export class WebGPUComputePipeline extends ComputePipeline {

super(device, props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "handle", void 0);
this.device = void 0;
this.handle = void 0;
this.device = device;

@@ -10,0 +9,0 @@ const module = cast(this.props.cs).handle;

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { ExternalTexture } from '@luma.gl/core';

@@ -7,5 +6,5 @@ import { WebGPUSampler } from "./webgpu-sampler.js";

super(device, props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "handle", void 0);
_defineProperty(this, "sampler", void 0);
this.device = void 0;
this.handle = void 0;
this.sampler = void 0;
this.device = device;

@@ -12,0 +11,0 @@ this.handle = this.props.handle || this.device.handle.importExternalTexture({

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { Framebuffer } from '@luma.gl/core';

@@ -6,3 +5,3 @@ export class WebGPUFramebuffer extends Framebuffer {

super(device, props);
_defineProperty(this, "device", void 0);
this.device = void 0;
this.device = device;

@@ -9,0 +8,0 @@ this.autoCreateAttachmentTextures();

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { RenderPass, cast } from '@luma.gl/core';

@@ -7,5 +6,5 @@ export class WebGPURenderPass extends RenderPass {

super(device, props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "handle", void 0);
_defineProperty(this, "pipeline", null);
this.device = void 0;
this.handle = void 0;
this.pipeline = null;
this.device = device;

@@ -12,0 +11,0 @@ const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { RenderPipeline, cast, log, isObjectEmpty } from '@luma.gl/core';

@@ -10,11 +9,11 @@ import { applyParametersToRenderPipelineDescriptor } from "../helpers/webgpu-parameters.js";

super(device, props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "handle", void 0);
_defineProperty(this, "vs", void 0);
_defineProperty(this, "fs", null);
_defineProperty(this, "_bufferSlots", void 0);
_defineProperty(this, "_buffers", void 0);
_defineProperty(this, "_indexBuffer", null);
_defineProperty(this, "_bindGroupLayout", void 0);
_defineProperty(this, "_bindGroup", null);
this.device = void 0;
this.handle = void 0;
this.vs = void 0;
this.fs = null;
this._bufferSlots = void 0;
this._buffers = void 0;
this._indexBuffer = null;
this._bindGroupLayout = void 0;
this._bindGroup = null;
this.device = device;

@@ -32,3 +31,3 @@ this.handle = this.props.handle || this.createHandle();

const renderPipeline = this.device.handle.createRenderPipeline(descriptor);
log.groupCollapsed(1, "new WebGPRenderPipeline(".concat(this.id, ")"))();
log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();
log.log(1, JSON.stringify(descriptor, null, 2))();

@@ -48,3 +47,3 @@ log.groupEnd(1)();

} else {
throw new Error("Setting attribute '".concat(name, "' not listed in shader layout for program ").concat(this.id));
throw new Error(`Setting attribute '${name}' not listed in shader layout for program ${this.id}`);
}

@@ -93,3 +92,3 @@ }

case 'line-loop-webgl':
throw new Error("WebGPU does not support primitive topology ".concat(this.props.topology));
throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);
default:

@@ -131,3 +130,3 @@ }

const attribute = this.props.shaderLayout.attributes.find(attribute => attribute.location === i);
throw new Error("No buffer provided for attribute '".concat((attribute === null || attribute === void 0 ? void 0 : attribute.name) || '', "' in Model '").concat(this.props.id, "'"));
throw new Error(`No buffer provided for attribute '${(attribute === null || attribute === void 0 ? void 0 : attribute.name) || ''}' in Model '${this.props.id}'`);
}

@@ -134,0 +133,0 @@ webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { Sampler } from '@luma.gl/core';

@@ -6,4 +5,4 @@ export class WebGPUSampler extends Sampler {

super(device, props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "handle", void 0);
this.device = void 0;
this.handle = void 0;
this.device = device;

@@ -10,0 +9,0 @@ const samplerProps = {

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { Shader, log } from '@luma.gl/core';

@@ -6,4 +5,4 @@ export class WebGPUShader extends Shader {

super(device, props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "handle", void 0);
this.device = void 0;
this.handle = void 0;
this.device = device;

@@ -19,4 +18,4 @@ this.device.handle.pushErrorScope('validation');

const shaderLog = await this.compilationInfo();
log.error("Shader compilation error: ".concat(error.message), shaderLog)();
throw new Error("Shader compilation error: ".concat(error.message));
log.error(`Shader compilation error: ${error.message}`, shaderLog)();
throw new Error(`Shader compilation error: ${error.message}`);
}

@@ -23,0 +22,0 @@ }

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { Texture } from '@luma.gl/core';

@@ -16,8 +15,8 @@ import { getWebGPUTextureFormat } from "../helpers/convert-texture-format.js";

super(device, props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "handle", void 0);
_defineProperty(this, "view", void 0);
_defineProperty(this, "sampler", void 0);
_defineProperty(this, "height", void 0);
_defineProperty(this, "width", void 0);
this.device = void 0;
this.handle = void 0;
this.view = void 0;
this.sampler = void 0;
this.height = void 0;
this.width = void 0;
if (typeof this.props.format === 'number') {

@@ -24,0 +23,0 @@ throw new Error('number format');

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { CanvasContext, log } from '@luma.gl/core';

@@ -8,12 +7,12 @@ import { getWebGPUTextureFormat } from "./helpers/convert-texture-format.js";

super(props);
_defineProperty(this, "device", void 0);
_defineProperty(this, "gpuCanvasContext", void 0);
_defineProperty(this, "format", void 0);
_defineProperty(this, "depthStencilFormat", 'depth24plus');
_defineProperty(this, "sampleCount", 1);
_defineProperty(this, "depthStencilAttachment", null);
this.device = void 0;
this.gpuCanvasContext = void 0;
this.format = void 0;
this.depthStencilFormat = 'depth24plus';
this.sampleCount = 1;
this.depthStencilAttachment = null;
this.device = device;
this.width = -1;
this.height = -1;
this._setAutoCreatedCanvasId("".concat(this.device.id, "-canvas"));
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
this.gpuCanvasContext = this.canvas.getContext('webgpu');

@@ -56,3 +55,3 @@ this.format = this.gpuCanvasContext.getPreferredFormat(adapter);

});
log.log(1, "Resized to ".concat(this.width, "x").concat(this.height, "px"))();
log.log(1, `Resized to ${this.width}x${this.height}px`)();
}

@@ -59,0 +58,0 @@ }

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

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { Device, CanvasContext, log, uid } from '@luma.gl/core';

@@ -49,11 +48,11 @@ import { WebGPUBuffer } from "./resources/webgpu-buffer.js";

});
_defineProperty(this, "handle", void 0);
_defineProperty(this, "adapter", void 0);
_defineProperty(this, "lost", void 0);
_defineProperty(this, "canvasContext", null);
_defineProperty(this, "commandEncoder", null);
_defineProperty(this, "renderPass", null);
_defineProperty(this, "_info", void 0);
_defineProperty(this, "_isLost", false);
_defineProperty(this, "features", void 0);
this.handle = void 0;
this.adapter = void 0;
this.lost = void 0;
this.canvasContext = null;
this.commandEncoder = null;
this.renderPass = null;
this._info = void 0;
this._isLost = false;
this.features = void 0;
this.handle = device;

@@ -226,3 +225,3 @@ this.adapter = adapter;

}
_defineProperty(WebGPUDevice, "type", 'webgpu');
WebGPUDevice.type = 'webgpu';
//# sourceMappingURL=webgpu-device.js.map
{
"name": "@luma.gl/webgpu",
"version": "9.0.0-alpha.33",
"version": "9.0.0-alpha.34",
"description": "WebGPU adapter for the luma.gl API",

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

"@babel/runtime": "^7.0.0",
"@luma.gl/core": "9.0.0-alpha.33",
"@luma.gl/core": "9.0.0-alpha.34",
"@probe.gl/env": "^4.0.2",
"@webgpu/types": "^0.1.34"
},
"gitHead": "65a38ac7ed371767303b5ded6cc3d34373e904e3"
"gitHead": "66ab5fe7caa59ef83224a0b7c892e00bd43cbefd"
}
import type {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';
import {decodeVertexFormat} from '@luma.gl/core';
import {getAttributeInfosFromLayouts, decodeVertexFormat} from '@luma.gl/core';

@@ -23,2 +23,5 @@ /** Throw error on any WebGL-only vertex formats */

): GPUVertexBufferLayout[] {
// @ts-expect-error Deduplicate and make use of the new core attribute logic here in webgpu module
const attributeInfos = getAttributeInfosFromLayouts(shaderLayout, bufferLayout);
const vertexBufferLayouts: GPUVertexBufferLayout[] = [];

@@ -35,14 +38,13 @@ const usedAttributes = new Set<string>();

let byteStride = 0;
const byteOffset = mapping.byteOffset || 0;
// interleaved mapping {..., attributes: [{...}, ...]}
if (mapping.attributes) {
// const arrayStride = mapping.byteStride; TODO
for (const interleaved of mapping.attributes) {
const attributeLayout = findAttributeLayout(shaderLayout, interleaved.name, usedAttributes);
for (const attributeMapping of mapping.attributes) {
const attributeName = attributeMapping.attribute;
const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);
stepMode = attributeLayout.stepMode || 'vertex';
vertexAttributes.push({
format: getWebGPUVertexFormat(interleaved.format || mapping.format),
offset: byteOffset + byteStride,
format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),
offset: attributeMapping.byteOffset,
shaderLocation: attributeLayout.location

@@ -61,3 +63,4 @@ });

format: getWebGPUVertexFormat(mapping.format),
offset: byteOffset,
// We only support 0 offset for non-interleaved buffer layouts
offset: 0,
shaderLocation: attributeLayout.location

@@ -108,3 +111,3 @@ });

for (const interleaved of mapping.attributes) {
usedAttributes.add(interleaved.name);
usedAttributes.add(interleaved.attribute);
}

@@ -111,0 +114,0 @@ // non-interleaved mapping (just set offset and stride)

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 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 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